summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/h5diff/testh5diff.sh5
-rw-r--r--tools/h5diff/testh5diff_basic.c7
-rw-r--r--tools/lib/h5diff_array.c93
-rw-r--r--tools/testfiles/file1.h5bin2192 -> 4368 bytes
-rw-r--r--tools/testfiles/file2.h5bin2192 -> 2192 bytes
-rw-r--r--tools/testfiles/file3.h5bin1408 -> 1408 bytes
-rw-r--r--tools/testfiles/file4.h5bin11040 -> 11040 bytes
-rw-r--r--tools/testfiles/file5.h5bin17624 -> 17624 bytes
-rw-r--r--tools/testfiles/file6.h5bin17624 -> 17624 bytes
-rw-r--r--tools/testfiles/file7.h5bin18616 -> 18616 bytes
-rw-r--r--tools/testfiles/file8.h5bin18616 -> 18616 bytes
-rw-r--r--tools/testfiles/h5diff_17.txt2
-rw-r--r--tools/testfiles/h5diff_192.txt11
13 files changed, 100 insertions, 18 deletions
diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh
index 20b0f9b..4cbad3f 100755
--- a/tools/h5diff/testh5diff.sh
+++ b/tools/h5diff/testh5diff.sh
@@ -276,9 +276,12 @@ TOOLTEST h5diff_17.txt file1.h5 file2.h5 -v
# 1.8 quiet mode
TOOLTEST h5diff_18.txt file1.h5 file2.h5 -q
-# 1.9 with -p (int)
+# 1.9.1 with -p (int)
TOOLTEST h5diff_191.txt file1.h5 file1.h5 -v -p 0.02 g1/dset5 g1/dset6
+# 1.9.2 with -p (unsigned long_long)
+TOOLTEST h5diff_192.txt file1.h5 file1.h5 -v -p 0.02 g1/dset7 g1/dset8
+
# ##############################################################################
# # not comparable types
diff --git a/tools/h5diff/testh5diff_basic.c b/tools/h5diff/testh5diff_basic.c
index 389744d..4a99c84 100644
--- a/tools/h5diff/testh5diff_basic.c
+++ b/tools/h5diff/testh5diff_basic.c
@@ -251,6 +251,8 @@ int test_basic(const char *file1, const char *file2)
double data4[3][2] = {{110,100},{90,80},{140,200}};
int data5[3][2] = {{100,100},{100,100},{100,100}};
int data6[3][2] = {{101,102},{103,104},{150,200}};
+ unsigned long_long data7[3][2] = {{100,100},{100,100},{100,100}};
+ unsigned long_long data8[3][2] = {{101,102},{103,104},{150,200}};
/*-------------------------------------------------------------------------
* Create two files
@@ -271,9 +273,12 @@ int test_basic(const char *file1, const char *file2)
write_dset(group2_id,2,dims,"dset4",H5T_NATIVE_DOUBLE,data4);
write_dset(group2_id,2,dims,"dset1",H5T_NATIVE_DOUBLE,data2);
- /* integer relative */
+ /* relative (int) */
write_dset(group1_id,2,dims,"dset5",H5T_NATIVE_INT,data5);
write_dset(group1_id,2,dims,"dset6",H5T_NATIVE_INT,data6);
+ /* relative (unsigned long_long) */
+ write_dset(group1_id,2,dims,"dset7",H5T_NATIVE_ULLONG,data7);
+ write_dset(group1_id,2,dims,"dset8",H5T_NATIVE_ULLONG,data8);
/*-------------------------------------------------------------------------
* Close
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index ed74fd3..f17a364 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -39,8 +39,8 @@
#define UI_FORMAT_P "%-15u %-15u %-15u %-14f\n"
#define LI_FORMAT_P "%-15ld %-15ld %-15ld %-14f\n"
#define ULI_FORMAT_P "%-15lu %-15lu %-15lu %-14f\n"
-#define LLI_FORMAT_P "%-15"H5_PRINTF_LL_WIDTH"d %-15"H5_PRINTF_LL_WIDTH"d %-15"H5_PRINTF_LL_WIDTH"d %-14"H5_PRINTF_LL_WIDTH"f\n"
-#define ULLI_FORMAT_P "%-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"d %-14"H5_PRINTF_LL_WIDTH"u\n"
+#define LLI_FORMAT_P "%-15"H5_PRINTF_LL_WIDTH"d %-15"H5_PRINTF_LL_WIDTH"d %-15"H5_PRINTF_LL_WIDTH"d %-14f\n"
+#define ULLI_FORMAT_P "%-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"d %-14f\n"
#define SPACES " "
@@ -54,6 +54,8 @@
static void close_obj(H5G_obj_t obj_type, hid_t obj_id);
static int diff_region(hid_t region1_id, hid_t region2_id);
static hbool_t is_zero(const void *_mem, size_t size);
+static int ull2float(unsigned long_long ull_value, float *f_value);
+
/*-------------------------------------------------------------------------
* Function: print_data
@@ -346,7 +348,7 @@ hsize_t diff_datum(void *_mem1,
H5G_stat_t sb2;
hsize_t nfound=0; /* differences found */
int ret=0; /* check return error */
- float per;
+ float f1, f2, per;
type_size = H5Tget_size( m_type );
@@ -1416,7 +1418,10 @@ hsize_t diff_datum(void *_mem1,
/* !-d and -p */
else if (!options->d && options->p)
{
- if ( temp1_ullong!=0 && labs((long)(1-temp2_ullong/temp1_ullong)) > (long)options->percent )
+ ull2float(temp1_ullong,&f1);
+ ull2float(temp2_ullong,&f2);
+ PER(f1,f2);
+ if ( per > options->percent )
{
if ( print_data(options) )
@@ -1425,7 +1430,7 @@ hsize_t diff_datum(void *_mem1,
parallel_print(SPACES);
parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,
(unsigned long_long)labs((long)(temp1_ullong-temp2_ullong)),
- (unsigned long_long)labs((long)(1-temp2_ullong/temp1_ullong)));
+ per);
}
nfound++;
}
@@ -1433,8 +1438,10 @@ hsize_t diff_datum(void *_mem1,
/* -d and -p */
else if ( options->d && options->p)
{
- if ( temp1_ullong!=0 && labs((long)(1-temp2_ullong/temp1_ullong)) > (long)options->percent &&
- labs((long)(temp1_ullong-temp2_ullong)) > (long)options->delta )
+ ull2float(temp1_ullong,&f1);
+ ull2float(temp2_ullong,&f2);
+ PER(f1,f2);
+ if ( per > options->percent && labs((long)(temp1_ullong-temp2_ullong)) > (long)options->delta )
{
if ( print_data(options) )
@@ -1444,7 +1451,7 @@ hsize_t diff_datum(void *_mem1,
parallel_print(SPACES);
parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,
(unsigned long_long)labs((long)(temp1_ullong-temp2_ullong)),
- (unsigned long_long)labs((long)(1-temp2_ullong/temp1_ullong)));
+ per);
}
nfound++;
}
@@ -3528,6 +3535,7 @@ hsize_t diff_llong(unsigned char *mem1,
+
/*-------------------------------------------------------------------------
* Function: diff_ullong
*
@@ -3553,8 +3561,8 @@ hsize_t diff_ullong(unsigned char *mem1,
unsigned long_long temp1_ullong;
unsigned long_long temp2_ullong;
hsize_t i;
-
-
+ float f1, f2, per;
+
/* -d and !-p */
if (options->d && !options->p)
{
@@ -3591,8 +3599,11 @@ hsize_t diff_ullong(unsigned char *mem1,
{
memcpy(&temp1_ullong, mem1, sizeof(unsigned long_long));
memcpy(&temp2_ullong, mem2, sizeof(unsigned long_long));
-
- if ( temp1_ullong!=0 && labs((long)(1-temp2_ullong/temp1_ullong)) > options->percent )
+
+ ull2float(temp1_ullong,&f1);
+ ull2float(temp2_ullong,&f2);
+ PER(f1,f2);
+ if ( per > options->percent )
{
if ( print_data(options) )
{
@@ -3600,7 +3611,7 @@ hsize_t diff_ullong(unsigned char *mem1,
parallel_print(SPACES);
parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,
(unsigned long_long)labs((long)(temp1_ullong-temp2_ullong)),
- (unsigned long_long)labs((long)(1-temp2_ullong/temp1_ullong)));
+ per);
}
nfound++;
}
@@ -3622,8 +3633,10 @@ hsize_t diff_ullong(unsigned char *mem1,
memcpy(&temp1_ullong, mem1, sizeof(unsigned long_long));
memcpy(&temp2_ullong, mem2, sizeof(unsigned long_long));
- if ( temp1_ullong!=0 && labs((long)(1-temp2_ullong/temp1_ullong)) > options->percent &&
- labs((long)(temp1_ullong-temp2_ullong)) > options->delta )
+ ull2float(temp1_ullong,&f1);
+ ull2float(temp2_ullong,&f2);
+ PER(f1,f2);
+ if ( per > options->percent && labs((long)(temp1_ullong-temp2_ullong)) > options->delta )
{
if ( print_data(options) )
{
@@ -3631,7 +3644,7 @@ hsize_t diff_ullong(unsigned char *mem1,
parallel_print(SPACES);
parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,
(unsigned long_long)labs((long)(temp1_ullong-temp2_ullong)),
- (unsigned long_long)labs((long)(1-temp2_ullong/temp1_ullong)));
+ per);
}
nfound++;
}
@@ -3675,4 +3688,52 @@ hsize_t diff_ullong(unsigned char *mem1,
+/*-------------------------------------------------------------------------
+ * Function: ull2float
+ *
+ * Purpose: convert unsigned long_long to float
+ *
+ * Programmer: pvn
+ * Mar 22, 2006
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static
+int ull2float(unsigned long_long ull_value, float *f_value)
+{
+ hid_t dxpl_id;
+ unsigned char *buf;
+ size_t src_size;
+ size_t dst_size;
+
+ if((dxpl_id = H5Pcreate(H5P_DATASET_XFER))<0)
+ goto error;
+
+ src_size = H5Tget_size(H5T_NATIVE_ULLONG);
+ dst_size = H5Tget_size(H5T_NATIVE_FLOAT);
+ buf = (unsigned char*)calloc(1, MAX(src_size, dst_size));
+
+ memcpy(buf, &ull_value, src_size);
+
+ /* do conversion */
+ if(H5Tconvert(H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT, 1, buf, NULL, dxpl_id)<0)
+ goto error;
+
+ memcpy(f_value, buf, dst_size);
+
+ if(buf)
+ free(buf);
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(dxpl_id);
+ } H5E_END_TRY;
+ if(buf)
+ free(buf);
+
+ return -1;
+}
diff --git a/tools/testfiles/file1.h5 b/tools/testfiles/file1.h5
index 4069a04..d9a33ae 100644
--- a/tools/testfiles/file1.h5
+++ b/tools/testfiles/file1.h5
Binary files differ
diff --git a/tools/testfiles/file2.h5 b/tools/testfiles/file2.h5
index 3226343..e2fcaff 100644
--- a/tools/testfiles/file2.h5
+++ b/tools/testfiles/file2.h5
Binary files differ
diff --git a/tools/testfiles/file3.h5 b/tools/testfiles/file3.h5
index 1554d66..91d7297 100644
--- a/tools/testfiles/file3.h5
+++ b/tools/testfiles/file3.h5
Binary files differ
diff --git a/tools/testfiles/file4.h5 b/tools/testfiles/file4.h5
index 714f472..b787c50 100644
--- a/tools/testfiles/file4.h5
+++ b/tools/testfiles/file4.h5
Binary files differ
diff --git a/tools/testfiles/file5.h5 b/tools/testfiles/file5.h5
index 91c64ea..e1d84aa 100644
--- a/tools/testfiles/file5.h5
+++ b/tools/testfiles/file5.h5
Binary files differ
diff --git a/tools/testfiles/file6.h5 b/tools/testfiles/file6.h5
index 08889b0..947f6b3 100644
--- a/tools/testfiles/file6.h5
+++ b/tools/testfiles/file6.h5
Binary files differ
diff --git a/tools/testfiles/file7.h5 b/tools/testfiles/file7.h5
index c792216..f949b68 100644
--- a/tools/testfiles/file7.h5
+++ b/tools/testfiles/file7.h5
Binary files differ
diff --git a/tools/testfiles/file8.h5 b/tools/testfiles/file8.h5
index 8f4af70..6880e8f 100644
--- a/tools/testfiles/file8.h5
+++ b/tools/testfiles/file8.h5
Binary files differ
diff --git a/tools/testfiles/h5diff_17.txt b/tools/testfiles/h5diff_17.txt
index 88047c9..5445e97 100644
--- a/tools/testfiles/h5diff_17.txt
+++ b/tools/testfiles/h5diff_17.txt
@@ -11,6 +11,8 @@ file1 file2
x /g1/dset4
x /g1/dset5
x /g1/dset6
+ x /g1/dset7
+ x /g1/dset8
x /g2
Group: </g1> and </g1>
diff --git a/tools/testfiles/h5diff_192.txt b/tools/testfiles/h5diff_192.txt
new file mode 100644
index 0000000..9e44bd0
--- /dev/null
+++ b/tools/testfiles/h5diff_192.txt
@@ -0,0 +1,11 @@
+#############################
+Expected output for 'h5diff file1.h5 file1.h5 -v -p 0.02 g1/dset7 g1/dset8'
+#############################
+Dataset: </g1/dset7> and </g1/dset8>
+position dset7 dset8 difference relative
+------------------------------------------------------------------------
+[ 1 0 ] 100 103 3 0.030000
+[ 1 1 ] 100 104 4 0.040000
+[ 2 0 ] 100 150 50 0.500000
+[ 2 1 ] 100 200 100 1.000000
+4 differences found