diff options
Diffstat (limited to 'tools/h5repack/h5repack.c')
-rw-r--r-- | tools/h5repack/h5repack.c | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index febf7d7..d827972 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -65,16 +65,16 @@ int h5repack(const char* infile, /* 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; } @@ -97,7 +97,7 @@ int h5repack_init (pack_opt_t *options, memset(options,0,sizeof(pack_opt_t)); options->threshold = 1024; options->verbose = verbose; - + for ( n = 0; n < H5_REPACK_MAX_NFILTERS; n++) { options->filter_g[n].filtn = -1; @@ -105,7 +105,7 @@ int h5repack_init (pack_opt_t *options, for ( k = 0; k < CD_VALUES; k++) options->filter_g[n].cd_values[k] = -1; } - + return (options_table_init(&(options->op_tbl))); } @@ -141,36 +141,36 @@ int h5repack_addfilter(const char* str, int n_objs; /* number of objects in the current -f or -l option entry */ int is_glb; /* is the filter global */ - - + + /* parse the -f option */ obj_list=parse_filter(str,&n_objs,&filter,options,&is_glb); if (obj_list==NULL) { return -1; } - + /* if it applies to all objects */ if (is_glb) { - + int n; - + n = options->n_filter_g++; /* increase # of global filters */ if (options->n_filter_g > H5_REPACK_MAX_NFILTERS) { error_msg(progname, "maximum number of filters exceeded for <%s>\n",str); return -1; - + } - + options->filter_g[n] = filter; } - + else options_add_filter(obj_list,n_objs,filter,options->op_tbl); - + free(obj_list); return 0; } @@ -190,25 +190,25 @@ int h5repack_addfilter(const char* str, 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 ) { @@ -230,13 +230,13 @@ int h5repack_addlayout(const char* str, } } } - + if (options->all_layout==0) options_add_layout(obj_list, n_objs, &pack, options->op_tbl); - + free(obj_list); return 0; } @@ -252,7 +252,7 @@ int h5repack_addlayout(const char* str, * Programmer: pvn@ncsa.uiuc.edu * * Date: September, 22, 2003 - * + * * Modification: * Peter Cao, July 9, 2007 * Add "-L, --latest" and other options to pack a file with the latest file format @@ -264,7 +264,7 @@ 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 *------------------------------------------------------------------------- @@ -297,11 +297,11 @@ static int check_options(pack_opt_t *options) } } }/* 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){ @@ -319,24 +319,24 @@ static int check_options(pack_opt_t *options) 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) { - + for (k = 0; k < options->n_filter_g; k++ ) { H5Z_filter_t filtn=options->filter_g[k].filtn; @@ -359,12 +359,12 @@ static int check_options(pack_opt_t *options) }; } } /* 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) @@ -373,18 +373,18 @@ static int check_options(pack_opt_t *options) 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; } - + /* check options for the latest format */ if (options->grp_compact < 0) { error_msg(progname, "invalid maximum number of links to store as header messages\n"); @@ -404,7 +404,7 @@ static int check_options(pack_opt_t *options) return -1; } } - + return 0; } @@ -429,11 +429,11 @@ static int check_objects(const char* fname, hid_t fid; unsigned int i; trav_table_t *travt = NULL; - + /* nothing to do */ if(options->op_tbl->nelems == 0) return 0; - + /*------------------------------------------------------------------------- * open the file *------------------------------------------------------------------------- @@ -442,32 +442,32 @@ static int check_objects(const char* fname, printf("<%s>: %s\n", fname, H5FOPENERROR ); return -1; } - + /*------------------------------------------------------------------------- * get the list of objects in the file *------------------------------------------------------------------------- */ - + /* init table */ trav_table_init(&travt); - + /* get the list of objects in the file */ if(h5trav_gettable(fid, travt) < 0) goto out; - + /*------------------------------------------------------------------------- * compare with user supplied list *------------------------------------------------------------------------- */ - + if(options->verbose) printf("Opening file <%s>. Searching for objects to modify...\n", fname); - + for(i = 0; i < options->op_tbl->nelems; i++) { char* name=options->op_tbl->objs[i].path; if(options->verbose) printf(" <%s>",name); - + /* the input object names are present in the file and are valid */ if(h5trav_getindext(name, travt) < 0) { error_msg(progname, "%s Could not find <%s> in file <%s>. Exiting...\n", @@ -489,7 +489,7 @@ static int check_objects(const char* fname, int rank; hid_t did; hid_t sid; - + if(options->op_tbl->objs[i].chunk.rank > 0) { rank = options->op_tbl->objs[i].chunk.rank; for(j = 0; j < rank; j++) @@ -512,7 +512,7 @@ static int check_objects(const char* fname, if(H5Dclose(did) < 0) goto out; } - + if (csize < ppb ) { printf(" <warning: SZIP settins, chunk size is smaller than pixels per block>\n"); goto out; @@ -521,7 +521,7 @@ static int check_objects(const char* fname, break; } } /* i */ - + /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- @@ -529,7 +529,7 @@ static int check_objects(const char* fname, H5Fclose(fid); trav_table_free(travt); return 0; - + out: H5Fclose(fid); trav_table_free(travt); |