summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Sachs <stephenmsachs@gmail.com>2022-06-30 19:52:33 +0200
committerGitHub <noreply@github.com>2022-06-30 10:52:33 -0700
commit8e591f058e13c1b7120e26ff46ed141f3d8d4341 (patch)
tree13728f8e598fbb891f58e3fac5c3923ee7410647
parent4397ec6a486c704e363ec037e9c987070c77ae6c (diff)
downloadspack-8e591f058e13c1b7120e26ff46ed141f3d8d4341.tar.gz
spack-8e591f058e13c1b7120e26ff46ed141f3d8d4341.tar.bz2
spack-8e591f058e13c1b7120e26ff46ed141f3d8d4341.tar.xz
spack-8e591f058e13c1b7120e26ff46ed141f3d8d4341.zip
[mpas-model] Add optional `make_target` and `precision` variants (#31388)
`make_target` can be used to instruct Spack to build one of the pre-defined make targets in the MPAS makefile. Spack will guess the targret based on the value of `spack_fc`, but the user can overwrite the target as variant. E.g. ``` spack install mpas-model make_target=pgi-nersc ``` `precision` is used to set the `PRECISION` flag in the Makefile to {single, double}. Default is double. Co-authored-by: Stephen Sachs <stesachs@amazon.com>
-rw-r--r--var/spack/repos/builtin/packages/mpas-model/package.py37
1 files changed, 35 insertions, 2 deletions
diff --git a/var/spack/repos/builtin/packages/mpas-model/package.py b/var/spack/repos/builtin/packages/mpas-model/package.py
index 0b9f2de65c..92ac98c3ca 100644
--- a/var/spack/repos/builtin/packages/mpas-model/package.py
+++ b/var/spack/repos/builtin/packages/mpas-model/package.py
@@ -2,6 +2,7 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import os
from spack.package import *
@@ -23,6 +24,24 @@ class MpasModel(MakefilePackage):
version('6.3', sha256='e7f1d9ebfeb6ada37d42a286aaedb2e69335cbc857049dc5c5544bb51e7a8db8')
version('6.2', sha256='2a81825a62a468bf5c56ef9d9677aa2eb88acf78d4f996cb49a7db98b94a6b16')
+ # These targets are defined in the Makefile. Some can be auto-detected by the
+ # compiler name, others need to be explicitly set.
+ make_target = [
+ 'xlf', 'ftn', 'titan-cray', 'pgi', 'pgi-nersc', 'pgi-llnl', 'ifort',
+ 'ifort-scorep', 'ifort-gcc', 'gfortran', 'gfortran-clang', 'g95',
+ 'pathscale-nersc', 'cray-nersc', 'gnu-nersc', 'intel-nersc', 'bluegene', 'llvm'
+ ]
+ variant(
+ 'make_target', default='none',
+ description='Predefined targets in the MPAS Makefile.',
+ values=make_target.extend('none'), multi=False
+ )
+ variant(
+ 'precision', default='double',
+ description='MPAS will be built with double/single precision reals.',
+ values=('double', 'single'), multi=False
+ )
+
depends_on('mpi')
depends_on('parallelio')
@@ -84,20 +103,34 @@ class MpasModel(MakefilePackage):
targets.append(
'PNETCDF={0}'.format(spec['parallel-netcdf'].prefix)
)
+ if self.spec.variants['precision']:
+ targets.extend([
+ 'PRECISION={0}'.format(self.spec.variants['precision'].value)
+ ])
+
+ if action == 'all':
+ # First try to guess by compiler name
+ if os.path.basename(spack_fc) in self.make_target:
+ action = os.path.basename(spack_fc)
+ # Then overwrite with the optional variant if set
+ if self.spec.variants['make_target'].value != 'none':
+ action = self.spec.variants['make_target'].value
+
targets.extend([
'USE_PIO2=true', 'CPP_FLAGS=-D_MPI', 'OPENMP=true',
'CORE={0}'.format(model), action
])
+
return targets
def build(self, spec, prefix):
copy_tree(join_path('MPAS-Data', 'atmosphere'),
join_path('src', 'core_atmosphere', 'physics'))
- make(*self.target('init_atmosphere', 'all'))
+ make(*self.target('init_atmosphere', 'all'), parallel=True)
mkdir('bin')
copy('init_atmosphere_model', 'bin')
make(*self.target('init_atmosphere', 'clean'))
- make(*self.target('atmosphere', 'all'))
+ make(*self.target('atmosphere', 'all'), parallel=True)
copy('atmosphere_model', 'bin')
def install(self, spec, prefix):