I have this code that creates an hdf5 file. Then I output the extents using
getSimpleExtentNdims and getSimpleExtentdims to see if they match.
Unfortunately they dont. Why? C++ only please.

The code:
#include <H5Cpp.h>
#include <iostream>
using namespace std;
using namespace H5;

int main()
{
  int rank = 1;
  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 int COMPRESSION = 6;
  const double NULL_VALUE = -999.99;
  int dimSize = 239400;
  const hsize_t MAX_DIMS[2] = {H5S_UNLIMITED, H5S_UNLIMITED};

  H5File file("extenttest.h5", H5F_ACC_TRUNC);

  DSetCreatPropList propList;
  propList.setChunk(rank, CHUNK_SPACE);
  propList.setDeflate(COMPRESSION);
  propList.setFillValue(PredType::NATIVE_DOUBLE, &NULL_VALUE);

  hsize_t dims[2] = {rank, (hsize_t)dimSize};
  DataSpace dataSpace(rank, dims, MAX_DIMS);
  DataSet dataset(file.createDataSet("60", PredType::NATIVE_DOUBLE,
dataSpace, propList));

  cout << "Creating File extenttest.h5" << endl;
  hsize_t dimsOut[2];
  dimsOut[0] = 1;
  dimsOut[1] = 2;
  cout << "Set Dims: " << dimsOut[0] << " X " << dimsOut[1] << endl;
  dataSpace.getSimpleExtentDims(dimsOut);
  cout << "getSimpleExtentNdims: " << dataSpace.getSimpleExtentNdims() <<
endl;
  cout << "dataspace set: " << rank << " X " << dimSize << endl;
  cout << "dataspace grabbed: " << dimsOut[0] << " X " << dimsOut[1] <<
endl;
}

the output from the code:
Creating File extenttest.h5
Set Dims: 1 X 2
getSimpleExtentNdims: 1
dataspace set: 1 X 239400
dataspace grabbed: 1 X 2
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

Reply via email to