From bd2c3b52a8acf822d8cb97a365425b2c18dc0621 Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Thu, 24 May 2007 14:09:36 -0500 Subject: [svn-r13810] Minor tunings to output verbose messages: 1)when there is not a filter request do not print a message saying the filter was not apllied when the dataset was too small 2) avoid printing the message that has a list of objects to modify when there is none Tested:linux --- tools/h5repack/h5repack.c | 26 +++++++++++++++++++++++--- tools/h5repack/h5repack.h | 7 +++++-- tools/h5repack/h5repack_copy.c | 25 ++++++++++++++++--------- tools/h5repack/h5repack_filters.c | 16 ++++++++++++---- 4 files changed, 56 insertions(+), 18 deletions(-) diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index 5ebd68b..2449c36 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -256,7 +256,7 @@ static int check_options(pack_opt_t *options) * objects to layout *------------------------------------------------------------------------- */ - if (options->verbose) + if (options->verbose && have_request(options) /* only print if requested */) { printf("Objects to modify layout are...\n"); if (options->all_layout==1) { @@ -318,7 +318,7 @@ static int check_options(pack_opt_t *options) *------------------------------------------------------------------------- */ - if (options->verbose) + if (options->verbose && have_request(options) /* only print if requested */) { printf("Objects to apply filter are...\n"); if (options->all_filter==1) @@ -407,7 +407,7 @@ void read_info(const char *filename, if ((fp = fopen(data_file, "r")) == (FILE *)NULL) { - error_msg(progname, "cannot open options file %s", filename); + error_msg(progname, "cannot open options file %s\n", filename); exit(1); } @@ -493,3 +493,23 @@ void read_info(const char *filename, } +/*------------------------------------------------------------------------- + * 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; + +} \ No newline at end of file diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index a397d0a..3fa23d3 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -153,6 +153,8 @@ int do_copy_refobjs(hid_t fidin, void read_info(const char *filename,pack_opt_t *options); void init_packobject(pack_info_t *obj); int print_filters(hid_t dcpl_id); +int have_request(pack_opt_t *options); + /*------------------------------------------------------------------------- @@ -163,8 +165,9 @@ int print_filters(hid_t dcpl_id); int apply_filters(const char* name, /* object name from traverse list */ int rank, /* rank of dataset */ hsize_t *dims, /* dimensions of dataset */ - hid_t dcpl_id, /* dataset creation property list */ - pack_opt_t *options); /* repack options */ + hid_t dcpl_id, /* (IN,OUT) dataset creation property list */ + pack_opt_t *options, /* repack options */ + int *has_filter); /* (OUT) object NAME has a filter */ int has_filter(hid_t dcpl_id, H5Z_filter_t filtnin); diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 54e9dd2..bb9fea3 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -231,6 +231,7 @@ int do_copy_objects(hid_t fidin, double per; /* percent utilization of storage */ void *buf=NULL; /* buffer for raw data */ void *sm_buf=NULL; /* buffer for raw data */ + int has_filter; /* current object has a filter */ unsigned i; int is_ref=0; @@ -287,6 +288,8 @@ int do_copy_objects(hid_t fidin, */ case H5G_DATASET: + has_filter = 0; + /* early detection of references */ if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0) goto error; @@ -376,7 +379,7 @@ int do_copy_objects(hid_t fidin, /* apply the filter */ if (apply_s){ - if (apply_filters(travt->objs[i].name,rank,dims,dcpl_out,options)<0) + if (apply_filters(travt->objs[i].name,rank,dims,dcpl_out,options,&has_filter)<0) goto error; } @@ -529,16 +532,20 @@ int do_copy_objects(hid_t fidin, } else print_dataset_info(dcpl_id,travt->objs[i].name,0.0); - } - if (apply_s==0 && options->verbose) - printf(" \n", - travt->objs[i].name, - (int)options->threshold); + /* print a message that the filter was not applied + (in case there was a filter) + */ + if ( has_filter && apply_s == 0 ) + printf(" \n", + travt->objs[i].name, + (int)options->threshold); - if (apply_f==0 && options->verbose) - printf(" \n", - travt->objs[i].name); + if ( has_filter && apply_f == 0 ) + printf(" \n", + travt->objs[i].name); + + } /* verbose */ /*------------------------------------------------------------------------- * copy attrs diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index 32b2e36..a2d86fa 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -28,7 +28,7 @@ static int aux_find_obj(const char* name, /* object name from traverse list */ pack_opt_t *options, /* repack options */ - pack_info_t *obj /*OUT*/) /* info about object to filter */ + pack_info_t *obj /*OUT*/) /* info about object to filter */ { char *pdest; int result; @@ -187,17 +187,23 @@ int aux_assign_obj(const char* name, /* object name from traverse lis * *------------------------------------------------------------------------- */ + int apply_filters(const char* name, /* object name from traverse list */ int rank, /* rank of dataset */ hsize_t *dims, /* dimensions of dataset */ - hid_t dcpl_id, /* dataset creation property list */ - pack_opt_t *options) /* repack options */ + hid_t dcpl_id, /* (IN,OUT) dataset creation property list */ + pack_opt_t *options, /* repack options */ + int *has_filter) /* (OUT) object NAME has a filter */ + + { int nfilters; /* number of filters in DCPL */ hsize_t chsize[64]; /* chunk size in elements */ H5D_layout_t layout; int i; pack_info_t obj; + + *has_filter = 0; if (rank==0) /* scalar dataset, do not apply */ return 0; @@ -225,7 +231,9 @@ int apply_filters(const char* name, /* object name from traverse list */ * only remove if we are inserting new ones *------------------------------------------------------------------------- */ - if (nfilters && obj.nfilters ) { + if (nfilters && obj.nfilters ) + { + *has_filter = 1; if (H5Premove_filter(dcpl_id,H5Z_FILTER_ALL)<0) return -1; } -- cgit v0.12