From 7b10ce85fad26255294e1c193e093571c604be37 Mon Sep 17 00:00:00 2001 From: Scott Wales Date: Wed, 24 Jul 2024 17:05:04 +1000 Subject: [PATCH] Import jopa container --- environments/jopa/README.md | 62 ++++++ environments/jopa/post-install.sh | 11 + environments/jopa/spack.yaml | 39 ++++ spack/packages/ecbuild/package.py | 37 ++++ spack/packages/eckit/package.py | 200 ++++++++++++++++++ ...c304525607c16cae7a44a2424c328df34d30.patch | 22 ++ spack/packages/ecmwf-atlas/package.py | 41 ++++ spack/packages/ectrans/package.py | 13 ++ spack/packages/fckit/package.py | 33 +++ spack/packages/fiat/package.py | 12 ++ spack/packages/fms/package.py | 153 ++++++++++++++ spack/packages/jedi-cmake/package.py | 10 + spack/packages/odc/cstdint.patch | 11 + spack/packages/odc/package.py | 35 +++ spack/packages/shumlib/package.py | 31 +++ 15 files changed, 710 insertions(+) create mode 100644 environments/jopa/README.md create mode 100755 environments/jopa/post-install.sh create mode 100644 environments/jopa/spack.yaml create mode 100644 spack/packages/ecbuild/package.py create mode 100644 spack/packages/eckit/package.py create mode 100644 spack/packages/ecmwf-atlas/a27fc304525607c16cae7a44a2424c328df34d30.patch create mode 100644 spack/packages/ecmwf-atlas/package.py create mode 100644 spack/packages/ectrans/package.py create mode 100644 spack/packages/fckit/package.py create mode 100644 spack/packages/fiat/package.py create mode 100644 spack/packages/fms/package.py create mode 100644 spack/packages/jedi-cmake/package.py create mode 100644 spack/packages/odc/cstdint.patch create mode 100644 spack/packages/odc/package.py create mode 100644 spack/packages/shumlib/package.py diff --git a/environments/jopa/README.md b/environments/jopa/README.md new file mode 100644 index 0000000..59a5e8d --- /dev/null +++ b/environments/jopa/README.md @@ -0,0 +1,62 @@ +# JOPA Container + +Contains the dependencies required to build mo-bundle and run JOPA + +https://github.com/MetOffice/mo-bundle + +# Building JOPA / mo-bundle + +## NCI, with a container + +1. Load the container + +``` +module use /g/data/access/ngm +module load envs/jopa +``` + +2. Build Jopa inside the container + +``` +cd mo-bundle + +imagerun cmake --preset=bom-container --workflow +``` + +## Met Office VDI, no container + +1. Install Spack, and activate with `$SPACK/share/spack/setup-env.sh` + +2. Copy `configs/meto_vdi/*` to the Spack configuration directory (e.g. `~/.spack` or `$SPACK/etc/spack`) + +3. Install and setup a compiler, e.g. GCC 9 + +``` +spack install gcc@9 +spack compiler find $(spack find --format='{prefix}' gcc@9) +``` + +4. Install the environment with GCC and MPICH + +``` +export SPACK_COMPILER="gcc@9" +export SPACK_MPI="mpich +slurm" + +srun -q -n1 -c10 --mem=40G --time=120 env -u SLURM_NODELIST ./bin/install.sh jopa-v0 +``` + +5. Activate the environment + +``` +spack load $SPACK_COMPILER +spack env activate jopa-v0 +export SPACK_ENV_VIEW=$SPACK_ENV/.spack-env/view +``` + +6. Build mo-bundle + +``` +cd mo-bundle + +cmake --preset=bom-container --workflow +``` diff --git a/environments/jopa/post-install.sh b/environments/jopa/post-install.sh new file mode 100755 index 0000000..778cd95 --- /dev/null +++ b/environments/jopa/post-install.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Copyright 2023 Bureau of Meteorology +# Author Scott Wales + +set -eu +set -o pipefail + +SCRIPT_DIR=$( cd -- "$( dirname -- "$(readlink -f ${BASH_SOURCE[0]})" )" &> /dev/null && pwd ) + +# Add FMS +echo "CPATH=$(spack find --format '{prefix}' fms)/include_r4:\$CPATH" >> $SPACK_ROOT/bin/activate-full.sh diff --git a/environments/jopa/spack.yaml b/environments/jopa/spack.yaml new file mode 100644 index 0000000..b2072b9 --- /dev/null +++ b/environments/jopa/spack.yaml @@ -0,0 +1,39 @@ +spack: + specs: + - eckit@1.24.4 compression=lz4 + - ecmwf-atlas@0.34.0 + - fckit@0.11.0 + - ectrans@1.2.0 + - fiat@1.1.2 + - odc + + - openblas + - boost + - 'cmake@3.26:' + - ecbuild@3.7 + - eigen + - git-lfs + - gsl-lite + - hdf5-plugins + - jedi-cmake + - lapack + - netcdf-c + - netcdf-cxx4 + - netcdf-fortran + - ninja + - nlohmann-json-schema-validator + - nlohmann-json + - py-pybind11 + - shumlib + - udunits + - zstd + - bom-ngm.hdf5@1.12.2 # Must match mamba + - fms@release-jcsda + + packages: + git-lfs: + require: '%gcc' + go: + require: '%gcc' + openmpi: + require: '~static +cxx' diff --git a/spack/packages/ecbuild/package.py b/spack/packages/ecbuild/package.py new file mode 100644 index 0000000..70aeaf2 --- /dev/null +++ b/spack/packages/ecbuild/package.py @@ -0,0 +1,37 @@ +# Copyright 2013-2023 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 * + + +class Ecbuild(CMakePackage): + """ecBuild is the ECMWF build system. It is built on top of CMake and + consists of a set of macros as well as a wrapper around CMake""" + + homepage = "https://github.com/ecmwf/ecbuild" + url = "https://github.com/ecmwf/ecbuild/archive/refs/tags/3.6.1.tar.gz" + + maintainers("skosukhin") + + version( + "3.7.2", + sha256="7a2d192cef1e53dc5431a688b2e316251b017d25808190faed485903594a3fb9", + ) + version( + "3.6.5", + sha256="98bff3d3c269f973f4bfbe29b4de834cd1d43f15b1c8d1941ee2bfe15e3d4f7f", + ) + version( + "3.6.1", + sha256="796ccceeb7af01938c2f74eab0724b228e9bf1978e32484aa3e227510f69ac59", + ) + + depends_on("cmake@3.11:", type=("build", "run")) + + # See https://github.com/ecmwf/ecbuild/issues/35 + depends_on("cmake@:3.19", type=("build", "run"), when="@:3.6.1") + + # Some of the installed scripts require running Perl: + depends_on("perl", type=("build", "run")) diff --git a/spack/packages/eckit/package.py b/spack/packages/eckit/package.py new file mode 100644 index 0000000..88fe2fa --- /dev/null +++ b/spack/packages/eckit/package.py @@ -0,0 +1,200 @@ +# Copyright 2013-2023 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 * + + +class Eckit(CMakePackage): + """ecKit is a cross-platform c++ toolkit that supports development of tools + and applications at ECMWF.""" + + homepage = "https://github.com/ecmwf/eckit" + url = "https://github.com/ecmwf/eckit/archive/refs/tags/1.16.0.tar.gz" + + maintainers("skosukhin") + + version( + "1.24.4", + sha256="b6129eb4f7b8532aa6905033e4cf7d09aadc8547c225780fea3db196e34e4671", + ) + version( + "1.24.0", + sha256="a25440011c66decbfb4908e5f4b7d0025b2166acfb9db941abdeb38d477c45b3", + ) + version( + "1.20.2", + sha256="9c11ddaaf346e40d11312b81ca7f1b510017f26618f4c0f5c5c59c37623fbac8", + ) + version( + "1.19.0", + sha256="a5fef36b4058f2f0aac8daf5bcc9740565f68da7357ddd242de3a5eed4765cc7", + ) + version( + "1.16.3", + sha256="d2aae7d8030e2ce39e5d04e36dd6aa739f3c8dfffe32c61c2a3127c36b573485", + ) + version( + "1.16.0", + sha256="9e09161ea6955df693d3c9ac70131985eaf7cf24a9fa4d6263661c6814ebbaf1", + ) + + variant("tools", default=True, description="Build the command line tools") + variant("mpi", default=True, description="Enable MPI support") + variant( + "admin", default=True, description="Build utilities for administration tools" + ) + variant("sql", default=True, description="Build SQL engine") + variant( + "linalg", + values=any_combination_of("eigen", "armadillo", "mkl", "lapack"), + description="List of supported linear algebra backends", + ) + variant( + "compression", + values=any_combination_of("bzip2", "snappy", "lz4", "aec"), + description="List of supported compression backends", + ) + variant("xxhash", default=True, description="Enable xxHash support for hashing") + variant( + "ssl", default=False, description="Enable MD4 and SHA1 support with OpenSSL" + ) + variant("curl", default=False, description="Enable URL data transferring with cURL") + variant( + "jemalloc", default=False, description="Link against jemalloc memory allocator" + ) + variant( + "unicode", + default=True, + description="Enable support for Unicode characters in Yaml/JSON" "parsers", + ) + variant("aio", default=True, description="Enable asynchronous IO") + + depends_on("cmake@3.12:", type="build") + depends_on("ecbuild@3.5:", type="build") + + depends_on("mpi", when="+mpi") + + depends_on("yacc", type="build", when="+admin") + depends_on("flex", type="build", when="+admin") + depends_on("ncurses", when="+admin") + + depends_on("yacc", type="build", when="+sql") + depends_on("flex", type="build", when="+sql") + depends_on("python@3", type="build") + + depends_on("eigen", when="linalg=eigen") + depends_on("armadillo", when="linalg=armadillo") + depends_on("mkl", when="linalg=mkl") + depends_on("lapack", when="linalg=lapack") + + depends_on("bzip2", when="compression=bzip2") + depends_on("snappy", when="compression=snappy") + depends_on("lz4", when="compression=lz4") + depends_on("libaec", when="compression=aec") + + depends_on("openssl", when="+ssl") + + depends_on("curl", when="+curl") + + depends_on("jemalloc", when="+jemalloc") + + # The package enables LAPACK backend (together with MKL backend) + # when='linalg=mkl'. This leads to two identical installations when: + # eckit linalg=mkl + # eckit linalg=mkl,lapack + # We prevent that by introducing the following conflict: + conflicts( + "linalg=lapack", + when="linalg=mkl", + msg='"linalg=lapack" is implied when "linalg=mkl" and ' + "must not be specified additionally", + ) + + def cmake_args(self): + args = [ + # Some features that we want to build are experimental: + self.define("ENABLE_EXPERIMENTAL", self._enable_experimental), + self.define_from_variant("ENABLE_BUILD_TOOLS", "tools"), + # We let ecBuild find the MPI library. We could help it by setting + # CMAKE_C_COMPILER to mpicc but that might give CMake a wrong + # impression that no additional flags are needed to link to + # libpthread, which will lead to problems with libraries that are + # linked with the C++ compiler. We could additionally set + # CMAKE_CXX_COMPILER to mpicxx. That would solve the problem with + # libpthread but lead to overlinking to MPI libraries, which we + # currently prefer to avoid since ecBuild does the job in all known + # cases. + self.define_from_variant("ENABLE_MPI", "mpi"), + self.define_from_variant("ENABLE_ECKIT_CMD", "admin"), + self.define_from_variant("ENABLE_ECKIT_SQL", "sql"), + self.define("ENABLE_EIGEN", "linalg=eigen" in self.spec), + self.define("ENABLE_ARMADILLO", "linalg=armadillo" in self.spec), + self.define("ENABLE_MKL", "linalg=mkl" in self.spec), + self.define("ENABLE_BZIP2", "compression=bzip2" in self.spec), + self.define("ENABLE_SNAPPY", "compression=snappy" in self.spec), + self.define("ENABLE_LZ4", "compression=lz4" in self.spec), + self.define("ENABLE_AEC", "compression=aec" in self.spec), + self.define_from_variant("ENABLE_XXHASH", "xxhash"), + self.define_from_variant("ENABLE_SSL", "ssl"), + self.define_from_variant("ENABLE_CURL", "curl"), + self.define_from_variant("ENABLE_JEMALLOC", "jemalloc"), + self.define_from_variant("ENABLE_UNICODE", "unicode"), + self.define_from_variant("ENABLE_AIO", "aio"), + self.define("ENABLE_TESTS", self.run_tests), + # Unconditionally disable additional unit/performance tests, since + # they download additional data (~1.6GB): + self.define("ENABLE_EXTRA_TESTS", False), + # No reason to check for doxygen and generate the documentation + # since it is not installed: + self.define("ENABLE_DOCS", False), + # Disable features that are currently not needed: + self.define("ENABLE_CUDA", False), + self.define("ENABLE_VIENNACL", False), + # Ceph/Rados storage support requires https://github.com/ceph/ceph + # and will be added later: + self.define("ENABLE_RADOS", False), + # rsync support requires https://github.com/librsync/librsync and + # will be added later: + self.define("ENABLE_RSYNC", False), + # Disable "prototyping code that may never see the light of day": + self.define("ENABLE_SANDBOX", False), + self.define( + "PYTHON_EXECUTABLE", self.spec["python"].prefix + "/bin/python3" + ), + ] + + if "linalg=mkl" not in self.spec: + # ENABLE_LAPACK is ignored if MKL backend is enabled + # (the LAPACK backend is still built though): + args.append(self.define("ENABLE_LAPACK", "linalg=lapack" in self.spec)) + + if "+admin" in self.spec and "+termlib" in self.spec["ncurses"]: + # Make sure that libeckit_cmd is linked to a library that resolves 'setupterm', + # 'tputs', etc. That is either libncurses (when 'ncurses~termlib') or libtinfo (when + # 'ncurses+termlib'). CMake considers the latter only if CURSES_NEED_NCURSES is set to + # TRUE. Note that the installation of eckit does not fail without this but the building + # of a dependent package (e.g. fdb) might fail due to the undefined references. + args.append(self.define("CURSES_NEED_NCURSES", True)) + + return args + + def check(self): + ctest_args = ["-j", str(make_jobs)] + + broken_tests = [] + if self._enable_experimental: + # The following test quasi-randomly fails not because it reveals a bug in the library + # but because its implementation has a bug (static initialization order fiasco): + broken_tests.append("eckit_test_experimental_singleton_singleton") + + if broken_tests: + ctest_args.extend(["-E", "|".join(broken_tests)]) + + with working_dir(self.build_directory): + ctest(*ctest_args) + + @property + def _enable_experimental(self): + return "linalg=armadillo" in self.spec diff --git a/spack/packages/ecmwf-atlas/a27fc304525607c16cae7a44a2424c328df34d30.patch b/spack/packages/ecmwf-atlas/a27fc304525607c16cae7a44a2424c328df34d30.patch new file mode 100644 index 0000000..68de0da --- /dev/null +++ b/spack/packages/ecmwf-atlas/a27fc304525607c16cae7a44a2424c328df34d30.patch @@ -0,0 +1,22 @@ +From a27fc304525607c16cae7a44a2424c328df34d30 Mon Sep 17 00:00:00 2001 +From: Willem Deconinck +Date: Wed, 10 May 2023 13:44:58 +0200 +Subject: [PATCH] Fix compilation of atlas_io due to missing header + +--- + atlas_io/src/atlas_io/Data.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/atlas_io/src/atlas_io/Data.h b/atlas_io/src/atlas_io/Data.h +index 7431fd7f4..69c51096f 100644 +--- a/atlas_io/src/atlas_io/Data.h ++++ b/atlas_io/src/atlas_io/Data.h +@@ -10,6 +10,8 @@ + + #pragma once + ++#include ++ + #include "eckit/io/Buffer.h" + + namespace atlas { diff --git a/spack/packages/ecmwf-atlas/package.py b/spack/packages/ecmwf-atlas/package.py new file mode 100644 index 0000000..e3ee64e --- /dev/null +++ b/spack/packages/ecmwf-atlas/package.py @@ -0,0 +1,41 @@ +#!/g/data/hh5/public/apps/miniconda3/envs/analysis3/bin/python +## Scott Wales 2023 + + +class EcmwfAtlas(CMakePackage): + git = "https://github.com/ecmwf/atlas" + url = "https://github.com/ecmwf/atlas/archive/refs/tags/0.32.1.tar.gz" + + version( + "0.34.0", + sha256="48536742cec0bc268695240843ac0e232e2b5142d06b19365688d9ea44dbd9ba", + ) + version( + "0.33.0", + sha256="a91fffe9cecb51c6ee8549cbc20f8279e7b1f67dd90448e6c04c1889281b0600", + ) + version( + "0.32.1", + sha256="3d1a46cb7f50e1a6ae9e7627c158760e132cc9f568152358e5f78460f1aaf01b", + ) + + depends_on("cmake@3.12:", type="build") + depends_on("ecbuild", type="build") + depends_on("eckit") + depends_on("fckit") + depends_on("eigen") + depends_on("python@3", type="build") + depends_on("ectrans") + + patch("a27fc304525607c16cae7a44a2424c328df34d30.patch", when="@0.33") + + def cmake_args(self): + args = [] + + args.append( + self.define( + "PYTHON_EXECUTABLE", self.spec["python"].prefix + "/bin/python3" + ) + ) + + return args diff --git a/spack/packages/ectrans/package.py b/spack/packages/ectrans/package.py new file mode 100644 index 0000000..2d503a2 --- /dev/null +++ b/spack/packages/ectrans/package.py @@ -0,0 +1,13 @@ +class Ectrans(CMakePackage): + git = "https://github.com/ecmwf-ifs/ectrans" + url = "https://github.com/ecmwf-ifs/ectrans/archive/refs/tags/1.2.0.tar.gz" + + version( + "1.2.0", + sha256="2ee6dccc8bbfcc23faada1d957d141f24e41bb077c1821a7bc2b812148dd336c", + ) + + depends_on('fiat') + depends_on('ecbuild', type='build') + depends_on('blas') + depends_on('fftw-api') diff --git a/spack/packages/fckit/package.py b/spack/packages/fckit/package.py new file mode 100644 index 0000000..c778433 --- /dev/null +++ b/spack/packages/fckit/package.py @@ -0,0 +1,33 @@ +#!/g/data/hh5/public/apps/miniconda3/envs/analysis3/bin/python +## Scott Wales 2023 + + +class Fckit(CMakePackage): + git = "https://github.com/ecmwf/fckit" + url = "https://github.com/ecmwf/fckit/archive/refs/tags/0.9.0.tar.gz" + + version( + "0.11.0", + sha256="846f5c369940c0a3d42cd12932f7d6155339e79218d149ebbfdd02e759dc86c5", + ) + version( + "0.10.1", + sha256="9cde04fefa50624bf89068ab793cc2e9437c0cd1c271a41af7d54dbd37c306be", + ) + + depends_on("cmake", type="build") + depends_on("ecbuild", type="build") + + depends_on("eckit+mpi") + depends_on("python@3", type="build") + + def cmake_args(self): + args = [] + + args.append( + self.define( + "PYTHON_EXECUTABLE", self.spec["python"].prefix + "/bin/python3" + ) + ) + + return args diff --git a/spack/packages/fiat/package.py b/spack/packages/fiat/package.py new file mode 100644 index 0000000..1b1cc87 --- /dev/null +++ b/spack/packages/fiat/package.py @@ -0,0 +1,12 @@ +class Fiat(CMakePackage): + git = "https://github.com/ecmwf-ifs/fiat" + url = "https://github.com/ecmwf-ifs/fiat/archive/refs/tags/1.1.2.tar.gz" + + version( + "1.1.2", + sha256="92a0cdbc96831b15ab8a36262a9de972c6606a7dd9245cccebd2448d6846252d", + ) + + depends_on("ecbuild", type="build") + depends_on("fckit") + depends_on("eckit") diff --git a/spack/packages/fms/package.py b/spack/packages/fms/package.py new file mode 100644 index 0000000..8e351b1 --- /dev/null +++ b/spack/packages/fms/package.py @@ -0,0 +1,153 @@ +# Copyright 2013-2023 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 * + + +class Fms(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.""" + + homepage = "https://github.com/NOAA-GFDL/FMS" + url = "https://github.com/NOAA-GFDL/FMS/archive/refs/tags/2022.04.tar.gz" + git = "https://github.com/NOAA-GFDL/FMS.git" + + maintainers("AlexanderRichert-NOAA", "Hang-Lei-NOAA", "edwardhartnett", "rem1776", "climbfuji") + + version("2023.03", sha256="008a9ff394efe6a8adbcf37dd45ca103e00ae25748fc2960b7bc54f2f3b08d85") + version( + "2023.02.01", sha256="1597f7a485d02e401ce76444b2401060d74bd032cbb060cef917f001b4ff14bc" + ) + version("2023.02", sha256="dc029ffadfd82c334f104268bedd8635c77976485f202f0966ae4cf06d2374be") + version( + "2023.01.01", sha256="f83e2814a1e3ba439ab847ec8bb251f3889d5ca14fb20849507590adbbe8e899" + ) + version("2023.01", sha256="6079ea885e9365513b453c77aadfc7c305bf413b840656bb333db1eabba0f18e") + version("2022.04", sha256="f741479128afc2b93ca8291a4c5bcdb024a8cbeda1a26bf77a236c0f629e1b03") + version("2022.03", sha256="42d2ac53d3c889a8177a6d7a132583364c0f6e5d5cbde0d980443b6797ad4838") + version("2022.02", sha256="ad4978302b219e11b883b2f52519e1ee455137ad947474abb316c8654f72c874") + version("2022.01", sha256="a1cba1f536923f5953c28729a28e5431e127b45d6bc2c15d230939f0c02daa9b") + version("2021.04", sha256="dcb4fe80cb3b7846f7cf89b812afff09a78a10261ea048a851f28935d6b241b1") + version( + "2021.03.01", sha256="1f70e2a57f0d01e80fceb9ca9ce9661f5c1565d0437ab67618c2c4dfea0da6e9" + ) + version("2021.03", sha256="a9fb6e85f44ff79e6f9e61e65f42a5ffd38fa661fe1a3e4da6f85ffacd2697ac") + version( + "2021.02.01", sha256="9b11d9474d7c90464af66d81fb86c4798cfa309b9a0da20b0fccf33c4f65386b" + ) + version("2021.02", sha256="db810b2452a6952239f064b52c0c5c58fc62126057982111b9fcd64f1b3bd879") + version("2021.01", sha256="38c748e2edb94ffeb021095d8bde4d74b7834610ce0ef1dbb4dce353eeb5cd96") + version( + "2020.04.02", sha256="bd6ce752b1018d4418398f14b9fc486f217de76bcbaaf2cdbf4c43e0b3f39f69" + ) + version( + "2020.04.01", sha256="2c409242de7dea0cf29f8dbf7495698b6bcac1eeb5c4599a728bdea172ffe37c" + ) + + # https://github.com/NOAA-GFDL/FMS/issues/1417 + patch( + "https://github.com/NOAA-GFDL/FMS/pull/1418/commits/c9bba516ba1115d4a7660fba92f9d67cf3fd32ad.patch?full_index=1", + sha256="f835c54b2898c980a4cc2a9786134af91a8b1e8b1f11b1734227c6dea26c3b79", + when="@2023.03", + ) + + # DH* 20220602 + # These versions were adapated by JCSDA and are only meant to be + # used temporarily, until the JCSDA changes have found their way + # back into the official repository. + # Commit corresponds to branch="release-stable" in the JCSDA public fork + version("release-jcsda", commit="1f739141ef8b000a0bd75ae8bebfadea340299ba") + # version("dev-jcsda", branch="dev/jcsda", no_cache=True) + + with when("@release-jcsda"): + git = "https://github.com/JCSDA/fms.git" + # *DH 20220602 + + variant( + "precision", + values=("32", "64"), + description="Build a version of the library with default 32 or 64 bit reals or both", + default="32", + multi=True, + ) + conflicts( + "precision=32,64", + when="@:2022.03", + msg="FMS versions prior to 2022.04 do not support both 32 and 64 bit precision", + ) + + variant("gfs_phys", default=True, description="Use GFS Physics") + variant("openmp", default=True, description="Use OpenMP") + variant("quad_precision", default=True, description="quad precision reals") + variant( + "yaml", + default=False, + description="yaml input file support(requires libyaml)", + when="@2021.04:", + ) + variant( + "constants", + default="GFDL", + description="Build with constants parameter definitions", + values=("GFDL", "GEOS", "GFS"), + multi=False, + when="@2022.02:", + ) + variant( + "pic", default=False, description="Build with position independent code", when="@2022.02:" + ) + variant( + "deprecated_io", + default=False, + description="Compiles with support for deprecated io modules fms_io and mpp_io", + when="@2023.02:", + ) + + depends_on("netcdf-c") + depends_on("netcdf-fortran") + depends_on("mpi") + depends_on("llvm-openmp", when="+openmp %apple-clang", type=("build", "run")) + depends_on("libyaml", when="+yaml") + + # DH* 20220602 + depends_on("ecbuild", type=("build"), when="@release-jcsda") + depends_on("jedi-cmake", type=("build"), when="@release-jcsda") + # *DH 20220602 + + def cmake_args(self): + args = [ + self.define_from_variant("GFS_PHYS"), + self.define_from_variant("OPENMP"), + self.define_from_variant("ENABLE_QUAD_PRECISION", "quad_precision"), + self.define_from_variant("WITH_YAML", "yaml"), + self.define_from_variant("CONSTANTS"), + self.define("32BIT", "precision=32" in self.spec), + self.define("64BIT", "precision=64" in self.spec), + self.define_from_variant("FPIC", "pic"), + self.define_from_variant("USE_DEPRECATED_IO", "deprecated_io"), + ] + + args.append(self.define("CMAKE_C_COMPILER", self.spec["mpi"].mpicc)) + args.append(self.define("CMAKE_CXX_COMPILER", self.spec["mpi"].mpicxx)) + args.append(self.define("CMAKE_Fortran_COMPILER", self.spec["mpi"].mpifc)) + + fflags = [] + + if self.compiler.name in ["gcc", "clang", "apple-clang"]: + gfortran_major_version = int( + spack.compiler.get_compiler_version_output(self.compiler.fc, "-dumpversion").split( + "." + )[0] + ) + + if gfortran_major_version >= 10: + fflags.append("-fallow-argument-mismatch") + + if fflags: + args.append(self.define("CMAKE_Fortran_FLAGS", " ".join(fflags))) + + return args diff --git a/spack/packages/jedi-cmake/package.py b/spack/packages/jedi-cmake/package.py new file mode 100644 index 0000000..c625cf1 --- /dev/null +++ b/spack/packages/jedi-cmake/package.py @@ -0,0 +1,10 @@ +#!/g/data/hh5/public/apps/miniconda3/envs/analysis3/bin/python +## Scott Wales 2023 + + +class JediCmake(CMakePackage): + git = "https://github.com/jcsda/jedi-cmake" + + version("develop", branch="develop", submodules=True) + + depends_on("ecbuild") diff --git a/spack/packages/odc/cstdint.patch b/spack/packages/odc/cstdint.patch new file mode 100644 index 0000000..16fa519 --- /dev/null +++ b/spack/packages/odc/cstdint.patch @@ -0,0 +1,11 @@ +diff -u a/src/odc/api/StridedData.h b/src/odc/api/StridedData.h +--- a/src/odc/api/StridedData.h 2023-07-17 15:17:41.136669000 +0100 ++++ b/src/odc/api/StridedData.h 2023-07-17 15:18:55.183160000 +0100 +@@ -16,6 +16,7 @@ + #define odc_api_StridedData_H + + #include ++#include + #include + #include + diff --git a/spack/packages/odc/package.py b/spack/packages/odc/package.py new file mode 100644 index 0000000..03a2e5d --- /dev/null +++ b/spack/packages/odc/package.py @@ -0,0 +1,35 @@ +# Copyright 2013-2023 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 * + + +class Odc(CMakePackage): + """ECMWF encoding and decoding of observational data in ODB2 format.""" + + homepage = "https://github.com/ecmwf/odc" + url = "https://github.com/ecmwf/odc/archive/refs/tags/1.3.0.tar.gz" + + maintainers("skosukhin") + + version("1.4.5", sha256="8532d0453531d62e1f15791d1c5c96540b842913bd211a8ef090211eaf4cccae") + version("1.3.0", sha256="97a4f10765b341cc8ccbbf203f5559cb1b838cbd945f48d4cecb1bc4305e6cd6") + + variant("fortran", default=False, description="Enable the Fortran interface") + + depends_on("ecbuild@3.4:", type="build") + depends_on("cmake@3.12:", type="build") + + depends_on("eckit@1.4:+sql") + + patch('cstdint.patch') + + def cmake_args(self): + args = [ + self.define_from_variant("ENABLE_FORTRAN", "fortran"), + # The tests download additional data (~650MB): + self.define("ENABLE_TESTS", self.run_tests), + ] + return args diff --git a/spack/packages/shumlib/package.py b/spack/packages/shumlib/package.py new file mode 100644 index 0000000..dea3dd3 --- /dev/null +++ b/spack/packages/shumlib/package.py @@ -0,0 +1,31 @@ +class Shumlib(MakefilePackage): + homepage = "https://code.metoffice.gov.uk/trac/utils/wiki/shumlib" + parallel = False + + url = "https://github.com/metomi/shumlib/archive/refs/tags/um13.0.tar.gz" + + version( + "um13.0", + sha256="50f43a2f8980e8fbeafd053376612503bcb17c34948297f19b2c95ce0642b340", + url="https://github.com/metomi/shumlib/archive/refs/tags/um13.0.tar.gz", + ) + + def edit(self, spec, prefix): + env["PLATFORM"] = "spack" + env["FPP"] = "cpp" + env[ + "FPPFLAGS" + ] = "-C -P -undef -nostdinc -DEVAL_NAN_BY_BITS -DEVAL_DENORMAL_BY_BITS" + env["FCFLAGS_OPENMP"] = "-fopenmp" + env["FCFLAGS_PIC"] = "-fPIC" + env["FCFLAGS_SHARED"] = "-shared" + env["CCFLAGS_OPENMP"] = "-fopenmp" + env["CCFLAGS_PIC"] = "-fPIC" + env["AR"] = "ar -rc" + + env["DIR_ROOT"] = self.stage.source_path + env["LIBDIR_OUT"] = prefix + env["SHUM_USE_C_OPENMP_VIA_THREAD_UTILS"] = "false" + + def install(self, spec, prefix): + pass