summaryrefslogtreecommitdiffstats
path: root/tools/h5repack
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/h5repack
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/h5repack')
-rw-r--r--tools/h5repack/h5repack.h12
-rw-r--r--tools/h5repack/h5repack_copy.c5
-rw-r--r--tools/h5repack/h5repack_refs.c324
-rw-r--r--tools/h5repack/testh5repack_attr.c5
-rw-r--r--tools/h5repack/testh5repack_dset.c222
-rw-r--r--tools/h5repack/testh5repack_main.c7
-rw-r--r--tools/h5repack/testh5repack_make.c6
7 files changed, 474 insertions, 107 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; u<nelmts; u++)
{
+ H5E_BEGIN_TRY {
if ((refobj_id = H5Rdereference(dset_in,H5R_OBJECT,&buf[u]))<0)
- goto error;
-
- /* get the name. a valid name could only occur in the
+ continue;
+ } H5E_END_TRY;
+ /* get the name. a valid name could only occur in the
second traversal of the file */
if ((refname=MapIdToName(refobj_id,travt))!=NULL)
{
- /* create the reference */
+ /* create the reference, -1 parameter for objects */
if (H5Rcreate(&refbuf[u],fidout,refname,H5R_OBJECT,-1)<0)
goto error;
if (options->verbose)
- 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; u<nelmts; u++)
+ {
+ H5E_BEGIN_TRY {
+ if ((refobj_id = H5Rdereference(dset_in,H5R_DATASET_REGION,&buf[u]))<0)
+ continue;
+ } H5E_END_TRY;
+
+ /* get the name. a valid name could only occur in the
+ second traversal of the file */
+ if ((refname=MapIdToName(refobj_id,travt))!=NULL)
+ {
+ hid_t region_id; /* region id of the referenced dataset */
+
+ if ((region_id = H5Rget_region(dset_in,H5R_DATASET_REGION,&buf[u]))<0)
+ goto error;
+
+ /* create the reference, we need the space_id */
+ if (H5Rcreate(&refbuf[u],fidout,refname,H5R_DATASET_REGION,region_id)<0)
+ goto error;
+
+ if (H5Sclose(region_id)<0)
+ goto error;
+
+ if (options->verbose)
+ 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; j<travt->objs[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; u<nelmts; u++)
+ {
+ H5E_BEGIN_TRY {
+ if ((refobj_id = H5Rdereference(attr_id,H5R_DATASET_REGION,&buf[u]))<0)
+ continue;
+ } H5E_END_TRY;
+
+ /* get the name. a valid name could only occur in the
+ second traversal of the file */
+ if ((refname=MapIdToName(refobj_id,travt))!=NULL)
+ {
+ hid_t region_id; /* region id of the referenced dataset */
+
+ if ((region_id = H5Rget_region(attr_id,H5R_DATASET_REGION,&buf[u]))<0)
+ goto error;
+
+ /* create the reference, we need the space_id */
+ if (H5Rcreate(&refbuf[u],fidout,refname,H5R_DATASET_REGION,region_id)<0)
+ goto error;
+
+ if (H5Sclose(region_id)<0)
+ goto error;
+
+ if (options->verbose)
+ 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; i<travt->nobjs; 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<SPACE2_DIM1*SPACE2_DIM2; i++)
+ dwbuf[i]=i*3;
+
+ /* Write selection to disk */
+ ret=H5Dwrite(dset2,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,dwbuf);
+
+ /* Close Dataset */
+ ret = H5Dclose(dset2);
+
+ /* Create dataspace for the reference dataset */
+ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
+
+ /* Create a dataset */
+ dset1=H5Dcreate(loc_id,"region reference",H5T_STD_REF_DSETREG,sid1,H5P_DEFAULT);
+
+ /* Create references */
+
+ /* Select 6x6 hyperslab for first reference */
+ start[0]=2; start[1]=2;
+ stride[0]=1; stride[1]=1;
+ count[0]=6; count[1]=6;
+ block[0]=1; block[1]=1;
+ ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block);
+
+ /* Store first dataset region */
+ ret = H5Rcreate(&wbuf[0],loc_id,"dset referenced region",H5R_DATASET_REGION,sid2);
+
+ /* Select sequence of ten points for second reference */
+ coord1[0][0]=6; coord1[0][1]=9;
+ coord1[1][0]=2; coord1[1][1]=2;
+ coord1[2][0]=8; coord1[2][1]=4;
+ coord1[3][0]=1; coord1[3][1]=6;
+ coord1[4][0]=2; coord1[4][1]=8;
+ coord1[5][0]=3; coord1[5][1]=2;
+ coord1[6][0]=0; coord1[6][1]=4;
+ coord1[7][0]=9; coord1[7][1]=0;
+ coord1[8][0]=7; coord1[8][1]=1;
+ coord1[9][0]=3; coord1[9][1]=3;
+ ret = H5Sselect_elements(sid2,H5S_SELECT_SET,NPOINTS,(const hssize_t **)coord1);
+
+ /* Store second dataset region */
+ ret = H5Rcreate(&wbuf[1],loc_id,"dset referenced region",H5R_DATASET_REGION,sid2);
+
+ /* Write selection to disk */
+ ret=H5Dwrite(dset1,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf);
+
+ /* Close all objects */
+ ret = H5Sclose(sid1);
+ ret = H5Dclose(dset1);
+ ret = H5Sclose(sid2);
+
+ free(wbuf);
+ free(dwbuf);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: read_dset_reg_ref
+ *
+ * Purpose: read dataset region references
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static void read_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 *coords; /* Coordinate buffer */
+ hssize_t low[SPACE2_RANK]; /* Selection bounds */
+ hssize_t high[SPACE2_RANK]; /* Selection bounds */
+ hdset_reg_ref_t *rbuf; /* buffer to read from disk */
+ int *drbuf; /* Buffer for reading numeric data from disk */
+ int i, j; /* counting variables */
+ herr_t ret; /* Generic return value */
+
+ /* Allocate write & read buffers */
+ rbuf=malloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1);
+ drbuf=calloc(sizeof(int),SPACE2_DIM1*SPACE2_DIM2);
+
+ /* Open the dataset */
+ dset1=H5Dopen(loc_id,"region reference");
+
+ /* Read selection from disk */
+ ret=H5Dread(dset1,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,rbuf);
+
+ /* Try to open objects */
+ dset2 = H5Rdereference(dset1,H5R_DATASET_REGION,&rbuf[0]);
+
+ /* Check information in referenced dataset */
+ sid1 = H5Dget_space(dset2);
+
+ ret=(herr_t)H5Sget_simple_extent_npoints(sid1);
+ printf(" Number of elements in the dataset is : %d\n",ret);
+
+ /* Read from disk */
+ ret=H5Dread(dset2,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,drbuf);
+
+ for(i=0; i<SPACE2_DIM1; i++) {
+ for (j=0; j<SPACE2_DIM2; j++) printf (" %d ", drbuf[i*SPACE2_DIM2+j]);
+ printf("\n"); }
+
+ /* Get the hyperslab selection */
+ sid2=H5Rget_region(dset1,H5R_DATASET_REGION,&rbuf[0]);
+
+ /* Verify correct hyperslab selected */
+ ret = (herr_t)H5Sget_select_npoints(sid2);
+ printf(" Number of elements in the hyperslab is : %d \n", ret);
+ ret = (herr_t)H5Sget_select_hyper_nblocks(sid2);
+ /* allocate space for the hyperslab blocks */
+ coords=malloc((size_t)ret*SPACE2_RANK*sizeof(hsize_t)*2);
+ ret = H5Sget_select_hyper_blocklist(sid2,0,ret,coords);
+ printf(" Hyperslab coordinates are : \n");
+ printf (" ( %lu , %lu ) ( %lu , %lu ) \n",
+ (unsigned long)coords[0],
+ (unsigned long)coords[1],
+ (unsigned long)coords[2],
+ (unsigned long)coords[3]);
+ free(coords);
+ ret = H5Sget_select_bounds(sid2,low,high);
+
+ /* Close region space */
+ ret = H5Sclose(sid2);
+
+ /* Get the element selection */
+ sid2=H5Rget_region(dset1,H5R_DATASET_REGION,&rbuf[1]);
+
+ /* Verify correct elements selected */
+ ret = (herr_t)H5Sget_select_elem_npoints(sid2);
+ printf(" Number of selected elements is : %d\n", ret);
+
+ /* Allocate space for the element points */
+ coords= malloc(ret*SPACE2_RANK*sizeof(hsize_t));
+ ret = H5Sget_select_elem_pointlist(sid2,0,ret,coords);
+ printf(" Coordinates of selected elements are : \n");
+ for (i=0; i<2*NPOINTS; i=i+2)
+ printf(" ( %lu , %lu ) \n",
+ (unsigned long)coords[i],
+ (unsigned long)coords[i+1]);
+
+ free(coords);
+ ret = H5Sget_select_bounds(sid2,low,high);
+
+ /* Close region space */
+ ret = H5Sclose(sid2);
+
+ /* Close first space */
+ ret = H5Sclose(sid1);
+
+ /* Close dereferenced Dataset */
+ ret = H5Dclose(dset2);
+
+ /* Close Dataset */
+ ret = H5Dclose(dset1);
+
+ /* Free memory buffers */
+ free(rbuf);
+ free(drbuf);
+}
diff --git a/tools/h5repack/testh5repack_main.c b/tools/h5repack/testh5repack_main.c
index 814b5c4..d81f311 100644
--- a/tools/h5repack/testh5repack_main.c
+++ b/tools/h5repack/testh5repack_main.c
@@ -41,9 +41,16 @@ test_copy(void)
diff_opt_t diff_options;
memset(&diff_options, 0, sizeof (diff_opt_t));
+
TESTING(" copy with no filters");
if (h5repack_init (&pack_options, 0)<0)
TEST_ERROR;
+
+#if defined(H5_REPACK_DEBUG)
+ diff_options.verbose=1;
+ pack_options.verbose=1;
+#endif
+
if (h5repack(FNAME1,FNAME1OUT,&pack_options)<0)
TEST_ERROR;
if (h5diff(FNAME1,FNAME1OUT,NULL,NULL,&diff_options) == 1)
diff --git a/tools/h5repack/testh5repack_make.c b/tools/h5repack/testh5repack_make.c
index 9d3fb3f..e5aa5ee 100644
--- a/tools/h5repack/testh5repack_make.c
+++ b/tools/h5repack/testh5repack_make.c
@@ -126,7 +126,7 @@ int make_all_objects(hid_t loc_id)
*/
space_id = H5Screate_simple(1,dims,NULL);
- dset_id = H5Dcreate(loc_id,"dset_ref",H5T_NATIVE_INT,space_id,H5P_DEFAULT);
+ dset_id = H5Dcreate(loc_id,"dset_referenced",H5T_NATIVE_INT,space_id,H5P_DEFAULT);
H5Sclose(space_id);
/*-------------------------------------------------------------------------
@@ -161,8 +161,8 @@ int make_all_objects(hid_t loc_id)
*-------------------------------------------------------------------------
*/
- write_dset_in(root_id,"dset_ref",loc_id,0);
- write_dset_in(group_id,"dset_ref",loc_id,0);
+ write_dset_in(root_id,"dset_referenced",loc_id,0);
+ write_dset_in(group_id,"dset_referenced",loc_id,0);
/* Close */