Incorrect Extents Returned

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

Hi Jamie,

I'm wondering that 'rank' should have been 2, and if so, 'rank' would not be used in this statement: hsize_t dims[2] = {rank, (hsize_t)dimSize}; but something else with a value of 1.

Binh-Minh

···

________________________________
From: Hdf-forum <hdf-forum-bounces@lists.hdfgroup.org> on behalf of Jamie Ryan Lahowetz <jlahowetz2@unl.edu>
Sent: Thursday, October 22, 2015 2:14 PM
To: HDF Users Discussion List
Subject: [Hdf-forum] Incorrect Extents Returned

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