From 131d8d37374814c5fbf0eaed945cf174bca385c4 Mon Sep 17 00:00:00 2001 From: Steven Hahn Date: Wed, 30 Nov 2022 15:56:38 -0500 Subject: [PATCH 1/5] Set H5_USE_18_API Signed-off-by: Steven Hahn --- CMakeLists.txt | 2 +- src/QMCHamiltonians/SkEstimator.cpp | 3 ++- .../PlaneWave/PWParameterSet.cpp | 4 ++-- src/io/hdf/hdf_stl.h | 12 +++++----- src/io/hdf/hdf_wrapper_functions.h | 24 +++++++++---------- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c49e519256..72b5aa5eb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -694,7 +694,7 @@ if(HDF5_FOUND) add_library(IO::HDF5 INTERFACE IMPORTED) target_include_directories(IO::HDF5 INTERFACE "${HDF5_INCLUDE_DIR}") - target_compile_definitions(IO::HDF5 INTERFACE "H5_USE_16_API") + target_compile_definitions(IO::HDF5 INTERFACE "H5_USE_18_API") target_link_libraries(IO::HDF5 INTERFACE "${HDF5_LIBRARIES}") if(ENABLE_PHDF5) target_compile_definitions(IO::HDF5 INTERFACE "ENABLE_PHDF5") diff --git a/src/QMCHamiltonians/SkEstimator.cpp b/src/QMCHamiltonians/SkEstimator.cpp index a3a37cb6d1..f93f05aa69 100644 --- a/src/QMCHamiltonians/SkEstimator.cpp +++ b/src/QMCHamiltonians/SkEstimator.cpp @@ -128,7 +128,8 @@ void SkEstimator::registerCollectables(std::vector& h5desc, hd kdims[1] = OHMMS_DIM; std::string kpath = name_ + "/kpoints"; hid_t k_space = H5Screate_simple(2, kdims, NULL); - hid_t k_set = H5Dcreate(file.getFileID(), kpath.c_str(), H5T_NATIVE_DOUBLE, k_space, H5P_DEFAULT); + hid_t k_set = + H5Dcreate(file.getFileID(), kpath.c_str(), H5T_NATIVE_DOUBLE, k_space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); hid_t mem_space = H5Screate_simple(2, kdims, NULL); auto* ptr = &(sourcePtcl->getSimulationCell().getKLists().kpts_cart[0][0]); herr_t ret = H5Dwrite(k_set, H5T_NATIVE_DOUBLE, mem_space, k_space, H5P_DEFAULT, ptr); diff --git a/src/QMCWaveFunctions/PlaneWave/PWParameterSet.cpp b/src/QMCWaveFunctions/PlaneWave/PWParameterSet.cpp index 83362c429b..6c769eb069 100644 --- a/src/QMCWaveFunctions/PlaneWave/PWParameterSet.cpp +++ b/src/QMCWaveFunctions/PlaneWave/PWParameterSet.cpp @@ -76,7 +76,7 @@ bool PWParameterSet::getEigVectorType(hid_t h) oss << "/" << spinTag << 0; oss << "/eigenvector"; hsize_t dimTot[4]; - hid_t dataset = H5Dopen(h, oss.str().c_str()); + hid_t dataset = H5Dopen(h, oss.str().c_str(), H5P_DEFAULT); hid_t dataspace = H5Dget_space(dataset); rank = H5Sget_simple_extent_ndims(dataspace); int status_n = H5Sget_simple_extent_dims(dataspace, dimTot, NULL); @@ -184,7 +184,7 @@ void PWParameterSet::checkVersion(hdf_archive& h) { if (is_manager()) { - hid_t dataset = H5Dopen(h.getFileID(), "version"); + hid_t dataset = H5Dopen(h.getFileID(), "version", H5P_DEFAULT); hid_t datatype = H5Dget_type(dataset); H5T_class_t classtype = H5Tget_class(datatype); H5Tclose(datatype); diff --git a/src/io/hdf/hdf_stl.h b/src/io/hdf/hdf_stl.h index f23109db5a..a6366bc2a3 100644 --- a/src/io/hdf/hdf_stl.h +++ b/src/io/hdf/hdf_stl.h @@ -96,7 +96,7 @@ struct h5data_proxy inline bool read(data_type& ref, hid_t grp, const std::string& aname, hid_t xfer_plist = H5P_DEFAULT) { - hid_t dataset = H5Dopen(grp, aname.c_str()); + hid_t dataset = H5Dopen(grp, aname.c_str(), H5P_DEFAULT); if (dataset > -1) { hid_t datatype = H5Dget_type(dataset); @@ -127,11 +127,11 @@ struct h5data_proxy hsize_t dim = 1; herr_t ret = -1; - hid_t h1 = H5Dopen(grp, aname.c_str()); + hid_t h1 = H5Dopen(grp, aname.c_str(), H5P_DEFAULT); if (h1 < 0) // missing create one { hid_t dataspace = H5Screate_simple(1, &dim, NULL); - hid_t dataset = H5Dcreate(grp, aname.c_str(), str80, dataspace, H5P_DEFAULT); + hid_t dataset = H5Dcreate(grp, aname.c_str(), str80, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); ret = H5Dwrite(dataset, str80, H5S_ALL, H5S_ALL, xfer_plist, ref.data()); H5Sclose(dataspace); H5Dclose(dataset); @@ -157,7 +157,7 @@ struct h5data_proxy> { hid_t datatype = H5Tcopy(H5T_C_S1); H5Tset_size(datatype, H5T_VARIABLE); - hid_t dataset = H5Dopen(grp, aname.c_str()); + hid_t dataset = H5Dopen(grp, aname.c_str(), H5P_DEFAULT); std::vector char_list; herr_t ret = -1; if (dataset > -1) @@ -198,12 +198,12 @@ struct h5data_proxy> for (int i = 0; i < ref.size(); i++) char_list.push_back(ref[i].data()); - hid_t h1 = H5Dopen(grp, aname.c_str()); + hid_t h1 = H5Dopen(grp, aname.c_str(), H5P_DEFAULT); herr_t ret = -1; if (h1 < 0) // missing create one { hid_t dataspace = H5Screate_simple(1, &dim, NULL); - hid_t dataset = H5Dcreate(grp, aname.c_str(), datatype, dataspace, H5P_DEFAULT); + hid_t dataset = H5Dcreate(grp, aname.c_str(), datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); ret = H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, xfer_plist, char_list.data()); H5Sclose(dataspace); H5Dclose(dataset); diff --git a/src/io/hdf/hdf_wrapper_functions.h b/src/io/hdf/hdf_wrapper_functions.h index 957e89bcd5..5421d3ef9e 100644 --- a/src/io/hdf/hdf_wrapper_functions.h +++ b/src/io/hdf/hdf_wrapper_functions.h @@ -47,7 +47,7 @@ inline bool getDataShape(hid_t grp, const std::string& aname, std::vector& s using TSpaceType = h5_space_type; TSpaceType TSpace; - hid_t h1 = H5Dopen(grp, aname.c_str()); + hid_t h1 = H5Dopen(grp, aname.c_str(), H5P_DEFAULT); hid_t dataspace = H5Dget_space(h1); int rank = H5Sget_simple_extent_ndims(dataspace); @@ -124,7 +124,7 @@ inline bool h5d_read(hid_t grp, const std::string& aname, T* first, hid_t xfer_p { if (grp < 0) return true; - hid_t h1 = H5Dopen(grp, aname.c_str()); + hid_t h1 = H5Dopen(grp, aname.c_str(), H5P_DEFAULT); if (h1 < 0) return false; hid_t h5d_type_id = get_h5_datatype(*first); @@ -144,12 +144,12 @@ inline bool h5d_write(hid_t grp, if (grp < 0) return true; hid_t h5d_type_id = get_h5_datatype(*first); - hid_t h1 = H5Dopen(grp, aname.c_str()); + hid_t h1 = H5Dopen(grp, aname.c_str(), H5P_DEFAULT); herr_t ret = -1; if (h1 < 0) //missing create one { hid_t dataspace = H5Screate_simple(ndims, dims, NULL); - hid_t dataset = H5Dcreate(grp, aname.c_str(), h5d_type_id, dataspace, H5P_DEFAULT); + hid_t dataset = H5Dcreate(grp, aname.c_str(), h5d_type_id, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); ret = H5Dwrite(dataset, h5d_type_id, H5S_ALL, H5S_ALL, xfer_plist, first); H5Sclose(dataspace); H5Dclose(dataset); @@ -180,7 +180,7 @@ bool h5d_read(hid_t grp, { if (grp < 0) return true; - hid_t h1 = H5Dopen(grp, aname.c_str()); + hid_t h1 = H5Dopen(grp, aname.c_str(), H5P_DEFAULT); if (h1 < 0) return false; //herr_t ret = H5Dread(h1, h5d_type_id, H5S_ALL, H5S_ALL, xfer_plist, first); @@ -223,7 +223,7 @@ inline bool h5d_write(hid_t grp, if (grp < 0) return true; hid_t h5d_type_id = get_h5_datatype(*first); - hid_t h1 = H5Dopen(grp, aname.c_str()); + hid_t h1 = H5Dopen(grp, aname.c_str(), H5P_DEFAULT); hid_t filespace, memspace; herr_t ret = -1; @@ -231,7 +231,7 @@ inline bool h5d_write(hid_t grp, if (h1 < 0) //missing create one { hid_t dataspace = H5Screate_simple(ndims, gcounts, NULL); - hid_t dataset = H5Dcreate(grp, aname.c_str(), h5d_type_id, dataspace, H5P_DEFAULT); + hid_t dataset = H5Dcreate(grp, aname.c_str(), h5d_type_id, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); hid_t filespace = H5Dget_space(dataset); ret = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offsets, NULL, ones.data(), counts); @@ -276,7 +276,7 @@ bool h5d_read(hid_t grp, { if (grp < 0) return true; - hid_t h1 = H5Dopen(grp, aname.c_str()); + hid_t h1 = H5Dopen(grp, aname.c_str(), H5P_DEFAULT); if (h1 < 0) return false; @@ -320,14 +320,14 @@ inline bool h5d_write(hid_t grp, << *(mem_gcounts + 2) << " " << *mem_counts << " " << *(mem_counts + 1) << " " << *(mem_counts + 2) << " " << *mem_offsets << " " << *(mem_offsets + 1) << " " << *(mem_offsets + 2) << " " << std::endl; hid_t h5d_type_id = get_h5_datatype(*first); - hid_t h1 = H5Dopen(grp, aname.c_str()); + hid_t h1 = H5Dopen(grp, aname.c_str(), H5P_DEFAULT); herr_t ret = -1; const std::vector ones(std::max(ndims, mem_ndims), 1); if (h1 < 0) //missing create one { hid_t dataspace = H5Screate_simple(ndims, gcounts, NULL); - hid_t dataset = H5Dcreate(grp, aname.c_str(), h5d_type_id, dataspace, H5P_DEFAULT); + hid_t dataset = H5Dcreate(grp, aname.c_str(), h5d_type_id, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); hid_t filespace = H5Dget_space(dataset); ret = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offsets, NULL, ones.data(), counts); @@ -373,7 +373,7 @@ inline bool h5d_append(hid_t grp, hid_t h5d_type_id = get_h5_datatype(*first); hid_t dataspace; hid_t memspace; - hid_t dataset = H5Dopen(grp, aname.c_str()); + hid_t dataset = H5Dopen(grp, aname.c_str(), H5P_DEFAULT); std::vector max_dims(ndims); max_dims[0] = H5S_UNLIMITED; for (int d = 1; d < ndims; ++d) @@ -397,7 +397,7 @@ inline bool h5d_append(hid_t grp, // set chunk size hid_t cs = H5Pset_chunk(p, ndims, chunk_dims.data()); // create the dataset - dataset = H5Dcreate2(grp, aname.c_str(), h5d_type_id, dataspace, H5P_DEFAULT, p, H5P_DEFAULT); + dataset = H5Dcreate(grp, aname.c_str(), h5d_type_id, dataspace, H5P_DEFAULT, p, H5P_DEFAULT); // create memory dataspace, size of current buffer memspace = H5Screate_simple(ndims, dims, NULL); // write the data for the first time From ea371e42792f937070a830c87ed31dd7a1f5998e Mon Sep 17 00:00:00 2001 From: Steven Hahn Date: Wed, 30 Nov 2022 17:03:20 -0500 Subject: [PATCH 2/5] set H5_USE_110_API Signed-off-by: Steven Hahn --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 72b5aa5eb9..8317f45f8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -694,7 +694,7 @@ if(HDF5_FOUND) add_library(IO::HDF5 INTERFACE IMPORTED) target_include_directories(IO::HDF5 INTERFACE "${HDF5_INCLUDE_DIR}") - target_compile_definitions(IO::HDF5 INTERFACE "H5_USE_18_API") + target_compile_definitions(IO::HDF5 INTERFACE "H5_USE_110_API") target_link_libraries(IO::HDF5 INTERFACE "${HDF5_LIBRARIES}") if(ENABLE_PHDF5) target_compile_definitions(IO::HDF5 INTERFACE "ENABLE_PHDF5") From 197913481864ad8e7e5db214d69d9d7354c085a3 Mon Sep 17 00:00:00 2001 From: Steven Hahn Date: Thu, 1 Dec 2022 09:38:54 -0500 Subject: [PATCH 3/5] Update deprecated functions Signed-off-by: Steven Hahn --- src/io/hdf/hdf_archive.h | 2 +- src/io/hdf/hdf_wrapper_functions.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/io/hdf/hdf_archive.h b/src/io/hdf/hdf_archive.h index 675851a1b4..5d97378c57 100644 --- a/src/io/hdf/hdf_archive.h +++ b/src/io/hdf/hdf_archive.h @@ -317,7 +317,7 @@ class hdf_archive if (Mode[NOIO]) return; hid_t p = group_id.empty() ? file_id : group_id.top(); - herr_t status = H5Gunlink(p, aname.c_str()); + herr_t status = H5Ldelete(p, aname.c_str(), H5P_DEFAULT); } }; diff --git a/src/io/hdf/hdf_wrapper_functions.h b/src/io/hdf/hdf_wrapper_functions.h index 5421d3ef9e..85eb9c5037 100644 --- a/src/io/hdf/hdf_wrapper_functions.h +++ b/src/io/hdf/hdf_wrapper_functions.h @@ -438,7 +438,7 @@ inline bool h5d_append(hid_t grp, start[0] = current; end[0] = start[0] + dims[0]; //extend the dataset (file) - herr_t he = H5Dextend(dataset, end.data()); + herr_t he = H5Dset_extent(dataset, end.data()); //get the corresponding dataspace (filespace) dataspace = H5Dget_space(dataset); //set the extent From 1149e83c7c311d91d5de17a5a6faf931d4b09800 Mon Sep 17 00:00:00 2001 From: Steven Hahn Date: Thu, 1 Dec 2022 09:57:53 -0500 Subject: [PATCH 4/5] Set minimum version in find_package Signed-off-by: Steven Hahn --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8317f45f8c..d7ebe80f99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -653,7 +653,7 @@ else() set(HDF5_USE_STATIC_LIBRARIES off) endif() -find_package(HDF5 COMPONENTS C) +find_package(HDF5 1.10 COMPONENTS C) if(HDF5_FOUND) if(HDF5_IS_PARALLEL) From 4633affeae2d9be7fd1cbaea61121782718212b3 Mon Sep 17 00:00:00 2001 From: Steven Hahn Date: Thu, 1 Dec 2022 13:56:35 -0500 Subject: [PATCH 5/5] Add HDF5 minimum version to README Signed-off-by: Steven Hahn --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a8466006f9..8f6355c7a1 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ particular emphasis is placed on code quality and reproducibility. * CMake v3.17.0 or later, build utility, http://www.cmake.org * BLAS/LAPACK, numerical library. Use vendor and platform-optimized libraries. * LibXml2, XML parser, http://xmlsoft.org/ - * HDF5, portable I/O library, http://www.hdfgroup.org/HDF5/ + * HDF5 v1.10.0 or later, portable I/O library, http://www.hdfgroup.org/HDF5/ * BOOST v1.61.0 or newer, peer-reviewed portable C++ source libraries, http://www.boost.org * FFTW, FFT library, http://www.fftw.org/ * MPI, parallel library. Optional, but a near requirement for production calculations.