Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flexpart-cosmo build modes eg. +omp #1000

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion repos/c2sm/packages/flexpart-cosmo/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@

#
from spack import *
import spack.error as error

from llnl.util.filesystem import working_dir, install_tree


def validate_mode(mode):
if 'none' in mode and any(
[x in mode for x in ('omp', 'opt', 'ncdfout', 'debug')]):
raise error.SpecError(
'Cannot have mode none in addition to other modes (omp, opt, ncdfout, debug) in the same build'
)


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

Expand All @@ -27,6 +37,27 @@ class FlexpartCosmo(MakefilePackage):
conflicts('%pgi')
conflicts('%cce')

# Make mode/Compile time options of Flexpart as defined in:
# https://github.com/C2SM-RCM/flexpart/blob/main/documentation/installation.md#compile-time-options
variant(
'none',
default=False,
description=
'Enable default flags only (do not combine with other variants); serial model.'
)
variant('omp',
default=False,
description='Specify OpenMP parallelism explicitly in mode.')
variant('opt',
default=False,
description='Specify code optimization explicitly in mode.')
variant('ncdfout',
default=False,
description='Specify netcdf output explicitly in mode.')
variant('debug',
default=False,
description='Specify netcdf output explicitly in mode.')

build_directory = 'src'

makefile_file = "Makefile.spack"
Expand All @@ -41,9 +72,19 @@ def setup_build_environment(self, env):

def build(self, spec, prefix):

mode = ''

for x in ['none', 'omp', 'opt', 'ncdfout', 'debug']:
if f'+{x}' in self.spec:
mode += x

with working_dir(self.build_directory):
make.jobs = 1
make('-f', self.makefile_file)
if mode:
validate_mode(mode)
make('-f', self.makefile_file, f"mode={mode}")
else:
make('-f', self.makefile_file)

def install(self, spec, prefix):
mkdir(prefix.bin)
Expand Down
5 changes: 5 additions & 0 deletions test/system_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def test_install_flexpart_cosmo():
spack_install('flexpart-cosmo @V8C4.0')


@pytest.mark.flexpart_cosmo
def test_install_flexpart_cosmo_omp():
spack_install('flexpart-cosmo @V8C4.0 +omp')


@pytest.mark.fdb
def test_install_fdb_5_11_17_gcc():
spack_install('fdb @5.11.17 %gcc')
Expand Down
Loading