This example shows how to create datasets.
#include <iostream>
#include <string>
#include "H5Cpp.h"
const H5std_string FILE_NAME("SDS.h5");
const H5std_string DATASET_NAME("IntArray");
const int NX = 5;
const int NY = 6;
const int RANK = 2;
int
main(void)
{
int i, j;
int data[NX][NY];
for (j = 0; j < NX; j++) {
for (i = 0; i < NY; i++)
data[j][i] = i + j;
}
try {
H5File file(FILE_NAME, H5F_ACC_TRUNC);
hsize_t dimsf[2];
dimsf[0] = NX;
dimsf[1] = NY;
DataSpace dataspace(RANK, dimsf);
datatype.setOrder(H5T_ORDER_LE);
DataSet dataset = file.createDataSet(DATASET_NAME, datatype, dataspace);
}
catch (FileIException error) {
error.printErrorStack();
return -1;
}
catch (DataSetIException error) {
error.printErrorStack();
return -1;
}
catch (DataSpaceIException error) {
error.printErrorStack();
return -1;
}
catch (DataTypeIException error) {
error.printErrorStack();
return -1;
}
return 0;
}
static void dontPrint()
Turns off the automatic error printing from the C library.
Definition: H5Exception.cpp:161
static const PredType & NATIVE_INT
Definition: H5PredType.h:151
Definition: H5AbstractDs.cpp:34