summaryrefslogtreecommitdiffstats
path: root/examples/h5_chunk_read.c
diff options
context:
space:
mode:
authorElena Pourmal <epourmal@hdfgroup.org>1998-02-13 14:26:11 (GMT)
committerElena Pourmal <epourmal@hdfgroup.org>1998-02-13 14:26:11 (GMT)
commit7cfd4f3872953ed92c25fa3079c4f9a26111f94b (patch)
treef46f712aafc0e7774d23db6df6f7d81edf0cf951 /examples/h5_chunk_read.c
parentea3daf23d061495c62186608635a091be743868b (diff)
downloadhdf5-7cfd4f3872953ed92c25fa3079c4f9a26111f94b.zip
hdf5-7cfd4f3872953ed92c25fa3079c4f9a26111f94b.tar.gz
hdf5-7cfd4f3872953ed92c25fa3079c4f9a26111f94b.tar.bz2
[svn-r267] Example has been updated to show how to read a hyperslab (column) from a
chunked dataset.
Diffstat (limited to 'examples/h5_chunk_read.c')
-rw-r--r--examples/h5_chunk_read.c47
1 files changed, 44 insertions, 3 deletions
diff --git a/examples/h5_chunk_read.c b/examples/h5_chunk_read.c
index be2a0be..859e526 100644
--- a/examples/h5_chunk_read.c
+++ b/examples/h5_chunk_read.c
@@ -8,8 +8,9 @@
#define FILE "SDSextendible.h5"
#define DATASETNAME "ExtendibleArray"
#define RANK 2
-#define NX 10
-#define NY 5
+#define RANKC 1
+#define NX 10
+#define NY 5
main ()
{
@@ -23,7 +24,7 @@ main ()
stored in file */
size_t dims[2]; /* dataset and chunk dimensions */
size_t chunk_dims[2];
-
+ size_t col_dims[1];
size_t size[2];
size_t count[2];
int offset[2];
@@ -32,6 +33,7 @@ main ()
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 i, j, rank, rank_chunk;
@@ -103,6 +105,45 @@ for (j = 0; j < dims[0]; j++) {
*/
/*
+ * Read the third column from the dataset.
+ * First define memory dataspace, then define hyperslab
+ * and read it into column array.
+ */
+col_dims[0] = 10;
+memspace = H5Pcreate_simple(RANKC, col_dims, NULL);
+
+/*
+ * Define the column (hyperslab) to read.
+ */
+offset[0] = 0;
+offset[1] = 2;
+count[0] = 10;
+count[1] = 1;
+status = H5Pset_hyperslab(filespace, offset, count, NULL);
+status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace,
+ H5C_DEFAULT, column);
+printf("\n");
+printf("Third column: \n");
+for (i = 0; i < 10; i++) {
+ printf("%d \n", column[i]);
+}
+
+/*
+
+ Third column:
+ 1
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+*/
+
+/*
* Define the memory space to read a chunk.
*/
memspace = H5Pcreate_simple(rank_chunk,chunk_dims,NULL);