Skip to content

Commit

Permalink
Add the ISSM model and supporting packages (#42)
Browse files Browse the repository at this point in the history
* m1qn3: Add m1qn3 package

This is a Fortran optimisation routine, one of the prerequisites for
ISSM.

* intel-oneapi-mkl: Add gadi-specific component_prefix

This version of intel-oneapi-mkl overrides the component_prefix
property to work with the non-standard paths used on Gadi.

* issm: Add the ISSM ice sheet model

This is a fairly simple configuration of ISSM, but it demonstrates
building with Intel compilers and MKL to bring in the PETSc
dependency.

* #42
  • Loading branch information
angus-g authored Oct 3, 2023
1 parent f9f5591 commit e8cfd24
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
53 changes: 53 additions & 0 deletions packages/issm/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# Copyright 2023 Angus Gibson
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *


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"

version("develop")

depends_on("autoconf", type="build")
depends_on("automake", type="build")
depends_on("libtool", type="build")
depends_on("m4", type="build")

depends_on("mpi")
depends_on("petsc+metis+mumps+scalapack")
depends_on("m1qn3")

def autoreconf(self, spec, prefix):
autoreconf("--install", "--verbose", "--force")

def configure_args(self):
args = [
"--with-wrappers=no",
"--enable-debugging",
"--enable-development",
"--enable-shared",
"--without-kriging",
]
args.append("--with-petsc-dir={0}".format(self.spec["petsc"].prefix))
args.append("--with-metis-dir={0}".format(self.spec["metis"].prefix))
args.append("--with-mumps-dir={0}".format(self.spec["mumps"].prefix))
args.append("--with-m1qn3-dir={0}".format(self.spec["m1qn3"].prefix.lib))

# Even though we set the MPI compilers manually, the build system
# wants us to explicitly request an MPI-enabled build by telling
# it the MPI include directory.
args.append("--with-mpi-include={0}".format(self.spec["mpi"].prefix.include))
args.append("CC=" + self.spec["mpi"].mpicc)
args.append("CXX=" + self.spec["mpi"].mpicxx)
args.append("FC=" + self.spec["mpi"].mpifc)
args.append("F77=" + self.spec["mpi"].mpif77)

return args
13 changes: 13 additions & 0 deletions packages/m1qn3/m1qn3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Reproduced from externalpackages/m1qn3/patch/m1qn3.f.patch
# in ISSM Subversion trunk.
--- src/src/m1qn3.f 2009-10-20 06:39:35.000000000 -0400
+++ m1qn3.f 2021-08-13 14:44:30.276019165 -0400
@@ -802,7 +802,7 @@
& " iter simul stepsize f |g|",
& " |g|/|g0|"
write(io,
- & '(1x,i5,2x,i5,2x,1pd8.2,2x,d21.14,2x,d11.5,2x,d10.4)')
+ & '(1x,i5,2x,i5,2x,1pd9.2,2x,d21.14,2x,d12.5,2x,d11.4)')
& niter, isim, t, f, gnorm, eps1
endif
if (impres.ge.5) write (io,940) eps1
45 changes: 45 additions & 0 deletions packages/m1qn3/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# Copyright 2023 Angus Gibson
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)


from spack.package import *


class M1qn3(MakefilePackage):
"""Minimise functions depending on a very large number of variables."""

homepage = "https://who.rocq.inria.fr/Jean-Charles.Gilbert/modulopt/optimization-routines/m1qn3/m1qn3.html"
url = "https://issm.ess.uci.edu/files/externalpackages/m1qn3-3.3-distrib.tgz"

version("3.3", sha256="27c6a8f56a4080420c25ffb0743e3dece7c57cc1740776936f220b4ed28b89d9")

patch("m1qn3.patch")

def url_for_version(self, version):
url = "https://issm.ess.uci.edu/files/externalpackages/m1qn3-{0}-distrib.tgz"
return url.format(version)

def edit(self, spec, prefix):
with open("Makefile", "w") as f:
f.write(f"""
LIB_EXT=a
FC={spack_fc}
install: libm1qn3.$(LIB_EXT) libddot.$(LIB_EXT)
install -D libm1qn3.$(LIB_EXT) {prefix}/lib/libm1qn3.$(LIB_EXT)
install -D libddot.$(LIB_EXT) {prefix}/lib/libddot.$(LIB_EXT)
OBJECTS=src/m1qn3.o
libm1qn3.$(LIB_EXT): $(OBJECTS)
ar -r $@ $(OBJECTS)
ranlib $@
DDOT_OBJECTS=blas/ddot.o
libddot.$(LIB_EXT): $(DDOT_OBJECTS)
ar -r $@ $(DDOT_OBJECTS)
ranlib $@
%.o: %.f
$(FC) $(FFLAGS) -fPIC -c $< -o $@
""")

15 changes: 15 additions & 0 deletions packages/nci-intel-oneapi-mkl/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# Copyright 2023 Angus Gibson
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.pkg.builtin.intel_oneapi_mkl import IntelOneapiMkl

class NciIntelOneapiMkl(IntelOneapiMkl):
@property
def component_prefix(self):
# we don't need to join the version into the prefix
# on Gadi, because the paths have been rearranged
return self.prefix.join(self.component_dir)

0 comments on commit e8cfd24

Please sign in to comment.