Skip to content

Commit

Permalink
Merging pull request from gsjaardema, see #335 for more information.
Browse files Browse the repository at this point in the history
  • Loading branch information
WardF committed Jan 30, 2017
2 parents 594f50a + 9491ea2 commit 0d2727d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

###
Expand All @@ -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()
Expand All @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
/* Define to 1 if you have the <ctype.h> 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

Expand Down
7 changes: 6 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions libsrc4/nc4file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0d2727d

Please sign in to comment.