summaryrefslogtreecommitdiffstats
path: root/examples/h5_chunk_read.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-12-29 14:26:20 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-12-29 14:26:20 (GMT)
commit427ff7da2848042f68ecfadf5a321b1d8077e9db (patch)
tree73024b1954031fbb724c2d96a485590348e5cc22 /examples/h5_chunk_read.c
parent9b96fd2003ae74cca389cc4c2216b4371d6eb173 (diff)
downloadhdf5-427ff7da2848042f68ecfadf5a321b1d8077e9db.zip
hdf5-427ff7da2848042f68ecfadf5a321b1d8077e9db.tar.gz
hdf5-427ff7da2848042f68ecfadf5a321b1d8077e9db.tar.bz2
[svn-r9727] Purpose:
Bug Fix/Code Cleanup/Doc Cleanup/Optimization/Branch Sync :-) Description: Generally speaking, this is the "signed->unsigned" change to selections. However, in the process of merging code back, things got stickier and stickier until I ended up doing a big "sync the two branches up" operation. So... I brought back all the "infrastructure" fixes from the development branch to the release branch (which I think were actually making some improvement in performance) as well as fixed several bugs which had been fixed in one branch, but not the other. I've also tagged the repository before making this checkin with the label "before_signed_unsigned_changes". Platforms tested: FreeBSD 4.10 (sleipnir) w/parallel & fphdf5 FreeBSD 4.10 (sleipnir) w/threadsafe FreeBSD 4.10 (sleipnir) w/backward compatibility Solaris 2.7 (arabica) w/"purify options" Solaris 2.8 (sol) w/FORTRAN & C++ AIX 5.x (copper) w/parallel & FORTRAN IRIX64 6.5 (modi4) w/FORTRAN Linux 2.4 (heping) w/FORTRAN & C++ Misc. update:
Diffstat (limited to 'examples/h5_chunk_read.c')
-rw-r--r--examples/h5_chunk_read.c106
1 files changed, 58 insertions, 48 deletions
diff --git a/examples/h5_chunk_read.c b/examples/h5_chunk_read.c
index c6bf728..af87c10 100644
--- a/examples/h5_chunk_read.c
+++ b/examples/h5_chunk_read.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
@@ -39,7 +38,7 @@ main (void)
hsize_t chunk_dims[2];
hsize_t col_dims[1];
hsize_t count[2];
- hssize_t offset[2];
+ hsize_t offset[2];
herr_t status, status_n;
@@ -68,24 +67,6 @@ main (void)
rank, (unsigned long)(dims[0]), (unsigned long)(dims[1]));
/*
- * Get creation properties list.
- */
- cparms = H5Dget_create_plist(dataset); /* Get properties handle first. */
-
- /*
- * Check if dataset is chunked.
- */
- 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]));
- }
-
- /*
* Define the memory space to read dataset.
*/
memspace = H5Screate_simple(RANK,dims,NULL);
@@ -103,6 +84,11 @@ main (void)
}
/*
+ * Close/release resources.
+ */
+ H5Sclose(memspace);
+
+ /*
* dataset rank 2, dimensions 10 x 5
* chunk rank 2, dimensions 2 x 5
@@ -145,6 +131,11 @@ main (void)
}
/*
+ * Close/release resources.
+ */
+ H5Sclose(memspace);
+
+ /*
* Third column:
* 1
* 1
@@ -159,36 +150,56 @@ main (void)
*/
/*
- * Define the memory space to read a chunk.
+ * Get creation properties list.
*/
- memspace = H5Screate_simple(rank_chunk,chunk_dims,NULL);
+ cparms = H5Dget_create_plist(dataset); /* Get properties handle first. */
- /*
- * Define chunk in the file (hyperslab) to read.
- */
- offset[0] = 2;
- offset[1] = 0;
- count[0] = chunk_dims[0];
- count[1] = chunk_dims[1];
- status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
- count, NULL);
+ if (H5D_CHUNKED == H5Pget_layout(cparms)) {
- /*
- * Read chunk back and display.
- */
- 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]);
- printf("\n");
- }
- /*
- * Chunk:
- * 1 1 1 0 0
- * 2 0 0 0 0
- */
+ /*
+ * 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);
+
+ /*
+ * Define chunk in the file (hyperslab) to read.
+ */
+ offset[0] = 2;
+ offset[1] = 0;
+ count[0] = chunk_dims[0];
+ count[1] = chunk_dims[1];
+ 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);
+ 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]);
+ printf("\n");
+ }
+ /*
+ * Chunk:
+ * 1 1 1 0 0
+ * 2 0 0 0 0
+ */
+
+ /*
+ * Close/release resources.
+ */
+ H5Sclose(memspace);
+ }
/*
* Close/release resources.
@@ -196,7 +207,6 @@ main (void)
H5Pclose(cparms);
H5Dclose(dataset);
H5Sclose(filespace);
- H5Sclose(memspace);
H5Fclose(file);
return 0;