summaryrefslogtreecommitdiffstats
path: root/examples/h5_cmprss.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_cmprss.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'examples/h5_cmprss.c')
-rw-r--r--examples/h5_cmprss.c121
1 files changed, 60 insertions, 61 deletions
diff --git a/examples/h5_cmprss.c b/examples/h5_cmprss.c
index 97f6567..bb77e28 100644
--- a/examples/h5_cmprss.c
+++ b/examples/h5_cmprss.c
@@ -18,27 +18,29 @@
#include "hdf5.h"
-#define FILE "cmprss.h5"
-#define RANK 2
-#define DIM0 100
-#define DIM1 20
+#define FILE "cmprss.h5"
+#define RANK 2
+#define DIM0 100
+#define DIM1 20
-int main () {
+int
+main()
+{
- hid_t file_id, dataset_id, dataspace_id; /* identifiers */
- hid_t plist_id;
+ hid_t file_id, dataset_id, dataspace_id; /* identifiers */
+ hid_t plist_id;
- size_t nelmts;
- unsigned flags, filter_info;
+ size_t nelmts;
+ unsigned flags, filter_info;
H5Z_filter_t filter_type;
- herr_t status;
- hsize_t dims[2];
- hsize_t cdims[2];
+ herr_t status;
+ hsize_t dims[2];
+ hsize_t cdims[2];
- int i,j, numfilt;
- int buf[DIM0][DIM1];
- int rbuf [DIM0][DIM1];
+ int i, j, numfilt;
+ int buf[DIM0][DIM1];
+ int rbuf[DIM0][DIM1];
/* Uncomment these variables to use SZIP compression
unsigned szip_options_mask;
@@ -46,25 +48,24 @@ int main () {
*/
/* Create a file. */
- file_id = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
+ file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/* Create dataset "Compressed Data" in the group using absolute name. */
- dims[0] = DIM0;
- dims[1] = DIM1;
- dataspace_id = H5Screate_simple (RANK, dims, NULL);
+ dims[0] = DIM0;
+ dims[1] = DIM1;
+ dataspace_id = H5Screate_simple(RANK, dims, NULL);
- plist_id = H5Pcreate (H5P_DATASET_CREATE);
+ plist_id = H5Pcreate(H5P_DATASET_CREATE);
/* Dataset must be chunked for compression */
cdims[0] = 20;
cdims[1] = 20;
- status = H5Pset_chunk (plist_id, 2, cdims);
+ status = H5Pset_chunk(plist_id, 2, cdims);
/* Set ZLIB / DEFLATE Compression using compression level 6.
* To use SZIP Compression comment out these lines.
- */
- status = H5Pset_deflate (plist_id, 6);
+ */
+ status = H5Pset_deflate(plist_id, 6);
/* Uncomment these lines to set SZIP Compression
szip_options_mask = H5_SZIP_NN_OPTION_MASK;
@@ -72,51 +73,49 @@ int main () {
status = H5Pset_szip (plist_id, szip_options_mask, szip_pixels_per_block);
*/
- dataset_id = H5Dcreate2 (file_id, "Compressed_Data", H5T_STD_I32BE,
- dataspace_id, H5P_DEFAULT, plist_id, H5P_DEFAULT);
+ dataset_id = H5Dcreate2(file_id, "Compressed_Data", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, plist_id,
+ H5P_DEFAULT);
- for (i = 0; i< DIM0; i++)
- for (j=0; j<DIM1; j++)
- buf[i][j] = i+j;
+ for (i = 0; i < DIM0; i++)
+ for (j = 0; j < DIM1; j++)
+ buf[i][j] = i + j;
- status = H5Dwrite (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
+ status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
- status = H5Sclose (dataspace_id);
- status = H5Dclose (dataset_id);
- status = H5Pclose (plist_id);
- status = H5Fclose (file_id);
+ status = H5Sclose(dataspace_id);
+ status = H5Dclose(dataset_id);
+ status = H5Pclose(plist_id);
+ status = H5Fclose(file_id);
/* Now reopen the file and dataset in the file. */
- file_id = H5Fopen (FILE, H5F_ACC_RDWR, H5P_DEFAULT);
- dataset_id = H5Dopen2 (file_id, "Compressed_Data", H5P_DEFAULT);
+ file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
+ dataset_id = H5Dopen2(file_id, "Compressed_Data", H5P_DEFAULT);
/* Retrieve filter information. */
- plist_id = H5Dget_create_plist (dataset_id);
-
- numfilt = H5Pget_nfilters (plist_id);
- printf ("Number of filters associated with dataset: %i\n", numfilt);
-
- for (i=0; i<numfilt; i++) {
- nelmts = 0;
- filter_type = H5Pget_filter2 (plist_id, i, &flags, &nelmts, NULL, 0, NULL,
- &filter_info);
- printf ("Filter Type: ");
- switch (filter_type) {
- case H5Z_FILTER_DEFLATE:
- printf ("H5Z_FILTER_DEFLATE\n");
- break;
- case H5Z_FILTER_SZIP:
- printf ("H5Z_FILTER_SZIP\n");
- break;
- default:
- printf ("Other filter type included.\n");
- }
+ plist_id = H5Dget_create_plist(dataset_id);
+
+ numfilt = H5Pget_nfilters(plist_id);
+ printf("Number of filters associated with dataset: %i\n", numfilt);
+
+ for (i = 0; i < numfilt; i++) {
+ nelmts = 0;
+ filter_type = H5Pget_filter2(plist_id, i, &flags, &nelmts, NULL, 0, NULL, &filter_info);
+ printf("Filter Type: ");
+ switch (filter_type) {
+ case H5Z_FILTER_DEFLATE:
+ printf("H5Z_FILTER_DEFLATE\n");
+ break;
+ case H5Z_FILTER_SZIP:
+ printf("H5Z_FILTER_SZIP\n");
+ break;
+ default:
+ printf("Other filter type included.\n");
+ }
}
- status = H5Dread (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, rbuf);
+ status = H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf);
- status = H5Dclose (dataset_id);
- status = H5Pclose (plist_id);
- status = H5Fclose (file_id);
+ status = H5Dclose(dataset_id);
+ status = H5Pclose(plist_id);
+ status = H5Fclose(file_id);
}