diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-02-12 20:52:34 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-02-12 20:52:34 (GMT) |
commit | 2f69871352b89bb99646a56d0e765829cbd8d527 (patch) | |
tree | b9efef768bcd894860a357b4655cf13b4928685c /tools | |
parent | 54a5561c78a2a229075b84219c883a38e28e5690 (diff) | |
download | hdf5-2f69871352b89bb99646a56d0e765829cbd8d527.zip hdf5-2f69871352b89bb99646a56d0e765829cbd8d527.tar.gz hdf5-2f69871352b89bb99646a56d0e765829cbd8d527.tar.bz2 |
[svn-r14558] remove commented code
tested: windows, linux, solaris
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5repack/h5repack.c | 387 | ||||
-rw-r--r-- | tools/h5repack/h5repack.h | 71 | ||||
-rw-r--r-- | tools/h5repack/h5repack_parse.c | 285 | ||||
-rw-r--r-- | tools/h5repack/h5repack_verify.c | 477 |
4 files changed, 0 insertions, 1220 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index 1318129..8246a73 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -576,390 +576,3 @@ static const char* get_sfilter(H5Z_filter_t filtn) - - - - - -#if 0 - -extern char *progname; - - -/*------------------------------------------------------------------------- - * File: h5repack.c - * Purpose: Public API functions - *------------------------------------------------------------------------- - */ - -static int check_options(pack_opt_t *options); - - -/*------------------------------------------------------------------------- - * Function: aux_initglb_filter - * - * Purpose: auxiliary function, initialize the options global filter - * - * Return: void - * - *------------------------------------------------------------------------- - */ -static void aux_initglb_filter(pack_opt_t *options) -{ - int k; - options->filter_g.filtn = -1; - for ( k=0; k<CDVALUES; k++) - options->filter_g.cd_values[k] = -1; -} - - -/*------------------------------------------------------------------------- - * Function: h5repack - * - * Purpose: locate all high-level HDF5 objects in the file - * and compress/chunk them using options - * - * Algorythm: 2 traversals are made to the file; the 1st builds a list of - * the objects, the 2nd makes a copy of them, using the options; - * the reason for the 1st traversal is to check for invalid - * object name requests - * - * Return: 0, ok, -1, fail - * - * Programmer: pvn@ncsa.uiuc.edu - * - * Date: September, 22, 2003 - * - *------------------------------------------------------------------------- - */ -int h5repack(const char* infile, - const char* outfile, - pack_opt_t *options) -{ - /* check input */ - if (check_options(options)<0) - return -1; - - /* check for objects in input that are in the file */ - if (check_objects(infile,options) < 0) - return -1; - - /* copy the objects */ - if (copy_objects(infile,outfile,options) < 0) - return -1; - - - return 0; -} - - - -/*------------------------------------------------------------------------- - * Function: h5repack_init - * - * Purpose: initialize options - * - * Return: 0, ok, -1, fail - * - *------------------------------------------------------------------------- - */ - -int h5repack_init (pack_opt_t *options, - int verbose) -{ - memset(options,0,sizeof(pack_opt_t)); - options->threshold = 1024; - options->verbose = verbose; - return (options_table_init(&(options->op_tbl))); -} - -/*------------------------------------------------------------------------- - * Function: h5repack_end - * - * Purpose: free options table - * - *------------------------------------------------------------------------- - */ - -int h5repack_end (pack_opt_t *options) -{ - return options_table_free(options->op_tbl); -} - -/*------------------------------------------------------------------------- - * Function: h5repack_addfilter - * - * Purpose: add a compression -f option to table - * Example: -f dset:GZIP=6 - * - * Return: 0, ok, -1, fail - * - *------------------------------------------------------------------------- - */ - -int h5repack_addfilter(const char* str, - pack_opt_t *options) -{ - obj_list_t *obj_list=NULL; /*one object list for the -f and -c option entry */ - filter_info_t filt; /*filter info for the current -f option entry */ - int n_objs; /*number of objects in the current -f or -c option entry */ - - if (options->all_filter==1){ - error_msg(progname, "invalid compression input: 'all' option is present \ - with other objects <%s>\n",str); - return -1; - } - - /* parse the -f option */ - obj_list=parse_filter(str,&n_objs,&filt,options); - if (obj_list==NULL) - { - return -1; - } - - if (options->all_filter==1) - { - /* if we are compressing all set the global filter type */ - aux_initglb_filter(options); - options->filter_g=filt; - } - - if (options->all_filter==0) - options_add_filter(obj_list,n_objs,filt,options->op_tbl); - - free(obj_list); - return 0; -} - - -/*------------------------------------------------------------------------- - * Function: h5repack_addlayout - * - * Purpose: add a layout option - * - * Return: 0, ok, -1, fail - * - *------------------------------------------------------------------------- - */ - - -int h5repack_addlayout(const char* str, - pack_opt_t *options) -{ - - 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 */ - pack_info_t pack; /*info about layout to extract from parse */ - int j; - - init_packobject(&pack); - - if (options->all_layout==1){ - error_msg(progname, "invalid layout input: 'all' option \ - is present with other objects <%s>\n",str); - return -1; - } - - /* parse the layout option */ - obj_list=parse_layout(str,&n_objs,&pack,options); - if (obj_list==NULL) - return -1; - - /* set global layout option */ - if (options->all_layout==1 ) - { - options->layout_g=pack.layout; - if (pack.layout==H5D_CHUNKED) - { - /* -2 means the NONE option, remove chunking - and set the global layout to contiguous */ - if (pack.chunk.rank==-2) - { - options->layout_g = H5D_CONTIGUOUS; - } - /* otherwise set the global chunking type */ - else - { - options->chunk_g.rank=pack.chunk.rank; - for (j = 0; j < pack.chunk.rank; j++) - options->chunk_g.chunk_lengths[j] = pack.chunk.chunk_lengths[j]; - } - } - } - - if (options->all_layout==0) - options_add_layout(obj_list, - n_objs, - &pack, - options->op_tbl); - - free(obj_list); - return 0; -} - - -/*------------------------------------------------------------------------- - * Function: check_options - * - * Purpose: print options, checks for invalid options - * - * Return: void, return -1 on error - * - * Programmer: pvn@ncsa.uiuc.edu - * - * Date: September, 22, 2003 - * - *------------------------------------------------------------------------- - */ -static int check_options(pack_opt_t *options) -{ - unsigned int i; - int k, j, has_cp=0, has_ck=0; - char slayout[30]; - - /*------------------------------------------------------------------------- - * objects to layout - *------------------------------------------------------------------------- - */ - if (options->verbose && have_request(options) /* only print if requested */) - { - printf("Objects to modify layout are...\n"); - if (options->all_layout==1) { - switch (options->layout_g) - { - case H5D_COMPACT: - strcpy(slayout,"compact"); - break; - case H5D_CONTIGUOUS: - strcpy(slayout,"contiguous"); - break; - case H5D_CHUNKED: - strcpy(slayout,"chunked"); - break; - default: - strcpy(slayout,"unknown"); - break; - } - printf(" Apply %s layout to all\n", slayout); - if (H5D_CHUNKED==options->layout_g) { - printf("with dimension ["); - for ( j = 0; j < options->chunk_g.rank; j++) - printf("%d ",(int)options->chunk_g.chunk_lengths[j]); - printf("]\n"); - } - } - }/* verbose */ - - for ( i = 0; i < options->op_tbl->nelems; i++) - { - char* name=options->op_tbl->objs[i].path; - - if (options->op_tbl->objs[i].chunk.rank>0) - { - if (options->verbose){ - printf(" <%s> with chunk size ",name); - for ( k = 0; k < options->op_tbl->objs[i].chunk.rank; k++) - printf("%d ",(int)options->op_tbl->objs[i].chunk.chunk_lengths[k]); - printf("\n"); - } - has_ck=1; - } - else if (options->op_tbl->objs[i].chunk.rank==-2) - { - if (options->verbose) - printf(" <%s> %s\n",name,"NONE (contigous)"); - has_ck=1; - } - } - - if (options->all_layout==1 && has_ck){ - error_msg(progname, "invalid chunking input: 'all' option\ - is present with other objects\n"); - return -1; - } - - /*------------------------------------------------------------------------- - * objects to filter - *------------------------------------------------------------------------- - */ - - if (options->verbose && have_request(options) /* only print if requested */) - { - printf("Objects to apply filter are...\n"); - if (options->all_filter==1) - { - H5Z_filter_t filtn=options->filter_g.filtn; - switch (filtn) - { - case H5Z_FILTER_NONE: - printf(" Uncompress all\n"); - break; - case H5Z_FILTER_SHUFFLE: - case H5Z_FILTER_FLETCHER32: - printf(" All with %s\n",get_sfilter(filtn)); - break; - case H5Z_FILTER_SZIP: - case H5Z_FILTER_DEFLATE: - printf(" All with %s, parameter %d\n", - get_sfilter(filtn), - options->filter_g.cd_values[0]); - break; - }; - } - } /* verbose */ - - for ( i = 0; i < options->op_tbl->nelems; i++) - { - pack_info_t pack = options->op_tbl->objs[i]; - char* name = pack.path; - - for ( j=0; j<pack.nfilters; j++) - { - if (options->verbose) - { - printf(" <%s> with %s filter\n", - name, - get_sfilter(pack.filter[j].filtn)); - } - - has_cp=1; - - } /* j */ - } /* i */ - - if (options->all_filter==1 && has_cp){ - error_msg(progname, "invalid compression input: 'all' option\ - is present with other objects\n"); - return -1; - } - - - return 0; -} - - - -/*------------------------------------------------------------------------- - * Function: have_request - * - * Purpose: check if a filter or layout was requested - * - * Return: 1 yes, 0 no - * - * Date: May, 24, 2007 - * - *------------------------------------------------------------------------- - */ -int have_request(pack_opt_t *options) -{ - - if (options->all_filter || options->all_layout || options->op_tbl->nelems) - return 1; - - return 0; - -} - -#endif - - diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index 13af382..b5d7554 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -51,18 +51,6 @@ typedef struct { */ - -#if 0 - -#define CDVALUES 2 - -typedef struct { - H5Z_filter_t filtn; /* filter identification number */ - int cd_values[CDVALUES]; /* filter client data values */ -} filter_info_t; - -#else - #define CD_VALUES 20 typedef struct { @@ -72,7 +60,6 @@ typedef struct { } filter_info_t; -#endif /* chunk lengths along each dimension and rank */ typedef struct { @@ -108,31 +95,6 @@ typedef struct { */ /* all the above, ready to go to the hrepack call */ - - -#if 0 - -typedef struct { - pack_opttbl_t *op_tbl; /*table with all -c and -f options */ - int all_layout; /*apply the layout to all objects */ - int all_filter; /*apply the filter to all objects */ - -#ifdef OLD - filter_info_t filter_g; /*global filter INFO for the ALL case */ -#else - filter_info_t filter_g[H5_REPACK_MAX_NFILTERS]; /*global filter array for the ALL case */ -#endif - - - 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 use_native; /*use a native type in write */ -} pack_opt_t; - -#else - typedef struct { pack_opttbl_t *op_tbl; /*table with all -c and -f options */ int all_layout; /*apply the layout to all objects */ @@ -149,8 +111,6 @@ typedef struct { -#endif - /*------------------------------------------------------------------------- * public functions *------------------------------------------------------------------------- @@ -181,12 +141,6 @@ int h5repack_cmpdcpl (const char *fname1, *------------------------------------------------------------------------- */ -#if 0 -int check_objects(const char* fname, - pack_opt_t *options); - -#endif - int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options); @@ -200,12 +154,6 @@ int do_copy_refobjs(hid_t fidin, void init_packobject(pack_info_t *obj); int print_filters(hid_t dcpl_id); -#if 0 -int have_request(pack_opt_t *options); -#endif - - - /*------------------------------------------------------------------------- * filters @@ -233,11 +181,6 @@ int can_read(const char* name, /* object name from traverse list */ *------------------------------------------------------------------------- */ -#if 0 -int has_layout(hid_t dcpl_id, - pack_info_t *obj); -#endif - int layout_this(hid_t dcpl_id, /* DCPL from input object */ const char* name, /* object name from traverse list */ pack_opt_t *options, /* repack options */ @@ -270,32 +213,18 @@ pack_info_t* options_get_object( const char *path, */ -#if 0 -obj_list_t* parse_filter(const char *str, - int *n_objs, - filter_info_t *filt, - pack_opt_t *options); - -#else - obj_list_t* parse_filter(const char *str, int *n_objs, filter_info_t *filt, pack_opt_t *options, int *is_glb); -#endif obj_list_t* parse_layout(const char *str, int *n_objs, pack_info_t *pack, /* info about object */ pack_opt_t *options); -#if 0 -const char* get_sfilter (H5Z_filter_t filtn); -#endif - - int parse_number(char *str); diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c index 7184391..f60f078 100644 --- a/tools/h5repack/h5repack_parse.c +++ b/tools/h5repack/h5repack_parse.c @@ -47,291 +47,7 @@ extern char *progname; *------------------------------------------------------------------------- */ -#if 0 -obj_list_t* parse_filter(const char *str, - int *n_objs, - filter_info_t *filt, - pack_opt_t *options) -{ - unsigned i, u; - char c; - size_t len=strlen(str); - int j, m, n, k, l, end_obj=-1, no_param=0; - char sobj[MAX_NC_NAME]; - char scomp[10]; - char stype[5]; - char smask[3]; - obj_list_t* obj_list=NULL; - unsigned pixels_per_block; - -#if defined(PARSE_DEBUG) - fprintf(stderr,"%s\n",str); -#endif - - /* initialize compression info */ - memset(filt,0,sizeof(filter_info_t)); - - /* check for the end of object list and number of objects */ - for ( i=0, n=0; i<len; i++) - { - c = str[i]; - if ( c==':' ) - { - end_obj=i; - } - if ( c==',' ) - { - n++; - } - } - - if (end_obj==-1) { /* missing : */ - /* apply to all objects */ - options->all_filter=1; - } - - n++; - obj_list=malloc(n*sizeof(obj_list_t)); - if (obj_list==NULL) - { - error_msg(progname, "could not allocate object list\n"); - return NULL; - } - *n_objs=n; - - /* get object list */ - for ( j=0, k=0, n=0; j<end_obj; j++,k++) - { - c = str[j]; - sobj[k]=c; - if ( c==',' || j==end_obj-1) - { - if ( c==',') sobj[k]='\0'; else sobj[k+1]='\0'; - strcpy(obj_list[n].obj,sobj); - memset(sobj,0,sizeof(sobj)); - n++; - k=-1; - } - } - /* nothing after : */ - if (end_obj+1==(int)len) - { - if (obj_list) free(obj_list); - error_msg(progname, "input Error: Invalid compression type in <%s>\n",str); - exit(1); - } - - - /* get filter additional parameters */ - m=0; - for ( i=end_obj+1, k=0, j=0; i<len; i++,k++) - { - c = str[i]; - scomp[k]=c; - if ( c=='=' || i==len-1) - { - if ( c=='=') { /*one more parameter */ - scomp[k]='\0'; /*cut space */ - -/*------------------------------------------------------------------------- - * H5Z_FILTER_SZIP - * szip has the format SZIP=<pixels per block,coding> - * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN' - * example SZIP=8,NN - *------------------------------------------------------------------------- - */ - if (strcmp(scomp,"SZIP")==0) - { - l=-1; /* mask index check */ - for ( m=0,u=i+1; u<len; u++,m++) - { - if (str[u]==',') - { - stype[m]='\0'; /* end digit of szip */ - l=0; /* start EC or NN search */ - u++; /* skip ',' */ - } - c = str[u]; - if (!isdigit(c) && l==-1){ - if (obj_list) free(obj_list); - error_msg(progname, "compression parameter not digit in <%s>\n",str); - exit(1); - } - if (l==-1) - stype[m]=c; - else - { - smask[l]=c; - l++; - if (l==2) - { - smask[l]='\0'; - i=len-1; /* end */ - (*n_objs)--; /* we counted an extra ',' */ - if (strcmp(smask,"NN")==0) - filt->cd_values[j++]=H5_SZIP_NN_OPTION_MASK; - else if (strcmp(smask,"EC")==0) - filt->cd_values[j++]=H5_SZIP_EC_OPTION_MASK; - else - { - error_msg(progname, "szip mask must be 'NN' or 'EC' \n"); - exit(1); - } - - } - } - - } /* u */ - } /*if */ - - - -/*------------------------------------------------------------------------- - * all other filters - *------------------------------------------------------------------------- - */ - - else - { - /* here we could have 1 or 2 digits */ - for ( m=0,u=i+1; u<len; u++,m++) - { - c = str[u]; - if (!isdigit(c)){ - if (obj_list) free(obj_list); - error_msg(progname, "compression parameter is not a digit in <%s>\n",str); - exit(1); - } - stype[m]=c; - } /* u */ - - stype[m]='\0'; - } /*if */ - - - - filt->cd_values[j++]=atoi(stype); - i+=m; /* jump */ - } - else if (i==len-1) { /*no more parameters */ - scomp[k+1]='\0'; - no_param=1; - } - -/*------------------------------------------------------------------------- - * H5Z_FILTER_NONE - *------------------------------------------------------------------------- - */ - if (strcmp(scomp,"NONE")==0) - filt->filtn=H5Z_FILTER_NONE; - -/*------------------------------------------------------------------------- - * H5Z_FILTER_DEFLATE - *------------------------------------------------------------------------- - */ - else if (strcmp(scomp,"GZIP")==0) - { - filt->filtn=H5Z_FILTER_DEFLATE; - if (no_param) { /*no more parameters, GZIP must have parameter */ - if (obj_list) free(obj_list); - error_msg(progname, "missing compression parameter in <%s>\n",str); - exit(1); - } - } - -/*------------------------------------------------------------------------- - * H5Z_FILTER_SZIP - *------------------------------------------------------------------------- - */ - else if (strcmp(scomp,"SZIP")==0) - { - filt->filtn=H5Z_FILTER_SZIP; - if (no_param) { /*no more parameters, SZIP must have parameter */ - if (obj_list) free(obj_list); - error_msg(progname, "missing compression parameter in <%s>\n",str); - exit(1); - } - } - -/*------------------------------------------------------------------------- - * H5Z_FILTER_SHUFFLE - *------------------------------------------------------------------------- - */ - else if (strcmp(scomp,"SHUF")==0) - { - filt->filtn=H5Z_FILTER_SHUFFLE; - if (m>0){ /*shuffle does not have parameter */ - if (obj_list) free(obj_list); - error_msg(progname, "extra parameter in SHUF <%s>\n",str); - exit(1); - } - } -/*------------------------------------------------------------------------- - * H5Z_FILTER_FLETCHER32 - *------------------------------------------------------------------------- - */ - else if (strcmp(scomp,"FLET")==0) - { - filt->filtn=H5Z_FILTER_FLETCHER32; - if (m>0){ /*shuffle does not have parameter */ - if (obj_list) free(obj_list); - error_msg(progname, "extra parameter in FLET <%s>\n",str); - exit(1); - } - } - - else { - if (obj_list) free(obj_list); - error_msg(progname, "invalid filter type in <%s>\n",str); - exit(1); - } - } - } /*i*/ - -/*------------------------------------------------------------------------- - * check valid parameters - *------------------------------------------------------------------------- - */ - - switch (filt->filtn) - { - - case H5Z_FILTER_DEFLATE: - if (filt->cd_values[0]<0 || filt->cd_values[0]>9 ){ - if (obj_list) free(obj_list); - error_msg(progname, "invalid compression parameter in <%s>\n",str); - exit(1); - } - break; - - - case H5Z_FILTER_SZIP: - pixels_per_block=filt->cd_values[0]; - if ((pixels_per_block%2)==1) { - if (obj_list) free(obj_list); - error_msg(progname, "pixels_per_block is not even in <%s>\n",str); - exit(1); - } - if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK) { - if (obj_list) free(obj_list); - error_msg(progname, "pixels_per_block is too large in <%s>\n",str); - exit(1); - } - if ( (strcmp(smask,"NN")!=0) && (strcmp(smask,"EC")!=0) ) { - if (obj_list) free(obj_list); - error_msg(progname, "szip mask must be 'NN' or 'EC' \n"); - exit(1); - } - break; - - }; - - return obj_list; -} - - -#else obj_list_t* parse_filter(const char *str, int *n_objs, @@ -651,7 +367,6 @@ obj_list_t* parse_filter(const char *str, -#endif /*------------------------------------------------------------------------- * Function: get_sfilter diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c index c734405..1a6b62d 100644 --- a/tools/h5repack/h5repack_verify.c +++ b/tools/h5repack/h5repack_verify.c @@ -24,476 +24,6 @@ static int has_filters(hid_t pid, hid_t tid, unsigned nfilters, filter_info_t *f -#if 0 - -extern char *progname; - - -/*------------------------------------------------------------------------- - * Function: has_filter - * - * Purpose: verify if a filter is present in the property list DCPL_ID - * - * Return: 1 has, 0 does not, -1 error - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: December 19, 2003 - * - *------------------------------------------------------------------------- - */ - -int has_filter(hid_t dcpl_id, - H5Z_filter_t filtnin) -{ - - 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 */ - char f_name[256]; /* filter name */ - int have=0; /* flag, filter is present */ - int i; /* index */ - - /* if no information about the input filter is requested return exit */ - if (filtnin==-1) - return 1; - - /* get information about filters */ - if ((nfilters = H5Pget_nfilters(dcpl_id))<0) - return -1; - - /* if we do not have filters and the requested filter is NONE, return 1 */ - if (!nfilters && filtnin==H5Z_FILTER_NONE) - return 1; - - for (i=0; i<nfilters; i++) - { - cd_nelmts = NELMTS(cd_values); - - filtn = H5Pget_filter(dcpl_id, - (unsigned)i, - &filt_flags, - &cd_nelmts, - cd_values, - sizeof(f_name), - f_name); - - - if (filtnin==filtn) - have=1; - - } - - return have; -} - - -/*------------------------------------------------------------------------- - * Function: has_layout - * - * Purpose: verify which layout is present in the property list DCPL_ID - * - * H5D_COMPACT = 0 - * H5D_CONTIGUOUS = 1 - * H5D_CHUNKED = 2 - * - * Return: 1 has, 0 does not, -1 error - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: December 30, 2003 - * - *------------------------------------------------------------------------- - */ - -int has_layout(hid_t dcpl_id, - pack_info_t *obj) -{ - hsize_t chsize[64]; /* chunk size in elements */ - H5D_layout_t layout; /* layout */ - int nfilters; /* number of filters */ - int rank; /* rank */ - int i; /* index */ - - /* if no information about the input layout is requested return exit */ - if (obj==NULL) - return 1; - - /* check if we have filters in the input object */ - if ((nfilters = H5Pget_nfilters(dcpl_id))<0) - return -1; - - /* a non chunked layout was requested on a filtered object; avoid the test */ - if (nfilters && obj->layout!=H5D_CHUNKED) - return 1; - - /* get layout */ - if ((layout = H5Pget_layout(dcpl_id))<0) - return -1; - - if (obj->layout != layout) - return 0; - - if (layout==H5D_CHUNKED) - { - if ((rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize/*out*/))<0) - return -1; - if (obj->chunk.rank != rank) - return 0; - for ( i=0; i<rank; i++) - if (chsize[i] != obj->chunk.chunk_lengths[i]) - return 0; - } - - return 1; -} - - -/*------------------------------------------------------------------------- - * Function: h5repack_verify - * - * Purpose: verify if the filters specified in the options list are - * present on the OUTPUT file - * - * Return: 1=filter present, 0=filter not present, -1=error - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: December 19, 2003 - * - *------------------------------------------------------------------------- - */ - -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 */ - int ret=1; - unsigned int i; - int j; - trav_table_t *travt=NULL; - - /* open the file */ - if ((fid=H5Fopen(fname,H5F_ACC_RDONLY,H5P_DEFAULT))<0 ) - return -1; - - for ( i=0; i<options->op_tbl->nelems; i++) - { - char* name=options->op_tbl->objs[i].path; - pack_info_t *obj = &options->op_tbl->objs[i]; - -/*------------------------------------------------------------------------- - * open - *------------------------------------------------------------------------- - */ - if ((dset_id=H5Dopen(fid,name))<0) - goto error; - if ((space_id=H5Dget_space(dset_id))<0) - goto error; - if ((dcpl_id=H5Dget_create_plist(dset_id))<0) - goto error; - -/*------------------------------------------------------------------------- - * filter check - *------------------------------------------------------------------------- - */ - for ( j=0; j<obj->nfilters; j++) - { - if (has_filter(dcpl_id,obj->filter[j].filtn)==0) - ret=0; - } - -/*------------------------------------------------------------------------- - * layout check - *------------------------------------------------------------------------- - */ - if ((obj->layout!=-1) && (has_layout(dcpl_id,obj)==0)) - ret=0; - -/*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - if (H5Pclose(dcpl_id)<0) - goto error; - if (H5Sclose(space_id)<0) - goto error; - if (H5Dclose(dset_id)<0) - goto error; - - } - - -/*------------------------------------------------------------------------- - * check for the "all" objects option - *------------------------------------------------------------------------- - */ - - if (options->all_filter==1 || options->all_layout==1) - { - - /* init table */ - trav_table_init(&travt); - - /* get the list of objects in the file */ - if (h5trav_gettable(fid,travt)<0) - goto error; - - for ( i=0; i<travt->nobjs; i++) - { - char* name=travt->objs[i].name; - - switch ( travt->objs[i].type ) - { - case H5G_DATASET: - - /*------------------------------------------------------------------------- - * open - *------------------------------------------------------------------------- - */ - if ((dset_id=H5Dopen(fid,name))<0) - goto error; - if ((space_id=H5Dget_space(dset_id))<0) - goto error; - if ((dcpl_id=H5Dget_create_plist(dset_id))<0) - goto error; - - /*------------------------------------------------------------------------- - * filter check - *------------------------------------------------------------------------- - */ - if (options->all_filter==1 ){ - if (has_filter(dcpl_id,options->filter_g.filtn)==0) - ret=0; - } - - /*------------------------------------------------------------------------- - * layout check - *------------------------------------------------------------------------- - */ - if (options->all_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) - ret=0; - } - - - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - if (H5Pclose(dcpl_id)<0) - goto error; - if (H5Sclose(space_id)<0) - goto error; - if (H5Dclose(dset_id)<0) - goto error; - - break; - default: - break; - } /* switch */ - - } /* i */ - - /* free table */ - trav_table_free(travt); - } - -/*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - - if (H5Fclose(fid)<0) - return -1; - - return ret; - -error: - H5E_BEGIN_TRY { - H5Pclose(dcpl_id); - H5Sclose(space_id); - H5Dclose(dset_id); - H5Fclose(fid); - if (travt) - trav_table_free(travt); - } H5E_END_TRY; - return -1; -} - - - -/*------------------------------------------------------------------------- - * Function: h5repack_cmpdcpl - * - * Purpose: compare 2 files for identical property lists of all objects - * - * Return: 1=identical, 0=not identical, -1=error - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: December 31, 2003 - * - *------------------------------------------------------------------------- - */ - -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 */ - trav_table_t *travt1=NULL; - trav_table_t *travt2=NULL; - int ret=1; - unsigned int i; - -/*------------------------------------------------------------------------- - * open the files first; if they are not valid, no point in continuing - *------------------------------------------------------------------------- - */ - - /* disable error reporting */ - H5E_BEGIN_TRY { - - /* Open the files */ - if ((fid1=H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT))<0 ) - { - error_msg(progname, "<%s>: %s\n", fname1, H5FOPENERROR ); - return -1; - } - if ((fid2=H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT))<0 ) - { - error_msg(progname, "<%s>: %s\n", fname2, H5FOPENERROR ); - H5Fclose(fid1); - return -1; - } - /* enable error reporting */ - } H5E_END_TRY; - -/*------------------------------------------------------------------------- - * get file table list of objects - *------------------------------------------------------------------------- - */ - trav_table_init(&travt1); - trav_table_init(&travt2); - if (h5trav_gettable(fid1,travt1)<0) - goto error; - if (h5trav_gettable(fid2,travt2)<0) - goto error; - - -/*------------------------------------------------------------------------- - * traverse the suppplied object list - *------------------------------------------------------------------------- - */ - - for ( i=0; i < travt1->nobjs; i++) - { - switch ( travt1->objs[i].type ) - { -/*------------------------------------------------------------------------- - * nothing to do for groups, links and types - *------------------------------------------------------------------------- - */ - default: - break; - -/*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ - case H5G_DATASET: - if ((dset1=H5Dopen(fid1,travt1->objs[i].name))<0) - goto error; - if ((dset2=H5Dopen(fid2,travt1->objs[i].name))<0) - goto error; - if ((dcpl1=H5Dget_create_plist(dset1))<0) - goto error; - if ((dcpl2=H5Dget_create_plist(dset2))<0) - goto error; - -/*------------------------------------------------------------------------- - * compare the property lists - *------------------------------------------------------------------------- - */ - if ((ret=H5Pequal(dcpl1,dcpl2))<0) - goto error; - - if (ret==0) - { - error_msg(progname, "property lists for <%s> are different\n",travt1->objs[i].name); - goto error; - } - -/*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - if (H5Pclose(dcpl1)<0) - goto error; - if (H5Pclose(dcpl2)<0) - goto error; - if (H5Dclose(dset1)<0) - goto error; - if (H5Dclose(dset2)<0) - goto error; - - break; - - } /*switch*/ - } /*i*/ - -/*------------------------------------------------------------------------- - * free - *------------------------------------------------------------------------- - */ - - trav_table_free(travt1); - trav_table_free(travt2); - -/*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - - H5Fclose(fid1); - H5Fclose(fid2); - return ret; - -/*------------------------------------------------------------------------- - * error - *------------------------------------------------------------------------- - */ - -error: - H5E_BEGIN_TRY { - H5Pclose(dcpl1); - H5Pclose(dcpl2); - H5Dclose(dset1); - H5Dclose(dset2); - H5Fclose(fid1); - H5Fclose(fid2); - trav_table_free(travt1); - trav_table_free(travt2); - } H5E_END_TRY; - return -1; - -} - -#else extern char *progname; @@ -1037,10 +567,3 @@ static int has_filters(hid_t pid, hid_t tid, unsigned nfilters, filter_info_t *f } - - - - - - -#endif |