diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2007-03-13 16:28:30 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2007-03-13 16:28:30 (GMT) |
commit | c05a215c2f2f39c223a97991c2554e3d87639354 (patch) | |
tree | 67d2ae39d85633547284dd13e354007ab24d7c11 /tools | |
parent | 5d132d20e72f56a309fd597e717493db1d3fe1e5 (diff) | |
download | hdf5-c05a215c2f2f39c223a97991c2554e3d87639354.zip hdf5-c05a215c2f2f39c223a97991c2554e3d87639354.tar.gz hdf5-c05a215c2f2f39c223a97991c2554e3d87639354.tar.bz2 |
[svn-r13511]
1.6 implementation of 1.7 h5dump bugs fixed
# 701 h5dump hardlink pointing to the root group "/"
# 466 h5dump: output data in binary format
h5dump, added long names for parameters that did not have them on the command line parsing
#344 h5dump does not show double long data
#467 h5dump does not show group comment
#405 h5dump does not print an attribute of a named datatype
#570 h5ls/h5dump print of datatype.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5dump/Makefile.in | 7 | ||||
-rw-r--r-- | tools/h5dump/binread.c | 101 | ||||
-rw-r--r-- | tools/h5dump/h5dump.c | 351 | ||||
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 136 | ||||
-rw-r--r-- | tools/h5dump/testh5dump.sh.in | 16 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 578 | ||||
-rw-r--r-- | tools/lib/h5tools.h | 4 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 148 | ||||
-rw-r--r-- | tools/lib/h5tools_str.h | 1 | ||||
-rw-r--r-- | tools/lib/h5tools_type.c | 153 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.c | 24 | ||||
-rw-r--r-- | tools/testfiles/tbin1.ddl | 11 | ||||
-rw-r--r-- | tools/testfiles/tbin2.ddl | 11 | ||||
-rw-r--r-- | tools/testfiles/tbin3.ddl | 11 | ||||
-rw-r--r-- | tools/testfiles/tbin4.ddl | 11 | ||||
-rw-r--r-- | tools/testfiles/tbinary.h5 | bin | 0 -> 806144 bytes | |||
-rw-r--r-- | tools/testfiles/thlink-1.ddl | 3 | ||||
-rw-r--r-- | tools/testfiles/thlink-1.ls | 1 | ||||
-rw-r--r-- | tools/testfiles/thlink.h5 | bin | 3332 -> 5712 bytes | |||
-rw-r--r-- | tools/testfiles/tldouble.h5 | bin | 0 -> 2084 bytes | |||
-rw-r--r-- | tools/testfiles/tnofilename.ddl | 15 |
21 files changed, 1355 insertions, 227 deletions
diff --git a/tools/h5dump/Makefile.in b/tools/h5dump/Makefile.in index 298a4d1..9aad930 100644 --- a/tools/h5dump/Makefile.in +++ b/tools/h5dump/Makefile.in @@ -53,7 +53,7 @@ DISTCLEAN=testh5dump.sh ## Source and object files for programs... ## -PROG_SRC=h5dump.c h5dumpgentest.c +PROG_SRC=h5dump.c h5dumpgentest.c binread.c PROG_OBJ=$(PROG_SRC:.c=.lo) PRIVATE_HDR=h5dump.h @@ -76,7 +76,7 @@ check-xml: ## How to build the programs...They all depend on the hdf5 library and ## the tools library compiled in this directory. ## -$(PROGS): $(LIBTOOLS) $(LIBHDF5) +$(PROGS): $(LIBTOOLS) $(LIBHDF5) binread h5dump: h5dump.lo @$(LT_LINK_EXE) $(CFLAGS) -o $@ h5dump.lo $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS) @@ -84,4 +84,7 @@ h5dump: h5dump.lo h5dumpgentest: h5dumpgentest.lo @$(LT_LINK_EXE) $(CFLAGS) -o $@ h5dumpgentest.lo $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS) +binread: binread.lo + @$(LT_LINK_EXE) $(CFLAGS) -o $@ binread.lo $(LDFLAGS) $(LIBS) + @CONCLUDE@ diff --git a/tools/h5dump/binread.c b/tools/h5dump/binread.c new file mode 100644 index 0000000..ab10af0 --- /dev/null +++ b/tools/h5dump/binread.c @@ -0,0 +1,101 @@ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +/* + This program reads binary output from h5dump (-b option). + To use change the following 3 symbols accordingly. + For example, to read 2 elements of a float type , define + + #define NELMTS 2 + #define TYPE float + #define FORMAT "%f " + +*/ + +#define NELMTS 6 +#define TYPE int +#define FORMAT "%d " + +/*------------------------------------------------------------------------- + * Function: usage + * + * Purpose: Prints a usage message on stderr and then returns. + * + * Return: void + * + * Programmer: Pedro Vicente Nunes + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +usage (void) +{ + fprintf(stderr, "\ + usage: binread FILE_NAME\n"); +} + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: main program. + * + *------------------------------------------------------------------------- + */ + +int +main (int argc, const char *argv[]) +{ + FILE *stream; + int numread; + TYPE buf[NELMTS]; + size_t i, nelmts = NELMTS; + char *fname=NULL; + + if (argc != 2) + { + usage(); + exit(1); + } + + fname = strdup(argv[1]); + + if( (stream = fopen(fname, "rb" )) != NULL ) + { + numread = fread( buf, sizeof( TYPE ), nelmts, stream ); + printf( "Number of items read = %d\n", numread ); + + for (i = 0; i < nelmts; i++) + { + printf(FORMAT,buf[i]); + } + printf("\n"); + + fclose( stream ); + } + else + printf( "File %s could not be opened\n",fname ); + + free(fname); + + return 0; +} + diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index db1a6ac..501e4f5 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -352,7 +352,7 @@ struct handler_t { * parameters. The long-named ones can be partially spelled. When * adding more, make sure that they don't clash with each other. */ -static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:s:S:A"; +static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:b:F:s:S:A"; static struct long_options l_opts[] = { { "help", no_arg, 'h' }, { "hel", no_arg, 'h' }, @@ -457,6 +457,11 @@ static struct long_options l_opts[] = { { "xml-n", require_arg, 'X' }, { "xml", no_arg, 'x' }, { "xm", no_arg, 'x' }, + { "onlyattr", no_arg, 'A' }, + { "escape", no_arg, 'e' }, + { "noindex", no_arg, 'y' }, + { "binary", require_arg, 'b' }, + { "form", require_arg, 'F' }, { NULL, 0, '\0' } }; @@ -588,19 +593,24 @@ usage(const char *prog) fprintf(stdout, " -n, --contents Print a list of the file contents and exit\n"); fprintf(stdout, " -B, --bootblock Print the content of the boot block\n"); fprintf(stdout, " -H, --header Print the header only; no data is displayed\n"); - fprintf(stdout, " -A Print the header and value of attributes; data of datasets is not displayed\n"); + fprintf(stdout, " -A, --onlyattr Print the header and value of attributes; data \n"); + fprintf(stdout, " of datasets is not displayed\n"); fprintf(stdout, " -i, --object-ids Print the object ids\n"); fprintf(stdout, " -r, --string Print 1-byte integer datasets as ASCII\n"); - fprintf(stdout, " -e, Escape non printing characters\n"); + fprintf(stdout, " -e, --escape Escape non printing characters\n"); fprintf(stdout, " -V, --version Print version number and exit\n"); fprintf(stdout, " -a P, --attribute=P Print the specified attribute\n"); fprintf(stdout, " -d P, --dataset=P Print the specified dataset\n"); - fprintf(stdout, " -y Do not print array indices with the data\n"); + fprintf(stdout, " -y, --noindex Do not print array indices with the data\n"); fprintf(stdout, " -p, --properties Print dataset filters, storage layout and fill value\n"); fprintf(stdout, " -f D, --filedriver=D Specify which driver to open the file with\n"); fprintf(stdout, " -g P, --group=P Print the specified group and all members\n"); fprintf(stdout, " -l P, --soft-link=P Print the value(s) of the specified soft link\n"); fprintf(stdout, " -o F, --output=F Output raw data into file F\n"); + fprintf(stdout, " -b B, --binary=B Binary file output, of form B. Recommended usage is\n"); + fprintf(stdout, " with -o (output file) and -d (dataset). B can be:\n"); + fprintf(stdout, " MEMORY for a memory type, FILE for the file type,\n"); + fprintf(stdout, " LE or BE for pre-existing little or big endian types\n"); fprintf(stdout, " -t P, --datatype=P Print the specified named data type\n"); fprintf(stdout, " -w N, --width=N Set the number of columns of output\n"); fprintf(stdout, " -x, --xml Output in XML using Schema\n"); @@ -645,6 +655,10 @@ usage(const char *prog) fprintf(stdout, "\n"); fprintf(stdout, " h5dump -d /foo -s \"0,1\" -S \"1,1\" -c \"2,3\" -k \"2,2\" quux.h5\n"); fprintf(stdout, "\n"); + fprintf(stdout, " 3) Saving dataset 'dset' in file quux.h5 to binary file 'out.bin' using a little-endian type \n"); + fprintf(stdout, "\n"); + fprintf(stdout, " h5dump -d /dset -b LE -o out.bin quux.h5\n"); + fprintf(stdout, "\n"); } /*------------------------------------------------------------------------- @@ -656,31 +670,36 @@ 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 * *------------------------------------------------------------------------- */ + static void print_datatype(hid_t type,unsigned in_group) { - char *fname; + char *mname; hid_t mtype, str_type; unsigned nmembers; - int perm[H5DUMP_MAX_RANK]; unsigned ndims; unsigned i; size_t size=0; hsize_t dims[H5DUMP_MAX_RANK]; H5T_str_t str_pad; H5T_cset_t cset; - H5G_stat_t statbuf; H5T_order_t order; 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 */ + H5G_stat_t statbuf; H5Gget_objinfo(type, ".", TRUE, &statbuf); obj = search_obj(type_table, statbuf.objno); @@ -706,82 +725,137 @@ 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_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"); - } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) { +#if H5_SIZEOF_LONG_DOUBLE !=0 + } 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; @@ -895,21 +969,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"); @@ -931,7 +1005,7 @@ done: printf("H5T_COMPOUND %s\n", dump_header_format->structblockbegin); for (i = 0; i < nmembers; i++) { - fname = H5Tget_member_name(type, i); + mname = H5Tget_member_name(type, i); mtype = H5Tget_member_type(type, i); indentation(indent + COL); @@ -943,8 +1017,8 @@ done: if (H5Tget_class(mtype) == H5T_COMPOUND) indent -= COL; - printf(" \"%s\";\n", fname); - free(fname); + printf(" \"%s\";\n", mname); + free(mname); } indentation(indent); @@ -987,7 +1061,7 @@ done: /* Get array information */ ndims = H5Tget_array_ndims(type); - H5Tget_array_dims(type, dims, perm); + H5Tget_array_dims(type, dims, NULL); /* Print array dimensions */ for (i = 0; i < ndims; i++) @@ -1606,26 +1680,33 @@ done: * * Programmer: Ruey-Hsia Li * - * Modifications: Comments: not yet implemented. + * Modifications: pvn March 27, 2006 + * add printing of attributes * *------------------------------------------------------------------------- */ static void dump_named_datatype(hid_t type, const char *name) { - indentation(indent); - printf("%s \"%s\" %s", dump_header_format->datatypebegin, name, - dump_header_format->datatypeblockbegin); - - if (H5Tget_class(type) == H5T_COMPOUND) { - print_datatype(type,1); - } else { - indentation(indent + COL); - print_datatype(type,1); - printf(";\n"); - } - end_obj(dump_header_format->datatypeend, - dump_header_format->datatypeblockend); + indentation(indent); + printf("%s \"%s\" %s", dump_header_format->datatypebegin, name, + dump_header_format->datatypeblockbegin); + + if (H5Tget_class(type) == H5T_COMPOUND) { + print_datatype(type,1); + } else { + indentation(indent + COL); + print_datatype(type,1); + printf(";\n"); + } + + /* print attributes */ + indent += COL; + H5Aiterate(type, NULL, dump_attr, NULL); + indent -= COL; + + end_obj(dump_header_format->datatypeend, + dump_header_format->datatypeblockend); } /*------------------------------------------------------------------------- @@ -1894,7 +1975,7 @@ dump_subsetting_header(struct subset_t *sset, int dims) *------------------------------------------------------------------------- */ static void -dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) +dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) { h5tool_format_t *outputformat = &dataformat; int status = -1; @@ -1909,7 +1990,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) outputformat->line_ncols = nCols; outputformat->do_escape=display_escape; /* print the matrix indices */ - outputformat->pindex=pindex; + outputformat->pindex=display_index; if (outputformat->pindex) { outputformat->idx_fmt = "(%s): "; outputformat->idx_n_fmt = HSIZE_T_FORMAT; @@ -2610,21 +2691,72 @@ static void dump_fcontents(hid_t fid) * Programmer: Albert Cheng, 2000/09/30 * * Modifications: + * pvn June, 1, 2006. Add a switch for binary output * *------------------------------------------------------------------------- */ static int -set_output_file(const char *fname) +set_output_file(const char *fname, int is_bin) { - FILE *f; /* temporary holding place for the stream pointer - * so that rawdatastream is changed only when succeeded */ - - if ((f = fopen(fname, "w")) != NULL) { - rawdatastream = f; - return 0; - } + FILE *f; /* temporary holding place for the stream pointer +* so that rawdatastream is changed only when succeeded */ + + if (rawdatastream && rawdatastream != stdout) { + if (fclose(rawdatastream)) + perror("closing rawdatastream"); + else + rawdatastream = NULL; + } + + /* binary output */ + if (is_bin) + { + if ((f = fopen(fname, "wb")) != NULL) { + rawdatastream = f; + return 0; + } + } + else + { + if ((f = fopen(fname, "w")) != NULL) { + rawdatastream = f; + return 0; + } + } + + return -1; +} - return -1; +/*------------------------------------------------------------------------- + * Function: set_binary_form + * + * Purpose: set the binary form of output by translating from a string input + * parameter to a integer return value + * + * Return: integer form of binary output or -1 if none found + * + * Programmer: Pedro Vicente Nunes + * June 28, 2006 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +set_binary_form(const char *form) +{ + int bform=-1; + + if (strcmp(form,"MEMORY")==0) /* native form */ + bform = 0; + else if (strcmp(form,"FILE")==0) /* file type form */ + bform = 1; + else if (strcmp(form,"LE")==0) /* convert to little endian */ + bform = 2; + else if (strcmp(form,"BE")==0) /* convert to big endian */ + bform = 3; + + return bform; } /*------------------------------------------------------------------------- @@ -3062,6 +3194,7 @@ handle_datatypes(hid_t fid, char *type, void UNUSED * data) * Tuesday, 20. February 2001 * * Modifications: + * pvn June, 1, 2006. Add a switch for binary output * *------------------------------------------------------------------------- */ @@ -3071,6 +3204,10 @@ parse_command_line(int argc, const char *argv[]) struct handler_t *hand, *last_dset = NULL; int i, opt, last_was_dset = FALSE; + /* some logic to handle both -o and -b order */ + const char *outfname=NULL; + bin_form = -1; + /* this will be plenty big enough to hold the info */ hand = calloc((size_t)argc, sizeof(struct handler_t)); @@ -3185,16 +3322,48 @@ parse_start: last_was_dset = FALSE; break; - case 'o': - if (set_output_file(opt_arg) < 0){ - /* failed to set output file */ - usage(progname); - leave(EXIT_FAILURE); - } - usingdasho = TRUE; - last_was_dset = FALSE; - break; + case 'o': + + if (bin_form > 0 ) + { + if (set_output_file(opt_arg, 1) < 0){ + usage(progname); + leave(EXIT_FAILURE); + } + } + else + { + if (set_output_file(opt_arg, 0) < 0){ + usage(progname); + leave(EXIT_FAILURE); + } + } + + usingdasho = TRUE; + last_was_dset = FALSE; + outfname = opt_arg; + break; + + case 'b': + + if ( ( bin_form = set_binary_form(opt_arg)) < 0){ + /* failed to set binary form */ + usage(progname); + leave(EXIT_FAILURE); + } + if (outfname!=NULL) { + if (set_output_file(outfname, 1) < 0){ + /* failed to set output file */ + usage(progname); + leave(EXIT_FAILURE); + } + + bin_output = TRUE; + last_was_dset = FALSE; + } + + break; /** begin XML parameters **/ case 'x': diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 97a71c0..4415bd7 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -451,7 +451,11 @@ static void gent_hardlink(void) group = H5Gopen(fid, "/g1"); H5Glink (group, H5G_LINK_HARD, "/g2", "g1.1"); H5Gclose(group); + + /* create a link to the root group */ + H5Glink (fid, H5G_LINK_HARD, "/", "g3"); H5Fclose(fid); + } /* @@ -5284,6 +5288,136 @@ static void gent_longlinks(void) HDfree(objname); } +/*------------------------------------------------------------------------- + * 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: gent_binary + * + * Purpose: Generate a file to be used in the binary output test + * Contains: + * 1) an integer dataset + * 2) a float dataset + * 3) an array dataset + * 4) a large double dataset + * + *------------------------------------------------------------------------- + */ +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}; + 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; + + fid = H5Fcreate(FILE55, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + +/*------------------------------------------------------------------------- + * integer + *------------------------------------------------------------------------- + */ + sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate(fid, "integer", H5T_NATIVE_INT, sid, 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 = H5Dcreate(fid, "float", H5T_NATIVE_FLOAT, sid, H5P_DEFAULT); + H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, fbuf); + H5Dclose(did); + H5Sclose(sid); + +/*------------------------------------------------------------------------- + * array + *------------------------------------------------------------------------- + */ + tid = H5Tarray_create(H5T_NATIVE_INT, 1, dims, NULL); + sid = H5Screate_simple(1, dimarray, NULL); + did = H5Dcreate(fid, "array", tid, sid, 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 = H5Dcreate(fid, "double", H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT); + dbuf=calloc(100000,sizeof(double)); + if (dbuf!=NULL) + { + H5Dwrite(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); + free(dbuf); + } + H5Dclose(did); + H5Sclose(sid); + + /* close */ + H5Fclose(fid); +} /*------------------------------------------------------------------------- * Function: gen_bigdims @@ -5480,6 +5614,8 @@ int main(void) gent_string(); gent_aindices(); gent_longlinks(); + gent_ldouble(); + gent_binary(); gent_bigdims(); gent_hyperslab(); diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 897eabc..32fb20f 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -301,6 +301,22 @@ TOOLTEST tbigdims.ddl -d dset4gb -s 4294967284 -c 22 tbigdims.h5 # hyperslab read TOOLTEST thyperslab.ddl thyperslab.h5 +# + +# test for long double (some systems do not have long double) +#TOOLTEST tldouble.ddl tldouble.h5 + +# test for binary output +TOOLTEST tbin1.ddl -d integer -o out1.bin -b LE tbinary.h5 +TOOLTEST tbin2.ddl -d float -o out2.bin -b BE tbinary.h5 +TOOLTEST tbin3.ddl -d array -o out3.bin -b MEMORY tbinary.h5 +TOOLTEST tbin4.ddl -d double -o out4.bin -b FILE tbinary.h5 + # Clean up binary output files + if test -z "$HDF5_NOCLEANUP"; then + rm -f $srcdir/../testfiles/out[1-4].bin + fi + + if test $nerrors -eq 0 ; then echo "All $DUMPER tests passed." diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index f76d4d3..e678a4f 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -30,23 +30,20 @@ #include "h5tools_utils.h" #include "H5private.h" -/* - * The output functions need a temporary buffer to hold a piece of the - * dataset while it's being printed. This constant sets the limit on the - * size of that temporary buffer in bytes. For efficiency's sake, choose the - * largest value suitable for your machine (for testing use a small value). - */ -#if 1 -#define H5TOOLS_BUFSIZE (1024 * 1024) -#else -#define H5TOOLS_BUFSIZE (1024) -#endif /* 1 */ + #define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z)) /* global variables */ int compound_data; FILE *rawdatastream; /* should initialize to stdout but gcc moans about it */ +int bin_output; /* binary output */ +int bin_form; /* binary form */ + + +/* local prototypes */ +static int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem); +static int render_bin_output(FILE *stream, hid_t tid, void *_mem); /* module-scoped variables */ static int h5tools_init_g; /* if h5tools lib has been initialized */ @@ -508,22 +505,22 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, * Robb Matzke, Monday, April 26, 1999 * Modifications: * Robb Matzke, 1999-06-04 - * The `container' argument is the optional dataset for reference types. + * The `container' argument is the optional dataset for reference types. * * Robb Matzke, 1999-09-29 - * Understands the `per_line' property which indicates that every Nth - * element should begin a new line. + * Understands the `per_line' property which indicates that every Nth + * element should begin a new line. * * Robb Matzke, LLNL, 2003-06-05 * Do not dereference the memory for a variable-length string here. * Deref in h5tools_str_sprint() instead so recursive types are * handled correctly. - * - * Pedro Vicente Nunes, THG, 2005-10-19 + * + * Pedro Vicente Nunes, THG, 2005-10-19 * pass to the prefix in h5tools_simple_prefix the total position - * instead of the current stripmine position i; this is necessary - * to print the array indices - * new field sm_pos in h5tools_context_t, the current stripmine element position + * instead of the current stripmine position i; this is necessary + * to print the array indices + * new field sm_pos in h5tools_context_t, the current stripmine element position *------------------------------------------------------------------------- */ void @@ -531,15 +528,15 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai h5tools_context_t *ctx/*in,out*/, unsigned flags, hsize_t nelmts, hid_t type, void *_mem) { - unsigned char *mem = (unsigned char*)_mem; - hsize_t i; /*element counter */ - char *s, *section; /*a section of output */ - int secnum; /*section sequence number */ - size_t size; /*size of each datum */ - size_t ncols = 80; /*available output width */ - h5tools_str_t buffer; /*string into which to render */ - int multiline; /*datum was multiline */ - hsize_t curr_pos; /* total data element position */ + unsigned char *mem = (unsigned char*)_mem; + hsize_t i; /*element counter */ + char *s, *section; /*a section of output */ + int secnum; /*section sequence number */ + size_t size; /*size of each datum */ + size_t ncols = 80; /*available output width */ + h5tools_str_t buffer; /*string into which to render */ + int multiline; /*datum was multiline */ + hsize_t curr_pos; /* total data element position */ int elmt_counter = 0;/*counts the # elements printed. *I (ptl?) needed something that *isn't going to get reset when a new @@ -548,21 +545,30 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai *break after we see a number equal *to the ctx->size_last_dim. */ - /* Setup */ - memset(&buffer, 0, sizeof(h5tools_str_t)); - size = H5Tget_size(type); + /* binary dump */ + if (bin_output) + { + do_bin_output(stream,nelmts,type,_mem); + bin_output=0; + } + else + { + /* Setup */ + memset(&buffer, 0, sizeof(h5tools_str_t)); + size = H5Tget_size(type); + + if (info->line_ncols > 0) + ncols = info->line_ncols; - if (info->line_ncols > 0) - ncols = info->line_ncols; /* pass to the prefix in h5tools_simple_prefix the total position - instead of the current stripmine position i; this is necessary - to print the array indices */ - curr_pos = ctx->sm_pos; - - h5tools_simple_prefix(stream, info, ctx, curr_pos, 0); + instead of the current stripmine position i; this is necessary + to print the array indices */ + curr_pos = ctx->sm_pos; + + h5tools_simple_prefix(stream, info, ctx, curr_pos, 0); - for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) { + for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) { /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_sprint(&buffer, info, container, type, mem + i * size, ctx); @@ -664,8 +670,8 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai multiline++; /* pass to the prefix in h5tools_simple_prefix the total position - instead of the current stripmine position i; this is necessary - to print the array indices */ + instead of the current stripmine position i; this is necessary + to print the array indices */ curr_pos = ctx->sm_pos + i; h5tools_simple_prefix(stream, info, ctx, curr_pos, secnum); @@ -683,6 +689,9 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai } h5tools_str_close(&buffer); + + }/* else bin */ + } /*------------------------------------------------------------------------- @@ -890,33 +899,33 @@ static int h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, hid_t p_type, int indentlevel) { - hid_t f_space; /*file data space */ - hsize_t elmtno; /*counter */ - int i; /*counter */ - int carry; /*counter carry value */ - hsize_t zero[8]; /*vector of zeros */ - unsigned int flags; /*buffer extent flags */ - hsize_t total_size[H5S_MAX_RANK];/*total size of dataset*/ + hid_t f_space; /* file data space */ + hsize_t elmtno; /* counter */ + hsize_t i; /* counter */ + int carry; /* counter carry value */ + hsize_t zero[8]; /* vector of zeros */ + unsigned int flags; /* buffer extent flags */ + hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ /* Print info */ - h5tools_context_t ctx; /*print context */ - size_t p_type_nbytes; /*size of memory type */ - hsize_t p_nelmts; /*total selected elmts */ + h5tools_context_t ctx; /* print context */ + size_t p_type_nbytes; /* size of memory type */ + hsize_t p_nelmts; /* total selected elmts */ /* Stripmine info */ - hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ - hsize_t sm_nbytes; /*bytes per stripmine */ - hsize_t sm_nelmts; /*elements per stripmine*/ - unsigned char *sm_buf = NULL; /*buffer for raw data */ - hid_t sm_space; /*stripmine data space */ + hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ + hsize_t sm_nbytes; /* bytes per stripmine */ + hsize_t sm_nelmts; /* elements per stripmine*/ + unsigned char *sm_buf = NULL; /* buffer for raw data */ + hid_t sm_space; /* stripmine data space */ /* Hyperslab info */ - hsize_t hs_offset[H5S_MAX_RANK];/*starting offset */ - hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */ - hsize_t hs_nelmts; /*elements in request */ + hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */ + hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */ + hsize_t hs_nelmts; /* elements in request */ /* VL data special information */ - unsigned int vl_data = 0; /*contains VL datatypes */ + unsigned int vl_data = 0; /* contains VL datatypes */ f_space = H5Dget_space(dset); @@ -932,7 +941,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, ctx.indent_level = indentlevel; ctx.need_prefix = 1; ctx.ndims = H5Sget_simple_extent_ndims(f_space); - + if ((size_t)ctx.ndims > NELMTS(sm_size)) { H5Sclose(f_space); return FAIL; @@ -1193,8 +1202,12 @@ h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, hid_t _ if (p_type < 0) { f_type = H5Dget_type(dset); - if (info->raw) + 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); @@ -1217,7 +1230,7 @@ h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, hid_t _ else status = h5tools_dump_simple_subset(rawdatastream, info, dset, p_type, sset, indentlevel); - } else /* space is H5S_NULL */ + } else status = SUCCEED; /* Close the dataspace */ @@ -1299,3 +1312,442 @@ void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) ctx->pos[i]=0; } +/*------------------------------------------------------------------------- + * Function: do_bin_output + * + * Purpose: Dump memory buffer to a binary file stream + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Pedro Vicente Nunes + * Friday, June 2, 2006 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static +int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem) +{ + unsigned char *mem = (unsigned char*)_mem; + size_t size; /* datum size */ + hsize_t i; /* element counter */ + + size = H5Tget_size(tid); + + for (i = 0; i < nelmts; i++) + { + if (render_bin_output(stream,tid,mem + i * size)<0) + { + printf("\nError in writing binary stream\n"); + return FAIL; + } + } + + return SUCCEED; +} + + +/*------------------------------------------------------------------------- + * Function: render_bin_output + * + * Purpose: Write one element of memory buffer to a binary file stream + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Pedro Vicente Nunes + * Friday, June 2, 2006 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static +int render_bin_output(FILE *stream, hid_t tid, void *_mem) +{ +#if 0 + #define DEBUG_H5DUMP_BIN 1 +#endif + unsigned char *mem = (unsigned char*)_mem; + size_t size; /* datum size */ + float tempfloat; + double tempdouble; + unsigned long_long tempullong; + long_long templlong; + unsigned long tempulong; + long templong; + unsigned int tempuint; + int tempint; + unsigned short tempushort; + short tempshort; + unsigned char tempuchar; + char tempschar; +#if H5_SIZEOF_LONG_DOUBLE !=0 + long double templdouble; +#endif +#ifdef DEBUG_H5DUMP_BIN + static char fmt_llong[8], fmt_ullong[8]; + if (!fmt_llong[0]) { + sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); + sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); + } +#endif + + size = H5Tget_size(tid); + + if (H5Tequal(tid, H5T_NATIVE_FLOAT)) + { + memcpy(&tempfloat, mem, sizeof(float)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%g ", tempfloat); +#else + if (1 != fwrite(&tempfloat, size, 1, stream)) + return FAIL; +#endif + } + else if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) + { + memcpy(&tempdouble, mem, sizeof(double)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%g ", tempdouble); +#else + if (1 != fwrite(&tempdouble, size, 1, stream)) + return FAIL; +#endif + } +#if H5_SIZEOF_LONG_DOUBLE !=0 + else if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) + { + memcpy(&templdouble, mem, sizeof(long double)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%Lf ", templdouble); +#else + if (1 != fwrite(&templdouble, size, 1, stream)) + return FAIL; +#endif + } +#endif + else if (H5T_STRING == H5Tget_class(tid)) + { + unsigned int i; + H5T_str_t pad; + char *s; + + pad = H5Tget_strpad(tid); + + if(H5Tis_variable_str(tid)) + { + s = *(char**)mem; + if(s!=NULL) + size = HDstrlen(s); + } + else + { + s = (char *)mem; + size = H5Tget_size(tid); + } + for (i=0; i<size && (s[i] || pad!=H5T_STR_NULLTERM); i++) + { + memcpy(&tempuchar, &s[i], sizeof(unsigned char)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%d", tempuchar); +#else + if (1 != fwrite(&tempuchar, size, 1, stream)) + return FAIL; +#endif + } /* i */ + } + else if (H5Tequal(tid, H5T_NATIVE_INT)) + { + memcpy(&tempint, mem, sizeof(int)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%d ", tempint); +#else + if (1 != fwrite(&tempint, size, 1, stream)) + return FAIL; +#endif + } + else if (H5Tequal(tid, H5T_NATIVE_UINT)) + { + memcpy(&tempuint, mem, sizeof(unsigned int)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%u ", tempuint); +#else + if (1 != fwrite(&tempuint, size, 1, stream)) + return FAIL; +#endif + } + else if (H5Tequal(tid, H5T_NATIVE_SCHAR)) + { + memcpy(&tempschar, mem, sizeof(char)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%d ", tempschar); +#else + if (1 != fwrite(&tempschar, size, 1, stream)) + return FAIL; +#endif + } + else if (H5Tequal(tid, H5T_NATIVE_UCHAR)) + { + memcpy(&tempuchar, mem, sizeof(unsigned char)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%u ", tempuchar); +#else + if (1 != fwrite(&tempuchar, size, 1, stream)) + return FAIL; +#endif + } + else if (H5Tequal(tid, H5T_NATIVE_SHORT)) + { + memcpy(&tempshort, mem, sizeof(short)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%d ", tempshort); +#else + if (1 != fwrite(&tempshort, size, 1, stream)) + return FAIL; +#endif + } + else if (H5Tequal(tid, H5T_NATIVE_USHORT)) + { + memcpy(&tempushort, mem, sizeof(unsigned short)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%u ", tempushort); +#else + if (1 != fwrite(&tempushort, size, 1, stream)) + return FAIL; +#endif + } + else if (H5Tequal(tid, H5T_NATIVE_LONG)) + { + memcpy(&templong, mem, sizeof(long)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%ld ", templong); +#else + if (1 != fwrite(&templong, size, 1, stream)) + return FAIL; +#endif + } + else if (H5Tequal(tid, H5T_NATIVE_ULONG)) + { + memcpy(&tempulong, mem, sizeof(unsigned long)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%lu ", tempulong); +#else + if (1 != fwrite(&tempulong, size, 1, stream)) + return FAIL; +#endif + } + else if (H5Tequal(tid, H5T_NATIVE_LLONG)) + { + memcpy(&templlong, mem, sizeof(long_long)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, fmt_llong, templlong); +#else + if (1 != fwrite(&templlong, size, 1, stream)) + return FAIL; +#endif + } + else if (H5Tequal(tid, H5T_NATIVE_ULLONG)) + { + memcpy(&tempullong, mem, sizeof(unsigned long_long)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, fmt_ullong, tempullong); +#else + if (1 != fwrite(&tempullong, size, 1, stream)) + return FAIL; +#endif + } + else if (H5Tequal(tid, H5T_NATIVE_HSSIZE)) + { + if (sizeof(hssize_t) == sizeof(int)) + { + memcpy(&tempint, mem, sizeof(int)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%d ", tempint); +#else + if (1 != fwrite(&tempint, size, 1, stream)) + return FAIL; +#endif + } + else if (sizeof(hssize_t) == sizeof(long)) + { + memcpy(&templong, mem, sizeof(long)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%ld ", templong); +#else + if (1 != fwrite(&templong, size, 1, stream)) + return FAIL; +#endif + } + else + { + memcpy(&templlong, mem, sizeof(long_long)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, fmt_llong, templlong); +#else + if (1 != fwrite(&templlong, size, 1, stream)) + return FAIL; +#endif + } + } + else if (H5Tequal(tid, H5T_NATIVE_HSIZE)) + { + if (sizeof(hsize_t) == sizeof(int)) + { + memcpy(&tempuint, mem, sizeof(unsigned int)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%u ", tempuint); +#else + if (1 != fwrite(&tempuint, size, 1, stream)) + return FAIL; +#endif + } + else if (sizeof(hsize_t) == sizeof(long)) + { + memcpy(&tempulong, mem, sizeof(unsigned long)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%lu ", tempulong); +#else + if (1 != fwrite(&tempulong, size, 1, stream)) + return FAIL; +#endif + } + else + { + memcpy(&tempullong, mem, sizeof(unsigned long_long)); +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, fmt_ullong, tempullong); +#else + if (1 != fwrite(&tempullong, size, 1, stream)) + return FAIL; +#endif + } + } + else if (H5Tget_class(tid) == H5T_COMPOUND) + { + unsigned j; + hid_t memb; + unsigned nmembs; + size_t offset; + + nmembs = H5Tget_nmembers(tid); + + for (j = 0; j < nmembs; j++) + { + offset = H5Tget_member_offset(tid, j); + memb = H5Tget_member_type(tid, j); + + if (render_bin_output(stream,memb,mem + offset)<0) + return FAIL; + + H5Tclose(memb); + } + } + else if (H5Tget_class(tid) == H5T_ENUM) + { + unsigned int i; + if (1==size) + { +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "0x%02x", mem[0]); +#else + if (1 != fwrite(&mem[0], size, 1, stream)) + return FAIL; +#endif + } + else + { + for (i = 0; i < size; i++) + { +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%s%02x", i?":":"", mem[i]); +#else + if (1 != fwrite(&mem[i], sizeof(char), 1, stream)) + return FAIL; +#endif + } /*i*/ + }/*else 1 */ + } + else if (H5Tget_class(tid) == H5T_ARRAY) + { + int k, ndims; + hsize_t i, dims[H5S_MAX_RANK], temp_nelmts, nelmts; + hid_t memb; + + /* get the array's base datatype for each element */ + memb = H5Tget_super(tid); + size = H5Tget_size(memb); + ndims = H5Tget_array_ndims(tid); + H5Tget_array_dims(tid, dims, NULL); + assert(ndims >= 1 && ndims <= H5S_MAX_RANK); + + /* calculate the number of array elements */ + for (k = 0, nelmts = 1; k < ndims; k++) + { + temp_nelmts = nelmts; + temp_nelmts *= dims[k]; + nelmts = (size_t)temp_nelmts; + } + + /* dump the array element */ + for (i = 0; i < nelmts; i++) + { + if (render_bin_output(stream,memb,mem + i * size)<0) + return FAIL; + } + + H5Tclose(memb); + } + else if (H5Tget_class(tid) == H5T_VLEN) + { + unsigned int i; + hsize_t nelmts; + hid_t memb; + + /* get the VL sequences's base datatype for each element */ + memb = H5Tget_super(tid); + size = H5Tget_size(memb); + + /* Get the number of sequence elements */ + nelmts = ((hvl_t *)mem)->len; + + for (i = 0; i < nelmts; i++) + { + /* dump the array element */ + if (render_bin_output(stream,memb,((char *)(((hvl_t *)mem)->p)) + i * size)<0) + return FAIL; + } + H5Tclose(memb); + } + else + { + size_t i; + if (1==size) + { +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "0x%02x", mem[0]); +#else + if (1 != fwrite(&mem[0], size, 1, stream)) + return FAIL; +#endif + } + else + { + for (i = 0; i < size; i++) + { +#ifdef DEBUG_H5DUMP_BIN + fprintf(stream, "%s%02x", i?":":"", mem[i]); +#else + if (1 != fwrite(&mem[i], sizeof(char), 1, stream)) + return FAIL; +#endif + } /*i*/ + }/*else 1 */ + } + + + return SUCCEED; +} + diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index bbb4d40..8a076a7 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -375,6 +375,8 @@ struct subset_t { }; extern FILE *rawdatastream; /*output stream for raw data */ +extern int bin_output; /* binary output */ +extern int bin_form; /* binary form */ /* Strings for output */ #define GROUP "GROUP" @@ -391,6 +393,8 @@ 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_str.c b/tools/lib/h5tools_str.c index 56baccf..9879ac4 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -47,6 +47,8 @@ static char *h5tools_escape(char *s, size_t size); static hbool_t h5tools_is_zero(const void *_mem, size_t size); +static void h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch); + /*------------------------------------------------------------------------- * Function: h5tools_str_close @@ -340,7 +342,7 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, h5tools_str_append(str, "%s", OPT(info->idx_sep, ",")); h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), - ctx->pos[i]); + (hsize_t)ctx->pos[i]); } } else { /* Scalar */ @@ -465,69 +467,70 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5tool_format_t * *------------------------------------------------------------------------- */ -void -h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, unsigned char ch) + +static void +h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch) { if (info->str_locale == ESCAPE_HTML) { if (ch <= ' ' || ch > '~') h5tools_str_append(str, "%%%02x", ch); else - h5tools_str_append(str, "%c", (char)ch); + h5tools_str_append(str, "%c", ch); } else { switch (ch) { - case '"': - if (!info->do_escape) - h5tools_str_append(str, "\""); - else - h5tools_str_append(str, "\\\""); - break; - case '\\': - if (!info->do_escape) - h5tools_str_append(str, "\\"); - else - h5tools_str_append(str, "\\\\"); - break; - case '\b': - if (!info->do_escape) - h5tools_str_append(str, "\b"); - else - h5tools_str_append(str, "\\b"); - break; - case '\f': - if (!info->do_escape) - h5tools_str_append(str, "\f"); - else - h5tools_str_append(str, "\\f"); - break; - case '\n': - if (!info->do_escape) { - h5tools_str_append(str, "\n"); - h5tools_str_append(str, " "); - } - else - h5tools_str_append(str, "\\n"); - break; - case '\r': - if (!info->do_escape) { - h5tools_str_append(str, "\r"); - h5tools_str_append(str, " "); - } - else - h5tools_str_append(str, "\\r"); - break; - case '\t': - if (!info->do_escape) - h5tools_str_append(str, "\t"); - else - h5tools_str_append(str, "\\t"); - break; - default: - if (isprint(ch)) - h5tools_str_append(str, "%c", (char)ch); - else - h5tools_str_append(str, "\\%03o", ch); - - break; + case '"': + if (!info->do_escape) + h5tools_str_append(str, "\""); + else + h5tools_str_append(str, "\\\""); + break; + case '\\': + if (!info->do_escape) + h5tools_str_append(str, "\\"); + else + h5tools_str_append(str, "\\\\"); + break; + case '\b': + if (!info->do_escape) + h5tools_str_append(str, "\b"); + else + h5tools_str_append(str, "\\b"); + break; + case '\f': + if (!info->do_escape) + h5tools_str_append(str, "\f"); + else + h5tools_str_append(str, "\\f"); + break; + case '\n': + if (!info->do_escape) { + h5tools_str_append(str, "\n"); + h5tools_str_append(str, " "); + } + else + h5tools_str_append(str, "\\n"); + break; + case '\r': + if (!info->do_escape) { + h5tools_str_append(str, "\r"); + h5tools_str_append(str, " "); + } + else + h5tools_str_append(str, "\\r"); + break; + case '\t': + if (!info->do_escape) + h5tools_str_append(str, "\t"); + else + h5tools_str_append(str, "\\t"); + break; + default: + if (isprint(ch)) + h5tools_str_append(str, "%c", ch); + else + h5tools_str_append(str, "\\%03o", ch); + + break; } } } @@ -557,15 +560,18 @@ h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, unsigned cha * Added support for printing raw data. If info->raw is non-zero * then data is printed in hexadecimal format. * - * Robb Matzke, 2003-01-10 - * Binary output format is dd:dd:... instead of 0xdddd... so it - * doesn't look like a hexadecimal integer, and thus users will - * be less likely to complain that HDF5 didn't properly byte - * swap their data during type conversion. + * Robb Matzke, 2003-01-10 + * Binary output format is dd:dd:... instead of 0xdddd... so it + * doesn't look like a hexadecimal integer, and thus users will + * be less likely to complain that HDF5 didn't properly byte + * swap their data during type conversion. + * + * Robb Matzke, LLNL, 2003-06-05 + * If TYPE is a variable length string then the pointer to + * the value to pring (VP) is a pointer to a `char*'. * - * Robb Matzke, LLNL, 2003-06-05 - * If TYPE is a variable length string then the pointer to - * the value to pring (VP) is a pointer to a `char*'. + * PVN, 28 March 2006 + * added H5T_NATIVE_LDOUBLE case *------------------------------------------------------------------------- */ char * @@ -597,6 +603,9 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai int tempint; unsigned short tempushort; short tempshort; +#if H5_SIZEOF_LONG_DOUBLE !=0 + long double templdouble; +#endif /* Build default formats for long long types */ if (!fmt_llong[0]) { @@ -624,9 +633,14 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { memcpy(&tempdouble, vp, sizeof(double)); h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble); +#if H5_SIZEOF_LONG_DOUBLE !=0 + } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) { + memcpy(&templdouble, vp, sizeof(long double)); + h5tools_str_append(str, "%Lf", templdouble); +#endif } else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || H5Tequal(type, H5T_NATIVE_UCHAR))) { - h5tools_print_char(str, info, (unsigned char)(*ucp_vp)); + h5tools_print_char(str, info, (char)(*ucp_vp)); } else if (H5T_STRING == H5Tget_class(type)) { unsigned int i; char quote = '\0'; @@ -680,7 +694,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } /* Print the character */ - h5tools_print_char(str, info, (unsigned char)(s[i])); + h5tools_print_char(str, info, s[i]); /* Print the repeat count */ if (info->str_repeat && j > info->str_repeat) { diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h index 1910bb5..0964b7b 100644 --- a/tools/lib/h5tools_str.h +++ b/tools/lib/h5tools_str.h @@ -36,7 +36,6 @@ extern char *h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_t *in hsize_t elmtno, int ndims, hsize_t min_idx[], hsize_t max_idx[], h5tools_context_t *ctx); extern int h5tools_str_dump_region(h5tools_str_t *, hid_t, const h5tool_format_t *); -extern void h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, unsigned char ch); extern char *h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, hid_t type, void *vp, h5tools_context_t *ctx); diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c index 77e6af3..103244e 100644 --- a/tools/lib/h5tools_type.c +++ b/tools/lib/h5tools_type.c @@ -47,3 +47,156 @@ 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/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 33718c8..73ddaad 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -598,6 +598,30 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table, info->type_table = *type_table; info->dset_table = *dset_table; + { + /* add the root group as an object, it may have hard links to it */ + + H5G_stat_t statbuf; + unsigned long objno[2]; /*object number */ + char* tmp; + + if(H5Gget_objinfo(fid, "/", FALSE, &statbuf) < 0) + return FAIL; + else + { + objno[0] = (unsigned long)(statbuf.objno[0]); +#if H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG + objno[1] = (unsigned long)(statbuf.objno[1] >> 8*sizeof(long)); +#else /* H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG */ + objno[1] = 0; +#endif /* H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG */ + + /* call with an empty string, it appends group separator */ + tmp = build_obj_path_name(info->prefix, ""); + add_obj(info->group_table, objno, tmp, TRUE); + } + } + /* Find all shared objects */ return(H5Giterate(fid, "/", NULL, find_objs_cb, (void *)info)); } diff --git a/tools/testfiles/tbin1.ddl b/tools/testfiles/tbin1.ddl new file mode 100644 index 0000000..3adbac0 --- /dev/null +++ b/tools/testfiles/tbin1.ddl @@ -0,0 +1,11 @@ +############################# +Expected output for 'h5dump -d integer -o out1.bin -b LE tbinary.h5' +############################# +HDF5 "tbinary.h5" { +DATASET "integer" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + DATA { + } +} +} diff --git a/tools/testfiles/tbin2.ddl b/tools/testfiles/tbin2.ddl new file mode 100644 index 0000000..f480e60 --- /dev/null +++ b/tools/testfiles/tbin2.ddl @@ -0,0 +1,11 @@ +############################# +Expected output for 'h5dump -d float -o out2.bin -b BE tbinary.h5' +############################# +HDF5 "tbinary.h5" { +DATASET "float" { + DATATYPE H5T_IEEE_F32LE + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } + DATA { + } +} +} diff --git a/tools/testfiles/tbin3.ddl b/tools/testfiles/tbin3.ddl new file mode 100644 index 0000000..a49547f --- /dev/null +++ b/tools/testfiles/tbin3.ddl @@ -0,0 +1,11 @@ +############################# +Expected output for 'h5dump -d array -o out3.bin -b MEMORY tbinary.h5' +############################# +HDF5 "tbinary.h5" { +DATASET "array" { + DATATYPE H5T_ARRAY { [6] H5T_STD_I32LE } + DATASPACE SIMPLE { ( 2 ) / ( 2 ) } + DATA { + } +} +} diff --git a/tools/testfiles/tbin4.ddl b/tools/testfiles/tbin4.ddl new file mode 100644 index 0000000..8b0b367 --- /dev/null +++ b/tools/testfiles/tbin4.ddl @@ -0,0 +1,11 @@ +############################# +Expected output for 'h5dump -d double -o out4.bin -b FILE tbinary.h5' +############################# +HDF5 "tbinary.h5" { +DATASET "double" { + DATATYPE H5T_IEEE_F64LE + DATASPACE SIMPLE { ( 100000 ) / ( 100000 ) } + DATA { + } +} +} diff --git a/tools/testfiles/tbinary.h5 b/tools/testfiles/tbinary.h5 Binary files differnew file mode 100644 index 0000000..0e53c8a --- /dev/null +++ b/tools/testfiles/tbinary.h5 diff --git a/tools/testfiles/thlink-1.ddl b/tools/testfiles/thlink-1.ddl index 4f50e80..c913201 100644 --- a/tools/testfiles/thlink-1.ddl +++ b/tools/testfiles/thlink-1.ddl @@ -23,5 +23,8 @@ GROUP "/" { GROUP "g2" { HARDLINK "/g1/g1.1" } + GROUP "g3" { + HARDLINK "/" + } } } diff --git a/tools/testfiles/thlink-1.ls b/tools/testfiles/thlink-1.ls index 5c9d408..01839bf 100644 --- a/tools/testfiles/thlink-1.ls +++ b/tools/testfiles/thlink-1.ls @@ -4,3 +4,4 @@ dset1 Dataset {5} g1 Group g2 Group +g3 Group, same as / diff --git a/tools/testfiles/thlink.h5 b/tools/testfiles/thlink.h5 Binary files differindex 678446e..19c6637 100644 --- a/tools/testfiles/thlink.h5 +++ b/tools/testfiles/thlink.h5 diff --git a/tools/testfiles/tldouble.h5 b/tools/testfiles/tldouble.h5 Binary files differnew file mode 100644 index 0000000..c3723aa --- /dev/null +++ b/tools/testfiles/tldouble.h5 diff --git a/tools/testfiles/tnofilename.ddl b/tools/testfiles/tnofilename.ddl index 36cbcad..f373857 100644 --- a/tools/testfiles/tnofilename.ddl +++ b/tools/testfiles/tnofilename.ddl @@ -7,19 +7,24 @@ usage: h5dump [OPTIONS] file -n, --contents Print a list of the file contents and exit -B, --bootblock Print the content of the boot block -H, --header Print the header only; no data is displayed - -A Print the header and value of attributes; data of datasets is not displayed + -A, --onlyattr Print the header and value of attributes; data + of datasets is not displayed -i, --object-ids Print the object ids -r, --string Print 1-byte integer datasets as ASCII - -e, Escape non printing characters + -e, --escape Escape non printing characters -V, --version Print version number and exit -a P, --attribute=P Print the specified attribute -d P, --dataset=P Print the specified dataset - -y Do not print array indices with the data + -y, --noindex Do not print array indices with the data -p, --properties Print dataset filters, storage layout and fill value -f D, --filedriver=D Specify which driver to open the file with -g P, --group=P Print the specified group and all members -l P, --soft-link=P Print the value(s) of the specified soft link -o F, --output=F Output raw data into file F + -b B, --binary=B Binary file output, of form B. Recommended usage is + with -o (output file) and -d (dataset). B can be: + MEMORY for a memory type, FILE for the file type, + LE or BE for pre-existing little or big endian types -t P, --datatype=P Print the specified named data type -w N, --width=N Set the number of columns of output -x, --xml Output in XML using Schema @@ -64,4 +69,8 @@ usage: h5dump [OPTIONS] file h5dump -d /foo -s "0,1" -S "1,1" -c "2,3" -k "2,2" quux.h5 + 3) Saving dataset 'dset' in file quux.h5 to binary file 'out.bin' using a little-endian type + + h5dump -d /dset -b LE -o out.bin quux.h5 + h5dump error: missing file name |