From 77bbe888607b40203946bf3f69ec24291b7f43d4 Mon Sep 17 00:00:00 2001 From: John Tramm Date: Wed, 25 Mar 2020 16:45:13 +0000 Subject: [PATCH] simplified the solution a little to make use of the HDF5 internal compatibility flags. --- CMakeLists.txt | 7 +++++-- src/hdf5_interface.cpp | 25 ------------------------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e44cdea22..f4ca745ed1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,8 +74,11 @@ if(HDF5_IS_PARALLEL) message(STATUS "Using parallel HDF5") endif() -if(${HDF5_VERSION} VERSION_LESS "1.12.0") - list(APPEND cxxflags -DHDF5_LEGACY) +# Version 1.12 of HDF5 deprecates the H5Oget_info_by_idx() interface. +# Thus, we give these flags to allow usage of the old interface in newer +# versions of HDF5. +if(${HDF5_VERSION} VERSION_GREATER_EQUAL "1.12.0") + list(APPEND cxxflags -DH5Oget_info_by_idx_vers=1 -DH5O_info_t_vers=1) endif() #=============================================================================== diff --git a/src/hdf5_interface.cpp b/src/hdf5_interface.cpp index cf59b265a2..1fcc97f3c3 100644 --- a/src/hdf5_interface.cpp +++ b/src/hdf5_interface.cpp @@ -251,13 +251,8 @@ int get_num_datasets(hid_t group_id) int ndatasets = 0; for (hsize_t i = 0; i < info.nlinks; ++i) { // Determine type of object (and skip non-group) - #ifdef HDF5_LEGACY H5Oget_info_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, &oinfo, H5P_DEFAULT); - #else - H5Oget_info_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, &oinfo, - H5O_INFO_BASIC, H5P_DEFAULT); - #endif if (oinfo.type == H5O_TYPE_DATASET) ndatasets += 1; } @@ -276,13 +271,8 @@ int get_num_groups(hid_t group_id) int ngroups = 0; for (hsize_t i = 0; i < info.nlinks; ++i) { // Determine type of object (and skip non-group) - #ifdef HDF5_LEGACY H5Oget_info_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, &oinfo, H5P_DEFAULT); - #else - H5Oget_info_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, &oinfo, - H5O_INFO_BASIC, H5P_DEFAULT); - #endif if (oinfo.type == H5O_TYPE_GROUP) ngroups += 1; } @@ -303,13 +293,8 @@ get_datasets(hid_t group_id, char* name[]) size_t size; for (hsize_t i = 0; i < info.nlinks; ++i) { // Determine type of object (and skip non-group) - #ifdef HDF5_LEGACY H5Oget_info_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, &oinfo, H5P_DEFAULT); - #else - H5Oget_info_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, &oinfo, - H5O_INFO_BASIC, H5P_DEFAULT); - #endif if (oinfo.type != H5O_TYPE_DATASET) continue; // Get size of name @@ -337,13 +322,8 @@ get_groups(hid_t group_id, char* name[]) size_t size; for (hsize_t i = 0; i < info.nlinks; ++i) { // Determine type of object (and skip non-group) - #ifdef HDF5_LEGACY H5Oget_info_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, &oinfo, H5P_DEFAULT); - #else - H5Oget_info_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, &oinfo, - H5O_INFO_BASIC, H5P_DEFAULT); - #endif if (oinfo.type != H5O_TYPE_GROUP) continue; // Get size of name @@ -370,13 +350,8 @@ member_names(hid_t group_id, H5O_type_t type) std::vector names; for (hsize_t i = 0; i < info.nlinks; ++i) { // Determine type of object (and skip non-group) - #ifdef HDF5_LEGACY H5Oget_info_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, &oinfo, H5P_DEFAULT); - #else - H5Oget_info_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, &oinfo, - H5O_INFO_BASIC, H5P_DEFAULT); - #endif if (oinfo.type != type) continue; // Get size of name