summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2006-09-26 15:47:36 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2006-09-26 15:47:36 (GMT)
commite9188e385af4ac913ee28e26717e9c8fb4336d2f (patch)
tree40ea75ee2506293321c648413e45ae235850a8ce
parent53a2d21415105951dd5d81969ee6f21d9e7216f8 (diff)
downloadhdf5-e9188e385af4ac913ee28e26717e9c8fb4336d2f.zip
hdf5-e9188e385af4ac913ee28e26717e9c8fb4336d2f.tar.gz
hdf5-e9188e385af4ac913ee28e26717e9c8fb4336d2f.tar.bz2
[svn-r12683]
revised binary flags, added a new file to the test generator program to be used in the binary tests usage is now -o F, --output=F Output raw data into file F -b F, --binary=F Binary output, of form F (into file -o F). Recommended usage is with --dataset=P Form F of binary output is: MEMORY for memory type, FILE for the disk file type, LE or BE for pre-existing little or big endian types example ./h5dump -d integer -b MEMORY -o out.bin tbinary.h5
-rw-r--r--tools/h5dump/binread.c6
-rw-r--r--tools/h5dump/h5dump.c84
-rw-r--r--tools/h5dump/h5dumpgentest.c40
-rw-r--r--tools/h5dump/testh5dump.sh.in8
-rw-r--r--tools/testfiles/tbin1.ddl6
-rw-r--r--tools/testfiles/tbin2.ddl10
-rw-r--r--tools/testfiles/tbin3.ddl6
-rw-r--r--tools/testfiles/tbin4.ddl10
-rw-r--r--tools/testfiles/tbinary.h5bin0 -> 2096 bytes
-rw-r--r--tools/testfiles/tnofilename.ddl8
10 files changed, 116 insertions, 62 deletions
diff --git a/tools/h5dump/binread.c b/tools/h5dump/binread.c
index 02bb115..108a760 100644
--- a/tools/h5dump/binread.c
+++ b/tools/h5dump/binread.c
@@ -20,15 +20,15 @@
/*
This program reads binary output from h5dump (-b option).
To use change the following 3 symbols accordingly.
- For example, to read 6 elements of a float type , define
+ For example, to read 2 elements of a float type , define
- #define NELMTS 6
+ #define NELMTS 2
#define TYPE float
#define FORMAT "%f "
*/
-#define NELMTS 2
+#define NELMTS 6
#define TYPE int
#define FORMAT "%d "
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 494317e..ba18c37 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -611,10 +611,10 @@ usage(const char *prog)
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 F, --binary=F Output raw data into file F in binary form \n");
- fprintf(stdout, " (recommended usage is with --dataset=P)\n");
- fprintf(stdout, " -F T, --form=T Form of binary output. T is: NA for native type,\n");
- fprintf(stdout, " DI for the disk file type, LE or BE for pre-existing\n");
+ fprintf(stdout, " -b F, --binary=F Binary output, of form F (into file -o F).\n");
+ fprintf(stdout, " Recommended usage is with --dataset=P\n");
+ fprintf(stdout, " Form F of binary output is: MEMORY for memory type,\n");
+ fprintf(stdout, " FILE for the disk file type, LE or BE for pre-existing\n");
fprintf(stdout, " 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");
@@ -2870,16 +2870,15 @@ set_binary_form(const char *form)
{
int bform=-1;
- if (strcmp(form,"NA")==0) /* native form */
+ if (strcmp(form,"MEMORY")==0) /* native form */
bform = 0;
- else if (strcmp(form,"DI")==0) /* file type form */
+ 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;
}
@@ -3365,6 +3364,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));
@@ -3479,37 +3482,48 @@ parse_start:
last_was_dset = FALSE;
break;
- case 'o':
- if (set_output_file(opt_arg, 0) < 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 (set_output_file(opt_arg, 1) < 0){
- /* failed to set output file */
- usage(progname);
- leave(EXIT_FAILURE);
- }
-
- bin_output = TRUE;
- last_was_dset = FALSE;
- break;
-
- case 'F':
- if ( ( bin_form = set_binary_form(opt_arg)) < 0){
- /* failed to set binary form */
- usage(progname);
- leave(EXIT_FAILURE);
- }
-
- last_was_dset = FALSE;
- break;
+
+ 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 09328f0..572558f 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -81,6 +81,7 @@
#define FILE52 "tldouble.h5"
#define FILE53 "textlink.h5"
#define FILE54 "tudlink.h5"
+#define FILE55 "tbinary.h5"
@@ -5551,6 +5552,44 @@ error:
}
+
+/*-------------------------------------------------------------------------
+ * Function: gent_binary
+ *
+ * Purpose: Generate a file to be used in the binary output test
+ * Contains:
+ * 1) an integer dataset
+ * 2) a float dataset
+ *
+ *-------------------------------------------------------------------------
+ */
+static void gent_binary()
+{
+ hid_t fid, sid, idid, fdid;
+ hsize_t dims[1] = {6};
+ int ibuf[6] = {1,2,3,4,5,6};
+ float fbuf[6] = {1,2,3,4,5,6};
+
+ fid = H5Fcreate(FILE55, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* create dataspace */
+ sid = H5Screate_simple(1, dims, NULL);
+
+ /* create datasets */
+ idid = H5Dcreate(fid, "integer", H5T_NATIVE_INT, sid, H5P_DEFAULT);
+ fdid = H5Dcreate(fid, "float", H5T_NATIVE_FLOAT, sid, H5P_DEFAULT);
+
+ /* write */
+ H5Dwrite(idid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf);
+ H5Dwrite(fdid, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, fbuf);
+
+ /* close */
+ H5Sclose(sid);
+ H5Dclose(idid);
+ H5Dclose(fdid);
+ H5Fclose(fid);
+}
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -5613,6 +5652,7 @@ int main(void)
gent_aindices();
gent_longlinks();
gent_ldouble();
+ gent_binary();
return 0;
}
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index 5de3a61..660b938 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -323,10 +323,10 @@ TOOLTEST tlonglinks.ddl tlonglinks.h5
TOOLTEST tvms.ddl tvms.h5
# test for binary output
-TOOLTEST tbin1.ddl -d integer -b out1.bin test1.h5
-TOOLTEST tbin2.ddl -d integer -b out2.bin -F DI test1.h5
-TOOLTEST tbin3.ddl -d integer -b out3.bin -F LE test1.h5
-TOOLTEST tbin4.ddl -d integer -b out4.bin -F BE test1.h5
+TOOLTEST tbin1.ddl -d integer -o out1.bin -b MEMORY tbinary.h5
+TOOLTEST tbin2.ddl -d float -o out2.bin -b FILE tbinary.h5
+TOOLTEST tbin3.ddl -d integer -o out3.bin -b LE tbinary.h5
+TOOLTEST tbin4.ddl -d float -o out4.bin -b BE tbinary.h5
# Clean up binary output files
if test -z "$HDF5_NOCLEANUP"; then
rm -f $srcdir/../testfiles/out[1-4].bin
diff --git a/tools/testfiles/tbin1.ddl b/tools/testfiles/tbin1.ddl
index 6b7a155..386ecde 100644
--- a/tools/testfiles/tbin1.ddl
+++ b/tools/testfiles/tbin1.ddl
@@ -1,10 +1,10 @@
#############################
-Expected output for 'h5dump -d integer -b out1.bin test1.h5'
+Expected output for 'h5dump -d integer -o out1.bin -b MEMORY tbinary.h5'
#############################
-HDF5 "test1.h5" {
+HDF5 "tbinary.h5" {
DATASET "integer" {
DATATYPE H5T_STD_I32LE
- DATASPACE SIMPLE { ( 2 ) / ( 2 ) }
+ DATASPACE SIMPLE { ( 6 ) / ( 6 ) }
DATA {
}
}
diff --git a/tools/testfiles/tbin2.ddl b/tools/testfiles/tbin2.ddl
index 2c17692..03f4e48 100644
--- a/tools/testfiles/tbin2.ddl
+++ b/tools/testfiles/tbin2.ddl
@@ -1,10 +1,10 @@
#############################
-Expected output for 'h5dump -d integer -b out2.bin -F DI test1.h5'
+Expected output for 'h5dump -d float -o out2.bin -b FILE tbinary.h5'
#############################
-HDF5 "test1.h5" {
-DATASET "integer" {
- DATATYPE H5T_STD_I32LE
- DATASPACE SIMPLE { ( 2 ) / ( 2 ) }
+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
index cbc2660..5226802 100644
--- a/tools/testfiles/tbin3.ddl
+++ b/tools/testfiles/tbin3.ddl
@@ -1,10 +1,10 @@
#############################
-Expected output for 'h5dump -d integer -b out3.bin -F LE test1.h5'
+Expected output for 'h5dump -d integer -o out3.bin -b LE tbinary.h5'
#############################
-HDF5 "test1.h5" {
+HDF5 "tbinary.h5" {
DATASET "integer" {
DATATYPE H5T_STD_I32LE
- DATASPACE SIMPLE { ( 2 ) / ( 2 ) }
+ DATASPACE SIMPLE { ( 6 ) / ( 6 ) }
DATA {
}
}
diff --git a/tools/testfiles/tbin4.ddl b/tools/testfiles/tbin4.ddl
index 3091874..7bd0de3 100644
--- a/tools/testfiles/tbin4.ddl
+++ b/tools/testfiles/tbin4.ddl
@@ -1,10 +1,10 @@
#############################
-Expected output for 'h5dump -d integer -b out4.bin -F BE test1.h5'
+Expected output for 'h5dump -d float -o out4.bin -b BE tbinary.h5'
#############################
-HDF5 "test1.h5" {
-DATASET "integer" {
- DATATYPE H5T_STD_I32LE
- DATASPACE SIMPLE { ( 2 ) / ( 2 ) }
+HDF5 "tbinary.h5" {
+DATASET "float" {
+ DATATYPE H5T_IEEE_F32LE
+ DATASPACE SIMPLE { ( 6 ) / ( 6 ) }
DATA {
}
}
diff --git a/tools/testfiles/tbinary.h5 b/tools/testfiles/tbinary.h5
new file mode 100644
index 0000000..e960d73
--- /dev/null
+++ b/tools/testfiles/tbinary.h5
Binary files differ
diff --git a/tools/testfiles/tnofilename.ddl b/tools/testfiles/tnofilename.ddl
index 543c5d8..92d9196 100644
--- a/tools/testfiles/tnofilename.ddl
+++ b/tools/testfiles/tnofilename.ddl
@@ -21,10 +21,10 @@ usage: h5dump [OPTIONS] file
-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 F, --binary=F Output raw data into file F in binary form
- (recommended usage is with --dataset=P)
- -F T, --form=T Form of binary output. T is: NA for native type,
- DI for the disk file type, LE or BE for pre-existing
+ -b F, --binary=F Binary output, of form F (into file -o F).
+ Recommended usage is with --dataset=P
+ Form F of binary output is: MEMORY for memory type,
+ FILE for the disk 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