diff options
Diffstat (limited to 'tools/h5diff')
-rw-r--r-- | tools/h5diff/h5diff.c | 46 | ||||
-rw-r--r-- | tools/h5diff/h5difftst.c | 113 | ||||
-rwxr-xr-x | tools/h5diff/testh5diff.sh | 42 |
3 files changed, 168 insertions, 33 deletions
diff --git a/tools/h5diff/h5diff.c b/tools/h5diff/h5diff.c index eb848d6..374f2c3 100644 --- a/tools/h5diff/h5diff.c +++ b/tools/h5diff/h5diff.c @@ -46,7 +46,8 @@ typedef struct options_t int diff_dataset( hid_t file1_id, hid_t file2_id, const char *obj1_name, const char *obj2_name, options_t options ); int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank, - hsize_t *dims, options_t options, const char *obj1, const char *obj2 ); + hsize_t *dims, options_t options, const char *obj1, const char *obj2, + size_t size_mem); void print_class( H5T_class_t tclass, char *sclass ); void list( const char *filename, int nobjects, info_t *info ); void diff( hid_t file1_id, const char *obj1_name, hid_t file2_id, const char *obj2_name, @@ -104,7 +105,7 @@ void usage(void) printf("[-n count] Print difference up to count number for each variable\n"); printf("[-d delta] Print difference when it is greater than limit delta\n"); printf("[-p relative] Print differences which are within a relative error value\n"); - printf("[-m ] Print differences on a sequencial match iteration\n"); + printf("[-m ] Print differences on a sequential match iteration\n"); } @@ -158,7 +159,6 @@ int main(int argc, const char *argv[]) const char *obj1_name = NULL; const char *obj2_name = NULL; - /*------------------------------------------------------------------------- * print the command line options *------------------------------------------------------------------------- @@ -797,6 +797,7 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, const char *obj1_name, char sclass2[20]; int nfound; hid_t type_mem =-1; /* read to memory type */ + size_t size_mem; /* size of type in memory */ void *edata; hid_t (*func)(void*); htri_t is1, is2; @@ -1043,6 +1044,9 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, const char *obj1_name, */ type_mem = fixtype( type1_id ); + /* Get the size. */ + size_mem = H5Tget_size( type_mem ); + /*------------------------------------------------------------------------- * read @@ -1060,7 +1064,8 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, const char *obj1_name, else tot_cnt = tot_cnt1; - nfound = array_diff(buf1,buf2,tot_cnt,type1_id,rank1,dims1,options,obj1_name,obj2_name); + nfound = array_diff(buf1,buf2,tot_cnt,type1_id,rank1,dims1,options, + obj1_name,obj2_name,size_mem); printf("%d differences found\n", nfound ); @@ -1105,7 +1110,8 @@ out: */ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank, - hsize_t *dims, options_t options, const char *obj1, const char *obj2 ) + hsize_t *dims, options_t options, const char *obj1, const char *obj2, + size_t size_mem ) { char *i1ptr1, *i1ptr2; short *i2ptr1, *i2ptr2; @@ -1116,6 +1122,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank int nfound=0; /* number of differences found */ int ph=1; /* print header */ int i8diff; + int v=0; /* accumulator and matrix position */ int acc[32]; @@ -1137,6 +1144,12 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank /* Get the size. */ type_size = H5Tget_size( type_id ); + if (v && size_mem!=type_size) + { + printf("memory type size is %d\n", size_mem); + printf("disk type size is %d\n", type_size); + } + switch(type_class) { @@ -1146,7 +1159,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank case H5T_INTEGER: - switch(type_size) + switch(size_mem) { /*------------------------------------------------------------------------- @@ -1515,7 +1528,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank case H5T_FLOAT: - switch(type_size) + switch(size_mem) { /*------------------------------------------------------------------------- @@ -1841,6 +1854,7 @@ hid_t fixtype(hid_t f_type) { hid_t m_type = -1; size_t size; + int v=0; size = H5Tget_size(f_type); @@ -1857,19 +1871,19 @@ hid_t fixtype(hid_t f_type) */ if (size <= sizeof(char)) { m_type = H5Tcopy(H5T_NATIVE_SCHAR); - printf("using memory type H5T_NATIVE_SCHAR\n"); + if (v) printf("using memory type H5T_NATIVE_SCHAR\n"); } else if (size <= sizeof(short)) { m_type = H5Tcopy(H5T_NATIVE_SHORT); - printf("using memory type H5T_NATIVE_SHORT\n"); + if (v) printf("using memory type H5T_NATIVE_SHORT\n"); } else if (size <= sizeof(int)) { m_type = H5Tcopy(H5T_NATIVE_INT); - printf("using memory type H5T_NATIVE_INT\n"); + if (v) printf("using memory type H5T_NATIVE_INT\n"); } else if (size <= sizeof(long)) { m_type = H5Tcopy(H5T_NATIVE_LONG); - printf("using memory type H5T_NATIVE_LONG\n"); + if (v) printf("using memory type H5T_NATIVE_LONG\n"); } else { m_type = H5Tcopy(H5T_NATIVE_LLONG); - printf("using memory type H5T_NATIVE_LLONG\n"); + if (v) printf("using memory type H5T_NATIVE_LLONG\n"); } H5Tset_sign(m_type, H5Tget_sign(f_type)); @@ -1883,13 +1897,13 @@ hid_t fixtype(hid_t f_type) */ if (size <= sizeof(float)) { m_type = H5Tcopy(H5T_NATIVE_FLOAT); - printf("using memory type H5T_NATIVE_FLOAT\n"); + if (v) printf("using memory type H5T_NATIVE_FLOAT\n"); } else if (size <= sizeof(double)) { m_type = H5Tcopy(H5T_NATIVE_DOUBLE); - printf("using memory type H5T_NATIVE_DOUBLE\n"); + if (v) printf("using memory type H5T_NATIVE_DOUBLE\n"); } else { m_type = H5Tcopy(H5T_NATIVE_LDOUBLE); - printf("using memory type H5T_NATIVE_LDOUBLE\n"); + if (v) printf("using memory type H5T_NATIVE_LDOUBLE\n"); } break; @@ -2006,3 +2020,5 @@ void print_datatype(hid_t type) + + diff --git a/tools/h5diff/h5difftst.c b/tools/h5diff/h5difftst.c index c795b55..714055e 100644 --- a/tools/h5diff/h5difftst.c +++ b/tools/h5diff/h5difftst.c @@ -20,7 +20,7 @@ /* diff tst*/ int do_test_files(void); -int write_dataset( hid_t file_id, int rank, hsize_t *dims, const char *dset_name, +int write_dataset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, hid_t type_id, void *data ); @@ -54,9 +54,6 @@ h5diff_test1.h5 # test 0.3.1: Check for -h option -h h5diff_test1.h5 h5diff_test2.h5 -# test 0.3.2: Check for -l option --l h5diff_test1.h5 h5diff_test2.h5 - # test 0.3.3: Check for -r option -r h5diff_test1.h5 h5diff_test2.h5 @@ -340,16 +337,49 @@ dset2.6a dset2.6b -p 3 h5diff_test1.h5 h5diff_test2.h5 h5diff_test3.h5 h5diff_test4.h5 # test 3.1 -dset3 dset3 h5diff_test3.h5 h5diff_test4.h5 +dset_A dset_A h5diff_test3.h5 h5diff_test4.h5 # test 3.2 -dset3 dset4 h5diff_test3.h5 h5diff_test4.h5 +dset_A dset_B h5diff_test3.h5 h5diff_test4.h5 # test 3.3 -dset6 dset3 h5diff_test3.h5 h5diff_test4.h5 +dset_C dset_A h5diff_test3.h5 h5diff_test4.h5 # test 3.4 -dset6 dset6 h5diff_test3.h5 h5diff_test4.h5 +dset_C dset_C h5diff_test3.h5 h5diff_test4.h5 + +####################################################### +# reverse direction +####################################################### + +# test 3.5 +h5diff_test4.h5 h5diff_test3.h5 + +####################################################### +# Different paths +####################################################### + +# test 4.0: should find +g1/dset1 g2/dset1 h5diff_test5.h5 h5diff_test6.h5 + +# test 4.1.1: should NOT find +dset1 dset1 h5diff_test5.h5 h5diff_test6.h5 + +# test 4.1.2: should NOT find +/g1/dset1 dset1 h5diff_test5.h5 h5diff_test6.h5 + +# test 4.1.3: should NOT find +/g1/dset1 /g1/dset1 h5diff_test5.h5 h5diff_test6.h5 + +####################################################### +# paths with several components +####################################################### + +# test 4.2.1: +/a/b/c /a/b/c h5diff_test5.h5 h5diff_test6.h5 + +# test 4.2.2: +/x/a/c /a/b/c h5diff_test5.h5 h5diff_test6.h5 */ @@ -358,9 +388,10 @@ int do_test_files(void) { hid_t file1_id, file2_id, file3_id, file4_id; + hid_t file5_id, file6_id; hid_t dataset_id; hid_t space_id; - hid_t group_id; + hid_t group_id, group2_id; hid_t plist_id; hid_t type_id, type2_id; herr_t status; @@ -744,6 +775,61 @@ int do_test_files(void) write_dataset(file4_id,1,dims1_1,"dset_C",H5T_NATIVE_INT,0); +/*------------------------------------------------------------------------- + * Create two files for path tests + *------------------------------------------------------------------------- + */ + + /* Create a file */ + file5_id = H5Fcreate ("h5diff_test5.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* Create a file */ + file6_id = H5Fcreate ("h5diff_test6.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + +/*------------------------------------------------------------------------- + * Test 4.1.x + * Check for different paths + *------------------------------------------------------------------------- + */ + + /* Create "g1/dset1" */ + group_id = H5Gcreate(file5_id, "g1", 0); + write_dataset(group_id,1,dims1_1,"dset1",H5T_NATIVE_INT,0); + status = H5Gclose(group_id); + + /* Create "g2/dset1" */ + group_id = H5Gcreate(file6_id, "g2", 0); + write_dataset(group_id,1,dims1_1,"dset1",H5T_NATIVE_INT,0); + status = H5Gclose(group_id); + +/*------------------------------------------------------------------------- + * Test 4.2.x + * paths with several components + *------------------------------------------------------------------------- + */ + + /* Create "/a/b/c" */ + group_id = H5Gcreate(file5_id, "a", 0); + group2_id = H5Gcreate(group_id, "b", 0); + write_dataset(group2_id,1,dims1_1,"c",H5T_NATIVE_INT,0); + status = H5Gclose(group_id); + status = H5Gclose(group2_id); + + /* Create "/a/b/c" */ + group_id = H5Gcreate(file6_id, "a", 0); + group2_id = H5Gcreate(group_id, "b", 0); + write_dataset(group2_id,1,dims1_1,"c",H5T_NATIVE_INT,0); + status = H5Gclose(group_id); + status = H5Gclose(group2_id); + + /* Create "/x/a/c" */ + group_id = H5Gcreate(file5_id, "x", 0); + group2_id = H5Gcreate(group_id, "a", 0); + write_dataset(group2_id,1,dims1_1,"c",H5T_NATIVE_INT,0); + status = H5Gclose(group_id); + status = H5Gclose(group2_id); + + /*------------------------------------------------------------------------- @@ -754,6 +840,8 @@ int do_test_files(void) status = H5Fclose(file2_id); status = H5Fclose(file3_id); status = H5Fclose(file4_id); + status = H5Fclose(file5_id); + status = H5Fclose(file6_id); return 0; @@ -775,7 +863,7 @@ int do_test_files(void) *------------------------------------------------------------------------- */ -int write_dataset( hid_t file_id, int rank, hsize_t *dims, const char *dset_name, +int write_dataset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, hid_t type_id, void *data ) { hid_t dataset_id; @@ -786,7 +874,7 @@ int write_dataset( hid_t file_id, int rank, hsize_t *dims, const char *dset_name space_id = H5Screate_simple(rank,dims,NULL); /* Create a dataset */ - dataset_id = H5Dcreate(file_id,dset_name,type_id,space_id,H5P_DEFAULT); + dataset_id = H5Dcreate(loc_id,dset_name,type_id,space_id,H5P_DEFAULT); /* Write the data */ if ( data ) @@ -805,6 +893,3 @@ int write_dataset( hid_t file_id, int rank, hsize_t *dims, const char *dset_name - - - diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh index 97025d5..4761595 100755 --- a/tools/h5diff/testh5diff.sh +++ b/tools/h5diff/testh5diff.sh @@ -389,16 +389,50 @@ TOOLTEST h5diff_263.txt dset2.6a dset2.6b -p 3 h5diff_test1.h5 h5diff_test2.h5 TOOLTEST h5diff_30.txt h5diff_test3.h5 h5diff_test4.h5 # test 3.1 -TOOLTEST h5diff_31.txt dset3 dset3 h5diff_test3.h5 h5diff_test4.h5 +TOOLTEST h5diff_31.txt dset_A dset_A h5diff_test3.h5 h5diff_test4.h5 # test 3.2 -TOOLTEST h5diff_32.txt dset3 dset4 h5diff_test3.h5 h5diff_test4.h5 +TOOLTEST h5diff_32.txt dset_A dset_B h5diff_test3.h5 h5diff_test4.h5 # test 3.3 -TOOLTEST h5diff_33.txt dset6 dset3 h5diff_test3.h5 h5diff_test4.h5 +TOOLTEST h5diff_33.txt dset_C dset_A h5diff_test3.h5 h5diff_test4.h5 # test 3.4 -TOOLTEST h5diff_34.txt dset6 dset6 h5diff_test3.h5 h5diff_test4.h5 +TOOLTEST h5diff_34.txt dset_C dset_C h5diff_test3.h5 h5diff_test4.h5 + +####################################################### +# reverse direction +####################################################### + +# test 3.5 +TOOLTEST h5diff_35.txt h5diff_test4.h5 h5diff_test3.h5 + +####################################################### +# Different paths +####################################################### + +# test 4.0: should find +TOOLTEST h5diff_40.txt g1/dset1 g2/dset1 h5diff_test5.h5 h5diff_test6.h5 + +# test 4.1.1: should NOT find +TOOLTEST h5diff_411.txt dset1 dset1 h5diff_test5.h5 h5diff_test6.h5 + +# test 4.1.2: should NOT find +TOOLTEST h5diff_412.txt /g1/dset1 dset1 h5diff_test5.h5 h5diff_test6.h5 + +# test 4.1.3: should NOT find +TOOLTEST h5diff_413.txt /g1/dset1 /g1/dset1 h5diff_test5.h5 h5diff_test6.h5 + +####################################################### +# paths with several components +####################################################### + +# test 4.2.1: +TOOLTEST h5diff_421.txt /a/b/c /a/b/c h5diff_test5.h5 h5diff_test6.h5 + +# test 4.2.2: +TOOLTEST h5diff_422.txt /x/a/c /a/b/c h5diff_test5.h5 h5diff_test6.h5 + |