diff options
author | Houjun Tang <htang4@lbl.gov> | 2022-12-07 13:26:05 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-07 14:26:05 -0700 |
commit | 412bec45aa2457aa181271afbafd912f9551ee20 (patch) | |
tree | d2ecb38e691b2c65abb65be6ee6966bc4c63dd9c | |
parent | c3dcd94ebcdbf1eedd9a595e0fc9361fa07da7b3 (diff) | |
download | spack-412bec45aa2457aa181271afbafd912f9551ee20.tar.gz spack-412bec45aa2457aa181271afbafd912f9551ee20.tar.bz2 spack-412bec45aa2457aa181271afbafd912f9551ee20.tar.xz spack-412bec45aa2457aa181271afbafd912f9551ee20.zip |
SW4: new package (#34252)
* sw4
* use h5z-zfp develop
* update for macos
* Update package.py
Co-authored-by: Houjun Tang <tang@Houjuns-MacBook-Pro.local>
-rw-r--r-- | var/spack/repos/builtin/packages/sw4/package.py | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/sw4/package.py b/var/spack/repos/builtin/packages/sw4/package.py new file mode 100644 index 0000000000..89bb8f56fc --- /dev/null +++ b/var/spack/repos/builtin/packages/sw4/package.py @@ -0,0 +1,75 @@ +# 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) + +import os + +from spack.package import * + + +class Sw4(MakefilePackage): + """This package builds SW4 with MPI, OpenMP, HDF5, FFTW, PROJ, and ZFP.""" + + homepage = "https://github.com/geodynamics/sw4" + git = "https://github.com/geodynamics/sw4.git" + + maintainers = ["houjun", "andersp"] + + version("master", branch="master") + version("developer", branch="developer") + version("3.0-beta2", tag="v3.0-beta2") + + variant("openmp", default=True, description="build with OpenMP") + variant("hdf5", default=True, description="build with HDF5") + variant("proj", default=True, description="build with proj") + variant("zfp", default=True, description="build with ZFP") + variant("fftw", default=True, description="build with FFTW") + + depends_on("mpi") + depends_on("blas") + depends_on("lapack") + depends_on("proj", when="+proj") + depends_on("hdf5+mpi", when="+hdf5") + depends_on("fftw@3.0: +mpi", when="+fftw") + depends_on("zfp", when="+zfp") + depends_on("h5z-zfp@develop", when="+zfp") + depends_on("python") + depends_on("py-h5py") + depends_on("llvm-openmp", when="%apple-clang +openmp") + + def edit(self, spec, prefix): + os.environ["CXX"] = spec["mpi"].mpicxx + os.environ["FC"] = spec["mpi"].mpifc + os.environ["proj"] = "yes" + os.environ["openmp"] = "yes" + os.environ["hdf5"] = "yes" + os.environ["zfp"] = "yes" + os.environ["fftw"] = "yes" + os.environ["SW4ROOT"] = spec["proj"].prefix + os.environ["HDF5ROOT"] = spec["hdf5"].prefix + os.environ["H5ZROOT"] = spec["h5z-zfp"].prefix + os.environ["ZFPROOT"] = spec["zfp"].prefix + os.environ["FFTWHOME"] = spec["fftw"].prefix + os.environ["EXTRA_LINK_FLAGS"] = "-lstdc++ -lm -ldl " + os.environ["EXTRA_LINK_FLAGS"] += spec["blas"].libs.ld_flags + " " + os.environ["EXTRA_LINK_FLAGS"] += spec["blas"].libs.ld_flags + " " + + if "+openmp" in spec: + if spec.satisfies("%apple-clang"): + os.environ["EXTRA_LINK_FLAGS"] += spec["llvm-openmp"].libs.ld_flags + " " + + # From spack/trilinos + if spec.compiler.name in ["clang", "apple-clang", "gcc"]: + fc = Executable(self.compiler.fc) + libgfortran = fc("--print-file-name", "libgfortran." + dso_suffix, output=str).strip() + if libgfortran == "libgfortran." + dso_suffix: + libgfortran = fc("--print-file-name", "libgfortran.a", output=str).strip() + os.environ["EXTRA_LINK_FLAGS"] += " -L{0} -lgfortran ".format( + os.path.dirname(libgfortran) + ) + + def install(self, spec, prefix): + mkdir(prefix.bin) + install("optimize_mp/sw4", prefix.bin) + install_tree("pytest", prefix.test) |