summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff_array.c114
-rw-r--r--tools/lib/h5diff_attr.c21
-rw-r--r--tools/lib/h5diff_dset.c428
-rw-r--r--tools/lib/h5tools.c4
-rw-r--r--tools/lib/h5tools.h4
-rw-r--r--tools/lib/h5tools_type.c32
6 files changed, 269 insertions, 334 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 49f41dc..499d5eb 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -623,6 +623,7 @@ static hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
case H5T_COMPOUND:
+ h5difftrace("diff_datum H5T_COMPOUND\n");
nmembs = members->n;
@@ -655,18 +656,21 @@ static hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
case H5T_STRING:
-
+ h5difftrace("diff_datum H5T_STRING\n");
{
- H5T_str_t pad;
- char *s;
- char *s1;
- char *s2;
- size_t size1;
- size_t size2;
+ char *s = NULL;
+ char *sx = NULL;
+ char *s1 = NULL;
+ char *s2 = NULL;
+ size_t size1;
+ size_t size2;
+ size_t sizex;
+ size_t size_mtype = H5Tget_size(m_type);
+ H5T_str_t pad = H5Tget_strpad(m_type);
/* if variable length string */
- if(H5Tis_variable_str(m_type))
- {
+ if(H5Tis_variable_str(m_type)) {
+ h5difftrace("diff_datum H5T_STRING variable\n");
/* Get pointer to first string */
s1 = *(char**) mem1;
size1 = HDstrlen(s1);
@@ -674,14 +678,26 @@ static hsize_t diff_datum(void *_mem1,
s2 = *(char**) mem2;
size2 = HDstrlen(s2);
}
- else
- {
+ else if (H5T_STR_NULLTERM == pad) {
+ h5difftrace("diff_datum H5T_STRING null term\n");
+ /* Get pointer to first string */
+ s1 = (char*) mem1;
+ size1 = HDstrlen(s1);
+ if (size1 > size_mtype)
+ size1 = size_mtype;
+ /* Get pointer to second string */
+ s2 = (char*) mem2;
+ size2 = HDstrlen(s2);
+ if (size2 > size_mtype)
+ size2 = size_mtype;
+ }
+ else {
/* Get pointer to first string */
s1 = (char *)mem1;
- size1 = H5Tget_size(m_type);
+ size1 = size_mtype;
/* Get pointer to second string */
s2 = (char *)mem2;
- size2 = H5Tget_size(m_type);
+ size2 = size_mtype;
}
/*
@@ -692,45 +708,59 @@ static hsize_t diff_datum(void *_mem1,
*/
h5diffdebug2("diff_datum string size:%d\n",size1);
h5diffdebug2("diff_datum string size:%d\n",size2);
- if(size1 != size2)
- {
+ if(size1 != size2) {
h5difftrace("diff_datum string sizes\n");
nfound++;
}
- if(size1 < size2)
- {
+ if(size1 < size2) {
size = size1;
s = s1;
+ sizex = size2;
+ sx = s2;
}
- else
- {
+ else {
size = size2;
s = s2;
+ sizex = size1;
+ sx = s1;
}
/* check for NULL pointer for string */
- if(s!=NULL)
- {
+ if(s!=NULL) {
/* try fast compare first */
- if (HDmemcmp(s1, s2, size)==0)
- break;
-
- pad = H5Tget_strpad(m_type);
-
- for (u=0; u<size; u++)
- nfound+=character_compare(
- s1 + u,
- s2 + u, /* offset */
- i, /* index position */
- u, /* string character position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
+ if(HDmemcmp(s1, s2, size)==0) {
+ if(size1 != size2)
+ if(print_data(options))
+ for (u=size; u<sizex; u++)
+ character_compare(
+ s1 + u,
+ s2 + u, /* offset */
+ i, /* index position */
+ u, /* string character position */
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ ph);
+ }
+ else
+ for (u=0; u<size; u++)
+ nfound+=character_compare(
+ s1 + u,
+ s2 + u, /* offset */
+ i, /* index position */
+ u, /* string character position */
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ ph);
}
}
@@ -741,6 +771,7 @@ static hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
case H5T_BITFIELD:
+ h5difftrace("diff_datum H5T_BITFIELD\n");
/* byte-by-byte comparison */
for (u=0; u<type_size; u++)
@@ -764,7 +795,7 @@ static hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
case H5T_OPAQUE:
-
+ h5difftrace("diff_datum H5T_OPAQUE\n");
/* byte-by-byte comparison */
for (u=0; u<type_size; u++)
nfound+=character_compare_opt(
@@ -788,6 +819,7 @@ static hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
case H5T_ENUM:
+ h5difftrace("diff_datum H5T_ENUM\n");
/* For enumeration types we compare the names instead of the
integer values. For each pair of elements being
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 004672e..74607da 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -91,7 +91,7 @@ static void table_attrs_free( table_attrs_t *table )
/*-------------------------------------------------------------------------
* Function: table_attr_mark_exist
*
- * Purpose: mark given attribute name to table as sign of exsit
+ * Purpose: mark given attribute name to table as sign of exist
*
* Parameter:
* - exist [IN]
@@ -155,6 +155,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
unsigned i;
table_attrs_t *table_lp = NULL;
+ h5difftrace("build_match_list_attrs start\n");
if(H5Oget_info(loc1_id, &oinfo1) < 0)
goto error;
if(H5Oget_info(loc2_id, &oinfo2) < 0)
@@ -162,6 +163,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
table_attrs_init( &table_lp );
+ h5diffdebug3("build_match_list_attrs: %ld - %ld\n", curr1 < oinfo1.num_attrs, curr2 < oinfo2.num_attrs);
/*--------------------------------------------------
* build the list
@@ -226,6 +228,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
/* get name */
if(H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0)
goto error;
+ h5diffdebug2("build_match_list_attrs #1 name - %s\n", name1);
table_attr_mark_exist(infile, name1, table_lp);
table_lp->nattrs_only1++;
@@ -247,6 +250,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
/* get name */
if(H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0)
goto error;
+ h5diffdebug2("build_match_list_attrs #2 name - %s\n", name2);
table_attr_mark_exist(infile, name2, table_lp);
table_lp->nattrs_only2++;
@@ -278,6 +282,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
*table_out = table_lp;
+ h5difftrace("build_match_list_attrs end\n");
return 0;
error:
@@ -286,6 +291,7 @@ error:
if (0 < attr2_id)
H5Aclose(attr2_id);
+ h5difftrace("build_match_list_attrs end with error\n");
return -1;
}
@@ -322,8 +328,8 @@ hsize_t diff_attr(hid_t loc1_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 */
- int vstrtype1=0; /* ftype1 is a variable string */
- int vstrtype2=0; /* ftype2 is a variable string */
+ int vstrtype1=0; /* ftype1 is a variable string */
+ int vstrtype2=0; /* ftype2 is a variable string */
hid_t mtype1_id=-1; /* memory data type ID */
hid_t mtype2_id=-1; /* memory data type ID */
size_t msize1; /* memory size of memory type */
@@ -346,12 +352,15 @@ hsize_t diff_attr(hid_t loc1_id,
hsize_t nfound_total = 0;
int j;
- table_attrs_t * match_list_attrs = NULL;
+ table_attrs_t *match_list_attrs = NULL;
+ h5difftrace("diff_attr start\n");
+
if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, options) < 0)
goto error;
/* if detect any unique extra attr */
if(match_list_attrs->nattrs_only1 || match_list_attrs->nattrs_only2) {
+ h5difftrace("diff_attr attributes only in one file\n");
/* exit will be 1 */
options->contents = 0;
}
@@ -359,6 +368,7 @@ hsize_t diff_attr(hid_t loc1_id,
for(u = 0; u < (unsigned)match_list_attrs->nattrs; u++) {
if((match_list_attrs->attrs[u].exist[0]) && (match_list_attrs->attrs[u].exist[1])) {
name1 = name2 = match_list_attrs->attrs[u].name;
+ h5diffdebug2("diff_attr name - %s\n", name1);
/*--------------
* attribute 1 */
@@ -370,6 +380,7 @@ hsize_t diff_attr(hid_t loc1_id,
if((attr2_id = H5Aopen(loc2_id, name2, H5P_DEFAULT)) < 0)
goto error;
+ h5difftrace("diff_attr got attributes\n");
/* get the datatypes */
if((ftype1_id = H5Aget_type(attr1_id)) < 0)
goto error;
@@ -556,6 +567,7 @@ hsize_t diff_attr(hid_t loc1_id,
table_attrs_free(match_list_attrs);
+ h5difftrace("diff_attr end\n");
return nfound_total;
error:
@@ -584,6 +596,7 @@ error:
} H5E_END_TRY;
options->err_stat = 1;
+ h5difftrace("diff_attr end with error\n");
return nfound_total;
}
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index 9f70299..991ef48 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -44,6 +44,7 @@ hsize_t diff_dataset( hid_t file1_id,
hid_t dcpl2 = -1;
hsize_t nfound = 0;
+ h5difftrace("diff_dataset start\n");
/*-------------------------------------------------------------------------
* open the handles
*-------------------------------------------------------------------------
@@ -52,13 +53,11 @@ hsize_t diff_dataset( hid_t file1_id,
H5E_BEGIN_TRY
{
/* Open the datasets */
- if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0)
- {
+ if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) {
parallel_print("Cannot open dataset <%s>\n", obj1_name);
goto error;
}
- if((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0)
- {
+ if((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0) {
parallel_print("Cannot open dataset <%s>\n", obj2_name);
goto error;
}
@@ -78,15 +77,9 @@ hsize_t diff_dataset( hid_t file1_id,
* 2) the internal filters might be turned off
*-------------------------------------------------------------------------
*/
- if ((h5tools_canreadf((options->m_verbose?obj1_name:NULL),dcpl1)==1) &&
- (h5tools_canreadf((options->m_verbose?obj2_name:NULL),dcpl2)==1))
- {
- nfound=diff_datasetid(did1,
- did2,
- obj1_name,
- obj2_name,
- options);
- }
+ if ((h5tools_canreadf((options->m_verbose ? obj1_name : NULL), dcpl1) == 1) &&
+ (h5tools_canreadf((options->m_verbose ? obj2_name : NULL), dcpl2) == 1))
+ nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, options);
else
goto error;
@@ -94,20 +87,12 @@ hsize_t diff_dataset( hid_t file1_id,
* close
*-------------------------------------------------------------------------
*/
- /* disable error reporting */
- H5E_BEGIN_TRY {
- H5Pclose(dcpl1);
- H5Pclose(dcpl2);
- H5Dclose(did1);
- H5Dclose(did2);
- /* enable error reporting */
- } H5E_END_TRY;
-
-
- return nfound;
+ goto done;
error:
- options->err_stat=1;
+ options->err_stat = 1;
+
+done:
/* disable error reporting */
H5E_BEGIN_TRY {
H5Pclose(dcpl1);
@@ -117,6 +102,7 @@ error:
/* enable error reporting */
} H5E_END_TRY;
+ h5difftrace("diff_dataset end\n");
return nfound;
}
@@ -188,20 +174,24 @@ hsize_t diff_datasetid( hid_t did1,
hid_t sid2=-1;
hid_t f_tid1=-1;
hid_t f_tid2=-1;
+ hid_t dam_tid=-1; /* m_tid for diff_array function */
hid_t m_tid1=-1;
hid_t m_tid2=-1;
hid_t dcpl1 = -1;
hid_t dcpl2 = -1;
H5D_layout_t stl1 = -1;
H5D_layout_t stl2 = -1;
+ size_t dam_size; /* m_size for diff_array function */
size_t m_size1;
size_t m_size2;
H5T_sign_t sign1;
H5T_sign_t sign2;
int rank1;
int rank2;
+ hsize_t danelmts; /* nelmts for diff_array function */
hsize_t nelmts1;
hsize_t nelmts2;
+ hsize_t *dadims; /* dims for diff_array function */
hsize_t dims1[H5S_MAX_RANK];
hsize_t dims2[H5S_MAX_RANK];
hsize_t maxdim1[H5S_MAX_RANK];
@@ -223,30 +213,29 @@ hsize_t diff_datasetid( hid_t did1,
h5difftrace("diff_datasetid start\n");
/* Get the dataspace handle */
- if ( (sid1 = H5Dget_space(did1)) < 0 )
+ if((sid1 = H5Dget_space(did1)) < 0)
goto error;
/* Get rank */
- if ( (rank1 = H5Sget_simple_extent_ndims(sid1)) < 0 )
+ if((rank1 = H5Sget_simple_extent_ndims(sid1)) < 0)
goto error;
/* Get the dataspace handle */
- if ( (sid2 = H5Dget_space(did2)) < 0 )
+ if((sid2 = H5Dget_space(did2)) < 0 )
goto error;
/* Get rank */
- if ( (rank2 = H5Sget_simple_extent_ndims(sid2)) < 0 )
+ if((rank2 = H5Sget_simple_extent_ndims(sid2)) < 0)
goto error;
/* Get dimensions */
- if ( H5Sget_simple_extent_dims(sid1,dims1,maxdim1) < 0 )
+ if(H5Sget_simple_extent_dims(sid1, dims1, maxdim1) < 0)
goto error;
/* Get dimensions */
- if ( H5Sget_simple_extent_dims(sid2,dims2,maxdim2) < 0 )
- {
+ if(H5Sget_simple_extent_dims(sid2, dims2, maxdim2) < 0)
goto error;
- }
+ h5diffdebug3("rank: %ld - %ld\n", rank1, rank2);
/*-------------------------------------------------------------------------
* get the file data type
@@ -254,15 +243,12 @@ hsize_t diff_datasetid( hid_t did1,
*/
/* Get the data type */
- if ( (f_tid1 = H5Dget_type(did1)) < 0 )
+ if((f_tid1 = H5Dget_type(did1)) < 0)
goto error;
/* Get the data type */
- if ( (f_tid2 = H5Dget_type(did2)) < 0 )
- {
+ if((f_tid2 = H5Dget_type(did2)) < 0)
goto error;
- }
-
/*-------------------------------------------------------------------------
* get the storage layout type
@@ -284,22 +270,20 @@ hsize_t diff_datasetid( hid_t did1,
*/
h5difftrace("check for empty datasets\n");
- storage_size1=H5Dget_storage_size(did1);
- storage_size2=H5Dget_storage_size(did2);
+ storage_size1 = H5Dget_storage_size(did1);
+ storage_size2 = H5Dget_storage_size(did2);
+ h5diffdebug3("storage size: %ld - %ld\n", storage_size1, storage_size2);
- if (storage_size1==0 || storage_size2==0)
- {
- if (stl1==H5D_VIRTUAL || stl2==H5D_VIRTUAL)
- {
- if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
+ if(storage_size1 == 0 || storage_size2 == 0) {
+ if(stl1 == H5D_VIRTUAL || stl2 == H5D_VIRTUAL) {
+ if((options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
parallel_print("Warning: <%s> or <%s> is a virtual dataset\n", obj1_name, obj2_name);
}
- else
- {
- if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
+ else {
+ if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name)
parallel_print("Not comparable: <%s> or <%s> is an empty dataset\n", obj1_name, obj2_name);
- can_compare=0;
- options->not_cmp=1;
+ can_compare = 0;
+ options->not_cmp = 1;
}
}
@@ -307,71 +291,58 @@ hsize_t diff_datasetid( hid_t did1,
* check for comparable TYPE and SPACE
*-------------------------------------------------------------------------
*/
-
- if (diff_can_type(f_tid1,
- f_tid2,
- rank1,
- rank2,
- dims1,
- dims2,
- maxdim1,
- maxdim2,
- obj1_name,
- obj2_name,
- options,
- 0)!=1)
- {
- can_compare=0;
- }
+ if (diff_can_type(f_tid1, f_tid2, rank1, rank2,
+ dims1, dims2, maxdim1, maxdim2,
+ obj1_name, obj2_name,
+ options, 0) != 1)
+ can_compare = 0;
/*-------------------------------------------------------------------------
* memory type and sizes
*-------------------------------------------------------------------------
*/
h5difftrace("check for memory type and sizes\n");
- if ((m_tid1=H5Tget_native_type(f_tid1, H5T_DIR_DEFAULT)) < 0)
+ if((m_tid1 = H5Tget_native_type(f_tid1, H5T_DIR_DEFAULT)) < 0)
goto error;
- if ((m_tid2=H5Tget_native_type(f_tid2, H5T_DIR_DEFAULT)) < 0)
+ if((m_tid2 = H5Tget_native_type(f_tid2, H5T_DIR_DEFAULT)) < 0)
goto error;
- m_size1 = H5Tget_size( m_tid1 );
- m_size2 = H5Tget_size( m_tid2 );
+ m_size1 = H5Tget_size(m_tid1);
+ m_size2 = H5Tget_size(m_tid2);
+ h5diffdebug3("type size: %ld - %ld\n", m_size1, m_size2);
/*-------------------------------------------------------------------------
* check for different signed/unsigned types
*-------------------------------------------------------------------------
*/
- if (can_compare)
- {
+ if(can_compare) {
h5difftrace("can_compare for sign\n");
- sign1=H5Tget_sign(m_tid1);
- sign2=H5Tget_sign(m_tid2);
- if ( sign1 != sign2 )
- {
+ sign1 = H5Tget_sign(m_tid1);
+ sign2 = H5Tget_sign(m_tid2);
+ if(sign1 != sign2) {
h5difftrace("sign1 != sign2\n");
- if ((options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
- {
+ if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) {
parallel_print("Not comparable: <%s> has sign %s ", obj1_name, get_sign(sign1));
parallel_print("and <%s> has sign %s\n", obj2_name, get_sign(sign2));
}
- can_compare=0;
- options->not_cmp=1;
+ 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) )
+ if(TRUE == h5tools_detect_vlen(m_tid1))
vl_data = TRUE;
/*------------------------------------------------------------------------
* only attempt to compare if possible
*-------------------------------------------------------------------------
*/
- if(can_compare) /* it is possible to compare */
- {
+ if(can_compare) { /* it is possible to compare */
+ H5T_class_t tclass = H5Tget_class(f_tid1);
h5difftrace("can_compare attempt\n");
/*-----------------------------------------------------------------
@@ -386,19 +357,44 @@ hsize_t diff_datasetid( hid_t did1,
for(i = 0; i < rank2; i++)
nelmts2 *= dims2[i];
+ h5diffdebug3("nelmts: %ld - %ld\n", nelmts1, nelmts2);
HDassert(nelmts1 == nelmts2);
- /*-----------------------------------------------------------------
- * "upgrade" the smaller memory size
- *------------------------------------------------------------------
- */
- h5difftrace("upgrade the smaller memory size?\n");
-
- if (FAIL == match_up_memsize (f_tid1, f_tid2,
- &m_tid1, &m_tid2,
- &m_size1, &m_size2))
- goto error;
-
+ if(tclass != H5T_ARRAY) {
+ /*-----------------------------------------------------------------
+ * "upgrade" the smaller memory size
+ *------------------------------------------------------------------
+ */
+ h5difftrace("upgrade the smaller memory size?\n");
+ if (FAIL == match_up_memsize (f_tid1, f_tid2,
+ &m_tid1, &m_tid2,
+ &m_size1, &m_size2))
+ goto error;
+ h5diffdebug3("m_size: %ld - %ld\n", m_size1, m_size2);
+ dadims = dims1;
+ dam_size = m_size1;
+ dam_tid = m_tid1;
+ danelmts = nelmts1;
+ need = (size_t)(nelmts1 * m_size1); /* bytes needed */
+ }
+ else {
+ h5diffdebug3("Array dims: %d - %d\n", dims1[0], dims2[0]);
+ /* Compare the smallest array, but create the largest buffer */
+ if(m_size1 <= m_size2) {
+ dadims = dims1;
+ dam_size = m_size1;
+ dam_tid = m_tid1;
+ danelmts = nelmts1;
+ need = (size_t)(nelmts2 * m_size2); /* bytes needed */
+ }
+ else {
+ dadims = dims2;
+ dam_size = m_size2;
+ dam_tid = m_tid2;
+ danelmts = nelmts2;
+ need = (size_t)(nelmts1 * m_size1); /* bytes needed */
+ }
+ }
/* print names */
if(obj1_name)
name1 = diff_basename(obj1_name);
@@ -410,7 +406,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);
buf2 = HDmalloc(need);
@@ -420,12 +415,13 @@ hsize_t diff_datasetid( hid_t did1,
h5difftrace("buf1 != NULL && buf2 != NULL\n");
if(H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0)
goto error;
+ h5difftrace("H5Dread did2\n");
if(H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0)
goto error;
/* array diff */
- nfound = diff_array(buf1, buf2, nelmts1, (hsize_t)0, rank1, dims1,
- options, name1, name2, m_tid1, did1, did2);
+ nfound = diff_array(buf1, buf2, danelmts, (hsize_t)0, rank1, dadims,
+ options, name1, name2, dam_tid, did1, did2);
/* reclaim any VL memory, if necessary */
if(vl_data) {
@@ -433,10 +429,9 @@ hsize_t diff_datasetid( hid_t did1,
H5Dvlen_reclaim(m_tid2, sid2, H5P_DEFAULT, buf2);
} /* end if */
} /* end if */
- else /* possibly not enough memory, read/compare by hyperslabs */
- {
- size_t p_type_nbytes = m_size1; /*size of memory type */
- hsize_t p_nelmts = nelmts1; /*total selected elmts */
+ else { /* possibly not enough memory, read/compare by hyperslabs */
+ size_t p_type_nbytes = dam_size; /*size of memory type */
+ hsize_t p_nelmts = danelmts; /*total selected elmts */
hsize_t elmtno; /*counter */
int carry; /*counter carry value */
@@ -462,7 +457,7 @@ hsize_t diff_datasetid( hid_t did1,
if(size == 0) /* datum size > H5TOOLS_BUFSIZE */
size = 1;
- sm_size[i - 1] = MIN(dims1[i - 1], size);
+ sm_size[i - 1] = MIN(dadims[i - 1], size);
sm_nbytes *= sm_size[i - 1];
HDassert(sm_nbytes > 0);
} /* end for */
@@ -490,7 +485,7 @@ hsize_t diff_datasetid( hid_t did1,
/* calculate the hyperslab size */
if(rank1 > 0) {
for(i = 0, hs_nelmts = 1; i < rank1; i++) {
- hs_size[i] = MIN(dims1[i] - hs_offset[i], sm_size[i]);
+ hs_size[i] = MIN(dadims[i] - hs_offset[i], sm_size[i]);
hs_nelmts *= hs_size[i];
} /* end for */
if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
@@ -503,15 +498,15 @@ hsize_t diff_datasetid( hid_t did1,
else
hs_nelmts = 1;
- if(H5Dread(did1,m_tid1,sm_space,sid1,H5P_DEFAULT,sm_buf1) < 0)
+ if(H5Dread(did1, m_tid1, sm_space, sid1, H5P_DEFAULT, sm_buf1) < 0)
goto error;
- if(H5Dread(did2,m_tid2,sm_space,sid2,H5P_DEFAULT,sm_buf2) < 0)
+ if(H5Dread(did2, m_tid2, sm_space, sid2, H5P_DEFAULT, sm_buf2) < 0)
goto error;
/* get array differences. in the case of hyperslab read, increment the number of differences
- found in each hyperslab and pass the position at the beggining for printing */
+ found in each hyperslab and pass the position at the beginning for printing */
nfound += diff_array(sm_buf1, sm_buf2, hs_nelmts, elmtno, rank1,
- dims1, options, name1, name2, m_tid1, did1, did2);
+ dadims, options, name1, name2, dam_tid, did1, did2);
/* reclaim any VL memory, if necessary */
if(vl_data) {
@@ -522,7 +517,7 @@ hsize_t diff_datasetid( hid_t did1,
/* calculate the next hyperslab offset */
for(i = rank1, carry = 1; i > 0 && carry; --i) {
hs_offset[i - 1] += hs_size[i - 1];
- if(hs_offset[i - 1] == dims1[i - 1])
+ if(hs_offset[i - 1] == dadims[i - 1])
hs_offset[i - 1] = 0;
else
carry = 0;
@@ -574,37 +569,33 @@ error:
options->err_stat=1;
/* free */
- if (buf1!=NULL)
- {
+ if(buf1 != NULL) {
/* reclaim any VL memory, if necessary */
if(vl_data)
H5Dvlen_reclaim(m_tid1, sid1, H5P_DEFAULT, buf1);
HDfree(buf1);
- buf1=NULL;
+ buf1 = NULL;
}
- if (buf2!=NULL)
- {
+ if(buf2 != NULL) {
/* reclaim any VL memory, if necessary */
if(vl_data)
H5Dvlen_reclaim(m_tid2, sid2, H5P_DEFAULT, buf2);
HDfree(buf2);
- buf2=NULL;
+ buf2 = NULL;
}
- if (sm_buf1!=NULL)
- {
+ if(sm_buf1 != NULL) {
/* reclaim any VL memory, if necessary */
if(vl_data)
H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf1);
HDfree(sm_buf1);
- sm_buf1=NULL;
+ sm_buf1 = NULL;
}
- if (sm_buf2!=NULL)
- {
+ if(sm_buf2 != NULL) {
/* reclaim any VL memory, if necessary */
if(vl_data)
H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf2);
HDfree(sm_buf2);
- sm_buf2=NULL;
+ sm_buf2 = NULL;
}
/* disable error reporting */
@@ -652,75 +643,55 @@ int diff_can_type( hid_t f_tid1, /* file data type */
diff_opt_t *options,
int is_compound)
{
-
-
H5T_class_t tclass1;
H5T_class_t tclass2;
- int maxdim_diff=0; /* maximum dimensions are different */
- int dim_diff=0; /* current dimensions are different */
+ int maxdim_diff = 0; /* maximum dimensions are different */
+ int dim_diff = 0; /* current dimensions are different */
int i;
- int can_compare = 1; /* return value */
+ int can_compare = 1; /* return value */
+ h5difftrace("diff_can_type start\n");
/*-------------------------------------------------------------------------
* check for the same class
*-------------------------------------------------------------------------
*/
-
- if ((tclass1=H5Tget_class(f_tid1)) < 0)
+ if((tclass1 = H5Tget_class(f_tid1)) < 0)
return -1;
-
- if ((tclass2=H5Tget_class(f_tid2)) < 0)
+ if((tclass2 = H5Tget_class(f_tid2)) < 0)
return -1;
- if ( tclass1 != tclass2 )
- {
-
- if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
- {
-
- if ( is_compound )
- {
-
+ if(tclass1 != tclass2) {
+ if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) {
+ if(is_compound) {
parallel_print("Not comparable: <%s> has a class %s and <%s> has a class %s\n",
- obj1_name, get_class(tclass1),
- obj2_name, get_class(tclass2) );
-
+ obj1_name, get_class(tclass1),
+ obj2_name, get_class(tclass2));
}
-
- else
-
- {
-
+ else {
parallel_print("Not comparable: <%s> is of class %s and <%s> is of class %s\n",
- obj1_name, get_class(tclass1),
- obj2_name, get_class(tclass2) );
-
+ obj1_name, get_class(tclass1),
+ obj2_name, get_class(tclass2));
}
-
}
-
-
can_compare = 0;
options->not_cmp = 1;
- return can_compare;
+ goto done;
}
/*-------------------------------------------------------------------------
* check for non supported classes
*-------------------------------------------------------------------------
*/
-
- HDassert(tclass1==tclass2);
- switch (tclass1)
- {
+ HDassert(tclass1 == tclass2);
+ switch (tclass1) {
case H5T_TIME:
- if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) {
+ if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) {
parallel_print("Not comparable: <%s> and <%s> are of class %s\n",
- obj1_name,obj2_name,get_class(tclass2) );
+ obj1_name, obj2_name, get_class(tclass2));
} /* end if */
can_compare = 0;
options->not_cmp = 1;
- return can_compare;
+ goto done;
case H5T_INTEGER:
case H5T_FLOAT:
@@ -735,6 +706,7 @@ int diff_can_type( hid_t f_tid1, /* file data type */
case H5T_NO_CLASS:
case H5T_NCLASSES:
default:
+ h5diffdebug2("diff_can_type class - %s\n", get_class(tclass1));
break;
} /* end switch */
@@ -742,17 +714,11 @@ int diff_can_type( hid_t f_tid1, /* file data type */
* check for equal file datatype; warning only
*-------------------------------------------------------------------------
*/
-
- if ( (H5Tequal(f_tid1, f_tid2)==0) &&
- (options->m_verbose) && obj1_name && obj2_name)
- {
-
+ if((H5Tequal(f_tid1, f_tid2) == 0) && (options->m_verbose) && obj1_name && obj2_name) {
H5T_class_t cl = H5Tget_class(f_tid1);
-
parallel_print("Warning: different storage datatype\n");
- if ( cl == H5T_INTEGER || cl == H5T_FLOAT )
- {
+ if(cl == H5T_INTEGER || cl == H5T_FLOAT) {
parallel_print("<%s> has file datatype ", obj1_name);
print_type(f_tid1);
parallel_print("\n");
@@ -760,110 +726,85 @@ int diff_can_type( hid_t f_tid1, /* file data type */
print_type(f_tid2);
parallel_print("\n");
}
-
-
-
}
/*-------------------------------------------------------------------------
* check for the same rank
*-------------------------------------------------------------------------
*/
-
-
- if ( rank1 != rank2 )
- {
-
- if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
- {
+ if(rank1 != rank2) {
+ if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) {
parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1);
- print_dimensions(rank1,dims1);
+ print_dimensions(rank1, dims1);
parallel_print(", max dimensions ");
- print_dimensions(rank1,maxdim1);
+ print_dimensions(rank1, maxdim1);
parallel_print("\n" );
parallel_print("and <%s> has rank %d, dimensions ", obj2_name, rank2);
- print_dimensions(rank2,dims2);
+ print_dimensions(rank2, dims2);
parallel_print(", max dimensions ");
- print_dimensions(rank2,maxdim2);
+ print_dimensions(rank2, maxdim2);
parallel_print("\n");
}
-
can_compare = 0;
options->not_cmp = 1;
- return can_compare;
+ goto done;
}
/*-------------------------------------------------------------------------
* check for different dimensions
*-------------------------------------------------------------------------
*/
-
- HDassert(rank1==rank2);
- for ( i=0; i<rank1; i++)
- {
- if (maxdim1 && maxdim2)
- {
- if ( maxdim1[i] != maxdim2[i] )
- maxdim_diff=1;
+ HDassert(rank1 == rank2);
+ for(i = 0; i<rank1; i++) {
+ if(maxdim1 && maxdim2) {
+ if(maxdim1[i] != maxdim2[i])
+ maxdim_diff = 1;
}
- if ( dims1[i] != dims2[i] )
- dim_diff=1;
+ if(dims1[i] != dims2[i])
+ dim_diff = 1;
}
/*-------------------------------------------------------------------------
* current dimensions
*-------------------------------------------------------------------------
*/
-
- if (dim_diff==1)
- {
- if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
- {
+ if(dim_diff == 1) {
+ if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) {
parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1);
- print_dimensions(rank1,dims1);
- if (maxdim1 && maxdim2)
- {
+ print_dimensions(rank1, dims1);
+ if(maxdim1 && maxdim2) {
parallel_print(", max dimensions ");
- print_dimensions(rank1,maxdim1);
+ print_dimensions(rank1, maxdim1);
parallel_print("\n" );
parallel_print("and <%s> has rank %d, dimensions ", obj2_name, rank2);
- print_dimensions(rank2,dims2);
+ print_dimensions(rank2, dims2);
parallel_print(", max dimensions ");
- print_dimensions(rank2,maxdim2);
+ print_dimensions(rank2, maxdim2);
parallel_print("\n");
}
}
-
-
can_compare = 0;
options->not_cmp = 1;
- return can_compare;
-
-
-
+ goto done;
}
/*-------------------------------------------------------------------------
* maximum dimensions; just give a warning
*-------------------------------------------------------------------------
*/
- if (maxdim1 && maxdim2 && maxdim_diff==1 && obj1_name )
- {
- if (options->m_verbose) {
+ if(maxdim1 && maxdim2 && maxdim_diff == 1 && obj1_name) {
+ if(options->m_verbose) {
parallel_print( "Warning: different maximum dimensions\n");
parallel_print("<%s> has max dimensions ", obj1_name);
- print_dimensions(rank1,maxdim1);
+ print_dimensions(rank1, maxdim1);
parallel_print("\n");
parallel_print("<%s> has max dimensions ", obj2_name);
- print_dimensions(rank2,maxdim2);
+ print_dimensions(rank2, maxdim2);
parallel_print("\n");
}
}
-
- if ( tclass1 == H5T_COMPOUND )
- {
-
+ if(tclass1 == H5T_COMPOUND) {
int nmembs1;
int nmembs2;
int j;
@@ -873,67 +814,40 @@ int diff_can_type( hid_t f_tid1, /* file data type */
nmembs1 = H5Tget_nmembers(f_tid1);
nmembs2 = H5Tget_nmembers(f_tid2);
- if ( nmembs1 != nmembs2 )
- {
-
- if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
- {
+ if(nmembs1 != nmembs2) {
+ if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) {
parallel_print("Not comparable: <%s> has %d members ", obj1_name, nmembs1);
parallel_print("<%s> has %d members ", obj2_name, nmembs2);
parallel_print("\n");
}
-
can_compare = 0;
options->not_cmp = 1;
- return can_compare;
+ goto done;
}
- for (j = 0; j < nmembs1; j++)
- {
+ for (j = 0; j < nmembs1; j++) {
memb_type1 = H5Tget_member_type(f_tid1, (unsigned)j);
memb_type2 = H5Tget_member_type(f_tid2, (unsigned)j);
- if (diff_can_type(memb_type1,
- memb_type2,
- rank1,
- rank2,
- dims1,
- dims2,
- maxdim1,
- maxdim2,
- obj1_name,
- obj2_name,
- options,
- 1)!=1)
- {
+ if (diff_can_type(memb_type1, memb_type2, rank1, rank2,
+ dims1, dims2, maxdim1, maxdim2, obj1_name, obj2_name,
+ options, 1) != 1) {
can_compare = 0;
options->not_cmp = 1;
H5Tclose(memb_type1);
H5Tclose(memb_type2);
- return can_compare;
+ goto done;
}
-
H5Tclose(memb_type1);
H5Tclose(memb_type2);
-
}
-
-
-
-
-
}
-
-
-
-
-
+done:
+ h5diffdebug2("diff_can_type end - %d\n", can_compare);
return can_compare;
}
-
-
/*-------------------------------------------------------------------------
* Function: print_sizes
*
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index a74fdd2..22fd863 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -51,6 +51,10 @@ unsigned packed_data_length; /* length of packed bits to display */
unsigned long long packed_data_mask; /* mask in which packed bits to display */
int enable_error_stack= FALSE; /* re-enable error stack */
+/* sort parameters */
+H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order | name] */
+H5_iter_order_t sort_order = H5_ITER_INC; /*sort_order [ascending | descending] */
+
/* module-scoped variables */
static int h5tools_init_g; /* if h5tools lib has been initialized */
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index c5e750a..3d38dd0 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -568,6 +568,10 @@ H5TOOLS_DLLVAR int oid_output; /* oid output */
H5TOOLS_DLLVAR int data_output; /* data output */
H5TOOLS_DLLVAR int attr_data_output; /* attribute data output */
+/* sort parameters */
+H5TOOLS_DLLVAR H5_index_t sort_by; /*sort_by [creation_order | name] */
+H5TOOLS_DLLVAR H5_iter_order_t sort_order; /*sort_order [ascending | descending] */
+
/* things to display or which are set via command line parameters */
H5TOOLS_DLLVAR int enable_error_stack; /* re-enable error stack */
diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c
index b57e274..ae7160b 100644
--- a/tools/lib/h5tools_type.c
+++ b/tools/lib/h5tools_type.c
@@ -15,38 +15,6 @@
#include "h5tools.h"
/*-------------------------------------------------------------------------
- * Function: h5tools_get_native_type
- *
- * Purpose: Wrapper around H5Tget_native_type() to work around
- * Problems with bitfields.
- *
- * Return: Success: datatype ID
- *
- * Failure: FAIL
- *
- * Programmer: Quincey Koziol
- * Tuesday, October 5, 2004
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-hid_t
-h5tools_get_native_type(hid_t type)
-{
- hid_t p_type;
- H5T_class_t type_class;
-
- type_class = H5Tget_class(type);
- if(type_class==H5T_BITFIELD)
- p_type=H5Tcopy(type);
- else
- p_type = H5Tget_native_type(type,H5T_DIR_DEFAULT);
-
- return(p_type);
-}
-
-/*-------------------------------------------------------------------------
* Function: h5tools_get_little_endian_type
*
* Purpose: Get a little endian type from a file type