summaryrefslogtreecommitdiffstats
path: root/examples/h5_ref2reg_deprec.c
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 /examples/h5_ref2reg_deprec.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'examples/h5_ref2reg_deprec.c')
-rw-r--r--examples/h5_ref2reg_deprec.c93
1 files changed, 45 insertions, 48 deletions
diff --git a/examples/h5_ref2reg_deprec.c b/examples/h5_ref2reg_deprec.c
index dc2964c..58b3095 100644
--- a/examples/h5_ref2reg_deprec.c
+++ b/examples/h5_ref2reg_deprec.c
@@ -26,33 +26,34 @@
#include "hdf5.h"
-#define filename "REF_REG.h5"
+#define filename "REF_REG.h5"
#define dsetnamev "MATRIX"
#define dsetnamer "REGION_REFERENCES"
-int main(void)
+int
+main(void)
{
- hid_t file_id; /* file identifier */
- hid_t space_id; /* dataspace identifiers */
- hid_t spacer_id;
- hid_t dsetv_id; /*dataset identifiers*/
- hid_t dsetr_id;
- hsize_t dims[2] = {2,9};
- hsize_t dimsr[1] = {2};
- int rank = 2;
- int rankr =1;
- herr_t status;
+ hid_t file_id; /* file identifier */
+ hid_t space_id; /* dataspace identifiers */
+ hid_t spacer_id;
+ hid_t dsetv_id; /*dataset identifiers*/
+ hid_t dsetr_id;
+ hsize_t dims[2] = {2, 9};
+ hsize_t dimsr[1] = {2};
+ int rank = 2;
+ int rankr = 1;
+ herr_t status;
hdset_reg_ref_t ref[2];
hdset_reg_ref_t ref_out[2];
- int data[2][9] = {{1,1,2,3,3,4,5,5,6},{1,2,2,3,4,4,5,6,6}};
- int data_out[2][9] = {{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0}};
- hsize_t start[2];
- hsize_t count[2];
- hsize_t coord[2][3] = {{0, 0, 1}, {6, 0, 8}};
- unsigned num_points = 3;
- int i, j;
- size_t name_size1, name_size2;
- char buf1[10], buf2[10];
+ int data[2][9] = {{1, 1, 2, 3, 3, 4, 5, 5, 6}, {1, 2, 2, 3, 4, 4, 5, 6, 6}};
+ int data_out[2][9] = {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}};
+ hsize_t start[2];
+ hsize_t count[2];
+ hsize_t coord[2][3] = {{0, 0, 1}, {6, 0, 8}};
+ unsigned num_points = 3;
+ int i, j;
+ size_t name_size1, name_size2;
+ char buf1[10], buf2[10];
/*
* Create file with default file access and file creation properties.
@@ -62,24 +63,26 @@ int main(void)
/*
* Create dataspace for datasets.
*/
- space_id = H5Screate_simple(rank, dims, NULL);
+ space_id = H5Screate_simple(rank, dims, NULL);
spacer_id = H5Screate_simple(rankr, dimsr, NULL);
/*
* Create integer dataset.
*/
- dsetv_id = H5Dcreate2(file_id, dsetnamev, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dsetv_id =
+ H5Dcreate2(file_id, dsetnamev, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/*
* Write data to the dataset.
*/
- status = H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT,data);
+ status = H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
status = H5Dclose(dsetv_id);
/*
* Dataset with references.
*/
- dsetr_id = H5Dcreate2(file_id, dsetnamer, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dsetr_id =
+ H5Dcreate2(file_id, dsetnamer, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/*
* Create a reference to the hyperslab.
@@ -88,8 +91,8 @@ int main(void)
start[1] = 3;
count[0] = 2;
count[1] = 3;
- status = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, NULL, count, NULL);
- status = H5Rcreate(&ref[0], file_id, dsetnamev, H5R_DATASET_REGION, space_id);
+ status = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, NULL, count, NULL);
+ status = H5Rcreate(&ref[0], file_id, dsetnamev, H5R_DATASET_REGION, space_id);
/*
* Create a reference to elements selection.
@@ -101,7 +104,7 @@ int main(void)
/*
* Write dataset with the references.
*/
- status = H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,ref);
+ status = H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref);
/*
* Close all objects.
@@ -114,7 +117,7 @@ int main(void)
/*
* Reopen the file to read selections back.
*/
- file_id = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
+ file_id = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
/*
* Reopen the dataset with object references and read references
@@ -122,8 +125,7 @@ int main(void)
*/
dsetr_id = H5Dopen2(file_id, dsetnamer, H5P_DEFAULT);
- status = H5Dread(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, ref_out);
+ status = H5Dread(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_out);
/*
* Dereference the first reference.
@@ -133,26 +135,26 @@ int main(void)
* Get name of the dataset the first region reference points to
* using H5Rget_name
*/
- name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0], (char*)buf1, 10);
- printf(" Dataset's name (returned by H5Rget_name) the reference points to is %s, name length is %d\n", buf1, (int)name_size1);
+ name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0], (char *)buf1, 10);
+ printf(" Dataset's name (returned by H5Rget_name) the reference points to is %s, name length is %d\n",
+ buf1, (int)name_size1);
/*
* Get name of the dataset the first region reference points to
* using H5Iget_name
*/
- name_size2 = H5Iget_name(dsetv_id, (char*)buf2, 10);
- printf(" Dataset's name (returned by H5Iget_name) the reference points to is %s, name length is %d\n", buf2, (int)name_size2);
+ name_size2 = H5Iget_name(dsetv_id, (char *)buf2, 10);
+ printf(" Dataset's name (returned by H5Iget_name) the reference points to is %s, name length is %d\n",
+ buf2, (int)name_size2);
- space_id = H5Rget_region(dsetr_id, H5R_DATASET_REGION,&ref_out[0]);
+ space_id = H5Rget_region(dsetr_id, H5R_DATASET_REGION, &ref_out[0]);
/*
* Read and display hyperslab selection from the dataset.
*/
- status = H5Dread(dsetv_id, H5T_NATIVE_INT, H5S_ALL, space_id,
- H5P_DEFAULT, data_out);
+ status = H5Dread(dsetv_id, H5T_NATIVE_INT, H5S_ALL, space_id, H5P_DEFAULT, data_out);
printf("Selected hyperslab: ");
- for (i = 0; i <= 1; i++)
- {
+ for (i = 0; i <= 1; i++) {
printf("\n");
for (j = 0; j <= 8; j++)
printf("%d ", data_out[i][j]);
@@ -176,17 +178,15 @@ int main(void)
* Dereference the second reference.
*/
dsetv_id = H5Rdereference2(dsetr_id, H5P_DEFAULT, H5R_DATASET_REGION, &ref_out[1]);
- space_id = H5Rget_region(dsetv_id, H5R_DATASET_REGION,&ref_out[1]);
+ space_id = H5Rget_region(dsetv_id, H5R_DATASET_REGION, &ref_out[1]);
/*
* Read selected data from the dataset.
*/
- status = H5Dread(dsetv_id, H5T_NATIVE_INT, H5S_ALL, space_id,
- H5P_DEFAULT, data_out);
+ status = H5Dread(dsetv_id, H5T_NATIVE_INT, H5S_ALL, space_id, H5P_DEFAULT, data_out);
printf("Selected points: ");
- for (i = 0; i <= 1; i++)
- {
+ for (i = 0; i <= 1; i++) {
printf("\n");
for (j = 0; j <= 8; j++)
printf("%d ", data_out[i][j]);
@@ -203,6 +203,3 @@ int main(void)
return 0;
}
-
-
-