From efbde3c2f3555df156c8b4ed42fcf9e98b5b16ef Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Fri, 16 Jan 2004 10:31:55 -0500 Subject: [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: --- tools/h5repack/h5repack.h | 12 +- tools/h5repack/h5repack_copy.c | 5 +- tools/h5repack/h5repack_refs.c | 324 +++++++++++++++++++++++++++---------- tools/h5repack/testh5repack_attr.c | 5 +- tools/h5repack/testh5repack_dset.c | 222 ++++++++++++++++++++++++- tools/h5repack/testh5repack_main.c | 7 + tools/h5repack/testh5repack_make.c | 6 +- tools/lib/h5diff.c | 4 +- tools/lib/h5diff_array.c | 157 ++++++++++++++++-- tools/lib/h5diff_attr.c | 6 +- tools/testfiles/h5diff_629.txt | 4 +- 11 files changed, 623 insertions(+), 129 deletions(-) diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index bd0ff5d..f55355a 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -19,7 +19,7 @@ #include "hdf5.h" #include "h5trav.h" -#if 1 +#if 0 #define H5_REPACK_DEBUG #endif @@ -158,20 +158,12 @@ int copy_attr(hid_t loc_in, pack_opt_t *options ); -const char* MapIdToName(hid_t refobj_id, - trav_table_t *travt); - int do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options); /* repack options */ -int do_copy_refobjs_inattr(hid_t loc_in, - hid_t loc_out, - pack_opt_t *options, - trav_table_t *travt, - hid_t fidout /* for saving references */ - ); + void read_info(const char *filename,pack_opt_t *options); void close_obj(H5G_obj_t obj_type, hid_t obj_id); diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 1ac6dbc..2dd1f67 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -233,12 +233,13 @@ int do_copy_objects(hid_t fidin, /*------------------------------------------------------------------------- - * object references are a special case + * references are a special case * we cannot just copy the buffers, but instead we recreate the reference * in a second traversal of the output file *------------------------------------------------------------------------- */ - if ( ! H5Tequal(mtype_id, H5T_STD_REF_OBJ) ) + + if ( H5Tget_class(mtype_id) != H5T_REFERENCE ) { /* the information about the object to be filtered/"layouted" */ diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c index d02038d..8b07624 100644 --- a/tools/h5repack/h5repack_refs.c +++ b/tools/h5repack/h5repack_refs.c @@ -20,6 +20,19 @@ #include "h5repack.h" + + +static const char* MapIdToName(hid_t refobj_id, + trav_table_t *travt); + +static int copy_refs_attr(hid_t loc_in, + hid_t loc_out, + pack_opt_t *options, + trav_table_t *travt, + hid_t fidout /* for saving references */ + ); + + /*------------------------------------------------------------------------- * Function: do_copy_refobjs * @@ -116,7 +129,12 @@ int do_copy_refobjs(hid_t fidin, goto error; if ((msize=H5Tget_size(mtype_id))==0) goto error; - + +/*------------------------------------------------------------------------- + * test for a valid output dataset + *------------------------------------------------------------------------- + */ + dset_out = FAIL; /*------------------------------------------------------------------------- * object references are a special case @@ -125,13 +143,12 @@ int do_copy_refobjs(hid_t fidin, */ if (H5Tequal(mtype_id, H5T_STD_REF_OBJ)) { - H5G_obj_t obj_type; - hid_t refobj_id; - hobj_ref_t *refbuf; - const char* refname; - hobj_ref_t *buf; - unsigned u; - + H5G_obj_t obj_type; + hid_t refobj_id; + hobj_ref_t *refbuf; /* buffer for object references */ + hobj_ref_t *buf; + const char* refname; + unsigned u; /*------------------------------------------------------------------------- * read to memory @@ -146,7 +163,6 @@ int do_copy_refobjs(hid_t fidin, if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) goto error; - if ((obj_type = H5Rget_obj_type(dset_in,H5R_OBJECT,buf))<0) goto error; refbuf=HDmalloc((unsigned)nelmts*msize); @@ -156,24 +172,25 @@ int do_copy_refobjs(hid_t fidin, } for ( u=0; uverbose) - printf("object <%s> reference created to <%s>\n",travt->objs[i].name,refname); + printf("object <%s> object reference created to <%s>\n", + travt->objs[i].name, + refname); } close_obj(obj_type,refobj_id); }/* j */ - - /*------------------------------------------------------------------------- * create/write dataset/close @@ -189,31 +206,113 @@ int do_copy_refobjs(hid_t fidin, }/*H5T_STD_REF_OBJ*/ +/*------------------------------------------------------------------------- + * dataset region references + *------------------------------------------------------------------------- + */ + else if (H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) + { + H5G_obj_t obj_type; + hid_t refobj_id; + hdset_reg_ref_t *refbuf; /* input buffer for region references */ + hdset_reg_ref_t *buf; /* output buffer */ + const char* refname; + unsigned u; /*------------------------------------------------------------------------- - * open previously created object in 1st traversal + * read input to memory *------------------------------------------------------------------------- */ + + buf=(void *) HDmalloc((unsigned)(nelmts*msize)); + if ( buf==NULL){ + printf( "cannot read into memory\n" ); + goto error; + } + if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + goto error; + if ((obj_type = H5Rget_obj_type(dset_in,H5R_DATASET_REGION,buf))<0) + goto error; + + /*------------------------------------------------------------------------- + * create output + *------------------------------------------------------------------------- + */ + + refbuf=HDcalloc(sizeof(hdset_reg_ref_t),(size_t)nelmts); /*init to zero */ + if ( refbuf==NULL){ + printf( "cannot allocate memory\n" ); + goto error; + } + for ( u=0; uverbose) + printf("object <%s> region reference created to <%s>\n", + travt->objs[i].name, + refname); + } + close_obj(obj_type,refobj_id); + }/* u */ + /*------------------------------------------------------------------------- + * create/write dataset/close + *------------------------------------------------------------------------- + */ + if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,ftype_id,space_id,dcpl_id))<0) + goto error; + if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,refbuf)<0) + goto error; + + free(buf); + free(refbuf); + } /* H5T_STD_REF_DSETREG */ + + +/*------------------------------------------------------------------------- + * not references, open previously created object in 1st traversal + *------------------------------------------------------------------------- + */ else { if ((dset_out=H5Dopen(fidout,travt->objs[i].name))<0) goto error; } + + assert(dset_out!=FAIL); - /*------------------------------------------------------------------------- - * copy referenced objects in attributes - *------------------------------------------------------------------------- - */ - - if (do_copy_refobjs_inattr(dset_in,dset_out,options,travt,fidout)<0) +/*------------------------------------------------------------------------- + * copy referenced objects in attributes + *------------------------------------------------------------------------- + */ + if (copy_refs_attr(dset_in,dset_out,options,travt,fidout)<0) goto error; - /*------------------------------------------------------------------------- - * check for hard links - *------------------------------------------------------------------------- - */ +/*------------------------------------------------------------------------- + * check for hard links + *------------------------------------------------------------------------- + */ if (travt->objs[i].nlinks) { for ( j=0; jobjs[i].nlinks; j++) @@ -225,7 +324,6 @@ int do_copy_refobjs(hid_t fidin, } } - /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- @@ -243,7 +341,6 @@ int do_copy_refobjs(hid_t fidin, goto error; if (H5Dclose(dset_out)<0) goto error; - break; @@ -295,7 +392,7 @@ int do_copy_refobjs(hid_t fidin, if ((grp_in = H5Gopen(fidin,"/"))<0) goto error; - if (do_copy_refobjs_inattr(grp_in,grp_out,options,travt,fidout)<0) + if (copy_refs_attr(grp_in,grp_out,options,travt,fidout)<0) goto error; if (H5Gclose(grp_out)<0) @@ -323,9 +420,10 @@ error: /*------------------------------------------------------------------------- - * Function: do_copy_refobjs_inattr + * Function: copy_refs_attr * - * Purpose: copy attributes located in LOC_IN, which is obtained either from + * Purpose: duplicate all referenced HDF5 located in attributes + * relative to LOC_IN, which is obtained either from * loc_id = H5Gopen( fid, name); * loc_id = H5Dopen( fid, name); * loc_id = H5Topen( fid, name); @@ -339,12 +437,12 @@ error: *------------------------------------------------------------------------- */ -int do_copy_refobjs_inattr(hid_t loc_in, - hid_t loc_out, - pack_opt_t *options, - trav_table_t *travt, - hid_t fidout /* for saving references */ - ) +static int copy_refs_attr(hid_t loc_in, + hid_t loc_out, + pack_opt_t *options, + trav_table_t *travt, + hid_t fidout /* for saving references */ + ) { hid_t attr_id; /* attr ID */ hid_t attr_out; /* attr ID */ @@ -402,8 +500,6 @@ int do_copy_refobjs_inattr(hid_t loc_in, if ((msize=H5Tget_size(mtype_id))==0) goto error; - - /*------------------------------------------------------------------------- * object references are a special case * we cannot just copy the buffers, but instead we recreate the reference @@ -418,7 +514,11 @@ int do_copy_refobjs_inattr(hid_t loc_in, const char* refname; hobj_ref_t *buf; - + /*------------------------------------------------------------------------- + * read input to memory + *------------------------------------------------------------------------- + */ + buf=(void *) HDmalloc((unsigned)(nelmts*msize)); if ( buf==NULL){ printf( "cannot read into memory\n" ); @@ -457,7 +557,7 @@ int do_copy_refobjs_inattr(hid_t loc_in, /*------------------------------------------------------------------------- * copy *------------------------------------------------------------------------- - */ + */ if ((attr_out=H5Acreate(loc_out,name,ftype_id,space_id,H5P_DEFAULT))<0) goto error; @@ -471,6 +571,92 @@ int do_copy_refobjs_inattr(hid_t loc_in, free(buf); }/*H5T_STD_REF_OBJ*/ + +/*------------------------------------------------------------------------- + * dataset region references + *------------------------------------------------------------------------- + */ + else if (H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) + { + H5G_obj_t obj_type; + hid_t refobj_id; + hdset_reg_ref_t *refbuf; /* input buffer for region references */ + hdset_reg_ref_t *buf; /* output buffer */ + const char* refname; + unsigned u; + + /*------------------------------------------------------------------------- + * read input to memory + *------------------------------------------------------------------------- + */ + + buf=(void *) HDmalloc((unsigned)(nelmts*msize)); + if ( buf==NULL){ + printf( "cannot read into memory\n" ); + goto error; + } + if (H5Aread(attr_id,mtype_id,buf)<0) + goto error; + + if ((obj_type = H5Rget_obj_type(attr_id,H5R_DATASET_REGION,buf))<0) + goto error; + + /*------------------------------------------------------------------------- + * create output + *------------------------------------------------------------------------- + */ + + refbuf=HDcalloc(sizeof(hdset_reg_ref_t),(size_t)nelmts); /*init to zero */ + if ( refbuf==NULL){ + printf( "cannot allocate memory\n" ); + goto error; + } + for ( u=0; uverbose) + printf("object <%s> region reference created to <%s>\n",name,refname); + } + close_obj(obj_type,refobj_id); + }/* u */ + + /*------------------------------------------------------------------------- + * copy + *------------------------------------------------------------------------- + */ + + if ((attr_out=H5Acreate(loc_out,name,ftype_id,space_id,H5P_DEFAULT))<0) + goto error; + if(H5Awrite(attr_out,mtype_id,refbuf)<0) + goto error; + + if (H5Aclose(attr_out)<0) + goto error; + + free(refbuf); + free(buf); + } /* H5T_STD_REF_DSETREG */ + /*------------------------------------------------------------------------- @@ -532,33 +718,31 @@ void close_obj(H5G_obj_t obj_type, hid_t obj_id) *------------------------------------------------------------------------- */ -const char* MapIdToName(hid_t refobj_id, - trav_table_t *travt) +static const char* MapIdToName(hid_t refobj_id, + trav_table_t *travt) { hid_t id; hid_t fid; int i; + /* obtains the file ID given an object ID. This ID must be closed */ if ((fid = H5Iget_file_id(refobj_id))<0) { assert(0); return NULL; } - + /* linear search */ for ( i=0; inobjs; i++) { switch ( travt->objs[i].type ) { - - /*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - + default: + assert(0); + break; case H5G_GROUP: - - + case H5G_TYPE: + case H5G_LINK: break; /*------------------------------------------------------------------------- @@ -573,49 +757,18 @@ const char* MapIdToName(hid_t refobj_id, assert(0); return NULL; } - if (H5Dclose(id)<0) { assert(0); return NULL; } - if (id==refobj_id) { H5Fclose(fid); return travt->objs[i].name; } - - break; - - /*------------------------------------------------------------------------- - * H5G_TYPE - *------------------------------------------------------------------------- - */ - - case H5G_TYPE: - - - - break; - - - /*------------------------------------------------------------------------- - * H5G_LINK - *------------------------------------------------------------------------- - */ - - case H5G_LINK: - break; - - default: - assert(0); - break; - - } - - + } /* switch */ } /* i */ if (H5Fclose(fid)<0) @@ -623,3 +776,4 @@ const char* MapIdToName(hid_t refobj_id, return NULL; } + diff --git a/tools/h5repack/testh5repack_attr.c b/tools/h5repack/testh5repack_attr.c index 9862b80..ec77864 100644 --- a/tools/h5repack/testh5repack_attr.c +++ b/tools/h5repack/testh5repack_attr.c @@ -213,14 +213,15 @@ void write_attr_in(hid_t loc_id, * H5T_REFERENCE *------------------------------------------------------------------------- */ - /* Create references to dataset */ + /* object references ( H5R_OBJECT */ if (dset_name) { status=H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,-1); status=H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,-1); - write_attr(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4); + write_attr(loc_id,1,dims,"reference to object",H5T_STD_REF_OBJ,buf4); } + /*------------------------------------------------------------------------- * H5T_ENUM *------------------------------------------------------------------------- diff --git a/tools/h5repack/testh5repack_dset.c b/tools/h5repack/testh5repack_dset.c index 42ad644..d74c214 100644 --- a/tools/h5repack/testh5repack_dset.c +++ b/tools/h5repack/testh5repack_dset.c @@ -16,7 +16,8 @@ #include "h5test.h" #include "h5repack.h" - +static void make_dset_reg_ref(hid_t loc_id); +static void read_dset_reg_ref(hid_t loc_id); /*------------------------------------------------------------------------- @@ -232,14 +233,20 @@ void write_dset_in(hid_t loc_id, * H5T_REFERENCE *------------------------------------------------------------------------- */ - /* Create references to dataset */ + /* object references ( H5R_OBJECT ) */ if (dset_name) { status=H5Rcreate(&buf4[0],file_id,dset_name,H5R_OBJECT,-1); status=H5Rcreate(&buf4[1],file_id,dset_name,H5R_OBJECT,-1); - write_dset(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4); + write_dset(loc_id,1,dims,"reference to object ",H5T_STD_REF_OBJ,buf4); } + /* Dataset region reference ( H5R_DATASET_REGION ) */ + make_dset_reg_ref(loc_id); +#if defined(H5_REPACK_DEBUG) + read_dset_reg_ref(loc_id); +#endif + /*------------------------------------------------------------------------- * H5T_ENUM *------------------------------------------------------------------------- @@ -392,7 +399,7 @@ void write_dset_in(hid_t loc_id, status=H5Rcreate(&buf42[i][j],file_id,dset_name,H5R_OBJECT,-1); } } - write_dset(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42); + write_dset(loc_id,2,dims2,"reference to object 2D",H5T_STD_REF_OBJ,buf42); } /*------------------------------------------------------------------------- @@ -578,7 +585,7 @@ void write_dset_in(hid_t loc_id, status=H5Rcreate(&buf43[i][j][k],file_id,dset_name,H5R_OBJECT,-1); } } - write_dset(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43); + write_dset(loc_id,3,dims3,"reference to object 3D",H5T_STD_REF_OBJ,buf43); } /*------------------------------------------------------------------------- @@ -673,3 +680,208 @@ void write_dset_in(hid_t loc_id, write_dset(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83); } + + +/*------------------------------------------------------------------------- + * Function: make_dset_reg_ref + * + * Purpose: write dataset region references + * + *------------------------------------------------------------------------- + */ + +#define SPACE1_RANK 1 +#define SPACE1_DIM1 4 +#define SPACE2_RANK 2 +#define SPACE2_DIM1 10 +#define SPACE2_DIM2 10 +#define NPOINTS 10 + +static void make_dset_reg_ref(hid_t loc_id) +{ + hid_t dset1; /* Dataset ID */ + hid_t dset2; /* Dereferenced dataset ID */ + hid_t sid1; /* Dataspace ID #1 */ + hid_t sid2; /* Dataspace ID #2 */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hssize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + hssize_t coord1[NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ + hdset_reg_ref_t *wbuf; /* buffer to write to disk */ + int *dwbuf; /* Buffer for writing numeric data to disk */ + int i; /* counting variables */ + herr_t ret; /* Generic return value */ + + /* Allocate write & read buffers */ + wbuf=calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + dwbuf=malloc(sizeof(int)*SPACE2_DIM1*SPACE2_DIM2); + + /* Create dataspace for datasets */ + sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL); + + /* Create a dataset */ + dset2=H5Dcreate(loc_id,"dset referenced region",H5T_STD_U8LE,sid2,H5P_DEFAULT); + + for(i=0; i: 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 -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 { diff --git a/tools/testfiles/h5diff_629.txt b/tools/testfiles/h5diff_629.txt index f41a971..232f1ff 100644 --- a/tools/testfiles/h5diff_629.txt +++ b/tools/testfiles/h5diff_629.txt @@ -1,6 +1,6 @@ ############################# Expected output for 'h5diff file1.h6 file2.h6' ############################# -h5diff: file1.h6: No such file or directory -h5diff: file2.h6: No such file or directory +h5diff: : unable to open file +h5diff: : unable to open file -- cgit v0.12