diff options
-rw-r--r-- | MANIFEST | 1 | ||||
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | tools/h5copy/testh5copy.sh | 12 | ||||
-rw-r--r-- | tools/h5dump/h5dump.c | 5 | ||||
-rw-r--r-- | tools/h5dump/testh5dump.sh.in | 3 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 4 | ||||
-rw-r--r-- | tools/lib/h5tools.h | 3 | ||||
-rw-r--r-- | tools/lib/h5tools_type.c | 167 | ||||
-rw-r--r-- | tools/testfiles/tbin3.ddl | 11 |
9 files changed, 193 insertions, 15 deletions
@@ -1091,6 +1091,7 @@ ./tools/testfiles/tvms.h5 ./tools/testfiles/tbin.ddl ./tools/testfiles/tbin2.ddl +./tools/testfiles/tbin3.ddl # Expected output from h5ls tests @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Id: configure.in 12482 2006-07-19 21:47:33Z pvn . +# From configure.in Id: configure.in 12491 2006-07-22 01:55:14Z koziol . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for HDF5 1.8.0-alpha5. # diff --git a/tools/h5copy/testh5copy.sh b/tools/h5copy/testh5copy.sh index 2a562b3..5bf4828 100644 --- a/tools/h5copy/testh5copy.sh +++ b/tools/h5copy/testh5copy.sh @@ -61,12 +61,12 @@ TOOLTEST() { ### T H E T E S T S ### ############################################################################## -TOOLTEST -v test1.h5/array test1.out.h5/array -TOOLTEST -v test1.h5/integer test1.out.h5/integer_copy -TOOLTEST -v test1.h5/g1 test1.out.h5/g1 +#TOOLTEST -v test1.h5/array test1.out.h5/array +#TOOLTEST -v test1.h5/integer test1.out.h5/integer_copy +#TOOLTEST -v test1.h5/g1 test1.out.h5/g1 -if test $nerrors -eq 0 ; then - echo "All h5copy tests passed." -fi +#if test $nerrors -eq 0 ; then +# echo "All h5copy tests passed." +#fi exit $nerrors diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index ca21773..69adb31 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -2725,6 +2725,11 @@ set_binary_form(const char *form) bform = 0; else if (strcmp(form,"DI")==0) /* file type form */ bform = 1; + else if (strcmp(form,"LI")==0) /* convert to little endian */ + bform = 2; + else if (strcmp(form,"BI")==0) /* convert to big endian */ + bform = 3; + return bform; } diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 1505b9f..81bcab8 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -322,9 +322,8 @@ TOOLTEST tvms.ddl tvms.h5 # test for binary output TOOLTEST tbin.ddl -d integer -b out.bin test1.h5 - -# test for binary output using a file type form -F DI TOOLTEST tbin2.ddl -d integer -b out2.bin -F DI test1.h5 +TOOLTEST tbin3.ddl -d integer -b out3.bin -F LI test1.h5 if test $nerrors -eq 0 ; then echo "All $DUMPER tests passed." diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index f48b335..a3cb2a8 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -1216,6 +1216,10 @@ h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, hid_t _ if (info->raw || bin_form == 1 ) p_type = H5Tcopy(f_type); + else if (bin_form == 2 ) + p_type = h5tools_get_little_endian_type(f_type); + else if (bin_form == 3 ) + p_type = h5tools_get_big_endian_type(f_type); else p_type = h5tools_get_native_type(f_type); diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 91f238f..672d72a 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -374,6 +374,9 @@ extern int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid extern int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t type, hid_t space, void *mem, int indentlevel); extern hid_t h5tools_get_native_type(hid_t type); +extern hid_t h5tools_get_little_endian_type(hid_t type); +extern hid_t h5tools_get_big_endian_type(hid_t type); + extern void h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container, h5tools_context_t *ctx/*in,out*/, unsigned flags, diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c index 1ef2579..517b1bc 100644 --- a/tools/lib/h5tools_type.c +++ b/tools/lib/h5tools_type.c @@ -15,16 +15,16 @@ #include "h5tools.h" /*------------------------------------------------------------------------- - * Function: h5tools_get_native_type + * Function: h5tools_get_native_type * - * Purpose: Wrapper around H5Tget_native_type() to work around - * Problems with bitfields. + * Purpose: Wrapper around H5Tget_native_type() to work around + * Problems with bitfields. * - * Return: Success: datatype ID + * Return: Success: datatype ID * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, October 5, 2004 * * Modifications: @@ -46,3 +46,158 @@ h5tools_get_native_type(hid_t type) return(p_type); } + +/*------------------------------------------------------------------------- + * Function: h5tools_get_little_endian_type + * + * Purpose: Get a little endian type from a file type + * + * Return: Success: datatype ID + * Failure: FAIL + * + * Programmer: Pedro Vicente Nunes + * Tuesday, July 18, 2006 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hid_t +h5tools_get_little_endian_type(hid_t tid) +{ + hid_t p_type=-1; + H5T_class_t type_class; + size_t size; + H5T_sign_t sign; + + type_class = H5Tget_class(tid); + size = H5Tget_size(tid); + sign = H5Tget_sign(tid); + + switch( type_class ) + { + case H5T_INTEGER: + { + if ( size == 1 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I8LE); + else if ( size == 2 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I16LE); + else if ( size == 4 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I32LE); + else if ( size == 8 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I64LE); + else if ( size == 1 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U8LE); + else if ( size == 2 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U16LE); + else if ( size == 4 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U32LE); + else if ( size == 8 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U64LE); + } + break; + + case H5T_FLOAT: + if ( size == 4) + p_type=H5Tcopy(H5T_IEEE_F32LE); + else if ( size == 8) + p_type=H5Tcopy(H5T_IEEE_F64LE); + break; + + case H5T_TIME: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_STRING: + case H5T_COMPOUND: + case H5T_REFERENCE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: + break; + + default: + break; + + } + + return(p_type); +} + + +/*------------------------------------------------------------------------- + * Function: h5tools_get_big_endian_type + * + * Purpose: Get a big endian type from a file type + * + * Return: Success: datatype ID + * Failure: FAIL + * + * Programmer: Pedro Vicente Nunes + * Tuesday, July 18, 2006 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hid_t +h5tools_get_big_endian_type(hid_t tid) +{ + hid_t p_type=-1; + H5T_class_t type_class; + size_t size; + H5T_sign_t sign; + + type_class = H5Tget_class(tid); + size = H5Tget_size(tid); + sign = H5Tget_sign(tid); + + switch( type_class ) + { + case H5T_INTEGER: + { + if ( size == 1 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I8BE); + else if ( size == 2 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I16BE); + else if ( size == 4 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I32BE); + else if ( size == 8 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I64BE); + else if ( size == 1 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U8BE); + else if ( size == 2 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U16BE); + else if ( size == 4 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U32BE); + else if ( size == 8 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U64BE); + } + break; + + case H5T_FLOAT: + if ( size == 4) + p_type=H5Tcopy(H5T_IEEE_F32BE); + else if ( size == 8) + p_type=H5Tcopy(H5T_IEEE_F64BE); + break; + + case H5T_TIME: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_STRING: + case H5T_COMPOUND: + case H5T_REFERENCE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: + break; + + default: + break; + + } + + + return(p_type); +} + diff --git a/tools/testfiles/tbin3.ddl b/tools/testfiles/tbin3.ddl new file mode 100644 index 0000000..2571f4b --- /dev/null +++ b/tools/testfiles/tbin3.ddl @@ -0,0 +1,11 @@ +############################# +Expected output for 'h5dump -d integer -b out3.bin -F LI test1.h5' +############################# +HDF5 "test1.h5" { +DATASET "integer" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 2 ) / ( 2 ) } + DATA { + } +} +} |