summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-08-13 20:53:35 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-08-13 20:53:35 (GMT)
commit6b45f5172ccb4311e0be9ae15da3758abb6b0e67 (patch)
tree5a7a112fe7a8a98c6fecb45b513789d15962eb3d /examples
parent6562465a2c2a58cfbc2f47bf60bb538f7a783933 (diff)
downloadhdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.zip
hdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.tar.gz
hdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.tar.bz2
[svn-r11245] Purpose:
Code cleanup Description: Trim trailing whitespace, which is making 'diff'ing the two branches difficult. Solution: Ran this script in each directory: foreach f (*.[ch] *.cpp) sed 's/[[:blank:]]*$//' $f > sed.out && mv sed.out $f end Platforms tested: FreeBSD 4.11 (sleipnir) Too minor to require h5committest
Diffstat (limited to 'examples')
-rw-r--r--examples/h5_attribute.c78
-rw-r--r--examples/h5_chunk_read.c90
-rw-r--r--examples/h5_compound.c16
-rw-r--r--examples/h5_drivers.c8
-rw-r--r--examples/h5_dtransform.c34
-rw-r--r--examples/h5_extend_write.c62
-rw-r--r--examples/h5_group.c74
-rw-r--r--examples/h5_mount.c40
-rw-r--r--examples/h5_read.c60
-rw-r--r--examples/h5_reference.c66
-rw-r--r--examples/h5_select.c162
-rw-r--r--examples/h5_write.c28
-rw-r--r--examples/ph5example.c84
13 files changed, 401 insertions, 401 deletions
diff --git a/examples/h5_attribute.c b/examples/h5_attribute.c
index 76609ec..6857236 100644
--- a/examples/h5_attribute.c
+++ b/examples/h5_attribute.c
@@ -12,52 +12,52 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
+/*
* This program illustrates the usage of the H5A Interface functions.
* It creates and writes a dataset, and then creates and writes array,
- * scalar, and string attributes of the dataset.
+ * scalar, and string attributes of the dataset.
* Program reopens the file, attaches to the scalar attribute using
* attribute name and reads and displays its value. Then index of the
* third attribute is used to read and display attribute values.
* The H5Aiterate function is used to iterate through the dataset attributes,
- * and display their names. The function is also reads and displays the values
- * of the array attribute.
- */
-
+ * and display their names. The function is also reads and displays the values
+ * of the array attribute.
+ */
+
#include <stdlib.h>
#include "hdf5.h"
#define H5FILE_NAME "Attributes.h5"
-#define RANK 1 /* Rank and size of the dataset */
+#define RANK 1 /* Rank and size of the dataset */
#define SIZE 7
#define ARANK 2 /* Rank and dimension sizes of the first dataset attribute */
#define ADIM1 2
-#define ADIM2 3
+#define ADIM2 3
#define ANAME "Float attribute" /* Name of the array attribute */
#define ANAMES "Character attribute" /* Name of the string attribute */
-herr_t attr_info(hid_t loc_id, const char *name, void *opdata);
+herr_t attr_info(hid_t loc_id, const char *name, void *opdata);
/* Operator function */
-int
+int
main (void)
{
hid_t file, dataset; /* File and dataset identifiers */
-
+
hid_t fid; /* Dataspace identifier */
hid_t attr1, attr2, attr3; /* Attribute identifiers */
hid_t attr;
- hid_t aid1, aid2, aid3; /* Attribute dataspace identifiers */
+ hid_t aid1, aid2, aid3; /* Attribute dataspace identifiers */
hid_t atype; /* Attribute type */
hsize_t fdim[] = {SIZE};
hsize_t adim[] = {ADIM1, ADIM2}; /* Dimensions of the first attribute */
-
- float matrix[ADIM1][ADIM2]; /* Attribute data */
+
+ float matrix[ADIM1][ADIM2]; /* Attribute data */
herr_t ret; /* Return value */
unsigned i,j; /* Counters */
@@ -69,10 +69,10 @@ main (void)
* Data initialization.
*/
int vector[] = {1, 2, 3, 4, 5, 6, 7}; /* Dataset data */
- int point = 1; /* Value of the scalar attribute */
+ int point = 1; /* Value of the scalar attribute */
char string[] = "ABCD"; /* Value of the string attribute */
-
+
for (i=0; i < ADIM1; i++) { /* Values of the array attribute */
for (j=0; j < ADIM2; j++)
matrix[i][j] = -1.;
@@ -83,7 +83,7 @@ main (void)
*/
file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- /*
+ /*
* Create the dataspace for the dataset in the file.
*/
fid = H5Screate(H5S_SIMPLE);
@@ -100,7 +100,7 @@ main (void)
ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT, vector);
/*
- * Create dataspace for the first attribute.
+ * Create dataspace for the first attribute.
*/
aid1 = H5Screate(H5S_SIMPLE);
ret = H5Sset_extent_simple(aid1, ARANK, adim, NULL);
@@ -125,7 +125,7 @@ main (void)
/*
* Write scalar attribute.
*/
- ret = H5Awrite(attr2, H5T_NATIVE_INT, &point);
+ ret = H5Awrite(attr2, H5T_NATIVE_INT, &point);
/*
* Create string attribute.
@@ -139,23 +139,23 @@ main (void)
/*
* Write string attribute.
*/
- ret = H5Awrite(attr3, atype, string);
+ ret = H5Awrite(attr3, atype, string);
/*
* Close attribute and file dataspaces.
*/
- ret = H5Sclose(aid1);
- ret = H5Sclose(aid2);
- ret = H5Sclose(aid3);
- ret = H5Sclose(fid);
+ ret = H5Sclose(aid1);
+ ret = H5Sclose(aid2);
+ ret = H5Sclose(aid3);
+ ret = H5Sclose(fid);
/*
* Close the attributes.
- */
+ */
ret = H5Aclose(attr1);
ret = H5Aclose(attr2);
ret = H5Aclose(attr3);
-
+
/*
* Close the dataset.
*/
@@ -177,12 +177,12 @@ main (void)
dataset = H5Dopen(file,"Dataset");
/*
- * Attach to the scalar attribute using attribute name, then read and
+ * Attach to the scalar attribute using attribute name, then read and
* display its value.
*/
attr = H5Aopen_name(dataset,"Integer attribute");
ret = H5Aread(attr, H5T_NATIVE_INT, &point_out);
- printf("The value of the attribute \"Integer attribute\" is %d \n", point_out);
+ printf("The value of the attribute \"Integer attribute\" is %d \n", point_out);
ret = H5Aclose(attr);
/*
@@ -197,7 +197,7 @@ main (void)
ret = H5Tclose(atype);
/*
- * Get attribute info using iteration function.
+ * Get attribute info using iteration function.
*/
idx = H5Aiterate(dataset, NULL, attr_info, NULL);
@@ -207,21 +207,21 @@ main (void)
H5Dclose(dataset);
H5Fclose(file);
- return 0;
+ return 0;
}
/*
* Operator function.
*/
-herr_t
+herr_t
attr_info(hid_t loc_id, const char *name, void *opdata)
{
hid_t attr, atype, aspace; /* Attribute, datatype and dataspace identifiers */
int rank;
- hsize_t sdim[64];
+ hsize_t sdim[64];
herr_t ret;
int i;
- size_t npoints; /* Number of elements in the array attribute. */
+ size_t npoints; /* Number of elements in the array attribute. */
float *float_array; /* Pointer to the array attribute. */
/* avoid warnings */
@@ -229,7 +229,7 @@ attr_info(hid_t loc_id, const char *name, void *opdata)
/*
* Open the attribute using its name.
- */
+ */
attr = H5Aopen_name(loc_id, name);
/*
@@ -239,7 +239,7 @@ attr_info(hid_t loc_id, const char *name, void *opdata)
printf("Name : ");
puts(name);
- /*
+ /*
* Get attribute datatype, dataspace, rank, and dimensions.
*/
atype = H5Aget_type(attr);
@@ -252,7 +252,7 @@ attr_info(hid_t loc_id, const char *name, void *opdata)
*/
if(rank > 0) {
- printf("Rank : %d \n", rank);
+ printf("Rank : %d \n", rank);
printf("Dimension sizes : ");
for (i=0; i< rank; i++) printf("%d ", (int)sdim[i]);
printf("\n");
@@ -263,12 +263,12 @@ attr_info(hid_t loc_id, const char *name, void *opdata)
*/
if (H5T_FLOAT == H5Tget_class(atype)) {
- printf("Type : FLOAT \n");
+ printf("Type : FLOAT \n");
npoints = H5Sget_simple_extent_npoints(aspace);
- float_array = (float *)malloc(sizeof(float)*(int)npoints);
+ float_array = (float *)malloc(sizeof(float)*(int)npoints);
ret = H5Aread(attr, atype, float_array);
printf("Values : ");
- for( i = 0; i < (int)npoints; i++) printf("%f ", float_array[i]);
+ for( i = 0; i < (int)npoints; i++) printf("%f ", float_array[i]);
printf("\n");
free(float_array);
}
diff --git a/examples/h5_chunk_read.c b/examples/h5_chunk_read.c
index af87c10..7bc7324 100644
--- a/examples/h5_chunk_read.c
+++ b/examples/h5_chunk_read.c
@@ -12,50 +12,50 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
+/*
* This example shows how to read data from a chunked dataset.
- * We will read from the file created by h5_extend_write.c
+ * We will read from the file created by h5_extend_write.c
*/
-
+
#include "hdf5.h"
#define H5FILE_NAME "SDSextendible.h5"
-#define DATASETNAME "ExtendibleArray"
+#define DATASETNAME "ExtendibleArray"
#define RANK 2
#define RANKC 1
#define NX 10
-#define NY 5
+#define NY 5
int
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*/
+ 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;
+ 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;
hsize_t i, j;
-
-
+
+
/*
* Open the file and the dataset.
*/
file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT);
dataset = H5Dopen(file, DATASETNAME);
-
+
/*
* Get dataset rank and dimension.
*/
@@ -70,7 +70,7 @@ main (void)
* Define the memory space to read dataset.
*/
memspace = H5Screate_simple(RANK,dims,NULL);
-
+
/*
* Read dataset back and display.
*/
@@ -81,7 +81,7 @@ main (void)
for (j = 0; j < dims[0]; j++) {
for (i = 0; i < dims[1]; i++) printf("%d ", data_out[j][i]);
printf("\n");
- }
+ }
/*
* Close/release resources.
@@ -89,20 +89,20 @@ main (void)
H5Sclose(memspace);
/*
- * dataset rank 2, dimensions 10 x 5
- * chunk rank 2, dimensions 2 x 5
+ * dataset rank 2, dimensions 10 x 5
+ * chunk rank 2, dimensions 2 x 5
* Dataset:
- * 1 1 1 3 3
- * 1 1 1 3 3
- * 1 1 1 0 0
- * 2 0 0 0 0
- * 2 0 0 0 0
- * 2 0 0 0 0
- * 2 0 0 0 0
- * 2 0 0 0 0
- * 2 0 0 0 0
- * 2 0 0 0 0
+ * 1 1 1 3 3
+ * 1 1 1 3 3
+ * 1 1 1 0 0
+ * 2 0 0 0 0
+ * 2 0 0 0 0
+ * 2 0 0 0 0
+ * 2 0 0 0 0
+ * 2 0 0 0 0
+ * 2 0 0 0 0
+ * 2 0 0 0 0
*/
/*
@@ -136,17 +136,17 @@ main (void)
H5Sclose(memspace);
/*
- * Third column:
- * 1
- * 1
- * 1
- * 0
- * 0
- * 0
- * 0
- * 0
- * 0
- * 0
+ * Third column:
+ * 1
+ * 1
+ * 1
+ * 0
+ * 0
+ * 0
+ * 0
+ * 0
+ * 0
+ * 0
*/
/*
@@ -175,7 +175,7 @@ main (void)
offset[1] = 0;
count[0] = chunk_dims[0];
count[1] = chunk_dims[1];
- status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
+ status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
count, NULL);
/*
@@ -188,11 +188,11 @@ main (void)
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
+ * Chunk:
+ * 1 1 1 0 0
+ * 2 0 0 0 0
*/
/*
@@ -210,4 +210,4 @@ main (void)
H5Fclose(file);
return 0;
-}
+}
diff --git a/examples/h5_compound.c b/examples/h5_compound.c
index 1819734..6a88448 100644
--- a/examples/h5_compound.c
+++ b/examples/h5_compound.c
@@ -33,7 +33,7 @@ main(void)
typedef struct s1_t {
int a;
float b;
- double c;
+ double c;
} s1_t;
s1_t s1[LENGTH];
hid_t s1_tid; /* File datatype identifier */
@@ -76,20 +76,20 @@ main(void)
file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/*
- * Create the memory data type.
+ * Create the memory data type.
*/
s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t));
H5Tinsert(s1_tid, "a_name", HOFFSET(s1_t, a), H5T_NATIVE_INT);
H5Tinsert(s1_tid, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE);
H5Tinsert(s1_tid, "b_name", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT);
- /*
+ /*
* Create the dataset.
*/
dataset = H5Dcreate(file, DATASETNAME, s1_tid, space, H5P_DEFAULT);
/*
- * Wtite data to the dataset;
+ * Wtite data to the dataset;
*/
status = H5Dwrite(dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1);
@@ -100,15 +100,15 @@ main(void)
H5Sclose(space);
H5Dclose(dataset);
H5Fclose(file);
-
+
/*
* Open the file and the dataset.
*/
file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT);
-
+
dataset = H5Dopen(file, DATASETNAME);
- /*
+ /*
* Create a data type for s2
*/
s2_tid = H5Tcreate(H5T_COMPOUND, sizeof(s2_t));
@@ -135,7 +135,7 @@ main(void)
for( i = 0; i < LENGTH; i++) printf("%d ", s2[i].a);
printf("\n");
- /*
+ /*
* Create a data type for s3.
*/
s3_tid = H5Tcreate(H5T_COMPOUND, sizeof(float));
diff --git a/examples/h5_drivers.c b/examples/h5_drivers.c
index ebe870b..5dea143 100644
--- a/examples/h5_drivers.c
+++ b/examples/h5_drivers.c
@@ -12,13 +12,13 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
+/*
* This shows how to use the hdf5 virtual file drivers.
* The example codes here do not check return values for the
* sake of simplicity. As in all proper programs, return codes
* should be checked.
*/
-
+
#include "hdf5.h"
#include "stdlib.h"
@@ -96,8 +96,8 @@ split_file(void)
int
main (void)
{
-
+
split_file();
return(0);
-}
+}
diff --git a/examples/h5_dtransform.c b/examples/h5_dtransform.c
index 3c15eec..2208e7e 100644
--- a/examples/h5_dtransform.c
+++ b/examples/h5_dtransform.c
@@ -12,8 +12,8 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
- * This example demonstrates how the data transform features of
+/*
+ * This example demonstrates how the data transform features of
* HDF5 works.
*
* (1)
@@ -31,7 +31,7 @@
* (4)
* Get the transform from the property using H5Pget_data_transform.
*/
-
+
#include "hdf5.h"
#define ROWS 12
@@ -63,7 +63,7 @@ const float windchillF[ROWS][COLS] =
}
-
+
int
main (void)
@@ -71,8 +71,8 @@ main (void)
hid_t file, dataset; /* file and dataset handles */
hid_t dataspace; /* handles */
hsize_t dimsf[2]; /* dataset dimensions */
- herr_t status;
- hid_t dxpl_id_f_to_c, dxpl_id_c_to_f; /* data transform handles */
+ herr_t status;
+ hid_t dxpl_id_f_to_c, dxpl_id_c_to_f; /* data transform handles */
const char* f_to_c = "(5/9.0)*(x-32)";
const char* c_to_f = "(9/5.0)*x + 32";
char* transform;
@@ -88,11 +88,11 @@ main (void)
/*
* Describe the size of the array and create the data space for fixed
- * size dataset.
+ * size dataset.
*/
dimsf[0] = ROWS;
dimsf[1] = COLS;
- dataspace = H5Screate_simple(2, dimsf, NULL);
+ dataspace = H5Screate_simple(2, dimsf, NULL);
/*
* Create a new dataset within the file using defined dataspace and
@@ -125,11 +125,11 @@ main (void)
/* Print the data from the read*/
printf("\nData with no write transform, but a read transform: \n");
PRINT(windchillC);
-
+
/**************** PART 2 **************/
/*
- * Write the data to the dataset with the f_to_c transform set
+ * Write the data to the dataset with the f_to_c transform set
*/
status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
dxpl_id_f_to_c, windchillF);
@@ -142,8 +142,8 @@ main (void)
PRINT(windchillC);
/************** PART 3 ***************/
-
-
+
+
/* Create the dataset transfer property list */
dxpl_id_c_to_f = H5Pcreate(H5P_DATASET_XFER);
@@ -156,7 +156,7 @@ main (void)
*/
status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
dxpl_id_f_to_c, windchillF);
-
+
/* Read the data with the c_to_f data transform */
H5Dread(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillC);
@@ -168,9 +168,9 @@ main (void)
transform_size = H5Pget_data_transform(dxpl_id_f_to_c, NULL, 0);
transform = (char*) malloc(transform_size+1);
H5Pget_data_transform(dxpl_id_f_to_c, transform, transform_size+1);
-
+
printf("\nTransform string (from dxpl_id_f_to_c) is: %s\n", transform);
-
+
/*
* Close/release resources.
*/
@@ -179,6 +179,6 @@ main (void)
H5Sclose(dataspace);
H5Dclose(dataset);
H5Fclose(file);
-
+
return 0;
-}
+}
diff --git a/examples/h5_extend_write.c b/examples/h5_extend_write.c
index bcb9949..9a30d46 100644
--- a/examples/h5_extend_write.c
+++ b/examples/h5_extend_write.c
@@ -12,46 +12,46 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
+/*
* This example shows how to work with extendible dataset.
* In the current version of the library dataset MUST be
* chunked.
- *
+ *
*/
-
+
#include "hdf5.h"
#define H5FILE_NAME "SDSextendible.h5"
-#define DATASETNAME "ExtendibleArray"
+#define DATASETNAME "ExtendibleArray"
#define RANK 2
#define NX 10
-#define NY 5
+#define NY 5
int
main (void)
{
hid_t file; /* handles */
- hid_t dataspace, dataset;
- hid_t filespace;
- hid_t cparms;
+ hid_t dataspace, dataset;
+ hid_t filespace;
+ hid_t cparms;
hsize_t dims[2] = { 3, 3}; /*
- * dataset dimensions
+ * 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 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];
- herr_t status;
+ herr_t status;
int data1[3][3] = { {1, 1, 1}, /* data to write */
{1, 1, 1},
- {1, 1, 1} };
+ {1, 1, 1} };
int data2[7] = { 2, 2, 2, 2, 2, 2, 2};
@@ -60,16 +60,16 @@ main (void)
int fillvalue = 0;
/*
- * Create the data space with unlimited dimensions.
+ * Create the data space with unlimited dimensions.
*/
- dataspace = H5Screate_simple(RANK, dims, maxdims);
+ dataspace = H5Screate_simple(RANK, dims, maxdims);
/*
* Create a new file. If file exists its contents will be overwritten.
*/
file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- /*
+ /*
* Modify dataset creation properties, i.e. enable chunking.
*/
cparms = H5Pcreate(H5P_DATASET_CREATE);
@@ -86,8 +86,8 @@ main (void)
/*
* Extend the dataset. This call assures that dataset is at least 3 x 3.
*/
- size[0] = 3;
- size[1] = 3;
+ size[0] = 3;
+ size[1] = 3;
status = H5Dextend (dataset, size);
/*
@@ -97,7 +97,7 @@ main (void)
offset[0] = 0;
offset[1] = 0;
status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
- dims1, NULL);
+ dims1, NULL);
/*
* Write the data to the hyperslab.
@@ -109,8 +109,8 @@ main (void)
* Extend the dataset. Dataset becomes 10 x 3.
*/
dims[0] = dims1[0] + dims2[0];
- size[0] = dims[0];
- size[1] = dims[1];
+ size[0] = dims[0];
+ size[1] = dims[1];
status = H5Dextend (dataset, size);
/*
@@ -120,12 +120,12 @@ main (void)
offset[0] = 3;
offset[1] = 0;
status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
- dims2, NULL);
+ dims2, NULL);
/*
* Define memory space
*/
- dataspace = H5Screate_simple(RANK, dims2, NULL);
+ dataspace = H5Screate_simple(RANK, dims2, NULL);
/*
* Write the data to the hyperslab.
@@ -137,8 +137,8 @@ main (void)
* Extend the dataset. Dataset becomes 10 x 5.
*/
dims[1] = dims1[1] + dims3[1];
- size[0] = dims[0];
- size[1] = dims[1];
+ size[0] = dims[0];
+ size[1] = dims[1];
status = H5Dextend (dataset, size);
/*
@@ -147,13 +147,13 @@ 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.
*/
- dataspace = H5Screate_simple(RANK, dims3, NULL);
+ dataspace = H5Screate_simple(RANK, dims3, NULL);
/*
* Write the data to the hyperslab.
@@ -163,7 +163,7 @@ main (void)
/*
* Resulting dataset
- *
+ *
* 3 3 3 2 2
* 3 3 3 2 2
* 3 3 3 0 0
@@ -185,4 +185,4 @@ main (void)
H5Fclose(file);
return 0;
-}
+}
diff --git a/examples/h5_group.c b/examples/h5_group.c
index 4e3eac1..7afe19b 100644
--- a/examples/h5_group.c
+++ b/examples/h5_group.c
@@ -13,12 +13,12 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * This program creates a group in the file and two datasets in the group.
+ * This program creates a group in the file and two datasets in the group.
* Hard link to the group object is created and one of the datasets is accessed
- * under new name.
+ * under new name.
* Iterator functions are used to find information about the objects
- * in the root group and in the created group.
- */
+ * in the root group and in the created group.
+ */
#include "hdf5.h"
@@ -38,12 +38,12 @@ main(void)
hid_t file;
hid_t grp;
hid_t dataset, dataspace;
- hid_t plist;
+ hid_t plist;
herr_t status;
hsize_t dims[2];
hsize_t cdims[2];
-
+
int idx_f, idx_g;
/*
@@ -52,15 +52,15 @@ main(void)
file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/*
- * Create a group in the file.
+ * Create a group in the file.
*/
grp = H5Gcreate(file, "/Data", 0);
/*
* Create dataset "Compressed Data" in the group using absolute
- * name. Dataset creation property list is modified to use
- * GZIP compression with the compression effort set to 6.
- * Note that compression can be used only when dataset is chunked.
+ * name. Dataset creation property list is modified to use
+ * GZIP compression with the compression effort set to 6.
+ * Note that compression can be used only when dataset is chunked.
*/
dims[0] = 1000;
dims[1] = 20;
@@ -69,16 +69,16 @@ main(void)
dataspace = H5Screate_simple(RANK, dims, NULL);
plist = H5Pcreate(H5P_DATASET_CREATE);
H5Pset_chunk(plist, 2, cdims);
- H5Pset_deflate( plist, 6);
- dataset = H5Dcreate(file, "/Data/Compressed_Data", H5T_NATIVE_INT,
- dataspace, plist);
- /*
+ H5Pset_deflate( plist, 6);
+ dataset = H5Dcreate(file, "/Data/Compressed_Data", H5T_NATIVE_INT,
+ dataspace, plist);
+ /*
* Close the first dataset .
*/
H5Sclose(dataspace);
H5Dclose(dataset);
- /*
+ /*
* Create the second dataset.
*/
dims[0] = 500;
@@ -87,7 +87,7 @@ main(void)
dataset = H5Dcreate(file, "/Data/Float_Data", H5T_NATIVE_FLOAT,
dataspace, H5P_DEFAULT);
- /*
+ /*
*Close the second dataset and file.
*/
H5Sclose(dataspace);
@@ -96,13 +96,13 @@ main(void)
H5Fclose(file);
/*
- * Now reopen the file and group in the file.
+ * Now reopen the file and group in the file.
*/
file = H5Fopen(H5FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
grp = H5Gopen(file, "Data");
- /*
- * Access "Compressed_Data" dataset in the group.
+ /*
+ * Access "Compressed_Data" dataset in the group.
*/
dataset = H5Dopen(grp, "Compressed_Data");
if( dataset < 0) printf(" Dataset 'Compressed-Data' is not found. \n");
@@ -118,9 +118,9 @@ main(void)
*/
status = H5Glink(file, H5G_LINK_HARD, "Data", "Data_new");
- /*
+ /*
* We can access "Compressed_Data" dataset using created
- * hard link "Data_new".
+ * hard link "Data_new".
*/
dataset = H5Dopen(file, "/Data_new/Compressed_Data");
if( dataset < 0) printf(" Dataset is not found. \n");
@@ -132,7 +132,7 @@ main(void)
status = H5Dclose(dataset);
- /*
+ /*
* Use iterator to see the names of the objects in the root group.
*/
idx_f = H5Giterate(file, "/", NULL, file_info, NULL);
@@ -141,15 +141,15 @@ main(void)
* Unlink name "Data" and use iterator to see the names
* of the objects in the file root direvtory.
*/
- if (H5Gunlink(file, "Data") < 0)
+ if (H5Gunlink(file, "Data") < 0)
printf(" H5Gunlink failed \n");
- else
+ else
printf("\"Data\" is unlinked \n");
idx_f = H5Giterate(file, "/", NULL, file_info, NULL);
- /*
- * Use iterator to see the names of the objects in the group
+ /*
+ * Use iterator to see the names of the objects in the group
* /Data_new.
*/
idx_g = H5Giterate(grp, "/Data_new", NULL, group_info, NULL);
@@ -157,7 +157,7 @@ main(void)
/*
* Close the file.
*/
-
+
status = H5Fclose(file);
return 0;
@@ -173,13 +173,13 @@ herr_t file_info(hid_t loc_id, const char *name, void *opdata)
opdata = opdata;
/*
- * Display group name. The name is passed to the function by
+ * Display group name. The name is passed to the function by
* the Library. Some magic :-)
*/
printf("\n");
printf("Name : ");
puts(name);
-
+
return 0;
}
@@ -204,20 +204,20 @@ herr_t group_info(hid_t loc_id, const char *name, void *opdata)
* Open the datasets using their names.
*/
did = H5Dopen(loc_id, name);
-
+
/*
* Display dataset name.
*/
printf("\n");
printf("Name : ");
puts(name);
-
- /*
+
+ /*
* Display dataset information.
*/
tid = H5Dget_type(did); /* get datatype*/
pid = H5Dget_create_plist(did); /* get creation property list */
-
+
/*
* Check if dataset is chunked.
*/
@@ -226,13 +226,13 @@ herr_t group_info(hid_t loc_id, const char *name, void *opdata)
* get chunking information: rank and dimensions.
*/
rank_chunk = H5Pget_chunk(pid, 2, chunk_dims_out);
- printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk,
+ printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk,
(unsigned long)(chunk_dims_out[0]),
(unsigned long)(chunk_dims_out[1]));
- }
+ }
else{
t_class = H5Tget_class(tid);
- if(t_class < 0){
+ if(t_class < 0){
puts(" Invalid datatype.\n");
}
else {
@@ -250,7 +250,7 @@ herr_t group_info(hid_t loc_id, const char *name, void *opdata)
puts(" Datatype is 'H5T_NATIVE_COMPOUND'.\n");
}
}
-
+
H5Dclose(did);
H5Pclose(pid);
diff --git a/examples/h5_mount.c b/examples/h5_mount.c
index 7075201..00927ff 100644
--- a/examples/h5_mount.c
+++ b/examples/h5_mount.c
@@ -12,12 +12,12 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
- * This program shows the concept of "mounting files".
+/*
+ * This program shows the concept of "mounting files".
* Program creates one file with group G in it, and another
* file with dataset D. Then second file is mounted in the first one
- * under the "mounting point" G. Dataset D is accessed in the first file
- * under name /G/D and data is printed out.
+ * under the "mounting point" G. Dataset D is accessed in the first file
+ * under name /G/D and data is printed out.
*/
#include "hdf5.h"
@@ -29,11 +29,11 @@
#define NX 4
#define NY 5
-int main(void)
+int main(void)
{
hid_t fid1, fid2, gid; /* Files and group identifiers */
- hid_t did, tid, sid; /* Dataset and datatype identifiers */
+ hid_t did, tid, sid; /* Dataset and datatype identifiers */
herr_t status;
hsize_t dims[] = {NX,NY}; /* Dataset dimensions */
@@ -42,26 +42,26 @@ int main(void)
int bm[NX][NY], bm_out[NX][NY]; /* Data buffers */
/*
- * Initialization of buffer matrix "bm"
+ * Initialization of buffer matrix "bm"
*/
for(i =0; i<NX; i++) {
for(j = 0; j<NY; j++)
bm[i][j] = i + j;
}
- /*
+ /*
* Create first file and a group in it.
*/
fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
gid = H5Gcreate(fid1, "/G", 0);
- /*
- * Close group and file
+ /*
+ * Close group and file
*/
H5Gclose(gid);
H5Fclose(fid1);
- /*
+ /*
* Create second file and dataset "D" in it.
*/
fid2 = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -69,31 +69,31 @@ int main(void)
dims[1] = NY;
sid = H5Screate_simple(RANK, dims, NULL);
did = H5Dcreate(fid2, "D", H5T_NATIVE_INT, sid, H5P_DEFAULT);
-
+
/*
* Write data to the dataset.
*/
status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, bm);
- /*
+ /*
* Close all identifiers.
*/
H5Sclose(sid);
H5Dclose(did);
H5Fclose(fid2);
- /*
+ /*
* Reopen both files
*/
fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT);
fid2 = H5Fopen(FILE2, H5F_ACC_RDONLY, H5P_DEFAULT);
-
- /*
+
+ /*
* Mount second file under G in the first file.
*/
H5Fmount(fid1, "/G", fid2, H5P_DEFAULT);
- /*
+ /*
* Access dataset D in the first file under /G/D name.
*/
did = H5Dopen(fid1,"/G/D");
@@ -109,13 +109,13 @@ int main(void)
printf("\n");
}
- /*
+ /*
* Close all identifers
*/
H5Tclose(tid);
H5Dclose(did);
-
- /*
+
+ /*
* Unmounting second file
*/
H5Funmount(fid1, "/G");
diff --git a/examples/h5_read.c b/examples/h5_read.c
index 9d57351..4d84de3 100644
--- a/examples/h5_read.c
+++ b/examples/h5_read.c
@@ -12,22 +12,22 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
- * This example reads hyperslab from the SDS.h5 file
+/*
+ * This example reads hyperslab from the SDS.h5 file
* created by h5_write.c program into two-dimensional
- * plane of the three-dimensional array.
- * Information about dataset in the SDS.h5 file is obtained.
+ * plane of the three-dimensional array.
+ * Information about dataset in the SDS.h5 file is obtained.
*/
-
+
#include "hdf5.h"
#define H5FILE_NAME "SDS.h5"
-#define DATASETNAME "IntArray"
-#define NX_SUB 3 /* hyperslab dimensions */
-#define NY_SUB 4
-#define NX 7 /* output buffer dimensions */
-#define NY 7
-#define NZ 3
+#define DATASETNAME "IntArray"
+#define NX_SUB 3 /* hyperslab dimensions */
+#define NY_SUB 4
+#define NX 7 /* output buffer dimensions */
+#define NY 7
+#define NZ 3
#define RANK 2
#define RANK_OUT 3
@@ -35,20 +35,20 @@ int
main (void)
{
hid_t file, dataset; /* handles */
- hid_t datatype, dataspace;
- hid_t memspace;
+ hid_t datatype, dataspace;
+ hid_t memspace;
H5T_class_t t_class; /* data type class */
H5T_order_t order; /* data order */
size_t size; /*
- * size of the data element
+ * size of the data element
* stored in file
*/
hsize_t dimsm[3]; /* memory space dimensions */
- hsize_t dims_out[2]; /* dataset dimensions */
- herr_t status;
+ hsize_t dims_out[2]; /* dataset dimensions */
+ herr_t status;
int data_out[NX][NY][NZ ]; /* output buffer */
-
+
hsize_t count[2]; /* size of the hyperslab in the file */
hsize_t offset[2]; /* hyperslab offset in the file */
hsize_t count_out[3]; /* size of the hyperslab in memory */
@@ -60,8 +60,8 @@ main (void)
for (k = 0; k < NZ ; k++)
data_out[j][i][k] = 0;
}
- }
-
+ }
+
/*
* Open the file and the dataset.
*/
@@ -72,7 +72,7 @@ main (void)
* Get datatype and dataspace handles and then query
* dataset class, order, size, rank and dimensions.
*/
- datatype = H5Dget_type(dataset); /* datatype handle */
+ datatype = H5Dget_type(dataset); /* datatype handle */
t_class = H5Tget_class(datatype);
if (t_class == H5T_INTEGER) printf("Data set has INTEGER type \n");
order = H5Tget_order(datatype);
@@ -87,14 +87,14 @@ main (void)
printf("rank %d, dimensions %lu x %lu \n", rank,
(unsigned long)(dims_out[0]), (unsigned long)(dims_out[1]));
- /*
- * Define hyperslab in the dataset.
+ /*
+ * Define hyperslab in the dataset.
*/
offset[0] = 1;
offset[1] = 2;
count[0] = NX_SUB;
count[1] = NY_SUB;
- status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, NULL,
+ status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, NULL,
count, NULL);
/*
@@ -103,10 +103,10 @@ main (void)
dimsm[0] = NX;
dimsm[1] = NY;
dimsm[2] = NZ ;
- memspace = H5Screate_simple(RANK_OUT,dimsm,NULL);
+ memspace = H5Screate_simple(RANK_OUT,dimsm,NULL);
- /*
- * Define memory hyperslab.
+ /*
+ * Define memory hyperslab.
*/
offset_out[0] = 3;
offset_out[1] = 0;
@@ -114,11 +114,11 @@ main (void)
count_out[0] = NX_SUB;
count_out[1] = NY_SUB;
count_out[2] = 1;
- status = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, offset_out, NULL,
+ status = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, offset_out, NULL,
count_out, NULL);
/*
- * Read data from hyperslab in the file into the hyperslab in
+ * Read data from hyperslab in the file into the hyperslab in
* memory and display.
*/
status = H5Dread(dataset, H5T_NATIVE_INT, memspace, dataspace,
@@ -131,7 +131,7 @@ main (void)
* 0 0 0 0 0 0 0
* 0 0 0 0 0 0 0
* 0 0 0 0 0 0 0
- * 3 4 5 6 0 0 0
+ * 3 4 5 6 0 0 0
* 4 5 6 7 0 0 0
* 5 6 7 8 0 0 0
* 0 0 0 0 0 0 0
@@ -147,4 +147,4 @@ main (void)
H5Fclose(file);
return 0;
-}
+}
diff --git a/examples/h5_reference.c b/examples/h5_reference.c
index 45f8850..c8dfc91 100644
--- a/examples/h5_reference.c
+++ b/examples/h5_reference.c
@@ -12,15 +12,15 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
- /*
+ /*
* This program illustrates how references to objects can be used.
- * Program creates a dataset and a group in a file. It also creates
- * second dataset, and references to the first dataset and the group
+ * Program creates a dataset and a group in a file. It also creates
+ * second dataset, and references to the first dataset and the group
* are stored in it.
* Program reopens the file and reads dataset with the references.
* References are used to open the objects. Information about the
* objects is displayed.
- */
+ */
#include <stdlib.h>
@@ -30,38 +30,38 @@
int
main(void) {
- hid_t fid; /* File, group, datasets, datatypes */
+ hid_t fid; /* File, group, datasets, datatypes */
hid_t gid_a; /* and dataspaces identifiers */
- hid_t did_b, sid_b, tid_b;
+ hid_t did_b, sid_b, tid_b;
hid_t did_r, tid_r, sid_r;
herr_t status;
hobj_ref_t *wbuf; /* buffer to write to disk */
hobj_ref_t *rbuf; /* buffer to read from disk */
-
- hsize_t dim_r[1];
+
+ hsize_t dim_r[1];
hsize_t dim_b[2];
-
- /*
+
+ /*
* Create a file using default properties.
*/
fid = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- /*
+ /*
* Create group "A" in the file.
*/
gid_a = H5Gcreate(fid, "A", 0);
-
- /*
+
+ /*
* Create dataset "B" in the file.
*/
dim_b[0] = 2;
dim_b[1] = 6;
- sid_b = H5Screate_simple(2, dim_b, NULL);
+ sid_b = H5Screate_simple(2, dim_b, NULL);
did_b = H5Dcreate(fid, "B", H5T_NATIVE_FLOAT, sid_b, H5P_DEFAULT);
-
- /*
+
+ /*
* Create dataset "R" to store references to the objects "A" and "B".
*/
dim_r[0] = 2;
@@ -69,62 +69,62 @@ main(void) {
tid_r = H5Tcopy(H5T_STD_REF_OBJ);
did_r = H5Dcreate(fid, "R", tid_r, sid_r, H5P_DEFAULT );
- /*
+ /*
* Allocate write and read buffers.
*/
wbuf = (hobj_ref_t *)malloc(sizeof(hobj_ref_t)*2);
rbuf = (hobj_ref_t *)malloc(sizeof(hobj_ref_t)*2);
-
+
/*
* Create references to the group "A" and dataset "B"
* and store them in the wbuf.
*/
- H5Rcreate(&wbuf[0], fid, "A", H5R_OBJECT, -1);
+ H5Rcreate(&wbuf[0], fid, "A", H5R_OBJECT, -1);
H5Rcreate(&wbuf[1], fid, "B", H5R_OBJECT, -1);
-
- /*
+
+ /*
* Write dataset R using default transfer properties.
*/
status = H5Dwrite(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL,
H5P_DEFAULT, wbuf);
- /*
- * Close all objects.
+ /*
+ * Close all objects.
*/
H5Gclose(gid_a);
-
+
H5Sclose(sid_b);
H5Dclose(did_b);
H5Tclose(tid_r);
H5Sclose(sid_r);
H5Dclose(did_r);
-
+
H5Fclose(fid);
-
- /*
+
+ /*
* Reopen the file.
*/
fid = H5Fopen(H5FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
- /*
+ /*
* Open and read dataset "R".
*/
did_r = H5Dopen(fid, "R");
status = H5Dread(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL,
H5P_DEFAULT, rbuf);
- /*
+ /*
* Find the type of referenced objects.
*/
status = H5Rget_obj_type(did_r, H5R_OBJECT, &rbuf[0]);
- if ( status == H5G_GROUP )
+ if ( status == H5G_GROUP )
printf("First dereferenced object is a group. \n");
status = H5Rget_obj_type(did_r, H5R_OBJECT, &rbuf[1]);
- if ( status == H5G_DATASET )
+ if ( status == H5G_DATASET )
printf("Second dereferenced object is a dataset. \n");
- /*
+ /*
* Get datatype of the dataset "B"
*/
did_b = H5Rdereference(did_r, H5R_OBJECT, &rbuf[1]);
@@ -133,7 +133,7 @@ main(void) {
printf("Datatype of the dataset is H5T_NATIVE_FLOAT.\n");
printf("\n");
- /*
+ /*
* Close all objects and free memory buffers.
*/
H5Dclose(did_r);
diff --git a/examples/h5_select.c b/examples/h5_select.c
index 0c34b1a..c3bdb2a 100644
--- a/examples/h5_select.c
+++ b/examples/h5_select.c
@@ -12,42 +12,42 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
+/*
* This program shows how the H5Sselect_hyperslab and H5Sselect_elements
* functions are used to write selected data from memory to the file.
* Program takes 48 elements from the linear buffer and writes them into
- * the matrix using 3x2 blocks, (4,3) stride and (2,4) count.
- * Then four elements of the matrix are overwritten with the new values and
- * file is closed. Program reopens the file and selects the union of two
+ * the matrix using 3x2 blocks, (4,3) stride and (2,4) count.
+ * Then four elements of the matrix are overwritten with the new values and
+ * file is closed. Program reopens the file and selects the union of two
* hyperslabs in the dataset in the file. Then it reads the selection into the
* memory dataset preserving the shape of the selection.
- */
-
+ */
+
#include "hdf5.h"
#define H5FILE_NAME "Select.h5"
#define MSPACE1_RANK 1 /* Rank of the first dataset in memory */
-#define MSPACE1_DIM 50 /* Dataset size in memory */
+#define MSPACE1_DIM 50 /* Dataset size in memory */
-#define MSPACE2_RANK 1 /* Rank of the second dataset in memory */
-#define MSPACE2_DIM 4 /* Dataset size in memory */
+#define MSPACE2_RANK 1 /* Rank of the second dataset in memory */
+#define MSPACE2_DIM 4 /* Dataset size in memory */
#define FSPACE_RANK 2 /* Dataset rank as it is stored in the file */
#define FSPACE_DIM1 8 /* Dimension sizes of the dataset as it is
stored in the file */
-#define FSPACE_DIM2 12
+#define FSPACE_DIM2 12
/* We will read dataset back from the file
to the dataset in memory with these
- dataspace parameters. */
+ dataspace parameters. */
#define MSPACE_RANK 2
-#define MSPACE_DIM1 8
-#define MSPACE_DIM2 9
+#define MSPACE_DIM1 8
+#define MSPACE_DIM2 9
-#define NPOINTS 4 /* Number of points that will be selected
- and overwritten */
-int
+#define NPOINTS 4 /* Number of points that will be selected
+ and overwritten */
+int
main (void)
{
@@ -55,13 +55,13 @@ main (void)
hid_t mid1, mid2, mid, fid; /* Dataspace identifiers */
hid_t plist; /* Dataset property list identifier */
- hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset
- (in memory) */
+ hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset
+ (in memory) */
hsize_t dim2[] = {MSPACE2_DIM}; /* Dimension size of the second dataset
- (in memory */
- hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2};
+ (in memory */
+ hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2};
/* Dimension sizes of the dataset (on disk) */
- hsize_t mdim[] = {MSPACE_DIM1, MSPACE_DIM2}; /* Dimension sizes of the
+ hsize_t mdim[] = {MSPACE_DIM1, MSPACE_DIM2}; /* Dimension sizes of the
dataset in memory when we
read selection from the
dataset on the disk */
@@ -71,13 +71,13 @@ main (void)
hsize_t count[2]; /* Block count */
hsize_t block[2]; /* Block sizes */
- hsize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points
- from the file dataspace */
+ hsize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points
+ from the file dataspace */
herr_t ret;
unsigned i,j;
int fillvalue = 0; /* Fill value for the dataset */
- int matrix_out[MSPACE_DIM1][MSPACE_DIM2]; /* Buffer to read from the
+ int matrix_out[MSPACE_DIM1][MSPACE_DIM2]; /* Buffer to read from the
dataset */
int vector[MSPACE1_DIM];
int values[] = {53, 59, 61, 67}; /* New values to be written */
@@ -97,9 +97,9 @@ main (void)
* Create property list for a dataset and set up fill values.
*/
plist = H5Pcreate(H5P_DATASET_CREATE);
- ret = H5Pset_fill_value(plist, H5T_NATIVE_INT, &fillvalue);
+ ret = H5Pset_fill_value(plist, H5T_NATIVE_INT, &fillvalue);
- /*
+ /*
* Create dataspace for the dataset in the file.
*/
fid = H5Screate_simple(FSPACE_RANK, fdim, NULL);
@@ -111,12 +111,12 @@ main (void)
dataset = H5Dcreate(file, "Matrix in file", H5T_NATIVE_INT, fid, plist);
/*
- * Select hyperslab for the dataset in the file, using 3x2 blocks,
+ * Select hyperslab for the dataset in the file, using 3x2 blocks,
* (4,3) stride and (2,4) count starting at the position (0,1).
*/
start[0] = 0; start[1] = 1;
stride[0] = 4; stride[1] = 3;
- count[0] = 2; count[1] = 4;
+ count[0] = 2; count[1] = 4;
block[0] = 3; block[1] = 2;
ret = H5Sselect_hyperslab(fid, H5S_SELECT_SET, start, stride, count, block);
@@ -126,7 +126,7 @@ main (void)
mid1 = H5Screate_simple(MSPACE1_RANK, dim1, NULL);
/*
- * Select hyperslab.
+ * Select hyperslab.
* We will use 48 elements of the vector buffer starting at the second element.
* Selected elements are 1 2 3 . . . 48
*/
@@ -135,12 +135,12 @@ main (void)
count[0] = 48;
block[0] = 1;
ret = H5Sselect_hyperslab(mid1, H5S_SELECT_SET, start, stride, count, block);
-
+
/*
* Write selection from the vector buffer to the dataset in the file.
*
- * File dataset should look like this:
- * 0 1 2 0 3 4 0 5 6 0 7 8
+ * File dataset should look like this:
+ * 0 1 2 0 3 4 0 5 6 0 7 8
* 0 9 10 0 11 12 0 13 14 0 15 16
* 0 17 18 0 19 20 0 21 22 0 23 24
* 0 0 0 0 0 0 0 0 0 0 0 0
@@ -169,17 +169,17 @@ main (void)
coord[2][0] = 3; coord[2][1] = 5;
coord[3][0] = 5; coord[3][1] = 6;
- ret = H5Sselect_elements(fid, H5S_SELECT_SET, NPOINTS,
+ ret = H5Sselect_elements(fid, H5S_SELECT_SET, NPOINTS,
(const hsize_t **)coord);
/*
* Write new selection of points to the dataset.
*/
- ret = H5Dwrite(dataset, H5T_NATIVE_INT, mid2, fid, H5P_DEFAULT, values);
+ ret = H5Dwrite(dataset, H5T_NATIVE_INT, mid2, fid, H5P_DEFAULT, values);
/*
- * File dataset should look like this:
- * 53 1 2 0 3 4 0 5 6 0 7 8
+ * File dataset should look like this:
+ * 53 1 2 0 3 4 0 5 6 0 7 8
* 0 9 10 0 11 12 0 13 14 0 15 16
* 0 17 18 0 19 20 0 21 22 0 23 24
* 0 0 0 59 0 61 0 0 0 0 0 0
@@ -187,16 +187,16 @@ main (void)
* 0 33 34 0 35 36 67 37 38 0 39 40
* 0 41 42 0 43 44 0 45 46 0 47 48
* 0 0 0 0 0 0 0 0 0 0 0 0
- *
+ *
*/
-
+
/*
* Close memory file and memory dataspaces.
*/
- ret = H5Sclose(mid1);
- ret = H5Sclose(mid2);
- ret = H5Sclose(fid);
-
+ ret = H5Sclose(mid1);
+ ret = H5Sclose(mid2);
+ ret = H5Sclose(fid);
+
/*
* Close dataset.
*/
@@ -216,8 +216,8 @@ main (void)
* Open the dataset.
*/
dataset = H5Dopen(file,"Matrix in file");
-
- /*
+
+ /*
* Get dataspace of the open dataset.
*/
fid = H5Dget_space(dataset);
@@ -225,7 +225,7 @@ main (void)
/*
* Select first hyperslab for the dataset in the file. The following
* elements are selected:
- * 10 0 11 12
+ * 10 0 11 12
* 18 0 19 20
* 0 59 0 61
*
@@ -233,50 +233,50 @@ main (void)
start[0] = 1; start[1] = 2;
block[0] = 1; block[1] = 1;
stride[0] = 1; stride[1] = 1;
- count[0] = 3; count[1] = 4;
+ count[0] = 3; count[1] = 4;
ret = H5Sselect_hyperslab(fid, H5S_SELECT_SET, start, stride, count, block);
- /*
- * Add second selected hyperslab to the selection.
+ /*
+ * Add second selected hyperslab to the selection.
* The following elements are selected:
- * 19 20 0 21 22
- * 0 61 0 0 0
- * 27 28 0 29 30
- * 35 36 67 37 38
+ * 19 20 0 21 22
+ * 0 61 0 0 0
+ * 27 28 0 29 30
+ * 35 36 67 37 38
* 43 44 0 45 46
* 0 0 0 0 0
- * Note that two hyperslabs overlap. Common elements are:
+ * Note that two hyperslabs overlap. Common elements are:
* 19 20
* 0 61
*/
- start[0] = 2; start[1] = 4;
- block[0] = 1; block[1] = 1;
+ start[0] = 2; start[1] = 4;
+ block[0] = 1; block[1] = 1;
stride[0] = 1; stride[1] = 1;
- count[0] = 6; count[1] = 5;
+ count[0] = 6; count[1] = 5;
ret = H5Sselect_hyperslab(fid, H5S_SELECT_OR, start, stride, count, block);
-
+
/*
* Create memory dataspace.
*/
mid = H5Screate_simple(MSPACE_RANK, mdim, NULL);
- /*
+ /*
* Select two hyperslabs in memory. Hyperslabs has the same
* size and shape as the selected hyperslabs for the file dataspace.
*/
- start[0] = 0; start[1] = 0;
- block[0] = 1; block[1] = 1;
+ start[0] = 0; start[1] = 0;
+ block[0] = 1; block[1] = 1;
stride[0] = 1; stride[1] = 1;
- count[0] = 3; count[1] = 4;
+ count[0] = 3; count[1] = 4;
ret = H5Sselect_hyperslab(mid, H5S_SELECT_SET, start, stride, count, block);
- start[0] = 1; start[1] = 2;
- block[0] = 1; block[1] = 1;
+ start[0] = 1; start[1] = 2;
+ block[0] = 1; block[1] = 1;
stride[0] = 1; stride[1] = 1;
- count[0] = 6; count[1] = 5;
+ count[0] = 6; count[1] = 5;
ret = H5Sselect_hyperslab(mid, H5S_SELECT_OR, start, stride, count, block);
-
- /*
+
+ /*
* Initialize data buffer.
*/
for (i = 0; i < MSPACE_DIM1; i++) {
@@ -290,16 +290,16 @@ main (void)
H5P_DEFAULT, matrix_out);
/*
- * Display the result. Memory dataset is:
- *
- * 10 0 11 12 0 0 0 0 0
- * 18 0 19 20 0 21 22 0 0
- * 0 59 0 61 0 0 0 0 0
- * 0 0 27 28 0 29 30 0 0
- * 0 0 35 36 67 37 38 0 0
- * 0 0 43 44 0 45 46 0 0
- * 0 0 0 0 0 0 0 0 0
- * 0 0 0 0 0 0 0 0 0
+ * Display the result. Memory dataset is:
+ *
+ * 10 0 11 12 0 0 0 0 0
+ * 18 0 19 20 0 21 22 0 0
+ * 0 59 0 61 0 0 0 0 0
+ * 0 0 27 28 0 29 30 0 0
+ * 0 0 35 36 67 37 38 0 0
+ * 0 0 43 44 0 45 46 0 0
+ * 0 0 0 0 0 0 0 0 0
+ * 0 0 0 0 0 0 0 0 0
*/
for (i=0; i < MSPACE_DIM1; i++) {
for(j=0; j < MSPACE_DIM2; j++) printf("%3d ", matrix_out[i][j]);
@@ -308,23 +308,23 @@ main (void)
/*
* Close memory file and memory dataspaces.
- */
+ */
ret = H5Sclose(mid);
ret = H5Sclose(fid);
-
+
/*
* Close dataset.
- */
+ */
ret = H5Dclose(dataset);
/*
* Close property list
*/
ret = H5Pclose(plist);
-
+
/*
* Close the file.
- */
+ */
ret = H5Fclose(file);
return 0;
diff --git a/examples/h5_write.c b/examples/h5_write.c
index 8cc4b8f..c3a8d35 100644
--- a/examples/h5_write.c
+++ b/examples/h5_write.c
@@ -12,15 +12,15 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
+/*
* This example writes data to the HDF5 file.
- * Data conversion is performed during write operation.
+ * Data conversion is performed during write operation.
*/
-
+
#include "hdf5.h"
#define H5FILE_NAME "SDS.h5"
-#define DATASETNAME "IntArray"
+#define DATASETNAME "IntArray"
#define NX 5 /* dataset dimensions */
#define NY 6
#define RANK 2
@@ -31,19 +31,19 @@ main (void)
hid_t file, dataset; /* file and dataset handles */
hid_t datatype, dataspace; /* handles */
hsize_t dimsf[2]; /* dataset dimensions */
- herr_t status;
+ herr_t status;
int data[NX][NY]; /* data to write */
int i, j;
- /*
- * Data and output buffer initialization.
+ /*
+ * Data and output buffer initialization.
*/
for (j = 0; j < NX; j++) {
for (i = 0; i < NY; i++)
data[j][i] = i + j;
- }
+ }
/*
- * 0 1 2 3 4 5
+ * 0 1 2 3 4 5
* 1 2 3 4 5 6
* 2 3 4 5 6 7
* 3 4 5 6 7 8
@@ -59,13 +59,13 @@ main (void)
/*
* Describe the size of the array and create the data space for fixed
- * size dataset.
+ * size dataset.
*/
dimsf[0] = NX;
dimsf[1] = NY;
- dataspace = H5Screate_simple(RANK, dimsf, NULL);
+ dataspace = H5Screate_simple(RANK, dimsf, NULL);
- /*
+ /*
* Define datatype for the data in the file.
* We will store little endian INT numbers.
*/
@@ -92,6 +92,6 @@ main (void)
H5Tclose(datatype);
H5Dclose(dataset);
H5Fclose(file);
-
+
return 0;
-}
+}
diff --git a/examples/ph5example.c b/examples/ph5example.c
index b2929ab..09ad7c2 100644
--- a/examples/ph5example.c
+++ b/examples/ph5example.c
@@ -26,7 +26,7 @@
* each dataset in an independent mode and prints them out.
* All processes collectively close the datasets and the file.
*
- * The need of requirement of parallel file prefix is that in general
+ * The need of requirement of parallel file prefix is that in general
* the current working directory in which compiling is done, is not suitable
* for parallel I/O and there is no standard pathname for parallel file
* systems. In some cases, the parallel file name may even needs some
@@ -250,7 +250,7 @@ phdf5writeInd(char *filename)
hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
herr_t ret; /* Generic return value */
-
+
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Info info = MPI_INFO_NULL;
@@ -258,14 +258,14 @@ phdf5writeInd(char *filename)
printf("Independent write test on file %s\n", filename);
/* -------------------
- * START AN HDF5 FILE
+ * START AN HDF5 FILE
* -------------------*/
/* setup file access template with parallel IO access. */
acc_tpl1 = H5Pcreate (H5P_FILE_ACCESS);
assert(acc_tpl1 != FAIL);
MESG("H5Pcreate access succeed");
/* set Parallel access with communicator */
- ret = H5Pset_fapl_mpio(acc_tpl1, comm, info);
+ ret = H5Pset_fapl_mpio(acc_tpl1, comm, info);
assert(ret != FAIL);
MESG("H5Pset_fapl_mpio succeed");
@@ -288,7 +288,7 @@ phdf5writeInd(char *filename)
assert (sid1 != FAIL);
MESG("H5Screate_simple succeed");
-
+
/* create a dataset collectively */
dataset1 = H5Dcreate(fid1, DATASETNAME1, H5T_NATIVE_INT, sid1,
H5P_DEFAULT);
@@ -321,8 +321,8 @@ if (verbose)
MESG("data_array initialized");
/* create a file dataspace independently */
- file_dataspace = H5Dget_space (dataset1);
- assert(file_dataspace != FAIL);
+ file_dataspace = H5Dget_space (dataset1);
+ assert(file_dataspace != FAIL);
MESG("H5Dget_space succeed");
ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride,
count, NULL);
@@ -334,21 +334,21 @@ if (verbose)
assert (mem_dataspace != FAIL);
/* write data independently */
- ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- H5P_DEFAULT, data_array1);
+ ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
+ H5P_DEFAULT, data_array1);
assert(ret != FAIL);
MESG("H5Dwrite succeed");
/* write data independently */
- ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- H5P_DEFAULT, data_array1);
+ ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
+ H5P_DEFAULT, data_array1);
assert(ret != FAIL);
MESG("H5Dwrite succeed");
/* release dataspace ID */
H5Sclose(file_dataspace);
- /* close dataset collectively */
+ /* close dataset collectively */
ret=H5Dclose(dataset1);
assert(ret != FAIL);
MESG("H5Dclose1 succeed");
@@ -359,8 +359,8 @@ if (verbose)
/* release all IDs created */
H5Sclose(sid1);
- /* close the file collectively */
- H5Fclose(fid1);
+ /* close the file collectively */
+ H5Fclose(fid1);
}
/* Example of using the parallel HDF5 library to read a dataset */
@@ -390,7 +390,7 @@ phdf5readInd(char *filename)
acc_tpl1 = H5Pcreate (H5P_FILE_ACCESS);
assert(acc_tpl1 != FAIL);
/* set Parallel access with communicator */
- ret = H5Pset_fapl_mpio(acc_tpl1, comm, info);
+ ret = H5Pset_fapl_mpio(acc_tpl1, comm, info);
assert(ret != FAIL);
@@ -497,7 +497,7 @@ phdf5writeAll(char *filename)
hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */
herr_t ret; /* Generic return value */
-
+
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Info info = MPI_INFO_NULL;
@@ -505,14 +505,14 @@ phdf5writeAll(char *filename)
printf("Collective write test on file %s\n", filename);
/* -------------------
- * START AN HDF5 FILE
+ * START AN HDF5 FILE
* -------------------*/
/* setup file access template with parallel IO access. */
acc_tpl1 = H5Pcreate (H5P_FILE_ACCESS);
assert(acc_tpl1 != FAIL);
MESG("H5Pcreate access succeed");
/* set Parallel access with communicator */
- ret = H5Pset_fapl_mpio(acc_tpl1, comm, info);
+ ret = H5Pset_fapl_mpio(acc_tpl1, comm, info);
assert(ret != FAIL);
MESG("H5Pset_fapl_mpio succeed");
@@ -535,7 +535,7 @@ phdf5writeAll(char *filename)
assert (sid1 != FAIL);
MESG("H5Screate_simple succeed");
-
+
/* create a dataset collectively */
dataset1 = H5Dcreate(fid1, DATASETNAME1, H5T_NATIVE_INT, sid1, H5P_DEFAULT);
assert(dataset1 != FAIL);
@@ -559,8 +559,8 @@ if (verbose)
(unsigned long)(count[0]*count[1]));
/* create a file dataspace independently */
- file_dataspace = H5Dget_space (dataset1);
- assert(file_dataspace != FAIL);
+ file_dataspace = H5Dget_space (dataset1);
+ assert(file_dataspace != FAIL);
MESG("H5Dget_space succeed");
ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride,
count, NULL);
@@ -588,7 +588,7 @@ if (verbose)
/* write data collectively */
ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- xfer_plist, data_array1);
+ xfer_plist, data_array1);
assert(ret != FAIL);
MESG("H5Dwrite succeed");
@@ -616,8 +616,8 @@ if (verbose)
}
/* create a file dataspace independently */
- file_dataspace = H5Dget_space (dataset1);
- assert(file_dataspace != FAIL);
+ file_dataspace = H5Dget_space (dataset1);
+ assert(file_dataspace != FAIL);
MESG("H5Dget_space succeed");
ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride,
count, NULL);
@@ -645,7 +645,7 @@ if (verbose)
/* write data independently */
ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- xfer_plist, data_array1);
+ xfer_plist, data_array1);
assert(ret != FAIL);
MESG("H5Dwrite succeed");
@@ -657,7 +657,7 @@ if (verbose)
/*
* All writes completed. Close datasets collectively
- */
+ */
ret=H5Dclose(dataset1);
assert(ret != FAIL);
MESG("H5Dclose1 succeed");
@@ -668,8 +668,8 @@ if (verbose)
/* release all IDs created */
H5Sclose(sid1);
- /* close the file collectively */
- H5Fclose(fid1);
+ /* close the file collectively */
+ H5Fclose(fid1);
}
/*
@@ -705,14 +705,14 @@ phdf5readAll(char *filename)
printf("Collective read test on file %s\n", filename);
/* -------------------
- * OPEN AN HDF5 FILE
+ * OPEN AN HDF5 FILE
* -------------------*/
/* setup file access template with parallel IO access. */
acc_tpl1 = H5Pcreate (H5P_FILE_ACCESS);
assert(acc_tpl1 != FAIL);
MESG("H5Pcreate access succeed");
/* set Parallel access with communicator */
- ret = H5Pset_fapl_mpio(acc_tpl1, comm, info);
+ ret = H5Pset_fapl_mpio(acc_tpl1, comm, info);
assert(ret != FAIL);
MESG("H5Pset_fapl_mpio succeed");
@@ -752,8 +752,8 @@ if (verbose)
(unsigned long)(count[0]*count[1]));
/* create a file dataspace independently */
- file_dataspace = H5Dget_space (dataset1);
- assert(file_dataspace != FAIL);
+ file_dataspace = H5Dget_space (dataset1);
+ assert(file_dataspace != FAIL);
MESG("H5Dget_space succeed");
ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride,
count, NULL);
@@ -781,7 +781,7 @@ if (verbose)
/* read data collectively */
ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- xfer_plist, data_array1);
+ xfer_plist, data_array1);
assert(ret != FAIL);
MESG("H5Dread succeed");
@@ -805,8 +805,8 @@ if (verbose)
(unsigned long)(count[0]*count[1]));
/* create a file dataspace independently */
- file_dataspace = H5Dget_space (dataset1);
- assert(file_dataspace != FAIL);
+ file_dataspace = H5Dget_space (dataset1);
+ assert(file_dataspace != FAIL);
MESG("H5Dget_space succeed");
ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride,
count, NULL);
@@ -834,7 +834,7 @@ if (verbose)
/* read data independently */
ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
- xfer_plist, data_array1);
+ xfer_plist, data_array1);
assert(ret != FAIL);
MESG("H5Dread succeed");
@@ -850,7 +850,7 @@ if (verbose)
/*
* All reads completed. Close datasets collectively
- */
+ */
ret=H5Dclose(dataset1);
assert(ret != FAIL);
MESG("H5Dclose1 succeed");
@@ -858,8 +858,8 @@ if (verbose)
assert(ret != FAIL);
MESG("H5Dclose2 succeed");
- /* close the file collectively */
- H5Fclose(fid1);
+ /* close the file collectively */
+ H5Fclose(fid1);
}
/*
@@ -903,9 +903,9 @@ test_split_comm_access(char filenames[][PATH_MAX])
/* setup file access template */
acc_tpl = H5Pcreate (H5P_FILE_ACCESS);
assert(acc_tpl != FAIL);
-
+
/* set Parallel access with communicator */
- ret = H5Pset_fapl_mpio(acc_tpl, comm, info);
+ ret = H5Pset_fapl_mpio(acc_tpl, comm, info);
assert(ret != FAIL);
/* create the file collectively */
@@ -1055,7 +1055,7 @@ cleanup(void)
int
main(int argc, char **argv)
{
- int mpi_namelen;
+ int mpi_namelen;
char mpi_name[MPI_MAX_PROCESSOR_NAME];
int i, n;