From 411e65bb66f4e01bf6b416ceb9e187c0f130e952 Mon Sep 17 00:00:00 2001 From: Harshula Jayasuriya Date: Fri, 20 Sep 2024 12:41:56 +1000 Subject: [PATCH 01/17] access-test: new SPD to test ACCESS-NRI infrastructure (#149) --- packages/access-test/package.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 packages/access-test/package.py diff --git a/packages/access-test/package.py b/packages/access-test/package.py new file mode 100644 index 0000000..d6cbc95 --- /dev/null +++ b/packages/access-test/package.py @@ -0,0 +1,26 @@ +# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# Copyright 2024 ACCESS-NRI +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack.package import * + +class AccessTest(BundlePackage): + """ACCESS-TEST bundle is for testing ACCESS-NRI infrastructure.""" + + homepage = "https://www.access-nri.org.au" + + git = "https://github.com/ACCESS-NRI/ACCESS-TEST.git" + + maintainers("harshula") + + version("latest") + + variant("deterministic", default=False, description="Deterministic build.") + + depends_on("oasis3-mct+deterministic", when="+deterministic", type="run") + depends_on("oasis3-mct~deterministic", when="~deterministic", type="run") + + # There is no need for install() since there is no code. From 3e1b31f20f0fd0a6490056a77bc2dfd04bf67683 Mon Sep 17 00:00:00 2001 From: Paul Leopardi Date: Fri, 20 Sep 2024 13:15:52 +1000 Subject: [PATCH 02/17] Configure UM via models (#139) * Configure UM via models * Rename the atmos model to default * Adjust variant types and defaults * Fix Python formatting * Bool variants always override the model * Remove unused import. Fix warning messages. * Add a space to warning messages. * Ensure that keys are case sensitive. Improve matching between model and spec. * Rename the models to something more version specific * Move platform_config_dir default from model to package. Improve messages. * Remove a trailing space. * Add model vn13p5-rns for UM vn13.5 version of Regional Nesting Suite. * Add v13p5-rns model. Tidy up versions. Improve depends_on. Improve comments. * Address pull request conversation items * Fix indentation * Simplify _rev_variants substitution. * Fix a spelling error --- packages/um/model/vn13/rose-app.conf | 50 ++++ .../um/{ => model/vn13p0-rns}/rose-app.conf | 0 packages/um/model/vn13p5-rns/rose-app.conf | 49 ++++ packages/um/package.py | 217 +++++++++++++++--- 4 files changed, 285 insertions(+), 31 deletions(-) create mode 100644 packages/um/model/vn13/rose-app.conf rename packages/um/{ => model/vn13p0-rns}/rose-app.conf (100%) create mode 100644 packages/um/model/vn13p5-rns/rose-app.conf diff --git a/packages/um/model/vn13/rose-app.conf b/packages/um/model/vn13/rose-app.conf new file mode 100644 index 0000000..6404d1a --- /dev/null +++ b/packages/um/model/vn13/rose-app.conf @@ -0,0 +1,50 @@ +# Based on um.xm_tr@vn13.0/rose-stem/app/fcm_make_um/rose-app.conf +#meta=um-fcm-make/vn13.0 + +[env] +COUPLER=none +DR_HOOK=false +casim_rev= +casim_sources= +compile_atmos=preprocess-atmos build-atmos +!!compile_createbc=preprocess-createbc build-createbc +!!compile_crmstyle_coarse_grid=preprocess-crmstyle_coarse_grid build-crmstyle_coarse_grid +!!compile_pptoanc=preprocess-pptoanc build-pptoanc +compile_recon=preprocess-recon build-recon +!!compile_scm=preprocess-scm build-scm +!!compile_sstpert_lib=preprocess-sstpert_lib build-sstpert_lib +!!compile_wafccb_lib=preprocess-wafccb_lib build-wafccb_lib +config_revision= +config_root_path=fcm:um.xm_tr +config_type=atmos +eccodes=true +extract=extract +fcflags_overrides= +gwd_ussp_precision=double +jules_rev= +jules_sources= +land_surface_model=jules +ldflags_overrides_prefix= +ldflags_overrides_suffix= +ls_precipitation_precision=double +mirror=mirror +mpp_version=1C +netcdf=true +openmp=true +optimisation_level=safe +platagnostic=false +platform_config_dir=nci-x86-ifort +portio_version=2A +prebuild= +!!recon_mpi=parallel +shumlib_rev= +shumlib_sources= +socrates_rev= +socrates_sources= +stash_version=1A +thread_utils=false +timer_version=3A +ukca_rev= +ukca_sources= +um_rev= +um_sources= diff --git a/packages/um/rose-app.conf b/packages/um/model/vn13p0-rns/rose-app.conf similarity index 100% rename from packages/um/rose-app.conf rename to packages/um/model/vn13p0-rns/rose-app.conf diff --git a/packages/um/model/vn13p5-rns/rose-app.conf b/packages/um/model/vn13p5-rns/rose-app.conf new file mode 100644 index 0000000..1ec5b2e --- /dev/null +++ b/packages/um/model/vn13p5-rns/rose-app.conf @@ -0,0 +1,49 @@ +#meta=um-fcm-make/vn13.5 + +[env] +COUPLER=none +DR_HOOK=false +casim_rev=um13.5 +casim_sources=fcm:casim.xm/branches/dev/paulfield/vn1.3_drop_agg_limit_and_switch@11187 +compile_atmos=preprocess-atmos build-atmos +!!compile_createbc=preprocess-createbc build-createbc +!!compile_crmstyle_coarse_grid=preprocess-crmstyle_coarse_grid build-crmstyle_coarse_grid +!!compile_pptoanc=preprocess-pptoanc build-pptoanc +compile_recon=preprocess-recon build-recon +!!compile_scm=preprocess-scm build-scm +!!compile_sstpert_lib=preprocess-sstpert_lib build-sstpert_lib +!!compile_wafccb_lib=preprocess-wafccb_lib build-wafccb_lib +config_revision=@vn13.5 +config_root_path=fcm:um.xm_tr +config_type=atmos +eccodes=true +extract=extract +fcflags_overrides= +gwd_ussp_precision=double +jules_rev=um13.5 +jules_sources= +land_surface_model=jules +ldflags_overrides_prefix= +ldflags_overrides_suffix= +ls_precipitation_precision=double +mirror=mirror +mpp_version=1C +netcdf=true +openmp=true +optimisation_level=safe +platagnostic=false +platform_config_dir=nci-x86-ifort +portio_version=2A +prebuild= +!!recon_mpi=parallel +shumlib_rev=um13.5 +shumlib_sources= +socrates_rev=um13.5 +socrates_sources= +stash_version=1A +thread_utils=false +timer_version=3A +ukca_rev=um13.5 +ukca_sources= +um_rev=vn13.5 +um_sources=fcm:um.xm/branches/dev/paulfield/vn13.5_casim_package_switches@124474 diff --git a/packages/um/package.py b/packages/um/package.py index 47a7d18..3ff5af0 100644 --- a/packages/um/package.py +++ b/packages/um/package.py @@ -8,6 +8,7 @@ import configparser from spack.package import * +import llnl.util.tty as tty class Um(Package): """ @@ -17,24 +18,98 @@ class Um(Package): homepage = "https://code.metoffice.gov.uk/trac/um" svn = "file:///g/data/ki32/mosrs/um/main/trunk" - # See 'fcm kp fcm:um.xm' for release versions - version("13.0", revision=111272, preferred=True) - version("13.1", revision=114076) - version("13.2", revision=116723) - version("13.3", revision=118802) - version("13.4", revision=120750) - version("13.5", revision=123226) - version("13.6", revision=124981) + # See 'fcm kp fcm:um.xm' for release versions. + _revision = { + "13.0": 111272, + "13.1": 114076, + "13.2": 116723, + "13.3": 118802, + "13.4": 120750, + "13.5": 123226, + "13.6": 124981} + _max_minor = 6 + version("13.0", revision=_revision["13.0"], preferred=True) + for v in range(1, 1 + _max_minor): + _version = f"13.{v}" + version(_version, revision=_revision[_version]) maintainers("penguian") - variant("optim", default="safe", description="Optimization level", - values=("debug", "high", "rigorous", "safe"), multi=False) - variant("platform", default="nci-x86-ifort", description="Site platform", - values=("nci-x86-ifort", "vm-x86-gnu"), multi=False) + variant("model", default="vn13", description="Model configuration.", + values=("vn13", "vn13p0-rns", "vn13p5-rns"), multi=False) + # Bool variants have their default value set to True here. + _bool_variants = ( + "eccodes", + "netcdf") + for var in _bool_variants: + variant(var, default=True, description=var) + + # Off/on variants have 3-value "none" "off", "on" logic. + _off_on_variants = ( + "openmp", + "platagnostic", + "thread_utils") + for var in _off_on_variants: + variant(var, default="none", description=var, + values=("none", "off", "on"), multi=False) + + # String variants have their default values set to "none" here. + # The real default is set by the model. + + # Revision variants. + _rev_variants = ( + "casim_rev", + "jules_rev", + "shumlib_rev", + "socrates_rev", + "ukca_rev") + + # Other string variants. + _other_variants = ( + "casim_sources", + "compile_atmos", + "compile_createbc", + "compile_crmstyle_coarse_grid", + "compile_pptoanc", + "compile_recon", + "compile_scm", + "compile_sstpert_lib", + "compile_wafccb_lib", + "config_revision", + "config_root_path", + "config_type", + "COUPLER", + "extract", + "fcflags_overrides", + "gwd_ussp_precision", + "jules_sources", + "land_surface_model", + "ldflags_overrides_prefix", + "ldflags_overrides_suffix", + "ls_precipitation_precision", + "mirror", + "mpp_version", + "optimisation_level", + "platform_config_dir", + "portio_version", + "prebuild", + "recon_mpi", + "shumlib_sources", + "socrates_sources", + "stash_version", + "timer_version", + "ukca_sources", + "um_sources") + _str_variants = _rev_variants + _other_variants + + for var in _str_variants: + variant(var, default="none", description=var, values="*", multi=False) + + # The 'site=nci-gadi' variant of fcm defines the keywords + # used by the FCM configuration of UM. + depends_on("fcm site=nci-gadi", type="build") - depends_on("fcm", type="build") # For GCOM versions, see # https://code.metoffice.gov.uk/trac/gcom/wiki/Gcom_meto_installed_versions depends_on("gcom@7.8", when="@:13.0", type=("build", "link")) @@ -43,17 +118,16 @@ class Um(Package): depends_on("gcom@8.1", when="@13.3", type=("build", "link")) depends_on("gcom@8.2", when="@13.4", type=("build", "link")) depends_on("gcom@8.3:", when="@13.5:", type=("build", "link")) - depends_on("eccodes +fortran +netcdf", type=("build", "link", "run")) - depends_on("netcdf-fortran@4.5.2", type=("build", "link", "run")) + depends_on("eccodes +fortran +netcdf", type=("build", "link", "run"), + when="+eccodes") + depends_on("netcdf-fortran@4.5.2", type=("build", "link", "run"), + when="+netcdf") phases = ["build", "install"] # The dependency name and the ld_flags from # the FCM config for each library configured via FCM. _lib_cfg = { - "DR_HOOK": { - "dep_name": "drhook", - "fcm_ld_flags": "-ldrhook"}, "eccodes": { "dep_name": "eccodes", "fcm_ld_flags": "-leccodes_f90 -leccodes"}, @@ -62,6 +136,15 @@ class Um(Package): "fcm_ld_flags": "-lnetcdff -lnetcdf"}} + def _config_file_path(self, model): + """ + Return the pathname of the Rose app config file + corresponding to model. + """ + return join_path( + self.package_dir, "model", model, "rose-app.conf") + + def _get_linker_args(self, spec, fcm_libname): """ Return the linker flags corresponding to fcm_libname, @@ -83,36 +166,108 @@ def setup_build_environment(self, env): """ Set environment variables to their required values. """ + + def check_model_vs_spec(model, config_env, var, spec_value): + """ + Check whether the value spec_value for the variant var + agrees with the model's configured value config_env[var], + and produce an appropriate warning or debug message. + """ + if var not in config_env: + tty.warn( + f"The {model} model does not specify {var}. " + f"The value {spec_value} will be used.") + else: + model_value = config_env[var] + if model_value != "" and model_value != spec_value: + tty.warn( + f"The {model} model sets {var}={model_value} but " + f"the spec sets {var}={spec_value}. " + f"The value {spec_value} will be used.") + + spec = self.spec - env.prepend_path("PATH", spec["fcm"].prefix.bin) + + # Define CPATH for dependencies that need include files. ideps = ["eccodes", "gcom", "netcdf-fortran"] incs = [spec[d].prefix.include for d in ideps] for ipath in incs: env.prepend_path("CPATH", ipath) + # The gcom library does not contain shared objects and # therefore must be statically linked. env.prepend_path("LIBRARY_PATH", spec["gcom"].prefix.lib) # Use rose-app.conf to set config options. config = configparser.ConfigParser() - config.read(join_path(self.package_dir, "rose-app.conf")) + # Ensure that keys are case sensitive. + # https://docs.python.org/3/library/configparser.html#customizing-parser-behaviour + config.optionxform = lambda option: option + model = spec.variants["model"].value + config.read(self._config_file_path(model)) + # Modify the config as per points 8 and 9 of # https://metomi.github.io/rose/2019.01.8/html/api/configuration/rose-configuration-format.html + config_env = dict() for key in config["env"]: if len(key) > 0 and key[0] != '!': - value = config["env"][key].replace("\n=", "\n") - env.set(key, value) - - # Override some specific environment variables - env.set("optimisation_level", spec.variants["optim"].value) - env.set("platform_config_dir", spec.variants["platform"].value) - env.set("um_rev", f"vn{spec.version}") - components = ["casim", "jules", "shumlib", "socrates", "ukca"] - for comp in components: - env.set(f"{comp}_rev", f"um{spec.version}") + config_env[key] = config["env"][key].replace("\n=", "\n") + + # Override the model UM revision based on the spec UM version. + key = "um_rev" + spec_um_rev = f"vn{spec.version}" + check_model_vs_spec(model, config_env, key, spec_um_rev) + config_env[key] = spec_um_rev + + # Set DR_HOOK="false" until this package is available. + config_env["DR_HOOK"] = "false" + + # Override those environment variables where a bool variant is specified. + bool_to_str = lambda b: "true" if b else "false" + for var in self._bool_variants: + spec_str_value = bool_to_str(spec.variants[var].value) + check_model_vs_spec(model, config_env, var, spec_str_value) + config_env[var] = spec_str_value + + # Override those environment variables where an off/on variant is specified. + off_on_to_str = lambda off_on: "true" if off_on == "on" else "false" + for var in self._off_on_variants: + spec_value = spec.variants[var].value + if spec_value != "none": + spec_str_value = off_on_to_str(spec_value) + check_model_vs_spec(model, config_env, var, spec_str_value) + config_env[var] = spec_str_value + + # Override those environment variables where a revision variant is specified. + # If the variant is left unspecified, and the model does not specify a revision, + # then use a component revision based on the spec UM version. + for var in self._rev_variants: + spec_value = spec.variants[var].value + if spec_value != "none": + check_model_vs_spec(model, config_env, var, spec_value) + config_env[var] = spec_value + elif var not in config_env or config_env[var] == "": + config_env[var] = f"um{spec.version}" + + # Override those environment variables where any other string variant is specified. + for var in self._other_variants: + spec_value = spec.variants[var].value + if spec_value != "none": + check_model_vs_spec(model, config_env, var, spec_value) + config_env[var] = spec_value + + # Get the linker arguments for some dependencies. for fcm_libname in ["eccodes", "netcdf"]: linker_args = self._get_linker_args(spec, fcm_libname) - env.set(f"ldflags_{fcm_libname}_on", linker_args) + config_env[f"ldflags_{fcm_libname}_on"] = linker_args + + # Set environment variables based on config_env. + for key in config_env: + tty.info(f"{key}={config_env[key]}") + env.set(key, config_env[key]) + + # Add the location of the FCM executable to PATH. + env.prepend_path("PATH", spec["fcm"].prefix.bin) def _build_dir(self): From a2e76678a8d4355e8120b19a04fa735be927b74d Mon Sep 17 00:00:00 2001 From: Paul Leopardi Date: Thu, 26 Sep 2024 10:55:58 +1000 Subject: [PATCH 03/17] Add package for fiat based on builtin Spack package but adding um as a version (#150) --- packages/fiat/intel_warnings_v110.patch | 39 ++++++++++++++++ packages/fiat/intel_warnings_v120.patch | 42 +++++++++++++++++ packages/fiat/package.py | 62 +++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 packages/fiat/intel_warnings_v110.patch create mode 100644 packages/fiat/intel_warnings_v120.patch create mode 100644 packages/fiat/package.py diff --git a/packages/fiat/intel_warnings_v110.patch b/packages/fiat/intel_warnings_v110.patch new file mode 100644 index 0000000..fd2a08f --- /dev/null +++ b/packages/fiat/intel_warnings_v110.patch @@ -0,0 +1,39 @@ +--- a/cmake/fiat_compiler_warnings.cmake ++++ b/cmake/fiat_compiler_warnings.cmake +@@ -5,12 +5,14 @@ if(HAVE_WARNINGS) + ecbuild_add_c_flags("-Wextra" NO_FAIL) + ecbuild_add_c_flags("-Wno-unused-parameter" NO_FAIL) + ecbuild_add_c_flags("-Wno-unused-variable" NO_FAIL) +- ecbuild_add_c_flags("-Wno-gnu-zero-variadic-macro-arguments" NO_FAIL) ++ if (CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") ++ ecbuild_add_c_flags("-Wno-gnu-zero-variadic-macro-arguments" NO_FAIL) ++ endif() + endif() + + # Always disable some warnings + ecbuild_add_c_flags("-Wno-deprecated-declarations" NO_FAIL) +-if( CMAKE_C_COMPILER_ID MATCHES Intel ) +- ecbuild_add_c_flags("-diag-disable=279") # controlling expression is constant +- ecbuild_add_c_flags("-diag-disable=11076") # inline limits +-endif() ++#if( CMAKE_C_COMPILER_ID MATCHES Intel ) ++# ecbuild_add_c_flags("-diag-disable=279") # controlling expression is constant ++# ecbuild_add_c_flags("-diag-disable=11076") # inline limits ++#endif() +--- a/src/fiat/CMakeLists.txt ++++ b/src/fiat/CMakeLists.txt +@@ -26,10 +26,10 @@ endif() + + ### Compilation flags + +-if( CMAKE_Fortran_COMPILER_ID MATCHES "Intel" ) +- ## To disable checking of argument correctness of dummy mpi symbols +- ecbuild_add_fortran_flags( -nowarn nointerfaces ) +-endif() ++#if( CMAKE_Fortran_COMPILER_ID MATCHES "Intel" ) ++# ## To disable checking of argument correctness of dummy mpi symbols ++# ecbuild_add_fortran_flags( -nowarn nointerfaces ) ++#endif() + + if( CMAKE_Fortran_COMPILER_ID MATCHES "GNU" ) + ecbuild_add_fortran_flags( -ffree-line-length-none ) diff --git a/packages/fiat/intel_warnings_v120.patch b/packages/fiat/intel_warnings_v120.patch new file mode 100644 index 0000000..a1b2c53 --- /dev/null +++ b/packages/fiat/intel_warnings_v120.patch @@ -0,0 +1,42 @@ +--- a/cmake/fiat_compiler_warnings.cmake 2023-08-21 08:29:06.000000000 -0600 ++++ b/cmake/fiat_compiler_warnings.cmake 2023-08-21 08:37:40.000000000 -0600 +@@ -5,15 +5,17 @@ + ecbuild_add_c_flags("-Wextra" NO_FAIL) + ecbuild_add_c_flags("-Wno-unused-parameter" NO_FAIL) + ecbuild_add_c_flags("-Wno-unused-variable" NO_FAIL) +- ecbuild_add_c_flags("-Wno-gnu-zero-variadic-macro-arguments" NO_FAIL) ++ if (CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") ++ ecbuild_add_c_flags("-Wno-gnu-zero-variadic-macro-arguments" NO_FAIL) ++ endif() + endif() + + # Always disable some warnings + ecbuild_add_c_flags("-Wno-deprecated-declarations" NO_FAIL) +-if( CMAKE_C_COMPILER_ID MATCHES Intel ) +- ecbuild_add_c_flags("-diag-disable=279") # controlling expression is constant +- ecbuild_add_c_flags("-diag-disable=11076") # inline limits +-endif() ++#if( CMAKE_C_COMPILER_ID MATCHES Intel ) ++# ecbuild_add_c_flags("-diag-disable=279") # controlling expression is constant ++# ecbuild_add_c_flags("-diag-disable=11076") # inline limits ++#endif() + if( CMAKE_Fortran_COMPILER_ID MATCHES Cray ) + ecbuild_add_fortran_flags("-hnomessage=878") # A module named ... has already been directly or indirectly use associated into this scope + ecbuild_add_fortran_flags("-hnomessage=867") # Module ... has no public objects declared in the module, therefore nothing can be use associated from the module. +--- a/src/fiat/CMakeLists.txt ++++ b/src/fiat/CMakeLists.txt +@@ -26,10 +26,10 @@ endif() + + ### Compilation flags + +-if( CMAKE_Fortran_COMPILER_ID MATCHES "Intel" ) +- ## To disable checking of argument correctness of dummy mpi symbols +- ecbuild_add_fortran_flags( -nowarn nointerfaces ) +-endif() ++#if( CMAKE_Fortran_COMPILER_ID MATCHES "Intel" ) ++# ## To disable checking of argument correctness of dummy mpi symbols ++# ecbuild_add_fortran_flags( -nowarn nointerfaces ) ++#endif() + + if( CMAKE_Fortran_COMPILER_ID MATCHES "GNU" ) + ecbuild_add_fortran_flags( -ffree-line-length-none ) diff --git a/packages/fiat/package.py b/packages/fiat/package.py new file mode 100644 index 0000000..11dfc1f --- /dev/null +++ b/packages/fiat/package.py @@ -0,0 +1,62 @@ +# Copyright 2013-2024 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) + +# Based on spack/var/spack/repos/builtin/packages/fiat/package.py + +from spack.package import * + + +class Fiat(CMakePackage): + """FIAT (Fortran IFS and Arpege Toolkit) is a collection of selected + Fortran utility libraries, extracted from the IFS/Arpege model.""" + + homepage = "https://github.com/ecmwf-ifs/fiat" + git = "https://github.com/ACCESS-NRI/fiat.git" + url = "https://github.com/ecmwf-ifs/fiat/archive/1.0.0.tar.gz" + + maintainers("climbfuji", "penguian") + + license("Apache-2.0") + + version("main", branch="main", no_cache=True) + version("um", branch="um", no_cache=True) + version("1.2.0", sha256="758147410a4a3c493290b87443b4091660b915fcf29f7c4d565c5168ac67745f") + version("1.1.0", sha256="58354e60d29a1b710bfcea9b87a72c0d89c39182cb2c9523ead76a142c695f82") + version("1.0.0", sha256="45afe86117142831fdd61771cf59f31131f2b97f52a2bd04ac5eae9b2ab746b8") + + variant( + "build_type", + default="RelWithDebInfo", + description="CMake build type", + values=("Debug", "Release", "RelWithDebInfo"), + ) + + variant("mpi", default=True, description="Use MPI") + variant("openmp", default=True, description="Use OpenMP") + variant("fckit", default=True, description="Use fckit") + + depends_on("ecbuild", type=("build")) + depends_on("mpi", when="+mpi") + depends_on("eckit", when="+fckit") + depends_on("fckit", when="+fckit") + + patch("intel_warnings_v110.patch", when="@0:1.1.0") + patch("intel_warnings_v120.patch", when="@1.2.0:") + + def cmake_args(self): + args = [ + self.define_from_variant("ENABLE_OMP", "openmp"), + self.define_from_variant("ENABLE_MPI", "mpi"), + self.define_from_variant("ENABLE_FCKIT", "fckit"), + ] + if "+mpi" in self.spec: + args.extend( + [ + self.define("CMAKE_C_COMPILER", self.spec["mpi"].mpicc), + self.define("CMAKE_CXX_COMPILER", self.spec["mpi"].mpicxx), + self.define("CMAKE_Fortran_COMPILER", self.spec["mpi"].mpifc), + ] + ) + return args From a49002968d99b0161ba57be15a0dba0f76bdbdbc Mon Sep 17 00:00:00 2001 From: Paul Leopardi Date: Fri, 27 Sep 2024 15:34:46 +1000 Subject: [PATCH 04/17] Add drhook to the um package (#151) --- packages/um/package.py | 52 ++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/packages/um/package.py b/packages/um/package.py index 3ff5af0..7b43cf5 100644 --- a/packages/um/package.py +++ b/packages/um/package.py @@ -40,6 +40,7 @@ class Um(Package): # Bool variants have their default value set to True here. _bool_variants = ( + "DR_HOOK", "eccodes", "netcdf") for var in _bool_variants: @@ -118,6 +119,8 @@ class Um(Package): depends_on("gcom@8.1", when="@13.3", type=("build", "link")) depends_on("gcom@8.2", when="@13.4", type=("build", "link")) depends_on("gcom@8.3:", when="@13.5:", type=("build", "link")) + depends_on("fiat@um", type=("build", "link", "run"), + when="+DR_HOOK") depends_on("eccodes +fortran +netcdf", type=("build", "link", "run"), when="+eccodes") depends_on("netcdf-fortran@4.5.2", type=("build", "link", "run"), @@ -125,14 +128,26 @@ class Um(Package): phases = ["build", "install"] - # The dependency name and the ld_flags from + # The dependency name, include paths, and ld_flags from # the FCM config for each library configured via FCM. _lib_cfg = { + "DR_HOOK": { + "includes": [ + join_path("include", "fiat"), + join_path("module", "fiat"), + join_path("module", "parkind_dp")], + "dep_name": "fiat", + "fcm_name": "drhook", + "fcm_ld_flags": "-lfiat -lparkind_dp"}, "eccodes": { + "includes": ["include"], "dep_name": "eccodes", + "fcm_name": "eccodes", "fcm_ld_flags": "-leccodes_f90 -leccodes"}, "netcdf": { + "includes": ["include"], "dep_name": "netcdf-fortran", + "fcm_name": "netcdf", "fcm_ld_flags": "-lnetcdff -lnetcdf"}} @@ -188,16 +203,6 @@ def check_model_vs_spec(model, config_env, var, spec_value): spec = self.spec - # Define CPATH for dependencies that need include files. - ideps = ["eccodes", "gcom", "netcdf-fortran"] - incs = [spec[d].prefix.include for d in ideps] - for ipath in incs: - env.prepend_path("CPATH", ipath) - - # The gcom library does not contain shared objects and - # therefore must be statically linked. - env.prepend_path("LIBRARY_PATH", spec["gcom"].prefix.lib) - # Use rose-app.conf to set config options. config = configparser.ConfigParser() # Ensure that keys are case sensitive. @@ -219,9 +224,6 @@ def check_model_vs_spec(model, config_env, var, spec_value): check_model_vs_spec(model, config_env, key, spec_um_rev) config_env[key] = spec_um_rev - # Set DR_HOOK="false" until this package is available. - config_env["DR_HOOK"] = "false" - # Override those environment variables where a bool variant is specified. bool_to_str = lambda b: "true" if b else "false" for var in self._bool_variants: @@ -256,10 +258,26 @@ def check_model_vs_spec(model, config_env, var, spec_value): check_model_vs_spec(model, config_env, var, spec_value) config_env[var] = spec_value + # Define CPATH and FPATH for dependencies that need include files or modules. + for path in ["CPATH", "FPATH"]: + env.prepend_path(path, spec["gcom"].prefix.include) + for var in self._bool_variants: + if config_env[var] == "true": + prefix = spec[self._lib_cfg[var]["dep_name"]].prefix + for include in self._lib_cfg[var]["includes"]: + env.prepend_path(path, prefix.join(include)) + tty.info(f"{path}={[p.value for p in env.group_by_name()[path]]}") + + # The gcom library does not contain shared objects and + # therefore must be statically linked. + env.prepend_path("LIBRARY_PATH", spec["gcom"].prefix.lib) + # Get the linker arguments for some dependencies. - for fcm_libname in ["eccodes", "netcdf"]: - linker_args = self._get_linker_args(spec, fcm_libname) - config_env[f"ldflags_{fcm_libname}_on"] = linker_args + for var in self._bool_variants: + if config_env[var] == "true": + fcm_name = self._lib_cfg[var]["fcm_name"] + linker_args = self._get_linker_args(spec, var) + config_env[f"ldflags_{fcm_name}_on"] = linker_args # Set environment variables based on config_env. for key in config_env: From 6d260364c554503356aa5db47fd6374d8c85fca4 Mon Sep 17 00:00:00 2001 From: Harshula Jayasuriya Date: Tue, 5 Nov 2024 17:44:39 +1100 Subject: [PATCH 05/17] access-mocsy: create an SPD for ACCESS-NRI's mocsy fork (#157) --- packages/access-mocsy/package.py | 108 +++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 packages/access-mocsy/package.py diff --git a/packages/access-mocsy/package.py b/packages/access-mocsy/package.py new file mode 100644 index 0000000..5da84fd --- /dev/null +++ b/packages/access-mocsy/package.py @@ -0,0 +1,108 @@ +# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# Copyright 2024 ACCESS-NRI +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack.package import find_libraries, install, join_path, mkdirp + +# https://spack.readthedocs.io/en/latest/build_systems/makefilepackage.html +class AccessMocsy(MakefilePackage): + """Routines to model ocean carbonate system thermodynamics. ACCESS NRI's fork.""" + + homepage = "https://www.access-nri.org.au" + git = "https://github.com/ACCESS-NRI/mocsy.git" + + maintainers("harshula") + + version("master", branch="master") + version("mom5", branch="mom5", preferred=True) + + # Need: self.spec["mpi"].mpifc + depends_on("mpi") + + _header = join_path("src", "mocsy_DNADHeaders.h") + _libname = "libmocsy.a" + _pcfile = "mocsy.pc" + _pkgdir = "pkgconfig" + _modfiles = [ + "dual_num_auto_diff.mod", + "mocsy_buffesm.mod", + "mocsy_constants.mod", + "mocsy_depth2press.mod", + "mocsy_derivauto.mod", + "mocsy_derivnum.mod", + "mocsy_errors.mod", + "mocsy_f2pco2.mod", + "mocsy_gasx.mod", + "mocsy_p2fco2.mod", + "mocsy_p80.mod", + "mocsy_phsolvers.mod", + "mocsy_rho.mod", + "mocsy_rhoinsitu.mod", + "mocsy_singledouble.mod", + "mocsy_sw_adtg.mod", + "mocsy_sw_ptmp.mod", + "mocsy_sw_temp.mod", + "mocsy_tis.mod", + "mocsy_tpot.mod", + "mocsy_vars.mod", + "mocsy_varsolver.mod", + ] + + def url_for_version(self, version): + return "https://github.com/ACCESS-NRI/mocsy/tarball/{0}".format(version) + + @property + def libs(self): + return find_libraries( + "libmocsy", root=self.prefix, shared=False, recursive=True + ) + + def _create_pkgconf(self, spec, prefix): + + text = f"""\ +prefix={prefix} +exec_prefix=${{prefix}} +libdir=${{exec_prefix}}/lib +includedir=${{prefix}}/include + +Name: mocsy +Description: Routines to model ocean carbonate system thermodynamics. +Version: 2024.08.1 +Libs: -L${{libdir}} -lmocsy +Cflags: -I${{includedir}} +Fflags: -I${{includedir}} +""" + + with open(join_path(self.stage.source_path, self._pcfile), "w", encoding="utf-8") as pc: + nchars_written = pc.write(text) + + if nchars_written < len(text): + raise OSError + + def build(self, spec, prefix): + build = Executable("make") + build( + self._libname, + "FC=" + self.spec["mpi"].mpifc, + # Copied from MOM5/bin/mkmf.template.nci + "FCFLAGS=-fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -i4 -r8 -traceback -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -grecord-gcc-switches -align all -g3 -O2 -xCORE-AVX2 -debug all -check none", + "F90=" + self.spec["mpi"].mpifc + ) + self._create_pkgconf(spec, prefix) + + def install(self, spec, prefix): + + # Creates prefix.lib too + pkgconfdir = join_path(prefix.lib, self._pkgdir) + mkdirp(pkgconfdir) + mkdirp(prefix.include) + + install(join_path(self.stage.source_path, self._libname), prefix.lib) + install(join_path(self.stage.source_path, self._header), prefix.include) + for f in self._modfiles: + install(join_path(self.stage.source_path, f), prefix.include) + install(join_path(self.stage.source_path, self._pcfile), pkgconfdir) + From 9ec2fbb32b32625dbaa0dce4391cbeefa28267f4 Mon Sep 17 00:00:00 2001 From: Anton Steketee <79179784+anton-seaice@users.noreply.github.com> Date: Mon, 11 Nov 2024 11:02:54 +1100 Subject: [PATCH 06/17] Switch to https for git (#155) Switch to https for git to avoid need for ssh key password --- packages/gcom4/package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gcom4/package.py b/packages/gcom4/package.py index 2fffa28..563ccd9 100644 --- a/packages/gcom4/package.py +++ b/packages/gcom4/package.py @@ -17,7 +17,7 @@ class Gcom4(Package): """ homepage = "https://code.metoffice.gov.uk/trac/gcom" - git = "git@github.com:ACCESS-NRI/GCOM4.git" + git = "https://github.com/ACCESS-NRI/GCOM4.git" maintainers("penguian") From 912e248f74beb6253c65f46156baa658917faf33 Mon Sep 17 00:00:00 2001 From: Paul Leopardi Date: Tue, 12 Nov 2024 11:53:54 +1100 Subject: [PATCH 07/17] Revert the recent change to the gcom4 git clone address (#160) --- packages/gcom4/package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gcom4/package.py b/packages/gcom4/package.py index 563ccd9..2fffa28 100644 --- a/packages/gcom4/package.py +++ b/packages/gcom4/package.py @@ -17,7 +17,7 @@ class Gcom4(Package): """ homepage = "https://code.metoffice.gov.uk/trac/gcom" - git = "https://github.com/ACCESS-NRI/GCOM4.git" + git = "git@github.com:ACCESS-NRI/GCOM4.git" maintainers("penguian") From 279851df25e6ee0216ca129f971b32c765367d54 Mon Sep 17 00:00:00 2001 From: Harshula Jayasuriya Date: Thu, 14 Nov 2024 19:04:19 +1100 Subject: [PATCH 08/17] access-fms: create an SPD for ACCESS-NRI's FMS fork (#162) --- packages/access-fms/package.py | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 packages/access-fms/package.py diff --git a/packages/access-fms/package.py b/packages/access-fms/package.py new file mode 100644 index 0000000..683b990 --- /dev/null +++ b/packages/access-fms/package.py @@ -0,0 +1,63 @@ +# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# Copyright 2024 ACCESS-NRI +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack.package import find_headers, find_libraries + +# Based on upstream $spack/var/spack/repos/builtin/packages/fms/package.py +class AccessFms(CMakePackage): + """GFDL's Flexible Modeling System (FMS) is a software environment + that supports the efficient development, construction, execution, + and scientific interpretation of atmospheric, oceanic, and climate + system models. This is ACCESS-NRI's fork.""" + + homepage = "https://github.com/ACCESS-NRI/FMS" + git = "https://github.com/ACCESS-NRI/FMS.git" + + license("LGPL-3.0-or-later") + + maintainers("harshula") + + version("master", branch="master") + # TODO: Needs to be changed once changes to build system enter master. + version("development", branch="development", preferred=True) + + variant("gfs_phys", default=True, description="Use GFS Physics") + variant("large_file", default=False, description="Enable compiler definition -Duse_LARGEFILE.") + variant( + "internal_file_nml", + default=True, + description="Enable compiler definition -DINTERNAL_FILE_NML.", + ) + + depends_on("netcdf-c") + depends_on("netcdf-fortran") + depends_on("mpi") + + def url_for_version(self, version): + return "https://github.com/ACCESS-NRI/FMS/tarball/{0}".format(version) + + @property + def headers(self): + return find_headers( + "*", root=self.prefix, recursive=True + ) + + @property + def libs(self): + libraries = ["libfms_r4", "libfms_r8"] + return find_libraries( + libraries, root=self.prefix, shared=False, recursive=True + ) + + def cmake_args(self): + args = [ + self.define_from_variant("GFS_PHYS"), + self.define_from_variant("LARGEFILE", "large_file"), + self.define_from_variant("INTERNAL_FILE_NML"), + ] + + return args From ff94cda179ca9cea6f3cb7794cc7016873ae2e26 Mon Sep 17 00:00:00 2001 From: Harshula Jayasuriya Date: Fri, 15 Nov 2024 11:37:50 +1100 Subject: [PATCH 09/17] access-generic-tracers: create an SPD for ACCESS-NRI's fork (#164) --- packages/access-generic-tracers/package.py | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 packages/access-generic-tracers/package.py diff --git a/packages/access-generic-tracers/package.py b/packages/access-generic-tracers/package.py new file mode 100644 index 0000000..a31a460 --- /dev/null +++ b/packages/access-generic-tracers/package.py @@ -0,0 +1,38 @@ +# Copyright 2013-2024 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.package import find_libraries + +class AccessGenericTracers(CMakePackage): + """This is a fork of the NOAA-GFDL/ocean_BGC repo managed by NOAA-GFDL. + It contains a collection of tracers and associated code for use with + the MOM and GOLD ocean models. This fork includes generic tracer + implementations of the suite of WOMBAT models used in ACCESS earth-system + models.""" + + homepage = "https://github.com/ACCESS-NRI/GFDL-generic-tracers" + git = "https://github.com/ACCESS-NRI/GFDL-generic-tracers.git" + + maintainers("harshula") + + version("master", branch="master") + # TODO: Needs to be changed once changes to build system enter master. + version("development", branch="development", preferred=True) + + depends_on("access-mocsy") + depends_on("access-fms") + depends_on("mpi") + + def url_for_version(self, version): + return "https://github.com/ACCESS-NRI/GFDL-generic-tracers/tarball/{0}".format(version) + + @property + def libs(self): + libraries = find_libraries( + "libgtracers", root=self.prefix, shared=False, recursive=True + ) + # mocsy is an internal lib dependency of this static library. + # Hence we need to propagate it. + return libraries + self.spec["access-mocsy"].libs From c46a39c954f000d530148a379778518d6a8ee4fe Mon Sep 17 00:00:00 2001 From: Harshula Jayasuriya Date: Mon, 18 Nov 2024 16:05:07 +1100 Subject: [PATCH 10/17] mom5: add support for generic tracers (#166) * Add new variant access-gtracers * Add new dependencies access-fms & access-generic-tracers --- packages/mom5/package.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/mom5/package.py b/packages/mom5/package.py index fce38eb..7828787 100644 --- a/packages/mom5/package.py +++ b/packages/mom5/package.py @@ -22,6 +22,7 @@ class Mom5(MakefilePackage): version("access-esm1.6", branch="master") variant("restart_repro", default=True, description="Reproducible restart build.") + variant("access-gtracers", default=False, description="Use ACCESS-NRI's fork of GFDL-generic-tracers.") # The following two variants are not applicable when version is "access-esm1.5": variant("deterministic", default=False, description="Deterministic build.") variant("optimisation_report", default=False, description="Generate optimisation reports.") @@ -30,6 +31,9 @@ class Mom5(MakefilePackage): multi=False, description="Build MOM5 to support a particular use case.") + depends_on("access-fms", when="+access-gtracers") + depends_on("access-generic-tracers", when="+access-gtracers") + with when("@:access-esm0,access-esm2:"): depends_on("netcdf-c@4.7.4:") depends_on("netcdf-fortran@4.5.2:") @@ -82,6 +86,10 @@ def edit(self, spec, prefix): FFLAGS_OPT = "-g0 -O0 -xCORE-AVX2 -debug none -check none" CFLAGS_OPT = "-O0 -debug none -xCORE-AVX2" + if self.spec.satisfies("+access-gtracers"): + ideps.extend(["access-fms", "access-generic-tracers"]) + ldeps.extend(["access-fms", "access-generic-tracers"]) + incs = " ".join([istr] + [(spec[d].headers).cpp_flags for d in ideps]) libs = " ".join([(spec[d].libs).ld_flags for d in ldeps]) @@ -488,6 +496,10 @@ def build(self, spec, prefix): build = Executable("./MOM_compile.csh") if "+restart_repro" in self.spec: build.add_default_env("REPRO", "true") + + if self.spec.satisfies("+access-gtracers"): + build.add_default_env("SPACK_BUILD", "true") + if not self.spec.satisfies("@access-esm1.5"): # The MOM5 commit d7ba13a3f364ce130b6ad0ba813f01832cada7a2 # requires the --no_version switch to avoid git hashes being From 7ef15e5a64742836fabaaa2deea7f4cf1ff15b19 Mon Sep 17 00:00:00 2001 From: Harshula Jayasuriya Date: Thu, 21 Nov 2024 14:40:37 +1100 Subject: [PATCH 11/17] mom5: rename the SPACK_BUILD environment variable (#169) * The variable name $SPACK_BUILD is confusing because we use Spack to build MOM5 regardless of whether that variable is set to true or false. --- packages/mom5/package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mom5/package.py b/packages/mom5/package.py index 7828787..16d72e7 100644 --- a/packages/mom5/package.py +++ b/packages/mom5/package.py @@ -498,7 +498,7 @@ def build(self, spec, prefix): build.add_default_env("REPRO", "true") if self.spec.satisfies("+access-gtracers"): - build.add_default_env("SPACK_BUILD", "true") + build.add_default_env("SPACK_FMS_EXTERNAL", "true") if not self.spec.satisfies("@access-esm1.5"): # The MOM5 commit d7ba13a3f364ce130b6ad0ba813f01832cada7a2 From 512b0e0940c798c712f6535624c537d5c55ccb56 Mon Sep 17 00:00:00 2001 From: Harshula Jayasuriya Date: Mon, 25 Nov 2024 12:37:25 +1100 Subject: [PATCH 12/17] mom5: use environment variable name SPACK_GTRACERS_EXTERNAL (#170) * The name SPACK_GTRACERS_EXTERNAL is better than SPACK_FMS_EXTERNAL. --- packages/mom5/package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mom5/package.py b/packages/mom5/package.py index 16d72e7..0408bae 100644 --- a/packages/mom5/package.py +++ b/packages/mom5/package.py @@ -498,7 +498,7 @@ def build(self, spec, prefix): build.add_default_env("REPRO", "true") if self.spec.satisfies("+access-gtracers"): - build.add_default_env("SPACK_FMS_EXTERNAL", "true") + build.add_default_env("SPACK_GTRACERS_EXTERNAL", "true") if not self.spec.satisfies("@access-esm1.5"): # The MOM5 commit d7ba13a3f364ce130b6ad0ba813f01832cada7a2 From ff2fbc0a9680118a805a0577edbe03008c5346ae Mon Sep 17 00:00:00 2001 From: Aidan Heerdegen Date: Mon, 2 Dec 2024 11:24:37 +1100 Subject: [PATCH 13/17] Migrate ISSM to GitHub repo (#172) ISSM: - Change to git address. Added url_for_version function - Add url_for_version function - Add release version --- packages/issm/package.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/issm/package.py b/packages/issm/package.py index 9f7f0ee..624330a 100644 --- a/packages/issm/package.py +++ b/packages/issm/package.py @@ -12,9 +12,10 @@ class Issm(AutotoolsPackage): """Ice-sheet and Sea-Level System Model""" homepage = "https://issm.jpl.nasa.gov/" - svn = "https://issm.ess.uci.edu/svn/issm/issm/trunk" + git = "https://github.com/ISSMteam/ISSM.git" version("develop") + version("4.24", sha256="0487bd025f37be4a39dfd48b047de6a6423e310dfe5281dbd9a52aa35b26151a") depends_on("autoconf", type="build") depends_on("automake", type="build") @@ -25,6 +26,9 @@ class Issm(AutotoolsPackage): depends_on("petsc+metis+mumps+scalapack") depends_on("m1qn3") + def url_for_version(self, version): + return "https://github.com/ISSMteam/ISSM/tarball/v{0}".format(version) + def autoreconf(self, spec, prefix): autoreconf("--install", "--verbose", "--force") From 3d0f200dd96e48654fcb7a908a43e206321ec96a Mon Sep 17 00:00:00 2001 From: Harshula Jayasuriya Date: Fri, 6 Dec 2024 12:03:57 +1100 Subject: [PATCH 14/17] um7: add version "access-esm1.6" that uses branch dev-access-esm1.6 (#176) --- packages/um7/package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/um7/package.py b/packages/um7/package.py index a99b85c..d578bbd 100644 --- a/packages/um7/package.py +++ b/packages/um7/package.py @@ -20,7 +20,7 @@ class Um7(Package): git = "git@github.com:ACCESS-NRI/UM7.git" # https://code.metoffice.gov.uk/trac/um/wiki/PastReleases - version("7.3", branch="main", preferred=True) + version("access-esm1.6", branch="dev-access-esm1.6", preferred=True) version("access-esm1.5", branch="access-esm1.5") maintainers("penguian") From 32bcad8cbe21c10dc06e7f4681f0cfe4e14e06a3 Mon Sep 17 00:00:00 2001 From: Harshula Jayasuriya Date: Mon, 9 Dec 2024 10:14:10 +1100 Subject: [PATCH 15/17] access-esm1p6: add variant cice, generic-tracers and um (#177) --- packages/access-esm1p6/package.py | 46 +++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/packages/access-esm1p6/package.py b/packages/access-esm1p6/package.py index b32fadf..895b027 100644 --- a/packages/access-esm1p6/package.py +++ b/packages/access-esm1p6/package.py @@ -8,7 +8,8 @@ from spack.package import * class AccessEsm1p6(BundlePackage): - """ACCESS-ESM1.6 bundle contains the coupled UM7, CICE4 and MOM5 models. + """ACCESS-ESM1.6 bundle contains the coupled UM7, CICE4/CICE5 and MOM5 + models. ACCESS-ESM1.6 comprises of: @@ -17,7 +18,7 @@ class AccessEsm1p6(BundlePackage): * The CABLE land surface model with biogeochemistry (CASA-CNP) (CABLE2.4) * The GFDL MOM5 ocean model at 1 degree resolution * The WOMBATlite ocean BGC model (generic tracer version) - * The LANL CICE4.1 sea ice model (version as ACCESS1.4) + * The LANL CICE4.1 sea ice model (version as ACCESS1.4). CICE5 for testing. * The OASIS-MCT coupler """ @@ -25,13 +26,46 @@ class AccessEsm1p6(BundlePackage): git = "https://github.com/ACCESS-NRI/ACCESS-ESM1.6.git" - maintainers("dougiesquire") + maintainers("dougiesquire", "harshula") version("latest") - depends_on("cice4@access-esm1.5", type="run") - depends_on("mom5@access-esm1.6 type=ACCESS-ESM", type="run") + variant( + "cice", + default="4", + description="Choose the version of the CICE sea-ice model.", + values=("4", "5"), + multi=False, + ) + variant( + "generic-tracers", + default=True, + description="Enable generic tracers.", + ) + variant( + "um", + default="access-esm1.6", + description="Choose the branch of um7.", + values=("access-esm1.5", "access-esm1.6"), + multi=False, + ) + + depends_on("cice4@access-esm1.5", type="run", when="cice=4") + depends_on("cice5@access-esm1.6", type="run", when="cice=5") + # TODO: Use the access-esm1.6 branch when it has been confirmed that + # MOM5 master supports building with generic tracers disabled. + depends_on( + "mom5@access-esm1.5 type=ACCESS-CM", + type="run", + when="~generic-tracers", + ) + depends_on( + "mom5@access-esm1.6 type=ACCESS-ESM", + type="run", + when="+generic-tracers", + ) # um7 is in a private repository - depends_on("um7@access-esm1.5", type="run") + depends_on("um7@access-esm1.5", type="run", when="um=access-esm1.5") + depends_on("um7@access-esm1.6", type="run", when="um=access-esm1.6") # There is no need for install() since there is no code. From 2fcdfb17f6934e04b03d0f60b73af449e0f20c33 Mon Sep 17 00:00:00 2001 From: Harshula Jayasuriya Date: Mon, 9 Dec 2024 14:19:37 +1100 Subject: [PATCH 16/17] cice5: improve handling of targets for ESM1.6 --- packages/cice5/package.py | 90 ++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/packages/cice5/package.py b/packages/cice5/package.py index 5906959..4b6ef59 100644 --- a/packages/cice5/package.py +++ b/packages/cice5/package.py @@ -16,7 +16,7 @@ class Cice5(MakefilePackage): maintainers = ["harshula"] - version("master", branch="master") + version("master", branch="master", preferred=True) variant("deterministic", default=False, description="Deterministic build.") variant("optimisation_report", default=False, description="Generate optimisation reports.") @@ -25,45 +25,25 @@ class Cice5(MakefilePackage): depends_on("mpi") depends_on("netcdf-fortran@4.5.2:") depends_on("netcdf-c@4.7.4:") - # TODO: For initial verification we are going to use static pio. - # Eventually we plan to move to shared pio - # ~shared requires: https://github.com/spack/spack/pull/34837 - depends_on("parallelio~pnetcdf~timing~shared") depends_on("datetime-fortran") depends_on("oasis3-mct+deterministic", when="+deterministic") depends_on("oasis3-mct~deterministic", when="~deterministic") - depends_on("libaccessom2+deterministic", when="+deterministic") - depends_on("libaccessom2~deterministic", when="~deterministic") - - phases = ["edit", "build", "install"] - - _buildscript = "spack-build.sh" - _buildscript_path = join_path("bld", _buildscript) - - # The integer represents environment variable NTASK - __targets = {24: {}, 480: {}, 722: {}, 1682: {}} - __targets[24]["driver"] = "auscom" - __targets[24]["grid"] = "360x300" - __targets[24]["blocks"] = "24x1" - - __targets[480]["driver"] = "auscom" - __targets[480]["grid"] = "1440x1080" - __targets[480]["blocks"] = "48x40" - - # Comment from bld/config.nci.auscom.3600x2700: - # Recommendations: - # use processor_shape = slenderX1 or slenderX2 in ice_in - # one per processor with distribution_type='cartesian' or - # squarish blocks with distribution_type='rake' - # If BLCKX (BLCKY) does not divide NXGLOB (NYGLOB) evenly, padding - # will be used on the right (top) of the grid. - __targets[722]["driver"] = "auscom" - __targets[722]["grid"] = "3600x2700" - __targets[722]["blocks"] = "90x90" - - __targets[1682]["driver"] = "auscom" - __targets[1682]["grid"] = "3600x2700" - __targets[1682]["blocks"] = "200x180" + + # Copied with when() from MOM5 SPR + with when("@:access-esm0,access-esm2:"): + # TODO: For initial verification we are going to use static pio. + # Eventually we plan to move to shared pio + # ~shared requires: https://github.com/spack/spack/pull/34837 + depends_on("parallelio~pnetcdf~timing~shared") + depends_on("libaccessom2+deterministic", when="+deterministic") + depends_on("libaccessom2~deterministic", when="~deterministic") + + phases = ["set_targets", "edit", "build", "install"] + + __buildscript = "spack-build.sh" + __buildscript_path = join_path("bld", __buildscript) + + __targets = {} def url_for_version(self, version): return "https://github.com/ACCESS-NRI/cice5/tarball/{0}".format(version) @@ -86,13 +66,43 @@ def make_linker_args(self, spec, name, namespecs): "-Wl,-rpath=" + path] ) + def add_target(self, ntask, driver, grid, blocks): + self.__targets[ntask]["driver"] = driver + self.__targets[ntask]["grid"] = grid + self.__targets[ntask]["blocks"] = blocks + + def set_targets(self, spec, prefix): + + if self.spec.satisfies("@access-esm1.6"): + # The integer represents environment variable NTASK + self.__targets = {12: {}} + self.add_target(12, "access-esm1.6", "360x300", "12x1") + + else: + # The integer represents environment variable NTASK + self.__targets = {24: {}, 480: {}, 722: {}, 1682: {}} + + # TODO: Each of these targets could map to a variant: + self.add_target(24, "auscom", "360x300", "24x1") + self.add_target(480, "auscom", "1440x1080", "48x40") + + # Comment from bld/config.nci.auscom.3600x2700: + # Recommendations: + # use processor_shape = slenderX1 or slenderX2 in ice_in + # one per processor with distribution_type='cartesian' or + # squarish blocks with distribution_type='rake' + # If BLCKX (BLCKY) does not divide NXGLOB (NYGLOB) evenly, padding + # will be used on the right (top) of the grid. + self.add_target(722, "auscom", "3600x2700", "90x90") + self.add_target(1682, "auscom", "3600x2700", "200x180") + def edit(self, spec, prefix): srcdir = self.stage.source_path - buildscript_dest = join_path(srcdir, self._buildscript_path) + buildscript_dest = join_path(srcdir, self.__buildscript_path) makeinc_path = join_path(srcdir, "bld", "Macros.spack") - copy(join_path(self.package_dir, self._buildscript), buildscript_dest) + copy(join_path(self.package_dir, self.__buildscript), buildscript_dest) config = {} @@ -224,7 +234,7 @@ def edit(self, spec, prefix): def build(self, spec, prefix): build = Executable( - join_path(self.stage.source_path, self._buildscript_path) + join_path(self.stage.source_path, self.__buildscript_path) ) for k in self.__targets: From cdd87af685a200f19013c32bdbcc64cd3643e0a2 Mon Sep 17 00:00:00 2001 From: Harshula Jayasuriya Date: Wed, 11 Dec 2024 10:45:10 +1100 Subject: [PATCH 17/17] cice5: Anton's feedback --- packages/cice5/package.py | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/packages/cice5/package.py b/packages/cice5/package.py index 4b6ef59..4568a1e 100644 --- a/packages/cice5/package.py +++ b/packages/cice5/package.py @@ -29,6 +29,7 @@ class Cice5(MakefilePackage): depends_on("oasis3-mct+deterministic", when="+deterministic") depends_on("oasis3-mct~deterministic", when="~deterministic") + # These are the default dependencies when building version "master". # Copied with when() from MOM5 SPR with when("@:access-esm0,access-esm2:"): # TODO: For initial verification we are going to use static pio. @@ -38,11 +39,12 @@ class Cice5(MakefilePackage): depends_on("libaccessom2+deterministic", when="+deterministic") depends_on("libaccessom2~deterministic", when="~deterministic") - phases = ["set_targets", "edit", "build", "install"] + phases = ["set_deps_targets", "edit", "build", "install"] __buildscript = "spack-build.sh" __buildscript_path = join_path("bld", __buildscript) + __deps = {"includes": "", "ldflags": ""} __targets = {} def url_for_version(self, version): @@ -71,13 +73,20 @@ def add_target(self, ntask, driver, grid, blocks): self.__targets[ntask]["grid"] = grid self.__targets[ntask]["blocks"] = blocks - def set_targets(self, spec, prefix): + def set_deps_targets(self, spec, prefix): if self.spec.satisfies("@access-esm1.6"): # The integer represents environment variable NTASK self.__targets = {12: {}} self.add_target(12, "access-esm1.6", "360x300", "12x1") + ideps = ["oasis3-mct", "netcdf-fortran"] + + # NOTE: The order of the libraries matter during the linking step! + ldeps = ["oasis3-mct", "netcdf-c", "netcdf-fortran"] + lstr = "" + + # These are the default settings when building version "master". else: # The integer represents environment variable NTASK self.__targets = {24: {}, 480: {}, 722: {}, 1682: {}} @@ -96,6 +105,19 @@ def set_targets(self, spec, prefix): self.add_target(722, "auscom", "3600x2700", "90x90") self.add_target(1682, "auscom", "3600x2700", "200x180") + ideps = ["parallelio", "oasis3-mct", "libaccessom2", "netcdf-fortran"] + + # NOTE: The order of the libraries matter during the linking step! + # NOTE: datetime-fortran is a dependency of libaccessom2. + ldeps = ["oasis3-mct", "libaccessom2", "netcdf-c", "netcdf-fortran", "datetime-fortran"] + lstr = self.make_linker_args(spec, "parallelio", "-lpiof -lpioc") + + istr = join_path((spec["oasis3-mct"].headers).cpp_flags, "psmile.MPI1") + self.__deps["includes"] = " ".join([istr] + [(spec[d].headers).cpp_flags for d in ideps]) + + self.__deps["ldflags"] = " ".join([lstr] + [self.get_linker_args(spec, d) for d in ldeps]) + + def edit(self, spec, prefix): srcdir = self.stage.source_path @@ -105,16 +127,8 @@ def edit(self, spec, prefix): copy(join_path(self.package_dir, self.__buildscript), buildscript_dest) config = {} - - istr = join_path((spec["oasis3-mct"].headers).cpp_flags, "psmile.MPI1") - ideps = ["parallelio", "oasis3-mct", "libaccessom2", "netcdf-fortran"] - incs = " ".join([istr] + [(spec[d].headers).cpp_flags for d in ideps]) - - lstr = self.make_linker_args(spec, "parallelio", "-lpiof -lpioc") - # NOTE: The order of the libraries matter during the linking step! - # NOTE: datetime-fortran is a dependency of libaccessom2. - ldeps = ["oasis3-mct", "libaccessom2", "netcdf-c", "netcdf-fortran", "datetime-fortran"] - libs = " ".join([lstr] + [self.get_linker_args(spec, d) for d in ldeps]) + incs = self.__deps["includes"] + libs = self.__deps["ldflags"] # TODO: https://github.com/ACCESS-NRI/ACCESS-OM/issues/12 NCI_OPTIM_FLAGS = "-g3 -O2 -axCORE-AVX2 -debug all -check none -traceback -assume buffered_io"