summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-07-15 16:20:16 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-07-15 16:20:16 (GMT)
commitbac0fc6309aaf777d4b6d093cf027dce3ecfb58c (patch)
tree1b944edb35a01a5bb8bb72445f82afb52317f06e /tools/lib
parent900e75544e214a82de3b7fcdbc083ee71d484892 (diff)
downloadhdf5-bac0fc6309aaf777d4b6d093cf027dce3ecfb58c.zip
hdf5-bac0fc6309aaf777d4b6d093cf027dce3ecfb58c.tar.gz
hdf5-bac0fc6309aaf777d4b6d093cf027dce3ecfb58c.tar.bz2
Tools refactor
Move error_stack setup to tools library Add structure for h5dump properties Eliminate duplicated h5diff functions Use properties structure in place of argument lists.
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff.c179
-rw-r--r--tools/lib/h5diff.h176
-rw-r--r--tools/lib/h5diff_array.c4436
-rw-r--r--tools/lib/h5diff_attr.c164
-rw-r--r--tools/lib/h5diff_dset.c672
-rw-r--r--tools/lib/h5tools.c140
-rw-r--r--tools/lib/h5tools.h67
-rw-r--r--tools/lib/h5tools_dump.c525
-rw-r--r--tools/lib/h5tools_dump.h80
-rw-r--r--tools/lib/h5tools_str.c74
-rw-r--r--tools/lib/h5tools_str.h5
-rw-r--r--tools/lib/io_timer.c1
12 files changed, 2778 insertions, 3741 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index 8b6ace9..96c2d32 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -29,7 +29,7 @@
H5_ATTR_PURE int
print_objname (diff_opt_t * opts, hsize_t nfound)
{
- return ((opts->m_verbose || nfound) && !opts->m_quiet) ? 1 : 0;
+ return ((opts->mode_verbose || nfound) && !opts->mode_quiet) ? 1 : 0;
}
/*-------------------------------------------------------------------------
@@ -45,7 +45,7 @@ do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_op
* displaying any object or symbolic links. This improves
* readability of the output.
*/
- if (opts->m_verbose_level >= 1)
+ if (opts->mode_verbose_level >= 1)
parallel_print("\n");
parallel_print("%-7s: <%s> and <%s>\n", OBJ, path1, path2);
}
@@ -74,7 +74,7 @@ do_print_attrname (const char *attr, const char *path1, const char *path2)
static int
print_warn(diff_opt_t *opts)
{
- return ((opts->m_verbose)) ? 1: 0;
+ return ((opts->mode_verbose)) ? 1: 0;
}
@@ -141,7 +141,7 @@ is_valid_options(diff_opt_t *opts)
/*-----------------------------------------------
* no -q(quiet) with -v (verbose) or -r (report) */
- if(opts->m_quiet && (opts->m_verbose || opts->m_report)) {
+ if(opts->mode_quiet && (opts->mode_verbose || opts->mode_report)) {
parallel_print("Error: -q (quiet mode) cannot be added to verbose or report modes\n");
opts->err_stat = H5DIFF_ERR;
H5TOOLS_GOTO_DONE(0);
@@ -169,9 +169,9 @@ done:
* 0 - not excluded path
*------------------------------------------------------------------------*/
static int
-is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *opts)
+is_exclude_path (char *path, h5trav_type_t type, diff_opt_t *opts)
{
- struct exclude_path_list * exclude_path_ptr;
+ struct exclude_path_list *exclude_path_ptr;
int ret_cmp;
int ret_value = 0;
@@ -210,7 +210,7 @@ is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *opts)
if (ret_cmp == 0) { /* found matching object */
/* excluded non-group object */
ret_value = 1;
- /* remember the type of this maching object.
+ /* remember the type of this matching object.
* if it's group, it can be used for excluding its member
* objects in this while() loop */
exclude_path_ptr->obj_type = type;
@@ -224,6 +224,71 @@ done:
return ret_value;
}
+/*-------------------------------------------------------------------------
+ * Function: is_exclude_attr
+ *
+ * Purpose: check if 'paths' are part of exclude path list
+ *
+ * Return:
+ * 1 - excluded path
+ * 0 - not excluded path
+ *------------------------------------------------------------------------*/
+static int
+is_exclude_attr (char *path, h5trav_type_t type, diff_opt_t *opts)
+{
+ struct exclude_path_list *exclude_ptr;
+ int ret_cmp;
+ int ret_value = 0;
+
+ /* check if exclude attr option is given */
+ if (!opts->exclude_attr_path)
+ H5TOOLS_GOTO_DONE(0);
+
+ /* assign to local exclude list pointer */
+ exclude_ptr = opts->exclude_attr;
+
+ /* search objects in exclude list */
+ while (NULL != exclude_ptr) {
+ /* if exclude path is is group, exclude its members as well */
+ if (exclude_ptr->obj_type == H5TRAV_TYPE_GROUP) {
+ ret_cmp = HDstrncmp(exclude_ptr->obj_path, path,
+ HDstrlen(exclude_ptr->obj_path));
+ if (ret_cmp == 0) { /* found matching members */
+ size_t len_grp;
+
+ /* check if given path belong to an excluding group, if so
+ * exclude it as well.
+ * This verifies if “/grp1/dset1” is only under “/grp1”, but
+ * not under “/grp1xxx/” group.
+ */
+ len_grp = HDstrlen(exclude_ptr->obj_path);
+ if (path[len_grp] == '/') {
+ /* belong to excluded group! */
+ ret_value = 1;
+ break; /* while */
+ }
+ }
+ }
+ /* exclude target is not group, just exclude the object */
+ else {
+ ret_cmp = HDstrcmp(exclude_ptr->obj_path, path);
+ if (ret_cmp == 0) { /* found matching object */
+ /* excluded non-group object */
+ ret_value = 1;
+ /* remember the type of this matching object.
+ * if it's group, it can be used for excluding its member
+ * objects in this while() loop */
+ exclude_ptr->obj_type = type;
+ break; /* while */
+ }
+ }
+ exclude_ptr = exclude_ptr->next;
+ }
+
+done:
+ return ret_value;
+}
+
/*-------------------------------------------------------------------------
* Function: free_exclude_path_list
@@ -243,6 +308,25 @@ free_exclude_path_list(diff_opt_t *opts)
}
}
+
+/*-------------------------------------------------------------------------
+ * Function: free_exclude_attr_list
+ *
+ * Purpose: free exclude object attribute list from diff options
+ *------------------------------------------------------------------------*/
+static void
+free_exclude_attr_list(diff_opt_t *opts)
+{
+ struct exclude_path_list *curr = opts->exclude_attr;
+ struct exclude_path_list *next;
+
+ while (NULL != curr) {
+ next = curr->next;
+ HDfree(curr);
+ curr = next;
+ }
+}
+
/*-------------------------------------------------------------------------
* Function: build_match_list
*
@@ -288,6 +372,7 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2
* All the objects belong to given groups are the candidates.
* So prepare to compare paths without the group names.
*/
+ H5TOOLS_DEBUG("objname1 = %s objname2 = %s ", objname1, objname2);
/* if obj1 is not root */
if (HDstrcmp (objname1,"/") != 0)
@@ -572,8 +657,8 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char
*-------------------------------------------------------------------------
*/
/* open file 1 */
- if (opts->custom_vol_1) {
- if((fapl1_id = h5tools_get_fapl(H5P_DEFAULT, &(opts->vol_info_1), NULL)) < 0 ) {
+ if (opts->custom_vol[0]) {
+ if((fapl1_id = h5tools_get_fapl(H5P_DEFAULT, &(opts->vol_info[0]), NULL)) < 0 ) {
parallel_print("h5diff: unable to create fapl for input file\n");
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "unable to create input fapl\n");
}
@@ -587,8 +672,8 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char
/* open file 2 */
- if (opts->custom_vol_2) {
- if((fapl2_id = h5tools_get_fapl(H5P_DEFAULT, &(opts->vol_info_2), NULL)) < 0 ) {
+ if (opts->custom_vol[1]) {
+ if((fapl2_id = h5tools_get_fapl(H5P_DEFAULT, &(opts->vol_info[1]), NULL)) < 0 ) {
parallel_print("h5diff: unable to create fapl for output file\n");
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "unable to create output fapl\n");
}
@@ -627,6 +712,7 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char
}
else
obj1fullname = HDstrdup(objname1);
+ H5TOOLS_DEBUG("obj1fullname = %s", obj1fullname);
/* make the given object2 fullpath, start with "/" */
if (HDstrncmp(objname2, "/", 1)) {
@@ -644,6 +730,7 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char
}
else
obj2fullname = HDstrdup(objname2);
+ H5TOOLS_DEBUG("obj2fullname = %s", obj2fullname);
/*----------------------------------------------------------
* check if obj1 is root, group, single object or symlink
@@ -777,12 +864,12 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char
H5TOOLS_DEBUG("h5diff ... dangling link");
if (opts->no_dangle_links) {
/* treat dangling link as error */
- if(opts->m_verbose)
+ if(opts->mode_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", obj1fullname);
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "treat dangling link as error");
}
else {
- if(opts->m_verbose)
+ if(opts->mode_verbose)
parallel_print("obj1 <%s> is a dangling link.\n", obj1fullname);
if (l_ret1 != 0 || l_ret2 != 0) {
nfound++;
@@ -818,12 +905,12 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char
H5TOOLS_DEBUG("h5diff ... dangling link");
if (opts->no_dangle_links) {
/* treat dangling link as error */
- if(opts->m_verbose)
+ if(opts->mode_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", obj2fullname);
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "treat dangling link as error");
}
else {
- if(opts->m_verbose)
+ if(opts->mode_verbose)
parallel_print("obj2 <%s> is a dangling link.\n", obj2fullname);
if (l_ret1 != 0 || l_ret2 != 0) {
nfound++;
@@ -857,8 +944,8 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char
* comparing details of same objects.
*/
- if(!(opts->m_verbose || opts->m_report)) {
- H5TOOLS_DEBUG("h5diff NOT (opts->m_verbose || opts->m_report)");
+ if(!(opts->mode_verbose || opts->mode_report)) {
+ H5TOOLS_DEBUG("h5diff NOT (opts->mode_verbose || opts->mode_report)");
/* if no danglink links */
if (l_ret1 > 0 && l_ret2 > 0)
if (h5tools_is_obj_same(file1_id, obj1fullname, file2_id, obj2fullname) != 0)
@@ -924,9 +1011,14 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char
/*------------------------------------------------------
* print the list
*/
- if(opts->m_verbose) {
+ if(opts->mode_verbose) {
unsigned u;
+ if(opts->mode_verbose_level > 2) {
+ parallel_print("file1: %s\n", fname1);
+ parallel_print("file2: %s\n", fname2);
+ }
+
parallel_print("\n");
/* if given objects is group under root */
if (HDstrcmp (obj1fullname,"/") || HDstrcmp (obj2fullname,"/"))
@@ -947,6 +1039,7 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char
nfound = diff_match(file1_id, obj1fullname, info1_lp,
file2_id, obj2fullname, info2_lp,
match_list, opts);
+ H5TOOLS_DEBUG("diff_match nfound: %d - errstat:%d", nfound, opts->err_stat);
done:
opts->err_stat = opts->err_stat | ret_value;
@@ -1047,12 +1140,14 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
*-------------------------------------------------------------------------
*/
+ H5TOOLS_DEBUG("exclude_path opts->contents:%d", opts->contents);
/* not valid compare used when --exclude-path option is used */
if (!opts->exclude_path) {
/* number of different objects */
if (info1->nused != info2->nused) {
opts->contents = 0;
}
+ H5TOOLS_DEBUG("opts->exclude_path opts->contents:%d", opts->contents);
}
/* objects in one file and not the other */
@@ -1061,6 +1156,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
opts->contents = 0;
break;
}
+ H5TOOLS_DEBUG("table->nobjs[%d] opts->contents:%d", i, opts->contents);
}
/*-------------------------------------------------------------------------
@@ -1133,9 +1229,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
opts->cmn_objs = 1;
if(!g_Parallel) {
H5TOOLS_DEBUG("diff paths - errstat:%d", opts->err_stat);
- nfound += diff(file1_id, obj1_fullpath,
- file2_id, obj2_fullpath,
- opts, &argdata);
+ nfound += diff(file1_id, obj1_fullpath, file2_id, obj2_fullpath, opts, &argdata);
} /* end if */
#ifdef H5_HAVE_PARALLEL
else {
@@ -1380,6 +1474,8 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
opts->err_stat = opts->err_stat | ret_value;
+ free_exclude_attr_list (opts);
+
/* free table */
if (table)
trav_table_free(table);
@@ -1404,7 +1500,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
*-------------------------------------------------------------------------
*/
hsize_t
-diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_opt_t * opts, diff_args_t *argdata)
+diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_opt_t *opts, diff_args_t *argdata)
{
int status = -1;
hid_t dset1_id = H5I_INVALID_HID;
@@ -1453,7 +1549,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
if (status == 0) {
if (opts->no_dangle_links) {
/* dangling link is error */
- if(opts->m_verbose)
+ if(opts->mode_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", path1);
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "dangling link is error");
}
@@ -1468,7 +1564,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
if (status == 0) {
if (opts->no_dangle_links) {
/* dangling link is error */
- if(opts->m_verbose)
+ if(opts->mode_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", path2);
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "dangling link is error");
}
@@ -1494,11 +1590,11 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
/* if objects are not the same type */
if (argdata->type[0] != argdata->type[1]) {
H5TOOLS_DEBUG("diff objects are not the same");
- if (opts->m_verbose||opts->m_list_not_cmp) {
+ if (opts->mode_verbose||opts->mode_list_not_cmp) {
parallel_print("Not comparable: <%s> is of type %s and <%s> is of type %s\n",
- path1, get_type(argdata->type[0]),
- path2, get_type(argdata->type[1]));
+ path1, get_type(argdata->type[0]), path2, get_type(argdata->type[1]));
}
+
opts->not_cmp = 1;
/* TODO: will need to update non-comparable is different
* opts->contents = 0;
@@ -1523,7 +1619,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
object_type == H5TRAV_TYPE_GROUP);
if (opts->follow_links || is_hard_link) {
/* print information is only verbose option is used */
- if(opts->m_verbose || opts->m_report) {
+ if(opts->mode_verbose || opts->mode_report) {
switch(object_type) {
case H5TRAV_TYPE_DATASET:
do_print_objname("dataset", path1, path2, opts);
@@ -1552,7 +1648,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
} /* switch(type)*/
print_found(nfound);
- } /* if(opts->m_verbose || opts->m_report) */
+ } /* if(opts->mode_verbose || opts->mode_report) */
/* exact same, so comparison is done */
H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR);
@@ -1570,15 +1666,16 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 failed");
if((dset2_id = H5Dopen2(file2_id, path2, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 failed");
+ H5TOOLS_DEBUG("paths: %s - %s", path1, path2);
/* verbose (-v) and report (-r) mode */
- if(opts->m_verbose || opts->m_report) {
+ if(opts->mode_verbose || opts->mode_report) {
do_print_objname("dataset", path1, path2, opts);
H5TOOLS_DEBUG("call diff_dataset 1:%s 2:%s ", path1, path2);
nfound = diff_dataset(file1_id, file2_id, path1, path2, opts);
print_found(nfound);
}
/* quiet mode (-q), just count differences */
- else if(opts->m_quiet) {
+ else if(opts->mode_quiet) {
nfound = diff_dataset(file1_id, file2_id, path1, path2, opts);
}
/* the rest (-c, none, ...) */
@@ -1598,7 +1695,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
* referenced object
*---------------------------------------------------------
*/
- if(path1) {
+ if(path1 && !is_exclude_attr(path1, object_type, opts)) {
H5TOOLS_DEBUG( "call diff_attr 1:%s 2:%s ", path1, path2);
nfound += diff_attr(dset1_id, dset2_id, path1, path2, opts);
}
@@ -1630,7 +1727,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
do_print_objname("datatype", path1, path2, opts);
/* always print the number of differences found in verbose mode */
- if(opts->m_verbose)
+ if(opts->mode_verbose)
print_found(nfound);
/*-----------------------------------------------------------------
@@ -1639,7 +1736,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
* referenced object
*-----------------------------------------------------------------
*/
- if(path1) {
+ if(path1 && !is_exclude_attr(path1, object_type, opts)) {
H5TOOLS_DEBUG("call diff_attr 1:%s 2:%s ", path1, path2);
nfound += diff_attr(type1_id, type2_id, path1, path2, opts);
}
@@ -1660,7 +1757,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
do_print_objname("group", path1, path2, opts);
/* always print the number of differences found in verbose mode */
- if(opts->m_verbose)
+ if(opts->mode_verbose)
print_found(nfound);
if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0)
@@ -1674,7 +1771,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
* referenced object
*-----------------------------------------------------------------
*/
- if(path1) {
+ if(path1 && !is_exclude_attr(path1, object_type, opts)) {
H5TOOLS_DEBUG("call diff_attr 1:%s 2:%s ", path1, path2);
nfound += diff_attr(grp1_id, grp2_id, path1, path2, opts);
}
@@ -1702,7 +1799,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
do_print_objname("link", path1, path2, opts);
/* always print the number of differences found in verbose mode */
- if(opts->m_verbose)
+ if(opts->mode_verbose)
print_found(nfound);
}
break;
@@ -1752,14 +1849,14 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
} /* end else */
/* always print the number of differences found in verbose mode */
- if(opts->m_verbose)
+ if(opts->mode_verbose)
print_found(nfound);
}
break;
case H5TRAV_TYPE_UNKNOWN:
default:
- if(opts->m_verbose)
+ if(opts->mode_verbose)
parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n",
path1, path2, get_type(object_type) );
opts->not_cmp = 1;
@@ -1781,7 +1878,7 @@ done:
}
/* path1 is dangling link */
else if (is_dangle_link1) {
- if(opts->m_verbose)
+ if(opts->mode_verbose)
parallel_print("obj1 <%s> is a dangling link.\n", path1);
nfound++;
if(print_objname(opts, nfound))
@@ -1789,7 +1886,7 @@ done:
}
/* path2 is dangling link */
else if (is_dangle_link2) {
- if(opts->m_verbose)
+ if(opts->mode_verbose)
parallel_print("obj2 <%s> is a dangling link.\n", path2);
nfound++;
if(print_objname(opts, nfound))
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index 37eb775..c3c111f 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -18,23 +18,6 @@
#include "h5tools.h"
#include "h5trav.h"
-/*
- * Debug printf macros. The prefix allows output filtering by test scripts.
- */
-#ifdef H5DIFF_DEBUG
-#define h5difftrace(x) HDfprintf(stderr, "h5diff debug: " x)
-#define h5diffdebug2(x1, x2) HDfprintf(stderr, "h5diff debug: " x1, x2)
-#define h5diffdebug3(x1, x2, x3) HDfprintf(stderr, "h5diff debug: " x1, x2, x3)
-#define h5diffdebug4(x1, x2, x3, x4) HDfprintf(stderr, "h5diff debug: " x1, x2, x3, x4)
-#define h5diffdebug5(x1, x2, x3, x4, x5) HDfprintf(stderr, "h5diff debug: " x1, x2, x3, x4, x5)
-#else
-#define h5difftrace(x)
-#define h5diffdebug2(x1, x2)
-#define h5diffdebug3(x1, x2, x3)
-#define h5diffdebug4(x1, x2, x3, x4)
-#define h5diffdebug5(x1, x2, x3, x4, x5)
-#endif
-
#define MAX_FILENAME 1024
/*-------------------------------------------------------------------------
@@ -58,6 +41,7 @@ struct exclude_path_list {
struct exclude_path_list *next;
};
+
/* Enumeration value for keeping track of whether an error occurred or differences were found */
typedef enum {
H5DIFF_NO_ERR, /* No error occurred */
@@ -66,31 +50,46 @@ typedef enum {
} diff_err_t;
typedef struct {
- int m_quiet; /* quiet mode: no output at all */
- int m_report; /* report mode: print the data */
- int m_verbose; /* verbose mode: print the data, list of objcets, warnings */
- int m_verbose_level; /* control verbose details */
- int d; /* delta, absolute value to compare */
- double delta; /* delta value */
- int p; /* relative error to compare*/
- int use_system_epsilon; /* flag to use system epsilon (1 or 0) */
- double percent; /* relative error value */
- int n; /* count, compare up to count */
- hsize_t count; /* count value */
- hbool_t follow_links; /* follow symbolic links */
- int no_dangle_links; /* return error when find dangling link */
- diff_err_t err_stat; /* an error ocurred (2, error, 1, differences, 0, no error) */
- int cmn_objs; /* do we have common objects */
- int not_cmp; /* are the objects comparable */
- int contents; /* equal contents */
- int do_nans; /* consider Nans while diffing floats */
- int m_list_not_cmp; /* list not comparable messages */
- int exclude_path; /* exclude path to an object */
- struct exclude_path_list * exclude; /* keep exclude path list */
- h5tools_vol_info_t vol_info_1; /* VOL information for input file */
- h5tools_vol_info_t vol_info_2; /* VOL information for output file */
- hbool_t custom_vol_1; /* Using a custom input VOL? */
- hbool_t custom_vol_2; /* Using a custom output VOL? */
+ int mode_quiet; /* quiet mode: no output at all */
+ int mode_report; /* report mode: print the data */
+ int mode_verbose; /* verbose mode: print the data, list of objcets, warnings */
+ int mode_verbose_level; /* control verbose details */
+ int mode_list_not_cmp; /* list not comparable messages */
+ int print_header; /* print header */
+ int print_percentage; /* print percentage */
+ int delta_bool; /* delta, absolute value to compare */
+ double delta; /* delta value */
+ int use_system_epsilon; /* flag to use system epsilon (1 or 0) */
+ int percent_bool; /* relative error to compare*/
+ double percent; /* relative error value */
+ hbool_t follow_links; /* follow symbolic links */
+ int no_dangle_links; /* return error when find dangling link */
+ int cmn_objs; /* do we have common objects */
+ int not_cmp; /* are the objects comparable */
+ int contents; /* equal contents */
+ int do_nans; /* consider Nans while diffing floats */
+ int exclude_path; /* exclude path to an object */
+ int exclude_attr_path; /* exclude path to an object */
+ struct exclude_path_list *exclude; /* keep exclude path list */
+ struct exclude_path_list *exclude_attr; /* keep exclude attribute list */
+ int count_bool; /* count, compare up to count */
+ hsize_t count; /* count value */
+ diff_err_t err_stat; /* an error ocurred (2, error, 1, differences, 0, no error) */
+ hsize_t nelmts; /* total number of elements */
+ hsize_t hs_nelmts; /* number of elements to read at a time*/
+ int rank; /* dimensionality */
+ size_t m_size; /* m_size for diff */
+ hid_t m_tid; /* m_tid for diff */
+ hsize_t dims[H5S_MAX_RANK]; /* dimensions of object */
+ hsize_t p_min_idx[H5S_MAX_RANK]; /* min selected index */
+ hsize_t p_max_idx[H5S_MAX_RANK]; /* max selected index */
+ hsize_t acc[H5S_MAX_RANK]; /* accumulator position */
+ hsize_t pos[H5S_MAX_RANK]; /* matrix position */
+ hsize_t sm_pos[H5S_MAX_RANK]; /* stripmine position */
+ char *obj_name[2]; /* name for object */
+ struct subset_t *sset[2]; /* subsetting parameters */
+ h5tools_vol_info_t vol_info[2]; /* VOL information for input file, output file */
+ hbool_t custom_vol[2]; /* Using a custom input, output VOL? */
} diff_opt_t;
@@ -103,18 +102,9 @@ typedef struct {
extern "C" {
#endif
-H5TOOLS_DLL hsize_t h5diff(const char *fname1,
- const char *fname2,
- const char *objname1,
- const char *objname2,
- diff_opt_t *opts);
+H5TOOLS_DLL hsize_t h5diff(const char *fname1, const char *fname2, const char *objname1, const char *objname2, diff_opt_t *opts);
-H5TOOLS_DLL hsize_t diff( hid_t file1_id,
- const char *path1,
- hid_t file2_id,
- const char *path2,
- diff_opt_t *opts,
- diff_args_t *argdata);
+H5TOOLS_DLL hsize_t diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_opt_t *opts, diff_args_t *argdata);
#ifdef H5_HAVE_PARALLEL
H5TOOLS_DLL void phdiff_dismiss_workers(void);
@@ -133,63 +123,29 @@ H5TOOLS_DLL void print_manager_output(void);
*/
-hsize_t diff_dataset( hid_t file1_id,
- hid_t file2_id,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *opts);
-
-hsize_t diff_datasetid( hid_t dset1_id,
- hid_t dset2_id,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *opts);
-
-
-hsize_t diff_match( hid_t file1_id, const char *grp1, trav_info_t *info1,
- hid_t file2_id, const char *grp2, trav_info_t *info2,
- trav_table_t *table, diff_opt_t *opts );
-
-hsize_t diff_array( void *_mem1,
- void *_mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- diff_opt_t *opts,
- const char *name1,
- const char *name2,
- hid_t m_type,
- hid_t container1_id,
- hid_t container2_id); /* dataset where the reference came from*/
-
-
-int diff_can_type( hid_t f_type1, /* file data type */
- hid_t f_type2, /* file data type */
- int rank1,
- int rank2,
- hsize_t *dims1,
- hsize_t *dims2,
- hsize_t *maxdim1,
- hsize_t *maxdim2,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *opts,
- int is_compound);
-
-hsize_t diff_attr_data(hid_t attr1_id,
- hid_t attr2_id,
- const char *attr1_name,
- const char *attr2_name,
- const char *path1,
- const char *path2,
- diff_opt_t *opts);
-
-hsize_t diff_attr(hid_t loc1_id,
- hid_t loc2_id,
- const char *path1,
- const char *path2,
- diff_opt_t *opts);
+hsize_t diff_dataset(hid_t file1_id, hid_t file2_id,
+ const char *obj1_name, const char *obj2_name, diff_opt_t *opts);
+
+hsize_t diff_datasetid(hid_t dset1_id, hid_t dset2_id,
+ const char *obj1_name, const char *obj2_name, diff_opt_t *opts);
+
+
+hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
+ hid_t file2_id, const char *grp2, trav_info_t *info2,
+ trav_table_t *table, diff_opt_t *opts);
+
+hsize_t diff_array(void *_mem1, void *_mem2,
+ diff_opt_t *opts, hid_t container1_id, hid_t container2_id);
+
+int diff_can_type(hid_t f_type1, hid_t f_type2, int rank1, int rank2,
+ hsize_t *dims1, hsize_t *dims2, hsize_t *maxdim1, hsize_t *maxdim2,
+ diff_opt_t *opts, int is_compound);
+
+hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const char *name2,
+ const char *path1, const char *path2, diff_opt_t *opts);
+
+hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id,
+ const char *path1, const char *path2, diff_opt_t *opts);
/*-------------------------------------------------------------------------
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 52bae51..9b680ec 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -132,97 +132,39 @@ typedef struct mcomp_t {
* local prototypes
*-------------------------------------------------------------------------
*/
-static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id,
- hid_t region2_id, diff_opt_t *opts);
static hbool_t all_zero(const void *_mem, size_t size);
static int ull2float(unsigned long long ull_value, float *f_value);
-static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u,
- int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos,
- diff_opt_t *opts, const char *obj1, const char *obj2, int *ph);
-static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2,
- hsize_t i, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos,
- diff_opt_t *opts, const char *obj1, const char *obj2, int *ph);
+static hsize_t character_compare(char *mem1, char *mem2, hsize_t elemtno, ssize_t u, diff_opt_t *opts);
+static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, hsize_t elemtno, diff_opt_t *opts);
static hbool_t equal_float(float value, float expected, diff_opt_t *opts);
static hbool_t equal_double(double value, double expected, diff_opt_t *opts);
#if H5_SIZEOF_LONG_DOUBLE !=0
static hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts);
#endif
+
static int print_data(diff_opt_t *opts);
-static void print_pos(int *ph, int pp, hsize_t curr_pos, hsize_t *acc,
- hsize_t *pos, int rank, hsize_t *dims, const char *obj1,
- const char *obj2);
-static void print_char_pos(int *ph, int pp, hsize_t curr_pos, size_t u,
- hsize_t *acc, hsize_t *pos, int rank, hsize_t *dims, const char *obj1,
- const char *obj2);
+static void print_pos(diff_opt_t *opts, hsize_t elemtno, ssize_t u);
static void h5diff_print_char(char ch);
-static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx,
- int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos,
- diff_opt_t *opts, const char *obj1, const char *obj2,
- hid_t container1_id, hid_t container2_id, /*where the reference came from*/
- int *ph, /*print header */
- mcomp_t *members); /*compound members */
-static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph);
-static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph);
+
+static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id, diff_opt_t *opts);
+static hsize_t diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts,
+ hid_t container1_id, hid_t container2_id, mcomp_t *members);
+/* element diffs */
+static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
+static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
#if H5_SIZEOF_LONG_DOUBLE !=0
-static hsize_t diff_ldouble(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *opts,
- const char *obj1,
- const char *obj2,
- int *ph);
+static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
#endif
-static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph);
-static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph);
-static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph);
-static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph);
-static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph);
-static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph);
-static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph);
-static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph);
-static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph);
-static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph);
+static hsize_t diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
+static hsize_t diff_uchar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
+static hsize_t diff_short_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
+static hsize_t diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
+static hsize_t diff_int_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
+static hsize_t diff_uint_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
+static hsize_t diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
+static hsize_t diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
+static hsize_t diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
+static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
/*-------------------------------------------------------------------------
* NaN detection
@@ -260,26 +202,24 @@ static void close_member_types(mcomp_t *members);
*-------------------------------------------------------------------------
*/
-hsize_t diff_array(void *_mem1, void *_mem2, hsize_t nelmts, hsize_t hyper_start,
- int rank, hsize_t *dims, diff_opt_t *opts, const char *name1, const char *name2,
- hid_t m_type, hid_t container1_id, hid_t container2_id)
+hsize_t
+diff_array(void *_mem1, void *_mem2, diff_opt_t *opts, hid_t container1_id, hid_t container2_id)
{
hsize_t nfound = 0; /* number of differences found */
size_t size; /* size of datum */
unsigned char *mem1 = (unsigned char*) _mem1;
unsigned char *mem2 = (unsigned char*) _mem2;
- hsize_t acc[32]; /* accumulator position */
- hsize_t pos[32]; /* matrix position */
- int ph = 1; /* print header */
hsize_t i;
int j;
mcomp_t members;
H5T_class_t type_class;
- H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
+ H5TOOLS_START_DEBUG(" - rank:%d hs_nelmts:%ld errstat:%d", opts->rank, opts->hs_nelmts, opts->err_stat);
+ opts->print_header = 1; /* enable print header */
+
/* get the size. */
- size = H5Tget_size(m_type);
- type_class = H5Tget_class(m_type);
+ size = H5Tget_size(opts->m_tid);
+ type_class = H5Tget_class(opts->m_tid);
/* Fast comparison first for atomic type by memcmp().
* It is OK not to list non-atomic type here because it will not be caught
@@ -289,24 +229,18 @@ hsize_t diff_array(void *_mem1, void *_mem2, hsize_t nelmts, hsize_t hyper_start
type_class != H5T_COMPOUND &&
type_class != H5T_STRING &&
type_class != H5T_VLEN &&
- HDmemcmp(mem1, mem2, size*nelmts) == 0)
+ HDmemcmp(mem1, mem2, size * opts->hs_nelmts) == 0) {
+ H5TOOLS_ENDDEBUG(":Fast comparison - errstat:%d", opts->err_stat);
return 0;
-
- if (rank > 0) {
- acc[rank - 1] = 1;
- for (j = (rank - 2); j >= 0; j--) {
- acc[j] = acc[j + 1] * dims[j + 1];
- }
- for (j = 0; j < rank; j++)
- pos[j] = 0;
}
- H5TOOLS_DEBUG("diff_array type_class:%d", type_class);
+ H5TOOLS_DEBUG("type_class:%d", type_class);
switch (type_class) {
case H5T_NO_CLASS:
case H5T_TIME:
case H5T_NCLASSES:
default:
+ H5TOOLS_DEBUG("type_class:INVALID");
HDassert(0);
break;
@@ -315,37 +249,142 @@ hsize_t diff_array(void *_mem1, void *_mem2, hsize_t nelmts, hsize_t hyper_start
*-------------------------------------------------------------------------
*/
case H5T_FLOAT:
- if (H5Tequal(m_type, H5T_NATIVE_FLOAT))
- nfound = diff_float(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
- else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE))
- nfound = diff_double(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
+ H5TOOLS_DEBUG("type_class:H5T_FLOAT");
+ if (H5Tequal(opts->m_tid, H5T_NATIVE_FLOAT)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_float_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(float);
+ mem2 += sizeof(float);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_DOUBLE)){
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_double_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(double);
+ mem2 += sizeof(double);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
#if H5_SIZEOF_LONG_DOUBLE != 0
- else if (H5Tequal(m_type, H5T_NATIVE_LDOUBLE))
- nfound = diff_ldouble(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_LDOUBLE)) {
+ for ( i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_ldouble_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(long double);
+ mem2 += sizeof(long double);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
#endif
break;
case H5T_INTEGER:
- if (H5Tequal(m_type, H5T_NATIVE_SCHAR))
- nfound = diff_schar(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
- else if (H5Tequal(m_type, H5T_NATIVE_UCHAR))
- nfound = diff_uchar(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
- else if (H5Tequal(m_type, H5T_NATIVE_SHORT))
- nfound = diff_short(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
- else if (H5Tequal(m_type, H5T_NATIVE_USHORT))
- nfound = diff_ushort(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
- else if (H5Tequal(m_type, H5T_NATIVE_INT))
- nfound = diff_int(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
- else if (H5Tequal(m_type, H5T_NATIVE_UINT))
- nfound = diff_uint(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
- else if (H5Tequal(m_type, H5T_NATIVE_LONG))
- nfound = diff_long(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
- else if (H5Tequal(m_type, H5T_NATIVE_ULONG))
- nfound = diff_ulong(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
- else if (H5Tequal(m_type, H5T_NATIVE_LLONG))
- nfound = diff_llong(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
- else if (H5Tequal(m_type, H5T_NATIVE_ULLONG))
- nfound = diff_ullong(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
+ H5TOOLS_DEBUG("type_class:H5T_INTEGER");
+ if (H5Tequal(opts->m_tid, H5T_NATIVE_SCHAR)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_schar_element(mem1, mem2, i, opts);
+ mem1 += sizeof(char);
+ mem2 += sizeof(char);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_UCHAR)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_uchar_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(unsigned char);
+ mem2 += sizeof(unsigned char);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_SHORT)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_short_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(short);
+ mem2 += sizeof(short);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_USHORT)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_ushort_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(unsigned short);
+ mem2 += sizeof(unsigned short);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_INT)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_int_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(int);
+ mem2 += sizeof(int);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_UINT)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_int_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(unsigned int);
+ mem2 += sizeof(unsigned int);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_LONG)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_long_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(long);
+ mem2 += sizeof(long);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_ULONG)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_ulong_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(unsigned long);
+ mem2 += sizeof(unsigned long);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_LLONG)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_llong_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(long long);
+ mem2 += sizeof(long long);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_ULLONG)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_ullong_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(unsigned long long);
+ mem2 += sizeof(unsigned long long);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
break;
/*-------------------------------------------------------------------------
@@ -360,13 +399,13 @@ hsize_t diff_array(void *_mem1, void *_mem2, hsize_t nelmts, hsize_t hyper_start
case H5T_ARRAY:
case H5T_VLEN:
case H5T_REFERENCE:
+ H5TOOLS_DEBUG("type_class:OTHER");
HDmemset(&members, 0, sizeof(mcomp_t));
- get_member_types(m_type, &members);
- H5TOOLS_DEBUG("call diff_datum nelmts:%d - errstat:%d", nelmts, opts->err_stat);
- for (i = 0; i < nelmts; i++) {
- nfound += diff_datum(mem1 + i * size, mem2 + i * size, m_type, i, rank, dims, acc, pos, opts,
- name1, name2, container1_id, container2_id, &ph, &members);
- if (opts->n && nfound >= opts->count)
+ get_member_types(opts->m_tid, &members);
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ H5TOOLS_DEBUG("opts->pos[%ld]:%ld - nelmts:%ld", i, opts->pos[i], opts->hs_nelmts);
+ nfound += diff_datum(mem1 + i * size, mem2 + i * size, i, opts, container1_id, container2_id, &members);
+ if (opts->count_bool && nfound >= opts->count)
break;
} /* i */
close_member_types(&members);
@@ -409,12 +448,7 @@ hsize_t diff_array(void *_mem1, void *_mem2, hsize_t nelmts, hsize_t hyper_start
*-------------------------------------------------------------------------
*/
static hsize_t
-diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
- hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts,
- const char *obj1, const char *obj2,
- hid_t container1_id, hid_t container2_id,
- int *ph, /*print header */
- mcomp_t *members) /*compound members */
+diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t container1_id, hid_t container2_id, mcomp_t *members)
{
unsigned char *mem1 = (unsigned char*) _mem1;
unsigned char *mem2 = (unsigned char*) _mem2;
@@ -425,7 +459,6 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
size_t offset;
unsigned nmembs;
unsigned j;
- hsize_t nelmts;
size_t size = 0;
hbool_t iszero1;
hbool_t iszero2;
@@ -434,10 +467,10 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
hbool_t both_zero;
diff_err_t ret_value = opts->err_stat;
- H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
+ H5TOOLS_START_DEBUG("ph:%d elemtno:%d - errstat:%d", opts->print_header, elemtno, opts->err_stat);
- type_size = H5Tget_size(m_type);
- type_class = H5Tget_class(m_type);
+ type_size = H5Tget_size(opts->m_tid);
+ type_class = H5Tget_class(opts->m_tid);
/* Fast comparison first for atomic type by memcmp().
* It is OK not to list non-atomic type here because it will not be caught
@@ -450,7 +483,7 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
HDmemcmp(mem1, mem2, type_size) == 0)
H5TOOLS_GOTO_DONE(opts->err_stat);
- switch (H5Tget_class(m_type)) {
+ switch (H5Tget_class(opts->m_tid)) {
case H5T_NO_CLASS:
case H5T_TIME:
case H5T_NCLASSES:
@@ -463,18 +496,22 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
case H5T_COMPOUND:
- H5TOOLS_DEBUG("diff_datum H5T_COMPOUND");
+ H5TOOLS_DEBUG("H5T_COMPOUND");
{
- hid_t memb_type = H5I_INVALID_HID;
+ diff_opt_t cmpd_opts;
+
+ cmpd_opts = *opts;
nmembs = members->n;
for (j = 0; j < nmembs; j++) {
offset = members->offsets[j];
- memb_type = members->ids[j];
+ cmpd_opts.m_tid = members->ids[j];
- nfound += diff_datum(mem1 + offset, mem2 + offset, memb_type, idx,
- rank, dims, acc, pos, opts, obj1, obj2, container1_id, container2_id, ph, members->m[j]);
+ nfound += diff_datum(mem1 + offset, mem2 + offset, elemtno, &cmpd_opts, container1_id, container2_id, members->m[j]);
}
+ opts->err_stat = opts->err_stat | cmpd_opts.err_stat;
+ opts->print_header = cmpd_opts.print_header;
+ opts->not_cmp = cmpd_opts.not_cmp;
}
break;
@@ -483,7 +520,7 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
case H5T_STRING:
- H5TOOLS_DEBUG("diff_datum H5T_STRING");
+ H5TOOLS_DEBUG("H5T_STRING");
{
char *s = NULL;
char *sx = NULL;
@@ -492,12 +529,12 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
size_t size1;
size_t size2;
size_t sizex;
- size_t size_mtype = H5Tget_size(m_type);
- H5T_str_t pad = H5Tget_strpad(m_type);
+ size_t size_mtype = H5Tget_size(opts->m_tid);
+ H5T_str_t pad = H5Tget_strpad(opts->m_tid);
/* if variable length string */
- if (H5Tis_variable_str(m_type)) {
- H5TOOLS_DEBUG("diff_datum H5T_STRING variable");
+ if (H5Tis_variable_str(opts->m_tid)) {
+ H5TOOLS_DEBUG("H5T_STRING variable");
/* Get pointer to first string */
s1 = *(char **)((void *)mem1);
if (s1)
@@ -513,7 +550,7 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
size2 = 0;
}
else if (H5T_STR_NULLTERM == pad) {
- H5TOOLS_DEBUG("diff_datum H5T_STRING null term");
+ H5TOOLS_DEBUG("H5T_STRING null term");
/* Get pointer to first string */
s1 = (char*) mem1;
if (s1)
@@ -550,10 +587,10 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
* of length of strings.
* For now mimic the previous way.
*/
- H5TOOLS_DEBUG("diff_datum string size:%d", size1);
- H5TOOLS_DEBUG("diff_datum string size:%d", size2);
+ H5TOOLS_DEBUG("string size:%d", size1);
+ H5TOOLS_DEBUG("string size:%d", size2);
if (size1 != size2) {
- H5TOOLS_DEBUG("diff_datum string sizes difference");
+ H5TOOLS_DEBUG("string sizes difference");
nfound++;
}
if (size1 < size2) {
@@ -572,15 +609,13 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
/* check for NULL pointer for string */
if (s != NULL) {
/* try fast compare first */
- if (HDmemcmp(s, sx, size) == 0) {
- if (size1 != size2)
- if (print_data(opts))
- for (u = size; u < sizex; u++)
- character_compare(s + u, sx + u, idx, u, rank, dims, acc, pos, opts, obj1, obj2, ph);
+ if ((HDmemcmp(s, sx, size) == 0) && (size1 != size2)) {
+ for (u = size; u < sizex; u++)
+ character_compare(s + u, sx + u, elemtno, u, opts);
}
else
for (u = 0; u < size; u++)
- nfound += character_compare(s + u, sx + u, idx, u, rank, dims, acc, pos, opts, obj1, obj2, ph);
+ nfound += character_compare(s + u, sx + u, elemtno, u, opts);
} /* end check for NULL pointer for string */
}
break;
@@ -590,10 +625,10 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
case H5T_BITFIELD:
- H5TOOLS_DEBUG("diff_datum H5T_BITFIELD");
+ H5TOOLS_DEBUG("H5T_BITFIELD");
/* byte-by-byte comparison */
for (u = 0; u < type_size; u++)
- nfound += character_compare_opt(mem1 + u, mem2 + u, idx, rank, dims, acc, pos, opts, obj1, obj2, ph);
+ nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts);
break;
/*-------------------------------------------------------------------------
@@ -601,10 +636,10 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
case H5T_OPAQUE:
- H5TOOLS_DEBUG("diff_datum H5T_OPAQUE");
+ H5TOOLS_DEBUG("H5T_OPAQUE");
/* byte-by-byte comparison */
for (u = 0; u < type_size; u++)
- nfound += character_compare_opt(mem1 + u, mem2 + u, idx, rank, dims, acc, pos, opts, obj1, obj2, ph);
+ nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts);
break;
/*-------------------------------------------------------------------------
@@ -617,7 +652,7 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
* compared, we convert both bit patterns to their corresponding
* enumeration constant and do a string comparison
*/
- H5TOOLS_DEBUG("diff_datum H5T_ENUM");
+ H5TOOLS_DEBUG("H5T_ENUM");
{
char enum_name1[1024];
char enum_name2[1024];
@@ -629,11 +664,11 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
/* If the enum value cannot be converted to a string
* it is set to an error string for later output.
*/
- err1 = H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1);
+ err1 = H5Tenum_nameof(opts->m_tid, mem1, enum_name1, sizeof enum_name1);
if (err1 < 0)
HDsnprintf(enum_name1, sizeof(enum_name1), "**INVALID VALUE**");
- err2 = H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2);
+ err2 = H5Tenum_nameof(opts->m_tid, mem2, enum_name2, sizeof enum_name2);
if (err2 < 0)
HDsnprintf(enum_name2, sizeof(enum_name2), "**INVALID VALUE**");
@@ -644,9 +679,9 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
* don't attempt to convert them - just report errors.
*/
nfound += 1;
+ opts->print_percentage = 0;
+ print_pos(opts, elemtno, -1);
if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
parallel_print(S_FORMAT, enum_name1, enum_name2);
}
}
@@ -654,15 +689,15 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
/* Both enum values were valid */
if (HDstrcmp(enum_name1, enum_name2) != 0) {
nfound = 1;
+ opts->print_percentage = 0;
+ print_pos(opts, elemtno, -1);
if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
parallel_print(S_FORMAT, enum_name1, enum_name2);
}
}
else {
for (u = 0; u < type_size; u++)
- nfound += character_compare_opt(mem1 + u, mem2 + u, idx, rank, dims, acc, pos, opts, obj1, obj2, ph);
+ nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts);
}
}
/* enable error reporting */
@@ -676,26 +711,32 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*/
case H5T_ARRAY:
{
- hid_t memb_type = H5I_INVALID_HID;
hsize_t adims[H5S_MAX_RANK];
int ndims;
+ diff_opt_t arr_opts;
+
+ H5TOOLS_DEBUG("H5T_ARRAY ph=%d", opts->print_header);
- H5TOOLS_DEBUG("diff_datum H5T_ARRAY");
+ arr_opts = *opts;
+ H5TOOLS_DEBUG("Check opts: hs_nelmts:%ld to %ld rank:%d to %ld", opts->hs_nelmts, arr_opts.hs_nelmts, opts->rank, arr_opts.rank);
/* get the array's base datatype for each element */
- memb_type = H5Tget_super(m_type);
- size = H5Tget_size(memb_type);
- ndims = H5Tget_array_ndims(m_type);
- H5Tget_array_dims2(m_type, adims);
+ arr_opts.m_tid = H5Tget_super(opts->m_tid);
+ size = H5Tget_size(arr_opts.m_tid);
+ ndims = H5Tget_array_ndims(opts->m_tid);
+ H5Tget_array_dims2(opts->m_tid, adims);
HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
+ H5TOOLS_DEBUG("attr ph=%d", arr_opts.print_header);
/* calculate the number of array elements */
- for (u = 0, nelmts = 1; u < (unsigned) ndims; u++)
- nelmts *= adims[u];
- for (u = 0; u < nelmts; u++) {
- nfound += diff_datum(mem1 + u * size, mem2 + u * size, memb_type, idx,
- rank, dims, acc, pos, opts, obj1, obj2, container1_id, container2_id, ph, members);
- }
- H5Tclose(memb_type);
+ for (u = 0, arr_opts.hs_nelmts = 1; u < (unsigned) ndims; u++)
+ arr_opts.hs_nelmts *= adims[u];
+ for (u = 0; u < arr_opts.hs_nelmts; u++) {
+ nfound += diff_datum(mem1 + u * size, mem2 + u * size, elemtno, &arr_opts, container1_id, container2_id, members);
+ }
+ opts->err_stat = opts->err_stat | arr_opts.err_stat;
+ opts->print_header = arr_opts.print_header;
+ opts->not_cmp = arr_opts.not_cmp;
+ H5Tclose(arr_opts.m_tid);
}
break;
@@ -704,9 +745,9 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
case H5T_REFERENCE:
- H5TOOLS_DEBUG("diff_datum H5T_REFERENCE");
- iszero1 = all_zero(_mem1, H5Tget_size(m_type));
- iszero2 = all_zero(_mem2, H5Tget_size(m_type));
+ H5TOOLS_DEBUG("H5T_REFERENCE");
+ iszero1 = all_zero(_mem1, H5Tget_size(opts->m_tid));
+ iszero2 = all_zero(_mem2, H5Tget_size(opts->m_tid));
if (iszero1 != iszero2) {
nfound++;
H5TOOLS_GOTO_DONE(opts->err_stat);
@@ -714,13 +755,17 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
else if (!iszero1 && !iszero2) {
hid_t obj1_id = H5I_INVALID_HID;
hid_t obj2_id = H5I_INVALID_HID;
+ diff_opt_t ref_opts;
/*-------------------------------------------------------------------------
* H5T_STD_REF
* Reference
*-------------------------------------------------------------------------
*/
- if (H5Tequal(m_type, H5T_STD_REF)) {
+ ref_opts = *opts;
+ ref_opts.obj_name[0] = NULL;
+ ref_opts.obj_name[1] = NULL;
+ if (H5Tequal(ref_opts.m_tid, H5T_STD_REF)) {
/* if (type_size == H5R_STD_REF_SIZE) */
hid_t region1_id = H5I_INVALID_HID;
hid_t region2_id = H5I_INVALID_HID;
@@ -730,66 +775,67 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
H5O_type_t obj2_type = -1; /* Object type */
H5R_type_t ref_type; /* Reference type */
- H5TOOLS_DEBUG("diff_datum H5T_REFERENCE - H5T_STD_REF");
+ H5TOOLS_DEBUG("H5T_REFERENCE - H5T_STD_REF");
ref_type = H5Rget_type(ref1_buf);
switch (ref_type) {
case H5R_OBJECT1:
H5TOOLS_DEBUG("ref_type is H5R_OBJECT1");
- if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed");
- }
- if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed");
- }
-
- /* check object type */
- if (obj1_type != obj2_type) {
- parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2);
- opts->not_cmp = 1;
- H5TOOLS_GOTO_DONE(opts->err_stat);
- }
-
- if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Ropen_object object 1 failed");
- }
- if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Ropen_object object 2 failed");
- }
-
- switch (obj1_type) {
- case H5O_TYPE_DATASET:
- nfound = diff_datasetid(obj1_id, obj2_id, NULL, NULL, opts);
- break;
-
- case H5O_TYPE_GROUP:
- case H5O_TYPE_NAMED_DATATYPE:
- case H5O_TYPE_MAP:
- case H5O_TYPE_UNKNOWN:
- case H5O_TYPE_NTYPES:
- default:
- if (opts->m_verbose)
- parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", obj1, obj2);
- opts->not_cmp = 1;
- break;
- } /* end switch */
- if(obj1_id >= 0)
- if(H5Oclose(obj1_id) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Oclose H5R_OBJECT1 failed");
+ if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) >= 0) {
+ if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) >= 0) {
+ /* check object type */
+ if (obj1_type == obj2_type) {
+ switch (obj1_type) {
+ case H5O_TYPE_DATASET:
+ if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ nfound = diff_datasetid(obj1_id, obj2_id, opts->obj_name[0], opts->obj_name[1], &ref_opts);
+ if(H5Dclose(obj2_id) < 0) {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Dclose H5R_OBJECT1 failed");
+ }
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Ropen_object object 2 failed");
+ }
+ if(H5Dclose(obj1_id) < 0) {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Dclose H5R_OBJECT1 failed");
+ }
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Ropen_object object 1 failed");
+ }
+ break;
+
+ case H5O_TYPE_GROUP:
+ case H5O_TYPE_NAMED_DATATYPE:
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ if (ref_opts.mode_verbose)
+ parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", opts->obj_name[0], opts->obj_name[1]);
+ ref_opts.not_cmp = 1;
+ break;
+ } /* end switch */
+ }
+ else {
+ parallel_print("Different object types referenced: <%s> and <%s>", opts->obj_name[0], opts->obj_name[1]);
+ ref_opts.not_cmp = 1;
+ ref_opts.err_stat = H5DIFF_ERR;
+ }
}
- if(obj2_id >= 0)
- if(H5Oclose(obj2_id) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Oclose H5R_OBJECT1 failed");
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed");
}
- if(H5Rdestroy(ref2_buf) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_OBJECT1 failed");
- if(H5Rdestroy(ref1_buf) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_OBJECT1 failed");
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed");
+ }
break;
case H5R_DATASET_REGION1:
H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1");
@@ -797,149 +843,143 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
if((region1_id = H5Ropen_region(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
if((region2_id = H5Ropen_region(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, opts);
+ nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, &ref_opts);
if(H5Sclose(region2_id) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Sclose H5R_DATASET_REGION1 failed");
+ H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION1 failed");
}
if(H5Sclose(region1_id) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Sclose H5R_DATASET_REGION1 failed");
+ H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION1 failed");
}
- if(H5Oclose(obj2_id) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Oclose H5R_DATASET_REGION1 failed");
+ if(H5Dclose(obj2_id) < 0)
+ H5TOOLS_INFO("H5Oclose H5R_DATASET_REGION1 failed");
}
else {
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_object H5R_DATASET_REGION1 failed");
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed");
}
- if(H5Oclose(obj1_id) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Oclose H5R_DATASET_REGION1 failed");
+ if(H5Dclose(obj1_id) < 0)
+ H5TOOLS_INFO("H5Oclose H5R_DATASET_REGION1 failed");
}
else {
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_object H5R_DATASET_REGION1 failed");
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed");
}
- if(H5Rdestroy(ref2_buf) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_DATASET_REGION1 failed");
- if(H5Rdestroy(ref1_buf) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_DATASET_REGION1 failed");
break;
case H5R_OBJECT2:
H5TOOLS_DEBUG("ref_type is H5R_OBJECT2");
- if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed");
- }
- if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed");
- }
-
- /* check object type */
- if (obj1_type != obj2_type) {
- parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2);
- opts->not_cmp = 1;
- H5TOOLS_GOTO_DONE(opts->err_stat);
- }
-
- if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Ropen_object object 1 failed");
- }
- if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Ropen_object object 2 failed");
- }
-
- switch (obj1_type) {
- case H5O_TYPE_DATASET:
- H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : DATASET");
- nfound = diff_datasetid(obj1_id, obj2_id, NULL, NULL, opts);
- break;
-
- case H5O_TYPE_GROUP:
- H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : GROUP");
- if (opts->m_verbose)
- parallel_print("Warning: Comparison not possible of group object types referenced: <%s> and <%s>\n", obj1, obj2);
- opts->not_cmp = 1;
- break;
-
- case H5O_TYPE_NAMED_DATATYPE:
- H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : NAMED");
- if (opts->m_verbose)
- parallel_print("Warning: Comparison not possible of named datatypes object types referenced: <%s> and <%s>\n", obj1, obj2);
- opts->not_cmp = 1;
- break;
-
- case H5O_TYPE_MAP:
- case H5O_TYPE_UNKNOWN:
- case H5O_TYPE_NTYPES:
- default:
- if (opts->m_verbose)
- parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", obj1, obj2);
- opts->not_cmp = 1;
- break;
- } /* end switch */
- if(obj1_id >= 0)
- if(H5Oclose(obj1_id) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed");
+ if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) >= 0) {
+ if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) >= 0) {
+ /* check object type */
+ if (obj1_type == obj2_type) {
+ if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ switch (obj1_type) {
+ case H5O_TYPE_DATASET:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : DATASET");
+ nfound = diff_datasetid(obj1_id, obj2_id, opts->obj_name[0], opts->obj_name[1], &ref_opts);
+ break;
+
+ case H5O_TYPE_GROUP:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : GROUP");
+ if (ref_opts.mode_verbose)
+ parallel_print("Warning: Comparison not possible of group object types referenced: <%s> and <%s>\n", opts->obj_name[0], opts->obj_name[1]);
+ ref_opts.not_cmp = 1;
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : NAMED");
+ if (ref_opts.mode_verbose)
+ parallel_print("Warning: Comparison not possible of named datatypes object types referenced: <%s> and <%s>\n", opts->obj_name[0], opts->obj_name[1]);
+ ref_opts.not_cmp = 1;
+ break;
+
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ if (ref_opts.mode_verbose)
+ parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", opts->obj_name[0], opts->obj_name[1]);
+ ref_opts.not_cmp = 1;
+ break;
+ } /* end switch */
+ if(H5Oclose(obj2_id) < 0) {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed");
+ }
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Ropen_object object 2 failed");
+ }
+ if(H5Oclose(obj1_id) < 0) {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed");
+ }
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Ropen_object object 1 failed");
+ }
+ }
+ else {
+ parallel_print("Different object types referenced: <%s> and <%s>", opts->obj_name[0], opts->obj_name[1]);
+ ref_opts.not_cmp = 1;
+ ref_opts.err_stat = H5DIFF_ERR;
+ }
}
- if(obj2_id >= 0)
- if(H5Oclose(obj2_id) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed");
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed");
}
- if(H5Rdestroy(ref2_buf) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_OBJECT2 failed");
- if(H5Rdestroy(ref1_buf) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_OBJECT2 failed");
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed");
+ }
break;
case H5R_DATASET_REGION2:
H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2");
/* if (obj_id < 0) - could mean that no reference was written do not throw failure */
- obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT);
- obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT);
- if((obj1_id < 0) || (obj2_id < 0)) {
- H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed");
+ if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 object 1 failed");
}
else {
- H5TOOLS_DEBUG("open_region - H5R_DATASET_REGION2");
- if((region1_id = H5Ropen_region(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- if (h5tools_is_zero(ref1_buf, H5Tget_size(H5T_STD_REF))) {
- H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
- }
- else {
- if((region2_id = H5Ropen_region(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- if (h5tools_is_zero(ref2_buf, H5Tget_size(H5T_STD_REF))) {
- H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
- }
- else {
- nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, opts);
- }
- if(H5Sclose(region2_id) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Sclose H5R_DATASET_REGION2 failed");
+ if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ H5TOOLS_DEBUG("open_region - H5R_DATASET_REGION2");
+ if((region1_id = H5Ropen_region(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if (h5tools_is_zero(ref1_buf, H5Tget_size(H5T_STD_REF))) {
+ H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
}
- else
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_region H5R_DATASET_REGION2 failed");
- } /* end else to if (h5tools_is_zero(... */
- if(H5Sclose(region1_id) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Sclose H5R_DATASET_REGION2 failed");
- }
- else
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_region H5R_DATASET_REGION2 failed");
- if (obj1_id >= 0)
- if(H5Dclose(obj1_id) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed");
+ else {
+ if((region2_id = H5Ropen_region(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if (h5tools_is_zero(ref2_buf, H5Tget_size(H5T_STD_REF))) {
+ H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
+ }
+ else {
+ nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, &ref_opts);
+ }
+ if(H5Sclose(region2_id) < 0)
+ H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed");
+ }
+ else
+ H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed");
+ } /* end else to if (h5tools_is_zero(... */
+ if(H5Sclose(region1_id) < 0)
+ H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed");
}
- if (obj2_id >= 0)
+ else
+ H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_region H5R_DATASET_REGION2 failed");
if(H5Dclose(obj2_id) < 0) {
- opts->err_stat = H5DIFF_ERR;
+ ref_opts.err_stat = H5DIFF_ERR;
H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed");
}
- if(H5Rdestroy(ref1_buf) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_DATASET_REGION2 failed");
- if(H5Rdestroy(ref2_buf) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_DATASET_REGION2 failed");
+ }
+ else {
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 object 2 failed");
+ }
+ if(H5Dclose(obj1_id) < 0) {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed");
+ }
}
break;
case H5R_ATTR:
@@ -948,44 +988,42 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
char name2[ATTR_NAME_MAX];
H5TOOLS_DEBUG("ref_type is H5R_ATTR");
- if((obj1_id = H5Ropen_attr(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
- parallel_print("Warning: Cannot open referenced attribute: attribute 1\n");
- H5TOOLS_INFO("H5Ropen_attr object 1 failed");
- }
- if((obj2_id = H5Ropen_attr(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
- parallel_print("Warning: Cannot open referenced attribute: attribute 2\n");
- H5TOOLS_INFO("H5Ropen_attr object 2 failed");
- }
-
- if((obj1_id < 0) || (obj2_id < 0)) {
- H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed");
- }
- else {
- /* get name */
- if(H5Aget_name(obj1_id, (size_t)ATTR_NAME_MAX, name1) < 0)
- H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_name first attribute failed");
- /* get name */
- if(H5Aget_name(obj2_id, (size_t)ATTR_NAME_MAX, name2) < 0)
- H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_name second attribute failed");
-
- H5TOOLS_DEBUG("H5R_ATTR diff_attr_data - name1=%s, name2=%s", name1, name2);
- nfound = diff_attr_data(obj1_id, obj2_id, name1, name2, NULL, NULL, opts);
- }
+ if((obj1_id = H5Ropen_attr(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((obj2_id = H5Ropen_attr(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ /* get name */
+ if(H5Aget_name(obj1_id, (size_t)ATTR_NAME_MAX, name1) >= 0) {
+ /* get name */
+ if(H5Aget_name(obj2_id, (size_t)ATTR_NAME_MAX, name2) >= 0) {
+ H5TOOLS_DEBUG("H5R_ATTR diff_attr_data - name1=%s, name2=%s", name1, name2);
+ nfound = diff_attr_data(obj1_id, obj2_id, name1, name2, opts->obj_name[0], opts->obj_name[1], &ref_opts);
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Aget_name second attribute failed");
+ }
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Aget_name first attribute failed");
+ }
- if(obj1_id >= 0)
- if(H5Aclose(obj1_id) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Aclose H5R_ATTR failed");
+ if(H5Aclose(obj2_id) < 0) {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Aclose H5R_ATTR failed");
+ }
}
- if(obj2_id >= 0)
- if(H5Aclose(obj2_id) < 0) {
- opts->err_stat = H5DIFF_ERR;
+ else {
+ parallel_print("Warning: Cannot open referenced attribute2\n");
+ H5TOOLS_INFO("H5Ropen_attr object 2 failed");
+ }
+ if(H5Aclose(obj1_id) < 0) {
H5TOOLS_INFO("H5Aclose H5R_ATTR failed");
}
- if(H5Rdestroy(ref2_buf) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_ATTR failed");
- if(H5Rdestroy(ref1_buf) < 0)
- H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_ATTR failed");
+ }
+ else {
+ parallel_print("Warning: Cannot open referenced attribute1\n");
+ H5TOOLS_INFO("H5Ropen_attr object 1 failed");
+ }
}
break;
case H5R_BADTYPE:
@@ -993,43 +1031,20 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
default:
break;
} /* end switch */
- H5TOOLS_DEBUG("diff_datum H5T_REFERENCE - H5T_STD_REF complete nfound:%d - errstat:%d", nfound, opts->err_stat);
+ if(H5Rdestroy(ref2_buf) < 0)
+ H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1 failed");
+ if(H5Rdestroy(ref1_buf) < 0)
+ H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1 failed");
+ H5TOOLS_DEBUG("H5T_REFERENCE - H5T_STD_REF complete nfound:%d - errstat:%d", nfound, ref_opts.err_stat);
}
/*-------------------------------------------------------------------------
* H5T_STD_REF_DSETREG
* Dataset region reference
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_STD_REF_DSETREG)) {
+ else if (H5Tequal(ref_opts.m_tid, H5T_STD_REF_DSETREG)) {
/* if (type_size == H5R_DSET_REG_REF_BUF_SIZE) */
- hid_t region1_id = H5I_INVALID_HID;
- hid_t region2_id = H5I_INVALID_HID;
-
- H5TOOLS_INFO("H5T_STD_REF_DSETREG reference type");
-
- if ((obj1_id = H5Rdereference2(container1_id, H5P_DEFAULT, H5R_DATASET_REGION, _mem1)) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Rdereference2 object 1 failed");
- }
- if ((obj2_id = H5Rdereference2(container2_id, H5P_DEFAULT, H5R_DATASET_REGION, _mem2)) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Rdereference2 object 2 failed");
- }
- if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1)) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Rget_region object 1 failed");
- }
- if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2)) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Rget_region object 2 failed");
- }
-
- nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, opts);
-
- H5Oclose(obj1_id);
- H5Oclose(obj2_id);
- H5Sclose(region1_id);
- H5Sclose(region2_id);
+ H5TOOLS_DEBUG("H5T_STD_REF_DSETREG");
}/*dataset reference*/
/*-------------------------------------------------------------------------
@@ -1037,52 +1052,15 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
* Object references. get the type and OID of the referenced object
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_STD_REF_OBJ)) {
+ else if (H5Tequal(ref_opts.m_tid, H5T_STD_REF_OBJ)) {
/* if (type_size == H5R_OBJ_REF_BUF_SIZE) */
- H5O_type_t obj1_type;
- H5O_type_t obj2_type;
-
- H5TOOLS_INFO("H5T_STD_REF_OBJ reference type");
-
- if (H5Rget_obj_type2(container1_id, H5R_OBJECT, _mem1, &obj1_type) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Rget_obj_type2 object 1 failed");
- }
- if (H5Rget_obj_type2(container2_id, H5R_OBJECT, _mem2, &obj2_type) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Rget_obj_type2 object 2 failed");
- }
-
- /* check object type */
- if (obj1_type != obj2_type) {
- parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2);
- opts->not_cmp = 1;
- H5TOOLS_GOTO_DONE(opts->err_stat);
- }
-
- if ((obj1_id = H5Rdereference2(container1_id, H5P_DEFAULT, H5R_OBJECT, _mem1)) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Rdereference2 object 1 failed");
- }
- if ((obj2_id = H5Rdereference2(container2_id, H5P_DEFAULT, H5R_OBJECT, _mem2)) < 0) {
- opts->err_stat = H5DIFF_ERR;
- H5TOOLS_INFO("H5Rdereference2 object 2 failed");
- }
-
- /* compare */
- if (obj1_type == H5O_TYPE_DATASET)
- nfound = diff_datasetid(obj1_id, obj2_id, NULL, NULL, opts);
- else {
- if (opts->m_verbose)
- parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", obj1, obj2);
- opts->not_cmp = 1;
- }
-
- H5Oclose(obj1_id);
- H5Oclose(obj2_id);
+ H5TOOLS_DEBUG("H5T_STD_REF_OBJ");
}/*object reference*/
+ opts->print_header = ref_opts.print_header;
+ opts->not_cmp = ref_opts.not_cmp;
+ opts->err_stat = ref_opts.err_stat | ret_value;
}/*is zero*/
- H5TOOLS_DEBUG("diff_datum H5T_REFERENCE complete");
+ H5TOOLS_DEBUG("H5T_REFERENCE complete");
break;
/*-------------------------------------------------------------------------
@@ -1091,21 +1069,26 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*/
case H5T_VLEN:
{
- hid_t memb_type = H5I_INVALID_HID;
+ diff_opt_t vl_opts;
+
+ H5TOOLS_DEBUG("H5T_VLEN");
- H5TOOLS_DEBUG("diff_datum H5T_VLEN");
+ vl_opts = *opts;
/* get the VL sequences's base datatype for each element */
- memb_type = H5Tget_super(m_type);
- size = H5Tget_size(memb_type);
+ vl_opts.m_tid = H5Tget_super(opts->m_tid);
+ size = H5Tget_size(vl_opts.m_tid);
/* get the number of sequence elements */
- nelmts = ((hvl_t *)((void *)mem1))->len;
+ vl_opts.hs_nelmts = ((hvl_t *)((void *)mem1))->len;
- for (j = 0; j < nelmts; j++)
- nfound += diff_datum(((char *) (((hvl_t *)((void *)mem1))->p)) + j * size, ((char *) (((hvl_t *)((void *)mem2))->p)) + j * size, memb_type, idx, /* Extra (void *) cast to quiet "cast to create alignment" warning - 2019/07/05, QAK */
- rank, dims, acc, pos, opts, obj1, obj2, container1_id, container2_id, ph, members);
+ for (j = 0; j < vl_opts.hs_nelmts; j++)
+ nfound += diff_datum(((char *) (((hvl_t *)((void *)mem1))->p)) + j * size, ((char *) (((hvl_t *)((void *)mem2))->p)) + j * size, elemtno, /* Extra (void *) cast to quiet "cast to create alignment" warning - 2019/07/05, QAK */
+ &vl_opts, container1_id, container2_id, members);
+ opts->print_header = vl_opts.print_header;
+ opts->not_cmp = vl_opts.not_cmp;
+ opts->err_stat = opts->err_stat | vl_opts.err_stat;
- H5Tclose(memb_type);
+ H5Tclose(vl_opts.m_tid);
}
break;
@@ -1114,81 +1097,16 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
case H5T_INTEGER:
- H5TOOLS_DEBUG("diff_datum H5T_INTEGER");
- type_sign = H5Tget_sign(m_type);
+ H5TOOLS_DEBUG("H5T_INTEGER");
+ type_sign = H5Tget_sign(opts->m_tid);
/*-------------------------------------------------------------------------
* H5T_NATIVE_SCHAR
*-------------------------------------------------------------------------
*/
if (type_size == 1 && type_sign != H5T_SGN_NONE) {
- char temp1_char;
- char temp2_char;
-
if(type_size != sizeof(char))
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not char size");
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
- /* -d and !-p */
- if (opts->d && !opts->p) {
- if (ABS(temp1_char-temp2_char) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!opts->d && opts->p) {
- PER(temp1_char, temp2_char);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if (opts->d && opts->p) {
- PER(temp1_char, temp2_char);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
- }
- nfound++;
- }
- else if (per > opts->percent && ABS(temp1_char - temp2_char) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per);
- }
- nfound++;
- }
- }
- else if (temp1_char != temp2_char) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
- }
- nfound++;
- }
+ nfound += diff_schar_element(mem1, mem2, elemtno, opts);
} /*H5T_NATIVE_SCHAR*/
/*-------------------------------------------------------------------------
@@ -1196,75 +1114,9 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
else if (type_size == 1 && type_sign == H5T_SGN_NONE) {
- unsigned char temp1_uchar;
- unsigned char temp2_uchar;
-
if(type_size != sizeof(unsigned char))
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned char size");
-
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
- /* -d and !-p */
- if (opts->d && !opts->p) {
- if (PDIFF(temp1_uchar, temp2_uchar) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!opts->d && opts->p) {
- PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if (opts->d && opts->p) {
- PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
- }
- nfound++;
- }
- else if (per > opts->percent && PDIFF(temp1_uchar, temp2_uchar) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per);
- }
- nfound++;
- }
- }
- else if (temp1_uchar != temp2_uchar) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
- }
- nfound++;
- }
+ nfound += diff_uchar_element(mem1, mem2, elemtno, opts);
} /*H5T_NATIVE_UCHAR*/
/*-------------------------------------------------------------------------
@@ -1272,75 +1124,9 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
else if (type_size == 2 && type_sign != H5T_SGN_NONE) {
- short temp1_short;
- short temp2_short;
-
if(type_size != sizeof(short))
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not short size");
-
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
- /* -d and !-p */
- if (opts->d && !opts->p) {
- if (ABS(temp1_short - temp2_short) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!opts->d && opts->p) {
- PER(temp1_short, temp2_short);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if (opts->d && opts->p) {
- PER(temp1_short, temp2_short);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
- }
- nfound++;
- }
- else if (per > opts->percent && ABS(temp1_short - temp2_short) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per);
- }
- nfound++;
- }
- }
- else if (temp1_short != temp2_short) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
- }
- nfound++;
- }
+ nfound += diff_short_element(mem1, mem2, elemtno, opts);
} /*H5T_NATIVE_SHORT*/
/*-------------------------------------------------------------------------
@@ -1348,75 +1134,9 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
else if (type_size == 2 && type_sign == H5T_SGN_NONE) {
- unsigned short temp1_ushort;
- unsigned short temp2_ushort;
-
if(type_size != sizeof(unsigned short))
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned short size");
-
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
- /* -d and !-p */
- if (opts->d && !opts->p) {
- if (PDIFF(temp1_ushort, temp2_ushort) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!opts->d && opts->p) {
- PER_UNSIGN(signed short, temp1_ushort, temp2_ushort);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if (opts->d && opts->p) {
- PER_UNSIGN(signed short, temp1_ushort, temp2_ushort);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
- }
- nfound++;
- }
- else if (per > opts->percent && PDIFF(temp1_ushort, temp2_ushort) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per);
- }
- nfound++;
- }
- }
- else if (temp1_ushort != temp2_ushort) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
- }
- nfound++;
- }
+ nfound += diff_ushort_element(mem1, mem2, elemtno, opts);
} /*H5T_NATIVE_USHORT*/
/*-------------------------------------------------------------------------
@@ -1424,75 +1144,9 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
else if (type_size == 4 && type_sign != H5T_SGN_NONE) {
- int temp1_int;
- int temp2_int;
-
if(type_size != sizeof(int))
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not int size");
-
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
- /* -d and !-p */
- if (opts->d && !opts->p) {
- if (ABS(temp1_int-temp2_int) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!opts->d && opts->p) {
- PER(temp1_int, temp2_int);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if (opts->d && opts->p) {
- PER(temp1_int, temp2_int);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
- }
- nfound++;
- }
- else if (per > opts->percent && ABS(temp1_int - temp2_int) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per);
- }
- nfound++;
- }
- }
- else if (temp1_int != temp2_int) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
- }
- nfound++;
- }
+ nfound += diff_int_element(mem1, mem2, elemtno, opts);
} /*H5T_NATIVE_INT*/
/*-------------------------------------------------------------------------
@@ -1500,75 +1154,9 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
else if (type_size == 4 && type_sign == H5T_SGN_NONE) {
- unsigned int temp1_uint;
- unsigned int temp2_uint;
-
if(type_size != sizeof(unsigned int))
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned int size");
-
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
- /* -d and !-p */
- if (opts->d && !opts->p) {
- if (PDIFF(temp1_uint, temp2_uint) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!opts->d && opts->p) {
- PER_UNSIGN(signed int, temp1_uint, temp2_uint);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(UI_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if (opts->d && opts->p) {
- PER_UNSIGN(signed int, temp1_uint, temp2_uint);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
- }
- nfound++;
- }
- else if (per > opts->percent && PDIFF(temp1_uint,temp2_uint) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(UI_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per);
- }
- nfound++;
- }
- }
- else if (temp1_uint != temp2_uint) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
- }
- nfound++;
- }
+ nfound += diff_uint_element(mem1, mem2, elemtno, opts);
} /*H5T_NATIVE_UINT*/
/*-------------------------------------------------------------------------
@@ -1576,75 +1164,9 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
else if (type_size == 8 && type_sign != H5T_SGN_NONE) {
- long temp1_long;
- long temp2_long;
-
if(type_size != sizeof(long))
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long size");
-
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
- /* -d and !-p */
- if (opts->d && !opts->p) {
- if (ABS(temp1_long-temp2_long) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!opts->d && opts->p) {
- PER(temp1_long, temp2_long);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if (opts->d && opts->p) {
- PER(temp1_long, temp2_long);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
- }
- nfound++;
- }
- else if (per > opts->percent && ABS(temp1_long-temp2_long) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per);
- }
- nfound++;
- }
- }
- else if (temp1_long != temp2_long) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
- }
- nfound++;
- }
+ nfound += diff_long_element(mem1, mem2, elemtno, opts);
} /*H5T_NATIVE_LONG*/
/*-------------------------------------------------------------------------
@@ -1652,76 +1174,30 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
else if (type_size == 8 && type_sign == H5T_SGN_NONE) {
- unsigned long temp1_ulong;
- unsigned long temp2_ulong;
-
if(type_size != sizeof(unsigned long))
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned long size");
+ nfound += diff_ulong_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_ULONG*/
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
- /* -d and !-p */
- if (opts->d && !opts->p) {
- if (PDIFF(temp1_ulong, temp2_ulong) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!opts->d && opts->p) {
- PER_UNSIGN(signed long, temp1_ulong, temp2_ulong);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if (opts->d && opts->p) {
- PER_UNSIGN(signed long, temp1_ulong, temp2_ulong);
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_LLONG
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 16 && type_sign != H5T_SGN_NONE) {
+ if(type_size != sizeof(long long))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long long size");
+ nfound += diff_llong_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_LLONG*/
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
- }
- nfound++;
- }
- else if (per > opts->percent && PDIFF(temp1_ulong,temp2_ulong) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per);
- }
- nfound++;
- }
- }
- else if (temp1_ulong != temp2_ulong) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
- }
- nfound++;
- }
- } /*H5T_NATIVE_ULONG*/
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_ULLONG
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 16 && type_sign == H5T_SGN_NONE) {
+ if(type_size != sizeof(unsigned long long))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned long long size");
+ nfound += diff_ullong_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_ULLONG*/
break; /* H5T_INTEGER class */
/*-------------------------------------------------------------------------
@@ -1733,319 +1209,21 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
* H5T_NATIVE_FLOAT
*-------------------------------------------------------------------------
*/
- H5TOOLS_DEBUG("diff_datum H5T_FLOAT");
+ H5TOOLS_DEBUG("H5T_FLOAT");
if (type_size == 4) {
- float temp1_float;
- float temp2_float;
- hbool_t isnan1 = FALSE;
- hbool_t isnan2 = FALSE;
-
if(type_size != sizeof(float))
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not float size");
-
- HDmemcpy(&temp1_float, mem1, sizeof(float));
- HDmemcpy(&temp2_float, mem2, sizeof(float));
-
- /* logic for detecting NaNs is different with opts -d, -p and no opts */
-
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
- if (opts->d && !opts->p) {
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_float);
- isnan2 = HDisnan(temp2_float);
- }
-
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- if (ABS(temp1_float-temp2_float) > (float) opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
- }
- nfound++;
- }
- }
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
- }
- nfound++;
- }
- }
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!opts->d && opts->p) {
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_float);
- isnan2 = HDisnan(temp2_float);
- }
-
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- PER(temp1_float, temp2_float);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
- }
- nfound++;
- }
- else if (per > opts->percent && (double) ABS(temp1_float - temp2_float) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float,
- (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float));
- }
- nfound++;
- }
- }
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
- }
- nfound++;
- }
- }
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if (opts->d && opts->p) {
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_float);
- isnan2 = HDisnan(temp2_float);
- }
-
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- PER(temp1_float, temp2_float);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float,
- (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float));
- }
- nfound++;
- }
- }
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
- }
- nfound++;
- }
- }
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else if (equal_float(temp1_float, temp2_float, opts) == FALSE) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
- }
- nfound++;
- }
- } /*H5T_NATIVE_FLOAT*/
-
+ nfound += diff_float_element(mem1, mem2, elemtno, opts);
+ }
/*-------------------------------------------------------------------------
* H5T_NATIVE_DOUBLE
*-------------------------------------------------------------------------
*/
else if (type_size == 8) {
- double temp1_double;
- double temp2_double;
- hbool_t isnan1 = FALSE;
- hbool_t isnan2 = FALSE;
-
if(type_size != sizeof(double))
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not double size");
-
- HDmemcpy(&temp1_double, mem1, sizeof(double));
- HDmemcpy(&temp2_double, mem2, sizeof(double));
-
- /* logic for detecting NaNs is different with opts -d, -p and no opts */
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
- if (opts->d && !opts->p) {
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_double);
- isnan2 = HDisnan(temp2_double);
- }
-
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- if (ABS(temp1_double-temp2_double) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- }
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- } /* opts->d && !opts->p */
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!opts->d && opts->p) {
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_double);
- isnan2 = HDisnan(temp2_double);
- }
-
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- PER(temp1_double, temp2_double);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double));
- }
- nfound++;
- }
- }
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- }
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if (opts->d && opts->p) {
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_double);
- isnan2 = HDisnan(temp2_double);
- }
-
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- PER(temp1_double, temp2_double);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- else if (per > opts->percent &&
- ABS(temp1_double-temp2_double) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double));
- }
- nfound++;
- }
- }
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- }
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else if (equal_double(temp1_double, temp2_double, opts) == FALSE) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- } /*H5T_NATIVE_DOUBLE*/
-
+ nfound += diff_double_element(mem1, mem2, elemtno, opts);
+ }
#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE
/*-------------------------------------------------------------------------
@@ -2053,157 +1231,10 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank,
*-------------------------------------------------------------------------
*/
else if (type_size == H5_SIZEOF_LONG_DOUBLE) {
- long double temp1_double;
- long double temp2_double;
- hbool_t isnan1 = FALSE;
- hbool_t isnan2 = FALSE;
-
if(type_size != sizeof(long double)) {
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long double size");
}
-
- HDmemcpy(&temp1_double, mem1, sizeof(long double));
- HDmemcpy(&temp2_double, mem2, sizeof(long double));
-
- /* logic for detecting NaNs is different with options -d, -p and no options */
-
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
- if (opts->d && !opts->p) {
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_double);
- isnan2 = HDisnan(temp2_double);
- }
-
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- if (ABS(temp1_double-temp2_double) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- } /* NaN */
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- }
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!opts->d && opts->p) {
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_double);
- isnan2 = HDisnan(temp2_double);
- }
-
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double));
- }
- nfound++;
- }
- } /* NaN */
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- }
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if (opts->d && opts->p) {
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_double);
- isnan2 = HDisnan(temp2_double);
- }
-
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- else if (per > opts->percent && ABS(temp1_double-temp2_double) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double));
- }
- nfound++;
- }
- } /* NaN */
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- }
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else if (equal_ldouble(temp1_double, temp2_double, opts) == FALSE) {
- if (print_data(opts)) {
- print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
+ nfound += diff_ldouble_element(mem1, mem2, elemtno, opts);
} /*H5T_NATIVE_LDOUBLE*/
#endif /* H5_SIZEOF_LONG_DOUBLE */
@@ -2320,8 +1351,8 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t
npoints1 = H5Sget_select_elem_npoints(region1_id);
npoints2 = H5Sget_select_elem_npoints(region2_id);
} H5E_END_TRY;
- H5TOOLS_DEBUG("diff_region blocks: 1=%ld-2=%ld", nblocks1, nblocks2);
- H5TOOLS_DEBUG("diff_region points: 1=%ld-2=%ld", npoints1, npoints2);
+ H5TOOLS_DEBUG("blocks: 1=%ld-2=%ld", nblocks1, nblocks2);
+ H5TOOLS_DEBUG("points: 1=%ld-2=%ld", npoints1, npoints2);
if (nblocks1 != nblocks2 || npoints1 != npoints2 || ndims1 != ndims2) {
opts->not_cmp = 1;
@@ -2369,7 +1400,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t
}
/* print differences if found */
- if (nfound_b && opts->m_verbose) {
+ if (nfound_b && opts->mode_verbose) {
H5O_info2_t oi1, oi2;
char *obj1_str = NULL, *obj2_str = NULL;
@@ -2437,7 +1468,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t
}
}
- if (nfound_p && opts->m_verbose) {
+ if (nfound_p && opts->mode_verbose) {
parallel_print("Region points\n");
for (i = 0; i < npoints1; i++) {
hsize_t pt1, pt2;
@@ -2497,8 +1528,7 @@ done:
*-------------------------------------------------------------------------
*/
-static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u,
- int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph)
+static hsize_t character_compare(char *mem1, char *mem2, hsize_t elemtno, ssize_t u, diff_opt_t *opts)
{
hsize_t nfound = 0; /* differences found */
char temp1_uchar;
@@ -2506,12 +1536,13 @@ static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u,
HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
- H5TOOLS_START_DEBUG(" %d=%d",temp1_uchar,temp2_uchar);
+ H5TOOLS_START_DEBUG(" %d=%d", temp1_uchar, temp2_uchar);
if (temp1_uchar != temp2_uchar) {
if (print_data(opts)) {
- print_char_pos(ph, 0, i, u, acc, pos, rank, dims, obj1, obj2);
- parallel_print(" ");
+ opts->print_percentage = 0;
+ print_pos(opts, elemtno, u);
+ parallel_print(" ");
h5diff_print_char(temp1_uchar);
parallel_print(" ");
h5diff_print_char(temp2_uchar);
@@ -2532,1953 +1563,1455 @@ static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u,
*-------------------------------------------------------------------------
*/
-static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2,
- hsize_t i, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph)
+static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, hsize_t elemtno, diff_opt_t *opts)
{
hsize_t nfound = 0; /* differences found */
unsigned char temp1_uchar;
unsigned char temp2_uchar;
+ hbool_t both_zero = FALSE;
double per;
- hbool_t both_zero;
HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+ H5TOOLS_START_DEBUG(" %d=%d", temp1_uchar, temp2_uchar);
/* -d and !-p */
- if (opts->d && !opts->p) {
+ if (opts->delta_bool && !opts->percent_bool) {
if (PDIFF(temp1_uchar,temp2_uchar) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elemtno, -1);
if (print_data(opts)) {
- print_pos(ph, 0, i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
}
}
/* !-d and -p */
- else if (!opts->d && opts->p) {
+ else if (!opts->delta_bool && opts->percent_bool) {
PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elemtno, -1);
if (print_data(opts)) {
- print_pos(ph, 1, i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per);
}
nfound++;
}
}
/* -d and -p */
- else if (opts->d && opts->p) {
+ else if (opts->delta_bool && opts->percent_bool) {
PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
if (per > opts->percent && PDIFF(temp1_uchar,temp2_uchar) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elemtno, -1);
if (print_data(opts)) {
- print_pos(ph, 1, i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per);
}
nfound++;
}
}
else if (temp1_uchar != temp2_uchar) {
+ opts->print_percentage = 0;
+ print_pos(opts, elemtno, -1);
if (print_data(opts)) {
- print_pos(ph, 0, i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
}
+ H5TOOLS_ENDDEBUG(": %d zero:%d", nfound, both_zero);
return nfound;
}
/*-------------------------------------------------------------------------
- * Function: diff_float
+ * Function: diff_float_element
*
- * Purpose: diff a H5T_NATIVE_FLOAT type
+ * Purpose: diff a single H5T_NATIVE_FLOAT type
*
* Return: number of differences found
*
*-------------------------------------------------------------------------
*/
-static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph)
-
+static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
hsize_t nfound = 0; /* number of differences found */
float temp1_float;
float temp2_float;
- hsize_t i;
double per;
- hbool_t both_zero;
+ hbool_t both_zero = FALSE;
hbool_t isnan1 = FALSE;
hbool_t isnan2 = FALSE;
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
+
+ HDmemcpy(&temp1_float, mem1, sizeof(float));
+ HDmemcpy(&temp2_float, mem2, sizeof(float));
+
+ /* logic for detecting NaNs is different with opts -d, -p and no opts */
+
/*-------------------------------------------------------------------------
* -d and !-p
*-------------------------------------------------------------------------
*/
+ if (opts->delta_bool && !opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_float);
+ isnan2 = HDisnan(temp2_float);
+ }
- if (opts->d && !opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_float, mem1, sizeof(float));
- HDmemcpy(&temp2_float, mem2, sizeof(float));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_float);
- isnan2 = HDisnan(temp2_float);
- }
-
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- if ((double) ABS(temp1_float - temp2_float) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
- }
- nfound++;
- }
- }
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ if ((double) ABS(temp1_float - temp2_float) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
nfound++;
-
}
- mem1 += sizeof(float);
- mem2 += sizeof(float);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* i */
+ }
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
+ }
+ nfound++;
+ }
}
/*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_float, mem1, sizeof(float));
- HDmemcpy(&temp2_float, mem2, sizeof(float));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_float);
- isnan2 = HDisnan(temp2_float);
- }
- /* both not NaN, do the comparison */
- if ((!isnan1 && !isnan2)) {
- PER(temp1_float, temp2_float);
+ * !-d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_float);
+ isnan2 = HDisnan(temp2_float);
+ }
+ /* both not NaN, do the comparison */
+ if ((!isnan1 && !isnan2)) {
+ PER(temp1_float, temp2_float);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float,
- (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
+ nfound++;
}
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
+ parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float,
+ (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float));
}
nfound++;
-
}
- mem1 += sizeof(float);
- mem2 += sizeof(float);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* i */
+ }
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
+ }
+ nfound++;
+ }
}
/*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if (opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_float, mem1, sizeof(float));
- HDmemcpy(&temp2_float, mem2, sizeof(float));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_float);
- isnan2 = HDisnan(temp2_float);
- }
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (opts->delta_bool && opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_float);
+ isnan2 = HDisnan(temp2_float);
+ }
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- PER(temp1_float, temp2_float);
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ PER(temp1_float, temp2_float);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
- }
- nfound++;
- }
- else if (per > opts->percent && (double) ABS(temp1_float - temp2_float) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float,
- (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
-
+ nfound++;
}
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ else if (per > opts->percent && (double) ABS(temp1_float - temp2_float) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
+ parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float,
+ (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float));
}
nfound++;
-
}
- mem1 += sizeof(float);
- mem2 += sizeof(float);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* i */
+ }
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
+ }
+ nfound++;
+ }
}
-
/*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
+ * no -d and -p
+ *-------------------------------------------------------------------------
+ */
else {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_float, mem1, sizeof(float));
- HDmemcpy(&temp2_float, mem2, sizeof(float));
-
- if (equal_float(temp1_float, temp2_float, opts) == FALSE) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
- }
- nfound++;
+ if (equal_float(temp1_float, temp2_float, opts) == FALSE) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
-
- mem1 += sizeof(float);
- mem2 += sizeof(float);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* nelmts */
+ nfound++;
+ }
}
+ H5TOOLS_ENDDEBUG(": %d zero:%d", nfound, both_zero);
return nfound;
}
/*-------------------------------------------------------------------------
- * Function: diff_double
+ * Function: diff_double_element
*
- * Purpose: diff a H5T_NATIVE_DOUBLE type
+ * Purpose: diff a single H5T_NATIVE_DOUBLE type
*
* Return: number of differences found
*-------------------------------------------------------------------------
*/
-static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph)
-
+static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
hsize_t nfound = 0; /* number of differences found */
double temp1_double;
double temp2_double;
- hsize_t i;
double per;
- hbool_t both_zero;
+ hbool_t both_zero = FALSE;
hbool_t isnan1 = FALSE;
hbool_t isnan2 = FALSE;
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- if (opts->d && !opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_double, mem1, sizeof(double));
- HDmemcpy(&temp2_double, mem2, sizeof(double));
+ HDmemcpy(&temp1_double, mem1, sizeof(double));
+ HDmemcpy(&temp2_double, mem2, sizeof(double));
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_double);
- isnan2 = HDisnan(temp2_double);
- }
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
+ if (opts->delta_bool && !opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
+ }
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- if (ABS(temp1_double-temp2_double) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- }
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ if (ABS(temp1_double-temp2_double) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
-
}
- mem1 += sizeof(double);
- mem2 += sizeof(double);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* i */
+ }
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ }
+ nfound++;
+ }
}
/*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_double, mem1, sizeof(double));
- HDmemcpy(&temp2_double, mem2, sizeof(double));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_double);
- isnan2 = HDisnan(temp2_double);
- }
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- PER(temp1_double, temp2_double);
+ * !-d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
+ }
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double, temp2_double);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P, temp1_double, temp2_double,
- ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
+ nfound++;
}
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ parallel_print(F_FORMAT_P, temp1_double, temp2_double,
+ ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double));
}
nfound++;
-
}
- mem1 += sizeof(double);
- mem2 += sizeof(double);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* i */
+ }
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ }
+ nfound++;
+ }
}
/*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if (opts->d && opts->p) {
-
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_double, mem1, sizeof(double));
- HDmemcpy(&temp2_double, mem2, sizeof(double));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_double);
- isnan2 = HDisnan(temp2_double);
- }
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (opts->delta_bool && opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
+ }
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- PER(temp1_double, temp2_double);
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double, temp2_double);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- else if (per > opts->percent && ABS(temp1_double-temp2_double) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P, temp1_double, temp2_double,
- ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
+ nfound++;
}
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ else if (per > opts->percent && ABS(temp1_double-temp2_double) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ parallel_print(F_FORMAT_P, temp1_double, temp2_double,
+ ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double));
}
nfound++;
}
- mem1 += sizeof(double);
- mem2 += sizeof(double);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* i */
+ }
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ }
+ nfound++;
+ }
}
/*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
+ * no -d and -p
+ *-------------------------------------------------------------------------
+ */
else {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_double, mem1, sizeof(double));
- HDmemcpy(&temp2_double, mem2, sizeof(double));
-
- if (equal_double(temp1_double, temp2_double, opts) == FALSE) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
+ if (equal_double(temp1_double, temp2_double, opts) == FALSE) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
-
- mem1 += sizeof(double);
- mem2 += sizeof(double);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* nelmts */
+ nfound++;
+ }
}
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
return nfound;
}
/*-------------------------------------------------------------------------
- * Function: diff_ldouble
+ * Function: diff_ldouble_element
*
- * Purpose: diff a H5T_NATIVE_LDOUBLE type
+ * Purpose: diff a single H5T_NATIVE_LDOUBLE type
*
* Return: number of differences found
*-------------------------------------------------------------------------
*/
#if H5_SIZEOF_LONG_DOUBLE !=0
-static hsize_t diff_ldouble(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *opts,
- const char *obj1,
- const char *obj2,
- int *ph)
-
+static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
hsize_t nfound = 0; /* number of differences found */
long double temp1_double;
long double temp2_double;
- hsize_t i;
double per;
- hbool_t both_zero;
+ hbool_t both_zero = FALSE;
hbool_t isnan1 = FALSE;
hbool_t isnan2 = FALSE;
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
+
+ HDmemcpy(&temp1_double, mem1, sizeof(long double));
+ HDmemcpy(&temp2_double, mem2, sizeof(long double));
+
+ /* logic for detecting NaNs is different with options -d, -p and no options */
+
/*-------------------------------------------------------------------------
* -d and !-p
*-------------------------------------------------------------------------
*/
+ if (opts->delta_bool && !opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
+ }
- if (opts->d && !opts->p) {
- for ( i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_double, mem1, sizeof(long double));
- HDmemcpy(&temp2_double, mem2, sizeof(long double));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_double);
- isnan2 = HDisnan(temp2_double);
- }
-
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- if (ABS(temp1_double-temp2_double) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- }
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ if (ABS(temp1_double-temp2_double) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
-
}
- mem1 += sizeof(long double);
- mem2 += sizeof(long double);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* i */
+ } /* NaN */
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ }
+ nfound++;
+ }
}
-
/*-------------------------------------------------------------------------
* !-d and -p
*-------------------------------------------------------------------------
*/
- else if (!opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_double, mem1, sizeof(long double));
- HDmemcpy(&temp2_double, mem2, sizeof(long double));
+ else if (!opts->delta_bool && opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
+ }
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_double);
- isnan2 = HDisnan(temp2_double);
- }
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- PER(temp1_double, temp2_double);
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double,temp2_double);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P, temp1_double, temp2_double,
- ABS(temp1_double - temp2_double), ABS(1-temp2_double / temp1_double));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
+ nfound++;
}
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
if (print_data(opts)) {
- print_pos(ph, 0, hyper_start+i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double));
}
nfound++;
}
- mem1 += sizeof(long double);
- mem2 += sizeof(long double);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* i */
+ } /* NaN */
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ }
+ nfound++;
+ }
}
/*-------------------------------------------------------------------------
* -d and -p
*-------------------------------------------------------------------------
*/
- else if (opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_double, mem1, sizeof(long double));
- HDmemcpy(&temp2_double, mem2, sizeof(long double));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if (opts->do_nans) {
- isnan1 = HDisnan(temp1_double);
- isnan2 = HDisnan(temp2_double);
- }
+ else if (opts->delta_bool && opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
+ }
- /* both not NaN, do the comparison */
- if (!isnan1 && !isnan2) {
- PER(temp1_double, temp2_double);
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double,temp2_double);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- else if (per > opts->percent && ABS(temp1_double - temp2_double) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1-temp2_double / temp1_double));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
+ nfound++;
}
- /* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ else if (per > opts->percent && ABS(temp1_double-temp2_double) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double));
}
nfound++;
}
- mem1 += sizeof(long double);
- mem2 += sizeof(long double);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* i */
+ } /* NaN */
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ }
+ nfound++;
+ }
}
/*-------------------------------------------------------------------------
* no -d and -p
*-------------------------------------------------------------------------
*/
- else {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_double, mem1, sizeof(long double));
- HDmemcpy(&temp2_double, mem2, sizeof(long double));
-
- if (equal_ldouble(temp1_double, temp2_double, opts) == FALSE) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
- }
- nfound++;
- }
- mem1 += sizeof(long double);
- mem2 += sizeof(long double);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* nelmts */
+ else if (equal_ldouble(temp1_double, temp2_double, opts) == FALSE) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ }
+ nfound++;
}
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
+
return nfound;
}
#endif /* H5_SIZEOF_LONG_DOUBLE */
/*-------------------------------------------------------------------------
- * Function: diff_schar
+ * Function: diff_schar_element
*
- * Purpose: diff a H5T_NATIVE_SCHAR type
+ * Purpose: diff a single H5T_NATIVE_SCHAR type
*
* Return: number of differences found
*-------------------------------------------------------------------------
*/
-static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph)
-
+static hsize_t diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
hsize_t nfound = 0; /* number of differences found */
char temp1_char;
char temp2_char;
- hsize_t i;
double per;
- hbool_t both_zero;
+ hbool_t both_zero = FALSE;
- /* -d and !-p */
- if (opts->d && !opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
+ HDmemcpy(&temp1_char, mem1, sizeof(char));
+ HDmemcpy(&temp2_char, mem2, sizeof(char));
- if (ABS(temp1_char-temp2_char) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
- }
- nfound++;
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (ABS(temp1_char-temp2_char) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
}
- mem1 += sizeof(char);
- mem2 += sizeof(char);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* !-d and -p */
- else if (!opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
-
- PER(temp1_char, temp2_char);
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER(temp1_char, temp2_char);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
}
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per);
}
- mem1 += sizeof(char);
- mem2 += sizeof(char);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* -d and -p */
- else if (opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER(temp1_char, temp2_char);
- PER(temp1_char, temp2_char);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
}
- else if (per > opts->percent && ABS(temp1_char-temp2_char) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent && ABS(temp1_char - temp2_char) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per);
}
- mem1 += sizeof(char);
- mem2 += sizeof(char);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
- else {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
-
- if (temp1_char != temp2_char) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
- }
- nfound++;
- }
-
- mem1 += sizeof(char);
- mem2 += sizeof(char);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* nelmts */
+ else if (temp1_char != temp2_char) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
+ }
+ nfound++;
}
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
+
return nfound;
}
/*-------------------------------------------------------------------------
- * Function: diff_uchar
+ * Function: diff_uchar_element
*
- * Purpose: diff a H5T_NATIVE_UCHAR type
+ * Purpose: diff a single H5T_NATIVE_UCHAR type
*
* Return: number of differences found
*-------------------------------------------------------------------------
*/
-static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph)
+static hsize_t diff_uchar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
hsize_t nfound = 0; /* number of differences found */
unsigned char temp1_uchar;
unsigned char temp2_uchar;
- hsize_t i;
double per;
- hbool_t both_zero;
+ hbool_t both_zero = FALSE;
- /* -d and !-p */
- if (opts->d && !opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- if (PDIFF(temp1_uchar,temp2_uchar) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
- }
- nfound++;
+ HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (PDIFF(temp1_uchar, temp2_uchar) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
- mem1 += sizeof(unsigned char);
- mem2 += sizeof(unsigned char);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* !-d and -p */
- else if (!opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per);
}
- mem1 += sizeof(unsigned char);
- mem2 += sizeof(unsigned char);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* -d and -p */
- else if (opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
- else if (per > opts->percent && PDIFF(temp1_uchar,temp2_uchar) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent && PDIFF(temp1_uchar, temp2_uchar) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per);
}
- mem1 += sizeof(unsigned char);
- mem2 += sizeof(unsigned char);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
- else {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- if (temp1_uchar != temp2_uchar) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
- }
- nfound++;
- }
-
- mem1 += sizeof(unsigned char);
- mem2 += sizeof(unsigned char);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* nelmts */
+ else if (temp1_uchar != temp2_uchar) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
+ }
+ nfound++;
}
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
+
return nfound;
}
/*-------------------------------------------------------------------------
- * Function: diff_short
+ * Function: diff_short_element
*
* Purpose: diff a H5T_NATIVE_SHORT type
*
* Return: number of differences found
*-------------------------------------------------------------------------
*/
-static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph)
+static hsize_t diff_short_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
hsize_t nfound = 0; /* number of differences found */
short temp1_short;
short temp2_short;
- hsize_t i;
double per;
- hbool_t both_zero;
+ hbool_t both_zero = FALSE;
- /* -d and !-p */
- if (opts->d && !opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- if (ABS(temp1_short-temp2_short) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
- }
- nfound++;
+ HDmemcpy(&temp1_short, mem1, sizeof(short));
+ HDmemcpy(&temp2_short, mem2, sizeof(short));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (ABS(temp1_short - temp2_short) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
}
- mem1 += sizeof(short);
- mem2 += sizeof(short);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* !-d and -p */
- else if (!opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
-
- PER(temp1_short, temp2_short);
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER(temp1_short, temp2_short);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
}
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per);
}
- mem1 += sizeof(short);
- mem2 += sizeof(short);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* -d and -p */
- else if (opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
-
- PER(temp1_short, temp2_short);
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER(temp1_short, temp2_short);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
}
- else if (per > opts->percent && ABS(temp1_short-temp2_short) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent && ABS(temp1_short - temp2_short) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per);
}
- mem1 += sizeof(short);
- mem2 += sizeof(short);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
- else {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
-
- if (temp1_short != temp2_short) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
- }
- nfound++;
- }
-
- mem1 += sizeof(short);
- mem2 += sizeof(short);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* nelmts */
+ else if (temp1_short != temp2_short) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
+ }
+ nfound++;
}
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
+
return nfound;
}
/*-------------------------------------------------------------------------
- * Function: diff_ushort
+ * Function: diff_ushort_element
*
- * Purpose: diff a H5T_NATIVE_USHORT type
+ * Purpose: diff a single H5T_NATIVE_USHORT type
*
* Return: number of differences found
*-------------------------------------------------------------------------
*/
-static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph)
-
+static hsize_t diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
hsize_t nfound = 0; /* number of differences found */
unsigned short temp1_ushort;
unsigned short temp2_ushort;
- hsize_t i;
double per;
- hbool_t both_zero;
+ hbool_t both_zero = FALSE;
- /* -d and !-p */
- if (opts->d && !opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- if (PDIFF(temp1_ushort,temp2_ushort) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
- }
- nfound++;
+ HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
+ HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (PDIFF(temp1_ushort, temp2_ushort) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
}
- mem1 += sizeof(unsigned short);
- mem2 += sizeof(unsigned short);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* !-d and -p */
- else if (!opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
-
- PER_UNSIGN(signed short, temp1_ushort, temp2_ushort);
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed short, temp1_ushort, temp2_ushort);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
}
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per);
}
- mem1 += sizeof(unsigned short);
- mem2 += sizeof(unsigned short);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* -d and -p */
- else if (opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
-
- PER_UNSIGN(signed short, temp1_ushort, temp2_ushort);
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed short, temp1_ushort, temp2_ushort);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
}
- else if (per > opts->percent && PDIFF(temp1_ushort,temp2_ushort) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent && PDIFF(temp1_ushort, temp2_ushort) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per);
}
- mem1 += sizeof(unsigned short);
- mem2 += sizeof(unsigned short);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
- else {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
-
- if (temp1_ushort != temp2_ushort) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
- }
- nfound++;
- }
-
- mem1 += sizeof(unsigned short);
- mem2 += sizeof(unsigned short);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* nelmts */
+ else if (temp1_ushort != temp2_ushort) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
+ }
+ nfound++;
}
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
+
return nfound;
}
/*-------------------------------------------------------------------------
- * Function: diff_int
+ * Function: diff_int_element
*
- * Purpose: diff a H5T_NATIVE_INT type
+ * Purpose: diff a single H5T_NATIVE_INT type
*
* Return: number of differences found
*-------------------------------------------------------------------------
*/
-static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph)
+static hsize_t diff_int_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
hsize_t nfound = 0; /* number of differences found */
int temp1_int;
int temp2_int;
- hsize_t i;
double per;
- hbool_t both_zero;
+ hbool_t both_zero = FALSE;
- /* -d and !-p */
- if (opts->d && !opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- if (ABS(temp1_int-temp2_int) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
- }
- nfound++;
+ HDmemcpy(&temp1_int, mem1, sizeof(int));
+ HDmemcpy(&temp2_int, mem2, sizeof(int));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (ABS(temp1_int-temp2_int) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
}
- mem1 += sizeof(int);
- mem2 += sizeof(int);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* !-d and -p */
- else if (!opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
-
- PER(temp1_int, temp2_int);
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER(temp1_int, temp2_int);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
}
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per);
}
- mem1 += sizeof(int);
- mem2 += sizeof(int);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* -d and -p */
- else if (opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER(temp1_int, temp2_int);
- PER(temp1_int, temp2_int);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
}
- else if (per > opts->percent && ABS(temp1_int-temp2_int) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent && ABS(temp1_int - temp2_int) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per);
}
- mem1 += sizeof(int);
- mem2 += sizeof(int);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
- else {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
-
- if (temp1_int != temp2_int) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
- }
- nfound++;
- }
+ else if (temp1_int != temp2_int) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
+ }
+ nfound++;
+ }
- mem1 += sizeof(int);
- mem2 += sizeof(int);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* nelmts */
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
- }
return nfound;
}
/*-------------------------------------------------------------------------
- * Function: diff_uint
+ * Function: diff_uint_element
*
- * Purpose: diff a H5T_NATIVE_UINT type
+ * Purpose: diff a single H5T_NATIVE_UINT type
*
* Return: number of differences found
*-------------------------------------------------------------------------
*/
-static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph)
+static hsize_t diff_uint_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
hsize_t nfound = 0; /* number of differences found */
unsigned int temp1_uint;
unsigned int temp2_uint;
- hsize_t i;
double per;
- hbool_t both_zero;
+ hbool_t both_zero = FALSE;
- /* -d and !-p */
- if (opts->d && !opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- if (PDIFF(temp1_uint,temp2_uint) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
- }
- nfound++;
+ HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
+ HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (PDIFF(temp1_uint, temp2_uint) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
}
- mem1 += sizeof(unsigned int);
- mem2 += sizeof(unsigned int);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* !-d and -p */
- else if (!opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
-
- PER_UNSIGN(signed int, temp1_uint, temp2_uint);
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed int, temp1_uint, temp2_uint);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
}
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(UI_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per);
}
- mem1 += sizeof(unsigned int);
- mem2 += sizeof(unsigned int);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* -d and -p */
- else if (opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed int, temp1_uint, temp2_uint);
- PER_UNSIGN(signed int, temp1_uint, temp2_uint);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
}
- else if (per > opts->percent
- && PDIFF(temp1_uint,temp2_uint) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent && PDIFF(temp1_uint,temp2_uint) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(UI_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per);
}
- mem1 += sizeof(unsigned int);
- mem2 += sizeof(unsigned int);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
- else {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
-
- if (temp1_uint != temp2_uint) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
- }
- nfound++;
- }
-
- mem1 += sizeof(unsigned int);
- mem2 += sizeof(unsigned int);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* nelmts */
+ else if (temp1_uint != temp2_uint) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
+ }
+ nfound++;
}
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
+
return nfound;
}
/*-------------------------------------------------------------------------
- * Function: diff_long
+ * Function: diff_long_element
*
- * Purpose: diff a H5T_NATIVE_LONG type
+ * Purpose: diff a single H5T_NATIVE_LONG type
*
* Return: number of differences found
*-------------------------------------------------------------------------
*/
-static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph)
+static hsize_t diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
hsize_t nfound = 0; /* number of differences found */
long temp1_long;
long temp2_long;
- hsize_t i;
double per;
- hbool_t both_zero;
+ hbool_t both_zero = FALSE;
- /* -d and !-p */
- if (opts->d && !opts->p) {
- for (i = 0; i < nelmts; i++) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- if (ABS(temp1_long-temp2_long) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
- }
- nfound++;
- }
- mem1 += sizeof(long);
- mem2 += sizeof(long);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ HDmemcpy(&temp1_long, mem1, sizeof(long));
+ HDmemcpy(&temp2_long, mem2, sizeof(long));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (ABS(temp1_long-temp2_long) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
}
+ nfound++;
}
}
/* !-d and -p */
- else if (!opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER(temp1_long, temp2_long);
- PER(temp1_long, temp2_long);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
}
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per);
}
- mem1 += sizeof(long);
- mem2 += sizeof(long);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* -d and -p */
- else if (opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER(temp1_long, temp2_long);
- PER(temp1_long, temp2_long);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
}
- else if (per > opts->percent && ABS(temp1_long-temp2_long) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent && ABS(temp1_long-temp2_long) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per);
}
- mem1 += sizeof(long);
- mem2 += sizeof(long);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
- else {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
-
- if (temp1_long != temp2_long) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
- }
- nfound++;
- }
-
- mem1 += sizeof(long);
- mem2 += sizeof(long);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* nelmts */
+ else if (temp1_long != temp2_long) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
+ }
+ nfound++;
}
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
+
return nfound;
}
/*-------------------------------------------------------------------------
- * Function: diff_ulong
+ * Function: diff_ulong_element
*
- * Purpose: diff a H5T_NATIVE_ULONG type
+ * Purpose: diff a single H5T_NATIVE_ULONG type
*
* Return: number of differences found
*-------------------------------------------------------------------------
*/
-static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph)
+static hsize_t diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
hsize_t nfound = 0; /* number of differences found */
unsigned long temp1_ulong;
unsigned long temp2_ulong;
- hsize_t i;
double per;
- hbool_t both_zero;
+ hbool_t both_zero = FALSE;
- /* -d and !-p */
- if (opts->d && !opts->p) {
- for (i = 0; i < nelmts; i++) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- if (PDIFF(temp1_ulong,temp2_ulong) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
- }
- nfound++;
- }
- mem1 += sizeof(unsigned long);
- mem2 += sizeof(unsigned long);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
+ HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (PDIFF(temp1_ulong, temp2_ulong) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
}
+ nfound++;
}
}
/* !-d and -p */
- else if (!opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed long, temp1_ulong, temp2_ulong);
- PER_UNSIGN(signed long, temp1_ulong, temp2_ulong);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
}
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(ULI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per);
}
- mem1 += sizeof(unsigned long);
- mem2 += sizeof(unsigned long);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* -d and -p */
- else if (opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
-
- PER_UNSIGN(signed long, temp1_ulong, temp2_ulong);
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed long, temp1_ulong, temp2_ulong);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
}
- else if (per > opts->percent
- && PDIFF(temp1_ulong,temp2_ulong) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent && PDIFF(temp1_ulong,temp2_ulong) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(ULI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per);
}
- mem1 += sizeof(unsigned long);
- mem2 += sizeof(unsigned long);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
- else {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
-
- if (temp1_ulong != temp2_ulong) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
- }
- nfound++;
- }
-
- mem1 += sizeof(unsigned long);
- mem2 += sizeof(unsigned long);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* nelmts */
+ else if (temp1_ulong != temp2_ulong) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
+ }
+ nfound++;
}
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
+
return nfound;
}
/*-------------------------------------------------------------------------
- * Function: diff_llong
+ * Function: diff_llong_element
*
- * Purpose: diff a H5T_NATIVE_LLONG type
+ * Purpose: diff a single H5T_NATIVE_LLONG type
*
* Return: number of differences found
*-------------------------------------------------------------------------
*/
-static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims,
- hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1,
- const char *obj2, int *ph)
+static hsize_t diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
hsize_t nfound = 0; /* number of differences found */
long long temp1_llong;
long long temp2_llong;
- hsize_t i;
double per;
- hbool_t both_zero;
+ hbool_t both_zero = FALSE;
- /* -d and !-p */
- if (opts->d && !opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- if (ABS( temp1_llong-temp2_llong) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
- }
- nfound++;
+ HDmemcpy(&temp1_llong, mem1, sizeof(long long));
+ HDmemcpy(&temp2_llong, mem2, sizeof(long long));
+
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (ABS( temp1_llong-temp2_llong) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
}
- mem1 += sizeof(long long);
- mem2 += sizeof(long long);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* !-d and -p */
- else if (!opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
-
- PER(temp1_llong, temp2_llong);
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER(temp1_llong, temp2_llong);
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
}
nfound++;
}
else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong),per);
}
nfound++;
}
- mem1 += sizeof(long long);
- mem2 += sizeof(long long);
- if (opts->n && nfound >= opts->count)
- return nfound;
- }
}
/* -d and -p */
- else if (opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER(temp1_llong, temp2_llong);
- PER(temp1_llong, temp2_llong);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
}
- else if (per > opts->percent
- && ABS(temp1_llong-temp2_llong) > opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong),per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent && ABS(temp1_llong-temp2_llong) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong),per);
}
- mem1 += sizeof(long long);
- mem2 += sizeof(long long);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
else {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
-
- if (temp1_llong != temp2_llong) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
- }
- nfound++;
+ if (temp1_llong != temp2_llong) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
}
-
- mem1 += sizeof(long long);
- mem2 += sizeof(long long);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* nelmts */
+ nfound++;
+ }
}
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
+
return nfound;
}
/*-------------------------------------------------------------------------
- * Function: diff_ullong
+ * Function: diff_ullong_element
*
- * Purpose: diff a H5T_NATIVE_ULLONG type
+ * Purpose: diff a single H5T_NATIVE_ULLONG type
*
* Return: number of differences found
*-------------------------------------------------------------------------
*/
-static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2,
- hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, hsize_t *acc,
- hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph)
-
+static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
hsize_t nfound = 0; /* number of differences found */
unsigned long long temp1_ullong;
unsigned long long temp2_ullong;
- hsize_t i;
float f1, f2;
double per;
- hbool_t both_zero;
+ hbool_t both_zero = FALSE;
- /* -d and !-p */
- if (opts->d && !opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- if (PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
+ HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
+ HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
+
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(ULLI_FORMAT, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong));
}
- mem1 += sizeof(unsigned long long);
- mem2 += sizeof(unsigned long long);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* !-d and -p */
- else if (!opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
-
- ull2float(temp1_ullong, &f1);
- ull2float(temp2_ullong, &f2);
- PER(f1, f2);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
+ else if (!opts->delta_bool && opts->percent_bool) {
+ ull2float(temp1_ullong, &f1);
+ ull2float(temp2_ullong, &f2);
+ PER(f1, f2);
+
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(ULLI_FORMAT_P_NOTCOMP, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong));
}
- else if (per > opts->percent) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(ULLI_FORMAT_P, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong,temp2_ullong), per);
}
- mem1 += sizeof(unsigned long long);
- mem2 += sizeof(unsigned long long);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
/* -d and -p */
- else if (opts->d && opts->p) {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
-
- ull2float(temp1_ullong, &f1);
- ull2float(temp2_ullong, &f2);
- PER(f1, f2);
-
- if (not_comparable && !both_zero) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
+ else if (opts->delta_bool && opts->percent_bool) {
+ ull2float(temp1_ullong, &f1);
+ ull2float(temp2_ullong, &f2);
+ PER(f1, f2);
+
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(ULLI_FORMAT_P_NOTCOMP, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong));
}
- else if (per > opts->percent
- && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) {
- if (print_data(opts)) {
- print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
- }
- nfound++;
+ nfound++;
+ }
+ else if (per > opts->percent && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(ULLI_FORMAT_P, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong), per);
}
- mem1 += sizeof(unsigned long long);
- mem2 += sizeof(unsigned long long);
- if (opts->n && nfound >= opts->count)
- return nfound;
+ nfound++;
}
}
else {
- for (i = 0; i < nelmts; i++) {
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
-
- if (temp1_ullong != temp2_ullong) {
- if (print_data(opts)) {
- print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
+ if (temp1_ullong != temp2_ullong) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, -1);
+ if (print_data(opts)) {
+ parallel_print(ULLI_FORMAT, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong));
}
-
- mem1 += sizeof(unsigned long long);
- mem2 += sizeof(unsigned long long);
- if (opts->n && nfound >= opts->count)
- return nfound;
- } /* nelmts */
+ nfound++;
+ }
}
+ H5TOOLS_ENDDEBUG(": %d zero:%d", nfound, both_zero);
return nfound;
}
@@ -4681,7 +3214,7 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *opts) {
static
int print_data(diff_opt_t *opts)
{
- return ((opts->m_report || opts->m_verbose) && !opts->m_quiet) ? 1 : 0;
+ return ((opts->mode_report || opts->mode_verbose) && !opts->mode_quiet) ? 1 : 0;
}
/*-------------------------------------------------------------------------
@@ -4691,25 +3224,24 @@ int print_data(diff_opt_t *opts)
*-------------------------------------------------------------------------
*/
static
-void print_header(int pp, /* print percentage */
- int rank, hsize_t *dims, const char *obj1, const char *obj2)
+void print_header(diff_opt_t *opts)
{
/* print header */
parallel_print("%-16s", "size:");
- print_dimensions(rank, dims);
+ print_dimensions(opts->rank, opts->dims);
parallel_print("%-11s", "");
- print_dimensions(rank, dims);
+ print_dimensions(opts->rank, opts->dims);
parallel_print("\n");
- if (pp) {
+ if (opts->print_percentage) {
parallel_print("%-15s %-15s %-15s %-15s %-15s\n", "position",
- (obj1 != NULL) ? obj1 : " ", (obj2 != NULL) ? obj2 : " ", "difference", "relative");
+ opts->obj_name[0], opts->obj_name[1], "difference", "relative");
parallel_print(
"------------------------------------------------------------------------\n");
}
else {
parallel_print("%-15s %-15s %-15s %-20s\n", "position",
- (obj1 != NULL) ? obj1 : " ", (obj2 != NULL) ? obj2 : " ", "difference");
+ opts->obj_name[0], opts->obj_name[1], "difference");
parallel_print(
"------------------------------------------------------------\n");
}
@@ -4722,77 +3254,93 @@ void print_header(int pp, /* print percentage */
*-------------------------------------------------------------------------
*/
static
-void print_pos(int *ph, /* print header */
- int pp, /* print percentage */
- hsize_t curr_pos, hsize_t *acc, hsize_t *pos, int rank, hsize_t *dims,
- const char *obj1, const char *obj2)
+void print_pos(diff_opt_t *opts, hsize_t idx, ssize_t u)
{
- int i;
-
- /* print header */
- if (*ph == 1) {
- *ph = 0;
-
- print_header(pp, rank, dims, obj1, obj2);
- } /* end print header */
-
- for (i = 0; i < rank; i++) {
- pos[i] = curr_pos / acc[i];
- curr_pos -= acc[i] * pos[i];
- }
- HDassert(curr_pos == 0);
+ int i,j;
+
+ H5TOOLS_START_DEBUG(" -- idx:%ld", idx);
+
+ if (print_data(opts)) {
+ /* print header */
+ if (opts->print_header == 1) {
+ opts->print_header = 0;
+
+ print_header(opts);
+ } /* end print header */
+
+ H5TOOLS_DEBUG("rank=%d", opts->rank);
+ if(opts->rank > 0) {
+ hsize_t curr_pos = idx;
+
+ parallel_print("[ ");
+ H5TOOLS_DEBUG("do calc_acc_pos[%ld] nelmts:%d - errstat:%d", i, opts->hs_nelmts, opts->err_stat);
+
+ if (opts->sset[0] != NULL) {
+ /* Subsetting is used - calculate total position */
+ hsize_t elmnt_cnt = 1;
+ hsize_t dim_cnt = 0; /* previous dim size */
+ hsize_t str_cnt = 0; /* previous dim stride */
+ hsize_t curr_idx = idx; /* calculated running position */
+ hsize_t str_idx = 0;
+ hsize_t blk_idx = 0;
+ hsize_t cnt_idx = 0;
+ hsize_t hs_idx = 0;
+ j = opts->rank-1;
+ do {
+ cnt_idx = opts->sset[0]->count.data[j]; /* Count value for current dim */
+ H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - count:%ld", j, curr_pos, curr_idx, cnt_idx);
+ blk_idx = opts->sset[0]->block.data[j]; /* Block value for current dim */
+ H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - block:%ld", j, curr_pos, curr_idx, blk_idx);
+ hs_idx = cnt_idx * blk_idx; /* hyperslab area value for current dim */
+ H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - hs:%ld", j, curr_pos, curr_idx, hs_idx);
+ str_idx = opts->sset[0]->stride.data[j]; /* Stride value for current dim */
+ H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - stride:%ld", j, curr_pos, curr_idx, str_idx);
+ elmnt_cnt *= opts->dims[j]; /* Total number of elements in dimension */
+ H5TOOLS_DEBUG("... sset loop:%d with elmnt_cnt:%ld", j, elmnt_cnt);
+ if (str_idx > blk_idx)
+ curr_idx += dim_cnt * (str_idx - blk_idx); /* */
+ else if (curr_idx >= hs_idx)
+ curr_idx += dim_cnt * str_cnt;
+ H5TOOLS_DEBUG("... sset loop:%d with idx:%ld (curr_idx:%ld) - stride:%ld", j, idx, curr_idx, str_idx);
+ dim_cnt = elmnt_cnt; /* */
+ if (str_idx > blk_idx)
+ str_cnt = str_idx - blk_idx; /* */
+ else
+ str_cnt = str_idx; /* */
+ H5TOOLS_DEBUG("... sset loop:%d with dim_cnt:%ld - str_cnt:%ld", j, dim_cnt, str_cnt);
+ j--;
+ } while (curr_idx >= elmnt_cnt && j >= 0);
+ curr_pos = curr_idx; /* New current position */
+ H5TOOLS_DEBUG("pos loop:%d,%d with elmnt_cnt:%ld - curr_pos:%ld", i, j, elmnt_cnt, curr_pos);
+ } /* if (opts->sset[0] != NULL) */
+ /*
+ * Calculate the number of elements represented by a unit change in a
+ * certain index position.
+ */
+ calc_acc_pos(opts->rank, curr_pos, opts->acc, opts->pos);
- if (rank > 0) {
- parallel_print("[ ");
- for (i = 0; i < rank; i++) {
- parallel_print(HSIZE_T_FORMAT, (unsigned long long)pos[i]);
- parallel_print(" ");
+ for (i = 0; i < opts->rank; i++) {
+ H5TOOLS_DEBUG("pos loop:%d with opts->pos=%ld opts->sm_pos=%ld", i, opts->pos[i], opts->sm_pos[i]);
+ opts->pos[i] += (unsigned long) opts->sm_pos[i];
+ H5TOOLS_DEBUG("pos loop:%d with opts->pos=%ld", i, opts->pos[i]);
+ parallel_print(HSIZE_T_FORMAT, (unsigned long long)opts->pos[i]);
+ parallel_print(" ");
+ }
+ parallel_print("]");
}
- parallel_print("]");
- }
- else
- parallel_print(" ");
-}
-
-/*-------------------------------------------------------------------------
- * Function: print_char_pos
- *
- * Purpose: print character position in string
- *-------------------------------------------------------------------------
- */
-static
-void print_char_pos(int *ph, /* print header */
- int pp, /* print percentage */
- hsize_t curr_pos, size_t u, hsize_t *acc, hsize_t *pos, int rank, hsize_t *dims,
- const char *obj1, const char *obj2)
-{
- int i;
-
- /* print header */
- if (*ph == 1) {
- *ph = 0;
-
- print_header(pp, rank, dims, obj1, obj2);
- } /* end print header */
-
- for (i = 0; i < rank; i++) {
- pos[i] = curr_pos / acc[i];
- curr_pos -= acc[i] * pos[i];
- }
- HDassert(curr_pos == 0);
-
- parallel_print("[ ");
- if (rank > 0) {
- for (i = 0; i < rank; i++) {
- parallel_print(HSIZE_T_FORMAT, (unsigned long long)pos[i]);
- parallel_print(" ");
+ else {
+ if (u >= 0) {
+ parallel_print("[ ");
+ parallel_print("%zu", u);
+ parallel_print("]");
+ }
+ else
+ parallel_print(" ");
}
-
+ parallel_print(SPACES);
}
- else
- parallel_print("%zu", u);
- parallel_print("]");
+ H5TOOLS_ENDDEBUG("");
}
/*-------------------------------------------------------------------------
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 5ad29fc..774859b 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -137,7 +137,7 @@ static void table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *ta
* Parameter:
* table_out [OUT] : return the list
*------------------------------------------------------------------------*/
-static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *opts)
+static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *opts)
{
table_attrs_t *table_lp = NULL;
H5O_info2_t oinfo1, oinfo2; /* Object info */
@@ -171,8 +171,8 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
* build the list
*/
while(curr1 < oinfo1.num_attrs && curr2 < oinfo2.num_attrs) {
- H5TOOLS_DEBUG("build_match_list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs);
- H5TOOLS_DEBUG("build_match_list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs);
+ H5TOOLS_DEBUG("list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs);
+ H5TOOLS_DEBUG("list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs);
/*------------------
* open attribute1 */
@@ -226,7 +226,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
infile[0] = 1;
infile[1] = 0;
while(curr1 < oinfo1.num_attrs) {
- H5TOOLS_DEBUG("build_match_list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs);
+ H5TOOLS_DEBUG("list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs);
/*------------------
* open attribute1 */
@@ -235,7 +235,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
/* get name */
if(H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0)
H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name first attribute failed");
- H5TOOLS_DEBUG("build_match_list_attrs #1 name - %s", name1);
+ H5TOOLS_DEBUG("list_attrs 1 name - %s", name1);
table_attr_mark_exist(infile, name1, table_lp);
table_lp->nattrs_only1++;
@@ -250,7 +250,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
infile[0] = 0;
infile[1] = 1;
while(curr2 < oinfo2.num_attrs) {
- H5TOOLS_DEBUG("build_match_list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs);
+ H5TOOLS_DEBUG("list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs);
/*------------------
* open attribute2 */
if((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, H5P_DEFAULT)) < 0)
@@ -258,7 +258,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
/* get name */
if(H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0)
H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name second attribute failed");
- H5TOOLS_DEBUG("build_match_list_attrs #2 name - %s", name2);
+ H5TOOLS_DEBUG("list_attrs 2 name - %s", name2);
table_attr_mark_exist(infile, name2, table_lp);
table_lp->nattrs_only2++;
@@ -272,7 +272,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
/*------------------------------------------------------
* print the list
*/
- if(opts->m_verbose_level == 2) {
+ if(opts->mode_verbose_level == 2) {
/* if '-v2' is detected */
parallel_print(" obj1 obj2\n");
parallel_print(" --------------------------------------\n");
@@ -284,7 +284,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
} /* end for */
}
- if(opts->m_verbose_level >= 1)
+ if(opts->mode_verbose_level >= 1)
parallel_print("Attributes status: %d common, %d only in obj1, %d only in obj2\n",
table_lp->nattrs - table_lp->nattrs_only1 - table_lp->nattrs_only2,
table_lp->nattrs_only1, table_lp->nattrs_only2);
@@ -313,7 +313,8 @@ done:
*-------------------------------------------------------------------------
*/
-hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const char *name2, const char *path1, const char *path2, diff_opt_t *opts)
+hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id,
+ const char *name1, const char *name2, const char *path1, const char *path2, diff_opt_t *opts)
{
hid_t space1_id = H5I_INVALID_HID; /* space ID */
hid_t space2_id = H5I_INVALID_HID; /* space ID */
@@ -327,19 +328,15 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const
void *buf2 = NULL; /* data buffer */
hbool_t buf1hasdata = FALSE; /* buffer has data */
hbool_t buf2hasdata = FALSE; /* buffer has data */
- hsize_t nelmts1; /* number of elements in dataset */
int rank1; /* rank of dataset */
int rank2; /* rank of dataset */
hsize_t dims1[H5S_MAX_RANK]; /* dimensions of dataset */
hsize_t dims2[H5S_MAX_RANK]; /* dimensions of dataset */
- char np1[512];
- char np2[512];
hsize_t nfound = 0;
int j;
diff_err_t ret_value = opts->err_stat;
H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
-
/* get the datatypes */
if((ftype1_id = H5Aget_type(attr1_id)) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed");
@@ -383,11 +380,32 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const
* check for comparable TYPE and SPACE
*----------------------------------------------------------------------
*/
- H5TOOLS_DEBUG("diff_attr_data check for comparable TYPE and SPACE");
+ H5TOOLS_DEBUG("Check for comparable TYPE and SPACE");
+
+ H5TOOLS_DEBUG("attr_names: %s - %s", name1, name2);
+ if (name1) {
+ j = (int)HDstrlen(name1);
+ H5TOOLS_DEBUG("attr1_name: %s - %d", name1, j);
+ if (j > 0) {
+ opts->obj_name[0] = (char *)HDcalloc((size_t)j + 1, sizeof(char));
+ HDstrncpy(opts->obj_name[0], name1, (size_t)j);
+ opts->obj_name[0][j] = '\0';
+ }
+ }
+ if (name2) {
+ j = (int)HDstrlen(name2);
+ H5TOOLS_DEBUG("attr2_name: %s - %d", name2, j);
+ if (j > 0) {
+ opts->obj_name[1] = (char *)HDcalloc((size_t)j + 1, sizeof(char));
+ HDstrncpy(opts->obj_name[1], name2, (size_t)j);
+ opts->obj_name[1][j] = '\0';
+ }
+ }
+ H5TOOLS_DEBUG("attr_names: %s - %s", opts->obj_name[0], opts->obj_name[1]);
/* pass dims1 and dims2 for maxdims as well since attribute's maxdims
* are always same */
- if(diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2, dims1, dims2, name1, name2, opts, 0) == 1) {
+ if(diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2, dims1, dims2, opts, 0) == 1) {
/*-----------------------------------------------------------------
* "upgrade" the smaller memory size
*------------------------------------------------------------------
@@ -395,17 +413,26 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const
if(FAIL == match_up_memsize(ftype1_id, ftype2_id, &mtype1_id, &mtype2_id, &msize1, &msize2))
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "match_up_memsize failed");
- H5TOOLS_DEBUG("diff_attr_data read");
+ H5TOOLS_DEBUG("initialize read");
/*---------------------------------------------------------------------
- * read
+ * initialize diff_opt_t structure for dimensions
*----------------------------------------------------------------------
*/
- nelmts1 = 1;
- for(j = 0; j < rank1; j++)
- nelmts1 *= dims1[j];
+ opts->nelmts = 1;
+ for(j = 0; j < rank1; j++) {
+ opts->dims[j] = dims1[j];
+ opts->nelmts *= dims1[j];
+ }
+ opts->rank = rank1;
+ init_acc_pos(opts->rank, opts->dims, opts->acc, opts->pos, opts->p_min_idx);
- buf1 = (void *)HDcalloc((size_t)(nelmts1), msize1);
- buf2 = (void *)HDcalloc((size_t)(nelmts1), msize2);
+ /*---------------------------------------------------------------------
+ * read
+ *----------------------------------------------------------------------
+ */
+ buf1 = (void *)HDcalloc((size_t)(opts->nelmts), msize1);
+ buf2 = (void *)HDcalloc((size_t)(opts->nelmts), msize2);
+ H5TOOLS_DEBUG("attr buffer size %ld * %ld", opts->nelmts, msize1);
if(buf1 == NULL || buf2 == NULL) {
parallel_print("cannot read into memory\n");
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "buffer allocation failed");
@@ -416,6 +443,7 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const
}
else
buf1hasdata = TRUE;
+ H5TOOLS_DEBUG("attr H5Aread 1");
if(H5Aread(attr2_id, mtype2_id, buf2) < 0) {
parallel_print("Failed reading attribute2 %s\n", name2);
@@ -423,49 +451,84 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const
}
else
buf2hasdata = TRUE;
+ H5TOOLS_DEBUG("attr H5Aread 2");
/* format output string */
- HDsnprintf(np1, sizeof(np1), "%s of <%s>", name1, path1);
- HDsnprintf(np2, sizeof(np1), "%s of <%s>", name2, path2);
+ if (opts->obj_name[0] != NULL)
+ HDfree(opts->obj_name[0]);
+ opts->obj_name[0] = NULL;
+ if (opts->obj_name[1] != NULL)
+ HDfree(opts->obj_name[1]);
+ opts->obj_name[1] = NULL;
+
+ H5TOOLS_DEBUG("attr_names: %s - %s : %s - %s", name1, name2, path1, path2);
+ if (name1) {
+ j = (int)HDstrlen(name1) + (int)HDstrlen(path1) + 7;
+ H5TOOLS_DEBUG("attr1_name: %s - %d", name1, j);
+ if (j > 0) {
+ opts->obj_name[0] = (char *)HDcalloc((size_t)j + 1, sizeof(char));
+ HDsnprintf(opts->obj_name[0], j, "%s of <%s>", name1, path1);
+ opts->obj_name[0][j] = '\0';
+ }
+ }
+ if (name2) {
+ j = (int)HDstrlen(name2) + (int)HDstrlen(path2) + 7;
+ H5TOOLS_DEBUG("attr2_name: %s - %d", name2, j);
+ if (j > 0) {
+ opts->obj_name[1] = (char *)HDcalloc((size_t)j + 1, sizeof(char));
+ HDsnprintf(opts->obj_name[1], j, "%s of <%s>", name2, path2);
+ opts->obj_name[1][j] = '\0';
+ }
+ }
/*---------------------------------------------------------------------
* array compare
*----------------------------------------------------------------------
*/
- H5TOOLS_DEBUG("diff_attr_data array compare %s - %s", name1, name1);
+ H5TOOLS_DEBUG("array compare %s - %s", opts->obj_name[0], opts->obj_name[1]);
+
+ opts->hs_nelmts = opts->nelmts;
+ opts->m_tid = mtype1_id;
+
+ /* initialize the current stripmine position; this is necessary to print the array indices */
+ for (j = 0; j < opts->rank; j++)
+ opts->sm_pos[j] = (hsize_t)0;
/* always print name */
/* verbose (-v) and report (-r) mode */
- if(opts->m_verbose || opts->m_report) {
- do_print_attrname("attribute", np1, np2);
+ if(opts->mode_verbose || opts->mode_report) {
+ do_print_attrname("attribute", opts->obj_name[0], opts->obj_name[1]);
- nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1,
- dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id);
+ nfound = diff_array(buf1, buf2, opts, attr1_id, attr2_id);
print_found(nfound);
}
/* quiet mode (-q), just count differences */
- else if(opts->m_quiet) {
- nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1,
- dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id);
+ else if(opts->mode_quiet) {
+ nfound = diff_array(buf1, buf2, opts, attr1_id, attr2_id);
}
/* the rest (-c, none, ...) */
else {
- nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1,
- dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id);
+ nfound = diff_array(buf1, buf2, opts, attr1_id, attr2_id);
/* print info if compatible and difference found */
if (nfound) {
- do_print_attrname("attribute", np1, np2);
+ do_print_attrname("attribute", opts->obj_name[0], opts->obj_name[1]);
print_found(nfound);
} /* end if */
} /* end else */
}
- H5TOOLS_DEBUG("diff_attr_data check for comparable TYPE and SPACE complete nfound:%d - errstat:%d", nfound, opts->err_stat);
+ H5TOOLS_DEBUG("check for comparable TYPE and SPACE complete nfound:%d - errstat:%d", nfound, opts->err_stat);
/*----------------------------------------------------------------------
* close
*----------------------------------------------------------------------
*/
+ if (opts->obj_name[0] != NULL)
+ HDfree(opts->obj_name[0]);
+ opts->obj_name[0] = NULL;
+ if (opts->obj_name[1] != NULL)
+ HDfree(opts->obj_name[1]);
+ opts->obj_name[1] = NULL;
/* Free buf1 and buf2, check both VLEN-data VLEN-string to reclaim any
* VLEN memory first */
@@ -543,28 +606,32 @@ hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *p
unsigned u; /* Local index variable */
hsize_t nfound = 0;
hsize_t nfound_total = 0;
+ diff_opt_t attr_opts;
diff_err_t ret_value = opts->err_stat;
H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
+ attr_opts = *opts;
+ attr_opts.obj_name[0] = NULL;
+ attr_opts.obj_name[1] = NULL;
- if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, opts) < 0) {
+ if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, &attr_opts) < 0) {
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "build_match_list_attrs failed");
}
- H5TOOLS_DEBUG("build_match_list_attrs - errstat:%d", opts->err_stat);
+ H5TOOLS_DEBUG("check match_list_attrs - opts->contents:%d - errstat:%d", attr_opts.contents, attr_opts.err_stat);
/* if detect any unique extra attr */
if(match_list_attrs->nattrs_only1 || match_list_attrs->nattrs_only2) {
- H5TOOLS_DEBUG("diff_attr attributes only in one file");
+ H5TOOLS_DEBUG("attributes only in one file");
/* exit will be 1 */
- opts->contents = 0;
+ attr_opts.contents = 0;
}
- H5TOOLS_DEBUG("match_list_attrs info - errstat:%d", opts->err_stat);
+ H5TOOLS_DEBUG("match_list_attrs info - opts->contents:%d", attr_opts.contents);
for(u = 0; u < (unsigned)match_list_attrs->nattrs; u++) {
- H5TOOLS_DEBUG("match_list_attrs loop[%d] - errstat:%d", u, opts->err_stat);
+ H5TOOLS_DEBUG("match_list_attrs loop[%d] - errstat:%d", u, attr_opts.err_stat);
if((match_list_attrs->attrs[u].exist[0]) && (match_list_attrs->attrs[u].exist[1])) {
name1 = name2 = match_list_attrs->attrs[u].name;
- H5TOOLS_DEBUG("diff_attr name - %s", name1);
+ H5TOOLS_DEBUG("name - %s", name1);
/*--------------
* attribute 1 */
@@ -576,8 +643,8 @@ hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *p
if((attr2_id = H5Aopen(loc2_id, name2, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aopen second attribute failed");
- H5TOOLS_DEBUG("diff_attr got attributes");
- nfound = diff_attr_data(attr1_id, attr2_id, name1, name2, path1, path2, opts);
+ H5TOOLS_DEBUG("got attributes");
+ nfound = diff_attr_data(attr1_id, attr2_id, name1, name2, path1, path2, &attr_opts);
if(H5Aclose(attr1_id) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed");
if(H5Aclose(attr2_id) < 0)
@@ -588,7 +655,10 @@ hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *p
} /* u */
done:
- opts->err_stat = opts->err_stat | ret_value;
+ opts->print_header = attr_opts.print_header;
+ opts->contents = attr_opts.contents;
+ opts->not_cmp = attr_opts.not_cmp;
+ opts->err_stat = attr_opts.err_stat | ret_value;
H5E_BEGIN_TRY {
table_attrs_free(match_list_attrs);
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index cea20a8..602255e 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -27,7 +27,8 @@
* Return: Number of differences found
*-------------------------------------------------------------------------
*/
-hsize_t diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, const char *obj2_name, diff_opt_t *opts)
+hsize_t
+diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, const char *obj2_name, diff_opt_t *opts)
{
int status = -1;
hid_t did1 = H5I_INVALID_HID;
@@ -35,9 +36,15 @@ hsize_t diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, cons
hid_t dcpl1 = H5I_INVALID_HID;
hid_t dcpl2 = H5I_INVALID_HID;
hsize_t nfound = 0;
+ diff_opt_t diff_opts;
diff_err_t ret_value = opts->err_stat;
H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
+ diff_opts = *opts;
+ diff_opts.obj_name[0] = NULL;
+ diff_opts.obj_name[1] = NULL;
+
+ H5TOOLS_DEBUG("obj_names: %s - %s", obj1_name, obj2_name);
/*-------------------------------------------------------------------------
* open the handles
*-------------------------------------------------------------------------
@@ -64,20 +71,22 @@ hsize_t diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, cons
* 2) the internal filters might be turned off
*-------------------------------------------------------------------------
*/
- H5TOOLS_DEBUG("diff_dataset h5tools_canreadf then diff_datasetid");
- if ((status = h5tools_canreadf((opts->m_verbose ? obj1_name : NULL), dcpl1) == 1) &&
- (status = h5tools_canreadf((opts->m_verbose ? obj2_name : NULL), dcpl2) == 1))
- nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, opts);
+ H5TOOLS_DEBUG("h5tools_canreadf then diff_datasetid");
+ if ((status = h5tools_canreadf((opts->mode_verbose ? obj1_name : NULL), dcpl1) == 1) &&
+ (status = h5tools_canreadf((opts->mode_verbose ? obj2_name : NULL), dcpl2) == 1))
+ nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, &diff_opts);
else if (status < 0) {
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "h5tools_canreadf failed");
}
else {
ret_value = 1;
- opts->not_cmp = 1;
+ diff_opts.not_cmp = 1;
}
done:
- opts->err_stat = opts->err_stat | ret_value;
+ opts->print_header = diff_opts.print_header;
+ opts->not_cmp = diff_opts.not_cmp;
+ opts->err_stat = diff_opts.err_stat | ret_value;
/* disable error reporting */
H5E_BEGIN_TRY {
@@ -143,36 +152,31 @@ done:
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_name, diff_opt_t *opts)
+hsize_t
+diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_name, diff_opt_t *opts)
{
hid_t sid1 = H5I_INVALID_HID;
hid_t sid2 = H5I_INVALID_HID;
hid_t f_tid1 = H5I_INVALID_HID;
hid_t f_tid2 = H5I_INVALID_HID;
- hid_t dam_tid = H5I_INVALID_HID; /* m_tid for diff_array function */
hid_t m_tid1 = H5I_INVALID_HID;
hid_t m_tid2 = H5I_INVALID_HID;
hid_t dcpl1 = H5I_INVALID_HID;
hid_t dcpl2 = H5I_INVALID_HID;
H5D_layout_t stl1 = -1;
H5D_layout_t stl2 = -1;
- size_t dam_size; /* m_size for diff_array function */
size_t m_size1;
size_t m_size2;
H5T_sign_t sign1;
H5T_sign_t sign2;
int rank1;
int rank2;
- hsize_t danelmts; /* nelmts for diff_array function */
hsize_t nelmts1;
hsize_t nelmts2;
- hsize_t *dadims; /* dims for diff_array function */
hsize_t dims1[H5S_MAX_RANK];
hsize_t dims2[H5S_MAX_RANK];
hsize_t maxdim1[H5S_MAX_RANK];
hsize_t maxdim2[H5S_MAX_RANK];
- const char *name1 = NULL; /* relative names */
- const char *name2 = NULL;
hsize_t storage_size1;
hsize_t storage_size2;
hsize_t nfound = 0; /* number of differences found */
@@ -181,9 +185,10 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char
void *buf2 = NULL;
void *sm_buf1 = NULL;
void *sm_buf2 = NULL;
- hid_t sm_space = H5I_INVALID_HID; /*stripmine data space */
+ hid_t sm_space1 = H5I_INVALID_HID; /*stripmine data space */
+ hid_t sm_space2 = H5I_INVALID_HID; /*stripmine data space */
size_t need; /* bytes needed for malloc */
- int i;
+ int i, j;
unsigned int vl_data1 = 0; /*contains VL datatypes */
unsigned int vl_data2 = 0; /*contains VL datatypes */
diff_err_t ret_value = opts->err_stat;
@@ -233,13 +238,15 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char
*/
if((dcpl1 = H5Dget_create_plist(did1)) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist failed");
- if((dcpl2 = H5Dget_create_plist(did2)) < 0)
- H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist failed");
-
if((stl1 = H5Pget_layout(dcpl1)) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Pget_layout failed");
+ H5Pclose(dcpl1);
+
+ if((dcpl2 = H5Dget_create_plist(did2)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist failed");
if((stl2 = H5Pget_layout(dcpl2)) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Pget_layout failed");
+ H5Pclose(dcpl2);
/*-------------------------------------------------------------------------
* check for empty datasets
@@ -253,27 +260,48 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char
if(storage_size1 == 0 || storage_size2 == 0) {
if(stl1 == H5D_VIRTUAL || stl2 == H5D_VIRTUAL) {
- if((opts->m_verbose||opts->m_list_not_cmp) && obj1_name && obj2_name)
+ if((opts->mode_verbose||opts->mode_list_not_cmp) && obj1_name && obj2_name)
parallel_print("Warning: <%s> or <%s> is a virtual dataset\n", obj1_name, obj2_name);
}
else {
- if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name)
+ if((opts->mode_verbose || opts->mode_list_not_cmp) && obj1_name && obj2_name)
parallel_print("Not comparable: <%s> or <%s> is an empty dataset\n", obj1_name, obj2_name);
can_compare = 0;
opts->not_cmp = 1;
}
}
+ H5TOOLS_DEBUG("obj_names: %s - %s", obj1_name, obj2_name);
+ opts->obj_name[0] = NULL;
+ if (obj1_name) {
+ j = (int)HDstrlen(obj1_name);
+ H5TOOLS_DEBUG("obj1_name: %s - %d", obj1_name, j);
+ if (j > 0) {
+ opts->obj_name[0] = (char *)HDcalloc((size_t)j + 1, sizeof(char));
+ HDstrncpy(opts->obj_name[0], obj1_name, (size_t)j );
+ opts->obj_name[0][j] = '\0';
+ }
+ }
+
+
+ opts->obj_name[1] = NULL;
+ if (obj2_name) {
+ j = (int)HDstrlen(obj2_name);
+ H5TOOLS_DEBUG("obj2_name: %s - %d", obj2_name, j);
+ if (j > 0) {
+ opts->obj_name[1] = (char *)HDcalloc((size_t)j + 1, sizeof(char));
+ HDstrncpy(opts->obj_name[1], obj2_name, (size_t)j);
+ opts->obj_name[1][j] = '\0';
+ }
+ }
+
/*-------------------------------------------------------------------------
* check for comparable TYPE and SPACE
*-------------------------------------------------------------------------
*/
- if (diff_can_type(f_tid1, f_tid2, rank1, rank2,
- dims1, dims2, maxdim1, maxdim2,
- obj1_name, obj2_name,
- opts, 0) != 1)
+ if (diff_can_type(f_tid1, f_tid2, rank1, rank2, dims1, dims2, maxdim1, maxdim2, opts, 0) != 1)
can_compare = 0;
- H5TOOLS_DEBUG("diff_can_type - errstat:%d", opts->err_stat);
+ H5TOOLS_DEBUG("diff_can_type returned errstat:%d", opts->err_stat);
/*-------------------------------------------------------------------------
* memory type and sizes
@@ -312,7 +340,7 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char
sign2 = H5Tget_sign(m_tid2);
if(sign1 != sign2) {
H5TOOLS_DEBUG("sign1 != sign2");
- if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) {
+ if((opts->mode_verbose || opts->mode_list_not_cmp) && obj1_name && obj2_name) {
parallel_print("Not comparable: <%s> has sign %s ", obj1_name, get_sign(sign1));
parallel_print("and <%s> has sign %s\n", obj2_name, get_sign(sign2));
}
@@ -360,41 +388,56 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char
*------------------------------------------------------------------
*/
H5TOOLS_DEBUG("NOT H5T_ARRAY, upgrade the smaller memory size?");
- if (FAIL == match_up_memsize (f_tid1, f_tid2,
- &m_tid1, &m_tid2,
- &m_size1, &m_size2))
+ if (FAIL == match_up_memsize (f_tid1, f_tid2, &m_tid1, &m_tid2, &m_size1, &m_size2))
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "match_up_memsize failed");
H5TOOLS_DEBUG("m_size: %ld - %ld", m_size1, m_size2);
- dadims = dims1;
- dam_size = m_size1;
- dam_tid = m_tid1;
- danelmts = nelmts1;
+ opts->rank = rank1;
+ for(i = 0; i < rank1; i++)
+ opts->dims[i] = dims1[i];
+ opts->m_size = m_size1;
+ opts->m_tid = m_tid1;
+ opts->nelmts = nelmts1;
need = (size_t)(nelmts1 * m_size1); /* bytes needed */
}
else {
H5TOOLS_DEBUG("Array dims: %d - %d", dims1[0], dims2[0]);
/* Compare the smallest array, but create the largest buffer */
if(m_size1 <= m_size2) {
- dadims = dims1;
- dam_size = m_size1;
- dam_tid = m_tid1;
- danelmts = nelmts1;
+ opts->rank = rank1;
+ for(i = 0; i < rank1; i++)
+ opts->dims[i] = dims1[i];
+ opts->m_size = m_size1;
+ opts->m_tid = m_tid1;
+ opts->nelmts = nelmts1;
need = (size_t)(nelmts2 * m_size2); /* bytes needed */
}
else {
- dadims = dims2;
- dam_size = m_size2;
- dam_tid = m_tid2;
- danelmts = nelmts2;
+ opts->rank = rank2;
+ for(i = 0; i < rank2; i++)
+ opts->dims[i] = dims2[i];
+ opts->m_size = m_size2;
+ opts->m_tid = m_tid2;
+ opts->nelmts = nelmts2;
need = (size_t)(nelmts1 * m_size1); /* bytes needed */
}
}
+ opts->hs_nelmts = opts->nelmts;
+ H5TOOLS_DEBUG("need: %ld", need);
/* print names */
+ H5TOOLS_DEBUG("obj_names: %s - %s", obj1_name, obj2_name);
+
+ if (opts->obj_name[0] != NULL)
+ HDfree(opts->obj_name[0]);
+ opts->obj_name[0] = NULL;
+ if (opts->obj_name[1] != NULL)
+ HDfree(opts->obj_name[1]);
+ opts->obj_name[1] = NULL;
+
if(obj1_name)
- name1 = diff_basename(obj1_name);
+ opts->obj_name[0] = HDstrdup(diff_basename(obj1_name));
if(obj2_name)
- name2 = diff_basename(obj2_name);
- H5TOOLS_DEBUG("obj_names: %s - %s", name1, name2);
+ opts->obj_name[1] = HDstrdup(diff_basename(obj2_name));
+ H5TOOLS_DEBUG("obj_names: %s - %s", opts->obj_name[0], opts->obj_name[1]);
H5TOOLS_DEBUG("read/compare");
@@ -407,7 +450,14 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char
buf2 = HDmalloc(need);
} /* end if */
- if(buf1 != NULL && buf2 != NULL) {
+ /* Assume entire data space to be printed */
+ init_acc_pos(opts->rank, opts->dims, opts->acc, opts->pos, opts->p_min_idx);
+
+ for(i = 0; i < opts->rank; i++) {
+ opts->p_max_idx[i] = opts->dims[i];
+ }
+
+ if(buf1 != NULL && buf2 != NULL && opts->sset[0] == NULL && opts->sset[1] == NULL) {
H5TOOLS_DEBUG("buf1 != NULL && buf2 != NULL");
H5TOOLS_DEBUG("H5Dread did1");
if(H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0)
@@ -416,10 +466,13 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char
if(H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed");
+ /* initialize the current stripmine position; this is necessary to print the array indices */
+ for (j = 0; j < opts->rank; j++)
+ opts->sm_pos[j] = (hsize_t)0;
+
/* array diff */
- nfound = diff_array(buf1, buf2, danelmts, (hsize_t)0, rank1, dadims,
- opts, name1, name2, dam_tid, did1, did2);
- H5TOOLS_DEBUG("diff_array nfound:%d - errstat:%d", nfound, opts->err_stat);
+ nfound = diff_array(buf1, buf2, opts, did1, did2);
+ H5TOOLS_DEBUG("diff_array ret nfound:%d - errstat:%d", nfound, opts->err_stat);
/* reclaim any VL memory, if necessary */
H5TOOLS_DEBUG("check vl_data1:%d", vl_data1);
@@ -438,111 +491,369 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char
}
} /* end if */
else { /* possibly not enough memory, read/compare by hyperslabs */
- size_t p_type_nbytes = dam_size; /*size of memory type */
- hsize_t p_nelmts = danelmts; /*total selected elmts */
- hsize_t elmtno; /*counter */
- int carry; /*counter carry value */
+ hsize_t elmtno; /* counter */
+ int carry; /* counter carry value */
/* stripmine info */
- hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */
- hsize_t sm_nbytes; /*bytes per stripmine */
- hsize_t sm_nelmts; /*elements per stripmine*/
+ hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
+ hsize_t sm_block[H5S_MAX_RANK]; /* stripmine block size */
+ hsize_t sm_nbytes; /* bytes per stripmine */
+ hsize_t sm_nelmts1; /* elements per stripmine */
+ hsize_t sm_nelmts2; /* elements per stripmine */
+ hssize_t ssm_nelmts; /* elements temp */
/* hyperslab info */
- hsize_t hs_offset[H5S_MAX_RANK]; /*starting offset */
- hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */
- hsize_t hs_nelmts; /*elements in request */
- hsize_t zero[8]; /*vector of zeros */
+ hsize_t hs_offset1[H5S_MAX_RANK]; /* starting offset */
+ hsize_t hs_count1[H5S_MAX_RANK]; /* number of blocks */
+ hsize_t hs_block1[H5S_MAX_RANK]; /* size of blocks */
+ hsize_t hs_stride1[H5S_MAX_RANK]; /* stride */
+ hsize_t hs_size1[H5S_MAX_RANK]; /* size this pass */
+ hsize_t hs_offset2[H5S_MAX_RANK]; /* starting offset */
+ hsize_t hs_count2[H5S_MAX_RANK]; /* number of blocks */
+ hsize_t hs_block2[H5S_MAX_RANK]; /* size of blocks */
+ hsize_t hs_stride2[H5S_MAX_RANK]; /* stride */
+ hsize_t hs_size2[H5S_MAX_RANK]; /* size this pass */
+ hsize_t hs_nelmts1 = 0; /* elements in request */
+ hsize_t hs_nelmts2 = 0; /* elements in request */
+ hsize_t zero[8]; /* vector of zeros */
+ hsize_t low[H5S_MAX_RANK]; /* low bound of hyperslab */
+ hsize_t high[H5S_MAX_RANK]; /* higher bound of hyperslab */
+
+ H5TOOLS_DEBUG("reclaim any VL memory and free unused buffers");
+ if(buf1 != NULL) {
+ /* reclaim any VL memory, if necessary */
+ if(vl_data1)
+ H5Treclaim(m_tid1, sid1, H5P_DEFAULT, buf1);
+ HDfree(buf1);
+ buf1 = NULL;
+ }
+ if(buf2 != NULL) {
+ /* reclaim any VL memory, if necessary */
+ if(vl_data2)
+ H5Treclaim(m_tid2, sid2, H5P_DEFAULT, buf2);
+ HDfree(buf2);
+ buf2 = NULL;
+ }
+
+ /* the stripmine loop */
+ HDmemset(hs_offset1, 0, sizeof hs_offset1);
+ HDmemset(hs_stride1, 0, sizeof hs_stride1);
+ HDmemset(hs_count1, 0, sizeof hs_count1);
+ HDmemset(hs_block1, 0, sizeof hs_block1);
+ HDmemset(hs_size1, 0, sizeof hs_size1);
+ HDmemset(hs_offset2, 0, sizeof hs_offset2);
+ HDmemset(hs_stride2, 0, sizeof hs_stride2);
+ HDmemset(hs_count2, 0, sizeof hs_count2);
+ HDmemset(hs_block2, 0, sizeof hs_block2);
+ HDmemset(hs_size2, 0, sizeof hs_size2);
+ HDmemset(zero, 0, sizeof zero);
+
+ /* if subsetting was requested - initialize the subsetting variables */
+ H5TOOLS_DEBUG("compare by hyperslabs: opts->nelmts=%ld - opts->m_size=%ld", opts->nelmts, opts->m_size);
+ if (opts->sset[0] != NULL) {
+ H5TOOLS_DEBUG("opts->sset[0] != NULL");
+
+ /* Check for valid settings - default if not specified */
+ if(!opts->sset[0]->start.data || !opts->sset[0]->stride.data || !opts->sset[0]->count.data || !opts->sset[0]->block.data) {
+ /* they didn't specify a ``stride'' or ``block''. default to 1 in all
+ * dimensions */
+ if(!opts->sset[0]->start.data) {
+ /* default to (0, 0, ...) for the start coord */
+ opts->sset[0]->start.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t));
+ opts->sset[0]->start.len = (unsigned)rank1;
+ }
+
+ if(!opts->sset[0]->stride.data) {
+ opts->sset[0]->stride.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t));
+ opts->sset[0]->stride.len = (unsigned)rank1;
+ for (i = 0; i < rank1; i++)
+ opts->sset[0]->stride.data[i] = 1;
+ }
+
+ if(!opts->sset[0]->count.data) {
+ opts->sset[0]->count.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t));
+ opts->sset[0]->count.len = (unsigned)rank1;
+ for (i = 0; i < rank1; i++)
+ opts->sset[0]->count.data[i] = 1;
+ }
+
+ if(!opts->sset[0]->block.data) {
+ opts->sset[0]->block.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t));
+ opts->sset[0]->block.len = (unsigned)rank1;
+ for (i = 0; i < rank1; i++)
+ opts->sset[0]->block.data[i] = 1;
+ }
+
+ /*-------------------------------------------------------------------------
+ * check for block overlap
+ *-------------------------------------------------------------------------
+ */
+ for(i = 0; i < rank1; i++) {
+ if(opts->sset[0]->count.data[i] > 1) {
+ if(opts->sset[0]->stride.data[i] < opts->sset[0]->block.data[i]) {
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "wrong subset selection[0]; blocks overlap");
+ } /* end if */
+ } /* end if */
+ } /* end for */
+ }
+
+ /* Reset the total number of elements to the subset from the command */
+ opts->nelmts = 1;
+ for (i = 0; i < rank1; i++) {
+ hs_offset1[i] = opts->sset[0]->start.data[i];
+ hs_stride1[i] = opts->sset[0]->stride.data[i];
+ hs_count1[i] = opts->sset[0]->count.data[i];
+ hs_block1[i] = opts->sset[0]->block.data[i];
+ opts->nelmts *= hs_count1[i] * hs_block1[i];
+ hs_size1[i] = 0;
+ H5TOOLS_DEBUG("[%d]hs_offset1:%ld, hs_stride1:%ld, hs_count1:%ld, hs_block1:%ld", i, hs_offset1[i], hs_stride1[i], hs_count1[i], hs_block1[i]);
+ }
+ }
+ if (opts->sset[1] != NULL) {
+ H5TOOLS_DEBUG("opts->sset[1] != NULL");
+
+ /* Check for valid settings - default if not specified */
+ if(!opts->sset[1]->start.data || !opts->sset[1]->stride.data || !opts->sset[1]->count.data || !opts->sset[1]->block.data) {
+ /* they didn't specify a ``stride'' or ``block''. default to 1 in all
+ * dimensions */
+ if(!opts->sset[1]->start.data) {
+ /* default to (0, 0, ...) for the start coord */
+ opts->sset[1]->start.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t));
+ opts->sset[1]->start.len = (unsigned)rank2;
+ }
+
+ if(!opts->sset[1]->stride.data) {
+ opts->sset[1]->stride.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t));
+ opts->sset[1]->stride.len = (unsigned)rank2;
+ for (i = 0; i < rank2; i++)
+ opts->sset[1]->stride.data[i] = 1;
+ }
+
+ if(!opts->sset[1]->count.data) {
+ opts->sset[1]->count.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t));
+ opts->sset[1]->count.len = (unsigned)rank2;
+ for (i = 0; i < rank2; i++)
+ opts->sset[1]->count.data[i] = 1;
+ }
+
+ if(!opts->sset[1]->block.data) {
+ opts->sset[1]->block.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t));
+ opts->sset[1]->block.len = (unsigned)rank2;
+ for (i = 0; i < rank2; i++)
+ opts->sset[1]->block.data[i] = 1;
+ }
+
+ /*-------------------------------------------------------------------------
+ * check for block overlap
+ *-------------------------------------------------------------------------
+ */
+ for(i = 0; i < rank2; i++) {
+ if(opts->sset[1]->count.data[i] > 1) {
+ if(opts->sset[1]->stride.data[i] < opts->sset[1]->block.data[i]) {
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "wrong subset selection[1]; blocks overlap");
+ } /* end if */
+ } /* end if */
+ } /* end for */
+ }
+
+ for (i = 0; i < rank2; i++) {
+ hs_offset2[i] = opts->sset[1]->start.data[i];
+ hs_stride2[i] = opts->sset[1]->stride.data[i];
+ hs_count2[i] = opts->sset[1]->count.data[i];
+ hs_block2[i] = opts->sset[1]->block.data[i];
+ hs_size2[i] = 0;
+ H5TOOLS_DEBUG("[%d]hs_offset2:%ld, hs_stride2:%ld, hs_count2:%ld, hs_block2:%ld", i, hs_offset2[i], hs_stride2[i], hs_count2[i], hs_block2[i]);
+ }
+ }
/*
* determine the strip mine size and allocate a buffer. The strip mine is
* a hyperslab whose size is manageable.
*/
- sm_nbytes = p_type_nbytes;
-
- for(i = rank1; i > 0; --i) {
- hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes;
-
- if(size == 0) /* datum size > H5TOOLS_BUFSIZE */
- size = 1;
- sm_size[i - 1] = MIN(dadims[i - 1], size);
- sm_nbytes *= sm_size[i - 1];
- H5TOOLS_DEBUG("sm_nbytes: %ld", sm_nbytes);
- } /* end for */
-
- /* malloc return code should be verified.
- * If fail, need to handle the error.
- * This else branch should be recoded as a separate function.
- * Note that there are many "goto error" within this branch
- * that fails to address freeing other objects created here.
- * E.g., sm_space.
- */
- if((sm_buf1 = HDmalloc((size_t)sm_nbytes)) == NULL)
- H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "HDmalloc failed");
- if((sm_buf2 = HDmalloc((size_t)sm_nbytes)) == NULL)
- H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "HDmalloc failed");
+ sm_nbytes = opts->m_size;
+ if(opts->rank > 0) {
+ for (i = opts->rank; i > 0; --i) {
+ hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes;
+ if (size == 0) /* datum size > H5TOOLS_BUFSIZE */
+ size = 1;
+ H5TOOLS_DEBUG("opts->dims[%d]: %ld - size: %ld", i - 1, opts->dims[i - 1], size);
+ if (opts->sset[1] != NULL) {
+ sm_size[i - 1] = MIN(hs_block1[i - 1] * hs_count1[i - 1], size);
+ sm_block[i - 1] = MIN(hs_block1[i - 1], sm_size[i - 1]);
+ }
+ else {
+ sm_size[i - 1] = MIN(opts->dims[i - 1], size);
+ sm_block[i - 1] = sm_size[i - 1];
+ }
+ H5TOOLS_DEBUG("sm_size[%d]: %ld - sm_block:%ld", i - 1, sm_size[i - 1], sm_block[i - 1]);
+ sm_nbytes *= sm_size[i - 1];
+ H5TOOLS_DEBUG("sm_nbytes: %ld", sm_nbytes);
+ }
+ }
- sm_nelmts = sm_nbytes / p_type_nbytes;
- sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
+ H5TOOLS_DEBUG("opts->nelmts: %ld", opts->nelmts);
+ for(elmtno = 0; elmtno < opts->nelmts; elmtno += opts->hs_nelmts) {
+ H5TOOLS_DEBUG("elmtno: %ld - hs_nelmts1: %ld", elmtno, hs_nelmts1);
- /* the stripmine loop */
- HDmemset(hs_offset, 0, sizeof hs_offset);
- HDmemset(zero, 0, sizeof zero);
+ if(NULL == (sm_buf1 = (unsigned char *)HDmalloc((size_t) sm_nbytes)))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not allocate buffer for strip-mine");
+ if(NULL == (sm_buf2 = (unsigned char *)HDmalloc((size_t) sm_nbytes)))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not allocate buffer for strip-mine");
- for(elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) {
/* calculate the hyperslab size */
- if(rank1 > 0) {
- for(i = 0, hs_nelmts = 1; i < rank1; i++) {
- hs_size[i] = MIN(dadims[i] - hs_offset[i], sm_size[i]);
- hs_nelmts *= hs_size[i];
- } /* end for */
- if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
- H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab failed");
- if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
+ /* initialize subset */
+ if(opts->rank > 0) {
+ if (opts->sset[0] != NULL) {
+ H5TOOLS_DEBUG("sset1 has data");
+ /* calculate the potential number of elements */
+ for(i = 0; i < rank1; i++) {
+ H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset1: %ld - sm_block: %ld", i, opts->dims[i], hs_offset1[i], sm_block[i]);
+ hs_size1[i] = MIN(opts->dims[i] - hs_offset1[i], sm_block[i]);
+ H5TOOLS_DEBUG("hs_size1[%d]: %ld", i, hs_size1[i]);
+ }
+ if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset1, hs_stride1, hs_count1, hs_size1) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid1 failed");
+ }
+ else {
+ for(i = 0, hs_nelmts1 = 1; i < rank1; i++) {
+ H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset1: %ld - sm_block: %ld", i, opts->dims[i], hs_offset1[i], sm_block[i]);
+ hs_size1[i] = MIN(opts->dims[i] - hs_offset1[i], sm_block[i]);
+ H5TOOLS_DEBUG("hs_size1[%d]: %ld", i, hs_size1[i]);
+ hs_nelmts1 *= hs_size1[i];
+ H5TOOLS_DEBUG("hs_nelmts1:%ld *= hs_size1[%d]: %ld", hs_nelmts1, i, hs_size1[i]);
+ }
+ if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset1, NULL, hs_size1, NULL) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid1 failed");
+ }
+
+ if((ssm_nelmts = H5Sget_select_npoints(sid1)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_select_npoints failed");
+ sm_nelmts1 = (hsize_t)ssm_nelmts;
+ H5TOOLS_DEBUG("sm_nelmts1: %ld", sm_nelmts1);
+ hs_nelmts1 = sm_nelmts1;
+
+ if((sm_space1 = H5Screate_simple(1, &sm_nelmts1, NULL)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Screate_simple failed");
+
+ if(H5Sselect_hyperslab(sm_space1, H5S_SELECT_SET, zero, NULL, &sm_nelmts1, NULL) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab failed");
- if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0)
+
+ if (opts->sset[1] != NULL) {
+ H5TOOLS_DEBUG("sset2 has data");
+ for(i = 0; i < rank2; i++) {
+ H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset2: %ld - sm_block: %ld", i, opts->dims[i], hs_offset2[i], sm_block[i]);
+ hs_size2[i] = MIN(opts->dims[i] - hs_offset2[i], sm_block[i]);
+ H5TOOLS_DEBUG("hs_size2[%d]: %ld", i, hs_size2[i]);
+ }
+ if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, hs_stride2, hs_count2, hs_size2) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid2 failed");
+ }
+ else {
+ for(i = 0, hs_nelmts2 = 1; i < rank2; i++) {
+ H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset2: %ld - sm_block: %ld", i, opts->dims[i], hs_offset2[i], sm_block[i]);
+ hs_size2[i] = MIN(opts->dims[i] - hs_offset2[i], sm_block[i]);
+ H5TOOLS_DEBUG("hs_size2[%d]: %ld", i, hs_size2[i]);
+ hs_nelmts2 *= hs_size2[i];
+ H5TOOLS_DEBUG("hs_nelmts2:%ld *= hs_size2[%d]: %ld", hs_nelmts2, i, hs_size2[i]);
+ }
+ if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, NULL, hs_size2, NULL) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid2 failed");
+ }
+
+ if((ssm_nelmts = H5Sget_select_npoints(sid2)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_select_npoints failed");
+ sm_nelmts2 = (hsize_t)ssm_nelmts;
+ H5TOOLS_DEBUG("sm_nelmts2: %ld", sm_nelmts2);
+ hs_nelmts2 = sm_nelmts2;
+
+ if((sm_space2 = H5Screate_simple(1, &sm_nelmts2, NULL)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Screate_simple failed");
+
+ if(H5Sselect_hyperslab(sm_space2, H5S_SELECT_SET, zero, NULL, &sm_nelmts2, NULL) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab failed");
- } /* end if */
+ }
else
- hs_nelmts = 1;
+ hs_nelmts1 = 1;
+ opts->hs_nelmts = hs_nelmts1;
+ H5TOOLS_DEBUG("hs_nelmts: %ld", opts->hs_nelmts);
- if(H5Dread(did1, m_tid1, sm_space, sid1, H5P_DEFAULT, sm_buf1) < 0)
+ /* read the data */
+ if(H5Dread(did1, m_tid1, sm_space1, sid1, H5P_DEFAULT, sm_buf1) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed");
- if(H5Dread(did2, m_tid2, sm_space, sid2, H5P_DEFAULT, sm_buf2) < 0)
+ if(H5Dread(did2, m_tid2, sm_space2, sid2, H5P_DEFAULT, sm_buf2) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed");
+ /* print array indices. get the lower bound of the hyperslab and calculate
+ the element position at the start of hyperslab */
+ if(H5Sget_select_bounds(sid1, low, high) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_select_bounds failed");
+ /* initialize the current stripmine position; this is necessary to print the array indices */
+ for (j = 0; j < opts->rank; j++)
+ opts->sm_pos[j] = low[j];
+
+ /* Assume entire data space to be printed */
+ init_acc_pos(opts->rank, opts->dims, opts->acc, opts->pos, opts->p_min_idx);
+
/* 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 */
- nfound += diff_array(sm_buf1, sm_buf2, hs_nelmts, elmtno, rank1,
- dadims, opts, name1, name2, dam_tid, did1, did2);
-
- /* reclaim any VL memory, if necessary */
- if(vl_data1)
- H5Treclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf1);
- if(vl_data2)
- H5Treclaim(m_tid2, sm_space, H5P_DEFAULT, sm_buf2);
+ nfound += diff_array(sm_buf1, sm_buf2, opts, did1, did2);
+
+ if(sm_buf1 != NULL) {
+ /* reclaim any VL memory, if necessary */
+ if(vl_data1)
+ H5Treclaim(m_tid1, sm_space1, H5P_DEFAULT, sm_buf1);
+ HDfree(sm_buf1);
+ sm_buf1 = NULL;
+ }
+ if(sm_buf2 != NULL) {
+ /* reclaim any VL memory, if necessary */
+ if(vl_data2)
+ H5Treclaim(m_tid2, sm_space2, H5P_DEFAULT, sm_buf2);
+ HDfree(sm_buf2);
+ sm_buf2 = NULL;
+ }
+
+ H5Sclose(sm_space1);
+ H5Sclose(sm_space2);
/* calculate the next hyperslab offset */
- for(i = rank1, carry = 1; i > 0 && carry; --i) {
- hs_offset[i - 1] += hs_size[i - 1];
- if(hs_offset[i - 1] == dadims[i - 1])
- hs_offset[i - 1] = 0;
+ for(i = opts->rank, carry = 1; i > 0 && carry; --i) {
+ if (opts->sset[0] != NULL) {
+ H5TOOLS_DEBUG("[%d]hs_size1:%ld - hs_block1:%ld - hs_stride1:%ld", i-1, hs_size1[i-1], hs_block1[i - 1], hs_stride1[i - 1]);
+ if(hs_size1[i - 1] >= hs_block1[i - 1]) {
+ hs_offset1[i - 1] += hs_size1[i - 1];
+ }
+ else {
+ hs_offset1[i - 1] += hs_stride1[i - 1];
+ }
+ }
+ else
+ hs_offset1[i - 1] += hs_size1[i - 1];
+ H5TOOLS_DEBUG("[%d]hs_offset1:%ld - opts->dims:%ld", i-1, hs_offset1[i-1], opts->dims[i - 1]);
+ if(hs_offset1[i - 1] >= opts->dims[i - 1])
+ hs_offset1[i - 1] = 0;
else
carry = 0;
- } /* i */
- } /* elmtno */
- if(sm_buf1 != NULL) {
- HDfree(sm_buf1);
- sm_buf1 = NULL;
- }
- if(sm_buf2 != NULL) {
- HDfree(sm_buf2);
- sm_buf2 = NULL;
- }
-
- H5Sclose(sm_space);
+ H5TOOLS_DEBUG("[%d]hs_offset1:%ld", i-1, hs_offset1[i-1]);
+ if (opts->sset[1] != NULL) {
+ H5TOOLS_DEBUG("[%d]hs_size2:%ld - hs_block2:%ld - hs_stride2:%ld", i-1, hs_size2[i-1], hs_block2[i - 1], hs_stride2[i - 1]);
+ if(hs_size2[i - 1] >= hs_block2[i - 1]) {
+ hs_offset2[i - 1] += hs_size2[i - 1];
+ }
+ else {
+ hs_offset2[i - 1] += hs_stride2[i - 1];
+ }
+ }
+ else
+ hs_offset2[i - 1] += hs_size2[i - 1];
+ H5TOOLS_DEBUG("[%d]hs_offset2:%ld - opts->dims:%ld", i-1, hs_offset2[i-1], opts->dims[i - 1]);
+ if(hs_offset2[i - 1] >= opts->dims[i - 1])
+ hs_offset2[i - 1] = 0;
+ H5TOOLS_DEBUG("[%d]hs_offset2:%ld", i-1, hs_offset2[i-1]);
+ }
+ } /* elmtno for loop */
} /* hyperslab read */
- H5TOOLS_DEBUG("can_compare complete");
+ H5TOOLS_DEBUG("can compare complete");
} /*can_compare*/
@@ -550,12 +861,20 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char
* close
*-------------------------------------------------------------------------
*/
- H5TOOLS_DEBUG("reclaim any VL memory - errstat:%d", opts->err_stat);
done:
opts->err_stat = opts->err_stat | ret_value;
+ H5TOOLS_DEBUG("free names - errstat:%d", opts->err_stat);
/* free */
+ if (opts->obj_name[0] != NULL)
+ HDfree(opts->obj_name[0]);
+ opts->obj_name[0] = NULL;
+ if (opts->obj_name[1] != NULL)
+ HDfree(opts->obj_name[1]);
+ opts->obj_name[1] = NULL;
+
+ H5TOOLS_DEBUG("reclaim any VL memory");
if(buf1 != NULL) {
/* reclaim any VL memory, if necessary */
if(vl_data1)
@@ -570,26 +889,31 @@ done:
HDfree(buf2);
buf2 = NULL;
}
+ H5TOOLS_DEBUG("reclaim any stripmine VL memory");
if(sm_buf1 != NULL) {
/* reclaim any VL memory, if necessary */
if(vl_data1)
- H5Treclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf1);
+ H5Treclaim(m_tid1, sm_space1, H5P_DEFAULT, sm_buf1);
HDfree(sm_buf1);
sm_buf1 = NULL;
}
if(sm_buf2 != NULL) {
/* reclaim any VL memory, if necessary */
if(vl_data2)
- H5Treclaim(m_tid2, sm_space, H5P_DEFAULT, sm_buf2);
+ H5Treclaim(m_tid2, sm_space2, H5P_DEFAULT, sm_buf2);
HDfree(sm_buf2);
sm_buf2 = NULL;
}
+ H5TOOLS_DEBUG("close ids");
/* disable error reporting */
H5E_BEGIN_TRY {
H5Sclose(sid1);
H5Sclose(sid2);
- H5Sclose(sm_space);
+ H5Sclose(sm_space1);
+ H5Sclose(sm_space2);
+ H5Pclose(dcpl1);
+ H5Pclose(dcpl2);
H5Tclose(f_tid1);
H5Tclose(f_tid2);
H5Tclose(m_tid1);
@@ -613,10 +937,9 @@ done:
*-------------------------------------------------------------------------
*/
-int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2,
- hsize_t *dims1, hsize_t *dims2, hsize_t *maxdim1, hsize_t *maxdim2,
- const char *obj1_name, const char *obj2_name,
- diff_opt_t *opts, int is_compound)
+int
+diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, hsize_t *dims1, hsize_t *dims2,
+ hsize_t *maxdim1, hsize_t *maxdim2, diff_opt_t *opts, int is_compound)
{
H5T_class_t tclass1;
H5T_class_t tclass2;
@@ -635,19 +958,21 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2,
if((tclass2 = H5Tget_class(f_tid2)) < 0)
H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_class second object failed");
+ H5TOOLS_DEBUG("obj_names: %s - %s", opts->obj_name[0], opts->obj_name[1]);
if(tclass1 != tclass2) {
- if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) {
+ if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) {
if(is_compound) {
parallel_print("Not comparable: <%s> has a class %s and <%s> has a class %s\n",
- obj1_name, get_class(tclass1),
- obj2_name, get_class(tclass2));
+ opts->obj_name[0], get_class(tclass1),
+ opts->obj_name[1], get_class(tclass2));
}
else {
parallel_print("Not comparable: <%s> is of class %s and <%s> is of class %s\n",
- obj1_name, get_class(tclass1),
- obj2_name, get_class(tclass2));
+ opts->obj_name[0], get_class(tclass1),
+ opts->obj_name[1], get_class(tclass2));
}
}
+
opts->not_cmp = 1;
H5TOOLS_GOTO_DONE(0);
}
@@ -658,10 +983,11 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2,
*/
switch (tclass1) {
case H5T_TIME:
- if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) {
+ if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) {
parallel_print("Not comparable: <%s> and <%s> are of class %s\n",
- obj1_name, obj2_name, get_class(tclass2));
+ opts->obj_name[0], opts->obj_name[1], get_class(tclass2));
} /* end if */
+
opts->not_cmp = 1;
H5TOOLS_GOTO_DONE(0);
break;
@@ -679,7 +1005,7 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2,
case H5T_NO_CLASS:
case H5T_NCLASSES:
default:
- H5TOOLS_DEBUG("diff_can_type class - %s", get_class(tclass1));
+ H5TOOLS_DEBUG("class - %s", get_class(tclass1));
break;
} /* end switch */
@@ -687,15 +1013,15 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2,
* check for equal file datatype; warning only
*-------------------------------------------------------------------------
*/
- if((H5Tequal(f_tid1, f_tid2) == 0) && (opts->m_verbose) && obj1_name && obj2_name) {
+ if((H5Tequal(f_tid1, f_tid2) == 0) && (opts->mode_verbose) && opts->obj_name[0] && opts->obj_name[1]) {
H5T_class_t cl = H5Tget_class(f_tid1);
parallel_print("Warning: different storage datatype\n");
if(cl == H5T_INTEGER || cl == H5T_FLOAT) {
- parallel_print("<%s> has file datatype ", obj1_name);
+ parallel_print("<%s> has file datatype ", opts->obj_name[0]);
print_type(f_tid1);
parallel_print("\n");
- parallel_print("<%s> has file datatype ", obj2_name);
+ parallel_print("<%s> has file datatype ", opts->obj_name[1]);
print_type(f_tid2);
parallel_print("\n");
}
@@ -706,18 +1032,19 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2,
*-------------------------------------------------------------------------
*/
if(rank1 != rank2) {
- if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) {
- parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1);
+ if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) {
+ parallel_print("Not comparable: <%s> has rank %d, dimensions ", opts->obj_name[0], rank1);
print_dimensions(rank1, dims1);
parallel_print(", max dimensions ");
print_dimensions(rank1, maxdim1);
parallel_print("\n" );
- parallel_print("and <%s> has rank %d, dimensions ", obj2_name, rank2);
+ parallel_print("and <%s> has rank %d, dimensions ", opts->obj_name[1], rank2);
print_dimensions(rank2, dims2);
parallel_print(", max dimensions ");
print_dimensions(rank2, maxdim2);
parallel_print("\n");
}
+
opts->not_cmp = 1;
H5TOOLS_GOTO_DONE(0);
}
@@ -740,20 +1067,21 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2,
*-------------------------------------------------------------------------
*/
if(dim_diff == 1) {
- if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) {
- parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1);
+ if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) {
+ parallel_print("Not comparable: <%s> has rank %d, dimensions ", opts->obj_name[0], rank1);
print_dimensions(rank1, dims1);
if(maxdim1 && maxdim2) {
parallel_print(", max dimensions ");
print_dimensions(rank1, maxdim1);
parallel_print("\n" );
- parallel_print("and <%s> has rank %d, dimensions ", obj2_name, rank2);
+ parallel_print("and <%s> has rank %d, dimensions ", opts->obj_name[1], rank2);
print_dimensions(rank2, dims2);
parallel_print(", max dimensions ");
print_dimensions(rank2, maxdim2);
parallel_print("\n");
}
}
+
opts->not_cmp = 1;
H5TOOLS_GOTO_DONE(0);
}
@@ -762,13 +1090,13 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2,
* maximum dimensions; just give a warning
*-------------------------------------------------------------------------
*/
- if(maxdim1 && maxdim2 && maxdim_diff == 1 && obj1_name) {
- if(opts->m_verbose) {
+ if(maxdim1 && maxdim2 && maxdim_diff == 1 && opts->obj_name[0]) {
+ if(opts->mode_verbose) {
parallel_print( "Warning: different maximum dimensions\n");
- parallel_print("<%s> has max dimensions ", obj1_name);
+ parallel_print("<%s> has max dimensions ", opts->obj_name[0]);
print_dimensions(rank1, maxdim1);
parallel_print("\n");
- parallel_print("<%s> has max dimensions ", obj2_name);
+ parallel_print("<%s> has max dimensions ", opts->obj_name[1]);
print_dimensions(rank2, maxdim2);
parallel_print("\n");
}
@@ -777,16 +1105,17 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2,
if(tclass1 == H5T_STRING) {
htri_t vstrtype1 = -1;
htri_t vstrtype2 = -1;
- H5TOOLS_DEBUG("diff_can_type end - H5T_STRING");
+ H5TOOLS_DEBUG(" - H5T_STRING");
vstrtype1 = H5Tis_variable_str(f_tid1);
vstrtype2 = H5Tis_variable_str(f_tid2);
/* no compare if either one but not both are variable string type */
if (vstrtype1 != vstrtype2) {
- if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name)
+ if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1])
parallel_print("Not comparable: <%s> or <%s> is of mixed string type\n",
- obj1_name, obj2_name);
+ opts->obj_name[0], opts->obj_name[1]);
+
opts->not_cmp = 1;
H5TOOLS_GOTO_DONE(0);
}
@@ -798,17 +1127,18 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2,
int j;
hid_t memb_type1 = H5I_INVALID_HID;
hid_t memb_type2 = H5I_INVALID_HID;
- H5TOOLS_DEBUG("diff_can_type end - H5T_COMPOUND");
+ H5TOOLS_DEBUG(" - H5T_COMPOUND");
nmembs1 = H5Tget_nmembers(f_tid1);
nmembs2 = H5Tget_nmembers(f_tid2);
if(nmembs1 != nmembs2) {
- if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) {
- parallel_print("Not comparable: <%s> has %d members ", obj1_name, nmembs1);
- parallel_print("<%s> has %d members ", obj2_name, nmembs2);
+ if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) {
+ parallel_print("Not comparable: <%s> has %d members ", opts->obj_name[0], nmembs1);
+ parallel_print("<%s> has %d members ", opts->obj_name[1], nmembs2);
parallel_print("\n");
}
+
opts->not_cmp = 1;
H5TOOLS_GOTO_DONE(0);
}
@@ -817,9 +1147,7 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2,
memb_type1 = H5Tget_member_type(f_tid1, (unsigned)j);
memb_type2 = H5Tget_member_type(f_tid2, (unsigned)j);
- if (diff_can_type(memb_type1, memb_type2, rank1, rank2,
- dims1, dims2, maxdim1, maxdim2, obj1_name, obj2_name,
- opts, 1) != 1) {
+ if (diff_can_type(memb_type1, memb_type2, rank1, rank2, dims1, dims2, maxdim1, maxdim2, opts, 1) != 1) {
opts->not_cmp = 1;
H5Tclose(memb_type1);
H5Tclose(memb_type2);
@@ -838,19 +1166,17 @@ done:
}
+#if defined (H5DIFF_DEBUG_UNUSED)
+/* this function is not currently used, but could be useful */
/*-------------------------------------------------------------------------
* Function: print_sizes
*
* Purpose: Print datatype sizes
*-------------------------------------------------------------------------
*/
-#if defined (H5DIFF_DEBUG)
-void print_sizes( const char *obj1,
- const char *obj2,
- hid_t f_tid1,
- hid_t f_tid2,
- hid_t m_tid1,
- hid_t m_tid2 )
+void print_sizes( const char *obj1, const char *obj2, hid_t f_tid1, hid_t f_tid2, hid_t m_tid1, hid_t m_tid2);
+
+void print_sizes( const char *obj1, const char *obj2, hid_t f_tid1, hid_t f_tid2, hid_t m_tid1, hid_t m_tid2)
{
size_t f_size1, f_size2; /* size of type in file */
size_t m_size1, m_size2; /* size of type in memory */
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index cc51e2c..d9c6715 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -29,28 +29,37 @@ int H5tools_INDENT_g = 0;
/* global variables */
+H5E_auto2_t lib_func;
+H5E_auto2_t tools_func;
+void *lib_edata;
+void *tools_edata;
+
hid_t H5tools_ERR_STACK_g = H5I_INVALID_HID;
hid_t H5tools_ERR_CLS_g = H5I_INVALID_HID;
hid_t H5E_tools_g = H5I_INVALID_HID;
hid_t H5E_tools_min_id_g = H5I_INVALID_HID;
hid_t H5E_tools_min_info_id_g = H5I_INVALID_HID;
hid_t H5E_tools_min_dbg_id_g = H5I_INVALID_HID;
-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 */
FILE *rawinstream = NULL; /* should initialize to stdin but gcc moans about it */
FILE *rawoutstream = NULL; /* should initialize to stdout but gcc moans about it */
FILE *rawerrorstream = NULL; /* should initialize to stderr but gcc moans about it */
+
int bin_output; /* binary output */
int bin_form = 0; /* binary form, default NATIVE */
int region_output; /* region output */
int oid_output; /* oid output */
int data_output; /* data output */
int attr_data_output; /* attribute data output */
+int compound_data;
+
unsigned packed_bits_num; /* number of packed bits to display */
unsigned packed_data_offset; /* offset of packed bits to display */
unsigned packed_data_length; /* length of packed bits to display */
unsigned long long packed_data_mask; /* mask in which packed bits to display */
+
int enable_error_stack = 0; /* re-enable error stack; disable=0 enable=1 */
/* sort parameters */
@@ -103,6 +112,10 @@ const char *drivernames[] = {
void
h5tools_init(void)
{
+ /* Disable error reporting */
+ H5Eget_auto2(H5E_DEFAULT, &lib_func, &lib_edata);
+ H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+
if (!h5tools_init_g) {
H5TOOLS_INIT_ERROR();
@@ -121,6 +134,29 @@ h5tools_init(void)
h5tools_init_g++;
}
+
+ /* Disable tools error reporting */
+ H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
+ H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_error_report
+ *
+ * Purpose: Enable error stack reporting after command line is parsed.
+ *
+ * Return: None
+ *-------------------------------------------------------------------------
+ */
+void
+h5tools_error_report(void)
+{
+ if (h5tools_init_g) {
+ if (enable_error_stack > 0) {
+ H5Eset_auto2(H5E_DEFAULT, lib_func, lib_edata);
+ H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
+ }
+ }
}
/*-------------------------------------------------------------------------
@@ -137,16 +173,11 @@ h5tools_init(void)
void
h5tools_close(void)
{
- H5E_auto2_t tools_func;
- void *tools_edata;
-
if (h5tools_init_g) {
/* special case where only data is output to stdout */
if ((rawoutstream == NULL) && rawdatastream && (rawdatastream == stdout))
HDfprintf(rawdatastream, "\n");
- H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
-
if (tools_func)
H5Eprint2(H5tools_ERR_STACK_g, rawerrorstream);
@@ -184,6 +215,10 @@ h5tools_close(void)
/* Clean up the reference path table, if it's been used */
term_ref_path_table();
+ /* Restore error stacks from init */
+ H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
+ H5Eset_auto2(H5E_DEFAULT, lib_func, lib_edata);
+
H5TOOLS_CLOSE_ERROR();
/* Shut down the library */
@@ -1090,8 +1125,8 @@ done:
*-------------------------------------------------------------------------
*/
void
-h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hsize_t elmtno, int secnum)
+h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ hsize_t elmtno, int secnum)
{
h5tools_str_t prefix;
h5tools_str_t str; /*temporary for indentation */
@@ -1119,7 +1154,7 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
H5TOOLS_DEBUG("after CR elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims);
/* Calculate new prefix */
- h5tools_str_prefix(&prefix, info, elmtno, ctx->ndims, ctx);
+ h5tools_str_prefix(&prefix, info, elmtno, ctx);
H5TOOLS_DEBUG("prefix=%s - str=%s", prefix.s, str.s);
/* Write new prefix to output */
@@ -1186,8 +1221,8 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
*-------------------------------------------------------------------------
*/
void
-h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum)
+h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ hsize_t elmtno, hsize_t *ptdata, int secnum)
{
h5tools_str_t prefix;
h5tools_str_t str; /*temporary for indentation */
@@ -1211,7 +1246,7 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
}
/* Calculate new prefix */
- h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx->ndims, ctx->p_max_idx, ctx);
+ h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx);
/* Write new prefix to output */
if (ctx->indent_level > 0)
@@ -1284,9 +1319,8 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
*-------------------------------------------------------------------------
*/
hbool_t
-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_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)
{
hbool_t dimension_break = TRUE;
char *s = NULL;
@@ -1455,9 +1489,8 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
*-------------------------------------------------------------------------
*/
hbool_t
-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_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)
{
hbool_t dimension_break = TRUE;
char *s = NULL;
@@ -1474,8 +1507,10 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
* 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
@@ -1484,7 +1519,8 @@ 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
@@ -1515,7 +1551,9 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
* 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)
+ (ctx->cur_column + h5tools_count_ncols(s) +
+ HDstrlen(OPT(info->elmt_suf2, " ")) +
+ HDstrlen(OPT(info->line_suf, ""))) > ncols)
ctx->need_prefix = TRUE;
/*
@@ -1543,7 +1581,9 @@ 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;
/*
@@ -1589,27 +1629,65 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
*-------------------------------------------------------------------------
*/
void
-init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
+init_acc_pos(unsigned ndims, hsize_t *dims, hsize_t *acc, hsize_t *pos, hsize_t *p_min_idx)
{
int i;
unsigned j;
H5TOOLS_START_DEBUG("");
- if(ctx->ndims > 0) {
- ctx->acc[ctx->ndims - 1] = 1;
- for (i = ((int)ctx->ndims - 2); i >= 0; i--) {
- ctx->acc[i] = ctx->acc[i + 1] * dims[i + 1];
- H5TOOLS_DEBUG("ctx->acc[%d]=%ld", i, ctx->acc[i]);
+ for (i = 0; (unsigned)i < ndims; i++)
+ p_min_idx[i] = 0;
+
+ if(ndims > 0) {
+ acc[ndims - 1] = 1;
+ for (i = ((int)ndims - 2); i >= 0; i--) {
+ acc[i] = acc[i + 1] * dims[i + 1];
+ H5TOOLS_DEBUG("acc[%d]=%ld", i, acc[i]);
}
- for (j = 0; j < ctx->ndims; j++)
- ctx->pos[j] = 0;
+ for (j = 0; j < ndims; j++)
+ pos[j] = 0;
}
H5TOOLS_ENDDEBUG("");
}
/*-------------------------------------------------------------------------
+ * Function: calc_acc_pos
+ *
+ * Purpose: Calculate the number of elements represented by a unit change
+ * in a certain index position.
+ *
+ * Return: void
+ *-------------------------------------------------------------------------
+ */
+hsize_t
+calc_acc_pos(unsigned ndims, hsize_t elmtno, hsize_t *acc, hsize_t *pos)
+{
+ int i;
+ hsize_t curr_pos = elmtno;
+
+ H5TOOLS_START_DEBUG("");
+
+ if(ndims > 0) {
+ for(i = 0; i < (size_t) ndims; i++) {
+ if(curr_pos > 0) {
+ H5TOOLS_DEBUG("curr_pos=%ld - ctx->acc[%d]=%ld", curr_pos, i, acc[i]);
+ pos[i] = curr_pos / acc[i];
+ curr_pos -= acc[i] * pos[i];
+ }
+ else
+ pos[i] = 0;
+ H5TOOLS_DEBUG("curr_pos=%ld - pos[%d]=%ld - acc[%d]=%ld", curr_pos, i, pos[i], i, acc[i]);
+ }
+ }
+
+ H5TOOLS_ENDDEBUG("");
+
+ return curr_pos;
+}
+
+/*-------------------------------------------------------------------------
* Function: render_bin_output
*
* Purpose: Write one element of memory buffer to a binary file stream
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 2b6fffb..152ec1a 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -570,9 +570,6 @@ typedef struct h5tools_vfd_info_t {
const char *name;
} h5tools_vfd_info_t;
-H5TOOLS_DLLVAR const char *volnames[];
-H5TOOLS_DLLVAR const char *drivernames[];
-
/* This enum should match the entries in the above 'volnames'
* since they are indices into the 'volnames' array. */
typedef enum {
@@ -603,14 +600,22 @@ typedef enum {
#include "h5tools_str.h"
-H5TOOLS_DLLVAR h5tool_format_t h5tools_dataformat;
-H5TOOLS_DLLVAR const h5tools_dump_header_t h5tools_standardformat;
-H5TOOLS_DLLVAR const h5tools_dump_header_t* h5tools_dump_header_format;
#ifdef __cplusplus
extern "C" {
#endif
+H5TOOLS_DLLVAR const char *volnames[];
+H5TOOLS_DLLVAR const char *drivernames[];
+
+H5TOOLS_DLLVAR h5tool_format_t h5tools_dataformat;
+H5TOOLS_DLLVAR const h5tools_dump_header_t h5tools_standardformat;
+H5TOOLS_DLLVAR const h5tools_dump_header_t* h5tools_dump_header_format;
+H5TOOLS_DLLVAR H5E_auto2_t lib_func;
+H5TOOLS_DLLVAR H5E_auto2_t tools_func;
+H5TOOLS_DLLVAR void *lib_edata;
+H5TOOLS_DLLVAR void *tools_edata;
+
H5TOOLS_DLLVAR unsigned packed_bits_num; /* number of packed bits to display */
H5TOOLS_DLLVAR unsigned packed_data_offset; /* offset of packed bits to display */
H5TOOLS_DLLVAR unsigned packed_data_length; /* length of packed bits to display */
@@ -644,14 +649,17 @@ H5TOOLS_DLLVAR int enable_error_stack; /* re-enable error stack; disable=0 e
/* Definitions of useful routines */
H5TOOLS_DLL void h5tools_init(void);
H5TOOLS_DLL void h5tools_close(void);
+
+H5TOOLS_DLL void h5tools_error_report(void);
H5TOOLS_DLL int h5tools_set_data_output_file(const char *fname, int is_bin);
H5TOOLS_DLL int h5tools_set_attr_output_file(const char *fname, int is_bin);
H5TOOLS_DLL int h5tools_set_input_file(const char *fname, int is_bin);
H5TOOLS_DLL int h5tools_set_output_file(const char *fname, int is_bin);
H5TOOLS_DLL int h5tools_set_error_file(const char *fname, int is_bin);
-H5TOOLS_DLL hid_t h5tools_get_fapl(hid_t prev_fapl_id, h5tools_vol_info_t *vol_info,
- h5tools_vfd_info_t *vfd_info);
-H5TOOLS_DLL herr_t h5tools_get_vfd_name(hid_t fapl_id, char *drivername, size_t drivername_size);
+
+H5TOOLS_DLL hid_t h5tools_get_fapl(hid_t prev_fapl_id, h5tools_vol_info_t *vol_info, h5tools_vfd_info_t *vfd_info);
+H5TOOLS_DLL herr_t h5tools_get_vfd_name(hid_t fapl_id,
+ char *drivername, size_t drivername_size);
H5TOOLS_DLL hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl,
hbool_t use_specific_driver, char *drivername, size_t drivername_size);
H5TOOLS_DLL hid_t h5tools_get_little_endian_type(hid_t type);
@@ -659,36 +667,29 @@ H5TOOLS_DLL hid_t h5tools_get_big_endian_type(hid_t type);
H5TOOLS_DLL htri_t h5tools_detect_vlen(hid_t tid);
H5TOOLS_DLL htri_t h5tools_detect_vlen_str(hid_t tid);
H5TOOLS_DLL hbool_t h5tools_is_obj_same(hid_t loc_id1, const char *name1, hid_t loc_id2, const char *name2);
-H5TOOLS_DLL void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims);
+H5TOOLS_DLL void init_acc_pos(unsigned ndims, hsize_t *dims, hsize_t *acc, hsize_t *pos, hsize_t *p_min_idx);
+H5TOOLS_DLL hsize_t calc_acc_pos(unsigned ndims, hsize_t elemtno, hsize_t *acc, hsize_t *pos);
H5TOOLS_DLL hbool_t h5tools_is_zero(const void *_mem, size_t size);
H5TOOLS_DLL int h5tools_canreadf(const char* name, hid_t dcpl_id);
H5TOOLS_DLL int h5tools_can_encode(H5Z_filter_t filtn);
-H5TOOLS_DLL void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hsize_t elmtno, int secnum);
-H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum);
+H5TOOLS_DLL void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ hsize_t elmtno, int secnum);
+H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ hsize_t elmtno, hsize_t *ptdata, int secnum);
H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t nelmts);
-H5TOOLS_DLL 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_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
- FILE *stream, hid_t container);
-H5TOOLS_DLL int 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_DLL hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id,
- FILE *stream, hid_t container);
-
-H5TOOLS_DLL hbool_t 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_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_DLL 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_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id, FILE *stream, hid_t container);
+H5TOOLS_DLL int 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_DLL hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container);
+
+H5TOOLS_DLL hbool_t 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_DLL hbool_t 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);
#ifdef __cplusplus
}
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index b59ae93..187ba18 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -253,9 +253,8 @@ 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_dump_simple_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, /* in,out */
+ hid_t container, unsigned flags, hsize_t nelmts, hid_t type, void *_mem)
{
unsigned char *mem = (unsigned char*) _mem;
hsize_t i; /* element counter */
@@ -568,9 +567,11 @@ h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_for
ctx.indent_level++;
if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) {
/* assume entire data space to be printed */
+ init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx);
+
+ /* reset 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;
@@ -939,9 +940,7 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
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);
+ init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx);
/* print the data */
region_flags = START_OF_DATA;
@@ -1274,9 +1273,6 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
if ((size_t) ctx->ndims > NELMTS(sm_size))
H5TOOLS_THROW(FAIL, "ndims and sm_size comparision failed");
- if (ctx->ndims > 0)
- init_acc_pos(ctx, total_size);
-
size_row_block = ctx->sset->block.data[row_dim];
/* Check if we have VL data in the dataset's datatype */
@@ -1347,27 +1343,25 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
for (i = 0; i < ctx->ndims; i++)
ctx->p_max_idx[i] = ctx->p_min_idx[i] + MIN(total_size[i], sm_size[i]);
- /* print array indices. get the lower bound of the hyperslab and calulate
- the element position at the start of hyperslab */
+ /* print array indices. get the lower bound of the hyperslab and calculate
+ the element position at the start of hyperslab */
if(H5Sget_select_bounds(f_space, low, high) < 0)
H5TOOLS_THROW(FAIL, "H5Sget_select_bounds failed");
- elmtno = 0;
+ /* initialize the current stripmine position; this is necessary to print the array indices */
+ ctx->sm_pos = 0;
for (i = 0; i < (size_t) ctx->ndims - 1; i++) {
hsize_t offset = 1; /* accumulation of the previous dimensions */
for (j = i + 1; j < (size_t) ctx->ndims; j++)
offset *= total_size[j];
- elmtno += low[i] * offset;
+ ctx->sm_pos += low[i] * offset;
}
- elmtno += low[ctx->ndims - 1];
+ ctx->sm_pos += low[ctx->ndims - 1];
- /* initialize the current stripmine position; this is necessary to print the array
- indices */
- ctx->sm_pos = elmtno;
ctx->need_prefix = TRUE;
- if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, sm_nelmts, p_type, sm_buf) < 0)
+ if(h5tools_dump_simple_data(stream, info, ctx, dset, flags, sm_nelmts, p_type, sm_buf) < 0)
H5TOOLS_THROW(FAIL, "h5tools_dump_simple_data failed");
/* Reclaim any VL memory, if necessary */
@@ -1586,12 +1580,10 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_co
ctx->ndims = (unsigned)sndims;
/* assume entire data space to be printed */
- if (ctx->ndims > 0)
- for (i = 0; i < (size_t) ctx->ndims; i++)
- ctx->p_min_idx[i] = 0;
-
if(H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0)
H5TOOLS_THROW(FAIL, "H5Sget_simple_extent_dims failed");
+ init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx);
+
ctx->size_last_dim = total_size[ctx->ndims - 1];
/* Set the compound datatype field list for display */
@@ -1623,38 +1615,37 @@ CATCH
*-------------------------------------------------------------------------
*/
static int
-h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
- hid_t dset, hid_t p_type)
+h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, hid_t p_type)
{
- hid_t f_space = H5I_INVALID_HID; /* file data space */
- hsize_t elmtno; /* counter */
- size_t i; /* counter */
- int sndims; /* rank of dataspace */
- int carry; /* counter carry value */
- hsize_t zero[8]; /* vector of zeros */
- unsigned int flags; /* buffer extent flags */
- hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
- hbool_t past_catch = FALSE;
+ hid_t f_space = H5I_INVALID_HID; /* file data space */
+ hsize_t elmtno; /* counter */
+ size_t i = 0; /* counter */
+ int sndims; /* rank of dataspace */
+ int carry; /* counter carry value */
+ hsize_t zero[8]; /* vector of zeros */
+ unsigned int flags; /* buffer extent flags */
+ hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
+ hbool_t past_catch = FALSE;
/* Print info */
- size_t p_type_nbytes; /* size of memory type */
- hsize_t p_nelmts; /* total selected elmts */
+ size_t p_type_nbytes; /* size of memory type */
+ hsize_t p_nelmts; /* total selected elmts */
/* Stripmine info */
- hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
- 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 = H5I_INVALID_HID; /* stripmine data space */
+ hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
+ 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 = H5I_INVALID_HID; /* stripmine data space */
/* Hyperslab info */
- hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */
- hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */
- hsize_t hs_nelmts; /* elements in request */
+ hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */
+ hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */
+ hsize_t hs_nelmts; /* elements in request */
/* VL data special information */
- unsigned int vl_data = 0; /* contains VL datatypes */
- int ret_value = 0;
+ unsigned int vl_data = 0; /* contains VL datatypes */
+ int ret_value = 0;
H5TOOLS_START_DEBUG("");
if (H5I_INVALID_HID == (f_space = H5Dget_space(dset)))
@@ -1670,11 +1661,8 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
H5TOOLS_GOTO_ERROR((-1), "ctx->ndims > NELMTS(sm_size) failed");
/* Assume entire data space to be printed */
- if (ctx->ndims > 0)
- for (i = 0; i < (size_t)ctx->ndims; i++)
- ctx->p_min_idx[i] = 0;
-
H5Sget_simple_extent_dims(f_space, total_size, NULL);
+ init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx);
/* calculate the number of elements we're going to print */
p_nelmts = 1;
@@ -1720,8 +1708,6 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
H5TOOLS_DEBUG("sm_nelmts size:%ld", sm_nelmts);
- if (ctx->ndims > 0)
- init_acc_pos(ctx, total_size);
H5TOOLS_DEBUG("ctx->ndims:%d", ctx->ndims);
/* The stripmine loop */
@@ -1762,7 +1748,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
indices */
ctx->sm_pos = elmtno;
- if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, hs_nelmts, p_type, sm_buf) < 0)
+ if(h5tools_dump_simple_data(stream, info, ctx, dset, flags, hs_nelmts, p_type, sm_buf) < 0)
H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed");
/* Reclaim any VL memory, if necessary */
@@ -1841,11 +1827,8 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_conte
H5TOOLS_THROW((-1), "ctx->ndims > NELMTS(ctx->p_min_idx) failed");
/* Assume entire data space to be printed */
- if (ctx->ndims > 0)
- for (i = 0; i < (size_t)ctx->ndims; i++)
- ctx->p_min_idx[i] = 0;
-
H5Sget_simple_extent_dims(f_space, total_size, NULL);
+ init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx);
/* calculate the number of elements we're going to print */
p_nelmts = 1;
@@ -1868,14 +1851,12 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_conte
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("ctx->ndims:%d", ctx->ndims);
H5TOOLS_DEBUG("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)
+ if(h5tools_dump_simple_data(stream, info, ctx, attr_id, START_OF_DATA | END_OF_DATA, p_nelmts, p_type, buf) < 0)
H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed");
/* Reclaim any VL memory, if necessary */
@@ -3987,6 +3968,226 @@ h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tool
}
/*-------------------------------------------------------------------------
+ * Function: dump_reference
+ *
+ * Purpose: Dump reference data
+ *
+ * Return: void
+ *-------------------------------------------------------------------------
+ */
+void
+h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t container, H5R_ref_t *ref_buf, int ndims)
+{
+ hid_t new_obj_id = H5I_INVALID_HID;
+ hid_t new_obj_sid = H5I_INVALID_HID;
+ hsize_t elmt_counter = 0; /*counts the # elements printed. */
+ size_t ncols = 80; /* available output width */
+ int i;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t datactx; /* print context */
+
+ H5TOOLS_START_DEBUG("");
+
+ datactx = *ctx; /* print context */
+ /* Assume entire data space to be printed */
+ datactx.need_prefix = TRUE;
+
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+ for(i = 0; i < ndims; i++, datactx.cur_elmt++, elmt_counter++) {
+ H5O_type_t obj_type = -1; /* Object type */
+ H5R_type_t ref_type; /* Reference type */
+
+ H5TOOLS_DEBUG("reference loop:%d with curr_pos=%ld", i, curr_pos);
+
+ datactx.need_prefix = TRUE;
+ h5tools_str_reset(&buffer);
+ H5TOOLS_DEBUG("reference loop - h5tools_str_sprint with H5T_STD_REF:%d", i);
+ h5tools_str_sprint(&buffer, info, container, H5T_STD_REF, &ref_buf[i], &datactx);
+ h5tools_render_element(stream, info, &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("ref_type is H5R_OBJECT1");
+ if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
+ switch (obj_type) {
+ case H5O_TYPE_DATASET:
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ datactx.indent_level++;
+ h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE);
+ //h5tools_dump_dset(stream, info, &datactx, new_obj_id);
+ datactx.indent_level--;
+ if(H5Dclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed");
+ }
+ else
+ H5TOOLS_INFO("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_INFO("H5Rget_obj_type3 H5R_OBJECT1 failed");
+ break;
+ case H5R_DATASET_REGION1:
+ H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1");
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ datactx.indent_level++;
+ h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE);
+ //h5tools_dump_dset(stream, info, &datactx, new_obj_id);
+ datactx.indent_level--;
+ if(H5Dclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION1 failed");
+ }
+ else
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed");
+ break;
+ case H5R_OBJECT2:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT2");
+ if (H5Rget_obj_type3(&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(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ datactx.indent_level++;
+ h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE);
+ //h5tools_dump_dset(stream, info, &datactx, new_obj_id);
+ datactx.indent_level--;
+ if(H5Oclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed");
+ }
+ else
+ H5TOOLS_INFO("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_INFO("H5Rget_obj_type3 H5R_OBJECT2 failed");
+ break;
+ case H5R_DATASET_REGION2:
+ H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2");
+
+ if (info->line_ncols > 0)
+ ncols = info->line_ncols;
+
+ /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed");
+ else {
+ if((new_obj_sid = H5Ropen_region(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) {
+ H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " {");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
+ datactx.need_prefix = TRUE;
+ datactx.indent_level++;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "NULL");
+ h5tools_render_element(stream, info, &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, info, &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("H5S_SEL_POINTS H5R_DATASET_REGION2");
+ h5tools_dump_region_data_points(new_obj_sid, new_obj_id, stream, info, &datactx,
+ &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter);
+ }
+ else if(region_type == H5S_SEL_HYPERSLABS) {
+ /* Print block information */
+ H5TOOLS_DEBUG("H5S_SEL_HYPERSLABS H5R_DATASET_REGION2");
+ h5tools_dump_region_data_blocks(new_obj_sid, new_obj_id, stream, info, &datactx,
+ &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter);
+ }
+ else
+ H5TOOLS_INFO("invalid region type");
+ } /* end else to if (h5tools_is_zero(... */
+ if(H5Sclose(new_obj_sid) < 0)
+ H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed");
+ }
+ else
+ H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed");
+ if(H5Dclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed");
+ }
+ break;
+ case H5R_ATTR:
+ H5TOOLS_DEBUG("ref_type is H5R_ATTR");
+ if((new_obj_id = H5Ropen_attr(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ h5tools_dump_region_attribute(new_obj_id, stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+ if(H5Aclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Aclose H5R_ATTR failed");
+ }
+ else {
+ H5TOOLS_DEBUG("NULL H5R_ATTR");
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " {");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
+ datactx.need_prefix = TRUE;
+ datactx.indent_level++;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "NULL");
+ h5tools_render_element(stream, info, &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, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
+ H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed");
+ }
+ break;
+ case H5R_BADTYPE:
+ case H5R_MAXTYPE:
+ default:
+ break;
+ } /* end switch */
+
+ if(H5Rdestroy(&ref_buf[i]) < 0)
+ H5TOOLS_INFO("H5Rdestroy failed");
+
+ H5TOOLS_DEBUG("finished reference loop:%d",i);
+ } /* end for(i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) */
+
+ h5tools_str_close(&buffer);
+
+ H5TOOLS_ENDDEBUG("");
+}
+
+/*-------------------------------------------------------------------------
* Function: dump_data
*
* Purpose: Dump attribute, obj_data is FALSE, or dataset data, obj_data is TRUE
@@ -3999,13 +4200,9 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
{
H5S_class_t space_type;
int ndims;
- 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;
h5tools_context_t datactx; /* print context */
h5tools_str_t buffer; /* string into which to render */
@@ -4070,13 +4267,9 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
H5TOOLS_DEBUG("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);
+ init_acc_pos(datactx.ndims, total_size, datactx.acc, datactx.pos, datactx.p_min_idx);
+
datactx.need_prefix = TRUE;
if (NULL != (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) {
@@ -4094,197 +4287,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
H5TOOLS_GOTO_DONE_NO_RET();
}
}
- for (i = 0; i < (size_t)ndims; i++, datactx.cur_elmt++, elmt_counter++) {
- H5O_type_t obj_type = -1; /* Object type */
- H5R_type_t ref_type; /* Reference type */
-
- H5TOOLS_DEBUG("reference loop:%d with curr_pos=%ld", i, curr_pos);
-
- datactx.need_prefix = TRUE;
- h5tools_str_reset(&buffer);
- H5TOOLS_DEBUG("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("ref_type is H5R_OBJECT1");
- if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
- switch (obj_type) {
- case H5O_TYPE_DATASET:
- if((new_obj_id = H5Ropen_object(&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_INFO("H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed");
- }
- else
- H5TOOLS_INFO("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_INFO("H5Rget_obj_type3 H5R_OBJECT1 failed");
- break;
- case H5R_DATASET_REGION1:
- H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1");
- if((new_obj_id = H5Ropen_object(&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_INFO("H5Dclose H5R_DATASET_REGION1 failed");
- }
- else
- H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed");
- break;
- case H5R_OBJECT2:
- H5TOOLS_DEBUG("ref_type is H5R_OBJECT2");
- if (H5Rget_obj_type3(&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(&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_INFO("H5Oclose H5R_OBJECT2 failed");
- }
- else
- H5TOOLS_INFO("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_INFO("H5Rget_obj_type3 H5R_OBJECT2 failed");
- break;
- case H5R_DATASET_REGION2:
- H5TOOLS_DEBUG("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(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0)
- H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed");
- else {
- if((new_obj_sid = H5Ropen_region(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) {
- H5TOOLS_DEBUG("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("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("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_INFO("invalid region type");
- } /* end else to if (h5tools_is_zero(... */
- if(H5Sclose(new_obj_sid) < 0)
- H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed");
- }
- else
- H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed");
- if(H5Dclose(new_obj_id) < 0)
- H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed");
- }
- break;
- case H5R_ATTR:
- H5TOOLS_DEBUG("ref_type is H5R_ATTR");
- if((new_obj_id = H5Ropen_attr(&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_INFO("H5Aclose H5R_ATTR failed");
- }
- else {
- H5TOOLS_DEBUG("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_INFO("H5Ropen_attr H5R_ATTR failed");
- }
- break;
- case H5R_BADTYPE:
- case H5R_MAXTYPE:
- default:
- break;
- } /* end switch */
-
- if(H5Rdestroy(&ref_buf[i]) < 0)
- H5TOOLS_INFO("H5Rdestroy failed");
-
- H5TOOLS_DEBUG("finished reference loop:%d",i);
- } /* end for(i = 0; i < ndims; i++, datactx->cur_elmt++, elmt_counter++) */
+ h5tools_dump_reference(stream, &outputformat, &datactx, obj_id, ref_buf, ndims);
HDfree(ref_buf);
}
ctx->indent_level--;
diff --git a/tools/lib/h5tools_dump.h b/tools/lib/h5tools_dump.h
index 2cd0bc1..add2e46 100644
--- a/tools/lib/h5tools_dump.h
+++ b/tools/lib/h5tools_dump.h
@@ -36,63 +36,53 @@ H5TOOLS_DLLVAR table_t *h5dump_type_table; /*type table reference for datatype
/* Definitions of useful routines */
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);
-H5TOOLS_DLL int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info,
- 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);
-H5TOOLS_DLL void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/, hid_t type);
-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);
-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,
- h5tools_context_t *ctx/*in,out*/, hid_t dcpl, hid_t type_id, hid_t obj_id);
-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);
+H5TOOLS_DLL int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, 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);
+H5TOOLS_DLL int h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
+ hid_t container, unsigned flags, hsize_t nelmts, hid_t type, void *_mem);
+H5TOOLS_DLL void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
+ hid_t type);
+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);
+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, h5tools_context_t *ctx/*in,out*/,
+ hid_t dcpl, hid_t type_id, hid_t obj_id);
+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);
+H5TOOLS_DLL void h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ hid_t container, H5R_ref_t *ref_buf, int ndims);
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);
+ FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
+ h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_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);
+ FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
+ h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_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);
+ FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
+ h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_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*/,
+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*/,
hid_t type, int object_search);
H5TOOLS_DLL int h5tools_print_dataspace(h5tools_str_t *buffer/*in,out*/,
hid_t space);
-H5TOOLS_DLL int h5tools_print_enum(FILE *stream, h5tools_str_t *buffer/*in,out*/,
- const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
+H5TOOLS_DLL int h5tools_print_enum(FILE *stream,
+ h5tools_str_t *buffer/*in,out*/, 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*/,
+H5TOOLS_DLL 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_DLL void h5tools_print_packed_bits(h5tools_str_t *buffer/*in,out*/, hid_t type);
+
#ifdef __cplusplus
}
#endif
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 5c777a9..d612fbd 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -278,16 +278,12 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt)
* Purpose: Renders the line prefix value into string STR.
*
* Return: Success: Pointer to the prefix.
- *
* Failure: NULL
- *
- * Programmer: Robb Matzke
- * Thursday, July 23, 1998
*-------------------------------------------------------------------------
*/
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_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, hsize_t elmtno,
+ h5tools_context_t *ctx)
{
size_t i = 0;
hsize_t curr_pos = elmtno;
@@ -297,28 +293,16 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info,
H5TOOLS_DEBUG("elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims);
h5tools_str_reset(str);
- H5TOOLS_DEBUG("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("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("curr_pos=%ld - ctx->pos[%d]=%ld - ctx->acc[%d]=%ld", curr_pos, i, ctx->pos[i], i, ctx->acc[i]);
- }
+ curr_pos = calc_acc_pos(ctx->ndims, elmtno, ctx->acc, ctx->pos);
+ if(ctx->ndims > 0) {
HDassert(curr_pos == 0);
/* Print the index values */
- for(i = 0; i < (size_t) ndims; i++) {
+ for(i = 0; i < (size_t) ctx->ndims; i++) {
if (i)
h5tools_str_append(str, "%s", OPT(info->idx_sep, ","));
- h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT),
- (hsize_t) ctx->pos[i]);
-
+ h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) ctx->pos[i]);
}
}
else /* Scalar */
@@ -338,52 +322,38 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info,
*
* Return: Success: Pointer to the prefix.
* Failure: NULL
- *
- * In/Out:
- * h5tools_context_t *ctx
- * h5tools_str_t *str
*-------------------------------------------------------------------------
*/
char *
-h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info,
- hsize_t elmtno, hsize_t *ptdata, unsigned ndims, hsize_t max_idx[],
- h5tools_context_t *ctx)
+h5tools_str_region_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, hsize_t elmtno,
+ hsize_t *ptdata, h5tools_context_t *ctx)
{
size_t i = 0;
hsize_t curr_pos = elmtno;
- hsize_t p_prod[H5S_MAX_RANK];
- h5tools_str_reset(str);
+ H5TOOLS_START_DEBUG("");
- if(ndims > 0) {
- /*
- * Calculate the number of elements represented by a unit change in a
- * certain index position.
- */
- for(i = ndims - 1, p_prod[ndims - 1] = 1; i > 0; --i)
- p_prod[i - 1] = (max_idx[i]) * p_prod[i];
+ H5TOOLS_DEBUG("elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims);
+ h5tools_str_reset(str);
- for(i = 0; i < (size_t) ndims; i++) {
- if(curr_pos > 0) {
- ctx->pos[i] = curr_pos / p_prod[i];
- curr_pos -= p_prod[i] * ctx->pos[i];
- }
- else
- ctx->pos[i] = 0;
- ctx->pos[i] += (unsigned long) ptdata[ctx->sm_pos+i];
- }
+ curr_pos = calc_acc_pos(ctx->ndims, elmtno, ctx->acc, ctx->pos);
+ if(ctx->ndims > 0) {
+ HDassert(curr_pos == 0);
/* Print the index values */
- for(i = 0; i < (size_t) ndims; i++) {
- if(i)
+ for(i = 0; i < (size_t) ctx->ndims; i++) {
+ ctx->pos[i] += (unsigned long) ptdata[ctx->sm_pos+i];
+ if (i)
h5tools_str_append(str, "%s", OPT(info->idx_sep, ","));
h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) ctx->pos[i]);
-
}
- } /* if (ndims > 0) */
+ }
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)0);
+ H5TOOLS_DEBUG("str=%s", str->s);
+
+ H5TOOLS_ENDDEBUG("");
/* Add prefix and suffix to the index */
return h5tools_str_fmt(str, (size_t)0, OPT(info->idx_fmt, "%s: "));
diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h
index 02bfe40..074e86d 100644
--- a/tools/lib/h5tools_str.h
+++ b/tools/lib/h5tools_str.h
@@ -31,13 +31,12 @@ H5TOOLS_DLL char *h5tools_str_reset(h5tools_str_t *str);
H5TOOLS_DLL char *h5tools_str_trunc(h5tools_str_t *str, size_t size);
H5TOOLS_DLL char *h5tools_str_fmt(h5tools_str_t *str, size_t start, const char *fmt);
H5TOOLS_DLL char *h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_t *info,
- hsize_t elmtno, unsigned ndims, h5tools_context_t *ctx);
+ hsize_t elmtno, h5tools_context_t *ctx);
/*
* 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 max_idx[], h5tools_context_t *ctx);
+ hsize_t elmtno, hsize_t *ptdata, 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 *);
diff --git a/tools/lib/io_timer.c b/tools/lib/io_timer.c
index 472824b..5c0c31d 100644
--- a/tools/lib/io_timer.c
+++ b/tools/lib/io_timer.c
@@ -23,7 +23,6 @@
*/
#include "H5private.h"
-#include "hdf5.h"
#include "io_timer.h"