[svn-r12678] bug fix

the number of atribute differences was not added to the total sum of
differences
This commit is contained in:
Pedro Vicente Nunes 2006-09-25 10:49:26 -05:00
parent afcf6b7608
commit c439d91f81
50 changed files with 246 additions and 192 deletions

View File

@ -181,7 +181,7 @@ void parse_input(int argc, const char* argv[], const char** fname1, const char**
*-------------------------------------------------------------------------
*/
void print_results(diff_opt_t* options)
void print_results(diff_opt_t* options, hsize_t nfound)
{
if (options->m_quiet || options->err_stat)
return;
@ -202,6 +202,8 @@ void print_results(diff_opt_t* options)
printf("Use -v for a list of objects.\n");
}
print_found(nfound);
}
/*-------------------------------------------------------------------------

View File

@ -20,5 +20,5 @@ int check_n_input( const char* );
int check_f_input( const char* );
void parse_input(int argc, const char* argv[], const char** fname1, const char** fname2, const char** objname1, const char** objname2, diff_opt_t* options);
void h5diff_exit(int status);
void print_results(diff_opt_t* options);
void print_results(diff_opt_t* options, hsize_t nfound);

View File

@ -63,7 +63,7 @@ int main(int argc, const char *argv[])
nfound = h5diff(fname1,fname2,objname1,objname2,&options);
print_results(&options);
print_results(&options,nfound);
/*-------------------------------------------------------------------------
* exit code

View File

@ -79,7 +79,7 @@ int main(int argc, const char *argv[])
nfound = h5diff(fname1,fname2,objname1,objname2,&options);
print_results(&options);
print_results(&options,nfound);
MPI_Finalize();
@ -95,7 +95,7 @@ int main(int argc, const char *argv[])
MPI_Barrier(MPI_COMM_WORLD);
print_results(&options);
print_results(&options,nfound);
print_manager_output();
MPI_Finalize();

View File

@ -982,7 +982,7 @@ hsize_t diff (hid_t file1_id,
*-------------------------------------------------------------------------
*/
if (path1)
diff_attr (type1_id, type2_id, path1, path2, options);
nfound += diff_attr (type1_id, type2_id, path1, path2, options);
if (H5Tclose (type1_id) < 0)
goto out;
@ -1019,7 +1019,7 @@ hsize_t diff (hid_t file1_id,
*-------------------------------------------------------------------------
*/
if (path1)
diff_attr (grp1_id, grp2_id, path1, path2, options);
nfound += diff_attr (grp1_id, grp2_id, path1, path2, options);
if (H5Gclose (grp1_id) < 0)
goto out;

View File

@ -138,12 +138,13 @@ int diff_can_type( hid_t f_type1, /* file data type */
diff_opt_t *options );
int diff_attr(hid_t loc1_id,
hid_t loc2_id,
const char *path1,
const char *path2,
diff_opt_t *options
);
hsize_t
diff_attr(hid_t loc1_id,
hid_t loc2_id,
const char *path1,
const char *path2,
diff_opt_t *options
);
/*-------------------------------------------------------------------------

View File

@ -16,6 +16,7 @@
#include "h5diff.h"
#include "H5private.h"
/*-------------------------------------------------------------------------
* Function: diff_attr
*
@ -26,8 +27,7 @@
* loc_id = H5Topen( fid, name);
*
* Return:
* 0 : no differences found
* 1 : differences found
* number of differences found
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
@ -36,20 +36,22 @@
*-------------------------------------------------------------------------
*/
int diff_attr(hid_t loc1_id,
hid_t loc2_id,
const char *path1,
const char *path2,
diff_opt_t *options)
hsize_t
diff_attr(hid_t loc1_id,
hid_t loc2_id,
const char *path1,
const char *path2,
diff_opt_t *options
)
{
hid_t attr1_id=-1; /* attr ID */
hid_t attr2_id=-1; /* attr ID */
hid_t space1_id=-1; /* space ID */
hid_t space2_id=-1; /* space ID */
hid_t ftype1_id=-1; /* file data type ID */
hid_t ftype2_id=-1; /* file data type ID */
hid_t mtype1_id=-1; /* memory data type ID */
hid_t mtype2_id=-1; /* memory data type ID */
hid_t attr1_id; /* attr ID */
hid_t attr2_id; /* attr ID */
hid_t space1_id; /* space ID */
hid_t space2_id; /* space ID */
hid_t ftype1_id; /* file data type ID */
hid_t ftype2_id; /* file data type ID */
hid_t mtype1_id; /* memory data type ID */
hid_t mtype2_id; /* memory data type ID */
size_t msize1; /* memory size of memory type */
size_t msize2; /* memory size of memory type */
void *buf1=NULL; /* data buffer */
@ -64,8 +66,7 @@ int diff_attr(hid_t loc1_id,
char np1[512];
char np2[512];
int n1, n2, i, j;
int ret=0;
hsize_t nfound;
hsize_t found, nfound=0;
int cmp=1;
if ((n1 = H5Aget_num_attrs(loc1_id))<0)
@ -74,18 +75,19 @@ int diff_attr(hid_t loc1_id,
goto error;
if (n1!=n2)
return 1;
return nfound;
for ( i = 0; i < n1; i++)
{
/* reset buffers for every attribute, we might goto out and call free */
buf1=NULL;
buf2=NULL;
/*-------------------------------------------------------------------------
* open
*-------------------------------------------------------------------------
*/
/*-------------------------------------------------------------------------
* open
*-------------------------------------------------------------------------
*/
/* open attribute */
if ((attr1_id = H5Aopen_idx(loc1_id, (unsigned)i))<0)
goto error;
@ -102,11 +104,10 @@ int diff_attr(hid_t loc1_id,
{
if (options->m_verbose)
{
parallel_print("Different name for attributes: <%s> and <%s>\n", name1, name2);
printf("Different name for attributes: <%s> and <%s>\n", name1, name2);
}
H5Aclose(attr1_id);
H5Aclose(attr2_id);
ret=1;
continue;
}
@ -128,168 +129,176 @@ int diff_attr(hid_t loc1_id,
if ( (rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0 )
goto error;
/*-------------------------------------------------------------------------
* check for comparable TYPE and SPACE
*-------------------------------------------------------------------------
*/
if (diff_can_type(ftype1_id,
ftype2_id,
rank1,
rank2,
dims1,
dims2,
NULL,
NULL,
name1,
name2,
options)!=1)
/*-------------------------------------------------------------------------
* check for comparable TYPE and SPACE
*-------------------------------------------------------------------------
*/
if (diff_can_type(ftype1_id,
ftype2_id,
rank1,
rank2,
dims1,
dims2,
NULL,
NULL,
name1,
name2,
options)!=1)
{
cmp=0;
options->not_cmp=1;
}
/*-------------------------------------------------------------------------
* only attempt to compare if possible
*-------------------------------------------------------------------------
*/
if (cmp)
{
/*-------------------------------------------------------------------------
* read to memory
*-------------------------------------------------------------------------
*/
nelmts1=1;
for (j=0; j<rank1; j++)
nelmts1*=dims1[j];
if ((mtype1_id=h5tools_get_native_type(ftype1_id))<0)
goto error;
if ((mtype2_id=h5tools_get_native_type(ftype2_id))<0)
goto error;
if ((msize1=H5Tget_size(mtype1_id))==0)
goto error;
if ((msize2=H5Tget_size(mtype2_id))==0)
goto error;
assert(msize1==msize2);
buf1=(void *) HDmalloc((unsigned)(nelmts1*msize1));
buf2=(void *) HDmalloc((unsigned)(nelmts1*msize2));
if ( buf1==NULL || buf2==NULL){
printf( "cannot read into memory\n" );
goto error;
}
if (H5Aread(attr1_id,mtype1_id,buf1)<0)
goto error;
if (H5Aread(attr2_id,mtype2_id,buf2)<0)
goto error;
/* format output string */
sprintf(np1,"%s of <%s>",name1,path1);
sprintf(np2,"%s of <%s>",name2,path2);
/*-------------------------------------------------------------------------
* array compare
*-------------------------------------------------------------------------
*/
/* always print name */
if (options->m_verbose)
{
printf( "Attribute: <%s> and <%s>\n",np1,np2);
found = diff_array(buf1,
buf2,
nelmts1,
rank1,
dims1,
options,
np1,
np2,
mtype1_id,
attr1_id,
attr2_id);
print_found(found);
nfound += found;
}
/* check first if we have differences */
else
{
if (options->m_quiet==0)
{
cmp=0;
options->not_cmp=1;
}
/*-------------------------------------------------------------------------
* only attempt to compare if possible
*-------------------------------------------------------------------------
*/
if (cmp)
/* shut up temporarily */
options->m_quiet=1;
found = diff_array(buf1,
buf2,
nelmts1,
rank1,
dims1,
options,
np1,
np2,
mtype1_id,
attr1_id,
attr2_id);
/* print again */
options->m_quiet=0;
if (found)
{
printf( "Attribute: <%s> and <%s>\n",np1,np2);
found = diff_array(buf1,
buf2,
nelmts1,
rank1,
dims1,
options,
np1,
np2,
mtype1_id,
attr1_id,
attr2_id);
print_found(found);
nfound += found;
} /*if*/
} /*if*/
/* in quiet mode, just count differences */
else
{
/*-------------------------------------------------------------------------
* read to memory
*-------------------------------------------------------------------------
*/
nelmts1=1;
for (j=0; j<rank1; j++)
nelmts1*=dims1[j];
if ((mtype1_id=h5tools_get_native_type(ftype1_id))<0)
goto error;
if ((mtype2_id=h5tools_get_native_type(ftype2_id))<0)
goto error;
if ((msize1=H5Tget_size(mtype1_id))==0)
goto error;
if ((msize2=H5Tget_size(mtype2_id))==0)
goto error;
assert(msize1==msize2);
buf1=(void *) HDmalloc((unsigned)(nelmts1*msize1));
buf2=(void *) HDmalloc((unsigned)(nelmts1*msize2));
if ( buf1==NULL || buf2==NULL){
parallel_print( "cannot read into memory\n" );
goto error;
}
if (H5Aread(attr1_id,mtype1_id,buf1)<0)
goto error;
if (H5Aread(attr2_id,mtype2_id,buf2)<0)
goto error;
/* format output string */
sprintf(np1,"%s of <%s>",name1,path1);
sprintf(np2,"%s of <%s>",name2,path2);
/*-------------------------------------------------------------------------
* array compare
*-------------------------------------------------------------------------
*/
/* always print name */
if (options->m_verbose)
{
parallel_print( "Attribute: <%s> and <%s>\n",np1,np2);
nfound = diff_array(buf1,
buf2,
nelmts1,
rank1,
dims1,
options,
np1,
np2,
mtype1_id,
attr1_id,
attr2_id);
print_found(nfound);
}
/* check first if we have differences */
else
{
if (options->m_quiet==0)
{
/* shut up temporarily */
options->m_quiet=1;
nfound = diff_array(buf1,
buf2,
nelmts1,
rank1,
dims1,
options,
np1,
np2,
mtype1_id,
attr1_id,
attr2_id);
/* print again */
options->m_quiet=0;
if (nfound)
{
parallel_print( "Attribute: <%s> and <%s>\n",np1,np2);
nfound = diff_array(buf1,
buf2,
nelmts1,
rank1,
dims1,
options,
np1,
np2,
mtype1_id,
attr1_id,
attr2_id);
print_found(nfound);
} /*if*/
} /*if*/
/* in quiet mode, just count differences */
else
{
nfound = diff_array(buf1,
buf2,
nelmts1,
rank1,
dims1,
options,
np1,
np2,
mtype1_id,
attr1_id,
attr2_id);
} /*else quiet */
} /*else verbose */
found = diff_array(buf1,
buf2,
nelmts1,
rank1,
dims1,
options,
np1,
np2,
mtype1_id,
attr1_id,
attr2_id);
nfound += found;
} /*else quiet */
} /*else verbose */
}/*cmp*/
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
if (H5Tclose(ftype1_id)<0) goto error;
if (H5Tclose(ftype2_id)<0) goto error;
if (H5Tclose(mtype1_id)<0) goto error;
if (H5Tclose(mtype2_id)<0) goto error;
if (H5Sclose(space1_id)<0) goto error;
if (H5Sclose(space2_id)<0) goto error;
if (H5Aclose(attr1_id)<0) goto error;
if (H5Aclose(attr2_id)<0) goto error;
if (buf1)
HDfree(buf1);
if (buf2)
HDfree(buf2);
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
if (H5Tclose(ftype1_id)<0) goto error;
if (H5Tclose(ftype2_id)<0) goto error;
if (H5Tclose(mtype1_id)<0) goto error;
if (H5Tclose(mtype2_id)<0) goto error;
if (H5Sclose(space1_id)<0) goto error;
if (H5Sclose(space2_id)<0) goto error;
if (H5Aclose(attr1_id)<0) goto error;
if (H5Aclose(attr2_id)<0) goto error;
if (buf1)
HDfree(buf1);
if (buf2)
HDfree(buf2);
} /* i */
return ret;
return nfound;
error:
H5E_BEGIN_TRY {
@ -308,7 +317,7 @@ error:
} H5E_END_TRY;
options->err_stat=1;
return 0;
return nfound;
}

View File

@ -438,7 +438,7 @@ hsize_t diff_datasetid( hid_t did1,
*/
if (obj1_name)
diff_attr(did1,did2,obj1_name,obj2_name,options);
nfound += diff_attr(did1,did2,obj1_name,obj2_name,options);
}/*cmp*/

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file1.h5 file2.h5'
#############################
Dataset: </g1/dset1> and </g1/dset1>
4 differences found
4 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file1.h5 file2.h5 g1/dset1 g1/dset2'
#############################
Dataset: </g1/dset1> and </g1/dset2>
4 differences found
4 differences found

View File

@ -9,3 +9,4 @@ position dset1 dset1 difference
[ 1 1 ] 1.000000 1.001000 0.001000
[ 2 0 ] 1.000000 1.000100 0.000100
4 differences found
4 differences found

View File

@ -9,3 +9,4 @@ position dset1 dset2 difference
[ 1 1 ] 1.000000 1.001000 0.001000
[ 2 0 ] 1.000000 1.000100 0.000100
4 differences found
4 differences found

View File

@ -11,3 +11,4 @@ position dset3 dset4 difference
[ 2 0 ] 100.000000 140.000000 40.000000
[ 2 1 ] 100.000000 200.000000 100.000000
6 differences found
6 differences found

View File

@ -11,3 +11,4 @@ position dset3 dset4 difference relative
[ 2 0 ] 100 140 40 0.4
[ 2 1 ] 100 200 100 1
6 differences found
6 differences found

View File

@ -27,3 +27,4 @@ position dset1 dset1 difference
4 differences found
Group: </> and </>
0 differences found
4 differences found

View File

@ -9,3 +9,4 @@ position dset5 dset6 difference relative
[ 2 0 ] 100 150 50 0.500000
[ 2 1 ] 100 200 100 1.000000
4 differences found
4 differences found

View File

@ -9,3 +9,4 @@ position dset7 dset8 difference relative
[ 2 0 ] 100 150 50 0.500000
[ 2 1 ] 100 200 100 1.000000
4 differences found
4 differences found

View File

@ -5,3 +5,4 @@ Comparison not possible: </dset> is of type H5G_DATASET and </g1> is of type H5G
--------------------------------
Some objects are not comparable
--------------------------------
0 differences found

View File

@ -5,3 +5,4 @@ Comparison not possible: </dset> is of type H5G_DATASET and </l1> is of type H5G
--------------------------------
Some objects are not comparable
--------------------------------
0 differences found

View File

@ -5,3 +5,4 @@ Comparison not possible: </dset> is of type H5G_DATASET and </t1> is of type H5G
--------------------------------
Some objects are not comparable
--------------------------------
0 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file3.h5 file3.h5 -v g1 g1'
#############################
Group: </g1> and </g1>
0 differences found
0 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file3.h5 file3.h5 -v t1 t1'
#############################
Datatype: </t1> and </t1>
0 differences found
0 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file3.h5 file3.h5 -v l1 l1'
#############################
Soft Link: </l1> and </l1>
0 differences found
0 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file3.h5 file3.h5 -v g1 g2'
#############################
Group: </g1> and </g2>
1 differences found
1 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file3.h5 file3.h5 -v t1 t2'
#############################
Datatype: </t1> and </t2>
1 differences found
1 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file3.h5 file3.h5 -v l1 l2'
#############################
Soft Link: </l1> and </l2>
1 differences found
1 differences found

View File

@ -12,3 +12,4 @@ position dset0a dset0b difference
[ 2 0 ] 1 5 4
[ 2 1 ] 1 6 5
4 differences found
4 differences found

View File

@ -9,3 +9,4 @@ position dset1a dset1b difference
[ 2 0 ] 1 5 4
[ 2 1 ] 1 6 5
4 differences found
4 differences found

View File

@ -9,3 +9,4 @@ position dset2a dset2b difference
[ 2 0 ] 1 5 4
[ 2 1 ] 1 6 5
4 differences found
4 differences found

View File

@ -9,3 +9,4 @@ position dset3a dset4b difference
[ 2 0 ] 1 5 4
[ 2 1 ] 1 6 5
4 differences found
4 differences found

View File

@ -9,3 +9,4 @@ position dset4a dset4b difference
[ 2 0 ] 1 5 4
[ 2 1 ] 1 6 5
4 differences found
4 differences found

View File

@ -9,3 +9,4 @@ position dset5a dset5b difference
[ 2 0 ] 1.000000 5.000000 4.000000
[ 2 1 ] 1.000000 6.000000 5.000000
4 differences found
4 differences found

View File

@ -9,3 +9,4 @@ position dset6a dset6b difference
[ 2 0 ] 1.000000 5.000000 4.000000
[ 2 1 ] 1.000000 6.000000 5.000000
4 differences found
4 differences found

View File

@ -10,3 +10,4 @@ Comparison not supported: </dset7a> has sign H5T_SGN_2 and </dset7b> has sign H5
--------------------------------
Some objects are not comparable
--------------------------------
0 differences found

View File

@ -11,3 +11,4 @@ point #1 (2,2) (3,3)
point #3 (1,6) (2,5)
point #4 (2,8) (1,7)
4 differences found
4 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file1.h5 file2.h5 -d 1 g1/dset3 g1/dset4'
#############################
Dataset: </g1/dset3> and </g1/dset4>
6 differences found
6 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file1.h5 file2.h5 -d 1 -d 2 g1/dset3 g1/dset4'
#############################
Dataset: </g1/dset3> and </g1/dset4>
6 differences found
6 differences found

View File

@ -1,3 +1,4 @@
#############################
Expected output for 'h5diff file1.h5 file2.h5 -d 200 g1/dset3 g1/dset4'
#############################
0 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file1.h5 file2.h5 -d 1 g1/dset3 g1/dset4'
#############################
Dataset: </g1/dset3> and </g1/dset4>
6 differences found
6 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file1.h5 file2.h5 -p 0.21 g1/dset3 g1/dset4'
#############################
Dataset: </g1/dset3> and </g1/dset4>
2 differences found
2 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file1.h5 file2.h5 -p 0.21 -p 0.22 g1/dset3 g1/dset4'
#############################
Dataset: </g1/dset3> and </g1/dset4>
2 differences found
2 differences found

View File

@ -1,3 +1,4 @@
#############################
Expected output for 'h5diff file1.h5 file2.h5 -p 2 g1/dset3 g1/dset4'
#############################
0 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file1.h5 file2.h5 -p 0.005 g1/dset3 g1/dset4'
#############################
Dataset: </g1/dset3> and </g1/dset4>
6 differences found
6 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file1.h5 file2.h5 -n 2 g1/dset3 g1/dset4'
#############################
Dataset: </g1/dset3> and </g1/dset4>
2 differences found
2 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file1.h5 file2.h5 -n 2 -n 3 g1/dset3 g1/dset4'
#############################
Dataset: </g1/dset3> and </g1/dset4>
3 differences found
3 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file1.h5 file2.h5 -n 200 g1/dset3 g1/dset4'
#############################
Dataset: </g1/dset3> and </g1/dset4>
6 differences found
6 differences found

View File

@ -3,3 +3,4 @@ Expected output for 'h5diff file1.h5 file2.h5 -n 1 g1/dset3 g1/dset4'
#############################
Dataset: </g1/dset3> and </g1/dset4>
1 differences found
1 differences found

View File

@ -1145,3 +1145,4 @@ position float3D of </> float3D of </> difference
--------------------------------
Some objects are not comparable
--------------------------------
912 differences found

View File

@ -729,3 +729,4 @@ Group: </> and </>
--------------------------------
Some objects are not comparable
--------------------------------
495 differences found

View File

@ -1,3 +1,4 @@
#############################
Expected output for 'h5diff file1.h5 file1.h5'
#############################
0 differences found