From 199b2f9a1d5f512728c38e271775d32c872405ce Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Mon, 30 Oct 2006 10:18:58 -0500 Subject: [svn-r12826] added a new test for h5diff relative error for the file generator program --- tools/h5diff/h5diffgentest.c | 55 +++--- tools/h5repack/testh5repack_make.c | 35 ++-- tools/lib/h5diff_array.c | 331 +++++++++++++------------------------ tools/testfiles/h5diff_16.txt | 15 +- tools/testfiles/h5diff_basic1.h5 | Bin 6416 -> 6416 bytes tools/testfiles/h5diff_basic2.h5 | Bin 4240 -> 4240 bytes 6 files changed, 165 insertions(+), 271 deletions(-) diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index fa4884f..ecce3c6 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -41,7 +41,7 @@ #define FILE10 "h5diff_hyper2.h5" #define UIMAX 4294967295u /*Maximum value for a variable of type unsigned int */ #define STR_SIZE 3 -#define GBLL ((unsigned long_long) 1024 * 1024 *1024 ) +#define GBLL ((unsigned long_long) 1024 * 1024 *1024 ) #define MY_LINKCLASS 187 @@ -129,8 +129,7 @@ int test_basic(const char *fname1, hid_t fid1, fid2; hid_t gid1, gid2, gid3; herr_t status; - hsize_t dims32[2] = { 3,2 }; - hsize_t dims42[2] = { 4,2 }; + hsize_t dims[2] = { 3,2 }; /* Test */ double data1[3][2] = {{1,1},{1,1},{1,1}}; @@ -141,18 +140,18 @@ int test_basic(const char *fname1, unsigned long_long data8[3][2] = {{101,102},{103,104},{150,200}}; double data3[3][2] = {{100,100},{100,100},{100,100}}; double data4[3][2] = {{105,120},{160,95},{80,40}}; - double data9[4][2] = {{100,100},{100,100},{100,100},{1,0}}; /* compare divide by zero */ - double data10[4][2] = {{105,120},{160,95},{80,40},{0,1}}; + double data9[3][2] = {{100,100},{100,0},{0,100}}; + /* compare divide by zero */ + /* compare both zero */ + double data10[3][2] ={{120,80},{0,100},{0,50}}; /* -A B 1-B/A % -100 105 0.05 5 -100 120 0.2 20 -100 160 0.6 60 -100 95 0.05 5 -100 80 0.2 20 -100 40 0.6 60 -1 0 1 100 -0 1 #DIV/0! +A B 1-B/A % +100 120 0.2 20 +100 80 0.2 20 +100 0 1 100 +0 100 #DIV/0! #DIV/0! +0 0 #DIV/0! #DIV/0! +100 50 0.5 50 */ /*------------------------------------------------------------------------- @@ -168,22 +167,22 @@ A B 1-B/A % gid2 = H5Gcreate(fid2, "g1", 0); gid3 = H5Gcreate(fid2, "g2", 0); - write_dset(gid1,2,dims32,"dset1",H5T_NATIVE_DOUBLE,data1); - write_dset(gid2,2,dims32,"dset2",H5T_NATIVE_DOUBLE,data2); - write_dset(gid1,2,dims32,"dset3",H5T_NATIVE_DOUBLE,data3); - write_dset(gid2,2,dims32,"dset4",H5T_NATIVE_DOUBLE,data4); - write_dset(gid2,2,dims32,"dset1",H5T_NATIVE_DOUBLE,data2); + write_dset(gid1,2,dims,"dset1",H5T_NATIVE_DOUBLE,data1); + write_dset(gid2,2,dims,"dset2",H5T_NATIVE_DOUBLE,data2); + write_dset(gid1,2,dims,"dset3",H5T_NATIVE_DOUBLE,data3); + write_dset(gid2,2,dims,"dset4",H5T_NATIVE_DOUBLE,data4); + write_dset(gid2,2,dims,"dset1",H5T_NATIVE_DOUBLE,data2); /* relative (int) */ - write_dset(gid1,2,dims32,"dset5",H5T_NATIVE_INT,data5); - write_dset(gid1,2,dims32,"dset6",H5T_NATIVE_INT,data6); + write_dset(gid1,2,dims,"dset5",H5T_NATIVE_INT,data5); + write_dset(gid1,2,dims,"dset6",H5T_NATIVE_INT,data6); /* relative (unsigned long_long) */ - write_dset(gid1,2,dims32,"dset7",H5T_NATIVE_ULLONG,data7); - write_dset(gid1,2,dims32,"dset8",H5T_NATIVE_ULLONG,data8); + write_dset(gid1,2,dims,"dset7",H5T_NATIVE_ULLONG,data7); + write_dset(gid1,2,dims,"dset8",H5T_NATIVE_ULLONG,data8); /* test divide by zero in percente case */ - write_dset(gid1,2,dims42,"dset9",H5T_NATIVE_DOUBLE,data9); - write_dset(gid1,2,dims42,"dset10",H5T_NATIVE_DOUBLE,data10); + write_dset(gid1,2,dims,"dset9",H5T_NATIVE_DOUBLE,data9); + write_dset(gid1,2,dims,"dset10",H5T_NATIVE_DOUBLE,data10); /*------------------------------------------------------------------------- * Close @@ -2387,13 +2386,13 @@ int test_hyperslab(char *fname, fid = H5Fcreate (fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if ((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) goto out; - if (H5Pset_fill_value(dcpl, H5T_NATIVE_CHAR, &fillvalue)<0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_CHAR, &fillvalue)<0) goto out; if(H5Pset_chunk(dcpl, 1, chunk_dims)<0) goto out; - if ((f_sid = H5Screate_simple(1,dims,NULL))<0) + if ((f_sid = H5Screate_simple(1,dims,NULL))<0) goto out; - if ((did = H5Dcreate(fid,"big",H5T_NATIVE_CHAR,f_sid,dcpl))<0) + if ((did = H5Dcreate(fid,"big",H5T_NATIVE_CHAR,f_sid,dcpl))<0) goto out; if ((m_sid = H5Screate_simple(1, hs_size, hs_size))<0) goto out; diff --git a/tools/h5repack/testh5repack_make.c b/tools/h5repack/testh5repack_make.c index 32016f6..883244b 100644 --- a/tools/h5repack/testh5repack_make.c +++ b/tools/h5repack/testh5repack_make.c @@ -22,7 +22,7 @@ #define CDIM1 DIM1/2 #define CDIM2 DIM2/2 #define RANK 2 -#define GBLL ((unsigned long_long) 1024*1024*1024) +#define GBLL ((unsigned long_long) 1024*1024*1024) int make_all_objects(hid_t loc_id); @@ -183,7 +183,7 @@ int make_testfiles(void) return -1; if (make_nbit(loc_id)<0) goto out; - if(H5Fclose(loc_id)<0) + if(H5Fclose(loc_id)<0) return -1; /*------------------------------------------------------------------------- @@ -194,7 +194,7 @@ int make_testfiles(void) return -1; if (make_scaleoffset(loc_id)<0) goto out; - if(H5Fclose(loc_id)<0) + if(H5Fclose(loc_id)<0) return -1; /*------------------------------------------------------------------------- @@ -455,7 +455,7 @@ if (szip_can_encode) { if (make_dset(loc_id,"dset_szip",sid,dcpl,buf)<0) goto out; } else { - /* WARNING? SZIP is decoder only, can't generate test files */ + /* WARNING? SZIP is decoder only, can't generate test files */ } if(H5Sclose(sid)<0) @@ -927,7 +927,7 @@ if (szip_can_encode) { if(H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block)<0) goto out; } else { - /* WARNING? SZIP is decoder only, can't generate test data using szip */ + /* WARNING? SZIP is decoder only, can't generate test data using szip */ } #endif @@ -971,7 +971,7 @@ if (szip_can_encode) { if (make_dset(loc_id,"dset_szip",sid,dcpl,buf)<0) goto out; } else { - /* WARNING? SZIP is decoder only, can't generate test dataset */ + /* WARNING? SZIP is decoder only, can't generate test dataset */ } #endif @@ -1264,13 +1264,13 @@ int make_fill(hid_t loc_id) */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) goto out; - if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue)<0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue)<0) goto out; - if ((sid = H5Screate_simple(2,dims,NULL))<0) + if ((sid = H5Screate_simple(2,dims,NULL))<0) goto out; - if ((did = H5Dcreate(loc_id,"dset_fill",H5T_NATIVE_INT,sid,dcpl))<0) + if ((did = H5Dcreate(loc_id,"dset_fill",H5T_NATIVE_INT,sid,dcpl))<0) goto out; - if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) goto out; /* close */ @@ -1294,13 +1294,14 @@ out: } /*------------------------------------------------------------------------- - * Function: make a big file + * Function: make_big * - * Purpose: used in test read by hyperslabs. writes a 1GB file by iterating - * trough 1MB hyperslabs + * Purpose: used in test read by hyperslabs. create a dataset with 1GB dimensions + * by iterating trough 1MB hyperslabs * *------------------------------------------------------------------------- */ + int make_big(hid_t loc_id) { hid_t did; @@ -1322,13 +1323,13 @@ int make_big(hid_t loc_id) /* create */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) goto out; - if (H5Pset_fill_value(dcpl, H5T_NATIVE_CHAR, &fillvalue)<0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_CHAR, &fillvalue)<0) goto out; if(H5Pset_chunk(dcpl, 1, chunk_dims)<0) goto out; - if ((f_sid = H5Screate_simple(1,dims,NULL))<0) + if ((f_sid = H5Screate_simple(1,dims,NULL))<0) goto out; - if ((did = H5Dcreate(loc_id,"big",H5T_NATIVE_CHAR,f_sid,dcpl))<0) + if ((did = H5Dcreate(loc_id,"big",H5T_NATIVE_CHAR,f_sid,dcpl))<0) goto out; if ((m_sid = H5Screate_simple(1, hs_size, hs_size))<0) goto out; @@ -1356,7 +1357,7 @@ int make_big(hid_t loc_id) if (H5Dwrite (did,H5T_NATIVE_CHAR,m_sid,f_sid,H5P_DEFAULT,buf)<0) goto out; - /* write only one hyperslab, for space considerations */ + /* write only one hyperslab */ if (i==0) break; diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 89e0c4a..fa4ebec 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -22,7 +22,6 @@ *------------------------------------------------------------------------- */ -#define COMP_0 #define F_FORMAT "%-15f %-15f %-15f\n" #define I_FORMAT "%-15d %-15d %-15d\n" #define C_FORMAT "%-16c %-17c\n" @@ -53,15 +52,30 @@ #define ULLI_FORMAT_P_NOTCOMP "%-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"d not comparable\n" +static int both_zero; +static float per; /*------------------------------------------------------------------------- * -p relative error formula + * + * We assume the true value of a quantity to be A (value in first dataset) + * and the measured or inferred value to be B (value in second dataset). + * The relative error is defined by + * + * B - A + * -------- + * A + * + *------------------------------------------------------------------------- */ #define PER(A,B) { per = -1; \ + both_zero=0; \ + if (A==0 && B==0) \ + both_zero=1; \ if (A!=0) \ - per = (float)fabs(1-( (float)B / (float)A )); \ + per = (float)fabs( ((float)B - (float)A) / (float) A ); \ } /*------------------------------------------------------------------------- @@ -239,6 +253,11 @@ hsize_t diff_array( void *_mem1, assert(0); break; + /*------------------------------------------------------------------------- + * float and integer atomic types + *------------------------------------------------------------------------- + */ + case H5T_FLOAT: if (H5Tequal(m_type, H5T_NATIVE_FLOAT)) @@ -272,6 +291,11 @@ hsize_t diff_array( void *_mem1, break; + /*------------------------------------------------------------------------- + * Other types than float and integer + *------------------------------------------------------------------------- + */ + case H5T_COMPOUND: case H5T_STRING: case H5T_BITFIELD: @@ -378,7 +402,7 @@ hsize_t diff_datum(void *_mem1, hid_t obj2_id; hsize_t nfound=0; /* differences found */ int ret=0; /* check return error */ - float f1, f2, per; + float f1, f2; type_size = H5Tget_size( m_type ); @@ -772,8 +796,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_char,temp2_char); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -784,7 +807,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent ) { if ( print_data(options) ) @@ -803,8 +826,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_char,temp2_char); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -815,7 +837,6 @@ hsize_t diff_datum(void *_mem1, } else -#endif if ( per > options->percent && abs(temp1_char-temp2_char) > options->delta ) { @@ -874,8 +895,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_uchar,temp2_uchar); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -886,7 +906,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent ) { if ( print_data(options) ) @@ -905,8 +925,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_uchar,temp2_uchar); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -917,7 +936,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent && abs(temp1_uchar-temp2_uchar) > options->delta ) { if ( print_data(options) ) @@ -977,8 +996,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_short,temp2_short); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -989,7 +1007,6 @@ hsize_t diff_datum(void *_mem1, } else -#endif if ( per > options->percent ) { @@ -1009,8 +1026,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_short,temp2_short); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1021,7 +1037,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent && abs(temp1_short-temp2_short) > options->delta ) { if ( print_data(options) ) @@ -1082,8 +1098,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_ushort,temp2_ushort); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1094,7 +1109,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent ) { if ( print_data(options) ) @@ -1113,8 +1128,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_ushort,temp2_ushort); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1125,7 +1139,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent && abs(temp1_ushort-temp2_ushort) > options->delta ) { if ( print_data(options) ) @@ -1184,8 +1198,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_int,temp2_int); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1196,7 +1209,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent ) { if ( print_data(options) ) @@ -1216,8 +1229,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_int,temp2_int); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1228,7 +1240,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent && abs(temp1_int-temp2_int) > options->delta ) { if ( print_data(options) ) @@ -1287,8 +1299,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_uint,temp2_uint); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1299,7 +1310,6 @@ hsize_t diff_datum(void *_mem1, } else -#endif if ( per > options->percent ) { @@ -1319,8 +1329,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_uint,temp2_uint); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1331,7 +1340,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent && abs((int)(temp1_uint-temp2_uint)) > options->delta ) { if ( print_data(options) ) @@ -1390,8 +1399,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_long,temp2_long); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1402,7 +1410,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent ) { if ( print_data(options) ) @@ -1421,8 +1429,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_long,temp2_long); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1433,7 +1440,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent && labs(temp1_long-temp2_long) > (long)options->delta ) { if ( print_data(options) ) @@ -1491,8 +1498,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_ulong,temp2_ulong); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1503,7 +1509,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent ) { if ( print_data(options) ) @@ -1522,8 +1528,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_ulong,temp2_ulong); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1534,7 +1539,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent && labs((long)(temp1_ulong-temp2_ulong)) > (long)options->delta ) { if ( print_data(options) ) @@ -1595,8 +1600,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_llong,temp2_llong); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1607,7 +1611,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent ) { if ( print_data(options) ) @@ -1626,8 +1630,7 @@ hsize_t diff_datum(void *_mem1, { PER(temp1_llong,temp2_llong); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1638,7 +1641,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent && labs((long)(temp1_llong-temp2_llong)) > (long)options->delta ) { if ( print_data(options) ) @@ -1701,8 +1704,7 @@ hsize_t diff_datum(void *_mem1, ull2float(temp2_ullong,&f2); PER(f1,f2); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1713,7 +1715,6 @@ hsize_t diff_datum(void *_mem1, } else -#endif if ( per > options->percent ) { @@ -1736,8 +1737,7 @@ hsize_t diff_datum(void *_mem1, ull2float(temp2_ullong,&f2); PER(f1,f2); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1748,7 +1748,7 @@ hsize_t diff_datum(void *_mem1, } else -#endif + if ( per > options->percent && labs((long)(temp1_ullong-temp2_ullong)) > (long)options->delta ) { @@ -1814,27 +1814,9 @@ hsize_t diff_datum(void *_mem1, { -#if 0 - if ( temp1_float!=0 && fabs(1-temp2_float/temp1_float) > options->percent ) - { - - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P,temp1_float,temp2_float,fabs(temp1_float-temp2_float), - fabs(1-temp2_float/temp1_float)); - } - nfound++; - } - } -#endif - - PER(temp1_float,temp2_float); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1845,7 +1827,6 @@ hsize_t diff_datum(void *_mem1, } else -#endif if ( per > options->percent && fabs(temp1_float-temp2_float) > options->delta ) { @@ -1865,27 +1846,9 @@ hsize_t diff_datum(void *_mem1, else if ( options->d && options->p) { -#if 0 - if ( temp1_float!=0 && fabs(1-temp2_float/temp1_float) > options->percent && - fabs(temp1_float-temp2_float) > options->delta ) - { - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - - parallel_print(SPACES); - parallel_print(F_FORMAT_P,temp1_float,temp2_float,fabs(temp1_float-temp2_float), - fabs(1-temp2_float/temp1_float)); - } - nfound++; - } - } -#endif - PER(temp1_float,temp2_float); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1896,7 +1859,6 @@ hsize_t diff_datum(void *_mem1, } else -#endif if ( per > options->percent ) { @@ -1957,25 +1919,10 @@ hsize_t diff_datum(void *_mem1, /* !-d and -p */ else if (!options->d && options->p) { - -#if 0 - if ( temp1_double!=0 && fabs(1-temp2_double/temp1_double) > options->percent ) - { - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P,temp1_double,temp2_double,fabs(temp1_double-temp2_double), fabs(1-temp2_double/temp1_double)); - } - nfound++; - } - } -#endif PER(temp1_double,temp2_double); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -1986,7 +1933,6 @@ hsize_t diff_datum(void *_mem1, } else -#endif if ( per > options->percent ) { @@ -2006,27 +1952,10 @@ hsize_t diff_datum(void *_mem1, /* -d and -p */ else if ( options->d && options->p) { - -#if 0 - if ( temp1_double!=0 && fabs(1-temp2_double/temp1_double) > options->percent && - fabs(temp1_double-temp2_double) > options->delta ) - { - - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P,temp1_double,temp2_double,fabs(temp1_double-temp2_double), fabs(1-temp2_double/temp1_double)); - } - nfound++; - } - } -#endif - + PER(temp1_double,temp2_double); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -2037,7 +1966,6 @@ hsize_t diff_datum(void *_mem1, } else -#endif if ( per > options->percent && fabs(temp1_double-temp2_double) > options->delta ) @@ -2450,7 +2378,6 @@ hsize_t character_compare_opt(unsigned char *mem1, hsize_t nfound=0; /* differences found */ unsigned char temp1_uchar; unsigned char temp2_uchar; - float per; memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); @@ -2584,8 +2511,7 @@ hsize_t diff_float(unsigned char *mem1, PER(temp1_float,temp2_float); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -2596,7 +2522,6 @@ hsize_t diff_float(unsigned char *mem1, } else -#endif if ( per > options->percent ) { @@ -2628,8 +2553,7 @@ hsize_t diff_float(unsigned char *mem1, PER(temp1_float,temp2_float); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -2640,7 +2564,6 @@ hsize_t diff_float(unsigned char *mem1, } else -#endif if ( per > options->percent && fabs(temp1_float-temp2_float) > options->delta ) { @@ -2758,8 +2681,7 @@ hsize_t diff_double(unsigned char *mem1, PER(temp1_double,temp2_double); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -2770,7 +2692,6 @@ hsize_t diff_double(unsigned char *mem1, } else -#endif if ( per > options->percent ) { @@ -2802,8 +2723,7 @@ hsize_t diff_double(unsigned char *mem1, PER(temp1_double,temp2_double); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -2814,7 +2734,6 @@ hsize_t diff_double(unsigned char *mem1, } else -#endif if ( per > options->percent && fabs(temp1_double-temp2_double) > options->delta ) { @@ -2930,8 +2849,7 @@ hsize_t diff_schar(unsigned char *mem1, PER(temp1_char,temp2_char); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -2942,7 +2860,6 @@ hsize_t diff_schar(unsigned char *mem1, } else -#endif if ( per > options->percent ) { @@ -2974,8 +2891,7 @@ hsize_t diff_schar(unsigned char *mem1, PER(temp1_char,temp2_char); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -2986,7 +2902,6 @@ hsize_t diff_schar(unsigned char *mem1, } else -#endif if ( per > options->percent && abs(temp1_char-temp2_char) > options->delta ) { @@ -3106,8 +3021,7 @@ hsize_t diff_uchar(unsigned char *mem1, PER(temp1_uchar,temp2_uchar); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -3118,7 +3032,6 @@ hsize_t diff_uchar(unsigned char *mem1, } else -#endif if ( per > options->percent ) { @@ -3150,8 +3063,7 @@ hsize_t diff_uchar(unsigned char *mem1, PER(temp1_uchar,temp2_uchar); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -3162,7 +3074,6 @@ hsize_t diff_uchar(unsigned char *mem1, } else -#endif if ( per > options->percent && abs(temp1_uchar-temp2_uchar) > options->delta ) { @@ -3280,8 +3191,7 @@ hsize_t diff_short(unsigned char *mem1, PER(temp1_short,temp2_short); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -3292,7 +3202,7 @@ hsize_t diff_short(unsigned char *mem1, } else -#endif + if ( per > options->percent ) { if ( print_data(options) ) @@ -3325,8 +3235,7 @@ hsize_t diff_short(unsigned char *mem1, PER(temp1_short,temp2_short); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -3337,7 +3246,7 @@ hsize_t diff_short(unsigned char *mem1, } else -#endif + if ( per > options->percent && abs(temp1_short-temp2_short) > options->delta ) { if ( print_data(options) ) @@ -3454,8 +3363,7 @@ hsize_t diff_ushort(unsigned char *mem1, PER(temp1_ushort,temp2_ushort); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -3466,7 +3374,7 @@ hsize_t diff_ushort(unsigned char *mem1, } else -#endif + if ( per > options->percent ) { if ( print_data(options) ) @@ -3499,8 +3407,7 @@ hsize_t diff_ushort(unsigned char *mem1, PER(temp1_ushort,temp2_ushort); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -3511,7 +3418,7 @@ hsize_t diff_ushort(unsigned char *mem1, } else -#endif + if ( per > options->percent && abs(temp1_ushort-temp2_ushort) > options->delta ) { if ( print_data(options) ) @@ -3629,8 +3536,7 @@ hsize_t diff_int(unsigned char *mem1, PER(temp1_int,temp2_int); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -3641,7 +3547,7 @@ hsize_t diff_int(unsigned char *mem1, } else -#endif + if ( per > options->percent ) { if ( print_data(options) ) @@ -3674,8 +3580,7 @@ hsize_t diff_int(unsigned char *mem1, PER(temp1_int,temp2_int); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -3686,7 +3591,7 @@ hsize_t diff_int(unsigned char *mem1, } else -#endif + if ( per > options->percent && abs(temp1_int-temp2_int) > options->delta ) { if ( print_data(options) ) @@ -3804,8 +3709,7 @@ hsize_t diff_uint(unsigned char *mem1, PER(temp1_uint,temp2_uint); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -3816,7 +3720,7 @@ hsize_t diff_uint(unsigned char *mem1, } else -#endif + if ( per > options->percent ) { if ( print_data(options) ) @@ -3849,8 +3753,7 @@ hsize_t diff_uint(unsigned char *mem1, PER(temp1_uint,temp2_uint); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -3861,7 +3764,7 @@ hsize_t diff_uint(unsigned char *mem1, } else -#endif + if ( per > options->percent && abs(temp1_uint-temp2_uint) > options->delta ) { if ( print_data(options) ) @@ -3982,8 +3885,7 @@ hsize_t diff_long(unsigned char *mem1, PER(temp1_long,temp2_long); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -3994,7 +3896,7 @@ hsize_t diff_long(unsigned char *mem1, } else -#endif + if ( per > options->percent ) { if ( print_data(options) ) @@ -4027,8 +3929,7 @@ hsize_t diff_long(unsigned char *mem1, PER(temp1_long,temp2_long); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -4039,7 +3940,7 @@ hsize_t diff_long(unsigned char *mem1, } else -#endif + if ( per > options->percent && labs(temp1_long-temp2_long) > options->delta ) { if ( print_data(options) ) @@ -4164,8 +4065,7 @@ hsize_t diff_ulong(unsigned char *mem1, PER(temp1_ulong,temp2_ulong); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -4176,8 +4076,8 @@ hsize_t diff_ulong(unsigned char *mem1, } else -#endif - if ( per > options->percent ) + + if ( per > options->percent ) { if ( print_data(options) ) { @@ -4209,8 +4109,7 @@ hsize_t diff_ulong(unsigned char *mem1, PER(temp1_ulong,temp2_ulong); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -4221,7 +4120,7 @@ hsize_t diff_ulong(unsigned char *mem1, } else -#endif + if ( per > options->percent && labs(temp1_ulong-temp2_ulong) > options->delta ) { if ( print_data(options) ) @@ -4339,8 +4238,8 @@ hsize_t diff_llong(unsigned char *mem1, memcpy(&temp2_llong, mem2, sizeof(long_long)); PER(temp1_llong,temp2_llong); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -4351,8 +4250,8 @@ hsize_t diff_llong(unsigned char *mem1, } else -#endif - if ( per > options->percent ) + + if ( per > options->percent ) { if ( print_data(options) ) { @@ -4383,8 +4282,8 @@ hsize_t diff_llong(unsigned char *mem1, memcpy(&temp2_llong, mem2, sizeof(long_long)); PER(temp1_llong,temp2_llong); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -4395,7 +4294,7 @@ hsize_t diff_llong(unsigned char *mem1, } else -#endif + if ( per > options->percent && labs((long)(temp1_llong-temp2_llong)) > options->delta ) { if ( print_data(options) ) @@ -4518,8 +4417,7 @@ hsize_t diff_ullong(unsigned char *mem1, ull2float(temp2_ullong,&f2); PER(f1,f2); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -4530,8 +4428,8 @@ hsize_t diff_ullong(unsigned char *mem1, } else -#endif - if ( per > options->percent ) + + if ( per > options->percent ) { if ( print_data(options) ) { @@ -4565,8 +4463,7 @@ hsize_t diff_ullong(unsigned char *mem1, ull2float(temp2_ullong,&f2); PER(f1,f2); -#ifdef COMP_0 - if (per==-1) /* not comparable */ + if (per==-1 && !both_zero) /* not comparable */ { print_pos(ph,1,hyper_start+i,acc,pos,rank,obj1,obj2); parallel_print(SPACES); @@ -4577,8 +4474,8 @@ hsize_t diff_ullong(unsigned char *mem1, } else -#endif - if ( per > options->percent && labs((long)(temp1_ullong-temp2_ullong)) > options->delta ) + + if ( per > options->percent && labs((long)(temp1_ullong-temp2_ullong)) > options->delta ) { if ( print_data(options) ) { diff --git a/tools/testfiles/h5diff_16.txt b/tools/testfiles/h5diff_16.txt index a0855c3..8145b00 100644 --- a/tools/testfiles/h5diff_16.txt +++ b/tools/testfiles/h5diff_16.txt @@ -4,15 +4,12 @@ Expected output for 'h5diff h5diff_basic1.h5 h5diff_basic1.h5 g1/dset9 g1/dset10 Dataset: and position dset9 dset10 difference relative ------------------------------------------------------------------------ -[ 0 0 ] 100 105 5 0.05 -[ 0 1 ] 100 120 20 0.2 -[ 1 0 ] 100 160 60 0.6 -[ 1 1 ] 100 95 5 0.05 -[ 2 0 ] 100 80 20 0.2 -[ 2 1 ] 100 40 60 0.6 -[ 3 0 ] 1 0 1 1 -[ 3 1 ] 0 1 1 not comparable -8 differences found +[ 0 0 ] 100 120 20 0.2 +[ 0 1 ] 100 80 20 0.2 +[ 1 0 ] 100 0 100 1 +[ 1 1 ] 0 100 100 not comparable +[ 2 1 ] 100 50 50 0.5 +5 differences found -------------------------------- Some objects are not comparable -------------------------------- diff --git a/tools/testfiles/h5diff_basic1.h5 b/tools/testfiles/h5diff_basic1.h5 index 58c399f..5609a56 100644 Binary files a/tools/testfiles/h5diff_basic1.h5 and b/tools/testfiles/h5diff_basic1.h5 differ diff --git a/tools/testfiles/h5diff_basic2.h5 b/tools/testfiles/h5diff_basic2.h5 index aa7e81e..0bd9ee1 100644 Binary files a/tools/testfiles/h5diff_basic2.h5 and b/tools/testfiles/h5diff_basic2.h5 differ -- cgit v0.12