summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/h5_attribute.c1
-rw-r--r--examples/h5_chunk_read.c106
-rw-r--r--examples/h5_compound.c1
-rw-r--r--examples/h5_drivers.c1
-rw-r--r--examples/h5_dtransform.c1
-rw-r--r--examples/h5_extend_write.c3
-rw-r--r--examples/h5_group.c1
-rw-r--r--examples/h5_mount.c1
-rw-r--r--examples/h5_read.c5
-rw-r--r--examples/h5_reference.c1
-rw-r--r--examples/h5_select.c7
-rw-r--r--examples/h5_write.c1
-rw-r--r--examples/ph5example.c80
13 files changed, 110 insertions, 99 deletions
diff --git a/examples/h5_attribute.c b/examples/h5_attribute.c
index 5b3c4f4..76609ec 100644
--- a/examples/h5_attribute.c
+++ b/examples/h5_attribute.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
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;
diff --git a/examples/h5_compound.c b/examples/h5_compound.c
index 6cde056..1819734 100644
--- a/examples/h5_compound.c
+++ b/examples/h5_compound.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
diff --git a/examples/h5_drivers.c b/examples/h5_drivers.c
index 51c7657..ebe870b 100644
--- a/examples/h5_drivers.c
+++ b/examples/h5_drivers.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
diff --git a/examples/h5_dtransform.c b/examples/h5_dtransform.c
index 153778a..3c15eec 100644
--- a/examples/h5_dtransform.c
+++ b/examples/h5_dtransform.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
diff --git a/examples/h5_extend_write.c b/examples/h5_extend_write.c
index 862cb98..bcb9949 100644
--- a/examples/h5_extend_write.c
+++ b/examples/h5_extend_write.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
@@ -46,7 +45,7 @@ main (void)
hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
hsize_t chunk_dims[2] ={2, 5};
hsize_t size[2];
- hssize_t offset[2];
+ hsize_t offset[2];
herr_t status;
diff --git a/examples/h5_group.c b/examples/h5_group.c
index f82978d..4e3eac1 100644
--- a/examples/h5_group.c
+++ b/examples/h5_group.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
diff --git a/examples/h5_mount.c b/examples/h5_mount.c
index 0811a09..7075201 100644
--- a/examples/h5_mount.c
+++ b/examples/h5_mount.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
diff --git a/examples/h5_read.c b/examples/h5_read.c
index 213bf47..9d57351 100644
--- a/examples/h5_read.c
+++ b/examples/h5_read.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
@@ -51,9 +50,9 @@ main (void)
int data_out[NX][NY][NZ ]; /* output buffer */
hsize_t count[2]; /* size of the hyperslab in the file */
- hssize_t offset[2]; /* hyperslab offset in the file */
+ hsize_t offset[2]; /* hyperslab offset in the file */
hsize_t count_out[3]; /* size of the hyperslab in memory */
- hssize_t offset_out[3]; /* hyperslab offset in memory */
+ hsize_t offset_out[3]; /* hyperslab offset in memory */
int i, j, k, status_n, rank;
for (j = 0; j < NX; j++) {
diff --git a/examples/h5_reference.c b/examples/h5_reference.c
index 7e159d1..45f8850 100644
--- a/examples/h5_reference.c
+++ b/examples/h5_reference.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
diff --git a/examples/h5_select.c b/examples/h5_select.c
index 498795c..0c34b1a 100644
--- a/examples/h5_select.c
+++ b/examples/h5_select.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
@@ -67,12 +66,12 @@ main (void)
read selection from the
dataset on the disk */
- hssize_t start[2]; /* Start of hyperslab */
+ hsize_t start[2]; /* Start of hyperslab */
hsize_t stride[2]; /* Stride of hyperslab */
hsize_t count[2]; /* Block count */
hsize_t block[2]; /* Block sizes */
- hssize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points
+ hsize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points
from the file dataspace */
herr_t ret;
unsigned i,j;
@@ -171,7 +170,7 @@ main (void)
coord[3][0] = 5; coord[3][1] = 6;
ret = H5Sselect_elements(fid, H5S_SELECT_SET, NPOINTS,
- (const hssize_t **)coord);
+ (const hsize_t **)coord);
/*
* Write new selection of points to the dataset.
diff --git a/examples/h5_write.c b/examples/h5_write.c
index 2c52fa7..8cc4b8f 100644
--- a/examples/h5_write.c
+++ b/examples/h5_write.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
diff --git a/examples/ph5example.c b/examples/ph5example.c
index c79d0ee..b2929ab 100644
--- a/examples/ph5example.c
+++ b/examples/ph5example.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
@@ -96,10 +95,10 @@ int dowrite=1; /* write test */
int docleanup=1; /* cleanup */
/* Prototypes */
-void slab_set(hssize_t start[], hsize_t count[], hsize_t stride[], int mode);
-void dataset_fill(hssize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset);
-void dataset_print(hssize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset);
-int dataset_vrfy(hssize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset, DATATYPE *original);
+void slab_set(hsize_t start[], hsize_t count[], hsize_t stride[], int mode);
+void dataset_fill(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset);
+void dataset_print(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset);
+int dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset, DATATYPE *original);
void phdf5writeInd(char *filename);
void phdf5readInd(char *filename);
void phdf5writeAll(char *filename);
@@ -117,7 +116,7 @@ void cleanup(void);
* Assume dimension rank is 2.
*/
void
-slab_set(hssize_t start[], hsize_t count[], hsize_t stride[], int mode)
+slab_set(hsize_t start[], hsize_t count[], hsize_t stride[], int mode)
{
switch (mode){
case BYROW:
@@ -157,10 +156,10 @@ slab_set(hssize_t start[], hsize_t count[], hsize_t stride[], int mode)
* Assume dimension rank is 2 and data is stored contiguous.
*/
void
-dataset_fill(hssize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset)
+dataset_fill(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset)
{
DATATYPE *dataptr = dataset;
- int i, j;
+ hsize_t i, j;
/* put some trivial data in the data_array */
for (i=0; i < count[0]; i++){
@@ -174,14 +173,14 @@ dataset_fill(hssize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dat
/*
* Print the content of the dataset.
*/
-void dataset_print(hssize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset)
+void dataset_print(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset)
{
DATATYPE *dataptr = dataset;
- int i, j;
+ hsize_t i, j;
/* print the slab read */
for (i=0; i < count[0]; i++){
- printf("Row %d: ", (int)(i*stride[0]+start[0]));
+ printf("Row %lu: ", (unsigned long)(i*stride[0]+start[0]));
for (j=0; j < count[1]; j++){
printf("%03d ", *dataptr++);
}
@@ -193,11 +192,12 @@ void dataset_print(hssize_t start[], hsize_t count[], hsize_t stride[], DATATYPE
/*
* Print the content of the dataset.
*/
-int dataset_vrfy(hssize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset, DATATYPE *original)
+int dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset, DATATYPE *original)
{
#define MAX_ERR_REPORT 10 /* Maximum number of errors reported */
- int i, j, nerr;
+ hsize_t i, j;
+ int nerr;
/* print it if verbose */
if (verbose)
@@ -209,9 +209,9 @@ int dataset_vrfy(hssize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *
if (*dataset++ != *original++){
nerr++;
if (nerr <= MAX_ERR_REPORT){
- printf("Dataset Verify failed at [%d][%d](row %d, col %d): expect %d, got %d\n",
- i, j,
- (int)(i*stride[0]+start[0]), (int)(j*stride[1]+start[1]),
+ printf("Dataset Verify failed at [%lu][%lu](row %lu, col %lu): expect %d, got %d\n",
+ (unsigned long)i, (unsigned long)j,
+ (unsigned long)(i*stride[0]+start[0]), (unsigned long)(j*stride[1]+start[1]),
*(dataset-1), *(original-1));
}
}
@@ -246,7 +246,7 @@ phdf5writeInd(char *filename)
{SPACE1_DIM1,SPACE1_DIM2}; /* dataspace dim sizes */
DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */
- hssize_t start[SPACE1_RANK]; /* for hyperslab setting */
+ hsize_t start[SPACE1_RANK]; /* for hyperslab setting */
hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
herr_t ret; /* Generic return value */
@@ -311,8 +311,10 @@ phdf5writeInd(char *filename)
stride[0] = 1;
stride[1] =1;
if (verbose)
- printf("start[]=(%d,%d), count[]=(%d,%d), total datapoints=%d\n",
- start[0], start[1], count[0], count[1], count[0]*count[1]);
+ printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n",
+ (unsigned long)start[0], (unsigned long)start[1],
+ (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)(count[0]*count[1]));
/* put some trivial data in the data_array */
dataset_fill(start, count, stride, &data_array1[0][0]);
@@ -373,7 +375,7 @@ phdf5readInd(char *filename)
DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */
DATATYPE data_origin1[SPACE1_DIM1][SPACE1_DIM2]; /* expected data buffer */
- hssize_t start[SPACE1_RANK]; /* for hyperslab setting */
+ hsize_t start[SPACE1_RANK]; /* for hyperslab setting */
hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
herr_t ret; /* Generic return value */
@@ -417,8 +419,10 @@ phdf5readInd(char *filename)
stride[0] = 1;
stride[1] =1;
if (verbose)
- printf("start[]=(%d,%d), count[]=(%d,%d), total datapoints=%d\n",
- start[0], start[1], count[0], count[1], count[0]*count[1]);
+ printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n",
+ (unsigned long)start[0], (unsigned long)start[1],
+ (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)(count[0]*count[1]));
/* create a file dataspace independently */
file_dataspace = H5Dget_space (dataset1);
@@ -489,7 +493,7 @@ phdf5writeAll(char *filename)
{SPACE1_DIM1,SPACE1_DIM2}; /* dataspace dim sizes */
DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */
- hssize_t start[SPACE1_RANK]; /* for hyperslab setting */
+ hsize_t start[SPACE1_RANK]; /* for hyperslab setting */
hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
herr_t ret; /* Generic return value */
@@ -549,8 +553,10 @@ phdf5writeAll(char *filename)
/* Dataset1: each process takes a block of rows. */
slab_set(start, count, stride, BYROW);
if (verbose)
- printf("start[]=(%d,%d), count[]=(%d,%d), total datapoints=%d\n",
- start[0], start[1], count[0], count[1], count[0]*count[1]);
+ printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n",
+ (unsigned long)start[0], (unsigned long)start[1],
+ (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)(count[0]*count[1]));
/* create a file dataspace independently */
file_dataspace = H5Dget_space (dataset1);
@@ -596,8 +602,10 @@ if (verbose)
/* Dataset2: each process takes a block of columns. */
slab_set(start, count, stride, BYCOL);
if (verbose)
- printf("start[]=(%d,%d), count[]=(%d,%d), total datapoints=%d\n",
- start[0], start[1], count[0], count[1], count[0]*count[1]);
+ printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n",
+ (unsigned long)start[0], (unsigned long)start[1],
+ (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)(count[0]*count[1]));
/* put some trivial data in the data_array */
dataset_fill(start, count, stride, &data_array1[0][0]);
@@ -685,7 +693,7 @@ phdf5readAll(char *filename)
DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */
DATATYPE data_origin1[SPACE1_DIM1][SPACE1_DIM2]; /* expected data buffer */
- hssize_t start[SPACE1_RANK]; /* for hyperslab setting */
+ hsize_t start[SPACE1_RANK]; /* for hyperslab setting */
hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
herr_t ret; /* Generic return value */
@@ -738,8 +746,10 @@ phdf5readAll(char *filename)
/* Dataset1: each process takes a block of columns. */
slab_set(start, count, stride, BYCOL);
if (verbose)
- printf("start[]=(%d,%d), count[]=(%d,%d), total datapoints=%d\n",
- start[0], start[1], count[0], count[1], count[0]*count[1]);
+ printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n",
+ (unsigned long)start[0], (unsigned long)start[1],
+ (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)(count[0]*count[1]));
/* create a file dataspace independently */
file_dataspace = H5Dget_space (dataset1);
@@ -789,8 +799,10 @@ if (verbose)
/* Dataset2: each process takes a block of rows. */
slab_set(start, count, stride, BYROW);
if (verbose)
- printf("start[]=(%d,%d), count[]=(%d,%d), total datapoints=%d\n",
- start[0], start[1], count[0], count[1], count[0]*count[1]);
+ printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n",
+ (unsigned long)start[0], (unsigned long)start[1],
+ (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)(count[0]*count[1]));
/* create a file dataspace independently */
file_dataspace = H5Dget_space (dataset1);
@@ -918,7 +930,7 @@ test_split_comm_access(char filenames[][PATH_MAX])
* Show command usage
*/
void
-usage()
+usage(void)
{
printf("Usage: testphdf5 [-f <prefix>] [-r] [-w] [-v]\n");
printf("\t-f\tfile prefix for parallel test files.\n");
@@ -1111,7 +1123,7 @@ finish:
#else /* H5_HAVE_PARALLEL */
/* dummy program since H5_HAVE_PARALLE is not configured in */
int
-main()
+main(void)
{
printf("No PHDF5 example because parallel is not configured in\n");
return(0);