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_chunk_read.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_chunk_read.c')
-rw-r--r-- | examples/h5_chunk_read.c | 103 |
1 files changed, 49 insertions, 54 deletions
diff --git a/examples/h5_chunk_read.c b/examples/h5_chunk_read.c index c3455f4..01e8c5d 100644 --- a/examples/h5_chunk_read.c +++ b/examples/h5_chunk_read.c @@ -18,68 +18,66 @@ #include "hdf5.h" -#define H5FILE_NAME "SDSextendible.h5" +#define H5FILE_NAME "SDSextendible.h5" #define DATASETNAME "ExtendibleArray" -#define RANK 2 -#define RANKC 1 -#define NX 10 -#define NY 5 +#define RANK 2 +#define RANKC 1 +#define NX 10 +#define NY 5 int -main (void) +main(void) { - hid_t file; /* handles */ - hid_t dataset; - hid_t filespace; - hid_t memspace; - hid_t cparms; - hsize_t dims[2]; /* dataset and chunk dimensions*/ - hsize_t chunk_dims[2]; - hsize_t col_dims[1]; - hsize_t count[2]; - hsize_t offset[2]; - - herr_t status, status_n; - - int data_out[NX][NY]; /* buffer for dataset to be read */ - int chunk_out[2][5]; /* buffer for chunk to be read */ - int column[10]; /* buffer for column to be read */ - int rank, rank_chunk; - int i, j; - - + hid_t file; /* handles */ + hid_t dataset; + hid_t filespace; + hid_t memspace; + hid_t cparms; + hsize_t dims[2]; /* dataset and chunk dimensions*/ + hsize_t chunk_dims[2]; + hsize_t col_dims[1]; + hsize_t count[2]; + hsize_t offset[2]; + + herr_t status, status_n; + + int data_out[NX][NY]; /* buffer for dataset to be read */ + int chunk_out[2][5]; /* buffer for chunk to be read */ + int column[10]; /* buffer for column to be read */ + int rank, rank_chunk; + int i, j; /* * Open the file and the dataset. */ - file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT); + file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT); dataset = H5Dopen2(file, DATASETNAME, H5P_DEFAULT); /* * Get dataset rank and dimension. */ - filespace = H5Dget_space(dataset); /* Get filespace handle first. */ + filespace = H5Dget_space(dataset); /* Get filespace handle first. */ rank = H5Sget_simple_extent_ndims(filespace); status_n = H5Sget_simple_extent_dims(filespace, dims, NULL); - printf("dataset rank %d, dimensions %lu x %lu\n", - rank, (unsigned long)(dims[0]), (unsigned long)(dims[1])); + printf("dataset rank %d, dimensions %lu x %lu\n", rank, (unsigned long)(dims[0]), + (unsigned long)(dims[1])); /* * Define the memory space to read dataset. */ - memspace = H5Screate_simple(RANK,dims,NULL); + memspace = H5Screate_simple(RANK, dims, NULL); /* * Read dataset back and display. */ - status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, data_out); + status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, data_out); printf("\n"); printf("Dataset: \n"); for (j = 0; j < dims[0]; j++) { - for (i = 0; i < dims[1]; i++) printf("%d ", data_out[j][i]); - printf("\n"); + for (i = 0; i < dims[1]; i++) + printf("%d ", data_out[j][i]); + printf("\n"); } /* @@ -110,7 +108,7 @@ main (void) * and read it into column array. */ col_dims[0] = 10; - memspace = H5Screate_simple(RANKC, col_dims, NULL); + memspace = H5Screate_simple(RANKC, col_dims, NULL); /* * Define the column (hyperslab) to read. @@ -119,14 +117,12 @@ main (void) offset[1] = 2; count[0] = 10; count[1] = 1; - status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, - count, NULL); - status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, column); + status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, count, NULL); + status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, column); printf("\n"); printf("Third column: \n"); for (i = 0; i < 10; i++) { - printf("%d \n", column[i]); + printf("%d \n", column[i]); } /* @@ -153,19 +149,19 @@ main (void) */ cparms = H5Dget_create_plist(dataset); /* Get properties handle first. */ - if (H5D_CHUNKED == H5Pget_layout(cparms)) { + if (H5D_CHUNKED == H5Pget_layout(cparms)) { - /* - * Get chunking information: rank and dimensions - */ - rank_chunk = H5Pget_chunk(cparms, 2, chunk_dims); - printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk, - (unsigned long)(chunk_dims[0]), (unsigned long)(chunk_dims[1])); + /* + * Get chunking information: rank and dimensions + */ + rank_chunk = H5Pget_chunk(cparms, 2, chunk_dims); + printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk, (unsigned long)(chunk_dims[0]), + (unsigned long)(chunk_dims[1])); /* * Define the memory space to read a chunk. */ - memspace = H5Screate_simple(rank_chunk,chunk_dims,NULL); + memspace = H5Screate_simple(rank_chunk, chunk_dims, NULL); /* * Define chunk in the file (hyperslab) to read. @@ -174,18 +170,17 @@ main (void) offset[1] = 0; count[0] = chunk_dims[0]; count[1] = chunk_dims[1]; - status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, - count, NULL); + status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, count, NULL); /* * Read chunk back and display. */ - status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, chunk_out); + status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, chunk_out); printf("\n"); printf("Chunk: \n"); for (j = 0; j < chunk_dims[0]; j++) { - for (i = 0; i < chunk_dims[1]; i++) printf("%d ", chunk_out[j][i]); + for (i = 0; i < chunk_dims[1]; i++) + printf("%d ", chunk_out[j][i]); printf("\n"); } /* |