diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2021-03-25 00:39:37 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2021-03-25 00:39:37 (GMT) |
commit | feb20aac304b39e18c70f88cae2f7cf7d5c82db2 (patch) | |
tree | e15d7e751af4e3c42e77ea955d91db4cf27a71cf /examples/h5_extend_write.c | |
parent | bdac2ecdbff2c389a222b3d93ff1eb1d23ec6b23 (diff) | |
download | hdf5-feb20aac304b39e18c70f88cae2f7cf7d5c82db2.zip hdf5-feb20aac304b39e18c70f88cae2f7cf7d5c82db2.tar.gz hdf5-feb20aac304b39e18c70f88cae2f7cf7d5c82db2.tar.bz2 |
Formats the source and updates the gcc warning pragmas
Diffstat (limited to 'examples/h5_extend_write.c')
-rw-r--r-- | examples/h5_extend_write.c | 102 |
1 files changed, 47 insertions, 55 deletions
diff --git a/examples/h5_extend_write.c b/examples/h5_extend_write.c index 4abda30..ad7ef50 100644 --- a/examples/h5_extend_write.c +++ b/examples/h5_extend_write.c @@ -20,43 +20,42 @@ #include "hdf5.h" -#define H5FILE_NAME "SDSextendible.h5" +#define H5FILE_NAME "SDSextendible.h5" #define DATASETNAME "ExtendibleArray" -#define RANK 2 -#define NX 10 -#define NY 5 +#define RANK 2 +#define NX 10 +#define NY 5 int -main (void) +main(void) { - hid_t file; /* handles */ - hid_t dataspace, dataset; - hid_t filespace; - hid_t cparms; - hsize_t dims[2] = { 3, 3}; /* - * dataset dimensions - * at the creation time - */ - hsize_t dims1[2] = { 3, 3}; /* data1 dimensions */ - hsize_t dims2[2] = { 7, 1}; /* data2 dimensions */ - hsize_t dims3[2] = { 2, 2}; /* data3 dimensions */ + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t filespace; + hid_t cparms; + hsize_t dims[2] = {3, 3}; /* + * dataset dimensions + * at the creation time + */ + hsize_t dims1[2] = {3, 3}; /* data1 dimensions */ + hsize_t dims2[2] = {7, 1}; /* data2 dimensions */ + hsize_t dims3[2] = {2, 2}; /* data3 dimensions */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t chunk_dims[2] ={2, 5}; - hsize_t size[2]; - hsize_t offset[2]; + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t chunk_dims[2] = {2, 5}; + hsize_t size[2]; + hsize_t offset[2]; - herr_t status; + herr_t status; - int data1[3][3] = { {1, 1, 1}, /* data to write */ - {1, 1, 1}, - {1, 1, 1} }; + int data1[3][3] = {{1, 1, 1}, /* data to write */ + {1, 1, 1}, + {1, 1, 1}}; - int data2[7] = { 2, 2, 2, 2, 2, 2, 2}; + int data2[7] = {2, 2, 2, 2, 2, 2, 2}; - int data3[2][2] = { {3, 3}, - {3, 3} }; - int fillvalue = 0; + int data3[2][2] = {{3, 3}, {3, 3}}; + int fillvalue = 0; /* * Create the data space with unlimited dimensions. @@ -72,22 +71,21 @@ main (void) * Modify dataset creation properties, i.e. enable chunking. */ cparms = H5Pcreate(H5P_DATASET_CREATE); - status = H5Pset_chunk( cparms, RANK, chunk_dims); - status = H5Pset_fill_value (cparms, H5T_NATIVE_INT, &fillvalue ); + status = H5Pset_chunk(cparms, RANK, chunk_dims); + status = H5Pset_fill_value(cparms, H5T_NATIVE_INT, &fillvalue); /* * Create a new dataset within the file using cparms * creation properties. */ - dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT); + dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT); /* * Extend the dataset. This call assures that dataset is at least 3 x 3. */ - size[0] = 3; - size[1] = 3; - status = H5Dset_extent(dataset, size); + size[0] = 3; + size[1] = 3; + status = H5Dset_extent(dataset, size); /* * Select a hyperslab. @@ -95,22 +93,20 @@ main (void) filespace = H5Dget_space(dataset); offset[0] = 0; offset[1] = 0; - status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, - dims1, NULL); + status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims1, NULL); /* * Write the data to the hyperslab. */ - status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, - H5P_DEFAULT, data1); + status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, H5P_DEFAULT, data1); /* * Extend the dataset. Dataset becomes 10 x 3. */ - dims[0] = dims1[0] + dims2[0]; - size[0] = dims[0]; - size[1] = dims[1]; - status = H5Dset_extent(dataset, size); + dims[0] = dims1[0] + dims2[0]; + size[0] = dims[0]; + size[1] = dims[1]; + status = H5Dset_extent(dataset, size); /* * Select a hyperslab. @@ -118,8 +114,7 @@ main (void) filespace = H5Dget_space(dataset); offset[0] = 3; offset[1] = 0; - status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, - dims2, NULL); + status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims2, NULL); /* * Define memory space @@ -129,16 +124,15 @@ main (void) /* * Write the data to the hyperslab. */ - status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, - H5P_DEFAULT, data2); + status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, H5P_DEFAULT, data2); /* * Extend the dataset. Dataset becomes 10 x 5. */ - dims[1] = dims1[1] + dims3[1]; - size[0] = dims[0]; - size[1] = dims[1]; - status = H5Dset_extent(dataset, size); + dims[1] = dims1[1] + dims3[1]; + size[0] = dims[0]; + size[1] = dims[1]; + status = H5Dset_extent(dataset, size); /* * Select a hyperslab @@ -146,8 +140,7 @@ main (void) filespace = H5Dget_space(dataset); offset[0] = 0; offset[1] = 3; - status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, - dims3, NULL); + status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims3, NULL); /* * Define memory space. @@ -157,8 +150,7 @@ main (void) /* * Write the data to the hyperslab. */ - status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, - H5P_DEFAULT, data3); + status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, H5P_DEFAULT, data3); /* * Resulting dataset |