summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2019-12-08 20:00:04 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2019-12-09 21:44:38 (GMT)
commit310b42e35af19780000344fa8902c1954659ee58 (patch)
tree1a70cbbde96b927f2392fcd9efc178c098026c1f /tools/lib
parentdbd6fb0ba6062f1a48b893f79224c257d3282292 (diff)
downloadhdf5-310b42e35af19780000344fa8902c1954659ee58.zip
hdf5-310b42e35af19780000344fa8902c1954659ee58.tar.gz
hdf5-310b42e35af19780000344fa8902c1954659ee58.tar.bz2
HDFFV-10876 Merge from develop
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/CMakeLists.txt4
-rw-r--r--tools/lib/h5diff.c86
-rw-r--r--tools/lib/h5diff_array.c40
-rw-r--r--tools/lib/h5diff_attr.c88
-rw-r--r--tools/lib/h5diff_dset.c62
-rw-r--r--tools/lib/h5diff_util.c6
-rw-r--r--tools/lib/h5tools.c270
-rw-r--r--tools/lib/h5tools.h52
-rw-r--r--tools/lib/h5tools_dump.c1789
-rw-r--r--tools/lib/h5tools_dump.h37
-rw-r--r--tools/lib/h5tools_error.h92
-rw-r--r--tools/lib/h5tools_filters.c12
-rw-r--r--tools/lib/h5tools_str.c277
-rw-r--r--tools/lib/h5tools_str.h9
-rw-r--r--tools/lib/h5tools_utils.c4
-rw-r--r--tools/lib/h5tools_utils.h74
-rw-r--r--tools/lib/h5trav.c20
17 files changed, 1747 insertions, 1175 deletions
diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt
index 75ed627..f46eb23 100644
--- a/tools/lib/CMakeLists.txt
+++ b/tools/lib/CMakeLists.txt
@@ -38,7 +38,7 @@ if (NOT ONLY_SHARED_LIBS)
PRIVATE "${HDF5_TOOLS_LIB_SOURCE_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
- #target_compile_definitions(${HDF5_TOOLS_LIB_TARGET} PRIVATE H5DIFF_DEBUG>)
+ #target_compile_definitions(${HDF5_TOOLS_LIB_TARGET} PRIVATE H5_TOOLS_DEBUG)
TARGET_C_PROPERTIES (${HDF5_TOOLS_LIB_TARGET} STATIC)
target_link_libraries (${HDF5_TOOLS_LIB_TARGET}
PUBLIC ${HDF5_LIB_TARGET}
@@ -58,7 +58,7 @@ if (BUILD_SHARED_LIBS)
)
target_compile_definitions(${HDF5_TOOLS_LIBSH_TARGET}
PUBLIC "H5_BUILT_AS_DYNAMIC_LIB"
- #PRIVATE H5DIFF_DEBUG
+ #PRIVATE H5_TOOLS_DEBUG
)
TARGET_C_PROPERTIES (${HDF5_TOOLS_LIBSH_TARGET} SHARED)
target_link_libraries (${HDF5_TOOLS_LIBSH_TARGET}
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index c2153e5..b22af18 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -280,7 +280,7 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2
/* init */
trav_table_init(&table);
if (table == NULL) {
- H5TOOLS_INFO(H5E_tools_min_id_g, "Cannot create traverse table");
+ H5TOOLS_INFO(H5E_tools_min_info_id_g, "Cannot create traverse table");
HGOTO_DONE(-1);
}
/*
@@ -440,7 +440,7 @@ trav_grp_symlinks(const char *path, const H5L_info_t *linfo, void *udata)
trav_grp_objs,trav_grp_symlinks, tinfo, H5O_INFO_BASIC) < 0) {
parallel_print("Error: Could not get file contents\n");
opts->err_stat = 1;
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Could not get file contents");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Could not get file contents");
}
break;
@@ -472,7 +472,7 @@ trav_grp_symlinks(const char *path, const H5L_info_t *linfo, void *udata)
trav_grp_objs,trav_grp_symlinks, tinfo, H5O_INFO_BASIC) < 0) {
parallel_print("Error: Could not get file contents\n");
opts->err_stat = 1;
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Could not get file contents\n");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Could not get file contents\n");
}
break;
@@ -482,7 +482,7 @@ trav_grp_symlinks(const char *path, const H5L_info_t *linfo, void *udata)
default:
parallel_print("Error: Invalid link type\n");
opts->err_stat = 1;
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Invalid link type");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Invalid link type");
break;
} /* end of switch */
@@ -564,14 +564,14 @@ h5diff(const char *fname1,
/* open file 1 */
if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) {
parallel_print("h5diff: <%s>: unable to open file\n", fname1);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "<%s>: unable to open file\n", fname1);
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "<%s>: unable to open file\n", fname1);
} /* end if */
/* open file 2 */
if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) {
parallel_print("h5diff: <%s>: unable to open file\n", fname2);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "<%s>: unable to open file\n", fname2);
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "<%s>: unable to open file\n", fname2);
} /* end if */
/*-------------------------------------------------------------------------
@@ -589,11 +589,11 @@ h5diff(const char *fname1,
#ifdef H5_HAVE_ASPRINTF
/* Use the asprintf() routine, since it does what we're trying to do below */
if(HDasprintf(&obj1fullname, "/%s", objname1) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
#else /* H5_HAVE_ASPRINTF */
/* (malloc 2 more for "/" and end-of-line) */
if ((obj1fullname = (char*)HDmalloc(HDstrlen(objname1) + 2)) == NULL)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
HDstrcpy(obj1fullname, "/");
HDstrcat(obj1fullname, objname1);
@@ -607,11 +607,11 @@ h5diff(const char *fname1,
#ifdef H5_HAVE_ASPRINTF
/* Use the asprintf() routine, since it does what we're trying to do below */
if(HDasprintf(&obj2fullname, "/%s", objname2) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
#else /* H5_HAVE_ASPRINTF */
/* (malloc 2 more for "/" and end-of-line) */
if ((obj2fullname = (char*)HDmalloc(HDstrlen(objname2) + 2)) == NULL)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
HDstrcpy(obj2fullname, "/");
HDstrcat(obj2fullname, objname2);
#endif /* H5_HAVE_ASPRINTF */
@@ -630,12 +630,12 @@ h5diff(const char *fname1,
/* check if link itself exist */
if(H5Lexists(file1_id, obj1fullname, H5P_DEFAULT) <= 0) {
parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Object could not be found");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Error: Object could not be found");
}
/* get info from link */
if(H5Lget_info(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0) {
parallel_print("Unable to get link info from <%s>\n", obj1fullname);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Lget_info failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Lget_info failed");
}
info1_lp = info1_obj;
@@ -651,7 +651,7 @@ h5diff(const char *fname1,
if(H5Oget_info_by_name2(file1_id, obj1fullname, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
parallel_print("Error: Could not get file contents\n");
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Could not get file contents");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Error: Could not get file contents");
}
obj1type = (h5trav_type_t)oinfo1.type;
trav_info_add(info1_obj, obj1fullname, obj1type);
@@ -680,12 +680,12 @@ h5diff(const char *fname1,
/* check if link itself exist */
if(H5Lexists(file2_id, obj2fullname, H5P_DEFAULT) <= 0) {
parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Object could not be found");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Error: Object could not be found");
}
/* get info from link */
if(H5Lget_info(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0) {
parallel_print("Unable to get link info from <%s>\n", obj2fullname);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Lget_info failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Lget_info failed");
}
info2_lp = info2_obj;
@@ -701,7 +701,7 @@ h5diff(const char *fname1,
if(H5Oget_info_by_name2(file2_id, obj2fullname, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
parallel_print("Error: Could not get file contents\n");
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Could not get file contents");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Error: Could not get file contents");
}
obj2type = (h5trav_type_t)oinfo2.type;
trav_info_add(info2_obj, obj2fullname, obj2type);
@@ -753,7 +753,7 @@ h5diff(const char *fname1,
/* treat dangling link as error */
if(opts->m_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", obj1fullname);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "treat dangling link as error");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "treat dangling link as error");
}
else {
if(opts->m_verbose)
@@ -767,7 +767,7 @@ h5diff(const char *fname1,
}
else if(l_ret1 < 0) { /* fail */
parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Object could not be found");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Object could not be found");
}
else if(l_ret1 != 2) { /* symbolic link */
obj1type = (h5trav_type_t)trg_linfo1.trg_type;
@@ -794,7 +794,7 @@ h5diff(const char *fname1,
/* treat dangling link as error */
if(opts->m_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", obj2fullname);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "treat dangling link as error");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "treat dangling link as error");
}
else {
if(opts->m_verbose)
@@ -808,7 +808,7 @@ h5diff(const char *fname1,
}
else if(l_ret2 < 0) { /* fail */
parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Object could not be found");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Object could not be found");
}
else if(l_ret2 != 2) { /* symbolic link */
obj2type = (h5trav_type_t)trg_linfo2.trg_type;
@@ -852,7 +852,7 @@ h5diff(const char *fname1,
if(h5trav_visit(file1_id, obj1fullname, TRUE, TRUE,
trav_grp_objs, trav_grp_symlinks, info1_grp, H5O_INFO_BASIC) < 0) {
parallel_print("Error: Could not get file contents\n");
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Could not get file contents");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Could not get file contents");
}
info1_lp = info1_grp;
@@ -866,7 +866,7 @@ h5diff(const char *fname1,
if(h5trav_visit(file2_id, obj2fullname, TRUE, TRUE,
trav_grp_objs, trav_grp_symlinks, info2_grp, H5O_INFO_BASIC) < 0) {
parallel_print("Error: Could not get file contents\n");
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Could not get file contents");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Could not get file contents");
} /* end if */
info2_lp = info2_grp;
}
@@ -1055,11 +1055,11 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
#ifdef H5_HAVE_ASPRINTF
/* Use the asprintf() routine, since it does what we're trying to do below */
if(HDasprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name) < 0) {
- HERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
+ H5TOOLS_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
}
#else /* H5_HAVE_ASPRINTF */
if((obj1_fullpath = (char*)HDmalloc(HDstrlen(grp1_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) {
- HERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
+ H5TOOLS_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
}
else {
HDstrcpy(obj1_fullpath, grp1_path);
@@ -1072,11 +1072,11 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
#ifdef H5_HAVE_ASPRINTF
/* Use the asprintf() routine, since it does what we're trying to do below */
if(HDasprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name) < 0) {
- HERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
+ H5TOOLS_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
}
#else /* H5_HAVE_ASPRINTF */
if((obj2_fullpath = (char*)HDmalloc(HDstrlen(grp2_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) {
- HERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
+ H5TOOLS_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
}
else {
HDstrcpy(obj2_fullpath, grp2_path);
@@ -1416,7 +1416,7 @@ diff(hid_t file1_id,
/* target object1 - get type and name */
if ((status = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, opts->follow_links)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5tools_get_symlink_info failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5tools_get_symlink_info failed");
/* dangling link */
if (status == 0) {
@@ -1424,7 +1424,7 @@ diff(hid_t file1_id,
/* dangling link is error */
if(opts->m_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", path1);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "dangling link is error");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "dangling link is error");
}
else
is_dangle_link1 = TRUE;
@@ -1432,14 +1432,14 @@ diff(hid_t file1_id,
/* target object2 - get type and name */
if ((status = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, opts->follow_links)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5tools_get_symlink_info failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5tools_get_symlink_info failed");
/* dangling link */
if (status == 0) {
if (opts->no_dangle_links) {
/* dangling link is error */
if(opts->m_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", path2);
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "dangling link is error");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "dangling link is error");
}
else
is_dangle_link2 = TRUE;
@@ -1534,9 +1534,9 @@ diff(hid_t file1_id,
*/
case H5TRAV_TYPE_DATASET:
if((dset1_id = H5Dopen2(file1_id, path1, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 failed");
if((dset2_id = H5Dopen2(file2_id, path2, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 failed");
/* verbose (-v) and report (-r) mode */
if(opts->m_verbose || opts->m_report) {
do_print_objname("dataset", path1, path2, opts);
@@ -1569,9 +1569,9 @@ diff(hid_t file1_id,
if(H5Dclose(dset1_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dclose failed");
if(H5Dclose(dset2_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dclose failed");
break;
/*----------------------------------------------------------------------
@@ -1580,12 +1580,12 @@ diff(hid_t file1_id,
*/
case H5TRAV_TYPE_NAMED_DATATYPE:
if((type1_id = H5Topen2(file1_id, path1, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Topen2 failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Topen2 failed");
if((type2_id = H5Topen2(file2_id, path2, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Topen2 failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Topen2 failed");
if((status = H5Tequal(type1_id, type2_id)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tequal failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tequal failed");
/* if H5Tequal is > 0 then the datatypes refer to the same datatype */
nfound = (status > 0) ? 0 : 1;
@@ -1607,9 +1607,9 @@ diff(hid_t file1_id,
nfound += diff_attr(type1_id, type2_id, path1, path2, opts);
if(H5Tclose(type1_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose failed");
if(H5Tclose(type2_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose failed");
break;
/*----------------------------------------------------------------------
@@ -1625,9 +1625,9 @@ diff(hid_t file1_id,
print_found(nfound);
if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed");
if((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed");
/*-----------------------------------------------------------------
* compare attributes
@@ -1639,9 +1639,9 @@ diff(hid_t file1_id,
nfound += diff_attr(grp1_id, grp2_id, path1, path2, opts);
if(H5Gclose(grp1_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed");
if(H5Gclose(grp2_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed");
break;
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 2a45913..c83b88d 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -472,7 +472,7 @@ static hsize_t diff_datum(
case H5T_TIME:
case H5T_NCLASSES:
default:
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Invalid type class");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Invalid type class");
break;
/*-------------------------------------------------------------------------
@@ -735,7 +735,12 @@ static hsize_t diff_datum(
hid_t obj1_id = -1;
hid_t obj2_id = -1;
- if (type_size == H5R_DSET_REG_REF_BUF_SIZE) {
+ if (H5Tequal(m_type, H5T_STD_REF)) {
+ /* if (type_size == H5R_STD_REF_SIZE) */
+ H5TOOLS_INFO(H5E_tools_min_info_id_g, "NEW reference type");
+ }
+ else if (H5Tequal(m_type, H5T_STD_REF_DSETREG)) {
+ /* if (type_size == H5R_DSET_REG_REF_BUF_SIZE) */
hid_t region1_id = -1;
hid_t region2_id = -1;
@@ -769,7 +774,8 @@ static hsize_t diff_datum(
* Object references. get the type and OID of the referenced object
*-------------------------------------------------------------------------
*/
- else if (type_size == H5R_OBJ_REF_BUF_SIZE) {
+ else if (H5Tequal(m_type, H5T_STD_REF_OBJ)) {
+ /* if (type_size == H5R_OBJ_REF_BUF_SIZE) */
H5O_type_t obj1_type;
H5O_type_t obj2_type;
@@ -853,7 +859,7 @@ static hsize_t diff_datum(
char temp2_char;
if(type_size != sizeof(char))
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not char size");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not char size");
HDmemcpy(&temp1_char, mem1, sizeof(char));
HDmemcpy(&temp2_char, mem2, sizeof(char));
/* -d and !-p */
@@ -928,7 +934,7 @@ static hsize_t diff_datum(
unsigned char temp2_uchar;
if(type_size != sizeof(unsigned char))
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned char size");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned char size");
HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
@@ -1004,7 +1010,7 @@ static hsize_t diff_datum(
short temp2_short;
if(type_size != sizeof(short))
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not short size");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not short size");
HDmemcpy(&temp1_short, mem1, sizeof(short));
HDmemcpy(&temp2_short, mem2, sizeof(short));
@@ -1080,7 +1086,7 @@ static hsize_t diff_datum(
unsigned short temp2_ushort;
if(type_size != sizeof(unsigned short))
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned short size");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned short size");
HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
@@ -1156,7 +1162,7 @@ static hsize_t diff_datum(
int temp2_int;
if(type_size != sizeof(int))
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not int size");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not int size");
HDmemcpy(&temp1_int, mem1, sizeof(int));
HDmemcpy(&temp2_int, mem2, sizeof(int));
@@ -1232,7 +1238,7 @@ static hsize_t diff_datum(
unsigned int temp2_uint;
if(type_size != sizeof(unsigned int))
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned int size");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned int size");
HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
@@ -1308,7 +1314,7 @@ static hsize_t diff_datum(
long temp2_long;
if(type_size != sizeof(long))
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not long size");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not long size");
HDmemcpy(&temp1_long, mem1, sizeof(long));
HDmemcpy(&temp2_long, mem2, sizeof(long));
@@ -1384,7 +1390,7 @@ static hsize_t diff_datum(
unsigned long temp2_ulong;
if(type_size != sizeof(unsigned long))
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned long size");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned long size");
HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
@@ -1468,7 +1474,7 @@ static hsize_t diff_datum(
hbool_t isnan2 = FALSE;
if(type_size != sizeof(float))
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not float size");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not float size");
HDmemcpy(&temp1_float, mem1, sizeof(float));
HDmemcpy(&temp2_float, mem2, sizeof(float));
@@ -1627,7 +1633,7 @@ static hsize_t diff_datum(
hbool_t isnan2 = FALSE;
if(type_size != sizeof(double))
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not double size");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not double size");
HDmemcpy(&temp1_double, mem1, sizeof(double));
HDmemcpy(&temp2_double, mem2, sizeof(double));
@@ -1786,7 +1792,7 @@ static hsize_t diff_datum(
hbool_t isnan2 = FALSE;
if(type_size != sizeof(long double)) {
- HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not long double size");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not long double size");
}
HDmemcpy(&temp1_double, mem1, sizeof(long double));
@@ -4242,18 +4248,18 @@ int ull2float(unsigned long long ull_value, float *f_value)
h5difftrace("ull2float start\n");
if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
src_size = H5Tget_size(H5T_NATIVE_ULLONG);
dst_size = H5Tget_size(H5T_NATIVE_FLOAT);
if((buf = (unsigned char*) HDcalloc((size_t )1, MAX(src_size, dst_size))) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
HDmemcpy(buf, &ull_value, src_size);
/* do conversion */
if (H5Tconvert(H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT, (size_t) 1, buf, NULL, dxpl_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tconvert failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tconvert failed");
HDmemcpy(f_value, buf, dst_size);
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 351e6ab..cd906af 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -155,13 +155,13 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
h5difftrace("build_match_list_attrs start\n");
if(H5Oget_info2(loc1_id, &oinfo1, H5O_INFO_NUM_ATTRS) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info first object failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info first object failed");
if(H5Oget_info2(loc2_id, &oinfo2, H5O_INFO_NUM_ATTRS) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info second object failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info second object failed");
table_attrs_init(&table_lp);
if (table_lp == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Table allocation failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "Table allocation failed");
/*--------------------------------------------------
* build the list
@@ -173,18 +173,18 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
/*------------------
* open attribute1 */
if((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx first attribute failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx first attribute failed");
/* get name */
if(H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name first attribute failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name first attribute failed");
/*------------------
* open attribute2 */
if((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx second attribute failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx second attribute failed");
/* get name */
if(H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name second attribute failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name second attribute failed");
/* criteria is string compare */
cmp = HDstrcmp(name1, name2);
@@ -227,10 +227,10 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
/*------------------
* open attribute1 */
if((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx first attribute failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx first attribute failed");
/* get name */
if(H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name first attribute failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name first attribute failed");
h5diffdebug2("build_match_list_attrs #1 name - %s\n", name1);
table_attr_mark_exist(infile, name1, table_lp);
@@ -250,10 +250,10 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
/*------------------
* open attribute2 */
if((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx second attribute failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx second attribute failed");
/* get name */
if(H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name second attribute failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name second attribute failed");
h5diffdebug2("build_match_list_attrs #2 name - %s\n", name2);
table_attr_mark_exist(infile, name2, table_lp);
@@ -351,7 +351,7 @@ hsize_t diff_attr(hid_t loc1_id,
h5difftrace("diff_attr start\n");
if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, opts) < 0) {
- HGOTO_ERROR(1, H5E_tools_min_id_g, "build_match_list_attrs failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "build_match_list_attrs failed");
}
h5diffdebug2("build_match_list_attrs - errstat:%d\n", opts->err_stat);
@@ -372,40 +372,40 @@ hsize_t diff_attr(hid_t loc1_id,
/*--------------
* attribute 1 */
if((attr1_id = H5Aopen(loc1_id, name1, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aopen first attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aopen first attribute failed");
/*--------------
* attribute 2 */
if((attr2_id = H5Aopen(loc2_id, name2, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aopen second attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aopen second attribute failed");
h5difftrace("diff_attr got attributes\n");
/* get the datatypes */
if((ftype1_id = H5Aget_type(attr1_id)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
if((ftype2_id = H5Aget_type(attr2_id)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
if((mtype1_id = H5Tget_native_type(ftype1_id, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type first attribute ftype failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type first attribute ftype failed");
if((mtype2_id = H5Tget_native_type(ftype2_id, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type second attribute ftype failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type second attribute ftype failed");
if((msize1 = H5Tget_size(mtype1_id)) == 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_size first attribute mtype failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_size first attribute mtype failed");
if((msize2 = H5Tget_size(mtype2_id)) == 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_size second attribute mtype failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_size second attribute mtype failed");
/* get the dataspace */
if((space1_id = H5Aget_space(attr1_id)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_space first attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_space first attribute failed");
if((space2_id = H5Aget_space(attr2_id)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_space second attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_space second attribute failed");
/* get dimensions */
if((rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims first attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims first attribute failed");
if((rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims second attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims second attribute failed");
/*----------------------------------------------------------------------
* check for comparable TYPE and SPACE
@@ -417,21 +417,21 @@ hsize_t diff_attr(hid_t loc1_id,
if(diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2,
dims1, dims2, name1, name2, opts, 0) != 1) {
if(H5Tclose(ftype1_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute ftype failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute ftype failed");
if(H5Tclose(ftype2_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute ftype failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute ftype failed");
if(H5Sclose(space1_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sclose first attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sclose first attribute failed");
if(H5Sclose(space2_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sclose second attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sclose second attribute failed");
if(H5Aclose(attr1_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose first attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose first attribute failed");
if(H5Aclose(attr2_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose second attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose second attribute failed");
if(H5Tclose(mtype1_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed");
if(H5Tclose(mtype2_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed");
continue;
}
@@ -442,7 +442,7 @@ hsize_t diff_attr(hid_t loc1_id,
*/
if(FAIL == match_up_memsize(ftype1_id, ftype2_id, &mtype1_id,
&mtype2_id, &msize1, &msize2))
- HGOTO_ERROR(1, H5E_tools_min_id_g, "match_up_memsize failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "match_up_memsize failed");
/*---------------------------------------------------------------------
* read
@@ -456,18 +456,18 @@ hsize_t diff_attr(hid_t loc1_id,
buf2 = (void *)HDcalloc((size_t)(nelmts1), msize2);
if(buf1 == NULL || buf2 == NULL) {
parallel_print("cannot read into memory\n");
- HGOTO_ERROR(1, H5E_tools_min_id_g, "buffer allocation failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "buffer allocation failed");
}
if(H5Aread(attr1_id, mtype1_id, buf1) < 0) {
parallel_print("Failed reading attribute1 %s/%s\n", path1, name1);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
}
else
buf1hasdata = TRUE;
if(H5Aread(attr2_id, mtype2_id, buf2) < 0) {
parallel_print("Failed reading attribute2 %s/%s\n", path2, name2);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
}
else
buf2hasdata = TRUE;
@@ -525,21 +525,21 @@ hsize_t diff_attr(hid_t loc1_id,
buf2 = NULL;
if(H5Tclose(ftype1_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
if(H5Tclose(ftype2_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
if(H5Sclose(space1_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
if(H5Sclose(space2_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
if(H5Aclose(attr1_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
if(H5Aclose(attr2_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
if(H5Tclose(mtype1_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed");
if(H5Tclose(mtype2_id) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed");
nfound_total += nfound;
}
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index 96f1d1a..56c4f0b 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -49,17 +49,17 @@ hsize_t diff_dataset(hid_t file1_id,
/* Open the datasets */
if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) {
parallel_print("Cannot open dataset <%s>\n", obj1_name);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 first dataset failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 first dataset failed");
}
if((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0) {
parallel_print("Cannot open dataset <%s>\n", obj2_name);
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 second dataset failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 second dataset failed");
}
if((dcpl1 = H5Dget_create_plist(did1)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist first dataset failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist first dataset failed");
if((dcpl2 = H5Dget_create_plist(did2)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist second dataset failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist second dataset failed");
/*-------------------------------------------------------------------------
* check if the dataset creation property list has filters that
@@ -72,7 +72,7 @@ hsize_t diff_dataset(hid_t file1_id,
(status = h5tools_canreadf((opts->m_verbose ? obj2_name : NULL), dcpl2) == 1))
nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, opts);
else if (status < 0) {
- HGOTO_ERROR(1, H5E_tools_min_id_g, "h5tools_canreadf failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "h5tools_canreadf failed");
}
else {
ret_value = 1;
@@ -198,27 +198,27 @@ hsize_t diff_datasetid(hid_t did1,
h5difftrace("diff_datasetid start\n");
/* Get the dataspace handle */
if((sid1 = H5Dget_space(did1)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_space failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_space failed");
/* Get rank */
if((rank1 = H5Sget_simple_extent_ndims(sid1)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
/* Get the dataspace handle */
if((sid2 = H5Dget_space(did2)) < 0 )
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_space failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_space failed");
/* Get rank */
if((rank2 = H5Sget_simple_extent_ndims(sid2)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
/* Get dimensions */
if(H5Sget_simple_extent_dims(sid1, dims1, maxdim1) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
/* Get dimensions */
if(H5Sget_simple_extent_dims(sid2, dims2, maxdim2) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
h5diffdebug3("rank: %ld - %ld\n", rank1, rank2);
/*-------------------------------------------------------------------------
@@ -228,25 +228,25 @@ hsize_t diff_datasetid(hid_t did1,
/* Get the data type */
if((f_tid1 = H5Dget_type(did1)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_type failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_type failed");
/* Get the data type */
if((f_tid2 = H5Dget_type(did2)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_type failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_type failed");
/*-------------------------------------------------------------------------
* get the storage layout type
*-------------------------------------------------------------------------
*/
if((dcpl1 = H5Dget_create_plist(did1)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((dcpl2 = H5Dget_create_plist(did2)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((stl1 = H5Pget_layout(dcpl1)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Pget_layout failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Pget_layout failed");
if((stl2 = H5Pget_layout(dcpl2)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Pget_layout failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Pget_layout failed");
/*-------------------------------------------------------------------------
* check for empty datasets
@@ -288,10 +288,10 @@ hsize_t diff_datasetid(hid_t did1,
*/
h5difftrace("check for memory type and sizes\n");
if((m_tid1 = H5Tget_native_type(f_tid1, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type failed");
if((m_tid2 = H5Tget_native_type(f_tid2, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type failed");
m_size1 = H5Tget_size(m_tid1);
m_size2 = H5Tget_size(m_tid2);
@@ -357,7 +357,7 @@ hsize_t diff_datasetid(hid_t did1,
if (FAIL == match_up_memsize (f_tid1, f_tid2,
&m_tid1, &m_tid2,
&m_size1, &m_size2))
- HGOTO_ERROR(1, H5E_tools_min_id_g, "match_up_memsize failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "match_up_memsize failed");
h5diffdebug3("m_size: %ld - %ld\n", m_size1, m_size2);
dadims = dims1;
dam_size = m_size1;
@@ -403,10 +403,10 @@ hsize_t diff_datasetid(hid_t did1,
if(buf1 != NULL && buf2 != NULL) {
h5difftrace("buf1 != NULL && buf2 != NULL\n");
if(H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed");
h5difftrace("H5Dread did2\n");
if(H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed");
/* array diff */
nfound = diff_array(buf1, buf2, danelmts, (hsize_t)0, rank1, dadims,
@@ -470,9 +470,9 @@ hsize_t diff_datasetid(hid_t did1,
* E.g., sm_space.
*/
if((sm_buf1 = HDmalloc((size_t)sm_nbytes)) == NULL)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "HDmalloc failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "HDmalloc failed");
if((sm_buf2 = HDmalloc((size_t)sm_nbytes)) == NULL)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "HDmalloc failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "HDmalloc failed");
sm_nelmts = sm_nbytes / p_type_nbytes;
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
@@ -489,19 +489,19 @@ hsize_t diff_datasetid(hid_t did1,
hs_nelmts *= hs_size[i];
} /* end for */
if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
} /* end if */
else
hs_nelmts = 1;
if(H5Dread(did1, m_tid1, sm_space, sid1, H5P_DEFAULT, sm_buf1) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed");
if(H5Dread(did2, m_tid2, sm_space, sid2, H5P_DEFAULT, sm_buf2) < 0)
- HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed");
+ H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed");
/* get array differences. in the case of hyperslab read, increment the number of differences
found in each hyperslab and pass the position at the beginning for printing */
@@ -630,9 +630,9 @@ int diff_can_type(hid_t f_tid1, /* file data type */
*-------------------------------------------------------------------------
*/
if((tclass1 = H5Tget_class(f_tid1)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_class first object failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_class first object failed");
if((tclass2 = H5Tget_class(f_tid2)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_class second object failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_class second object failed");
if(tclass1 != tclass2) {
if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) {
diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c
index 41a40f1..6b5ca2f 100644
--- a/tools/lib/h5diff_util.c
+++ b/tools/lib/h5diff_util.c
@@ -346,7 +346,7 @@ herr_t match_up_memsize (hid_t f_tid1_id, hid_t f_tid2_id,
H5Tclose(*m_tid1);
if(((*m_tid1) = H5Tget_native_type(f_tid2_id, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed");
*m_size1 = H5Tget_size(*m_tid1);
} /* end if */
@@ -354,13 +354,13 @@ herr_t match_up_memsize (hid_t f_tid1_id, hid_t f_tid2_id,
H5Tclose(*m_tid2);
if(((*m_tid2) = H5Tget_native_type(f_tid1_id, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed");
*m_size2 = H5Tget_size(*m_tid2);
} /* end else */
} /* end if */
if((*m_size1) != (*m_size2))
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "native type sizes do not compare");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "native type sizes do not compare");
done:
return ret_value;
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 627d4f2..727e493 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -27,6 +27,8 @@ hid_t H5tools_ERR_STACK_g = 0;
hid_t H5tools_ERR_CLS_g = -1;
hid_t H5E_tools_g = -1;
hid_t H5E_tools_min_id_g = -1;
+hid_t H5E_tools_min_info_id_g = -1;
+hid_t H5E_tools_min_dbg_id_g = -1;
int compound_data;
FILE *rawattrstream = NULL; /* should initialize to stdout but gcc moans about it */
FILE *rawdatastream = NULL; /* should initialize to stdout but gcc moans about it */
@@ -440,11 +442,11 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
/* Make a copy of the FAPL, for the file open call to use, eventually */
if (fapl == H5P_DEFAULT) {
if ((new_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
} /* end if */
else {
if ((new_fapl = H5Pcopy(fapl)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcopy failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcopy failed");
} /* end else */
/* Determine which driver the user wants to open the file with. Try
@@ -452,7 +454,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
if (!HDstrcmp(driver, drivernames[SEC2_IDX])) {
/* SEC2 driver */
if (H5Pset_fapl_sec2(new_fapl) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_sec2 failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_sec2 failed");
if (drivernum)
*drivernum = SEC2_IDX;
@@ -464,7 +466,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
* is the member size.
*/
if (H5Pset_fapl_family(new_fapl, (hsize_t) 0, H5P_DEFAULT) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_family failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_family failed");
if (drivernum)
*drivernum = FAMILY_IDX;
@@ -472,7 +474,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
else if (!HDstrcmp(driver, drivernames[SPLIT_IDX])) {
/* SPLIT Driver */
if (H5Pset_fapl_split(new_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_split failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_split failed");
if (drivernum)
*drivernum = SPLIT_IDX;
@@ -480,7 +482,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
else if (!HDstrcmp(driver, drivernames[MULTI_IDX])) {
/* MULTI Driver */
if (H5Pset_fapl_multi(new_fapl, NULL, NULL, NULL, NULL, TRUE) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_multi failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_multi failed");
if(drivernum)
*drivernum = MULTI_IDX;
@@ -496,7 +498,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
if(mpi_initialized && !mpi_finalized) {
if(H5Pset_fapl_mpio(new_fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_mpio failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_mpio failed");
if(drivernum)
*drivernum = MPIO_IDX;
} /* end if */
@@ -734,6 +736,7 @@ void
h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
h5tools_context_t *ctx, hsize_t elmtno, int secnum)
{
+ H5TOOLS_ERR_INIT(int, SUCCEED)
h5tools_str_t prefix;
h5tools_str_t str; /*temporary for indentation */
size_t templength = 0;
@@ -745,18 +748,24 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
if (!ctx->need_prefix)
return;
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
+
HDmemset(&prefix, 0, sizeof(h5tools_str_t));
HDmemset(&str, 0, sizeof(h5tools_str_t));
/* Terminate previous line, if any */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "before CR elmtno=%ld, ctx->cur_column=%d, info->idx_fmt=%s, info->line_suf=%s", elmtno, ctx->cur_column, info->idx_fmt, info->line_suf);
if (ctx->cur_column) {
PUTSTREAM(OPT(info->line_suf, ""), stream);
HDputc('\n', stream);
PUTSTREAM(OPT(info->line_sep, ""), stream);
}
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "after CR elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims);
/* Calculate new prefix */
h5tools_str_prefix(&prefix, info, elmtno, ctx->ndims, ctx);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "prefix=%s - str=%s", prefix.s, str.s);
/* Write new prefix to output */
if (ctx->indent_level > 0)
@@ -784,8 +793,9 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_pre), stream);
templength = h5tools_str_len(&prefix);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "prefix=%s - templength=%d", prefix.s, templength);
- for (u = 0; u < indentlevel; u++)
+ for (u = 0; u < indentlevel; u++) {
/*we already made the indent for the array indices case */
if (!info->pindex) {
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_indent), stream);
@@ -795,14 +805,20 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
/*we cannot count the prefix for the array indices case */
templength += h5tools_str_len(&str);
}
+ }
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "prefix=%s - templength=%d", prefix.s, templength);
ctx->cur_column = ctx->prev_prefix_len = templength;
ctx->cur_elmt = 0;
ctx->need_prefix = 0;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "prefix=%s - str=%s", prefix.s, str.s);
/* Free string */
h5tools_str_close(&prefix);
h5tools_str_close(&str);
+
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
}
/*-------------------------------------------------------------------------
@@ -918,6 +934,7 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos,
size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter)
{
+ H5TOOLS_ERR_INIT(hbool_t, TRUE)
hbool_t dimension_break = TRUE;
char *s = NULL;
char *section = NULL; /* a section of output */
@@ -927,7 +944,12 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
if (stream == NULL)
return dimension_break;
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter need_prefix=%d", ctx->need_prefix);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "elmt_counter=%ld - local_elmt_counter=%ld", elmt_counter, local_elmt_counter);
+
s = h5tools_str_fmt(buffer, (size_t)0, "%s");
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "s=%s", s);
/*
* If the element would split on multiple lines if printed at our
@@ -954,6 +976,7 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
*/
ctx->need_prefix = TRUE;
}
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ctx->need_prefix=%d", ctx->need_prefix);
}
/*
@@ -969,7 +992,9 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
ctx->need_prefix = TRUE;
dimension_break = FALSE;
}
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ctx->need_prefix=%d", ctx->need_prefix);
}
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "elmt_counter=%ld - ctx->size_last_dim=%ld info->line_suf=%s", elmt_counter, ctx->size_last_dim, info->line_suf);
/*
* If the previous element occupied multiple lines and this element
@@ -983,6 +1008,7 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
HDstrlen(OPT(info->elmt_suf2, " ")) +
HDstrlen(OPT(info->line_suf, ""))) > ncols)
ctx->need_prefix = TRUE;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ctx->need_prefix=%d", ctx->need_prefix);
/*
* If too many elements have already been printed then we need to
@@ -990,6 +1016,7 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
*/
if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line)
ctx->need_prefix = TRUE;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ctx->need_prefix=%d", ctx->need_prefix);
/*
* Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause
@@ -1018,6 +1045,7 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
* Print the prefix or separate the beginning of this element
* from the previous element.
*/
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ctx->need_prefix=%d", ctx->need_prefix);
if (ctx->need_prefix) {
if (secnum)
multiline++;
@@ -1027,6 +1055,7 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
* this is necessary to print the array indices
*/
*curr_pos = ctx->sm_pos + local_elmt_counter;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "curr_pos=%ld - ctx->sm_pos=%ld - ctx->ndims=%ld", *curr_pos, ctx->sm_pos, ctx->ndims);
h5tools_simple_prefix(stream, info, ctx, *curr_pos, secnum);
}
@@ -1034,6 +1063,7 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
PUTSTREAM(OPT(info->elmt_suf2, " "), stream);
ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " "));
}
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "section=%s", section);
/* Print the section */
PUTSTREAM(section, stream);
@@ -1041,6 +1071,10 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
}
ctx->prev_multiline = multiline;
+
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
+
return dimension_break;
}
@@ -1074,22 +1108,25 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos,
size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter)
{
+ H5TOOLS_ERR_INIT(hbool_t, TRUE)
hbool_t dimension_break = TRUE;
char *s = NULL;
char *section = NULL; /* a section of output */
int secnum; /* section sequence number */
int multiline; /* datum was multiline */
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "elmt_counter=%ld - local_elmt_counter=%ld", elmt_counter, local_elmt_counter);
+
s = h5tools_str_fmt(buffer, (size_t)0, "%s");
/*
* If the element would split on multiple lines if printed at our
* current location...
*/
- if (info->line_multi_new == 1 &&
- (ctx->cur_column + h5tools_count_ncols(s) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) > ncols) {
+ if (info->line_multi_new == 1 && (ctx->cur_column + h5tools_count_ncols(s) +
+ HDstrlen(OPT(info->elmt_suf2, " ")) + HDstrlen(OPT(info->line_suf, ""))) > ncols) {
if (ctx->prev_multiline) {
/*
* ... and the previous element also occupied more than one
@@ -1098,8 +1135,7 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
ctx->need_prefix = TRUE;
}
else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) <= ncols) {
+ HDstrlen(OPT(info->elmt_suf2, " ")) + HDstrlen(OPT(info->line_suf, ""))) <= ncols) {
/*
* ...but *could* fit on one line otherwise, then we
* should end the current line and start this element on its
@@ -1129,12 +1165,8 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
* is too long to fit on a line then start this element at the
* beginning of the line.
*/
- if (info->line_multi_new == 1 &&
- ctx->prev_multiline &&
- (ctx->cur_column +
- h5tools_count_ncols(s) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) > ncols)
+ if (info->line_multi_new == 1 && ctx->prev_multiline &&
+ (ctx->cur_column + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) + HDstrlen(OPT(info->line_suf, ""))) > ncols)
ctx->need_prefix = TRUE;
/*
@@ -1150,8 +1182,7 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
* one-at a time.
*/
multiline = 0;
- for (secnum = 0, multiline = 0; (section = HDstrtok(secnum ? NULL : s,
- OPTIONAL_LINE_BREAK)); secnum++) {
+ for (secnum = 0, multiline = 0; (section = HDstrtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); secnum++) {
/*
* If the current section plus possible suffix and end-of-line
* information would cause the output to wrap then we need to
@@ -1163,10 +1194,7 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
* this check to happen for the first line
*/
if ((!info->skip_first || local_elmt_counter) &&
- (ctx->cur_column +
- HDstrlen(section) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) > ncols)
+ (ctx->cur_column + HDstrlen(section) + HDstrlen(OPT(info->elmt_suf2, " ")) + HDstrlen(OPT(info->line_suf, ""))) > ncols)
ctx->need_prefix = 1;
/*
@@ -1177,11 +1205,12 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
if (secnum)
multiline++;
- /* pass to the prefix in h5tools_simple_prefix the total
+ /* pass to the prefix in h5tools_region_simple_prefix the total
* position instead of the current stripmine position i;
* this is necessary to print the array indices
*/
*curr_pos = ctx->sm_pos + local_elmt_counter;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "curr_pos=%ld - ctx->sm_pos=%ld", *curr_pos, ctx->sm_pos);
h5tools_region_simple_prefix(stream, info, ctx, local_elmt_counter, ptdata, secnum);
}
@@ -1196,6 +1225,10 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
}
ctx->prev_multiline = multiline;
+
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
+
return dimension_break;
}
@@ -1210,16 +1243,25 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
void
init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
{
+ H5TOOLS_ERR_INIT(int, SUCCEED)
int i;
unsigned j;
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
+
if(ctx->ndims > 0) {
ctx->acc[ctx->ndims - 1] = 1;
- for (i = ((int)ctx->ndims - 2); i >= 0; i--)
+ for (i = ((int)ctx->ndims - 2); i >= 0; i--) {
ctx->acc[i] = ctx->acc[i + 1] * dims[i + 1];
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ctx->acc[%d]=%ld", i, ctx->acc[i]);
+ }
for (j = 0; j < ctx->ndims; j++)
ctx->pos[j] = 0;
}
+
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
}
/*-------------------------------------------------------------------------
@@ -1234,23 +1276,26 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
int
render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts)
{
- HERR_INIT(int, SUCCEED)
+ H5TOOLS_ERR_INIT(int, SUCCEED)
unsigned char *mem = (unsigned char*)_mem;
size_t size; /* datum size */
hsize_t block_index;
H5T_class_t type_class;
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
if((size = H5Tget_size(tid)) == 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
if((type_class = H5Tget_class(tid)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed");
switch (type_class) {
case H5T_INTEGER:
case H5T_FLOAT:
case H5T_ENUM:
case H5T_BITFIELD:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "numbers");
block_index = block_nelmts * size;
while(block_index > 0) {
size_t bytes_in = 0; /* # of bytes to write */
@@ -1264,7 +1309,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
bytes_wrote = HDfwrite(mem, 1, bytes_in, stream);
if(bytes_wrote != bytes_in || (0 == bytes_wrote && HDferror(stream)))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
block_index -= (hsize_t)bytes_wrote;
mem = mem + bytes_wrote;
@@ -1277,6 +1322,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
char *s = NULL;
unsigned char tempuchar;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_STRING");
pad = H5Tget_strpad(tid);
for (block_index = 0; block_index < block_nelmts; block_index++) {
@@ -1287,7 +1333,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
if (s != NULL)
size = HDstrlen(s);
else
- H5E_THROW(FAIL, H5E_tools_min_id_g, "NULL string");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "NULL string");
}
else {
s = (char *) mem;
@@ -1295,7 +1341,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char));
if (1 != HDfwrite(&tempuchar, sizeof(unsigned char), 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
} /* i */
} /* for (block_index = 0; block_index < block_nelmts; block_index++) */
}
@@ -1305,8 +1351,9 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
int snmembs;
unsigned nmembs;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_COMPOUND");
if((snmembs = H5Tget_nmembers(tid)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers of compound failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers of compound failed");
nmembs = (unsigned)snmembs;
for (block_index = 0; block_index < block_nelmts; block_index++) {
@@ -1322,7 +1369,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
if (render_bin_output(stream, container, memb, mem + offset, 1) < 0) {
H5Tclose(memb);
- H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output of compound member failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output of compound member failed");
}
H5Tclose(memb);
@@ -1336,6 +1383,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts;
hid_t memb = -1;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_ARRAY");
/* get the array's base datatype for each element */
memb = H5Tget_super(tid);
ndims = H5Tget_array_ndims(tid);
@@ -1350,7 +1398,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
}
else {
H5Tclose(memb);
- H5E_THROW(FAIL, H5E_tools_min_id_g, "calculate the number of array elements failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "calculate the number of array elements failed");
}
for (block_index = 0; block_index < block_nelmts; block_index++) {
@@ -1358,7 +1406,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
/* dump the array element */
if (render_bin_output(stream, container, memb, mem, nelmts) < 0) {
H5Tclose(memb);
- H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
}
}
H5Tclose(memb);
@@ -1369,7 +1417,8 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
hsize_t nelmts;
hid_t memb = -1;
- /* get the VL sequences's base datatype for each element */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_VLEN");
+ /* get the VL sequences's base datatype for each element */
memb = H5Tget_super(tid);
for (block_index = 0; block_index < block_nelmts; block_index++) {
@@ -1380,7 +1429,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
/* dump the array element */
if (render_bin_output(stream, container, memb, ((char *) (((hvl_t *)((void *)mem))->p)), nelmts) < 0) {
H5Tclose(memb);
- H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
}
}
H5Tclose(memb);
@@ -1388,45 +1437,58 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
break;
case H5T_REFERENCE:
{
- if (size == H5R_DSET_REG_REF_BUF_SIZE) {
- /* if (H5Tequal(tid, H5T_STD_REF_DSETREG)) */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "reference class type");
+ if (H5Tequal(tid, H5T_STD_REF)) {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_STD_REF");
if (region_output) {
/* region data */
- hid_t region_id = -1;
- hid_t region_space = -1;
+ hid_t region_id = H5I_INVALID_HID;
+ hid_t region_space = H5I_INVALID_HID;
H5S_sel_type region_type;
for (block_index = 0; block_index < block_nelmts; block_index++) {
mem = ((unsigned char*)_mem) + block_index * size;
- region_id = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, mem);
- if (region_id >= 0) {
- region_space = H5Rget_region(container, H5R_DATASET_REGION, mem);
- if (region_space >= 0) {
- region_type = H5Sget_select_type(region_space);
- if(region_type == H5S_SEL_POINTS)
- render_bin_output_region_points(region_space, region_id, stream, container);
- else
- render_bin_output_region_blocks(region_space, region_id, stream, container);
+ if((region_id = H5Ropen_object((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g,
+ "H5Ropen_object H5T_STD_REF failed");
+ else {
+ if((region_space = H5Ropen_region((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if (!h5tools_is_zero(mem, H5Tget_size(H5T_STD_REF))) {
+ region_type = H5Sget_select_type(region_space);
+ if(region_type == H5S_SEL_POINTS)
+ render_bin_output_region_points(region_space, region_id, stream, container);
+ else
+ render_bin_output_region_blocks(region_space, region_id, stream, container);
+ }
+ else {
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g,
+ "H5Ropen_object H5T_STD_REF NULL");
+ }
H5Sclose(region_space);
} /* end if (region_space >= 0) */
H5Dclose(region_id);
- } /* end if (region_id >= 0) */
+ }
}
} /* end if (region_output... */
}
- else if (size == H5R_OBJ_REF_BUF_SIZE) {
- /* if (H5Tequal(tid, H5T_STD_REF_OBJ)) */
- ;
+ else if (H5Tequal(tid, H5T_STD_REF_DSETREG)) {
+ /* if (size == H5R_DSET_REG_REF_BUF_SIZE) */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_STD_REF_DSETREG");
+ }
+ else if (H5Tequal(tid, H5T_STD_REF_OBJ)) {
+ /* if (size == H5R_OBJ_REF_BUF_SIZE) */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_STD_REF_OBJ");
}
}
break;
case H5T_TIME:
case H5T_OPAQUE:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_OPAQUE");
for (block_index = 0; block_index < block_nelmts; block_index++) {
mem = ((unsigned char*)_mem) + block_index * size;
if (size != HDfwrite(mem, sizeof(char), size, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
} /* end for */
break;
@@ -1434,11 +1496,13 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
case H5T_NCLASSES:
default:
/* Badness */
- H5E_THROW(FAIL, H5E_tools_min_id_g, "bad type class");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "bad type class");
break;
} /* end switch */
CATCH
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
return ret_value;
}
@@ -1457,6 +1521,7 @@ int
render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
hid_t container, unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata)
{
+ H5TOOLS_ERR_INIT(int, SUCCEED)
hsize_t *dims1 = NULL;
hsize_t *start = NULL;
hsize_t *count = NULL;
@@ -1468,15 +1533,14 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
void *region_buf = NULL;
hsize_t blkndx;
hid_t sid1 = -1;
- int ret_value = SUCCEED;
/* Get the dataspace of the dataset */
if((sid1 = H5Dget_space(region_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
/* Allocate space for the dimension array */
if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
/* find the dimensions of each data space from the block coordinates */
numelem = 1;
@@ -1487,21 +1551,21 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
/* Create dataspace for reading buffer */
if((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
if((type_size = H5Tget_size(type_id)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
if((region_buf = HDmalloc(type_size * (size_t)numelem)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate region buffer");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate region buffer");
/* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */
/* 1 2 n 1 2 n */
if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start");
if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count");
for (blkndx = 0; blkndx < nblocks; blkndx++) {
for (jndx = 0; jndx < ndims; jndx++) {
@@ -1510,29 +1574,31 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
}
if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
if(render_bin_output(stream, container, type_id, (char*)region_buf, numelem) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "render_bin_output of data region failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "render_bin_output of data region failed");
/* Render the region data element end */
+done:
+ ;
} /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */
- done:
+CATCH
HDfree(start);
HDfree(count);
HDfree(region_buf);
HDfree(dims1);
if(H5Sclose(mem_space) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
if(H5Sclose(sid1) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
return ret_value;
}
@@ -1551,7 +1617,7 @@ hbool_t
render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
FILE *stream, hid_t container)
{
- HERR_INIT(hbool_t, TRUE)
+ H5TOOLS_ERR_INIT(hbool_t, TRUE)
hssize_t snblocks;
hsize_t nblocks;
hsize_t alloc_size;
@@ -1562,37 +1628,36 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
hid_t type_id = -1;
if((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
- H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed");
+ H5TOOLS_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed");
nblocks = (hsize_t)snblocks;
/* Print block information */
if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
- H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ H5TOOLS_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
ndims = (unsigned)sndims;
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
+ H5TOOLS_GOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, nblocks, ptdata) < 0)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed");
+ H5TOOLS_GOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed");
if((dtype = H5Dget_type(region_id)) < 0)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
+ H5TOOLS_GOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed");
+ H5TOOLS_GOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed");
- render_bin_output_region_data_blocks(region_id, stream, container, ndims,
- type_id, nblocks, ptdata);
+ render_bin_output_region_data_blocks(region_id, stream, container, ndims, type_id, nblocks, ptdata);
done:
HDfree(ptdata);
if(type_id > 0 && H5Tclose(type_id) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
if(dtype > 0 && H5Tclose(dtype) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
H5_LEAVE(TRUE)
@@ -1622,40 +1687,40 @@ render_bin_output_region_data_points(hid_t region_space, hid_t region_id,
FILE *stream, hid_t container,
unsigned ndims, hid_t type_id, hsize_t npoints)
{
+ H5TOOLS_ERR_INIT(int, SUCCEED)
hsize_t *dims1 = NULL;
size_t type_size;
hid_t mem_space = -1;
void *region_buf = NULL;
- int ret_value = SUCCEED;
if((type_size = H5Tget_size(type_id)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
if((region_buf = HDmalloc(type_size * (size_t)npoints)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for region");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for region");
/* Allocate space for the dimension array */
if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
dims1[0] = npoints;
if((mem_space = H5Screate_simple(1, dims1, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
if(render_bin_output(stream, container, type_id, (char*)region_buf, npoints) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "render_bin_output of data points failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "render_bin_output of data points failed");
done:
HDfree(region_buf);
HDfree(dims1);
if(H5Sclose(mem_space) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
return ret_value;
}
@@ -1674,7 +1739,7 @@ hbool_t
render_bin_output_region_points(hid_t region_space, hid_t region_id,
FILE *stream, hid_t container)
{
- HERR_INIT(hbool_t, TRUE)
+ H5TOOLS_ERR_INIT(hbool_t, TRUE)
hssize_t snpoints;
hsize_t npoints;
int sndims;
@@ -1683,29 +1748,28 @@ render_bin_output_region_points(hid_t region_space, hid_t region_id,
hid_t type_id = -1;
if((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0)
- H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed");
+ H5TOOLS_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed");
npoints = (hsize_t)snpoints;
/* Allocate space for the dimension array */
if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
- H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ H5TOOLS_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
ndims = (unsigned)sndims;
if((dtype = H5Dget_type(region_id)) < 0)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
+ H5TOOLS_GOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed");
+ H5TOOLS_GOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed");
- render_bin_output_region_data_points(region_space, region_id,
- stream, container, ndims, type_id, npoints);
+ render_bin_output_region_data_points(region_space, region_id, stream, container, ndims, type_id, npoints);
done:
if(type_id > 0 && H5Tclose(type_id) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
if(dtype > 0 && H5Tclose(dtype) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
H5_LEAVE(ret_value)
CATCH
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index c360230..11ba612 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -91,6 +91,7 @@
#define PACKED_BITS "PACKED_BITS"
#define PACKED_OFFSET "OFFSET"
#define PACKED_LENGTH "LENGTH"
+#define REGION "REGION"
#define VDS_VIRTUAL "VIRTUAL"
#define VDS_MAPPING "MAPPING"
#define VDS_SOURCE "SOURCE"
@@ -479,10 +480,10 @@ typedef struct h5tool_format_t {
/*used to skip the first set of checks for line length*/
int skip_first;
- /*flag used to hide or show the file number for obj refs*/
+ /*flag used to hide or show the file number for object refs*/
int obj_hidefileno;
- /*string used to format the output for the obje refs*/
+ /*string used to format the output for the object refs*/
const char *obj_format;
/*flag used to hide or show the file number for dataset regions*/
@@ -504,25 +505,25 @@ typedef struct h5tool_format_t {
} h5tool_format_t;
typedef struct h5tools_context_t {
- size_t cur_column; /*current column for output */
- size_t cur_elmt; /*current element/output line */
- int need_prefix; /*is line prefix needed? */
- unsigned ndims; /*dimensionality */
- hsize_t p_min_idx[H5S_MAX_RANK]; /*min selected index */
- hsize_t p_max_idx[H5S_MAX_RANK]; /*max selected index */
- int prev_multiline; /*was prev datum multiline? */
- size_t prev_prefix_len; /*length of previous prefix */
- int continuation; /*continuation of previous data?*/
- hsize_t size_last_dim; /*the size of the last dimension,
- *needed so we can break after each
- *row */
- unsigned indent_level; /*the number of times we need some
- *extra indentation */
- unsigned default_indent_level; /*this is used when the indent level gets changed */
+ size_t cur_column; /* current column for output */
+ size_t cur_elmt; /* current element/output line */
+ int need_prefix; /* is line prefix needed? */
+ unsigned ndims; /* dimensionality */
+ hsize_t p_min_idx[H5S_MAX_RANK]; /* min selected index */
+ hsize_t p_max_idx[H5S_MAX_RANK]; /* max selected index */
+ int prev_multiline; /* was prev datum multiline? */
+ size_t prev_prefix_len; /* length of previous prefix */
+ int continuation; /* continuation of previous data?*/
+ hsize_t size_last_dim; /* the size of the last dimension, needed so we can break after each row */
+ unsigned indent_level; /* the number of times we need some extra indentation */
+ unsigned default_indent_level; /* this is used when the indent level gets changed */
hsize_t acc[H5S_MAX_RANK]; /* accumulator position */
hsize_t pos[H5S_MAX_RANK]; /* matrix position */
hsize_t sm_pos; /* current stripmine element position */
const struct H5LD_memb_t * const *cmpd_listv; /* h5watch: vector containing info about the list of compound fields to be printed */
+ struct subset_t *sset; /* subsetting parameters */
+ int display_index; /* */
+ int display_char; /* */
} h5tools_context_t;
typedef struct subset_d {
@@ -569,8 +570,8 @@ H5TOOLS_DLLVAR int data_output; /* data output */
H5TOOLS_DLLVAR int attr_data_output; /* attribute data output */
/* sort parameters */
-H5TOOLS_DLLVAR H5_index_t sort_by; /*sort_by [creation_order | name] */
-H5TOOLS_DLLVAR H5_iter_order_t sort_order; /*sort_order [ascending | descending] */
+H5TOOLS_DLLVAR H5_index_t sort_by; /* sort_by [creation_order | name] */
+H5TOOLS_DLLVAR H5_iter_order_t sort_order; /* sort_order [ascending | descending] */
/* things to display or which are set via command line parameters */
H5TOOLS_DLLVAR int enable_error_stack; /* re-enable error stack; disable=0 enable=1 */
@@ -579,6 +580,7 @@ H5TOOLS_DLLVAR int enable_error_stack; /* re-enable error stack; disable=0 e
#define H5_TOOLS_GROUP "GROUP"
#define H5_TOOLS_DATASET "DATASET"
#define H5_TOOLS_DATATYPE "DATATYPE"
+#define H5_TOOLS_ATTRIBUTE "ATTRIBUTE"
/* Definitions of useful routines */
H5TOOLS_DLL void h5tools_init(void);
@@ -619,12 +621,12 @@ H5TOOLS_DLL hbool_t h5tools_render_element(FILE *stream, const h5tool_format_t *
h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos,
size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter);
H5TOOLS_DLL hbool_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/,
- h5tools_str_t *buffer/*string into which to render */,
- hsize_t *curr_pos/*total data element position*/,
- size_t ncols, hsize_t *ptdata,
- hsize_t local_elmt_counter/*element counter*/,
- hsize_t elmt_counter);
+ h5tools_context_t *ctx, /*in,out*/
+ h5tools_str_t *buffer, /*string into which to render */
+ hsize_t *curr_pos, /*total data element position*/
+ size_t ncols, hsize_t *ptdata,
+ hsize_t local_elmt_counter, /*element counter*/
+ hsize_t elmt_counter);
#ifdef __cplusplus
}
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index ebe5c4a..4a18785 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -184,45 +184,30 @@ BLOCK, /*blockbegin */
};
const h5tools_dump_header_t* h5tools_dump_header_format;
-table_t *h5dump_type_table = NULL; /*type table reference for datatype dump */
+table_t *h5dump_type_table = NULL; /* type table reference for datatype dump */
/* local prototypes */
+
static int h5tools_print_region_data_blocks(hid_t region_id,
FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
- h5tools_str_t *buffer/*string into which to render */, size_t ncols,
- unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata);
-
-hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
- FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/,
- h5tools_str_t *buffer/*string into which to render */,
- hsize_t *curr_pos/*total data element position*/,
- size_t ncols, hsize_t region_elmt_counter/*element counter*/,
- hsize_t elmt_counter);
+ h5tools_str_t *buffer, /* string into which to render */
+ size_t ncols, unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata);
static int h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
h5tools_str_t *buffer, size_t ncols,
unsigned ndims, hid_t type_id, hsize_t npoints, hsize_t *ptdata);
-hbool_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
- FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/,
- h5tools_str_t *buffer/*string into which to render */,
- hsize_t *curr_pos/*total data element position*/,
- size_t ncols, hsize_t region_elmt_counter/*element counter*/,
- hsize_t elmt_counter);
-
void h5tools_print_dims(h5tools_str_t *buffer, hsize_t *s, int dims);
void h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, struct subset_t *sset, int dims);
+ h5tools_context_t *ctx, int dims);
static void h5tools_print_virtual_selection(hid_t vspace,
FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/,
- h5tools_str_t *buffer/*string into which to render */,
- hsize_t *curr_pos/*total data element position*/,
+ h5tools_context_t *ctx, /* in,out */
+ h5tools_str_t *buffer, /* string into which to render */
+ hsize_t *curr_pos, /* total data element position */
size_t ncols);
void
@@ -269,30 +254,31 @@ h5tools_dump_init(void)
*/
int
h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container,
- h5tools_context_t *ctx/*in,out*/, unsigned flags,
- hsize_t nelmts, hid_t type, void *_mem)
+ h5tools_context_t *ctx, /* in,out */
+ unsigned flags, hsize_t nelmts, hid_t type, void *_mem)
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
+ H5TOOLS_ERR_INIT(int, SUCCEED)
unsigned char *mem = (unsigned char*) _mem;
- hsize_t i; /*element counter */
- size_t size; /*size of each datum */
- hid_t region_space = -1;
- hid_t region_id = -1;
+ hsize_t i; /* element counter */
+ size_t size; /* size of each datum */
hbool_t dimension_break = TRUE;
- H5S_sel_type region_type;
- size_t ncols = 80; /*available output width */
- h5tools_str_t buffer; /*string into which to render */
- hsize_t curr_pos = 0; /* total data element position */
- hsize_t elmt_counter = 0;/*counts the # elements printed.
- *I (ptl?) needed something that
- *isn't going to get reset when a new
- *line is formed. I'm going to use
- *this var to count elements and
- *break after we see a number equal
- *to the ctx->size_last_dim. */
-
+ size_t ncols = 80; /* available output width */
+ h5tools_str_t buffer; /* string into which to render */
+ hsize_t curr_pos = 0; /* total data element position */
+ hsize_t elmt_counter = 0;/* counts the # elements printed.
+ * I (ptl?) needed something that
+ * isn't going to get reset when a new
+ * line is formed. I'm going to use
+ * this var to count elements and
+ * break after we see a number equal
+ * to the ctx->size_last_dim. */
+
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter file=%p", (void*)stream);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "rawdata file=%p", (void*)rawdatastream);
/* binary dump */
if (bin_output && (rawdatastream != NULL)) {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "render_bin_output");
if (render_bin_output(rawdatastream, container, type, _mem, nelmts) < 0) {
PRINTVALSTREAM(rawoutstream, "\nError in writing binary stream\n");
}
@@ -301,6 +287,7 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
size = H5Tget_size(type);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "type size is %ld", size);
if (info->line_ncols > 0)
ncols = info->line_ncols;
@@ -311,97 +298,173 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
*/
curr_pos = ctx->sm_pos;
- if (region_output && (size == H5R_DSET_REG_REF_BUF_SIZE)) {
- for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) {
- void* memref = mem + i * size;
- char ref_name[1024];
-
- /* region data */
- region_id = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, memref);
- if (region_id >= 0) {
- region_space = H5Rget_region(container, H5R_DATASET_REGION, memref);
- if (region_space >= 0) {
- if (h5tools_is_zero(memref, H5Tget_size(type))) {
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, info, ctx, curr_pos, 0);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "data render start:%ld", nelmts);
+ for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) {
+ void* memref = mem + i * size;
- /* Render the region element begin */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "NULL");
+ /* Render the data element begin*/
+ h5tools_str_reset(&buffer);
+ h5tools_str_sprint(&buffer, info, container, type, memref, ctx);
- dimension_break = h5tools_render_element(rawoutstream, info,
- ctx, &buffer, &curr_pos, ncols, i, elmt_counter);
- }
- else {
- if(H5Rget_name(region_id, H5R_DATASET_REGION, memref, (char*) ref_name, (size_t)1024)<0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_name failed");
+ if (i + 1 < nelmts || (flags & END_OF_DATA) == 0)
+ h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ","));
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, info, ctx, curr_pos+i, 0);
+ dimension_break = h5tools_render_element(stream, info, ctx, &buffer,
+ &curr_pos, ncols, i, elmt_counter);
+ /* Render the data element end*/
+ if(FALSE == dimension_break)
+ elmt_counter = 0;
+ } /* end for (i = 0; i < nelmts... */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "data render finish");
- /* Render the region element begin */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, info->dset_format, ref_name);
-
- dimension_break = h5tools_render_element(rawoutstream, info,
- ctx, &buffer, &curr_pos, ncols, i, elmt_counter);
-
- region_type = H5Sget_select_type(region_space);
- if(region_type == H5S_SEL_POINTS)
- /* Print point information */
- dimension_break = h5tools_dump_region_data_points(
- region_space, region_id, rawoutstream, info, ctx,
- &buffer, &curr_pos, ncols, i, elmt_counter);
- else if(region_type == H5S_SEL_HYPERSLABS)
- /* Print block information */
- dimension_break = h5tools_dump_region_data_blocks(
- region_space, region_id, rawoutstream, info, ctx,
- &buffer, &curr_pos, ncols, i, elmt_counter);
- else
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "invalid region type");
- /* Render the region element end */
+ h5tools_str_close(&buffer);
+ }/* else bin */
- } /* end else to if (h5tools_is_zero(... */
- if(H5Sclose(region_space) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
- } /* end if (region_space >= 0) */
- else
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_region failed");
- if(H5Dclose(region_id) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
+ return ret_value;
+}
- } /* if (region_id >= 0) */
- else {
- /* if (region_id < 0) - could mean that no reference was written do not throw failure */
- H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference failed");
- }
+/*-------------------------------------------------------------------------
+ * Audience: Public
+ * Chapter: H5Tools Library
+ * Purpose: Print some values from an attribute referenced by object reference.
+ *
+ * Description:
+ * This is a special case subfunction to dump aa attribute references.
+ *
+ * Return:
+ * The function returns False if the last dimension has been reached, otherwise True
+ *
+ * In/Out:
+ * h5tools_context_t *ctx
+ * hsize_t *curr_pos
+ *
+ * Parameters Description:
+ * h5tools_str_t *buffer is the string into which to render
+ * hsize_t curr_pos is the total data element position
+ * size_t ncols
+ * hsize_t region_elmt_counter is the region element loop counter
+ * hsize_t elmt_count is the data element loop counter
+ *-------------------------------------------------------------------------
+ */
+hbool_t
+h5tools_dump_region_attribute(hid_t region_id,
+ FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *ctx, /* in,out */
+ h5tools_str_t *buffer, /* string into which to render */
+ hsize_t *curr_pos, /* total data element position */
+ size_t ncols, hsize_t region_elmt_counter, /* element counter */
+ hsize_t elmt_counter)
+{
+ H5TOOLS_ERR_INIT(hbool_t, TRUE)
+ hbool_t dimension_break = TRUE;
+ hid_t atype = H5I_INVALID_HID;
+ hid_t type_id = H5I_INVALID_HID;
+ hid_t region_space = H5I_INVALID_HID;
+ h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */
- ctx->need_prefix = TRUE;
+ HDassert(info);
+ HDassert(ctx);
+ HDassert(buffer);
- if(FALSE == dimension_break)
- elmt_counter = 0;
- } /* end for (i = 0; i < nelmts... */
- } /* end if (region_output... */
- else {
- for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) {
- void* memref = mem + i * size;
- /* Render the data element begin*/
- h5tools_str_reset(&buffer);
- h5tools_str_sprint(&buffer, info, container, type, memref, ctx);
+ H5TOOLS_PUSH_STACK();
- if (i + 1 < nelmts || (flags & END_OF_DATA) == 0)
- h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ","));
+ outputformat = *info;
+ outputformat.idx_fmt = "";
+ outputformat.idx_n_fmt = "";
+ outputformat.idx_sep = "";
+ outputformat.line_pre = "";
- dimension_break = h5tools_render_element(stream, info, ctx, &buffer,
- &curr_pos, ncols, i, elmt_counter);
- /* Render the data element end*/
- if(FALSE == dimension_break)
- elmt_counter = 0;
- } /* end for (i = 0; i < nelmts... */
- }
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter file=%p", (void*)stream);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "rawdata file=%p", (void*)rawdatastream);
- h5tools_str_close(&buffer);
- }/* else bin */
+ /* Render the region { element begin */
+ h5tools_str_reset(buffer);
+
+ h5tools_str_append(buffer, " {");
+ dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ /* Render the region { element end */
+
+ if((region_space = H5Aget_space(region_id)) < 0)
+ H5TOOLS_GOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Aget_space failed");
+ if((atype = H5Aget_type(region_id)) < 0)
+ H5TOOLS_GOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Aget_type failed");
+ if((type_id = H5Tget_native_type(atype, H5T_DIR_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Tget_native_type failed");
+
+ ctx->indent_level++;
+ ctx->need_prefix = TRUE;
+
+ /* Render the datatype element begin */
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "%s %s ",
+ h5tools_dump_header_format->datatypebegin,
+ h5tools_dump_header_format->datatypeblockbegin);
+
+ ctx->need_prefix = TRUE;
+ ctx->indent_level++;
+ h5tools_print_datatype(stream, buffer, info, ctx, atype, TRUE);
+ ctx->indent_level--;
+
+ if (HDstrlen(h5tools_dump_header_format->datatypeblockend)) {
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeblockend);
+ if (HDstrlen(h5tools_dump_header_format->datatypeend))
+ h5tools_str_append(buffer, " ");
+ }
+ if (HDstrlen(h5tools_dump_header_format->datatypeend))
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeend);
+
+ dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ /* Render the datatype element end */
+
+ ctx->need_prefix = TRUE;
+
+ /* Render the dataspace element begin */
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin);
+
+ h5tools_print_dataspace(buffer, region_space);
+
+ if (HDstrlen(h5tools_dump_header_format->dataspaceblockend)) {
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
+ if (HDstrlen(h5tools_dump_header_format->dataspaceend))
+ h5tools_str_append(buffer, " ");
+ }
+ if (HDstrlen(h5tools_dump_header_format->dataspaceend))
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
+
+ dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ /* Render the dataspace element end */
+
+ if (region_output) {
+ ctx->need_prefix = TRUE;
+
+ h5tools_dump_data(stream, &outputformat, ctx, region_id, FALSE);
+ }
+ done:
+
+ if(H5Tclose(type_id) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+
+ if(H5Tclose(atype) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+
+ ctx->indent_level--;
+ ctx->need_prefix = TRUE;
+
+ /* Render the region } element begin */
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "}");
+ dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ /* Render the region } element end */
+
+ H5_LEAVE(dimension_break)
+
+CATCH
+
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
return ret_value;
}
@@ -427,9 +490,10 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
static int
h5tools_print_region_data_blocks(hid_t region_id,
FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
- h5tools_str_t *buffer/*string into which to render */, size_t ncols,
- unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata)
+ h5tools_str_t *buffer, /* string into which to render */
+ size_t ncols, unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata)
{
+ H5TOOLS_ERR_INIT(int, SUCCEED)
hbool_t dimension_break = TRUE;
hsize_t *dims1 = NULL;
hsize_t *start = NULL;
@@ -444,7 +508,6 @@ h5tools_print_region_data_blocks(hid_t region_id,
unsigned indx;
unsigned jndx;
size_t type_size;
- int ret_value = SUCCEED;
hid_t mem_space = -1;
hid_t sid1 = -1;
h5tools_context_t ctx;
@@ -457,13 +520,19 @@ h5tools_print_region_data_blocks(hid_t region_id,
HDmemset(&ctx, 0, sizeof(ctx));
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
+
+ if((type_size = H5Tget_size(type_id)) == 0)
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+
/* Get the dataspace of the dataset */
if((sid1 = H5Dget_space(region_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
/* Allocate space for the dimension array */
if((dims1 = (hsize_t *) HDmalloc((size_t)(sizeof(hsize_t) * ndims))) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
/* find the dimensions of each data space from the block coordinates */
numelem = 1;
@@ -474,21 +543,18 @@ h5tools_print_region_data_blocks(hid_t region_id,
/* Create dataspace for reading buffer */
if((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
-
- if((type_size = H5Tget_size(type_id)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
if((region_buf = HDmalloc(type_size * (size_t)numelem)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate region buffer");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate region buffer");
/* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */
/* 1 2 n 1 2 n */
if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start");
if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count");
curr_pos = 0;
ctx.indent_level = cur_ctx->indent_level;
@@ -503,56 +569,63 @@ h5tools_print_region_data_blocks(hid_t region_id,
count[indx] = dims1[indx];
}
- if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
-
- if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dread failed");
-
- ctx.indent_level++;
- if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
-
- /* assume entire data space to be printed */
- for (indx = 0; indx < (unsigned)ctx.ndims; indx++)
- ctx.p_min_idx[indx] = start[indx];
- init_acc_pos(&ctx, total_size);
-
- /* print the data */
- region_flags = START_OF_DATA;
- if (blkndx == nblocks - 1)
- region_flags |= END_OF_DATA;
-
- for (indx = 0; indx < (unsigned)ctx.ndims; indx++)
- ctx.p_max_idx[indx] = dims1[indx];
-
- curr_pos = 0;
- ctx.sm_pos = blkndx * 2 * ndims;
- ctx.size_last_dim = dims1[ndims-1];
-
- h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0);
-
- elmtno = 0;
- for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) {
- /* Render the region data element begin */
- h5tools_str_reset(buffer);
-
- h5tools_str_append(buffer, "%s", numindex ? OPTIONAL_LINE_BREAK "" : "");
- h5tools_str_sprint(buffer, info, region_id, type_id,
- ((char*)region_buf + numindex * type_size), &ctx);
-
- if (numindex + 1 < numelem || (region_flags & END_OF_DATA) == 0)
- h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ","));
-
- dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos,
- ncols, ptdata, numindex, elmtno);
- /* Render the region data element end */
-
- if(FALSE == dimension_break)
- elmtno = 0;
- } /* end for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) */
+ if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) >= 0) {
+ if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) {
+ ctx.indent_level++;
+ if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) {
+ /* assume entire data space to be printed */
+ for (indx = 0; indx < (unsigned)ctx.ndims; indx++)
+ ctx.p_min_idx[indx] = start[indx];
+ init_acc_pos(&ctx, total_size);
+
+ /* print the data */
+ region_flags = START_OF_DATA;
+ if (blkndx == nblocks - 1)
+ region_flags |= END_OF_DATA;
+
+ for (indx = 0; indx < (unsigned)ctx.ndims; indx++)
+ ctx.p_max_idx[indx] = dims1[indx];
+
+ curr_pos = 0;
+ ctx.sm_pos = blkndx * 2 * ndims;
+ ctx.size_last_dim = dims1[ndims-1];
+
+ h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0);
+
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "data render start:%ld", numelem);
+ elmtno = 0;
+ for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) {
+ /* Render the region data element begin */
+ h5tools_str_reset(buffer);
+
+ h5tools_str_append(buffer, "%s", numindex ? OPTIONAL_LINE_BREAK "" : "");
+ h5tools_str_sprint(buffer, info, region_id, type_id,
+ ((char*)region_buf + numindex * type_size), &ctx);
+
+ if (numindex + 1 < numelem || (region_flags & END_OF_DATA) == 0)
+ h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ","));
+
+ dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos,
+ ncols, ptdata, numindex, elmtno);
+ /* Render the region data element end */
+
+ if(FALSE == dimension_break)
+ elmtno = 0;
+ } /* end for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) */
+ }
+ else {
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ }
+ ctx.indent_level--;
+ }
+ else {
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dread failed");
+ }
+ }
+ else {
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ }
- ctx.indent_level--;
} /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */
done:
@@ -562,9 +635,12 @@ h5tools_print_region_data_blocks(hid_t region_id,
HDfree(dims1);
if(H5Sclose(mem_space) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
if(H5Sclose(sid1) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+CATCH
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
return ret_value;
}
@@ -595,13 +671,13 @@ h5tools_print_region_data_blocks(hid_t region_id,
hbool_t
h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/,
- h5tools_str_t *buffer/*string into which to render */,
- hsize_t *curr_pos/*total data element position*/,
- size_t ncols, hsize_t region_elmt_counter/*element counter*/,
+ h5tools_context_t *ctx, /* in,out */
+ h5tools_str_t *buffer, /* string into which to render */
+ hsize_t *curr_pos, /* total data element position */
+ size_t ncols, hsize_t region_elmt_counter, /* element counter */
hsize_t elmt_counter)
{
- HERR_INIT(hbool_t, TRUE)
+ H5TOOLS_ERR_INIT(hbool_t, TRUE)
hbool_t dimension_break = TRUE;
hssize_t snblocks;
hsize_t nblocks;
@@ -609,28 +685,39 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
hsize_t *ptdata = NULL;
int sndims;
unsigned ndims;
- hid_t dtype = -1;
- hid_t type_id = -1;
- hsize_t u;
+ hsize_t indx;
+ hid_t dtype = H5I_INVALID_HID;
+ hid_t type_id = H5I_INVALID_HID;
+ h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */
HDassert(info);
HDassert(ctx);
HDassert(buffer);
+ H5TOOLS_PUSH_STACK();
+
+ outputformat = *info;
+ outputformat.idx_fmt = "";
+ outputformat.idx_n_fmt = "";
+ outputformat.idx_sep = "";
+ outputformat.line_pre = "";
+
if((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
- H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed");
+ H5TOOLS_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed");
nblocks = (hsize_t)snblocks;
/* Print block information */
if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
- H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ H5TOOLS_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
ndims = (unsigned)sndims;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter ndims=%d", ndims);
+
/* Render the region { element begin */
h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "{");
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ h5tools_str_append(buffer, " {");
+ dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the region { element end */
ctx->indent_level++;
@@ -642,31 +729,29 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
- if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL) {
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
- HGOTO_DONE(dimension_break);
- }
+ if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL)
+ H5TOOLS_GOTO_ERROR(dimension_break, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
if(H5Sget_select_hyper_blocklist(region_space, (hsize_t)0, nblocks, ptdata) < 0)
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed");
+ H5TOOLS_GOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed");
- for(u = 0; u < nblocks; u++) {
- unsigned v;
+ for(indx = 0; indx < nblocks; indx++) {
+ unsigned loop_indx;
- h5tools_str_append(buffer, info->dset_blockformat_pre,
- u ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)u);
+ h5tools_str_append(buffer, outputformat.dset_blockformat_pre,
+ indx ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)indx);
/* Start coordinates and opposite corner */
- for (v = 0; v < ndims; v++)
- h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, v ? "," : "(",
- ptdata[u * 2 * ndims + v]);
+ for (loop_indx = 0; loop_indx < ndims; loop_indx++)
+ h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, loop_indx ? "," : "(",
+ ptdata[indx * 2 * ndims + loop_indx]);
- for (v = 0; v < ndims; v++)
- h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, v ? "," : ")-(",
- ptdata[u * 2 * ndims + v + ndims]);
+ for (loop_indx = 0; loop_indx < ndims; loop_indx++)
+ h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, loop_indx ? "," : ")-(",
+ ptdata[indx * 2 * ndims + loop_indx + ndims]);
h5tools_str_append(buffer, ")");
- } /* end for (u = 0; u < nblocks; u++) */
+ } /* end for (indx = 0; indx < nblocks; indx++) */
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the region datatype info and indices element end */
@@ -674,9 +759,9 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
ctx->need_prefix = TRUE;
if((dtype = H5Dget_type(region_id)) < 0)
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Dget_type failed");
+ H5TOOLS_GOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Dget_type failed");
if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Tget_native_type failed");
+ H5TOOLS_GOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Tget_native_type failed");
/* Render the datatype element begin */
h5tools_str_reset(buffer);
@@ -718,40 +803,47 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the dataspace element end */
- ctx->need_prefix = TRUE;
-
- /* Render the databegin element begin */
- h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s %s ",
- h5tools_dump_header_format->databegin,
- h5tools_dump_header_format->datablockbegin);
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
- /* Render the databegin element end */
+ if (region_output) {
+ ctx->need_prefix = TRUE;
- ctx->need_prefix = TRUE;
+ /* Render the databegin element begin */
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "%s %s",
+ h5tools_dump_header_format->databegin,
+ h5tools_dump_header_format->datablockbegin);
+ dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ /* Render the databegin element end */
- h5tools_print_region_data_blocks(region_id, rawdatastream, info, ctx,
- buffer, ncols, ndims, type_id, nblocks, ptdata);
+ ctx->need_prefix = TRUE;
+ h5tools_print_region_data_blocks(region_id, rawdatastream, info, ctx, buffer, ncols, ndims, type_id, nblocks, ptdata);
+ }
done:
HDfree(ptdata);
- if(H5Tclose(type_id) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ if(type_id > 0 && H5Tclose(type_id) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
- if(H5Tclose(dtype) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ if(dtype > 0 && H5Tclose(dtype) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
- ctx->need_prefix = TRUE;
+ if (region_output) {
+ ctx->need_prefix = TRUE;
- /* Render the dataend element begin */
- h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s %s ",
- h5tools_dump_header_format->dataend,
- h5tools_dump_header_format->datablockend);
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos,
- ncols, region_elmt_counter, elmt_counter);
- /* Render the dataend element end */
+ /* Render the dataend element begin */
+ h5tools_str_reset(buffer);
+ if(HDstrlen(h5tools_dump_header_format->datablockend)) {
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datablockend);
+ if(HDstrlen(h5tools_dump_header_format->dataend))
+ h5tools_str_append(buffer, " ");
+ }
+
+ if(HDstrlen(h5tools_dump_header_format->dataend))
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataend);
+ dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos,
+ ncols, region_elmt_counter, elmt_counter);
+ /* Render the dataend element end */
+ }
ctx->indent_level--;
ctx->need_prefix = TRUE;
@@ -759,13 +851,16 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
/* Render the region } element begin */
h5tools_str_reset(buffer);
h5tools_str_append(buffer, "}");
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos,
- ncols, region_elmt_counter, elmt_counter);
+ dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the region } element end */
H5_LEAVE(dimension_break)
- CATCH
+CATCH
+
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
+
return ret_value;
}
@@ -793,6 +888,7 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
h5tools_str_t *buffer, size_t ncols,
unsigned ndims, hid_t type_id, hsize_t npoints, hsize_t *ptdata)
{
+ H5TOOLS_ERR_INIT(int, SUCCEED)
hbool_t dimension_break = TRUE;
hsize_t *dims1 = NULL;
hsize_t elmtno; /* elemnt index */
@@ -801,9 +897,8 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
hsize_t jndx;
unsigned indx;
size_t type_size;
- int ret_value = SUCCEED;
unsigned int region_flags; /* buffer extent flags */
- hid_t mem_space = -1;
+ hid_t mem_space = H5I_INVALID_HID;
void *region_buf = NULL;
h5tools_context_t ctx;
@@ -813,22 +908,25 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
HDassert(ptdata);
HDassert(ndims > 0);
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
+
HDmemset(&ctx, 0, sizeof(ctx));
/* Allocate space for the dimension array */
if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
dims1[0] = npoints;
/* Create dataspace for reading buffer */
if((mem_space = H5Screate_simple(1, dims1, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
if((type_size = H5Tget_size(type_id)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
if((region_buf = HDmalloc(type_size * (size_t)npoints)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for region");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for region");
curr_pos = 0;
ctx.indent_level = cur_ctx->indent_level;
@@ -837,64 +935,70 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
ctx.ndims = ndims;
if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "data render start:%ld", npoints);
elmtno = 0;
for (jndx = 0; jndx < npoints; jndx++, elmtno++) {
ctx.need_prefix = TRUE;
ctx.cur_elmt = 0; /* points are always 0 */
-
ctx.indent_level++;
- if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
- /* assume entire data space to be printed */
- for (indx = 0; indx < ctx.ndims; indx++)
- ctx.p_min_idx[indx] = 0;
- init_acc_pos(&ctx, total_size);
+ if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) {
+ /* assume entire data space to be printed */
+ for (indx = 0; indx < ctx.ndims; indx++)
+ ctx.p_min_idx[indx] = 0;
+ init_acc_pos(&ctx, total_size);
- /* print the data */
- region_flags = START_OF_DATA;
- if (jndx == npoints - 1)
- region_flags |= END_OF_DATA;
+ /* print the data */
+ region_flags = START_OF_DATA;
+ if (jndx == npoints - 1)
+ region_flags |= END_OF_DATA;
- for (indx = 0; indx < ctx.ndims; indx++)
- ctx.p_max_idx[indx] = cur_ctx->p_max_idx[indx];
+ for (indx = 0; indx < ctx.ndims; indx++)
+ ctx.p_max_idx[indx] = cur_ctx->p_max_idx[indx];
- ctx.sm_pos = jndx * ndims;
- if (ctx.ndims > 0)
- ctx.size_last_dim = ctx.p_max_idx[ctx.ndims - 1];
- else
- ctx.size_last_dim = 0;
-
- curr_pos = 0; /* points requires constant 0 */
- h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0);
+ ctx.sm_pos = jndx * ndims;
+ if (ctx.ndims > 0)
+ ctx.size_last_dim = ctx.p_max_idx[ctx.ndims - 1];
+ else
+ ctx.size_last_dim = 0;
- /* Render the point element begin */
- h5tools_str_reset(buffer);
+ curr_pos = 0; /* points requires constant 0 */
+ h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0);
- h5tools_str_append(buffer, "%s", jndx ? OPTIONAL_LINE_BREAK "" : "");
- h5tools_str_sprint(buffer, info, region_id, type_id,
- ((char*)region_buf + jndx * type_size), &ctx);
+ /* Render the point element begin */
+ h5tools_str_reset(buffer);
- if (jndx + 1 < npoints || (region_flags & END_OF_DATA) == 0)
- h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ","));
+ h5tools_str_append(buffer, "%s", jndx ? OPTIONAL_LINE_BREAK "" : "");
+ h5tools_str_sprint(buffer, info, region_id, type_id,
+ ((char*)region_buf + jndx * type_size), &ctx);
- dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos,
- ncols, ptdata, (hsize_t)0, elmtno);
- /* Render the point element end */
- if(FALSE == dimension_break)
- elmtno = 0;
+ if (jndx + 1 < npoints || (region_flags & END_OF_DATA) == 0)
+ h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ","));
+ dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos,
+ ncols, ptdata, (hsize_t)0, elmtno);
+ /* Render the point element end */
+ if(FALSE == dimension_break)
+ elmtno = 0;
+ }
+ else {
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ }
ctx.indent_level--;
} /* end for (jndx = 0; jndx < npoints; jndx++, elmtno++) */
- done:
+done:
HDfree(region_buf);
+CATCH
HDfree(dims1);
if(H5Sclose(mem_space) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
return ret_value;
}
@@ -926,8 +1030,9 @@ hbool_t
h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter,
- hsize_t elmt_counter) {
- HERR_INIT(hbool_t, TRUE)
+ hsize_t elmt_counter)
+{
+ H5TOOLS_ERR_INIT(hbool_t, TRUE)
hbool_t dimension_break = TRUE;
hssize_t snpoints;
hsize_t npoints;
@@ -936,48 +1041,59 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
int sndims;
unsigned ndims;
hsize_t indx;
- hid_t dtype = -1;
- hid_t type_id = -1;
+ hid_t dtype = H5I_INVALID_HID;
+ hid_t type_id = H5I_INVALID_HID;
+ h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */
HDassert(info);
HDassert(ctx);
HDassert(buffer);
+ H5TOOLS_PUSH_STACK();
+
+ outputformat = *info;
+ outputformat.idx_fmt = "";
+ outputformat.idx_n_fmt = "";
+ outputformat.idx_sep = "";
+ outputformat.line_pre = "";
+
if((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0)
- H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed");
+ H5TOOLS_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed");
npoints = (hsize_t)snpoints;
/* Allocate space for the dimension array */
if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
- H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ H5TOOLS_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
ndims = (unsigned)sndims;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter ndims=%d", ndims);
+
/* Render the region { element begin */
h5tools_str_reset(buffer);
h5tools_str_append(buffer, "{");
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the region { element end */
- /* Render the region datatype info and indices element begin */
- h5tools_str_reset(buffer);
-
ctx->indent_level++;
ctx->need_prefix = TRUE;
+
+ /* Render the region datatype info and indices element begin */
+ h5tools_str_reset(buffer);
h5tools_str_append(buffer, "REGION_TYPE POINT ");
alloc_size = npoints * ndims * sizeof(ptdata[0]);
HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
if(NULL == (ptdata = (hsize_t *)HDmalloc((size_t) alloc_size)))
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
+ H5TOOLS_GOTO_ERROR(dimension_break, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
if(H5Sget_select_elem_pointlist(region_space, (hsize_t) 0, npoints, ptdata) < 0)
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Sget_select_elem_pointlist failed");
+ H5TOOLS_GOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Sget_select_elem_pointlist failed");
for (indx = 0; indx < npoints; indx++) {
unsigned loop_indx;
- h5tools_str_append(buffer, info->dset_ptformat_pre,
+ h5tools_str_append(buffer, outputformat.dset_ptformat_pre,
indx ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long) indx);
for (loop_indx = 0; loop_indx < ndims; loop_indx++)
@@ -993,10 +1109,9 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
ctx->need_prefix = TRUE;
if((dtype = H5Dget_type(region_id)) < 0)
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Dget_type failed");
-
+ H5TOOLS_GOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Dget_type failed");
if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Tget_native_type failed");
+ H5TOOLS_GOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Tget_native_type failed");
/* Render the datatype element begin */
h5tools_str_reset(buffer);
@@ -1023,8 +1138,6 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
/* Render the dataspace element begin */
h5tools_str_reset(buffer);
-
- ctx->need_prefix = TRUE;
h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin);
h5tools_print_dataspace(buffer, region_space);
@@ -1040,41 +1153,49 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the dataspace element end */
- ctx->need_prefix = TRUE;
+ if (region_output) {
+ ctx->need_prefix = TRUE;
- /* Render the databegin element begin */
- h5tools_str_reset(buffer);
+ /* Render the databegin element begin */
+ h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s %s ",
- h5tools_dump_header_format->databegin,
- h5tools_dump_header_format->datablockbegin);
+ h5tools_str_append(buffer, "%s %s",
+ h5tools_dump_header_format->databegin,
+ h5tools_dump_header_format->datablockbegin);
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
- ctx->need_prefix = TRUE;
+ ctx->need_prefix = TRUE;
- h5tools_print_region_data_points(region_space, region_id,
- rawdatastream, info, ctx, buffer, ncols, ndims, type_id, npoints, ptdata);
+ h5tools_print_region_data_points(region_space, region_id, rawdatastream, info, ctx, buffer, ncols, ndims, type_id, npoints, ptdata);
+ }
done:
HDfree(ptdata);
if(type_id > 0 && H5Tclose(type_id) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
if(dtype > 0 && H5Tclose(dtype) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
- ctx->need_prefix = TRUE;
+ if (region_output) {
+ ctx->need_prefix = TRUE;
- /* Render the dataend element begin */
- h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s %s ",
- h5tools_dump_header_format->dataend,
- h5tools_dump_header_format->datablockend);
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos,
- ncols, region_elmt_counter, elmt_counter);
- /* Render the dataend element end*/
+ /* Render the dataend element begin */
+ h5tools_str_reset(buffer);
+ if(HDstrlen(h5tools_dump_header_format->datablockend)) {
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datablockend);
+ if(HDstrlen(h5tools_dump_header_format->dataend))
+ h5tools_str_append(buffer, " ");
+ }
+
+ if(HDstrlen(h5tools_dump_header_format->dataend))
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataend);
+ dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos,
+ ncols, region_elmt_counter, elmt_counter);
+ /* Render the dataend element end*/
+ }
ctx->indent_level--;
ctx->need_prefix = TRUE;
@@ -1088,6 +1209,10 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
H5_LEAVE(dimension_break)
CATCH
+
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
+
return ret_value;
}
@@ -1125,16 +1250,16 @@ CATCH
*/
static herr_t
h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
- hid_t dset, hid_t p_type, struct subset_t *sset,
+ hid_t dset, hid_t p_type,
hid_t f_space, hsize_t hyperslab_count,
- hsize_t *temp_start,/* start inside offset count loop */
- hsize_t *temp_count,/* count inside offset count loop */
- hsize_t *temp_block,/* block size used in loop */
- hsize_t *temp_stride,/* stride size used in loop */
- hsize_t *total_size,/* total size of dataset */
- unsigned int row_dim/* index of row_counter dimension */)
+ hsize_t *temp_start, /* start inside offset count loop */
+ hsize_t *temp_count, /* count inside offset count loop */
+ hsize_t *temp_block, /* block size used in loop */
+ hsize_t *temp_stride, /* stride size used in loop */
+ hsize_t *total_size, /* total size of dataset */
+ unsigned int row_dim) /* index of row_counter dimension */
{
- HERR_INIT(herr_t, SUCCEED)
+ H5TOOLS_ERR_INIT(herr_t, SUCCEED)
size_t i; /* counters */
size_t j; /* counters */
hsize_t zero[1] = {0}; /* vector of zeros */
@@ -1148,7 +1273,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
hssize_t ssm_nelmts; /* elements per stripmine*/
hsize_t sm_nelmts; /* elements per stripmine*/
unsigned char *sm_buf = NULL; /* buffer for raw data */
- hid_t sm_space = -1; /* stripmine data space */
+ hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */
hsize_t size_row_block; /* size for blocks along rows */
hsize_t row_counter = 0;
@@ -1156,12 +1281,12 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
unsigned int vl_data = 0; /* contains VL datatypes */
if ((size_t) ctx->ndims > NELMTS(sm_size))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "ndims and sm_size comparision failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "ndims and sm_size comparision failed");
if (ctx->ndims > 0)
init_acc_pos(ctx, total_size);
- size_row_block = sset->block.data[row_dim];
+ size_row_block = ctx->sset->block.data[row_dim];
/* Check if we have VL data in the dataset's datatype */
if (h5tools_detect_vlen(p_type) == TRUE)
@@ -1173,9 +1298,9 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
cases where block > 1 only and stride > block */
if (size_row_block > 1
&& row_counter == size_row_block
- && sset->stride.data[row_dim] > sset->block.data[row_dim]) {
+ && ctx->sset->stride.data[row_dim] > ctx->sset->block.data[row_dim]) {
- hsize_t increase_rows = sset->stride.data[row_dim] - sset->block.data[row_dim];
+ hsize_t increase_rows = ctx->sset->stride.data[row_dim] - ctx->sset->block.data[row_dim];
temp_start[row_dim] += increase_rows;
row_counter = 0;
}
@@ -1184,10 +1309,10 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
/* calculate the potential number of elements we're going to print */
if(H5Sselect_hyperslab(f_space, H5S_SELECT_SET, temp_start, temp_stride, temp_count, temp_block) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
if((ssm_nelmts = H5Sget_select_npoints(f_space)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_npoints failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_npoints failed");
sm_nelmts = (hsize_t)ssm_nelmts;
if (sm_nelmts > 0) {
@@ -1196,7 +1321,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
* a hyperslab whose size is manageable.
*/
if((sm_nbytes = p_type_nbytes = H5Tget_size(p_type)) == 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
if (ctx->ndims > 0)
for (i = ctx->ndims; i > 0; --i) {
@@ -1210,17 +1335,17 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
HDassert(sm_nbytes == (hsize_t) ((size_t) sm_nbytes)); /*check for overflow*/
if(NULL == (sm_buf = (unsigned char *)HDmalloc((size_t) sm_nelmts * p_type_nbytes)))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for strip-mine");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for strip-mine");
if((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &sm_nelmts, NULL) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
/* read the data */
if(H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Dread failed");
/* print the data */
flags = START_OF_DATA;
@@ -1234,7 +1359,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
/* print array indices. get the lower bound of the hyperslab and calulate
the element position at the start of hyperslab */
if(H5Sget_select_bounds(f_space, low, high) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_bounds failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_bounds failed");
elmtno = 0;
for (i = 0; i < (size_t) ctx->ndims - 1; i++) {
@@ -1252,20 +1377,20 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
ctx->need_prefix = TRUE;
if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, sm_nelmts, p_type, sm_buf) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_dump_simple_data failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_dump_simple_data failed");
/* Reclaim any VL memory, if necessary */
if (vl_data)
H5Treclaim(p_type, sm_space, H5P_DEFAULT, sm_buf);
if(H5Sclose(sm_space) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
if(sm_buf)
HDfree(sm_buf);
sm_buf = NULL;
}
else
- H5E_THROW(SUCCEED, H5E_tools_min_id_g, "nothing to print");
+ H5TOOLS_THROW(SUCCEED, H5E_tools_min_id_g, "nothing to print");
ctx->continuation++;
@@ -1312,8 +1437,7 @@ CATCH
*/
static herr_t
h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
- hid_t dset, hid_t p_type, struct subset_t *sset,
- hid_t f_space, hsize_t *total_size)
+ hid_t dset, hid_t p_type, hid_t f_space, hsize_t *total_size)
{
size_t i; /* counters */
hsize_t n; /* counters */
@@ -1339,21 +1463,21 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
if (ctx->ndims > 2)
for (i = 0; i < (size_t) ctx->ndims - 2; i++) {
/* block size is handled by containing h5tools_print_simple_subset call */
- outer_count = outer_count * sset->count.data[i];
+ outer_count = outer_count * ctx->sset->count.data[i];
}
/* initialize temporary start, count and maximum start */
for (i = 0; i < ctx->ndims; i++) {
- temp_start[i] = sset->start.data[i];
- temp_count[i] = sset->count.data[i];
- temp_block[i] = sset->block.data[i];
- temp_stride[i] = sset->stride.data[i];
+ temp_start[i] = ctx->sset->start.data[i];
+ temp_count[i] = ctx->sset->count.data[i];
+ temp_block[i] = ctx->sset->block.data[i];
+ temp_stride[i] = ctx->sset->stride.data[i];
max_start[i] = 0;
}
if (ctx->ndims > 2) {
for (i = 0; i < (size_t) ctx->ndims - 2; i++) {
- max_start[i] = temp_start[i] + sset->count.data[i] * sset->stride.data[i];
+ max_start[i] = temp_start[i] + ctx->sset->count.data[i] * ctx->sset->stride.data[i];
temp_count[i] = 1;
}
}
@@ -1364,14 +1488,14 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
if (ctx->ndims > 1) {
/* count is the number of iterations to display all the rows,
the block size count times */
- count = sset->count.data[row_dim] * sset->block.data[row_dim];
+ count = ctx->sset->count.data[row_dim] * ctx->sset->block.data[row_dim];
/* always 1 row_counter at a time, that is a block of size 1, 1 time */
temp_count[row_dim] = 1;
temp_block[row_dim] = 1;
/* advance 1 row_counter at a time */
- if (sset->block.data[row_dim] > 1)
+ if (ctx->sset->block.data[row_dim] > 1)
temp_stride[row_dim] = 1;
}
/* for the 1D case */
@@ -1379,7 +1503,7 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
count = 1;
}
- h5tools_print_simple_subset(stream, info, ctx, dset, p_type, sset,
+ h5tools_print_simple_subset(stream, info, ctx, dset, p_type,
f_space, count, temp_start, temp_count,
temp_block, temp_stride, total_size, row_dim);
@@ -1389,14 +1513,14 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
/* set start to original from current_outer_dim up */
for (i = (size_t)(current_outer_dim + 1); i < ctx->ndims; i++)
- temp_start[i] = sset->start.data[i];
+ temp_start[i] = ctx->sset->start.data[i];
/* increment start dimension */
do {
reset_dim = 0;
- temp_start[current_outer_dim] += sset->stride.data[current_outer_dim];
+ temp_start[current_outer_dim] += ctx->sset->stride.data[current_outer_dim];
if (temp_start[current_outer_dim] >= max_start[current_outer_dim]) {
- temp_start[current_outer_dim] = sset->start.data[current_outer_dim];
+ temp_start[current_outer_dim] = ctx->sset->start.data[current_outer_dim];
current_outer_dim--;
reset_dim = 1;
@@ -1452,20 +1576,20 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
*-------------------------------------------------------------------------
*/
static herr_t
-h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset,
- hid_t p_type, struct subset_t *sset)
+h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ hid_t dset, hid_t p_type)
{
- HERR_INIT(herr_t, SUCCEED)
+ H5TOOLS_ERR_INIT(herr_t, SUCCEED)
int sndims;
- hid_t f_space = -1; /* file data space */
+ hid_t f_space = H5I_INVALID_HID; /* file data space */
size_t i; /* counters */
hsize_t total_size[H5S_MAX_RANK];/* total size of dataset*/
if((f_space = H5Dget_space(dset)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
if((sndims = H5Sget_simple_extent_ndims(f_space)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
ctx->ndims = (unsigned)sndims;
/* assume entire data space to be printed */
@@ -1474,17 +1598,17 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_co
ctx->p_min_idx[i] = 0;
if(H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
ctx->size_last_dim = total_size[ctx->ndims - 1];
/* Set the compound datatype field list for display */
ctx->cmpd_listv = info->cmpd_listv;
- h5tools_display_simple_subset(stream, info, ctx, dset, p_type, sset, f_space, total_size);
+ h5tools_display_simple_subset(stream, info, ctx, dset, p_type, f_space, total_size);
CATCH
if(f_space >= 0 && H5Sclose(f_space) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
return ret_value;
}
@@ -1508,8 +1632,8 @@ static int
h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
hid_t dset, hid_t p_type)
{
- HERR_INIT(herr_t, SUCCEED)
- hid_t f_space = -1; /* file data space */
+ H5TOOLS_ERR_INIT(herr_t, SUCCEED)
+ hid_t f_space = H5I_INVALID_HID; /* file data space */
hsize_t elmtno; /* counter */
size_t i; /* counter */
int sndims; /* rank of dataspace */
@@ -1527,7 +1651,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
hsize_t sm_nbytes; /* bytes per stripmine */
hsize_t sm_nelmts; /* elements per stripmine*/
unsigned char *sm_buf = NULL; /* buffer for raw data */
- hid_t sm_space = -1; /* stripmine data space */
+ hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */
/* Hyperslab info */
hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */
@@ -1537,18 +1661,19 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
/* VL data special information */
unsigned int vl_data = 0; /* contains VL datatypes */
- f_space = H5Dget_space(dset);
-
- if (f_space == FAIL)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
+ if (FAIL == (f_space = H5Dget_space(dset)))
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
sndims = H5Sget_simple_extent_ndims(f_space);
if(sndims < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_simple_extent_ndims failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_simple_extent_ndims failed");
ctx->ndims = (unsigned)sndims;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "sndims:%d", sndims);
if ((size_t)ctx->ndims > NELMTS(sm_size))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "ctx->ndims > NELMTS(sm_size) failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "ctx->ndims > NELMTS(sm_size) failed");
/* Assume entire data space to be printed */
if (ctx->ndims > 0)
@@ -1581,96 +1706,103 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
* a hyperslab whose size is manageable.
*/
sm_nbytes = p_type_nbytes = H5Tget_size(p_type);
-
if (ctx->ndims > 0) {
for (i = ctx->ndims; i > 0; --i) {
hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes;
- if ( size == 0) /* datum size > H5TOOLS_BUFSIZE */
+ if (size == 0) /* datum size > H5TOOLS_BUFSIZE */
size = 1;
sm_size[i - 1] = MIN(total_size[i - 1], size);
sm_nbytes *= sm_size[i - 1];
- HDassert(sm_nbytes > 0);
}
}
-
if(!sm_nbytes)
goto done;
HDassert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/
- sm_buf = (unsigned char *)HDmalloc((size_t)sm_nbytes);
-
- sm_nelmts = sm_nbytes / p_type_nbytes;
- sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
-
- if (ctx->ndims > 0)
- init_acc_pos(ctx, total_size);
+ if (NULL != (sm_buf = (unsigned char *)HDmalloc((size_t)sm_nbytes))) {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "stripmine size:%ld", sm_nbytes);
+
+ sm_nelmts = sm_nbytes / p_type_nbytes;
+ sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "sm_nelmts size:%ld", sm_nelmts);
+
+ if (ctx->ndims > 0)
+ init_acc_pos(ctx, total_size);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ctx->ndims:%d", ctx->ndims);
+
+ /* The stripmine loop */
+ HDmemset(hs_offset, 0, sizeof hs_offset);
+ HDmemset(zero, 0, sizeof zero);
+
+ for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "stripmine read loop:%d", i);
+ /* Calculate the hyperslab size */
+ if (ctx->ndims > 0) {
+ for (i = 0, hs_nelmts = 1; i < ctx->ndims; i++) {
+ hs_size[i] = MIN(total_size[i] - hs_offset[i], sm_size[i]);
+ ctx->p_max_idx[i] = ctx->p_min_idx[i] + hs_size[i];
+ hs_nelmts *= hs_size[i];
+ }
- /* The stripmine loop */
- HDmemset(hs_offset, 0, sizeof hs_offset);
- HDmemset(zero, 0, sizeof zero);
-
- for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) {
- /* Calculate the hyperslab size */
- if (ctx->ndims > 0) {
- for (i = 0, hs_nelmts = 1; i < ctx->ndims; i++) {
- hs_size[i] = MIN(total_size[i] - hs_offset[i], sm_size[i]);
- ctx->p_max_idx[i] = ctx->p_min_idx[i] + hs_size[i];
- hs_nelmts *= hs_size[i];
+ if (H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab hs_offset failed");
+ if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab zero failed");
+ }
+ else {
+ if (H5Sselect_all(f_space) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_all f_space failed");
+ if (H5Sselect_all(sm_space) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_all sm_space failed");
+ hs_nelmts = 1;
}
- H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL);
- H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL);
- }
- else {
- H5Sselect_all(f_space);
- H5Sselect_all(sm_space);
- hs_nelmts = 1;
- }
-
- /* Read the data */
- if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) {
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dread failed");
- }
-
- /* Print the data */
- flags = (elmtno == 0) ? START_OF_DATA : 0;
- flags |= ((elmtno + hs_nelmts) >= p_nelmts) ? END_OF_DATA : 0;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "Read the data");
+ /* Read the data */
+ if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) >= 0) {
+ /* Print the data */
+ flags = (elmtno == 0) ? START_OF_DATA : 0;
+ flags |= ((elmtno + hs_nelmts) >= p_nelmts) ? END_OF_DATA : 0;
- /* initialize the current stripmine position; this is necessary to print the array
- indices */
- ctx->sm_pos = elmtno;
+ /* initialize the current stripmine position; this is necessary to print the array
+ indices */
+ ctx->sm_pos = elmtno;
- if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, hs_nelmts, p_type, sm_buf) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_dump_simple_data failed");
+ if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, hs_nelmts, p_type, sm_buf) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_dump_simple_data failed");
- /* Reclaim any VL memory, if necessary */
- if (vl_data)
- H5Treclaim(p_type, sm_space, H5P_DEFAULT, sm_buf);
+ /* Reclaim any VL memory, if necessary */
+ if (vl_data)
+ H5Treclaim(p_type, sm_space, H5P_DEFAULT, sm_buf);
- /* Calculate the next hyperslab offset */
- for (i = ctx->ndims, carry = 1; i > 0 && carry; --i) {
- ctx->p_min_idx[i - 1] = ctx->p_max_idx[i - 1];
- hs_offset[i - 1] += hs_size[i - 1];
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "Calculate the next hyperslab offset");
+ /* Calculate the next hyperslab offset */
+ for (i = ctx->ndims, carry = 1; i > 0 && carry; --i) {
+ ctx->p_min_idx[i - 1] = ctx->p_max_idx[i - 1];
+ hs_offset[i - 1] += hs_size[i - 1];
- if (hs_offset[i - 1] == total_size[i - 1])
- hs_offset[i - 1] = 0;
+ if (hs_offset[i - 1] == total_size[i - 1])
+ hs_offset[i - 1] = 0;
+ else
+ carry = 0;
+ }
+ }
else
- carry = 0;
- }
-
- ctx->continuation++;
- }
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dread failed");
-CATCH
- if(sm_buf)
+ ctx->continuation++;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "stripmine read loop:%d complete", i);
+ }
HDfree(sm_buf);
-
+ } /* if (NULL != (sm_buf...)) */
done:
if(sm_space >= 0 && H5Sclose(sm_space) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
if(f_space >= 0 && H5Sclose(f_space) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
-
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+CATCH
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
return ret_value;
}
@@ -1682,51 +1814,90 @@ done:
*
* Return: Success: SUCCEED
* Failure: FAIL
- *
*-------------------------------------------------------------------------
*/
static int
-h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id,
- hid_t type, hid_t space, void *mem)
+h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ hid_t attr_id, hid_t p_type)
{
- HERR_INIT(herr_t, SUCCEED)
- int sndims; /* rank of dataspace */
- unsigned i; /*counters */
- hsize_t nelmts; /*total selected elmts */
+ H5TOOLS_ERR_INIT(herr_t, SUCCEED)
+ hid_t f_space = H5I_INVALID_HID; /* file data space */
+ hsize_t alloc_size;
+ int sndims; /* rank of dataspace */
+ unsigned i; /* counters */
+ hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
+ hsize_t p_nelmts; /* total selected elmts */
+ unsigned char *buf = NULL; /* buffer for raw data */
+
+ /* VL data special information */
+ unsigned int vl_data = 0; /* contains VL datatypes */
+
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
+ if (FAIL == (f_space = H5Aget_space(attr_id)))
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
- sndims = H5Sget_simple_extent_ndims(space);
+ sndims = H5Sget_simple_extent_ndims(f_space);
if(sndims < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_simple_extent_ndims failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_simple_extent_ndims failed");
ctx->ndims = (unsigned)sndims;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "sndims:%d", sndims);
if ((size_t) ctx->ndims > NELMTS(ctx->p_min_idx))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "ctx->ndims > NELMTS(ctx->p_min_idx) failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "ctx->ndims > NELMTS(ctx->p_min_idx) failed");
/* Assume entire data space to be printed */
- for (i = 0; i < ctx->ndims; i++)
- ctx->p_min_idx[i] = 0;
+ if (ctx->ndims > 0)
+ for (i = 0; i < (size_t)ctx->ndims; i++)
+ ctx->p_min_idx[i] = 0;
- H5Sget_simple_extent_dims(space, ctx->p_max_idx, NULL);
+ H5Sget_simple_extent_dims(f_space, total_size, NULL);
- for (i = 0, nelmts = 1; ctx->ndims != 0 && i < ctx->ndims; i++)
- nelmts *= ctx->p_max_idx[i] - ctx->p_min_idx[i];
+ /* calculate the number of elements we're going to print */
+ p_nelmts = 1;
- if (nelmts == 0)
- H5_LEAVE(SUCCEED); /* nothing to print */
if (ctx->ndims > 0) {
- HDassert(ctx->p_max_idx[ctx->ndims - 1] == (hsize_t) ((int) ctx->p_max_idx[ctx->ndims - 1]));
- ctx->size_last_dim = ctx->p_max_idx[ctx->ndims - 1];
+ for (i = 0; i < ctx->ndims; i++)
+ p_nelmts *= total_size[i];
+ ctx->size_last_dim = (total_size[ctx->ndims - 1]);
} /* end if */
else
ctx->size_last_dim = 0;
- if (ctx->ndims > 0)
- init_acc_pos(ctx, ctx->p_max_idx);
+ if (p_nelmts == 0)
+ H5_LEAVE(SUCCEED); /* nothing to print */
+
+ /* Check if we have VL data in the dataset's datatype */
+ if (h5tools_detect_vlen(p_type) == TRUE)
+ vl_data = TRUE;
- if(h5tools_dump_simple_data(stream, info, obj_id, ctx, START_OF_DATA | END_OF_DATA, nelmts, type, mem) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_dump_simple_data failed");
+ alloc_size = p_nelmts * H5Tget_size(p_type);
+ HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
+ if (NULL != (buf = (unsigned char *)HDmalloc((size_t)alloc_size))) {
+ if (ctx->ndims > 0)
+ init_acc_pos(ctx, total_size);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ctx->ndims:%d", ctx->ndims);
+
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "Read the data");
+ /* Read the data */
+ if (H5Aread(attr_id, p_type, buf) >= 0) {
+ if(h5tools_dump_simple_data(stream, info, attr_id, ctx, START_OF_DATA | END_OF_DATA, p_nelmts, p_type, buf) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_dump_simple_data failed");
+ /* Reclaim any VL memory, if necessary */
+ if (vl_data)
+ H5Treclaim(p_type, f_space, H5P_DEFAULT, buf);
+ }
+ else
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aread failed");
+ HDfree(buf);
+ } /* if (NULL != (buf...)) */
+done:
+ if(f_space >= 0 && H5Sclose(f_space) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
CATCH
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
return ret_value;
}
@@ -1746,27 +1917,16 @@ CATCH
*
* Return: Success: SUCCEED
* Failure: FAIL
- *
- * Modifications:
- * Robb Matzke, 1999-06-07
- * If info->raw is set then the memory datatype will be the same
- * as the file datatype.
- *
- * Bill Wendling, 2001-02-27
- * Renamed to ``h5tools_dump_dset'' and added the subsetting
- * parameter.
- *
*-------------------------------------------------------------------------
*/
int
-h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
- hid_t dset, struct subset_t *sset)
+h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset)
{
- hid_t f_space = -1;
- hid_t p_type = -1;
- hid_t f_type = -1;
+ H5TOOLS_ERR_INIT(int, SUCCEED)
+ hid_t f_space = H5I_INVALID_HID;
+ hid_t p_type = H5I_INVALID_HID;
+ hid_t f_type = H5I_INVALID_HID;
H5S_class_t space_type;
- int status = FAIL;
h5tool_format_t info_dflt;
/* Use default values */
if (!stream)
@@ -1802,15 +1962,15 @@ h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
/* Print the data */
if (space_type == H5S_SIMPLE || space_type == H5S_SCALAR) {
- if(!sset)
- status = h5tools_dump_simple_dset(rawdatastream, info, ctx, dset, p_type);
+ if(!ctx->sset)
+ ret_value = h5tools_dump_simple_dset(rawdatastream, info, ctx, dset, p_type);
else
- status = h5tools_dump_simple_subset(rawdatastream, info, ctx, dset, p_type, sset);
+ ret_value = h5tools_dump_simple_subset(rawdatastream, info, ctx, dset, p_type);
}
- else
+ else {
/* space is H5S_NULL */
- status = SUCCEED;
-
+ ret_value = SUCCEED;
+ }
done:
if (f_type > 0)
H5Tclose(f_type);
@@ -1819,7 +1979,7 @@ done:
if (f_space > 0)
H5Sclose(f_space);
- return status;
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -1831,14 +1991,15 @@ done:
*
* Return: Success: SUCCEED
* Failure: FAIL
- *
*-------------------------------------------------------------------------
*/
int
-h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
- hid_t obj_id, hid_t type, hid_t space, void *mem)
+h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t attr_id)
{
- HERR_INIT(int, SUCCEED)
+ H5TOOLS_ERR_INIT(int, SUCCEED)
+ hid_t f_space = H5I_INVALID_HID;
+ hid_t p_type = H5I_INVALID_HID;
+ hid_t f_type = H5I_INVALID_HID;
h5tool_format_t info_dflt;
/* Use default values */
@@ -1850,13 +2011,42 @@ h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *c
info = &info_dflt;
}
+ f_type = H5Aget_type(attr_id);
+ if (f_type < 0)
+ goto done;
+
+ if (info->raw || bin_form == 1)
+ p_type = H5Tcopy(f_type);
+ else if (bin_form == 2)
+ p_type = h5tools_get_little_endian_type(f_type);
+ else if (bin_form == 3)
+ p_type = h5tools_get_big_endian_type(f_type);
+ else
+ p_type = H5Tget_native_type(f_type, H5T_DIR_DEFAULT);
+
+ if (p_type < 0)
+ goto done;
+
/* Check the data space */
- if (H5Sis_simple(space) <= 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sis_simple failed")
+ f_space = H5Aget_space(attr_id);
+ if (f_space < 0)
+ goto done;
- H5_LEAVE(h5tools_dump_simple_mem(rawattrstream, info, ctx, obj_id, type, space, mem))
+ /* Check the data space */
+ if (H5Sis_simple(f_space) <= 0) {
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sis_simple failed");
+ }
+ else {
+ ret_value = h5tools_dump_simple_mem(rawattrstream, info, ctx, attr_id, p_type);
+ }
+done:
+ if (f_type > 0)
+ H5Tclose(f_type);
+ if (p_type > 0)
+ H5Tclose(p_type);
+ if (f_space > 0)
+ H5Sclose(f_space);
-CATCH
return ret_value;
}
@@ -1869,14 +2059,13 @@ CATCH
*
* In/Out: h5tools_str_t *buffer
* h5tools_context_t *ctx
- *
*-------------------------------------------------------------------------
*/
int
h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info,
h5tools_context_t *ctx, hid_t type, int object_search)
{
- HERR_INIT(int, SUCCEED)
+ H5TOOLS_ERR_INIT(int, SUCCEED)
char *mname;
hid_t mtype = -1;
hid_t str_type = -1;
@@ -1900,7 +2089,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
const char *order_s = NULL; /* byte order string */
if((type_class = H5Tget_class(type)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed");
if (object_search && H5Tcommitted(type) > 0) {
H5O_info_t oinfo;
obj_t *obj = NULL; /* Found object */
@@ -2190,11 +2379,11 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
order = H5Tget_order(tmp_type);
if(order == H5T_ORDER_LE) {
if(H5Tset_order(str_type, H5T_ORDER_LE) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed");
} /* end if */
else if(order == H5T_ORDER_BE) {
if(H5Tset_order(str_type, H5T_ORDER_BE) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed");
} /* end if */
if(H5Tequal(tmp_type, str_type)) {
@@ -2204,7 +2393,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
/* If not equal to C variable-length string, check Fortran type. */
if(H5Tclose(str_type) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
str_type = H5Tcopy(H5T_FORTRAN_S1);
H5Tset_cset(str_type, cset);
@@ -2221,11 +2410,11 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
order = H5Tget_order(tmp_type);
if(order == H5T_ORDER_LE) {
if(H5Tset_order(str_type, H5T_ORDER_LE) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed");
} /* end if */
else if(order == H5T_ORDER_BE) {
if(H5Tset_order(str_type, H5T_ORDER_BE) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed");
} /* end if */
if(H5Tequal(tmp_type, str_type)) {
@@ -2244,9 +2433,9 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
h5tools_str_reset(buffer);
if(H5Tclose(str_type) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
if(H5Tclose(tmp_type) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->strblockend);
break;
@@ -2280,7 +2469,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
char *ttag;
if(NULL == (ttag = H5Tget_tag(type)))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_tag failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_tag failed");
ctx->need_prefix = TRUE;
@@ -2308,7 +2497,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
case H5T_COMPOUND:
if((snmembers = H5Tget_nmembers(type)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
nmembers = (unsigned)snmembers;
h5tools_str_append(buffer, "H5T_COMPOUND %s", h5tools_dump_header_format->structblockbegin);
@@ -2326,10 +2515,10 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
h5tools_str_append(buffer, " \"%s\";", mname);
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
if(H5Tclose(mtype) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
}
else
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_member_type failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_member_type failed");
H5free_memory(mname);
}
ctx->indent_level--;
@@ -2350,13 +2539,15 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
}
else if (H5Tequal(type, H5T_STD_REF) == TRUE) {
h5tools_str_append(buffer, " { H5T_STD_REF }");
- } else
+ }
+ else {
h5tools_str_append(buffer, " { UNDEFINED }");
+ }
break;
case H5T_ENUM:
if((super = H5Tget_super(type)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed");
h5tools_str_append(buffer, "H5T_ENUM %s", h5tools_dump_header_format->enumblockbegin);
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
@@ -2368,7 +2559,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE);
if(H5Tclose(super) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
h5tools_str_append(buffer, ";");
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
@@ -2386,14 +2577,14 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
case H5T_VLEN:
if((super = H5Tget_super(type)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed");
h5tools_str_append(buffer, "H5T_VLEN %s ", h5tools_dump_header_format->vlenblockbegin);
h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE);
if(H5Tclose(super) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->vlenblockend);
@@ -2414,10 +2605,10 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
h5tools_str_append(buffer, " ");
}
else
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_array_dims2 failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_array_dims2 failed");
}
else
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_array_ndims failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_array_ndims failed");
/* Get array base type */
if((super = H5Tget_super(type)) >= 0) {
@@ -2425,10 +2616,10 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE);
/* Close array base type */
if(H5Tclose(super) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
}
else
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_super failed");
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_super failed");
h5tools_str_append(buffer, " }");
@@ -2454,13 +2645,12 @@ CATCH
*
* In/Out: h5tools_str_t *buffer
* h5tools_context_t *ctx
- *
*-------------------------------------------------------------------------
*/
int
h5tools_print_dataspace(h5tools_str_t *buffer, hid_t space)
{
- HERR_INIT(int, SUCCEED)
+ H5TOOLS_ERR_INIT(int, SUCCEED)
hsize_t size[H5TOOLS_DUMP_MAX_RANK];
hsize_t maxsize[H5TOOLS_DUMP_MAX_RANK];
int ndims = -1;
@@ -2468,10 +2658,10 @@ h5tools_print_dataspace(h5tools_str_t *buffer, hid_t space)
int i;
if((ndims = H5Sget_simple_extent_dims(space, size, maxsize)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
if((space_type = H5Sget_simple_extent_type(space)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_type failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_type failed");
switch(space_type) {
case H5S_SCALAR:
@@ -2534,10 +2724,9 @@ CATCH
*
*-----------------------------------------------------------------------*/
int
-h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t type)
+h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t type)
{
- HERR_INIT(int, SUCCEED)
+ H5TOOLS_ERR_INIT(int, SUCCEED)
char **name = NULL; /*member names */
unsigned char *value = NULL; /*value array */
unsigned char *copy = NULL; /*a pointer to value array */
@@ -2556,15 +2745,15 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i
ncols = info->line_ncols;
if((snmembs = H5Tget_nmembers(type)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
nmembs = (unsigned)snmembs;
HDassert(nmembs > 0);
if((super = H5Tget_super(type)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed");
if((type_size = H5Tget_size(type)) <= 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size(type) failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size(type) failed");
/*
* Determine what datatype to use for the native values. To simplify
@@ -2577,7 +2766,7 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i
dst_size = sizeof(long long);
if((sign_type = H5Tget_sign(type))<0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_sign failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_sign failed");
if(H5T_SGN_NONE == sign_type)
native = H5T_NATIVE_ULLONG;
else
@@ -2588,20 +2777,20 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i
/* Get the names and raw values of all members */
if(NULL == (name = (char **)HDcalloc((size_t)nmembs, sizeof(char *))))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for member name");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for member name");
if(NULL == (value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(type_size, dst_size))))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for member value");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for member value");
for (i = 0; i < nmembs; i++) {
name[i] = H5Tget_member_name(type, i);
if(H5Tget_member_value(type, i, value + i * type_size) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_member_value failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_member_value failed");
}
/* Convert values to native datatype */
if (native > 0)
if(H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tconvert failed");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tconvert failed");
/*
* Sort members by increasing value
@@ -2658,7 +2847,7 @@ CATCH
HDfree(value);
if(super >= 0 && H5Tclose(super) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not close datatype's super class");
+ H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not close datatype's super class");
if(0 == nmembs)
h5tools_str_append(buffer, "\n<empty>");
@@ -2678,8 +2867,7 @@ CATCH
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t type)
+h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t type)
{
h5tools_str_t buffer; /* string into which to render */
size_t ncols = 80; /* available output width */
@@ -2726,8 +2914,7 @@ h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info,
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t type)
+h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t type)
{
h5tools_str_t buffer; /* string into which to render */
size_t ncols = 80; /* available output width */
@@ -2775,8 +2962,7 @@ h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info,
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_oid(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t oid)
+h5tools_dump_oid(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t oid)
{
h5tools_str_t buffer; /* string into which to render */
size_t ncols = 80; /* available output width */
@@ -2810,11 +2996,10 @@ h5tools_dump_oid(FILE *stream, const h5tool_format_t *info,
*-------------------------------------------------------------------------
*/
static void
-h5tools_print_virtual_selection(hid_t vspace,
- FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/,
- h5tools_str_t *buffer/*string into which to render */,
- hsize_t *curr_pos/*total data element position*/,
+h5tools_print_virtual_selection(hid_t vspace, FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *ctx, /* in,out*/
+ h5tools_str_t *buffer, /* string into which to render */
+ hsize_t *curr_pos, /* total data element position */
size_t ncols)
{
switch(H5Sget_select_type(vspace)) {
@@ -2881,7 +3066,8 @@ h5tools_print_virtual_selection(hid_t vspace,
*-------------------------------------------------------------------------
*/
void
-h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, hid_t dcpl, hid_t type_id, hid_t obj_id)
+h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info,
+ h5tools_context_t *ctx/*in,out*/, hid_t dcpl, hid_t type_id, hid_t obj_id)
{
size_t size;
hid_t n_type = -1;
@@ -3367,7 +3553,6 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
} /*i*/
}/*nfilters*/
else {
-
ctx->need_prefix = TRUE;
h5tools_str_reset(&buffer);
@@ -3502,12 +3687,10 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
* Purpose: prints the comment for the the object name
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_comment(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t obj_id)
+h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id)
{
char *comment = NULL;
ssize_t cmt_bufsize = -1;
@@ -3561,9 +3744,7 @@ h5tools_dump_comment(FILE *stream, const h5tool_format_t *info,
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, const char *attr_name, hid_t attr_id,
- int display_index, int display_char)
+h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, const char *attr_name, hid_t attr_id)
{
h5tools_str_t buffer; /* string into which to render */
size_t ncols = 80; /* available output width */
@@ -3606,7 +3787,7 @@ h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info,
h5tools_dump_oid(stream, info, ctx, attr_id);
if(data_output || attr_data_output)
- h5tools_dump_data(stream, info, ctx, attr_id, FALSE, NULL, display_index, display_char);
+ h5tools_dump_data(stream, info, ctx, attr_id, FALSE);
ctx->indent_level--;
@@ -3638,12 +3819,6 @@ h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info,
* Purpose: Dump the dimensions handed to it in a comma separated list
*
* Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 27. February 2001
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
@@ -3665,7 +3840,6 @@ h5tools_print_dims(h5tools_str_t *buffer, hsize_t *s, int dims)
* Purpose: Prints the packed bits offset and length
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
void
@@ -3712,17 +3886,10 @@ h5tools_print_packed_bits(h5tools_str_t *buffer, hid_t type)
* Purpose: Dump the subsetting header like specified in the DDL.
*
* Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 27. February 2001
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, struct subset_t *sset, int dims)
+h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, int dims)
{
h5tools_str_t buffer; /* string into which to render */
hsize_t curr_pos = 0; /* total data element position */
@@ -3745,7 +3912,7 @@ h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info,
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->startbegin, h5tools_dump_header_format->startblockbegin);
- h5tools_print_dims(&buffer, sset->start.data, dims);
+ h5tools_print_dims(&buffer, ctx->sset->start.data, dims);
h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->startend, h5tools_dump_header_format->startblockend);
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
@@ -3753,7 +3920,7 @@ h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info,
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->stridebegin, h5tools_dump_header_format->strideblockbegin);
- h5tools_print_dims(&buffer, sset->stride.data, dims);
+ h5tools_print_dims(&buffer, ctx->sset->stride.data, dims);
h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->strideend, h5tools_dump_header_format->strideblockend);
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
@@ -3762,8 +3929,8 @@ h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info,
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->countbegin, h5tools_dump_header_format->countblockbegin);
- if(sset->count.data)
- h5tools_print_dims(&buffer, sset->count.data, dims);
+ if(ctx->sset->count.data)
+ h5tools_print_dims(&buffer, ctx->sset->count.data, dims);
else
h5tools_str_append(&buffer, "DEFAULT");
@@ -3775,8 +3942,8 @@ h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info,
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->blockbegin, h5tools_dump_header_format->blockblockbegin);
- if(sset->block.data)
- h5tools_print_dims(&buffer, sset->block.data, dims);
+ if(ctx->sset->block.data)
+ h5tools_print_dims(&buffer, ctx->sset->block.data, dims);
else
h5tools_str_append(&buffer, "DEFAULT");
@@ -3791,34 +3958,35 @@ h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info,
/*-------------------------------------------------------------------------
* Function: dump_data
*
- * Purpose: Dump attribute or dataset data
+ * Purpose: Dump attribute, obj_data is FALSE, or dataset data, obj_data is TRUE
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_data(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t obj_id, int obj_data, struct subset_t *sset,
- int display_index, int display_char)
+h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id, int obj_data)
{
+ H5TOOLS_ERR_INIT(int, SUCCEED)
H5S_class_t space_type;
int ndims;
- int i;
- hid_t space = -1;
- hid_t type = -1;
- hid_t p_type = -1;
- hsize_t size[64];
- hsize_t alloc_size;
- hsize_t nelmts = 1;
+ size_t i;
+ hid_t space = H5I_INVALID_HID;
+ hid_t f_type = H5I_INVALID_HID;
+ hid_t new_obj_id = H5I_INVALID_HID;
+ hid_t new_obj_sid = H5I_INVALID_HID;
+ hsize_t total_size[H5S_MAX_RANK];
+ hsize_t elmt_counter = 0; /*counts the # elements printed. */
int status = -1;
- void *buf = NULL;
- h5tools_str_t buffer; /* string into which to render */
- hsize_t curr_pos = 0; /* total data element position */
- size_t ncols = 80; /* available output width */
- h5tool_format_t string_dataformat;
- h5tool_format_t outputformat;
-
+ h5tools_str_t buffer; /* string into which to render */
+ hsize_t curr_pos = 0; /* total data element position */
+ size_t ncols = 80; /* available output width */
+ h5tool_format_t string_dataformat;
+ h5tool_format_t outputformat;
+ H5R_ref_t *ref_buf = NULL;
+
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter file=%p", (void*)stream);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "rawdata file=%p", (void*)rawdatastream);
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
if (info->line_ncols > 0)
@@ -3827,26 +3995,17 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info,
outputformat = *info;
string_dataformat = *info;
/* print the matrix indices */
- string_dataformat.pindex = display_index;
+ string_dataformat.pindex = ctx->display_index;
- /* do not print indices for regions */
if(obj_data) {
- hid_t f_type = H5Dget_type(obj_id);
-
- if (H5Tequal(f_type, H5T_STD_REF_DSETREG)) {
- /* For the region option, correct the display of indices */
- if (region_output) {
- if (!string_dataformat.pindex) {
- string_dataformat.idx_fmt = "";
- string_dataformat.idx_n_fmt = "";
- string_dataformat.idx_sep = "";
- string_dataformat.line_pre = "";
- }
- }
- else
- string_dataformat.pindex = 0;
- }
- H5Tclose(f_type);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "dataset");
+ f_type = H5Dget_type(obj_id);
+ space = H5Dget_space(obj_id);
+ }
+ else {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "attribute");
+ f_type = H5Aget_type(obj_id);
+ space = H5Aget_space(obj_id);
}
if (string_dataformat.pindex) {
@@ -3857,11 +4016,9 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info,
}
info = &string_dataformat;
- if (sset && obj_data) {
- hid_t f_space = H5Dget_space(obj_id);
+ if (ctx->sset && obj_data) {
- h5tools_dump_subsetting_header(stream, &outputformat, ctx, sset, H5Sget_simple_extent_ndims(f_space));
- H5Sclose(f_space);
+ h5tools_dump_subsetting_header(stream, &outputformat, ctx, H5Sget_simple_extent_ndims(space));
ctx->indent_level++;
}
@@ -3871,135 +4028,310 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info,
h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->databegin, h5tools_dump_header_format->datablockbegin);
h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- /* Print all the values. */
- if(obj_data) {
+ if (H5Tget_class(f_type) == H5T_REFERENCE) {
+ ctx->indent_level++;
h5tools_context_t datactx = *ctx; /* print context */
- hid_t f_type = H5Dget_type(obj_id);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "reference class type");
+ if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) && !H5Tequal(f_type, H5T_STD_REF_OBJ)) {
+ HGOTO_DONE(SUCCEED);
+ }
+
+ ndims = (int)H5Sget_simple_extent_npoints(space);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ndims=%d - datactx.ndims=%d", ndims, datactx.ndims);
+
+ /* Assume entire data space to be printed */
+ if (datactx.ndims > 0)
+ for (i = 0; i < (size_t)datactx.ndims; i++)
+ datactx.p_min_idx[i] = 0;
+
+ H5Sget_simple_extent_dims(space, total_size, NULL);
+ if (datactx.ndims > 0)
+ init_acc_pos(&datactx, total_size);
+ datactx.need_prefix = TRUE;
+
+ if (NULL != (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), ndims))) {
+ if(obj_data) {
+ if(H5Dread(obj_id, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf) < 0) {
+ HDfree(ref_buf);
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread reference failed");
+ }
+ }
+ else {
+ if(H5Aread(obj_id, H5T_STD_REF, ref_buf) < 0) {
+ HDfree(ref_buf);
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread reference failed");
+ }
+ }
+ for(i = 0; i < ndims; i++, datactx.cur_elmt++, elmt_counter++) {
+ H5O_type_t obj_type; /* Object type */
+ H5R_type_t ref_type; /* Reference type */
- if((display_char && H5Tget_size(f_type) == 1) && (H5Tget_class(f_type) == H5T_INTEGER)) {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "reference loop:%d with curr_pos=%ld", i, curr_pos);
+
+ datactx.need_prefix = TRUE;
+ h5tools_str_reset(&buffer);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "reference loop - h5tools_str_sprint with H5T_STD_REF:%d", i);
+ h5tools_str_sprint(&buffer, &outputformat, obj_id, H5T_STD_REF, &ref_buf[i], &datactx);
+ h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)i, (hsize_t)ndims);
+
+ ref_type = H5Rget_type((const H5R_ref_t *)&ref_buf[i]);
+ switch (ref_type) {
+ case H5R_OBJECT1:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_OBJECT1");
+ if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
+ switch (obj_type) {
+ case H5O_TYPE_DATASET:
+ if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ datactx.indent_level++;
+ h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE);
+ datactx.indent_level--;
+ if(H5Dclose(new_obj_id) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed");
+ if(H5Rdestroy(&ref_buf[i]) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdestroy H5R_OBJECT1:H5O_TYPE_DATASET failed");
+ }
+ else
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Ropen_object H5R_OBJECT1:H5O_TYPE_DATASET failed");
+ break;
+
+ case H5O_TYPE_GROUP:
+ case H5O_TYPE_NAMED_DATATYPE:
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ break;
+ } /* end switch */
+ }
+ else
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_obj_type3 H5R_OBJECT1 failed");
+ break;
+ case H5R_DATASET_REGION1:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_DATASET_REGION1");
+ if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ datactx.indent_level++;
+ h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE);
+ datactx.indent_level--;
+ if(H5Dclose(new_obj_id) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose H5R_DATASET_REGION1 failed");
+ if(H5Rdestroy(&ref_buf[i]) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdestroy H5R_DATASET_REGION1 failed");
+ }
+ else
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Ropen_object H5R_DATASET_REGION1 failed");
+ break;
+ case H5R_OBJECT2:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_OBJECT2");
+ if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
+ switch (obj_type) {
+ case H5O_TYPE_GROUP:
+ break;
+
+ case H5O_TYPE_DATASET:
+ if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ datactx.indent_level++;
+ h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE);
+ datactx.indent_level--;
+ if(H5Oclose(new_obj_id) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Oclose H5R_OBJECT2 failed");
+ if(H5Rdestroy(&ref_buf[i]) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdestroy H5R_OBJECT2 failed");
+ }
+ else
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Ropen_object H5R_OBJECT2 failed");
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ break;
+
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ break;
+ } /* end switch */
+ }
+ else
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_obj_type3 H5R_OBJECT2 failed");
+ break;
+ case H5R_DATASET_REGION2:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_DATASET_REGION2");
+
+ if (outputformat.line_ncols > 0)
+ ncols = outputformat.line_ncols;
+
+ /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */
+ if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g,
+ "H5Ropen_object H5R_DATASET_REGION2 failed");
+ else {
+ if((new_obj_sid = H5Ropen_region((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "NULL H5R_DATASET_REGION2");
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " {");
+ h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
+ datactx.indent_level++;
+ datactx.need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "NULL");
+ h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
+ datactx.indent_level--;
+ datactx.need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "}");
+ h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+ }
+ else {
+ H5S_sel_type region_type;
+
+ region_type = H5Sget_select_type(new_obj_sid);
+ if(region_type == H5S_SEL_POINTS) {
+ /* Print point information */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5S_SEL_POINTS H5R_DATASET_REGION2");
+ h5tools_dump_region_data_points(new_obj_sid, new_obj_id, stream, &outputformat, &datactx,
+ &buffer, &curr_pos, ncols, i, elmt_counter);
+ }
+ else if(region_type == H5S_SEL_HYPERSLABS) {
+ /* Print block information */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5S_SEL_HYPERSLABS H5R_DATASET_REGION2");
+ h5tools_dump_region_data_blocks(new_obj_sid, new_obj_id, stream, &outputformat, &datactx,
+ &buffer, &curr_pos, ncols, i, elmt_counter);
+ }
+ else
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "invalid region type");
+ } /* end else to if (h5tools_is_zero(... */
+ if(H5Sclose(new_obj_sid) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose H5R_DATASET_REGION2 failed");
+ }
+ else
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Ropen_region H5R_DATASET_REGION2 failed");
+ if(H5Dclose(new_obj_id) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose H5R_DATASET_REGION2 failed");
+ if(H5Rdestroy(&ref_buf[i]) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdestroy H5R_DATASET_REGION2 failed");
+ }
+ break;
+ case H5R_ATTR:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_ATTR");
+ if((new_obj_id = H5Ropen_attr((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ h5tools_dump_region_attribute(new_obj_id, stream, &outputformat, &datactx,
+ &buffer, &curr_pos, ncols, i, elmt_counter);
+ if(H5Aclose(new_obj_id) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aclose H5R_ATTR failed");
+ if(H5Rdestroy(&ref_buf[i]) < 0)
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdestroy H5R_ATTR failed");
+ }
+ else {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "NULL H5R_ATTR");
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " {");
+ h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
+ datactx.indent_level++;
+ datactx.need_prefix = TRUE;
+
+ datactx.indent_level++;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "NULL");
+ h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+ datactx.indent_level--;
+
+ datactx.indent_level--;
+ datactx.need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "}");
+ h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
+ H5TOOLS_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Ropen_attr H5R_ATTR failed");
+ }
+ break;
+ case H5R_BADTYPE:
+ case H5R_MAXTYPE:
+ default:
+ break;
+ } /* end switch */
+
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "finished reference loop:%d",i);
+ } /* end for(i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) */
+ HDfree(ref_buf);
+ }
+ ctx->indent_level--;
+ }
+ else {
+ h5tools_context_t datactx = *ctx; /* print context */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "Print all the values");
+ string_dataformat = *info;
+ if((datactx.display_char && H5Tget_size(f_type) == 1) && (H5Tget_class(f_type) == H5T_INTEGER)) {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "Print 1-byte integer data as an ASCII character string");
/*
- * Print 1-byte integer data as an ASCII character string
- * instead of integers if the `-r' or `--string' command-line
- * option was given.
- *
- * We don't want to modify the global dataformat, so make a
- * copy of it instead.
- */
- string_dataformat = *info;
+ * Print 1-byte integer data as an ASCII character string
+ * instead of integers if the `-r' or `--string' command-line
+ * option was given.
+ *
+ * We don't want to modify the global dataformat, so make a
+ * copy of it instead.
+ */
string_dataformat.idx_fmt = "\"";
- info = &string_dataformat;
datactx.indent_level++;
datactx.need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, &datactx, (hsize_t)0, 0);
+ h5tools_simple_prefix(stream, &string_dataformat, &datactx, (hsize_t)0, 0);
- string_dataformat = *info;
- string_dataformat.idx_fmt = "\"";
string_dataformat.line_multi_new = 1;
string_dataformat.str_repeat = 8;
string_dataformat.ascii = TRUE;
string_dataformat.elmt_suf1 = "";
string_dataformat.elmt_suf2 = "";
string_dataformat.line_suf = "\"";
- info = &string_dataformat;
}
- else
+ else {
datactx.need_prefix = TRUE;
- status = h5tools_dump_dset(stream, info, &datactx, obj_id, sset);
- if((display_char && H5Tget_size(f_type) == 1) && (H5Tget_class(f_type) == H5T_INTEGER)) {
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "\"");
- h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
}
- H5Tclose(f_type);
- }
- else {
- h5tools_context_t datactx = *ctx; /* print context */
- /* need to call h5tools_dump_mem for the attribute data */
- space = H5Aget_space(obj_id);
- space_type = H5Sget_simple_extent_type(space);
- if(space_type == H5S_NULL || space_type == H5S_NO_CLASS) {
- status = SUCCEED;
+
+ /* Print all the values. */
+ if(obj_data) {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "h5tools_dump_dset");
+ status = h5tools_dump_dset(stream, &string_dataformat, &datactx, obj_id);
}
else {
- /* VL data special information */
- unsigned int vl_data = 0; /* contains VL datatypes */
-
- type = H5Aget_type(obj_id);
- p_type = H5Tget_native_type(type, H5T_DIR_DEFAULT);
-
- ndims = H5Sget_simple_extent_dims(space, size, NULL);
-
- /* Check if we have VL data in the dataset's datatype */
- if (h5tools_detect_vlen(p_type) == TRUE)
- vl_data = TRUE;
-
- for (i = 0; i < ndims; i++)
- nelmts *= size[i];
-
- alloc_size = nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type));
- HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
-
- if(alloc_size) {
- buf = HDmalloc((size_t)alloc_size);
- HDassert(buf);
-
- if (H5Aread(obj_id, p_type, buf) >= 0) {
- if (display_char && H5Tget_size(type) == 1 && H5Tget_class(type) == H5T_INTEGER) {
- /*
- * Print 1-byte integer data as an ASCII character string
- * instead of integers if the `-r' or `--string' command-line
- * option was given.
- *
- * We don't want to modify the global dataformat, so make a
- * copy of it instead.
- */
- string_dataformat = *info;
- string_dataformat.idx_fmt = "\"";
- info = &string_dataformat;
- datactx.indent_level++;
- datactx.need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, &datactx, (hsize_t)0, 0);
-
- string_dataformat = *info;
- string_dataformat.idx_fmt = "\"";
- string_dataformat.line_multi_new = 1;
- string_dataformat.str_repeat = 8;
- string_dataformat.ascii = TRUE;
- string_dataformat.elmt_suf1 = "";
- string_dataformat.elmt_suf2 = "";
- string_dataformat.line_suf = "\"";
- info = &string_dataformat;
- }
- else
- datactx.need_prefix = TRUE;
- }
-
- status = h5tools_dump_mem(stream, info, &datactx, obj_id, p_type, space, buf);
- if (display_char && H5Tget_size(type) == 1 && H5Tget_class(type) == H5T_INTEGER) {
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "\"");
- h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- }
-
- /* Reclaim any VL memory, if necessary */
- if (vl_data)
- H5Treclaim(p_type, space, H5P_DEFAULT, buf);
-
- HDfree(buf);
- }
- else
+ /* need to call h5tools_dump_mem for the attribute data */
+ space_type = H5Sget_simple_extent_type(space);
+ if(space_type == H5S_NULL || space_type == H5S_NO_CLASS) {
status = SUCCEED;
-
- H5Tclose(p_type);
- H5Tclose(type);
+ }
+ else {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "call h5tools_dump_mem");
+ status = h5tools_dump_mem(stream, &string_dataformat, &datactx, obj_id);
+ }
}
- H5Sclose(space);
- }
+ if (datactx.display_char && H5Tget_size(f_type) == 1 && H5Tget_class(f_type) == H5T_INTEGER) {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "Print 1-byte integer data as an ASCII character string eol=%s",string_dataformat.line_suf);
+ datactx.need_prefix = FALSE;
+ string_dataformat.arr_linebreak = 0;
+ string_dataformat.idx_fmt = "";
+ string_dataformat.line_multi_new = 0;
+ string_dataformat.line_suf = "";
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"");
+ h5tools_render_element(stream, &string_dataformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+ }
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "Print all the values Complete");
- if (status == FAIL) {
- error_msg("unable to print data\n");
- h5tools_setstatus(EXIT_FAILURE);
+ if (status == FAIL) {
+ error_msg("unable to print data\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ }
}
+done:
+ H5Sclose(space);
+ H5Tclose(f_type);
ctx->need_prefix = TRUE;
h5tools_simple_prefix(stream, &outputformat, ctx, (hsize_t)0, 0);
@@ -4010,11 +4342,12 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info,
if(HDstrlen(h5tools_dump_header_format->dataend))
h5tools_str_append(&buffer, " ");
}
+
if(HDstrlen(h5tools_dump_header_format->dataend))
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->dataend);
h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- if (sset && obj_data) {
+ if (ctx->sset && obj_data) {
ctx->indent_level--;
ctx->need_prefix = TRUE;
@@ -4032,5 +4365,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info,
}
h5tools_str_close(&buffer);
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
}
diff --git a/tools/lib/h5tools_dump.h b/tools/lib/h5tools_dump.h
index dc79f43..2cd0bc1 100644
--- a/tools/lib/h5tools_dump.h
+++ b/tools/lib/h5tools_dump.h
@@ -37,11 +37,9 @@ H5TOOLS_DLLVAR table_t *h5dump_type_table; /*type table reference for datatype
H5TOOLS_DLL void h5tools_dump_init(void);
H5TOOLS_DLL int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/, hid_t dset,
- struct subset_t *sset);
+ h5tools_context_t *ctx/*in,out*/, hid_t dset);
H5TOOLS_DLL int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/, hid_t obj_id,
- hid_t type, hid_t space, void *mem);
+ h5tools_context_t *ctx/*in,out*/, hid_t obj_id);
H5TOOLS_DLL int h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container,
h5tools_context_t *ctx/*in,out*/, unsigned flags,
hsize_t nelmts, hid_t type, void *_mem);
@@ -50,8 +48,7 @@ H5TOOLS_DLL void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *i
H5TOOLS_DLL void h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info,
h5tools_context_t *ctx/*in,out*/, hid_t space);
H5TOOLS_DLL void h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/, const char *attr_name,
- hid_t attr_id, int display_index, int display_char);
+ h5tools_context_t *ctx/*in,out*/, const char *attr_name, hid_t attr_id);
H5TOOLS_DLL void h5tools_dump_oid(FILE *stream, const h5tool_format_t *info,
h5tools_context_t *ctx/*in,out*/, hid_t oid);
H5TOOLS_DLL void h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
@@ -59,8 +56,30 @@ H5TOOLS_DLL void h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
H5TOOLS_DLL void h5tools_dump_comment(FILE *stream, const h5tool_format_t *info,
h5tools_context_t *ctx/*in,out*/, hid_t obj_id);
H5TOOLS_DLL void h5tools_dump_data(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t obj_id,
- int obj_data, struct subset_t *sset, int display_index, int display_char);
+ h5tools_context_t *ctx, hid_t obj_id, int obj_data);
+H5TOOLS_DLL hbool_t h5tools_dump_region_attribute(hid_t region_id,
+ FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *ctx/*in,out*/,
+ h5tools_str_t *buffer/*string into which to render */,
+ hsize_t *curr_pos/*total data element position*/,
+ size_t ncols, hsize_t region_elmt_counter/*element counter*/,
+ hsize_t elmt_counter);
+
+H5TOOLS_DLL hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
+ FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *ctx/*in,out*/,
+ h5tools_str_t *buffer/*string into which to render */,
+ hsize_t *curr_pos/*total data element position*/,
+ size_t ncols, hsize_t region_elmt_counter/*element counter*/,
+ hsize_t elmt_counter);
+
+H5TOOLS_DLL hbool_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
+ FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *ctx/*in,out*/,
+ h5tools_str_t *buffer/*string into which to render */,
+ hsize_t *curr_pos/*total data element position*/,
+ size_t ncols, hsize_t region_elmt_counter/*element counter*/,
+ hsize_t elmt_counter);
H5TOOLS_DLL int h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer/*in,out*/,
const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
@@ -71,7 +90,7 @@ H5TOOLS_DLL int h5tools_print_enum(FILE *stream, h5tools_str_t *buffer/*in,o
const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
hid_t type);
H5TOOLS_DLL void h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/,
- const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
+ const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
hid_t dcpl, hid_t type_id, hid_t obj_id);
H5TOOLS_DLL void h5tools_print_packed_bits(h5tools_str_t *buffer/*in,out*/, hid_t type);
#ifdef __cplusplus
diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h
index 2cdaf74..2c5e6c9 100644
--- a/tools/lib/h5tools_error.h
+++ b/tools/lib/h5tools_error.h
@@ -18,12 +18,15 @@
#define H5TOOLS_ERROR_H_
#include "H5Epublic.h"
+#include "H5Eprivate.h" /* Error handling */
/* tools-HDF5 Error variables */
H5TOOLS_DLLVAR hid_t H5tools_ERR_STACK_g;
H5TOOLS_DLLVAR hid_t H5tools_ERR_CLS_g;
H5TOOLS_DLLVAR hid_t H5E_tools_g;
H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
+H5TOOLS_DLLVAR hid_t H5E_tools_min_info_id_g;
+H5TOOLS_DLLVAR hid_t H5E_tools_min_dbg_id_g;
/* Use FUNC to safely handle variations of C99 __func__ keyword handling */
#ifdef H5_HAVE_C99_FUNC
@@ -39,41 +42,84 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
*/
#define H5TOOLS_INIT_ERROR() { \
H5tools_ERR_CLS_g = H5Eregister_class("H5tools", "HDF5:tools", lib_str); \
- H5E_tools_g= H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MAJOR, "Failure in tools library"); \
+ H5E_tools_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MAJOR, "Failure in tools library"); \
H5E_tools_min_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "error in function"); \
+ H5E_tools_min_info_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function info"); \
+ H5E_tools_min_dbg_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function debug"); \
}
/*
* H5TOOLS_CLOSE_ERROR macro, used to initialize error reporting.
*/
#define H5TOOLS_CLOSE_ERROR() { \
+ H5Eclose_msg(H5E_tools_min_dbg_id_g); \
+ H5Eclose_msg(H5E_tools_min_info_id_g); \
H5Eclose_msg(H5E_tools_min_id_g); \
H5Eclose_msg(H5E_tools_g); \
H5Eunregister_class(H5tools_ERR_CLS_g); \
}
/*
- * HERR_INIT macro, used to facilitate error reporting. Declaration and assignments of error variables.
+ * H5TOOLS_ERR_INIT macro, used to facilitate error reporting. Declaration and assignments of error variables.
* Use at the beginning of a function using error handling macros.
*/
-#define HERR_INIT(ret_typ, ret_init) \
- hbool_t past_catch = FALSE; \
+#define H5TOOLS_ERR_INIT(ret_typ, ret_init) \
+ hid_t pstack_id = H5I_INVALID_HID; \
+ hid_t estack_id = H5tools_ERR_STACK_g; \
+ hbool_t past_catch = FALSE; \
ret_typ ret_value = ret_init;
+/*
+ * H5TOOLS_PUSH_STACK macro, used to create a new error stack.
+ */
+#define H5TOOLS_PUSH_STACK() { \
+ pstack_id = estack_id; \
+ estack_id = H5Ecreate_stack(); \
+}
/*
- * H5TOOLS_INFO macro, used to facilitate error reporting . The arguments are the major
- * error number, the minor error number, and a description of the error.
+ * H5TOOLS_POP_STACK macro, used to release a new error stack.
+ */
+#define H5TOOLS_POP_STACK() { \
+ if (H5I_INVALID_HID != pstack_id) { \
+ H5Eclose_stack(estack_id); \
+ estack_id = pstack_id; \
+ pstack_id = H5I_INVALID_HID; \
+ } \
+}
+
+/*
+ * H5TOOLS_DEBUG macro, used to facilitate error reporting. The arguments are the minor error number, and a description of the error.
+ */
+#ifdef H5_TOOLS_DEBUG
+#define H5TOOLS_DEBUG(min_id, ...) { \
+ H5Epush2(estack_id, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, min_id, __VA_ARGS__); \
+}
+#define H5TOOLS_ENDDEBUG(min_id, ...) { \
+ H5Epush2(estack_id, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, min_id, __VA_ARGS__); \
+ H5Eprint2(estack_id, stderr); \
+}
+#else
+#define H5TOOLS_DEBUG(min_id, ...) { \
+ ; \
+}
+#define H5TOOLS_ENDDEBUG(min_id, ...) { \
+ ; \
+}
+#endif
+
+/*
+ * H5TOOLS_INFO macro, used to facilitate error reporting . The arguments are the minor error number, and a description of the error.
*/
#define H5TOOLS_INFO(min_id, ...) { \
H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, min_id, __VA_ARGS__); \
}
/*
- * HERROR macro, used to facilitate error reporting . The arguments are the major
+ * H5TOOLS_ERROR macro, used to facilitate error reporting . The arguments are the major
* error number, the minor error number, and a description of the error.
*/
-#define HERROR(maj_id, min_id, ...) { \
+#define H5TOOLS_ERROR(maj_id, min_id, ...) { \
H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, maj_id, min_id, __VA_ARGS__); \
ret_value = FAIL; \
}
@@ -82,7 +128,7 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
/* Macro for "catching" flow of control when an error occurs. Note that the
* H5_LEAVE macro won't jump back here once it's past this point.
*/
-#define CATCH catch_except:; past_catch = TRUE;
+/* #define CATCH catch_except:; past_catch = TRUE; defined in H5Eprivate.h */
/*
* H5_LEAVE macro, used to facilitate control flow between a
@@ -91,32 +137,34 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
* The return value is assigned to a variable `ret_value' and control branches
* to the `catch_except' label, if we're not already past it.
*/
-#define H5_LEAVE(v) { \
- ret_value = v; \
- if(!past_catch) \
- goto catch_except; \
-}
+/*
+ * #define H5_LEAVE(v) { \
+ * ret_value = v; \
+ * if(!past_catch) \
+ * goto catch_except; \
+ * }
+ * defined in H5Eprivate.h */
/*
- * H5E_THROW macro, used to facilitate error reporting within a function body.
+ * H5TOOLS_THROW macro, used to facilitate error reporting within a function body.
* The arguments are the minor error number, and an error string.
* The return value is assigned to a variable `ret_value' and control branches
* to the `catch_except' label, if we're not already past it.
*/
-#define H5E_THROW(fail_value, min_id, ...) { \
+#define H5TOOLS_THROW(fail_value, min_id, ...) { \
H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, min_id, __VA_ARGS__); \
- H5_LEAVE(fail_value) \
+ H5_LEAVE(fail_value) \
}
/*
- * HGOTO_ERROR macro, used to facilitate error reporting within a function body. The arguments are
+ * H5TOOLS_GOTO_ERROR macro, used to facilitate error reporting within a function body. The arguments are
* the major error number, the minor error number, the return value, and an
* error string. The return value is assigned to a variable `ret_value' and
* control branches to the `done' label.
*/
-#define HGOTO_ERROR(fail_value, min_id, ...) { \
- HERROR(H5E_tools_g, min_id, __VA_ARGS__); \
- HGOTO_DONE(fail_value) \
+#define H5TOOLS_GOTO_ERROR(fail_value, min_id, ...) { \
+ H5TOOLS_ERROR(H5E_tools_g, min_id, __VA_ARGS__); \
+ HGOTO_DONE(fail_value) \
}
/*
@@ -124,7 +172,7 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
* The argument is the return value which is assigned to the `ret_value'
* variable. Control branches to the `done' label.
*/
-#define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;}
+/* #define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;} defined in H5Eprivate.h */
#endif /* H5TOOLS_ERROR_H_ */
diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c
index cfe7422..aafc7ba 100644
--- a/tools/lib/h5tools_filters.c
+++ b/tools/lib/h5tools_filters.c
@@ -51,7 +51,7 @@ h5tools_canreadf(const char* name, /* object name, serves also as boolean pr
/* get information about filters */
if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_nfilters failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_nfilters failed");
/* if we do not have filters, we can read the dataset safely */
if (!nfilters)
@@ -60,7 +60,7 @@ h5tools_canreadf(const char* name, /* object name, serves also as boolean pr
/* check availability of filters */
for (i = 0; i < nfilters; i++) {
if ((filtn = H5Pget_filter2(dcpl_id, (unsigned) i, 0, 0, 0, (size_t) 0, 0, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_filter2 failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_filter2 failed");
switch (filtn) {
/*-------------------------------------------------------------------------
@@ -69,7 +69,7 @@ h5tools_canreadf(const char* name, /* object name, serves also as boolean pr
*/
default:
if ((udfilter_avail = H5Zfilter_avail(filtn)) < 0) {
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Zfilter_avail failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Zfilter_avail failed");
}
else if (!udfilter_avail) {
if (name)
@@ -164,11 +164,11 @@ h5tools_can_encode(H5Z_filter_t filtn)
unsigned int filter_config_flags;
if (H5Zget_filter_info(filtn, &filter_config_flags) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Zget_filter_info failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Zget_filter_info failed");
if ((filter_config_flags
& (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
/* filter present but neither encode nor decode is supported (???) */
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "neither encode nor decode is supported");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "neither encode nor decode is supported");
}
else if ((filter_config_flags
& (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_DECODE_ENABLED) {
@@ -178,7 +178,7 @@ h5tools_can_encode(H5Z_filter_t filtn)
else if ((filter_config_flags
& (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
/* encoder only: write but not read (???) */
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "encoder only: write but not read");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "encoder only: write but not read");
}
else if ((filter_config_flags
& (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED))
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index c5759d8..f35fdab 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -289,19 +289,27 @@ char *
h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info,
hsize_t elmtno, unsigned ndims, h5tools_context_t *ctx)
{
+ H5TOOLS_ERR_INIT(int, SUCCEED)
size_t i = 0;
hsize_t curr_pos = elmtno;
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
+
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims);
h5tools_str_reset(str);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ndims=%d", ndims);
if(ndims > 0) {
/*
* Calculate the number of elements represented by a unit change in a
* certain index position.
*/
for(i = 0; i < (size_t) ndims; i++) {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "curr_pos=%ld - ctx->acc[%d]=%ld", curr_pos, i, ctx->acc[i]);
ctx->pos[i] = curr_pos / ctx->acc[i];
curr_pos -= ctx->acc[i] * ctx->pos[i];
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "curr_pos=%ld - ctx->pos[%d]=%ld - ctx->acc[%d]=%ld", curr_pos, i, ctx->pos[i], i, ctx->acc[i]);
}
HDassert(curr_pos == 0);
@@ -316,7 +324,11 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info,
}
}
else /* Scalar */
- h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) 0);
+ h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t)elmtno);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "str=%s", str->s);
+
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
/* Add prefix and suffix to the index */
return h5tools_str_fmt(str, (size_t)0, OPT(info->idx_fmt, "%s: "));
@@ -672,6 +684,7 @@ char *
h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container,
hid_t type, void *vp, h5tools_context_t *ctx)
{
+ H5TOOLS_ERR_INIT(char*, NULL)
size_t nsize, offset, size=0, nelmts, start;
H5T_sign_t nsign;
char *name = NULL;
@@ -683,6 +696,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
H5T_str_t pad;
H5T_class_t type_class;
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
/* Build default formats for long long types */
if(!fmt_llong[0]) {
HDsnprintf(fmt_llong, sizeof(fmt_llong), "%%%sd", H5_PRINTF_LL_WIDTH);
@@ -711,6 +726,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
return NULL;
switch (type_class) {
case H5T_FLOAT:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_FLOAT");
if(sizeof(float) == nsize) {
/* if (H5Tequal(type, H5T_NATIVE_FLOAT)) */
float tempfloat;
@@ -742,12 +758,14 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
char quote = '\0';
char *s;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_STRING");
quote = '\0';
if(H5Tis_variable_str(type)) {
/* cp_vp is the pointer into the struct where a `char*' is stored. So we have
* to dereference the pointer to get the `char*' to pass to HDstrlen(). */
s = *(char **)((void *)cp_vp);
- if(s != NULL) size = HDstrlen(s);
+ if(s != NULL)
+ size = HDstrlen(s);
}
else {
s = cp_vp;
@@ -767,8 +785,9 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
* threshold is zero then that means it can repeat any number
* of times.
*/
- if(info->str_repeat > 0) while (i + j < size && s[i] == s[i + j])
- j++;
+ if(info->str_repeat > 0)
+ while (i + j < size && s[i] == s[i + j])
+ j++;
/*
* Print the opening quote. If the repeat count is high enough to
@@ -814,6 +833,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
break;
case H5T_INTEGER:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_INTEGER");
if(sizeof(char) == nsize) {
if(info->ascii)
h5tools_print_char(str, info, (char) (*ucp_vp));
@@ -951,6 +971,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
break;
case H5T_COMPOUND:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_COMPOUND");
if(ctx->cmpd_listv) { /* there is <list_of_fields> */
unsigned save_indent_level; /* The indentation level */
size_t curr_field; /* Current field to display */
@@ -1052,6 +1073,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
{
char enum_name[1024];
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_ENUM");
if(H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0)
h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name)));
else {
@@ -1066,61 +1088,118 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
break;
case H5T_REFERENCE:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_REFERENCE");
if(h5tools_str_is_zero(vp, nsize))
h5tools_str_append(str, "NULL");
else {
- if(nsize == H5R_DSET_REG_REF_BUF_SIZE) {
- /* if (H5Tequal(type, H5T_STD_REF_DSETREG)) */
- h5tools_str_sprint_region(str, info, container, vp);
+ if (H5Tequal(type, H5T_STD_REF)) {
+ H5O_type_t obj_type; /* Object type */
+ H5R_type_t ref_type; /* Reference type */
+ const H5R_ref_t *ref_vp = (const H5R_ref_t *)vp;
+
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_REFERENCE:H5T_STD_REF");
+ ref_type = H5Rget_type(ref_vp);
+ H5Rget_obj_type3(ref_vp, H5P_DEFAULT, &obj_type);
+ switch (ref_type) {
+ case H5R_OBJECT1:
+ {
+ /* Object references -- show the type and OID of the referenced object. */
+ H5O_info_t oi;
+
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_OBJECT1");
+ if((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ H5Oget_info2(obj, &oi, H5O_INFO_BASIC);
+ if(H5Oclose(obj) < 0)
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g,
+ "H5Oclose H5R_OBJECT1 failed");
+ }
+ else
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g,
+ "H5Ropen_object H5R_OBJECT1 failed");
+
+ /* Print object type and close object */
+ switch (obj_type) {
+ case H5O_TYPE_GROUP:
+ h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_GROUP);
+ break;
+
+ case H5O_TYPE_DATASET:
+ h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_DATASET);
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_DATATYPE);
+ break;
+
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ h5tools_str_append(str, "%u-", (unsigned) oi.type);
+ break;
+ } /* end switch */
+ H5Oclose(obj);
+ h5tools_str_sprint_reference(str, info, container, ref_vp);
+
+ /* Print OID */
+ if(info->obj_hidefileno)
+ h5tools_str_append(str, info->obj_format, oi.addr);
+ else
+ h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr);
+ }
+ break;
+ case H5R_DATASET_REGION1:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_DATASET_REGION1");
+ h5tools_str_append(str, H5_TOOLS_DATASET);
+ h5tools_str_sprint_reference(str, info, container, ref_vp);
+ break;
+ case H5R_OBJECT2:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_OBJECT2");
+ switch (obj_type) {
+ case H5O_TYPE_GROUP:
+ h5tools_str_append(str, H5_TOOLS_GROUP);
+ break;
+
+ case H5O_TYPE_DATASET:
+ h5tools_str_append(str, H5_TOOLS_DATASET);
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ h5tools_str_append(str, H5_TOOLS_DATATYPE);
+ break;
+
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ break;
+ } /* end switch */
+ h5tools_str_sprint_reference(str, info, container, ref_vp);
+ break;
+ case H5R_DATASET_REGION2:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_DATASET_REGION2");
+ h5tools_str_append(str, H5_TOOLS_DATASET);
+ h5tools_str_sprint_reference(str, info, container, ref_vp);
+ break;
+ case H5R_ATTR:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_ATTR");
+ h5tools_str_append(str, H5_TOOLS_ATTRIBUTE);
+ h5tools_str_sprint_reference(str, info, container, ref_vp);
+ break;
+ case H5R_BADTYPE:
+ case H5R_MAXTYPE:
+ default:
+ break;
+ } /* end switch */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_REFERENCE:H5T_STD_REF end");
}
- else if (nsize == H5R_OBJ_REF_BUF_SIZE) {
- /* if (H5Tequal(type, H5T_STD_REF_OBJ)) */
- /*
- * Object references -- show the type and OID of the referenced
- * object.
- */
- H5O_info_t oi;
- const char *path;
-
- obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp);
- H5Oget_info2(obj, &oi, H5O_INFO_BASIC);
-
- /* Print object type and close object */
- switch(oi.type) {
- case H5O_TYPE_GROUP:
- h5tools_str_append(str, H5_TOOLS_GROUP);
- break;
-
- case H5O_TYPE_DATASET:
- h5tools_str_append(str, H5_TOOLS_DATASET);
- break;
-
- case H5O_TYPE_NAMED_DATATYPE:
- h5tools_str_append(str, H5_TOOLS_DATATYPE);
- break;
-
- case H5O_TYPE_MAP:
- case H5O_TYPE_UNKNOWN:
- case H5O_TYPE_NTYPES:
- default:
- h5tools_str_append(str, "%u-", (unsigned) oi.type);
- break;
- } /* end switch */
- H5Oclose(obj);
-
- /* Print OID */
- if(info->obj_hidefileno)
- h5tools_str_append(str, info->obj_format, oi.addr);
- else
- h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr);
-
- /* Print name */
- path = lookup_ref_path(*(haddr_t *) vp);
- if(path) {
- h5tools_str_append(str, " ");
- h5tools_str_append(str, path);
- h5tools_str_append(str, " ");
- } /* end if */
+ else if (H5Tequal(type, H5T_STD_REF_DSETREG)) {
+ /* if(nsize == H5R_DSET_REG_REF_BUF_SIZE) */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_REFERENCE:H5T_STD_REF_DSETREG");
+ }
+ else if (H5Tequal(type, H5T_STD_REF_OBJ)) {
+ /* if (nsize == H5R_OBJ_REF_BUF_SIZE) */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_REFERENCE:H5T_STD_REF_OBJ");
} /* end else if (H5Tequal(type, H5T_STD_REF_OBJ)) */
}
break;
@@ -1131,6 +1210,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
hsize_t i, dims[H5S_MAX_RANK], temp_nelmts;
static int is_next_arry_elmt = 0;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_ARRAY");
/* Get the array's base datatype for each element */
memb = H5Tget_super(type);
size = H5Tget_size(memb);
@@ -1192,6 +1272,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
{
unsigned int i;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_VLEN");
/* Get the VL sequences's base datatype for each element */
memb = H5Tget_super(type);
size = H5Tget_size(memb);
@@ -1238,6 +1319,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
case H5T_BITFIELD:
case H5T_OPAQUE:
{
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "OTHER");
/* All other types get printed as hexadecimal */
size_t i;
if(1 == nsize)
@@ -1255,49 +1337,76 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
break;
} /* end switch */
}
- return h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s"));
+CATCH
+ ret_value = h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s"));
+
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit with %s", ret_value);
+ H5TOOLS_POP_STACK();
+ return ret_value;
}
/*-------------------------------------------------------------------------
- * Function: h5tools_str_sprint_region
+ * Function: h5tools_str_sprint_reference
*
- * Purpose: Dataset region reference -- show the type and data of the referenced object.
+ * Purpose: Object reference -- show the name of the referenced object.
*
* Return: Nothing
*-------------------------------------------------------------------------
*/
void
-h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info,
- hid_t container, void *vp)
+h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info,
+ hid_t container, H5R_ref_t *ref_vp)
{
- hid_t obj = -1;
- hid_t region = -1;
- char ref_name[1024];
- H5S_sel_type region_type;
-
- obj = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, vp);
- if(obj >= 0) {
- region = H5Rget_region(container, H5R_DATASET_REGION, vp);
- if(region >= 0) {
- H5Rget_name(obj, H5R_DATASET_REGION, vp, (char*) ref_name, 1024);
-
- h5tools_str_append(str, info->dset_format, ref_name);
-
- h5tools_str_append(str, "{");
+ H5TOOLS_ERR_INIT(int, SUCCEED)
+ ssize_t buf_size;
+
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
+
+ h5tools_str_append(str, " \"");
+ buf_size = H5Rget_file_name(ref_vp, NULL, 0);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "buf_size=%ld", buf_size);
+ if (buf_size) {
+ char *file_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
+ if (H5Rget_file_name(ref_vp, file_name, buf_size + 1) >= 0) {
+ file_name[buf_size] = '\0';
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "name=%s", file_name);
+ h5tools_str_append(str, "%s", file_name);
+ }
+ HDfree(file_name);
+ }
- region_type = H5Sget_select_type(region);
- if(region_type==H5S_SEL_POINTS)
- h5tools_str_dump_space_points(str, region, info);
- else
- h5tools_str_dump_space_blocks(str, region, info);
+ buf_size = H5Rget_obj_name(ref_vp, H5P_DEFAULT, NULL, 0);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "buf_size=%ld", buf_size);
+ if (buf_size) {
+ char *obj_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
+ if (H5Rget_obj_name(ref_vp, H5P_DEFAULT, obj_name, buf_size + 1) >= 0) {
+ obj_name[buf_size] = '\0';
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "name=%s", obj_name);
+ h5tools_str_append(str, "%s", obj_name);
+ }
+ HDfree(obj_name);
+ }
- h5tools_str_append(str, "}");
+ if (H5Rget_type(ref_vp) == H5R_ATTR) {
+ buf_size = H5Rget_attr_name(ref_vp, NULL, 0);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "buf_size=%ld", buf_size);
+ if (buf_size) {
+ char *attr_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
+ if (H5Rget_attr_name(ref_vp, attr_name, buf_size + 1) >= 0) {
+ attr_name[buf_size] = '\0';
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "name=%s", attr_name);
+ h5tools_str_append(str, "/%s", attr_name);
+ }
+ HDfree(attr_name);
+ }
+ }
+ h5tools_str_append(str, "\"");
- H5Sclose(region);
- } /* end if (region >= 0) */
- H5Dclose(obj);
- } /* end if (obj >= 0) */
+CATCH
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
}
/*-------------------------------------------------------------------------
diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h
index a5045ac..6fdf36a 100644
--- a/tools/lib/h5tools_str.h
+++ b/tools/lib/h5tools_str.h
@@ -36,17 +36,16 @@ H5TOOLS_DLL char *h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_
* new functions needed to display region reference data
*/
H5TOOLS_DLL char *h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info,
- hsize_t elmtno, hsize_t *ptdata, unsigned ndims,
+ hsize_t elmtno, hsize_t *ptdata, unsigned ndims,
hsize_t max_idx[], h5tools_context_t *ctx);
H5TOOLS_DLL void h5tools_str_dump_space_slabs(h5tools_str_t *, hid_t, const h5tool_format_t *, h5tools_context_t *ctx);
H5TOOLS_DLL void h5tools_str_dump_space_blocks(h5tools_str_t *, hid_t, const h5tool_format_t *);
H5TOOLS_DLL void h5tools_str_dump_space_points(h5tools_str_t *, hid_t, const h5tool_format_t *);
-H5TOOLS_DLL void h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info, hid_t container,
- void *vp);
+H5TOOLS_DLL void h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, H5R_ref_t *vp);
H5TOOLS_DLL char *h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info,
hid_t container, hid_t type, void *vp,
h5tools_context_t *ctx);
-H5TOOLS_DLL char *h5tools_str_replace ( const char *string, const char *substr,
- const char *replacement );
+H5TOOLS_DLL char *h5tools_str_replace ( const char *string, const char *substr,
+ const char *replacement );
#endif /* H5TOOLS_STR_H__ */
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index 47ce690..7b47f4d 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -803,7 +803,7 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
/* Find all shared objects */
if((ret_value = h5trav_visit(fid, "/", TRUE, TRUE, find_objs_cb, NULL, info, H5O_INFO_BASIC)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "finding shared objects failed")
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "finding shared objects failed")
done:
/* Release resources */
@@ -1056,7 +1056,7 @@ h5tools_getenv_update_hyperslab_bufsize(void)
errno = 0;
hyperslab_bufsize_mb = HDstrtol(env_str, (char**)NULL, 10);
if (errno != 0 || hyperslab_bufsize_mb <= 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "hyperslab buffer size failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "hyperslab buffer size failed");
/* convert MB to byte */
H5TOOLS_BUFSIZE = (hsize_t)hyperslab_bufsize_mb * 1024 * 1024;
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index 0fa5250..17c16bf 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -28,13 +28,13 @@ extern "C" {
/* ``parallel_print'' information */
#define PRINT_DATA_MAX_SIZE 512
-#define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE*4)
+#define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE*4)
-H5TOOLS_DLLVAR int g_nTasks;
+H5TOOLS_DLLVAR int g_nTasks;
H5TOOLS_DLLVAR unsigned char g_Parallel;
-H5TOOLS_DLLVAR char outBuff[];
+H5TOOLS_DLLVAR char outBuff[];
H5TOOLS_DLLVAR unsigned outBuffOffset;
-H5TOOLS_DLLVAR FILE * overflow_file;
+H5TOOLS_DLLVAR FILE *overflow_file;
/* Maximum size used in a call to malloc for a dataset */
H5TOOLS_DLLVAR hsize_t H5TOOLS_MALLOCSIZE;
@@ -88,8 +88,7 @@ typedef struct long_options {
* this gets returned from get_option */
} long_options;
-H5TOOLS_DLL int get_option(int argc, const char **argv, const char *opt,
- const struct long_options *l_opt);
+H5TOOLS_DLL int get_option(int argc, const char **argv, const char *opt, const struct long_options *l_opt);
/*
* end get_option section
*/
@@ -97,7 +96,7 @@ H5TOOLS_DLL int get_option(int argc, const char **argv, const char *opt,
/*struct taken from the dumper. needed in table struct*/
typedef struct obj_t {
haddr_t objno;
- char *objname;
+ char *objname;
hbool_t displayed; /* Flag to indicate that the object has been displayed */
hbool_t recorded; /* Flag for named datatypes to indicate they were found in the group hierarchy */
} obj_t;
@@ -111,7 +110,7 @@ typedef struct table_t {
/*this struct stores the information that is passed to the find_objs function*/
typedef struct find_objs_t {
- hid_t fid;
+ hid_t fid;
table_t *group_table;
table_t *type_table;
table_t *dset_table;
@@ -120,26 +119,21 @@ typedef struct find_objs_t {
H5TOOLS_DLLVAR unsigned h5tools_nCols; /*max number of columns for outputting */
/* Definitions of useful routines */
-H5TOOLS_DLL void indentation(unsigned);
-H5TOOLS_DLL void print_version(const char *progname);
-H5TOOLS_DLL void parallel_print(const char* format, ... );
-H5TOOLS_DLL herr_t parse_tuple(const char *start,
- int sep,
- char **cpy_out,
- unsigned *nelems,
- char ***ptrs_out);
-H5TOOLS_DLL void error_msg(const char *fmt, ...);
-H5TOOLS_DLL void warn_msg(const char *fmt, ...);
-H5TOOLS_DLL void help_ref_msg(FILE *output);
-H5TOOLS_DLL void free_table(table_t *table);
+H5TOOLS_DLL void indentation(unsigned);
+H5TOOLS_DLL void print_version(const char *progname);
+H5TOOLS_DLL void parallel_print(const char* format, ... );
+H5TOOLS_DLL herr_t parse_tuple(const char *start, int sep, char **cpy_out, unsigned *nelems, char ***ptrs_out);
+H5TOOLS_DLL void error_msg(const char *fmt, ...);
+H5TOOLS_DLL void warn_msg(const char *fmt, ...);
+H5TOOLS_DLL void help_ref_msg(FILE *output);
+H5TOOLS_DLL void free_table(table_t *table);
#ifdef H5DUMP_DEBUG
-H5TOOLS_DLL void dump_tables(find_objs_t *info)
+H5TOOLS_DLL void dump_tables(find_objs_t *info)
#endif /* H5DUMP_DEBUG */
-H5TOOLS_DLL herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
- table_t **dset_table, table_t **type_table);
-H5TOOLS_DLL obj_t *search_obj(table_t *temp, haddr_t objno);
+H5TOOLS_DLL herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table);
+H5TOOLS_DLL obj_t *search_obj(table_t *temp, haddr_t objno);
#ifndef H5_HAVE_TMPFILE
-H5TOOLS_DLL FILE * tmpfile(void);
+H5TOOLS_DLL FILE *tmpfile(void);
#endif
/*************************************************************
@@ -161,30 +155,26 @@ typedef struct {
/* obtain link info from H5tools_get_symlink_info() */
typedef struct {
- H5O_type_t trg_type; /* OUT: target type */
- char *trg_path; /* OUT: target obj path. This must be freed
- * when used with H5tools_get_symlink_info() */
- haddr_t objno; /* OUT: target object address */
- unsigned long fileno; /* OUT: File number that target object is located in */
- H5L_info_t linfo; /* OUT: link info */
- h5tool_opt_t opt; /* IN: options */
+ H5O_type_t trg_type; /* OUT: target type */
+ char *trg_path; /* OUT: target obj path. This must be freed
+ * when used with H5tools_get_symlink_info() */
+ haddr_t objno; /* OUT: target object address */
+ unsigned long fileno; /* OUT: File number that target object is located in */
+ H5L_info_t linfo; /* OUT: link info */
+ h5tool_opt_t opt; /* IN: options */
} h5tool_link_info_t;
/* Definitions of routines */
-H5TOOLS_DLL int H5tools_get_symlink_info(hid_t file_id, const char * linkpath,
- h5tool_link_info_t *link_info, hbool_t get_obj_type);
+H5TOOLS_DLL int H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info, hbool_t get_obj_type);
H5TOOLS_DLL const char *h5tools_getprogname(void);
-H5TOOLS_DLL void h5tools_setprogname(const char*progname);
-H5TOOLS_DLL int h5tools_getstatus(void);
-H5TOOLS_DLL void h5tools_setstatus(int d_status);
+H5TOOLS_DLL void h5tools_setprogname(const char*progname);
+H5TOOLS_DLL int h5tools_getstatus(void);
+H5TOOLS_DLL void h5tools_setstatus(int d_status);
H5TOOLS_DLL int h5tools_getenv_update_hyperslab_bufsize(void);
-H5TOOLS_DLL int h5tools_set_configured_fapl(hid_t fapl_id,
- const char vfd_name[],
- void *fapl_t_ptr);
+H5TOOLS_DLL int h5tools_set_configured_fapl(hid_t fapl_id, const char vfd_name[], void *fapl_t_ptr);
#ifdef H5_HAVE_ROS3_VFD
-H5TOOLS_DLL int h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa,
- const char **values);
+H5TOOLS_DLL int h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values);
#endif /* H5_HAVE_ROS3_VFD */
#ifdef __cplusplus
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index eb7b56d..4f4f42a 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -259,7 +259,7 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
/* Get info for starting object */
if(H5Oget_info_by_name2(file_id, grp_name, &oinfo, fields, H5P_DEFAULT) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info_by_name failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info_by_name failed");
/* Visit the starting object */
if(visit_start && visitor->visit_obj)
@@ -289,12 +289,12 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
if(recurse) {
/* Visit all links in group, recursively */
if(H5Lvisit_by_name(file_id, grp_name, trav_index_by, trav_index_order, traverse_cb, &udata, H5P_DEFAULT) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lvisit_by_name failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lvisit_by_name failed");
} /* end if */
else {
/* Iterate over links in group */
if(H5Literate_by_name(file_id, grp_name, trav_index_by, trav_index_order, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Literate_by_name failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Literate_by_name failed");
} /* end else */
/* Free visited addresses table */
@@ -439,7 +439,7 @@ h5trav_getinfo(hid_t file_id, trav_info_t *info)
/* Traverse all objects in the file, visiting each object & link */
if(traverse(file_id, "/", TRUE, TRUE, &info_visitor, H5O_INFO_BASIC) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
done:
return ret_value;
@@ -605,7 +605,7 @@ h5trav_gettable(hid_t fid, trav_table_t *table)
/* Traverse all objects in the file, visiting each object & link */
if(traverse(fid, "/", TRUE, TRUE, &table_visitor, H5O_INFO_BASIC) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
done:
return ret_value;
@@ -1031,7 +1031,7 @@ h5trav_print(hid_t fid)
/* Traverse all objects in the file, visiting each object & link */
if(traverse(fid, "/", TRUE, TRUE, &print_visitor, H5O_INFO_BASIC) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
done:
return ret_value;
@@ -1062,7 +1062,7 @@ h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start,
/* Traverse all objects in the file, visiting each object & link */
if(traverse(fid, grp_name, visit_start, recurse, &visitor, fields) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
done:
return ret_value;
@@ -1089,7 +1089,7 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co
visited->nalloc = MAX(1, visited->nalloc * 2);
if(NULL == (tmp_ptr = HDrealloc(visited->objs, visited->nalloc * sizeof(symlink_trav_path_t))))
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure realloc failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure realloc failed");
visited->objs = (symlink_trav_path_t *)tmp_ptr;
} /* end if */
@@ -1103,7 +1103,7 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co
if(type == H5L_TYPE_EXTERNAL) {
if(NULL == (visited->objs[idx].file = HDstrdup(file))) {
visited->nused--;
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure name allocation failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure name allocation failed");
} /* end if */
} /* end if */
@@ -1111,7 +1111,7 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co
visited->nused--;
if(visited->objs[idx].file)
HDfree (visited->objs[idx].file);
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure path allocation failed");
+ H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure path allocation failed");
} /* end if */
done: