From 70a3868168e8eb71fd7a4e7201fc5dff9cbbba81 Mon Sep 17 00:00:00 2001 From: Sergey Kosukhin Date: Thu, 6 Oct 2022 16:20:55 +0200 Subject: ncl: enable building with recent versions of hdf5 (#32842) --- var/spack/repos/builtin/packages/ncl/package.py | 28 ++++++++++++++------ .../builtin/packages/ncl/set_spack_config.patch | 12 +++++++++ .../repos/builtin/packages/ncl/spack_ncl.patch | 30 ---------------------- 3 files changed, 32 insertions(+), 38 deletions(-) create mode 100644 var/spack/repos/builtin/packages/ncl/set_spack_config.patch delete mode 100644 var/spack/repos/builtin/packages/ncl/spack_ncl.patch (limited to 'var') diff --git a/var/spack/repos/builtin/packages/ncl/package.py b/var/spack/repos/builtin/packages/ncl/package.py index c9f160c455..66fd442485 100644 --- a/var/spack/repos/builtin/packages/ncl/package.py +++ b/var/spack/repos/builtin/packages/ncl/package.py @@ -26,12 +26,19 @@ class Ncl(Package): patch("for_aarch64.patch", when="target=aarch64:") - patch("spack_ncl.patch") + # Use Spack config file, which we generate during the installation: + patch("set_spack_config.patch") # Make ncl compile with hdf5 1.10 (upstream as of 6.5.0) patch("hdf5.patch", when="@6.4.0") # ymake-filter's buffer may overflow (upstream as of 6.5.0) patch("ymake-filter.patch", when="@6.4.0") # ymake additional local library and includes will be filtered improperly + # WARNING: it is tempting to replace '-Dlinux=linux -Dx86_64=x86_64' with '-Ulinux -Ux86_64' + # to get rid of 'error: detected recursion whilst expanding macro "linux"' but that breaks + # the building because the Makefile generation logic depends on whether those macros are + # defined. Also, the errors can be ignored since "GCC detects when it is expanding recursive + # macros, emits an error message, and *continues* after the offending macro invocation" + # (see https://gcc.gnu.org/onlinedocs/cpp/Traditional-macros.html#Traditional-macros). patch("ymake.patch", when="@6.4.0:") # ncl does not build with gcc@10: # https://github.com/NCAR/ncl/issues/123 @@ -83,14 +90,13 @@ class Ncl(Package): # support for netcdf-4, but the script assumes that hdf5 is compiled with # szip support. We introduce this restriction with the following dependency # statement. - depends_on("hdf5@:1.10+szip") + depends_on("hdf5+szip") depends_on("szip") # ESMF is only required at runtime (for ESMF_regridding.ncl) - depends_on("esmf", type="run") - - # In Spack, we also do not have an option to compile netcdf-c without DAP - # support, so we will tell the ncl configuration script that we have it. + # There might be more requirements to ESMF but at least the NetCDF support is required to run + # the examples (see https://www.ncl.ucar.edu/Applications/ESMF.shtml) + depends_on("esmf+netcdf", type="run") # Some of the optional dependencies according to the manual: depends_on("hdf", when="+hdf4") @@ -138,6 +144,7 @@ class Ncl(Package): def setup_run_environment(self, env): env.set("NCARG_ROOT", self.spec.prefix) + env.set("ESMFBINDIR", self.spec["esmf"].prefix.bin) def prepare_site_config(self): fc_flags = [] @@ -148,12 +155,17 @@ class Ncl(Package): fc_flags.append(self.compiler.openmp_flag) cc_flags.append(self.compiler.openmp_flag) + if self.spec.satisfies("^hdf5@1.11:"): + cc_flags.append("-DH5_USE_110_API") + if self.compiler.name == "gcc": fc_flags.append("-fno-range-check") c2f_flags.extend(["-lgfortran", "-lm"]) elif self.compiler.name == "intel": fc_flags.append("-fp-model precise") - cc_flags.append("-fp-model precise" " -std=c99" " -D_POSIX_C_SOURCE=2 -D_GNU_SOURCE") + cc_flags.extend( + ["-fp-model precise", "-std=c99", "-D_POSIX_C_SOURCE=2", "-D_GNU_SOURCE"] + ) c2f_flags.extend(["-lifcore", "-lifport"]) if self.spec.satisfies("%gcc@10:"): @@ -238,7 +250,7 @@ class Ncl(Package): # If you are using NetCDF V4.x, did you enable NetCDF-4 support? "y\n", # Did you build NetCDF with OPeNDAP support? - "y\n", + "y\n" if self.spec.satisfies("^netcdf-c+dap") else "n\n", # Build GDAL support (optional) into NCL? "y\n" if "+gdal" in self.spec else "n\n", # Build EEMD support (optional) into NCL? diff --git a/var/spack/repos/builtin/packages/ncl/set_spack_config.patch b/var/spack/repos/builtin/packages/ncl/set_spack_config.patch new file mode 100644 index 0000000000..305a93916e --- /dev/null +++ b/var/spack/repos/builtin/packages/ncl/set_spack_config.patch @@ -0,0 +1,12 @@ +--- a/config/ymake ++++ b/config/ymake +@@ -535,6 +535,9 @@ default: + breaksw + endsw + ++# We want to have our own definitions for spack ++set sysincs = Spack ++ + if ($?sysincs == 0) then + echo "$0 : Unknown System Type - No Config file" > /dev/tty + exit 1 diff --git a/var/spack/repos/builtin/packages/ncl/spack_ncl.patch b/var/spack/repos/builtin/packages/ncl/spack_ncl.patch deleted file mode 100644 index ebbecc43ba..0000000000 --- a/var/spack/repos/builtin/packages/ncl/spack_ncl.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/config/ymake 2015-03-16 22:21:42.000000000 +0100 -+++ b/config/ymake 2016-10-14 13:44:49.530646098 +0200 -@@ -537,0 +538,3 @@ -+# We want to have our own definitions for spack -+set sysincs = Spack -+ ---- a/Configure 2015-03-16 22:22:17.000000000 +0100 -+++ b/Configure 2016-10-14 13:49:42.157631106 +0200 -@@ -1137,5 +1137,13 @@ -- if (! -d $incs[1]) then -- echo " *** Warning: <$incs[1]> does not exist" -- echo "" -- goto proc_locincdir -- else -+ -+ # We don't want our path(s) to be preprocessed by cpp -+ # inside ymake script. That is why we pass them in quotes (') -+ # to this script. But if we do so, the following condition -+ # is always false. That is why we comment it out and promise -+ # to pass only correct path(s). You might want to do the same -+ # thing for the libraries search path(s). -+ -+ # if (! -d $incs[1]) then -+ # echo " *** Warning: <$incs[1]> does not exist" -+ # echo "" -+ # goto proc_locincdir -+ # else -@@ -1143 +1151 @@ -- endif -+ # endif -- cgit v1.2.3-70-g09d2