diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c36a26..d0901eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ find_program(CYTHON cython) if(HDF5_ROOTDIR) SET(ENV{HDF5_ROOT} ${HDF5_ROOTDIR}) endif(HDF5_ROOTDIR) -find_package(HDF5 COMPONENTS HL CXX) +find_package(HDF5 COMPONENTS CXX HL) set(NETCDF_FIND_REQUIRED TRUE) diff --git a/external/external_build.cmake b/external/external_build.cmake index 6a4ec87..170cf8f 100644 --- a/external/external_build.cmake +++ b/external/external_build.cmake @@ -66,8 +66,8 @@ if (INTERNAL_HDF5) SET(hdf5_built hdf5) set(HDF5_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5.a CACHE STRING "HDF5 lib" FORCE) set(HDF5_CPP_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5_cpp.a CACHE STRING "HDF5 C++ lib" FORCE) - set(HDF5HL_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5_hl.a CACHE STRING "HDF5-HL lib" FORCE) - set(HDF5HL_CPP_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5_hl_cpp.a CACHE STRING "HDF5-HL C++ lib" FORCE) + set(HDF5_HL_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5_hl.a CACHE STRING "HDF5-HL lib" FORCE) + set(HDF5_HL_CPP_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5_hl_cpp.a CACHE STRING "HDF5-HL C++ lib" FORCE) SET(HDF5_INCLUDE_PATH ${HDF5_BIN_DIR}/include CACHE STRING "HDF5 include path" FORCE) SET(ENV{HDF5_ROOT} ${HDF5_BIN_DIR}) SET(HDF5_ROOTDIR ${HDF5_BIN_DIR}) @@ -76,11 +76,11 @@ else(INTERNAL_HDF5) find_path(HDF5_INCLUDE_PATH hdf5.h) find_library(HDF5_LIBRARY hdf5) find_library(HDF5_CPP_LIBRARY hdf5_cpp) - find_library(HDF5HL_CPP_LIBRARY hdf5_hl_cpp) - find_library(HDF5HL_LIBRARY hdf5_hl) + find_library(HDF5_HL_CPP_LIBRARY hdf5_hl_cpp) + find_library(HDF5_HL_LIBRARY hdf5_hl) endif (INTERNAL_HDF5) SET(CONFIGURE_CPP_FLAGS "${CONFIGURE_CPP_FLAGS} -I${HDF5_INCLUDE_PATH}") -mark_as_advanced(HDF5_INCLUDE_PATH HDF5_LIBRARY HDF5_CPP_LIBRARY HDF5HL_LIBRARY HDF5HL_CPP_LIBRARY) +mark_as_advanced(HDF5_INCLUDE_PATH HDF5_LIBRARY HDF5_CPP_LIBRARY HDF5_HL_LIBRARY HDF5_HL_CPP_LIBRARY) ############### # Build NetCDF diff --git a/src/hdf5_array.hpp b/src/hdf5_array.hpp index 64eab5f..45b0b07 100644 --- a/src/hdf5_array.hpp +++ b/src/hdf5_array.hpp @@ -105,11 +105,13 @@ namespace CosmoTool { bool doCreate = true, bool useBases = false) { - H5::DataSpace dataspace(data.num_dimensions(), dimensions.data()); + std::vector memdims(data.shape(), data.shape() + data.num_dimensions()); + H5::DataSpace dataspace(dimensions.size(), dimensions.data()); + H5::DataSpace memspace(memdims.size(), memdims.data()); if (useBases) { - std::vector offsets(data.index_bases(), data.index_bases() + data.num_dimensions()); - dataspace.offsetSimple(offsets.data()); + std::vector offsets(data.index_bases(), data.index_bases() + data.num_dimensions()); + dataspace.selectHyperslab(H5S_SELECT_SET, memdims.data(), offsets.data()); } H5::DataSet dataset; @@ -118,7 +120,7 @@ namespace CosmoTool { else dataset = fg.openDataSet(data_set_name); - dataset.write(data.data(), datatype); + dataset.write(data.data(), datatype, memspace, dataspace); }