summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/Makefile.in1
-rw-r--r--tools/lib/h5diff.c1286
-rw-r--r--tools/lib/h5diff.h22
-rw-r--r--tools/lib/h5diff_array.c6442
-rw-r--r--tools/lib/h5diff_attr.c269
-rw-r--r--tools/lib/h5diff_dset.c633
-rw-r--r--tools/lib/h5diff_util.c89
-rw-r--r--tools/lib/h5tools.c505
-rw-r--r--tools/lib/h5tools_dump.c329
-rw-r--r--tools/lib/h5tools_error.h20
-rw-r--r--tools/lib/h5tools_filters.c254
-rw-r--r--tools/lib/h5tools_ref.c47
-rw-r--r--tools/lib/h5tools_str.c18
-rw-r--r--tools/lib/h5tools_type.c126
-rw-r--r--tools/lib/h5tools_utils.c245
-rw-r--r--tools/lib/h5trav.c563
-rw-r--r--tools/lib/io_timer.c10
-rw-r--r--tools/lib/ph5diff.h2
18 files changed, 4415 insertions, 6446 deletions
diff --git a/tools/lib/Makefile.in b/tools/lib/Makefile.in
index 8ee8348..342b4e8 100644
--- a/tools/lib/Makefile.in
+++ b/tools/lib/Makefile.in
@@ -581,6 +581,7 @@ dvidir = @dvidir@
enable_shared = @enable_shared@
enable_static = @enable_static@
exec_prefix = @exec_prefix@
+fortran_linux_linker_option = @fortran_linux_linker_option@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index 20b5136..0b10249 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -11,8 +11,6 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include <stdlib.h>
-
#include "H5private.h"
#include "h5tools.h"
#include "h5tools_utils.h"
@@ -23,25 +21,25 @@
/*-------------------------------------------------------------------------
* Function: print_objname
*
- * Purpose: check if object name is to be printed, only when:
- * 1) verbose mode
- * 2) when diff was found (normal mode)
+ * Purpose: check if object name is to be printed, only when:
+ * 1) verbose mode
+ * 2) when diff was found (normal mode)
*-------------------------------------------------------------------------
*/
-int
-print_objname (diff_opt_t * options, hsize_t nfound)
+ int
+print_objname (diff_opt_t * opts, hsize_t nfound)
{
- return ((options->m_verbose || nfound) && !options->m_quiet) ? 1 : 0;
+ return ((opts->m_verbose || nfound) && !opts->m_quiet) ? 1 : 0;
}
/*-------------------------------------------------------------------------
* Function: do_print_objname
*
- * Purpose: print object name
- *
+ * Purpose: print object name
*-------------------------------------------------------------------------
*/
-void do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_opt_t * opts)
+void
+do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_opt_t * opts)
{
/* if verbose level is higher than 0, put space line before
* displaying any object or symbolic links. This improves
@@ -55,8 +53,7 @@ void do_print_objname (const char *OBJ, const char *path1, const char *path2, di
/*-------------------------------------------------------------------------
* Function: do_print_attrname
*
- * Purpose: print attribute name
- *
+ * Purpose: print attribute name
*-------------------------------------------------------------------------
*/
void
@@ -68,17 +65,16 @@ do_print_attrname (const char *attr, const char *path1, const char *path2)
/*-------------------------------------------------------------------------
* Function: print_warn
*
- * Purpose: check print warning condition.
+ * Purpose: check print warning condition.
* Return:
- * 1 if verbose mode
- * 0 if not verbos mode
- * Programmer: Jonathan Kim
- * Date: Feb 4, 2010
+ * 1 if verbose mode
+ * 0 if not verbos mode
*-------------------------------------------------------------------------
*/
-static int print_warn(diff_opt_t *options)
+static int
+print_warn(diff_opt_t *opts)
{
- return ((options->m_verbose))?1:0;
+ return ((opts->m_verbose)) ? 1: 0;
}
@@ -86,20 +82,16 @@ static int print_warn(diff_opt_t *options)
/*-------------------------------------------------------------------------
* Function: phdiff_dismiss_workers
*
- * Purpose: tell all workers to end.
- *
- * Return: none
- *
- * Programmer: Albert Cheng
- *
- * Date: Feb 6, 2005
+ * Purpose: tell all workers to end.
*
+ * Return: none
*-------------------------------------------------------------------------
*/
-void phdiff_dismiss_workers(void)
+void
+phdiff_dismiss_workers(void)
{
int i;
- for(i=1; i<g_nTasks; i++)
+ for (i = 1; i < g_nTasks; i++)
MPI_Send(NULL, 0, MPI_BYTE, i, MPI_TAG_END, MPI_COMM_WORLD);
}
@@ -107,29 +99,23 @@ void phdiff_dismiss_workers(void)
/*-------------------------------------------------------------------------
* Function: print_incoming_data
*
- * Purpose: special function that prints any output that has been sent to the manager
- * and is currently sitting in the incoming message queue
- *
- * Return: none
- *
- * Programmer: Leon Arber
- *
- * Date: March 7, 2005
+ * Purpose: special function that prints any output that has been sent to the manager
+ * and is currently sitting in the incoming message queue
*
+ * Return: none
*-------------------------------------------------------------------------
*/
-static void print_incoming_data(void)
+static void
+print_incoming_data(void)
{
- char data[PRINT_DATA_MAX_SIZE+1];
+ char data[PRINT_DATA_MAX_SIZE + 1];
int incomingMessage;
MPI_Status Status;
- do
- {
+ do {
MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &incomingMessage, &Status);
- if(incomingMessage)
- {
+ if(incomingMessage) {
HDmemset(data, 0, PRINT_DATA_MAX_SIZE+1);
MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &Status);
@@ -142,81 +128,68 @@ static void print_incoming_data(void)
/*-------------------------------------------------------------------------
* Function: is_valid_options
*
- * Purpose: check if options are valid
+ * Purpose: check if options are valid
*
* Return:
- * 1 : Valid
- * 0 : Not valid
- *
- * Programmer: Jonathan Kim
- *
- * Date: Feb 17, 2010
- *
+ * 1 : Valid
+ * 0 : Not valid
*------------------------------------------------------------------------*/
-static int is_valid_options(diff_opt_t *options)
+static int
+is_valid_options(diff_opt_t *opts)
{
- int ret=1; /* init to valid */
+ int ret_value = 1; /* init to valid */
/*-----------------------------------------------
* no -q(quiet) with -v (verbose) or -r (report) */
- if(options->m_quiet && (options->m_verbose || options->m_report))
- {
+ if(opts->m_quiet && (opts->m_verbose || opts->m_report)) {
parallel_print("Error: -q (quiet mode) cannot be added to verbose or report modes\n");
- options->err_stat=1;
- ret = 0;
- goto out;
+ opts->err_stat = 1;
+ HGOTO_DONE(0);
}
/* -------------------------------------------------------
* only allow --no-dangling-links along with --follow-symlinks */
- if(options->no_dangle_links && !options->follow_links)
- {
+ if(opts->no_dangle_links && !opts->follow_links) {
parallel_print("Error: --no-dangling-links must be used along with --follow-symlinks option.\n");
- options->err_stat=1;
- ret = 0;
- goto out;
+ opts->err_stat = 1;
+ HGOTO_DONE(0);
}
-out:
+done:
- return ret;
+ return ret_value;
}
/*-------------------------------------------------------------------------
* Function: is_exclude_path
*
- * Purpose: check if 'paths' are part of exclude path list
+ * Purpose: check if 'paths' are part of exclude path list
*
* Return:
- * 1 - excluded path
- * 0 - not excluded path
- *
- * Programmer: Jonathan Kim
- * Date: Aug 23, 2010
+ * 1 - excluded path
+ * 0 - not excluded path
*------------------------------------------------------------------------*/
-static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options)
+static int
+is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *opts)
{
struct exclude_path_list * exclude_path_ptr;
- int ret_cmp;
- int ret = 0;
+ int ret_cmp;
+ int ret_value = 0;
/* check if exclude path option is given */
- if (!options->exclude_path)
- goto out;
+ if (!opts->exclude_path)
+ HGOTO_DONE(0);
/* assign to local exclude list pointer */
- exclude_path_ptr = options->exclude;
+ exclude_path_ptr = opts->exclude;
/* search objects in exclude list */
- while (NULL != exclude_path_ptr)
- {
+ while (NULL != exclude_path_ptr) {
/* if exclude path is is group, exclude its members as well */
- if (exclude_path_ptr->obj_type == H5TRAV_TYPE_GROUP)
- {
+ if (exclude_path_ptr->obj_type == H5TRAV_TYPE_GROUP) {
ret_cmp = HDstrncmp(exclude_path_ptr->obj_path, path,
HDstrlen(exclude_path_ptr->obj_path));
- if (ret_cmp == 0) /* found matching members */
- {
+ if (ret_cmp == 0) { /* found matching members */
size_t len_grp;
/* check if given path belong to an excluding group, if so
@@ -225,22 +198,19 @@ static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options
* not under “/grp1xxx/” group.
*/
len_grp = HDstrlen(exclude_path_ptr->obj_path);
- if (path[len_grp] == '/')
- {
+ if (path[len_grp] == '/') {
/* belong to excluded group! */
- ret = 1;
+ ret_value = 1;
break; /* while */
}
}
}
/* exclude target is not group, just exclude the object */
- else
- {
+ else {
ret_cmp = HDstrcmp(exclude_path_ptr->obj_path, path);
- if (ret_cmp == 0) /* found matching object */
- {
+ if (ret_cmp == 0) { /* found matching object */
/* excluded non-group object */
- ret = 1;
+ ret_value = 1;
/* remember the type of this maching object.
* if it's group, it can be used for excluding its member
* objects in this while() loop */
@@ -251,26 +221,23 @@ static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options
exclude_path_ptr = exclude_path_ptr->next;
}
-out:
- return ret;
+done:
+ return ret_value;
}
/*-------------------------------------------------------------------------
* Function: free_exclude_path_list
*
- * Purpose: free exclud object list from diff options
- *
- * Programmer: Jonathan Kim
- * Date: Aug 23, 2010
+ * Purpose: free exclude object list from diff options
*------------------------------------------------------------------------*/
-static void free_exclude_path_list(diff_opt_t *options)
+static void
+free_exclude_path_list(diff_opt_t *opts)
{
- struct exclude_path_list * curr = options->exclude;
- struct exclude_path_list * next;
+ struct exclude_path_list *curr = opts->exclude;
+ struct exclude_path_list *next;
- while (NULL != curr)
- {
+ while (NULL != curr) {
next = curr->next;
HDfree(curr);
curr = next;
@@ -280,44 +247,43 @@ static void free_exclude_path_list(diff_opt_t *options)
/*-------------------------------------------------------------------------
* Function: build_match_list
*
- * Purpose: get list of matching path_name from info1 and info2
+ * Purpose: get list of matching path_name from info1 and info2
*
* Note:
- * Find common objects; the algorithm used for this search is the
- * cosequential match algorithm and is described in
- * Folk, Michael; Zoellick, Bill. (1992). File Structures. Addison-Wesley.
- * Moved out from diff_match() to make code more flexible.
+ * Find common objects; the algorithm used for this search is the
+ * cosequential match algorithm and is described in
+ * Folk, Michael; Zoellick, Bill. (1992). File Structures. Addison-Wesley.
+ * Moved out from diff_match() to make code more flexible.
*
* Parameter:
- * table_out [OUT] : return the list
- *
- * Programmer: Jonathan Kim
- *
- * Date: Aug 18, 2010
+ * table_out [OUT] : return the list
*------------------------------------------------------------------------*/
-static void build_match_list (const char *objname1, trav_info_t *info1, const char *objname2, trav_info_t *info2, trav_table_t ** table_out, diff_opt_t *options)
+static void
+build_match_list (const char *objname1, trav_info_t *info1, const char *objname2, trav_info_t *info2,
+ trav_table_t ** table_out, diff_opt_t *opts)
{
- size_t curr1 = 0;
- size_t curr2 = 0;
+ size_t curr1 = 0;
+ size_t curr2 = 0;
unsigned infile[2];
- char * path1_lp;
- char * path2_lp;
+ char *path1_lp = NULL;
+ char *path2_lp = NULL;
h5trav_type_t type1_l;
h5trav_type_t type2_l;
- size_t path1_offset = 0;
- size_t path2_offset = 0;
- int cmp;
- trav_table_t *table;
- size_t idx;
+ size_t path1_offset = 0;
+ size_t path2_offset = 0;
+ int cmp;
+ trav_table_t *table = NULL;
+ size_t idx;
h5difftrace("build_match_list start\n");
/* init */
- trav_table_init( &table );
-
+ trav_table_init(&table);
+ if (table == NULL)
+ H5TOOLS_INFO(H5E_tools_min_id_g, "Cannot create tarverse table");
/*
* This is necessary for the case that given objects are group and
* have different names (ex: obj1 is /grp1 and obj2 is /grp5).
- * All the objects belong to given groups are the cadidates.
+ * All the objects belong to given groups are the candidates.
* So prepare to compare paths without the group names.
*/
@@ -331,8 +297,7 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch
/*--------------------------------------------------
* build the list
*/
- while(curr1 < info1->nused && curr2 < info2->nused)
- {
+ while(curr1 < info1->nused && curr2 < info2->nused) {
path1_lp = (info1->paths[curr1].path) + path1_offset;
path2_lp = (info2->paths[curr2].path) + path2_offset;
type1_l = info1->paths[curr1].type;
@@ -340,19 +305,15 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch
/* criteria is string compare */
cmp = HDstrcmp(path1_lp, path2_lp);
-
- if(cmp == 0)
- {
- if(!is_exclude_path(path1_lp, type1_l, options))
- {
+ if(cmp == 0) {
+ if(!is_exclude_path(path1_lp, type1_l, opts)) {
infile[0] = 1;
infile[1] = 1;
trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table);
/* if the two point to the same target object,
* mark that in table */
if (info1->paths[curr1].fileno == info2->paths[curr2].fileno &&
- info1->paths[curr1].objno == info2->paths[curr2].objno )
- {
+ info1->paths[curr1].objno == info2->paths[curr2].objno) {
idx = table->nobjs - 1;
table->objs[idx].is_same_trgobj = 1;
}
@@ -360,20 +321,16 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch
curr1++;
curr2++;
} /* end if */
- else if(cmp < 0)
- {
- if(!is_exclude_path(path1_lp, type1_l, options))
- {
+ else if(cmp < 0) {
+ if(!is_exclude_path(path1_lp, type1_l, opts)) {
infile[0] = 1;
infile[1] = 0;
trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table);
}
curr1++;
} /* end else-if */
- else
- {
- if (!is_exclude_path(path2_lp, type2_l, options))
- {
+ else {
+ if (!is_exclude_path(path2_lp, type2_l, opts)) {
infile[0] = 0;
infile[1] = 1;
trav_table_addflags(infile, path2_lp, info2->paths[curr2].type, table);
@@ -385,13 +342,11 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch
/* list1 did not end */
infile[0] = 1;
infile[1] = 0;
- while(curr1 < info1->nused)
- {
+ while(curr1 < info1->nused) {
path1_lp = (info1->paths[curr1].path) + path1_offset;
type1_l = info1->paths[curr1].type;
- if(!is_exclude_path(path1_lp, type1_l, options))
- {
+ if(!is_exclude_path(path1_lp, type1_l, opts)) {
trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table);
}
curr1++;
@@ -400,19 +355,17 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch
/* list2 did not end */
infile[0] = 0;
infile[1] = 1;
- while(curr2 < info2->nused)
- {
+ while(curr2 < info2->nused) {
path2_lp = (info2->paths[curr2].path) + path2_offset;
type2_l = info2->paths[curr2].type;
- if (!is_exclude_path(path2_lp, type2_l, options))
- {
+ if (!is_exclude_path(path2_lp, type2_l, opts)) {
trav_table_addflags(infile, path2_lp, info2->paths[curr2].type, table);
}
curr2++;
} /* end while */
- free_exclude_path_list (options);
+ free_exclude_path_list (opts);
*table_out = table;
h5difftrace("build_match_list finish\n");
@@ -422,15 +375,11 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch
/*-------------------------------------------------------------------------
* Function: trav_grp_objs
*
- * Purpose:
- * Call back function from h5trav_visit().
- *
- * Programmer: Jonathan Kim
- *
- * Date: Aug 16, 2010
+ * Purpose: Call back function from h5trav_visit().
*------------------------------------------------------------------------*/
-static herr_t trav_grp_objs(const char *path, const H5O_info_t *oinfo,
- const char *already_visited, void *udata)
+static herr_t
+trav_grp_objs(const char *path, const H5O_info_t *oinfo,
+ const char *already_visited, void *udata)
{
trav_info_visit_obj(path, oinfo, already_visited, udata);
@@ -440,99 +389,86 @@ static herr_t trav_grp_objs(const char *path, const H5O_info_t *oinfo,
/*-------------------------------------------------------------------------
* Function: trav_grp_symlinks
*
- * Purpose:
- * Call back function from h5trav_visit().
- * Track and extra checkings while visiting all symbolic-links.
- *
- * Programmer: Jonathan Kim
- *
- * Date: Aug 16, 2010
+ * Purpose: Call back function from h5trav_visit().
+ * Track and extra checkings while visiting all symbolic-links.
*------------------------------------------------------------------------*/
-static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo,
- void *udata)
+static herr_t
+trav_grp_symlinks(const char *path, const H5L_info_t *linfo, void *udata)
{
- trav_info_t *tinfo = (trav_info_t *)udata;
- diff_opt_t *opts = (diff_opt_t *)tinfo->opts;
- int ret;
+ herr_t ret_value = 0;
+ trav_info_t *tinfo = (trav_info_t *)udata;
+ diff_opt_t *opts = (diff_opt_t *)tinfo->opts;
h5tool_link_info_t lnk_info;
- const char *ext_fname;
- const char *ext_path;
+ const char *ext_fname;
+ const char *ext_path;
/* init linkinfo struct */
HDmemset(&lnk_info, 0, sizeof(h5tool_link_info_t));
- if (!opts->follow_links)
- {
+ if (!opts->follow_links) {
trav_info_visit_lnk(path, linfo, tinfo);
- goto done;
+ HGOTO_DONE(0);
}
- switch(linfo->type)
- {
+ switch(linfo->type) {
case H5L_TYPE_SOFT:
- ret = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links);
- /* error */
- if (ret < 0)
- goto done;
- /* no dangling link option given and detect dangling link */
- else if (ret == 0)
- {
- tinfo->symlink_visited.dangle_link = TRUE;
+ if((ret_value = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links)) < 0) {
+ HGOTO_DONE(FAIL);
+ }
+ else if (ret_value == 0) {
+ /* no dangling link option given and detect dangling link */
+ tinfo->symlink_visited.dangle_link = TRUE;
trav_info_visit_lnk(path, linfo, tinfo);
if (opts->no_dangle_links)
opts->err_stat = 1; /* make dangling link is error */
- goto done;
+ HGOTO_DONE(0);
}
/* check if already visit the target object */
if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path))
- goto done;
+ HGOTO_DONE(0);
/* add this link as visited link */
if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path) < 0)
- goto done;
+ HGOTO_DONE(0);
if(h5trav_visit(tinfo->fid, path, TRUE, TRUE,
- trav_grp_objs,trav_grp_symlinks, tinfo) < 0)
- {
+ trav_grp_objs,trav_grp_symlinks, tinfo) < 0) {
parallel_print("Error: Could not get file contents\n");
opts->err_stat = 1;
- goto done;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Could not get file contents");
}
break;
case H5L_TYPE_EXTERNAL:
- ret = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links);
- /* error */
- if (ret < 0)
- goto done;
+ if ((ret_value = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links)) < 0) {
+ HGOTO_DONE(FAIL);
+ }
+ else if (ret_value == 0) {
/* no dangling link option given and detect dangling link */
- else if (ret == 0)
- {
tinfo->symlink_visited.dangle_link = TRUE;
trav_info_visit_lnk(path, linfo, tinfo);
if (opts->no_dangle_links)
opts->err_stat = 1; /* make dangling link is error */
- goto done;
+ HGOTO_DONE(0);
}
if(H5Lunpack_elink_val(lnk_info.trg_path, linfo->u.val_size, NULL, &ext_fname, &ext_path) < 0)
- goto done;
+ HGOTO_DONE(0);
/* check if already visit the target object */
if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path))
- goto done;
+ HGOTO_DONE(0);
/* add this link as visited link */
if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path) < 0)
- goto done;
+ HGOTO_DONE(0);
if(h5trav_visit(tinfo->fid, path, TRUE, TRUE,
- trav_grp_objs,trav_grp_symlinks, tinfo) < 0)
- {
+ trav_grp_objs,trav_grp_symlinks, tinfo) < 0) {
parallel_print("Error: Could not get file contents\n");
opts->err_stat = 1;
- goto done;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Could not get file contents\n");
}
break;
@@ -542,51 +478,48 @@ static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo,
default:
parallel_print("Error: Invalid link type\n");
opts->err_stat = 1;
- goto done;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Invalid link type");
break;
} /* end of switch */
done:
if (lnk_info.trg_path)
HDfree(lnk_info.trg_path);
- return 0;
+ return ret_value;
}
/*-------------------------------------------------------------------------
* Function: h5diff
*
- * Purpose: public function, can be called in an application program.
- * return differences between 2 HDF5 files
- *
- * Return: Number of differences found.
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: October 22, 2003
+ * Purpose: public function, can be called in an application program.
+ * return differences between 2 HDF5 files
*
+ * Return: Number of differences found.
*-------------------------------------------------------------------------
*/
-hsize_t h5diff(const char *fname1,
+hsize_t
+h5diff(const char *fname1,
const char *fname2,
const char *objname1,
const char *objname2,
- diff_opt_t *options)
+ diff_opt_t *opts)
{
- hid_t file1_id = (-1);
- hid_t file2_id = (-1);
- char filenames[2][MAX_FILENAME];
- hsize_t nfound = 0;
- int l_ret1 = -1;
- int l_ret2 = -1;
- char * obj1fullname = NULL;
- char * obj2fullname = NULL;
- int both_objs_grp = 0;
+ int ret_value = 0;
+ hid_t file1_id = -1;
+ hid_t file2_id = -1;
+ char filenames[2][MAX_FILENAME];
+ hsize_t nfound = 0;
+ int l_ret1 = -1;
+ int l_ret2 = -1;
+ char *obj1fullname = NULL;
+ char *obj2fullname = NULL;
+ int both_objs_grp = 0;
/* init to group type */
h5trav_type_t obj1type = H5TRAV_TYPE_GROUP;
h5trav_type_t obj2type = H5TRAV_TYPE_GROUP;
/* for single object */
- H5O_info_t oinfo1, oinfo2; /* object info */
+ H5O_info_t oinfo1, oinfo2; /* object info */
trav_info_t *info1_obj = NULL;
trav_info_t *info2_obj = NULL;
/* for group object */
@@ -596,8 +529,8 @@ hsize_t h5diff(const char *fname1,
trav_info_t *info1_lp = NULL;
trav_info_t *info2_lp = NULL;
/* link info from specified object */
- H5L_info_t src_linfo1;
- H5L_info_t src_linfo2;
+ H5L_info_t src_linfo1;
+ H5L_info_t src_linfo2;
/* link info from member object */
h5tool_link_info_t trg_linfo1;
h5tool_link_info_t trg_linfo2;
@@ -614,37 +547,28 @@ hsize_t h5diff(const char *fname1,
/*-------------------------------------------------------------------------
* check invalid combination of options
*-----------------------------------------------------------------------*/
- if(!is_valid_options(options))
- goto out;
+ if(!is_valid_options(opts))
+ HGOTO_DONE(0);
- options->cmn_objs = 1; /* eliminate warning */
+ opts->cmn_objs = 1; /* eliminate warning */
+ opts->err_stat = 0; /* initialize error status */
/*-------------------------------------------------------------------------
* open the files first; if they are not valid, no point in continuing
*-------------------------------------------------------------------------
*/
-
- /* disable error reporting */
- H5E_BEGIN_TRY
- {
- /* open file 1 */
- if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0)
- {
- parallel_print("h5diff: <%s>: unable to open file\n", fname1);
- options->err_stat = 1;
- goto out;
- } /* end if */
+ /* open file 1 */
+ if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) {
+ parallel_print("h5diff: <%s>: unable to open file\n", fname1);
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "<%s>: unable to open file\n", fname1);
+ } /* end if */
- /* open file 2 */
- if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0)
- {
- parallel_print("h5diff: <%s>: unable to open file\n", fname2);
- options->err_stat = 1;
- goto out;
- } /* end if */
- /* enable error reporting */
- } H5E_END_TRY;
+ /* open file 2 */
+ if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) {
+ parallel_print("h5diff: <%s>: unable to open file\n", fname2);
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "<%s>: unable to open file\n", fname2);
+ } /* end if */
/*-------------------------------------------------------------------------
* Initialize the info structs
@@ -655,18 +579,18 @@ hsize_t h5diff(const char *fname1,
h5difftrace("trav_info_init initialized\n");
/* if any object is specified */
- if (objname1)
- {
+ if (objname1) {
/* make the given object1 fullpath, start with "/" */
- if (HDstrncmp(objname1, "/", 1))
- {
+ if (HDstrncmp(objname1, "/", 1)) {
#ifdef H5_HAVE_ASPRINTF
/* Use the asprintf() routine, since it does what we're trying to do below */
if(HDasprintf(&obj1fullname, "/%s", objname1) < 0)
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
#else /* H5_HAVE_ASPRINTF */
/* (malloc 2 more for "/" and end-of-line) */
- obj1fullname = (char*)HDmalloc(HDstrlen(objname1) + 2);
+ if ((obj1fullname = (char*)HDmalloc(HDstrlen(objname1) + 2)) == NULL)
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
+
HDstrcpy(obj1fullname, "/");
HDstrcat(obj1fullname, objname1);
#endif /* H5_HAVE_ASPRINTF */
@@ -675,15 +599,15 @@ hsize_t h5diff(const char *fname1,
obj1fullname = HDstrdup(objname1);
/* make the given object2 fullpath, start with "/" */
- if (HDstrncmp(objname2, "/", 1))
- {
+ if (HDstrncmp(objname2, "/", 1)) {
#ifdef H5_HAVE_ASPRINTF
/* Use the asprintf() routine, since it does what we're trying to do below */
if(HDasprintf(&obj2fullname, "/%s", objname2) < 0)
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
#else /* H5_HAVE_ASPRINTF */
/* (malloc 2 more for "/" and end-of-line) */
- obj2fullname = (char*)HDmalloc(HDstrlen(objname2) + 2);
+ if ((obj2fullname = (char*)HDmalloc(HDstrlen(objname2) + 2)) == NULL)
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
HDstrcpy(obj2fullname, "/");
HDstrcat(obj2fullname, objname2);
#endif /* H5_HAVE_ASPRINTF */
@@ -695,24 +619,19 @@ hsize_t h5diff(const char *fname1,
* check if obj1 is root, group, single object or symlink
*/
h5difftrace("h5diff check if obj1 is root, group, single object or symlink\n");
- if(!HDstrcmp(obj1fullname, "/"))
- {
+ if(!HDstrcmp(obj1fullname, "/")) {
obj1type = H5TRAV_TYPE_GROUP;
}
- else
- {
+ else {
/* check if link itself exist */
- if(H5Lexists(file1_id, obj1fullname, H5P_DEFAULT) <= 0)
- {
+ if(H5Lexists(file1_id, obj1fullname, H5P_DEFAULT) <= 0) {
parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1);
- options->err_stat = 1;
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Object could not be found");
}
/* get info from link */
- if(H5Lget_info(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0)
- {
+ if(H5Lget_info(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0) {
parallel_print("Unable to get link info from <%s>\n", obj1fullname);
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Lget_info failed");
}
info1_lp = info1_obj;
@@ -720,18 +639,15 @@ hsize_t h5diff(const char *fname1,
/*
* check the type of specified path for hard and symbolic links
*/
- if(src_linfo1.type == H5L_TYPE_HARD)
- {
+ if(src_linfo1.type == H5L_TYPE_HARD) {
size_t idx;
/* optional data pass */
- info1_obj->opts = (diff_opt_t*)options;
+ info1_obj->opts = (diff_opt_t*)opts;
- if(H5Oget_info_by_name(file1_id, obj1fullname, &oinfo1, H5P_DEFAULT) < 0)
- {
+ if(H5Oget_info_by_name(file1_id, obj1fullname, &oinfo1, H5P_DEFAULT) < 0) {
parallel_print("Error: Could not get file contents\n");
- options->err_stat = 1;
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Could not get file contents");
}
obj1type = (h5trav_type_t)oinfo1.type;
trav_info_add(info1_obj, obj1fullname, obj1type);
@@ -739,13 +655,11 @@ hsize_t h5diff(const char *fname1,
info1_obj->paths[idx].objno = oinfo1.addr;
info1_obj->paths[idx].fileno = oinfo1.fileno;
}
- else if (src_linfo1.type == H5L_TYPE_SOFT)
- {
+ else if (src_linfo1.type == H5L_TYPE_SOFT) {
obj1type = H5TRAV_TYPE_LINK;
trav_info_add(info1_obj, obj1fullname, obj1type);
}
- else if (src_linfo1.type == H5L_TYPE_EXTERNAL)
- {
+ else if (src_linfo1.type == H5L_TYPE_EXTERNAL) {
obj1type = H5TRAV_TYPE_UDLINK;
trav_info_add(info1_obj, obj1fullname, obj1type);
}
@@ -755,24 +669,19 @@ hsize_t h5diff(const char *fname1,
* check if obj2 is root, group, single object or symlink
*/
h5difftrace("h5diff check if obj2 is root, group, single object or symlink\n");
- if(!HDstrcmp(obj2fullname, "/"))
- {
+ if(!HDstrcmp(obj2fullname, "/")) {
obj2type = H5TRAV_TYPE_GROUP;
}
- else
- {
+ else {
/* check if link itself exist */
- if(H5Lexists(file2_id, obj2fullname, H5P_DEFAULT) <= 0)
- {
+ if(H5Lexists(file2_id, obj2fullname, H5P_DEFAULT) <= 0) {
parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2);
- options->err_stat = 1;
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Object could not be found");
}
/* get info from link */
- if(H5Lget_info(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0)
- {
+ if(H5Lget_info(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0) {
parallel_print("Unable to get link info from <%s>\n", obj2fullname);
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Lget_info failed");
}
info2_lp = info2_obj;
@@ -780,18 +689,15 @@ hsize_t h5diff(const char *fname1,
/*
* check the type of specified path for hard and symbolic links
*/
- if(src_linfo2.type == H5L_TYPE_HARD)
- {
+ if(src_linfo2.type == H5L_TYPE_HARD) {
size_t idx;
/* optional data pass */
- info2_obj->opts = (diff_opt_t*)options;
+ info2_obj->opts = (diff_opt_t*)opts;
- if(H5Oget_info_by_name(file2_id, obj2fullname, &oinfo2, H5P_DEFAULT) < 0)
- {
+ if(H5Oget_info_by_name(file2_id, obj2fullname, &oinfo2, H5P_DEFAULT) < 0) {
parallel_print("Error: Could not get file contents\n");
- options->err_stat = 1;
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Could not get file contents");
}
obj2type = (h5trav_type_t)oinfo2.type;
trav_info_add(info2_obj, obj2fullname, obj2type);
@@ -799,21 +705,18 @@ hsize_t h5diff(const char *fname1,
info2_obj->paths[idx].objno = oinfo2.addr;
info2_obj->paths[idx].fileno = oinfo2.fileno;
}
- else if (src_linfo2.type == H5L_TYPE_SOFT)
- {
+ else if (src_linfo2.type == H5L_TYPE_SOFT) {
obj2type = H5TRAV_TYPE_LINK;
trav_info_add(info2_obj, obj2fullname, obj2type);
}
- else if (src_linfo2.type == H5L_TYPE_EXTERNAL)
- {
+ else if (src_linfo2.type == H5L_TYPE_EXTERNAL) {
obj2type = H5TRAV_TYPE_UDLINK;
trav_info_add(info2_obj, obj2fullname, obj2type);
}
}
}
/* if no object specified */
- else
- {
+ else {
h5difftrace("h5diff no object specified\n");
/* set root group */
obj1fullname = (char*)HDstrdup("/");
@@ -822,18 +725,17 @@ hsize_t h5diff(const char *fname1,
obj2type = H5TRAV_TYPE_GROUP;
}
-
+ h5diffdebug2("get any symbolic links info - errstat:%d\n", opts->err_stat);
/* get any symbolic links info */
- l_ret1 = H5tools_get_symlink_info(file1_id, obj1fullname, &trg_linfo1, options->follow_links);
- l_ret2 = H5tools_get_symlink_info(file2_id, obj2fullname, &trg_linfo2, options->follow_links);
+ l_ret1 = H5tools_get_symlink_info(file1_id, obj1fullname, &trg_linfo1, opts->follow_links);
+ l_ret2 = H5tools_get_symlink_info(file2_id, obj2fullname, &trg_linfo2, opts->follow_links);
/*---------------------------------------------
* check for following symlinks
*/
- if (options->follow_links)
- {
+ if (opts->follow_links) {
/* pass how to handle printing warning to linkinfo option */
- if(print_warn(options))
+ if(print_warn(opts))
trg_linfo1.opt.msg_mode = trg_linfo2.opt.msg_mode = 1;
/*-------------------------------
@@ -841,37 +743,29 @@ hsize_t h5diff(const char *fname1,
*/
h5difftrace("h5diff check symbolic link (object1)\n");
/* dangling link */
- if (l_ret1 == 0)
- {
+ if (l_ret1 == 0) {
h5difftrace("h5diff ... dangling link\n");
- if (options->no_dangle_links)
- {
- /* treat dangling link is error */
- if(options->m_verbose)
+ if (opts->no_dangle_links) {
+ /* treat dangling link as error */
+ if(opts->m_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", obj1fullname);
- options->err_stat = 1;
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "treat dangling link as error");
}
- else
- {
- if(options->m_verbose)
+ else {
+ if(opts->m_verbose)
parallel_print("obj1 <%s> is a dangling link.\n", obj1fullname);
- if (l_ret1 != 0 || l_ret2 != 0)
- {
+ if (l_ret1 != 0 || l_ret2 != 0) {
nfound++;
print_found(nfound);
- goto out;
+ HGOTO_DONE(0);
}
}
}
- else if(l_ret1 < 0) /* fail */
- {
+ else if(l_ret1 < 0) { /* fail */
parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1);
- options->err_stat = 1;
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Object could not be found");
}
- else if(l_ret1 != 2) /* symbolic link */
- {
+ else if(l_ret1 != 2) { /* symbolic link */
obj1type = (h5trav_type_t)trg_linfo1.trg_type;
h5difftrace("h5diff ... ... trg_linfo1.trg_type == H5L_TYPE_HARD\n");
if (info1_lp != NULL) {
@@ -890,37 +784,29 @@ hsize_t h5diff(const char *fname1,
*/
h5difftrace("h5diff check symbolic link (object2)\n");
/* dangling link */
- if (l_ret2 == 0)
- {
+ if (l_ret2 == 0) {
h5difftrace("h5diff ... dangling link\n");
- if (options->no_dangle_links)
- {
- /* treat dangling link is error */
- if(options->m_verbose)
+ if (opts->no_dangle_links) {
+ /* treat dangling link as error */
+ if(opts->m_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", obj2fullname);
- options->err_stat = 1;
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "treat dangling link as error");
}
- else
- {
- if(options->m_verbose)
+ else {
+ if(opts->m_verbose)
parallel_print("obj2 <%s> is a dangling link.\n", obj2fullname);
- if (l_ret1 != 0 || l_ret2 != 0)
- {
+ if (l_ret1 != 0 || l_ret2 != 0) {
nfound++;
print_found(nfound);
- goto out;
+ HGOTO_DONE(0);
}
}
}
- else if(l_ret2 < 0) /* fail */
- {
+ else if(l_ret2 < 0) { /* fail */
parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2);
- options->err_stat = 1;
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Object could not be found");
}
- else if(l_ret2 != 2) /* symbolic link */
- {
+ else if(l_ret2 != 2) { /* symbolic link */
obj2type = (h5trav_type_t)trg_linfo2.trg_type;
if (info2_lp != NULL) {
size_t idx = info2_lp->nused - 1;
@@ -941,32 +827,28 @@ hsize_t h5diff(const char *fname1,
* comparing details of same objects.
*/
- if(!(options->m_verbose || options->m_report))
- {
- h5difftrace("h5diff NOT (options->m_verbose || options->m_report)\n");
+ if(!(opts->m_verbose || opts->m_report)) {
+ h5difftrace("h5diff NOT (opts->m_verbose || opts->m_report)\n");
/* if no danglink links */
- if ( l_ret1 > 0 && l_ret2 > 0 )
- if (h5tools_is_obj_same(file1_id, obj1fullname, file2_id, obj2fullname)!=0)
- goto out;
+ if (l_ret1 > 0 && l_ret2 > 0)
+ if (h5tools_is_obj_same(file1_id, obj1fullname, file2_id, obj2fullname) != 0)
+ HGOTO_DONE(0);
}
both_objs_grp = (obj1type == H5TRAV_TYPE_GROUP && obj2type == H5TRAV_TYPE_GROUP);
- if (both_objs_grp)
- {
+ if (both_objs_grp) {
h5difftrace("h5diff both_objs_grp TRUE\n");
/*
* traverse group1
*/
trav_info_init(fname1, file1_id, &info1_grp);
/* optional data pass */
- info1_grp->opts = (diff_opt_t*)options;
+ info1_grp->opts = (diff_opt_t*)opts;
if(h5trav_visit(file1_id, obj1fullname, TRUE, TRUE,
- trav_grp_objs, trav_grp_symlinks, info1_grp) < 0)
- {
+ trav_grp_objs, trav_grp_symlinks, info1_grp) < 0) {
parallel_print("Error: Could not get file contents\n");
- options->err_stat = 1;
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Could not get file contents");
}
info1_lp = info1_grp;
@@ -975,25 +857,22 @@ hsize_t h5diff(const char *fname1,
*/
trav_info_init(fname2, file2_id, &info2_grp);
/* optional data pass */
- info2_grp->opts = (diff_opt_t*)options;
+ info2_grp->opts = (diff_opt_t*)opts;
if(h5trav_visit(file2_id, obj2fullname, TRUE, TRUE,
- trav_grp_objs, trav_grp_symlinks, info2_grp) < 0)
- {
+ trav_grp_objs, trav_grp_symlinks, info2_grp) < 0) {
parallel_print("Error: Could not get file contents\n");
- options->err_stat = 1;
- goto out;
- } /* end if */
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Could not get file contents");
+ } /* end if */
info2_lp = info2_grp;
}
+ h5diffdebug2("groups traversed - errstat:%d\n", opts->err_stat);
#ifdef H5_HAVE_PARALLEL
- if(g_Parallel)
- {
+ if(g_Parallel) {
int i;
- if((HDstrlen(fname1) > MAX_FILENAME) || (HDstrlen(fname2) > MAX_FILENAME))
- {
+ if((HDstrlen(fname1) > MAX_FILENAME) || (HDstrlen(fname2) > MAX_FILENAME)) {
HDfprintf(stderr, "The parallel diff only supports path names up to %d characters\n", MAX_FILENAME);
MPI_Abort(MPI_COMM_WORLD, 0);
} /* end if */
@@ -1008,15 +887,12 @@ hsize_t h5diff(const char *fname1,
#endif
/* process the objects */
- build_match_list (obj1fullname, info1_lp, obj2fullname, info2_lp,
- &match_list, options);
- if (both_objs_grp)
- {
+ build_match_list (obj1fullname, info1_lp, obj2fullname, info2_lp, &match_list, opts);
+ if (both_objs_grp) {
/*------------------------------------------------------
* print the list
*/
- if(options->m_verbose)
- {
+ if(opts->m_verbose) {
unsigned u;
parallel_print("\n");
@@ -1026,8 +902,7 @@ hsize_t h5diff(const char *fname1,
else
parallel_print("file1 file2\n");
parallel_print("---------------------------------------\n");
- for(u = 0; u < match_list->nobjs; u++)
- {
+ for(u = 0; u < match_list->nobjs; u++) {
char c1, c2;
c1 = (match_list->objs[u].flags[0]) ? 'x' : ' ';
c2 = (match_list->objs[u].flags[1]) ? 'x' : ' ';
@@ -1038,9 +913,11 @@ hsize_t h5diff(const char *fname1,
}
nfound = diff_match(file1_id, obj1fullname, info1_lp,
file2_id, obj2fullname, info2_lp,
- match_list, options);
+ match_list, opts);
+
+done:
+ opts->err_stat = opts->err_stat | ret_value;
-out:
#ifdef H5_HAVE_PARALLEL
if(g_Parallel)
/* All done at this point, let tasks know that they won't be needed */
@@ -1075,6 +952,7 @@ out:
H5Fclose(file1_id);
H5Fclose(file2_id);
} H5E_END_TRY;
+
h5difftrace("h5diff finish\n");
return nfound;
@@ -1085,43 +963,34 @@ out:
/*-------------------------------------------------------------------------
* Function: diff_match
*
- * Purpose:
- * Compare common objects in given groups according to table structure.
- * The table structure has flags which can be used to find common objects
- * and will be compared.
- * Common object means same name (absolute path) objects in both location.
- *
- * Return: Number of differences found
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Purpose: Compare common objects in given groups according to table structure.
+ * The table structure has flags which can be used to find common objects
+ * and will be compared.
+ * Common object means same name (absolute path) objects in both location.
*
- * Date: May 9, 2003
+ * Return: Number of differences found
*
- * Modifications: Jan 2005 Leon Arber, larber@uiuc.edu
- * Added support for parallel diffing
- *
- * Pedro Vicente, pvn@hdfgroup.org, Nov 4, 2008
- * Compare the graph and make h5diff return 1 for difference if
- * 1) the number of objects in file1 is not the same as in file2
- * 2) the graph does not match, i.e same names (absolute path)
- * 3) objects with the same name are not of the same type
+ * Modifications: Compare the graph and make h5diff return 1 for difference if
+ * 1) the number of objects in file1 is not the same as in file2
+ * 2) the graph does not match, i.e same names (absolute path)
+ * 3) objects with the same name are not of the same type
*-------------------------------------------------------------------------
*/
-hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
+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 *options)
+ trav_table_t *table, diff_opt_t *opts)
{
hsize_t nfound = 0;
unsigned i;
-
- const char * grp1_path = "";
- const char * grp2_path = "";
- char * obj1_fullpath = NULL;
- char * obj2_fullpath = NULL;
- diff_args_t argdata;
- size_t idx1 = 0;
- size_t idx2 = 0;
-
+ int ret_value = opts->err_stat;
+ const char *grp1_path = "";
+ const char *grp2_path = "";
+ char *obj1_fullpath = NULL;
+ char *obj2_fullpath = NULL;
+ diff_args_t argdata;
+ size_t idx1 = 0;
+ size_t idx2 = 0;
h5difftrace("diff_match start\n");
/*
@@ -1134,85 +1003,89 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
grp2_path = grp2;
/*-------------------------------------------------------------------------
- * regarding the return value of h5diff (0, no difference in files, 1 difference )
- * 1) the number of objects in file1 must be the same as in file2
- * 2) the graph must match, i.e same names (absolute path)
- * 3) objects with the same name must be of the same type
- *-------------------------------------------------------------------------
- */
+ * regarding the return value of h5diff (0, no difference in files, 1 difference )
+ * 1) the number of objects in file1 must be the same as in file2
+ * 2) the graph must match, i.e same names (absolute path)
+ * 3) objects with the same name must be of the same type
+ *-------------------------------------------------------------------------
+ */
/* not valid compare used when --exclude-path option is used */
- if (!options->exclude_path)
- {
+ if (!opts->exclude_path) {
/* number of different objects */
- if ( info1->nused != info2->nused )
- {
- options->contents = 0;
+ if (info1->nused != info2->nused) {
+ opts->contents = 0;
}
}
/* objects in one file and not the other */
- for( i = 0; i < table->nobjs; i++)
- {
- if( table->objs[i].flags[0] != table->objs[i].flags[1] )
- {
- options->contents = 0;
+ for(i = 0; i < table->nobjs; i++) {
+ if(table->objs[i].flags[0] != table->objs[i].flags[1]) {
+ opts->contents = 0;
break;
}
}
-
/*-------------------------------------------------------------------------
- * do the diff for common objects
- *-------------------------------------------------------------------------
- */
+ * do the diff for common objects
+ *-------------------------------------------------------------------------
+ */
#ifdef H5_HAVE_PARALLEL
{
- char *workerTasks = (char*)HDmalloc((g_nTasks - 1) * sizeof(char));
- int n;
- int busyTasks = 0;
- struct diffs_found nFoundbyWorker;
- struct diff_mpi_args args;
- int havePrintToken = 1;
- MPI_Status Status;
-
- /*set all tasks as free */
- HDmemset(workerTasks, 1, (g_nTasks - 1));
+ char *workerTasks = (char*)HDmalloc((g_nTasks - 1) * sizeof(char));
+ int n;
+ int busyTasks = 0;
+ struct diffs_found nFoundbyWorker;
+ struct diff_mpi_args args;
+ int havePrintToken = 1;
+ MPI_Status Status;
+
+ /*set all tasks as free */
+ HDmemset(workerTasks, 1, (g_nTasks - 1));
#endif
- for(i = 0; i < table->nobjs; i++)
- {
- if( table->objs[i].flags[0] && table->objs[i].flags[1])
- {
+ for(i = 0; i < table->nobjs; i++) {
+ h5diffdebug3("diff for common objects[%d] - errstat:%d\n", i, opts->err_stat);
+ if(table->objs[i].flags[0] && table->objs[i].flags[1]) {
/* make full path for obj1 */
#ifdef H5_HAVE_ASPRINTF
/* Use the asprintf() routine, since it does what we're trying to do below */
- if(HDasprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name) < 0)
- goto out;
+ if(HDasprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name) < 0) {
+ HERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
+ }
#else /* H5_HAVE_ASPRINTF */
- obj1_fullpath = (char*)HDmalloc(HDstrlen(grp1_path) + HDstrlen(table->objs[i].name) + 1);
- HDstrcpy(obj1_fullpath, grp1_path);
- HDstrcat(obj1_fullpath, table->objs[i].name);
+ if((obj1_fullpath = (char*)HDmalloc(HDstrlen(grp1_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) {
+ HERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
+ }
+ else {
+ HDstrcpy(obj1_fullpath, grp1_path);
+ HDstrcat(obj1_fullpath, table->objs[i].name);
+ }
#endif /* H5_HAVE_ASPRINTF */
+ h5diffdebug2("diff_match path1 - %s\n", obj1_fullpath);
/* make full path for obj2 */
#ifdef H5_HAVE_ASPRINTF
/* Use the asprintf() routine, since it does what we're trying to do below */
- if(HDasprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name) < 0)
- goto out;
+ if(HDasprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name) < 0) {
+ HERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
+ }
#else /* H5_HAVE_ASPRINTF */
- obj2_fullpath = (char*)HDmalloc(HDstrlen(grp2_path) + HDstrlen(table->objs[i].name) + 1);
- HDstrcpy(obj2_fullpath, grp2_path);
- HDstrcat(obj2_fullpath, table->objs[i].name);
+ if((obj2_fullpath = (char*)HDmalloc(HDstrlen(grp2_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) {
+ HERROR(1, H5E_tools_min_id_g, "name buffer allocation failed");
+ }
+ else {
+ HDstrcpy(obj2_fullpath, grp2_path);
+ HDstrcat(obj2_fullpath, table->objs[i].name);
+ }
#endif /* H5_HAVE_ASPRINTF */
+ h5diffdebug2("diff_match path2 - %s\n", obj2_fullpath);
/* get index to figure out type of the object in file1 */
- while(info1->paths[idx1].path &&
- (HDstrcmp(obj1_fullpath, info1->paths[idx1].path) != 0))
+ while(info1->paths[idx1].path && (HDstrcmp(obj1_fullpath, info1->paths[idx1].path) != 0))
idx1++;
/* get index to figure out type of the object in file2 */
- while(info2->paths[idx2].path &&
- (HDstrcmp(obj2_fullpath, info2->paths[idx2].path) != 0))
+ while(info2->paths[idx2].path && (HDstrcmp(obj2_fullpath, info2->paths[idx2].path) != 0))
idx2++;
/* Set argdata to pass other args into diff() */
@@ -1220,16 +1093,14 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
argdata.type[1] = info2->paths[idx2].type;
argdata.is_same_trgobj = table->objs[i].is_same_trgobj;
- options->cmn_objs = 1;
- if(!g_Parallel)
- {
+ opts->cmn_objs = 1;
+ if(!g_Parallel) {
nfound += diff(file1_id, obj1_fullpath,
file2_id, obj2_fullpath,
- options, &argdata);
+ opts, &argdata);
} /* end if */
#ifdef H5_HAVE_PARALLEL
- else
- {
+ else {
int workerFound = 0;
h5difftrace("Beginning of big else block\n");
@@ -1243,8 +1114,7 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
/*Set up args to pass to worker task. */
if(HDstrlen(obj1_fullpath) > 255 ||
- HDstrlen(obj2_fullpath) > 255)
- {
+ HDstrlen(obj2_fullpath) > 255) {
printf("The parallel diff only supports object names up to 255 characters\n");
MPI_Abort(MPI_COMM_WORLD, 0);
} /* end if */
@@ -1252,32 +1122,29 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
/* set args struct to pass */
HDstrcpy(args.name1, obj1_fullpath);
HDstrcpy(args.name2, obj2_fullpath);
- args.options = *options;
+ args.opts = *opts;
args.argdata.type[0] = info1->paths[idx1].type;
args.argdata.type[1] = info2->paths[idx2].type;
args.argdata.is_same_trgobj = table->objs[i].is_same_trgobj;
/* if there are any outstanding print requests, let's handle one. */
- if(busyTasks > 0)
- {
+ if(busyTasks > 0) {
int incomingMessage;
/* check if any tasks freed up, and didn't need to print. */
MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &incomingMessage, &Status);
/* first block*/
- if(incomingMessage)
- {
+ if(incomingMessage) {
workerTasks[Status.MPI_SOURCE - 1] = 1;
MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status);
nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
busyTasks--;
} /* end if */
/* check to see if the print token was returned. */
- if(!havePrintToken)
- {
+ if(!havePrintToken) {
/* If we don't have the token, someone is probably sending us output */
print_incoming_data();
@@ -1289,19 +1156,17 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
workerTasks[Status.MPI_SOURCE - 1] = 1;
MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
busyTasks--;
havePrintToken = 1;
} /* end if */
} /* end if */
/* check to see if anyone needs the print token. */
- if(havePrintToken)
- {
+ if(havePrintToken) {
/* check incoming queue for print token requests */
MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &incomingMessage, &Status);
- if(incomingMessage)
- {
+ if(incomingMessage) {
MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status);
MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD);
havePrintToken = 0;
@@ -1312,10 +1177,8 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
/* check array of tasks to see which ones are free.
* Manager task never does work, so freeTasks[0] is really
* worker task 0. */
- for(n = 1; (n < g_nTasks) && !workerFound; n++)
- {
- if(workerTasks[n-1])
- {
+ for(n = 1; (n < g_nTasks) && !workerFound; n++) {
+ if(workerTasks[n-1]) {
/* send file id's and names to first free worker */
MPI_Send(&args, sizeof(args), MPI_BYTE, n, MPI_TAG_ARGS, MPI_COMM_WORLD);
@@ -1328,55 +1191,47 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
} /* end if */
} /* end for */
- if(!workerFound)
- {
+ if(!workerFound) {
/* if they were all busy, we've got to wait for one free up
* before we can move on. If we don't have the token, some
* task is currently printing so we'll wait for that task to
* return it.
*/
- if(!havePrintToken)
- {
- while(!havePrintToken)
- {
+ if(!havePrintToken) {
+ while(!havePrintToken) {
int incomingMessage;
print_incoming_data();
MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status);
- if(incomingMessage)
- {
+ if(incomingMessage) {
MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
havePrintToken = 1;
nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
/* send this task the work unit. */
MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD);
} /* end if */
} /* end while */
} /* end if */
/* if we do have the token, check for task to free up, or wait for a task to request it */
- else
- {
+ else {
/* But first print all the data in our incoming queue */
print_incoming_data();
MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status);
- if(Status.MPI_TAG == MPI_TAG_DONE)
- {
+ if(Status.MPI_TAG == MPI_TAG_DONE) {
MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status);
nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD);
} /* end if */
- else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST)
- {
+ else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) {
int incomingMessage;
MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status);
MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD);
- do
- {
+ do {
MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status);
print_incoming_data();
@@ -1384,11 +1239,10 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD);
} /* end else-if */
- else
- {
+ else {
printf("ERROR: Invalid tag (%d) received \n", Status.MPI_TAG);
MPI_Abort(MPI_COMM_WORLD, 0);
MPI_Finalize();
@@ -1403,27 +1257,22 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
HDfree(obj2_fullpath);
} /* end if */
} /* end for */
- h5difftrace("done with for loop\n");
+ h5diffdebug2("done with for loop - errstat:%d\n", opts->err_stat);
#ifdef H5_HAVE_PARALLEL
- if(g_Parallel)
- {
+ if(g_Parallel) {
/* make sure all tasks are done */
- while(busyTasks > 0)
- {
+ while(busyTasks > 0) {
MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status);
- if(Status.MPI_TAG == MPI_TAG_DONE)
- {
+ if(Status.MPI_TAG == MPI_TAG_DONE) {
MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status);
nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
busyTasks--;
} /* end if */
- else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST)
- {
+ else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) {
MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status);
- if(havePrintToken)
- {
+ if(havePrintToken) {
int incomingMessage;
MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD);
@@ -1436,17 +1285,15 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
busyTasks--;
} /* end if */
/* someone else must have it...wait for them to return it, then give it to the task that just asked for it. */
- else
- {
+ else {
int source = Status.MPI_SOURCE;
int incomingMessage;
- do
- {
+ do {
MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status);
print_incoming_data();
@@ -1455,21 +1302,19 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
busyTasks--;
MPI_Send(NULL, 0, MPI_BYTE, source, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD);
} /* end else */
} /* end else-if */
- else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN)
- {
+ else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) {
MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
busyTasks--;
havePrintToken = 1;
} /* end else-if */
- else if(Status.MPI_TAG == MPI_TAG_PRINT_DATA)
- {
+ else if(Status.MPI_TAG == MPI_TAG_PRINT_DATA) {
char data[PRINT_DATA_MAX_SIZE + 1];
HDmemset(data, 0, PRINT_DATA_MAX_SIZE + 1);
@@ -1477,8 +1322,7 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
printf("%s", data);
} /* end else-if */
- else
- {
+ else {
printf("ph5diff-manager: ERROR!! Invalid tag (%d) received \n", Status.MPI_TAG);
MPI_Abort(MPI_COMM_WORLD, 0);
} /* end else */
@@ -1497,10 +1341,12 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
#endif /* H5_HAVE_PARALLEL */
out:
- /* free table */
+ opts->err_stat = opts->err_stat | ret_value;
+
+/* free table */
if (table)
trav_table_free(table);
- h5difftrace("diff_match finish\n");
+ h5diffdebug2("diff_match finish:%d\n", nfound);
return nfound;
}
@@ -1509,47 +1355,36 @@ out:
/*-------------------------------------------------------------------------
* Function: diff
*
- * Purpose: switch between types and choose the diff function
- * TYPE is either
- * H5G_GROUP Object is a group
- * H5G_DATASET Object is a dataset
- * H5G_TYPE Object is a named data type
- * H5G_LINK Object is a symbolic link
- *
- * Return: Number of differences found
- *
- * Programmer: Jonathan Kim
- * - Move follow symlinks code toward top. (March 2812)
- * - Add following symlinks feature (Feb 11,2010)
- * - Change to use diff_args_t to pass the rest of args.
- * Passing through it instead of individual args provides smoother
- * extensibility through its members along with MPI code update for ph5diff
- * as it doesn't require interface change.
- * (May 6,2011)
+ * Purpose: switch between types and choose the diff function
+ * TYPE is either
+ * H5G_GROUP Object is a group
+ * H5G_DATASET Object is a dataset
+ * H5G_TYPE Object is a named data type
+ * H5G_LINK Object is a symbolic link
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- * Date: May 9, 2003
+ * Return: Number of differences found
*-------------------------------------------------------------------------
*/
-
-hsize_t diff(hid_t file1_id,
+hsize_t
+diff(hid_t file1_id,
const char *path1,
hid_t file2_id,
const char *path2,
- diff_opt_t * options,
+ diff_opt_t * opts,
diff_args_t *argdata)
{
- hid_t dset1_id = (-1);
- hid_t dset2_id = (-1);
- hid_t type1_id = (-1);
- hid_t type2_id = (-1);
- hid_t grp1_id = (-1);
- hid_t grp2_id = (-1);
- int ret;
- hbool_t is_dangle_link1 = FALSE;
- hbool_t is_dangle_link2 = FALSE;
- hbool_t is_hard_link = FALSE;
- hsize_t nfound = 0;
+ int ret_value = opts->err_stat;
+ int status = -1;
+ hid_t dset1_id = -1;
+ hid_t dset2_id = -1;
+ hid_t type1_id = -1;
+ hid_t type2_id = -1;
+ hid_t grp1_id = -1;
+ hid_t grp2_id = -1;
+ hbool_t is_dangle_link1 = FALSE;
+ hbool_t is_dangle_link2 = FALSE;
+ hbool_t is_hard_link = FALSE;
+ hsize_t nfound = 0;
h5trav_type_t object_type;
/* to get link info */
@@ -1559,11 +1394,11 @@ hsize_t diff(hid_t file1_id,
h5difftrace("diff start\n");
/*init link info struct */
- HDmemset(&linkinfo1,0,sizeof(h5tool_link_info_t));
- HDmemset(&linkinfo2,0,sizeof(h5tool_link_info_t));
+ HDmemset(&linkinfo1, 0, sizeof(h5tool_link_info_t));
+ HDmemset(&linkinfo2, 0, sizeof(h5tool_link_info_t));
/* pass how to handle printing warnings to linkinfo option */
- if(print_warn(options))
+ if(print_warn(opts))
linkinfo1.opt.msg_mode = linkinfo2.opt.msg_mode = 1;
/* for symbolic links, take care follow symlink and no dangling link
@@ -1571,78 +1406,69 @@ hsize_t diff(hid_t file1_id,
if (argdata->type[0] == H5TRAV_TYPE_LINK ||
argdata->type[0] == H5TRAV_TYPE_UDLINK ||
argdata->type[1] == H5TRAV_TYPE_LINK ||
- argdata->type[1] == H5TRAV_TYPE_UDLINK )
- {
+ argdata->type[1] == H5TRAV_TYPE_UDLINK) {
/*
* check dangling links for path1 and path2
*/
/* target object1 - get type and name */
- ret = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, options->follow_links);
+ if ((status = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, opts->follow_links)) < 0)
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5tools_get_symlink_info failed");
+
/* dangling link */
- if (ret == 0)
- {
- if (options->no_dangle_links)
- {
+ if (status == 0) {
+ if (opts->no_dangle_links) {
/* dangling link is error */
- if(options->m_verbose)
+ if(opts->m_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", path1);
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "dangling link is error");
}
else
is_dangle_link1 = TRUE;
}
- else if (ret < 0)
- goto out;
/* target object2 - get type and name */
- ret = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, options->follow_links );
+ if ((status = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, opts->follow_links)) < 0)
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5tools_get_symlink_info failed");
/* dangling link */
- if (ret == 0)
- {
- if (options->no_dangle_links)
- {
+ if (status == 0) {
+ if (opts->no_dangle_links) {
/* dangling link is error */
- if(options->m_verbose)
+ if(opts->m_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", path2);
- goto out;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "dangling link is error");
}
else
is_dangle_link2 = TRUE;
}
- else if (ret < 0)
- goto out;
/* found dangling link */
- if (is_dangle_link1 || is_dangle_link2)
- goto out2;
+ if (is_dangle_link1 || is_dangle_link2) {
+ HGOTO_DONE(0);
+ }
/* follow symbolic link option */
- if (options->follow_links)
- {
+ if (opts->follow_links) {
if (linkinfo1.linfo.type == H5L_TYPE_SOFT ||
linkinfo1.linfo.type == H5L_TYPE_EXTERNAL)
argdata->type[0] = (h5trav_type_t)linkinfo1.trg_type;
- if (linkinfo2.linfo.type == H5L_TYPE_SOFT ||
- linkinfo2.linfo.type == H5L_TYPE_EXTERNAL)
+ if (linkinfo2.linfo.type == H5L_TYPE_SOFT || linkinfo2.linfo.type == H5L_TYPE_EXTERNAL)
argdata->type[1] = (h5trav_type_t)linkinfo2.trg_type;
}
}
/* if objects are not the same type */
- if (argdata->type[0] != argdata->type[1])
- {
- if (options->m_verbose||options->m_list_not_cmp)
- {
+ if (argdata->type[0] != argdata->type[1]) {
+ if (opts->m_verbose||opts->m_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]));
}
- options->not_cmp=1;
+ opts->not_cmp = 1;
/* TODO: will need to update non-comparable is different
- * options->contents = 0;
+ * opts->contents = 0;
*/
- goto out2;
+ HGOTO_DONE(0);
}
else /* now both object types are same */
object_type = argdata->type[0];
@@ -1655,88 +1481,79 @@ hsize_t diff(hid_t file1_id,
*
* Perform this to match the outputs as bypassing.
*/
- if (argdata->is_same_trgobj)
- {
+ if (argdata->is_same_trgobj) {
h5difftrace("argdata->is_same_trgobj\n");
is_hard_link = (object_type == H5TRAV_TYPE_DATASET ||
object_type == H5TRAV_TYPE_NAMED_DATATYPE ||
object_type == H5TRAV_TYPE_GROUP);
- if (options->follow_links || is_hard_link)
- {
+ if (opts->follow_links || is_hard_link) {
/* print information is only verbose option is used */
- if(options->m_verbose || options->m_report)
- {
- switch(object_type)
- {
+ if(opts->m_verbose || opts->m_report) {
+ switch(object_type) {
case H5TRAV_TYPE_DATASET:
- do_print_objname("dataset", path1, path2, options);
+ do_print_objname("dataset", path1, path2, opts);
break;
case H5TRAV_TYPE_NAMED_DATATYPE:
- do_print_objname("datatype", path1, path2, options);
+ do_print_objname("datatype", path1, path2, opts);
break;
case H5TRAV_TYPE_GROUP:
- do_print_objname("group", path1, path2, options);
+ do_print_objname("group", path1, path2, opts);
break;
case H5TRAV_TYPE_LINK:
- do_print_objname("link", path1, path2, options);
+ do_print_objname("link", path1, path2, opts);
break;
case H5TRAV_TYPE_UDLINK:
if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL)
- do_print_objname("external link", path1, path2, options);
+ do_print_objname("external link", path1, path2, opts);
else
- do_print_objname ("user defined link", path1, path2, options);
+ do_print_objname ("user defined link", path1, path2, opts);
break;
case H5TRAV_TYPE_UNKNOWN:
default:
parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n",
path1, path2, get_type(object_type) );
- options->not_cmp = 1;
+ opts->not_cmp = 1;
break;
} /* switch(type)*/
print_found(nfound);
- } /* if(options->m_verbose || options->m_report) */
+ } /* if(opts->m_verbose || opts->m_report) */
/* exact same, so comparison is done */
- goto out2;
+ HGOTO_DONE(0);
}
}
- switch(object_type)
- {
+ switch(object_type) {
/*----------------------------------------------------------------------
* H5TRAV_TYPE_DATASET
*----------------------------------------------------------------------
*/
case H5TRAV_TYPE_DATASET:
if((dset1_id = H5Dopen2(file1_id, path1, H5P_DEFAULT)) < 0)
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 failed");
if((dset2_id = H5Dopen2(file2_id, path2, H5P_DEFAULT)) < 0)
- goto out;
- /* verbose (-v) and report (-r) mode */
- if(options->m_verbose || options->m_report)
- {
- do_print_objname("dataset", path1, path2, options);
- nfound = diff_dataset(file1_id, file2_id, path1, path2, options);
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 failed");
+ /* verbose (-v) and report (-r) mode */
+ if(opts->m_verbose || opts->m_report) {
+ do_print_objname("dataset", path1, path2, opts);
+ nfound = diff_dataset(file1_id, file2_id, path1, path2, opts);
print_found(nfound);
}
/* quiet mode (-q), just count differences */
- else if(options->m_quiet)
- {
- nfound = diff_dataset(file1_id, file2_id, path1, path2, options);
+ else if(opts->m_quiet) {
+ nfound = diff_dataset(file1_id, file2_id, path1, path2, opts);
}
- /* the rest (-c, none, ...) */
- else
- {
- nfound = diff_dataset(file1_id, file2_id, path1, path2, options);
+ /* the rest (-c, none, ...) */
+ else {
+ nfound = diff_dataset(file1_id, file2_id, path1, path2, opts);
/* print info if difference found */
- if (nfound)
- {
- do_print_objname("dataset", path1, path2, options);
+ if (nfound) {
+ do_print_objname("dataset", path1, path2, opts);
print_found(nfound);
}
}
-
+ h5diffdebug2("diff after dataset:%d\n", nfound);
/*---------------------------------------------------------
* compare attributes
@@ -1745,13 +1562,13 @@ hsize_t diff(hid_t file1_id,
*---------------------------------------------------------
*/
if(path1)
- nfound += diff_attr(dset1_id, dset2_id, path1, path2, options);
+ nfound += diff_attr(dset1_id, dset2_id, path1, path2, opts);
if(H5Dclose(dset1_id) < 0)
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dclose failed");
if(H5Dclose(dset2_id) < 0)
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dclose failed");
break;
/*----------------------------------------------------------------------
@@ -1760,21 +1577,21 @@ hsize_t diff(hid_t file1_id,
*/
case H5TRAV_TYPE_NAMED_DATATYPE:
if((type1_id = H5Topen2(file1_id, path1, H5P_DEFAULT)) < 0)
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Topen2 failed");
if((type2_id = H5Topen2(file2_id, path2, H5P_DEFAULT)) < 0)
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Topen2 failed");
- if((ret = H5Tequal(type1_id, type2_id)) < 0)
- goto out;
+ if((status = H5Tequal(type1_id, type2_id)) < 0)
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tequal failed");
/* if H5Tequal is > 0 then the datatypes refer to the same datatype */
- nfound = (ret > 0) ? 0 : 1;
+ nfound = (status > 0) ? 0 : 1;
- if(print_objname(options,nfound))
- do_print_objname("datatype", path1, path2, options);
+ if(print_objname(opts, nfound))
+ do_print_objname("datatype", path1, path2, opts);
/* always print the number of differences found in verbose mode */
- if(options->m_verbose)
+ if(opts->m_verbose)
print_found(nfound);
/*-----------------------------------------------------------------
@@ -1784,12 +1601,12 @@ hsize_t diff(hid_t file1_id,
*-----------------------------------------------------------------
*/
if(path1)
- nfound += diff_attr(type1_id, type2_id, path1, path2, options);
+ nfound += diff_attr(type1_id, type2_id, path1, path2, opts);
if(H5Tclose(type1_id) < 0)
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose failed");
if(H5Tclose(type2_id) < 0)
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose failed");
break;
/*----------------------------------------------------------------------
@@ -1797,17 +1614,17 @@ hsize_t diff(hid_t file1_id,
*----------------------------------------------------------------------
*/
case H5TRAV_TYPE_GROUP:
- if(print_objname(options, nfound))
- do_print_objname("group", path1, path2, options);
+ if(print_objname(opts, nfound))
+ do_print_objname("group", path1, path2, opts);
/* always print the number of differences found in verbose mode */
- if(options->m_verbose)
+ if(opts->m_verbose)
print_found(nfound);
if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0)
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed");
if((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0)
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed");
/*-----------------------------------------------------------------
* compare attributes
@@ -1816,12 +1633,12 @@ hsize_t diff(hid_t file1_id,
*-----------------------------------------------------------------
*/
if(path1)
- nfound += diff_attr(grp1_id, grp2_id, path1, path2, options);
+ nfound += diff_attr(grp1_id, grp2_id, path1, path2, opts);
if(H5Gclose(grp1_id) < 0)
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed");
if(H5Gclose(grp2_id) < 0)
- goto out;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed");
break;
@@ -1831,19 +1648,19 @@ hsize_t diff(hid_t file1_id,
*/
case H5TRAV_TYPE_LINK:
{
- ret = HDstrcmp(linkinfo1.trg_path, linkinfo2.trg_path);
+ status = HDstrcmp(linkinfo1.trg_path, linkinfo2.trg_path);
- /* if the target link name is not same then the links are "different" */
- nfound = (ret != 0) ? 1 : 0;
+ /* if the target link name is not same then the links are "different" */
+ nfound = (status != 0) ? 1 : 0;
- if(print_objname(options, nfound))
- do_print_objname("link", path1, path2, options);
+ if(print_objname(opts, nfound))
+ do_print_objname("link", path1, path2, opts);
- /* always print the number of differences found in verbose mode */
- if(options->m_verbose)
- print_found(nfound);
+ /* always print the number of differences found in verbose mode */
+ if(opts->m_verbose)
+ print_found(nfound);
- }
+ }
break;
/*----------------------------------------------------------------------
@@ -1852,101 +1669,85 @@ hsize_t diff(hid_t file1_id,
*/
case H5TRAV_TYPE_UDLINK:
{
- /* Only external links will have a query function registered */
- if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL)
- {
- /* If the buffers are the same size, compare them */
- if(linkinfo1.linfo.u.val_size == linkinfo2.linfo.u.val_size)
- {
- ret = HDmemcmp(linkinfo1.trg_path, linkinfo2.trg_path, linkinfo1.linfo.u.val_size);
- }
- else
- ret = 1;
+ /* Only external links will have a query function registered */
+ if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) {
+ /* If the buffers are the same size, compare them */
+ if(linkinfo1.linfo.u.val_size == linkinfo2.linfo.u.val_size) {
+ status = HDmemcmp(linkinfo1.trg_path, linkinfo2.trg_path, linkinfo1.linfo.u.val_size);
+ }
+ else
+ status = 1;
- /* if "linkinfo1.trg_path" != "linkinfo2.trg_path" then the links
- * are "different" extlinkinfo#.path is combination string of
- * file_name and obj_name
- */
- nfound = (ret != 0) ? 1 : 0;
+ /* if "linkinfo1.trg_path" != "linkinfo2.trg_path" then the links
+ * are "different" extlinkinfo#.path is combination string of
+ * file_name and obj_name
+ */
+ nfound = (status != 0) ? 1 : 0;
- if(print_objname(options, nfound))
- do_print_objname("external link", path1, path2, options);
+ if(print_objname(opts, nfound))
+ do_print_objname("external link", path1, path2, opts);
- } /* end if */
- else
- {
- /* If one or both of these links isn't an external link, we can only
- * compare information from H5Lget_info since we don't have a query
- * function registered for them.
- *
- * If the link classes or the buffer length are not the
- * same, the links are "different"
- */
- if((linkinfo1.linfo.type != linkinfo2.linfo.type) ||
- (linkinfo1.linfo.u.val_size != linkinfo2.linfo.u.val_size))
- nfound = 1;
- else
- nfound = 0;
-
- if (print_objname (options, nfound))
- do_print_objname ("user defined link", path1, path2, options);
- } /* end else */
+ } /* end if */
+ else {
+ /* If one or both of these links isn't an external link, we can only
+ * compare information from H5Lget_info since we don't have a query
+ * function registered for them.
+ *
+ * If the link classes or the buffer length are not the
+ * same, the links are "different"
+ */
+ if((linkinfo1.linfo.type != linkinfo2.linfo.type) ||
+ (linkinfo1.linfo.u.val_size != linkinfo2.linfo.u.val_size))
+ nfound = 1;
+ else
+ nfound = 0;
- /* always print the number of differences found in verbose mode */
- if(options->m_verbose)
- print_found(nfound);
+ if (print_objname (opts, nfound))
+ do_print_objname ("user defined link", path1, path2, opts);
+ } /* end else */
+
+ /* always print the number of differences found in verbose mode */
+ if(opts->m_verbose)
+ print_found(nfound);
}
break;
case H5TRAV_TYPE_UNKNOWN:
default:
- if(options->m_verbose)
+ if(opts->m_verbose)
parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n",
path1, path2, get_type(object_type) );
- options->not_cmp = 1;
+ opts->not_cmp = 1;
break;
}
- /* free link info buffer */
- if (linkinfo1.trg_path)
- HDfree(linkinfo1.trg_path);
- if (linkinfo2.trg_path)
- HDfree(linkinfo2.trg_path);
-
- return nfound;
-
-out:
- options->err_stat = 1;
+done:
+ opts->err_stat = opts->err_stat | ret_value;
-out2:
/*-----------------------------------
* handle dangling link(s)
*/
/* both path1 and path2 are dangling links */
- if(is_dangle_link1 && is_dangle_link2)
- {
- if(print_objname(options, nfound))
- {
- do_print_objname("dangling link", path1, path2, options);
+ if(is_dangle_link1 && is_dangle_link2) {
+ if(print_objname(opts, nfound)) {
+ do_print_objname("dangling link", path1, path2, opts);
print_found(nfound);
}
}
/* path1 is dangling link */
- else if (is_dangle_link1)
- {
- if(options->m_verbose)
+ else if (is_dangle_link1) {
+ if(opts->m_verbose)
parallel_print("obj1 <%s> is a dangling link.\n", path1);
nfound++;
- if(print_objname(options, nfound))
+ if(print_objname(opts, nfound))
print_found(nfound);
}
/* path2 is dangling link */
- else if (is_dangle_link2)
- {
- if(options->m_verbose)
+ else if (is_dangle_link2) {
+ if(opts->m_verbose)
parallel_print("obj2 <%s> is a dangling link.\n", path2);
nfound++;
- if(print_objname(options, nfound))
+ if(print_objname(opts, nfound))
print_found(nfound);
}
@@ -1959,13 +1760,16 @@ out2:
/* close */
/* disable error reporting */
H5E_BEGIN_TRY {
+ H5Dclose(dset1_id);
+ H5Dclose(dset2_id);
H5Tclose(type1_id);
H5Tclose(type2_id);
H5Gclose(grp1_id);
- H5Tclose(grp2_id);
+ H5Gclose(grp2_id);
/* enable error reporting */
} H5E_END_TRY;
- h5difftrace("diff finish\n");
+
+ h5diffdebug3("diff finish:%d - errstat:%d\n", nfound, opts->err_stat);
return nfound;
}
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index 0226e83..26bcd95 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -38,7 +38,7 @@
/*-------------------------------------------------------------------------
* This is used to pass multiple args into diff().
- * Passing this instead of several each arg provides smoother extensibility
+ * Passing this instead of several each arg provides smoother extensibility
* through its members along with MPI code for ph5diff
* as it doesn't require interface change.
*------------------------------------------------------------------------*/
@@ -95,13 +95,13 @@ H5TOOLS_DLL hsize_t h5diff(const char *fname1,
const char *fname2,
const char *objname1,
const char *objname2,
- diff_opt_t *options);
+ 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 *options,
+ diff_opt_t *opts,
diff_args_t *argdata);
#ifdef H5_HAVE_PARALLEL
@@ -125,18 +125,18 @@ hsize_t diff_dataset( hid_t file1_id,
hid_t file2_id,
const char *obj1_name,
const char *obj2_name,
- diff_opt_t *options);
+ 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 *options);
+ 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 *options );
+ trav_table_t *table, diff_opt_t *opts );
hsize_t diff_array( void *_mem1,
void *_mem2,
@@ -144,7 +144,7 @@ hsize_t diff_array( void *_mem1,
hsize_t hyper_start,
int rank,
hsize_t *dims,
- diff_opt_t *options,
+ diff_opt_t *opts,
const char *name1,
const char *name2,
hid_t m_type,
@@ -162,7 +162,7 @@ int diff_can_type( hid_t f_type1, /* file data type */
hsize_t *maxdim2,
const char *obj1_name,
const char *obj2_name,
- diff_opt_t *options,
+ diff_opt_t *opts,
int is_compound);
@@ -170,7 +170,7 @@ hsize_t diff_attr(hid_t loc1_id,
hid_t loc2_id,
const char *path1,
const char *path2,
- diff_opt_t *options);
+ diff_opt_t *opts);
/*-------------------------------------------------------------------------
@@ -187,10 +187,10 @@ const char* get_class(H5T_class_t tclass);
const char* get_sign(H5T_sign_t sign);
void print_dimensions (int rank, hsize_t *dims);
herr_t match_up_memsize (hid_t f_tid1_id, hid_t f_tid2_id,
- hid_t *m_tid1, hid_t *m_tid2,
+ hid_t *m_tid1, hid_t *m_tid2,
size_t *m_size1, size_t *m_size2);
/* in h5diff.c */
-int print_objname(diff_opt_t *options, hsize_t nfound);
+int print_objname(diff_opt_t *opts, hsize_t nfound);
void do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_opt_t * opts);
void do_print_attrname (const char *attr, const char *path1, const char *path2);
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 1b17382..955819e 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -17,7 +17,6 @@
#include "h5diff.h"
#include "ph5diff.h"
-
/*-------------------------------------------------------------------------
* printf formatting
*-------------------------------------------------------------------------
@@ -66,9 +65,8 @@
#define LLI_FORMAT_P_NOTCOMP "%-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d not comparable\n"
#define ULLI_FORMAT_P_NOTCOMP "%-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "d not comparable\n"
-
/* if system EPSILON is defined, use the system EPSILON; otherwise, use
- constants that are close to most EPSILON values */
+ constants that are close to most EPSILON values */
#ifndef FLT_EPSILON
#define FLT_EPSILON 1.19209E-07
@@ -78,7 +76,6 @@
#define DBL_EPSILON 2.22045E-16
#endif
-
/*-------------------------------------------------------------------------
* -p relative error formula
*
@@ -97,234 +94,131 @@
static hbool_t not_comparable;
#define PER(A,B) { \
- per = -1; \
- not_comparable = FALSE; \
- both_zero = FALSE; \
- if(0 == (A) && 0 == (B)) \
+ per = -1; \
+ not_comparable = FALSE; \
+ both_zero = FALSE; \
+ if(0 == (A) && 0 == (B)) \
both_zero = TRUE; \
- if(0 != (A)) \
+ if(0 != (A)) \
per = (double)ABS((double)((B) - (A)) / (double)(A)); \
- else \
+ else \
not_comparable = TRUE; \
}
-
#define PER_UNSIGN(TYPE,A,B) { \
- per = -1; \
- not_comparable = FALSE; \
- both_zero = FALSE; \
- if((A) == 0 && (B) == 0) \
+ per = -1; \
+ not_comparable = FALSE; \
+ both_zero = FALSE; \
+ if((A) == 0 && (B) == 0) \
both_zero = TRUE; \
- if((A) != 0) \
+ if((A) != 0) \
per = ABS((double)((TYPE)((B) - (A))) / (double)(A)) ; \
- else \
+ else \
not_comparable = TRUE; \
}
-
#define PDIFF(a,b) (((b) > (a)) ? ((b) - (a)) : ((a) -(b)))
-typedef struct mcomp_t
-{
- unsigned n; /* number of members */
- hid_t *ids; /* member type id */
- size_t *offsets;
- struct mcomp_t **m; /* members */
-}mcomp_t;
-
+typedef struct mcomp_t {
+ unsigned n; /* number of members */
+ hid_t *ids; /* member type id */
+ size_t *offsets;
+ struct mcomp_t **m; /* members */
+} 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 *options);
+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,unsigned u,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,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 *options,const char *obj1,const char *obj2,int *ph);
-static hbool_t equal_float(float value, float expected, diff_opt_t *options);
-static hbool_t equal_double(double value, double expected, diff_opt_t *options);
+static int ull2float(unsigned long long ull_value, float *f_value);
+static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, unsigned 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 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 *options);
+static hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts);
#endif
-static int print_data(diff_opt_t *options);
-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,unsigned u,hsize_t *acc,hsize_t *pos,int rank,hsize_t *dims,const char *obj1,const char *obj2 );
+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, unsigned u,
+ hsize_t *acc, hsize_t *pos, int rank, hsize_t *dims, const char *obj1, const char *obj2);
static void h5diff_print_char(char ch);
-static hsize_t diff_datum(void *_mem1,
- void *_mem2,
- hid_t m_type,
- hsize_t i,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- 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 *options,
- 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 *options,
- const char *obj1,
- const char *obj2,
- int *ph);
+static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
+ 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);
#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 *options,
- const char *obj1,
- const char *obj2,
- int *ph);
+ 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);
#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 *options,
- 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 *options,
- 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 *options,
- 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 *options,
- 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 *options,
- 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 *options,
- 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 *options,
- 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 *options,
- 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 *options,
- 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 *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
+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);
/*-------------------------------------------------------------------------
* NaN detection
@@ -337,13 +231,11 @@ typedef enum dtype_t
FLT_FLOAT,
FLT_DOUBLE,
FLT_LDOUBLE
-} dtype_t;
+}dtype_t;
#else
-typedef enum dtype_t
-{
- FLT_FLOAT,
- FLT_DOUBLE
+typedef enum dtype_t {
+ FLT_FLOAT, FLT_DOUBLE
} dtype_t;
#endif
@@ -356,50 +248,44 @@ static hbool_t my_isnan(dtype_t type, void *val);
static void get_member_types(hid_t tid, mcomp_t *members);
static void close_member_types(mcomp_t *members);
-
-
/*-------------------------------------------------------------------------
* Function: diff_array
*
* Purpose: compare two memory buffers;
*
* Return: number of differences found
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 12, 2003
- *
*-------------------------------------------------------------------------
*/
-hsize_t diff_array( void *_mem1,
- void *_mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- diff_opt_t *options,
- const char *name1,
- const char *name2,
- hid_t m_type,
- hid_t container1_id,
- hid_t container2_id) /* dataset where the reference came from*/
+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*/
{
- 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;
-
- h5difftrace("diff_array start\n");
+ 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;
+
+ h5diffdebug2("diff_array start - errstat:%d\n", opts->err_stat);
/* get the size. */
- size = H5Tget_size( m_type );
+ size = H5Tget_size(m_type);
type_class = H5Tget_class(m_type);
/* Fast comparison first for atomic type by memcmp().
@@ -410,23 +296,19 @@ hsize_t diff_array( void *_mem1,
type_class != H5T_COMPOUND &&
type_class != H5T_STRING &&
type_class != H5T_VLEN &&
- HDmemcmp(mem1, mem2, size*nelmts)==0)
+ HDmemcmp(mem1, mem2, size*nelmts) == 0)
return 0;
- if ( rank > 0 )
- {
-
- acc[rank-1]=1;
- for(j=(rank-2); j>=0; j--)
- {
- acc[j]=acc[j+1]*dims[j+1];
+ 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;
+ for (j = 0; j < rank; j++)
+ pos[j] = 0;
}
- switch (type_class)
- {
+ switch (type_class) {
case H5T_NO_CLASS:
case H5T_TIME:
case H5T_NCLASSES:
@@ -434,52 +316,48 @@ hsize_t diff_array( void *_mem1,
HDassert(0);
break;
- /*-------------------------------------------------------------------------
- * float and integer atomic types
- *-------------------------------------------------------------------------
- */
-
+ /*-------------------------------------------------------------------------
+ * float and integer atomic types
+ *-------------------------------------------------------------------------
+ */
case H5T_FLOAT:
if (H5Tequal(m_type, H5T_NATIVE_FLOAT))
- nfound=diff_float(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ 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,options,name1,name2,&ph);
-#if H5_SIZEOF_LONG_DOUBLE !=0
+ nfound = diff_double(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
+#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,options,name1,name2,&ph);
+ nfound = diff_ldouble(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
#endif
break;
case H5T_INTEGER:
-
if (H5Tequal(m_type, H5T_NATIVE_SCHAR))
- nfound=diff_schar(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ 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,options,name1,name2,&ph);
+ 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,options,name1,name2,&ph);
+ 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,options,name1,name2,&ph);
+ 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,options,name1,name2,&ph);
+ 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,options,name1,name2,&ph);
+ 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,options,name1,name2,&ph);
+ 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,options,name1,name2,&ph);
+ 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,options,name1,name2,&ph);
+ 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,options,name1,name2,&ph);
-
+ nfound = diff_ullong(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph);
break;
/*-------------------------------------------------------------------------
* Other types than float and integer
*-------------------------------------------------------------------------
*/
-
case H5T_COMPOUND:
case H5T_STRING:
case H5T_BITFIELD:
@@ -488,34 +366,17 @@ hsize_t diff_array( void *_mem1,
case H5T_ARRAY:
case H5T_VLEN:
case H5T_REFERENCE:
- HDmemset(&members, 0, sizeof (mcomp_t));
+ HDmemset(&members, 0, sizeof(mcomp_t));
get_member_types(m_type, &members);
- for ( i = 0; i < nelmts; i++)
- {
- nfound+=diff_datum(
- mem1 + i * size,
- mem2 + i * size, /* offset */
- m_type,
- i,
- rank,
- dims,
- acc,
- pos,
- options,
- name1,
- name2,
- container1_id,
- container2_id,
- &ph, &members);
- if (options->n && nfound>=options->count)
- {
- close_member_types(&members);
- return nfound;
- }
+ 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)
+ break;
} /* i */
close_member_types(&members);
} /* switch */
- h5difftrace("diff_array finish\n");
+ h5diffdebug3("diff_array finish:%d - errstat:%d\n", nfound, opts->err_stat);
return nfound;
}
@@ -527,10 +388,6 @@ hsize_t diff_array( void *_mem1,
*
* Return: number of differences found
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: October 29, 2003
- *
* The comparison of the 2 buffers read from the files is made datum by datum.
*
* H5T_INTEGER and H5T_FLOAT
@@ -557,46 +414,45 @@ hsize_t diff_array( void *_mem1,
* Dereference the object and compare the type (basic object type).
*-------------------------------------------------------------------------
*/
-static hsize_t diff_datum(void *_mem1,
- void *_mem2,
- hid_t m_type,
- hsize_t i,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- 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_datum(
+ void *_mem1,
+ void *_mem2,
+ hid_t m_type,
+ hsize_t index,
+ 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 */
{
- unsigned char *mem1 = (unsigned char*)_mem1;
- unsigned char *mem2 = (unsigned char*)_mem2;
- unsigned u;
- hid_t memb_type;
- size_t type_size;
- H5T_sign_t type_sign;
- H5T_class_t type_class;
- size_t offset;
- unsigned nmembs;
- unsigned j;
- hsize_t nelmts;
- size_t size=0;
- hbool_t iszero1;
- hbool_t iszero2;
- hid_t obj1_id;
- hid_t obj2_id;
- hsize_t nfound=0; /* differences found */
- int ret=0; /* check return error */
- float f1, f2;
- double per;
- hbool_t both_zero;
+ unsigned char *mem1 = (unsigned char*) _mem1;
+ unsigned char *mem2 = (unsigned char*) _mem2;
+ unsigned u;
+ size_t type_size;
+ H5T_sign_t type_sign;
+ H5T_class_t type_class;
+ size_t offset;
+ unsigned nmembs;
+ unsigned j;
+ hsize_t nelmts;
+ size_t size = 0;
+ hbool_t iszero1;
+ hbool_t iszero2;
+ hsize_t nfound = 0; /* differences found */
+ hsize_t ret_value = opts->err_stat;
+ float f1, f2;
+ double per;
+ hbool_t both_zero;
h5difftrace("diff_datum start\n");
- type_size = H5Tget_size( m_type );
+
+ type_size = H5Tget_size(m_type);
type_class = H5Tget_class(m_type);
/* Fast comparison first for atomic type by memcmp().
@@ -607,97 +463,100 @@ static hsize_t diff_datum(void *_mem1,
type_class != H5T_COMPOUND &&
type_class != H5T_STRING &&
type_class != H5T_VLEN &&
- HDmemcmp(mem1, mem2, type_size)==0)
- return 0;
+ HDmemcmp(mem1, mem2, type_size) == 0)
+ HGOTO_DONE(opts->err_stat);
- switch (H5Tget_class(m_type))
- {
+ switch (H5Tget_class(m_type)) {
case H5T_NO_CLASS:
case H5T_TIME:
case H5T_NCLASSES:
default:
- HDassert(0);
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Invalid type class");
break;
- /*-------------------------------------------------------------------------
- * H5T_COMPOUND
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5T_COMPOUND
+ *-------------------------------------------------------------------------
+ */
case H5T_COMPOUND:
h5difftrace("diff_datum H5T_COMPOUND\n");
+ {
+ hid_t memb_type = -1;
+ nmembs = members->n;
- nmembs = members->n;
-
+ for (j = 0; j < nmembs; j++) {
+ offset = members->offsets[j];
+ memb_type = members->ids[j];
- for (j = 0; j < nmembs; j++)
- {
- offset = members->offsets[j];
- memb_type = members->ids[j];
-
- nfound+=diff_datum(
- mem1 + offset,
- mem2 + offset,
- memb_type,
- i,
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph, members->m[j]);
+ nfound += diff_datum(mem1 + offset, mem2 + offset, memb_type, index,
+ rank, dims, acc, pos, opts, obj1, obj2, container1_id, container2_id, ph, members->m[j]);
+ }
}
break;
- /*-------------------------------------------------------------------------
- * H5T_STRING
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5T_STRING
+ *-------------------------------------------------------------------------
+ */
case H5T_STRING:
h5difftrace("diff_datum H5T_STRING\n");
{
- char *s = NULL;
- char *sx = NULL;
- char *s1 = NULL;
- char *s2 = NULL;
- 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);
+ char *s = NULL;
+ char *sx = NULL;
+ char *s1 = NULL;
+ char *s2 = NULL;
+ 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);
/* if variable length string */
- if(H5Tis_variable_str(m_type)) {
+ if (H5Tis_variable_str(m_type)) {
h5difftrace("diff_datum H5T_STRING variable\n");
/* Get pointer to first string */
s1 = *(char**) mem1;
- size1 = HDstrlen(s1);
+ if (s1)
+ size1 = HDstrlen(s1);
+ else
+ size1 = 0;
+
/* Get pointer to second string */
s2 = *(char**) mem2;
- size2 = HDstrlen(s2);
+ if (s2)
+ size2 = HDstrlen(s2);
+ else
+ size2 = 0;
}
else if (H5T_STR_NULLTERM == pad) {
h5difftrace("diff_datum H5T_STRING null term\n");
/* Get pointer to first string */
s1 = (char*) mem1;
- size1 = HDstrlen(s1);
+ if (s1)
+ size1 = HDstrlen(s1);
+ else
+ size1 = 0;
+
if (size1 > size_mtype)
size1 = size_mtype;
+
/* Get pointer to second string */
s2 = (char*) mem2;
- size2 = HDstrlen(s2);
+ if (s2)
+ size2 = HDstrlen(s2);
+ else
+ size2 = 0;
+
if (size2 > size_mtype)
size2 = size_mtype;
}
else {
/* Get pointer to first string */
- s1 = (char *)mem1;
+ s1 = (char *) mem1;
size1 = size_mtype;
+
/* Get pointer to second string */
- s2 = (char *)mem2;
+ s2 = (char *) mem2;
size2 = size_mtype;
}
@@ -707,13 +566,13 @@ static hsize_t diff_datum(void *_mem1,
* of length of strings.
* For now mimic the previous way.
*/
- h5diffdebug2("diff_datum string size:%d\n",size1);
- h5diffdebug2("diff_datum string size:%d\n",size2);
- if(size1 != size2) {
+ h5diffdebug2("diff_datum string size:%d\n", size1);
+ h5diffdebug2("diff_datum string size:%d\n", size2);
+ if (size1 != size2) {
h5difftrace("diff_datum string sizes\n");
nfound++;
}
- if(size1 < size2) {
+ if (size1 < size2) {
size = size1;
s = s1;
sizex = size2;
@@ -727,68 +586,30 @@ static hsize_t diff_datum(void *_mem1,
}
/* check for NULL pointer for string */
- if(s!=NULL) {
+ if (s != NULL) {
/* try fast compare first */
- if(HDmemcmp(s1, s2, size)==0) {
- if(size1 != size2)
- if(print_data(options))
- for (u=size; u<sizex; u++)
- character_compare(
- s1 + u,
- s2 + u, /* offset */
- i, /* index position */
- u, /* string character position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
+ 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, index, u, rank, dims, acc, pos, opts, obj1, obj2, ph);
}
else
- for (u=0; u<size; u++)
- nfound+=character_compare(
- s1 + u,
- s2 + u, /* offset */
- i, /* index position */
- u, /* string character position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
- }
-
+ for (u = 0; u < size; u++)
+ nfound += character_compare(s + u, sx + u, index, u, rank, dims, acc, pos, opts, obj1, obj2, ph);
+ } /* end check for NULL pointer for string */
}
break;
- /*-------------------------------------------------------------------------
- * H5T_BITFIELD
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5T_BITFIELD
+ *-------------------------------------------------------------------------
+ */
case H5T_BITFIELD:
h5difftrace("diff_datum H5T_BITFIELD\n");
-
/* byte-by-byte comparison */
- for (u=0; u<type_size; u++)
- nfound+=character_compare_opt(
- mem1 + u,
- mem2 + u, /* offset */
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
-
+ for (u = 0; u < type_size; u++)
+ nfound += character_compare_opt(mem1 + u, mem2 + u, index, rank, dims, acc, pos, opts, obj1, obj2, ph);
break;
/*-------------------------------------------------------------------------
@@ -798,1189 +619,910 @@ static hsize_t diff_datum(void *_mem1,
case H5T_OPAQUE:
h5difftrace("diff_datum H5T_OPAQUE\n");
/* byte-by-byte comparison */
- for (u=0; u<type_size; u++)
- nfound+=character_compare_opt(
- mem1 + u,
- mem2 + u, /* offset */
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
-
+ for (u = 0; u < type_size; u++)
+ nfound += character_compare_opt(mem1 + u, mem2 + u, index, rank, dims, acc, pos, opts, obj1, obj2, ph);
break;
-
- /*-------------------------------------------------------------------------
- * H5T_ENUM
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5T_ENUM
+ *-------------------------------------------------------------------------
+ */
case H5T_ENUM:
+ /* For enumeration types we compare the names instead of the
+ * integer values. For each pair of elements being
+ * compared, we convert both bit patterns to their corresponding
+ * enumeration constant and do a string comparison
+ */
h5difftrace("diff_datum H5T_ENUM\n");
-
- /* For enumeration types we compare the names instead of the
- integer values. For each pair of elements being
- compared, we convert both bit patterns to their corresponding
- enumeration constant and do a string comparison
- */
-
{
char enum_name1[1024];
char enum_name2[1024];
-
herr_t err1;
herr_t err2;
/* disable error reporting */
H5E_BEGIN_TRY {
-
/* 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);
- if(err1 < 0)
+ if (err1 < 0)
HDsnprintf(enum_name1, sizeof(enum_name1), "**INVALID VALUE**");
err2 = H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2);
- if(err2 < 0)
+ if (err2 < 0)
HDsnprintf(enum_name2, sizeof(enum_name2), "**INVALID VALUE**");
- if(err1 < 0 || err2 < 0)
- {
- /* One or more bad enum values */
-
+ /* One or more bad enum values */
+ if (err1 < 0 || err2 < 0) {
/* If the two values cannot be converted to a string
* (probably due to them being invalid enum values),
* don't attempt to convert them - just report errors.
*/
nfound += 1;
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(S_FORMAT,enum_name1,enum_name2);
+ parallel_print(S_FORMAT, enum_name1, enum_name2);
}
}
- else
- {
+ else {
/* Both enum values were valid */
-
- if (HDstrcmp(enum_name1,enum_name2)!=0)
- {
- nfound=1;
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (HDstrcmp(enum_name1, enum_name2) != 0) {
+ nfound = 1;
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(S_FORMAT,enum_name1,enum_name2);
+ parallel_print(S_FORMAT, enum_name1, enum_name2);
}
}
- else
- {
- for (u=0; u<type_size; u++)
- nfound+=character_compare_opt(
- mem1 + u,
- mem2 + u, /* offset */
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
+ else {
+ for (u = 0; u < type_size; u++)
+ nfound += character_compare_opt(mem1 + u, mem2 + u, index, rank, dims, acc, pos, opts, obj1, obj2, ph);
}
}
/* enable error reporting */
} H5E_END_TRY;
}
-
-
break;
- /*-------------------------------------------------------------------------
- * H5T_ARRAY
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5T_ARRAY
+ *-------------------------------------------------------------------------
+ */
case H5T_ARRAY:
-
- {
- hsize_t adims[H5S_MAX_RANK];
- int ndims;
-
- /* 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);
- HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
-
- /* 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, /* offset */
- memb_type,
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph, members);
+ {
+ hid_t memb_type = -1;
+ hsize_t adims[H5S_MAX_RANK];
+ int ndims;
+
+ /* 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);
+ HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
+
+ /* 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, index,
+ rank, dims, acc, pos, opts, obj1, obj2, container1_id, container2_id, ph, members);
+ }
+ H5Tclose(memb_type);
}
- H5Tclose(memb_type);
- }
- break;
-
-
-
- /*-------------------------------------------------------------------------
- * H5T_REFERENCE
- *-------------------------------------------------------------------------
- */
+ break;
+ /*-------------------------------------------------------------------------
+ * H5T_REFERENCE
+ *-------------------------------------------------------------------------
+ */
case H5T_REFERENCE:
-
- iszero1=all_zero(_mem1, H5Tget_size(m_type));
- iszero2=all_zero(_mem2, H5Tget_size(m_type));
- if (iszero1 != iszero2)
- {
- return 1;
+ iszero1 = all_zero(_mem1, H5Tget_size(m_type));
+ iszero2 = all_zero(_mem2, H5Tget_size(m_type));
+ if (iszero1 != iszero2) {
+ nfound++;
+ HGOTO_DONE (opts->err_stat);
}
- else if (!iszero1 && !iszero2)
- {
-
- /*-------------------------------------------------------------------------
- * H5T_STD_REF_DSETREG
- * Dataset region reference
- *-------------------------------------------------------------------------
- */
- if (type_size==H5R_DSET_REG_REF_BUF_SIZE)
- {
- hid_t region1_id;
- hid_t region2_id;
+ else if (!iszero1 && !iszero2) {
+ /*-------------------------------------------------------------------------
+ * H5T_STD_REF_DSETREG
+ * Dataset region reference
+ *-------------------------------------------------------------------------
+ */
+ hid_t obj1_id = -1;
+ hid_t obj2_id = -1;
- if ((obj1_id = H5Rdereference(container1_id, H5R_DATASET_REGION, _mem1))<0)
- ret= -1;
- if ((obj2_id = H5Rdereference(container2_id, H5R_DATASET_REGION, _mem2))<0)
- ret= -1;
- if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1))<0)
- ret= -1;
- if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2))<0)
- ret= -1;
+ if (type_size == H5R_DSET_REG_REF_BUF_SIZE) {
+ hid_t region1_id = -1;
+ hid_t region2_id = -1;
- if (ret==-1) {
- options->err_stat=1;
- return 0;
+ if ((obj1_id = H5Rdereference(container1_id, H5R_DATASET_REGION, _mem1)) < 0) {
+ opts->err_stat = 1;
+ H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rdereference object 1 failed");
+ }
+ if ((obj2_id = H5Rdereference(container2_id, H5R_DATASET_REGION, _mem2)) < 0) {
+ opts->err_stat = 1;
+ H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rdereference object 2 failed");
+ }
+ if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1)) < 0) {
+ opts->err_stat = 1;
+ H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rget_region object 1 failed");
+ }
+ if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2)) < 0) {
+ opts->err_stat = 1;
+ H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rget_region object 2 failed");
}
- nfound = diff_region(obj1_id,obj2_id,region1_id,region2_id,options);
+ nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, opts);
H5Oclose(obj1_id);
H5Oclose(obj2_id);
H5Sclose(region1_id);
H5Sclose(region2_id);
-
}/*dataset reference*/
+ /*-------------------------------------------------------------------------
+ * H5T_STD_REF_OBJ
+ * Object references. get the type and OID of the referenced object
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == H5R_OBJ_REF_BUF_SIZE) {
+ H5O_type_t obj1_type;
+ H5O_type_t obj2_type;
- /*-------------------------------------------------------------------------
- * H5T_STD_REF_OBJ
- * Object references. get the type and OID of the referenced object
- *-------------------------------------------------------------------------
- */
- else if (type_size == H5R_OBJ_REF_BUF_SIZE)
- {
- H5O_type_t obj1_type;
- H5O_type_t obj2_type;
-
- if(H5Rget_obj_type2(container1_id, H5R_OBJECT, _mem1, &obj1_type) < 0)
- ret = -1;
- if(H5Rget_obj_type2(container2_id, H5R_OBJECT, _mem2, &obj2_type) < 0)
- ret = -1;
- if(ret == -1) {
- options->err_stat = 1;
- return 0;
- } /* end if */
+ if (H5Rget_obj_type2(container1_id, H5R_OBJECT, _mem1, &obj1_type) < 0) {
+ opts->err_stat = 1;
+ H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rget_obj_type2 object 1 failed");
+ }
+ if (H5Rget_obj_type2(container2_id, H5R_OBJECT, _mem2, &obj2_type) < 0) {
+ opts->err_stat = 1;
+ H5TOOLS_INFO(H5E_tools_min_id_g, "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);
- options->not_cmp = 1;
- return 0;
- }
-
- if((obj1_id = H5Rdereference(container1_id, H5R_OBJECT, _mem1)) < 0)
- ret = -1;
- if((obj2_id = H5Rdereference(container2_id, H5R_OBJECT, _mem2)) < 0)
- ret = -1;
- if(ret == -1) {
- options->err_stat = 1;
- return 0;
- } /* end if */
+ if (ret_value >= 0)
+ if (obj1_type != obj2_type) {
+ parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2);
+ opts->not_cmp = 1;
+ HGOTO_DONE (opts->err_stat);
+ }
+
+ if ((obj1_id = H5Rdereference(container1_id, H5R_OBJECT, _mem1)) < 0) {
+ opts->err_stat = 1;
+ H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rdereference object 1 failed");
+ }
+ if ((obj2_id = H5Rdereference(container2_id, H5R_OBJECT, _mem2)) < 0) {
+ opts->err_stat = 1;
+ H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rdereference object 2 failed");
+ }
/* compare */
- if(obj1_type == H5O_TYPE_DATASET)
- nfound = diff_datasetid(obj1_id,
- obj2_id,
- NULL,
- NULL,
- options);
+ if (obj1_type == H5O_TYPE_DATASET)
+ nfound = diff_datasetid(obj1_id, obj2_id, NULL, NULL, opts);
else {
- if(options->m_verbose)
- parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n",
+ if (opts->m_verbose)
+ parallel_print(
+ "Warning: Comparison not possible of object types referenced: <%s> and <%s>\n",
obj1, obj2);
- options->not_cmp = 1;
+ opts->not_cmp = 1;
}
H5Oclose(obj1_id);
H5Oclose(obj2_id);
-
}/*object reference*/
-
}/*is zero*/
-
-
break;
- /*-------------------------------------------------------------------------
- * H5T_VLEN
- *-------------------------------------------------------------------------
- */
-
+ /*-------------------------------------------------------------------------
+ * H5T_VLEN
+ *-------------------------------------------------------------------------
+ */
case H5T_VLEN:
+ {
+ hid_t memb_type = -1;
- /* get the VL sequences's base datatype for each element */
- memb_type = H5Tget_super(m_type);
- size = H5Tget_size(memb_type);
-
- /* get the number of sequence elements */
- nelmts = ((hvl_t *)mem1)->len;
-
- for (j = 0; j < nelmts; j++)
- nfound += diff_datum(
- ((char *)(((hvl_t *)mem1)->p)) + j * size,
- ((char *)(((hvl_t *)mem2)->p)) + j * size, /* offset */
- memb_type,
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph, members);
-
- H5Tclose(memb_type);
-
- break;
+ /* get the VL sequences's base datatype for each element */
+ memb_type = H5Tget_super(m_type);
+ size = H5Tget_size(memb_type);
+ /* get the number of sequence elements */
+ nelmts = ((hvl_t *) mem1)->len;
+ for (j = 0; j < nelmts; j++)
+ nfound += diff_datum(((char *) (((hvl_t *) mem1)->p)) + j * size, ((char *) (((hvl_t *) mem2)->p)) + j * size, memb_type, index,
+ rank, dims, acc, pos, opts, obj1, obj2, container1_id, container2_id, ph, members);
- /*-------------------------------------------------------------------------
- * H5T_INTEGER
- *-------------------------------------------------------------------------
- */
+ H5Tclose(memb_type);
+ }
+ break;
+ /*-------------------------------------------------------------------------
+ * H5T_INTEGER
+ *-------------------------------------------------------------------------
+ */
case H5T_INTEGER:
type_sign = H5Tget_sign(m_type);
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_SCHAR
- *-------------------------------------------------------------------------
- */
- if (type_size==1 && type_sign!=H5T_SGN_NONE)
- {
- char temp1_char;
- char temp2_char;
- HDassert(type_size==sizeof(char));
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_SCHAR
+ *-------------------------------------------------------------------------
+ */
+ if (type_size == 1 && type_sign != H5T_SGN_NONE) {
+ char temp1_char;
+ char temp2_char;
+
+ if(type_size != sizeof(char))
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not char size");
HDmemcpy(&temp1_char, mem1, sizeof(char));
HDmemcpy(&temp2_char, mem2, sizeof(char));
/* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_char-temp2_char) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (opts->d && !opts->p) {
+ if (ABS(temp1_char-temp2_char) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
+ parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
}
nfound++;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_char,temp2_char);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (!opts->d && opts->p) {
+ PER(temp1_char, temp2_char);
+
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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 ( options->d && options->p)
- {
- PER(temp1_char,temp2_char);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (opts->d && opts->p) {
+ PER(temp1_char, temp2_char);
+
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
}
nfound++;
}
-
- else
-
- if ( per > options->percent && ABS(temp1_char-temp2_char) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent && ABS(temp1_char - temp2_char) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if (temp1_char != temp2_char) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
+ parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
}
nfound++;
}
-
} /*H5T_NATIVE_SCHAR*/
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_UCHAR
- *-------------------------------------------------------------------------
- */
- else if (type_size==1 && type_sign==H5T_SGN_NONE)
- {
- unsigned char temp1_uchar;
- unsigned char temp2_uchar;
- HDassert(type_size==sizeof(unsigned char));
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_UCHAR
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 1 && type_sign == H5T_SGN_NONE) {
+ unsigned char temp1_uchar;
+ unsigned char temp2_uchar;
+
+ if(type_size != sizeof(unsigned char))
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned char size");
HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
/* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_uchar,temp2_uchar) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (opts->d && !opts->p) {
+ if (PDIFF(temp1_uchar, temp2_uchar) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ 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, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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 (per > opts->percent) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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 ( options->d && options->p)
- {
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ 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, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
}
-
- else
-
- if ( per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta )
- {
- if ( print_data(options) )
- {
- 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 (per > opts->percent && PDIFF(temp1_uchar, temp2_uchar) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if (temp1_uchar != temp2_uchar) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
}
-
} /*H5T_NATIVE_UCHAR*/
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_SHORT
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 2 && type_sign != H5T_SGN_NONE) {
+ short temp1_short;
+ short temp2_short;
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_SHORT
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==2 && type_sign!=H5T_SGN_NONE)
- {
- short temp1_short;
- short temp2_short;
- HDassert(type_size==sizeof(short));
+ if(type_size != sizeof(short))
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not short size");
HDmemcpy(&temp1_short, mem1, sizeof(short));
HDmemcpy(&temp2_short, mem2, sizeof(short));
/* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_short-temp2_short) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (opts->d && !opts->p) {
+ if (ABS(temp1_short - temp2_short) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
+ parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
}
nfound++;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_short,temp2_short);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (!opts->d && opts->p) {
+ PER(temp1_short, temp2_short);
+
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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 ( options->d && options->p)
- {
- PER(temp1_short,temp2_short);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (opts->d && opts->p) {
+ PER(temp1_short, temp2_short);
+
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
}
nfound++;
}
-
- else
-
- if ( per > options->percent && ABS(temp1_short-temp2_short) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent && ABS(temp1_short - temp2_short) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if (temp1_short != temp2_short) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
+ parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
}
nfound++;
}
-
-
} /*H5T_NATIVE_SHORT*/
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_USHORT
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_USHORT
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 2 && type_sign == H5T_SGN_NONE) {
+ unsigned short temp1_ushort;
+ unsigned short temp2_ushort;
- else if (type_size==2 && type_sign==H5T_SGN_NONE)
- {
- unsigned short temp1_ushort;
- unsigned short temp2_ushort;
- HDassert(type_size==sizeof(short));
+ if(type_size != sizeof(unsigned short))
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned short size");
HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
/* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_ushort,temp2_ushort) > options->delta)
- {
-
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (opts->d && !opts->p) {
+ if (PDIFF(temp1_ushort, temp2_ushort) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
+ parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
}
nfound++;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ 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, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,
- PDIFF(temp1_ushort,temp2_ushort));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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 ( options->d && options->p)
- {
- PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ 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, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
}
nfound++;
}
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ushort,temp2_ushort) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent && PDIFF(temp1_ushort, temp2_ushort) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if (temp1_ushort != temp2_ushort) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
+ parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
}
nfound++;
}
} /*H5T_NATIVE_USHORT*/
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_INT
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 4 && type_sign != H5T_SGN_NONE) {
+ int temp1_int;
+ int temp2_int;
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_INT
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==4 && type_sign!=H5T_SGN_NONE)
- {
- int temp1_int;
- int temp2_int;
- HDassert(type_size==sizeof(int));
+ if(type_size != sizeof(int))
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not int size");
HDmemcpy(&temp1_int, mem1, sizeof(int));
HDmemcpy(&temp2_int, mem2, sizeof(int));
/* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_int-temp2_int) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (opts->d && !opts->p) {
+ if (ABS(temp1_int-temp2_int) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
+ parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
}
nfound++;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_int,temp2_int);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (!opts->d && opts->p) {
+ PER(temp1_int, temp2_int);
+
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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 ( options->d && options->p)
- {
- PER(temp1_int,temp2_int);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (opts->d && opts->p) {
+ PER(temp1_int, temp2_int);
+
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
}
nfound++;
}
-
- else
-
- if ( per > options->percent && ABS(temp1_int-temp2_int) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent && ABS(temp1_int - temp2_int) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if (temp1_int != temp2_int) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
+ parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
}
nfound++;
}
} /*H5T_NATIVE_INT*/
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_UINT
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 4 && type_sign == H5T_SGN_NONE) {
+ unsigned int temp1_uint;
+ unsigned int temp2_uint;
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_UINT
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==4 && type_sign==H5T_SGN_NONE)
- {
- unsigned int temp1_uint;
- unsigned int temp2_uint;
- HDassert(type_size==sizeof(int));
+ if(type_size != sizeof(unsigned int))
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned int size");
HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
/* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_uint,temp2_uint) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (opts->d && !opts->p) {
+ if (PDIFF(temp1_uint, temp2_uint) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(UI_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
}
nfound++;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed int,temp1_uint,temp2_uint);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ 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, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(UI_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,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 (per > opts->percent) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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 ( options->d && options->p)
- {
- PER_UNSIGN(signed int,temp1_uint,temp2_uint);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ 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, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(UI_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
}
nfound++;
}
-
- else
-
- if ( per > options->percent && PDIFF(temp1_uint,temp2_uint) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,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 (per > opts->percent && PDIFF(temp1_uint,temp2_uint) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if (temp1_uint != temp2_uint) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(UI_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
}
nfound++;
}
} /*H5T_NATIVE_UINT*/
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_LONG
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 8 && type_sign != H5T_SGN_NONE) {
+ long temp1_long;
+ long temp2_long;
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_LONG
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==8 && type_sign!=H5T_SGN_NONE)
- {
- long temp1_long;
- long temp2_long;
- HDassert(type_size==sizeof(long));
+ if(type_size != sizeof(long))
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not long size");
HDmemcpy(&temp1_long, mem1, sizeof(long));
HDmemcpy(&temp2_long, mem2, sizeof(long));
/* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_long-temp2_long) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (opts->d && !opts->p) {
+ if (ABS(temp1_long-temp2_long) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
+ parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
}
nfound++;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_long,temp2_long);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (!opts->d && opts->p) {
+ PER(temp1_long, temp2_long);
+
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,
- ABS(temp1_long-temp2_long));
+ parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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 ( options->d && options->p)
- {
- PER(temp1_long,temp2_long);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (opts->d && opts->p) {
+ PER(temp1_long, temp2_long);
+
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
+ parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
}
nfound++;
}
-
- else
-
- if ( per > options->percent && ABS(temp1_long-temp2_long) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent && ABS(temp1_long-temp2_long) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if (temp1_long != temp2_long) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
+ parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
}
nfound++;
}
} /*H5T_NATIVE_LONG*/
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_ULONG
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_ULONG
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 8 && type_sign == H5T_SGN_NONE) {
+ unsigned long temp1_ulong;
+ unsigned long temp2_ulong;
- else if (type_size==8 && type_sign==H5T_SGN_NONE)
- {
- unsigned long temp1_ulong;
- unsigned long temp2_ulong;
- HDassert(type_size==sizeof(unsigned long));
+ if(type_size != sizeof(unsigned long))
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned long size");
HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
/* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_ulong,temp2_ulong) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (opts->d && !opts->p) {
+ if (PDIFF(temp1_ulong, temp2_ulong) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(ULI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
+ parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
}
nfound++;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ 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, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
+ parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,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 (per > opts->percent) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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 ( options->d && options->p)
- {
- PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ 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, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
+ parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
}
nfound++;
}
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ulong,temp2_ulong) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,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 (per > opts->percent && PDIFF(temp1_ulong,temp2_ulong) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if (temp1_ulong != temp2_ulong) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(ULI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
+ parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
}
nfound++;
}
-
-
} /*H5T_NATIVE_ULONG*/
/*-------------------------------------------------------------------------
- * H5T_NATIVE_LLONG
- *-------------------------------------------------------------------------
- */
+ * H5T_NATIVE_LLONG
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 8 && type_sign != H5T_SGN_NONE) {
+ long long temp1_llong;
+ long long temp2_llong;
- else if (type_size==8 && type_sign!=H5T_SGN_NONE)
- {
- long long temp1_llong;
- long long temp2_llong;
- HDassert(type_size==sizeof(long long));
+ if(type_size != sizeof(long long))
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not long long size");
HDmemcpy(&temp1_llong, mem1, sizeof(long long));
HDmemcpy(&temp2_llong, mem2, sizeof(long long));
/* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_llong-temp2_llong) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (opts->d && !opts->p) {
+ if (ABS(temp1_llong-temp2_llong) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
+ parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
}
nfound++;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_llong,temp2_llong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (!opts->d && opts->p) {
+ PER(temp1_llong, temp2_llong);
+
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
+ parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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++;
+ }
}
/* -d and -p */
- else if ( options->d && options->p)
- {
- PER(temp1_llong,temp2_llong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (opts->d && opts->p) {
+ PER(temp1_llong, temp2_llong);
+
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
+ parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
}
nfound++;
}
- else
-
- if ( per > options->percent && ABS(temp1_llong-temp2_llong) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent && ABS(temp1_llong-temp2_llong) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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++;
+ }
}
- else if (temp1_llong != temp2_llong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if (temp1_llong != temp2_llong) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
+ parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
}
nfound++;
}
@@ -1988,769 +1530,584 @@ static hsize_t diff_datum(void *_mem1,
} /*H5T_NATIVE_LLONG*/
/*-------------------------------------------------------------------------
- * H5T_NATIVE_ULLONG
- *-------------------------------------------------------------------------
- */
+ * H5T_NATIVE_ULLONG
+ *-------------------------------------------------------------------------
+ */
- else if (type_size==8 && type_sign==H5T_SGN_NONE)
- {
- unsigned long long temp1_ullong;
- unsigned long long temp2_ullong;
- HDassert(type_size==sizeof(unsigned long long));
+ else if (type_size == 8 && type_sign == H5T_SGN_NONE) {
+ unsigned long long temp1_ullong;
+ unsigned long long temp2_ullong;
+
+ if(type_size != sizeof(unsigned long long))
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned long long size");
HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
/* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long)options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (opts->d && !opts->p) {
+ if (PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
+ parallel_print(ULLI_FORMAT, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong));
}
nfound++;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- ull2float(temp1_ullong,&f1);
- ull2float(temp2_ullong,&f2);
- PER(f1,f2);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (!opts->d && opts->p) {
+ ull2float(temp1_ullong, &f1);
+ ull2float(temp2_ullong, &f2);
+ PER(f1, f2);
+
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
+ parallel_print(ULLI_FORMAT_P_NOTCOMP, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong));
}
nfound++;
- }
-
- else
+ }
- if ( per > options->percent )
- {
+ else if (per > opts->percent) {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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++;
+ }
}
/* -d and -p */
- else if ( options->d && options->p)
- {
- ull2float(temp1_ullong,&f1);
- ull2float(temp2_ullong,&f2);
- PER(f1,f2);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (opts->d && opts->p) {
+ ull2float(temp1_ullong, &f1);
+ ull2float(temp2_ullong, &f2);
+ PER(f1, f2);
+
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
+ parallel_print(ULLI_FORMAT_P_NOTCOMP, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong));
}
nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long)options->delta )
- {
-
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ }
+ else if (per > opts->percent && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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++;
+ }
}
- else if (temp1_ullong != temp2_ullong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if (temp1_ullong != temp2_ullong) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
+ parallel_print(ULLI_FORMAT, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong));
}
nfound++;
}
} /*H5T_NATIVE_ULLONG*/
-
break; /* H5T_INTEGER class */
-
- /*-------------------------------------------------------------------------
- * H5T_FLOAT
- *-------------------------------------------------------------------------
- */
-
+ /*-------------------------------------------------------------------------
+ * H5T_FLOAT
+ *-------------------------------------------------------------------------
+ */
case H5T_FLOAT:
-
-
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_FLOAT
- *-------------------------------------------------------------------------
- */
- if (type_size==4)
- {
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_FLOAT
+ *-------------------------------------------------------------------------
+ */
+ if (type_size == 4) {
float temp1_float;
float temp2_float;
- hbool_t isnan1 = FALSE;
- hbool_t isnan2 = FALSE;
+ hbool_t isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
- HDassert(type_size==sizeof(float));
+ if(type_size != sizeof(float))
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not float size");
HDmemcpy(&temp1_float, mem1, sizeof(float));
HDmemcpy(&temp2_float, mem2, sizeof(float));
- /* logic for detecting NaNs is different with options -d, -p and no options */
+ /* logic for detecting NaNs is different with opts -d, -p and no opts */
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
- if (options->d && !options->p)
- {
-
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
- isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
+ if (opts->d && !opts->p) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
+ isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
}
- /* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
-
- if (ABS(temp1_float-temp2_float) > (float)options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ /* 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, index, 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, (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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, 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, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
nfound++;
-
}
}
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!options->d && options->p)
- {
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
- isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
+ /*-------------------------------------------------------------------------
+ * !-d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (!opts->d && opts->p) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
+ isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
+ if (!isnan1 && !isnan2) {
+ PER(temp1_float, temp2_float);
- PER(temp1_float,temp2_float);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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));
+ parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
nfound++;
}
-
- else
-
- if ( per > options->percent && (double)ABS(temp1_float-temp2_float) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent && (double) ABS(temp1_float - temp2_float) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, 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, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
nfound++;
-
}
}
-
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
-
- else if ( options->d && options->p)
- {
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
- isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
+ /*-------------------------------------------------------------------------
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (opts->d && opts->p) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
+ isnan2 = my_isnan(FLT_FLOAT, &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) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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));
+ parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, 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, (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,options)==FALSE)
- {
-
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ /*-------------------------------------------------------------------------
+ * no -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (equal_float(temp1_float, temp2_float, opts) == FALSE) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, 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, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
nfound++;
}
} /*H5T_NATIVE_FLOAT*/
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_DOUBLE
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==8)
- {
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_DOUBLE
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 8) {
double temp1_double;
double temp2_double;
- hbool_t isnan1 = FALSE;
- hbool_t isnan2 = FALSE;
+ hbool_t isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
- HDassert(type_size==sizeof(double));
+ if(type_size != sizeof(double))
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not double size");
HDmemcpy(&temp1_double, mem1, sizeof(double));
HDmemcpy(&temp2_double, mem2, sizeof(double));
- /* logic for detecting NaNs is different with options -d, -p and no options */
-
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
- if (options->d && !options->p)
- {
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE,&temp2_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 = my_isnan(FLT_DOUBLE, &temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
-
- if (ABS(temp1_double-temp2_double) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (!isnan1 && !isnan2) {
+ if (ABS(temp1_double-temp2_double) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, 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, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, 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, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
-
}
- } /* options->d && !options->p */
-
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!options->d && options->p)
- {
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
+ } /* opts->d && !opts->p */
+ /*-------------------------------------------------------------------------
+ * !-d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (!opts->d && opts->p) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double, temp2_double);
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
+ parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, 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, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
-
}
}
-
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if ( options->d && options->p)
- {
-
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (opts->d && opts->p) {
+ /*-------------------------------------------------------------------------
* detect NaNs
*-------------------------------------------------------------------------
*/
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
-
- PER(temp1_double,temp2_double);
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double, temp2_double);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
+ parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
-
- else
-
- if ( per > options->percent &&
- ABS(temp1_double-temp2_double) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,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++;
+ else if (per > opts->percent &&
+ ABS(temp1_double-temp2_double) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, 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, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
}
-
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else if (equal_double(temp1_double,temp2_double,options)==FALSE)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ /*-------------------------------------------------------------------------
+ * no -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (equal_double(temp1_double, temp2_double, opts) == FALSE) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, 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, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
} /*H5T_NATIVE_DOUBLE*/
-#if H5_SIZEOF_LONG_DOUBLE !=0
-
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_LDOUBLE
- *-------------------------------------------------------------------------
- */
+#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE
- else if (type_size==8)
- {
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_LDOUBLE
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == H5_SIZEOF_LONG_DOUBLE) {
long double temp1_double;
long double temp2_double;
- hbool_t isnan1 = FALSE;
- hbool_t isnan2 = FALSE;
+ hbool_t isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
-
- HDassert(type_size == sizeof(long double));
+ if(type_size != sizeof(long double)) {
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "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 (options->d && !options->p)
- {
+ /* logic for detecting NaNs is different with options -d, -p and no options */
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
+ if (opts->d && !opts->p) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
-
- if (ABS(temp1_double-temp2_double) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (!isnan1 && !isnan2) {
+ if (ABS(temp1_double-temp2_double) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(LD_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
+ 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, 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, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
}
-
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!options->d && options->p)
- {
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
+ /*-------------------------------------------------------------------------
+ * !-d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (!opts->d && opts->p) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double);
+ isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
-
+ if (!isnan1 && !isnan2) {
PER(temp1_double,temp2_double);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(LD_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
+ parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,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++;
+ else if (per > opts->percent) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, 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, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
}
-
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if ( options->d && options->p)
- {
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
+ /*-------------------------------------------------------------------------
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (opts->d && opts->p) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double);
+ isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
-
+ if (!isnan1 && !isnan2) {
PER(temp1_double,temp2_double);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ if (not_comparable && !both_zero) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(LD_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
+ parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
-
- else
-
- if ( per > options->percent &&
- ABS(temp1_double-temp2_double) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,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++;
+ else if (per > opts->percent && ABS(temp1_double-temp2_double) > opts->delta) {
+ if (print_data(opts)) {
+ print_pos(ph, 1, index, 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, 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, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
}
-
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else if (equal_ldouble(temp1_double,temp2_double,options)==FALSE)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ /*-------------------------------------------------------------------------
+ * no -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (equal_ldouble(temp1_double, temp2_double, opts) == FALSE) {
+ if (print_data(opts)) {
+ print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2);
parallel_print(SPACES);
- parallel_print(LD_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
+ parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
} /*H5T_NATIVE_LDOUBLE*/
#endif /* H5_SIZEOF_LONG_DOUBLE */
-
-
break; /* H5T_FLOAT class */
} /* switch */
- h5difftrace("diff_datum finish\n");
+
+done:
+ opts->err_stat = opts->err_stat | ret_value;
+
+ h5diffdebug3("diff_datum finish:%d - errstat:%d\n", nfound, opts->err_stat);
return nfound;
- }
+}
/*-------------------------------------------------------------------------
* Function: all_zero
@@ -2758,16 +2115,14 @@ static hsize_t diff_datum(void *_mem1,
* Purpose: Determines if memory is initialized to all zero bytes.
*
* Return: TRUE if all bytes are zero; FALSE otherwise
- *
*-------------------------------------------------------------------------
*/
-static hbool_t all_zero(const void *_mem, size_t size)
-{
- const unsigned char *mem = (const unsigned char *)_mem;
+static hbool_t all_zero(const void *_mem, size_t size) {
+ const unsigned char *mem = (const unsigned char *) _mem;
- while(size-- > 0)
- if(mem[size])
+ while (size-- > 0)
+ if (mem[size])
return FALSE;
return TRUE;
@@ -2779,46 +2134,38 @@ static hbool_t all_zero(const void *_mem, size_t size)
* Purpose: print start coordinates and opposite corner of a region block
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
static
-void print_region_block(int i, hsize_t *ptdata, int ndims)
-{
+void print_region_block(int i, hsize_t *ptdata, int ndims) {
int j;
parallel_print(" ");
for (j = 0; j < ndims; j++)
- parallel_print("%s%lu", j ? "," : " (",
- (unsigned long)ptdata[i * 2 * ndims + j]);
+ parallel_print("%s%lu", j ? "," : " (", (unsigned long) ptdata[i * 2 * ndims + j]);
for (j = 0; j < ndims; j++)
- parallel_print("%s%lu", j ? "," : ")-(",
- (unsigned long)ptdata[i * 2 * ndims + j + ndims]);
+ parallel_print("%s%lu", j ? "," : ")-(", (unsigned long) ptdata[i * 2 * ndims + j + ndims]);
parallel_print(")");
}
-
/*-------------------------------------------------------------------------
* Function: print_points
*
* Purpose: print points of a region reference
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
static
-void print_points(int i, hsize_t *ptdata, int ndims)
-{
+void print_points(int i, hsize_t *ptdata, int ndims) {
int j;
parallel_print(" ");
for (j = 0; j < ndims; j++)
- parallel_print("%s%lu", j ? "," : "(",
- (unsigned long)(ptdata[i * ndims + j]));
+ parallel_print("%s%lu", j ? "," : "(", (unsigned long) (ptdata[i * ndims + j]));
parallel_print(")");
}
@@ -2829,37 +2176,32 @@ void print_points(int i, hsize_t *ptdata, int ndims)
* Purpose: diff a dataspace region
*
* Return: number of differences
- *
*-------------------------------------------------------------------------
*/
-static
-hsize_t diff_region(hid_t obj1_id,
- hid_t obj2_id,
- hid_t region1_id,
- hid_t region2_id,
- diff_opt_t *options)
+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)
{
- hssize_t nblocks1, npoints1;
- hssize_t nblocks2, npoints2;
- hsize_t alloc_size;
- hsize_t *ptdata1;
- hsize_t *ptdata2;
- int ndims1;
- int ndims2;
- int i, j;
- hsize_t nfound_b = 0; /* block differences found */
- hsize_t nfound_p = 0; /* point differences found */
+ hsize_t ret_value = 0;
+ hssize_t nblocks1, npoints1;
+ hssize_t nblocks2, npoints2;
+ hsize_t alloc_size;
+ hsize_t *ptdata1 = NULL;
+ hsize_t *ptdata2 = NULL;
+ int ndims1;
+ int ndims2;
+ int i, j;
+ hsize_t nfound_b = 0; /* block differences found */
+ hsize_t nfound_p = 0; /* point differences found */
ndims1 = H5Sget_simple_extent_ndims(region1_id);
ndims2 = H5Sget_simple_extent_ndims(region2_id);
/*
- * These two functions fail if the region does not have blocks or points,
- * respectively. They do not currently know how to translate from one to
- * the other.
- */
+ * These two functions fail if the region does not have blocks or points,
+ * respectively. They do not currently know how to translate from one to
+ * the other.
+ */
H5E_BEGIN_TRY {
nblocks1 = H5Sget_select_hyper_nblocks(region1_id);
nblocks2 = H5Sget_select_hyper_nblocks(region2_id);
@@ -2868,179 +2210,182 @@ hsize_t diff_region(hid_t obj1_id,
npoints2 = H5Sget_select_elem_npoints(region2_id);
} H5E_END_TRY;
- if(nblocks1 != nblocks2 || npoints1 != npoints2 || ndims1 != ndims2) {
- options->not_cmp = 1;
- return 0;
+ if (nblocks1 != nblocks2 || npoints1 != npoints2 || ndims1 != ndims2) {
+ opts->not_cmp = 1;
+ HGOTO_DONE (0);
}
/*-------------------------------------------------------------------------
- * compare block information
- *-------------------------------------------------------------------------
- */
- if(nblocks1 > 0) {
+ * compare block information
+ *-------------------------------------------------------------------------
+ */
+ if (nblocks1 > 0) {
HDassert(ndims1 > 0);
- alloc_size = (hsize_t)nblocks1 * (unsigned)ndims1 * 2 * sizeof(ptdata1[0]);
- HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
-
- ptdata1 = (hsize_t *)HDmalloc((size_t)alloc_size);
- H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t);
- H5Sget_select_hyper_blocklist(region1_id, (hsize_t)0, (hsize_t)nblocks1, ptdata1);
+ alloc_size = (hsize_t) nblocks1 * (unsigned) ndims1 * 2 * sizeof(ptdata1[0]);
+ HDassert(alloc_size == (hsize_t)((size_t )alloc_size)); /*check for overflow*/
- ptdata2 = (hsize_t *)HDmalloc((size_t)alloc_size);
- H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t);
- H5Sget_select_hyper_blocklist(region2_id, (hsize_t)0, (hsize_t)nblocks2, ptdata2);
-
- for (i = 0; i < nblocks1; i++) {
- /* start coordinates and opposite corner */
- for (j = 0; j < ndims1; j++) {
- hsize_t start1, start2, end1, end2;
-
- start1 = ptdata1[i * 2 * ndims1 + j];
- start2 = ptdata2[i * 2 * ndims1 + j];
- end1 = ptdata1[i * 2 * ndims1 + j + ndims1];
- end2 = ptdata2[i * 2 * ndims1 + j + ndims1];
- if (start1 != start2 || end1 != end2)
- nfound_b++;
- }
+ if((ptdata1 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) {
+ opts->err_stat = 1;
+ H5TOOLS_INFO(H5E_tools_min_id_g, "Buffer allocation failed");
}
+ else {
+ H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t);
+ H5Sget_select_hyper_blocklist(region1_id, (hsize_t) 0, (hsize_t) nblocks1, ptdata1);
+ if((ptdata2 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) {
+ opts->err_stat = 1;
+ H5TOOLS_INFO(H5E_tools_min_id_g, "Buffer allocation failed");
+ }
+ else {
+ H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t);
+ H5Sget_select_hyper_blocklist(region2_id, (hsize_t) 0, (hsize_t) nblocks2, ptdata2);
+
+ for (i = 0; i < nblocks1; i++) {
+ /* start coordinates and opposite corner */
+ for (j = 0; j < ndims1; j++) {
+ hsize_t start1, start2, end1, end2;
+
+ start1 = ptdata1[i * 2 * ndims1 + j];
+ start2 = ptdata2[i * 2 * ndims1 + j];
+ end1 = ptdata1[i * 2 * ndims1 + j + ndims1];
+ end2 = ptdata2[i * 2 * ndims1 + j + ndims1];
+ if (start1 != start2 || end1 != end2)
+ nfound_b++;
+ }
+ }
- /* print differences if found */
- if (nfound_b && options->m_verbose) {
- H5O_info_t oi1, oi2;
+ /* print differences if found */
+ if (nfound_b && opts->m_verbose) {
+ H5O_info_t oi1, oi2;
- H5Oget_info(obj1_id, &oi1);
- H5Oget_info(obj2_id, &oi2);
+ H5Oget_info(obj1_id, &oi1);
+ H5Oget_info(obj2_id, &oi2);
- parallel_print("Referenced dataset %lu %lu\n",
- (unsigned long)oi1.addr, (unsigned long)oi2.addr);
- parallel_print("------------------------------------------------------------\n");
+ parallel_print("Referenced dataset %lu %lu\n", (unsigned long) oi1.addr, (unsigned long) oi2.addr);
+ parallel_print( "------------------------------------------------------------\n");
- parallel_print("Region blocks\n");
- for (i = 0; i < nblocks1; i++) {
- parallel_print("block #%d", i);
- print_region_block(i, ptdata1, ndims1);
- print_region_block(i, ptdata2, ndims1);
- parallel_print("\n");
- }
- }
+ parallel_print("Region blocks\n");
+ for (i = 0; i < nblocks1; i++) {
+ parallel_print("block #%d", i);
+ print_region_block(i, ptdata1, ndims1);
+ print_region_block(i, ptdata2, ndims1);
+ parallel_print("\n");
+ }
+ }
+ HDfree(ptdata2);
+ } /* else ptdata2 */
- HDfree(ptdata1);
- HDfree(ptdata2);
+ HDfree(ptdata1);
+ } /* else ptdata1 */
}
/*-------------------------------------------------------------------------
- * compare point information
- *-------------------------------------------------------------------------
- */
- if(npoints1 > 0) {
- alloc_size = (hsize_t)npoints1 * (unsigned)ndims1 * sizeof(ptdata1[0]);
- HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
-
- ptdata1 = (hsize_t *)HDmalloc((size_t)alloc_size);
- H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t);
- H5Sget_select_elem_pointlist(region1_id, (hsize_t)0, (hsize_t)npoints1, ptdata1);
-
- ptdata2 = (hsize_t *)HDmalloc((size_t)alloc_size);
- H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t);
- H5Sget_select_elem_pointlist(region2_id, (hsize_t)0, (hsize_t)npoints2, ptdata2);
+ * compare point information
+ *-------------------------------------------------------------------------
+ */
+ if (npoints1 > 0) {
+ alloc_size = (hsize_t) npoints1 * (unsigned) ndims1 * sizeof(ptdata1[0]);
+ HDassert(alloc_size == (hsize_t)((size_t )alloc_size)); /*check for overflow*/
- for(i = 0; i < npoints1; i++) {
- hsize_t pt1, pt2;
+ if((ptdata1 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) {
+ opts->err_stat = 1;
+ H5TOOLS_INFO(H5E_tools_min_id_g, "Buffer allocation failed");
+ }
+ else {
+ H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t);
+ H5Sget_select_elem_pointlist(region1_id, (hsize_t) 0, (hsize_t) npoints1, ptdata1);
- for(j = 0; j < ndims1; j++) {
- pt1 = ptdata1[i * ndims1 + j];
- pt2 = ptdata2[i * ndims1 + j];
- if(pt1 != pt2)
- nfound_p++;
+ if((ptdata2 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) {
+ opts->err_stat = 1;
+ H5TOOLS_INFO(H5E_tools_min_id_g, "Buffer allocation failed");
}
- }
+ else {
+ H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t);
+ H5Sget_select_elem_pointlist(region2_id, (hsize_t) 0, (hsize_t) npoints2, ptdata2);
+
+ for (i = 0; i < npoints1; i++) {
+ hsize_t pt1, pt2;
- if(nfound_p && options->m_verbose) {
- parallel_print("Region points\n");
- for(i = 0; i < npoints1; i++) {
- hsize_t pt1, pt2;
- int diff_data = 0;
-
- for(j = 0; j < ndims1; j++) {
- pt1 = ptdata1[i * ndims1 + j];
- pt2 = ptdata2[i * ndims1 + j];
- if(pt1 != pt2) {
- diff_data = 1;
- break;
+ for (j = 0; j < ndims1; j++) {
+ pt1 = ptdata1[i * ndims1 + j];
+ pt2 = ptdata2[i * ndims1 + j];
+ if (pt1 != pt2)
+ nfound_p++;
}
}
- if(diff_data) {
- parallel_print("point #%d", i);
- print_points(i, ptdata1, ndims1);
- print_points(i, ptdata2, ndims1);
- parallel_print("\n");
- }
- }
- }
+ if (nfound_p && opts->m_verbose) {
+ parallel_print("Region points\n");
+ for (i = 0; i < npoints1; i++) {
+ hsize_t pt1, pt2;
+ int diff_data = 0;
-#if defined (H5DIFF_DEBUG)
- for (i = 0; i < npoints1; i++) {
- int j;
+ for (j = 0; j < ndims1; j++) {
+ pt1 = ptdata1[i * ndims1 + j];
+ pt2 = ptdata2[i * ndims1 + j];
+ if (pt1 != pt2) {
+ diff_data = 1;
+ break;
+ }
+ }
+ if (diff_data) {
+ parallel_print("point #%d", i);
+ print_points(i, ptdata1, ndims1);
+ print_points(i, ptdata2, ndims1);
+ parallel_print("\n");
+ }
+ }
+ }
+ HDfree(ptdata2);
+ } /* else ptdata2 */
- parallel_print("%sPt%lu: " , i ? "," : "", (unsigned long)i);
+#if defined (H5DIFF_DEBUG)
+ for (i = 0; i < npoints1; i++) {
+ parallel_print("%sPt%lu: " , i ? "," : "", (unsigned long)i);
- for (j = 0; j < ndims1; j++)
- parallel_print("%s%lu", j ? "," : "(",
- (unsigned long)(ptdata1[i * ndims1 + j]));
+ for (j = 0; j < ndims1; j++)
+ parallel_print("%s%lu", j ? "," : "(", (unsigned long)(ptdata1[i * ndims1 + j]));
- parallel_print(")");
- }
+ parallel_print(")");
+ }
#endif
- HDfree(ptdata1);
- HDfree(ptdata2);
+ HDfree(ptdata1);
+ } /* else ptdata1 */
}
- nfound_b = nfound_b / (unsigned)ndims1;
- nfound_p = nfound_p / (unsigned)ndims1;
- return (nfound_p + nfound_b);
-}
+ nfound_b = nfound_b / (unsigned) ndims1;
+ nfound_p = nfound_p / (unsigned) ndims1;
+
+ ret_value = nfound_p + nfound_b;
+done:
+ return ret_value;
+}
/*-------------------------------------------------------------------------
* Function: character_compare
*
- * Purpose: do a byte-by-byte comparison and print in char format
- *
- * Return: number of differences found
+ * Purpose: do a byte-by-byte comparison and print in char format
*
+ * Return: number of differences found
*-------------------------------------------------------------------------
*/
-static
-hsize_t character_compare(char *mem1,
- char *mem2,
- hsize_t i,
- unsigned u,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, unsigned u,
+ int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph)
{
- hsize_t nfound=0; /* differences found */
- char temp1_uchar;
- char temp2_uchar;
+ hsize_t nfound = 0; /* differences found */
+ char temp1_uchar;
+ char temp2_uchar;
HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
h5diffdebug3("character_compare start %d=%d\n",temp1_uchar,temp2_uchar);
- if (temp1_uchar != temp2_uchar)
- {
- if ( print_data(options) )
- {
- print_char_pos(ph,0,i,u,acc,pos,rank,dims,obj1,obj2);
+ if (temp1_uchar != temp2_uchar) {
+ if (print_data(opts)) {
+ print_char_pos(ph, 0, i, u, acc, pos, rank, dims, obj1, obj2);
parallel_print(" ");
h5diff_print_char(temp1_uchar);
parallel_print(" ");
@@ -3054,34 +2399,23 @@ hsize_t character_compare(char *mem1,
return nfound;
}
-
/*-------------------------------------------------------------------------
* Function: character_compare_opt
*
- * Purpose: do a byte-by-byte comparison and print in numerical format
- *
- * Return: number of differences found
+ * Purpose: do a byte-by-byte comparison and print in numerical format
*
+ * Return: number of differences found
*-------------------------------------------------------------------------
*/
-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 *options,
- 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)
{
- hsize_t nfound=0; /* differences found */
- unsigned char temp1_uchar;
- unsigned char temp2_uchar;
- double per;
- hbool_t both_zero;
+ hsize_t nfound = 0; /* differences found */
+ unsigned char temp1_uchar;
+ unsigned char temp2_uchar;
+ double per;
+ hbool_t both_zero;
HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
@@ -3089,650 +2423,501 @@ static hsize_t character_compare_opt(unsigned char *mem1,
h5difftrace("character_compare_opt start\n");
/* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_uchar,temp2_uchar) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ if (opts->d && !opts->p) {
+ if (PDIFF(temp1_uchar,temp2_uchar) > opts->delta) {
+ 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));
+ parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (!opts->d && opts->p) {
+ PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
+ if (per > opts->percent) {
+ 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);
+ parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per);
}
nfound++;
}
}
/* -d and -p */
- else if ( options->d && options->p)
- {
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
- if ( per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ else if (opts->d && opts->p) {
+ PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
+ if (per > opts->percent && PDIFF(temp1_uchar,temp2_uchar) > opts->delta) {
+ 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);
+ 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(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ else if (temp1_uchar != temp2_uchar) {
+ 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));
+ parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
- }
- h5difftrace("character_compare_opt finish\n");
+ } h5difftrace("character_compare_opt finish\n");
return nfound;
-
}
-
/*-------------------------------------------------------------------------
* Function: diff_float
*
- * Purpose: diff a H5T_NATIVE_FLOAT type
- *
- * Return: number of differences found
+ * Purpose: diff a 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 *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+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)
{
- 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 isnan1 = FALSE;
- hbool_t isnan2 = FALSE;
+ 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 isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
h5difftrace("diff_float start\n");
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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 ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
- isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
+ isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
- if ((double)ABS(temp1_float-temp2_float) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ 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(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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, (double)temp1_float, (double)temp2_float, (double)ABS(temp1_float - temp2_float));
+ parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
nfound++;
}
- mem1+=sizeof(float);
- mem2+=sizeof(float);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(float);
+ mem2 += sizeof(float);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* i */
}
-
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ /*-------------------------------------------------------------------------
+ * !-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 ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
- isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
+ isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
}
/* both not NaN, do the comparison */
- if ( (!isnan1 && !isnan2))
- {
-
- PER(temp1_float,temp2_float);
+ if ((!isnan1 && !isnan2)) {
+ PER(temp1_float, temp2_float);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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++;
+ }
}
/* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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, (double)temp1_float, (double)temp2_float, (double)ABS(temp1_float - temp2_float));
+ parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
nfound++;
}
- mem1+=sizeof(float);
- mem2+=sizeof(float);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(float);
+ mem2 += sizeof(float);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* i */
}
-
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
+ /*-------------------------------------------------------------------------
+ * -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 ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
- isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
+ isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
-
- PER(temp1_float,temp2_float);
+ if (!isnan1 && !isnan2) {
+ PER(temp1_float, temp2_float);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
nfound++;
}
-
- else
-
- if ( per > options->percent && (double)ABS(temp1_float - temp2_float) > options->delta )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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++;
+ }
}
/* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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, (double)temp1_float, (double)temp2_float, (double)ABS(temp1_float - temp2_float));
+ parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
nfound++;
}
- mem1+=sizeof(float);
- mem2+=sizeof(float);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(float);
+ mem2 += sizeof(float);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* i */
}
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else
- {
- for ( i = 0; i < nelmts; i++)
- {
+ /*-------------------------------------------------------------------------
+ * 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,options)==FALSE)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float));
}
nfound++;
}
- mem1+=sizeof(float);
- mem2+=sizeof(float);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(float);
+ mem2 += sizeof(float);
+ if (opts->n && nfound >= opts->count)
return nfound;
-
} /* nelmts */
-
-
-
-
-
}
h5difftrace("diff_float finish\n");
return nfound;
}
-
/*-------------------------------------------------------------------------
* Function: diff_double
*
- * Purpose: diff a H5T_NATIVE_DOUBLE type
- *
- * Return: number of differences found
+ * Purpose: diff a 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 *options,
- 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)
{
- 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 isnan1 = FALSE;
- hbool_t isnan2 = FALSE;
+ 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 isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
h5difftrace("diff_double start\n");
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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 ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
- if (ABS(temp1_double-temp2_double) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ 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(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
- mem1+=sizeof(double);
- mem2+=sizeof(double);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(double);
+ mem2 += sizeof(double);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* i */
}
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ /*-------------------------------------------------------------------------
+ * !-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 ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
-
- PER(temp1_double,temp2_double);
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double, temp2_double);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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++;
+ }
}
/* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
- mem1+=sizeof(double);
- mem2+=sizeof(double);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(double);
+ mem2 += sizeof(double);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* i */
}
+ /*-------------------------------------------------------------------------
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (opts->d && opts->p) {
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
+ for (i = 0; i < nelmts; i++) {
HDmemcpy(&temp1_double, mem1, sizeof(double));
HDmemcpy(&temp2_double, mem2, sizeof(double));
/*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
-
- PER(temp1_double,temp2_double);
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double, temp2_double);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
-
- else
-
- if ( per > options->percent && ABS(temp1_double-temp2_double) > options->delta )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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++;
+ }
}
/* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
-
}
- mem1+=sizeof(double);
- mem2+=sizeof(double);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(double);
+ mem2 += sizeof(double);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* i */
}
-
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else
- {
-
-
-
- for ( i = 0; i < nelmts; i++)
- {
+ /*-------------------------------------------------------------------------
+ * 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,options)==FALSE)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
- mem1+=sizeof(double);
- mem2+=sizeof(double);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(double);
+ mem2 += sizeof(double);
+ if (opts->n && nfound >= opts->count)
return nfound;
-
} /* nelmts */
-
-
-
-
-
}
h5difftrace("diff_double finish\n");
return nfound;
}
-
-
-
-
/*-------------------------------------------------------------------------
* Function: diff_ldouble
*
- * Purpose: diff a H5T_NATIVE_LDOUBLE type
- *
- * Return: number of differences found
+ * Purpose: diff a 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 *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+ 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)
{
- hsize_t nfound=0; /* number of differences found */
+ hsize_t nfound = 0; /* number of differences found */
long double temp1_double;
long double temp2_double;
hsize_t i;
@@ -3743,245 +2928,183 @@ static hsize_t diff_ldouble(unsigned char *mem1,
h5difftrace("diff_ldouble start\n");
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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 ( options->do_nans )
- {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
- if (ABS(temp1_double-temp2_double) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ 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(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
- mem1+=sizeof(long double);
- mem2+=sizeof(long double);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(long double);
+ mem2 += sizeof(long double);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* i */
}
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ /*-------------------------------------------------------------------------
+ * !-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 ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double);
+ isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
-
- PER(temp1_double,temp2_double);
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double, temp2_double);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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++;
+ }
}
/* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
-
}
- mem1+=sizeof(long double);
- mem2+=sizeof(long double);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(long double);
+ mem2 += sizeof(long double);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* i */
}
-
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
+ /*-------------------------------------------------------------------------
+ * -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 ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double);
+ isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double);
}
/* both not NaN, do the comparison */
- if ( !isnan1 && !isnan2)
- {
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double, temp2_double);
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
-
- else
-
- if ( per > options->percent && ABS(temp1_double-temp2_double) > options->delta )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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++;
+ }
}
/* only one is NaN, assume difference */
- else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
-
}
- mem1+=sizeof(long double);
- mem2+=sizeof(long double);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(long double);
+ mem2 += sizeof(long double);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* i */
}
-
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else
- {
-
-
-
- for ( i = 0; i < nelmts; i++)
- {
+ /*-------------------------------------------------------------------------
+ * 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,options)==FALSE)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
-
- mem1+=sizeof(long double);
- mem2+=sizeof(long double);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(long double);
+ mem2 += sizeof(long double);
+ if (opts->n && nfound >= opts->count)
return nfound;
-
} /* nelmts */
-
-
-
-
-
}
h5difftrace("diff_ldouble finish\n");
@@ -3989,209 +3112,147 @@ static hsize_t diff_ldouble(unsigned char *mem1,
}
#endif /* H5_SIZEOF_LONG_DOUBLE */
-
-
-
-
-
/*-------------------------------------------------------------------------
* Function: diff_schar
*
- * Purpose: diff a H5T_NATIVE_SCHAR type
- *
- * Return: number of differences found
+ * Purpose: diff a 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 *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+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)
{
- hsize_t nfound=0; /* number of differences found */
- char temp1_char;
- char temp2_char;
- hsize_t i;
- double per;
- hbool_t both_zero;
+ hsize_t nfound = 0; /* number of differences found */
+ char temp1_char;
+ char temp2_char;
+ hsize_t i;
+ double per;
+ hbool_t both_zero;
h5difftrace("diff_schar start\n");
-
/* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
+ if (opts->d && !opts->p) {
+ for (i = 0; i < nelmts; i++) {
HDmemcpy(&temp1_char, mem1, sizeof(char));
HDmemcpy(&temp2_char, mem2, sizeof(char));
- if (ABS(temp1_char-temp2_char) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
}
nfound++;
}
- mem1+=sizeof(char);
- mem2+=sizeof(char);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(char);
+ mem2 += sizeof(char);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
-
/* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER(temp1_char, temp2_char);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
}
nfound++;
}
- else
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(char);
- mem2+=sizeof(char);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(char);
+ mem2 += sizeof(char);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
-
/* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER(temp1_char, temp2_char);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
}
nfound++;
}
- else
- if ( per > options->percent && ABS(temp1_char-temp2_char) > options->delta )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(char);
- mem2+=sizeof(char);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(char);
+ mem2 += sizeof(char);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
-
}
- else
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
}
nfound++;
}
- mem1+=sizeof(char);
- mem2+=sizeof(char);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(char);
+ mem2 += sizeof(char);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* nelmts */
-
}
h5difftrace("diff_schar finish\n");
return nfound;
}
-
-
/*-------------------------------------------------------------------------
* Function: diff_uchar
*
- * Purpose: diff a H5T_NATIVE_UCHAR type
- *
- * Return: number of differences found
+ * Purpose: diff a 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 *options,
- 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)
{
- hsize_t nfound=0; /* number of differences found */
+ hsize_t nfound = 0; /* number of differences found */
unsigned char temp1_uchar;
unsigned char temp2_uchar;
hsize_t i;
@@ -4199,137 +3260,105 @@ static hsize_t diff_uchar(unsigned char *mem1,
hbool_t both_zero;
h5difftrace("diff_uchar start\n");
-
/* -d and !-p */
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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));
- if ( PDIFF(temp1_uchar,temp2_uchar) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
}
- mem1+=sizeof(unsigned char);
- mem2+=sizeof(unsigned char);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(unsigned char);
+ mem2 += sizeof(unsigned char);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
-
/* !-d and -p */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
}
- else
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(unsigned char);
- mem2+=sizeof(unsigned char);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(unsigned char);
+ mem2 += sizeof(unsigned char);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
-
/* -d and -p */
- else if ( options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
}
- else
- if ( per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(unsigned char);
- mem2+=sizeof(unsigned char);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(unsigned char);
+ mem2 += sizeof(unsigned char);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
- else
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
}
- mem1+=sizeof(unsigned char);
- mem2+=sizeof(unsigned char);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(unsigned char);
+ mem2 += sizeof(unsigned char);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* nelmts */
-
}
h5difftrace("diff_uchar finish\n");
@@ -4339,161 +3368,121 @@ static hsize_t diff_uchar(unsigned char *mem1,
/*-------------------------------------------------------------------------
* Function: diff_short
*
- * Purpose: diff a H5T_NATIVE_SHORT type
- *
- * Return: number of differences found
+ * 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 *options,
- 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)
{
- hsize_t nfound=0; /* number of differences found */
- short temp1_short;
- short temp2_short;
- hsize_t i;
- double per;
- hbool_t both_zero;
+ hsize_t nfound = 0; /* number of differences found */
+ short temp1_short;
+ short temp2_short;
+ hsize_t i;
+ double per;
+ hbool_t both_zero;
h5difftrace("diff_short start\n");
/* -d and !-p */
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ if (opts->d && !opts->p) {
+ for (i = 0; i < nelmts; i++) {
HDmemcpy(&temp1_short, mem1, sizeof(short));
HDmemcpy(&temp2_short, mem2, sizeof(short));
- if (ABS(temp1_short-temp2_short) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
}
nfound++;
}
- mem1+=sizeof(short);
- mem2+=sizeof(short);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(short);
+ mem2 += sizeof(short);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
-
/* !-d and -p */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER(temp1_short, temp2_short);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
}
nfound++;
}
- else
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(short);
- mem2+=sizeof(short);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(short);
+ mem2 += sizeof(short);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
-
/* -d and -p */
- else if ( options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER(temp1_short, temp2_short);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
}
nfound++;
}
- else
- if ( per > options->percent && ABS(temp1_short-temp2_short) > options->delta )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(short);
- mem2+=sizeof(short);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(short);
+ mem2 += sizeof(short);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
- else
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
}
nfound++;
}
- mem1+=sizeof(short);
- mem2+=sizeof(short);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(short);
+ mem2 += sizeof(short);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* nelmts */
}
@@ -4502,31 +3491,21 @@ static hsize_t diff_short(unsigned char *mem1,
return nfound;
}
-
/*-------------------------------------------------------------------------
* Function: diff_ushort
*
- * Purpose: diff a H5T_NATIVE_USHORT type
- *
- * Return: number of differences found
+ * Purpose: diff a 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 *options,
- 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)
{
- hsize_t nfound=0; /* number of differences found */
+ hsize_t nfound = 0; /* number of differences found */
unsigned short temp1_ushort;
unsigned short temp2_ushort;
hsize_t i;
@@ -4535,460 +3514,355 @@ static hsize_t diff_ushort(unsigned char *mem1,
h5difftrace("diff_ushort start\n");
/* -d and !-p */
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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));
- if ( PDIFF(temp1_ushort,temp2_ushort) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
}
nfound++;
}
- mem1+=sizeof(unsigned short);
- mem2+=sizeof(unsigned short);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(unsigned short);
+ mem2 += sizeof(unsigned short);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER_UNSIGN(signed short, temp1_ushort, temp2_ushort);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
}
nfound++;
}
- else
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(unsigned short);
- mem2+=sizeof(unsigned short);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(unsigned short);
+ mem2 += sizeof(unsigned short);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
/* -d and -p */
- else if ( options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER_UNSIGN(signed short, temp1_ushort, temp2_ushort);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
}
nfound++;
}
- else
- if ( per > options->percent && PDIFF(temp1_ushort,temp2_ushort) > options->delta )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(unsigned short);
- mem2+=sizeof(unsigned short);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(unsigned short);
+ mem2 += sizeof(unsigned short);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
- else
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
}
nfound++;
}
- mem1+=sizeof(unsigned short);
- mem2+=sizeof(unsigned short);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(unsigned short);
+ mem2 += sizeof(unsigned short);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* nelmts */
-
}
h5difftrace("diff_ushort finish\n");
return nfound;
}
-
/*-------------------------------------------------------------------------
- * Function: diff_int
- *
- * Purpose: diff a H5T_NATIVE_INT type
+ * Function: diff_int
*
- * Return: number of differences found
+ * Purpose: diff a 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 *options,
- 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)
{
- hsize_t nfound=0; /* number of differences found */
- int temp1_int;
- int temp2_int;
- hsize_t i;
- double per;
- hbool_t both_zero;
+ hsize_t nfound = 0; /* number of differences found */
+ int temp1_int;
+ int temp2_int;
+ hsize_t i;
+ double per;
+ hbool_t both_zero;
h5difftrace("diff_int start\n");
/* -d and !-p */
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ if (opts->d && !opts->p) {
+ for (i = 0; i < nelmts; i++) {
HDmemcpy(&temp1_int, mem1, sizeof(int));
HDmemcpy(&temp2_int, mem2, sizeof(int));
- if (ABS(temp1_int-temp2_int) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
}
nfound++;
}
- mem1+=sizeof(int);
- mem2+=sizeof(int);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(int);
+ mem2 += sizeof(int);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER(temp1_int, temp2_int);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
}
nfound++;
}
- else
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(int);
- mem2+=sizeof(int);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(int);
+ mem2 += sizeof(int);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
/* -d and -p */
- else if ( options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER(temp1_int, temp2_int);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
}
nfound++;
}
- else
- if ( per > options->percent && ABS(temp1_int-temp2_int) > options->delta )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(int);
- mem2+=sizeof(int);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(int);
+ mem2 += sizeof(int);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
- else
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
}
nfound++;
}
- mem1+=sizeof(int);
- mem2+=sizeof(int);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(int);
+ mem2 += sizeof(int);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* nelmts */
}
h5difftrace("diff_int finish\n");
-
return nfound;
}
-
/*-------------------------------------------------------------------------
* Function: diff_uint
*
- * Purpose: diff a H5T_NATIVE_UINT type
- *
- * Return: number of differences found
+ * Purpose: diff a 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 *options,
- 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)
{
- 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;
+ 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;
h5difftrace("diff_uint start\n");
/* -d and !-p */
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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));
- if ( PDIFF(temp1_uint,temp2_uint) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
}
nfound++;
}
- mem1+=sizeof(unsigned int);
- mem2+=sizeof(unsigned int);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(unsigned int);
+ mem2 += sizeof(unsigned int);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER_UNSIGN(signed int, temp1_uint, temp2_uint);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
}
nfound++;
}
- else
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(unsigned int);
- mem2+=sizeof(unsigned int);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(unsigned int);
+ mem2 += sizeof(unsigned int);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
/* -d and -p */
- else if ( options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER_UNSIGN(signed int, temp1_uint, temp2_uint);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
}
nfound++;
}
- else
- if ( per > options->percent && PDIFF(temp1_uint,temp2_uint) > options->delta )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(unsigned int);
- mem2+=sizeof(unsigned int);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(unsigned int);
+ mem2 += sizeof(unsigned int);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
- else
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(I_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
}
nfound++;
}
- mem1+=sizeof(unsigned int);
- mem2+=sizeof(unsigned int);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(unsigned int);
+ mem2 += sizeof(unsigned int);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* nelmts */
}
@@ -4997,334 +3871,256 @@ static hsize_t diff_uint(unsigned char *mem1,
return nfound;
}
-
/*-------------------------------------------------------------------------
* Function: diff_long
*
- * Purpose: diff a H5T_NATIVE_LONG type
- *
- * Return: number of differences found
+ * Purpose: diff a 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 *options,
- 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)
{
- hsize_t nfound=0; /* number of differences found */
- long temp1_long;
- long temp2_long;
- hsize_t i;
- double per;
- hbool_t both_zero;
+ hsize_t nfound = 0; /* number of differences found */
+ long temp1_long;
+ long temp2_long;
+ hsize_t i;
+ double per;
+ hbool_t both_zero;
h5difftrace("diff_long start\n");
/* -d and !-p */
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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));
- if (ABS(temp1_long-temp2_long) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
}
nfound++;
}
- mem1+=sizeof(long);
- mem2+=sizeof(long);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(long);
+ mem2 += sizeof(long);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ else if (!opts->d && opts->p) {
+ for (i = 0; i < nelmts; i++) {
HDmemcpy(&temp1_long, mem1, sizeof(long));
HDmemcpy(&temp2_long, mem2, sizeof(long));
- PER(temp1_long,temp2_long);
+ PER(temp1_long, temp2_long);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
}
nfound++;
}
- else
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(long);
- mem2+=sizeof(long);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(long);
+ mem2 += sizeof(long);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
/* -d and -p */
- else if ( options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ else if (opts->d && opts->p) {
+ for (i = 0; i < nelmts; i++) {
HDmemcpy(&temp1_long, mem1, sizeof(long));
HDmemcpy(&temp2_long, mem2, sizeof(long));
- PER(temp1_long,temp2_long);
+ PER(temp1_long, temp2_long);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
}
nfound++;
}
- else
- if ( per > options->percent && ABS(temp1_long-temp2_long) > options->delta )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(long);
- mem2+=sizeof(long);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(long);
+ mem2 += sizeof(long);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
- else
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
}
nfound++;
}
- mem1+=sizeof(long);
- mem2+=sizeof(long);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(long);
+ mem2 += sizeof(long);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* nelmts */
-
}
h5difftrace("diff_long finish\n");
return nfound;
}
-
/*-------------------------------------------------------------------------
* Function: diff_ulong
*
- * Purpose: diff a H5T_NATIVE_ULONG type
- *
- * Return: number of differences found
+ * Purpose: diff a 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 *options,
- 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)
{
- 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;
+ 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;
h5difftrace("diff_ulong start\n");
/* -d and !-p */
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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));
- if ( PDIFF(temp1_ulong,temp2_ulong) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(LI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
}
nfound++;
}
- mem1+=sizeof(unsigned long);
- mem2+=sizeof(unsigned long);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(unsigned long);
+ mem2 += sizeof(unsigned long);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER_UNSIGN(signed long, temp1_ulong, temp2_ulong);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
}
nfound++;
}
- else
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(unsigned long);
- mem2+=sizeof(unsigned long);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(unsigned long);
+ mem2 += sizeof(unsigned long);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
/* -d and -p */
- else if ( options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER_UNSIGN(signed long, temp1_ulong, temp2_ulong);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
}
nfound++;
}
- else
- if ( per > options->percent && PDIFF(temp1_ulong,temp2_ulong) > options->delta )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(unsigned long);
- mem2+=sizeof(unsigned long);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(unsigned long);
+ mem2 += sizeof(unsigned long);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
- else
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(LI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
}
nfound++;
}
- mem1+=sizeof(unsigned long);
- mem2+=sizeof(unsigned long);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(unsigned long);
+ mem2 += sizeof(unsigned long);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* nelmts */
}
@@ -5333,157 +4129,125 @@ static hsize_t diff_ulong(unsigned char *mem1,
return nfound;
}
-
/*-------------------------------------------------------------------------
* Function: diff_llong
*
- * Purpose: diff a H5T_NATIVE_LLONG type
- *
- * Return: number of differences found
+ * Purpose: diff a 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 *options,
- 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)
{
- 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;
+ 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;
h5difftrace("diff_llong start\n");
/* -d and !-p */
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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));
- if (ABS( temp1_llong-temp2_llong) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
}
nfound++;
}
- mem1+=sizeof(long long);
- mem2+=sizeof(long long);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(long long);
+ mem2 += sizeof(long long);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER(temp1_llong, temp2_llong);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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++;
+ parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
}
- else
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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 (options->n && nfound>=options->count)
- return nfound;
+ 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(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 ( options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ PER(temp1_llong, temp2_llong);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
}
nfound++;
}
- else
- if ( per > options->percent && ABS(temp1_llong-temp2_llong) > options->delta )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(long long);
- mem2+=sizeof(long long);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(long long);
+ mem2 += sizeof(long long);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
- else
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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));
+ parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
}
nfound++;
}
- mem1+=sizeof(long long);
- mem2+=sizeof(long long);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(long long);
+ mem2 += sizeof(long long);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* nelmts */
}
@@ -5492,162 +4256,130 @@ static hsize_t diff_llong(unsigned char *mem1,
return nfound;
}
-
/*-------------------------------------------------------------------------
* Function: diff_ullong
*
- * Purpose: diff a H5T_NATIVE_ULLONG type
- *
- * Return: number of differences found
+ * Purpose: diff a 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 *options,
- 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)
{
- 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;
+ 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;
h5difftrace("diff_ullong start\n");
/* -d and !-p */
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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));
- if ( PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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++;
}
- mem1+=sizeof(unsigned long long);
- mem2+=sizeof(unsigned long long);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(unsigned long long);
+ mem2 += sizeof(unsigned long long);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ ull2float(temp1_ullong, &f1);
+ ull2float(temp2_ullong, &f2);
+ PER(f1, f2);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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 ( per > options->percent )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(unsigned long long);
- mem2+=sizeof(unsigned long long);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(unsigned long long);
+ mem2 += sizeof(unsigned long long);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
/* -d and -p */
- else if ( options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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);
+ ull2float(temp1_ullong, &f1);
+ ull2float(temp2_ullong, &f2);
+ PER(f1, f2);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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 ( per > options->percent && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long)options->delta )
- {
- if ( print_data(options) )
- {
- 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++;
+ 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);
}
- mem1+=sizeof(unsigned long long);
- mem2+=sizeof(unsigned long long);
- if (options->n && nfound>=options->count)
+ nfound++;
+ }
+ mem1 += sizeof(unsigned long long);
+ mem2 += sizeof(unsigned long long);
+ if (opts->n && nfound >= opts->count)
return nfound;
}
}
- else
- {
- for ( i = 0; i < nelmts; i++)
- {
+ 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(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ 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++;
}
- mem1+=sizeof(unsigned long long);
- mem2+=sizeof(unsigned long long);
- if (options->n && nfound>=options->count)
+ mem1 += sizeof(unsigned long long);
+ mem2 += sizeof(unsigned long long);
+ if (opts->n && nfound >= opts->count)
return nfound;
} /* nelmts */
}
@@ -5656,114 +4388,89 @@ static hsize_t diff_ullong(unsigned char *mem1,
return nfound;
}
-
/*-------------------------------------------------------------------------
* Function: ull2float
*
* Purpose: convert unsigned long long to float
- *
- * Programmer: pvn
- * Mar 22, 2006
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static
int ull2float(unsigned long long ull_value, float *f_value)
{
- hid_t dxpl_id;
- unsigned char *buf = NULL;
+ int ret_value = SUCCEED;
+ hid_t dxpl_id = -1;
+ unsigned char *buf = NULL;
size_t src_size;
size_t dst_size;
h5difftrace("ull2float start\n");
- if((dxpl_id = H5Pcreate(H5P_DATASET_XFER))<0)
- goto error;
+ if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
src_size = H5Tget_size(H5T_NATIVE_ULLONG);
dst_size = H5Tget_size(H5T_NATIVE_FLOAT);
- buf = (unsigned char*)HDcalloc((size_t)1, MAX(src_size, dst_size));
- if(!buf)
- goto error;
+ if((buf = (unsigned char*) HDcalloc((size_t )1, MAX(src_size, dst_size))) == NULL)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
HDmemcpy(buf, &ull_value, src_size);
/* do conversion */
- if(H5Tconvert(H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT, (size_t)1, buf, NULL, dxpl_id)<0)
- goto error;
+ if (H5Tconvert(H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT, (size_t) 1, buf, NULL, dxpl_id) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tconvert failed");
HDmemcpy(f_value, buf, dst_size);
- if(buf)
- HDfree(buf);
- h5difftrace("ull2float finish\n");
-
- return 0;
-
-error:
+done:
H5E_BEGIN_TRY {
H5Pclose(dxpl_id);
} H5E_END_TRY;
- if(buf)
+
+ if (buf)
HDfree(buf);
- h5difftrace("ull2float errored\n");
- return -1;
-}
+ h5difftrace("ull2float finish\n");
+ return ret_value;
+}
/*-------------------------------------------------------------------------
* Function: equal_double
*
- * Purpose: use a absolute error formula to deal with floating point
- * uncertainty
- *
- * Modifications:
- * 8/1/2007. handle NaNs
- *
+ * Purpose: use a absolute error formula to deal with floating point uncertainty
*-------------------------------------------------------------------------
*/
-static
-hbool_t equal_double(double value, double expected, diff_opt_t *options)
-{
+static hbool_t equal_double(double value, double expected, diff_opt_t *opts) {
h5difftrace("equal_double start\n");
- if ( options->do_nans )
- {
-
+ if (opts->do_nans) {
/*-------------------------------------------------------------------------
* detect NaNs
*-------------------------------------------------------------------------
*/
- hbool_t isnan1 = my_isnan(FLT_DOUBLE,&value);
- hbool_t isnan2 = my_isnan(FLT_DOUBLE,&expected);
+ hbool_t isnan1 = my_isnan(FLT_DOUBLE, &value);
+ hbool_t isnan2 = my_isnan(FLT_DOUBLE, &expected);
/*-------------------------------------------------------------------------
* we consider NaN == NaN to be true
*-------------------------------------------------------------------------
*/
- if ( isnan1 && isnan2 )
- {
+ if (isnan1 && isnan2)
return TRUE;
- }
/*-------------------------------------------------------------------------
* one is a NaN, do not compare but assume difference
*-------------------------------------------------------------------------
*/
- if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) )
- {
+ if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
return FALSE;
- }
}
if (value == expected)
return TRUE;
- if (options->use_system_epsilon) {
- if ( ABS( (value-expected) ) < DBL_EPSILON)
+ if (opts->use_system_epsilon)
+ if (ABS((value-expected)) < DBL_EPSILON)
return TRUE;
- }
+
h5difftrace("equal_double finish\n");
return FALSE;
@@ -5772,53 +4479,45 @@ hbool_t equal_double(double value, double expected, diff_opt_t *options)
/*-------------------------------------------------------------------------
* Function: equal_ldouble
*
- * Purpose: use a absolute error formula to deal with floating point
- * uncertainty
- *
+ * Purpose: use a absolute error formula to deal with floating point uncertainty
*-------------------------------------------------------------------------
*/
#if H5_SIZEOF_LONG_DOUBLE !=0
static
-hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *options)
+hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts)
{
h5difftrace("equal_ldouble start\n");
- if ( options->do_nans )
- {
-
+ if (opts->do_nans) {
/*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- hbool_t isnan1 = my_isnan(FLT_LDOUBLE,&value);
- hbool_t isnan2 = my_isnan(FLT_LDOUBLE,&expected);
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ hbool_t isnan1 = my_isnan(FLT_LDOUBLE, &value);
+ hbool_t isnan2 = my_isnan(FLT_LDOUBLE, &expected);
/*-------------------------------------------------------------------------
- * we consider NaN == NaN to be true
- *-------------------------------------------------------------------------
- */
- if ( isnan1 && isnan2 )
- {
+ * we consider NaN == NaN to be true
+ *-------------------------------------------------------------------------
+ */
+ if (isnan1 && isnan2)
return TRUE;
- }
/*-------------------------------------------------------------------------
- * one is a NaN, do not compare but assume difference
- *-------------------------------------------------------------------------
- */
- if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) )
- {
+ * one is a NaN, do not compare but assume difference
+ *-------------------------------------------------------------------------
+ */
+ if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
return FALSE;
- }
}
if (value == expected)
return TRUE;
- if (options->use_system_epsilon) {
- if ( ABS( (value-expected) ) < DBL_EPSILON)
+ if (opts->use_system_epsilon)
+ if (ABS((value-expected)) < DBL_EPSILON)
return TRUE;
- }
+
h5difftrace("equal_ldouble finish\n");
return FALSE;
@@ -5826,106 +4525,76 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio
#endif /* #if H5_SIZEOF_LONG_DOUBLE !=0 */
-
/*-------------------------------------------------------------------------
* Function: equal_float
*
- * Purpose: use a absolute error formula to deal with floating point
- * uncertainty
- *
- * Modifications:
- * 8/1/2007. handle NaNs
- *
+ * Purpose: use a absolute error formula to deal with floating point uncertainty
*-------------------------------------------------------------------------
*/
-static
-hbool_t equal_float(float value, float expected, diff_opt_t *options)
-{
+static hbool_t equal_float(float value, float expected, diff_opt_t *opts) {
h5difftrace("equal_float start\n");
- if ( options->do_nans )
- {
-
+ if (opts->do_nans) {
/*-------------------------------------------------------------------------
* detect NaNs
*-------------------------------------------------------------------------
*/
- hbool_t isnan1 = my_isnan(FLT_FLOAT,&value);
- hbool_t isnan2 = my_isnan(FLT_FLOAT,&expected);
+ hbool_t isnan1 = my_isnan(FLT_FLOAT, &value);
+ hbool_t isnan2 = my_isnan(FLT_FLOAT, &expected);
/*-------------------------------------------------------------------------
- * we consider NaN == NaN to be true
- *-------------------------------------------------------------------------
- */
- if ( isnan1 && isnan2 )
- {
+ * we consider NaN == NaN to be true
+ *-------------------------------------------------------------------------
+ */
+ if (isnan1 && isnan2)
return TRUE;
- }
/*-------------------------------------------------------------------------
- * one is a NaN, do not compare but assume difference
- *-------------------------------------------------------------------------
- */
- if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) )
- {
+ * one is a NaN, do not compare but assume difference
+ *-------------------------------------------------------------------------
+ */
+ if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
return FALSE;
- }
}
if (value == expected)
return TRUE;
- if (options->use_system_epsilon) {
- if ( ABS( (value-expected) ) < FLT_EPSILON)
+ if (opts->use_system_epsilon)
+ if (ABS( (value-expected) ) < FLT_EPSILON)
return TRUE;
- }
+
h5difftrace("equal_float finish\n");
return FALSE;
-
}
-
-
/*-------------------------------------------------------------------------
* Function: my_isnan
*
- * Purpose: Determines whether VAL points to NaN.
- *
- * Return: TRUE or FALSE
- *
- * Programmer: Robb Matzke
- * Monday, July 6, 1998
- *
- * Modifications:
- * Pedro Vicente, 12 October 2007.
- * Add a string detection type for WIN32
+ * Purpose: Determines whether VAL points to NaN.
*
+ * Return: TRUE or FALSE
*-------------------------------------------------------------------------
*/
-static hbool_t
-my_isnan(dtype_t type, void *val)
-{
+static hbool_t my_isnan(dtype_t type, void *val) {
hbool_t retval = FALSE;
char s[256];
h5difftrace("my_isnan start\n");
- if (FLT_FLOAT==type)
- {
+ if (FLT_FLOAT == type) {
float x;
HDmemcpy(&x, val, sizeof(float));
- retval = (x!=x);
+ retval = (x != x);
}
- else if (FLT_DOUBLE==type)
- {
+ else if (FLT_DOUBLE == type) {
double x;
HDmemcpy(&x, val, sizeof(double));
- retval = (x!=x);
+ retval = (x != x);
}
-#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0
- else if (FLT_LDOUBLE==type)
- {
+#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0
+ else if (FLT_LDOUBLE == type) {
long double x;
HDmemcpy(&x, val, sizeof(long double));
@@ -5933,33 +4602,27 @@ my_isnan(dtype_t type, void *val)
}
#endif
else
- {
return FALSE;
- }
- /*
+ /*
* Sometimes NaN==NaN (e.g., DEC Alpha) so we try to print it and see if
* the result contains a NaN string.
*/
- if (!retval)
- {
- if (FLT_FLOAT==type)
- {
+ if (!retval) {
+ if (FLT_FLOAT == type) {
float x;
HDmemcpy(&x, val, sizeof(float));
- HDsnprintf(s, sizeof(s), "%g", (double)x);
+ HDsnprintf(s, sizeof(s), "%g", (double) x);
}
- else if (FLT_DOUBLE==type)
- {
+ else if (FLT_DOUBLE == type) {
double x;
HDmemcpy(&x, val, sizeof(double));
HDsnprintf(s, sizeof(s), "%g", x);
}
-#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0
- else if (FLT_LDOUBLE==type)
- {
+#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0
+ else if (FLT_LDOUBLE == type) {
long double x;
HDmemcpy(&x, val, sizeof(long double));
@@ -5967,16 +4630,12 @@ my_isnan(dtype_t type, void *val)
}
#endif
else
- {
return FALSE;
- }
- if ( HDstrstr(s, "NaN") ||
+ if (HDstrstr(s, "NaN") ||
HDstrstr(s, "NAN") ||
HDstrstr(s, "nan") ||
- HDstrstr(s, "-1.#IND") /* WIN32 */
- )
- {
+ HDstrstr(s, "-1.#IND")) {
retval = TRUE;
}
}
@@ -5986,7 +4645,6 @@ my_isnan(dtype_t type, void *val)
return retval;
}
-
/*-------------------------------------------------------------------------
*
* Local functions
@@ -5997,180 +4655,140 @@ my_isnan(dtype_t type, void *val)
/*-------------------------------------------------------------------------
* Function: print_data
*
- * Purpose: print data only in report or verbose modes, and do not print in quiet mode
+ * Purpose: print data only in report or verbose modes, and do not print in quiet mode
*-------------------------------------------------------------------------
*/
static
-int print_data(diff_opt_t *options)
+int print_data(diff_opt_t *opts)
{
- return ( (options->m_report || options->m_verbose) && !options->m_quiet)?1:0;
+ return ((opts->m_report || opts->m_verbose) && !opts->m_quiet) ? 1 : 0;
}
/*-------------------------------------------------------------------------
* Function: print_header
*
- * Purpose: print header for difference
- *
+ * Purpose: print header for difference
*-------------------------------------------------------------------------
*/
-
static
-void print_header(int pp, /* print percentage */
- int rank,
- hsize_t *dims,
- const char *obj1,
- const char *obj2 )
+void print_header(int pp, /* print percentage */
+ int rank, hsize_t *dims, const char *obj1, const char *obj2)
{
/* print header */
- parallel_print("%-16s","size:");
- print_dimensions (rank,dims);
- parallel_print("%-11s","");
- print_dimensions (rank,dims);
+ parallel_print("%-16s", "size:");
+ print_dimensions(rank, dims);
+ parallel_print("%-11s", "");
+ print_dimensions(rank, dims);
parallel_print("\n");
- if(pp) {
- parallel_print("%-15s %-15s %-15s %-15s %-15s\n",
- "position",
- (obj1!=NULL) ? obj1 : " ",
- (obj2!=NULL) ? obj2 : " ",
- "difference",
- "relative");
- parallel_print("------------------------------------------------------------------------\n");
+ if (pp) {
+ parallel_print("%-15s %-15s %-15s %-15s %-15s\n", "position",
+ (obj1 != NULL) ? obj1 : " ", (obj2 != NULL) ? obj2 : " ", "difference", "relative");
+ parallel_print(
+ "------------------------------------------------------------------------\n");
}
else {
- parallel_print("%-15s %-15s %-15s %-20s\n",
- "position",
- (obj1!=NULL) ? obj1 : " ",
- (obj2!=NULL) ? obj2 : " ",
- "difference");
- parallel_print("------------------------------------------------------------\n");
+ parallel_print("%-15s %-15s %-15s %-20s\n", "position",
+ (obj1 != NULL) ? obj1 : " ", (obj2 != NULL) ? obj2 : " ", "difference");
+ parallel_print(
+ "------------------------------------------------------------\n");
}
}
/*-------------------------------------------------------------------------
* Function: print_pos
*
- * Purpose: print in matrix notation, converting from an array index position
- *
+ * Purpose: print in matrix notation, converting from an array index position
*-------------------------------------------------------------------------
*/
-
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(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)
{
int i;
/* print header */
- if ( *ph==1 )
- {
- *ph=0;
+ 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];
+ for (i = 0; i < rank; i++) {
+ pos[i] = curr_pos / acc[i];
+ curr_pos -= acc[i] * pos[i];
}
- HDassert( curr_pos == 0 );
+ HDassert(curr_pos == 0);
- if ( rank > 0 )
- {
- parallel_print("[ " );
- for ( i = 0; i < rank; i++)
- {
+ if (rank > 0) {
+ parallel_print("[ ");
+ for (i = 0; i < rank; i++) {
parallel_print(HSIZE_T_FORMAT, (unsigned long long)pos[i]);
parallel_print(" ");
}
- parallel_print("]" );
+ parallel_print("]");
}
else
- {
parallel_print(" ");
- }
}
/*-------------------------------------------------------------------------
* Function: print_char_pos
*
- * Purpose: print character position in string
- *
+ * Purpose: print character position in string
*-------------------------------------------------------------------------
*/
-
static
-void print_char_pos( int *ph, /* print header */
- int pp, /* print percentage */
- hsize_t curr_pos,
- unsigned u,
- hsize_t *acc,
- hsize_t *pos,
- int rank,
- hsize_t *dims,
- const char *obj1,
- const char *obj2 )
+void print_char_pos(int *ph, /* print header */
+ int pp, /* print percentage */
+ hsize_t curr_pos, unsigned 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;
+ 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];
+ 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 )
- {
+ HDassert(curr_pos == 0);
- for ( i = 0; i < rank; i++)
- {
+ parallel_print("[ ");
+ if (rank > 0) {
+ for (i = 0; i < rank; i++) {
parallel_print(HSIZE_T_FORMAT, (unsigned long long)pos[i]);
parallel_print(" ");
}
}
else
- {
- parallel_print("%u", (unsigned)u);
- }
- parallel_print("]" );
+ parallel_print("%zu", u);
+
+ parallel_print("]");
}
/*-------------------------------------------------------------------------
- * Function: h5diff_print_char. Adapted from h5tools_print_char
- *
- * Purpose: Print a char
+ * Function: h5diff_print_char. Adapted from h5tools_print_char
*
+ * Purpose: Print a char
*-------------------------------------------------------------------------
*/
static void h5diff_print_char(char ch)
{
-
- switch (ch)
- {
+ switch (ch) {
case '"':
parallel_print("\\\"");
break;
case '\\':
- parallel_print( "\\\\");
+ parallel_print("\\\\");
break;
case '\b':
parallel_print("\\b");
@@ -6189,79 +4807,69 @@ static void h5diff_print_char(char ch)
break;
default:
if (isprint(ch))
- parallel_print( "%c", ch);
+ parallel_print("%c", ch);
else
- parallel_print( "\\%03o", ch);
-
+ parallel_print("\\%03o", ch);
break;
}
}
-
/*-------------------------------------------------------------------------
- * XCAO, 11/10/2010
* added to improve performance for compound datasets
* set up compound datatype structures.
+ *-------------------------------------------------------------------------
*/
static void get_member_types(hid_t tid, mcomp_t *members)
{
- int tclass;
+ int tclass;
unsigned u;
- if (tid <=0 || !members)
+ if (tid <= 0 || !members)
return;
tclass = H5Tget_class(tid);
- if (tclass == H5T_ARRAY || tclass == H5T_VLEN)
- {
+ if (tclass == H5T_ARRAY || tclass == H5T_VLEN) {
hid_t base_tid = H5Tget_super(tid);
get_member_types(base_tid, members);
H5Tclose(base_tid);
}
- else if (tclass == H5T_COMPOUND)
- {
- int nmembs;
+ else if (tclass == H5T_COMPOUND) {
+ int nmembs;
- nmembs = H5Tget_nmembers(tid);
- if(nmembs <= 0)
+ if ((nmembs = H5Tget_nmembers(tid)) <= 0)
return;
- members->n = (unsigned)nmembs;
+ members->n = (unsigned) nmembs;
- members->ids = (hid_t *)HDcalloc((size_t)members->n, sizeof(hid_t));
- members->offsets = (size_t *)HDcalloc((size_t)members->n, sizeof(size_t));
- members->m = (mcomp_t **)HDcalloc((size_t)members->n, sizeof(mcomp_t *));
+ members->ids = (hid_t *) HDcalloc((size_t )members->n, sizeof(hid_t));
+ members->offsets = (size_t *) HDcalloc((size_t )members->n, sizeof(size_t));
+ members->m = (mcomp_t **) HDcalloc((size_t )members->n, sizeof(mcomp_t *));
- for(u = 0; u < members->n; u++)
- {
- members->ids[u] = H5Tget_member_type( tid, u );
- members->offsets[u] = H5Tget_member_offset( tid, u );
- members->m[u] = (mcomp_t *)HDmalloc(sizeof(mcomp_t));
+ for (u = 0; u < members->n; u++) {
+ members->ids[u] = H5Tget_member_type(tid, u);
+ members->offsets[u] = H5Tget_member_offset(tid, u);
+ members->m[u] = (mcomp_t *) HDmalloc(sizeof(mcomp_t));
HDmemset(members->m[u], 0, sizeof(mcomp_t));
get_member_types(members->ids[u], members->m[u]);
}
}
return;
-
-
}
/*-------------------------------------------------------------------------
- * XCAO, 11/10/2010
* added to improve performance for compound datasets
* clean and close compound members.
+ *-------------------------------------------------------------------------
*/
static void close_member_types(mcomp_t *members)
{
unsigned u;
- if (!members || members->n<=0 || !members->ids)
+ if (!members || members->n <= 0 || !members->ids)
return;
- for(u = 0; u < members->n; u++)
- {
- if(members->m[u])
- {
+ for (u = 0; u < members->n; u++) {
+ if (members->m[u]) {
close_member_types(members->m[u]);
HDfree(members->m[u]);
}
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 3018f18..6019738 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -136,52 +136,55 @@ static void table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *ta
*
* Parameter:
* table_out [OUT] : return the list
- *
- * Programmer: Jonathan Kim
- *
- * Date: March 15, 2011
*------------------------------------------------------------------------*/
-static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *options)
+static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *opts)
{
- H5O_info_t oinfo1, oinfo2; /* Object info */
- hid_t attr1_id=-1; /* attr ID */
- hid_t attr2_id=-1; /* attr ID */
- size_t curr1 = 0;
- size_t curr2 = 0;
- unsigned infile[2];
- char name1[ATTR_NAME_MAX];
- char name2[ATTR_NAME_MAX];
- int cmp;
- unsigned i;
+ int ret_value = 0;
+ H5O_info_t oinfo1, oinfo2; /* Object info */
+ hid_t attr1_id = -1; /* attr ID */
+ hid_t attr2_id = -1; /* attr ID */
+ size_t curr1 = 0;
+ size_t curr2 = 0;
+ unsigned infile[2];
+ char name1[ATTR_NAME_MAX];
+ char name2[ATTR_NAME_MAX];
+ int cmp;
+ unsigned i;
table_attrs_t *table_lp = NULL;
+ h5difftrace("build_match_list_attrs start\n");
+
if(H5Oget_info(loc1_id, &oinfo1) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info first object failed");
if(H5Oget_info(loc2_id, &oinfo2) < 0)
- goto error;
-
- table_attrs_init( &table_lp );
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info second object failed");
+ table_attrs_init(&table_lp);
+ if (table_lp == NULL)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Table allocation failed");
/*--------------------------------------------------
* build the list
*/
while(curr1 < oinfo1.num_attrs && curr2 < oinfo2.num_attrs) {
+ h5diffdebug3("build_match_list_attrs 1: %ld - %ld\n", curr1, oinfo1.num_attrs);
+ h5diffdebug3("build_match_list_attrs 2: %ld - %ld\n", curr2, oinfo2.num_attrs);
+
/*------------------
* open attribute1 */
if((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx first attribute failed");
/* get name */
if(H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name first attribute failed");
/*------------------
* open attribute2 */
if((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx second attribute failed");
/* get name */
if(H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name second attribute failed");
/* criteria is string compare */
cmp = HDstrcmp(name1, name2);
@@ -219,13 +222,16 @@ 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) {
+ h5diffdebug3("build_match_list_attrs 1: %ld - %ld\n", curr1, oinfo1.num_attrs);
+
/*------------------
* open attribute1 */
if((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx first attribute failed");
/* get name */
if(H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name first attribute failed");
+ h5diffdebug2("build_match_list_attrs #1 name - %s\n", name1);
table_attr_mark_exist(infile, name1, table_lp);
table_lp->nattrs_only1++;
@@ -240,13 +246,15 @@ 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) {
+ h5diffdebug3("build_match_list_attrs 2: %ld - %ld\n", 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)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx second attribute failed");
/* get name */
if(H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name second attribute failed");
+ h5diffdebug2("build_match_list_attrs #2 name - %s\n", name2);
table_attr_mark_exist(infile, name2, table_lp);
table_lp->nattrs_only2++;
@@ -254,12 +262,13 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
/* close for next turn */
H5Aclose(attr2_id);
+ attr2_id = -1;
}
/*------------------------------------------------------
* print the list
*/
- if(options->m_verbose_level == 2) {
+ if(opts->m_verbose_level == 2) {
/* if '-v2' is detected */
parallel_print(" obj1 obj2\n");
parallel_print(" --------------------------------------\n");
@@ -271,42 +280,35 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
} /* end for */
}
- if(options->m_verbose_level >= 1)
+ if(opts->m_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);
+done:
*table_out = table_lp;
- return 0;
-
-error:
- if (0 < attr1_id)
+ /* disable error reporting */
+ H5E_BEGIN_TRY {
H5Aclose(attr1_id);
- if (0 < attr2_id)
H5Aclose(attr2_id);
+ } H5E_END_TRY;
+
+ h5diffdebug2("build_match_list_attrs end - errstat:%d\n", opts->err_stat);
- return -1;
+ return ret_value;
}
/*-------------------------------------------------------------------------
* Function: diff_attr
*
- * Purpose: compare attributes located in LOC1_ID and LOC2_ID, which are
- * obtained either from
- * loc_id = H5Gopen2(fid, name, H5P_DEFAULT);
- * loc_id = H5Dopen2(fid, name);
- * loc_id = H5Topen2(fid, name, H5P_DEFAULT);
- *
- * Return: number of differences found
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November, 03, 2003
- *
- * Modifications:
- * March, 02, 2007: return the number of differences found
+ * Purpose: compare attributes located in LOC1_ID and LOC2_ID, which are
+ * obtained either from
+ * loc_id = H5Gopen2(fid, name, H5P_DEFAULT);
+ * loc_id = H5Dopen2(fid, name);
+ * loc_id = H5Topen2(fid, name, H5P_DEFAULT);
*
+ * Return: number of differences found
*-------------------------------------------------------------------------
*/
@@ -314,107 +316,118 @@ hsize_t diff_attr(hid_t loc1_id,
hid_t loc2_id,
const char *path1,
const char *path2,
- diff_opt_t *options)
+ diff_opt_t *opts)
{
- hid_t attr1_id=-1; /* attr ID */
- hid_t attr2_id=-1; /* attr ID */
- hid_t space1_id=-1; /* space ID */
- hid_t space2_id=-1; /* space ID */
- hid_t ftype1_id=-1; /* file data type ID */
- hid_t ftype2_id=-1; /* file data type ID */
- int vstrtype1=0; /* ftype1 is a variable string */
- int vstrtype2=0; /* ftype2 is a variable string */
- hid_t mtype1_id=-1; /* memory data type ID */
- hid_t mtype2_id=-1; /* memory data type ID */
- size_t msize1; /* memory size of memory type */
- size_t msize2; /* memory size of memory type */
- void *buf1=NULL; /* data buffer */
- 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 *name1;
- char *name2;
+ int ret_value = opts->err_stat;
+ hid_t attr1_id = -1; /* attr ID */
+ hid_t attr2_id = -1; /* attr ID */
+ hid_t space1_id = -1; /* space ID */
+ hid_t space2_id = -1; /* space ID */
+ hid_t ftype1_id = -1; /* file data type ID */
+ hid_t ftype2_id = -1; /* file data type ID */
+ int vstrtype1 = 0; /* ftype1 is a variable string */
+ int vstrtype2 = 0; /* ftype2 is a variable string */
+ hid_t mtype1_id = -1; /* memory data type ID */
+ hid_t mtype2_id = -1; /* memory data type ID */
+ size_t msize1; /* memory size of memory type */
+ size_t msize2; /* memory size of memory type */
+ void *buf1 = NULL; /* data buffer */
+ 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 *name1 = NULL;
+ char *name2 = NULL;
char np1[512];
char np2[512];
- unsigned u; /* Local index variable */
+ unsigned u; /* Local index variable */
hsize_t nfound = 0;
hsize_t nfound_total = 0;
int j;
- table_attrs_t * match_list_attrs = NULL;
- if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, options) < 0)
- goto error;
+ table_attrs_t *match_list_attrs = NULL;
+ h5difftrace("diff_attr start\n");
+
+ if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, opts) < 0) {
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "build_match_list_attrs failed");
+ }
+ h5diffdebug2("build_match_list_attrs - errstat:%d\n", opts->err_stat);
/* if detect any unique extra attr */
if(match_list_attrs->nattrs_only1 || match_list_attrs->nattrs_only2) {
+ h5difftrace("diff_attr attributes only in one file\n");
/* exit will be 1 */
- options->contents = 0;
+ opts->contents = 0;
}
+ h5diffdebug2("match_list_attrs info - errstat:%d\n", opts->err_stat);
for(u = 0; u < (unsigned)match_list_attrs->nattrs; u++) {
+ h5diffdebug3("match_list_attrs loop[%d] - errstat:%d\n", u, 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;
+ h5diffdebug2("diff_attr name - %s\n", name1);
/*--------------
* attribute 1 */
if((attr1_id = H5Aopen(loc1_id, name1, H5P_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aopen first attribute failed");
/*--------------
* attribute 2 */
if((attr2_id = H5Aopen(loc2_id, name2, H5P_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aopen second attribute failed");
+ h5difftrace("diff_attr got attributes\n");
/* get the datatypes */
if((ftype1_id = H5Aget_type(attr1_id)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
vstrtype1 = H5Tis_variable_str(ftype1_id);
if((ftype2_id = H5Aget_type(attr2_id)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
vstrtype2 = H5Tis_variable_str(ftype2_id);
+
/* no compare if either one but not both are variable string type */
if (vstrtype1 != vstrtype2) {
- if((options->m_verbose || options->m_list_not_cmp))
+ if((opts->m_verbose || opts->m_list_not_cmp))
parallel_print("Not comparable: one of attribute <%s/%s> or <%s/%s> is of variable length type\n",
path1, name1, path2, name2);
- options->not_cmp = 1;
+ opts->not_cmp = 1;
if (H5Tclose(ftype1_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute ftype failed");
if (H5Tclose(ftype2_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute ftype failed");
if (H5Aclose(attr1_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose first attribute failed");
if (H5Aclose(attr2_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose second attribute failed");
continue;
}
if((mtype1_id = H5Tget_native_type(ftype1_id, H5T_DIR_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type first attribute ftype failed");
if((mtype2_id = H5Tget_native_type(ftype2_id, H5T_DIR_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type second attribute ftype failed");
if((msize1 = H5Tget_size(mtype1_id)) == 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_size first attribute mtype failed");
if((msize2 = H5Tget_size(mtype2_id)) == 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_size second attribute mtype failed");
/* get the dataspace */
if((space1_id = H5Aget_space(attr1_id)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_space first attribute failed");
if((space2_id = H5Aget_space(attr2_id)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_space second attribute failed");
/* get dimensions */
if((rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims first attribute failed");
if((rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims second attribute failed");
/*----------------------------------------------------------------------
* check for comparable TYPE and SPACE
@@ -424,23 +437,23 @@ hsize_t diff_attr(hid_t loc1_id,
/* 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, options, 0) != 1) {
+ dims1, dims2, name1, name2, opts, 0) != 1) {
if(H5Tclose(ftype1_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute ftype failed");
if(H5Tclose(ftype2_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute ftype failed");
if(H5Sclose(space1_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sclose first attribute failed");
if(H5Sclose(space2_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sclose second attribute failed");
if(H5Aclose(attr1_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose first attribute failed");
if(H5Aclose(attr2_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose second attribute failed");
if(H5Tclose(mtype1_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed");
if(H5Tclose(mtype2_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed");
continue;
}
@@ -451,7 +464,7 @@ hsize_t diff_attr(hid_t loc1_id,
*/
if(FAIL == match_up_memsize(ftype1_id, ftype2_id, &mtype1_id,
&mtype2_id, &msize1, &msize2))
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "match_up_memsize failed");
/*---------------------------------------------------------------------
* read
@@ -461,22 +474,22 @@ hsize_t diff_attr(hid_t loc1_id,
for(j = 0; j < rank1; j++)
nelmts1 *= dims1[j];
- buf1 = (void *)HDmalloc((size_t)(nelmts1 * msize1));
- buf2 = (void *)HDmalloc((size_t)(nelmts1 * msize2));
+ buf1 = (void *)HDcalloc((size_t)(nelmts1), msize1);
+ buf2 = (void *)HDcalloc((size_t)(nelmts1), msize2);
if(buf1 == NULL || buf2 == NULL) {
parallel_print("cannot read into memory\n");
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "buffer allocation failed");
}
if(H5Aread(attr1_id, mtype1_id, buf1) < 0) {
parallel_print("Failed reading attribute1 %s/%s\n", path1, name1);
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
}
else
buf1hasdata = TRUE;
if(H5Aread(attr2_id, mtype2_id, buf2) < 0) {
parallel_print("Failed reading attribute2 %s/%s\n", path2, name2);
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
}
else
buf2hasdata = TRUE;
@@ -492,22 +505,22 @@ hsize_t diff_attr(hid_t loc1_id,
/* always print name */
/* verbose (-v) and report (-r) mode */
- if(options->m_verbose || options->m_report) {
+ if(opts->m_verbose || opts->m_report) {
do_print_attrname("attribute", np1, np2);
nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1,
- dims1, options, np1, np2, mtype1_id, attr1_id, attr2_id);
+ dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id);
print_found(nfound);
}
/* quiet mode (-q), just count differences */
- else if(options->m_quiet) {
+ else if(opts->m_quiet) {
nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1,
- dims1, options, np1, np2, mtype1_id, attr1_id, attr2_id);
+ dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id);
}
/* the rest (-c, none, ...) */
else {
nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1,
- dims1, options, np1, np2, mtype1_id, attr1_id, attr2_id);
+ dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id);
/* print info if compatible and difference found */
if (nfound) {
@@ -534,31 +547,29 @@ hsize_t diff_attr(hid_t loc1_id,
buf2 = NULL;
if(H5Tclose(ftype1_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
if(H5Tclose(ftype2_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
if(H5Sclose(space1_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
if(H5Sclose(space2_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
if(H5Aclose(attr1_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed");
if(H5Aclose(attr2_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed");
if(H5Tclose(mtype1_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed");
if(H5Tclose(mtype2_id) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed");
nfound_total += nfound;
}
} /* u */
- table_attrs_free(match_list_attrs);
-
- return nfound_total;
+done:
+ opts->err_stat = opts->err_stat | ret_value;
-error:
H5E_BEGIN_TRY {
if(buf1) {
if(buf1hasdata && TRUE == h5tools_detect_vlen(mtype1_id))
@@ -583,7 +594,7 @@ error:
H5Aclose(attr2_id);
} H5E_END_TRY;
- options->err_stat = 1;
+ h5diffdebug2("diff_attr end - errstat:%d\n", opts->err_stat);
return nfound_total;
}
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index 1ac3d79..9d0462d 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* Copyright by The HDF Group. *
-* Copyright by the Board of Trustees of the University of Illinois. *
-* All rights reserved. *
-* *
-* This file is part of HDF5. The full HDF5 copyright notice, including *
-* terms governing use, modification, and redistribution, is contained in *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "H5private.h"
#include "h5tools.h"
@@ -19,25 +19,22 @@
/*-------------------------------------------------------------------------
-* Function: diff_dataset
-*
-* Purpose: check for comparable datasets and read into a compatible
-* memory type
-*
-* Return: Number of differences found
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: May 9, 2003
-*
-*-------------------------------------------------------------------------
-*/
-hsize_t diff_dataset( hid_t file1_id,
- hid_t file2_id,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *options)
+ * Function: diff_dataset
+ *
+ * Purpose: check for comparable datasets and read into a compatible
+ * memory type
+ *
+ * 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)
{
+ int ret_value = opts->err_stat;
+ int status = -1;
hid_t did1 = -1;
hid_t did2 = -1;
hid_t dcpl1 = -1;
@@ -46,53 +43,45 @@ hsize_t diff_dataset( hid_t file1_id,
h5difftrace("diff_dataset start\n");
/*-------------------------------------------------------------------------
- * open the handles
- *-------------------------------------------------------------------------
- */
- /* disable error reporting */
- H5E_BEGIN_TRY
- {
- /* Open the datasets */
- if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) {
- parallel_print("Cannot open dataset <%s>\n", obj1_name);
- goto error;
- }
- if((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0) {
- parallel_print("Cannot open dataset <%s>\n", obj2_name);
- goto error;
- }
- /* enable error reporting */
- } H5E_END_TRY;
-
+ * open the handles
+ *-------------------------------------------------------------------------
+ */
+ /* Open the datasets */
+ if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) {
+ parallel_print("Cannot open dataset <%s>\n", obj1_name);
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 first dataset failed");
+ }
+ if((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0) {
+ parallel_print("Cannot open dataset <%s>\n", obj2_name);
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 second dataset failed");
+ }
if((dcpl1 = H5Dget_create_plist(did1)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist first dataset failed");
if((dcpl2 = H5Dget_create_plist(did2)) < 0)
- goto error;
-
- /*-------------------------------------------------------------------------
- * check if the dataset creation property list has filters that
- * are not registered in the current configuration
- * 1) the external filters GZIP and SZIP might not be available
- * 2) the internal filters might be turned off
- *-------------------------------------------------------------------------
- */
- if ((h5tools_canreadf((options->m_verbose ? obj1_name : NULL), dcpl1) == 1) &&
- (h5tools_canreadf((options->m_verbose ? obj2_name : NULL), dcpl2) == 1))
- nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, options);
- else
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist second dataset failed");
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- goto done;
-
-error:
- options->err_stat = 1;
+ * check if the dataset creation property list has filters that
+ * are not registered in the current configuration
+ * 1) the external filters GZIP and SZIP might not be available
+ * 2) the internal filters might be turned off
+ *-------------------------------------------------------------------------
+ */
+ 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);
+ else if (status < 0) {
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "h5tools_canreadf failed");
+ }
+ else {
+ ret_value = 1;
+ opts->not_cmp = 1;
+ }
done:
+ opts->err_stat = opts->err_stat | ret_value;
+
/* disable error reporting */
H5E_BEGIN_TRY {
H5Pclose(dcpl1);
@@ -102,81 +91,75 @@ done:
/* enable error reporting */
} H5E_END_TRY;
- h5difftrace("diff_dataset end\n");
+ h5diffdebug3("diff_dataset finish:%d - errstat:%d\n", nfound, opts->err_stat);
return nfound;
}
/*-------------------------------------------------------------------------
-* Function: diff_datasetid
-*
-* Purpose: check for comparable datasets and read into a compatible
-* memory type
-*
-* Return: Number of differences found
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: May 9, 2003
-*
-* Modifications:
-*
-*
-* October 2006: Read by hyperslabs for big datasets.
-*
-* A threshold of H5TOOLS_MALLOCSIZE (128 MB) is the limit upon which I/O hyperslab is done
-* i.e., if the memory needed to read a dataset is greater than this limit,
-* then hyperslab I/O is done instead of one operation I/O
-* For each dataset, the memory needed is calculated according to
-*
-* memory needed = number of elements * size of each element
-*
-* if the memory needed is lower than H5TOOLS_MALLOCSIZE, then the following operations
-* are done
-*
-* H5Dread( input_dataset1 )
-* H5Dread( input_dataset2 )
-*
-* with all elements in the datasets selected. If the memory needed is greater than
-* H5TOOLS_MALLOCSIZE, then the following operations are done instead:
-*
-* a strip mine is defined for each dimension k (a strip mine is defined as a
-* hyperslab whose size is memory manageable) according to the formula
-*
-* (1) strip_mine_size[k ] = MIN(dimension[k ], H5TOOLS_BUFSIZE / size of memory type)
-*
-* where H5TOOLS_BUFSIZE is a constant currently defined as 1MB. This formula assures
-* that for small datasets (small relative to the H5TOOLS_BUFSIZE constant), the strip
-* mine size k is simply defined as its dimension k, but for larger datasets the
-* hyperslab size is still memory manageable.
-* a cycle is done until the number of elements in the dataset is reached. In each
-* iteration, two parameters are defined for the function H5Sselect_hyperslab,
-* the start and size of each hyperslab, according to
-*
-* (2) hyperslab_size [k] = MIN(dimension[k] - hyperslab_offset[k], strip_mine_size [k])
-*
-* where hyperslab_offset [k] is initially set to zero, and later incremented in
-* hyperslab_size[k] offsets. The reason for the operation
-*
-* dimension[k] - hyperslab_offset[k]
-*
-* in (2) is that, when using the strip mine size, it assures that the "remaining" part
-* of the dataset that does not fill an entire strip mine is processed.
-*
-*-------------------------------------------------------------------------
-*/
-hsize_t diff_datasetid( hid_t did1,
- hid_t did2,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *options)
+ * Function: diff_datasetid
+ *
+ * Purpose: check for comparable datasets and read into a compatible
+ * memory type
+ *
+ * Return: Number of differences found
+ *
+ * October 2006: Read by hyperslabs for big datasets.
+ *
+ * A threshold of H5TOOLS_MALLOCSIZE (128 MB) is the limit upon which I/O hyperslab is done
+ * i.e., if the memory needed to read a dataset is greater than this limit,
+ * then hyperslab I/O is done instead of one operation I/O
+ * For each dataset, the memory needed is calculated according to
+ *
+ * memory needed = number of elements * size of each element
+ *
+ * if the memory needed is lower than H5TOOLS_MALLOCSIZE, then the following operations
+ * are done
+ *
+ * H5Dread( input_dataset1 )
+ * H5Dread( input_dataset2 )
+ *
+ * with all elements in the datasets selected. If the memory needed is greater than
+ * H5TOOLS_MALLOCSIZE, then the following operations are done instead:
+ *
+ * a strip mine is defined for each dimension k (a strip mine is defined as a
+ * hyperslab whose size is memory manageable) according to the formula
+ *
+ * (1) strip_mine_size[k ] = MIN(dimension[k ], H5TOOLS_BUFSIZE / size of memory type)
+ *
+ * where H5TOOLS_BUFSIZE is a constant currently defined as 1MB. This formula assures
+ * that for small datasets (small relative to the H5TOOLS_BUFSIZE constant), the strip
+ * mine size k is simply defined as its dimension k, but for larger datasets the
+ * hyperslab size is still memory manageable.
+ * a cycle is done until the number of elements in the dataset is reached. In each
+ * iteration, two parameters are defined for the function H5Sselect_hyperslab,
+ * the start and size of each hyperslab, according to
+ *
+ * (2) hyperslab_size [k] = MIN(dimension[k] - hyperslab_offset[k], strip_mine_size [k])
+ *
+ * where hyperslab_offset [k] is initially set to zero, and later incremented in
+ * hyperslab_size[k] offsets. The reason for the operation
+ *
+ * dimension[k] - hyperslab_offset[k]
+ *
+ * in (2) is that, when using the strip mine size, it assures that the "remaining" part
+ * of the dataset that does not fill an entire strip mine is processed.
+ *
+ *-------------------------------------------------------------------------
+ */
+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=-1;
- hid_t sid2=-1;
- hid_t f_tid1=-1;
- hid_t f_tid2=-1;
- hid_t dam_tid=-1; /* m_tid for diff_array function */
- hid_t m_tid1=-1;
- hid_t m_tid2=-1;
+ int ret_value = opts->err_stat;
+ hid_t sid1 = -1;
+ hid_t sid2 = -1;
+ hid_t f_tid1 = -1;
+ hid_t f_tid2 = -1;
+ hid_t dam_tid = -1; /* m_tid for diff_array function */
+ hid_t m_tid1 = -1;
+ hid_t m_tid2 = -1;
hid_t dcpl1 = -1;
hid_t dcpl2 = -1;
H5D_layout_t stl1 = -1;
@@ -196,78 +179,78 @@ hsize_t diff_datasetid( hid_t did1,
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;
+ 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 */
- int can_compare=1; /* do diff or not */
- void *buf1=NULL;
- void *buf2=NULL;
- void *sm_buf1=NULL;
- void *sm_buf2=NULL;
- hid_t sm_space; /*stripmine data space */
- size_t need; /* bytes needed for malloc */
+ hsize_t nfound = 0; /* number of differences found */
+ int can_compare = 1; /* do diff or not */
+ void *buf1 = NULL;
+ void *buf2 = NULL;
+ void *sm_buf1 = NULL;
+ void *sm_buf2 = NULL;
+ hid_t sm_space = -1; /*stripmine data space */
+ size_t need; /* bytes needed for malloc */
int i;
- unsigned int vl_data = 0; /*contains VL datatypes */
+ unsigned int vl_data = 0; /*contains VL datatypes */
h5difftrace("diff_datasetid start\n");
/* Get the dataspace handle */
if((sid1 = H5Dget_space(did1)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_space failed");
/* Get rank */
if((rank1 = H5Sget_simple_extent_ndims(sid1)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
/* Get the dataspace handle */
if((sid2 = H5Dget_space(did2)) < 0 )
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_space failed");
/* Get rank */
if((rank2 = H5Sget_simple_extent_ndims(sid2)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
/* Get dimensions */
if(H5Sget_simple_extent_dims(sid1, dims1, maxdim1) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
/* Get dimensions */
if(H5Sget_simple_extent_dims(sid2, dims2, maxdim2) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
h5diffdebug3("rank: %ld - %ld\n", rank1, rank2);
/*-------------------------------------------------------------------------
- * get the file data type
- *-------------------------------------------------------------------------
- */
+ * get the file data type
+ *-------------------------------------------------------------------------
+ */
/* Get the data type */
if((f_tid1 = H5Dget_type(did1)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_type failed");
/* Get the data type */
if((f_tid2 = H5Dget_type(did2)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_type failed");
/*-------------------------------------------------------------------------
- * get the storage layout type
- *-------------------------------------------------------------------------
- */
+ * get the storage layout type
+ *-------------------------------------------------------------------------
+ */
if((dcpl1 = H5Dget_create_plist(did1)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((dcpl2 = H5Dget_create_plist(did2)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((stl1 = H5Pget_layout(dcpl1)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Pget_layout failed");
if((stl2 = H5Pget_layout(dcpl2)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Pget_layout failed");
/*-------------------------------------------------------------------------
- * check for empty datasets
- *-------------------------------------------------------------------------
- */
+ * check for empty datasets
+ *-------------------------------------------------------------------------
+ */
h5difftrace("check for empty datasets\n");
storage_size1 = H5Dget_storage_size(did1);
@@ -275,66 +258,69 @@ hsize_t diff_datasetid( hid_t did1,
h5diffdebug3("storage size: %ld - %ld\n", storage_size1, storage_size2);
if(storage_size1 == 0 || storage_size2 == 0) {
- if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name)
- parallel_print("Not comparable: <%s> or <%s> is an empty dataset\n", obj1_name, obj2_name);
+ if((opts->m_verbose || opts->m_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;
- options->not_cmp = 1;
+ opts->not_cmp = 1;
}
/*-------------------------------------------------------------------------
- * check for comparable TYPE and SPACE
- *-------------------------------------------------------------------------
- */
+ * check for comparable TYPE and SPACE
+ *-------------------------------------------------------------------------
+ */
if (diff_can_type(f_tid1, f_tid2, rank1, rank2,
dims1, dims2, maxdim1, maxdim2,
obj1_name, obj2_name,
- options, 0) != 1)
+ opts, 0) != 1)
can_compare = 0;
+ h5diffdebug2("diff_can_type - errstat:%d\n", opts->err_stat);
/*-------------------------------------------------------------------------
- * memory type and sizes
- *-------------------------------------------------------------------------
- */
+ * memory type and sizes
+ *-------------------------------------------------------------------------
+ */
h5difftrace("check for memory type and sizes\n");
if((m_tid1 = H5Tget_native_type(f_tid1, H5T_DIR_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type failed");
if((m_tid2 = H5Tget_native_type(f_tid2, H5T_DIR_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type failed");
m_size1 = H5Tget_size(m_tid1);
m_size2 = H5Tget_size(m_tid2);
h5diffdebug3("type size: %ld - %ld\n", m_size1, m_size2);
/*-------------------------------------------------------------------------
- * check for different signed/unsigned types
- *-------------------------------------------------------------------------
- */
+ * check for different signed/unsigned types
+ *-------------------------------------------------------------------------
+ */
if(can_compare) {
h5difftrace("can_compare for sign\n");
sign1 = H5Tget_sign(m_tid1);
sign2 = H5Tget_sign(m_tid2);
if(sign1 != sign2) {
h5difftrace("sign1 != sign2\n");
- if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) {
+ if((opts->m_verbose || opts->m_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));
}
can_compare = 0;
- options->not_cmp = 1;
+ opts->not_cmp = 1;
}
}
/* Check if type is either VLEN-data or VLEN-string to reclaim any
- * VLEN memory buffer later */
+ * VLEN memory buffer later
+ */
if(TRUE == h5tools_detect_vlen(m_tid1))
vl_data = TRUE;
+ h5diffdebug2("h5tools_detect_vlen - errstat:%d\n", opts->err_stat);
/*------------------------------------------------------------------------
- * only attempt to compare if possible
- *-------------------------------------------------------------------------
- */
+ * only attempt to compare if possible
+ *-------------------------------------------------------------------------
+ */
if(can_compare) { /* it is possible to compare */
H5T_class_t tclass = H5Tget_class(f_tid1);
h5difftrace("can_compare attempt\n");
@@ -352,25 +338,24 @@ hsize_t diff_datasetid( hid_t did1,
nelmts2 *= dims2[i];
h5diffdebug3("nelmts: %ld - %ld\n", nelmts1, nelmts2);
- HDassert(nelmts1 == nelmts2);
if(tclass != H5T_ARRAY) {
/*-----------------------------------------------------------------
- * "upgrade" the smaller memory size
- *------------------------------------------------------------------
- */
+ * "upgrade" the smaller memory size
+ *------------------------------------------------------------------
+ */
h5difftrace("upgrade the smaller memory size?\n");
if (FAIL == match_up_memsize (f_tid1, f_tid2,
&m_tid1, &m_tid2,
&m_size1, &m_size2))
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "match_up_memsize failed");
h5diffdebug3("m_size: %ld - %ld\n", m_size1, m_size2);
dadims = dims1;
dam_size = m_size1;
dam_tid = m_tid1;
danelmts = nelmts1;
need = (size_t)(nelmts1 * m_size1); /* bytes needed */
- }
+ }
else {
h5diffdebug3("Array dims: %d - %d\n", dims1[0], dims2[0]);
/* Compare the smallest array, but create the largest buffer */
@@ -394,12 +379,13 @@ hsize_t diff_datasetid( hid_t did1,
name1 = diff_basename(obj1_name);
if(obj2_name)
name2 = diff_basename(obj2_name);
+ h5diffdebug3("obj_names: %s - %s\n", name1, name2);
/*----------------------------------------------------------------
- * read/compare
- *-----------------------------------------------------------------
- */
+ * read/compare
+ *-----------------------------------------------------------------
+ */
if(need < H5TOOLS_MALLOCSIZE) {
buf1 = HDmalloc(need);
buf2 = HDmalloc(need);
@@ -408,20 +394,30 @@ hsize_t diff_datasetid( hid_t did1,
if(buf1 != NULL && buf2 != NULL) {
h5difftrace("buf1 != NULL && buf2 != NULL\n");
if(H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed");
h5difftrace("H5Dread did2\n");
if(H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed");
/* array diff */
nfound = diff_array(buf1, buf2, danelmts, (hsize_t)0, rank1, dadims,
- options, name1, name2, dam_tid, did1, did2);
+ opts, name1, name2, dam_tid, did1, did2);
+ h5diffdebug2("diff_array nfound:%d\n", nfound);
/* reclaim any VL memory, if necessary */
if(vl_data) {
+ h5difftrace("check vl_data\n");
H5Dvlen_reclaim(m_tid1, sid1, H5P_DEFAULT, buf1);
H5Dvlen_reclaim(m_tid2, sid2, H5P_DEFAULT, buf2);
} /* end if */
+ if(buf1 != NULL) {
+ HDfree(buf1);
+ buf1 = NULL;
+ }
+ if(buf2 != NULL) {
+ HDfree(buf2);
+ buf2 = NULL;
+ }
} /* end if */
else { /* possibly not enough memory, read/compare by hyperslabs */
size_t p_type_nbytes = dam_size; /*size of memory type */
@@ -453,7 +449,7 @@ hsize_t diff_datasetid( hid_t did1,
size = 1;
sm_size[i - 1] = MIN(dadims[i - 1], size);
sm_nbytes *= sm_size[i - 1];
- HDassert(sm_nbytes > 0);
+ h5diffdebug2("sm_nbytes: %ld\n", sm_nbytes);
} /* end for */
/* malloc return code should be verified.
@@ -463,10 +459,10 @@ hsize_t diff_datasetid( hid_t did1,
* that fails to address freeing other objects created here.
* E.g., sm_space.
*/
- sm_buf1 = HDmalloc((size_t)sm_nbytes);
- HDassert(sm_buf1);
- sm_buf2 = HDmalloc((size_t)sm_nbytes);
- HDassert(sm_buf2);
+ if((sm_buf1 = HDmalloc((size_t)sm_nbytes)) == NULL)
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "HDmalloc failed");
+ if((sm_buf2 = HDmalloc((size_t)sm_nbytes)) == NULL)
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "HDmalloc failed");
sm_nelmts = sm_nbytes / p_type_nbytes;
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
@@ -483,24 +479,24 @@ hsize_t diff_datasetid( hid_t did1,
hs_nelmts *= hs_size[i];
} /* end for */
if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
} /* end if */
else
hs_nelmts = 1;
if(H5Dread(did1, m_tid1, sm_space, sid1, H5P_DEFAULT, sm_buf1) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed");
if(H5Dread(did2, m_tid2, sm_space, sid2, H5P_DEFAULT, sm_buf2) < 0)
- goto error;
+ HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed");
/* get array differences. in the case of hyperslab read, increment the number of differences
found in each hyperslab and pass the position at the beginning for printing */
nfound += diff_array(sm_buf1, sm_buf2, hs_nelmts, elmtno, rank1,
- dadims, options, name1, name2, dam_tid, did1, did2);
+ dadims, opts, name1, name2, dam_tid, did1, did2);
/* reclaim any VL memory, if necessary */
if(vl_data) {
@@ -517,6 +513,14 @@ hsize_t diff_datasetid( hid_t did1,
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);
} /* hyperslab read */
@@ -527,40 +531,10 @@ hsize_t diff_datasetid( hid_t did1,
* close
*-------------------------------------------------------------------------
*/
- h5difftrace("compare attributes?\n");
-
- /* free */
- if(buf1 != NULL) {
- HDfree(buf1);
- buf1 = NULL;
- } /* end if */
- if(buf2 != NULL) {
- HDfree(buf2);
- buf2 = NULL;
- } /* end if */
- if(sm_buf1 != NULL) {
- HDfree(sm_buf1);
- sm_buf1 = NULL;
- } /* end if */
- if(sm_buf2 != NULL) {
- HDfree(sm_buf2);
- sm_buf2 = NULL;
- } /* end if */
-
- H5E_BEGIN_TRY {
- H5Sclose(sid1);
- H5Sclose(sid2);
- H5Tclose(f_tid1);
- H5Tclose(f_tid2);
- H5Tclose(m_tid1);
- H5Tclose(m_tid2);
- } H5E_END_TRY;
- h5difftrace("diff_datasetid finish\n");
-
- return nfound;
+ h5diffdebug2("reclaim any VL memory - errstat:%d\n", opts->err_stat);
-error:
- options->err_stat=1;
+done:
+ opts->err_stat = opts->err_stat | ret_value;
/* free */
if(buf1 != NULL) {
@@ -602,60 +576,55 @@ error:
H5Tclose(m_tid2);
/* enable error reporting */
} H5E_END_TRY;
- h5difftrace("diff_datasetid errored\n");
+ h5diffdebug3("diff_datasetid return:%d with nfound:%d\n", ret_value, nfound);
return nfound;
}
/*-------------------------------------------------------------------------
-* Function: diff_can_type
-*
-* Purpose: check for comparable TYPE and SPACE
-*
-* Return:
-* 1, can compare
-* 0, cannot compare
-* -1, error
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: November 3, 2003
-*
-*-------------------------------------------------------------------------
-*/
-
-int diff_can_type( hid_t f_tid1, /* file data type */
- hid_t f_tid2, /* 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 *options,
- int is_compound)
+ * Function: diff_can_type
+ *
+ * Purpose: check for comparable TYPE and SPACE
+ *
+ * Return:
+ * 1, can compare
+ * 0, cannot compare
+ * -1, error
+ *-------------------------------------------------------------------------
+ */
+
+int diff_can_type(hid_t f_tid1, /* file data type */
+ hid_t f_tid2, /* 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)
{
+ int ret_value = 1; /* can_compare value */
H5T_class_t tclass1;
H5T_class_t tclass2;
int maxdim_diff = 0; /* maximum dimensions are different */
int dim_diff = 0; /* current dimensions are different */
int i;
- int can_compare = 1; /* return value */
h5difftrace("diff_can_type start\n");
/*-------------------------------------------------------------------------
- * check for the same class
- *-------------------------------------------------------------------------
- */
+ * check for the same class
+ *-------------------------------------------------------------------------
+ */
if((tclass1 = H5Tget_class(f_tid1)) < 0)
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_class first object failed");
if((tclass2 = H5Tget_class(f_tid2)) < 0)
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_class second object failed");
if(tclass1 != tclass2) {
- if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) {
+ if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) {
if(is_compound) {
parallel_print("Not comparable: <%s> has a class %s and <%s> has a class %s\n",
obj1_name, get_class(tclass1),
@@ -667,25 +636,22 @@ int diff_can_type( hid_t f_tid1, /* file data type */
obj2_name, get_class(tclass2));
}
}
- can_compare = 0;
- options->not_cmp = 1;
- goto done;
+ opts->not_cmp = 1;
+ HGOTO_DONE(0);
}
/*-------------------------------------------------------------------------
- * check for non supported classes
- *-------------------------------------------------------------------------
- */
- HDassert(tclass1 == tclass2);
+ * check for non supported classes
+ *-------------------------------------------------------------------------
+ */
switch (tclass1) {
case H5T_TIME:
- if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) {
+ if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) {
parallel_print("Not comparable: <%s> and <%s> are of class %s\n",
obj1_name, obj2_name, get_class(tclass2));
} /* end if */
- can_compare = 0;
- options->not_cmp = 1;
- goto done;
+ opts->not_cmp = 1;
+ HGOTO_DONE(0);
case H5T_INTEGER:
case H5T_FLOAT:
@@ -705,10 +671,10 @@ int diff_can_type( hid_t f_tid1, /* file data type */
} /* end switch */
/*-------------------------------------------------------------------------
- * check for equal file datatype; warning only
- *-------------------------------------------------------------------------
- */
- if((H5Tequal(f_tid1, f_tid2) == 0) && (options->m_verbose) && obj1_name && obj2_name) {
+ * check for equal file datatype; warning only
+ *-------------------------------------------------------------------------
+ */
+ if((H5Tequal(f_tid1, f_tid2) == 0) && (opts->m_verbose) && obj1_name && obj2_name) {
H5T_class_t cl = H5Tget_class(f_tid1);
parallel_print("Warning: different storage datatype\n");
@@ -723,11 +689,11 @@ int diff_can_type( hid_t f_tid1, /* file data type */
}
/*-------------------------------------------------------------------------
- * check for the same rank
- *-------------------------------------------------------------------------
- */
+ * check for the same rank
+ *-------------------------------------------------------------------------
+ */
if(rank1 != rank2) {
- if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) {
+ 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);
print_dimensions(rank1, dims1);
parallel_print(", max dimensions ");
@@ -739,16 +705,14 @@ int diff_can_type( hid_t f_tid1, /* file data type */
print_dimensions(rank2, maxdim2);
parallel_print("\n");
}
- can_compare = 0;
- options->not_cmp = 1;
- goto done;
+ opts->not_cmp = 1;
+ HGOTO_DONE(0);
}
/*-------------------------------------------------------------------------
- * check for different dimensions
- *-------------------------------------------------------------------------
- */
- HDassert(rank1 == rank2);
+ * check for different dimensions
+ *-------------------------------------------------------------------------
+ */
for(i = 0; i<rank1; i++) {
if(maxdim1 && maxdim2) {
if(maxdim1[i] != maxdim2[i])
@@ -759,11 +723,11 @@ int diff_can_type( hid_t f_tid1, /* file data type */
}
/*-------------------------------------------------------------------------
- * current dimensions
- *-------------------------------------------------------------------------
- */
+ * current dimensions
+ *-------------------------------------------------------------------------
+ */
if(dim_diff == 1) {
- if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) {
+ 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);
print_dimensions(rank1, dims1);
if(maxdim1 && maxdim2) {
@@ -777,17 +741,16 @@ int diff_can_type( hid_t f_tid1, /* file data type */
parallel_print("\n");
}
}
- can_compare = 0;
- options->not_cmp = 1;
- goto done;
+ opts->not_cmp = 1;
+ HGOTO_DONE(0);
}
/*-------------------------------------------------------------------------
- * maximum dimensions; just give a warning
- *-------------------------------------------------------------------------
- */
+ * maximum dimensions; just give a warning
+ *-------------------------------------------------------------------------
+ */
if(maxdim1 && maxdim2 && maxdim_diff == 1 && obj1_name) {
- if(options->m_verbose) {
+ if(opts->m_verbose) {
parallel_print( "Warning: different maximum dimensions\n");
parallel_print("<%s> has max dimensions ", obj1_name);
print_dimensions(rank1, maxdim1);
@@ -802,21 +765,20 @@ int diff_can_type( hid_t f_tid1, /* file data type */
int nmembs1;
int nmembs2;
int j;
- hid_t memb_type1;
- hid_t memb_type2;
+ hid_t memb_type1 = -1;
+ hid_t memb_type2 = -1;
nmembs1 = H5Tget_nmembers(f_tid1);
nmembs2 = H5Tget_nmembers(f_tid2);
if(nmembs1 != nmembs2) {
- if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) {
+ 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);
parallel_print("\n");
}
- can_compare = 0;
- options->not_cmp = 1;
- goto done;
+ opts->not_cmp = 1;
+ HGOTO_DONE(0);
}
for (j = 0; j < nmembs1; j++) {
@@ -825,30 +787,31 @@ int diff_can_type( hid_t f_tid1, /* file data type */
if (diff_can_type(memb_type1, memb_type2, rank1, rank2,
dims1, dims2, maxdim1, maxdim2, obj1_name, obj2_name,
- options, 1) != 1) {
- can_compare = 0;
- options->not_cmp = 1;
+ opts, 1) != 1) {
+ opts->not_cmp = 1;
H5Tclose(memb_type1);
H5Tclose(memb_type2);
- goto done;
+ HGOTO_DONE(0);
}
H5Tclose(memb_type1);
H5Tclose(memb_type2);
}
}
done:
- h5diffdebug2("diff_can_type end - %d\n", can_compare);
- return can_compare;
+ if (ret_value < 0)
+ opts->err_stat = 1;
+
+ h5diffdebug2("diff_can_type end - %d\n", ret_value);
+ return ret_value;
}
/*-------------------------------------------------------------------------
-* Function: print_sizes
-*
-* Purpose: Print datatype sizes
-*
-*-------------------------------------------------------------------------
-*/
+ * Function: print_sizes
+ *
+ * Purpose: Print datatype sizes
+ *-------------------------------------------------------------------------
+ */
#if defined (H5DIFF_DEBUG)
void print_sizes( const char *obj1,
const char *obj2,
diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c
index 0c02779..0f0fd14 100644
--- a/tools/lib/h5diff_util.c
+++ b/tools/lib/h5diff_util.c
@@ -24,8 +24,7 @@ int g_nTasks = 1;
/*-------------------------------------------------------------------------
* Function: print_dimensions
*
- * Purpose: print dimensions
- *
+ * Purpose: print dimensions
*-------------------------------------------------------------------------
*/
void
@@ -33,14 +32,14 @@ print_dimensions (int rank, hsize_t *dims)
{
int i;
- if( rank <= 0 )
+ if(rank <= 0)
parallel_print("H5S_SCALAR" );
else {
if (!dims)
parallel_print("dimension is NULL");
else {
parallel_print("[");
- for ( i = 0; i < rank-1; i++) {
+ for (i = 0; i < rank-1; i++) {
parallel_print(HSIZE_T_FORMAT, dims[i]);
parallel_print("x");
}
@@ -55,16 +54,11 @@ print_dimensions (int rank, hsize_t *dims)
/*-------------------------------------------------------------------------
* Function: print_type
*
- * Purpose: Print name of datatype
- *
- * Return: void
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Purpose: Print name of datatype
*
- * Date: May 9, 2003
- *
- * Comments: Adapted from h5dump for H5T_INTEGER and H5T_FLOAT classes only
+ * Return: void
*
+ * Comments: Adapted from h5dump for H5T_INTEGER and H5T_FLOAT classes only
*-------------------------------------------------------------------------
*/
void print_type(hid_t type)
@@ -188,15 +182,10 @@ void print_type(hid_t type)
/*-------------------------------------------------------------------------
* Function: diff_basename
*
- * Purpose: Returns a pointer to the last component absolute name
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
- *
+ * Purpose: Returns a pointer to the last component absolute name
*-------------------------------------------------------------------------
*/
-const char*
+ const char*
diff_basename(const char *name)
{
size_t i;
@@ -219,12 +208,7 @@ diff_basename(const char *name)
/*-------------------------------------------------------------------------
* Function: get_type
*
- * Purpose: Returns the type as a string
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
- *
+ * Purpose: Returns the type as a string
*-------------------------------------------------------------------------
*/
const char*
@@ -255,21 +239,13 @@ get_type(h5trav_type_t type)
/*-------------------------------------------------------------------------
* Function: get_sign
*
- * Purpose: Returns the sign as a string
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
- *
- * Comments:
- *
+ * Purpose: Returns the sign as a string
*-------------------------------------------------------------------------
*/
-const char*
+ const char*
get_sign(H5T_sign_t sign)
{
- switch(sign)
- {
+ switch(sign) {
case H5T_SGN_NONE:
return "H5T_SGN_NONE";
@@ -283,7 +259,6 @@ get_sign(H5T_sign_t sign)
return "H5T_NSGN";
default:
- HDassert(0);
return "unknown sign value";
} /* end switch */
}
@@ -292,15 +267,10 @@ get_sign(H5T_sign_t sign)
/*-------------------------------------------------------------------------
* Function: get_class
*
- * Purpose: Returns the class as a string
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
- *
+ * Purpose: Returns the class as a string
*-------------------------------------------------------------------------
*/
-const char*
+ const char*
get_class(H5T_class_t tclass)
{
switch(tclass) {
@@ -340,7 +310,6 @@ get_class(H5T_class_t tclass)
case H5T_NO_CLASS:
case H5T_NCLASSES:
default:
- HDassert(0);
return("Invalid class");
} /* end switch */
} /* end get_class() */
@@ -348,8 +317,7 @@ get_class(H5T_class_t tclass)
/*-------------------------------------------------------------------------
* Function: print_found
*
- * Purpose: print number of differences found
- *
+ * Purpose: print number of differences found
*-------------------------------------------------------------------------
*/
void print_found(hsize_t nfound)
@@ -364,40 +332,37 @@ void print_found(hsize_t nfound)
/*-----------------------------------------------------------------
* Function: match_up_memsize
*
- * Purpose: match smaller memory size up to bigger memory size
+ * Purpose: match smaller memory size up to bigger memory size
*------------------------------------------------------------------
*/
herr_t match_up_memsize (hid_t f_tid1_id, hid_t f_tid2_id,
hid_t *m_tid1, hid_t *m_tid2,
size_t *m_size1, size_t *m_size2)
{
- herr_t ret = SUCCEED;
+ herr_t ret_value = SUCCEED;
if((*m_size1) != (*m_size2)) {
if((*m_size1) < (*m_size2)) {
- H5Tclose( *m_tid1 );
+ H5Tclose(*m_tid1);
- if(((*m_tid1) = H5Tget_native_type(f_tid2_id, H5T_DIR_DEFAULT)) < 0) {
- ret = FAIL;
- goto out;
- }
+ if(((*m_tid1) = H5Tget_native_type(f_tid2_id, H5T_DIR_DEFAULT)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed");
- *m_size1 = H5Tget_size( *m_tid1 );
+ *m_size1 = H5Tget_size(*m_tid1);
} /* end if */
else {
H5Tclose(*m_tid2);
- if(((*m_tid2) = H5Tget_native_type(f_tid1_id, H5T_DIR_DEFAULT)) < 0) {
- ret = FAIL;
- goto out;
- }
+ if(((*m_tid2) = H5Tget_native_type(f_tid1_id, H5T_DIR_DEFAULT)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed");
*m_size2 = H5Tget_size(*m_tid2);
} /* end else */
} /* end if */
- HDassert((*m_size1) == (*m_size2));
+ if((*m_size1) != (*m_size2))
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "native type sizes do not compare");
-out:
- return ret;
+done:
+ return ret_value;
}
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 159349a..9230bb1 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -12,16 +12,10 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Robb Matzke <matzke@llnl.gov>
- * Thursday, July 23, 1998
- *
* Purpose: A library for displaying the values of a dataset in a human
* readable format.
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "h5tools.h"
#include "h5tools_dump.h"
#include "h5tools_ref.h"
@@ -29,10 +23,10 @@
#include "H5private.h"
/* global variables */
-hid_t H5tools_ERR_STACK_g = 0;
-hid_t H5tools_ERR_CLS_g = -1;
-hid_t H5E_tools_g = -1;
-hid_t H5E_tools_min_id_g = -1;
+hid_t H5tools_ERR_STACK_g = 0;
+hid_t H5tools_ERR_CLS_g = -1;
+hid_t H5E_tools_g = -1;
+hid_t H5E_tools_min_id_g = -1;
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 */
@@ -40,7 +34,7 @@ FILE *rawinstream = NULL; /* should initialize to stdin but gcc moa
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; /* binary form */
+int bin_form = 0; /* binary form, default NATIVE */
int region_output; /* region output */
int oid_output; /* oid output */
int data_output; /* data output */
@@ -83,18 +77,13 @@ typedef enum {
#define NUM_DRIVERS (sizeof(drivernames) / sizeof(drivernames[0]))
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Initialize the H5 Tools library
- * Description:
- * This should be called before any other h5tools function is called.
- * Effect of any h5tools function called before this has been called is
- * undetermined.
- * Return:
- * None
- * Programmer:
- * Albert Cheng, 2000-10-31
- * Modifications:
+ * Function: h5tools_init
+ *
+ * Purpose: This should be called before any other h5tools function is called.
+ * Effect of any h5tools function called before this has been called is
+ * undetermined.
+ *
+ * Return None
*-------------------------------------------------------------------------
*/
void
@@ -127,19 +116,14 @@ h5tools_init(void)
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Close the H5 Tools library
- * Description:
- * Close or release resources such as files opened by the library. This
- * should be called after all other h5tools functions have been called.
- * Effect of any h5tools function called after this has been called is
- * undetermined.
- * Return:
- * None
- * Programmer:
- * Albert Cheng, 2000-10-31
- * Modifications:
+ * Function: h5tools_close
+ *
+ * Purpose: Close or release resources such as files opened by the library. This
+ * should be called after all other h5tools functions have been called.
+ * Effect of any h5tools function called after this has been called is
+ * undetermined.
+ *
+ * Return: None
*-------------------------------------------------------------------------
*/
void
@@ -199,19 +183,13 @@ h5tools_close(void)
}
/*-------------------------------------------------------------------------
- * Function: h5tools_set_data_output_file
+ * Function: h5tools_set_data_output_file
*
- * Purpose: Open fname as the output file for dataset raw data.
- * Set rawdatastream as its file stream.
- *
- * Return: 0 -- succeeded
- * negative -- failed
- *
- * Programmer: Albert Cheng, 2000/09/30
- *
- * Modifications:
- * pvn June, 1, 2006. Add a switch for binary output
+ * Purpose: Open fname as the output file for dataset raw data.
+ * Set rawdatastream as its file stream.
*
+ * Return: 0 -- succeeded
+ * negative -- failed
*-------------------------------------------------------------------------
*/
int
@@ -253,14 +231,13 @@ h5tools_set_data_output_file(const char *fname, int is_bin)
}
/*-------------------------------------------------------------------------
- * Function: h5tools_set_attr_output_file
+ * Function: h5tools_set_attr_output_file
*
- * Purpose: Open fname as the output file for attribute raw data.
- * Set rawattrstream as its file stream.
- *
- * Return: 0 -- succeeded
- * negative -- failed
+ * Purpose: Open fname as the output file for attribute raw data.
+ * Set rawattrstream as its file stream.
*
+ * Return: 0 -- succeeded
+ * negative -- failed
*-------------------------------------------------------------------------
*/
int
@@ -302,13 +279,13 @@ h5tools_set_attr_output_file(const char *fname, int is_bin)
}
/*-------------------------------------------------------------------------
- * Function: h5tools_set_input_file
+ * Function: h5tools_set_input_file
*
- * Purpose: Open fname as the input file for raw input.
- * Set rawinstream as its file stream.
+ * Purpose: Open fname as the input file for raw input.
+ * Set rawinstream as its file stream.
*
- * Return: 0 -- succeeded
- * negative -- failed
+ * Return: 0 -- succeeded
+ * negative -- failed
*
*-------------------------------------------------------------------------
*/
@@ -350,13 +327,13 @@ h5tools_set_input_file(const char *fname, int is_bin)
}
/*-------------------------------------------------------------------------
- * Function: h5tools_set_output_file
+ * Function: h5tools_set_output_file
*
- * Purpose: Open fname as the output file for raw output.
- * Set rawoutstream as its file stream.
+ * Purpose: Open fname as the output file for raw output.
+ * Set rawoutstream as its file stream.
*
- * Return: 0 -- succeeded
- * negative -- failed
+ * Return: 0 -- succeeded
+ * negative -- failed
*
*-------------------------------------------------------------------------
*/
@@ -398,14 +375,13 @@ h5tools_set_output_file(const char *fname, int is_bin)
}
/*-------------------------------------------------------------------------
- * Function: h5tools_set_error_file
- *
- * Purpose: Open fname as the error output file for dataset raw error.
- * Set rawerrorstream as its file stream.
+ * Function: h5tools_set_error_file
*
- * Return: 0 -- succeeded
- * negative -- failed
+ * Purpose: Open fname as the error output file for dataset raw error.
+ * Set rawerrorstream as its file stream.
*
+ * Return: 0 -- succeeded
+ * negative -- failed
*-------------------------------------------------------------------------
*/
int
@@ -447,33 +423,28 @@ h5tools_set_error_file(const char *fname, int is_bin)
}
/*-------------------------------------------------------------------------
- * Audience: Private
- * Chapter: H5Tools Library
- * Purpose: Get a FAPL for a driver
- * Description:
- * Get a FAPL for a given VFL driver name.
- * Return:
- * None
- * Programmer:
- * Quincey Koziol, 2004-02-04
- * Modifications:
- * Pedro Vicente Nunes, Thursday, July 27, 2006
- * Added error return conditions for the H5Pset_fapl calls
+ * Function: h5tools_get_fapl
+ *
+ * Purpose: Get a FAPL for a given VFL driver name.
+ *
+ * Return: positive - succeeded
+ * negative - failed
*-------------------------------------------------------------------------
*/
static hid_t
h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
{
- hid_t new_fapl; /* Copy of file access property list passed in, or new property list */
+ hid_t new_fapl = -1; /* Copy of file access property list passed in, or new property list */
+ int ret_value = SUCCEED;
/* Make a copy of the FAPL, for the file open call to use, eventually */
if (fapl == H5P_DEFAULT) {
if ((new_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
} /* end if */
else {
if ((new_fapl = H5Pcopy(fapl)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcopy failed");
} /* end else */
/* Determine which driver the user wants to open the file with. Try
@@ -481,7 +452,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
if (!HDstrcmp(driver, drivernames[SEC2_IDX])) {
/* SEC2 driver */
if (H5Pset_fapl_sec2(new_fapl) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_sec2 failed");
if (drivernum)
*drivernum = SEC2_IDX;
@@ -493,7 +464,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
* is the member size.
*/
if (H5Pset_fapl_family(new_fapl, (hsize_t) 0, H5P_DEFAULT) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_family failed");
if (drivernum)
*drivernum = FAMILY_IDX;
@@ -501,7 +472,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
else if (!HDstrcmp(driver, drivernames[SPLIT_IDX])) {
/* SPLIT Driver */
if (H5Pset_fapl_split(new_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_split failed");
if (drivernum)
*drivernum = SPLIT_IDX;
@@ -509,7 +480,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
else if (!HDstrcmp(driver, drivernames[MULTI_IDX])) {
/* MULTI Driver */
if (H5Pset_fapl_multi(new_fapl, NULL, NULL, NULL, NULL, TRUE) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_multi failed");
if(drivernum)
*drivernum = MULTI_IDX;
@@ -525,29 +496,28 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
if(mpi_initialized && !mpi_finalized) {
if(H5Pset_fapl_mpio(new_fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_mpio failed");
if(drivernum)
*drivernum = MPIO_IDX;
} /* end if */
}
#endif /* H5_HAVE_PARALLEL */
else
- goto error;
+ ret_value = -1;
- return(new_fapl);
-
-error:
- if(new_fapl != H5P_DEFAULT)
+done:
+ if((new_fapl != H5P_DEFAULT) && (ret_value < 0)) {
H5Pclose(new_fapl);
- return -1;
+ new_fapl = -1;
+ }
+
+ return(new_fapl);
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Open a file with various VFL drivers.
- * Description:
- * Loop through the various types of VFL drivers trying to open FNAME.
+ * Function: h5tools_fopen
+ *
+ * Purpose: Loop through the various types of VFL drivers trying to open FNAME.
* If the HDF5 library is version 1.2 or less, then we have only the SEC2
* driver to try out. If the HDF5 library is greater than version 1.2,
* then we have the FAMILY, SPLIT, and MULTI drivers to play with.
@@ -555,6 +525,7 @@ error:
* If DRIVER is non-NULL, then it will try to open the file with that
* driver first. We assume that the user knows what they are doing so, if
* we fail, then we won't try other file drivers.
+ *
* Return:
* On success, returns a file id for the opened file. If DRIVERNAME is
* non-null then the first DRIVERNAME_SIZE-1 characters of the driver
@@ -562,38 +533,6 @@ error:
*
* Otherwise, the function returns FAIL. If DRIVERNAME is non-null then
* the first byte is set to the null terminator.
- * Programmer:
- * Lost in the mists of time.
- * Modifications:
- * Robb Matzke, 2000-06-23
- * We only have to initialize driver[] on the first call, thereby
- * preventing memory leaks from repeated calls to H5Pcreate().
- *
- * Robb Matzke, 2000-06-23
- * Added DRIVERNAME_SIZE arg to prevent overflows when writing to
- * DRIVERNAME.
- *
- * Robb Matzke, 2000-06-23
- * Added test to prevent coredump when the file could not be opened by
- * any driver.
- *
- * Robb Matzke, 2000-06-23
- * Changed name from H5ToolsFopen() so it jives better with the names we
- * already have at the top of this source file.
- *
- * Thomas Radke, 2000-09-12
- * Added Stream VFD to the driver[] array.
- *
- * Bill Wendling, 2001-01-10
- * Changed macro behavior so that if we have a version other than 1.2.x
- * (i.e., > 1.2), then we do the drivers check.
- *
- * Bill Wendling, 2001-07-30
- * Added DRIVER parameter so that the user can specify "try this driver"
- * instead of the default behaviour. If it fails to open the file with
- * that driver, this will fail completely (i.e., we won't try the other
- * drivers). We're assuming the user knows what they're doing. How UNIX
- * of us.
*-------------------------------------------------------------------------
*/
hid_t
@@ -658,18 +597,13 @@ done:
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Count the number of columns in a string.
- * Description:
- * Count the number of columns in a string. This is the number of
- * characters in the string not counting line-control characters.
- * Return:
- * On success, returns the width of the string. Otherwise this function
- * returns 0.
- * Programmer:
- * Robb Matzke, Tuesday, April 27, 1999
- * Modifications:
+ * Function: h5tools_count_ncols
+ *
+ * Purpose: Count the number of columns in a string. This is the number of
+ * characters in the string not counting line-control characters.
+ *
+ * Return: success - returns the width of the string.
+ * failure - 0.
*-------------------------------------------------------------------------
*/
static size_t
@@ -687,20 +621,17 @@ h5tools_count_ncols(const char *s)
/*-------------------------------------------------------------------------
* Function: h5tools_detect_vlen
*
- * Purpose: Recursive check for any variable length data in given type.
+ * Purpose: Recursive check for any variable length data in given type.
*
- * Return:
- * TRUE : type conatains any variable length data
- * FALSE : type doesn't contain any variable length data
- * Negative value: error occur
- *
- * Programmer: Jonathan Kim March 18, 2011
+ * Return: TRUE : type contains any variable length data
+ * FALSE : type doesn't contain any variable length data
+ * Negative value: failed
*-------------------------------------------------------------------------
*/
htri_t
h5tools_detect_vlen(hid_t tid)
{
- htri_t ret;
+ htri_t ret = FALSE;
/* recursive detect any vlen data values in type (compound, array ...) */
ret = H5Tdetect_class(tid, H5T_VLEN);
@@ -719,20 +650,18 @@ done:
/*-------------------------------------------------------------------------
* Function: h5tools_detect_vlen_str
*
- * Purpose: Recursive check for variable length string of a datatype.
- *
- * Return:
- * TRUE : type conatains any variable length string
- * FALSE : type doesn't contain any variable length string
- * Negative value: error occur
+ * Purpose: Recursive check for variable length string of a datatype.
*
+ * Return: TRUE : type contains any variable length string
+ * FALSE : type doesn't contain any variable length string
+ * Negative value: failed
*-------------------------------------------------------------------------
*/
htri_t
h5tools_detect_vlen_str(hid_t tid)
{
H5T_class_t tclass = -1;
- htri_t ret = FALSE;
+ htri_t ret = FALSE;
ret = H5Tis_variable_str(tid);
if((ret == TRUE) || (ret < 0))
@@ -780,25 +709,13 @@ done:
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Emit a simple prefix to STREAM.
- * Description:
- * If /ctx->need_prefix/ is set then terminate the current line (if
- * applicable), calculate the prefix string, and display it at the start
- * of a line.
- * Return:
- * None
- * Programmer:
- * Robb Matzke, Monday, April 26, 1999
- * Modifications:
- * Robb Matzke, 1999-09-29
- * If a new prefix is printed then the current element number is set back
- * to zero.
- * pvn, 2004-07-08
- * Added support for printing array indices:
- * the indentation is printed before the prefix (printed one indentation
- * level before)
+ * Function: h5tools_simple_prefix
+ *
+ * Purpose: If /ctx->need_prefix/ is set then terminate the current line (if
+ * applicable), calculate the prefix string, and display it at the start
+ * of a line.
+ *
+ * Return: None
*-------------------------------------------------------------------------
*/
void
@@ -806,7 +723,7 @@ 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 */
+ h5tools_str_t str; /*temporary for indentation */
size_t templength = 0;
unsigned u, indentlevel = 0;
@@ -877,15 +794,13 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Emit a simple prefix to STREAM.
- * Description:
- * If /ctx->need_prefix/ is set then terminate the current line (if
- * applicable), calculate the prefix string, and display it at the start
- * of a line. Calls region specific function.
- * Return:
- * None
+ * Function: h5tools_region_simple_prefix
+ *
+ * Purpose: If /ctx->need_prefix/ is set then terminate the current line (if
+ * applicable), calculate the prefix string, and display it at the start
+ * of a line. Calls region specific function.
+ *
+ * Return: None
*-------------------------------------------------------------------------
*/
void
@@ -893,7 +808,7 @@ 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 */
+ h5tools_str_t str; /*temporary for indentation */
size_t templength = 0;
unsigned u, indentlevel = 0;
@@ -964,28 +879,26 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Render an element to output STREAM.
- * Description:
- * Prints the string buffer to the output STREAM. The string is
- * printed according to the format described in INFO. The CTX struct
- * contains context information shared between calls to this function.
+ * Function: h5tools_render_element
*
- * Return:
- * False if a dimension end is reached, otherwise true
+ * Purpose: Prints the string buffer to the output STREAM. The string is
+ * printed according to the format described in INFO. The CTX struct
+ * contains context information shared between calls to this function.
+ *
+ * Return: False if a dimension end is reached
+ * True otherwise
*
* In/Out:
- * h5tools_context_t *ctx
- * h5tools_str_t *buffer
- * hsize_t *curr_pos
+ * h5tools_context_t *ctx
+ * h5tools_str_t *buffer
+ * hsize_t *curr_pos
*
* Parameters Description:
- * h5tools_str_t *buffer is the string into which to render
- * hsize_t curr_pos is the total data element position
- * size_t ncols
- * hsize_t local_elmt_counter is the local element loop counter
- * hsize_t elmt_count is the data element loop counter
+ * h5tools_str_t *buffer is the string into which to render
+ * hsize_t curr_pos is the total data element position
+ * size_t ncols
+ * hsize_t local_elmt_counter is the local element loop counter
+ * hsize_t elmt_count is the data element loop counter
*-------------------------------------------------------------------------
*/
hbool_t
@@ -994,10 +907,10 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter)
{
hbool_t dimension_break = TRUE;
- char *s;
- char *section; /*a section of output */
- int secnum; /*section sequence number */
- int multiline; /*datum was multiline */
+ char *s = NULL;
+ char *section = NULL; /* a section of output */
+ int secnum; /* section sequence number */
+ int multiline; /* datum was multiline */
if (stream == NULL)
return dimension_break;
@@ -1120,29 +1033,28 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Render a region element to output STREAM.
- * Description:
- * Prints the string buffer to the output STREAM. The string is
- * printed according to the format described in INFO. The CTX struct
- * contains context information shared between calls to this function.
+ * Function: h5tools_render_region_element
+ *
+ * Purpose: Prints the string buffer to the output STREAM. The string is
+ * printed according to the format described in INFO. The CTX struct
+ * contains context information shared between calls to this function.
*
* Return:
- * False if a dimension end is reached, otherwise true
+ * False if a dimension end is reached
+ * True otherwise
*
* In/Out:
- * h5tools_context_t *ctx
- * h5tools_str_t *buffer
- * hsize_t *curr_pos
+ * h5tools_context_t *ctx
+ * h5tools_str_t *buffer
+ * hsize_t *curr_pos
*
* Parameters Description:
- * h5tools_str_t *buffer is the string into which to render
- * hsize_t curr_pos is the total data element position
- * size_t ncols
- * hsize_t *ptdata
- * hsize_t local_elmt_counter is the local element loop counter
- * hsize_t elmt_count is the data element loop counter
+ * h5tools_str_t *buffer is the string into which to render
+ * hsize_t curr_pos is the total data element position
+ * size_t ncols
+ * hsize_t *ptdata
+ * hsize_t local_elmt_counter is the local element loop counter
+ * hsize_t elmt_count is the data element loop counter
*-------------------------------------------------------------------------
*/
hbool_t
@@ -1151,10 +1063,10 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter)
{
hbool_t dimension_break = TRUE;
- char *s;
- char *section; /*a section of output */
- int secnum; /*section sequence number */
- int multiline; /*datum was multiline */
+ char *s = NULL;
+ char *section = NULL; /* a section of output */
+ int secnum; /* section sequence number */
+ int multiline; /* datum was multiline */
s = h5tools_str_fmt(buffer, (size_t)0, "%s");
@@ -1276,11 +1188,11 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
}
/*-------------------------------------------------------------------------
- * Function: init_acc_pos
+ * Function: init_acc_pos
*
- * Purpose: initialize accumulator and matrix position
+ * Purpose: initialize accumulator and matrix position
*
- * Return: void
+ * Return: void
*-------------------------------------------------------------------------
*/
void
@@ -1289,22 +1201,22 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
int i;
unsigned j;
- HDassert(ctx->ndims);
-
- 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];
- for (j = 0; j < ctx->ndims; j++)
- ctx->pos[j] = 0;
+ 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];
+ for (j = 0; j < ctx->ndims; j++)
+ ctx->pos[j] = 0;
+ }
}
/*-------------------------------------------------------------------------
* Function: render_bin_output
*
- * Purpose: Write one element of memory buffer to a binary file stream
+ * Purpose: Write one element of memory buffer to a binary file stream
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: Success: SUCCEED
+ * Failure: FAIL
*-------------------------------------------------------------------------
*/
int
@@ -1350,7 +1262,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
{
unsigned int i;
H5T_str_t pad;
- char *s;
+ char *s = NULL;
unsigned char tempuchar;
pad = H5Tget_strpad(tid);
@@ -1378,7 +1290,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
break;
case H5T_COMPOUND:
{
- int snmembs;
+ int snmembs;
unsigned nmembs;
if((snmembs = H5Tget_nmembers(tid)) < 0)
@@ -1390,7 +1302,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
mem = ((unsigned char*)_mem) + block_index * size;
for (j = 0; j < nmembs; j++) {
- hid_t memb;
+ hid_t memb = -1;
size_t offset;
offset = H5Tget_member_offset(tid, j);
@@ -1410,19 +1322,23 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
{
int k, ndims;
hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts;
- hid_t memb;
+ hid_t memb = -1;
/* get the array's base datatype for each element */
memb = H5Tget_super(tid);
ndims = H5Tget_array_ndims(tid);
H5Tget_array_dims2(tid, dims);
- HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
-
- /* calculate the number of array elements */
- for (k = 0, nelmts = 1; k < ndims; k++) {
- temp_nelmts = nelmts;
- temp_nelmts *= dims[k];
- nelmts = (size_t) temp_nelmts;
+ if(ndims >= 1 && ndims <= H5S_MAX_RANK) {
+ /* calculate the number of array elements */
+ for (k = 0, nelmts = 1; k < ndims; k++) {
+ temp_nelmts = nelmts;
+ temp_nelmts *= dims[k];
+ nelmts = (size_t) temp_nelmts;
+ }
+ }
+ else {
+ H5Tclose(memb);
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "calculate the number of array elements failed");
}
for (block_index = 0; block_index < block_nelmts; block_index++) {
@@ -1439,7 +1355,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
case H5T_VLEN:
{
hsize_t nelmts;
- hid_t memb;
+ hid_t memb = -1;
/* get the VL sequences's base datatype for each element */
memb = H5Tget_super(tid);
@@ -1464,7 +1380,8 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
/* if (H5Tequal(tid, H5T_STD_REF_DSETREG)) */
if (region_output) {
/* region data */
- hid_t region_id, region_space;
+ hid_t region_id = -1;
+ hid_t region_space = -1;
H5S_sel_type region_type;
for (block_index = 0; block_index < block_nelmts; block_index++) {
@@ -1514,15 +1431,13 @@ CATCH
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Print the data values from a dataset referenced by region blocks.
+ * Function: render_bin_output_region_data_blocks
*
- * Description:
- * This is a special case subfunction to print the data in a region reference of type blocks.
+ * Purpose: Print the data values from a dataset referenced by region blocks.
+ * This is a special case subfunction to print the data in a region reference of type blocks.
*
- * Return:
- * The function returns FAIL if there was an error, otherwise SUCEED
+ * Return: FAIL if there was an error
+ * SUCCEED otherwise
*
*-------------------------------------------------------------------------
*/
@@ -1611,16 +1526,13 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Print some values from a dataset referenced by region blocks.
+ * Function: render_bin_output_region_blocks
*
- * Description:
- * This is a special case subfunction to dump a region reference using blocks.
- *
- * Return:
- * The function returns False if ERROR, otherwise True
+ * Purpose: Print some values from a dataset referenced by region blocks.
+ * This is a special case subfunction to dump a region reference using blocks.
*
+ * Return: False if ERROR
+ * True otherwise
*-------------------------------------------------------------------------
*/
hbool_t
@@ -1631,7 +1543,7 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
hssize_t snblocks;
hsize_t nblocks;
hsize_t alloc_size;
- hsize_t *ptdata;
+ hsize_t *ptdata = NULL;
int sndims;
unsigned ndims;
hid_t dtype = -1;
@@ -1647,7 +1559,6 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
ndims = (unsigned)sndims;
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
- HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL)
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
@@ -1678,8 +1589,7 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
+ * Function: H5Tools Library
* Purpose: Print the data values from a dataset referenced by region points.
*
* Description:
@@ -1739,16 +1649,13 @@ render_bin_output_region_data_points(hid_t region_space, hid_t region_id,
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Print some values from a dataset referenced by region points.
+ * Function: render_bin_output_region_points
*
- * Description:
- * This is a special case subfunction to dump a region reference using points.
- *
- * Return:
- * The function returns False if the last dimension has been reached, otherwise True
+ * Purpose: Print some values from a dataset referenced by region points.
+ * This is a special case function to dump a region reference using points.
*
+ * Return: False if the last dimension has been reached
+ * True otherwise
*-------------------------------------------------------------------------
*/
hbool_t
@@ -1794,11 +1701,12 @@ CATCH
}
/*-------------------------------------------------------------------------
- * Function: h5tools_is_zero
+ * Function: h5tools_is_zero
*
- * Purpose: Determines if memory is initialized to all zero bytes.
+ * Purpose: Determines if memory is initialized to all zero bytes.
*
- * Return: TRUE if all bytes are zero; FALSE otherwise
+ * Return: TRUE if all bytes are zero
+ * FALSE otherwise
*-------------------------------------------------------------------------
*/
hbool_t
@@ -1814,23 +1722,20 @@ h5tools_is_zero(const void *_mem, size_t size)
}
/*-------------------------------------------------------------------------
- * Function: h5tools_is_obj_same
+ * Function: h5tools_is_obj_same
*
- * Purpose: Check if two given object IDs or link names point to the same object.
+ * Purpose: Check if two given object IDs or link names point to the same object.
*
* Parameters:
- * hid_t loc_id1: location of the first object
- * char *name1: link name of the first object.
- * Use "." or NULL if loc_id1 is the object to be compared.
- * hid_t loc_id2: location of the second object
- * char *name1: link name of the first object.
- * Use "." or NULL if loc_id2 is the object to be compared.
- *
- * Return: TRUE if it is the same object; FALSE otherwise.
+ * hid_t loc_id1: location of the first object
+ * char *name1: link name of the first object.
+ * Use "." or NULL if loc_id1 is the object to be compared.
+ * hid_t loc_id2: location of the second object
+ * char *name1: link name of the first object.
+ * Use "." or NULL if loc_id2 is the object to be compared.
*
- * Programmer: Peter Cao
- * 4/27/2011
- *
+ * Return: TRUE if it is the same object
+ * FALSE otherwise.
*-------------------------------------------------------------------------
*/
hbool_t
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index f8f1810..31c54d3 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -12,16 +12,10 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Robb Matzke <matzke@llnl.gov>
- * Thursday, July 23, 1998
- *
* Purpose: A library for displaying the values of a dataset in a human
* readable format.
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "h5tools.h"
#include "h5tools_dump.h"
#include "h5tools_ref.h"
@@ -29,72 +23,72 @@
#include "H5private.h"
h5tool_format_t h5tools_dataformat = {
-0, /*raw */
-
-"", /*fmt_raw */
-"%d", /*fmt_int */
-"%u", /*fmt_uint */
-"%hhd", /*fmt_schar */
-"%u", /*fmt_uchar */
-"%d", /*fmt_short */
-"%u", /*fmt_ushort */
-"%ld", /*fmt_long */
-"%lu", /*fmt_ulong */
-NULL, /*fmt_llong */
-NULL, /*fmt_ullong */
-"%g", /*fmt_double */
-"%g", /*fmt_float */
-
-0, /*ascii */
-0, /*str_locale */
-0, /*str_repeat */
-
-"[ ", /*arr_pre */
-",", /*arr_sep */
-" ]", /*arr_suf */
-1, /*arr_linebreak */
-
-"", /*cmpd_name */
-",\n", /*cmpd_sep */
-"{", /*cmpd_pre */
-"}", /*cmpd_suf */
-"\n", /*cmpd_end */
-
-", ", /*vlen_sep */
-"(", /*vlen_pre */
-")", /*vlen_suf */
-"", /*vlen_end */
-
-"%s", /*elmt_fmt */
-",", /*elmt_suf1 */
-" ", /*elmt_suf2 */
-
-"", /*idx_n_fmt */
-"", /*idx_sep */
-"", /*idx_fmt */
-
-80, /*line_ncols *//*standard default columns */
-0, /*line_per_line */
-"", /*line_pre */
-"%s", /*line_1st */
-"%s", /*line_cont */
-"", /*line_suf */
-"", /*line_sep */
-1, /*line_multi_new */
-" ", /*line_indent */
-
-1, /*skip_first */
-
-1, /*obj_hidefileno */
-" "H5_PRINTF_HADDR_FMT, /*obj_format */
-
-1, /*dset_hidefileno */
-"DATASET %s ", /*dset_format */
-"%s", /*dset_blockformat_pre */
-"%s", /*dset_ptformat_pre */
-"%s", /*dset_ptformat */
-1, /*array indices */
-1 /*escape non printable characters */
+ 0, /*raw */
+
+ "", /*fmt_raw */
+ "%d", /*fmt_int */
+ "%u", /*fmt_uint */
+ "%hhd", /*fmt_schar */
+ "%u", /*fmt_uchar */
+ "%d", /*fmt_short */
+ "%u", /*fmt_ushort */
+ "%ld", /*fmt_long */
+ "%lu", /*fmt_ulong */
+ NULL, /*fmt_llong */
+ NULL, /*fmt_ullong */
+ "%g", /*fmt_double */
+ "%g", /*fmt_float */
+
+ 0, /*ascii */
+ 0, /*str_locale */
+ 0, /*str_repeat */
+
+ "[ ", /*arr_pre */
+ ",", /*arr_sep */
+ " ]", /*arr_suf */
+ 1, /*arr_linebreak */
+
+ "", /*cmpd_name */
+ ",\n", /*cmpd_sep */
+ "{", /*cmpd_pre */
+ "}", /*cmpd_suf */
+ "\n", /*cmpd_end */
+
+ ", ", /*vlen_sep */
+ "(", /*vlen_pre */
+ ")", /*vlen_suf */
+ "", /*vlen_end */
+
+ "%s", /*elmt_fmt */
+ ",", /*elmt_suf1 */
+ " ", /*elmt_suf2 */
+
+ "", /*idx_n_fmt */
+ "", /*idx_sep */
+ "", /*idx_fmt */
+
+ 80, /*line_ncols *//*standard default columns */
+ 0, /*line_per_line */
+ "", /*line_pre */
+ "%s", /*line_1st */
+ "%s", /*line_cont */
+ "", /*line_suf */
+ "", /*line_sep */
+ 1, /*line_multi_new */
+ " ", /*line_indent */
+
+ 1, /*skip_first */
+
+ 1, /*obj_hidefileno */
+ " "H5_PRINTF_HADDR_FMT, /*obj_format */
+
+ 1, /*dset_hidefileno */
+ "DATASET %s ", /*dset_format */
+ "%s", /*dset_blockformat_pre */
+ "%s", /*dset_ptformat_pre */
+ "%s", /*dset_ptformat */
+ 1, /*array indices */
+ 1 /*escape non printable characters */
};
const h5tools_dump_header_t h5tools_standardformat = {
@@ -631,8 +625,7 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
- if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL)
- {
+ if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL) {
HERROR(H5E_tools_g, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
HGOTO_DONE(dimension_break);
}
@@ -1896,9 +1889,8 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
obj = search_obj(h5dump_type_table, oinfo.addr);
if(obj) {
- if(!obj->recorded) {
+ if(!obj->recorded)
h5tools_str_append(buffer,"\"/#"H5_PRINTF_HADDR_FMT"\"", obj->objno);
- }
else
h5tools_str_append(buffer, "\"%s\"", obj->objname);
}
@@ -1915,121 +1907,86 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
switch (type_class) {
case H5T_INTEGER:
- if (H5Tequal(type, H5T_STD_I8BE) == TRUE) {
+ if (H5Tequal(type, H5T_STD_I8BE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_I8BE");
- }
- else if (H5Tequal(type, H5T_STD_I8LE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_I8LE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_I8LE");
- }
- else if (H5Tequal(type, H5T_STD_I16BE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_I16BE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_I16BE");
- }
- else if (H5Tequal(type, H5T_STD_I16LE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_I16LE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_I16LE");
- }
- else if (H5Tequal(type, H5T_STD_I32BE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_I32BE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_I32BE");
- }
- else if (H5Tequal(type, H5T_STD_I32LE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_I32LE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_I32LE");
- }
- else if (H5Tequal(type, H5T_STD_I64BE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_I64BE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_I64BE");
- }
- else if (H5Tequal(type, H5T_STD_I64LE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_I64LE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_I64LE");
- }
- else if (H5Tequal(type, H5T_STD_U8BE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_U8BE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_U8BE");
- }
- else if (H5Tequal(type, H5T_STD_U8LE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_U8LE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_U8LE");
- }
- else if (H5Tequal(type, H5T_STD_U16BE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_U16BE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_U16BE");
- }
- else if (H5Tequal(type, H5T_STD_U16LE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_U16LE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_U16LE");
- }
- else if (H5Tequal(type, H5T_STD_U32BE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_U32BE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_U32BE");
- }
- else if (H5Tequal(type, H5T_STD_U32LE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_U32LE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_U32LE");
- }
- else if (H5Tequal(type, H5T_STD_U64BE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_U64BE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_U64BE");
- }
- else if (H5Tequal(type, H5T_STD_U64LE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_U64LE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_U64LE");
- }
- else if (H5Tequal(type, H5T_NATIVE_SCHAR) == TRUE) {
+ else if (H5Tequal(type, H5T_NATIVE_SCHAR) == TRUE)
h5tools_str_append(buffer, "H5T_NATIVE_SCHAR");
- }
- else if (H5Tequal(type, H5T_NATIVE_UCHAR) == TRUE) {
+ else if (H5Tequal(type, H5T_NATIVE_UCHAR) == TRUE)
h5tools_str_append(buffer, "H5T_NATIVE_UCHAR");
- }
- else if (H5Tequal(type, H5T_NATIVE_SHORT) == TRUE) {
+ else if (H5Tequal(type, H5T_NATIVE_SHORT) == TRUE)
h5tools_str_append(buffer, "H5T_NATIVE_SHORT");
- }
- else if (H5Tequal(type, H5T_NATIVE_USHORT) == TRUE) {
+ else if (H5Tequal(type, H5T_NATIVE_USHORT) == TRUE)
h5tools_str_append(buffer, "H5T_NATIVE_USHORT");
- }
- else if (H5Tequal(type, H5T_NATIVE_INT) == TRUE) {
+ else if (H5Tequal(type, H5T_NATIVE_INT) == TRUE)
h5tools_str_append(buffer, "H5T_NATIVE_INT");
- }
- else if (H5Tequal(type, H5T_NATIVE_UINT) == TRUE) {
+ else if (H5Tequal(type, H5T_NATIVE_UINT) == TRUE)
h5tools_str_append(buffer, "H5T_NATIVE_UINT");
- }
- else if (H5Tequal(type, H5T_NATIVE_LONG) == TRUE) {
+ else if (H5Tequal(type, H5T_NATIVE_LONG) == TRUE)
h5tools_str_append(buffer, "H5T_NATIVE_LONG");
- }
- else if (H5Tequal(type, H5T_NATIVE_ULONG) == TRUE) {
+ else if (H5Tequal(type, H5T_NATIVE_ULONG) == TRUE)
h5tools_str_append(buffer, "H5T_NATIVE_ULONG");
- }
- else if (H5Tequal(type, H5T_NATIVE_LLONG) == TRUE) {
+ else if (H5Tequal(type, H5T_NATIVE_LLONG) == TRUE)
h5tools_str_append(buffer, "H5T_NATIVE_LLONG");
- }
- else if (H5Tequal(type, H5T_NATIVE_ULLONG) == TRUE) {
+ else if (H5Tequal(type, H5T_NATIVE_ULLONG) == TRUE)
h5tools_str_append(buffer, "H5T_NATIVE_ULLONG");
- }
else {
/* byte order */
if (H5Tget_size(type) > 1) {
order = H5Tget_order(type);
- if (H5T_ORDER_LE == order) {
+ if (H5T_ORDER_LE == order)
order_s = " little-endian";
- }
- else if (H5T_ORDER_BE == order) {
+ else if (H5T_ORDER_BE == order)
order_s = " big-endian";
- }
- else if (H5T_ORDER_VAX == order) {
+ else if (H5T_ORDER_VAX == order)
order_s = " mixed-endian";
- }
- else {
+ else
order_s = " unknown-byte-order";
- }
}
- else {
+ else
order_s = "";
- }
/* sign */
if ((sign = H5Tget_sign(type)) >= 0) {
- if (H5T_SGN_NONE == sign) {
+ if (H5T_SGN_NONE == sign)
sign_s = " unsigned";
- }
- else if (H5T_SGN_2 == sign) {
+ else if (H5T_SGN_2 == sign)
sign_s = "";
- }
- else {
+ else
sign_s = " unknown-sign";
- }
}
- else {
+ else
sign_s = " unknown-sign";
- }
/* print size, order, and sign */
h5tools_str_append(buffer, "%lu-bit%s%s integer",
@@ -2038,56 +1995,42 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
break;
case H5T_FLOAT:
- if (H5Tequal(type, H5T_IEEE_F32BE) == TRUE) {
+ if (H5Tequal(type, H5T_IEEE_F32BE) == TRUE)
h5tools_str_append(buffer, "H5T_IEEE_F32BE");
- }
- else if (H5Tequal(type, H5T_IEEE_F32LE) == TRUE) {
+ else if (H5Tequal(type, H5T_IEEE_F32LE) == TRUE)
h5tools_str_append(buffer, "H5T_IEEE_F32LE");
- }
- else if (H5Tequal(type, H5T_IEEE_F64BE) == TRUE) {
+ else if (H5Tequal(type, H5T_IEEE_F64BE) == TRUE)
h5tools_str_append(buffer, "H5T_IEEE_F64BE");
- }
- else if (H5Tequal(type, H5T_IEEE_F64LE) == TRUE) {
+ else if (H5Tequal(type, H5T_IEEE_F64LE) == TRUE)
h5tools_str_append(buffer, "H5T_IEEE_F64LE");
- }
- else if (H5Tequal(type, H5T_VAX_F32) == TRUE) {
+ else if (H5Tequal(type, H5T_VAX_F32) == TRUE)
h5tools_str_append(buffer, "H5T_VAX_F32");
- }
- else if (H5Tequal(type, H5T_VAX_F64) == TRUE) {
+ else if (H5Tequal(type, H5T_VAX_F64) == TRUE)
h5tools_str_append(buffer, "H5T_VAX_F64");
- }
- else if (H5Tequal(type, H5T_NATIVE_FLOAT) == TRUE) {
+ else if (H5Tequal(type, H5T_NATIVE_FLOAT) == TRUE)
h5tools_str_append(buffer, "H5T_NATIVE_FLOAT");
- }
- else if (H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE) {
+ else if (H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE)
h5tools_str_append(buffer, "H5T_NATIVE_DOUBLE");
#if H5_SIZEOF_LONG_DOUBLE !=0
- }
- else if (H5Tequal(type, H5T_NATIVE_LDOUBLE) == TRUE) {
+ else if (H5Tequal(type, H5T_NATIVE_LDOUBLE) == TRUE)
h5tools_str_append(buffer, "H5T_NATIVE_LDOUBLE");
#endif
- }
else {
/* byte order */
if (H5Tget_size(type) > 1) {
order = H5Tget_order(type);
- if (H5T_ORDER_LE == order) {
+ if (H5T_ORDER_LE == order)
order_s = " little-endian";
- }
- else if (H5T_ORDER_BE == order) {
+ else if (H5T_ORDER_BE == order)
order_s = " big-endian";
- }
- else if (H5T_ORDER_VAX == order) {
+ else if (H5T_ORDER_VAX == order)
order_s = " mixed-endian";
- }
- else {
+ else
order_s = " unknown-byte-order";
- }
}
- else {
+ else
order_s = "";
- }
/* print size and byte order */
h5tools_str_append(buffer, "%lu-bit%s floating-point",
@@ -2294,33 +2237,24 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
break;
case H5T_BITFIELD:
- if (H5Tequal(type, H5T_STD_B8BE) == TRUE) {
+ if (H5Tequal(type, H5T_STD_B8BE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_B8BE");
- }
- else if (H5Tequal(type, H5T_STD_B8LE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_B8LE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_B8LE");
- }
- else if (H5Tequal(type, H5T_STD_B16BE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_B16BE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_B16BE");
- }
- else if (H5Tequal(type, H5T_STD_B16LE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_B16LE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_B16LE");
- }
- else if (H5Tequal(type, H5T_STD_B32BE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_B32BE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_B32BE");
- }
- else if (H5Tequal(type, H5T_STD_B32LE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_B32LE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_B32LE");
- }
- else if (H5Tequal(type, H5T_STD_B64BE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_B64BE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_B64BE");
- }
- else if (H5Tequal(type, H5T_STD_B64LE) == TRUE) {
+ else if (H5Tequal(type, H5T_STD_B64LE) == TRUE)
h5tools_str_append(buffer, "H5T_STD_B64LE");
- }
- else {
+ else
h5tools_str_append(buffer, "undefined bitfield");
- }
break;
case H5T_OPAQUE:
@@ -2860,7 +2794,7 @@ 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)
{
size_t size;
- hid_t n_type;
+ hid_t n_type = -1;
void *buf = NULL;
n_type = H5Tget_native_type(type_id, H5T_DIR_DEFAULT);
@@ -3501,7 +3435,8 @@ h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info,
error_msg("unable to open attribute \"%s\"\n", attr_name);
}
else {
- hid_t type, space;
+ hid_t type = -1;
+ hid_t space = -1;
ctx->indent_level++;
@@ -3720,9 +3655,9 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info,
H5S_class_t space_type;
int ndims;
int i;
- hid_t space;
- hid_t type;
- hid_t p_type;
+ hid_t space = -1;
+ hid_t type = -1;
+ hid_t p_type = -1;
hsize_t size[64];
hsize_t alloc_size;
hsize_t nelmts = 1;
diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h
index 136c5ed..2cdaf74 100644
--- a/tools/lib/h5tools_error.h
+++ b/tools/lib/h5tools_error.h
@@ -62,11 +62,19 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
/*
+ * H5TOOLS_INFO macro, used to facilitate error reporting . The arguments are the major
+ * error number, the minor error number, and a description of the error.
+ */
+#define H5TOOLS_INFO(min_id, ...) { \
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, min_id, __VA_ARGS__); \
+}
+
+/*
* HERROR macro, used to facilitate error reporting . The arguments are the major
* error number, the minor error number, and a description of the error.
*/
-#define HERROR(maj_id, min_id, str) { \
- H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, maj_id, min_id, str); \
+#define HERROR(maj_id, min_id, ...) { \
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, maj_id, min_id, __VA_ARGS__); \
ret_value = FAIL; \
}
@@ -95,8 +103,8 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
* The return value is assigned to a variable `ret_value' and control branches
* to the `catch_except' label, if we're not already past it.
*/
-#define H5E_THROW(fail_value, min_id, str) { \
- H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, min_id, str); \
+#define H5E_THROW(fail_value, min_id, ...) { \
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, min_id, __VA_ARGS__); \
H5_LEAVE(fail_value) \
}
@@ -106,8 +114,8 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
* error string. The return value is assigned to a variable `ret_value' and
* control branches to the `done' label.
*/
-#define HGOTO_ERROR(fail_value, min_id, str) { \
- HERROR(H5E_tools_g, min_id, str); \
+#define HGOTO_ERROR(fail_value, min_id, ...) { \
+ HERROR(H5E_tools_g, min_id, __VA_ARGS__); \
HGOTO_DONE(fail_value) \
}
diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c
index 65be089..457d1af 100644
--- a/tools/lib/h5tools_filters.c
+++ b/tools/lib/h5tools_filters.c
@@ -18,191 +18,191 @@
* print a warning message
*-------------------------------------------------------------------------
*/
-static void print_warning(const char *dname, const char *fname)
+static void print_filter_warning(const char *dname, const char *fname)
{
- fprintf(stderr,
- "warning: dataset <%s> cannot be read, %s filter is not available\n",
- dname, fname);
+ fprintf(stderr,
+ "Warning: dataset <%s> cannot be read, %s filter is not available\n",
+ dname, fname);
}
/*-------------------------------------------------------------------------
* Function: h5tools_canreadf
*
- * Purpose: check if the dataset creation property list has filters that
- * are not registered in the current configuration
- * 1) the external filters GZIP and SZIP might not be available
- * 2) the internal filters might be turned off
- *
- * Return: 1, can read, 0, cannot, -1 error
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 1, 2004
+ * Purpose: check if the dataset creation property list has filters that
+ * are not registered in the current configuration
+ * 1) the external filters GZIP and SZIP might not be available
+ * 2) the internal filters might be turned off
*
+ * Return:
+ * 1 can read,
+ * 0 cannot,
+ * -1 error
*-------------------------------------------------------------------------
*/
-int h5tools_canreadf(const char* name, /* object name, serves also as boolean print */
+int
+h5tools_canreadf(const char* name, /* object name, serves also as boolean print */
hid_t dcpl_id) /* dataset creation property list */
{
+ int ret_value = 1;
+ int nfilters; /* number of filters */
+ H5Z_filter_t filtn; /* filter identification number */
+ int i; /* index */
+ int udfilter_avail; /* index */
+
+ /* get information about filters */
+ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_nfilters failed");
+
+ /* if we do not have filters, we can read the dataset safely */
+ if (!nfilters)
+ HGOTO_DONE(1);
+
+ /* check availability of filters */
+ for (i = 0; i < nfilters; i++) {
+ if ((filtn = H5Pget_filter2(dcpl_id, (unsigned) i, 0, 0, 0, (size_t) 0, 0, NULL)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_filter2 failed");
+
+ switch (filtn) {
+ /*-------------------------------------------------------------------------
+ * user defined filter
+ *-------------------------------------------------------------------------
+ */
+ default:
+ if ((udfilter_avail = H5Zfilter_avail(filtn)) < 0) {
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Zfilter_avail failed");
+ }
+ else if (!udfilter_avail) {
+ if (name)
+ print_filter_warning(name, "user defined");
+ ret_value = 0;
+ }
+ break;
- int nfilters; /* number of filters */
- H5Z_filter_t filtn; /* filter identification number */
- int i; /* index */
- int udfilter_avail; /* index */
-
- /* get information about filters */
- if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
- return -1;
-
- /* if we do not have filters, we can read the dataset safely */
- if (!nfilters)
- return 1;
-
- /* check availability of filters */
- for (i = 0; i < nfilters; i++) {
- if ((filtn = H5Pget_filter2(dcpl_id, (unsigned) i, 0, 0, 0, (size_t) 0, 0, NULL)) < 0)
- return -1;
-
- switch (filtn) {
- /*-------------------------------------------------------------------------
- * user defined filter
- *-------------------------------------------------------------------------
- */
- default:
- if ((udfilter_avail = H5Zfilter_avail(filtn)) < 0)
- return -1;
- else if (udfilter_avail == 0) {
- if (name)
- print_warning(name, "user defined");
- return 0;
- }
- break;
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE 1 , deflation like gzip
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_DEFLATE:
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_DEFLATE 1 , deflation like gzip
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_DEFLATE:
#ifndef H5_HAVE_FILTER_DEFLATE
- if (name)
- print_warning(name,"deflate");
- return 0;
+ if (name)
+ print_filter_warning(name,"deflate");
+ ret_value = 0;
#endif
- break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP 4 , szip compression
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SZIP:
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP 4 , szip compression
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SZIP:
#ifndef H5_HAVE_FILTER_SZIP
- if (name)
- print_warning(name,"SZIP");
- return 0;
+ if (name)
+ print_filter_warning(name,"SZIP");
+ ret_value = 0;
#endif
- break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SHUFFLE 2 , shuffle the data
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SHUFFLE:
- break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_FLETCHER32:
- break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_NBIT
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_NBIT:
- break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SCALEOFFSET:
- break;
- }/*switch*/
- }/*for*/
-
- return 1;
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SHUFFLE 2 , shuffle the data
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SHUFFLE:
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_FLETCHER32:
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_NBIT
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_NBIT:
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SCALEOFFSET
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SCALEOFFSET:
+ break;
+ }/*switch*/
+ }/*for*/
+
+done:
+ return ret_value;
}
/*-------------------------------------------------------------------------
* Function: h5tools_canwritef
*
- * Purpose: check if the filter is available and can write data.
- * At this time, all filters that are available can write data,
- * except SZIP, which may be configured decoder-only.
- *
- * Return: 1, can write, 0, cannot, -1 error
- *
- * Programmer:
- *
- * Date: October 5, 2004
+ * Purpose: check if the filter is available and can write data.
*
+ * Return: 1 can write,
+ * 0 cannot,
+ * -1 error
*-------------------------------------------------------------------------
*/
-int h5tools_can_encode(H5Z_filter_t filtn) {
- switch (filtn) {
- /* user defined filter */
- default:
- return 0;
+int
+h5tools_can_encode(H5Z_filter_t filtn)
+{
+ int ret_value = 1;
- case H5Z_FILTER_DEFLATE:
+ switch (filtn) {
+ /* user defined filter */
+ default:
+ HGOTO_DONE(0)
+ case H5Z_FILTER_DEFLATE:
#ifndef H5_HAVE_FILTER_DEFLATE
- return 0;
+ HGOTO_DONE(0)
#endif
break;
- case H5Z_FILTER_SZIP:
+ case H5Z_FILTER_SZIP:
#ifndef H5_HAVE_FILTER_SZIP
- return 0;
+ HGOTO_DONE(0)
#else
- {
+ {
unsigned int filter_config_flags;
if (H5Zget_filter_info(filtn, &filter_config_flags) < 0)
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Zget_filter_info failed");
if ((filter_config_flags
& (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
/* filter present but neither encode nor decode is supported (???) */
- return -1;
- }
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "neither encode nor decode is supported");
+ }
else if ((filter_config_flags
& (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_DECODE_ENABLED) {
/* decoder only: read but not write */
- return 0;
- }
+ HGOTO_DONE(0)
+ }
else if ((filter_config_flags
& (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
/* encoder only: write but not read (???) */
- return -1;
- }
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "encoder only: write but not read");
+ }
else if ((filter_config_flags
& (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED))
== (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
- return 1;
+ HGOTO_DONE(1)
}
- }
+ }
#endif
break;
- case H5Z_FILTER_SHUFFLE:
+ case H5Z_FILTER_SHUFFLE:
break;
- case H5Z_FILTER_FLETCHER32:
+ case H5Z_FILTER_FLETCHER32:
break;
- case H5Z_FILTER_NBIT:
+ case H5Z_FILTER_NBIT:
break;
- case H5Z_FILTER_SCALEOFFSET:
+ case H5Z_FILTER_SCALEOFFSET:
break;
}/*switch*/
- return 1;
+done:
+ return ret_value;
}
diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c
index 85850e3..d6e5f01 100644
--- a/tools/lib/h5tools_ref.c
+++ b/tools/lib/h5tools_ref.c
@@ -11,8 +11,6 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include <stdio.h>
-#include <stdlib.h>
#include "h5tools_ref.h"
#include "H5private.h"
#include "H5SLprivate.h"
@@ -109,19 +107,21 @@ static int
init_ref_path_table(void)
{
/* Sanity check */
- HDassert(thefile > 0);
-
- /* Create skip list to store reference path information */
- if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, NULL))==NULL)
+ if(thefile > 0) {
+ /* Create skip list to store reference path information */
+ if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, NULL))==NULL)
+ return (-1);
+
+ /* Iterate over objects in this file */
+ if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL) < 0) {
+ error_msg("unable to construct reference path table\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end if */
+
+ return(0);
+ }
+ else
return (-1);
-
- /* Iterate over objects in this file */
- if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL) < 0) {
- error_msg("unable to construct reference path table\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
-
- return(0);
}
/*-------------------------------------------------------------------------
@@ -167,6 +167,8 @@ ref_path_table_lookup(const char *thepath)
{
H5O_info_t oi;
+ if((thepath == NULL) || (HDstrlen(thepath) == 0))
+ return HADDR_UNDEF;
/* Allow lookups on the root group, even though it doesn't have any link info */
if(HDstrcmp(thepath, "/")) {
H5L_info_t li;
@@ -213,16 +215,17 @@ ref_path_table_put(const char *path, haddr_t objno)
{
ref_path_node_t *new_node;
- HDassert(ref_path_table);
- HDassert(path);
+ if(ref_path_table && path) {
+ if((new_node = (ref_path_node_t *)HDmalloc(sizeof(ref_path_node_t))) == NULL)
+ return(-1);
- if((new_node = (ref_path_node_t *)HDmalloc(sizeof(ref_path_node_t))) == NULL)
- return(-1);
+ new_node->objno = objno;
+ new_node->path = HDstrdup(path);
- new_node->objno = objno;
- new_node->path = HDstrdup(path);
-
- return(H5SL_insert(ref_path_table, new_node, &(new_node->objno)));
+ return(H5SL_insert(ref_path_table, new_node, &(new_node->objno)));
+ }
+ else
+ return (-1);
}
/*
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 1719929..fdd88ed 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -12,20 +12,12 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Bill Wendling <wendling@ncsa.uiuc.edu>
- * Monday, 19. February 2001
- *
* Purpose: These are string functions for us to use and abuse.
*/
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "H5private.h"
#include "h5tools.h" /* for h5tool_format_t structure */
#include "h5tools_ref.h"
-#include "h5tools_str.h" /*function prototypes */
+#include "h5tools_str.h" /* function prototypes */
/*
* If REPEAT_VERBOSE is defined then character strings will be printed so
@@ -645,10 +637,11 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
{
size_t nsize, offset, size=0, nelmts, start;
H5T_sign_t nsign;
- char *name;
+ char *name = NULL;
unsigned char *ucp_vp = (unsigned char *)vp;
char *cp_vp = (char *)vp;
- hid_t memb, obj;
+ hid_t memb = -1;
+ hid_t obj = -1;
static char fmt_llong[8], fmt_ullong[8];
H5T_str_t pad;
H5T_class_t type_class;
@@ -1184,7 +1177,8 @@ void
h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info,
hid_t container, void *vp)
{
- hid_t obj, region;
+ hid_t obj = -1;
+ hid_t region = -1;
char ref_name[1024];
H5S_sel_type region_type;
diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c
index ae7160b..f63c228 100644
--- a/tools/lib/h5tools_type.c
+++ b/tools/lib/h5tools_type.c
@@ -21,12 +21,6 @@
*
* Return: Success: datatype ID
* Failure: FAIL
- *
- * Programmer: Pedro Vicente Nunes
- * Tuesday, July 18, 2006
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
hid_t
@@ -43,40 +37,40 @@ h5tools_get_little_endian_type(hid_t tid)
switch(type_class) {
case H5T_INTEGER:
- if ( size == 1 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I8LE);
- else if ( size == 2 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I16LE);
- else if ( size == 4 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I32LE);
- else if ( size == 8 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I64LE);
- else if ( size == 1 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U8LE);
- else if ( size == 2 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U16LE);
- else if ( size == 4 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U32LE);
- else if ( size == 8 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U64LE);
+ if (size == 1 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I8LE);
+ else if (size == 2 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I16LE);
+ else if (size == 4 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I32LE);
+ else if (size == 8 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I64LE);
+ else if (size == 1 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U8LE);
+ else if (size == 2 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U16LE);
+ else if (size == 4 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U32LE);
+ else if (size == 8 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U64LE);
break;
case H5T_FLOAT:
- if ( size == 4)
- p_type=H5Tcopy(H5T_IEEE_F32LE);
- else if ( size == 8)
- p_type=H5Tcopy(H5T_IEEE_F64LE);
+ if (size == 4)
+ p_type = H5Tcopy(H5T_IEEE_F32LE);
+ else if (size == 8)
+ p_type = H5Tcopy(H5T_IEEE_F64LE);
break;
case H5T_BITFIELD:
- if ( size == 1)
- p_type=H5Tcopy(H5T_STD_B8LE);
- else if ( size == 2)
- p_type=H5Tcopy(H5T_STD_B16LE);
- else if ( size == 4)
- p_type=H5Tcopy(H5T_STD_B32LE);
- else if ( size == 8)
- p_type=H5Tcopy(H5T_STD_B64LE);
+ if (size == 1)
+ p_type = H5Tcopy(H5T_STD_B8LE);
+ else if (size == 2)
+ p_type = H5Tcopy(H5T_STD_B16LE);
+ else if (size == 4)
+ p_type = H5Tcopy(H5T_STD_B32LE);
+ else if (size == 8)
+ p_type = H5Tcopy(H5T_STD_B64LE);
break;
case H5T_TIME:
@@ -92,7 +86,6 @@ h5tools_get_little_endian_type(hid_t tid)
case H5T_NO_CLASS:
case H5T_NCLASSES:
default:
- HDassert(0);
break;
} /* end switch */
@@ -108,18 +101,12 @@ h5tools_get_little_endian_type(hid_t tid)
*
* Return: Success: datatype ID
* Failure: FAIL
- *
- * Programmer: Pedro Vicente Nunes
- * Tuesday, July 18, 2006
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
hid_t
h5tools_get_big_endian_type(hid_t tid)
{
- hid_t p_type=-1;
+ hid_t p_type = -1;
H5T_class_t type_class;
size_t size;
H5T_sign_t sign;
@@ -130,39 +117,39 @@ h5tools_get_big_endian_type(hid_t tid)
switch(type_class) {
case H5T_INTEGER:
- if ( size == 1 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I8BE);
- else if ( size == 2 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I16BE);
- else if ( size == 4 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I32BE);
- else if ( size == 8 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I64BE);
- else if ( size == 1 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U8BE);
- else if ( size == 2 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U16BE);
- else if ( size == 4 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U32BE);
- else if ( size == 8 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U64BE);
+ if (size == 1 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I8BE);
+ else if (size == 2 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I16BE);
+ else if (size == 4 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I32BE);
+ else if (size == 8 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I64BE);
+ else if (size == 1 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U8BE);
+ else if (size == 2 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U16BE);
+ else if (size == 4 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U32BE);
+ else if (size == 8 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U64BE);
break;
case H5T_FLOAT:
- if ( size == 4)
- p_type=H5Tcopy(H5T_IEEE_F32BE);
- else if ( size == 8)
- p_type=H5Tcopy(H5T_IEEE_F64BE);
+ if (size == 4)
+ p_type = H5Tcopy(H5T_IEEE_F32BE);
+ else if (size == 8)
+ p_type = H5Tcopy(H5T_IEEE_F64BE);
break;
case H5T_BITFIELD:
- if ( size == 1)
- p_type=H5Tcopy(H5T_STD_B8BE);
- else if ( size == 2)
- p_type=H5Tcopy(H5T_STD_B16BE);
- else if ( size == 4)
- p_type=H5Tcopy(H5T_STD_B32BE);
- else if ( size == 8)
+ if (size == 1)
+ p_type = H5Tcopy(H5T_STD_B8BE);
+ else if (size == 2)
+ p_type = H5Tcopy(H5T_STD_B16BE);
+ else if (size == 4)
+ p_type = H5Tcopy(H5T_STD_B32BE);
+ else if (size == 8)
p_type=H5Tcopy(H5T_STD_B64BE);
break;
@@ -179,7 +166,6 @@ h5tools_get_big_endian_type(hid_t tid)
case H5T_NO_CLASS:
case H5T_NCLASSES:
default:
- HDassert(0);
break;
} /* end switch */
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index 4084be0..3f66ef6 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -12,20 +12,10 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Bill Wendling <wendling@ncsa.uiuc.edu>
- * Tuesday, 6. March 2001
- */
-
-/*
* Portions of this work are derived from _Obfuscated C and Other Mysteries_,
* by Don Libes, copyright (c) 1993 by John Wiley & Sons, Inc.
*/
-#include <ctype.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "h5tools.h"
#include "h5tools_utils.h"
#include "H5private.h"
@@ -68,15 +58,11 @@ static void add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t
/*-------------------------------------------------------------------------
* Function: parallel_print
*
- * Purpose: wrapper for printf for use in parallel mode.
- *
- * Programmer: Leon Arber
- *
- * Date: December 1, 2004
- *
+ * Purpose: wrapper for printf for use in parallel mode.
*-------------------------------------------------------------------------
*/
-void parallel_print(const char* format, ...)
+void
+parallel_print(const char* format, ...)
{
int bytes_written;
va_list ap;
@@ -113,18 +99,12 @@ void parallel_print(const char* format, ...)
/*-------------------------------------------------------------------------
- * Function: error_msg
+ * Function: error_msg
*
- * Purpose: Print a nicely formatted error message to stderr flushing the
+ * Purpose: Print a nicely formatted error message to stderr flushing the
* stdout stream first.
*
- * Return: Nothing
- *
- * Programmer: Bill Wendling
- * Tuesday, 20. February 2001
- *
- * Modifications:
- *
+ * Return: Nothing
*-------------------------------------------------------------------------
*/
void
@@ -144,18 +124,12 @@ error_msg(const char *fmt, ...)
/*-------------------------------------------------------------------------
- * Function: warn_msg
+ * Function: warn_msg
*
- * Purpose: Print a nicely formatted warning message to stderr flushing
+ * Purpose: Print a nicely formatted warning message to stderr flushing
* the stdout stream first.
*
- * Return: Nothing
- *
- * Programmer: Bill Wendling
- * Tuesday, 20. February 2001
- *
- * Modifications:
- *
+ * Return: Nothing
*-------------------------------------------------------------------------
*/
void
@@ -173,14 +147,11 @@ warn_msg(const char *fmt, ...)
}
/*-------------------------------------------------------------------------
- * Function: help_ref_msg
- *
- * Purpose: Print a message to refer help page
+ * Function: help_ref_msg
*
- * Return: Nothing
- *
- * Modifications:
+ * Purpose: Print a message to refer help page
*
+ * Return: Nothing
*-------------------------------------------------------------------------
*/
void
@@ -192,24 +163,16 @@ help_ref_msg(FILE *output)
/*-------------------------------------------------------------------------
- * Function: get_option
+ * Function: get_option
*
- * Purpose: Determine the command-line options a user specified. We can
- * accept both short and long type command-lines.
+ * Purpose: Determine the command-line options a user specified. We can
+ * accept both short and long type command-lines.
*
* Return: Success: The short valued "name" of the command line
* parameter or EOF if there are no more
* parameters to process.
*
- * Failure: A question mark.
- *
- * Programmer: Bill Wendling
- * Friday, 5. January 2001
- *
- * Modifications: Pedro Vicente
- * October, 27 2008
- * Wilcard "*" argument type
- *
+ * Failure: A question mark.
*-------------------------------------------------------------------------
*/
int
@@ -361,16 +324,11 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
/*-------------------------------------------------------------------------
- * Function: indentation
+ * Function: indentation
*
- * Purpose: Print spaces for indentation
- *
- * Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
+ * Purpose: Print spaces for indentation
*
+ * Return: void
*-------------------------------------------------------------------------
*/
void
@@ -388,17 +346,12 @@ indentation(unsigned x)
/*-------------------------------------------------------------------------
- * Function: print_version
+ * Function: print_version
*
- * Purpose: Print the program name and the version information which is
- * defined the same as the HDF5 library version.
- *
- * Return: void
- *
- * Programmer: unknown
- *
- * Modifications:
+ * Purpose: Print the program name and the version information which is
+ * defined the same as the HDF5 library version.
*
+ * Return: void
*-------------------------------------------------------------------------
*/
void
@@ -417,11 +370,6 @@ print_version(const char *progname)
* and committed types
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
@@ -444,11 +392,6 @@ init_table(table_t **tbl)
* and committed types
*
* Return: void
- *
- * Programmer: Paul Harten
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
@@ -472,11 +415,6 @@ free_table(table_t *table)
* Purpose: display the contents of tables for debugging purposes
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
@@ -498,11 +436,6 @@ dump_table(char* tablename, table_t *table)
* Purpose: display the contents of tables for debugging purposes
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
@@ -523,14 +456,9 @@ dump_tables(find_objs_t *info)
* Return: Success: an integer, the location of the object
*
* Failure: FAIL if object is not found
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-obj_t *
+ obj_t *
search_obj(table_t *table, haddr_t objno)
{
unsigned u;
@@ -551,11 +479,6 @@ search_obj(table_t *table, haddr_t objno)
* Return: Success: SUCCEED
*
* Failure: FAIL
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -573,7 +496,7 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen
case H5O_TYPE_DATASET:
if(NULL == already_seen) {
- hid_t dset;
+ hid_t dset = -1;
/* Add the dataset to the list of objects */
add_obj(info->dset_table, oinfo->addr, name, TRUE);
@@ -618,7 +541,6 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen
case H5O_TYPE_UNKNOWN:
case H5O_TYPE_NTYPES:
default:
- HDassert(0);
break;
} /* end switch */
@@ -634,11 +556,6 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen
* Return: Success: SUCCEED
*
* Failure: FAIL
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -668,11 +585,6 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
* realloc the table if necessary
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
@@ -706,11 +618,6 @@ add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t record)
*
* Return: a stream description when succeeds.
* NULL if fails.
- *
- * Programmer: Albert Cheng, 2005/8/9
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
FILE *
@@ -734,67 +641,61 @@ tmpfile(void)
*
* Return:
* 2 : given pathname is object
- * 1 : Succed to get link info.
+ * 1 : Succeed to get link info.
* 0 : Detected as a dangling link
* -1 : H5 API failed.
*
* NOTE:
* link_info->trg_path must be freed out of this function
- *
- * Programmer: Jonathan Kim
- *
- * Date: Feb 8, 2010
*-------------------------------------------------------------------------*/
int
-H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info,
- hbool_t get_obj_type)
+H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info, hbool_t get_obj_type)
{
htri_t l_ret;
H5O_info_t trg_oinfo;
hid_t fapl = H5P_DEFAULT;
hid_t lapl = H5P_DEFAULT;
- int ret = -1; /* init to fail */
+ int ret_value = -1; /* init to fail */
/* init */
link_info->trg_type = H5O_TYPE_UNKNOWN;
/* if path is root, return group type */
- if(!HDstrcmp(linkpath,"/"))
- {
+ if(!HDstrcmp(linkpath,"/")) {
link_info->trg_type = H5O_TYPE_GROUP;
- ret = 2;
- goto out;
+ HGOTO_DONE(2);
}
/* check if link itself exist */
if(H5Lexists(file_id, linkpath, H5P_DEFAULT) <= 0) {
if(link_info->opt.msg_mode == 1)
parallel_print("Warning: link <%s> doesn't exist \n",linkpath);
- goto out;
+ HGOTO_DONE(FAIL);
} /* end if */
/* get info from link */
if(H5Lget_info(file_id, linkpath, &(link_info->linfo), H5P_DEFAULT) < 0) {
if(link_info->opt.msg_mode == 1)
parallel_print("Warning: unable to get link info from <%s>\n",linkpath);
- goto out;
+ HGOTO_DONE(FAIL);
} /* end if */
/* given path is hard link (object) */
- if(link_info->linfo.type == H5L_TYPE_HARD) {
- ret = 2;
- goto out;
- } /* end if */
+ if(link_info->linfo.type == H5L_TYPE_HARD)
+ HGOTO_DONE(2);
/* trg_path must be freed out of this function when finished using */
- link_info->trg_path = (char*)HDcalloc(link_info->linfo.u.val_size, sizeof(char));
- HDassert(link_info->trg_path);
+ if((link_info->trg_path = (char*)HDcalloc(link_info->linfo.u.val_size, sizeof(char))) == NULL) {
+ if(link_info->opt.msg_mode == 1)
+ parallel_print("Warning: unable to allocate buffer for <%s>\n",linkpath);
+ HGOTO_DONE(FAIL);
+ } /* end if */
/* get link value */
if(H5Lget_val(file_id, linkpath, (void *)link_info->trg_path, link_info->linfo.u.val_size, H5P_DEFAULT) < 0) {
if(link_info->opt.msg_mode == 1)
parallel_print("Warning: unable to get link value from <%s>\n",linkpath);
- goto out;
+ HGOTO_DONE(FAIL);
} /* end if */
/*-----------------------------------------------------
@@ -803,13 +704,13 @@ H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_
*/
if(link_info->linfo.type == H5L_TYPE_EXTERNAL) {
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- goto out;
+ HGOTO_DONE(FAIL);
if(H5Pset_fapl_sec2(fapl) < 0)
- goto out;
+ HGOTO_DONE(FAIL);
if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0)
- goto out;
+ HGOTO_DONE(FAIL);
if(H5Pset_elink_fapl(lapl, fapl) < 0)
- goto out;
+ HGOTO_DONE(FAIL);
} /* end if */
/* Check for retrieving object info */
@@ -822,25 +723,24 @@ H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_
/* detect dangling link */
if(l_ret == FALSE) {
- ret = 0;
- goto out;
- } /* end if */
- /* function failed */
- else if(l_ret < 0)
- goto out;
+ HGOTO_DONE(0);
+ }
+ else if(l_ret < 0) { /* function failed */
+ HGOTO_DONE(FAIL);
+ }
/* get target object info */
if(H5Oget_info_by_name(file_id, linkpath, &trg_oinfo, lapl) < 0) {
if(link_info->opt.msg_mode == 1)
parallel_print("Warning: unable to get object information for <%s>\n", linkpath);
- goto out;
+ HGOTO_DONE(FAIL);
} /* end if */
/* check unknown type */
if(trg_oinfo.type < H5O_TYPE_GROUP || trg_oinfo.type >=H5O_TYPE_NTYPES) {
if(link_info->opt.msg_mode == 1)
parallel_print("Warning: target object of <%s> is unknown type\n", linkpath);
- goto out;
+ HGOTO_DONE(FAIL);
} /* end if */
/* set target obj type to return */
@@ -852,41 +752,46 @@ H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_
link_info->trg_type = H5O_TYPE_UNKNOWN;
/* succeed */
- ret = 1;
+ ret_value = 1;
-out:
+done:
if(fapl != H5P_DEFAULT)
H5Pclose(fapl);
if(lapl != H5P_DEFAULT)
H5Pclose(lapl);
- return ret;
+ return ret_value;
} /* end H5tools_get_symlink_info() */
/*-------------------------------------------------------------------------
* Audience: Public
- * Chapter: H5Tools Library
+ *
* Purpose: Initialize the name and operation status of the H5 Tools library
+ *
* Description:
* These are utility functions to set/get the program name and operation status.
*-------------------------------------------------------------------------
*/
-void h5tools_setprogname(const char *Progname)
+void
+h5tools_setprogname(const char *Progname)
{
h5tools_progname = Progname;
}
-void h5tools_setstatus(int D_status)
+void
+h5tools_setstatus(int D_status)
{
h5tools_d_status = D_status;
}
-const char*h5tools_getprogname(void)
+const char *
+h5tools_getprogname(void)
{
return h5tools_progname;
}
-int h5tools_getstatus(void)
+int
+h5tools_getstatus(void)
{
return h5tools_d_status;
}
@@ -898,25 +803,19 @@ int h5tools_getstatus(void)
* This can be called from each tools main() as part of initial act.
* Note: this is more of debugging purpose for now.
*/
-int h5tools_getenv_update_hyperslab_bufsize(void)
+int
+h5tools_getenv_update_hyperslab_bufsize(void)
{
const char *env_str = NULL;
long hyperslab_bufsize_mb;
+ int ret_value = 1;
/* check if environment variable is set for the hyperslab buffer size */
- if (NULL != (env_str = HDgetenv ("H5TOOLS_BUFSIZE")))
- {
+ if (NULL != (env_str = HDgetenv ("H5TOOLS_BUFSIZE"))) {
errno = 0;
hyperslab_bufsize_mb = HDstrtol(env_str, (char**)NULL, 10);
if (errno != 0 || hyperslab_bufsize_mb <= 0)
- {
- /* TODO: later when pubilshed
- HDfprintf(rawerrorstream,"Error: Invalid environment variable \"H5TOOLS_BUFSIZE\" : %s\n", env_str);
- */
-
- goto error;
- }
-
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "hyperslab buffer size failed");
/* convert MB to byte */
H5TOOLS_BUFSIZE = (hsize_t)hyperslab_bufsize_mb * 1024 * 1024;
@@ -924,9 +823,7 @@ int h5tools_getenv_update_hyperslab_bufsize(void)
H5TOOLS_MALLOCSIZE = MAX(H5TOOLS_BUFSIZE, H5TOOLS_MALLOCSIZE);
}
- return (1);
-
-error:
- return (-1);
+done:
+ return ret_value;
}
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index df5ba5c..ce47f4f 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -13,6 +13,7 @@
#include "h5trav.h"
+#include "h5tools.h"
#include "H5private.h"
/*-------------------------------------------------------------------------
@@ -81,10 +82,9 @@ static int trav_verbosity = 0;
/*-------------------------------------------------------------------------
* Function: h5trav_set_index
*
- * Purpose: Set indexing properties for the objects & links in the file
- *
- * Return: none
+ * Purpose: Set indexing properties for the objects & links in the file
*
+ * Return: none
*-------------------------------------------------------------------------
*/
void
@@ -97,10 +97,9 @@ h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order)
/*-------------------------------------------------------------------------
* Function: h5trav_set_verbose
*
- * Purpose: Set verbosity of file contents 1=>attributes
- *
- * Return: none
+ * Purpose: Set verbosity of file contents 1=>attributes
*
+ * Return: none
*-------------------------------------------------------------------------
*/
void
@@ -118,14 +117,9 @@ h5trav_set_verbose(int print_verbose)
/*-------------------------------------------------------------------------
* Function: trav_addr_add
*
- * Purpose: Add a hardlink address to visited data structure
- *
- * Return: void
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
+ * Purpose: Add a hardlink address to visited data structure
*
+ * Return: void
*-------------------------------------------------------------------------
*/
static void
@@ -149,14 +143,9 @@ trav_addr_add(trav_addr_t *visited, haddr_t addr, const char *path)
/*-------------------------------------------------------------------------
* Function: trav_addr_visited
*
- * Purpose: Check if an address has already been visited
- *
- * Return: TRUE/FALSE
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
+ * Purpose: Check if an address has already been visited
*
+ * Return: TRUE/FALSE
*-------------------------------------------------------------------------
*/
static const char *
@@ -178,12 +167,7 @@ trav_addr_visited(trav_addr_t *visited, haddr_t addr)
/*-------------------------------------------------------------------------
* Function: traverse_cb
*
- * Purpose: Iterator callback for traversing objects in file
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
- *
+ * Purpose: Iterator callback for traversing objects in file
*-------------------------------------------------------------------------
*/
static herr_t
@@ -258,26 +242,23 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
/*-------------------------------------------------------------------------
* Function: traverse
*
- * Purpose: Iterate over all the objects/links in a file. Conforms to the
- * "visitor" pattern.
- *
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
+ * Purpose: Iterate over all the objects/links in a file. Conforms to the
+ * "visitor" pattern.
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
static int
traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
- hbool_t recurse, const trav_visitor_t *visitor)
+ hbool_t recurse, const trav_visitor_t *visitor)
{
H5O_info_t oinfo; /* Object info for starting group */
+ int ret_value = SUCCEED;
/* Get info for starting object */
if(H5Oget_info_by_name(file_id, grp_name, &oinfo, H5P_DEFAULT) < 0)
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info_by_name failed");
/* Visit the starting object */
if(visit_start && visitor->visit_obj)
@@ -306,12 +287,12 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
if(recurse) {
/* Visit all links in group, recursively */
if(H5Lvisit_by_name(file_id, grp_name, trav_index_by, trav_index_order, traverse_cb, &udata, H5P_DEFAULT) < 0)
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lvisit_by_name failed");
} /* end if */
else {
/* Iterate over links in group */
if(H5Literate_by_name(file_id, grp_name, trav_index_by, trav_index_order, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0)
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Literate_by_name failed");
} /* end else */
/* Free visited addresses table */
@@ -325,21 +306,17 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
} /* end if */
} /* end if */
- return 0;
+done:
+ return ret_value;
}
/*-------------------------------------------------------------------------
* Function: trav_info_add
*
- * Purpose: Add a link path & type to info struct
- *
- * Return: void
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
+ * Purpose: Add a link path & type to info struct
*
+ * Return: void
*-------------------------------------------------------------------------
*/
void
@@ -347,18 +324,20 @@ trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type)
{
size_t idx; /* Index of address to use */
- /* Allocate space if necessary */
- if(info->nused == info->nalloc) {
- info->nalloc = MAX(1, info->nalloc * 2);;
- info->paths = (trav_path_t *)HDrealloc(info->paths, info->nalloc * sizeof(trav_path_t));
- } /* end if */
+ if (info) {
+ /* Allocate space if necessary */
+ if(info->nused == info->nalloc) {
+ info->nalloc = MAX(1, info->nalloc * 2);;
+ info->paths = (trav_path_t *)HDrealloc(info->paths, info->nalloc * sizeof(trav_path_t));
+ } /* end if */
- /* Append it */
- idx = info->nused++;
- info->paths[idx].path = HDstrdup(path);
- info->paths[idx].type = obj_type;
- info->paths[idx].fileno = 0;
- info->paths[idx].objno = HADDR_UNDEF;
+ /* Append it */
+ idx = info->nused++;
+ info->paths[idx].path = HDstrdup(path);
+ info->paths[idx].type = obj_type;
+ info->paths[idx].fileno = 0;
+ info->paths[idx].objno = HADDR_UNDEF;
+ }
} /* end trav_info_add() */
@@ -368,7 +347,6 @@ trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type)
* Purpose: Add a file addr & fileno to info struct
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
void
@@ -390,22 +368,19 @@ trav_fileinfo_add(trav_info_t *info, hid_t loc_id)
/*-------------------------------------------------------------------------
* Function: trav_info_visit_obj
*
- * Purpose: Callback for visiting object, with 'info' structure
- *
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
+ * Purpose: Callback for visiting object, with 'info' structure
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
int
trav_info_visit_obj(const char *path, const H5O_info_t *oinfo,
- const char H5_ATTR_UNUSED *already_visited, void *udata)
+ const char H5_ATTR_UNUSED *already_visited, void *udata)
{
size_t idx;
trav_info_t *info_p;
+
/* Add the object to the 'info' struct */
/* (object types map directly to "traversal" types) */
trav_info_add((trav_info_t *)udata, path, (h5trav_type_t)oinfo->type);
@@ -423,14 +398,10 @@ trav_info_visit_obj(const char *path, const H5O_info_t *oinfo,
/*-------------------------------------------------------------------------
* Function: trav_info_visit_lnk
*
- * Purpose: Callback for visiting link, with 'info' structure
- *
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
+ * Purpose: Callback for visiting link, with 'info' structure
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
int
@@ -446,21 +417,18 @@ trav_info_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
/*-------------------------------------------------------------------------
* Function: h5trav_getinfo
*
- * Purpose: get an array of "trav_info_t" , containing the name and type of
- * objects in the file
- *
- * Return: number of object names in file
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 6, 2002
+ * Purpose: get an array of "trav_info_t" , containing the name and type of
+ * objects in the file
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
int
h5trav_getinfo(hid_t file_id, trav_info_t *info)
{
trav_visitor_t info_visitor; /* Visitor structure for trav_info_t's */
+ int ret_value = SUCCEED;
/* Init visitor structure */
info_visitor.visit_obj = trav_info_visit_obj;
@@ -469,25 +437,21 @@ h5trav_getinfo(hid_t file_id, trav_info_t *info)
/* Traverse all objects in the file, visiting each object & link */
if(traverse(file_id, "/", TRUE, TRUE, &info_visitor) < 0)
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
- return 0;
+done:
+ return ret_value;
}
/*-------------------------------------------------------------------------
* Function: h5trav_getindex
*
- * Purpose: get index of OBJ in list
- *
- * Return: index, -1 if not found
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
+ * Purpose: get index of OBJ in list
*
+ * Return: index on success,
+ * -1 if not found
*-------------------------------------------------------------------------
*/
-
ssize_t
h5trav_getindex(const trav_info_t *info, const char *obj)
{
@@ -511,17 +475,11 @@ h5trav_getindex(const trav_info_t *info, const char *obj)
/*-------------------------------------------------------------------------
* Function: trav_info_init
*
- * Purpose: Initialize the info
- *
- * Return: void
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 6, 2007
+ * Purpose: Initialize the info
*
+ * Return: void
*-------------------------------------------------------------------------
*/
-
void
trav_info_init(const char *filename, hid_t fileid, trav_info_t **_info)
{
@@ -545,11 +503,9 @@ trav_info_init(const char *filename, hid_t fileid, trav_info_t **_info)
/*-------------------------------------------------------------------------
* Function: trav_info_free
*
- * Purpose: free info memory
- *
+ * Purpose: free info memory
*-------------------------------------------------------------------------
*/
-
void
trav_info_free(trav_info_t *info)
{
@@ -557,11 +513,9 @@ trav_info_free(trav_info_t *info)
if(info) {
/* Free visited symbolic links path and file (if alloc) */
- for(u=0; u < info->symlink_visited.nused; u++)
- {
+ for(u = 0; u < info->symlink_visited.nused; u++) {
if (info->symlink_visited.objs[u].file)
HDfree(info->symlink_visited.objs[u].file);
-
HDfree(info->symlink_visited.objs[u].path);
}
HDfree(info->symlink_visited.objs);
@@ -586,12 +540,8 @@ trav_info_free(trav_info_t *info)
*
* Purpose: Callback for visiting object, with 'table' sructure
*
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
- *
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
static int
@@ -608,21 +558,17 @@ trav_table_visit_obj(const char *path, const H5O_info_t *oinfo,
/* Add alias for object to table */
trav_table_addlink(table, oinfo->addr, path);
- return(0);
+ return 0;
} /* end trav_table_visit_obj() */
/*-------------------------------------------------------------------------
* Function: trav_table_visit_lnk
*
- * Purpose: Callback for visiting link, with 'table' sructure
- *
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
+ * Purpose: Callback for visiting link, with 'table' sructure
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
static int
@@ -631,28 +577,24 @@ trav_table_visit_lnk(const char *path, const H5L_info_t H5_ATTR_UNUSED *linfo, v
/* Add the link to the 'table' struct */
trav_table_add((trav_table_t *)udata, path, NULL);
- return(0);
+ return 0;
} /* end trav_table_visit_lnk() */
/*-------------------------------------------------------------------------
* Function: h5trav_gettable
*
- * Purpose: get the trav_table_t struct
- *
- * Return: 0, -1 on error
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: December 17, 2003
+ * Purpose: get the trav_table_t struct
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
-
int
h5trav_gettable(hid_t fid, trav_table_t *table)
{
trav_visitor_t table_visitor; /* Visitor structure for trav_table_t's */
+ int ret_value = SUCCEED;
/* Init visitor structure */
table_visitor.visit_obj = trav_table_visit_obj;
@@ -661,71 +603,63 @@ h5trav_gettable(hid_t fid, trav_table_t *table)
/* Traverse all objects in the file, visiting each object & link */
if(traverse(fid, "/", TRUE, TRUE, &table_visitor) < 0)
- return -1;
- return 0;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
+
+done:
+ return ret_value;
}
/*-------------------------------------------------------------------------
* Function: h5trav_getindext
*
- * Purpose: get index of NAME in list
- *
- * Return: index, -1 if not found
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: December 18, 2003
+ * Purpose: get index of NAME in list
*
+ * Return: index on success,
+ * -1 if not found
*-------------------------------------------------------------------------
*/
-
int
h5trav_getindext(const char *name, const trav_table_t *table)
{
unsigned int i;
- for(i = 0; i < table->nobjs; i++) {
- /* Check for object name having full path (with leading '/') */
- if(HDstrcmp(name, table->objs[i].name) == 0)
- return((int)i);
-
- /* Check for object name without leading '/' */
- if(HDstrcmp(name, table->objs[i].name + 1) == 0)
- return((int)i);
+ if(table) {
+ for(i = 0; i < table->nobjs; i++) {
+ /* Check for object name having full path (with leading '/') */
+ if(HDstrcmp(name, table->objs[i].name) == 0)
+ return((int)i);
- /* search also in the list of links */
- if(table->objs[i].nlinks) {
- unsigned int j;
+ /* Check for object name without leading '/' */
+ if(HDstrcmp(name, table->objs[i].name + 1) == 0)
+ return((int)i);
- for ( j=0; j<table->objs[i].nlinks; j++) {
- /* Check for object name having full path (with leading '/') */
- if(HDstrcmp(name, table->objs[i].links[j].new_name) == 0)
- return((int)i);
+ /* search also in the list of links */
+ if(table->objs[i].nlinks) {
+ unsigned int j;
- /* Check for object name without leading '/' */
- if(HDstrcmp(name, table->objs[i].links[j].new_name + 1) == 0)
- return((int)i);
- } /* end for */
- } /* end if */
- } /* end for */
+ for ( j=0; j<table->objs[i].nlinks; j++) {
+ /* Check for object name having full path (with leading '/') */
+ if(HDstrcmp(name, table->objs[i].links[j].new_name) == 0)
+ return((int)i);
+ /* Check for object name without leading '/' */
+ if(HDstrcmp(name, table->objs[i].links[j].new_name + 1) == 0)
+ return((int)i);
+ } /* end for */
+ } /* end if */
+ } /* end for */
+ }
return -1;
}
/*-------------------------------------------------------------------------
* Function: trav_table_add
*
- * Purpose: Add OBJNO, NAME and TYPE of object to table
- *
- * Return: void
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 4, 2002
+ * Purpose: Add OBJNO, NAME and TYPE of object to table
*
+ * Return: void
*-------------------------------------------------------------------------
*/
-
static void
trav_table_add(trav_table_t *table,
const char *path,
@@ -733,20 +667,22 @@ trav_table_add(trav_table_t *table,
{
size_t new_obj;
- if(table->nobjs == table->size) {
- table->size = MAX(1, table->size * 2);
- table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
- } /* end if */
+ if(table) {
+ if(table->nobjs == table->size) {
+ table->size = MAX(1, table->size * 2);
+ table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
+ } /* end if */
- new_obj = table->nobjs++;
- table->objs[new_obj].objno = oinfo ? oinfo->addr : HADDR_UNDEF;
- table->objs[new_obj].flags[0] = table->objs[new_obj].flags[1] = 0;
- table->objs[new_obj].is_same_trgobj = 0;
- table->objs[new_obj].name = (char *)HDstrdup(path);
- table->objs[new_obj].type = oinfo ? (h5trav_type_t)oinfo->type : H5TRAV_TYPE_LINK;
- table->objs[new_obj].nlinks = 0;
- table->objs[new_obj].sizelinks = 0;
- table->objs[new_obj].links = NULL;
+ new_obj = table->nobjs++;
+ table->objs[new_obj].objno = oinfo ? oinfo->addr : HADDR_UNDEF;
+ table->objs[new_obj].flags[0] = table->objs[new_obj].flags[1] = 0;
+ table->objs[new_obj].is_same_trgobj = 0;
+ table->objs[new_obj].name = (char *)HDstrdup(path);
+ table->objs[new_obj].type = oinfo ? (h5trav_type_t)oinfo->type : H5TRAV_TYPE_LINK;
+ table->objs[new_obj].nlinks = 0;
+ table->objs[new_obj].sizelinks = 0;
+ table->objs[new_obj].links = NULL;
+ }
}
/*-------------------------------------------------------------------------
@@ -755,60 +691,47 @@ trav_table_add(trav_table_t *table,
* Purpose: Add a hardlink name to the object
*
* Return: void
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: December 17, 2003
- *
*-------------------------------------------------------------------------
*/
-
static void
trav_table_addlink(trav_table_t *table, haddr_t objno, const char *path)
{
size_t i; /* Local index variable */
- for(i = 0; i < table->nobjs; i++) {
- if(table->objs[i].objno == objno) {
- size_t n;
+ if(table) {
+ for(i = 0; i < table->nobjs; i++) {
+ if(table->objs[i].objno == objno) {
+ size_t n;
- /* already inserted? */
- if(HDstrcmp(table->objs[i].name, path) == 0)
- return;
+ /* already inserted? */
+ if(HDstrcmp(table->objs[i].name, path) == 0)
+ return;
- /* allocate space if necessary */
- if(table->objs[i].nlinks == (unsigned)table->objs[i].sizelinks) {
- table->objs[i].sizelinks = MAX(1, table->objs[i].sizelinks * 2);
- table->objs[i].links = (trav_link_t *)HDrealloc(table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t));
- } /* end if */
+ /* allocate space if necessary */
+ if(table->objs[i].nlinks == (unsigned)table->objs[i].sizelinks) {
+ table->objs[i].sizelinks = MAX(1, table->objs[i].sizelinks * 2);
+ table->objs[i].links = (trav_link_t *)HDrealloc(table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t));
+ } /* end if */
- /* insert it */
- n = table->objs[i].nlinks++;
- table->objs[i].links[n].new_name = (char *)HDstrdup(path);
+ /* insert it */
+ n = table->objs[i].nlinks++;
+ table->objs[i].links[n].new_name = (char *)HDstrdup(path);
- return;
+ return;
+ } /* end for */
} /* end for */
- } /* end for */
-
- HDassert(0 && "object not in table?!?");
+ }
}
-
/*-------------------------------------------------------------------------
* Function: trav_table_addflags
*
- * Purpose: Add FLAGS, NAME and TYPE of object to table
- *
- * Return: void
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 4, 2002
+ * Purpose: Add FLAGS, NAME and TYPE of object to table
*
+ * Return: void
*-------------------------------------------------------------------------
*/
-
void trav_table_addflags(unsigned *flags,
char *name,
h5trav_type_t type,
@@ -816,92 +739,83 @@ void trav_table_addflags(unsigned *flags,
{
size_t new_obj;
- if(table->nobjs == table->size) {
- table->size = MAX(1, table->size * 2);
- table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
- } /* end if */
+ if(table) {
+ if(table->nobjs == table->size) {
+ table->size = MAX(1, table->size * 2);
+ table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
+ } /* end if */
- new_obj = table->nobjs++;
- table->objs[new_obj].objno = 0;
- table->objs[new_obj].flags[0] = flags[0];
- table->objs[new_obj].flags[1] = flags[1];
- table->objs[new_obj].is_same_trgobj = 0;
- table->objs[new_obj].name = (char *)HDstrdup(name);
- table->objs[new_obj].type = type;
- table->objs[new_obj].nlinks = 0;
- table->objs[new_obj].sizelinks = 0;
- table->objs[new_obj].links = NULL;
+ new_obj = table->nobjs++;
+ table->objs[new_obj].objno = 0;
+ table->objs[new_obj].flags[0] = flags[0];
+ table->objs[new_obj].flags[1] = flags[1];
+ table->objs[new_obj].is_same_trgobj = 0;
+ table->objs[new_obj].name = (char *)HDstrdup(name);
+ table->objs[new_obj].type = type;
+ table->objs[new_obj].nlinks = 0;
+ table->objs[new_obj].sizelinks = 0;
+ table->objs[new_obj].links = NULL;
+ }
}
/*-------------------------------------------------------------------------
* Function: trav_table_init
*
- * Purpose: Initialize the table
- *
- * Return: void
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 4, 2002
+ * Purpose: Initialize the table
*
+ * Return: void
*-------------------------------------------------------------------------
*/
-
void trav_table_init(trav_table_t **tbl)
{
trav_table_t* table = (trav_table_t*) HDmalloc(sizeof(trav_table_t));
-
- table->size = 0;
- table->nobjs = 0;
- table->objs = NULL;
-
+ if(table) {
+ table->size = 0;
+ table->nobjs = 0;
+ table->objs = NULL;
+ }
*tbl = table;
}
-
/*-------------------------------------------------------------------------
* Function: trav_table_free
*
- * Purpose: free table memory
- *
- * Return: void
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 4, 2002
+ * Purpose: free table memory
*
+ * Return: void
*-------------------------------------------------------------------------
*/
-
-void trav_table_free( trav_table_t *table )
+void trav_table_free(trav_table_t *table)
{
- if(table->objs) {
- unsigned int i;
+ if(table) {
+ if(table->objs) {
+ unsigned int i;
- for(i = 0; i < table->nobjs; i++) {
- HDfree(table->objs[i].name );
- if(table->objs[i].nlinks) {
- unsigned int j;
+ for(i = 0; i < table->nobjs; i++) {
+ HDfree(table->objs[i].name );
+ if(table->objs[i].nlinks) {
+ unsigned int j;
- for(j = 0; j < table->objs[i].nlinks; j++)
- HDfree(table->objs[i].links[j].new_name);
+ for(j = 0; j < table->objs[i].nlinks; j++)
+ HDfree(table->objs[i].links[j].new_name);
- HDfree(table->objs[i].links);
- } /* end if */
- } /* end for */
- HDfree(table->objs);
- } /* end if */
- HDfree(table);
+ HDfree(table->objs[i].links);
+ } /* end if */
+ } /* end for */
+ HDfree(table->objs);
+ } /* end if */
+ HDfree(table);
+ }
}
static herr_t
trav_attr(hid_t
#ifndef H5TRAV_PRINT_SPACE
-H5_ATTR_UNUSED
+ H5_ATTR_UNUSED
#endif /* H5TRAV_PRINT_SPACE */
-obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_data)
+ obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_data)
{
trav_path_op_data_t *op_data = (trav_path_op_data_t *)_op_data;
const char *buf = op_data->path;
@@ -940,7 +854,7 @@ obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_da
case H5S_SIMPLE:
/* simple dataspace */
printf(" {");
- for (i=0; i<ndims; i++) {
+ for (i = 0; i < ndims; i++) {
printf("%s" HSIZE_T_FORMAT, i?", ":"", size[i]);
}
printf("}\n");
@@ -970,19 +884,15 @@ obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_da
/*-------------------------------------------------------------------------
* Function: trav_print_visit_obj
*
- * Purpose: Callback for visiting object, when printing info
- *
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 6, 2007
+ * Purpose: Callback for visiting object, when printing info
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
static int
trav_print_visit_obj(const char *path, const H5O_info_t *oinfo,
- const char *already_visited, void *udata)
+ const char *already_visited, void *udata)
{
trav_print_udata_t *print_udata = (trav_print_udata_t *)udata;
/* Print the name of the object */
@@ -1017,7 +927,7 @@ trav_print_visit_obj(const char *path, const H5O_info_t *oinfo,
/* Finish printing line about object */
printf("\n");
if(trav_verbosity > 0)
- H5Aiterate_by_name(print_udata->fid, path, trav_index_by, trav_index_order,
+ H5Aiterate_by_name(print_udata->fid, path, trav_index_by, trav_index_order,
NULL, trav_attr, &op_data, H5P_DEFAULT);
}
else
@@ -1031,14 +941,10 @@ trav_print_visit_obj(const char *path, const H5O_info_t *oinfo,
/*-------------------------------------------------------------------------
* Function: trav_print_visit_lnk
*
- * Purpose: Callback for visiting link, when printing info
- *
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 6, 2007
+ * Purpose: Callback for visiting link, when printing info
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
static int
@@ -1051,12 +957,12 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
case H5L_TYPE_SOFT:
if(linfo->u.val_size > 0) {
char *targbuf = (char*)HDmalloc(linfo->u.val_size + 1);
- HDassert(targbuf);
-
- if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0)
- targbuf[0] = 0;
- printf(" %-10s %s -> %s\n", "link", path, targbuf);
- HDfree(targbuf);
+ if(targbuf) {
+ if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0)
+ targbuf[0] = 0;
+ printf(" %-10s %s -> %s\n", "link", path, targbuf);
+ HDfree(targbuf);
+ }
} /* end if */
else
printf(" %-10s %s ->\n", "link", path);
@@ -1064,18 +970,18 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
case H5L_TYPE_EXTERNAL:
if(linfo->u.val_size > 0) {
- char *targbuf;
+ char *targbuf = NULL;
const char *filename = NULL;
const char *objname = NULL;
targbuf = (char*)HDmalloc(linfo->u.val_size + 1);
- HDassert(targbuf);
-
- if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0)
- targbuf[0] = 0;
- if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &objname) >= 0)
- printf(" %-10s %s -> %s %s\n", "ext link", path, filename, objname);
- HDfree(targbuf);
+ if(targbuf) {
+ if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0)
+ targbuf[0] = 0;
+ if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &objname) >= 0)
+ printf(" %-10s %s -> %s %s\n", "ext link", path, filename, objname);
+ HDfree(targbuf);
+ }
} /* end if */
else
printf(" %-10s %s ->\n", "ext link", path);
@@ -1099,22 +1005,18 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
/*-------------------------------------------------------------------------
* Function: h5trav_print
*
- * Purpose: Print information about the objects & links in the file
- *
- * Return: 0, -1 on error
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 6, 2007
+ * Purpose: Print information about the objects & links in the file
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
-
int
h5trav_print(hid_t fid)
{
trav_print_udata_t print_udata; /* User data for traversal */
trav_visitor_t print_visitor; /* Visitor structure for printing objects */
+ int ret_value = SUCCEED;
/* Init user data for printing */
print_udata.fid = fid;
@@ -1126,9 +1028,10 @@ h5trav_print(hid_t fid)
/* Traverse all objects in the file, visiting each object & link */
if(traverse(fid, "/", TRUE, TRUE, &print_visitor) < 0)
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
- return 0;
+done:
+ return ret_value;
}
@@ -1137,21 +1040,17 @@ h5trav_print(hid_t fid)
*
* Purpose: Generic traversal routine for visiting objects and links
*
- * Return: 0, -1 on error
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: November 6, 2007
- *
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
-
int
h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start,
hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk,
void *udata)
{
trav_visitor_t visitor; /* Visitor structure for objects */
+ int ret_value = SUCCEED;
/* Init visitor structure */
visitor.visit_obj = visit_obj;
@@ -1160,9 +1059,10 @@ h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start,
/* Traverse all objects in the file, visiting each object & link */
if(traverse(fid, grp_name, visit_start, recurse, &visitor) < 0)
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
- return 0;
+done:
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -1170,19 +1070,15 @@ h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start,
*
* Purpose: Add an symbolic link to visited data structure
*
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Neil Fortner, nfortne2@hdfgroup.org
- * Adapted from trav_addr_add in h5trav.c by Quincey Koziol
- *
- * Date: September 5, 2008
- *
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
herr_t
symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path)
{
- size_t idx; /* Index of address to use */
+ herr_t ret_value = SUCCEED;
+ size_t idx; /* Index of address to use */
/* Allocate space if necessary */
if(visited->nused == visited->nalloc) {
@@ -1190,7 +1086,7 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co
visited->nalloc = MAX(1, visited->nalloc * 2);
if(NULL == (tmp_ptr = HDrealloc(visited->objs, visited->nalloc * sizeof(symlink_trav_path_t))))
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure realloc failed");
visited->objs = (symlink_trav_path_t *)tmp_ptr;
} /* end if */
@@ -1204,7 +1100,7 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co
if(type == H5L_TYPE_EXTERNAL) {
if(NULL == (visited->objs[idx].file = HDstrdup(file))) {
visited->nused--;
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure name allocation failed");
} /* end if */
} /* end if */
@@ -1212,25 +1108,20 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co
visited->nused--;
if(visited->objs[idx].file)
HDfree (visited->objs[idx].file);
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure path allocation failed");
} /* end if */
- return 0;
+done:
+ return ret_value;
} /* end symlink_visit_add() */
/*-------------------------------------------------------------------------
* Function: symlink_is_visited
*
- * Purpose: Check if an symbolic link has already been visited
- *
- * Return: TRUE/FALSE
- *
- * Programmer: Neil Fortner, nfortne2@hdfgroup.org
- * Adapted from trav_addr_visited in h5trav.c by Quincey Koziol
- *
- * Date: September 5, 2008
+ * Purpose: Check if an symbolic link has already been visited
*
+ * Return: TRUE/FALSE
*-------------------------------------------------------------------------
*/
hbool_t
diff --git a/tools/lib/io_timer.c b/tools/lib/io_timer.c
index 6a5df98..c894598 100644
--- a/tools/lib/io_timer.c
+++ b/tools/lib/io_timer.c
@@ -22,9 +22,6 @@
* This is a module of useful timing functions for performance testing.
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "H5private.h"
#include "hdf5.h"
@@ -53,9 +50,9 @@ io_time_t *timer_g; /* timer: global for stub functions */
static double sub_time(struct timeval* a, struct timeval* b)
{
return (((double)a->tv_sec +
- ((double)a->tv_usec) / MICROSECOND) -
+ ((double)a->tv_usec) / (double)MICROSECOND) -
((double)b->tv_sec +
- ((double)b->tv_usec) / MICROSECOND));
+ ((double)b->tv_usec) / (double)MICROSECOND));
}
@@ -195,8 +192,9 @@ set_time(io_time_t *pt, timer_type t, int start_stop)
}
break;
+
default:
- HDfprintf(stderr, "Unknown time clock type (%d)\n", pt->type);
+ HDfprintf(stderr, "Unknown time clock type (%d)\n", pt->type);
return NULL;
} /* end switch */
diff --git a/tools/lib/ph5diff.h b/tools/lib/ph5diff.h
index 9628d45..21d7d00 100644
--- a/tools/lib/ph5diff.h
+++ b/tools/lib/ph5diff.h
@@ -32,7 +32,7 @@ struct diff_mpi_args
{
char name1[256];
char name2[256];
- diff_opt_t options;
+ diff_opt_t opts;
diff_args_t argdata; /* rest args */
};