Compare commits

...

5 Commits

Author SHA1 Message Date
Peter Scheibel
c899dcac5b style fix 2024-05-23 22:25:25 -07:00
Peter Scheibel
94dc25ecfa add test 2024-05-23 17:14:00 -07:00
Peter Scheibel
aded859856 Merge branch 'develop' into bugfix/invalid-compiler-warning 2024-05-23 16:30:54 -07:00
Alex Richert
f7b9c30456 Add develop version to ufs-weather-model (major updates) (#39265)
* Add develop version to ufs-weather-model (major updates)

* Update ufs-weather-model maintainers

* Update package.py

* Update package.py

* Update package.py

* Update package.py

* Update ufs-weather-model defaults and fms dep

* Update package.py

* Update package.py

* Update package.py
2024-05-22 11:33:17 -06:00
Gregory Becker
2e3fc288ae warn and continue on failure to parse compiler from external 2024-04-18 08:46:05 -07:00
3 changed files with 178 additions and 28 deletions

View File

@@ -156,7 +156,15 @@ def get_compiler_config_from_packages(
def _compiler_config_from_package_config(config):
compilers = []
for entry in config:
compiler = _compiler_config_from_external(entry)
try:
compiler = _compiler_config_from_external(entry)
except Exception as e:
msg = "Reading compiler from packages config section failed\n"
msg += f" Compiler: {entry.get('spec', None)}\n"
msg += f" Prefix: {entry.get('prefix', None)}\n"
msg += f" Failure: {e}"
warnings.warn(msg)
compiler = None
if compiler:
compilers.append(compiler)

View File

@@ -1492,3 +1492,26 @@ def test_config_path_dsl(path, it_should_work, expected_parsed):
else:
with pytest.raises(ValueError):
spack.config.ConfigPath._validate(path)
def test_compiler_parsing_errors(tmpdir):
content = """\
packages:
gcc:
externals:
- spec: gcc@8.5.0 languages='c,c++,fortran'
prefix: /usr
extra_attributes:
compilers:
c: /usr/bin/gcc
cxx: /usr/bin/g++
fortran: /usr/bin/gfortran
"""
testscope = join_path(tmpdir.strpath, "packages.yaml")
with open(testscope, "w") as f:
f.write(content)
with spack.config.use_configuration(tmpdir.strpath):
compilers = spack.compilers.get_compiler_config_from_packages(spack.config.CONFIG)
assert spack.spec.Spec(compilers[0]["compiler"]["spec"]).satisfies("gcc@8.5.0")

View File

@@ -17,8 +17,9 @@ class UfsWeatherModel(CMakePackage):
url = "https://github.com/ufs-community/ufs-weather-model/archive/refs/tags/ufs-v1.1.0.tar.gz"
git = "https://github.com/ufs-community/ufs-weather-model.git"
maintainers("t-brown")
maintainers("AlexanderRichert-NOAA")
version("develop", branch="develop", submodules=True)
version(
"2.0.0",
tag="ufs-v2.0.0",
@@ -32,12 +33,45 @@ class UfsWeatherModel(CMakePackage):
submodules=True,
)
variant("mpi", default=True, description="Enable MPI")
variant(
"32bit", default=True, description="Enable 32-bit single precision arithmetic in dycore"
)
variant("avx2", default=False, description="Enable AVX2 instructions")
variant(
"ccpp", default=True, description="Enable the Common Community Physics Package (CCPP))"
"ccpp_32bit",
default=False,
description="Enable CCPP_32BIT (single precision arithmetic in slow physics)",
)
variant("debug", default=False, description="Enable DEBUG mode", when="@develop")
variant(
"debug_linkmpi",
default=True,
description="Enable linkmpi option when DEBUG mode is on",
when="@develop",
)
variant("inline_post", default=False, description="Enable inline post")
variant("multi_gases", default=False, description="Enable multi gases in physics routines")
variant("moving_nest", default=False, description="Enable moving nest code", when="@develop")
variant("openmp", default=True, description="Enable OpenMP")
variant("pdlib", default=False, description="Enable PDLIB (WW3)", when="@develop")
variant("parallel_netcdf", default=True, description="Enable parallel NetCDF")
variant(
"jedi_driver",
default=False,
description="Enable JEDI as top level driver",
when="@develop",
)
variant(
"cmeps_aoflux",
default=False,
description="Enable atmosphere-ocean flux calculation in mediator",
when="@develop",
)
variant(
"ccpp",
default=True,
description="Enable the Common Community Physics Package (CCPP)",
when="@:2.0.0",
)
variant(
"ccpp_suites",
@@ -45,37 +79,96 @@ class UfsWeatherModel(CMakePackage):
description="CCPP suites to compile",
values=("FV3_GFS_v15p2", "FV3_RRFS_v1alpha", "FV3_GFS_v15p2,FV3_RRFS_v1alpha"),
multi=True,
when="@:2.0.0",
)
dev_ccpp_default = [
"FV3_GFS_v16",
"FV3_GFS_v16_flake",
"FV3_GFS_v17_p8",
"FV3_GFS_v17_p8_rrtmgp",
"FV3_GFS_v15_thompson_mynn_lam3km",
"FV3_WoFS_v0",
"FV3_GFS_v17_p8_mynn",
"FV3_GFS_v17_p8_ugwpv1",
]
variant(
"ccpp_suites",
default=",".join(dev_ccpp_default),
description="CCPP suites to compile",
multi=True,
when="@develop",
)
variant("inline_post", default=False, description="Compile post processing inline")
variant("multi_gases", default=False, description="Enable multi gases in physics routines")
variant("openmp", default=True, description="Enable OpenMP")
variant("parallel_netcdf", default=True, description="Enable parallel I/O in netCDF")
variant(
"quad_precision",
default=False,
description="Enable quad precision for certain grid metric terms in dycore",
when="@:2.0.0",
)
variant(
"simdmultiarch", default=False, description="Enable multi-target SIMD instruction sets"
)
variant("mom6solo", default=False, description="Build MOM6 solo executable", when="@develop")
variant("app", default="ATM", description="UFS application", when="@develop")
depends_on("bacio")
depends_on("esmf@:8.0.0")
depends_on("mpi")
depends_on("nemsio")
depends_on("mpi", when="+mpi")
depends_on("netcdf-c")
depends_on("netcdf-fortran")
depends_on("sp")
depends_on("w3emc")
depends_on("w3nco")
depends_on("python", type="build")
depends_on("esmf@:8.0.0", when="@:2.0.0")
depends_on("nemsio", when="@:2.0.0")
depends_on("w3nco", when="@:2.0.0")
depends_on("bacio@2.4.0:", when="@develop")
depends_on("crtm", when="@develop")
depends_on("esmf@8.3.0:", when="@develop")
depends_on("fms@2022.04: +deprecated_io precision=32,64 constants=GFS", when="@develop")
depends_on("g2", when="@develop")
depends_on("g2tmpl", when="@develop")
depends_on("hdf5+hl+mpi", when="@develop")
depends_on("ip@:4", when="@develop")
depends_on("netcdf-c~parallel-netcdf+mpi", when="@develop")
for app in [
"ATMW",
"ATML",
"NG-GODAS",
"S2S",
"S2SA",
"S2SW",
"S2SWA",
"S2SWAL",
"HAFS",
"HAFSW",
"HAFS-ALL",
"LND",
]:
depends_on("parallelio@2.5.3: +fortran~pnetcdf~shared", when="@develop app=%s" % app)
depends_on("python@3.6:", type="build", when="@develop")
depends_on("sp@2.3.3:", when="@develop")
depends_on("w3emc@2.9.2:", when="@develop")
with when("@develop app=S2SA"):
depends_on("mapl")
depends_on("gftl-shared")
with when("@develop app=S2SWA"):
depends_on("mapl")
depends_on("gftl-shared")
with when("@develop app=ATMAERO"):
depends_on("mapl")
depends_on("gftl-shared")
depends_on("scotch", when="+pdlib")
depends_on("w3nco", when="@:2.0.0")
depends_on("python", type="build", when="@:2.0.0")
conflicts("%gcc@:8", when="@develop")
def setup_build_environment(self, env):
spec = self.spec
env.set("CC", spec["mpi"].mpicc)
env.set("CXX", spec["mpi"].mpicxx)
env.set("FC", spec["mpi"].mpifc)
env.set("CMAKE_C_COMPILER", spec["mpi"].mpicc)
env.set("CMAKE_CXX_COMPILER", spec["mpi"].mpicxx)
env.set("CMAKE_Fortran_COMPILER", spec["mpi"].mpifc)
env.set("ESMFMKFILE", join_path(spec["esmf"].prefix.lib, "esmf.mk"))
env.set("CCPP_SUITES", ",".join([x for x in spec.variants["ccpp_suites"].value if x]))
@@ -91,25 +184,51 @@ def setup_build_environment(self, env):
raise InstallError(msg.format(spec.platform, self.compiler.name))
def cmake_args(self):
from_variant = self.define_from_variant
args = [
from_variant("32BIT", "32bit"),
from_variant("AVX2", "avx2"),
from_variant("CCPP", "ccpp"),
from_variant("INLINE_POST", "inline_post"),
from_variant("MULTI_GASES", "multi_gases"),
from_variant("OPENMP", "openmp"),
from_variant("PARALLEL_NETCDF", "parallel_netcdf"),
from_variant("QUAD_PRECISION", "quad_precision"),
from_variant("SIMDMULTIARCH", "simdmultiarch"),
self.define("AVX2", False), # use target settings from Spack
self.define("SIMDMULTIARCH", False), # use target settings from Spack
self.define_from_variant("CCPP_SUITES", "ccpp_suites").replace(";", ","),
]
variants = [
"32bit",
"app",
"ccpp_32bit",
"ccpp_suites",
"cmeps_aoflux",
"debug",
"debug_linkmpi",
"inline_post",
"jedi_driver",
"moving_nest",
"mpi",
"multi_gases",
"openmp",
"parallel_netcdf",
"pdlib",
]
for variant in variants:
args.append(self.define_from_variant(variant.upper(), variant))
if self.spec.satisfies("@:2.0.0"):
args.append(self.define_from_variant("CCPP", "ccpp"))
args.append(self.define_from_variant("QUAD_PRECISION", "quad_precision"))
return args
# This patch can be removed once https://github.com/NOAA-EMC/WW3/issues/1021
# is resolved.
@when("+pdlib ^scotch+shared")
def patch(self):
filter_file(r"(lib[^ ]+)\.a", r"\1.so", "WW3/cmake/FindSCOTCH.cmake")
filter_file("STATIC", "SHARED", "WW3/cmake/FindSCOTCH.cmake")
@run_after("install")
def install_additional_files(self):
mkdirp(prefix.bin)
ufs_src = join_path(self.build_directory, "NEMS.exe")
if self.spec.satisfies("@develop"):
ufs_src = join_path(self.build_directory, "ufs_model")
else:
ufs_src = join_path(self.build_directory, "NEMS.exe")
ufs_dst = join_path(prefix.bin, "ufs_weather_model")
install(ufs_src, ufs_dst)
set_executable(ufs_dst)