summaryrefslogtreecommitdiffstats
path: root/tools/h5dump
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2006-03-28 21:25:10 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2006-03-28 21:25:10 (GMT)
commitcd25a7690abbd3665996dc7657b13101ba032c79 (patch)
treef6f9e860bb7e86d7d496875f87af9fff58f667aa /tools/h5dump
parent194d3dfe522c2b6612586829d47e830ad5c7ef0c (diff)
downloadhdf5-cd25a7690abbd3665996dc7657b13101ba032c79.zip
hdf5-cd25a7690abbd3665996dc7657b13101ba032c79.tar.gz
hdf5-cd25a7690abbd3665996dc7657b13101ba032c79.tar.bz2
[svn-r12171] Purpose:
bug fixes Description: h5dump/h5ls were not displaying long doubles correctly Solution: 1) the print datatype functions were incorrectly testing for the valid return value from H5Tequal, (TRUE), causing the display of an incorrect name of a dataype in error cases from H5Tequal 2) h5tools_print_str did not have a case for native long double 3) added a file generator for a long double dataset 4) added one script test for the long double data (commented , some sytems don't have a native long double match, and the output differs) 5) added a vms file and h5dump script test Platforms tested: linux 32, 64 solaris AIX Misc. update:
Diffstat (limited to 'tools/h5dump')
-rw-r--r--tools/h5dump/h5dump.c153
-rw-r--r--tools/h5dump/h5dumpgentest.c56
-rw-r--r--tools/h5dump/testh5dump.sh.in5
3 files changed, 166 insertions, 48 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 1e9ad28..ed6fa6d 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -655,7 +655,8 @@ usage(const char *prog)
*
* Programmer: Ruey-Hsia Li
*
- * Modifications:
+ * Modifications: pvn, March 28, 2006
+ * print information about type when a native match is not possible
*
*-------------------------------------------------------------------------
*/
@@ -677,6 +678,9 @@ print_datatype(hid_t type,unsigned in_group)
hid_t super;
hid_t tmp_type;
htri_t is_vlstr=FALSE;
+ const char *order_s=NULL; /* byte order string */
+ H5T_sign_t sign; /* sign scheme value */
+ const char *sign_s=NULL; /* sign scheme string */
if (!in_group && H5Tcommitted(type) > 0) {
obj_t *obj; /* Found object */
@@ -696,88 +700,141 @@ print_datatype(hid_t type,unsigned in_group)
} else {
switch (H5Tget_class(type)) {
case H5T_INTEGER:
- if (H5Tequal(type, H5T_STD_I8BE)) {
+ if (H5Tequal(type, H5T_STD_I8BE)==TRUE) {
printf("H5T_STD_I8BE");
- } else if (H5Tequal(type, H5T_STD_I8LE)) {
+ } else if (H5Tequal(type, H5T_STD_I8LE)==TRUE) {
printf("H5T_STD_I8LE");
- } else if (H5Tequal(type, H5T_STD_I16BE)) {
+ } else if (H5Tequal(type, H5T_STD_I16BE)==TRUE) {
printf("H5T_STD_I16BE");
- } else if (H5Tequal(type, H5T_STD_I16LE)) {
+ } else if (H5Tequal(type, H5T_STD_I16LE)==TRUE) {
printf("H5T_STD_I16LE");
- } else if (H5Tequal(type, H5T_STD_I32BE)) {
+ } else if (H5Tequal(type, H5T_STD_I32BE)==TRUE) {
printf("H5T_STD_I32BE");
- } else if (H5Tequal(type, H5T_STD_I32LE)) {
+ } else if (H5Tequal(type, H5T_STD_I32LE)==TRUE) {
printf("H5T_STD_I32LE");
- } else if (H5Tequal(type, H5T_STD_I64BE)) {
+ } else if (H5Tequal(type, H5T_STD_I64BE)==TRUE) {
printf("H5T_STD_I64BE");
- } else if (H5Tequal(type, H5T_STD_I64LE)) {
+ } else if (H5Tequal(type, H5T_STD_I64LE)==TRUE) {
printf("H5T_STD_I64LE");
- } else if (H5Tequal(type, H5T_STD_U8BE)) {
+ } else if (H5Tequal(type, H5T_STD_U8BE)==TRUE) {
printf("H5T_STD_U8BE");
- } else if (H5Tequal(type, H5T_STD_U8LE)) {
+ } else if (H5Tequal(type, H5T_STD_U8LE)==TRUE) {
printf("H5T_STD_U8LE");
- } else if (H5Tequal(type, H5T_STD_U16BE)) {
+ } else if (H5Tequal(type, H5T_STD_U16BE)==TRUE) {
printf("H5T_STD_U16BE");
- } else if (H5Tequal(type, H5T_STD_U16LE)) {
+ } else if (H5Tequal(type, H5T_STD_U16LE)==TRUE) {
printf("H5T_STD_U16LE");
- } else if (H5Tequal(type, H5T_STD_U32BE)) {
+ } else if (H5Tequal(type, H5T_STD_U32BE)==TRUE) {
printf("H5T_STD_U32BE");
- } else if (H5Tequal(type, H5T_STD_U32LE)) {
+ } else if (H5Tequal(type, H5T_STD_U32LE)==TRUE) {
printf("H5T_STD_U32LE");
- } else if (H5Tequal(type, H5T_STD_U64BE)) {
+ } else if (H5Tequal(type, H5T_STD_U64BE)==TRUE) {
printf("H5T_STD_U64BE");
- } else if (H5Tequal(type, H5T_STD_U64LE)) {
+ } else if (H5Tequal(type, H5T_STD_U64LE)==TRUE) {
printf("H5T_STD_U64LE");
- } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) {
+ } else if (H5Tequal(type, H5T_NATIVE_SCHAR)==TRUE) {
printf("H5T_NATIVE_SCHAR");
- } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
+ } else if (H5Tequal(type, H5T_NATIVE_UCHAR)==TRUE) {
printf("H5T_NATIVE_UCHAR");
- } else if (H5Tequal(type, H5T_NATIVE_SHORT)) {
+ } else if (H5Tequal(type, H5T_NATIVE_SHORT)==TRUE) {
printf("H5T_NATIVE_SHORT");
- } else if (H5Tequal(type, H5T_NATIVE_USHORT)) {
+ } else if (H5Tequal(type, H5T_NATIVE_USHORT)==TRUE) {
printf("H5T_NATIVE_USHORT");
- } else if (H5Tequal(type, H5T_NATIVE_INT)) {
+ } else if (H5Tequal(type, H5T_NATIVE_INT)==TRUE) {
printf("H5T_NATIVE_INT");
- } else if (H5Tequal(type, H5T_NATIVE_UINT)) {
+ } else if (H5Tequal(type, H5T_NATIVE_UINT)==TRUE) {
printf("H5T_NATIVE_UINT");
- } else if (H5Tequal(type, H5T_NATIVE_LONG)) {
+ } else if (H5Tequal(type, H5T_NATIVE_LONG)==TRUE) {
printf("H5T_NATIVE_LONG");
- } else if (H5Tequal(type, H5T_NATIVE_ULONG)) {
+ } else if (H5Tequal(type, H5T_NATIVE_ULONG)==TRUE) {
printf("H5T_NATIVE_ULONG");
- } else if (H5Tequal(type, H5T_NATIVE_LLONG)) {
+ } else if (H5Tequal(type, H5T_NATIVE_LLONG)==TRUE) {
printf("H5T_NATIVE_LLONG");
- } else if (H5Tequal(type, H5T_NATIVE_ULLONG)) {
+ } else if (H5Tequal(type, H5T_NATIVE_ULLONG)==TRUE) {
printf("H5T_NATIVE_ULLONG");
} else {
- printf("undefined integer");
- d_status = EXIT_FAILURE;
+
+ /* byte order */
+ if (H5Tget_size(type)>1)
+ {
+ order = H5Tget_order(type);
+ if (H5T_ORDER_LE==order) {
+ order_s = " little-endian";
+ } else if (H5T_ORDER_BE==order) {
+ order_s = " big-endian";
+ } else if (H5T_ORDER_VAX==order) {
+ order_s = " mixed-endian";
+ } else {
+ order_s = " unknown-byte-order";
+ }
+ } else {
+ order_s = "";
+ }
+
+ /* sign */
+ if ((sign=H5Tget_sign(type))>=0)
+ {
+ if (H5T_SGN_NONE==sign) {
+ sign_s = " unsigned";
+ } else if (H5T_SGN_2==sign) {
+ sign_s = "";
+ } else {
+ sign_s = " unknown-sign";
+ }
+ } else {
+ sign_s = " unknown-sign";
+ }
+
+ /* print size, order, and sign */
+ printf("%lu-bit%s%s integer",
+ (unsigned long)(8*H5Tget_size(type)), order_s, sign_s);
}
break;
case H5T_FLOAT:
- if (H5Tequal(type, H5T_IEEE_F32BE)) {
+ if (H5Tequal(type, H5T_IEEE_F32BE)==TRUE) {
printf("H5T_IEEE_F32BE");
- } else if (H5Tequal(type, H5T_IEEE_F32LE)) {
+ } else if (H5Tequal(type, H5T_IEEE_F32LE)==TRUE) {
printf("H5T_IEEE_F32LE");
- } else if (H5Tequal(type, H5T_IEEE_F64BE)) {
+ } else if (H5Tequal(type, H5T_IEEE_F64BE)==TRUE) {
printf("H5T_IEEE_F64BE");
- } else if (H5Tequal(type, H5T_IEEE_F64LE)) {
+ } else if (H5Tequal(type, H5T_IEEE_F64LE)==TRUE) {
printf("H5T_IEEE_F64LE");
- } else if (H5Tequal(type, H5T_VAX_F32)) {
+ } else if (H5Tequal(type, H5T_VAX_F32)==TRUE) {
printf("H5T_VAX_F32");
- } else if (H5Tequal(type, H5T_VAX_F64)) {
+ } else if (H5Tequal(type, H5T_VAX_F64)==TRUE) {
printf("H5T_VAX_F64");
- } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) {
+ } else if (H5Tequal(type, H5T_NATIVE_FLOAT)==TRUE) {
printf("H5T_NATIVE_FLOAT");
- } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) {
+ } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)==TRUE) {
printf("H5T_NATIVE_DOUBLE");
#if H5_SIZEOF_LONG_DOUBLE !=0
- } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) {
+ } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)==TRUE) {
printf("H5T_NATIVE_LDOUBLE");
#endif
} else {
- printf("undefined float");
- d_status = EXIT_FAILURE;
+
+ /* byte order */
+ if (H5Tget_size(type)>1)
+ {
+ order = H5Tget_order(type);
+ if (H5T_ORDER_LE==order) {
+ order_s = " little-endian";
+ } else if (H5T_ORDER_BE==order) {
+ order_s = " big-endian";
+ } else if (H5T_ORDER_VAX==order) {
+ order_s = " mixed-endian";
+ } else {
+ order_s = " unknown-byte-order";
+ }
+ } else {
+ order_s = "";
+ }
+
+ /* print size and byte order */
+ printf("%lu-bit%s floating-point",
+ (unsigned long)(8*H5Tget_size(type)), order_s);
+
}
break;
@@ -891,21 +948,21 @@ done:
break;
case H5T_BITFIELD:
- if (H5Tequal(type, H5T_STD_B8BE)) {
+ if (H5Tequal(type, H5T_STD_B8BE)==TRUE) {
printf("H5T_STD_B8BE");
- } else if (H5Tequal(type, H5T_STD_B8LE)) {
+ } else if (H5Tequal(type, H5T_STD_B8LE)==TRUE) {
printf("H5T_STD_B8LE");
- } else if (H5Tequal(type, H5T_STD_B16BE)) {
+ } else if (H5Tequal(type, H5T_STD_B16BE)==TRUE) {
printf("H5T_STD_B16BE");
- } else if (H5Tequal(type, H5T_STD_B16LE)) {
+ } else if (H5Tequal(type, H5T_STD_B16LE)==TRUE) {
printf("H5T_STD_B16LE");
- } else if (H5Tequal(type, H5T_STD_B32BE)) {
+ } else if (H5Tequal(type, H5T_STD_B32BE)==TRUE) {
printf("H5T_STD_B32BE");
- } else if (H5Tequal(type, H5T_STD_B32LE)) {
+ } else if (H5Tequal(type, H5T_STD_B32LE)==TRUE) {
printf("H5T_STD_B32LE");
- } else if (H5Tequal(type, H5T_STD_B64BE)) {
+ } else if (H5Tequal(type, H5T_STD_B64BE)==TRUE) {
printf("H5T_STD_B64BE");
- } else if (H5Tequal(type, H5T_STD_B64LE)) {
+ } else if (H5Tequal(type, H5T_STD_B64LE)==TRUE) {
printf("H5T_STD_B64LE");
} else {
printf("undefined bitfield");
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index 20ab958..e7bf7a7 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -78,6 +78,8 @@
#define FILE49 "tstr3.h5"
#define FILE50 "taindices.h5"
#define FILE51 "tlonglinks.h5"
+#define FILE52 "tldouble.h5"
+
@@ -5415,6 +5417,59 @@ static void gent_longlinks(void)
}
+
+/*-------------------------------------------------------------------------
+ * Function: gent_ldouble
+ *
+ * Purpose: make file with a long double dataset
+ *
+ *-------------------------------------------------------------------------
+ */
+static int gent_ldouble(void)
+{
+ hid_t fid;
+ hid_t did;
+ hid_t tid;
+ hid_t sid;
+ size_t size;
+ hsize_t dims[1] = {3};
+ long double buf[3] = {1,2,3};
+
+ if ((fid = H5Fcreate(FILE52, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0)
+ goto error;
+
+ if ((sid = H5Screate_simple(1, dims, NULL))<0)
+ goto error;
+
+ if ((tid = H5Tcopy(H5T_NATIVE_LDOUBLE))<0)
+ goto error;
+
+ if ((size = H5Tget_size(tid))<0)
+ goto error;
+
+ if ((did = H5Dcreate(fid, "dset", tid, sid, H5P_DEFAULT))<0)
+ goto error;
+
+ if (H5Dwrite(did,tid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
+ goto error;
+
+ if (H5Sclose(sid)<0)
+ goto error;
+ if (H5Tclose(tid)<0)
+ goto error;
+ if (H5Dclose(did)<0)
+ goto error;
+ if (H5Fclose(fid)<0)
+ goto error;
+
+ return 0;
+
+error:
+ printf("error !\n");
+ return -1;
+
+}
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -5474,6 +5529,7 @@ int main(void)
gent_string();
gent_aindices();
gent_longlinks();
+ gent_ldouble();
return 0;
}
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index b9d42c8..c23651b 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -314,6 +314,11 @@ TOOLTEST tnullspace.ddl tnullspace.h5
# test for displaying objects with very long names
TOOLTEST tlonglinks.ddl tlonglinks.h5
+# test for long double (some systems do not have long double)
+#TOOLTEST tldouble.ddl tldouble.h5
+
+# test for vms
+TOOLTEST tvms.ddl tvms.h5
if test $nerrors -eq 0 ; then
echo "All $DUMPER tests passed."