From 27a971f44c9103917a62096b6cc8243591fb8d1b Mon Sep 17 00:00:00 2001 From: Aidan Heerdegen Date: Tue, 20 Dec 2022 15:40:09 +1100 Subject: [PATCH 1/3] Add MOM5 CMake package --- packages/mom5/package.py | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 packages/mom5/package.py diff --git a/packages/mom5/package.py b/packages/mom5/package.py new file mode 100644 index 0000000..26a27e3 --- /dev/null +++ b/packages/mom5/package.py @@ -0,0 +1,70 @@ +# Copyright 2013-2022 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) + +# ---------------------------------------------------------------------------- +# If you submit this package back to Spack as a pull request, +# please first remove this boilerplate and all FIXME comments. +# +# This is a template package file for Spack. We've put "FIXME" +# next to all the things you'll want to change. Once you've handled +# them, you can save this file and test your package like this: +# +# spack install mom5-git +# +# You can edit this file again by typing: +# +# spack edit mom5-git +# +# See the Spack documentation for more information on packaging. +# ---------------------------------------------------------------------------- + +from spack.package import * +from spack.util.executable import which + +class Mom5Git(CMakePackage): + """FIXME: Put a proper description of your package here.""" + + # FIXME: Add a proper url for your package's homepage here. + homepage = "https://mom-ocean.github.io" + git = "https://github.com/ACCESS-NRI/MOM5.git" + + # FIXME: Add a list of GitHub accounts to + # notify when the package is updated. + # maintainers = ['github_user1', 'github_user2'] + + variant("netcdf", default=True, description="enable netcdf interface") + + # FIXME: Add dependencies if required. + depends_on("mpi") + depends_on("netcdf-c", type="link", when="+netcdf") + depends_on("netcdf-fortran", type="link", when="+netcdf") + + root_cmakelists_dir = 'cmake' + + def patch(self): + + # Get the commit hash + git_exe = which('git') + commit = git_exe("rev-parse", "--short", "HEAD", output=str).strip() + + # Write commit into version file + version_file = 'src/version/version.F90' + + copy(version_file+'.template', version_file) + filter_file('{MOM_COMMIT_HASH}', commit, version_file, string=True) + + def cmake_args(self): + define = self.define + define_from_variant = self.define_from_variant + spec = self.spec + env["CC"] = spec["mpi"].mpicc + env["FC"] = spec["mpi"].mpifc + args = [ + define("CPPFLAGS", "-Duse_netCDF=1 -Duse_libMPI=1 -DLAND_BND_TRACERS=1 -DUSE_OCEAN_BGC=1 -DENABLE_ODA=1 -DSPMD=1") + ] + + return args + + From c709287de3aef6e2966c820efbdb24cb23ce45f4 Mon Sep 17 00:00:00 2001 From: Aidan Heerdegen Date: Tue, 20 Dec 2022 15:48:32 +1100 Subject: [PATCH 2/3] Remove boilerplate and rename class --- packages/mom5/package.py | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/packages/mom5/package.py b/packages/mom5/package.py index 26a27e3..51ac45d 100644 --- a/packages/mom5/package.py +++ b/packages/mom5/package.py @@ -3,30 +3,12 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -# ---------------------------------------------------------------------------- -# If you submit this package back to Spack as a pull request, -# please first remove this boilerplate and all FIXME comments. -# -# This is a template package file for Spack. We've put "FIXME" -# next to all the things you'll want to change. Once you've handled -# them, you can save this file and test your package like this: -# -# spack install mom5-git -# -# You can edit this file again by typing: -# -# spack edit mom5-git -# -# See the Spack documentation for more information on packaging. -# ---------------------------------------------------------------------------- - from spack.package import * from spack.util.executable import which -class Mom5Git(CMakePackage): +class Mom5(CMakePackage): """FIXME: Put a proper description of your package here.""" - # FIXME: Add a proper url for your package's homepage here. homepage = "https://mom-ocean.github.io" git = "https://github.com/ACCESS-NRI/MOM5.git" @@ -36,7 +18,6 @@ class Mom5Git(CMakePackage): variant("netcdf", default=True, description="enable netcdf interface") - # FIXME: Add dependencies if required. depends_on("mpi") depends_on("netcdf-c", type="link", when="+netcdf") depends_on("netcdf-fortran", type="link", when="+netcdf") From 242ddfd8651403fcf0781a2a404ce5d3e1843e94 Mon Sep 17 00:00:00 2001 From: Aidan Heerdegen Date: Mon, 30 Jan 2023 13:03:18 +1100 Subject: [PATCH 3/3] Added harded-coded version with git code access --- packages/mom5/package.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/mom5/package.py b/packages/mom5/package.py index 51ac45d..c0e40aa 100644 --- a/packages/mom5/package.py +++ b/packages/mom5/package.py @@ -12,6 +12,8 @@ class Mom5(CMakePackage): homepage = "https://mom-ocean.github.io" git = "https://github.com/ACCESS-NRI/MOM5.git" + version("5.1", git=git) + # FIXME: Add a list of GitHub accounts to # notify when the package is updated. # maintainers = ['github_user1', 'github_user2']