summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2004-07-20 19:21:03 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2004-07-20 19:21:03 (GMT)
commit4cb6c01d7f59be968649e36a61346be044f76345 (patch)
treee0a0b81e542768b75d5bbb2de8afc1abfb8c4370 /tools/lib
parent00909f278d64017c21c8348537231daba97be9dd (diff)
downloadhdf5-4cb6c01d7f59be968649e36a61346be044f76345.zip
hdf5-4cb6c01d7f59be968649e36a61346be044f76345.tar.gz
hdf5-4cb6c01d7f59be968649e36a61346be044f76345.tar.bz2
[svn-r8904] Purpose:
h5diff and h5repack changes Description: h5diff introduced the following four modes of output: Normal mode: print the number of differences found and where they occured Report mode: print the above plus the differences Verbose mode: print the above plus a list of objects and warnings Quiet mode: do not print output (h5diff always returns an exit code of 1 when differences are found) h5repack added an extra parameter for SZIP filter (coding method) the new syntax is -f SZIP=<pixels per block,coding> (pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN') Example of use: ./h5repack -i file1 -o file2 -f SZIP=8,NN -v updated usage messages, test scripts and files accordingly Solution: Platforms tested: linux AIX solaris Misc. update:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff.c187
-rw-r--r--tools/lib/h5diff.h171
-rw-r--r--tools/lib/h5diff_array.c303
-rw-r--r--tools/lib/h5diff_attr.c222
-rw-r--r--tools/lib/h5diff_dset.c219
-rw-r--r--tools/lib/h5diff_util.c12
6 files changed, 588 insertions, 526 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index ab90ebb..818bc40 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -16,13 +16,28 @@
#include "h5diff.h"
#include "H5private.h"
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_objname
+ *
+ * Purpose: print object name only when:
+ * 1) verbose mode
+ * 2) when diff was found (normal mode)
+ *-------------------------------------------------------------------------
+ */
+int print_objname(diff_opt_t *options, hsize_t nfound)
+{
+ return ( (options->m_verbose || nfound) && !options->m_quiet) ?1:0;
+}
+
/*-------------------------------------------------------------------------
* Function: h5diff
*
- * Purpose: public function, can be called in an applicattion program.
+ * Purpose: public function, can be called in an application program.
* return differences between 2 HDF5 files
*
- * Return: Number of differences found; -1 for error.
+ * Return: Number of differences found.
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
@@ -31,17 +46,25 @@
*-------------------------------------------------------------------------
*/
-int h5diff(const char *fname1,
- const char *fname2,
- const char *objname1,
- const char *objname2,
- diff_opt_t *options)
+hsize_t h5diff(const char *fname1,
+ const char *fname2,
+ const char *objname1,
+ const char *objname2,
+ diff_opt_t *options)
{
int nobjects1, nobjects2;
trav_info_t *info1=NULL;
trav_info_t *info2=NULL;
hid_t file1_id, file2_id;
- int nfound=0;
+ hsize_t nfound=0;
+
+ if (options->m_quiet &&
+ (options->m_verbose || options->m_report))
+ {
+ printf("Error: -q (quiet mode) cannot be added to verbose or report modes\n");
+ options->err_stat=1;
+ return 0;
+ }
/*-------------------------------------------------------------------------
* open the files first; if they are not valid, no point in continuing
@@ -50,31 +73,40 @@ int h5diff(const char *fname1,
/* disable error reporting */
H5E_BEGIN_TRY {
-
/* Open the files */
if ((file1_id=H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT))<0 )
{
printf("h5diff: <%s>: unable to open file\n", fname1 );
- nfound = -1;
+ options->err_stat=1;
+ goto out;
}
if ((file2_id=H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT))<0 )
{
printf("h5diff: <%s>: unable to open file\n", fname2 );
- nfound = -1;
+ options->err_stat=1;
+ goto out;
}
/* enable error reporting */
} H5E_END_TRY;
- if (nfound<0)
- return -1;
+
/*-------------------------------------------------------------------------
* get the number of objects in the files
*-------------------------------------------------------------------------
*/
-
nobjects1 = h5trav_getinfo( file1_id, NULL, 0 );
nobjects2 = h5trav_getinfo( file2_id, NULL, 0 );
+ if (nobjects1<0 || nobjects2<0)
+ {
+ printf("Error: Could not get get file contents\n");
+ options->err_stat=1;
+ goto out;
+ }
+
+ assert(nobjects1>0);
+ assert(nobjects2>0);
+
/*-------------------------------------------------------------------------
* get the list of objects in the files
*-------------------------------------------------------------------------
@@ -84,7 +116,10 @@ int h5diff(const char *fname1,
info2 = (trav_info_t*) malloc( nobjects2 * sizeof(trav_info_t));
if (info1==NULL || info2==NULL)
{
- nfound=-1;
+ printf("Error: Not enough memory for object list\n");
+ options->err_stat=1;
+ if (info1) h5trav_freeinfo(info1,nobjects1);
+ if (info2) h5trav_freeinfo(info2,nobjects1);
goto out;
}
@@ -99,6 +134,7 @@ int h5diff(const char *fname1,
if ( objname1 )
{
assert(objname2);
+ options->cmn_objs=1; /* eliminate warning */
nfound=diff_compare(file1_id,fname1,objname1,nobjects1,info1,
file2_id,fname2,objname2,nobjects2,info2,options);
}
@@ -120,12 +156,13 @@ int h5diff(const char *fname1,
out:
/* close */
- H5Fclose(file1_id);
- H5Fclose(file2_id);
-
- return nfound;
+ H5E_BEGIN_TRY {
+ H5Fclose(file1_id);
+ H5Fclose(file2_id);
+ } H5E_END_TRY;
+ return nfound;
}
@@ -145,13 +182,13 @@ out:
*
*-------------------------------------------------------------------------
*/
-int diff_match( hid_t file1_id,
- int nobjects1,
- trav_info_t *info1,
- hid_t file2_id,
- int nobjects2,
- trav_info_t *info2,
- diff_opt_t *options )
+hsize_t diff_match( hid_t file1_id,
+ int nobjects1,
+ trav_info_t *info1,
+ hid_t file2_id,
+ int nobjects2,
+ trav_info_t *info2,
+ diff_opt_t *options )
{
int more_names_exist = (nobjects1>0 && nobjects2>0) ? 1 : 0;
trav_table_t *table=NULL;
@@ -160,7 +197,8 @@ int diff_match( hid_t file1_id,
int curr2=0;
unsigned infile[2];
char c1, c2;
- int nfound=0, i;
+ hsize_t nfound=0;
+ int i;
/*-------------------------------------------------------------------------
* build the list
@@ -168,7 +206,6 @@ int diff_match( hid_t file1_id,
*/
trav_table_init( &table );
-
while ( more_names_exist )
{
/* criteria is string compare */
@@ -226,7 +263,7 @@ int diff_match( hid_t file1_id,
*-------------------------------------------------------------------------
*/
- if (options->verbose)
+ if (options->m_verbose)
{
printf("\n");
printf("file1 file2\n");
@@ -249,12 +286,15 @@ int diff_match( hid_t file1_id,
for (i = 0; i < table->nobjs; i++)
{
if ( table->objs[i].flags[0] && table->objs[i].flags[1] )
+ {
+ options->cmn_objs=1;
nfound+=diff( file1_id,
table->objs[i].name,
file2_id,
table->objs[i].name,
options,
table->objs[i].type );
+ }
}
/* free table */
@@ -294,21 +334,21 @@ int diff_match( hid_t file1_id,
*-------------------------------------------------------------------------
*/
-int diff_compare( hid_t file1_id,
- const char *file1_name,
- const char *obj1_name,
- int nobjects1,
- trav_info_t *info1,
- hid_t file2_id,
- const char *file2_name,
- const char *obj2_name,
- int nobjects2,
- trav_info_t *info2,
- diff_opt_t *options )
+hsize_t diff_compare( hid_t file1_id,
+ const char *file1_name,
+ const char *obj1_name,
+ int nobjects1,
+ trav_info_t *info1,
+ hid_t file2_id,
+ const char *file2_name,
+ const char *obj2_name,
+ int nobjects2,
+ trav_info_t *info2,
+ diff_opt_t *options )
{
- int f1=0, f2=0;
- int nfound=0;
+ int f1=0, f2=0;
+ hsize_t nfound=0;
int i = h5trav_getindex( obj1_name, nobjects1, info1 );
int j = h5trav_getindex( obj2_name, nobjects2, info2 );
@@ -323,20 +363,23 @@ int diff_compare( hid_t file1_id,
printf( "Object <%s> could not be found in <%s>\n", obj2_name, file2_name );
f2=1;
}
- if ( f1 || f2 )
- return -1;
+ if ( f1 || f2 ) {
+ options->err_stat=1;
+ return 0;
+ }
/* use the name with "/" first, as obtained by iterator function */
obj1_name=info1[i].name;
obj2_name=info2[j].name;
/* objects are not the same type */
- if ( info1[i].type != info2[j].type && options->verbose)
+ if ( info1[i].type != info2[j].type)
{
+ if (options->m_verbose)
printf("Comparison not possible: <%s> is of type %s and <%s> is of type %s\n",
obj1_name, get_type(info1[i].type),
obj2_name, get_type(info2[j].type) );
- return 1;
+ return 0;
}
nfound=diff( file1_id, obj1_name, file2_id, obj2_name, options, info1[i].type );
@@ -364,23 +407,23 @@ int diff_compare( hid_t file1_id,
*-------------------------------------------------------------------------
*/
-int diff( hid_t file1_id,
- const char *path1,
- hid_t file2_id,
- const char *path2,
- diff_opt_t *options,
- H5G_obj_t type )
+hsize_t diff( hid_t file1_id,
+ const char *path1,
+ hid_t file2_id,
+ const char *path2,
+ diff_opt_t *options,
+ H5G_obj_t1 type )
{
- hid_t type1_id=-1;
- hid_t type2_id=-1;
- hid_t grp1_id=-1;
- hid_t grp2_id=-1;
+ hid_t type1_id;
+ hid_t type2_id;
+ hid_t grp1_id;
+ hid_t grp2_id;
int ret;
H5G_stat_t sb1;
H5G_stat_t sb2;
char *buf1=NULL;
char *buf2=NULL;
- int nfound=-1;
+ hsize_t nfound=0;
switch ( type )
{
@@ -389,9 +432,9 @@ int diff( hid_t file1_id,
*-------------------------------------------------------------------------
*/
case H5G_DATASET:
- if (options->verbose)
- printf( "Dataset: <%s> and <%s>\n",path1,path2);
- nfound=diff_dataset(file1_id,file2_id,path1,path2,options);
+ nfound=diff_dataset(file1_id,file2_id,path1,path2,options);
+ if (print_objname(options,nfound))
+ printf( "Dataset: <%s> and <%s>\n",path1,path2);
break;
/*-------------------------------------------------------------------------
@@ -399,9 +442,6 @@ int diff( hid_t file1_id,
*-------------------------------------------------------------------------
*/
case H5G_TYPE:
- if (options->verbose)
- printf( "Datatype: <%s> and <%s>\n",path1,path2);
-
if ((type1_id = H5Topen(file1_id, path1))<0)
goto out;
if ((type2_id = H5Topen(file2_id, path2))<0)
@@ -412,6 +452,9 @@ int diff( hid_t file1_id,
/* if H5Tequal is > 0 then the datatypes refer to the same datatype */
nfound = (ret>0) ? 0 : 1;
+
+ if (print_objname(options,nfound))
+ printf( "Datatype: <%s> and <%s>\n",path1,path2);
/*-------------------------------------------------------------------------
* compare attributes
@@ -419,7 +462,7 @@ int diff( hid_t file1_id,
*-------------------------------------------------------------------------
*/
if (path1)
- nfound=diff_attr(type1_id,type2_id,path1,path2,options);
+ diff_attr(type1_id,type2_id,path1,path2,options);
if ( H5Tclose(type1_id)<0)
goto out;
@@ -433,9 +476,6 @@ int diff( hid_t file1_id,
*-------------------------------------------------------------------------
*/
case H5G_GROUP:
- if (options->verbose)
- printf( "Group: <%s> and <%s>\n",path1,path2);
-
if ((grp1_id = H5Gopen(file1_id, path1))<0)
goto out;
if ((grp2_id = H5Gopen(file2_id, path2))<0)
@@ -445,6 +485,9 @@ int diff( hid_t file1_id,
/* if "path1" != "path2" then the groups are "different" */
nfound = (ret!=0) ? 1 : 0;
+
+ if (print_objname(options,nfound))
+ printf( "Group: <%s> and <%s>\n",path1,path2);
/*-------------------------------------------------------------------------
* compare attributes
@@ -452,7 +495,7 @@ int diff( hid_t file1_id,
*-------------------------------------------------------------------------
*/
if (path1)
- nfound=diff_attr(grp1_id,grp2_id,path1,path2,options);
+ diff_attr(grp1_id,grp2_id,path1,path2,options);
if ( H5Gclose(grp1_id)<0)
goto out;
@@ -467,9 +510,6 @@ int diff( hid_t file1_id,
*-------------------------------------------------------------------------
*/
case H5G_LINK:
- if (options->verbose)
- printf( "Link: <%s> and <%s>\n",path1,path2);
-
if (H5Gget_objinfo(file1_id,path1,FALSE,&sb1)<0)
goto out;
if (H5Gget_objinfo(file1_id,path1,FALSE,&sb2)<0)
@@ -488,6 +528,9 @@ int diff( hid_t file1_id,
/* if "buf1" != "buf2" then the links are "different" */
nfound = (ret!=0) ? 1 : 0;
+ if (print_objname(options,nfound))
+ printf( "Link: <%s> and <%s>\n",path1,path2);
+
if (buf1) {
free(buf1);
buf1=NULL;
@@ -503,7 +546,7 @@ int diff( hid_t file1_id,
default:
nfound=0;
- if (options->verbose) {
+ if (options->m_verbose) {
printf("Comparison not supported: <%s> and <%s> are of type %s\n",
path1, path2, get_type(type) );
}
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index 0c52f76..4c56f81 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -18,6 +18,9 @@
#include "hdf5.h"
#include "h5trav.h"
+typedef H5G_obj_t H5G_obj_t1;
+
+
#if 0
#define H5DIFF_DEBUG
@@ -51,14 +54,18 @@
*/
typedef struct {
- int r; /* report only what objects differ */
- int d; /* delta */
- double delta; /* delta value */
- int p; /* relative error */
- double percent; /* relative error value */
- int n; /* count */
- int count; /* count value */
- int verbose; /* print information */
+ int m_quiet; /* quiet mide: no output at all */
+ int m_report; /* report mode: print the data */
+ int m_verbose; /* verbose mode: print the data, list of objcets, warnings */
+ int d; /* delta, absolute value to compare */
+ double delta; /* delta value */
+ int p; /* relative error to compare*/
+ double percent; /* relative error value */
+ int n; /* count, compare up to count */
+ int count; /* count value */
+ int err_stat; /* an error ocurred (1, error, 0, no error) */
+ int cmn_objs; /* do we have comparable objects */
+
} diff_opt_t;
@@ -72,11 +79,11 @@ typedef struct {
extern "C" {
#endif
-int h5diff(const char *fname1,
- const char *fname2,
- const char *objname1,
- const char *objname2,
- diff_opt_t *options);
+hsize_t h5diff(const char *fname1,
+ const char *fname2,
+ const char *objname1,
+ const char *objname2,
+ diff_opt_t *options);
#ifdef __cplusplus
@@ -91,56 +98,56 @@ int h5diff(const char *fname1,
*/
-int diff_dataset( hid_t file1_id,
- hid_t file2_id,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *options );
+hsize_t diff_dataset( hid_t file1_id,
+ hid_t file2_id,
+ const char *obj1_name,
+ const char *obj2_name,
+ diff_opt_t *options );
-int diff_datasetid( hid_t dset1_id,
- hid_t dset2_id,
- const char *obj1_name,
- const char *obj2_name,
+hsize_t diff_datasetid( hid_t dset1_id,
+ hid_t dset2_id,
+ const char *obj1_name,
+ const char *obj2_name,
+ diff_opt_t *options );
+
+hsize_t diff( hid_t file1_id,
+ const char *path1,
+ hid_t file2_id,
+ const char *path2,
+ diff_opt_t *options,
+ H5G_obj_t1 type );
+
+hsize_t diff_compare( hid_t file1_id,
+ const char *file1_name,
+ const char *obj1_name,
+ int nobjects1,
+ trav_info_t *info1,
+ hid_t file2_id,
+ const char *file2_name,
+ const char *obj2_name,
+ int nobjects2,
+ trav_info_t *info2,
+ diff_opt_t *options );
+
+hsize_t diff_match( hid_t file1_id,
+ int nobjects1,
+ trav_info_t *info1,
+ hid_t file2_id,
+ int nobjects2,
+ trav_info_t *info2,
diff_opt_t *options );
-int diff( hid_t file1_id,
- const char *path1,
- hid_t file2_id,
- const char *path2,
- diff_opt_t *options,
- H5G_obj_t type );
-
-int diff_compare( hid_t file1_id,
- const char *file1_name,
- const char *obj1_name,
- int nobjects1,
- trav_info_t *info1,
- hid_t file2_id,
- const char *file2_name,
- const char *obj2_name,
- int nobjects2,
- trav_info_t *info2,
- diff_opt_t *options );
-
-int diff_match( hid_t file1_id,
- int nobjects1,
- trav_info_t *info1,
- hid_t file2_id,
- int nobjects2,
- trav_info_t *info2,
- diff_opt_t *options );
-
-int diff_array( void *_mem1,
- void *_mem2,
- hsize_t nelmts,
- 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,
+ 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*/
int diff_can_type( hid_t f_type1, /* file data type */
@@ -169,6 +176,7 @@ int diff_attr(hid_t loc1_id,
*-------------------------------------------------------------------------
*/
+void print_found(hsize_t nfound);
void print_type(hid_t type);
const char* diff_basename(const char *name);
const char* get_type(int type);
@@ -184,15 +192,52 @@ void print_pos( int *ph,
const char *obj1,
const char *obj2 );
+int print_objname(diff_opt_t *options, hsize_t nfound);
+
+
#if defined (H5DIFF_DEBUG)
void print_sizes( const char *obj1, const char *obj2,
hid_t f_type1, hid_t f_type2,
hid_t m_type1, hid_t m_type2 );
#endif
-#ifdef NOT_YET
-void diff_list( const char *filename, int nobjects, trav_info_t *info );
-#endif /* NOT_YET */
+
+hsize_t diff_native_uchar(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t i,
+ int rank,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+
+
+hsize_t diff_char(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t i,
+ int rank,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+
+hsize_t diff_datum(void *_mem1,
+ void *_mem2,
+ hid_t m_type,
+ hsize_t i,
+ int rank,
+ 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 */
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 838cc3d..51d87d0 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -16,54 +16,28 @@
#include "h5diff.h"
#include "H5private.h"
-static int diff_datum(void *_mem1,
- void *_mem2,
- hid_t m_type,
- hsize_t i,
- int rank,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- hid_t container1_id,
- hid_t container2_id,
- int *ph);
-
-static int diff_native_uchar(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t i,
- int rank,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-static int diff_char(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t i,
- int rank,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
+/* local functions */
+static void close_obj(H5G_obj_t1 obj_type, hid_t obj_id);
+static int diff_region(hid_t region1_id, hid_t region2_id);
static hbool_t is_zero(const void *_mem, size_t size);
-static void close_obj(H5G_obj_t obj_type, hid_t obj_id);
-static int diff_region(hid_t region1_id, hid_t region2_id);
-
+/*-------------------------------------------------------------------------
+ * Function: print_data
+ *
+ * Purpose: print data only in report or verbose modes
+ *-------------------------------------------------------------------------
+ */
+static int print_data(diff_opt_t *options)
+{
+ return (options->m_report || options->m_verbose==1)?1:0;
+}
/*-------------------------------------------------------------------------
* Function: diff_array
*
* Purpose: compare two memory buffers;
*
- * Return: number of differences found, -1 on error
+ * Return: number of differences found
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
@@ -72,19 +46,19 @@ static int diff_region(hid_t region1_id, hid_t region2_id);
*-------------------------------------------------------------------------
*/
-int diff_array( void *_mem1,
- void *_mem2,
- hsize_t nelmts,
- 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,
+ 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*/
{
- int nfound=0; /* number of differences found */
+ 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;
@@ -164,7 +138,7 @@ int diff_array( void *_mem1,
*
* Purpose: Compare the values pointed to in _MEM1 and _MEM2 of type M_TYPE
*
- * Return: number of differences found, -1 on error
+ * Return: number of differences found
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
@@ -197,20 +171,19 @@ int diff_array( void *_mem1,
*-------------------------------------------------------------------------
*/
-static
-int diff_datum( void *_mem1,
- void *_mem2,
- hid_t m_type,
- hsize_t i,
- int rank,
- 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 */
+hsize_t diff_datum(void *_mem1,
+ void *_mem2,
+ hid_t m_type,
+ hsize_t i,
+ int rank,
+ 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 */
{
char fmt_llong[255], fmt_ullong[255];
char fmt_llongp[255], fmt_ullongp[255];
@@ -228,13 +201,14 @@ int diff_datum( void *_mem1,
size_t size;
int iszero1;
int iszero2;
- H5G_obj_t obj1_type;
- H5G_obj_t obj2_type;
+ H5G_obj_t1 obj1_type;
+ H5G_obj_t1 obj2_type;
hid_t obj1_id;
hid_t obj2_id;
H5G_stat_t sb1;
H5G_stat_t sb2;
- int nfound=0; /* differences found */
+ hsize_t nfound=0; /* differences found */
+ int ret;
/* Build default formats for long long types */
sprintf(fmt_llong, "%%%sd %%%sd %%%sd\n",
@@ -381,7 +355,7 @@ int diff_datum( void *_mem1,
if (HDstrcmp(enum_name1,enum_name2)!=0)
{
nfound=1;
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -501,17 +475,22 @@ int diff_datum( void *_mem1,
hid_t region2_id;
if ((obj1_id = H5Rdereference(container1_id, H5R_DATASET_REGION, _mem1))<0)
- return -1;
+ ret= -1;
if ((obj2_id = H5Rdereference(container2_id, H5R_DATASET_REGION, _mem2))<0)
- return -1;
+ ret= -1;
if (H5Gget_objinfo(obj1_id, ".", FALSE, &sb1)<0)
- return -1;
+ ret= -1;
if (H5Gget_objinfo(obj2_id, ".", FALSE, &sb2)<0)
- return -1;
+ ret= -1;
if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1))<0)
- return -1;
+ ret= -1;
if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2))<0)
- return -1;
+ ret= -1;
+
+ if (ret==-1) {
+ options->err_stat=1;
+ return 0;
+ }
if (diff_region(region1_id,region2_id))
{
@@ -535,9 +514,13 @@ int diff_datum( void *_mem1,
{
if ((obj1_type = H5Rget_obj_type(container1_id, H5R_OBJECT, _mem1))<0)
- return -1;
+ ret= -1;
if ((obj2_type = H5Rget_obj_type(container2_id, H5R_OBJECT, _mem2))<0)
- return -1;
+ ret= -1;
+ if (ret==-1) {
+ options->err_stat=1;
+ return 0;
+ }
/* check object type */
if (obj1_type!=obj2_type)
@@ -547,9 +530,13 @@ int diff_datum( void *_mem1,
}
if ((obj1_id = H5Rdereference(container1_id, H5R_OBJECT, _mem1))<0)
- return -1;
+ ret= -1;
if ((obj2_id = H5Rdereference(container2_id, H5R_OBJECT, _mem2))<0)
- return -1;
+ ret= -1;
+ if (ret==-1) {
+ options->err_stat=1;
+ return 0;
+ }
/*deep compare */
@@ -597,7 +584,7 @@ int diff_datum( void *_mem1,
{
if (abs(temp1_char-temp2_char) > options->delta)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -611,7 +598,7 @@ int diff_datum( void *_mem1,
{
if ( temp1_char!=0 && abs(1-temp2_char/temp1_char) > options->percent )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -627,7 +614,7 @@ int diff_datum( void *_mem1,
if ( temp1_char!=0 && abs(1-temp2_char/temp1_char) > options->percent &&
abs(temp1_char-temp2_char) > options->delta )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -639,7 +626,7 @@ int diff_datum( void *_mem1,
}
else if (temp1_char != temp2_char)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -667,7 +654,7 @@ int diff_datum( void *_mem1,
{
if (abs(temp1_uchar-temp2_uchar) > options->delta)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -681,7 +668,7 @@ int diff_datum( void *_mem1,
{
if ( temp1_uchar!=0 && abs(1-temp2_uchar/temp1_uchar) > options->percent )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -697,7 +684,7 @@ int diff_datum( void *_mem1,
if ( temp1_uchar!=0 && abs(1-temp2_uchar/temp1_uchar) > options->percent &&
abs(temp1_uchar-temp2_uchar) > options->delta )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -709,7 +696,7 @@ int diff_datum( void *_mem1,
}
else if (temp1_uchar != temp2_uchar)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -739,7 +726,7 @@ int diff_datum( void *_mem1,
{
if (abs(temp1_short-temp2_short) > options->delta)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -753,7 +740,7 @@ int diff_datum( void *_mem1,
{
if ( temp1_short!=0 && abs(1-temp2_short/temp1_short) > options->percent )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -769,7 +756,7 @@ int diff_datum( void *_mem1,
if ( temp1_short!=0 && abs(1-temp2_short/temp1_short) > options->percent &&
abs(temp1_short-temp2_short) > options->delta )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -781,7 +768,7 @@ int diff_datum( void *_mem1,
}
else if (temp1_short != temp2_short)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -812,7 +799,7 @@ int diff_datum( void *_mem1,
if (abs(temp1_ushort-temp2_ushort) > options->delta)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -827,7 +814,7 @@ int diff_datum( void *_mem1,
if ( temp1_ushort!=0 && abs(1-temp2_ushort/temp1_ushort) > options->percent )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -844,7 +831,7 @@ int diff_datum( void *_mem1,
abs(temp1_ushort-temp2_ushort) > options->delta )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -857,7 +844,7 @@ int diff_datum( void *_mem1,
else if (temp1_ushort != temp2_ushort)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -889,7 +876,7 @@ int diff_datum( void *_mem1,
if (abs(temp1_int-temp2_int) > options->delta)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -904,7 +891,7 @@ int diff_datum( void *_mem1,
if ( temp1_int!=0 && abs(1-temp2_int/temp1_int) > options->percent )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -921,7 +908,7 @@ int diff_datum( void *_mem1,
abs(temp1_int-temp2_int) > options->delta )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -934,7 +921,7 @@ int diff_datum( void *_mem1,
else if (temp1_int != temp2_int)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -966,7 +953,7 @@ int diff_datum( void *_mem1,
if (abs((int)(temp1_uint-temp2_uint)) > options->delta)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -981,7 +968,7 @@ int diff_datum( void *_mem1,
if ( temp1_uint!=0 && abs((int)(1-temp2_uint/temp1_uint)) > options->percent )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -998,7 +985,7 @@ int diff_datum( void *_mem1,
abs((int)(temp1_uint-temp2_uint)) > options->delta )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1011,7 +998,7 @@ int diff_datum( void *_mem1,
else if (temp1_uint != temp2_uint)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1044,7 +1031,7 @@ int diff_datum( void *_mem1,
if (labs(temp1_long-temp2_long) > (long)options->delta)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1059,7 +1046,7 @@ int diff_datum( void *_mem1,
if ( temp1_long!=0 && labs(1-temp2_long/temp1_long) > (long)options->percent )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1076,7 +1063,7 @@ int diff_datum( void *_mem1,
labs(temp1_long-temp2_long) > (long)options->delta )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1089,7 +1076,7 @@ int diff_datum( void *_mem1,
else if (temp1_long != temp2_long)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1121,7 +1108,7 @@ int diff_datum( void *_mem1,
if (labs((long)(temp1_ulong-temp2_ulong)) > (long)options->delta)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1136,7 +1123,7 @@ int diff_datum( void *_mem1,
if ( temp1_ulong!=0 && labs((long)(1-temp2_ulong/temp1_ulong)) > (long)options->percent )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1153,7 +1140,7 @@ int diff_datum( void *_mem1,
labs((long)(temp1_ulong-temp2_ulong)) > (long)options->delta )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1166,7 +1153,7 @@ int diff_datum( void *_mem1,
else if (temp1_ulong != temp2_ulong)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1197,7 +1184,7 @@ int diff_datum( void *_mem1,
if (labs((long)(temp1_llong-temp2_llong)) > (long)options->delta)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1212,7 +1199,7 @@ int diff_datum( void *_mem1,
if ( temp1_llong!=0 && labs((long)(1-temp2_llong/temp1_llong)) > (long)options->percent )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1229,7 +1216,7 @@ int diff_datum( void *_mem1,
labs((long)(temp1_llong-temp2_llong)) > (long)options->delta )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1242,7 +1229,7 @@ int diff_datum( void *_mem1,
else if (temp1_llong != temp2_llong)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1273,7 +1260,7 @@ int diff_datum( void *_mem1,
if (labs((long)(temp1_ullong-temp2_ullong)) > (long)options->delta)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1289,7 +1276,7 @@ int diff_datum( void *_mem1,
if ( temp1_ullong!=0 && labs((long)(1-temp2_ullong/temp1_ullong)) > (long)options->percent )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1307,7 +1294,7 @@ int diff_datum( void *_mem1,
labs((long)(temp1_ullong-temp2_ullong)) > (long)options->delta )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1321,7 +1308,7 @@ int diff_datum( void *_mem1,
else if (temp1_ullong != temp2_ullong)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1358,7 +1345,7 @@ int diff_datum( void *_mem1,
if (fabs(temp1_float-temp2_float) > options->delta)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1373,7 +1360,7 @@ int diff_datum( void *_mem1,
if ( temp1_float!=0 && fabs(1-temp2_float/temp1_float) > options->percent )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1390,7 +1377,7 @@ int diff_datum( void *_mem1,
fabs(temp1_float-temp2_float) > options->delta )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1403,7 +1390,7 @@ int diff_datum( void *_mem1,
else if (temp1_float != temp2_float)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1433,7 +1420,7 @@ int diff_datum( void *_mem1,
if (fabs(temp1_double-temp2_double) > options->delta)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1448,7 +1435,7 @@ int diff_datum( void *_mem1,
if ( temp1_double!=0 && fabs(1-temp2_double/temp1_double) > options->percent )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1465,7 +1452,7 @@ int diff_datum( void *_mem1,
fabs(temp1_double-temp2_double) > options->delta )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1478,7 +1465,7 @@ int diff_datum( void *_mem1,
else if (temp1_double != temp2_double)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1514,19 +1501,18 @@ int diff_datum( void *_mem1,
*-------------------------------------------------------------------------
*/
-static
-int diff_native_uchar(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t i,
- int rank,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+hsize_t diff_native_uchar(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t i,
+ int rank,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph)
{
- int nfound=0; /* differences found */
+ hsize_t nfound=0; /* differences found */
unsigned char temp1_uchar;
unsigned char temp2_uchar;
@@ -1538,7 +1524,7 @@ int diff_native_uchar(unsigned char *mem1,
{
if (abs(temp1_uchar-temp2_uchar) > options->delta)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1552,7 +1538,7 @@ int diff_native_uchar(unsigned char *mem1,
{
if ( temp1_uchar!=0 && abs(1-temp2_uchar/temp1_uchar) > options->percent )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1568,7 +1554,7 @@ int diff_native_uchar(unsigned char *mem1,
if ( temp1_uchar!=0 && abs(1-temp2_uchar/temp1_uchar) > options->percent &&
abs(temp1_uchar-temp2_uchar) > options->delta )
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1580,7 +1566,7 @@ int diff_native_uchar(unsigned char *mem1,
}
else if (temp1_uchar != temp2_uchar)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1607,19 +1593,18 @@ int diff_native_uchar(unsigned char *mem1,
*-------------------------------------------------------------------------
*/
-static
-int diff_char(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t i,
- int rank,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+hsize_t diff_char(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t i,
+ int rank,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph)
{
- int nfound=0; /* differences found */
+ hsize_t nfound=0; /* differences found */
unsigned char temp1_uchar;
unsigned char temp2_uchar;
@@ -1628,7 +1613,7 @@ int diff_char(unsigned char *mem1,
if (temp1_uchar != temp2_uchar)
{
- if ( options->r==0 )
+ if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,obj1,obj2);
printf(SPACES);
@@ -1673,7 +1658,7 @@ is_zero(const void *_mem, size_t size)
*/
static
-void close_obj(H5G_obj_t obj_type, hid_t obj_id)
+void close_obj(H5G_obj_t1 obj_type, hid_t obj_id)
{
switch (obj_type) {
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index a7e6ce4..bf3a874 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -28,7 +28,6 @@
* Return:
* 0 : no differences found
* 1 : differences found
- * -1 : error ocurred
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
@@ -52,7 +51,7 @@ int diff_attr(hid_t loc1_id,
hid_t ftype2_id=-1; /* file data type ID */
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 msize1; /* memory size of memory type */
size_t msize2; /* memory size of memory type */
void *buf1=NULL; /* data buffer */
void *buf2=NULL; /* data buffer */
@@ -61,11 +60,12 @@ int diff_attr(hid_t loc1_id,
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[255];
+ char name1[255];
char name2[255];
- int n1, n2, i, j, nfound;
- H5S_class_t space_type1, space_type2;
+ int n1, n2, i, j;
int ret=0;
+ hsize_t nfound;
+ int cmp=1;
if ((n1 = H5Aget_num_attrs(loc1_id))<0)
goto error;
@@ -100,7 +100,7 @@ int diff_attr(hid_t loc1_id,
if (HDstrcmp(name1,name2)!=0)
{
- if (options->verbose)
+ if (options->m_verbose)
{
printf("Different name for attributes: <%s> and <%s>\n", name1, name2);
}
@@ -110,119 +110,109 @@ int diff_attr(hid_t loc1_id,
continue;
}
- /* get the file datatype */
- if ((ftype1_id = H5Aget_type( attr1_id )) < 0 )
- goto error;
+ /* get the file datatype */
+ if ((ftype1_id = H5Aget_type( attr1_id )) < 0 )
+ goto error;
if ((ftype2_id = H5Aget_type( attr2_id )) < 0 )
- goto error;
+ goto error;
- /* get the dataspace handle */
- if ((space1_id = H5Aget_space( attr1_id )) < 0 )
- goto error;
+ /* get the dataspace handle */
+ if ((space1_id = H5Aget_space( attr1_id )) < 0 )
+ goto error;
if ((space2_id = H5Aget_space( attr2_id )) < 0 )
- goto error;
+ goto error;
- space_type1 = H5Sget_simple_extent_type(space1_id);
- space_type2 = H5Sget_simple_extent_type(space2_id);
+ /* get dimensions */
+ if ( (rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0 )
+ goto error;
+ if ( (rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0 )
+ goto error;
- /* get dimensions */
- if(space_type1 == H5S_NULL && space_type2 == H5S_NULL) {
- if(options->verbose) {
- printf( "Attribute: <%s> and <%s>\n",name1,name2);
- sprintf(name1,"%s of <%s>",name1,path1);
- sprintf(name2,"%s of <%s>",name2,path2);
- printf( "type %s %s difference\n",name1,name2);
- if ( !(H5Tequal(ftype1_id, ftype2_id)) && options->verbose) {
- printf("\t\t");
- print_type(ftype1_id);
- printf("\t\t");
- print_type(ftype2_id);
- printf("\n");
- }
-
- printf("1 differences found\n");
- }
- } else {
- if ( (rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0 )
- goto error;
+/*-------------------------------------------------------------------------
+ * check for comparable TYPE and SPACE
+ *-------------------------------------------------------------------------
+ */
+
+ if (diff_can_type(ftype1_id,
+ ftype2_id,
+ rank1,
+ rank2,
+ dims1,
+ dims2,
+ NULL,
+ NULL,
+ name1,
+ name2,
+ options)!=1)
+ cmp=0;
+/*-------------------------------------------------------------------------
+ * only attempt to compare if possible
+ *-------------------------------------------------------------------------
+ */
+ if (cmp)
+ {
+
+/*-------------------------------------------------------------------------
+ * read to memory
+ *-------------------------------------------------------------------------
+ */
+ nelmts1=1;
+ for (j=0; j<rank1; j++)
+ nelmts1*=dims1[j];
+ if ((mtype1_id=H5Tget_native_type(ftype1_id,H5T_DIR_DEFAULT))<0)
+ goto error;
+ if ((mtype2_id=H5Tget_native_type(ftype2_id,H5T_DIR_DEFAULT))<0)
+ goto error;
+ if ((msize1=H5Tget_size(mtype1_id))==0)
+ goto error;
+ if ((msize2=H5Tget_size(mtype2_id))==0)
+ goto error;
+
+ assert(msize1==msize2);
+
+ buf1=(void *) HDmalloc((unsigned)(nelmts1*msize1));
+ buf2=(void *) HDmalloc((unsigned)(nelmts1*msize2));
+ if ( buf1==NULL || buf2==NULL){
+ printf( "cannot read into memory\n" );
+ goto error;
+ }
+ if (H5Aread(attr1_id,mtype1_id,buf1)<0)
+ goto error;
+ if (H5Aread(attr2_id,mtype2_id,buf2)<0)
+ goto error;
- if ( (rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0 )
- goto error;
+
+/*-------------------------------------------------------------------------
+ * array compare
+ *-------------------------------------------------------------------------
+ */
+ sprintf(name1,"%s of <%s>",name1,path1);
+ sprintf(name2,"%s of <%s>",name2,path2);
+ nfound = diff_array(buf1,
+ buf2,
+ nelmts1,
+ rank1,
+ dims1,
+ options,
+ name1,
+ name2,
+ mtype1_id,
+ attr1_id,
+ attr2_id);
+
+ }/*cmp*/
- /*-------------------------------------------------------------------------
- * check for comparable TYPE and SPACE
- *-------------------------------------------------------------------------
- */
- if (diff_can_type(ftype1_id,
- ftype2_id,
- rank1,
- rank2,
- dims1,
- dims2,
- NULL,
- NULL,
- name1,
- name2,
- options)!=1)
- goto error;
-
- /*-------------------------------------------------------------------------
- * read to memory
- *-------------------------------------------------------------------------
- */
- nelmts1=1;
- for (j=0; j<rank1; j++)
- nelmts1*=dims1[j];
- if ((mtype1_id=H5Tget_native_type(ftype1_id,H5T_DIR_DEFAULT))<0)
- goto error;
- if ((mtype2_id=H5Tget_native_type(ftype2_id,H5T_DIR_DEFAULT))<0)
- goto error;
- if ((msize1=H5Tget_size(mtype1_id))==0)
- goto error;
- if ((msize2=H5Tget_size(mtype2_id))==0)
- goto error;
-
- assert(msize1==msize2);
-
- buf1=(void *) HDmalloc((unsigned)(nelmts1*msize1));
- buf2=(void *) HDmalloc((unsigned)(nelmts1*msize2));
- if ( buf1==NULL || buf2==NULL){
- printf( "cannot read into memory\n" );
- goto error;
- }
- if (H5Aread(attr1_id,mtype1_id,buf1)<0)
- goto error;
- if (H5Aread(attr2_id,mtype2_id,buf2)<0)
- goto error;
-
- /*-------------------------------------------------------------------------
- * array compare
- *-------------------------------------------------------------------------
- */
+/*-------------------------------------------------------------------------
+ * print how many differences were found
+ *-------------------------------------------------------------------------
+ */
+ if (print_objname(options,nfound))
+ {
+ printf( "Attribute: <%s> and <%s>\n",name1,name2);
+ print_found(nfound);
+ }
- if (options->verbose)
- printf( "Attribute: <%s> and <%s>\n",name1,name2);
- sprintf(name1,"%s of <%s>",name1,path1);
- sprintf(name2,"%s of <%s>",name2,path2);
- nfound = diff_array(buf1,
- buf2,
- nelmts1,
- rank1,
- dims1,
- options,
- name1,
- name2,
- mtype1_id,
- attr1_id,
- attr2_id);
-
- if (options->verbose && nfound)
- printf("%d differences found\n", nfound );
-
- if (mtype1_id && H5Tclose(mtype1_id)<0) goto error;
- if (mtype2_id && H5Tclose(mtype2_id)<0) goto error;
- }
/*-------------------------------------------------------------------------
* close
@@ -231,6 +221,8 @@ int diff_attr(hid_t loc1_id,
if (H5Tclose(ftype1_id)<0) goto error;
if (H5Tclose(ftype2_id)<0) goto error;
+ if (H5Tclose(mtype1_id)<0) goto error;
+ if (H5Tclose(mtype2_id)<0) goto error;
if (H5Sclose(space1_id)<0) goto error;
if (H5Sclose(space2_id)<0) goto error;
if (H5Aclose(attr1_id)<0) goto error;
@@ -247,18 +239,20 @@ error:
H5E_BEGIN_TRY {
H5Tclose(ftype1_id);
H5Tclose(ftype2_id);
- H5Tclose(mtype1_id);
+ H5Tclose(mtype1_id);
H5Tclose(mtype2_id);
- H5Sclose(space1_id);
+ H5Sclose(space1_id);
H5Sclose(space2_id);
- H5Aclose(attr1_id);
+ H5Aclose(attr1_id);
H5Aclose(attr2_id);
if (buf1)
HDfree(buf1);
if (buf2)
HDfree(buf2);
} H5E_END_TRY;
- return -1;
+
+ options->err_stat=1;
+ return 0;
}
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index 4f90d67..69acfbd 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -30,47 +30,43 @@
*
*-------------------------------------------------------------------------
*/
-int diff_dataset( hid_t file1_id,
- hid_t file2_id,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *options )
+hsize_t diff_dataset( hid_t file1_id,
+ hid_t file2_id,
+ const char *obj1_name,
+ const char *obj2_name,
+ diff_opt_t *options )
{
- hid_t dset1_id =-1;
- hid_t dset2_id =-1;
- hid_t dcpl1_id=-1;
- hid_t dcpl2_id=-1;
- int gout=0, nfound=0;
-
-
- /* disable error reporting */
- H5E_BEGIN_TRY {
+ hid_t dset1_id=-1;
+ hid_t dset2_id=-1;
+ hid_t dcpl1_id=-1;
+ hid_t dcpl2_id=-1;
+ hsize_t nfound=0;
/*-------------------------------------------------------------------------
* open the handles
*-------------------------------------------------------------------------
*/
-
+ /* disable error reporting */
+ H5E_BEGIN_TRY {
/* Open the datasets */
if ( (dset1_id = H5Dopen(file1_id,obj1_name)) < 0 )
{
printf("Cannot open dataset <%s>\n", obj1_name );
- gout=1;
+ goto error;
}
if ( (dset2_id = H5Dopen(file2_id,obj2_name)) < 0 )
{
printf("Cannot open dataset <%s>\n", obj2_name );
- gout=1;
+ goto error;
}
/* enable error reporting */
} H5E_END_TRY;
- if (gout)
- goto out;
+
if ((dcpl1_id=H5Dget_create_plist(dset1_id))<0)
- goto out;
+ goto error;
if ((dcpl2_id=H5Dget_create_plist(dset2_id))<0)
- goto out;
+ goto error;
/*-------------------------------------------------------------------------
* check if the dataset creation property list has filters that
@@ -79,8 +75,8 @@ int diff_dataset( hid_t file1_id,
* 2) the internal filters might be turned off
*-------------------------------------------------------------------------
*/
- if ((h5tools_canreadf((options->verbose?obj1_name:NULL),dcpl1_id)==1) &&
- (h5tools_canreadf((options->verbose?obj2_name:NULL),dcpl2_id)==1))
+ if ((h5tools_canreadf((options->m_verbose?obj1_name:NULL),dcpl1_id)==1) &&
+ (h5tools_canreadf((options->m_verbose?obj2_name:NULL),dcpl2_id)==1))
{
nfound=diff_datasetid(dset1_id,
dset2_id,
@@ -92,7 +88,19 @@ int diff_dataset( hid_t file1_id,
* close
*-------------------------------------------------------------------------
*/
-out:
+ /* disable error reporting */
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl1_id);
+ H5Pclose(dcpl2_id);
+ H5Dclose(dset1_id);
+ H5Dclose(dset2_id);
+ /* enable error reporting */
+ } H5E_END_TRY;
+
+ return nfound;
+
+error:
+ options->err_stat=1;
/* disable error reporting */
H5E_BEGIN_TRY {
H5Pclose(dcpl1_id);
@@ -123,11 +131,11 @@ out:
*
*-------------------------------------------------------------------------
*/
-int diff_datasetid( hid_t dset1_id,
- hid_t dset2_id,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *options )
+hsize_t diff_datasetid( hid_t dset1_id,
+ hid_t dset2_id,
+ const char *obj1_name,
+ const char *obj2_name,
+ diff_opt_t *options )
{
hid_t space1_id =-1;
hid_t space2_id =-1;
@@ -142,83 +150,37 @@ int diff_datasetid( hid_t dset1_id,
hsize_t dims2[H5S_MAX_RANK];
hsize_t maxdim1[H5S_MAX_RANK];
hsize_t maxdim2[H5S_MAX_RANK];
- int nfound=0; /* number of differences found */
const char *name1=NULL; /* relative names */
const char *name2=NULL;
hsize_t storage_size1;
hsize_t storage_size2;
- H5S_class_t space_type1, space_type2;
+ hsize_t nfound=0; /* number of differences found */
+ int cmp=1; /* do diff or not */
int i;
- if (obj1_name)
- name1=diff_basename(obj1_name);
- if (obj2_name)
- name2=diff_basename(obj2_name);
-
-/*-------------------------------------------------------------------------
- * Get the file data type
- *-------------------------------------------------------------------------
- */
-
- /* Get the data type */
- if ( (f_type1 = H5Dget_type(dset1_id)) < 0 )
- goto out;
-
- /* Get the data type */
- if ( (f_type2 = H5Dget_type(dset2_id)) < 0 )
- goto out;
-
-/*-------------------------------------------------------------------------
- * Get the file data space
- *-------------------------------------------------------------------------
- */
-
- /* Get the dataspace handle */
+ /* Get the dataspace handle */
if ( (space1_id = H5Dget_space(dset1_id)) < 0 )
- goto out;
+ goto error;
- if ( (space2_id = H5Dget_space(dset2_id)) < 0 )
- goto out;
-
- /* Get space type */
- space_type1 = H5Sget_simple_extent_type(space1_id);
- space_type2 = H5Sget_simple_extent_type(space2_id);
-
- /* get dimensions */
- if(space_type1 == H5S_NULL && space_type2 == H5S_NULL) {
- if(options->verbose) {
- /*printf( "Dataset: <%s> and <%s>\n",name1,name2);*/
- /*sprintf(name1,"%s of <%s>",name1,path1);
- sprintf(name2,"%s of <%s>",name2,path2);*/
- printf( "type %s %s difference\n",name1,name2);
-
- if ( !(H5Tequal(f_type1, f_type2)) && options->verbose) {
- printf("\t");
- print_type(f_type1);
- printf("\t\t");
- print_type(f_type2);
- printf("\n");
- }
-
- printf("1 differences found\n");
- nfound = 1;
- }
- goto out;
- }
-
/* Get rank */
if ( (rank1 = H5Sget_simple_extent_ndims(space1_id)) < 0 )
- goto out;
+ goto error;
+ /* Get the dataspace handle */
+ if ( (space2_id = H5Dget_space(dset2_id)) < 0 )
+ goto error;
+
+ /* Get rank */
if ( (rank2 = H5Sget_simple_extent_ndims(space2_id)) < 0 )
- goto out;
+ goto error;
/* Get dimensions */
if ( H5Sget_simple_extent_dims(space1_id,dims1,maxdim1) < 0 )
- goto out;
+ goto error;
+ /* Get dimensions */
if ( H5Sget_simple_extent_dims(space2_id,dims2,maxdim2) < 0 )
- goto out;
+ goto error;
/*-------------------------------------------------------------------------
* Get the file data type
@@ -227,11 +189,11 @@ int diff_datasetid( hid_t dset1_id,
/* Get the data type */
if ( (f_type1 = H5Dget_type(dset1_id)) < 0 )
- goto out;
+ goto error;
/* Get the data type */
if ( (f_type2 = H5Dget_type(dset2_id)) < 0 )
- goto out;
+ goto error;
/*-------------------------------------------------------------------------
@@ -243,9 +205,9 @@ int diff_datasetid( hid_t dset1_id,
storage_size2=H5Dget_storage_size(dset2_id);
if (storage_size1<=0 && storage_size2<=0)
{
- if (options->verbose && obj1_name && obj2_name)
+ if (options->m_verbose && obj1_name && obj2_name)
printf("<%s> and <%s> are empty datasets\n", obj1_name, obj2_name);
- goto out;
+ cmp=0;
}
@@ -265,15 +227,11 @@ int diff_datasetid( hid_t dset1_id,
obj1_name,
obj2_name,
options)!=1)
- goto out;
-
-
-
+ cmp=0;
/*-------------------------------------------------------------------------
* get number of elements
*-------------------------------------------------------------------------
*/
-
nelmts1 = 1;
for (i = 0; i < rank1; i++)
{
@@ -293,7 +251,7 @@ int diff_datasetid( hid_t dset1_id,
*-------------------------------------------------------------------------
*/
- if ( (H5Tequal(f_type1, f_type2)==0) && options->verbose && obj1_name)
+ if ( (H5Tequal(f_type1, f_type2)==0) && options->m_verbose && obj1_name)
{
printf("Warning: Different storage datatype\n");
printf("<%s> has file datatype ", obj1_name);
@@ -329,11 +287,11 @@ int diff_datasetid( hid_t dset1_id,
sign2=H5Tget_sign(m_type2);
if ( sign1 != sign2 )
{
- if (options->verbose && obj1_name) {
+ if (options->m_verbose && obj1_name) {
printf("Comparison not supported: <%s> has sign %s ", obj1_name, get_sign(sign1));
printf("and <%s> has sign %s\n", obj2_name, get_sign(sign2));
}
- goto out;
+ cmp=0;
}
/*-------------------------------------------------------------------------
@@ -363,13 +321,20 @@ int diff_datasetid( hid_t dset1_id,
}
assert(m_size1==m_size2);
+/*-------------------------------------------------------------------------
+ * only attempt to compare if possible
+ *-------------------------------------------------------------------------
+ */
+ if (cmp)
+ {
+
buf1 = (void *) HDmalloc((unsigned) (nelmts1*m_size1));
buf2 = (void *) HDmalloc((unsigned) (nelmts2*m_size2));
if ( buf1 == NULL || buf2 == NULL )
{
printf( "cannot read into memory\n" );
- goto out;
+ goto error;
}
/*-------------------------------------------------------------------------
@@ -378,15 +343,19 @@ int diff_datasetid( hid_t dset1_id,
*/
if ( H5Dread(dset1_id,m_type1,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf1) < 0 )
- goto out;
+ goto error;
if ( H5Dread(dset2_id,m_type2,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf2) < 0 )
- goto out;
+ goto error;
/*-------------------------------------------------------------------------
* array compare
*-------------------------------------------------------------------------
*/
+ if (obj1_name)
+ name1=diff_basename(obj1_name);
+ if (obj2_name)
+ name2=diff_basename(obj2_name);
nfound = diff_array(buf1,
buf2,
nelmts1,
@@ -398,10 +367,6 @@ int diff_datasetid( hid_t dset1_id,
m_type1,
dset1_id,
dset2_id);
-
- if (options->verbose && nfound)
- printf("%d differences found\n", nfound );
-
/*-------------------------------------------------------------------------
* compare attributes
* the if condition refers to cases when the dataset is a referenced object
@@ -409,18 +374,36 @@ int diff_datasetid( hid_t dset1_id,
*/
if (obj1_name)
- nfound=diff_attr(dset1_id,dset2_id,obj1_name,obj2_name,options);
+ diff_attr(dset1_id,dset2_id,obj1_name,obj2_name,options);
+
+ }/*cmp*/
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
-
-out:
-
+
+
if ( buf1) HDfree(buf1);
if ( buf2) HDfree(buf2);
+ /* close */
+ /* disable error reporting */
+ H5E_BEGIN_TRY {
+ H5Sclose(space1_id);
+ H5Sclose(space2_id);
+ H5Tclose(f_type1);
+ H5Tclose(f_type2);
+ H5Tclose(m_type1);
+ H5Tclose(m_type2);
+ /* enable error reporting */
+ } H5E_END_TRY;
+ return nfound;
+
+error:
+ options->err_stat=1;
+ if ( buf1) HDfree(buf1);
+ if ( buf2) HDfree(buf2);
/* close */
/* disable error reporting */
H5E_BEGIN_TRY {
@@ -486,7 +469,7 @@ int diff_can_type( hid_t f_type1, /* file data type */
if ( tclass1 != tclass2 )
{
- if (options->verbose && obj1_name) {
+ if (options->m_verbose && obj1_name) {
printf("Comparison not possible: <%s> is of class %s and <%s> is of class %s\n",
obj1_name, get_class(tclass1),
obj2_name, get_class(tclass2) );
@@ -516,7 +499,7 @@ int diff_can_type( hid_t f_type1, /* file data type */
break;
default: /*H5T_TIME */
- if (options->verbose && obj1_name )
+ if (options->m_verbose && obj1_name )
printf("Comparison not supported: <%s> and <%s> are of class %s\n",
obj1_name,obj2_name,get_class(tclass2) );
return 0;
@@ -527,7 +510,7 @@ int diff_can_type( hid_t f_type1, /* file data type */
*-------------------------------------------------------------------------
*/
- if ( (H5Tequal(f_type1, f_type2)==0) && options->verbose && obj1_name)
+ if ( (H5Tequal(f_type1, f_type2)==0) && options->m_verbose && obj1_name)
{
printf("Warning: Different storage datatype\n");
printf("<%s> has file datatype ", obj1_name);
@@ -545,7 +528,7 @@ int diff_can_type( hid_t f_type1, /* file data type */
if ( rank1 != rank2 )
{
- if (options->verbose && obj1_name) {
+ if (options->m_verbose && obj1_name) {
printf("Comparison not supported: <%s> has rank %d, dimensions ", obj1_name, rank1);
print_dims(rank1,dims1);
printf(", max dimensions ");
@@ -583,7 +566,7 @@ int diff_can_type( hid_t f_type1, /* file data type */
if (dim_diff==1)
{
- if (options->verbose && obj1_name) {
+ if (options->m_verbose && obj1_name) {
printf("Comparison not supported: <%s> has rank %d, dimensions ", obj1_name, rank1);
print_dims(rank1,dims1);
if (maxdim1 && maxdim2) {
@@ -605,7 +588,7 @@ int diff_can_type( hid_t f_type1, /* file data type */
*/
if (maxdim1 && maxdim2 && maxdim_diff==1 && obj1_name )
{
- if (options->verbose) {
+ if (options->m_verbose) {
printf( "Warning: Different maximum dimensions\n");
printf("<%s> has max dimensions ", obj1_name);
print_dims(rank1,maxdim1);
diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c
index 7af48c4..bbd1747 100644
--- a/tools/lib/h5diff_util.c
+++ b/tools/lib/h5diff_util.c
@@ -333,6 +333,18 @@ get_class(H5T_class_t tclass)
}
}
+/*-------------------------------------------------------------------------
+ * Function: print_found
+ *
+ * Purpose: print number of differences found
+ *
+ *-------------------------------------------------------------------------
+ */
+void print_found(hsize_t nfound)
+{
+ HDfprintf(stdout,"%Hu differences found\n",nfound);
+}
+
/*-------------------------------------------------------------------------
* Function: print_sizes