#include <iostream>
using std::cout;
using std::endl;
#include <string>
#include "H5Cpp.h"
const H5std_string FILE_NAME("SDS.h5");
const H5std_string DATASET_NAME("IntArray");
const int NX_SUB = 3;
const int NY_SUB = 4;
const int NX = 7;
const int NY = 7;
const int NZ = 3;
const int RANK_OUT = 3;
int
main(void)
{
int i, j, k;
int data_out[NX][NY][NZ];
for (j = 0; j < NX; j++) {
for (i = 0; i < NY; i++) {
for (k = 0; k < NZ; k++)
data_out[j][i][k] = 0;
}
}
try {
Exception::dontPrint();
H5File file(FILE_NAME, H5F_ACC_RDONLY);
if (type_class == H5T_INTEGER) {
cout << "Data set has INTEGER type" << endl;
H5std_string order_string;
H5T_order_t order = intype.
getOrder(order_string);
cout << order_string << endl;
cout << "Data size is " << size << endl;
}
hsize_t dims_out[2];
cout << "rank " << rank << ", dimensions " << (unsigned long)(dims_out[0]) << " x "
<< (unsigned long)(dims_out[1]) << endl;
hsize_t offset[2];
hsize_t count[2];
offset[0] = 1;
offset[1] = 2;
count[0] = NX_SUB;
count[1] = NY_SUB;
hsize_t dimsm[3];
dimsm[0] = NX;
dimsm[1] = NY;
dimsm[2] = NZ;
hsize_t offset_out[3];
hsize_t count_out[3];
offset_out[0] = 3;
offset_out[1] = 0;
offset_out[2] = 0;
count_out[0] = NX_SUB;
count_out[1] = NY_SUB;
count_out[2] = 1;
memspace.selectHyperslab(H5S_SELECT_SET, count_out, offset_out);
dataset.
read(data_out, PredType::NATIVE_INT, memspace, dataspace);
for (j = 0; j < NX; j++) {
for (i = 0; i < NY; i++)
cout << data_out[j][i][0] << " ";
cout << endl;
}
}
return -1;
}
return -1;
}
return -1;
}
return -1;
}
return 0;
}
H5T_class_t getTypeClass() const
Creates an AbstractDs instance using an existing id.
Definition: H5AbstractDs.cpp:67
IntType getIntType() const
Returns the integer datatype of this abstract dataset which can be a dataset or an attribute.
Definition: H5AbstractDs.cpp:228
H5T_order_t getOrder() const
Returns the byte order of an atomic datatype.
Definition: H5AtomType.cpp:91
Class DataSet operates on HDF5 datasets.
Definition: H5DataSet.h:28
virtual DataSpace getSpace() const
Gets a copy of the dataspace of this dataset.
Definition: H5DataSet.cpp:133
void read(void *buf, const DataType &mem_type, const DataSpace &mem_space=DataSpace::ALL, const DataSpace &file_space=DataSpace::ALL, const DSetMemXferPropList &xfer_plist=DSetMemXferPropList::DEFAULT) const
Reads raw data from the specified dataset.
Definition: H5DataSet.cpp:417
Definition: H5Exception.h:131
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:25
void selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, const hsize_t *stride=NULL, const hsize_t *block=NULL) const
Selects a hyperslab region to add to the current selected region.
Definition: H5DataSpace.cpp:598
int getSimpleExtentDims(hsize_t *dims, hsize_t *maxdims=NULL) const
Retrieves dataspace dimension size and maximum size.
Definition: H5DataSpace.cpp:245
int getSimpleExtentNdims() const
Returns the dimensionality of a dataspace.
Definition: H5DataSpace.cpp:263
Definition: H5Exception.h:103
size_t getSize() const
Returns the size of a datatype.
Definition: H5DataType.cpp:629
Definition: H5Exception.h:110
static void printErrorStack(FILE *stream=stderr, hid_t err_stack=H5E_DEFAULT)
Prints the error stack in a default manner.
Definition: H5Exception.cpp:315
Definition: H5Exception.h:89
Class H5File represents an HDF5 file and inherits from class Group as file is a root group.
Definition: H5File.h:25
DataSet openDataSet(const char *name, const DSetAccPropList &dapl=DSetAccPropList::DEFAULT) const
Opens an existing dataset at this location.
Definition: H5Location.cpp:1006
IntType is a derivative of a DataType and operates on HDF5 integer datatype.
Definition: H5IntType.h:25
Definition: H5AbstractDs.cpp:34