Trying to write to a hyperslab and get this error:
HDF5-DIAG: Error detected in HDF5 (1.8.13) thread 140423587391296:
#000: ../../../src/H5Dio.c line 225 in H5Dwrite(): can't prepare for
writing data
major: Dataset
minor: Write failed
#001: ../../../src/H5Dio.c line 347 in H5D__pre_write(): can't write
data
major: Dataset
minor: Write failed
#002: ../../../src/H5Dio.c line 685 in H5D__write(): src and dest data
spaces have different sizes
major: Invalid arguments to routine
minor: Bad value
terminate called after throwing an instance of 'H5::DataSetIException'
Aborted
not sure why. Here is the code:
#include <H5Cpp.h>
#include <string>
const hsize_t MAX_DIMS[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
const int CHUNK_RANK = 1;
const int CHUNK_DIM = 365;
const hsize_t CHUNK_SPACE[2] = {(hsize_t)CHUNK_RANK,
(hsize_t)CHUNK_DIM};
const double NULL_VALUE = -999.99;
int main()
{
hsize_t rank = 2;
std::string filename = "NEALL01-60.h5";
hsize_t offset[2], count[2];
int dimSize = 14363702;
H5::DSetCreatPropList propList;
propList.setChunk(rank, CHUNK_SPACE);
propList.setDeflate(6);
H5::H5File file(filename, H5F_ACC_TRUNC);
hsize_t dims[2] = {rank, (hsize_t)dimSize};
H5::DataSpace dataSpace(rank, dims, MAX_DIMS);
H5::DataSet dataset(file.createDataSet("60",
H5::PredType::NATIVE_DOUBLE, dataSpace, propList));
H5::DataSpace memSpace = dataset.getSpace();
double data[CHUNK_RANK][CHUNK_DIM];
for (int a = 0; a < CHUNK_RANK; a++)
{
for (int b = 0; b < CHUNK_DIM; b++)
{
data[a][b] = NULL_VALUE;
}
}
count[0] = CHUNK_RANK;
count[1] = CHUNK_DIM;
offset[0] = 0;
offset[1] = 0;
memSpace.selectHyperslab(H5S_SELECT_SET, count, offset);
dataset.write(data, H5::PredType::NATIVE_DOUBLE, memSpace, dataSpace);
}
Thought the getSpace() call would copy the dataspace so I'm not sure why it
is failing since this seems similar to the tutorials. Or perhaps I missed
something.