From be7ebb248fbe7d887b44b4aecbfe80f2517d53b1 Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Thu, 8 Jan 2004 10:53:32 -0500 Subject: [svn-r8040] Purpose: bug fix, code improvment Description: fixed a bug in the parse of chunking function added some auxiliary functions to avoid repeated parts of the code in several places Solution: Platforms tested: linux solaris AIX Misc. update: --- tools/h5repack/h5repack.c | 4 +- tools/h5repack/h5repack.h | 4 ++ tools/h5repack/h5repack_copy.c | 11 ++++++ tools/h5repack/h5repack_filters.c | 80 ++++++++++++++++++++++++++------------ tools/h5repack/h5repack_main.c | 8 ++-- tools/h5repack/h5repack_opttable.c | 34 +++++++++++++++- tools/h5repack/h5repack_parse.c | 8 ++++ tools/h5repack/h5repack_verify.c | 1 + 8 files changed, 119 insertions(+), 31 deletions(-) diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index 147b6db..a6a6989 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -178,8 +178,10 @@ int h5repack_addlayout(const char* str, obj_list_t *obj_list=NULL; /*one object list for the -t and -c option entry */ int n_objs; /*number of objects in the current -t or -c option entry */ - int j; pack_info_t pack; /*info about layout to extract from parse */ + int j; + + init_packobject(&pack); if (options->all_layout==1){ printf("Error: Invalid layout input: all option \ diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index 965219e..0b82aea 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -175,6 +175,10 @@ int do_copy_refobjs_inattr(hid_t loc_in, void read_info(const char *filename,pack_opt_t *options); void close_obj(H5G_obj_t obj_type, hid_t obj_id); +void init_packobject(pack_info_t *obj); +int print_filters(hid_t dcpl_id); + + /*------------------------------------------------------------------------- * filters diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 2d6752b..3ca7c11 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -231,6 +231,9 @@ int do_copy_file(hid_t fidin, if ((msize=H5Tget_size(mtype_id))==0) goto error; + if (options->verbose) + print_filters(dcpl_id); + /*------------------------------------------------------------------------- * object references are a special case @@ -243,6 +246,7 @@ int do_copy_file(hid_t fidin, /* the information about the object to be filtered/"layouted" */ pack_info_t obj; + init_packobject(&obj); /* get the storage size of the input dataset */ dsize_in=H5Dget_storage_size(dset_in); @@ -278,6 +282,13 @@ int do_copy_file(hid_t fidin, */ if (filter_this(travt->objs[i].name,options,&obj)) { + /* filters require CHUNK layout; if we do not have one define a default */ + if (obj.chunk.rank==0) + { + obj.chunk.rank=rank; + for (j=0; jfilter[j].filtn = -1; - } - obj->nfilters=1; obj->filter[0]=filt; @@ -101,6 +94,62 @@ int filter_this(const char* name, /* object name from traverse list */ } +/*------------------------------------------------------------------------- + * Function: print_filters + * + * Purpose: print the filters in DCPL + * + * Return: 0, ok, -1 no + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: December 19, 2003 + * + *------------------------------------------------------------------------- + */ + +int print_filters(hid_t dcpl_id) +{ + int nfilters; /* number of filters */ + unsigned filt_flags; /* filter flags */ + H5Z_filter_t filtn; /* filter identification number */ + unsigned cd_values[20]; /* filter client data values */ + size_t cd_nelmts; /* filter client number of values */ + size_t cd_num; /* filter client data counter */ + char f_name[256]; /* filter/file name */ + char s[64]; /* temporary string buffer */ + int i; + + /* get information about filters */ + if ((nfilters = H5Pget_nfilters(dcpl_id))<0) + return -1; + + for (i=0; iverbose) - { - f_name[sizeof(f_name)-1] = '\0'; - sprintf(s, "Filter-%d:", i); - printf(" %-10s %s-%u %s {", s, - f_name[0]?f_name:"method", - (unsigned)filtn, - filt_flags & H5Z_FLAG_OPTIONAL?"OPT":""); - for (cd_num=0; cd_numpath,"\0"); + for ( j=0; jfilter[j].filtn = -1; + for ( k=0; kfilter[j].cd_values[k] = -1; + } + obj->chunk.rank = -1; + obj->refobj_id = -1; + obj->layout = -1; + obj->nfilters = 0; + + +} + /*------------------------------------------------------------------------- * Function: aux_tblinsert_filter * @@ -28,8 +58,8 @@ */ static void aux_tblinsert_filter(pack_opttbl_t *table, - int I, - filter_info_t filt) + int I, + filter_info_t filt) { if (table->objs[ I ].nfilters(int)len) + { + if (obj_list) free(obj_list); + printf("Parse layout error: <%s> Chunk dimensions missing\n",str); + exit(1); + } + for ( i=j, c_index=0; iall_layout==1){ pack_info_t pack; + init_packobject(&pack); pack.layout=options->layout_g; pack.chunk=options->chunk_g; if (has_layout(dcpl_id,&pack)==0) -- cgit v0.12