Skip to content

Commit

Permalink
Unifies flexpart-ifs, -opr and -fdb (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominichofer authored Nov 24, 2023
1 parent 93e868a commit 77ed8e0
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 181 deletions.
25 changes: 15 additions & 10 deletions repos/c2sm/packages/fdb-fortran/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@ class FdbFortran(CMakePackage):
depends_on('eckit')
depends_on('metkit')
depends_on('eccodes +fortran')

depends_on('[email protected]:')


def cmake_args(self):
args = [
self.define('Deckit_DIR', self.spec['eckit'].prefix),
self.define('Dmetkit_DIR', self.spec['metkit'].prefix),
self.define('Deccodes_DIR', self.spec['eccodes'].prefix),
self.define('Dfdb5_DIR', self.spec['fdb'].prefix),
]
return args
@property
def libs(self):
return find_libraries("libfdbf",
root=self.prefix,
shared=False,
recursive=True)

def cmake_args(self):
args = [
self.define('Deckit_DIR', self.spec['eckit'].prefix),
self.define('Dmetkit_DIR', self.spec['metkit'].prefix),
self.define('Deccodes_DIR', self.spec['eccodes'].prefix),
self.define('Dfdb5_DIR', self.spec['fdb'].prefix),
]
return args
7 changes: 7 additions & 0 deletions repos/c2sm/packages/fdb/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@ class Fdb(SpackFdb):

depends_on("[email protected]:", type="build", when="@5.11.6:")

@property
def libs(self):
return find_libraries("libfdb5",
root=self.prefix,
shared=True,
recursive=True)

def setup_build_environment(self, env):
env.set('CTEST_OUTPUT_ON_FAILURE', 1)
82 changes: 0 additions & 82 deletions repos/c2sm/packages/flexpart-fdb/package.py

This file was deleted.

64 changes: 30 additions & 34 deletions repos/c2sm/packages/flexpart-ifs/package.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,49 @@
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

#
from spack import *
from distutils.dir_util import copy_tree


class FlexpartIfs(MakefilePackage):
"""flexpart is a Lagrangian dispersion model"""

homepage = 'https://github.com/MeteoSwiss-APN/flexpart-ifs'
url = 'https://github.com/MeteoSwiss-APN/flexpart-ifs/archive/refs/tags/v9.2mch.tar.gz'
git = '[email protected]:MeteoSwiss-APN/flexpart-ifs.git'
homepage = 'https://github.com/MeteoSwiss/flexpart'
url = 'https://github.com/MeteoSwiss/flexpart/archive/refs/tags/v10.4.4.tar.gz'
git = '[email protected]:MeteoSwiss/flexpart.git'
maintainers = ['pirmink']

version('meteoswiss-10', branch='meteoswiss-10')
version('main', branch='main')
version('fdb', tag='10.4.4_fdb')
version('10.4.4', tag='10.4.4')

depends_on('eccodes jp2k=none +fortran')
depends_on('eccodes +fortran')
depends_on('netcdf-fortran')
depends_on('fdb-fortran', when='@fdb')

conflicts('%nvhpc')
conflicts('%pgi')

build_directory = 'src'

@property
def build_targets(self):
return ['ncf=yes', 'VERBOSE=1', 'serial']

def edit(self, spec, prefix):
copy('src/makefile.meteoswiss', 'src/makefile')

def setup_build_environment(self, env):
env.set('ECCODESROOT', self.spec['eccodes'].prefix)
env.set(
'ECCODES_LD_FLAGS', '-L' + self.spec['eccodes'].prefix +
'/lib64 -leccodes_f90 -leccodes')
env.set('EBROOTNETCDFMINFORTRAN', self.spec['netcdf-fortran'].prefix)
#abuse of JASPER_LD_FLAGS since there is no other entrypoint var for LDFLAGS
env.set('JASPER_LD_FLAGS', '-Wl,--no-relax')
# not really required, just a default since the -I flags would be inconsistent with an empty string
env.set('CURL_INCLUDES', '/usr')
env.set('ECCODES_DIR', self.spec['eccodes'].prefix)
env.set('ECCODES_LD_FLAGS', self.spec['eccodes:fortran'].libs.ld_flags)
env.set('NETCDF_FORTRAN_INCLUDE',
'-I' + self.spec['netcdf-fortran'].prefix.include)
env.set('NETCDF_FORTRAN_LD_FLAGS',
self.spec['netcdf-fortran'].libs.ld_flags)
if self.spec.satisfies('@fdb'):
env.set('FDB_DIR', self.spec['fdb'].prefix)
env.set('FDB_LD_FLAGS', self.spec['fdb'].libs.ld_flags)
env.set('FDB_FORTRAN_DIR', self.spec['fdb-fortran'].prefix)
env.set('FDB_FORTRAN_LD_FLAGS',
self.spec['fdb-fortran'].libs.ld_flags)

def build(self, spec, prefix):
with working_dir(self.build_directory):
make('-f', 'makefile_meteoswiss')

def install(self, spec, prefix):
mkdir(prefix.bin)
mkdir(prefix.share)
mkdir(prefix.share + '/test/')
mkdir(prefix.share + '/options/')
copy_tree('options/', prefix.share + '/options/')
install('src/FLEXPART', prefix.bin)
install('test/*', prefix.share + '/test/')
install(join_path(self.build_directory, 'FLEXPART'), prefix.bin)
install_tree('test_meteoswiss', prefix.share.test_meteoswiss)
install_tree('options', join_path(prefix.share, 'options'))
install_tree('options.meteoswiss',
join_path(prefix.share, 'options.meteoswiss'))
25 changes: 0 additions & 25 deletions repos/c2sm/packages/flexpart-opr/package.py

This file was deleted.

12 changes: 0 additions & 12 deletions test/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,9 @@ def test_fdb_fortran(self):
def test_flexpart_cosmo(self):
spack_info('flexpart-cosmo')

def test_flexpart_fdb(self):
spack_info('flexpart-fdb')

def test_flexpart_ifs(self):
spack_info('flexpart-ifs')

def test_flexpart_opr(self):
spack_info('flexpart-opr')

def test_gridtools(self):
spack_info('gridtools')

Expand Down Expand Up @@ -302,15 +296,9 @@ def test_fdb_fortran(self):
def test_flexpart_cosmo(self):
spack_spec('flexpart-cosmo')

def test_flexpart_fdb(self):
spack_spec('flexpart-fdb')

def test_flexpart_ifs(self):
spack_spec('flexpart-ifs')

def test_flexpart_opr(self):
spack_spec('flexpart-opr')

def test_gridtools(self):
spack_spec('gridtools')
spack_spec('gridtools ~cuda')
Expand Down
24 changes: 6 additions & 18 deletions test/system_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,28 +314,16 @@ def test_install_5_11_17_nvhpc(self):
class FdbFortranTest(unittest.TestCase):

def test_install(self):
spack_install_and_test('fdb-fortran @0.1.0')


class FlexpartOprTest(unittest.TestCase):

def test_install(self):
spack_install_and_test('flexpart-opr')


class FlexpartFdbTest(unittest.TestCase):

def test_wo_mch(self):
spack_install_and_test('flexpart-fdb ~mch')

def test_w_mch(self):
spack_install_and_test('flexpart-fdb +mch')
spack_install_and_test('fdb-fortran')


class FlexpartIfsTest(unittest.TestCase):

def test_install_latest(self):
spack_install_and_test('flexpart-ifs @meteoswiss-10')
def test_install_10_4_4(self):
spack_install_and_test('flexpart-ifs @10.4.4')

def test_install_fdb(self):
spack_install_and_test('flexpart-ifs @fdb')


@pytest.mark.no_tsa # No one uses spack for flexpart-cosmo on Tsa
Expand Down

0 comments on commit 77ed8e0

Please sign in to comment.