summaryrefslogtreecommitdiffstats
path: root/c++/examples/h5tutr_subset.cpp
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /c++/examples/h5tutr_subset.cpp
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'c++/examples/h5tutr_subset.cpp')
-rw-r--r--c++/examples/h5tutr_subset.cpp67
1 files changed, 30 insertions, 37 deletions
diff --git a/c++/examples/h5tutr_subset.cpp b/c++/examples/h5tutr_subset.cpp
index f7d0513..d4b77c3 100644
--- a/c++/examples/h5tutr_subset.cpp
+++ b/c++/examples/h5tutr_subset.cpp
@@ -24,23 +24,23 @@ using std::endl;
#include "H5Cpp.h"
using namespace H5;
-const H5std_string FILE_NAME("h5tutr_subset.h5");
-const H5std_string DATASET_NAME("IntArray");
+const H5std_string FILE_NAME("h5tutr_subset.h5");
+const H5std_string DATASET_NAME("IntArray");
-const int RANK = 2;
-const int DIM0_SUB = 3; // subset dimensions
-const int DIM1_SUB = 4;
-const int DIM0 = 8; // size of dataset
-const int DIM1 = 10;
+const int RANK = 2;
+const int DIM0_SUB = 3; // subset dimensions
+const int DIM1_SUB = 4;
+const int DIM0 = 8; // size of dataset
+const int DIM1 = 10;
-int main (void)
+int
+main(void)
{
- int i,j;
- int data[DIM0][DIM1], sdata[DIM0_SUB][DIM1_SUB], rdata[DIM0][DIM1];
+ int i, j;
+ int data[DIM0][DIM1], sdata[DIM0_SUB][DIM1_SUB], rdata[DIM0][DIM1];
// Try block to detect exceptions raised by any of the calls inside it
- try
- {
+ try {
// Turn off the auto-printing when failure occurs so that we can
// handle the errors appropriately
Exception::dontPrint();
@@ -54,28 +54,26 @@ int main (void)
H5File file(FILE_NAME, H5F_ACC_TRUNC);
hsize_t dims[2];
- dims[0] = DIM0;
- dims[1] = DIM1;
- DataSpace dataspace = DataSpace (RANK, dims);
-
- DataSet dataset(file.createDataSet( DATASET_NAME,
- PredType::STD_I32BE, dataspace) );
+ dims[0] = DIM0;
+ dims[1] = DIM1;
+ DataSpace dataspace = DataSpace(RANK, dims);
+ DataSet dataset(file.createDataSet(DATASET_NAME, PredType::STD_I32BE, dataspace));
for (j = 0; j < DIM0; j++) {
- for (i = 0; i < DIM1; i++)
- if (i< (DIM1/2))
+ for (i = 0; i < DIM1; i++)
+ if (i < (DIM1 / 2))
data[j][i] = 1;
- else
+ else
data[j][i] = 2;
- }
+ }
dataset.write(data, PredType::NATIVE_INT);
cout << endl << "Data Written to File:" << endl;
for (j = 0; j < DIM0; j++) {
for (i = 0; i < DIM1; i++)
- cout << " " << data[j][i];
+ cout << " " << data[j][i];
cout << endl;
}
@@ -99,8 +97,8 @@ int main (void)
offset[0] = 1;
offset[1] = 2;
- count[0] = DIM0_SUB;
- count[1] = DIM1_SUB;
+ count[0] = DIM0_SUB;
+ count[1] = DIM1_SUB;
stride[0] = 1;
stride[1] = 1;
@@ -126,17 +124,16 @@ int main (void)
cout << " offset=1x2 stride=1x1 count=3x4 block=1x1" << endl;
for (j = 0; j < DIM0_SUB; j++) {
for (i = 0; i < DIM1_SUB; i++)
- sdata[j][i] = 5;
+ sdata[j][i] = 5;
}
dataset.write(sdata, PredType::NATIVE_INT, memspace, dataspace);
dataset.read(rdata, PredType::NATIVE_INT);
-
cout << endl << "Data in File after Subset is Written:" << endl;
for (i = 0; i < DIM0; i++) {
for (j = 0; j < DIM1; j++)
- cout << " " << rdata[i][j];
+ cout << " " << rdata[i][j];
cout << endl;
}
cout << endl;
@@ -148,29 +145,25 @@ int main (void)
dataset.close();
file.close();
- } // end of try block
+ } // end of try block
// catch failure caused by the H5File operations
- catch(FileIException error)
- {
+ catch (FileIException error) {
error.printErrorStack();
return -1;
}
// catch failure caused by the DataSet operations
- catch(DataSetIException error)
- {
+ catch (DataSetIException error) {
error.printErrorStack();
return -1;
}
// catch failure caused by the DataSpace operations
- catch(DataSpaceIException error)
- {
+ catch (DataSpaceIException error) {
error.printErrorStack();
return -1;
}
- return 0; // successfully terminated
+ return 0; // successfully terminated
}
-