diff options
Diffstat (limited to 'tools/h5repack/h5repack_copy.c')
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 21 |
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); |