summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5diff_array.c
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2008-04-30 19:51:13 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2008-04-30 19:51:13 (GMT)
commitaec106e324ce20e5efb725c25a6a333c7970127b (patch)
tree234df369115a46b08037c5f385061cf58823e497 /tools/lib/h5diff_array.c
parent5773fd34bc5adf59b4530d95ac9f0c0585902803 (diff)
downloadhdf5-aec106e324ce20e5efb725c25a6a333c7970127b.zip
hdf5-aec106e324ce20e5efb725c25a6a333c7970127b.tar.gz
hdf5-aec106e324ce20e5efb725c25a6a333c7970127b.tar.bz2
[svn-r14903] Undoing change committed in r14902.
Diffstat (limited to 'tools/lib/h5diff_array.c')
-rw-r--r--tools/lib/h5diff_array.c276
1 files changed, 160 insertions, 116 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 008b6b9..c5646ed 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -119,7 +119,7 @@ static int not_comparable;
is_zero=1; \
}
-# define PDIFF(a,b) ( (b>a) ? (b-a) : (a-b))
+#define PDIFF(a,b) ( (b>a) ? (b-a) : (a-b))
/*-------------------------------------------------------------------------
* local prototypes
@@ -127,11 +127,12 @@ static int not_comparable;
*/
static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id,hid_t region1_id, hid_t region2_id, diff_opt_t *options);
static hbool_t all_zero(const void *_mem, size_t size);
-static int ull2float(unsigned long_long ull_value, float *f_value);
static hsize_t character_compare(unsigned char *mem1,unsigned char *mem2,hsize_t i,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
static hsize_t character_compare_opt(unsigned char *mem1,unsigned char *mem2,hsize_t i,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
static hbool_t equal_float(float value, float expected);
static hbool_t equal_double(double value, double expected);
+static int ull2float(unsigned long_long ull_value, float *f_value);
+
/*-------------------------------------------------------------------------
* NaN detection
@@ -266,8 +267,6 @@ hsize_t diff_array( void *_mem1,
size_t size; /* size of datum */
unsigned char *mem1 = (unsigned char*)_mem1;
unsigned char *mem2 = (unsigned char*)_mem2;
- unsigned char *tmp1;
- unsigned char *tmp2;
hsize_t acc[32]; /* accumulator position */
hsize_t pos[32]; /* matrix position */
int ph=1; /* print header */
@@ -288,23 +287,26 @@ hsize_t diff_array( void *_mem1,
if(H5Tis_variable_str(m_type))
{
- tmp1 = ((unsigned char**)mem1)[0];
- tmp2 = ((unsigned char**)mem2)[0];
- nfound+=diff_datum(
- tmp1,
- tmp2,
- m_type,
- (hsize_t)0,
- rank,
- dims,
- acc,
- pos,
- options,
- name1,
- name2,
- container1_id,
- container2_id,
- &ph);
+ for ( i = 0; i < nelmts; i++)
+ {
+ nfound+=diff_datum(
+ ((unsigned char**)mem1)[(size_t)i],
+ ((unsigned char**)mem2)[(size_t)i],
+ m_type,
+ i,
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ name1,
+ name2,
+ container1_id,
+ container2_id,
+ &ph);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* i */
}
else
@@ -515,42 +517,35 @@ hsize_t diff_datum(void *_mem1,
case H5T_STRING:
{
-
H5T_str_t pad;
char *s;
- if(H5Tis_variable_str(m_type))
- {
- /* mem1 is the pointer into the struct where a `char*' is stored. So we have
- * to dereference the pointer to get the `char*' to pass to HDstrlen(). */
- s = *(char**)mem1;
- if(s!=NULL)
- size = HDstrlen(s);
- }
- else
- {
- s = (char *)mem1;
- size = H5Tget_size(m_type);
- }
-
- pad = H5Tget_strpad(m_type);
-
+ /* Get pointer to first string to compare */
+ s = (char *)mem1;
+
/* check for NULL pointer for string */
if(s!=NULL)
{
+ if(H5Tis_variable_str(m_type))
+ size = HDstrlen(s);
+ else
+ size = H5Tget_size(m_type);
+
+ pad = H5Tget_strpad(m_type);
+
for (u=0; u<size && (s[u] || pad!=H5T_STR_NULLTERM); u++)
nfound+=character_compare(
- mem1 + u,
- mem2 + u, /* offset */
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
+ mem1 + u,
+ mem2 + u, /* offset */
+ i, /* index position */
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ ph);
}
}
@@ -697,7 +692,6 @@ hsize_t diff_datum(void *_mem1,
H5Tclose(memb_type);
}
break;
-
/*-------------------------------------------------------------------------
@@ -2867,7 +2861,6 @@ hsize_t diff_float(unsigned char *mem1,
}
-
/*-------------------------------------------------------------------------
* Function: diff_double
*
@@ -2897,80 +2890,111 @@ hsize_t diff_double(unsigned char *mem1,
hsize_t i;
double per;
int both_zero;
+ int isnan1;
+ int isnan2;
-
- /* -d and !-p */
+
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
+
if (options->d && !options->p)
{
-
for ( i = 0; i < nelmts; i++)
{
memcpy(&temp1_double, mem1, sizeof(double));
memcpy(&temp2_double, mem2, sizeof(double));
-
- if (ABS(temp1_double-temp2_double) > options->delta)
- {
- if ( print_data(options) )
+
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
+
+ if ( !isnan1 && !isnan2)
+ {
+ if (ABS(temp1_double-temp2_double) > options->delta)
{
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
+ }
+ nfound++;
}
- nfound++;
- }
+ } /* NaN */
mem1+=sizeof(double);
mem2+=sizeof(double);
if (options->n && nfound>=options->count)
return nfound;
- }
+ } /* i */
}
-
- /* !-d and -p */
+
+ /*-------------------------------------------------------------------------
+ * !-d and -p
+ *-------------------------------------------------------------------------
+ */
else if (!options->d && options->p)
{
-
for ( i = 0; i < nelmts; i++)
{
memcpy(&temp1_double, mem1, sizeof(double));
memcpy(&temp2_double, mem2, sizeof(double));
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- options->not_cmp=1;
- nfound++;
- }
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
- else
+ if ( !isnan1 && !isnan2)
+ {
+
+ PER(temp1_double,temp2_double);
- if ( per > options->percent )
+ if (not_comparable && !both_zero) /* not comparable */
{
if ( print_data(options) )
{
print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
+ parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
+ ABS(temp1_double-temp2_double));
}
+ options->not_cmp=1;
nfound++;
}
- mem1+=sizeof(double);
- mem2+=sizeof(double);
- if (options->n && nfound>=options->count)
- return nfound;
- }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P,temp1_double,temp2_double,
+ ABS(temp1_double-temp2_double),
+ ABS(1-temp2_double/temp1_double));
+ }
+ nfound++;
+ }
+ } /* NaN */
+ mem1+=sizeof(double);
+ mem2+=sizeof(double);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* i */
}
- /* -d and -p */
+ /*-------------------------------------------------------------------------
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
else if ( options->d && options->p)
{
@@ -2979,41 +3003,58 @@ hsize_t diff_double(unsigned char *mem1,
memcpy(&temp1_double, mem1, sizeof(double));
memcpy(&temp2_double, mem2, sizeof(double));
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- options->not_cmp=1;
- nfound++;
- }
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
- else
+ if ( !isnan1 && !isnan2)
+ {
+
+ PER(temp1_double,temp2_double);
- if ( per > options->percent && ABS(temp1_double-temp2_double) > options->delta )
+ if (not_comparable && !both_zero) /* not comparable */
{
if ( print_data(options) )
{
print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
+ parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
+ ABS(temp1_double-temp2_double));
}
+ options->not_cmp=1;
nfound++;
}
- mem1+=sizeof(double);
- mem2+=sizeof(double);
- if (options->n && nfound>=options->count)
- return nfound;
- }
+
+ else
+
+ if ( per > options->percent && ABS(temp1_double-temp2_double) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P,temp1_double,temp2_double,
+ ABS(temp1_double-temp2_double),
+ ABS(1-temp2_double/temp1_double));
+ }
+ nfound++;
+ }
+
+ } /* NaN */
+ mem1+=sizeof(double);
+ mem2+=sizeof(double);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* i */
}
+
+ /*-------------------------------------------------------------------------
+ * no -d and -p
+ *-------------------------------------------------------------------------
+ */
else
{
@@ -3044,6 +3085,9 @@ hsize_t diff_double(unsigned char *mem1,
return nfound;
}
+
+
+
/*-------------------------------------------------------------------------
* Function: diff_schar
*