-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working draft version of gcom4 package
- Loading branch information
Showing
1 changed file
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other | ||
# Spack Project Developers. See the top-level COPYRIGHT file for details. | ||
# | ||
# Copyright 2024 ACCESS-NRI | ||
# Based on gcom/package.py by scottwales 2023 | ||
# and https://github.com/coecms/access-esm-build-gadi/blob/master/Makefile | ||
# | ||
# SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
|
||
from spack.package import * | ||
|
||
import llnl.util.filesystem as fs | ||
import llnl.util.tty as tty | ||
|
||
|
||
class Gcom4(Package): | ||
""" | ||
GCOM is a wrapper around multiprocessing libraries such as MPI | ||
Gcom4 is a package for older versions of GCOM as used by UM vn7.3 in ACCESS ESM 1.5 | ||
""" | ||
|
||
homepage = "https://code.metoffice.gov.uk/trac/gcom" | ||
git = "[email protected]:ACCESS-NRI/GCOM.git" | ||
|
||
maintainers = ["penguian"] | ||
|
||
version("4.5", branch="dev") | ||
build_directory = join_path("Share", "gcom4.5_access_config") | ||
|
||
variant("mpi", default=True, description="Build with MPI") | ||
|
||
depends_on("fcm", type="build") | ||
depends_on("mpi", when="+mpi") | ||
|
||
|
||
def patch(self): | ||
""" | ||
Perform the equivalent of the following sed commands: | ||
sed -i '/build.target{ns}/d' $@/fcm-make/gcom.cfg | ||
sed -i 's/-openmp/-qopenmp/g' $@/fcm-make/machines/nci_ifort_openmpi.cfg | ||
""" | ||
with fs.working_dir(self.build_directory): | ||
filter_file( | ||
r"build\.target\{ns\}.*", "#", | ||
join_path("fcm-make", "gcom.cfg")) | ||
filter_file( | ||
r"-openmp", "-qopenmp", | ||
join_path("fcm-make", "machines", "nci_ifort_openmpi.cfg")) | ||
|
||
|
||
def install(self, spec, prefix): | ||
|
||
fcm = which("fcm") | ||
if fcm is None: | ||
raise FileNotFoundError("fcm not found in $PATH") | ||
with fs.working_dir(self.build_directory): | ||
|
||
# Set up variables used by fcm-make/gcom.cfg | ||
env["ACTION"] = "preprocess build" | ||
env["DATE"] = "" | ||
env["GCOM_SOURCE"] = "$HERE/.." | ||
env["MIRROR"] = "" | ||
env["REMOTE_ACTION"] = "" | ||
env["ROSE_TASK_MIRROR_TARGET"] = "localhost" | ||
|
||
# Decide on the build variant | ||
if spec.satisfies("%intel"): | ||
mach_c = "ifort" | ||
elif spec.satisfies("%gcc"): | ||
mach_c = "gfortran" | ||
else: | ||
raise NotImplementedError("Unknown compiler") | ||
if "+mpi" in spec: | ||
mach_m = "openmpi" | ||
else: | ||
mach_m = "serial" | ||
|
||
env["GCOM_MACHINE"] = f"nci_{mach_c}_{mach_m}" | ||
|
||
# Do the build with fcm | ||
fcm("make", "-f", join_path("fcm-make", "gcom.cfg")) | ||
|
||
# Install the library | ||
mkdirp(prefix.lib) | ||
install( | ||
join_path("build", "lib", "libgcom.a"), | ||
join_path(prefix.lib, "libgcom.a")) | ||
install_tree(join_path("build", "include"), prefix.include) | ||
|