summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5diff_attr.c
diff options
context:
space:
mode:
authorLeon Arber <larber@ncsa.uiuc.edu>2005-02-08 05:42:49 (GMT)
committerLeon Arber <larber@ncsa.uiuc.edu>2005-02-08 05:42:49 (GMT)
commit2183c5971ad1ef5ddbff3fd19d8af13737f4f03f (patch)
tree818a85e1aecc8e8aab2eda3deccb4df03f49b6cc /tools/lib/h5diff_attr.c
parentb4153b4f5edef4833abea9a1249baf4690984258 (diff)
downloadhdf5-2183c5971ad1ef5ddbff3fd19d8af13737f4f03f.zip
hdf5-2183c5971ad1ef5ddbff3fd19d8af13737f4f03f.tar.gz
hdf5-2183c5971ad1ef5ddbff3fd19d8af13737f4f03f.tar.bz2
[svn-r9956] Purpose:
Fixed numerous ph5diff bugs. Description: Fixed manager output printing Fixed out of order output printing Fixed test script execution problem Temporary fix for large amounts of output overflowing buffer. Solution: The manager task buffers its output. However, since the manager task never gets a print token, this output was lost. Solution: new function called print_manager_output that prints buffered output is called in places where the manager buffers its output. printf was apparently buffering output. This means that a task would sometimes print even after it had given up its print token. Added fflush() call after printf() calls, which seems to have fixed the problem. calling rsh multiple times in succession seems to overwhelm something in Linux, as it begins to refuse new connections until the old ones reset. Since each call to mpirun in the test script starts up 4 rsh sessions, the test script eventually is unable to run any further tests. Solution: Added a short delay in the testscript between successive calls to mpirun to allow old connections to reset. The 10k output buffer was of insufficient size to hold the large amounts of output generated by some of the tests. Since code to buffer to a file has not been implemented yet, a temporary fix was to increase the size of the output buffer to 50k. Platforms tested: heping Misc. update:
Diffstat (limited to 'tools/lib/h5diff_attr.c')
-rw-r--r--tools/lib/h5diff_attr.c518
1 files changed, 259 insertions, 259 deletions
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index d1f18df..24ade01 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -38,276 +38,276 @@
*/
int diff_attr(hid_t loc1_id,
- hid_t loc2_id,
- const char *path1,
- const char *path2,
- diff_opt_t *options
- )
+ hid_t loc2_id,
+ const char *path1,
+ const char *path2,
+ diff_opt_t *options
+ )
{
- hid_t attr1_id=-1; /* attr ID */
- hid_t attr2_id=-1; /* attr ID */
- hid_t space1_id=-1; /* space 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 */
- 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 */
- size_t msize2; /* memory size of memory type */
- void *buf1=NULL; /* data buffer */
- void *buf2=NULL; /* data buffer */
- hsize_t nelmts1; /* number of elements in dataset */
- int rank1; /* rank of dataset */
- int rank2; /* rank of dataset */
- hsize_t dims1[H5S_MAX_RANK];/* dimensions of dataset */
- hsize_t dims2[H5S_MAX_RANK];/* dimensions of dataset */
- char name1[255];
- char name2[255];
- int n1, n2, i, j;
- int ret=0;
- hsize_t nfound;
- int cmp=1;
-
- if ((n1 = H5Aget_num_attrs(loc1_id))<0)
- goto error;
- if ((n2 = H5Aget_num_attrs(loc2_id))<0)
- goto error;
-
- if (n1!=n2)
- return 1;
-
- for ( i = 0; i < n1; i++)
- {
-
- /* reset buffers for every attribute, we might goto out and call free */
- buf1=NULL;
- buf2=NULL;
+ hid_t attr1_id=-1; /* attr ID */
+ hid_t attr2_id=-1; /* attr ID */
+ hid_t space1_id=-1; /* space 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 */
+ 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 */
+ size_t msize2; /* memory size of memory type */
+ void *buf1=NULL; /* data buffer */
+ void *buf2=NULL; /* data buffer */
+ hsize_t nelmts1; /* number of elements in dataset */
+ int rank1; /* rank of dataset */
+ int rank2; /* rank of dataset */
+ hsize_t dims1[H5S_MAX_RANK];/* dimensions of dataset */
+ hsize_t dims2[H5S_MAX_RANK];/* dimensions of dataset */
+ char name1[255];
+ char name2[255];
+ int n1, n2, i, j;
+ int ret=0;
+ hsize_t nfound;
+ int cmp=1;
-/*-------------------------------------------------------------------------
- * open
- *-------------------------------------------------------------------------
- */
- /* open attribute */
- if ((attr1_id = H5Aopen_idx(loc1_id, (unsigned)i))<0)
- goto error;
- if ((attr2_id = H5Aopen_idx(loc2_id, (unsigned)i))<0)
- goto error;
-
- /* get name */
- if (H5Aget_name( attr1_id, 255, name1 )<0)
- goto error;
- if (H5Aget_name( attr2_id, 255, name2 )<0)
- goto error;
-
- if (HDstrcmp(name1,name2)!=0)
- {
- if (options->m_verbose)
- {
- parallel_print("Different name for attributes: <%s> and <%s>\n", name1, name2);
- }
- H5Aclose(attr1_id);
- H5Aclose(attr2_id);
- ret=1;
- continue;
- }
-
- /* get the file datatype */
- if ((ftype1_id = H5Aget_type( attr1_id )) < 0 )
- goto error;
- if ((ftype2_id = H5Aget_type( attr2_id )) < 0 )
- goto error;
-
- /* get the dataspace handle */
- if ((space1_id = H5Aget_space( attr1_id )) < 0 )
- goto error;
- if ((space2_id = H5Aget_space( attr2_id )) < 0 )
- goto error;
-
- /* get dimensions */
- if ( (rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0 )
- goto error;
- if ( (rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0 )
- goto error;
+ if ((n1 = H5Aget_num_attrs(loc1_id))<0)
+ goto error;
+ if ((n2 = H5Aget_num_attrs(loc2_id))<0)
+ goto error;
+ if (n1!=n2)
+ return 1;
-/*-------------------------------------------------------------------------
- * check for comparable TYPE and SPACE
- *-------------------------------------------------------------------------
- */
+ for ( i = 0; i < n1; i++)
+ {
- if (diff_can_type(ftype1_id,
- ftype2_id,
- rank1,
- rank2,
- dims1,
- dims2,
- NULL,
- NULL,
- name1,
- name2,
- options)!=1)
- cmp=0;
-/*-------------------------------------------------------------------------
- * only attempt to compare if possible
- *-------------------------------------------------------------------------
- */
- if (cmp)
- {
-
-/*-------------------------------------------------------------------------
- * read to memory
- *-------------------------------------------------------------------------
- */
- nelmts1=1;
- for (j=0; j<rank1; j++)
- nelmts1*=dims1[j];
-
- if ((mtype1_id=h5tools_get_native_type(ftype1_id))<0)
- goto error;
-
- if ((mtype2_id=h5tools_get_native_type(ftype2_id))<0)
- goto error;
-
- if ((msize1=H5Tget_size(mtype1_id))==0)
- goto error;
- if ((msize2=H5Tget_size(mtype2_id))==0)
- goto error;
-
- assert(msize1==msize2);
-
- buf1=(void *) HDmalloc((unsigned)(nelmts1*msize1));
- buf2=(void *) HDmalloc((unsigned)(nelmts1*msize2));
- if ( buf1==NULL || buf2==NULL){
- parallel_print( "cannot read into memory\n" );
- goto error;
- }
- if (H5Aread(attr1_id,mtype1_id,buf1)<0)
- goto error;
- if (H5Aread(attr2_id,mtype2_id,buf2)<0)
- goto error;
-
-
-/*-------------------------------------------------------------------------
- * array compare
- *-------------------------------------------------------------------------
- */
- sprintf(name1,"%s of <%s>",name1,path1);
- sprintf(name2,"%s of <%s>",name2,path2);
-
- /* always print name */
- if (options->m_verbose)
- {
- parallel_print( "Attribute: <%s> and <%s>\n",name1,name2);
- nfound = diff_array(buf1,
- buf2,
- nelmts1,
- rank1,
- dims1,
- options,
- name1,
- name2,
- mtype1_id,
- attr1_id,
- attr2_id);
- print_found(nfound);
-
- }
- /* check first if we have differences */
- else
- {
- if (options->m_quiet==0)
- {
- /* shut up temporarily */
- options->m_quiet=1;
- nfound = diff_array(buf1,
- buf2,
- nelmts1,
- rank1,
- dims1,
- options,
- name1,
- name2,
- mtype1_id,
- attr1_id,
- attr2_id);
- /* print again */
- options->m_quiet=0;
- if (nfound)
- {
- parallel_print( "Attribute: <%s> and <%s>\n",name1,name2);
- nfound = diff_array(buf1,
- buf2,
- nelmts1,
- rank1,
- dims1,
- options,
- name1,
- name2,
- mtype1_id,
- attr1_id,
- attr2_id);
- print_found(nfound);
- } /*if*/
- } /*if*/
- /* in quiet mode, just count differences */
- else
- {
- nfound = diff_array(buf1,
- buf2,
- nelmts1,
- rank1,
- dims1,
- options,
- name1,
- name2,
- mtype1_id,
- attr1_id,
- attr2_id);
- } /*else quiet */
- } /*else verbose */
- }/*cmp*/
+ /* reset buffers for every attribute, we might goto out and call free */
+ buf1=NULL;
+ buf2=NULL;
+ /*-------------------------------------------------------------------------
+ * open
+ *-------------------------------------------------------------------------
+ */
+ /* open attribute */
+ if ((attr1_id = H5Aopen_idx(loc1_id, (unsigned)i))<0)
+ goto error;
+ if ((attr2_id = H5Aopen_idx(loc2_id, (unsigned)i))<0)
+ goto error;
+ /* get name */
+ if (H5Aget_name( attr1_id, 255, name1 )<0)
+ goto error;
+ if (H5Aget_name( attr2_id, 255, name2 )<0)
+ goto error;
-/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
+ if (HDstrcmp(name1,name2)!=0)
+ {
+ if (options->m_verbose)
+ {
+ parallel_print("Different name for attributes: <%s> and <%s>\n", name1, name2);
+ }
+ H5Aclose(attr1_id);
+ H5Aclose(attr2_id);
+ ret=1;
+ continue;
+ }
+
+ /* get the file datatype */
+ if ((ftype1_id = H5Aget_type( attr1_id )) < 0 )
+ goto error;
+ if ((ftype2_id = H5Aget_type( attr2_id )) < 0 )
+ goto error;
+
+ /* get the dataspace handle */
+ if ((space1_id = H5Aget_space( attr1_id )) < 0 )
+ goto error;
+ if ((space2_id = H5Aget_space( attr2_id )) < 0 )
+ goto error;
- if (H5Tclose(ftype1_id)<0) goto error;
- if (H5Tclose(ftype2_id)<0) goto error;
- if (H5Tclose(mtype1_id)<0) goto error;
- if (H5Tclose(mtype2_id)<0) goto error;
- if (H5Sclose(space1_id)<0) goto error;
- if (H5Sclose(space2_id)<0) goto error;
- if (H5Aclose(attr1_id)<0) goto error;
- if (H5Aclose(attr2_id)<0) goto error;
- if (buf1)
- HDfree(buf1);
- if (buf2)
- HDfree(buf2);
- } /* i */
-
- return ret;
+ /* get dimensions */
+ if ( (rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0 )
+ goto error;
+ if ( (rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0 )
+ goto error;
+
+
+ /*-------------------------------------------------------------------------
+ * check for comparable TYPE and SPACE
+ *-------------------------------------------------------------------------
+ */
+
+ if (diff_can_type(ftype1_id,
+ ftype2_id,
+ rank1,
+ rank2,
+ dims1,
+ dims2,
+ NULL,
+ NULL,
+ name1,
+ name2,
+ options)!=1)
+ cmp=0;
+ /*-------------------------------------------------------------------------
+ * only attempt to compare if possible
+ *-------------------------------------------------------------------------
+ */
+ if (cmp)
+ {
+
+ /*-------------------------------------------------------------------------
+ * read to memory
+ *-------------------------------------------------------------------------
+ */
+ nelmts1=1;
+ for (j=0; j<rank1; j++)
+ nelmts1*=dims1[j];
+
+ if ((mtype1_id=h5tools_get_native_type(ftype1_id))<0)
+ goto error;
+
+ if ((mtype2_id=h5tools_get_native_type(ftype2_id))<0)
+ goto error;
+
+ if ((msize1=H5Tget_size(mtype1_id))==0)
+ goto error;
+ if ((msize2=H5Tget_size(mtype2_id))==0)
+ goto error;
+
+ assert(msize1==msize2);
+
+ buf1=(void *) HDmalloc((unsigned)(nelmts1*msize1));
+ buf2=(void *) HDmalloc((unsigned)(nelmts1*msize2));
+ if ( buf1==NULL || buf2==NULL){
+ parallel_print( "cannot read into memory\n" );
+ goto error;
+ }
+ if (H5Aread(attr1_id,mtype1_id,buf1)<0)
+ goto error;
+ if (H5Aread(attr2_id,mtype2_id,buf2)<0)
+ goto error;
+
+
+ /*-------------------------------------------------------------------------
+ * array compare
+ *-------------------------------------------------------------------------
+ */
+ sprintf(name1,"%s of <%s>",name1,path1);
+ sprintf(name2,"%s of <%s>",name2,path2);
+
+ /* always print name */
+ if (options->m_verbose)
+ {
+ parallel_print( "Attribute: <%s> and <%s>\n",name1,name2);
+ nfound = diff_array(buf1,
+ buf2,
+ nelmts1,
+ rank1,
+ dims1,
+ options,
+ name1,
+ name2,
+ mtype1_id,
+ attr1_id,
+ attr2_id);
+ print_found(nfound);
+
+ }
+ /* check first if we have differences */
+ else
+ {
+ if (options->m_quiet==0)
+ {
+ /* shut up temporarily */
+ options->m_quiet=1;
+ nfound = diff_array(buf1,
+ buf2,
+ nelmts1,
+ rank1,
+ dims1,
+ options,
+ name1,
+ name2,
+ mtype1_id,
+ attr1_id,
+ attr2_id);
+ /* print again */
+ options->m_quiet=0;
+ if (nfound)
+ {
+ parallel_print( "Attribute: <%s> and <%s>\n",name1,name2);
+ nfound = diff_array(buf1,
+ buf2,
+ nelmts1,
+ rank1,
+ dims1,
+ options,
+ name1,
+ name2,
+ mtype1_id,
+ attr1_id,
+ attr2_id);
+ print_found(nfound);
+ } /*if*/
+ } /*if*/
+ /* in quiet mode, just count differences */
+ else
+ {
+ nfound = diff_array(buf1,
+ buf2,
+ nelmts1,
+ rank1,
+ dims1,
+ options,
+ name1,
+ name2,
+ mtype1_id,
+ attr1_id,
+ attr2_id);
+ } /*else quiet */
+ } /*else verbose */
+ }/*cmp*/
+
+
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5Tclose(ftype1_id)<0) goto error;
+ if (H5Tclose(ftype2_id)<0) goto error;
+ if (H5Tclose(mtype1_id)<0) goto error;
+ if (H5Tclose(mtype2_id)<0) goto error;
+ if (H5Sclose(space1_id)<0) goto error;
+ if (H5Sclose(space2_id)<0) goto error;
+ if (H5Aclose(attr1_id)<0) goto error;
+ if (H5Aclose(attr2_id)<0) goto error;
+ if (buf1)
+ HDfree(buf1);
+ if (buf2)
+ HDfree(buf2);
+ } /* i */
+
+ return ret;
error:
- H5E_BEGIN_TRY {
- H5Tclose(ftype1_id);
- H5Tclose(ftype2_id);
- H5Tclose(mtype1_id);
- H5Tclose(mtype2_id);
- H5Sclose(space1_id);
- H5Sclose(space2_id);
- H5Aclose(attr1_id);
- H5Aclose(attr2_id);
- if (buf1)
- HDfree(buf1);
- if (buf2)
- HDfree(buf2);
- } H5E_END_TRY;
-
- options->err_stat=1;
- return 0;
+ H5E_BEGIN_TRY {
+ H5Tclose(ftype1_id);
+ H5Tclose(ftype2_id);
+ H5Tclose(mtype1_id);
+ H5Tclose(mtype2_id);
+ H5Sclose(space1_id);
+ H5Sclose(space2_id);
+ H5Aclose(attr1_id);
+ H5Aclose(attr2_id);
+ if (buf1)
+ HDfree(buf1);
+ if (buf2)
+ HDfree(buf2);
+ } H5E_END_TRY;
+
+ options->err_stat=1;
+ return 0;
}