summaryrefslogtreecommitdiffstats
path: root/examples/h5_group.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/h5_group.c')
-rw-r--r--examples/h5_group.c155
1 files changed, 74 insertions, 81 deletions
diff --git a/examples/h5_group.c b/examples/h5_group.c
index 4bad2ea..744f7b8 100644
--- a/examples/h5_group.c
+++ b/examples/h5_group.c
@@ -28,10 +28,10 @@
#define H5FILE_NAME "group.h5"
#define RANK 2
-herr_t file_info(hid_t loc_id, const char *name, void *opdata);
- /* Operator function */
-herr_t group_info(hid_t loc_id, const char *name, void *opdata);
- /* Operator function */
+static herr_t file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo,
+ void *opdata); /* Link iteration operator function */
+static herr_t group_info(hid_t loc_id, const char *name, const H5L_info_t *linfo,
+ void *opdata); /* Link iteration operator function */
int
main(void)
{
@@ -137,7 +137,7 @@ main(void)
/*
* Use iterator to see the names of the objects in the root group.
*/
- idx_f = H5Giterate(file, "/", NULL, file_info, NULL);
+ idx_f = H5Literate(file, "/", H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL, H5P_DEFAULT);
/*
* Unlink name "Data" and use iterator to see the names
@@ -148,13 +148,13 @@ main(void)
else
printf("\"Data\" is unlinked \n");
- idx_f = H5Giterate(file, "/", NULL, file_info, NULL);
+ idx_f = H5Literate(file, "/", H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL, H5P_DEFAULT);
/*
* Use iterator to see the names of the objects in the group
* /Data_new.
*/
- idx_g = H5Giterate(grp, "/Data_new", NULL, group_info, NULL);
+ idx_g = H5Literate(grp, "/Data_new", H5_INDEX_NAME, H5_ITER_INC, NULL, group_info, NULL, H5P_DEFAULT);
/*
* Close the file.
@@ -169,100 +169,93 @@ main(void)
/*
* Operator function.
*/
-herr_t file_info(hid_t loc_id, const char *name, void *opdata)
+static herr_t
+file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata)
{
- /* avoid warnings */
+ /* avoid compiler warnings */
loc_id = loc_id;
opdata = opdata;
+ linfo = linfo;
/*
* Display group name. The name is passed to the function by
* the Library. Some magic :-)
*/
- printf("\n");
- printf("Name : ");
- puts(name);
+ printf("\nName : %s\n", name);
return 0;
- }
+}
/*
* Operator function.
*/
-herr_t group_info(hid_t loc_id, const char *name, void *opdata)
+static herr_t
+group_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata)
{
- hid_t did; /* dataset identifier */
- hid_t tid; /* datatype identifier */
- H5T_class_t t_class;
- hid_t pid; /* data_property identifier */
- hsize_t chunk_dims_out[2];
-
- int rank_chunk;
-
- /* avoid warnings */
- opdata = 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.
- */
- if(H5D_CHUNKED == H5Pget_layout(pid)){
- /*
- * 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,
- (unsigned long)(chunk_dims_out[0]),
- (unsigned long)(chunk_dims_out[1]));
- }
- else{
- t_class = H5Tget_class(tid);
- if(t_class < 0){
- puts(" Invalid datatype.\n");
- }
- else {
- if(t_class == H5T_INTEGER)
- puts(" Datatype is 'H5T_NATIVE_INTEGER'.\n");
- if(t_class == H5T_FLOAT)
- puts(" Datatype is 'H5T_NATIVE_FLOAT'.\n");
- if(t_class == H5T_STRING)
- puts(" Datatype is 'H5T_NATIVE_STRING'.\n");
- if(t_class == H5T_BITFIELD)
- puts(" Datatype is 'H5T_NATIVE_BITFIELD'.\n");
- if(t_class == H5T_OPAQUE)
- puts(" Datatype is 'H5T_NATIVE_OPAQUE'.\n");
- if(t_class == H5T_COMPOUND)
- puts(" Datatype is 'H5T_NATIVE_COMPOUND'.\n");
- }
- }
-
+ hid_t did; /* dataset identifier */
+ hid_t tid; /* datatype identifier */
+ H5T_class_t t_class;
+ hid_t pid; /* data_property identifier */
+ hsize_t chunk_dims_out[2];
+ int rank_chunk;
- H5Dclose(did);
- H5Pclose(pid);
- H5Tclose(tid);
- return 0;
- }
+ /* avoid warnings */
+ opdata = opdata;
+ linfo = linfo;
+ /*
+ * Open the datasets using their names.
+ */
+ did = H5Dopen(loc_id, name);
+ /*
+ * Display dataset name.
+ */
+ printf("\nName : %s\n", name);
+ /*
+ * Display dataset information.
+ */
+ tid = H5Dget_type(did); /* get datatype*/
+ pid = H5Dget_create_plist(did); /* get creation property list */
+ /*
+ * Check if dataset is chunked.
+ */
+ if(H5D_CHUNKED == H5Pget_layout(pid)) {
+ /*
+ * 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,
+ (unsigned long)(chunk_dims_out[0]),
+ (unsigned long)(chunk_dims_out[1]));
+ }
+ else {
+ t_class = H5Tget_class(tid);
+ if(t_class < 0) {
+ puts(" Invalid datatype.\n");
+ }
+ else {
+ if(t_class == H5T_INTEGER)
+ puts(" Datatype is 'H5T_NATIVE_INTEGER'.\n");
+ if(t_class == H5T_FLOAT)
+ puts(" Datatype is 'H5T_NATIVE_FLOAT'.\n");
+ if(t_class == H5T_STRING)
+ puts(" Datatype is 'H5T_NATIVE_STRING'.\n");
+ if(t_class == H5T_BITFIELD)
+ puts(" Datatype is 'H5T_NATIVE_BITFIELD'.\n");
+ if(t_class == H5T_OPAQUE)
+ puts(" Datatype is 'H5T_NATIVE_OPAQUE'.\n");
+ if(t_class == H5T_COMPOUND)
+ puts(" Datatype is 'H5T_NATIVE_COMPOUND'.\n");
+ }
+ }
+ H5Dclose(did);
+ H5Pclose(pid);
+ H5Tclose(tid);
+ return 0;
+}