summaryrefslogtreecommitdiffstats
path: root/tools/h5dump
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2004-06-22 14:29:21 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2004-06-22 14:29:21 (GMT)
commita5f1d15035deb7b400f6228da936f1b96664aa35 (patch)
tree5ec7c5cab2035ef00a38bce95ad43cfaebf3fc22 /tools/h5dump
parent18a656663a73a693cabf49d6f4858f7af311e6f5 (diff)
downloadhdf5-a5f1d15035deb7b400f6228da936f1b96664aa35.zip
hdf5-a5f1d15035deb7b400f6228da936f1b96664aa35.tar.gz
hdf5-a5f1d15035deb7b400f6228da936f1b96664aa35.tar.bz2
[svn-r8715] Purpose:
h5dump output change, new tests Description: the storage layout output format the storage layout output format had some changes same for the user defined filter add an option (-y) for not printing the array indices (default is print indices ) the option for escaping non printable characters covers all characters (default is not escape) (this might be not very portable, the test files are tstring.ddl and tstringe.ddl ) add tests for the new options Solution: Platforms tested: linux solaris AIX Misc. update:
Diffstat (limited to 'tools/h5dump')
-rw-r--r--tools/h5dump/h5dump.c83
-rw-r--r--tools/h5dump/h5dumpgentest.c103
-rw-r--r--tools/h5dump/testh5dump.sh.in30
3 files changed, 151 insertions, 65 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 9c50fbf..7ae01c4 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -47,13 +47,13 @@ static int display_all = TRUE;
static int display_oid = FALSE;
static int display_data = TRUE;
static int display_attr_data = TRUE;
-static int display_char = FALSE; /*print 1-byte numbers as ASCII? */
+static int display_char = FALSE; /*print 1-byte numbers as ASCII? */
static int usingdasho = FALSE;
static int display_bb = FALSE; /*superblock */
static int display_dcpl = FALSE; /*dcpl */
static int display_fi = FALSE; /*file index */
static int display_ai = TRUE; /*array index */
-static int display_lf = FALSE; /*do CR/LF */
+static int display_escape = FALSE; /*escape non printable characters */
@@ -154,7 +154,7 @@ static h5dump_t dataformat = {
"%s", /*dset_ptformat_pre */
"%s", /*dset_ptformat */
1 , /*array indices */
- 1 /*interpret CR/LF information */
+ 1 /*escape non printable characters */
};
@@ -239,7 +239,7 @@ static h5dump_t xml_dataformat = {
"%s", /*dset_ptformat_pre */
"%s", /*dset_ptformat */
0 , /*array indices */
- 0 /*interpret CR/LF information */
+ 0 /*escape non printable characters */
};
/** XML **/
@@ -341,25 +341,12 @@ 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.
*/
-#if 0
- /* binary: not implemented yet */
-static const char *s_opts = "hbBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:s:S:A";
-#else
-static const char *s_opts = "hnpeBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:s:S:A";
-#endif /* 0 */
+static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:s:S:A";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
{ "hel", no_arg, 'h' },
{ "contents", no_arg, 'n' },
{ "properties", no_arg, 'p' },
-#if 0
- /* binary: not implemented yet */
- { "binary", no_arg, 'b' },
- { "binar", no_arg, 'b' },
- { "bina", no_arg, 'b' },
- { "bin", no_arg, 'b' },
- { "bi", no_arg, 'b' },
-#endif /* 0 */
{ "boot-block", no_arg, 'B' },
{ "boot-bloc", no_arg, 'B' },
{ "boot-blo", no_arg, 'B' },
@@ -593,10 +580,11 @@ usage(const char *prog)
fprintf(stdout, " -A Print the header and value of attributes; data 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, Interpret carriage return (\\n) as new line\n");
+ fprintf(stdout, " -e, 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, " -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");
@@ -648,6 +636,7 @@ usage(const char *prog)
fprintf(stdout, "\n");
}
+
/*-------------------------------------------------------------------------
* Function: print_datatype
*
@@ -1888,6 +1877,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex)
int stdindent = COL; /* should be 3 */
outputformat->line_ncols = nCols;
+ outputformat->do_escape=display_escape;
indent += COL;
@@ -1960,10 +1950,6 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex)
depth=0;
}
- /*interpret CR/LF information */
- outputformat->do_lf=display_lf;
-
-
status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, sset, depth);
H5Tclose(f_type);
} else {
@@ -2148,6 +2134,7 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
storage_size=H5Dget_storage_size(obj_id);
ioffset=H5Dget_offset(obj_id);
next=H5Pget_external_count(dcpl_id);
+ strcpy(f_name,"\0");
/*-------------------------------------------------------------------------
@@ -2155,20 +2142,21 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
*-------------------------------------------------------------------------
*/
indentation(indent + COL);
- printf("%s ", STORAGE_LAYOUT);
+ printf("%s %s\n", STORAGE_LAYOUT, BEGIN);
if (H5D_CHUNKED == H5Pget_layout(dcpl_id))
{
- printf("%s %s\n", CHUNKED, BEGIN);
/*start indent */
indent += COL;
indentation(indent + COL);
- HDfprintf(stdout, "SIZE %Hu ", storage_size);
+ printf("%s ", CHUNKED);
rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize);
HDfprintf(stdout,"%s %Hu", dump_header_format->dataspacedimbegin, chsize[0]);
for ( i=1; i<rank; i++)
HDfprintf(stdout, ", %Hu", chsize[i]);
printf(" %s\n", dump_header_format->dataspacedimend);
+ indentation(indent + COL);
+ HDfprintf(stdout, "SIZE %Hu\n ", storage_size);
/*end indent */
indent -= COL;
indentation(indent + COL);
@@ -2176,10 +2164,11 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
}
else if (H5D_COMPACT == H5Pget_layout(dcpl_id))
{
- printf("%s %s\n", COMPACT, BEGIN);
/*start indent */
indent += COL;
indentation(indent + COL);
+ printf("%s\n", COMPACT);
+ indentation(indent + COL);
HDfprintf(stdout, "SIZE %Hu\n", storage_size);
/*end indent */
indent -= COL;
@@ -2194,10 +2183,14 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
*/
if (next)
{
- printf("%s %s %s\n", CONTIGUOUS, EXTERNAL, BEGIN);
- /*start indent */
+ /*start indent */
+ indent += COL;
+ indentation(indent + COL);
+ printf("%s\n", CONTIGUOUS);
+ indentation(indent + COL);
+ printf("%s %s\n", EXTERNAL, BEGIN);
+ /*start indent */
indent += COL;
-
for ( i=0; i<next; i++) {
H5Pget_external(dcpl_id,i,sizeof(name),name,&offset,&size);
indentation(indent + COL);
@@ -2207,15 +2200,22 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
indent -= COL;
indentation(indent + COL);
printf("%s\n",END);
+ /*end indent */
+ indent -= COL;
+ indentation(indent + COL);
+ printf("%s\n",END);
}
else
{
- printf("%s %s\n", CONTIGUOUS, BEGIN);
/*start indent */
indent += COL;
indentation(indent + COL);
- HDfprintf(stdout,"SIZE %Hu OFFSET %Hu\n", storage_size, ioffset);
+ printf("%s\n", CONTIGUOUS);
+ indentation(indent + COL);
+ HDfprintf(stdout,"SIZE %Hu\n", storage_size);
+ indentation(indent + COL);
+ HDfprintf(stdout,"OFFSET %Hu\n", ioffset);
/*end indent */
indent -= COL;
indentation(indent + COL);
@@ -2309,8 +2309,20 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
break;
default:
indentation(indent + COL);
- printf("%s %d %s", UNKNOWN_FILTER, filtn, cd_nelmts? "" : "\n" );
+ if (H5Zfilter_avail(filtn))
+ printf("%s %s\n", "USER_REGISTERED_FILTER", BEGIN);
+ else
+ printf("%s %s\n", "UNKNOWN_FILTER", BEGIN);
+ /*start indent */
+ indent += COL;
+ indentation(indent + COL);
+ printf("FILTER_ID %d\n", filtn);
+ if (f_name[0]!='\0') {
+ indentation(indent + COL);
+ printf("COMMENT %s\n", f_name);
+ }
if (cd_nelmts) {
+ indentation(indent + COL);
printf("%s %s ","PARAMS", BEGIN);
for (j=0; j<cd_nelmts; j++) {
printf("%d ", cd_values[j]);
@@ -3062,8 +3074,11 @@ parse_start:
case 'p':
display_dcpl = TRUE;
break;
+ case 'y':
+ display_ai = FALSE;
+ break;
case 'e':
- display_lf = TRUE;
+ display_escape = TRUE;
break;
case 'H':
display_data = FALSE;
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index ffe24b1..9c3d20b 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -4433,6 +4433,7 @@ make_external(hid_t fid)
+
/*-------------------------------------------------------------------------
* Function: gent_filters
*
@@ -4449,6 +4450,7 @@ static void gent_filters()
hid_t sid1; /* dataspace ID */
hid_t tid; /* datatype ID */
hid_t did; /* dataset ID */
+ hid_t gid; /* group ID */
#if defined (H5_HAVE_FILTER_SZIP)
unsigned szip_options_mask=H5_SZIP_ALLOW_K13_OPTION_MASK|H5_SZIP_NN_OPTION_MASK;
unsigned szip_pixels_per_block=4;
@@ -4459,22 +4461,20 @@ static void gent_filters()
hsize_t dims2[1]={2};
hvl_t buf2[2];
hsize_t dims3[1]={1};
- char buf3[]={"this is\n a string \twith three\n newline\n escape \tcharacters"};
+ char buf3[]={"quote \" backspace\b form feed\f new line\n tab\t new line\n carriage return\r"};
hsize_t dims4[1]={6};
char buf4[6]={"abcdef"};
- hobj_ref_t buf5[5];
- hsize_t dims5[1]={5};
+ hobj_ref_t buf5[1];
+ hsize_t dims5[1]={1};
int i, j, n, ret, val;
int fillval = -99;
-
typedef enum
{
E_RED,
E_GREEN
} e_t;
-
for (i=n=0; i<DIM1; i++){
for (j=0; j<DIM2; j++){
buf1[i][j]=n++;
@@ -4661,7 +4661,7 @@ static void gent_filters()
#endif
assert(ret>=0);
- H5Pset_filter (dcpl, MYFILTER_ID, 0, 0, NULL);
+ ret=H5Pset_filter (dcpl, MYFILTER_ID, 0, 0, NULL);
assert(ret>=0);
ret=make_dset(fid,"myfilter",sid,dcpl,buf1);
@@ -4671,43 +4671,96 @@ static void gent_filters()
ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL);
assert(ret>=0);
+
+
/*-------------------------------------------------------------------------
* make an external dataset
*-------------------------------------------------------------------------
*/
make_external(fid);
- /*-------------------------------------------------------------------------
+/*-------------------------------------------------------------------------
* make datasets with fill value combinations
+ * H5D_FILL_TIME_IFSET
*-------------------------------------------------------------------------
*/
+ ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET);
+ assert(ret>=0);
-
- ret=H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY);
+ ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"fill_time_ifset",sid,dcpl,buf1);
assert(ret>=0);
+/*-------------------------------------------------------------------------
+ * H5D_FILL_TIME_ALLOC
+ *-------------------------------------------------------------------------
+ */
ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC);
assert(ret>=0);
ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
assert(ret>=0);
-
- ret=make_dset(fid,"fill_early",sid,dcpl,buf1);
+
+ ret=make_dset(fid,"fill_time_alloc",sid,dcpl,buf1);
assert(ret>=0);
+/*-------------------------------------------------------------------------
+ * H5D_FILL_TIME_NEVER
+ *-------------------------------------------------------------------------
+ */
ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER);
assert(ret>=0);
- ret=make_dset(fid,"fill_never",sid,dcpl,buf1);
+ ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"fill_time_never",sid,dcpl,buf1);
assert(ret>=0);
+/*-------------------------------------------------------------------------
+ * H5D_ALLOC_TIME_EARLY
+ *-------------------------------------------------------------------------
+ */
+
ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET);
assert(ret>=0);
- ret=make_dset(fid,"fill_ifset",sid,dcpl,buf1);
+ ret=H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY);
assert(ret>=0);
+ ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
+ assert(ret>=0);
+ ret=make_dset(fid,"alloc_time_early",sid,dcpl,buf1);
+ assert(ret>=0);
+
+/*-------------------------------------------------------------------------
+ * H5D_ALLOC_TIME_INCR
+ *-------------------------------------------------------------------------
+ */
+ ret=H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR);
+ assert(ret>=0);
+
+ ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"alloc_time_incr",sid,dcpl,buf1);
+ assert(ret>=0);
+
+/*-------------------------------------------------------------------------
+ * H5D_ALLOC_TIME_LATE
+ *-------------------------------------------------------------------------
+ */
+ ret=H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE);
+ assert(ret>=0);
+
+ ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"alloc_time_late",sid,dcpl,buf1);
+ assert(ret>=0);
/*-------------------------------------------------------------------------
* commit a H5G_TYPE type with a comment
@@ -4770,7 +4823,7 @@ static void gent_filters()
assert(ret>=0);
/*-------------------------------------------------------------------------
- * string
+ * string with escaped characters
*-------------------------------------------------------------------------
*/
@@ -4778,6 +4831,7 @@ static void gent_filters()
ret=H5Tset_size(tid, sizeof(buf3));
assert(ret>=0);
write_dset(fid,1,dims3,"string",tid,buf3);
+ assert(ret>=0);
ret=H5Tclose(tid);
assert(ret>=0);
@@ -4788,21 +4842,22 @@ static void gent_filters()
write_dset(fid,1,dims4,"char",H5T_NATIVE_CHAR,buf4);
/*-------------------------------------------------------------------------
- * reference
+ * a group and a link
*-------------------------------------------------------------------------
*/
- ret=H5Rcreate(&buf5[0],fid,"compact",H5R_OBJECT,-1);
- assert(ret>=0);
- ret=H5Rcreate(&buf5[1],fid,"myvlen",H5R_OBJECT,-1);
- assert(ret>=0);
- ret=H5Rcreate(&buf5[2],fid,"compact",H5R_OBJECT,-1);
+ gid = H5Gcreate(fid,"g1",0);
+ H5Glink (gid, H5G_LINK_SOFT, "somevalue", "slink");
+ write_dset(gid,1,dims4,"mydset",H5T_NATIVE_CHAR,buf4);
+ ret = H5Gclose(gid);
assert(ret>=0);
- ret=H5Rcreate(&buf5[3],fid,"myvlen",H5R_OBJECT,-1);
- assert(ret>=0);
- ret=H5Rcreate(&buf5[4],fid,"contiguous",H5R_OBJECT,-1);
+
+/*-------------------------------------------------------------------------
+ * reference
+ *-------------------------------------------------------------------------
+ */
+ ret=H5Rcreate(&buf5[0],fid,"g1/mydset",H5R_OBJECT,-1);
assert(ret>=0);
write_dset(fid,1,dims5,"reference",H5T_STD_REF_OBJ,buf5);
-
/*-------------------------------------------------------------------------
* close
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index 19aa89a..cb9d398 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -211,13 +211,15 @@ TOOLTEST tchar1.ddl -r tchar.h5
# Missing file name
TOOLTEST tnofilename.ddl
+
+
+
# test for super block
TOOLTEST tboot.ddl -H -B -d compact tfilters.h5
# test for file contents
TOOLTEST tcontents.ddl -n tfilters.h5
-
# tests for storage layout
# compact
TOOLTEST tcompact.ddl -H -p -d compact tfilters.h5
@@ -229,16 +231,23 @@ TOOLTEST tchunked.ddl -H -p -d chunked tfilters.h5
TOOLTEST texternal.ddl -H -p -d external tfilters.h5
# Fill values
-TOOLTEST tfillearly.ddl -H -p -d fill_early tfilters.h5
-TOOLTEST tfillnever.ddl -H -p -d fill_never tfilters.h5
-TOOLTEST tfillifset.ddl -H -p -d fill_ifset tfilters.h5
+TOOLTEST tfillifset.ddl -H -p -d fill_time_ifset tfilters.h5
+TOOLTEST tfillalloc.ddl -H -p -d fill_time_alloc tfilters.h5
+TOOLTEST tfillnever.ddl -H -p -d fill_time_never tfilters.h5
+TOOLTEST tfillearly.ddl -H -p -d alloc_time_early tfilters.h5
+TOOLTEST tfillincr.ddl -H -p -d alloc_time_incr tfilters.h5
+TOOLTEST tfilllate.ddl -H -p -d alloc_time_late tfilters.h5
# references , print path
TOOLTEST treference.ddl -d reference tfilters.h5
-# string , print new lines
-TOOLTEST tstring.ddl -e -d string tfilters.h5
+# escape/not escape non printable characters
+TOOLTEST tstringe.ddl -e -d string tfilters.h5
+TOOLTEST tstring.ddl -d string tfilters.h5
+# array indices print/not print
+TOOLTEST tindicesyes.ddl -d compact tfilters.h5
+TOOLTEST tindicesno.ddl -y -d compact tfilters.h5
# tests for filters
# SZIP
@@ -269,8 +278,15 @@ if test $USE_FILTER_FLETCHER32 != "yes"; then
else
TOOLTEST tfletcher32.ddl $option
fi
+# all
+option="-H -p -d all tfilters.h5"
+if test $USE_FILTER_FLETCHER32 != "yes" -o $USE_FILTER_SZIP != "yes" -o $USE_FILTER_DEFLATE != "yes" -o $USE_FILTER_SHUFFLE != "yes" ; then
+ SKIP $option
+else
+ TOOLTEST tallfilters.ddl $option
+fi
# user defined
-TOOLTEST tuserfilter.ddl -H -d myfilter tfilters.h5
+TOOLTEST tuserfilter.ddl -H -p -d myfilter tfilters.h5
# test for displaying dataset and attribute of null space
TOOLTEST tnullspace.ddl tnullspace.h5