diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2009-05-08 13:59:54 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2009-05-08 13:59:54 (GMT) |
commit | 0c1b7185adee382ec6c1d81b11a044a628dec8b0 (patch) | |
tree | d9cc6b5a4932997f433c145bfa7b58085fc39d44 | |
parent | 72af05c9ecda4477d8417a68be415bd991d93d77 (diff) | |
download | hdf5-0c1b7185adee382ec6c1d81b11a044a628dec8b0.zip hdf5-0c1b7185adee382ec6c1d81b11a044a628dec8b0.tar.gz hdf5-0c1b7185adee382ec6c1d81b11a044a628dec8b0.tar.bz2 |
[svn-r16927] Added multiple packed bits loop.
-rw-r--r-- | tools/h5dump/h5dump.c | 16 | ||||
-rw-r--r-- | tools/h5dump/testh5dump.sh.in | 1 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 1 | ||||
-rw-r--r-- | tools/lib/h5tools.h | 1 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 12 | ||||
-rw-r--r-- | tools/testfiles/tpackedbits2.ddl | 35 |
6 files changed, 57 insertions, 9 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index f7fe292..b2b790d 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -2194,6 +2194,8 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) hid_t type, space; unsigned attr_crt_order_flags; hid_t dcpl_id; /* dataset creation property list ID */ + int data_loop = 1; + int i; if ((dcpl_id = H5Dget_create_plist(did)) < 0) @@ -2226,10 +2228,16 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) if(display_dcpl) dump_dcpl(dcpl_id, type, did); - if(display_packed_bits) - dump_packed_bits(packed_output-1); + if(display_data) { + if(display_packed_bits) + data_loop = packed_output; + for(i=0;i<data_loop;i++) { + if(display_packed_bits) { + dump_packed_bits(i); + packed_counter = packed_mask[i]; + packed_normalize = packed_offset[i]; + } - if(display_data) switch(H5Tget_class(type)) { case H5T_TIME: indentation(indent + COL); @@ -2252,6 +2260,8 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) default: break; } /* end switch */ + } + } indent += COL; diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 16b4b04..07ed852 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -515,6 +515,7 @@ TOOLTEST textlinkfar.ddl textlinkfar.h5 # test for dataset packed bits TOOLTEST tpackedbits.ddl -d /dset1 -M 0,2 tdset.h5 +TOOLTEST tpackedbits2.ddl -d /dset1 -M 0,2,2,1 tdset.h5 if test $nerrors -eq 0 ; then diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index a1b6bad..72c4ece 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -41,6 +41,7 @@ int bin_output; /* binary output */ int bin_form; /* binary form */ int region_output; /* region output */ int packed_output; /* number of packed bits to display */ +int packed_normalize; /* number of bits to shift right to display normalized */ unsigned int packed_counter; /* counter for which packed bits to display */ static h5tool_format_t h5tools_dataformat = { diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 932ed0b..b0e67b8 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -515,6 +515,7 @@ extern int bin_output; /* binary output */ extern int bin_form; /* binary form */ extern int region_output; /* region output */ extern int packed_output; /* packed bits output count */ +extern int packed_normalize; /* number of bits to shift right to display normalized */ extern unsigned int packed_counter; /* counter for which packed bits to display */ diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index e83fff3..a6a4001 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -827,13 +827,13 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, else if (H5Tequal(type, H5T_NATIVE_INT)) { HDmemcpy(&tempint, vp, sizeof(int)); if(packed_output) - tempint &= packed_counter; + tempint = (tempint & packed_counter)>>packed_normalize; h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); } else if (H5Tequal(type, H5T_NATIVE_UINT)) { HDmemcpy(&tempuint, vp, sizeof(unsigned int)); if(packed_output) - tempuint &= packed_counter; + tempuint = (tempuint & packed_counter)>>packed_normalize; h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { @@ -847,7 +847,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, HDmemcpy(&tempshort, vp, sizeof(short)); if(packed_output) - tempshort &= packed_counter; + tempshort = (tempshort & packed_counter)>>packed_normalize; h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort); } else if (H5Tequal(type, H5T_NATIVE_USHORT)) { @@ -855,19 +855,19 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, HDmemcpy(&tempushort, vp, sizeof(unsigned short)); if(packed_output) - tempushort &= packed_counter; + tempushort = (tempushort & packed_counter)>>packed_normalize; h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort); } else if (H5Tequal(type, H5T_NATIVE_LONG)) { HDmemcpy(&templong, vp, sizeof(long)); if(packed_output) - templong &= packed_counter; + templong = (templong & packed_counter)>>packed_normalize; h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); } else if (H5Tequal(type, H5T_NATIVE_ULONG)) { HDmemcpy(&tempulong, vp, sizeof(unsigned long)); if(packed_output) - tempulong &= packed_counter; + tempulong = (tempulong & packed_counter)>>packed_normalize; h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); } else if (H5Tequal(type, H5T_NATIVE_LLONG)) { diff --git a/tools/testfiles/tpackedbits2.ddl b/tools/testfiles/tpackedbits2.ddl new file mode 100644 index 0000000..0bd9ea1 --- /dev/null +++ b/tools/testfiles/tpackedbits2.ddl @@ -0,0 +1,35 @@ +############################# +Expected output for 'h5dump -d /dset1 -M 0,2,2,1 tdset.h5' +############################# +HDF5 "tdset.h5" { +DATASET "/dset1" {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