summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorPeter Cao <xcao@hdfgroup.org>2011-07-15 23:02:50 (GMT)
committerPeter Cao <xcao@hdfgroup.org>2011-07-15 23:02:50 (GMT)
commit877b7aed1b543d2e7fde2d9c2c2eda325d3894c0 (patch)
tree9eaa4845a0a330a3f73ebb6b2cd995232c61898a /tools/lib
parentdc9288a44706fa89558d218325f34dbfdad31d07 (diff)
downloadhdf5-877b7aed1b543d2e7fde2d9c2c2eda325d3894c0.zip
hdf5-877b7aed1b543d2e7fde2d9c2c2eda325d3894c0.tar.gz
hdf5-877b7aed1b543d2e7fde2d9c2c2eda325d3894c0.tar.bz2
[svn-r21105] Fixed two bugs:
- h5repack: h5repack failed to copy dataset if the layout is changed from chunked with unlimited dims to contiguous. (PC -- 2011/07/15) - h5diff: "--delta" option considers two NaN of the same type are different, which is wrong based on http://www.hdfgroup.org/HDF5/doc/RM/Tools.html#Tools-Diff. (PC -- 2011/07/15)
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff_array.c132
-rw-r--r--tools/lib/h5diff_dset.c7
2 files changed, 83 insertions, 56 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 6c5744f..ecfc238 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -234,11 +234,11 @@ hsize_t diff_array( void *_mem1,
size = H5Tget_size( m_type );
type_class = H5Tget_class(m_type);
- /* Fast comparison first for atomic type by memcmp().
+ /* Fast comparison first for atomic type by memcmp().
* It is OK not to list non-atomic type here because it will not be caught
- * by the confition, but it gives more clarity for code planning
+ * by the condition, but it gives more clarity for code planning
*/
- if (type_class != H5T_REFERENCE &&
+ if (type_class != H5T_REFERENCE &&
type_class != H5T_COMPOUND &&
type_class != H5T_STRING &&
type_class != H5T_VLEN &&
@@ -269,7 +269,6 @@ hsize_t diff_array( void *_mem1,
*/
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))
@@ -427,11 +426,11 @@ hsize_t diff_datum(void *_mem1,
type_size = H5Tget_size( m_type );
type_class = H5Tget_class(m_type);
- /* Fast comparison first for atomic type by memcmp().
+ /* Fast comparison first for atomic type by memcmp().
* It is OK not to list non-atomic type here because it will not be caught
- * by the confition, but it gives more clarity for code planning
+ * by the confition, but it gives more clarity for code planning
*/
- if (type_class != H5T_REFERENCE &&
+ if (type_class != H5T_REFERENCE &&
type_class != H5T_COMPOUND &&
type_class != H5T_STRING &&
type_class != H5T_VLEN &&
@@ -513,10 +512,10 @@ hsize_t diff_datum(void *_mem1,
size2 = H5Tget_size(m_type);
}
- /*
+ /*
* compare for shorter string
- * TODO: this code need to be improved to handle the difference
- * of length of strings.
+ * TODO: this code need to be improved to handle the difference
+ * of length of strings.
* For now mimic the previous way.
*/
if(size1 < size2)
@@ -622,7 +621,7 @@ hsize_t diff_datum(void *_mem1,
char enum_name2[1024];
herr_t err1;
- herr_t err2;
+ herr_t err2;
/* disable error reporting */
H5E_BEGIN_TRY {
@@ -1946,8 +1945,8 @@ hsize_t diff_datum(void *_mem1,
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -2009,8 +2008,8 @@ hsize_t diff_datum(void *_mem1,
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -2075,8 +2074,8 @@ hsize_t diff_datum(void *_mem1,
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -2131,7 +2130,6 @@ hsize_t diff_datum(void *_mem1,
*/
if (options->d && !options->p)
{
-
/*-------------------------------------------------------------------------
* detect NaNs
*-------------------------------------------------------------------------
@@ -2158,8 +2156,8 @@ hsize_t diff_datum(void *_mem1,
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -2223,8 +2221,8 @@ hsize_t diff_datum(void *_mem1,
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -2289,8 +2287,8 @@ hsize_t diff_datum(void *_mem1,
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -2299,7 +2297,6 @@ hsize_t diff_datum(void *_mem1,
parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
}
nfound++;
-
}
}
@@ -2373,8 +2370,18 @@ hsize_t diff_datum(void *_mem1,
}
nfound++;
}
-
} /* NaN */
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ {
+ 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++;
+ }
}
/*-------------------------------------------------------------------------
@@ -2428,7 +2435,18 @@ hsize_t diff_datum(void *_mem1,
}
} /* NaN */
- }
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ {
+ 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
@@ -2482,6 +2500,17 @@ hsize_t diff_datum(void *_mem1,
}
} /* NaN */
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ {
+ 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++;
+ }
}
/*-------------------------------------------------------------------------
@@ -2973,8 +3002,8 @@ hsize_t diff_float(unsigned char *mem1,
nfound++;
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -3045,8 +3074,8 @@ hsize_t diff_float(unsigned char *mem1,
nfound++;
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -3120,8 +3149,8 @@ hsize_t diff_float(unsigned char *mem1,
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -3210,7 +3239,6 @@ hsize_t diff_double(unsigned char *mem1,
int isnan1=0;
int isnan2=0;
-
/*-------------------------------------------------------------------------
* -d and !-p
*-------------------------------------------------------------------------
@@ -3247,8 +3275,8 @@ hsize_t diff_double(unsigned char *mem1,
nfound++;
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -3319,8 +3347,8 @@ hsize_t diff_double(unsigned char *mem1,
nfound++;
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -3394,8 +3422,8 @@ hsize_t diff_double(unsigned char *mem1,
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -3530,8 +3558,8 @@ hsize_t diff_ldouble(unsigned char *mem1,
nfound++;
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -3602,8 +3630,8 @@ hsize_t diff_ldouble(unsigned char *mem1,
nfound++;
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -3677,8 +3705,8 @@ hsize_t diff_ldouble(unsigned char *mem1,
}
}
- /* one is NaN, assume difference */
- else if ( isnan1==1 || isnan2==1)
+ /* only one is NaN, assume difference */
+ else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
{
if ( print_data(options) )
{
@@ -6107,13 +6135,13 @@ static void set_comp_members(hid_t tid, mcomp_t *members)
members->flags = HDcalloc(members->n, sizeof(unsigned char));
members->offsets = HDcalloc(members->n, sizeof(size_t));
members->m = HDcalloc(members->n, sizeof(mcomp_t *));
-
- for (i=0; i< members->n; i++)
+
+ for (i=0; i< members->n; i++)
{
members->ids[i] = H5Tget_member_type( tid, i );
members->flags[i] = H5Tis_variable_str( members->ids[i] );
members->offsets[i] = H5Tget_member_offset( tid, i );
- if (H5Tget_class( members->ids[i])==H5T_COMPOUND)
+ if (H5Tget_class( members->ids[i])==H5T_COMPOUND)
{
members->m[i] = (mcomp_t *)HDmalloc(sizeof(mcomp_t));
set_comp_members(members->ids[i], members->m[i]);
@@ -6126,16 +6154,16 @@ static void set_comp_members(hid_t tid, mcomp_t *members)
* added to improve performance for compound datasets
* clean and close compound members.
*/
-static void free_comp_members(mcomp_t *members)
+static void free_comp_members(mcomp_t *members)
{
int i;
if (!members || members->n<=0 || !members->ids)
return;
- for (i=0; i<members->n; i++)
+ for (i=0; i<members->n; i++)
{
- if (members->m[i])
+ if (members->m[i])
{
free_comp_members(members->m[i]);
HDfree(members->m[i]);
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index 230e7bb..c26c766 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -327,7 +327,7 @@ hsize_t diff_datasetid( hid_t did1,
can_compare=0;
options->not_cmp=1;
}
-
+
/* Check if type is either VLEN-data or VLEN-string to reclaim any
* VLEN memory buffer later */
if( TRUE == h5tools_detect_vlen(m_tid1) )
@@ -390,7 +390,6 @@ hsize_t diff_datasetid( hid_t did1,
* read/compare
*-------------------------------------------------------------------------
*/
-
need = (size_t)(nelmts1 * m_size1); /* bytes needed */
if(need < H5TOOLS_MALLOCSIZE) {
buf1 = HDmalloc(need);
@@ -562,7 +561,7 @@ error:
if (buf1!=NULL)
{
/* reclaim any VL memory, if necessary */
- if(vl_data)
+ if(vl_data)
H5Dvlen_reclaim(m_tid1, sid1, H5P_DEFAULT, buf1);
free(buf1);
buf1=NULL;
@@ -570,7 +569,7 @@ error:
if (buf2!=NULL)
{
/* reclaim any VL memory, if necessary */
- if(vl_data)
+ if(vl_data)
H5Dvlen_reclaim(m_tid2, sid2, H5P_DEFAULT, buf2);
free(buf2);
buf2=NULL;