diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2004-04-20 00:19:46 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2004-04-20 00:19:46 (GMT) |
commit | 365ca1225d447e1680d9c0dbe00c375655c3948d (patch) | |
tree | 509845d3928879ed774f8c48d44acb669565f1c2 /tools/h5repack | |
parent | beb0079ae11d4932a1ce91545e49801ac206c75a (diff) | |
download | hdf5-365ca1225d447e1680d9c0dbe00c375655c3948d.zip hdf5-365ca1225d447e1680d9c0dbe00c375655c3948d.tar.gz hdf5-365ca1225d447e1680d9c0dbe00c375655c3948d.tar.bz2 |
[svn-r8397] Purpose:
h5repack in 1.6
Description:
2 functions we re added to /src:
H5Premove filter and H5Iget_file_id
Solution:
Platforms tested:
linux
solaris
AIX
Misc. update:
Diffstat (limited to 'tools/h5repack')
-rw-r--r-- | tools/h5repack/h5repack.h | 5 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 38 | ||||
-rw-r--r-- | tools/h5repack/h5repack_filters.c | 7 | ||||
-rw-r--r-- | tools/h5repack/h5repack_main.c | 2 | ||||
-rw-r--r-- | tools/h5repack/h5repack_opttable.c | 6 | ||||
-rw-r--r-- | tools/h5repack/h5repack_refs.c | 68 | ||||
-rw-r--r-- | tools/h5repack/h5repack_verify.c | 18 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_dset.c | 22 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_main.c | 6 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_make.c | 25 |
10 files changed, 109 insertions, 88 deletions
diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index b91d516..4e88f1e 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -99,7 +99,7 @@ typedef struct { chunk_info_t chunk_g; /*global chunk INFO for the ALL case */ H5D_layout_t layout_g; /*global layout information for the ALL case */ int verbose; /*verbose mode */ - hsize_t threshold; /*minimum size to compress, in bytes */ + int threshold; /*minimum size to compress, in bytes */ } pack_opt_t; @@ -159,7 +159,8 @@ int copy_attr(hid_t loc_in, int do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, - pack_opt_t *options); /* repack options */ + pack_opt_t *options, + const char *fnamein); /* repack options */ diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 7763bd2..cc774d0 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -87,7 +87,7 @@ int copy_objects(const char* fnamein, * and create hard links *------------------------------------------------------------------------- */ - if(do_copy_refobjs(fidin,fidout,travt,options)<0) { + if(do_copy_refobjs(fidin,fidout,travt,options,fnamein)<0) { printf("h5repack: <%s>: Could not copy data to: %s\n", fnamein, fnameout); goto out; } @@ -141,25 +141,23 @@ int do_copy_objects(hid_t fidin, trav_table_t *travt, pack_opt_t *options) /* repack options */ { - hid_t grp_in=-1; /* group ID */ - hid_t grp_out=-1; /* group ID */ - hid_t dset_in=-1; /* read dataset ID */ - hid_t dset_out=-1; /* write dataset ID */ - hid_t type_in=-1; /* named type ID */ - hid_t type_out=-1; /* named type ID */ - hid_t dcpl_id=-1; /* dataset creation property list ID */ - hid_t space_id=-1; /* space ID */ - hid_t ftype_id=-1; /* file data type ID */ - hid_t mtype_id=-1; /* memory data type ID */ + hid_t grp_in; /* group ID */ + hid_t grp_out; /* group ID */ + hid_t dset_in; /* read dataset ID */ + hid_t dset_out; /* write dataset ID */ + hid_t type_in; /* named type ID */ + hid_t type_out; /* named type ID */ + hid_t dcpl_id; /* dataset creation property list ID */ + hid_t space_id; /* space ID */ + hid_t ftype_id; /* file data type ID */ + hid_t mtype_id; /* memory data type ID */ size_t msize; /* memory size of memory type */ void *buf=NULL; /* data buffer */ hsize_t nelmts; /* number of elements in dataset */ int rank; /* rank of dataset */ hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ hsize_t dsize_in; /* input dataset size before filter */ -#ifdef LATER hsize_t dsize_out; /* output dataset size after filter */ -#endif /* LATER */ int i, j; /*------------------------------------------------------------------------- @@ -310,14 +308,12 @@ int do_copy_objects(hid_t fidin, if (copy_attr(dset_in,dset_out,options)<0) goto error; -#ifdef LATER /*------------------------------------------------------------------------- * store the storage sizes *------------------------------------------------------------------------- */ dsize_out=H5Dget_storage_size(dset_out); -#endif /* LATER */ /*close */ if (H5Dclose(dset_out)<0) @@ -486,13 +482,13 @@ int copy_attr(hid_t loc_in, pack_opt_t *options ) { - hid_t attr_id=-1; /* attr ID */ - hid_t attr_out=-1; /* attr ID */ - hid_t space_id=-1; /* space ID */ - hid_t ftype_id=-1; /* file data type ID */ - hid_t mtype_id=-1; /* memory data type ID */ + hid_t attr_id; /* attr ID */ + hid_t attr_out; /* attr ID */ + hid_t space_id; /* space ID */ + hid_t ftype_id; /* file data type ID */ + hid_t mtype_id; /* memory data type ID */ size_t msize; /* memory size of type */ - void *buf=NULL; /* data buffer */ + void *buf; /* data buffer */ hsize_t nelmts; /* number of elements in dataset */ int rank; /* rank of dataset */ hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index c8b9b5d..9aacdd3 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -143,7 +143,7 @@ int apply_filters(const char* name, /* object name from traverse list */ { if (options->verbose) printf("Warning: Filter not applied to <%s>. Dataset smaller than <%d> bytes\n", - name,(int)options->threshold); + name,options->threshold); return 0; } @@ -346,7 +346,7 @@ int check_szip(hid_t type_id, /* dataset datatype */ unsigned *szip_pixels_per_block /*IN,OUT*/, pack_opt_t *options) { - size_t size=0; /* size of datatype in bytes */ + size_t size; /* size of datatype in bytes */ szip_comp_t szip; int i; unsigned ppb=*szip_pixels_per_block; @@ -360,6 +360,7 @@ int check_szip(hid_t type_id, /* dataset datatype */ { default: return 0; + break; case H5T_INTEGER: case H5T_FLOAT: break; @@ -436,7 +437,7 @@ int check_szip(hid_t type_id, /* dataset datatype */ szip.bits_per_pixel = 64; break; default: - printf("Warning: Invalid numeric type of size <%u> for SZIP\n",(unsigned)size); + printf("Warning: Invalid numeric type of size <%d> for SZIP\n",size); return 0; }} diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index cc3f6ea..8056fcc 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_main.c @@ -61,7 +61,7 @@ int main(int argc, char **argv) else if (strcmp(argv[i], "-m") == 0) { options.threshold = parse_number(argv[i+1]); - if ((int)options.threshold==-1) { + if (options.threshold==-1) { printf("Error: Invalid treshold size <%s>\n",argv[i+1]); exit(1); } diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c index 45dfac5..fa7fd11 100644 --- a/tools/h5repack/h5repack_opttable.c +++ b/tools/h5repack/h5repack_opttable.c @@ -41,7 +41,7 @@ void init_packobject(pack_info_t *obj) } obj->chunk.rank = -1; obj->refobj_id = -1; - obj->layout = H5D_LAYOUT_ERROR; + obj->layout = -1; obj->nfilters = 0; @@ -104,7 +104,7 @@ static int aux_inctable(pack_opttbl_t *table, int n_objs ) } table->objs[i].chunk.rank = -1; table->objs[i].refobj_id = -1; - table->objs[i].layout = H5D_LAYOUT_ERROR; + table->objs[i].layout = -1; table->objs[i].nfilters = 0; } return 0; @@ -148,7 +148,7 @@ int options_table_init( pack_opttbl_t **tbl ) } table->objs[i].chunk.rank = -1; table->objs[i].refobj_id = -1; - table->objs[i].layout = H5D_LAYOUT_ERROR; + table->objs[i].layout = -1; table->objs[i].nfilters = 0; } diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c index e824493..1035a06 100644 --- a/tools/h5repack/h5repack_refs.c +++ b/tools/h5repack/h5repack_refs.c @@ -20,7 +20,8 @@ #include "h5repack.h" static const char* MapIdToName(hid_t refobj_id, - trav_table_t *travt); + trav_table_t *travt, + const char* fname); static void close_obj(H5G_obj_t obj_type, hid_t obj_id); @@ -29,7 +30,9 @@ 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 fidout, /* for saving references */ + hid_t fidin, + const char *fname ); /*------------------------------------------------------------------------- @@ -50,17 +53,18 @@ static int copy_refs_attr(hid_t loc_in, int do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, - pack_opt_t *options) /* repack options */ + pack_opt_t *options, /* repack options */ + const char *fnamein) { - hid_t grp_in=-1; /* group ID */ - hid_t grp_out=-1; /* group ID */ - hid_t dset_in=-1; /* read dataset ID */ - hid_t dset_out=-1; /* write dataset ID */ - hid_t type_in=-1; /* named type ID */ - hid_t dcpl_id=-1; /* dataset creation property list ID */ - hid_t space_id=-1; /* space ID */ - hid_t ftype_id=-1; /* file data type ID */ - hid_t mtype_id=-1; /* memory data type ID */ + hid_t grp_in; /* group ID */ + hid_t grp_out; /* group ID */ + hid_t dset_in; /* read dataset ID */ + hid_t dset_out; /* write dataset ID */ + hid_t type_in; /* named type ID */ + hid_t dcpl_id; /* dataset creation property list ID */ + hid_t space_id; /* space ID */ + hid_t ftype_id; /* file data type ID */ + hid_t mtype_id; /* memory data type ID */ size_t msize; /* memory size of memory type */ hsize_t nelmts; /* number of elements in dataset */ int rank; /* rank of dataset */ @@ -186,7 +190,7 @@ int do_copy_refobjs(hid_t fidin, } 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) + if ((refname=MapIdToName(refobj_id,travt,fnamein))!=NULL) { /* create the reference, -1 parameter for objects */ if (H5Rcreate(&refbuf[u],fidout,refname,H5R_OBJECT,-1)<0) @@ -266,7 +270,7 @@ int do_copy_refobjs(hid_t fidin, /* get the name. a valid name could only occur in the second traversal of the file */ - if ((refname=MapIdToName(refobj_id,travt))!=NULL) + if ((refname=MapIdToName(refobj_id,travt,fnamein))!=NULL) { hid_t region_id; /* region id of the referenced dataset */ if ((region_id = H5Rget_region(dset_in,H5R_DATASET_REGION,&buf[u]))<0) @@ -319,7 +323,7 @@ int do_copy_refobjs(hid_t fidin, * copy referenced objects in attributes *------------------------------------------------------------------------- */ - if (copy_refs_attr(dset_in,dset_out,options,travt,fidout)<0) + if (copy_refs_attr(dset_in,dset_out,options,travt,fidout,fidin,fnamein)<0) goto error; @@ -406,7 +410,7 @@ int do_copy_refobjs(hid_t fidin, if ((grp_in = H5Gopen(fidin,"/"))<0) goto error; - if (copy_refs_attr(grp_in,grp_out,options,travt,fidout)<0) + if (copy_refs_attr(grp_in,grp_out,options,travt,fidout,fidin,fnamein)<0) goto error; if (H5Gclose(grp_out)<0) @@ -455,14 +459,16 @@ 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 fidout, /* for saving references */ + hid_t fidin, + const char *fnamein ) { - hid_t attr_id=-1; /* attr ID */ - hid_t attr_out=-1; /* attr ID */ - hid_t space_id=-1; /* space ID */ - hid_t ftype_id=-1; /* file data type ID */ - hid_t mtype_id=-1; /* memory data type ID */ + hid_t attr_id; /* attr ID */ + hid_t attr_out; /* attr ID */ + hid_t space_id; /* space ID */ + hid_t ftype_id; /* file data type ID */ + hid_t mtype_id; /* memory data type ID */ size_t msize; /* memory size of type */ hsize_t nelmts; /* number of elements in dataset */ int rank; /* rank of dataset */ @@ -558,7 +564,7 @@ static int copy_refs_attr(hid_t loc_in, } 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) + if ((refname=MapIdToName(refobj_id,travt,fnamein))!=NULL) { /* create the reference */ if (H5Rcreate(&refbuf[k],fidout,refname,H5R_OBJECT,-1)<0) @@ -640,7 +646,7 @@ static int copy_refs_attr(hid_t loc_in, } 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) + if ((refname=MapIdToName(refobj_id,travt,fnamein))!=NULL) { hid_t region_id; /* region id of the referenced dataset */ if ((region_id = H5Rget_region(attr_id,H5R_DATASET_REGION,&buf[k]))<0) @@ -738,16 +744,17 @@ static void close_obj(H5G_obj_t obj_type, hid_t obj_id) */ static const char* MapIdToName(hid_t refobj_id, - trav_table_t *travt) + trav_table_t *travt, + const char* fname) { 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) - { - return NULL; + /* open */ + if ((fid=H5Fopen(fname,H5F_ACC_RDONLY,H5P_DEFAULT))<0 ){ + printf("h5repack: <%s>: %s\n", fname, H5FOPENERROR ); + exit(1); } /* linear search */ @@ -778,8 +785,7 @@ static const char* MapIdToName(hid_t refobj_id, } /* switch */ } /* i */ - if (H5Fclose(fid)<0) - return NULL; + H5Fclose(fid); return NULL; } diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c index 4f69d5f..e1c01eb 100644 --- a/tools/h5repack/h5repack_verify.c +++ b/tools/h5repack/h5repack_verify.c @@ -157,9 +157,9 @@ int h5repack_verify(const char *fname, pack_opt_t *options) { hid_t fid; /* file ID */ - hid_t dset_id=-1; /* dataset ID */ - hid_t dcpl_id=-1; /* dataset creation property list ID */ - hid_t space_id=-1; /* space ID */ + hid_t dset_id; /* dataset ID */ + hid_t dcpl_id; /* dataset creation property list ID */ + hid_t space_id; /* space ID */ int ret=1, i, j; trav_table_t *travt=NULL; @@ -343,12 +343,12 @@ error: int h5repack_cmpdcpl(const char *fname1, const char *fname2) { - hid_t fid1=-1; /* file ID */ - hid_t fid2=-1; /* file ID */ - hid_t dset1=-1; /* dataset ID */ - hid_t dset2=-1; /* dataset ID */ - hid_t dcpl1=-1; /* dataset creation property list ID */ - hid_t dcpl2=-1; /* dataset creation property list ID */ + hid_t fid1; /* file ID */ + hid_t fid2; /* file ID */ + hid_t dset1; /* dataset ID */ + hid_t dset2; /* dataset ID */ + hid_t dcpl1; /* dataset creation property list ID */ + hid_t dcpl2; /* dataset creation property list ID */ trav_table_t *travt1=NULL; trav_table_t *travt2=NULL; int ret=1, i; diff --git a/tools/h5repack/testh5repack_dset.c b/tools/h5repack/testh5repack_dset.c index 57a5b27..74ca97e 100644 --- a/tools/h5repack/testh5repack_dset.c +++ b/tools/h5repack/testh5repack_dset.c @@ -17,9 +17,7 @@ #include "h5repack.h" static void make_dset_reg_ref(hid_t loc_id); -#ifdef LATER static void read_dset_reg_ref(hid_t loc_id); -#endif /* LATER */ @@ -82,6 +80,7 @@ void write_dset_in(hid_t loc_id, char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */ s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */ hobj_ref_t buf42[3][2]; /* reference */ + e_t buf452[3][2]; /* enum */ hvl_t buf52[3][2]; /* vlen */ int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ @@ -95,6 +94,7 @@ void write_dset_in(hid_t loc_id, char buf23[4][3][2]; /* bitfield, opaque */ s_t buf33[4][3][2]; /* compound */ hobj_ref_t buf43[4][3][2]; /* reference */ + e_t buf453[4][3][2]; /* enum */ hvl_t buf53[4][3][2]; /* vlen */ int buf63[24][3]; /* array */ int buf73[4][3][2]; /* integer */ @@ -360,6 +360,13 @@ void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ + for (i=0; i<3; i++) + for (j=0; j<2; j++) + { + if (make_diffs) buf452[i][j]=GREEN; else buf452[i][j]=RED; + } + + type_id = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(type_id, "RED", (val = 0, &val)); H5Tenum_insert(type_id, "GREEN", (val = 1, &val)); @@ -539,6 +546,15 @@ void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ + + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) buf453[i][j][k]=RED; else buf453[i][j][k]=GREEN; + } + } + } + type_id = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(type_id, "RED", (val = 0, &val)); H5Tenum_insert(type_id, "GREEN", (val = 1, &val)); @@ -725,7 +741,6 @@ static void make_dset_reg_ref(hid_t loc_id) *------------------------------------------------------------------------- */ -#ifdef LATER static void read_dset_reg_ref(hid_t loc_id) { hid_t dset1; /* Dataset ID */ @@ -823,4 +838,3 @@ static void read_dset_reg_ref(hid_t loc_id) free(rbuf); free(drbuf); } -#endif /* LATER */ diff --git a/tools/h5repack/testh5repack_main.c b/tools/h5repack/testh5repack_main.c index ddecd98..1959ea2 100644 --- a/tools/h5repack/testh5repack_main.c +++ b/tools/h5repack/testh5repack_main.c @@ -38,6 +38,7 @@ int main (void) { + int verbose=0; pack_opt_t pack_options; diff_opt_t diff_options; memset(&diff_options, 0, sizeof (diff_opt_t)); @@ -58,14 +59,14 @@ int main (void) * it returns RET==0 if the objects have the same data *------------------------------------------------------------------------- */ - + TESTING(" copy of datasets"); /*------------------------------------------------------------------------- * file with all kinds of dataset datatypes *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0)<0) + if (h5repack_init (&pack_options, verbose)<0) TEST_ERROR; if (h5repack(FNAME1,FNAME1OUT,&pack_options)<0) TEST_ERROR; @@ -124,6 +125,7 @@ int main (void) *------------------------------------------------------------------------- */ PASSED(); + TESTING(" copy of datasets with all filters"); if (h5repack_init (&pack_options, 0)<0) diff --git a/tools/h5repack/testh5repack_make.c b/tools/h5repack/testh5repack_make.c index c69abd9..3b8cb5c 100644 --- a/tools/h5repack/testh5repack_make.c +++ b/tools/h5repack/testh5repack_make.c @@ -20,7 +20,7 @@ int make_all_objects(hid_t loc_id); int make_attributes(hid_t loc_id); int make_special_objects(hid_t loc_id); -int make_early(void); +int make_early(); @@ -245,6 +245,7 @@ int make_special_objects(hid_t loc_id) hid_t dset_id; hid_t space_id; hid_t plist_id; + herr_t status; int fillvalue=2; /*------------------------------------------------------------------------- @@ -289,13 +290,13 @@ int make_special_objects(hid_t loc_id) */ plist_id = H5Pcreate(H5P_DATASET_CREATE); - H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &fillvalue); + status = H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &fillvalue); space_id = H5Screate_simple(2,dims,NULL); dset_id = H5Dcreate(loc_id,"dset_fill",H5T_NATIVE_INT,space_id,plist_id); - H5Dwrite(dset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf); - H5Pclose(plist_id); - H5Dclose(dset_id); - H5Sclose(space_id); + status = H5Dwrite(dset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf); + status = H5Pclose(plist_id); + status = H5Dclose(dset_id); + status = H5Sclose(space_id); return 0; @@ -309,15 +310,15 @@ int make_special_objects(hid_t loc_id) * *------------------------------------------------------------------------- */ -int make_early(void) +int make_early() { hsize_t dims[1] ={3000}; hsize_t cdims[1]={30}; - hid_t fid=-1; - hid_t dset_id=-1; - hid_t sid=-1; - hid_t tid=-1; - hid_t dcpl=-1; + hid_t fid; + hid_t dset_id; + hid_t sid; + hid_t tid; + hid_t dcpl; int i; char name[10]; int iter=100; |