Skip to content
Snippets Groups Projects
Commit a04a28a2 authored by Fabian.Jakub's avatar Fabian.Jakub
Browse files

enhance spack icon-nwp package to allow a build with PETSc and 3D radiation

parent 3c2c2749
No related branches found
No related tags found
1 merge request!5Update readme
......@@ -27,6 +27,8 @@ class IconNwp(Package):
version("psp", branch="icon-nwp/icon-nwp-psp")
variant("lmu", default=False, description="if git.url and submodules should be patched to use the LMU mirrors")
variant("plexrt", default=False, description="add 3D radiation support with TenStream")
variant("petsc", default=False, description="add PETSc support")
# Dependencies
depends_on("mpi")
......@@ -35,6 +37,10 @@ class IconNwp(Package):
depends_on("eccodes+fortran")
depends_on("libxml2")
depends_on("petsc", when="+petsc")
depends_on("petsc", when="+plexrt")
depends_on("tenstream", when="+plexrt")
# Openblas? best way of doing it?
depends_on("openblas", when="%gcc")
depends_on("intel-mkl", when="%intel")
......@@ -162,13 +168,27 @@ class IconNwp(Package):
libs.append("-lyaml")
mtune = "generic"
INCLUDES = f"-I{spec['libxml2'].prefix}/include/libxml2"
INCLUDES = [f"-I{spec['libxml2'].prefix}/include/libxml2", ]
CPPFLAGS = []
if "+plexrt" in self.spec:
CPPFLAGS.append("-DHAVE_PLEXRT")
INCLUDES.append(f"-I{spec['tenstream'].prefix}/include")
libs.append(f"-L{spec['tenstream'].prefix.lib} -ltenstream")
if "+petsc" in self.spec:
CPPFLAGS.append("-DHAVE_PETSC")
INCLUDES.append(f"-I{spec['petsc'].prefix}/include")
libs.append(f"-L{spec['petsc'].prefix.lib} -lpetsc")
options = [
f"CC={spec['mpi'].mpicc}",
f"FC={spec['mpi'].mpifc}",
f"CFLAGS=-g -mpc64 {INCLUDES}",
f"CFLAGS=-g -mpc64 {' '.join(INCLUDES)}",
f"ICON_CFLAGS=-O3 -g -mtune={mtune}",
f"ICON_BUNDLED_CFLAGS=-O3 -mtune={mtune}",
f"CPPFLAGS={' '.join(CPPFLAGS)}",
"FCFLAGS=-std=legacy -fmodule-private -fimplicit-none -fmax-identifier-length=63 -Wall -Wcharacter-truncation -Wconversion -Wunderflow -Wunused-parameter -Wno-surprising -fall-intrinsics -g -mpc64 -w",
"ICON_FCFLAGS=-fbacktrace -fbounds-check -fstack-protector-all -finit-real=nan -finit-integer=-2147483648 -finit-character=127 -w -O2",
f"ICON_OCEAN_FCFLAGS=-O3 -mtune={mtune}",
......
# 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)
from spack.package import *
class Tenstream(CMakePackage):
"""
Recipe to build TenStream radiative transfer lib.
"""
homepage = "https://gitlab.com/jakubfabian/tenstream.git"
git = "https://gitlab.com/jakubfabian/tenstream.git"
version("master", branch="master")
version("next", branch="next")
variant("debug", default=False, description="use debug flags to build")
variant("rayli", default=False, description="download and build with RayLI - MonteCarlo raytracer for unstructured meshes")
# Dependencies
depends_on("mpi")
depends_on("cmake")
depends_on("netcdf-fortran")
depends_on("petsc")
def setup_build_environment(self, env):
spec = self.spec
# Some environment variables to set
env_variables_to_set = {
"CC": spec["mpi"].mpicc,
"CXX": spec["mpi"].mpicxx,
"FC": spec["mpi"].mpifc,
"F77": spec["mpi"].mpif77,
}
for variable, value in env_variables_to_set.items():
env.set(variable, value)
def cmake_args(self):
args = []
if "+debug" in self.spec:
args.append('-DCMAKE_BUILD_TYPE=DEBUG')
if "+rayli" in self.spec:
args.append("-DBUILD_RAYLI=ON")
return args
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment