diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index f493bb62bd..831edc9260 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -19,15 +19,29 @@ #include static -int diff_array_mem( void *_mem1, - void *_mem2, - hid_t m_type, - unsigned i, - int rank, - hsize_t *dims, +int diff_array_mem( void *_mem1, + void *_mem2, + hid_t m_type, + unsigned i, + int rank, + int *acc, + int *pos, diff_opt_t *options, - const char *name1, - const char *name2); + const char *obj1, + const char *obj2); + +static +int diff_native_uchar(unsigned char *mem1, + unsigned char *mem2, + size_t type_size, + unsigned i, + int rank, + int *acc, + int *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int ph); /*------------------------------------------------------------------------- @@ -60,33 +74,43 @@ int diff_array( void *_mem1, const char *name1, const char *name2, hid_t m_type ) -{ +{ int 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 i; + size_t size; /* size of datum */ + unsigned char *mem1 = (unsigned char*)_mem1; + unsigned char *mem2 = (unsigned char*)_mem2; + int acc[32]; /* accumulator and matrix position */ + int pos[32]; + unsigned i; + int j; + + acc[rank-1]=1; + for(j=(rank-2); j>=0; j--) + { + acc[j]=acc[j+1]*(int)dims[j+1]; + } - /* Get the size. */ + /* Get the size. */ size = H5Tget_size( m_type ); - - for ( i = 0; i < nelmts; i++) + + for ( i = 0; i < nelmts; i++) { nfound+=diff_array_mem( - mem1 + i * size, - mem2 + i * size, /* offset */ - m_type, + mem1 + i * size, + mem2 + i * size, /* offset */ + m_type, i, rank, - dims, + acc, + pos, options, name1, name2); - if (options->n && nfound>=options->count) - return nfound; - } - - return nfound; + if (options->n && nfound>=options->count) + return nfound; + } + + return nfound; } @@ -106,31 +130,34 @@ int diff_array( void *_mem1, */ static -int diff_array_mem( void *_mem1, - void *_mem2, - hid_t m_type, - unsigned i, - int rank, - hsize_t *dims, +int diff_array_mem( void *_mem1, + void *_mem2, + hid_t m_type, + unsigned i, + int rank, + int *acc, + int *pos, diff_opt_t *options, - const char *obj1, + const char *obj1, const char *obj2) { char fmt_llong[255], fmt_ullong[255]; char fmt_llongp[255], fmt_ullongp[255]; - size_t type_size;/* just check */ - static int ph=1; /* print header */ - int nfound=0; /* difference found */ - unsigned char *mem1 = (unsigned char*)_mem1; - unsigned char *mem2 = (unsigned char*)_mem2; - hid_t memb_type; + size_t type_size; + static int ph=1; /* print header */ + int nfound=0; /* differences found */ + unsigned char *mem1 = (unsigned char*)_mem1; + unsigned char *mem2 = (unsigned char*)_mem2; + unsigned u; + hid_t memb_type; size_t offset; - int nmembs; - int acc[32]; /* accumulator and matrix position */ - int pos[32]; + int nmembs; int j; - - + /* for H5T_ARRAY */ + hsize_t adims[H5S_MAX_RANK],anelmts,andims; + hid_t amemb_id; + size_t asize; + /* Build default formats for long long types */ sprintf(fmt_llong, "%%%sd %%%sd %%%sd\n", H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); @@ -142,12 +169,6 @@ int diff_array_mem( void *_mem1, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); - acc[rank-1]=1; - for(j=(rank-2); j>=0; j--) - { - acc[j]=acc[j+1]*(int)dims[j+1]; - } - /* Get the size. */ type_size = H5Tget_size( m_type ); @@ -167,14 +188,77 @@ int diff_array_mem( void *_mem1, { offset = H5Tget_member_offset(m_type, j); memb_type = H5Tget_member_type(m_type, j); - nfound+=diff_array_mem(mem1+offset,mem2+offset,memb_type,i,rank,dims,options,obj1,obj2); + nfound+=diff_array_mem(mem1+offset, + mem2+offset, + memb_type, + i, + rank, + acc, + pos, + options, + obj1, + obj2); H5Tclose(memb_type); } break; case H5T_TIME: break; +/*------------------------------------------------------------------------- + * H5T_STRING + *------------------------------------------------------------------------- + */ case H5T_STRING: + + for (u=0; u= 1 && andims <= H5S_MAX_RANK); + + /* calculate the number of array elements */ + for (u = 0, anelmts = 1; u d && !options->p) { @@ -1100,7 +1185,104 @@ int diff_array_mem( void *_mem1, } /* switch */ - + return nfound; } + + +/*------------------------------------------------------------------------- + * Function: diff_native_uchar + * + * Purpose: compare H5T_NATIVE_UCHAR (used in H5T_NATIVE_UCHAR + * and H5T_STRING class) + * + * Return: number of differences found + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: October 29, 2003 + * + *------------------------------------------------------------------------- + */ + + +static +int diff_native_uchar(unsigned char *mem1, + unsigned char *mem2, + size_t type_size, + unsigned i, + int rank, + int *acc, + int *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int ph) +{ + int 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)); + + /* -d and !-p */ + if (options->d && !options->p) + { + if (abs(temp1_uchar-temp2_uchar) > options->delta) + { + if ( options->r==0 ) + { + print_pos(&ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar)); + } + nfound++; + } + } + /* !-d and -p */ + else if (!options->d && options->p) + { + if ( temp1_uchar!=0 && abs(1-temp2_uchar/temp1_uchar) > options->percent ) + { + if ( options->r==0 ) + { + print_pos(&ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IPFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar), + abs(1-temp2_uchar/temp1_uchar)); + } + nfound++; + } + } + /* -d and -p */ + else if ( options->d && options->p) + { + if ( temp1_uchar!=0 && abs(1-temp2_uchar/temp1_uchar) > options->percent && + abs(temp1_uchar-temp2_uchar) > options->delta ) + { + if ( options->r==0 ) + { + print_pos(&ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IPFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar), + abs(1-temp2_uchar/temp1_uchar)); + } + nfound++; + } + } + else if (temp1_uchar != temp2_uchar) + { + if ( options->r==0 ) + { + print_pos(&ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar)); + } + nfound++; + } + + return nfound; +} diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index f5e2188f3d..0db6bf9624 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -63,6 +63,8 @@ int diff_dataset( hid_t file1_id, int maxdim_diff=0; /* maximum dimensions are different */ int dim_diff=0; /* current dimensions are different */ int can1, can2; /* supported diff */ + hsize_t storage_size1; + hsize_t storage_size2; int i; @@ -156,17 +158,21 @@ int diff_dataset( hid_t file1_id, assert(tclass1==tclass2); switch (tclass1) { - case H5T_TIME: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: #if 0 case H5T_COMPOUND: + case H5T_STRING: + case H5T_ARRAY: + #endif + + + case H5T_TIME: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_REFERENCE: case H5T_ENUM: case H5T_VLEN: - case H5T_ARRAY: if (options->verbose ) { printf("Comparison not supported\n"); printf("<%s> is of class %s and <%s> is of class %s\n", @@ -178,6 +184,19 @@ int diff_dataset( hid_t file1_id, break; } + + +/*------------------------------------------------------------------------- + * check for empty datasets + *------------------------------------------------------------------------- + */ + + storage_size1=H5Dget_storage_size(dset1_id); + storage_size2=H5Dget_storage_size(dset2_id); + if (storage_size1<=0 && storage_size2<=0) + goto out; + + /*------------------------------------------------------------------------- * check for the same rank *------------------------------------------------------------------------- @@ -375,6 +394,8 @@ int diff_dataset( hid_t file1_id, goto out; } + + /*------------------------------------------------------------------------- * read *------------------------------------------------------------------------- diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c index 36175c78d3..3340e2d5ff 100644 --- a/tools/lib/h5diff_util.c +++ b/tools/lib/h5diff_util.c @@ -25,7 +25,7 @@ * Date: May 30, 2003 * * Modifications: October 29, 2003 - * Added support for H5T_COMPOUND types; + * Added support for H5T_COMPOUND, H5T_STRING, H5T_ARRAY types; * *------------------------------------------------------------------------- */ @@ -34,6 +34,9 @@ int diff_can(hid_t type_id) int ret=0; if ( ((H5Tget_class(type_id) == H5T_COMPOUND)==1)|| /* get class */ + ((H5Tget_class(type_id) == H5T_STRING)==1)|| /* get class */ + ((H5Tget_class(type_id) == H5T_ARRAY)==1)|| /* get class */ + (H5Tequal(type_id, H5T_NATIVE_FLOAT)==1)|| (H5Tequal(type_id, H5T_NATIVE_DOUBLE)==1)|| (H5Tequal(type_id, H5T_NATIVE_INT)==1)|| diff --git a/tools/testfiles/h5diff_30.txt b/tools/testfiles/h5diff_30.txt index e7b30f1e7a..d0a072e430 100644 --- a/tools/testfiles/h5diff_30.txt +++ b/tools/testfiles/h5diff_30.txt @@ -16,23 +16,15 @@ file1 file2 x x /string x x /vlen -Comparison not supported - is of class H5T_ARRAY and is of class H5T_ARRAY Comparison not supported is of class H5T_BITFIELD and is of class H5T_BITFIELD -Comparing with -0 differences found Comparison not supported is of class H5T_ENUM and is of class H5T_ENUM -Comparing with -0 differences found -Comparing with -0 differences found Comparison not supported is of class H5T_OPAQUE and is of class H5T_OPAQUE @@ -40,8 +32,6 @@ Comparison not supported Comparison not supported is of class H5T_REFERENCE and is of class H5T_REFERENCE -Comparison not supported - is of class H5T_STRING and is of class H5T_STRING Comparison not supported is of class H5T_VLEN and is of class H5T_VLEN diff --git a/tools/testfiles/h5diff_31.txt b/tools/testfiles/h5diff_31.txt index 1244794714..18b51fc2b1 100644 --- a/tools/testfiles/h5diff_31.txt +++ b/tools/testfiles/h5diff_31.txt @@ -16,23 +16,15 @@ file1 file2 x x /string x x /vlen -Comparison not supported - is of class H5T_ARRAY and is of class H5T_ARRAY Comparison not supported is of class H5T_BITFIELD and is of class H5T_BITFIELD -Comparing with -0 differences found Comparison not supported is of class H5T_ENUM and is of class H5T_ENUM -Comparing with -0 differences found -Comparing with -0 differences found Comparison not supported is of class H5T_OPAQUE and is of class H5T_OPAQUE @@ -40,8 +32,6 @@ Comparison not supported Comparison not supported is of class H5T_REFERENCE and is of class H5T_REFERENCE -Comparison not supported - is of class H5T_STRING and is of class H5T_STRING Comparison not supported is of class H5T_VLEN and is of class H5T_VLEN diff --git a/tools/testfiles/h5diff_32.txt b/tools/testfiles/h5diff_32.txt index c401cf7751..904bd5bdcd 100644 --- a/tools/testfiles/h5diff_32.txt +++ b/tools/testfiles/h5diff_32.txt @@ -16,23 +16,15 @@ file1 file2 x x /string x x /vlen -Comparison not supported - is of class H5T_ARRAY and is of class H5T_ARRAY Comparison not supported is of class H5T_BITFIELD and is of class H5T_BITFIELD -Comparing with -0 differences found Comparison not supported is of class H5T_ENUM and is of class H5T_ENUM -Comparing with -0 differences found -Comparing with -0 differences found Comparison not supported is of class H5T_OPAQUE and is of class H5T_OPAQUE @@ -40,8 +32,6 @@ Comparison not supported Comparison not supported is of class H5T_REFERENCE and is of class H5T_REFERENCE -Comparison not supported - is of class H5T_STRING and is of class H5T_STRING Comparison not supported is of class H5T_VLEN and is of class H5T_VLEN diff --git a/tools/testfiles/h5diff_33.txt b/tools/testfiles/h5diff_33.txt index 142240220c..3829c258e5 100644 --- a/tools/testfiles/h5diff_33.txt +++ b/tools/testfiles/h5diff_33.txt @@ -16,23 +16,15 @@ file1 file2 x x /string x x /vlen -Comparison not supported - is of class H5T_ARRAY and is of class H5T_ARRAY Comparison not supported is of class H5T_BITFIELD and is of class H5T_BITFIELD -Comparing with -0 differences found Comparison not supported is of class H5T_ENUM and is of class H5T_ENUM -Comparing with -0 differences found -Comparing with -0 differences found Comparison not supported is of class H5T_OPAQUE and is of class H5T_OPAQUE @@ -40,8 +32,6 @@ Comparison not supported Comparison not supported is of class H5T_REFERENCE and is of class H5T_REFERENCE -Comparison not supported - is of class H5T_STRING and is of class H5T_STRING Comparison not supported is of class H5T_VLEN and is of class H5T_VLEN diff --git a/tools/testfiles/h5diff_34.txt b/tools/testfiles/h5diff_34.txt index 6aca9b029c..9261800810 100644 --- a/tools/testfiles/h5diff_34.txt +++ b/tools/testfiles/h5diff_34.txt @@ -16,23 +16,15 @@ file1 file2 x x /string x x /vlen -Comparison not supported - is of class H5T_ARRAY and is of class H5T_ARRAY Comparison not supported is of class H5T_BITFIELD and is of class H5T_BITFIELD -Comparing with -0 differences found Comparison not supported is of class H5T_ENUM and is of class H5T_ENUM -Comparing with -0 differences found -Comparing with -0 differences found Comparison not supported is of class H5T_OPAQUE and is of class H5T_OPAQUE @@ -40,8 +32,6 @@ Comparison not supported Comparison not supported is of class H5T_REFERENCE and is of class H5T_REFERENCE -Comparison not supported - is of class H5T_STRING and is of class H5T_STRING Comparison not supported is of class H5T_VLEN and is of class H5T_VLEN diff --git a/tools/testfiles/h5diff_35.txt b/tools/testfiles/h5diff_35.txt index 5f4e6ad2c6..5b18d3f52e 100644 --- a/tools/testfiles/h5diff_35.txt +++ b/tools/testfiles/h5diff_35.txt @@ -16,23 +16,15 @@ file1 file2 x x /string x x /vlen -Comparison not supported - is of class H5T_ARRAY and is of class H5T_ARRAY Comparison not supported is of class H5T_BITFIELD and is of class H5T_BITFIELD -Comparing with -0 differences found Comparison not supported is of class H5T_ENUM and is of class H5T_ENUM -Comparing with -0 differences found -Comparing with -0 differences found Comparison not supported is of class H5T_OPAQUE and is of class H5T_OPAQUE @@ -40,8 +32,6 @@ Comparison not supported Comparison not supported is of class H5T_REFERENCE and is of class H5T_REFERENCE -Comparison not supported - is of class H5T_STRING and is of class H5T_STRING Comparison not supported is of class H5T_VLEN and is of class H5T_VLEN diff --git a/tools/testfiles/h5diff_36.txt b/tools/testfiles/h5diff_36.txt index bc845b62c9..01f6c07fc6 100644 --- a/tools/testfiles/h5diff_36.txt +++ b/tools/testfiles/h5diff_36.txt @@ -16,23 +16,15 @@ file1 file2 x x /string x x /vlen -Comparison not supported - is of class H5T_ARRAY and is of class H5T_ARRAY Comparison not supported is of class H5T_BITFIELD and is of class H5T_BITFIELD -Comparing with -0 differences found Comparison not supported is of class H5T_ENUM and is of class H5T_ENUM -Comparing with -0 differences found -Comparing with -0 differences found Comparison not supported is of class H5T_OPAQUE and is of class H5T_OPAQUE @@ -40,8 +32,6 @@ Comparison not supported Comparison not supported is of class H5T_REFERENCE and is of class H5T_REFERENCE -Comparison not supported - is of class H5T_STRING and is of class H5T_STRING Comparison not supported is of class H5T_VLEN and is of class H5T_VLEN diff --git a/tools/testfiles/h5diff_37.txt b/tools/testfiles/h5diff_37.txt index 65bcf11659..ce746a8de9 100644 --- a/tools/testfiles/h5diff_37.txt +++ b/tools/testfiles/h5diff_37.txt @@ -16,23 +16,15 @@ file1 file2 x x /string x x /vlen -Comparison not supported - is of class H5T_ARRAY and is of class H5T_ARRAY Comparison not supported is of class H5T_BITFIELD and is of class H5T_BITFIELD -Comparing with -0 differences found Comparison not supported is of class H5T_ENUM and is of class H5T_ENUM -Comparing with -0 differences found -Comparing with -0 differences found Comparison not supported is of class H5T_OPAQUE and is of class H5T_OPAQUE @@ -40,8 +32,6 @@ Comparison not supported Comparison not supported is of class H5T_REFERENCE and is of class H5T_REFERENCE -Comparison not supported - is of class H5T_STRING and is of class H5T_STRING Comparison not supported is of class H5T_VLEN and is of class H5T_VLEN diff --git a/tools/testfiles/h5diff_38.txt b/tools/testfiles/h5diff_38.txt index 206f050d1d..82472e353c 100644 --- a/tools/testfiles/h5diff_38.txt +++ b/tools/testfiles/h5diff_38.txt @@ -2,7 +2,5 @@ Expected output for 'h5diff file4.h5 file4.h5 -v integer float' ############################# $h5diff file4.h5 file4.h5 -v integer float -Comparing with -0 differences found diff --git a/tools/testfiles/h5diff_40.txt b/tools/testfiles/h5diff_40.txt index 1ee7449269..72d2e7d2ee 100644 --- a/tools/testfiles/h5diff_40.txt +++ b/tools/testfiles/h5diff_40.txt @@ -2,7 +2,5 @@ Expected output for 'h5diff file5.h5 file5.h5 -v dset1 dset2' ############################# $h5diff file5.h5 file5.h5 -v dset1 dset2 -Comparing with -0 differences found diff --git a/tools/testfiles/h5diff_41.txt b/tools/testfiles/h5diff_41.txt index e1112cb366..f2dbd2506e 100644 --- a/tools/testfiles/h5diff_41.txt +++ b/tools/testfiles/h5diff_41.txt @@ -2,7 +2,5 @@ Expected output for 'h5diff file5.h5 file5.h5 -v dset3 dset4' ############################# $h5diff file5.h5 file5.h5 -v dset3 dset4 -Comparing with -0 differences found diff --git a/tools/testfiles/h5diff_42.txt b/tools/testfiles/h5diff_42.txt index 7f48b42773..b71acd02fa 100644 --- a/tools/testfiles/h5diff_42.txt +++ b/tools/testfiles/h5diff_42.txt @@ -2,7 +2,5 @@ Expected output for 'h5diff file5.h5 file5.h5 -v dset5 dset6' ############################# $h5diff file5.h5 file5.h5 -v dset5 dset6 -Comparing with -0 differences found