summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2007-11-27 20:21:40 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2007-11-27 20:21:40 (GMT)
commitdf3aac7f009aeb8acf650964378251db0a02ca71 (patch)
tree5481b3b4fd1eac1667f646364c43938d7b50dff4
parentb0024d3f0309c1a90e16b3fd233247c02e7a8b63 (diff)
downloadhdf5-df3aac7f009aeb8acf650964378251db0a02ca71.zip
hdf5-df3aac7f009aeb8acf650964378251db0a02ca71.tar.gz
hdf5-df3aac7f009aeb8acf650964378251db0a02ca71.tar.bz2
[svn-r14294] bug fix: in the filter percentage calculation
tested: windows, linux, solaris
-rw-r--r--tools/h5repack/h5repack_copy.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 2bcdfd4..848b609 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -29,10 +29,6 @@ extern char *progname;
*/
#define FORMAT_OBJ " %-27s %s\n" /* obj type, name */
#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */
-#define PER(A,B) { per = 0; \
- if (A!=0) \
- per = (double) fabs( (double)(B-A) / (double)A ); \
- }
#define USERBLOCK_XFER_SIZE 512 /* Size of buffer/# of bytes to xfer at a time when copying userblock */
/*-------------------------------------------------------------------------
@@ -355,7 +351,6 @@ int do_copy_objects(hid_t fidin,
hsize_t dsize_out; /* output dataset size after filter */
int apply_s; /* flag for apply filter to small dataset sizes */
int apply_f; /* flag for apply filter to return error on H5Dcreate */
- 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 */
@@ -662,10 +657,22 @@ int do_copy_objects(hid_t fidin,
{
if (apply_s && apply_f)
{
+ double per=0;
+ hssize_t a, b;
+
/* get the storage size of the input dataset */
dsize_out=H5Dget_storage_size(dset_out);
- PER((hssize_t)dsize_in,(hssize_t)dsize_out);
- print_dataset_info(dcpl_out,travt->objs[i].name,per*100.0);
+
+ a = dsize_in; b = dsize_out;
+ if (a!=0)
+ per = (double) (b-a)/a;
+ if (per>0)
+ per+=1;
+ else
+ per=fabs(per);
+ per *=100;
+
+ print_dataset_info(dcpl_out,travt->objs[i].name,per);
}
else
print_dataset_info(dcpl_id,travt->objs[i].name,0.0);