Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cice5: improve handling of targets and dependencies for ESM1.6 #179

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 74 additions & 50 deletions packages/cice5/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

maintainers = ["harshula"]

version("master", branch="master")
version("master", branch="master", preferred=True)

variant("deterministic", default=False, description="Deterministic build.")
variant("optimisation_report", default=False, description="Generate optimisation reports.")
Expand All @@ -25,45 +25,27 @@
depends_on("mpi")
depends_on("[email protected]:")
depends_on("[email protected]:")
# TODO: For initial verification we are going to use static pio.
# Eventually we plan to move to shared pio
# ~shared requires: https://github.com/spack/spack/pull/34837
depends_on("parallelio~pnetcdf~timing~shared")
depends_on("datetime-fortran")
depends_on("oasis3-mct+deterministic", when="+deterministic")
depends_on("oasis3-mct~deterministic", when="~deterministic")
depends_on("libaccessom2+deterministic", when="+deterministic")
depends_on("libaccessom2~deterministic", when="~deterministic")

phases = ["edit", "build", "install"]

_buildscript = "spack-build.sh"
_buildscript_path = join_path("bld", _buildscript)

# The integer represents environment variable NTASK
__targets = {24: {}, 480: {}, 722: {}, 1682: {}}
__targets[24]["driver"] = "auscom"
__targets[24]["grid"] = "360x300"
__targets[24]["blocks"] = "24x1"

__targets[480]["driver"] = "auscom"
__targets[480]["grid"] = "1440x1080"
__targets[480]["blocks"] = "48x40"

# Comment from bld/config.nci.auscom.3600x2700:
# Recommendations:
# use processor_shape = slenderX1 or slenderX2 in ice_in
# one per processor with distribution_type='cartesian' or
# squarish blocks with distribution_type='rake'
# If BLCKX (BLCKY) does not divide NXGLOB (NYGLOB) evenly, padding
# will be used on the right (top) of the grid.
__targets[722]["driver"] = "auscom"
__targets[722]["grid"] = "3600x2700"
__targets[722]["blocks"] = "90x90"

__targets[1682]["driver"] = "auscom"
__targets[1682]["grid"] = "3600x2700"
__targets[1682]["blocks"] = "200x180"

# These are the default dependencies when building version "master".
# Copied with when() from MOM5 SPR
anton-seaice marked this conversation as resolved.
Show resolved Hide resolved
with when("@:access-esm0,access-esm2:"):
# TODO: For initial verification we are going to use static pio.
# Eventually we plan to move to shared pio
# ~shared requires: https://github.com/spack/spack/pull/34837
depends_on("parallelio~pnetcdf~timing~shared")
depends_on("libaccessom2+deterministic", when="+deterministic")
depends_on("libaccessom2~deterministic", when="~deterministic")

phases = ["set_deps_targets", "edit", "build", "install"]

__buildscript = "spack-build.sh"
__buildscript_path = join_path("bld", __buildscript)

__deps = {"includes": "", "ldflags": ""}
__targets = {}

def url_for_version(self, version):
return "https://github.com/ACCESS-NRI/cice5/tarball/{0}".format(version)
Expand All @@ -86,25 +68,67 @@
"-Wl,-rpath=" + path]
)

def add_target(self, ntask, driver, grid, blocks):
self.__targets[ntask]["driver"] = driver
self.__targets[ntask]["grid"] = grid
self.__targets[ntask]["blocks"] = blocks

def set_deps_targets(self, spec, prefix):

if self.spec.satisfies("@access-esm1.6"):
# The integer represents environment variable NTASK
self.__targets = {12: {}}
self.add_target(12, "access-esm1.6", "360x300", "12x1")

ideps = ["oasis3-mct", "netcdf-fortran"]

# NOTE: The order of the libraries matter during the linking step!
ldeps = ["oasis3-mct", "netcdf-c", "netcdf-fortran"]
lstr = ""

# These are the default settings when building version "master".
else:
# The integer represents environment variable NTASK
self.__targets = {24: {}, 480: {}, 722: {}, 1682: {}}

# TODO: Each of these targets could map to a variant:
self.add_target(24, "auscom", "360x300", "24x1")
self.add_target(480, "auscom", "1440x1080", "48x40")

# Comment from bld/config.nci.auscom.3600x2700:
# Recommendations:
# use processor_shape = slenderX1 or slenderX2 in ice_in
# one per processor with distribution_type='cartesian' or
# squarish blocks with distribution_type='rake'
# If BLCKX (BLCKY) does not divide NXGLOB (NYGLOB) evenly, padding
# will be used on the right (top) of the grid.
self.add_target(722, "auscom", "3600x2700", "90x90")
self.add_target(1682, "auscom", "3600x2700", "200x180")

ideps = ["parallelio", "oasis3-mct", "libaccessom2", "netcdf-fortran"]

# NOTE: The order of the libraries matter during the linking step!
# NOTE: datetime-fortran is a dependency of libaccessom2.
ldeps = ["oasis3-mct", "libaccessom2", "netcdf-c", "netcdf-fortran", "datetime-fortran"]
lstr = self.make_linker_args(spec, "parallelio", "-lpiof -lpioc")

istr = join_path((spec["oasis3-mct"].headers).cpp_flags, "psmile.MPI1")
self.__deps["includes"] = " ".join([istr] + [(spec[d].headers).cpp_flags for d in ideps])

self.__deps["ldflags"] = " ".join([lstr] + [self.get_linker_args(spec, d) for d in ldeps])


def edit(self, spec, prefix):

srcdir = self.stage.source_path
buildscript_dest = join_path(srcdir, self._buildscript_path)
buildscript_dest = join_path(srcdir, self.__buildscript_path)
makeinc_path = join_path(srcdir, "bld", "Macros.spack")

copy(join_path(self.package_dir, self._buildscript), buildscript_dest)
copy(join_path(self.package_dir, self.__buildscript), buildscript_dest)

config = {}

istr = join_path((spec["oasis3-mct"].headers).cpp_flags, "psmile.MPI1")
ideps = ["parallelio", "oasis3-mct", "libaccessom2", "netcdf-fortran"]
incs = " ".join([istr] + [(spec[d].headers).cpp_flags for d in ideps])

lstr = self.make_linker_args(spec, "parallelio", "-lpiof -lpioc")
# NOTE: The order of the libraries matter during the linking step!
# NOTE: datetime-fortran is a dependency of libaccessom2.
ldeps = ["oasis3-mct", "libaccessom2", "netcdf-c", "netcdf-fortran", "datetime-fortran"]
libs = " ".join([lstr] + [self.get_linker_args(spec, d) for d in ldeps])
incs = self.__deps["includes"]
libs = self.__deps["ldflags"]

# TODO: https://github.com/ACCESS-NRI/ACCESS-OM/issues/12
NCI_OPTIM_FLAGS = "-g3 -O2 -axCORE-AVX2 -debug all -check none -traceback -assume buffered_io"
Expand All @@ -131,10 +155,10 @@
FREEFLAGS :=
"""

config["gcc"] = f"""
# TODO: removed -std=f2008 due to compiler errors
FFLAGS = -Wall -fdefault-real-8 -fdefault-double-8 -ffpe-trap=invalid,zero,overflow -fallow-argument-mismatch
"""

Check failure on line 161 in packages/cice5/package.py

View workflow job for this annotation

GitHub Actions / Check syntax

Ruff (F541)

packages/cice5/package.py:158:25: F541 f-string without any placeholders

# module load intel-compiler/2019.5.281
config["intel"] = f"""
Expand Down Expand Up @@ -224,7 +248,7 @@
def build(self, spec, prefix):

build = Executable(
join_path(self.stage.source_path, self._buildscript_path)
join_path(self.stage.source_path, self.__buildscript_path)
)

for k in self.__targets:
Expand Down
Loading