summaryrefslogtreecommitdiffstats
path: root/tools/h5repack/h5repack.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5repack/h5repack.c')
-rw-r--r--tools/h5repack/h5repack.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c
index 91ade4f..eabdb6c 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->min_comp = 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,12 +373,12 @@ 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");
@@ -420,7 +420,7 @@ static int check_options(pack_opt_t *options)
options->ublock_filename);
return -1;
}
-
+
if ( options->ublock_filename == NULL && options->ublock_size != 0 )
{
error_msg(progname, "file name missing for user block\n",
@@ -433,13 +433,13 @@ static int check_options(pack_opt_t *options)
* verify alignment options; threshold is zero default but alignment not
*---------------------------------------------------------------------------------
*/
-
+
if ( options->alignment == 0 && options->threshold != 0 )
{
error_msg(progname, "alignment for H5Pset_alignment missing\n");
return -1;
}
-
+
return 0;
}
@@ -464,11 +464,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
*-------------------------------------------------------------------------
@@ -477,32 +477,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",
@@ -524,7 +524,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++)
@@ -547,7 +547,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;
@@ -556,7 +556,7 @@ static int check_objects(const char* fname,
break;
}
} /* i */
-
+
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
@@ -564,7 +564,7 @@ static int check_objects(const char* fname,
H5Fclose(fid);
trav_table_free(travt);
return 0;
-
+
out:
H5Fclose(fid);
trav_table_free(travt);