Fixed HDF5 hyperslab
This commit is contained in:
parent
bf0be4fb61
commit
9b47369d0e
@ -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)
|
||||
|
10
external/external_build.cmake
vendored
10
external/external_build.cmake
vendored
@ -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
|
||||
|
@ -105,11 +105,13 @@ namespace CosmoTool {
|
||||
bool doCreate = true,
|
||||
bool useBases = false)
|
||||
{
|
||||
H5::DataSpace dataspace(data.num_dimensions(), dimensions.data());
|
||||
std::vector<hsize_t> 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<hssize_t> offsets(data.index_bases(), data.index_bases() + data.num_dimensions());
|
||||
dataspace.offsetSimple(offsets.data());
|
||||
std::vector<hsize_t> 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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user