diff options
Diffstat (limited to 'tools/h5dump')
-rw-r--r-- | tools/h5dump/h5dump.c | 83 | ||||
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 38 | ||||
-rw-r--r-- | tools/h5dump/testh5dump.sh.in | 3 |
3 files changed, 86 insertions, 38 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 70d889f..2389ef4 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -2440,6 +2440,9 @@ static void dump_fill_value(hid_t dcpl,hid_t type_id, hid_t obj_id) * * Programmer: pvn * + * Modifications: pvn, March 28, 2008 + * Add a COMPRESSION ratio information for cases when filters are present + * *------------------------------------------------------------------------- */ static void @@ -2455,7 +2458,7 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) unsigned szip_pixels_per_block; hsize_t chsize[64]; /* chunk size in elements */ int rank; /* rank */ - char name[256]; /* external file name */ + char name[256]; /* external file name */ off_t offset; /* offset of external file */ hsize_t size; /* size of external file */ H5D_fill_value_t fvstatus; @@ -2467,11 +2470,12 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) unsigned j; storage_size=H5Dget_storage_size(obj_id); + nfilters = H5Pget_nfilters(dcpl_id); ioffset=H5Dget_offset(obj_id); next=H5Pget_external_count(dcpl_id); strcpy(f_name,"\0"); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * STORAGE_LAYOUT *------------------------------------------------------------------------- */ @@ -2490,7 +2494,72 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) HDfprintf(stdout, ", %Hu", chsize[i]); printf(" %s\n", dump_header_format->dataspacedimend); indentation(indent + COL); - HDfprintf(stdout, "SIZE %Hu\n ", storage_size); + + + /* if there are filters, print a compression ratio */ + if ( nfilters ) + { + + hid_t sid = H5Dget_space( obj_id ); + hid_t tid = H5Dget_type( obj_id ); + size_t datum_size = H5Tget_size( tid ); + hsize_t dims[H5S_MAX_RANK]; + int ndims = H5Sget_simple_extent_dims( sid, dims, NULL); + hsize_t nelmts = 1; + hsize_t size; + double per = 0; + hssize_t a, b; + int ok = 0; + + /* only print the compression ratio for these filters */ + for ( i = 0; i < nfilters; i++) + { + cd_nelmts = NELMTS(cd_values); + filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, + cd_values, sizeof(f_name), f_name, NULL); + + switch (filtn) + { + case H5Z_FILTER_DEFLATE: + case H5Z_FILTER_SZIP: + case H5Z_FILTER_NBIT: + case H5Z_FILTER_SCALEOFFSET: + ok = 1; + break; + } + } + + if (ndims && ok ) + { + + for (i = 0; i < ndims; i++) + { + nelmts *= dims[i]; + } + size = nelmts * datum_size; + + a = size; b = storage_size; + if (a!=0) + per = (double) (b-a)/a; + + per = -per; + per *=100; + + HDfprintf(stdout, "SIZE %Hu (%.1f%%COMPRESSION)\n ", storage_size, per); + + } + else + HDfprintf(stdout, "SIZE %Hu\n ", storage_size); + + + H5Sclose(sid); + H5Tclose(tid); + + } + else + { + HDfprintf(stdout, "SIZE %Hu\n ", storage_size); + } /*end indent */ indent -= COL; @@ -2563,14 +2632,16 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) * FILTERS *------------------------------------------------------------------------- */ - nfilters = H5Pget_nfilters(dcpl_id); + indentation(indent + COL); printf("%s %s\n", FILTERS, BEGIN); indent += COL; - if (nfilters) { - for (i=0; i<nfilters; i++) { + if (nfilters) + { + for (i=0; i<nfilters; i++) + { cd_nelmts = NELMTS(cd_values); filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, sizeof(f_name), f_name, NULL); diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index b21a020..4070425 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -5542,8 +5542,7 @@ error: * Contains: * 1) an integer dataset * 2) a float dataset - * 3) an array dataset - * 4) a large double dataset + * 4) a double dataset * *------------------------------------------------------------------------- */ @@ -5551,64 +5550,43 @@ static void gent_binary(void) { hid_t fid, sid, did, tid; - hsize_t dims[1] = {6}; - hsize_t dimarray[1] = {2}; - hsize_t dimsl[1] = {100000}; + hsize_t dims[1] = {6}; int ibuf[6] = {1,2,3,4,5,6}; float fbuf[6] = {1,2,3,4,5,6}; - int abuf[2][6] = {{1,2,3,4,5,6},{7,8,9,10,11,12}}; /* array */ - double *dbuf=NULL; + double dbuf[6] = {1,2,3,4,5,6}; fid = H5Fcreate(FILE55, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); /*------------------------------------------------------------------------- * integer *------------------------------------------------------------------------- */ - sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate2(fid, "integer", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf); H5Dclose(did); - H5Sclose(sid); /*------------------------------------------------------------------------- * float *------------------------------------------------------------------------- */ - sid = H5Screate_simple(1, dims, NULL); did = H5Dcreate2(fid, "float", H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, fbuf); H5Dclose(did); - H5Sclose(sid); - -/*------------------------------------------------------------------------- - * array - *------------------------------------------------------------------------- - */ - tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dims); - sid = H5Screate_simple(1, dimarray, NULL); - did = H5Dcreate2(fid, "array", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, abuf); - H5Dclose(did); - H5Tclose(tid); - H5Sclose(sid); /*------------------------------------------------------------------------- * double *------------------------------------------------------------------------- */ - sid = H5Screate_simple(1, dimsl, NULL); did = H5Dcreate2(fid, "double", H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - dbuf = calloc(100000, sizeof(double)); - if(dbuf != NULL) { - H5Dwrite(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); - free(dbuf); - } + H5Dwrite(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); H5Dclose(did); - H5Sclose(sid); + /* close */ + H5Sclose(sid); H5Fclose(fid); } diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index b7b8429..1a8c18a 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -325,8 +325,7 @@ TOOLTEST tall-2B.ddl -A -r tall.h5 TOOLTEST tall-4s.ddl --dataset=/g1/g1.1/dset1.1.1 --start=1,1 --stride=2,3 --count=3,2 --block=1,1 tall.h5 TOOLTEST tall-5s.ddl -d "/g1/g1.1/dset1.1.2[0;2;10;]" tall.h5 TOOLTEST tdset-3s.ddl -d "/dset1[1,1;;;]" tdset.h5 -# block -# TOOLTEST tdset2-1s.ddl -d "/dset1[;3,2;4,4;1,4]" tdset2.h5 + # test printing characters in ASCII instead of decimal TOOLTEST tchar1.ddl -r tchar.h5 |