Skip to content

Commit 971b6d6

Browse files
authored
Merge pull request #21 from climbfuji/feature/esmf891_netcdf_cmpi
Add [email protected] + bug fix for netcdf-c to find MPI functions when build system is cmake (replaces #18)
2 parents bfc5556 + 8468567 commit 971b6d6

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

repos/spack_repo/builtin/packages/esmf/package.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class Esmf(MakefilePackage, PythonExtension):
3131
# Develop is a special name for spack and is always considered the newest version
3232
version("develop", branch="develop")
3333
# generate chksum with 'spack checksum [email protected]'
34+
# Todo: replace commit with hash once tagged
35+
version("8.9.1", commit="6a091126030012504e2d42a21eb8764066f0bb6a")
3436
version("8.9.0", sha256="586e0101d76ff9842d9ad43567fae50317ee794d80293430d9f1847dec0eefa5")
3537
version("8.8.1", sha256="b0acb59d4f000bfbdfddc121a24819bd2a50997c7b257b0db2ceb96f3111b173")
3638
version("8.8.0", sha256="f89327428aeef6ad34660b5b78f30d1c55ec67efb8f7df1991fdaa6b1eb3a27c")
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- a/CMakeLists.txt
2+
+++ b/CMakeLists.txt
3+
@@ -1911,8 +1911,11 @@
4+
CHECK_FUNCTION_EXISTS(mktemp HAVE_MKTEMP)
5+
CHECK_FUNCTION_EXISTS(random HAVE_RANDOM)
6+
CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
7+
-CHECK_FUNCTION_EXISTS(MPI_Comm_f2c HAVE_MPI_COMM_F2C)
8+
-CHECK_FUNCTION_EXISTS(MPI_Info_f2c HAVE_MPI_INFO_F2C)
9+
+if(MPI_C_COMPILER_INCLUDE_DIRS)
10+
+ set (CMAKE_REQUIRED_INCLUDES "${MPI_C_COMPILER_INCLUDE_DIRS}")
11+
+endif()
12+
+CHECK_SYMBOL_EXISTS(MPI_Comm_f2c "mpi.h" HAVE_MPI_COMM_F2C)
13+
+CHECK_SYMBOL_EXISTS(MPI_Info_f2c "mpi.h" HAVE_MPI_INFO_F2C)
14+
CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
15+
CHECK_FUNCTION_EXISTS(getpagesize HAVE_GETPAGESIZE)
16+
CHECK_FUNCTION_EXISTS(sysconf HAVE_SYSCONF)

repos/spack_repo/builtin/packages/netcdf_c/package.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,20 @@ class NetcdfC(CMakePackage, AutotoolsPackage):
124124
when="@4.9.0:4.9.2",
125125
)
126126

127+
# https://github.com/Unidata/netcdf-c/issues/3199
128+
patch("cmakelists_mpi_symbols.patch", when="build_system=cmake")
129+
130+
def patch(self):
131+
"""Fix bad code in ncgen/CMakeLists.txt that removes
132+
the rpath for dependencies like hdf5."""
133+
if self.spec.satisfies("build_system=cmake"):
134+
filter_file(
135+
"SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)",
136+
"#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)",
137+
"ncgen/CMakeLists.txt",
138+
string=True,
139+
)
140+
127141
variant("mpi", default=True, description="Enable parallel I/O for netcdf-4")
128142
variant("parallel-netcdf", default=False, description="Enable parallel I/O for classic files")
129143
variant("hdf4", default=False, description="Enable HDF4 support")
@@ -288,16 +302,6 @@ class NetcdfC(CMakePackage, AutotoolsPackage):
288302

289303
build_system("cmake", "autotools", default=default_build_system)
290304

291-
def patch(self):
292-
"""Fix bad code in ncgen/CMakeLists.txt that removes
293-
the rpath for dependencies like hdf5."""
294-
filter_file(
295-
"SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)",
296-
"#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)",
297-
"ncgen/CMakeLists.txt",
298-
string=True
299-
)
300-
301305
def setup_run_environment(self, env: EnvironmentModifications) -> None:
302306
if self.spec.satisfies("@4.9.0:+shared"):
303307
# Both HDF5 and NCZarr backends honor the same environment variable:
@@ -358,6 +362,8 @@ def cmake_args(self):
358362
self.define("ENABLE_LARGE_FILE_SUPPORT", True),
359363
self.define_from_variant("NETCDF_ENABLE_LOGGING", "logging"),
360364
]
365+
if any(self.spec.satisfies(s) for s in ["+mpi", "+parallel-netcdf", "^hdf5+mpi~shared"]):
366+
base_cmake_args.append(self.define("CMAKE_C_COMPILER", self.spec["mpi"].mpicc))
361367
if "+parallel-netcdf" in self.pkg.spec:
362368
base_cmake_args.append(self.define("ENABLE_PNETCDF", True))
363369
if self.pkg.spec.satisfies("@4.3.1:"):

0 commit comments

Comments
 (0)