Skip to content

Commit

Permalink
netcdf-{c,fortran}: add parallel testing variants (#521)
Browse files Browse the repository at this point in the history
This PR adds a variant for enabling parallel testing for netcdf-c and netcdf-fortran. Note that it is disregarded if build-time tests are not being run anyway. The run_after()'s are related to spack#49200.
  • Loading branch information
AlexanderRichert-NOAA authored Feb 27, 2025
1 parent 0978cb9 commit cefeafe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
7 changes: 7 additions & 0 deletions var/spack/repos/builtin/packages/netcdf-c/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ class NetcdfC(CMakePackage, AutotoolsPackage):
variant("szip", default=True, description="Enable Szip compression plugin")
variant("blosc", default=True, description="Enable Blosc compression plugin")
variant("zstd", default=True, description="Enable Zstandard compression plugin")
# JCSDA fork only:
variant("parallel_tests", default=False, description="Run parallel tests", when="+mpi")

with when("build_system=cmake"):
# Based on the versions required by the root CMakeLists.txt:
Expand Down Expand Up @@ -398,6 +400,10 @@ def configure_args(self):
"--enable-netcdf-4",
]

# JCSDA fork only:
if self.spec.satisfies("+parallel_tests") and self.pkg.run_tests:
config_args.append("--enable-parallel-tests")

# NCZarr was added in version 4.8.0 as an experimental feature and became a supported one
# in version 4.8.1:
if self.spec.satisfies("@4.8.1:"):
Expand Down Expand Up @@ -556,6 +562,7 @@ def configure_args(self):
# It looks like the issues with running the tests in parallel were fixed around version 4.6.0
# (see https://github.com/Unidata/netcdf-c/commit/812c2fd4d108cca927582c0d84049c0f271bb9e0):
@when("@:4.5.0")
@run_after("install")
def check(self):
# h5_test fails when run in parallel
make("check", parallel=False)
17 changes: 11 additions & 6 deletions var/spack/repos/builtin/packages/netcdf-fortran/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class NetcdfFortran(AutotoolsPackage):
variant("pic", default=True, description="Produce position-independent code (for shared libs)")
variant("shared", default=True, description="Enable shared library")
variant("doc", default=False, description="Enable building docs")
# JCSDA fork only:
variant("parallel_tests", default=False, description="Enable parallel tests")

depends_on("netcdf-c")
depends_on("netcdf-c@4.7.4:", when="@4.5.3:") # nc_def_var_szip required
Expand Down Expand Up @@ -130,12 +132,14 @@ def configure_args(self):

netcdf_c_spec = self.spec["netcdf-c"]
if "+mpi" in netcdf_c_spec or "+parallel-netcdf" in netcdf_c_spec:
# Prefixing with 'mpiexec -n 4' is not necessarily the correct way
# to launch MPI programs on a particular machine (e.g. 'srun -n 4'
# with additional arguments might be the right one). Therefore, we
# make sure the parallel tests are not launched at all (although it
# is the default behaviour currently):
config_args.append("--disable-parallel-tests")
# JCSDA fork only:
if self.spec.satisfies("+parallel_tests") and self.run_tests:
config_args.append("--enable-parallel-tests")
config_args.append("CC=%s" % self.spec["mpi"].mpicc)
config_args.append("FC=%s" % self.spec["mpi"].mpifc)
config_args.append("F77=%s" % self.spec["mpi"].mpifc)
else:
config_args.append("--disable-parallel-tests")
if self.spec.satisfies("@4.5.0:4.5.2"):
# Versions from 4.5.0 to 4.5.2 check whether the Fortran MPI
# interface is available and fail the configuration if it is
Expand All @@ -153,6 +157,7 @@ def configure_args(self):

return config_args

@run_after("install")
def check(self):
make("check", parallel=self.spec.satisfies("@4.5:"))

Expand Down

0 comments on commit cefeafe

Please sign in to comment.