Skip to content

Commit

Permalink
Adds HDF5 api calls depending on HDF5 library version
Browse files Browse the repository at this point in the history
  • Loading branch information
wwissdorf committed Feb 11, 2024
1 parent 8884487 commit ad643fd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ find_package(HDF5 COMPONENTS CXX HL)
if(HDF5_FOUND)
message(STATUS "HDF5 Found, Version:")
message(STATUS ${HDF5_VERSION})

set(USE_OLD_HDF5_API false)
if(${HDF5_VERSION} VERSION_LESS_EQUAL "1.14.1")
set(USE_OLD_HDF5_API true)
endif()

if(USE_OLD_HDF5_API)
message(STATUS "Using old HDF5 API Calls")
add_compile_definitions(OLD_HDF5_API)
endif()

endif()

include_directories(${HDF5_INCLUDE_DIRS})
Expand Down
10 changes: 8 additions & 2 deletions modules/FileIO/FileIO_HDF5Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ herr_t collectDatasetNames(hid_t loc_id, const char *name, const H5L_info_t* /*l
{
// Open the object using its name.
hid_t object = H5Oopen(loc_id, name, H5P_DEFAULT);
H5O_info_t object_info;
H5Oget_info(object, &object_info, H5O_INFO_ALL);

#ifdef OLD_HDF5_API
H5O_info_t object_info;
H5Oget_info(object, &object_info);
#else
H5O_info1_t object_info;
H5Oget_info1(object, &object_info);
#endif

//Write object name to vector if it is a dataset:
if (object_info.type == H5O_TYPE_DATASET){
Expand Down

0 comments on commit ad643fd

Please sign in to comment.