diff --git a/CMakeLists.txt b/CMakeLists.txt index 753df8072a..d4286a5244 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -627,6 +627,9 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4) ENDIF() ENDIF(MSVC) + IF(NOT HDF5_C_LIBRARY) + SET(HDF5_C_LIBRARY hdf5) + ENDIF() ENDIF(HDF5_C_LIBRARY AND HDF5_HL_LIBRARY AND HDF5_INCLUDE_DIR) ### @@ -636,8 +639,8 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4) # Find out if HDF5 was built with parallel support. # Do that by checking for the targets H5Pget_fapl_mpiposx and # H5Pget_fapl_mpio in ${HDF5_LIB}. - CHECK_LIBRARY_EXISTS(hdf5 H5Pget_fapl_mpiposix "" HDF5_IS_PARALLEL_MPIPOSIX) - CHECK_LIBRARY_EXISTS(hdf5 H5Pget_fapl_mpio "" HDF5_IS_PARALLEL_MPIO) + CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pget_fapl_mpiposix "" HDF5_IS_PARALLEL_MPIPOSIX) + CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pget_fapl_mpio "" HDF5_IS_PARALLEL_MPIO) IF(HDF5_IS_PARALLEL_MPIPOSIX OR HDF5_IS_PARALLEL_MPIO) SET(HDF5_PARALLEL ON) ELSE() @@ -653,11 +656,13 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4) SET(USE_PARALLEL_POSIX ON) ENDIF() + #Check to see if HDF5 library has collective metadata APIs, (HDF5 >= 1.10.0) + CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pset_all_coll_metadata_ops "" HDF5_HAS_COLL_METADATA_OPS) + OPTION(ENABLE_DYNAMIC_LOADING "Enable Dynamic Loading" ON) IF(ENABLE_DYNAMIC_LOADING) SET(USE_LIBDL ON CACHE BOOL "") ENDIF() - SET(HDF5_C_LIBRARY hdf5) ENDIF(NOT MSVC) # Make sure the user has built the library with zlib support. diff --git a/config.h.cmake.in b/config.h.cmake.in index 8d6708a39b..c7b3f5c774 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -60,6 +60,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_CTYPE_H 1 +/* Define to 1 if you have hdf5_coll_metadata_ops */ +#cmakedefine HDF5_HAS_COLL_METADATA_OPS 1 + /* Is CURLINFO_RESPONSE_CODE defined */ #cmakedefine HAVE_CURLINFO_RESPONSE_CODE 1 diff --git a/configure.ac b/configure.ac index e768313022..d51dde38cb 100644 --- a/configure.ac +++ b/configure.ac @@ -924,7 +924,7 @@ if test "x$enable_netcdf_4" = xyes; then [AC_MSG_ERROR([Can't find or link to the hdf5 high-level. Use --disable-netcdf-4, or see config.log for errors.])]) AC_CHECK_HEADERS([hdf5.h], [], [AC_MSG_ERROR([Compiling a test with HDF5 failed. Either hdf5.h cannot be found, or config.log should be checked for other reason.])]) - AC_CHECK_FUNCS([H5Pget_fapl_mpiposix H5Pget_fapl_mpio H5Pset_deflate H5Z_SZIP H5free_memory H5Pset_libver_bounds]) + AC_CHECK_FUNCS([H5Pget_fapl_mpiposix H5Pget_fapl_mpio H5Pset_deflate H5Z_SZIP H5free_memory H5Pset_libver_bounds H5Pset_all_coll_metadata_ops]) # The user may have parallel HDF5 based on MPI POSIX. if test "x$ac_cv_func_H5Pget_fapl_mpiposix" = xyes; then @@ -936,6 +936,11 @@ if test "x$enable_netcdf_4" = xyes; then AC_DEFINE([USE_PARALLEL_MPIO], [1], [if true, compile in parallel netCDF-4 based on MPI/IO]) fi + # Check to see if HDF5 library has collective metadata APIs, (HDF5 >= 1.10.0) + if test "x$ac_cv_func_H5Pset_all_coll_metadata_ops" = xyes; then + AC_DEFINE([HDF5_HAS_COLL_METADATA_OPS], [1], [if true, use collective metadata ops in parallel netCDF-4]) + fi + # If parallel is available in hdf5, enable it in the C code. Also add some stuff to netcdf.h. hdf5_parallel=no if test "x$ac_cv_func_H5Pget_fapl_mpio" = xyes -o "x$ac_cv_func_H5Pget_fapl_mpiposix" = xyes; then diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index 5ae72fdecb..f1ac3460d8 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -446,6 +446,11 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info, BAIL(NC_EHDFERR); /* Create the file. */ +#ifdef HDF5_HAS_COLL_METADATA_OPS + H5Pset_all_coll_metadata_ops(fapl_id, 1 ); + H5Pset_coll_metadata_write(fapl_id, 1); +#endif + if ((nc4_info->hdfid = H5Fcreate(path, flags, fcpl_id, fapl_id)) < 0) /*Change the return error from NC_EFILEMETADATA to System error EACCES because that is the more likely problem */ @@ -2315,6 +2320,9 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc) /* The NetCDF-3.x prototype contains an mode option NC_SHARE for multiple processes accessing the dataset concurrently. As there is no HDF5 equivalent, NC_SHARE is treated as NC_NOWRITE. */ +#ifdef HDF5_HAS_COLL_METADATA_OPS + H5Pset_all_coll_metadata_ops(fapl_id, 1 ); +#endif if(inmemory) { if((nc4_info->hdfid = H5LTopen_file_image(meminfo->memory,meminfo->size, H5LT_FILE_IMAGE_DONT_COPY|H5LT_FILE_IMAGE_DONT_RELEASE