diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2008-06-16 22:17:29 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2008-06-16 22:17:29 (GMT) |
commit | db2c4c497abab139485dbf6797e56b1340e4577d (patch) | |
tree | f7dfb321a3643658ed24aaf776ec4c1e48bc76a3 /tools/lib | |
parent | 55af47c47c3c0c7bc17266968f5e0e782189e819 (diff) | |
download | hdf5-db2c4c497abab139485dbf6797e56b1340e4577d.zip hdf5-db2c4c497abab139485dbf6797e56b1340e4577d.tar.gz hdf5-db2c4c497abab139485dbf6797e56b1340e4577d.tar.bz2 |
[svn-r15221] Description:
Bring changes from trunk from the time the branch was created (r14280)
up to the 1.8.0 release (r14525) back into the metadata journaling branch.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/Makefile.in | 1 | ||||
-rw-r--r-- | tools/lib/h5diff.c | 2 | ||||
-rw-r--r-- | tools/lib/h5diff_array.c | 4130 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 155 | ||||
-rw-r--r-- | tools/lib/h5tools_ref.c | 192 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.c | 186 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.h | 2 | ||||
-rw-r--r-- | tools/lib/h5trav.c | 276 | ||||
-rw-r--r-- | tools/lib/h5trav.h | 14 |
9 files changed, 2588 insertions, 2370 deletions
diff --git a/tools/lib/Makefile.in b/tools/lib/Makefile.in index 8de1275..ab8643d 100644 --- a/tools/lib/Makefile.in +++ b/tools/lib/Makefile.in @@ -209,6 +209,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 4a6a8cd..4f4074f 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -810,7 +810,7 @@ hsize_t diff(hid_t file1_id, /*------------------------------------------------------------------------- * non verbose, check first if we have differences by enabling quiet mode * so that printing is off, and compare again if differences found, - * disabling quite mode + * disabling quiet mode *------------------------------------------------------------------------- */ else { diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 75b773a..008b6b9 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -21,6 +21,12 @@ #include <sys/timeb.h> #include <time.h> +#if 0 +#define H5DIFF_DO_TIME +#endif +#if 1 +#define H5DIFF_DO_NAN +#endif /*------------------------------------------------------------------------- * printf formatting @@ -61,8 +67,6 @@ #define H5DIFF_FLT_EPSILON .00001 #define H5DIFF_DBL_EPSILON .000000001 -static hbool_t equal_float(float value, float expected); -static hbool_t equal_double(double value, double expected); /*------------------------------------------------------------------------- * -p relative error formula @@ -126,8 +130,13 @@ 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(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 *options,const char *obj1,const char *obj2,int *ph); +static hbool_t equal_float(float value, float expected); +static hbool_t equal_double(double value, double expected); - +/*------------------------------------------------------------------------- + * NaN detection + *------------------------------------------------------------------------- + */ typedef enum dtype_t { FLT_FLOAT, FLT_DOUBLE, @@ -154,7 +163,7 @@ static int my_isnan(dtype_t type, void *val); static int print_data(diff_opt_t *options) { - return ( (options->m_report || options->m_verbose) && !options->m_quiet)?1:0; + return ( (options->m_report || options->m_verbose) && !options->m_quiet)?1:0; } /*------------------------------------------------------------------------- @@ -253,170 +262,135 @@ hsize_t diff_array( void *_mem1, 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; - unsigned char *tmp1; - unsigned char *tmp2; - hsize_t acc[32]; /* accumulator position */ - hsize_t pos[32]; /* matrix position */ - int ph=1; /* print header */ - hsize_t i; - int j; - - - /* get the size. */ - size = H5Tget_size( m_type ); - - 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; - - if(H5Tis_variable_str(m_type)) - { - tmp1 = ((unsigned char**)mem1)[0]; - tmp2 = ((unsigned char**)mem2)[0]; - nfound+=diff_datum( - tmp1, - tmp2, - m_type, - (hsize_t)0, - rank, - dims, - acc, - pos, - options, - name1, - name2, - container1_id, - container2_id, - &ph); - } - - else - { - switch (H5Tget_class(m_type)) - { - default: - assert(0); - break; - - /*------------------------------------------------------------------------- - * float and integer atomic types - *------------------------------------------------------------------------- - */ - - case H5T_FLOAT: - - if (H5Tequal(m_type, H5T_NATIVE_FLOAT)) - { - -#if defined (H5DIFF_DO_TIME) - int time; - - #if defined (WIN32) - struct _timeb *tbstart = malloc(sizeof(struct _timeb)); - struct _timeb *tbstop = malloc(sizeof(struct _timeb)); - _ftime( tbstart); - #else - struct timeb *tbstart = malloc(sizeof(struct timeb)); - struct timeb *tbstop = malloc(sizeof(struct timeb)); - ftime( tbstart); - #endif - -#endif - - - - nfound=diff_float(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph); - - -#if defined (H5DIFF_DO_TIME) - - #if defined (WIN32) - _ftime( tbstop ); - #else - ftime( tbstop ); - #endif - - time = tbstop->time - tbstart->time; - printf(" TIME = %d\n", time ); - -#endif - - } - else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE)) - nfound=diff_double(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph); - 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); - else if (H5Tequal(m_type, H5T_NATIVE_UCHAR)) - nfound=diff_uchar(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,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); - else if (H5Tequal(m_type, H5T_NATIVE_USHORT)) - nfound=diff_ushort(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,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); - else if (H5Tequal(m_type, H5T_NATIVE_UINT)) - nfound=diff_uint(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,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); - else if (H5Tequal(m_type, H5T_NATIVE_ULONG)) - nfound=diff_ulong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,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); - else if (H5Tequal(m_type, H5T_NATIVE_ULLONG)) - nfound=diff_ullong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph); - - break; - - /*------------------------------------------------------------------------- - * Other types than float and integer - *------------------------------------------------------------------------- - */ - - case H5T_COMPOUND: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_ARRAY: - case H5T_VLEN: - case H5T_REFERENCE: - - 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); - if (options->n && nfound>=options->count) - return nfound; - } /* i */ - } /* switch */ - } /* else */ - - return nfound; + 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; + unsigned char *tmp1; + unsigned char *tmp2; + hsize_t acc[32]; /* accumulator position */ + hsize_t pos[32]; /* matrix position */ + int ph=1; /* print header */ + hsize_t i; + int j; + + + /* get the size. */ + size = H5Tget_size( m_type ); + + 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; + + if(H5Tis_variable_str(m_type)) + { + tmp1 = ((unsigned char**)mem1)[0]; + tmp2 = ((unsigned char**)mem2)[0]; + nfound+=diff_datum( + tmp1, + tmp2, + m_type, + (hsize_t)0, + rank, + dims, + acc, + pos, + options, + name1, + name2, + container1_id, + container2_id, + &ph); + } + + else + { + switch (H5Tget_class(m_type)) + { + default: + assert(0); + break; + + /*------------------------------------------------------------------------- + * 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); + else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE)) + nfound=diff_double(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph); + 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); + else if (H5Tequal(m_type, H5T_NATIVE_UCHAR)) + nfound=diff_uchar(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,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); + else if (H5Tequal(m_type, H5T_NATIVE_USHORT)) + nfound=diff_ushort(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,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); + else if (H5Tequal(m_type, H5T_NATIVE_UINT)) + nfound=diff_uint(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,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); + else if (H5Tequal(m_type, H5T_NATIVE_ULONG)) + nfound=diff_ulong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,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); + else if (H5Tequal(m_type, H5T_NATIVE_ULLONG)) + nfound=diff_ullong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph); + + break; + + /*------------------------------------------------------------------------- + * Other types than float and integer + *------------------------------------------------------------------------- + */ + + case H5T_COMPOUND: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_ENUM: + case H5T_ARRAY: + case H5T_VLEN: + case H5T_REFERENCE: + + 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); + if (options->n && nfound>=options->count) + return nfound; + } /* i */ + } /* switch */ + } /* else */ + + return nfound; } /*------------------------------------------------------------------------- @@ -472,1640 +446,1778 @@ hsize_t diff_datum(void *_mem1, hid_t container2_id, /*where the reference came from*/ int *ph) /*print header */ { - unsigned char *mem1 = (unsigned char*)_mem1; - unsigned char *mem2 = (unsigned char*)_mem2; - unsigned u; - hid_t memb_type; - size_t type_size; - size_t offset; - int nmembs; - int j; - hsize_t nelmts; - size_t size=0; - int iszero1; - int 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; - int both_zero; - - type_size = H5Tget_size( m_type ); - - switch (H5Tget_class(m_type)) - { - default: - assert(0); - break; - case H5T_TIME: - assert(0); - break; - - /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - case H5T_COMPOUND: - nmembs = H5Tget_nmembers(m_type); - for (j = 0; j < nmembs; j++) - { - offset = H5Tget_member_offset(m_type, (unsigned)j); - memb_type = H5Tget_member_type(m_type, (unsigned)j); - nfound+=diff_datum( - mem1+offset, - mem2+offset, - memb_type, - i, - rank, - dims, - acc, - pos, - options, - obj1, - obj2, - container1_id, - container2_id, - ph); - H5Tclose(memb_type); - } - break; - - /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - case H5T_STRING: - { - - H5T_str_t pad; - char *s; - - if(H5Tis_variable_str(m_type)) - { - /* mem1 is the pointer into the struct where a `char*' is stored. So we have - * to dereference the pointer to get the `char*' to pass to HDstrlen(). */ - s = *(char**)mem1; - if(s!=NULL) - size = HDstrlen(s); - } - else - { - s = (char *)mem1; - size = H5Tget_size(m_type); - } - - pad = H5Tget_strpad(m_type); - - /* check for NULL pointer for string */ - if(s!=NULL) - for (u=0; u<size && (s[u] || pad!=H5T_STR_NULLTERM); u++) - nfound+=character_compare( - mem1 + u, - mem2 + u, /* offset */ - i, /* index position */ - rank, - dims, - acc, - pos, - options, - obj1, - obj2, - ph); - - } - break; - - /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - case H5T_BITFIELD: - { - /* 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); - - } - break; - - /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - case H5T_OPAQUE: - - /* 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); - - break; + unsigned char *mem1 = (unsigned char*)_mem1; + unsigned char *mem2 = (unsigned char*)_mem2; + unsigned u; + hid_t memb_type; + size_t type_size; + size_t offset; + int nmembs; + int j; + hsize_t nelmts; + size_t size=0; + int iszero1; + int 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; + int both_zero; + + type_size = H5Tget_size( m_type ); + + switch (H5Tget_class(m_type)) + { + default: + assert(0); + break; + case H5T_TIME: + assert(0); + break; + + /*------------------------------------------------------------------------- + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ + case H5T_COMPOUND: + nmembs = H5Tget_nmembers(m_type); - /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - case H5T_ENUM: + for (j = 0; j < nmembs; j++) + { + offset = H5Tget_member_offset(m_type, (unsigned)j); + memb_type = H5Tget_member_type(m_type, (unsigned)j); + nfound+=diff_datum( + mem1+offset, + mem2+offset, + memb_type, + i, + rank, + dims, + acc, + pos, + options, + obj1, + obj2, + container1_id, + container2_id, + ph); + H5Tclose(memb_type); + } + break; + + /*------------------------------------------------------------------------- + * H5T_STRING + *------------------------------------------------------------------------- + */ + case H5T_STRING: - /* For enumeration types we compare the names instead of the + { + + H5T_str_t pad; + char *s; + + if(H5Tis_variable_str(m_type)) + { + /* mem1 is the pointer into the struct where a `char*' is stored. So we have + * to dereference the pointer to get the `char*' to pass to HDstrlen(). */ + s = *(char**)mem1; + if(s!=NULL) + size = HDstrlen(s); + } + else + { + s = (char *)mem1; + size = H5Tget_size(m_type); + } + + pad = H5Tget_strpad(m_type); + + /* check for NULL pointer for string */ + if(s!=NULL) + { + for (u=0; u<size && (s[u] || pad!=H5T_STR_NULLTERM); u++) + nfound+=character_compare( + mem1 + u, + mem2 + u, /* offset */ + i, /* index position */ + rank, + dims, + acc, + pos, + options, + obj1, + obj2, + ph); + } + + } + break; + + /*------------------------------------------------------------------------- + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ + case H5T_BITFIELD: + + /* 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); + + break; + + /*------------------------------------------------------------------------- + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + case H5T_OPAQUE: + + /* 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); + + break; + + + /*------------------------------------------------------------------------- + * 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 - */ - - { - char enum_name1[1024]; - char enum_name2[1024]; - - /* disable error reporting */ - H5E_BEGIN_TRY { - - if ((H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1) >= 0) && - (H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2) >= 0)) - { - if (HDstrcmp(enum_name1,enum_name2)!=0) - { - nfound=1; - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(S_FORMAT,enum_name1,enum_name2); - } - } - else - { - for (u=0; u<type_size; u++) - nfound+=character_compare_opt( - mem1 + u, - mem2 + u, /* offset */ - i, /* index position */ - rank, - dims, - acc, - pos, - options, - obj1, - obj2, - ph); - } - } - /* enable error reporting */ - } H5E_END_TRY; - } - - - break; - - /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - case H5T_ARRAY: - { - hsize_t adims[H5S_MAX_RANK]; - hsize_t 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); - assert(ndims >= 1 && ndims <= H5S_MAX_RANK); - - /* calculate the number of array elements */ - for (u = 0, nelmts = 1; u <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); - H5Tclose(memb_type); - } - break; - - /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ - - case H5T_VLEN: - - /* 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 < (int)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); - - H5Tclose(memb_type); - - break; - - - case H5T_REFERENCE: - - iszero1=all_zero(_mem1, H5Tget_size(m_type)); - iszero2=all_zero(_mem2, H5Tget_size(m_type)); - if (iszero1 != iszero2) - { - return 1; - } - else if (!iszero1 && !iszero2) - { - - /*------------------------------------------------------------------------- - * H5T_STD_REF_DSETREG - * Dataset region reference - *------------------------------------------------------------------------- - */ - - if (H5Tequal(m_type, H5T_STD_REF_DSETREG)) - { - hid_t region1_id; - hid_t region2_id; - - 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 (ret==-1) { - options->err_stat=1; - return 0; - } - - nfound = diff_region(obj1_id,obj2_id,region1_id,region2_id,options); - - 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 (H5Tequal(m_type, H5T_STD_REF_OBJ)) - { - 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 */ - - /* 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 */ - - /* compare */ - if(obj1_type == H5O_TYPE_DATASET) - nfound = diff_datasetid(obj1_id, - obj2_id, - NULL, - NULL, - options); - else { - parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>", - obj1, obj2); - options->not_cmp = 1; - } - - H5Oclose(obj1_id); - H5Oclose(obj2_id); - - }/*object reference*/ - - }/*is zero*/ - - - break; - - - case H5T_INTEGER: - - - /*------------------------------------------------------------------------- - * H5T_NATIVE_SCHAR - *------------------------------------------------------------------------- - */ - if (H5Tequal(m_type, H5T_NATIVE_SCHAR)) - { - char temp1_char; - char temp2_char; - assert(type_size==sizeof(char)); - memcpy(&temp1_char, mem1, sizeof(char)); - memcpy(&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); - parallel_print(SPACES); - 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); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,ABS(temp1_char-temp2_char)); - } - options->not_cmp=1; - 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++; - } - } - /* -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); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,ABS(temp1_char-temp2_char)); - } - options->not_cmp=1; - 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 (temp1_char != temp2_char) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char)); - } - nfound++; - } - - } /*H5T_NATIVE_SCHAR*/ - - /*------------------------------------------------------------------------- - * H5T_NATIVE_UCHAR - *------------------------------------------------------------------------- - */ - else if (H5Tequal(m_type, H5T_NATIVE_UCHAR)) - { - unsigned char temp1_uchar; - unsigned char temp2_uchar; - assert(type_size==sizeof(unsigned char)); - - memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - memcpy(&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); - parallel_print(SPACES); - 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); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar)); - } - options->not_cmp=1; - 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++; - } - } - /* -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); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar)); - } - options->not_cmp=1; - 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 (temp1_uchar != temp2_uchar) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar)); - } - nfound++; - } - - } /*H5T_NATIVE_UCHAR*/ - - - /*------------------------------------------------------------------------- - * H5T_NATIVE_SHORT - *------------------------------------------------------------------------- - */ - - else if (H5Tequal(m_type, H5T_NATIVE_SHORT)) - { - short temp1_short; - short temp2_short; - assert(type_size==sizeof(short)); - - memcpy(&temp1_short, mem1, sizeof(short)); - memcpy(&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); - parallel_print(SPACES); - 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); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,ABS(temp1_short-temp2_short)); - } - options->not_cmp=1; - 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++; - } - } - /* -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); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,ABS(temp1_short-temp2_short)); - } - options->not_cmp=1; - 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 (temp1_short != temp2_short) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short)); - } - nfound++; - } - - - } /*H5T_NATIVE_SHORT*/ - - /*------------------------------------------------------------------------- - * H5T_NATIVE_USHORT - *------------------------------------------------------------------------- - */ - - else if (H5Tequal(m_type, H5T_NATIVE_USHORT)) - { - unsigned short temp1_ushort; - unsigned short temp2_ushort; - assert(type_size==sizeof(short)); - - memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); - memcpy(&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); - parallel_print(SPACES); - 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); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort, - PDIFF(temp1_ushort,temp2_ushort)); - } - options->not_cmp=1; - 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++; - } - } - /* -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); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort)); - } - options->not_cmp=1; - 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 (temp1_ushort != temp2_ushort) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort)); - } - nfound++; - } - } /*H5T_NATIVE_USHORT*/ - - - /*------------------------------------------------------------------------- - * H5T_NATIVE_INT - *------------------------------------------------------------------------- - */ - - else if (H5Tequal(m_type, H5T_NATIVE_INT)) - { - int temp1_int; - int temp2_int; - assert(type_size==sizeof(int)); - - memcpy(&temp1_int, mem1, sizeof(int)); - memcpy(&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); - parallel_print(SPACES); - 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); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,ABS(temp1_int-temp2_int)); - } - options->not_cmp=1; - 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++; - } - } - /* -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); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,ABS(temp1_int-temp2_int)); - } - options->not_cmp=1; - 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 (temp1_int != temp2_int) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int)); - } - nfound++; - } - } /*H5T_NATIVE_INT*/ - - - /*------------------------------------------------------------------------- - * H5T_NATIVE_UINT - *------------------------------------------------------------------------- - */ - - else if (H5Tequal(m_type, H5T_NATIVE_UINT)) - { - unsigned int temp1_uint; - unsigned int temp2_uint; - assert(type_size==sizeof(int)); - - memcpy(&temp1_uint, mem1, sizeof(unsigned int)); - memcpy(&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); - parallel_print(SPACES); - 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); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint)); - } - options->not_cmp=1; - 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_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); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint)); - } - options->not_cmp=1; - 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(I_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); - parallel_print(SPACES); - parallel_print(UI_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint)); - } - nfound++; - } - } /*H5T_NATIVE_UINT*/ + */ + + { + char enum_name1[1024]; + char enum_name2[1024]; + + /* disable error reporting */ + H5E_BEGIN_TRY { + + if ((H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1) >= 0) && + (H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2) >= 0)) + { + if (HDstrcmp(enum_name1,enum_name2)!=0) + { + nfound=1; + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(S_FORMAT,enum_name1,enum_name2); + } + } + else + { + for (u=0; u<type_size; u++) + nfound+=character_compare_opt( + mem1 + u, + mem2 + u, /* offset */ + i, /* index position */ + rank, + dims, + acc, + pos, + options, + obj1, + obj2, + ph); + } + } + /* enable error reporting */ + } H5E_END_TRY; + } + + + break; + + /*------------------------------------------------------------------------- + * H5T_ARRAY + *------------------------------------------------------------------------- + */ + case H5T_ARRAY: + { + hsize_t adims[H5S_MAX_RANK]; + hsize_t 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); + assert(ndims >= 1 && ndims <= H5S_MAX_RANK); + + /* calculate the number of array elements */ + for (u = 0, nelmts = 1; u <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); + H5Tclose(memb_type); + } + 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; + } + else if (!iszero1 && !iszero2) + { + + /*------------------------------------------------------------------------- + * H5T_STD_REF_DSETREG + * Dataset region reference + *------------------------------------------------------------------------- + */ + + if (H5Tequal(m_type, H5T_STD_REF_DSETREG)) + { + hid_t region1_id; + hid_t region2_id; + + 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 (ret==-1) { + options->err_stat=1; + return 0; + } + + nfound = diff_region(obj1_id,obj2_id,region1_id,region2_id,options); + + 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 (H5Tequal(m_type, H5T_STD_REF_OBJ)) + { + 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 */ + + /* 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 */ + + /* compare */ + if(obj1_type == H5O_TYPE_DATASET) + nfound = diff_datasetid(obj1_id, + obj2_id, + NULL, + NULL, + options); + else { + parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>", + obj1, obj2); + options->not_cmp = 1; + } + + H5Oclose(obj1_id); + H5Oclose(obj2_id); + + }/*object reference*/ + + }/*is zero*/ + + + break; - /*------------------------------------------------------------------------- - * H5T_NATIVE_LONG - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5T_VLEN + *------------------------------------------------------------------------- + */ + + case H5T_VLEN: + + /* 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 < (int)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); + + H5Tclose(memb_type); + + break; + - else if (H5Tequal(m_type, H5T_NATIVE_LONG)) - { - long temp1_long; - long temp2_long; - assert(type_size==sizeof(long)); - - memcpy(&temp1_long, mem1, sizeof(long)); - memcpy(&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); - parallel_print(SPACES); - 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); - parallel_print(SPACES); - parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long, - ABS(temp1_long-temp2_long)); - } - options->not_cmp=1; - 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++; - } - } - /* -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); - parallel_print(SPACES); - parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,ABS(temp1_long-temp2_long)); - } - options->not_cmp=1; - 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 (temp1_long != temp2_long) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long)); - } - nfound++; - } - } /*H5T_NATIVE_LONG*/ + + /*------------------------------------------------------------------------- + * H5T_INTEGER + *------------------------------------------------------------------------- + */ + + case H5T_INTEGER: + + + /*------------------------------------------------------------------------- + * H5T_NATIVE_SCHAR + *------------------------------------------------------------------------- + */ + if (H5Tequal(m_type, H5T_NATIVE_SCHAR)) + { + char temp1_char; + char temp2_char; + assert(type_size==sizeof(char)); + memcpy(&temp1_char, mem1, sizeof(char)); + memcpy(&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); + parallel_print(SPACES); + 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); + parallel_print(SPACES); + parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,ABS(temp1_char-temp2_char)); + } + options->not_cmp=1; + 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++; + } + } + /* -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); + parallel_print(SPACES); + parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,ABS(temp1_char-temp2_char)); + } + options->not_cmp=1; + 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 (temp1_char != temp2_char) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char)); + } + nfound++; + } + + } /*H5T_NATIVE_SCHAR*/ + + /*------------------------------------------------------------------------- + * H5T_NATIVE_UCHAR + *------------------------------------------------------------------------- + */ + else if (H5Tequal(m_type, H5T_NATIVE_UCHAR)) + { + unsigned char temp1_uchar; + unsigned char temp2_uchar; + assert(type_size==sizeof(unsigned char)); + + memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); + memcpy(&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); + parallel_print(SPACES); + 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); + parallel_print(SPACES); + parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar)); + } + options->not_cmp=1; + 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++; + } + } + /* -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); + parallel_print(SPACES); + parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar)); + } + options->not_cmp=1; + 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 (temp1_uchar != temp2_uchar) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar)); + } + nfound++; + } + + } /*H5T_NATIVE_UCHAR*/ + + + /*------------------------------------------------------------------------- + * H5T_NATIVE_SHORT + *------------------------------------------------------------------------- + */ + + else if (H5Tequal(m_type, H5T_NATIVE_SHORT)) + { + short temp1_short; + short temp2_short; + assert(type_size==sizeof(short)); + + memcpy(&temp1_short, mem1, sizeof(short)); + memcpy(&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); + parallel_print(SPACES); + 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); + parallel_print(SPACES); + parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,ABS(temp1_short-temp2_short)); + } + options->not_cmp=1; + 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++; + } + } + /* -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); + parallel_print(SPACES); + parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,ABS(temp1_short-temp2_short)); + } + options->not_cmp=1; + 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 (temp1_short != temp2_short) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short)); + } + nfound++; + } + + + } /*H5T_NATIVE_SHORT*/ + + /*------------------------------------------------------------------------- + * H5T_NATIVE_USHORT + *------------------------------------------------------------------------- + */ + + else if (H5Tequal(m_type, H5T_NATIVE_USHORT)) + { + unsigned short temp1_ushort; + unsigned short temp2_ushort; + assert(type_size==sizeof(short)); + + memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); + memcpy(&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); + parallel_print(SPACES); + 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); + parallel_print(SPACES); + parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort, + PDIFF(temp1_ushort,temp2_ushort)); + } + options->not_cmp=1; + 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++; + } + } + /* -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); + parallel_print(SPACES); + parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort)); + } + options->not_cmp=1; + 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 (temp1_ushort != temp2_ushort) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort)); + } + nfound++; + } + } /*H5T_NATIVE_USHORT*/ + + + /*------------------------------------------------------------------------- + * H5T_NATIVE_INT + *------------------------------------------------------------------------- + */ + + else if (H5Tequal(m_type, H5T_NATIVE_INT)) + { + int temp1_int; + int temp2_int; + assert(type_size==sizeof(int)); + + memcpy(&temp1_int, mem1, sizeof(int)); + memcpy(&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); + parallel_print(SPACES); + 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); + parallel_print(SPACES); + parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,ABS(temp1_int-temp2_int)); + } + options->not_cmp=1; + 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++; + } + } + /* -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); + parallel_print(SPACES); + parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,ABS(temp1_int-temp2_int)); + } + options->not_cmp=1; + 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 (temp1_int != temp2_int) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int)); + } + nfound++; + } + } /*H5T_NATIVE_INT*/ + + + /*------------------------------------------------------------------------- + * H5T_NATIVE_UINT + *------------------------------------------------------------------------- + */ + + else if (H5Tequal(m_type, H5T_NATIVE_UINT)) + { + unsigned int temp1_uint; + unsigned int temp2_uint; + assert(type_size==sizeof(int)); + + memcpy(&temp1_uint, mem1, sizeof(unsigned int)); + memcpy(&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); + parallel_print(SPACES); + 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); + parallel_print(SPACES); + parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint)); + } + options->not_cmp=1; + 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_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); + parallel_print(SPACES); + parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint)); + } + options->not_cmp=1; + 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(I_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); + parallel_print(SPACES); + parallel_print(UI_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint)); + } + nfound++; + } + } /*H5T_NATIVE_UINT*/ + + + /*------------------------------------------------------------------------- + * H5T_NATIVE_LONG + *------------------------------------------------------------------------- + */ + + else if (H5Tequal(m_type, H5T_NATIVE_LONG)) + { + long temp1_long; + long temp2_long; + assert(type_size==sizeof(long)); + + memcpy(&temp1_long, mem1, sizeof(long)); + memcpy(&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); + parallel_print(SPACES); + 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); + parallel_print(SPACES); + parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long, + ABS(temp1_long-temp2_long)); + } + options->not_cmp=1; + 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++; + } + } + /* -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); + parallel_print(SPACES); + parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,ABS(temp1_long-temp2_long)); + } + options->not_cmp=1; + 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 (temp1_long != temp2_long) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long)); + } + nfound++; + } + } /*H5T_NATIVE_LONG*/ + + /*------------------------------------------------------------------------- + * H5T_NATIVE_ULONG + *------------------------------------------------------------------------- + */ + + else if (H5Tequal(m_type, H5T_NATIVE_ULONG)) + { + unsigned long temp1_ulong; + unsigned long temp2_ulong; + assert(type_size==sizeof(unsigned long)); + + memcpy(&temp1_ulong, mem1, sizeof(unsigned long)); + memcpy(&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); + parallel_print(SPACES); + 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); + parallel_print(SPACES); + parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong)); + } + options->not_cmp=1; + 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++; + } + } + /* -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); + parallel_print(SPACES); + parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong)); + } + options->not_cmp=1; + 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 (temp1_ulong != temp2_ulong) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(ULI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong)); + } + nfound++; + } + + + } /*H5T_NATIVE_ULONG*/ + + /*------------------------------------------------------------------------- + * H5T_NATIVE_LLONG + *------------------------------------------------------------------------- + */ + + else if (H5Tequal(m_type, H5T_NATIVE_LLONG)) + { + long_long temp1_llong; + long_long temp2_llong; + assert(type_size==sizeof(long_long)); + + memcpy(&temp1_llong, mem1, sizeof(long_long)); + memcpy(&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); + parallel_print(SPACES); + 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); + parallel_print(SPACES); + parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong)); + } + options->not_cmp=1; + 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++; + } + } + /* -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); + parallel_print(SPACES); + parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong)); + } + options->not_cmp=1; + 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 (temp1_llong != temp2_llong) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong)); + } + nfound++; + } + + } /*H5T_NATIVE_LLONG*/ + + /*------------------------------------------------------------------------- + * H5T_NATIVE_ULLONG + *------------------------------------------------------------------------- + */ + + else if (H5Tequal(m_type, H5T_NATIVE_ULLONG)) + { + unsigned long_long temp1_ullong; + unsigned long_long temp2_ullong; + assert(type_size==sizeof(unsigned long_long)); + + memcpy(&temp1_ullong, mem1, sizeof(unsigned long_long)); + memcpy(&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); + parallel_print(SPACES); + 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); + parallel_print(SPACES); + parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); + } + options->not_cmp=1; + 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(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); + parallel_print(SPACES); + parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); + } + options->not_cmp=1; + 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 (temp1_ullong != temp2_ullong) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); + } + nfound++; + } + + } /*H5T_NATIVE_ULLONG*/ + + + break; /* H5T_INTEGER class */ - /*------------------------------------------------------------------------- - * H5T_NATIVE_ULONG - *------------------------------------------------------------------------- - */ + + /*------------------------------------------------------------------------- + * H5T_FLOAT + *------------------------------------------------------------------------- + */ + + case H5T_FLOAT: + + + + /*------------------------------------------------------------------------- + * H5T_NATIVE_FLOAT + *------------------------------------------------------------------------- + */ + if (H5Tequal(m_type, H5T_NATIVE_FLOAT)) + { + float temp1_float; + float temp2_float; + int isnan1; + int isnan2; - else if (H5Tequal(m_type, H5T_NATIVE_ULONG)) - { - unsigned long temp1_ulong; - unsigned long temp2_ulong; - assert(type_size==sizeof(unsigned long)); - - memcpy(&temp1_ulong, mem1, sizeof(unsigned long)); - memcpy(&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); - parallel_print(SPACES); - 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); - parallel_print(SPACES); - parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong)); - } - options->not_cmp=1; - 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++; - } - } - /* -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); - parallel_print(SPACES); - parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong)); - } - options->not_cmp=1; - 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 (temp1_ulong != temp2_ulong) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(ULI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong)); - } - nfound++; - } - - - } /*H5T_NATIVE_ULONG*/ + assert(type_size==sizeof(float)); - /*------------------------------------------------------------------------- - * H5T_NATIVE_LLONG - *------------------------------------------------------------------------- - */ + memcpy(&temp1_float, mem1, sizeof(float)); + memcpy(&temp2_float, mem2, sizeof(float)); - else if (H5Tequal(m_type, H5T_NATIVE_LLONG)) - { - long_long temp1_llong; - long_long temp2_llong; - assert(type_size==sizeof(long_long)); - - memcpy(&temp1_llong, mem1, sizeof(long_long)); - memcpy(&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); - parallel_print(SPACES); - 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); - parallel_print(SPACES); - parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong)); - } - options->not_cmp=1; - 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++; - } - } - /* -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); - parallel_print(SPACES); - parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong)); - } - options->not_cmp=1; - 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 (temp1_llong != temp2_llong) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong)); - } - nfound++; - } - - } /*H5T_NATIVE_LLONG*/ + /* logic for detecting NaNs is different with options -d, -p and no options */ - /*------------------------------------------------------------------------- - * H5T_NATIVE_ULLONG - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * -d and !-p + *------------------------------------------------------------------------- + */ + if (options->d && !options->p) + { + + + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + isnan1 = my_isnan(FLT_FLOAT,&temp1_float); + isnan2 = my_isnan(FLT_FLOAT,&temp2_float); + + if ( !isnan1 && !isnan2) + { + + if (ABS(temp1_float-temp2_float) > options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + } + + } /* NaN */ + } + /*------------------------------------------------------------------------- + * !-d and -p + *------------------------------------------------------------------------- + */ + else if (!options->d && options->p) + { + + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + isnan1 = my_isnan(FLT_FLOAT,&temp1_float); + isnan2 = my_isnan(FLT_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,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + } + options->not_cmp=1; + nfound++; + } + + else + + if ( per > options->percent && 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,temp1_float,temp2_float, + ABS(temp1_float-temp2_float), + ABS(1-temp2_float/temp1_float)); + } + nfound++; + } + + } /* NaN */ + } - else if (H5Tequal(m_type, H5T_NATIVE_ULLONG)) - { - unsigned long_long temp1_ullong; - unsigned long_long temp2_ullong; - assert(type_size==sizeof(unsigned long_long)); - - memcpy(&temp1_ullong, mem1, sizeof(unsigned long_long)); - memcpy(&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); - parallel_print(SPACES); - 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); - parallel_print(SPACES); - parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); - } - options->not_cmp=1; - 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(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); - parallel_print(SPACES); - parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); - } - options->not_cmp=1; - 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 (temp1_ullong != temp2_ullong) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); - } - nfound++; - } + /*------------------------------------------------------------------------- + * -d and -p + *------------------------------------------------------------------------- + */ + + else if ( options->d && options->p) + { + + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + isnan1 = my_isnan(FLT_FLOAT,&temp1_float); + isnan2 = my_isnan(FLT_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,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float, + ABS(temp1_float-temp2_float)); + } + options->not_cmp=1; + 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_float,temp2_float, + ABS(temp1_float-temp2_float), + ABS(1-temp2_float/temp1_float)); + } + nfound++; + } + + } /* NaN */ + } + + /*------------------------------------------------------------------------- + * no -d and -p + *------------------------------------------------------------------------- + */ + else if (equal_float(temp1_float,temp2_float)==FALSE) + { + + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + } + } /*H5T_NATIVE_FLOAT*/ - } /*H5T_NATIVE_ULLONG*/ + /*------------------------------------------------------------------------- + * H5T_NATIVE_DOUBLE + *------------------------------------------------------------------------- + */ + + else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE)) + { + double temp1_double; + double temp2_double; + int isnan1; + int isnan2; - break; /* H5T_INTEGER class */ + assert(type_size==sizeof(double)); + + memcpy(&temp1_double, mem1, sizeof(double)); + memcpy(&temp2_double, mem2, sizeof(double)); - case H5T_FLOAT: + /* logic for detecting NaNs is different with options -d, -p and no options */ - /*------------------------------------------------------------------------- - * H5T_NATIVE_FLOAT - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * -d and !-p + *------------------------------------------------------------------------- + */ + if (options->d && !options->p) + { - if (H5Tequal(m_type, H5T_NATIVE_FLOAT)) - { - float temp1_float; - float temp2_float; - assert(type_size==sizeof(float)); - memcpy(&temp1_float, mem1, sizeof(float)); - memcpy(&temp2_float, mem2, sizeof(float)); - - /* -d and !-p */ - if (options->d && !options->p) - { - if (ABS(temp1_float-temp2_float) > options->delta) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!options->d && options->p) - { - - 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); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); - } - options->not_cmp=1; - nfound++; - } - - else - - if ( per > options->percent && 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,temp1_float,temp2_float, - ABS(temp1_float-temp2_float), - ABS(1-temp2_float/temp1_float)); - } - nfound++; - } - } - - /* -d and -p */ - else if ( options->d && options->p) - { - - 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); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float, - ABS(temp1_float-temp2_float)); - } - options->not_cmp=1; - 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_float,temp2_float, - ABS(temp1_float-temp2_float), - ABS(1-temp2_float/temp1_float)); - } - nfound++; - } - } - - else if (equal_float(temp1_float,temp2_float)==FALSE) - { - - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); - } - nfound++; - } - - } /*H5T_NATIVE_FLOAT*/ - - /*------------------------------------------------------------------------- - * H5T_NATIVE_DOUBLE - *------------------------------------------------------------------------- - */ - - else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE)) - { - double temp1_double; - double temp2_double; - assert(type_size==sizeof(double)); - - memcpy(&temp1_double, mem1, sizeof(double)); - memcpy(&temp2_double, mem2, sizeof(double)); - /* -d and !-p */ - if (options->d && !options->p) - { - if (ABS(temp1_double-temp2_double) > options->delta) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!options->d && options->p) - { - - 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); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double, - ABS(temp1_double-temp2_double)); - } - options->not_cmp=1; - 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++; - } - } - - - /* -d and -p */ - else if ( options->d && options->p) - { - - 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); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double, - ABS(temp1_double-temp2_double)); - } - options->not_cmp=1; - 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 (equal_double(temp1_double,temp2_double)==FALSE) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); - } - nfound++; - } - } /*H5T_NATIVE_DOUBLE*/ + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + isnan1 = my_isnan(FLT_DOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_DOUBLE,&temp2_double); + + 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); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + } + + } /* NaN */ + } + /*------------------------------------------------------------------------- + * !-d and -p + *------------------------------------------------------------------------- + */ + else if (!options->d && options->p) + { - break; /* H5T_FLOAT class */ + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + isnan1 = my_isnan(FLT_DOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_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); + parallel_print(SPACES); + parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double, + ABS(temp1_double-temp2_double)); + } + options->not_cmp=1; + 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++; + } + + } /* NaN */ + } + + /*------------------------------------------------------------------------- + * -d and -p + *------------------------------------------------------------------------- + */ + else if ( options->d && options->p) + { + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + isnan1 = my_isnan(FLT_DOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_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); + parallel_print(SPACES); + parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double, + ABS(temp1_double-temp2_double)); + } + options->not_cmp=1; + 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++; + } + + } /* NaN */ + } + + /*------------------------------------------------------------------------- + * no -d and -p + *------------------------------------------------------------------------- + */ + else if (equal_double(temp1_double,temp2_double)==FALSE) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + } + } /*H5T_NATIVE_DOUBLE*/ + + + break; /* H5T_FLOAT class */ + } /* switch */ - + return nfound; } @@ -2143,17 +2255,17 @@ static hbool_t all_zero(const void *_mem, size_t size) static 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]); - for (j = 0; j < ndims; j++) - parallel_print("%s%lu", j ? "," : ")-(", - (unsigned long)ptdata[i * 2 * ndims + j + ndims]); - parallel_print(")"); - + int j; + + parallel_print(" "); + for (j = 0; j < 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(")"); + } @@ -2170,14 +2282,14 @@ void print_region_block(int i, hsize_t *ptdata, int ndims) static 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(")"); - + int j; + + parallel_print(" "); + for (j = 0; j < ndims; j++) + parallel_print("%s%lu", j ? "," : "(", + (unsigned long)(ptdata[i * ndims + j])); + parallel_print(")"); + } /*------------------------------------------------------------------------- @@ -2383,25 +2495,25 @@ hsize_t character_compare(unsigned char *mem1, const char *obj2, int *ph) { - hsize_t nfound=0; /* differences found */ - unsigned char temp1_uchar; - unsigned char temp2_uchar; - - memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); - - if (temp1_uchar != temp2_uchar) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(C_FORMAT,temp1_uchar,temp2_uchar); - } - nfound++; - } - - return nfound; + hsize_t nfound=0; /* differences found */ + unsigned char temp1_uchar; + unsigned char temp2_uchar; + + memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); + memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); + + if (temp1_uchar != temp2_uchar) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(C_FORMAT,temp1_uchar,temp2_uchar); + } + nfound++; + } + + return nfound; } @@ -2427,73 +2539,73 @@ hsize_t character_compare_opt(unsigned char *mem1, const char *obj2, int *ph) { - hsize_t nfound=0; /* differences found */ - unsigned char temp1_uchar; - unsigned char temp2_uchar; - double per; - int both_zero; + hsize_t nfound=0; /* differences found */ + unsigned char temp1_uchar; + unsigned char temp2_uchar; + double per; + int both_zero; + + memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); + memcpy(&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); + parallel_print(SPACES); + 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); + 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 ( 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 (temp1_uchar != temp2_uchar) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar)); + } + nfound++; + } + + return nfound; - memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - memcpy(&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); - parallel_print(SPACES); - 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); - 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 ( 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 (temp1_uchar != temp2_uchar) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar)); - } - nfound++; - } - - return nfound; - } @@ -2526,34 +2638,53 @@ hsize_t diff_float(unsigned char *mem1, hsize_t i; double per; int both_zero; + int isnan1; + int isnan2; - - /* -d and !-p */ + + /*------------------------------------------------------------------------- + * -d and !-p + *------------------------------------------------------------------------- + */ + if (options->d && !options->p) { for ( i = 0; i < nelmts; i++) { memcpy(&temp1_float, mem1, sizeof(float)); memcpy(&temp2_float, mem2, sizeof(float)); - - if (ABS(temp1_float-temp2_float) > options->delta) - { - if ( print_data(options) ) + + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + isnan1 = my_isnan(FLT_FLOAT,&temp1_float); + isnan2 = my_isnan(FLT_FLOAT,&temp2_float); + + if ( !isnan1 && !isnan2) + { + if (ABS(temp1_float-temp2_float) > options->delta) { - print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + if ( print_data(options) ) + { + print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; } - nfound++; - } + } /* NaN */ mem1+=sizeof(float); mem2+=sizeof(float); if (options->n && nfound>=options->count) return nfound; - } + } /* i */ } - - /* !-d and -p */ + + /*------------------------------------------------------------------------- + * !-d and -p + *------------------------------------------------------------------------- + */ else if (!options->d && options->p) { for ( i = 0; i < nelmts; i++) @@ -2561,43 +2692,57 @@ hsize_t diff_float(unsigned char *mem1, memcpy(&temp1_float, mem1, sizeof(float)); memcpy(&temp2_float, mem2, sizeof(float)); - 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); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float, - ABS(temp1_float-temp2_float)); - } - options->not_cmp=1; - nfound++; - } + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + isnan1 = my_isnan(FLT_FLOAT,&temp1_float); + isnan2 = my_isnan(FLT_FLOAT,&temp2_float); - else + if ( !isnan1 && !isnan2) + { - if ( per > options->percent ) + 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); parallel_print(SPACES); - parallel_print(F_FORMAT_P,temp1_float,temp2_float, - ABS(temp1_float-temp2_float), - ABS(1-temp2_float/temp1_float)); + parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float, + ABS(temp1_float-temp2_float)); } + options->not_cmp=1; nfound++; } - mem1+=sizeof(float); - mem2+=sizeof(float); - if (options->n && nfound>=options->count) - return 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_float,temp2_float, + ABS(temp1_float-temp2_float), + ABS(1-temp2_float/temp1_float)); + } + nfound++; + } + } /* NaN */ + mem1+=sizeof(float); + mem2+=sizeof(float); + if (options->n && nfound>=options->count) + return nfound; + } /* i */ } - /* -d and -p */ + /*------------------------------------------------------------------------- + * -d and -p + *------------------------------------------------------------------------- + */ else if ( options->d && options->p) { @@ -2606,43 +2751,75 @@ hsize_t diff_float(unsigned char *mem1, memcpy(&temp1_float, mem1, sizeof(float)); memcpy(&temp2_float, mem2, sizeof(float)); - 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); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float, - ABS(temp1_float-temp2_float)); - } - options->not_cmp=1; - nfound++; - } + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + isnan1 = my_isnan(FLT_FLOAT,&temp1_float); + isnan2 = my_isnan(FLT_FLOAT,&temp2_float); - else + if ( !isnan1 && !isnan2) + { - if ( per > options->percent && ABS(temp1_float-temp2_float) > options->delta ) + 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); parallel_print(SPACES); - parallel_print(F_FORMAT_P,temp1_float,temp2_float, - ABS(temp1_float-temp2_float), - ABS(1-temp2_float/temp1_float)); + parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float, + ABS(temp1_float-temp2_float)); } + options->not_cmp=1; nfound++; } - mem1+=sizeof(float); - mem2+=sizeof(float); - if (options->n && nfound>=options->count) - return nfound; - } + + else + + if ( per > options->percent && 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,temp1_float,temp2_float, + ABS(temp1_float-temp2_float), + ABS(1-temp2_float/temp1_float)); + } + nfound++; + } + + } /* NaN */ + mem1+=sizeof(float); + mem2+=sizeof(float); + if (options->n && nfound>=options->count) + return nfound; + } /* i */ } + + /*------------------------------------------------------------------------- + * no -d and -p + *------------------------------------------------------------------------- + */ else { + +#if defined (H5DIFF_DO_TIME) + int time; + + #if defined (WIN32) + struct _timeb *tbstart = malloc(sizeof(struct _timeb)); + struct _timeb *tbstop = malloc(sizeof(struct _timeb)); + _ftime( tbstart); + #else + struct timeb *tbstart = malloc(sizeof(struct timeb)); + struct timeb *tbstop = malloc(sizeof(struct timeb)); + ftime( tbstart); + #endif + +#endif for ( i = 0; i < nelmts; i++) { @@ -2665,7 +2842,24 @@ hsize_t diff_float(unsigned char *mem1, mem2+=sizeof(float); if (options->n && nfound>=options->count) return nfound; + } /* nelmts */ + + + +#if defined (H5DIFF_DO_TIME) + + #if defined (WIN32) + _ftime( tbstop ); + #else + ftime( tbstop ); + #endif + + time = tbstop->time - tbstart->time; + printf(" TIME = %d sec\n", time ); + +#endif + } @@ -4705,7 +4899,7 @@ error: /*------------------------------------------------------------------------- - * Function: equal_float, equal_double + * Function: equal_double * * Purpose: use a relative error formula to deal with floating point * uncertainty @@ -4714,18 +4908,50 @@ error: * October 24, 2006 * * Modifications: + * 8/1/2007. handle NaNs * *------------------------------------------------------------------------- */ - - - static hbool_t equal_double(double value, double expected) { int both_zero; int is_zero; +#if defined (H5DIFF_DO_NAN) + +/*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + int isnan1 = my_isnan(FLT_DOUBLE,&value); + int isnan2 = my_isnan(FLT_DOUBLE,&expected); + + /*------------------------------------------------------------------------- + * 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 ) ) + { + return FALSE; + } + + /*------------------------------------------------------------------------- + * both are not NaNs, compare + *------------------------------------------------------------------------- + */ + +#endif + BOTH_ZERO(value,expected) if (both_zero) return TRUE; @@ -4741,8 +4967,6 @@ hbool_t equal_double(double value, double expected) } - - /*------------------------------------------------------------------------- * Function: equal_float * @@ -4763,6 +4987,8 @@ hbool_t equal_float(float value, float expected) int both_zero; int is_zero; +#if defined (H5DIFF_DO_NAN) + /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- @@ -4770,8 +4996,6 @@ hbool_t equal_float(float value, float expected) int isnan1 = my_isnan(FLT_FLOAT,&value); int isnan2 = my_isnan(FLT_FLOAT,&expected); - - /*------------------------------------------------------------------------- * we consider NaN == NaN to be true *------------------------------------------------------------------------- @@ -4794,6 +5018,8 @@ hbool_t equal_float(float value, float expected) * both are not NaNs, compare *------------------------------------------------------------------------- */ + +#endif BOTH_ZERO(value,expected) if (both_zero) diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 3d8c871..6fc09d7 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -30,6 +30,7 @@ #include "h5tools_utils.h" #include "H5private.h" +#define SANITY_CHECK #define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z)) @@ -612,7 +613,7 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai } /* - * We need to break after each row of a dimension---> we should + * We need to break after each row_counter of a dimension---> we should * break at the end of the each last dimension well that is the * way the dumper did it before */ @@ -706,28 +707,40 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai * Chapter: H5Tools Library * Purpose: Dump out a subset of a dataset. * Description: - * Select a hyperslab from the dataset DSET using the parameters - * specified in SSET. Dump this out to STREAM. + * + * Select a hyperslab from the dataset DSET using the parameters + * specified in SSET. Dump this out to STREAM. + * + * Hyperslabs select "count" blocks of size "block", spaced "stride" elements + * from each other, starting at coordinate "start". + * * Return: * On success, return SUCCEED. Otherwise, the function returns FAIL. - * Programmer: - * Bill Wendling, Wednesday, 07. March 2001 - * Modifications: - * Pedro Vicente, 12 December 2006 - * Add information to print array indices from the element position - * The algorythm used is + * + * Original programmer: + * Bill Wendling, Wednesday, March 07, 2001 + * + * Rewritten with modified algorithm by: + * Pedro Vicente, Wednesday, January 16, 2008, contributions from Quincey Koziol + * + * Algorithm + * + * In a inner loop, the parameters from SSET are translated into temporary + * variables so that 1 row is printed at a time (getting the coordinate indices + * at each row). + * We define the stride, count and block to be 1 in the row dimension to achieve + * this and advance until all points are printed. + * An outer loop for cases where dimensionality is greater than 2D is made. + * In each iteration, the 2D block is displayed in the inner loop. The remaining + * slower dimensions above the first 2 are incremented one at a time in the outer loop + * + * The element position is obtained from the matrix according to: * Given an index I(z,y,x) its position from the beginning of an array * of sizes A(size_z, size_y,size_x) is given by * Position of I(z,y,x) = index_z * size_y * size_x * + index_y * size_x * + index_x - * - * Pedro Vicente, Quincey Koziol, 4 January 2007 - * Introduced an outer loop for cases where dimensionality is greater - * than 2D. In each iteration a 2D block is displayed by rows in a inner - * loop. The remainning slower dimensions above the first 2 are incremented - * one at a time in the outer loop - * + * *------------------------------------------------------------------------- */ static herr_t @@ -755,13 +768,21 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset hid_t sm_space; /* stripmine data space */ hsize_t count; /* hyperslab count */ hsize_t outer_count; /* offset count */ - unsigned int row_dim; /* index of row dimension */ + unsigned int row_dim; /* index of row_counter dimension */ int current_outer_dim; /* dimension for start */ hsize_t temp_start[H5S_MAX_RANK];/* temporary start inside offset count loop */ hsize_t max_start[H5S_MAX_RANK]; /* maximum start inside offset count loop */ hsize_t temp_count[H5S_MAX_RANK];/* temporary count inside offset count loop */ - - int reset_dim; + hsize_t temp_block[H5S_MAX_RANK];/* temporary block size used in loop */ + hsize_t temp_stride[H5S_MAX_RANK];/* temporary stride size used in loop */ + int reset_dim; + hsize_t size_row_block; /* size for blocks along rows */ + +#if defined (SANITY_CHECK) + hsize_t total_points = 1; /* to print */ + hsize_t printed_points = 0; /* printed */ +#endif + ret = FAIL; /* be pessimistic */ f_space = H5Dget_space(dset); @@ -799,17 +820,32 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset outer_count = 1; if (ctx.ndims > 2) for (i = 0; i < (size_t)ctx.ndims - 2; i++) - outer_count *= sset->count[ i ]; + { + /* consider block size */ + outer_count = outer_count * sset->count[ i ] * sset->block[ i ]; + + } if(ctx.ndims>0) init_acc_pos(&ctx,total_size); + /* calculate total number of points to print */ +#if defined (SANITY_CHECK) + for (i = 0; i < (size_t)ctx.ndims; i++) + { + total_points *= sset->count[ i ] * sset->block[ i ];; + } +#endif + + /* initialize temporary start, count and maximum start */ for (i = 0; i < (size_t)ctx.ndims; i++) { temp_start[ i ] = sset->start[ i ]; temp_count[ i ] = sset->count[ i ]; + temp_block[ i ] = sset->block[ i ]; + temp_stride[ i ] = sset->stride[ i ]; max_start[ i ] = 0; } @@ -828,29 +864,69 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset for (n = 0; n < outer_count; n++) { + hsize_t row_counter = 0; + /* number of read iterations in inner loop, read by rows, to match 2D display */ if (ctx.ndims > 1) { - count = sset->count[ row_dim ]; - temp_count[ row_dim ] = 1; + + /* count is the number of iterations to display all the rows, + the block size count times */ + count = sset->count[ row_dim ] * sset->block[ row_dim ]; + + /* always 1 row_counter at a time, that is a block of size 1, 1 time */ + temp_count[ row_dim ] = 1; + temp_block[ row_dim ] = 1; + + /* advance 1 row_counter at a time */ + if (sset->block[ row_dim ] > 1 ) + temp_stride[ row_dim ] = 1; + + } /* for the 1D case */ else { count = 1; } - + + size_row_block = sset->block[ row_dim ]; + + /* display loop */ - for (; count > 0; temp_start[ row_dim ] += sset->stride[ row_dim ], - count--) - { + for (; count > 0; + temp_start[ row_dim ] += temp_stride[ row_dim ], + count--) + { + + + /* jump rows if size of block exceeded + cases where block > 1 only and stride > block */ + if ( size_row_block > 1 && + row_counter == size_row_block && + sset->stride[ row_dim ] > sset->block[ row_dim ] + ) + { + + hsize_t increase_rows = sset->stride[ row_dim ] - + sset->block[ row_dim ]; + + temp_start[ row_dim ] += increase_rows; + + row_counter = 0; + + } + + row_counter++; + + /* calculate the potential number of elements we're going to print */ H5Sselect_hyperslab(f_space, H5S_SELECT_SET, temp_start, - sset->stride, + temp_stride, temp_count, - sset->block); + temp_block); sm_nelmts = H5Sget_select_npoints(f_space); if (sm_nelmts == 0) { @@ -920,6 +996,13 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset ctx.need_prefix = 1; ctx.continuation++; + + +#if defined (SANITY_CHECK) + printed_points += sm_nelmts; +#endif + + } /* count */ if (ctx.ndims > 2) @@ -930,8 +1013,9 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset /* set start to original from current_outer_dim up */ for (i = current_outer_dim + 1; i < ctx.ndims; i++) { - temp_start[ i ] = sset->start[ i ]; + temp_start[ i ] = sset->start[ i ]; } + /* increment start dimension */ do @@ -941,6 +1025,11 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset if (temp_start[ current_outer_dim ] >= max_start[ current_outer_dim ]) { temp_start[ current_outer_dim ] = sset->start[ current_outer_dim ]; + + /* consider block */ + if ( sset->block[ current_outer_dim ] > 1 ) + temp_start[ current_outer_dim ]++; + current_outer_dim--; reset_dim = 1; } @@ -951,6 +1040,11 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset } /* outer_count */ +#if defined (SANITY_CHECK) + assert( printed_points == total_points ); +#endif + + /* Terminate the output */ if (ctx.cur_column) { fputs(OPT(info->line_suf, ""), stream); @@ -1459,9 +1553,6 @@ int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem) static int render_bin_output(FILE *stream, hid_t tid, void *_mem) { -#if 0 - #define DEBUG_H5DUMP_BIN 1 -#endif unsigned char *mem = (unsigned char*)_mem; size_t size; /* datum size */ float tempfloat; diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c index 123065b..de1e2c3 100644 --- a/tools/lib/h5tools_ref.c +++ b/tools/lib/h5tools_ref.c @@ -20,6 +20,7 @@ #include "H5SLprivate.h" #include "h5tools.h" #include "h5tools_utils.h" +#include "h5trav.h" /* @@ -42,15 +43,12 @@ typedef struct { } ref_path_node_t; static H5SL_t *ref_path_table = NULL; /* the "table" (implemented with a skip list) */ -static hid_t thefile; +static hid_t thefile = (-1); extern char *progname; extern int d_status; static int ref_path_table_put(const char *, haddr_t objno); -static hbool_t ref_path_table_find(haddr_t objno); -static herr_t fill_ref_path_table_cb(hid_t group, const char *obj_name, - const H5L_info_t *linfo, void *op_data); /*------------------------------------------------------------------------- * Function: free_ref_path_info @@ -77,6 +75,61 @@ free_ref_path_info(void *item, void UNUSED *key, void UNUSED *operator_data/*in, } /*------------------------------------------------------------------------- + * Function: init_ref_path_cb + * + * Purpose: Called by interator to create references for + * all objects and enter them in the table. + * + * Return: Error status. + * + * Programmer: REMcG + * + *------------------------------------------------------------------------- + */ +static herr_t +init_ref_path_cb(const char *obj_name, const H5O_info_t *oinfo, + const char *already_seen, void UNUSED *_udata) +{ + /* Check if the object is already in the path table */ + if(NULL == already_seen) { + /* Insert the object into the path table */ + ref_path_table_put(obj_name, oinfo->addr); + } /* end if */ + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: init_ref_path_table + * + * Purpose: Initalize the reference path table + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Quincey Koziol + * + *------------------------------------------------------------------------- + */ +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, 0.5, (size_t)16))==NULL) + return (-1); + + /* Iterate over objects in this file */ + if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL) < 0) { + error_msg(progname, "unable to construct reference path table\n"); + d_status = EXIT_FAILURE; + } /* end if */ + + return(0); +} + +/*------------------------------------------------------------------------- * Function: term_ref_path_table * * Purpose: Terminate the reference path table @@ -137,39 +190,11 @@ ref_path_table_lookup(const char *thepath) if(H5Oget_info_by_name(thefile, thepath, &oi, H5P_DEFAULT) < 0) return HADDR_UNDEF; - /* All existing objects in the file had better be in the table */ - HDassert(ref_path_table_find(oi.addr)); - /* Return OID */ return(oi.addr); } /*------------------------------------------------------------------------- - * Function: ref_path_table_find - * - * Purpose: Looks up a table entry given a object number. - * Used during construction of the table. - * - * Return: TRUE/FALSE on success, can't fail - * - * Programmer: Quincey Koziol - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static hbool_t -ref_path_table_find(haddr_t objno) -{ - HDassert(ref_path_table); - - if(H5SL_search(ref_path_table, &objno) == NULL) - return FALSE; - else - return TRUE; -} - -/*------------------------------------------------------------------------- * Function: ref_path_table_put * * Purpose: Enter the 'obj' with 'path' in the table (assumes its not @@ -200,7 +225,7 @@ ref_path_table_put(const char *path, haddr_t objno) return(-1); new_node->objno = objno; - new_node->path = path; + new_node->path = HDstrdup(path); return(H5SL_insert(ref_path_table, new_node, &(new_node->objno))); } @@ -237,17 +262,17 @@ get_fake_xid (void) { haddr_t ref_path_table_gen_fake(const char *path) { - const char *dup_path; haddr_t fake_objno; - if((dup_path = HDstrdup(path)) == NULL) - return HADDR_UNDEF; - /* Generate fake ID for string */ fake_objno = get_fake_xid(); - /* Insert "fake" object into table (takes ownership of path) */ - ref_path_table_put(dup_path, fake_objno); + /* Create ref path table, if it hasn't already been created */ + if(ref_path_table == NULL) + init_ref_path_table(); + + /* Insert "fake" object into table */ + ref_path_table_put(path, fake_objno); return(fake_objno); } @@ -271,74 +296,19 @@ lookup_ref_path(haddr_t ref) ref_path_node_t *node; /* Be safer for h5ls */ - if(!ref_path_table) + if(thefile < 0) return(NULL); + /* Create ref path table, if it hasn't already been created */ + if(ref_path_table == NULL) + init_ref_path_table(); + node = H5SL_search(ref_path_table, &ref); return(node ? node->path : NULL); } /*------------------------------------------------------------------------- - * Function: fill_ref_path_table_cb - * - * Purpose: Called by interator to create references for - * all objects and enter them in the table. - * - * Return: Error status. - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -fill_ref_path_table_cb(hid_t group, const char *obj_name, const H5L_info_t *linfo, - void *op_data) -{ - if(linfo->type == H5L_TYPE_HARD) { - H5O_info_t oinfo; - - H5Oget_info_by_name(group, obj_name, &oinfo, H5P_DEFAULT); - - /* Check if the object is already in the path table */ - if(!ref_path_table_find(oinfo.addr)) { - const char *obj_prefix = (const char *)op_data; - size_t tmp_len; - char *thepath; - - /* Compute length for this object's path */ - tmp_len = HDstrlen(obj_prefix) + HDstrlen(obj_name) + 2; - - /* Allocate room for the path for this object */ - if((thepath = (char *)HDmalloc(tmp_len)) == NULL) - return FAIL; - - /* Build the name for this object */ - HDstrcpy(thepath, obj_prefix); - HDstrcat(thepath, "/"); - HDstrcat(thepath, obj_name); - - /* Insert the object into the path table (takes ownership of the path) */ - ref_path_table_put(thepath, oinfo.addr); - - if(oinfo.type == H5O_TYPE_GROUP) { - /* Iterate over objects in this group, using this group's - * name as their prefix - */ - if(H5Literate_by_name(group, obj_name, H5_INDEX_NAME, H5_ITER_INC, NULL, fill_ref_path_table_cb, thepath, H5P_DEFAULT) < 0) { - error_msg(progname, "unable to dump group \"%s\"\n", thepath); - d_status = EXIT_FAILURE; - } /* end if */ - } /* end if */ - } /* end if */ - } /* end if */ - - return 0; -} - -/*------------------------------------------------------------------------- * Function: fill_ref_path_table * * Purpose: Called by interator to create references for @@ -348,37 +318,15 @@ fill_ref_path_table_cb(hid_t group, const char *obj_name, const H5L_info_t *linf * * Programmer: REMcG * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t fill_ref_path_table(hid_t fid) { - H5O_info_t oinfo; - char *root_path; - /* Set file ID for later queries (XXX: this should be fixed) */ thefile = fid; - /* Create skip list to store reference path information */ - if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16))==NULL) - return (-1); - - /* Build the name for root group */ - root_path = HDstrdup("/"); - - /* Get info for root group */ - H5Oget_info_by_name(fid, root_path, &oinfo, H5P_DEFAULT); - - /* Insert the root group into the path table (takes ownership of path) */ - ref_path_table_put(root_path, oinfo.addr); - - /* Iterate over objects in this file */ - if(H5Literate(fid, H5_INDEX_NAME, H5_ITER_INC, NULL, fill_ref_path_table_cb, (void *)"") < 0) { - error_msg(progname, "unable to dump root group\n"); - d_status = EXIT_FAILURE; - } /* end if */ + /* Defer creating the ref path table until it's needed */ return 0; } diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index cb38e7a..512a3fb 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -30,6 +30,7 @@ #include "h5tools_utils.h" #include "H5private.h" +#include "h5trav.h" /* global variables */ int nCols = 80; @@ -44,10 +45,7 @@ static void init_table(table_t **tbl); #ifdef H5DUMP_DEBUG static void dump_table(char* tablename, table_t *table); #endif /* H5DUMP_DEBUG */ -static void add_obj(table_t *table, haddr_t objno, char *objname, hbool_t recorded); -static char * build_obj_path_name(const char *prefix, const char *name); -static herr_t find_objs_cb(hid_t group, const char *name, const H5L_info_t *info, - void *op_data); +static void add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t recorded); /*------------------------------------------------------------------------- @@ -428,44 +426,15 @@ search_obj(table_t *table, haddr_t objno) { unsigned u; - for (u = 0; u < table->nobjs; u++) - if (table->objs[u].objno == objno) - return &(table->objs[u]); + for(u = 0; u < table->nobjs; u++) + if(table->objs[u].objno == objno) + return &(table->objs[u]); return NULL; } /*------------------------------------------------------------------------- - * Function: build_obj_path_name - * - * Purpose: Allocate space & build path name from prefix & name - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Quincey Koziol - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static char * -build_obj_path_name(const char *prefix, const char *name) -{ - char *path; - - path = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); - HDstrcpy(path, prefix); - HDstrcat(path,"/"); - HDstrcat(path,name); /* absolute name of the data set */ - - return(path); -} /* end build_obj_path_name() */ - - -/*------------------------------------------------------------------------- * Function: find_objs_cb * * Purpose: Callback to find objects, committed types and store them in tables @@ -481,90 +450,65 @@ build_obj_path_name(const char *prefix, const char *name) *------------------------------------------------------------------------- */ static herr_t -find_objs_cb(hid_t group, const char *name, const H5L_info_t UNUSED *linfo, void *op_data) +find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen, + void *op_data) { - H5O_info_t oinfo; find_objs_t *info = (find_objs_t*)op_data; herr_t ret_value = 0; - if(H5Oget_info_by_name(group, name, &oinfo, H5P_DEFAULT) < 0) - ; /* keep going */ - else { - switch(oinfo.type) { - char *tmp; - size_t tmp_len; - - case H5O_TYPE_GROUP: - if(search_obj(info->group_table, oinfo.addr) == NULL) { - char *old_prefix; + switch(oinfo->type) { + case H5O_TYPE_GROUP: + if(NULL == already_seen) + add_obj(info->group_table, oinfo->addr, name, TRUE); + break; - tmp = build_obj_path_name(info->prefix, name); - add_obj(info->group_table, oinfo.addr, tmp, TRUE); + case H5O_TYPE_DATASET: + if(NULL == already_seen) { + hid_t dset; - old_prefix = info->prefix; - tmp_len = HDstrlen(tmp); - info->prefix = HDmalloc(tmp_len+1); - HDstrcpy(info->prefix, tmp); + /* Add the dataset to the list of objects */ + add_obj(info->dset_table, oinfo->addr, name, TRUE); - if(H5Literate_by_name(group, name, H5_INDEX_NAME, H5_ITER_INC, NULL, find_objs_cb, (void *)info, H5P_DEFAULT) < 0) - ret_value = FAIL; + /* Check for a dataset that uses a named datatype */ + if((dset = H5Dopen2(info->fid, name, H5P_DEFAULT)) >= 0) { + hid_t type = H5Dget_type(dset); - info->prefix = old_prefix; - } /* end if */ - break; - - case H5O_TYPE_DATASET: - if(search_obj(info->dset_table, oinfo.addr) == NULL) { - hid_t dset; - - tmp = build_obj_path_name(info->prefix, name); - add_obj(info->dset_table, oinfo.addr, tmp, TRUE); - - if((dset = H5Dopen2(group, name, H5P_DEFAULT)) >= 0) { - hid_t type; + if(H5Tcommitted(type) > 0) { + H5O_info_t type_oinfo; - type = H5Dget_type(dset); - - if(H5Tcommitted(type) > 0) { - H5Oget_info(type, &oinfo); - if(search_obj(info->type_table, oinfo.addr) == NULL) { - char *type_name = HDstrdup(tmp); - - add_obj(info->type_table, oinfo.addr, type_name, FALSE); - } /* end if */ - } /* end if */ - - H5Tclose(type); - H5Dclose(dset); + H5Oget_info(type, &type_oinfo); + if(search_obj(info->type_table, type_oinfo.addr) == NULL) + add_obj(info->type_table, type_oinfo.addr, name, FALSE); } /* end if */ - else - ret_value = FAIL; - } /* end if */ - break; - case H5O_TYPE_NAMED_DATATYPE: - { - obj_t *found_obj; - - tmp = build_obj_path_name(info->prefix, name); - if((found_obj = search_obj(info->type_table, oinfo.addr)) == NULL) - add_obj(info->type_table, oinfo.addr, tmp, TRUE); - else { - /* Use latest version of name */ - HDfree(found_obj->objname); - found_obj->objname = HDstrdup(tmp); - - /* Mark named datatype as having valid name */ - found_obj->recorded = TRUE; - } /* end else */ - break; - } - - default: - /* Ignore links, etc. */ - break; + H5Tclose(type); + H5Dclose(dset); + } /* end if */ + else + ret_value = FAIL; + } /* end if */ + break; + + case H5O_TYPE_NAMED_DATATYPE: + { + obj_t *found_obj; + + if((found_obj = search_obj(info->type_table, oinfo->addr)) == NULL) + add_obj(info->type_table, oinfo->addr, name, TRUE); + else { + /* Use latest version of name */ + HDfree(found_obj->objname); + found_obj->objname = HDstrdup(name); + + /* Mark named datatype as having valid name */ + found_obj->recorded = TRUE; + } /* end else */ + break; } - } /* end else */ + + default: + break; + } /* end switch */ return ret_value; } @@ -589,31 +533,19 @@ herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table) { - H5O_info_t oinfo; - /* Initialize the tables */ init_table(group_table); init_table(dset_table); init_table(type_table); /* Init the find_objs_t */ - info->prefix = HDcalloc(1, 1); + info->fid = fid; info->group_table = *group_table; info->type_table = *type_table; info->dset_table = *dset_table; - /* add the root group as an object, it may have hard links to it */ - if(H5Oget_info(fid, &oinfo) < 0) - return FAIL; - else { - /* call with an empty string, it appends '/' group separator */ - char *tmp = build_obj_path_name(info->prefix, ""); - - add_obj(info->group_table, oinfo.addr, tmp, TRUE); - } /* end else */ - /* Find all shared objects */ - return(H5Literate(fid, H5_INDEX_NAME, H5_ITER_INC, NULL, find_objs_cb, (void *)info)); + return(h5trav_visit(fid, "/", TRUE, TRUE, find_objs_cb, NULL, info)); } @@ -632,22 +564,22 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table, *------------------------------------------------------------------------- */ static void -add_obj(table_t *table, haddr_t objno, char *objname, hbool_t record) +add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t record) { unsigned u; /* See if we need to make table larger */ - if (table->nobjs == table->size) { + if(table->nobjs == table->size) { table->size *= 2; - table->objs = HDrealloc(table->objs, table->size * sizeof(obj_t)); - } + table->objs = HDrealloc(table->objs, table->size * sizeof(table->objs[0])); + } /* end if */ /* Increment number of objects in table */ u = table->nobjs++; /* Set information about object */ table->objs[u].objno = objno; - table->objs[u].objname = objname; + table->objs[u].objname = HDstrdup(objname); table->objs[u].recorded = record; table->objs[u].displayed = 0; } diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h index e604e5a..e7b175c 100644 --- a/tools/lib/h5tools_utils.h +++ b/tools/lib/h5tools_utils.h @@ -95,7 +95,7 @@ typedef struct table_t { /*this struct stores the information that is passed to the find_objs function*/ typedef struct find_objs_t { - char *prefix; + hid_t fid; table_t *group_table; table_t *type_table; table_t *dset_table; diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index 97de021..14ced60 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -24,24 +24,25 @@ typedef struct trav_addr_t { size_t nalloc; size_t nused; - haddr_t *addrs; + struct { + haddr_t addr; + char *path; + } *objs; } trav_addr_t; typedef struct { - herr_t (*visit_obj)(const char *path_name, const H5O_info_t *oinfo, hbool_t already_visited, void *udata); - herr_t (*visit_lnk)(const char *path_name, const H5L_info_t *linfo, void *udata); + h5trav_obj_func_t visit_obj; /* Callback for visiting objects */ + h5trav_lnk_func_t visit_lnk; /* Callback for visiting links */ void *udata; /* User data to pass to callbacks */ } trav_visitor_t; typedef struct { trav_addr_t *seen; /* List of addresses seen already */ - const char *curr_path; /* Current path to parent group */ const trav_visitor_t *visitor; /* Information for visiting each link/object */ } trav_ud_traverse_t; typedef struct { hid_t fid; /* File ID being traversed */ - trav_table_t *table; /* Table for tracking name of objects with >1 hard link */ } trav_print_udata_t; /*------------------------------------------------------------------------- @@ -52,10 +53,8 @@ static void trav_table_add(trav_table_t *table, const char *objname, const H5O_info_t *oinfo); -static size_t trav_table_search(const trav_table_t *table, haddr_t objno); - static void trav_table_addlink(trav_table_t *table, - size_t j /* the object index */, + haddr_t objno, const char *path); /*------------------------------------------------------------------------- @@ -78,19 +77,20 @@ static void trav_table_addlink(trav_table_t *table, *------------------------------------------------------------------------- */ static void -trav_addr_add(trav_addr_t *visited, haddr_t addr) +trav_addr_add(trav_addr_t *visited, haddr_t addr, const char *path) { size_t idx; /* Index of address to use */ /* Allocate space if necessary */ if(visited->nused == visited->nalloc) { visited->nalloc = MAX(1, visited->nalloc * 2);; - visited->addrs = (haddr_t *)HDrealloc(visited->addrs, visited->nalloc * sizeof(haddr_t)); + visited->objs = HDrealloc(visited->objs, visited->nalloc * sizeof(visited->objs[0])); } /* end if */ /* Append it */ idx = visited->nused++; - visited->addrs[idx] = addr; + visited->objs[idx].addr = addr; + visited->objs[idx].path = HDstrdup(path); } /* end trav_addr_add() */ @@ -107,7 +107,7 @@ trav_addr_add(trav_addr_t *visited, haddr_t addr) * *------------------------------------------------------------------------- */ -static hbool_t +static const char * trav_addr_visited(trav_addr_t *visited, haddr_t addr) { size_t u; /* Local index variable */ @@ -115,11 +115,11 @@ trav_addr_visited(trav_addr_t *visited, haddr_t addr) /* Look for address */ for(u = 0; u < visited->nused; u++) /* Check for address already in array */ - if(visited->addrs[u] == addr) - return(TRUE); + if(visited->objs[u].addr == addr) + return(visited->objs[u].path); /* Didn't find address */ - return(FALSE); + return(NULL); } /* end trav_addr_visited() */ @@ -135,68 +135,44 @@ trav_addr_visited(trav_addr_t *visited, haddr_t addr) *------------------------------------------------------------------------- */ static herr_t -traverse_cb(hid_t loc_id, const char *link_name, const H5L_info_t *linfo, +traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo, void *_udata) { trav_ud_traverse_t *udata = (trav_ud_traverse_t *)_udata; /* User data */ - hbool_t is_group = FALSE; /* If the object is a group */ - hbool_t already_visited = FALSE; /* Whether the link/object was already visited */ - char *link_path; /* Full path name of a link */ + char *full_name; + const char *already_visited = NULL; /* Whether the link/object was already visited */ - /* Construct the full path name of this link */ - link_path = (char*)HDmalloc(HDstrlen(udata->curr_path) + HDstrlen(link_name) + 2); - HDassert(link_path); - HDstrcpy(link_path, udata->curr_path); - HDstrcat(link_path, "/"); - HDstrcat(link_path, link_name); + /* Create the full path name for the link */ + full_name = HDmalloc(HDstrlen(path) + 2); + *full_name = '/'; + HDstrcpy(full_name + 1, path); /* Perform the correct action for different types of links */ if(linfo->type == H5L_TYPE_HARD) { H5O_info_t oinfo; /* Get information about the object */ - if(H5Oget_info_by_name(loc_id, link_name, &oinfo, H5P_DEFAULT) < 0) + if(H5Oget_info_by_name(loc_id, path, &oinfo, H5P_DEFAULT) < 0) return(H5_ITER_ERROR); /* If the object has multiple links, add it to the list of addresses * already visited, if it isn't there already */ - if(oinfo.rc > 1) { - already_visited = trav_addr_visited(udata->seen, oinfo.addr); - if(!already_visited) - trav_addr_add(udata->seen, oinfo.addr); - } /* end if */ - - /* Check if object is a group, for later */ - is_group = (oinfo.type == H5O_TYPE_GROUP) ? TRUE : FALSE; + if(oinfo.rc > 1) + if(NULL == (already_visited = trav_addr_visited(udata->seen, oinfo.addr))) + trav_addr_add(udata->seen, oinfo.addr, full_name); /* Make 'visit object' callback */ if(udata->visitor->visit_obj) - (*udata->visitor->visit_obj)(link_path, &oinfo, already_visited, udata->visitor->udata); + (*udata->visitor->visit_obj)(full_name, &oinfo, already_visited, udata->visitor->udata); } /* end if */ else { /* Make 'visit link' callback */ if(udata->visitor->visit_lnk) - (*udata->visitor->visit_lnk)(link_path, linfo, udata->visitor->udata); + (*udata->visitor->visit_lnk)(full_name, linfo, udata->visitor->udata); } /* end else */ - /* Check for group that we haven't visited yet & recurse */ - if(is_group && !already_visited) { - const char *prev_path = udata->curr_path; /* Previous path to link's parent group */ - - /* Set current path to this object */ - udata->curr_path = link_path; - - /* Iterate over all links in group object */ - if(H5Literate_by_name(loc_id, link_name, H5_INDEX_NAME, H5_ITER_INC, NULL, traverse_cb, udata, H5P_DEFAULT) < 0) - return(H5_ITER_ERROR); - - /* Restore path in udata */ - udata->curr_path = prev_path; - } /* end if */ - - /* Free path name for current link/object */ - HDfree(link_path); + HDfree(full_name); return(H5_ITER_CONT); } /* end traverse_cb() */ @@ -217,39 +193,58 @@ traverse_cb(hid_t loc_id, const char *link_name, const H5L_info_t *linfo, *------------------------------------------------------------------------- */ static int -traverse(hid_t file_id, const trav_visitor_t *visitor) +traverse(hid_t file_id, const char *grp_name, hbool_t visit_start, + hbool_t recurse, const trav_visitor_t *visitor) { - H5O_info_t oinfo; /* Object info for root group */ - trav_addr_t seen; /* List of addresses seen */ - trav_ud_traverse_t udata; /* User data for iteration callback */ + H5O_info_t oinfo; /* Object info for starting group */ - /* Get info for root group */ - if(H5Oget_info(file_id, &oinfo) < 0) + /* Get info for starting object */ + if(H5Oget_info_by_name(file_id, grp_name, &oinfo, H5P_DEFAULT) < 0) return -1; - /* Visit the root group of the file */ - (*visitor->visit_obj)("/", &oinfo, FALSE, visitor->udata); + /* Visit the starting object */ + if(visit_start && visitor->visit_obj) + (*visitor->visit_obj)(grp_name, &oinfo, NULL, visitor->udata); - /* Init addresses seen */ - seen.nused = seen.nalloc = 0; - seen.addrs = NULL; + /* Go visiting, if the object is a group */ + if(oinfo.type == H5O_TYPE_GROUP) { + trav_addr_t seen; /* List of addresses seen */ + trav_ud_traverse_t udata; /* User data for iteration callback */ - /* Check for multiple links to root group */ - if(oinfo.rc > 1) - trav_addr_add(&seen, oinfo.addr); + /* Init addresses seen */ + seen.nused = seen.nalloc = 0; + seen.objs = NULL; - /* Set up user data structure */ - udata.seen = &seen; - udata.curr_path = ""; - udata.visitor = visitor; + /* Check for multiple links to top group */ + if(oinfo.rc > 1) + trav_addr_add(&seen, oinfo.addr, grp_name); - /* Iterate over all links in root group */ - if(H5Literate(file_id, H5_INDEX_NAME, H5_ITER_INC, NULL, traverse_cb, &udata) < 0) - return -1; + /* Set up user data structure */ + udata.seen = &seen; + udata.visitor = visitor; - /* Free visited addresses table */ - if(seen.addrs) - HDfree(seen.addrs); + /* Check for iteration of links vs. visiting all links recursively */ + if(recurse) { + /* Visit all links in group, recursively */ + if(H5Lvisit_by_name(file_id, grp_name, H5_INDEX_NAME, H5_ITER_INC, traverse_cb, &udata, H5P_DEFAULT) < 0) + return -1; + } /* end if */ + else { + /* Iterate over links in group */ + if(H5Literate_by_name(file_id, grp_name, H5_INDEX_NAME, H5_ITER_INC, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0) + return -1; + } /* end else */ + + /* Free visited addresses table */ + if(seen.objs) { + size_t u; /* Local index variable */ + + /* Free paths to objects */ + for(u = 0; u < seen.nused; u++) + HDfree(seen.objs[u].path); + HDfree(seen.objs); + } /* end if */ + } /* end if */ return 0; } @@ -301,7 +296,7 @@ trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type) */ static int trav_info_visit_obj(const char *path, const H5O_info_t *oinfo, - hbool_t UNUSED already_visited, void *udata) + const char UNUSED *already_visited, void *udata) { /* Add the object to the 'info' struct */ /* (object types map directly to "traversal" types) */ @@ -359,7 +354,7 @@ h5trav_getinfo(hid_t file_id, trav_info_t *info) info_visitor.udata = info; /* Traverse all objects in the file, visiting each object & link */ - if(traverse(file_id, &info_visitor) < 0) + if(traverse(file_id, "/", TRUE, TRUE, &info_visitor) < 0) return -1; return 0; @@ -470,24 +465,17 @@ trav_info_free(trav_info_t *info) */ static int trav_table_visit_obj(const char *path, const H5O_info_t *oinfo, - hbool_t already_visited, void *udata) + const char *already_visited, void *udata) { trav_table_t *table = (trav_table_t *)udata; /* Check if we've already seen this object */ - if(!already_visited) + if(NULL == already_visited) /* add object to table */ trav_table_add(table, path, oinfo); - else { - size_t found; /* Index of original object seen */ - - /* Look for object in existing table */ - found = trav_table_search(table, oinfo->addr); - HDassert(found < table->nobjs); - + else /* Add alias for object to table */ - trav_table_addlink(table, found, path); - } /* end else */ + trav_table_addlink(table, oinfo->addr, path); return(0); } /* end trav_table_visit_obj() */ @@ -541,7 +529,7 @@ h5trav_gettable(hid_t fid, trav_table_t *table) table_visitor.udata = table; /* Traverse all objects in the file, visiting each object & link */ - if(traverse(fid, &table_visitor) < 0) + if(traverse(fid, "/", TRUE, TRUE, &table_visitor) < 0) return -1; return 0; } @@ -670,25 +658,33 @@ trav_table_add(trav_table_t *table, */ static void -trav_table_addlink(trav_table_t *table, - size_t j /* the object index */, - const char *path) +trav_table_addlink(trav_table_t *table, haddr_t objno, const char *path) { - size_t new; + size_t i; /* Local index variable */ - /* already inserted */ - if(HDstrcmp(table->objs[j].name, path) == 0) - return; + for(i = 0; i < table->nobjs; i++) { + if(table->objs[i].objno == objno) { + size_t n; - /* allocate space if necessary */ - if(table->objs[j].nlinks == (unsigned)table->objs[j].sizelinks) { - table->objs[j].sizelinks = MAX(1, table->objs[j].sizelinks * 2); - table->objs[j].links = (trav_link_t*)HDrealloc(table->objs[j].links, table->objs[j].sizelinks * sizeof(trav_link_t)); - } /* end if */ + /* 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 */ - /* insert it */ - new = table->objs[j].nlinks++; - table->objs[j].links[new].new_name = (char *)HDstrdup(path); + /* insert it */ + n = table->objs[i].nlinks++; + table->objs[i].links[n].new_name = (char *)HDstrdup(path); + + return; + } /* end for */ + } /* end for */ + + HDassert(0 && "object not in table?!?"); } @@ -809,10 +805,8 @@ void trav_table_free( trav_table_t *table ) */ static int trav_print_visit_obj(const char *path, const H5O_info_t *oinfo, - hbool_t already_visited, void *udata) + const char *already_visited, void UNUSED *udata) { - trav_print_udata_t *print_udata = (trav_print_udata_t *)udata; - /* Print the name of the object */ /* (no new-line, so that objects that we've encountered before can print * the name of the original object) @@ -836,26 +830,12 @@ trav_print_visit_obj(const char *path, const H5O_info_t *oinfo, } /* end switch */ /* Check if we've already seen this object */ - if(!already_visited) { + if(NULL == already_visited) /* Finish printing line about object */ printf("\n"); - - /* Check if we will encounter another hard link to this object */ - if(oinfo->rc > 1) { - /* Add object to table */ - trav_table_add(print_udata->table, path, oinfo); - } /* end if */ - } /* end if */ - else { - size_t found; /* Index of original object seen */ - - /* Locate object in table */ - found = trav_table_search(print_udata->table, oinfo->addr); - HDassert(found < print_udata->table->nobjs); - - /* Print the link's destination */ - printf(" -> %s\n", print_udata->table->objs[found].name); - } /* end else */ + else + /* Print the link's original name */ + printf(" -> %s\n", already_visited); return(0); } /* end trav_print_visit_obj() */ @@ -938,16 +918,11 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata) int h5trav_print(hid_t fid) { - trav_table_t *table = NULL; /* Table for objects w/multiple hard links */ trav_print_udata_t print_udata; /* User data for traversal */ trav_visitor_t print_visitor; /* Visitor structure for printing objects */ - /* Initialize the table */ - trav_table_init(&table); - /* Init user data for printing */ print_udata.fid = fid; - print_udata.table = table; /* Init visitor structure */ print_visitor.visit_obj = trav_print_visit_obj; @@ -955,11 +930,42 @@ h5trav_print(hid_t fid) print_visitor.udata = &print_udata; /* Traverse all objects in the file, visiting each object & link */ - if(traverse(fid, &print_visitor) < 0) + if(traverse(fid, "/", TRUE, TRUE, &print_visitor) < 0) return -1; - /* Free table */ - trav_table_free(table); + return 0; +} + + +/*------------------------------------------------------------------------- + * Function: h5trav_visit + * + * Purpose: Generic traversal routine for visiting objects and links + * + * Return: 0, -1 on error + * + * Programmer: Quincey Koziol, koziol@hdfgroup.org + * + * Date: November 6, 2007 + * + *------------------------------------------------------------------------- + */ + +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 */ + + /* Init visitor structure */ + visitor.visit_obj = visit_obj; + visitor.visit_lnk = visit_lnk; + visitor.udata = udata; + + /* Traverse all objects in the file, visiting each object & link */ + if(traverse(fid, grp_name, visit_start, recurse, &visitor) < 0) + return -1; return 0; } diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h index 05bc3cb..5c07331 100644 --- a/tools/lib/h5trav.h +++ b/tools/lib/h5trav.h @@ -18,6 +18,12 @@ #include "hdf5.h" +/* Typedefs for visiting objects */ +typedef herr_t (*h5trav_obj_func_t)(const char *path_name, const H5O_info_t *oinfo, + const char *first_seen, void *udata); +typedef herr_t (*h5trav_lnk_func_t)(const char *path_name, const H5L_info_t *linfo, + void *udata); + /*------------------------------------------------------------------------- * public enum to specify type of an object * the TYPE can be: @@ -101,6 +107,14 @@ extern "C" { #endif /*------------------------------------------------------------------------- + * "h5trav general" public functions + *------------------------------------------------------------------------- + */ +int h5trav_visit(hid_t file_id, 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); + +/*------------------------------------------------------------------------- * "h5trav info" public functions *------------------------------------------------------------------------- */ |