summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2004-01-16 15:31:55 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2004-01-16 15:31:55 (GMT)
commitefbde3c2f3555df156c8b4ed42fcf9e98b5b16ef (patch)
tree1199e2cabf76e857b576a858675de101a98ba4ad /tools/lib
parent5112a79d81b500bc1fa9cad9580afb7de029ab0c (diff)
downloadhdf5-efbde3c2f3555df156c8b4ed42fcf9e98b5b16ef.zip
hdf5-efbde3c2f3555df156c8b4ed42fcf9e98b5b16ef.tar.gz
hdf5-efbde3c2f3555df156c8b4ed42fcf9e98b5b16ef.tar.bz2
[svn-r8074] Purpose:
added h5repack and h5diff support for copying and differences of references to dataset regions modified the behaviour in the diff of attributes, when a difference in name is detected in the attribute cycle (number of attributes of object), instead of exiting the cycle, rather continue Description: Solution: Platforms tested: linux solaris AIX Misc. update:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff.c4
-rw-r--r--tools/lib/h5diff_array.c157
-rw-r--r--tools/lib/h5diff_attr.c6
3 files changed, 147 insertions, 20 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index eeabd8c..38acf82 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -58,12 +58,12 @@ int h5diff(const char *fname1,
/* Open the files */
if ((file1_id=H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT))<0 )
{
- printf("h5diff: %s: No such file or directory\n", fname1 );
+ printf("h5diff: <%s>: unable to open file\n", fname1 );
nfound = -1;
}
if ((file2_id=H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT))<0 )
{
- printf("h5diff: %s: No such file or directory\n", fname2 );
+ printf("h5diff: <%s>: unable to open file\n", fname2 );
nfound = -1;
}
/* enable error reporting */
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 10bba40..90a50cd 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -19,8 +19,7 @@
#include <math.h>
-static
-int diff_datum( void *_mem1,
+static int diff_datum(void *_mem1,
void *_mem2,
hid_t m_type,
hsize_t i,
@@ -34,8 +33,7 @@ int diff_datum( void *_mem1,
hid_t container2_id,
int *ph);
-static
-int diff_native_uchar(unsigned char *mem1,
+static int diff_native_uchar(unsigned char *mem1,
unsigned char *mem2,
size_t type_size,
hsize_t i,
@@ -47,8 +45,7 @@ int diff_native_uchar(unsigned char *mem1,
const char *obj2,
int *ph);
-static
-int diff_char(unsigned char *mem1,
+static int diff_char(unsigned char *mem1,
unsigned char *mem2,
size_t type_size,
hsize_t i,
@@ -60,10 +57,10 @@ int diff_char(unsigned char *mem1,
const char *obj2,
int *ph);
-static
-hbool_t is_zero(const void *_mem, size_t size);
-static
-void close_obj(H5G_obj_t obj_type, hid_t obj_id);
+static hbool_t is_zero(const void *_mem, size_t size);
+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);
+
/*-------------------------------------------------------------------------
@@ -509,6 +506,9 @@ int diff_datum( void *_mem1,
if (H5Tequal(m_type, H5T_STD_REF_DSETREG))
{
+ hid_t region1_id;
+ hid_t region2_id;
+
if ((obj1_id = H5Rdereference(container1_id, H5R_DATASET_REGION, _mem1))<0)
return -1;
if ((obj2_id = H5Rdereference(container2_id, H5R_DATASET_REGION, _mem2))<0)
@@ -517,17 +517,21 @@ int diff_datum( void *_mem1,
return -1;
if (H5Gget_objinfo(obj2_id, ".", FALSE, &sb2)<0)
return -1;
+ if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1))<0)
+ return -1;
+ if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2))<0)
+ return -1;
- /* compare OID */
- if (sb1.objno!=sb2.objno)
+ if (diff_region(region1_id,region2_id))
{
- HDfprintf(stdout,"Different OIDs in reference: <%s, %Hu> and <%s, %Hu>",
- obj1, sb1.objno, obj2, sb2.objno);
- nfound = 1;
+ printf("Different region referenced\n");
}
+
close_obj(H5G_DATASET,obj1_id);
close_obj(H5G_DATASET,obj2_id);
-
+ H5Sclose(region1_id);
+ H5Sclose(region2_id);
+
}/*dataset reference*/
@@ -1699,3 +1703,124 @@ void close_obj(H5G_obj_t obj_type, hid_t obj_id)
}
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: diff_region
+ *
+ * Purpose: diff a dataspace region
+ *
+ * Return: 0, diff not found, 1 found
+ *
+ *-------------------------------------------------------------------------
+ */
+static int diff_region(hid_t region1_id, hid_t region2_id)
+{
+ hssize_t nblocks1, npoints1;
+ hssize_t nblocks2, npoints2;
+ hsize_t alloc_size;
+ hsize_t *ptdata1;
+ hsize_t *ptdata2;
+ int ndims1 = H5Sget_simple_extent_ndims(region1_id);
+ int ndims2 = H5Sget_simple_extent_ndims(region2_id);
+ int ret=0;
+
+#if defined (H5DIFF_DEBUG)
+ int i;
+#endif
+
+/*
+ * These two functions fail if the region does not have blocks or points,
+ * respectively. They do not currently know how to translate from one to
+ * the other.
+ */
+ H5E_BEGIN_TRY {
+ nblocks1 = H5Sget_select_hyper_nblocks(region1_id);
+ nblocks2 = H5Sget_select_hyper_nblocks(region2_id);
+
+ npoints1 = H5Sget_select_elem_npoints(region1_id);
+ npoints2 = H5Sget_select_elem_npoints(region2_id);
+ } H5E_END_TRY;
+
+ if (nblocks1!=nblocks2 || npoints1!=npoints2 || ndims1!=ndims2)
+ return 1;
+
+ /* compare block information */
+ if (nblocks1 > 0)
+ {
+
+ alloc_size = nblocks1 * ndims1 * 2 * sizeof(ptdata1[0]);
+ assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
+
+ ptdata1 = malloc((size_t)alloc_size);
+ H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t);
+ H5Sget_select_hyper_blocklist(region1_id, (hsize_t)0, (hsize_t)nblocks1, ptdata1);
+
+ ptdata2 = malloc((size_t)alloc_size);
+ H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t);
+ H5Sget_select_hyper_blocklist(region2_id, (hsize_t)0, (hsize_t)nblocks2, ptdata2);
+
+ ret=HDmemcmp(ptdata1,ptdata2,(size_t)alloc_size);
+
+#if defined (H5DIFF_DEBUG)
+ for (i = 0; i < nblocks1; i++)
+ {
+ int j;
+
+ /* start coordinates and opposite corner */
+ for (j = 0; j < ndims1; j++)
+ printf("%s%lu", j ? "," : "(",
+ (unsigned long)ptdata1[i * 2 * ndims1 + j]);
+
+ for (j = 0; j < ndims1; j++)
+ printf("%s%lu", j ? "," : ")-(",
+ (unsigned long)ptdata1[i * 2 * ndims1 + j + ndims1]);
+
+ printf(")\n");
+ }
+#endif
+
+
+ HDfree(ptdata1);
+ HDfree(ptdata2);
+ }
+
+ /* Print point information */
+ if (npoints1 > 0)
+ {
+ alloc_size = npoints1 * ndims1 * sizeof(ptdata1[0]);
+ assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
+
+ ptdata1 = malloc((size_t)alloc_size);
+ H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t);
+ H5Sget_select_elem_pointlist(region1_id, (hsize_t)0, (hsize_t)npoints1, ptdata1);
+
+ ptdata2 = malloc((size_t)alloc_size);
+ H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t);
+ H5Sget_select_elem_pointlist(region2_id, (hsize_t)0, (hsize_t)npoints2, ptdata2);
+
+ ret=HDmemcmp(ptdata1,ptdata2,(size_t)alloc_size);
+
+#if defined (H5DIFF_DEBUG)
+ for (i = 0; i < npoints1; i++)
+ {
+ int j;
+
+ printf("%sPt%lu: " ,
+ i ? "," : "",
+ (unsigned long)i);
+
+ for (j = 0; j < ndims1; j++)
+ printf("%s%lu", j ? "," : "(",
+ (unsigned long)(ptdata1[i * ndims1 + j]));
+
+ printf(")");
+ }
+#endif
+
+ HDfree(ptdata1);
+ HDfree(ptdata2);
+ }
+
+ return ret;
+} \ No newline at end of file
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index c1dc945..ed051f8 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -65,6 +65,7 @@ int diff_attr(hid_t loc1_id,
char name1[255];
char name2[255];
int n1, n2, i, j, nfound;
+ int ret=0;
if ((n1 = H5Aget_num_attrs(loc1_id))<0)
goto error;
@@ -105,7 +106,8 @@ int diff_attr(hid_t loc1_id,
}
H5Aclose(attr1_id);
H5Aclose(attr2_id);
- return 1;
+ ret=1;
+ continue;
}
/* get the file datatype */
@@ -218,7 +220,7 @@ int diff_attr(hid_t loc1_id,
HDfree(buf2);
} /* i */
- return 0;
+ return ret;
error:
H5E_BEGIN_TRY {