summaryrefslogtreecommitdiffstats
path: root/examples/h5_group.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_group.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'examples/h5_group.c')
-rw-r--r--examples/h5_group.c105
1 files changed, 51 insertions, 54 deletions
diff --git a/examples/h5_group.c b/examples/h5_group.c
index 75bed91..fe6405c 100644
--- a/examples/h5_group.c
+++ b/examples/h5_group.c
@@ -19,31 +19,29 @@
* in the root group and in the created group.
*/
-
#include "hdf5.h"
-
-#define H5FILE_NAME "group.h5"
-#define RANK 2
+#define H5FILE_NAME "group.h5"
+#define RANK 2
static herr_t file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo,
- void *opdata); /* Link iteration operator function */
+ void *opdata); /* Link iteration operator function */
static herr_t group_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo,
- void *opdata); /* Link iteration operator function */
+ void *opdata); /* Link iteration operator function */
int
main(void)
{
- hid_t file;
- hid_t grp;
- hid_t dataset, dataspace;
- hid_t plist;
+ hid_t file;
+ hid_t grp;
+ hid_t dataset, dataspace;
+ hid_t plist;
- herr_t status;
- hsize_t dims[2];
- hsize_t cdims[2];
+ herr_t status;
+ hsize_t dims[2];
+ hsize_t cdims[2];
- int idx_f, idx_g;
+ int idx_f, idx_g;
/*
* Create a file.
@@ -61,16 +59,16 @@ main(void)
* GZIP compression with the compression effort set to 6.
* Note that compression can be used only when dataset is chunked.
*/
- dims[0] = 1000;
- dims[1] = 20;
- cdims[0] = 20;
- cdims[1] = 20;
+ dims[0] = 1000;
+ dims[1] = 20;
+ cdims[0] = 20;
+ cdims[1] = 20;
dataspace = H5Screate_simple(RANK, dims, NULL);
plist = H5Pcreate(H5P_DATASET_CREATE);
- H5Pset_chunk(plist, 2, cdims);
- H5Pset_deflate( plist, 6);
- dataset = H5Dcreate2(file, "/Data/Compressed_Data", H5T_NATIVE_INT,
- dataspace, H5P_DEFAULT, plist, H5P_DEFAULT);
+ H5Pset_chunk(plist, 2, cdims);
+ H5Pset_deflate(plist, 6);
+ dataset =
+ H5Dcreate2(file, "/Data/Compressed_Data", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, plist, H5P_DEFAULT);
/*
* Close the first dataset .
*/
@@ -80,11 +78,11 @@ main(void)
/*
* Create the second dataset.
*/
- dims[0] = 500;
- dims[1] = 20;
+ dims[0] = 500;
+ dims[1] = 20;
dataspace = H5Screate_simple(RANK, dims, NULL);
- dataset = H5Dcreate2(file, "/Data/Float_Data", H5T_NATIVE_FLOAT,
- dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(file, "/Data/Float_Data", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT);
/*
*Close the second dataset and file.
@@ -105,7 +103,8 @@ main(void)
* Access "Compressed_Data" dataset in the group.
*/
dataset = H5Dopen2(grp, "Compressed_Data", H5P_DEFAULT);
- if( dataset < 0) printf(" Dataset 'Compressed-Data' is not found. \n");
+ if (dataset < 0)
+ printf(" Dataset 'Compressed-Data' is not found. \n");
printf("\"/Data/Compressed_Data\" dataset is open \n");
/*
@@ -123,7 +122,8 @@ main(void)
* hard link "Data_new".
*/
dataset = H5Dopen2(file, "/Data_new/Compressed_Data", H5P_DEFAULT);
- if( dataset < 0) printf(" Dataset is not found. \n");
+ if (dataset < 0)
+ printf(" Dataset is not found. \n");
printf("\"/Data_new/Compressed_Data\" dataset is open \n");
/*
@@ -131,7 +131,6 @@ main(void)
*/
status = H5Dclose(dataset);
-
/*
* Use iterator to see the names of the objects in the root group.
*/
@@ -141,10 +140,10 @@ main(void)
* Unlink name "Data" and use iterator to see the names
* of the objects in the file root direvtory.
*/
- if(H5Ldelete(file, "Data", H5P_DEFAULT) < 0)
- printf(" H5Ldelete failed \n");
+ if (H5Ldelete(file, "Data", H5P_DEFAULT) < 0)
+ printf(" H5Ldelete failed \n");
else
- printf("\"Data\" is unlinked \n");
+ printf("\"Data\" is unlinked \n");
idx_f = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL);
@@ -152,7 +151,8 @@ main(void)
* Use iterator to see the names of the objects in the group
* /Data_new.
*/
- idx_g = H5Literate_by_name2(grp, "/Data_new", H5_INDEX_NAME, H5_ITER_INC, NULL, group_info, NULL, H5P_DEFAULT);
+ idx_g = H5Literate_by_name2(grp, "/Data_new", H5_INDEX_NAME, H5_ITER_INC, NULL, group_info, NULL,
+ H5P_DEFAULT);
/*
* Close the file.
@@ -173,7 +173,7 @@ file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdata
/* avoid compiler warnings */
loc_id = loc_id;
opdata = opdata;
- linfo = linfo;
+ linfo = linfo;
/*
* Display group name. The name is passed to the function by
@@ -184,23 +184,22 @@ file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdata
return 0;
}
-
/*
* Operator function.
*/
static herr_t
group_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdata)
{
- hid_t did; /* dataset identifier */
- hid_t tid; /* datatype identifier */
+ hid_t did; /* dataset identifier */
+ hid_t tid; /* datatype identifier */
H5T_class_t t_class;
- hid_t pid; /* data_property identifier */
- hsize_t chunk_dims_out[2];
- int rank_chunk;
+ hid_t pid; /* data_property identifier */
+ hsize_t chunk_dims_out[2];
+ int rank_chunk;
/* avoid warnings */
opdata = opdata;
- linfo = linfo;
+ linfo = linfo;
/*
* Open the datasets using their names.
@@ -215,38 +214,37 @@ group_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdat
/*
* Display dataset information.
*/
- tid = H5Dget_type(did); /* get datatype*/
+ tid = H5Dget_type(did); /* get datatype*/
pid = H5Dget_create_plist(did); /* get creation property list */
/*
* Check if dataset is chunked.
*/
- if(H5D_CHUNKED == H5Pget_layout(pid)) {
+ if (H5D_CHUNKED == H5Pget_layout(pid)) {
/*
* get chunking information: rank and dimensions.
*/
rank_chunk = H5Pget_chunk(pid, 2, chunk_dims_out);
- printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk,
- (unsigned long)(chunk_dims_out[0]),
- (unsigned long)(chunk_dims_out[1]));
+ printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk, (unsigned long)(chunk_dims_out[0]),
+ (unsigned long)(chunk_dims_out[1]));
}
else {
t_class = H5Tget_class(tid);
- if(t_class < 0) {
+ if (t_class < 0) {
puts(" Invalid datatype.\n");
}
else {
- if(t_class == H5T_INTEGER)
+ if (t_class == H5T_INTEGER)
puts(" Datatype is 'H5T_NATIVE_INTEGER'.\n");
- if(t_class == H5T_FLOAT)
+ if (t_class == H5T_FLOAT)
puts(" Datatype is 'H5T_NATIVE_FLOAT'.\n");
- if(t_class == H5T_STRING)
+ if (t_class == H5T_STRING)
puts(" Datatype is 'H5T_NATIVE_STRING'.\n");
- if(t_class == H5T_BITFIELD)
+ if (t_class == H5T_BITFIELD)
puts(" Datatype is 'H5T_NATIVE_BITFIELD'.\n");
- if(t_class == H5T_OPAQUE)
+ if (t_class == H5T_OPAQUE)
puts(" Datatype is 'H5T_NATIVE_OPAQUE'.\n");
- if(t_class == H5T_COMPOUND)
+ if (t_class == H5T_COMPOUND)
puts(" Datatype is 'H5T_NATIVE_COMPOUND'.\n");
}
}
@@ -256,4 +254,3 @@ group_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdat
H5Tclose(tid);
return 0;
}
-