summaryrefslogtreecommitdiffstats
path: root/tools/h5dump
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2004-06-07 16:40:25 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2004-06-07 16:40:25 (GMT)
commitbad5b7ec31f44e1d6fae9300cf27461c92566c5d (patch)
tree672cf1189aff2e694852bc7d1153d75b0abee671 /tools/h5dump
parent95da7ce5c4997daae35f695817beeb6b65ae20fe (diff)
downloadhdf5-bad5b7ec31f44e1d6fae9300cf27461c92566c5d.zip
hdf5-bad5b7ec31f44e1d6fae9300cf27461c92566c5d.tar.gz
hdf5-bad5b7ec31f44e1d6fae9300cf27461c92566c5d.tar.bz2
[svn-r8622] Purpose:
h5dump new version Description: added the changes already made for 1.6 support for dumping of 1) filters 2) storage layout 3) fill value 4) comments 5) superblock 6) file contents 7) array indices Solution: Platforms tested: linux solaris AIX Misc. update:
Diffstat (limited to 'tools/h5dump')
-rw-r--r--tools/h5dump/h5dump.c815
-rw-r--r--tools/h5dump/h5dumpgentest.c538
-rwxr-xr-xtools/h5dump/testh5dump.sh20
3 files changed, 1292 insertions, 81 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index ed7b713..550527b 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -18,10 +18,20 @@
#include "H5private.h"
#include "h5tools.h"
#include "h5tools_utils.h"
+#include "h5trav.h"
+
/* module-scoped variables */
static const char *progname = "h5dump";
+/* 3 private values: can't be set, but can be read.
+ Note: these are defined in H5Zprivate, they are
+ duplicated here.
+ */
+#define H5_SZIP_LSB_OPTION_MASK 8
+#define H5_SZIP_MSB_OPTION_MASK 16
+#define H5_SZIP_RAW_OPTION_MASK 128
+
static int d_status = EXIT_SUCCESS;
static int unamedtype = 0; /* shared data type with no name */
static size_t prefix_len = 1024;
@@ -32,13 +42,17 @@ static const char *driver = NULL; /* The driver to open the file with. */
static const dump_header *dump_header_format;
/* things to display or which are set via command line parameters */
-static int display_all = TRUE;
-static int display_bb = FALSE;
-static int display_oid = FALSE;
-static int display_data = TRUE;
+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 usingdasho = FALSE;
+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 */
+
/**
** Added for XML **
@@ -65,6 +79,7 @@ typedef struct ref_path_table_entry {
/** end XML **/
/* internal functions */
+static hid_t h5_fileaccess(void);
static void dump_oid(hid_t oid);
static void print_enum(hid_t type);
static herr_t dump_all(hid_t group, const char *name, void *op_data);
@@ -145,6 +160,8 @@ static h5dump_t dataformat = {
"%s", /*dset_blockformat_pre */
"%s", /*dset_ptformat_pre */
"%s", /*dset_ptformat */
+ 1 /*array indices */
+
};
/**
@@ -227,6 +244,7 @@ static h5dump_t xml_dataformat = {
"%s", /*dset_blockformat_pre */
"%s", /*dset_ptformat_pre */
"%s", /*dset_ptformat */
+ 0 /*array indices */
};
/** XML **/
@@ -235,7 +253,7 @@ static const dump_header standardformat = {
"standardformat", /*name */
"HDF5", /*fileebgin */
"", /*fileend */
- BOOT_BLOCK, /*bootblockbegin */
+ SUPER_BLOCK, /*bootblockbegin */
"", /*bootblockend */
GROUPNAME, /*groupbegin */
"", /*groupend */
@@ -334,11 +352,13 @@ struct handler_t {
/* 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 = "hBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:s:S:A";
+static const char *s_opts = "hnpBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:s:S:A";
#endif /* 0 */
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' },
@@ -470,7 +490,11 @@ static void dump_dataset(hid_t, const char *, struct subset_t *);
static void dump_dataspace(hid_t space);
static void dump_datatype(hid_t type);
static herr_t dump_attr(hid_t, const char *, void *);
-static void dump_data(hid_t, int, struct subset_t *);
+static void dump_data(hid_t, int, struct subset_t *, int);
+static void dump_dcpl(hid_t dcpl, hid_t type_id, hid_t obj_id);
+static void dump_comment(hid_t obj_id);
+static void dump_fcpl(hid_t fid);
+static void dump_list(hid_t fid);
/* XML format: same interface, alternative output */
@@ -480,7 +504,7 @@ static void xml_dump_dataset(hid_t, const char *, struct subset_t *)
static void xml_dump_dataspace(hid_t space);
static void xml_dump_datatype(hid_t type);
static herr_t xml_dump_attr(hid_t, const char *, void *);
-static void xml_dump_data(hid_t, int, struct subset_t *);
+static void xml_dump_data(hid_t, int, struct subset_t *, int);
/**
** Added for XML **
@@ -495,7 +519,7 @@ typedef struct dump_functions_t {
void (*dump_dataspace_function) (hid_t);
void (*dump_datatype_function) (hid_t);
herr_t (*dump_attribute_function) (hid_t, const char *, void *);
- void (*dump_data_function) (hid_t, int, struct subset_t *);
+ void (*dump_data_function) (hid_t, int, struct subset_t *, int);
} dump_functions;
/* Standard DDL output */
@@ -570,6 +594,7 @@ usage(const char *prog)
fprintf(stdout, "usage: %s [OPTIONS] file\n", prog);
fprintf(stdout, " OPTIONS\n");
fprintf(stdout, " -h, --help Print a usage message and exit\n");
+ 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");
@@ -578,6 +603,7 @@ usage(const char *prog)
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, " -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");
@@ -955,25 +981,7 @@ print_datatype(hid_t type,unsigned in_group)
} /* end else */
}
-/*-------------------------------------------------------------------------
- * Function: dump_bb
- *
- * Purpose: Dump the boot block
- *
- * Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-dump_bb(void)
-{
- printf("%s %s boot block not yet implemented %s\n",
- BOOT_BLOCK, BEGIN, END);
-}
+
/*-------------------------------------------------------------------------
* Function: dump_datatype
@@ -1125,7 +1133,7 @@ dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data)
dump_oid(attr_id);
if (display_data || display_attr_data)
- dump_data(attr_id, ATTRIBUTE_DATA, NULL);
+ dump_data(attr_id, ATTRIBUTE_DATA, NULL, 0);
H5Tclose(type);
H5Sclose(space);
@@ -1235,7 +1243,7 @@ dump_selected_attr(hid_t loc_id, const char *name)
dump_oid(attr_id);
if (display_data || display_attr_data)
- dump_data(attr_id, ATTRIBUTE_DATA, NULL);
+ dump_data(attr_id, ATTRIBUTE_DATA, NULL, 0);
H5Tclose(type);
H5Sclose(space);
@@ -1599,7 +1607,7 @@ dump_group(hid_t gid, const char *name)
{
H5G_stat_t statbuf;
hid_t dset, type;
- char type_name[1024], *tmp, comment[50];
+ char type_name[1024], *tmp;
int i, xtype = H5G_UNKNOWN; /* dump all */
tmp = malloc(strlen(prefix) + strlen(name) + 2);
@@ -1610,15 +1618,9 @@ dump_group(hid_t gid, const char *name)
indent += COL;
if (display_oid)
- dump_oid(gid);
-
- comment[0] = '\0';
- H5Gget_comment(gid, ".", sizeof(comment), comment);
+ dump_oid(gid);
- if (comment[0]) {
- indentation(indent);
- printf("COMMENT \"%s\"\n", comment);
- }
+ dump_comment(gid);
if (!strcmp(name, "/") && unamedtype)
/* dump unamed type in root group */
@@ -1626,7 +1628,7 @@ dump_group(hid_t gid, const char *name)
if (!type_table->objs[i].recorded) {
dset = H5Dopen(gid, type_table->objs[i].objname);
type = H5Dget_type(dset);
- sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[i].objno);
+ sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[i].objno);
dump_named_datatype(type, type_name);
H5Tclose(type);
H5Dclose(dset);
@@ -1679,18 +1681,24 @@ dump_group(hid_t gid, const char *name)
static void
dump_dataset(hid_t did, const char *name, struct subset_t *sset)
{
- hid_t type, space;
+ hid_t type, space, dcpl_id;
indentation(indent);
begin_obj(dump_header_format->datasetbegin, name,
dump_header_format->datasetblockbegin);
type = H5Dget_type(did);
space = H5Dget_space(did);
+ dcpl_id = H5Dget_create_plist(did);
+
+ dump_comment(did);
dump_datatype(type);
dump_dataspace(space);
if (display_oid)
- dump_oid(did);
+ dump_oid(did);
+
+ if (display_dcpl)
+ dump_dcpl(dcpl_id, type, did);
if (display_data)
switch (H5Tget_class(type)) {
@@ -1709,7 +1717,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
case H5T_ENUM:
case H5T_VLEN:
case H5T_ARRAY:
- dump_data(did, DATASET_DATA, sset);
+ dump_data(did, DATASET_DATA, sset, display_ai);
break;
default:
@@ -1721,6 +1729,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
indent -= COL;
H5Tclose(type);
H5Sclose(space);
+ H5Pclose(dcpl_id);
indentation(indent);
end_obj(dump_header_format->datasetend,
dump_header_format->datasetblockend);
@@ -1872,7 +1881,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)
+dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex)
{
h5dump_t *outputformat = &dataformat;
int status = -1;
@@ -1943,6 +1952,21 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset)
outputformat = &string_dataformat;
}
+
+ /* print the matrix indices */
+ outputformat->pindex=pindex;
+ if (outputformat->pindex)
+ {
+ outputformat->idx_fmt = "(%s)";
+ outputformat->idx_n_fmt = "%lu";
+ outputformat->idx_sep = ",";
+ outputformat->line_pre = " %s ";
+ outputformat->line_1st = " %s ";
+ outputformat->line_cont = " %s ";
+ depth=0;
+ }
+
+
status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, sset, depth);
H5Tclose(f_type);
} else {
@@ -2014,6 +2038,529 @@ dump_oid(hid_t oid)
printf("%s %s %d %s\n", OBJID, BEGIN, oid, END);
}
+
+/*-------------------------------------------------------------------------
+ * Function: dump_comment
+ *
+ * Purpose: prints the comment for the the object name
+ *
+ * Return: void
+ *
+ * Programmer: pvn
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static void dump_comment(hid_t obj_id)
+{
+ char comment[50];
+
+ comment[0] = '\0';
+ H5Gget_comment(obj_id, ".", sizeof(comment), comment);
+
+ if (comment[0]) {
+ indentation(indent);
+ printf("COMMENT \"%s\"\n", comment);
+ }
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: dump_fill_value
+ *
+ * Purpose: prints the fill value
+ *
+ * Return: void
+ *
+ * Programmer: pvn
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static void dump_fill_value(hid_t dcpl,hid_t type_id, hid_t obj_id)
+{
+ h5tools_context_t ctx; /*print context */
+ size_t size;
+ void *buf=NULL;
+ hsize_t nelmts=1;
+ h5dump_t *outputformat = &dataformat;
+
+ memset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level=2;
+ size = H5Tget_size(type_id);
+ buf = malloc(size);
+
+ H5Pget_fill_value(dcpl, type_id, buf);
+
+ h5tools_dump_simple_data(stdout, outputformat, obj_id, &ctx,
+ START_OF_DATA | END_OF_DATA, nelmts, type_id, buf);
+
+ if (buf)
+ free (buf);
+
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: dump_dcpl
+ *
+ * Purpose: prints several dataset create property list properties
+ *
+ * Return: void
+ *
+ * Programmer: pvn
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
+{
+ int nfilters; /* number of filters */
+ unsigned filt_flags; /* filter flags */
+ H5Z_filter_t filtn; /* filter identification number */
+ unsigned cd_values[20]; /* filter client data values */
+ size_t cd_nelmts; /* filter client number of values */
+ char f_name[256]; /* filter name */
+ unsigned szip_options_mask;
+ unsigned szip_pixels_per_block;
+ hsize_t chsize[64]; /* chunk size in elements */
+ int rank; /* rank */
+ char name[256]; /* external file name */
+ off_t offset; /* offset of external file */
+ hsize_t size; /* size of external file */
+ H5D_fill_value_t fvstatus;
+ H5D_alloc_time_t at;
+ H5D_fill_time_t ft;
+ hsize_t storage_size;
+ haddr_t ioffset;
+ int i, next;
+ unsigned j;
+
+ storage_size=H5Dget_storage_size(obj_id);
+ ioffset=H5Dget_offset(obj_id);
+ next=H5Pget_external_count(dcpl_id);
+
+
+/*-------------------------------------------------------------------------
+ * STORAGE_LAYOUT
+ *-------------------------------------------------------------------------
+ */
+ indentation(indent + COL);
+ printf("%s ", STORAGE_LAYOUT);
+
+ if (H5D_CHUNKED == H5Pget_layout(dcpl_id))
+ {
+ printf("%s %s\n", CHUNKED, BEGIN);
+ /*start indent */
+ indent += COL;
+ indentation(indent + COL);
+ printf("SIZE %d ", (int)storage_size);
+ rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize);
+ printf("%s %d", dump_header_format->dataspacedimbegin, (int)chsize[0]);
+ for ( i=1; i<rank; i++)
+ printf(", %d", (int)chsize[i]);
+ printf(" %s\n", dump_header_format->dataspacedimend);
+ /*end indent */
+ indent -= COL;
+ indentation(indent + COL);
+ printf("%s\n",END);
+ }
+ else if (H5D_COMPACT == H5Pget_layout(dcpl_id))
+ {
+ printf("%s %s\n", COMPACT, BEGIN);
+ /*start indent */
+ indent += COL;
+ indentation(indent + COL);
+ printf("SIZE %d\n", (int)storage_size);
+ /*end indent */
+ indent -= COL;
+ indentation(indent + COL);
+ printf("%s\n",END);
+ }
+ else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl_id))
+ {
+ /*-------------------------------------------------------------------------
+ * EXTERNAL_FILE
+ *-------------------------------------------------------------------------
+ */
+ if (next)
+ {
+ printf("%s %s %s\n", CONTIGUOUS, EXTERNAL, BEGIN);
+ /*start indent */
+ indent += COL;
+
+ for ( i=0; i<next; i++) {
+ H5Pget_external(dcpl_id,(unsigned)i,sizeof(name),name,&offset,&size);
+ indentation(indent + COL);
+ printf("FILENAME %s SIZE %d OFFSET %d\n",name,(int)size,(int)offset);
+ }
+ /*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);
+ printf("SIZE %d OFFSET %d\n", (int)storage_size, (int)ioffset);
+ /*end indent */
+ indent -= COL;
+ indentation(indent + COL);
+ printf("%s\n",END);
+ }
+ }
+
+
+
+
+/*-------------------------------------------------------------------------
+ * FILTERS
+ *-------------------------------------------------------------------------
+ */
+ nfilters = H5Pget_nfilters(dcpl_id);
+ if (nfilters)
+ {
+
+ indentation(indent + COL);
+ printf("%s %s\n", FILTERS, BEGIN);
+ indent += COL;
+
+
+ for (i=0; i<nfilters; i++)
+ {
+ cd_nelmts = NELMTS(cd_values);
+ filtn = H5Pget_filter(dcpl_id,
+ (unsigned)i,
+ &filt_flags,
+ &cd_nelmts,
+ cd_values,
+ sizeof(f_name),
+ f_name);
+
+ switch (filtn)
+ {
+ case H5Z_FILTER_DEFLATE:
+ indentation(indent + COL);
+ printf("%s %s %s %d %s\n", DEFLATE, BEGIN, DEFLATE_LEVEL, cd_values[0], END);
+ break;
+ case H5Z_FILTER_SHUFFLE:
+ indentation(indent + COL);
+ printf("%s\n", SHUFFLE);
+ break;
+ case H5Z_FILTER_FLETCHER32:
+ indentation(indent + COL);
+ printf("%s\n", FLETCHER32);
+ break;
+ case H5Z_FILTER_SZIP:
+ {
+ szip_options_mask=cd_values[0];;
+ szip_pixels_per_block=cd_values[1];
+
+ indentation(indent + COL);
+ printf("%s %s\n",SZIP, BEGIN);
+
+ /*start indent */
+
+ indent += COL;
+ indentation(indent + COL);
+ printf("PIXELS_PER_BLOCK %d\n", szip_pixels_per_block);
+
+ indentation(indent + COL);
+ if (szip_options_mask & H5_SZIP_CHIP_OPTION_MASK)
+ printf("MODE %s\n", "HARDWARE");
+ else if (szip_options_mask & H5_SZIP_ALLOW_K13_OPTION_MASK)
+ printf("MODE %s\n", "K13");
+
+ indentation(indent + COL);
+ if (szip_options_mask & H5_SZIP_EC_OPTION_MASK)
+ printf("CODING %s\n", "ENTROPY");
+ else if (szip_options_mask & H5_SZIP_NN_OPTION_MASK)
+ printf("CODING %s\n", "NEAREST NEIGHBOUR");
+
+ indentation(indent + COL);
+ if (szip_options_mask & H5_SZIP_LSB_OPTION_MASK)
+ printf("BYTE_ORDER %s\n", "LSB");
+ else if (szip_options_mask & H5_SZIP_MSB_OPTION_MASK)
+ printf("BYTE_ORDER %s\n", "MSB");
+
+ indentation(indent + COL);
+ if (szip_options_mask & H5_SZIP_RAW_OPTION_MASK)
+ printf("HEADER %s\n", "RAW");
+
+ /*end indent */
+
+ indent -= COL;
+ indentation(indent + COL);
+ printf("%s\n",END);
+ }
+ break;
+ default:
+ indentation(indent + COL);
+ printf("%s %d %s", UNKNOWN_FILTER, filtn, cd_nelmts? "" : "\n" );
+ if (cd_nelmts) {
+ printf("%s %s ","PARAMS", BEGIN);
+ for (j=0; j<cd_nelmts; j++) {
+ printf("%d ", cd_values[j]);
+ }
+ printf("%s\n", END);
+ }
+ break;
+ }/*switch*/
+ } /*i*/
+
+ indent -= COL;
+ indentation(indent + COL);
+ printf("%s\n",END);
+ }/*nfilters*/
+
+/*-------------------------------------------------------------------------
+ * FILLVALUE
+ *-------------------------------------------------------------------------
+ */
+
+ indentation(indent + COL);
+ printf("%s %s\n", FILLVALUE, BEGIN);
+
+ /*start indent */
+ indent += COL;
+
+ indentation(indent + COL);
+ printf("FILL_TIME ");
+
+ H5Pget_fill_time(dcpl_id, &ft);
+ switch ( ft )
+ {
+ default:
+ break;
+ case H5D_FILL_TIME_ALLOC:
+ printf("%s", "ALLOC\n");
+ break;
+ case H5D_FILL_TIME_NEVER:
+ printf("%s", "NEVER\n");
+ break;
+ case H5D_FILL_TIME_IFSET:
+ printf("%s", "IFSET\n");
+ break;
+ }
+
+ indentation(indent + COL);
+ printf("%s", "ALLOC_TIME ");
+ H5Pget_alloc_time(dcpl_id, &at);
+
+ switch (at)
+ {
+ case H5D_ALLOC_TIME_EARLY:
+ printf("%s", "EARLY\n");
+ break;
+ case H5D_ALLOC_TIME_INCR:
+ printf("%s", "INCR\n");
+ break;
+ case H5D_ALLOC_TIME_LATE:
+ printf("%s", "LATE\n");
+ break;
+ }
+
+ indentation(indent + COL);
+ printf("%s ", "VALUE ");
+
+ H5Pfill_value_defined(dcpl_id, &fvstatus);
+
+ if (fvstatus == H5D_FILL_VALUE_UNDEFINED)
+ {
+ printf("%s\n", "UNDEFINED");
+ }
+ else
+ {
+ dump_fill_value(dcpl_id,type_id,obj_id);
+ }
+
+ /* end indent */
+ indent -= COL;
+ indentation(indent + COL);
+ printf("\n");
+ indentation(indent + COL);
+ printf("%s\n",END);
+
+}
+
+/*-------------------------------------------------------------------------
+ * Function: dump_fcpl
+ *
+ * Purpose: prints file creation property list information
+ *
+ * Return: void
+ *
+ * Programmer: pvn
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+dump_fcpl(hid_t fid)
+{
+ hid_t fcpl; /* file creation property list ID */
+ hid_t fapl; /* file access property list ID */
+ hsize_t userblock; /* userblock size retrieved from FCPL */
+ size_t off_size; /* size of offsets in the file */
+ size_t len_size; /* size of lengths in the file */
+#ifdef H5_WANT_H5_V1_6_COMPAT
+ int super; /* superblock version # */
+ int freelist; /* free list version # */
+ int stab; /* symbol table entry version # */
+ int shhdr; /* shared object header version # */
+#else
+ unsigned super; /* superblock version # */
+ unsigned freelist; /* free list version # */
+ unsigned stab; /* symbol table entry version # */
+ unsigned shhdr; /* shared object header version # */
+#endif
+ herr_t ret; /* generic return value */
+ hid_t fdriver; /* file driver */
+ char dname[15]; /* buffer to store driver name */
+ unsigned sym_lk; /* symbol table B-tree leaf 'K' value */
+#ifdef H5_WANT_H5_V1_6_COMPAT
+ int sym_ik; /* symbol table B-tree initial 'K' value */
+ int istore_ik; /* indexed storage B-tree initial 'K' value */
+#else
+ unsigned sym_ik; /* symbol table B-tree initial 'K' value */
+ unsigned istore_ik; /* indexed storage B-tree initial 'K' value */
+#endif
+
+
+
+ fcpl=H5Fget_create_plist(fid);
+ ret=H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr);
+ ret=H5Pget_userblock(fcpl,&userblock);
+ ret=H5Pget_sizes(fcpl,&off_size,&len_size);
+ ret=H5Pget_sym_k(fcpl,&sym_ik,&sym_lk);
+ ret=H5Pget_istore_k(fcpl,&istore_ik);
+ ret=H5Pclose(fcpl);
+ fapl = h5_fileaccess();
+ fdriver = H5Pget_driver(fapl);
+ H5Pclose(fapl);
+
+
+ printf("%s %s\n",SUPER_BLOCK, BEGIN);
+ indentation(indent + COL);
+ printf("%s %d\n","SUPERBLOCK_VERSION", super);
+ indentation(indent + COL);
+ printf("%s %d\n","FREELIST_VERSION", freelist);
+ indentation(indent + COL);
+ printf("%s %d\n","SYMBOLTABLE_VERSION", stab);
+ indentation(indent + COL);
+ printf("%s %d\n","OBJECTHEADER_VERSION", (int)shhdr);
+ indentation(indent + COL);
+ printf("%s %d\n","USERBLOCK_VERSION", userblock);
+ indentation(indent + COL);
+ printf("%s %d\n","OFFSET_SIZE", off_size);
+ indentation(indent + COL);
+ printf("%s %d\n","LENGTH_SIZE", len_size);
+ indentation(indent + COL);
+ printf("%s %d\n","BTREE_RANK", sym_ik);
+ indentation(indent + COL);
+ printf("%s %d\n","BTREE_LEAF", sym_lk);
+
+ if (H5FD_CORE==fdriver)
+ {
+ strcpy(dname,"H5FD_CORE");
+ }
+#if 0
+ else if (H5FD_DPSS==fdriver)
+ {
+ strcpy(dname,"H5FD_DPSS");
+ }
+#endif
+ else if (H5FD_FAMILY==fdriver)
+ {
+ strcpy(dname,"H5FD_FAMILY");
+ }
+ else if (H5FD_GASS==fdriver)
+ {
+ strcpy(dname,"H5FD_GASS");
+ }
+ else if (H5FD_LOG==fdriver)
+ {
+ strcpy(dname,"H5FD_LOG");
+ }
+ else if (H5FD_MPIO==fdriver)
+ {
+ strcpy(dname,"H5FD_MPIO");
+ }
+ else if (H5FD_MULTI==fdriver)
+ {
+ strcpy(dname,"H5FD_MULTI");
+ }
+ else if (H5FD_SEC2==fdriver)
+ {
+ strcpy(dname,"H5FD_SEC2");
+ }
+ else if (H5FD_STDIO==fdriver)
+ {
+ strcpy(dname,"H5FD_STDIO");
+ }
+#ifdef H5_HAVE_STREAM
+ else if (H5FD_STREAM==fdriver)
+ {
+ strcpy(dname,"H5FD_STREAM");
+ }
+#endif
+
+ indentation(indent + COL);
+ printf("%s %s\n","FILE_DRIVER", dname);
+ indentation(indent + COL);
+ printf("%s %d\n","ISTORE_K", istore_ik);
+
+ printf("%s\n",END);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: dump_list
+ *
+ * Purpose: prints all objects
+ *
+ * Return: void
+ *
+ * Programmer: pvn
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static void dump_list(hid_t fid)
+{
+ int nobjects;
+ trav_info_t *info=NULL;
+
+ /* get the number of objects in the files */
+ nobjects = h5trav_getinfo(fid, NULL);
+
+ /* get the list of objects in the files */
+ info = (trav_info_t*) malloc( nobjects * sizeof(trav_info_t));
+ if (info==NULL)
+ return;
+
+ h5trav_getinfo(fid, info);
+ printf("%s %s\n",FILE_CONTENTS, BEGIN);
+ h5trav_printinfo(nobjects,info);
+ printf(" %s\n",END);
+ h5trav_freeinfo(info,nobjects);
+}
+
+
+
+
/*-------------------------------------------------------------------------
* Function: set_output_file
*
@@ -2507,6 +3054,13 @@ parse_start:
display_bb = TRUE;
last_was_dset = FALSE;
break;
+ case 'n':
+ display_fi = TRUE;
+ last_was_dset = FALSE;
+ break;
+ case 'p':
+ display_dcpl = TRUE;
+ break;
case 'H':
display_data = FALSE;
display_attr_data = FALSE;
@@ -2876,20 +3430,22 @@ main(int argc, const char *argv[])
info.dset_table = dset_table;
info.status = d_status;
+
+ thefile = fid;
+ /* find all objects that might be targets of a refernce */
+ if ((gid = H5Gopen(fid, "/")) < 0) {
+ error_msg(progname, "unable to open root group\n");
+ d_status = EXIT_FAILURE;
+ goto done;
+ }
+ ref_path_table_put(gid, "/");
+ H5Giterate(fid, "/", NULL, fill_ref_path_table, NULL);
+ H5Gclose(gid);
+
+
if (doxml) {
/* initialize XML */
- thefile = fid;
- /* find all objects that might be targets of a refernce */
- if ((gid = H5Gopen(fid, "/")) < 0) {
- error_msg(progname, "unable to open root group\n");
- d_status = EXIT_FAILURE;
- goto done;
- }
-
- ref_path_table_put(gid, "/");
- H5Giterate(fid, "/", NULL, fill_ref_path_table, NULL);
- H5Gclose(gid);
/* reset prefix! */
strcpy(prefix, "");
@@ -2958,8 +3514,19 @@ main(int argc, const char *argv[])
}
}
- if (display_bb)
- dump_bb();
+ if (!doxml)
+ {
+ if (display_fi)
+ {
+ dump_list(fid);
+ end_obj(dump_header_format->fileend,dump_header_format->fileblockend);
+ goto done;
+ }
+
+ if (display_bb)
+ dump_fcpl(fid);
+ }
+
if (display_all) {
if ((gid = H5Gopen(fid, "/")) < 0) {
@@ -4199,7 +4766,7 @@ xml_dump_dataspace(hid_t space)
*-------------------------------------------------------------------------
*/
static void
-xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset)
+xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNUSED pindex)
{
h5dump_t *outputformat = &xml_dataformat;
int status = -1;
@@ -4337,7 +4904,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data)
case H5T_OPAQUE:
case H5T_ENUM:
case H5T_ARRAY:
- dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL);
+ dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0);
break;
case H5T_TIME:
@@ -4357,7 +4924,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data)
case H5T_COMPOUND:
indentation(indent);
printf("<!-- Note: format of compound data not specified -->\n");
- dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL);
+ dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0);
break;
case H5T_REFERENCE:
@@ -4380,7 +4947,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data)
case H5T_VLEN:
printf("<!-- Note: format of VL data not specified -->\n");
- dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL);
+ dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0);
break;
default:
indentation(indent);
@@ -5024,13 +5591,7 @@ check_filters(hid_t dcpl)
indentation(indent + COL);
printf("<%sShuffle />",xmlnsprefix);
} else if (filter == H5Z_FILTER_SZIP) {
-/* 3 private values: can't be set, but can be read.
- Note: these are defined in H5Zprivate, they are
- duplicated here.
- */
-#define H5_SZIP_LSB_OPTION_MASK 8
-#define H5_SZIP_MSB_OPTION_MASK 16
-#define H5_SZIP_RAW_OPTION_MASK 128
+
indentation(indent + COL);
printf("<%sSZIP ",xmlnsprefix);
if (cd_nelmts < 2) {
@@ -5392,7 +5953,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset)
case H5T_OPAQUE:
case H5T_ENUM:
case H5T_ARRAY:
- dump_function_table->dump_data_function(did, DATASET_DATA, NULL);
+ dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0);
break;
case H5T_TIME:
@@ -5411,7 +5972,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset)
case H5T_COMPOUND:
indentation(indent);
printf("<!-- Note: format of compound data not specified -->\n");
- dump_function_table->dump_data_function(did, DATASET_DATA, NULL);
+ dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0);
break;
case H5T_REFERENCE:
@@ -5434,7 +5995,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset)
case H5T_VLEN:
printf("<!-- Note: format of VL data not specified -->\n");
- dump_function_table->dump_data_function(did, DATASET_DATA, NULL);
+ dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0);
break;
default:
indentation(indent);
@@ -5576,3 +6137,111 @@ xml_print_enum(hid_t type)
free(value);
H5Tclose(super);
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5_fileaccess
+ *
+ * Purpose: Returns a file access template which is the default template
+ * but with a file driver set according to the constant or
+ * environment variable HDF5_DRIVER
+ *
+ * Return: Success: A file access property list
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 19, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static hid_t
+h5_fileaccess(void)
+{
+ static const char *multi_letters = "msbrglo";
+
+ const char *val = NULL;
+ const char *name;
+ char s[1024];
+ hid_t fapl = -1;
+
+ /* First use the environment variable, then the constant */
+ val = HDgetenv("HDF5_DRIVER");
+#ifdef HDF5_DRIVER
+ if (!val) val = HDF5_DRIVER;
+#endif
+
+ if ((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1;
+ if (!val || !*val) return fapl; /*use default*/
+
+ HDstrncpy(s, val, sizeof s);
+ s[sizeof(s)-1] = '\0';
+ if (NULL==(name=HDstrtok(s, " \t\n\r"))) return fapl;
+
+ if (!HDstrcmp(name, "sec2")) {
+ /* Unix read() and write() system calls */
+ if (H5Pset_fapl_sec2(fapl)<0) return -1;
+ } else if (!HDstrcmp(name, "stdio")) {
+ /* Standard C fread() and fwrite() system calls */
+ if (H5Pset_fapl_stdio(fapl)<0) return -1;
+ } else if (!HDstrcmp(name, "core")) {
+ /* In-core temporary file with 1MB increment */
+ if (H5Pset_fapl_core(fapl, 1024*1024, FALSE)<0) return -1;
+ } else if (!HDstrcmp(name, "split")) {
+ /* Split meta data and raw data each using default driver */
+ if (H5Pset_fapl_split(fapl,
+ "-m.h5", H5P_DEFAULT,
+ "-r.h5", H5P_DEFAULT)<0)
+ return -1;
+ } else if (!HDstrcmp(name, "multi")) {
+ /* Multi-file driver, general case of the split driver */
+ H5FD_mem_t memb_map[H5FD_MEM_NTYPES];
+ hid_t memb_fapl[H5FD_MEM_NTYPES];
+ const char *memb_name[H5FD_MEM_NTYPES];
+ char sv[H5FD_MEM_NTYPES][1024];
+ haddr_t memb_addr[H5FD_MEM_NTYPES];
+ H5FD_mem_t mt;
+
+ HDmemset(memb_map, 0, sizeof memb_map);
+ HDmemset(memb_fapl, 0, sizeof memb_fapl);
+ HDmemset(memb_name, 0, sizeof memb_name);
+ HDmemset(memb_addr, 0, sizeof memb_addr);
+
+ assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
+ memb_fapl[mt] = H5P_DEFAULT;
+ sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
+ memb_name[mt] = sv[mt];
+ memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10);
+ }
+
+ if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name,
+ memb_addr, FALSE)<0) {
+ return -1;
+ }
+ } else if (!HDstrcmp(name, "family")) {
+ hsize_t fam_size = 100*1024*1024; /*100 MB*/
+
+ /* Family of files, each 1MB and using the default driver */
+ if ((val=HDstrtok(NULL, " \t\n\r")))
+ fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024);
+ if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0)
+ return -1;
+ } else if (!HDstrcmp(name, "log")) {
+ long log_flags = H5FD_LOG_LOC_IO;
+
+ /* Log file access */
+ if ((val = HDstrtok(NULL, " \t\n\r")))
+ log_flags = HDstrtol(val, NULL, 0);
+
+ if (H5Pset_fapl_log(fapl, NULL, (unsigned)log_flags, 0) < 0)
+ return -1;
+ } else {
+ /* Unknown driver */
+ return -1;
+ }
+
+ return fapl;
+}
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index b3c55a6..9231b64 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -68,15 +68,44 @@
#define FILE40 "tattr2.h5"
#define FILE41 "tcompound_complex.h5"
#define FILE42 "tnamed_dtype_attr.h5"
-#define FILE43 "tvldtypes5.h5"
+#define FILE43 "tvldtypes5.h5"
+#define FILE44 "tfilters.h5"
-/* prototypes */
-static int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name,
+/*-------------------------------------------------------------------------
+ * prototypes
+ *-------------------------------------------------------------------------
+ */
+
+/* utility functions */
+static int
+write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name,
hid_t type_id, void *buf);
-static int write_dset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name,
+static int
+write_dset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name,
hid_t type_id, void *buf );
+/* a filter operation callback function */
+static size_t
+myfilter(unsigned int UNUSED flags, size_t UNUSED cd_nelmts,
+ const unsigned int UNUSED *cd_values, size_t nbytes,
+ size_t UNUSED *buf_size, void UNUSED **buf);
+
+/* a "set local" callback */
+static herr_t
+set_local_myfilter(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id);
+
+#define MYFILTER_ID 405
+
+/* This message derives from H5Z */
+const H5Z_class_t H5Z_MYFILTER[1] = {{
+ MYFILTER_ID, /* Filter id number */
+ "myfilter", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ set_local_myfilter, /* The "set local" callback */
+ myfilter, /* The actual filter function */
+}};
+
#define LENSTR 50
@@ -89,6 +118,12 @@ static int write_dset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_n
#define SPACE1_RANK 1
#define SPACE1_DIM1 4
+#define DIM1 20
+#define DIM2 10
+#define CDIM1 DIM1/2
+#define CDIM2 DIM2/2
+#define RANK 2
+
/* Element selection information */
#define POINT1_NPOINTS 10
@@ -4331,6 +4366,499 @@ static void gent_named_dtype_attr(void)
/*-------------------------------------------------------------------------
+ * Function: make_dset
+ *
+ * Purpose: utility function to create and write a dataset in LOC_ID
+ *
+ *-------------------------------------------------------------------------
+ */
+static
+int make_dset(hid_t loc_id,
+ const char *name,
+ hid_t sid,
+ hid_t dcpl,
+ void *buf)
+{
+ hid_t dsid;
+
+ /* create the dataset */
+ if((dsid = H5Dcreate (loc_id,name,H5T_NATIVE_INT,sid,dcpl))<0)
+ return -1;
+
+ /* write */
+ if(H5Dwrite(dsid,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
+ goto out;
+
+ /* close */
+ if(H5Dclose(dsid)<0)
+ return -1;
+
+ return 0;
+ out:
+ H5E_BEGIN_TRY {
+ H5Dclose(dsid);
+ } H5E_END_TRY;
+ return -1;
+}
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: make_external
+ *
+ * Purpose: make a dataset with external storage
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+make_external(hid_t fid)
+{
+ hid_t dcpl; /*dataset creation property list */
+ hid_t sid; /*dataspace ID */
+ hid_t dsid; /*dataset ID */
+ hsize_t cur_size[1]; /*data space current size */
+ hsize_t max_size[1]; /*data space maximum size */
+ hsize_t size; /*bytes reserved for data in the external file*/
+ int ret;
+
+ cur_size[0] = max_size[0] = 100;
+ size = (max_size[0]*sizeof(int)/2);
+
+ dcpl=H5Pcreate(H5P_DATASET_CREATE);
+ ret=H5Pset_external(dcpl,"ext1.bin",(off_t)0,size);
+ assert(ret>=0);
+
+ ret=H5Pset_external(dcpl,"ext2.bin",(off_t)0,size);
+ assert(ret>=0);
+
+ sid=H5Screate_simple(1, cur_size, max_size);
+ assert(ret>=0);
+
+ dsid=H5Dcreate(fid, "external", H5T_NATIVE_INT, sid, dcpl);
+ assert(ret>=0);
+
+ H5Dclose(dsid);
+ assert(ret>=0);
+
+ H5Sclose(sid);
+ assert(ret>=0);
+
+ H5Pclose(dcpl);
+ assert(ret>=0);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: gent_filters
+ *
+ * Purpose: make several datasets with filters, external dataset
+ * fill value
+ *
+ *-------------------------------------------------------------------------
+ */
+static void gent_filters(void)
+{
+ hid_t fid; /* file id */
+ hid_t dcpl; /* dataset creation property list */
+ hid_t sid; /* dataspace ID */
+ hid_t sid1; /* dataspace ID */
+ hid_t tid; /* datatype ID */
+ hid_t did; /* dataset 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;
+#endif
+ hsize_t dims1[RANK]={DIM1,DIM2};
+ hsize_t chunk_dims[RANK]={CDIM1,CDIM2};
+ int buf1[DIM1][DIM2];
+ hsize_t dims2[1]={2};
+ hvl_t buf2[2];
+ hsize_t dims3[1]={1};
+ char buf3[]={"string\n new"};
+ hsize_t dims4[1]={6};
+ char buf4[6]={"abcdef"};
+ hobj_ref_t buf5[2];
+ int i, j, n, ret, fillval, val;
+
+ 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++;
+ }
+ }
+
+ /* create a file */
+ fid = H5Fcreate(FILE44, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ assert(fid>=0);
+
+ /* create a space */
+ sid = H5Screate_simple(SPACE2_RANK, dims1, NULL);
+
+ /* create a dataset creation property list; the same DCPL is used for all dsets */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+
+/*-------------------------------------------------------------------------
+ * create a compact and contiguous storage layout dataset
+ * add a comment to the datasets
+ *-------------------------------------------------------------------------
+ */
+ ret=H5Pset_layout(dcpl, H5D_COMPACT);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"compact",sid,dcpl,buf1);
+ assert(ret>=0);
+
+ ret=H5Gset_comment(fid,"compact", "This is a dataset with compact storage");
+ assert(ret>=0);
+
+ ret=H5Pset_layout(dcpl, H5D_CONTIGUOUS);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"contiguous",sid,dcpl,buf1);
+ assert(ret>=0);
+
+ ret=H5Gset_comment(fid,"contiguous", "This is a dataset with contiguous storage");
+ assert(ret>=0);
+
+/*-------------------------------------------------------------------------
+ * make several dataset with filters
+ *-------------------------------------------------------------------------
+ */
+
+ /* set up chunk */
+ ret=H5Pset_chunk(dcpl, SPACE2_RANK, chunk_dims);
+ assert(ret>=0);
+
+/*-------------------------------------------------------------------------
+ * SZIP
+ *-------------------------------------------------------------------------
+ */
+#if defined (H5_HAVE_FILTER_SZIP)
+ /* remove the filters from the dcpl */
+ ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL);
+ assert(ret>=0);
+
+ /* set szip data */
+ ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"szip",sid,dcpl,buf1);
+ assert(ret>=0);
+#endif
+
+/*-------------------------------------------------------------------------
+ * GZIP
+ *-------------------------------------------------------------------------
+ */
+#if defined (H5_HAVE_FILTER_DEFLATE)
+ /* remove the filters from the dcpl */
+ ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL);
+ assert(ret>=0);
+
+ /* set deflate data */
+ ret=H5Pset_deflate(dcpl, 9);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"deflate",sid,dcpl,buf1);
+ assert(ret>=0);
+#endif
+
+
+/*-------------------------------------------------------------------------
+ * shuffle
+ *-------------------------------------------------------------------------
+ */
+#if defined (H5_HAVE_FILTER_SHUFFLE)
+ /* remove the filters from the dcpl */
+ ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL);
+ assert(ret>=0);
+
+ /* set the shuffle filter */
+ ret=H5Pset_shuffle(dcpl);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"shuffle",sid,dcpl,buf1);
+ assert(ret>=0);
+#endif
+
+
+/*-------------------------------------------------------------------------
+ * checksum
+ *-------------------------------------------------------------------------
+ */
+#if defined (H5_HAVE_FILTER_FLETCHER32)
+ /* remove the filters from the dcpl */
+ ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL);
+ assert(ret>=0);
+
+ /* set the checksum filter */
+ ret=H5Pset_fletcher32(dcpl);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"fletcher32",sid,dcpl,buf1);
+ assert(ret>=0);
+#endif
+
+/*-------------------------------------------------------------------------
+ * all filters
+ *-------------------------------------------------------------------------
+ */
+ /* remove the filters from the dcpl */
+ ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL);
+ assert(ret>=0);
+
+#if defined (H5_HAVE_FILTER_SHUFFLE)
+ /* set the shuffle filter */
+ ret=H5Pset_shuffle(dcpl);
+ assert(ret>=0);
+#endif
+
+#if defined (H5_HAVE_FILTER_SZIP)
+ szip_options_mask=H5_SZIP_CHIP_OPTION_MASK | H5_SZIP_EC_OPTION_MASK;
+ /* set szip data */
+ ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block);
+ assert(ret>=0);
+#endif
+
+#if defined (H5_HAVE_FILTER_DEFLATE)
+ /* set deflate data */
+ ret=H5Pset_deflate(dcpl, 5);
+ assert(ret>=0);
+#endif
+
+#if defined (H5_HAVE_FILTER_FLETCHER32)
+ /* set the checksum filter */
+ ret=H5Pset_fletcher32(dcpl);
+ assert(ret>=0);
+#endif
+
+ ret=make_dset(fid,"all",sid,dcpl,buf1);
+ assert(ret>=0);
+
+
+/*-------------------------------------------------------------------------
+ * user defined filter
+ *-------------------------------------------------------------------------
+ */
+ /* remove the filters from the dcpl */
+ ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL);
+ assert(ret>=0);
+
+#ifdef H5_WANT_H5_V1_4_COMPAT
+ ret=H5Zregister (MYFILTER_ID, "myfilter", myfilter);
+#else
+ ret=H5Zregister (H5Z_MYFILTER);
+#endif
+ assert(ret>=0);
+
+ H5Pset_filter (dcpl, MYFILTER_ID, 0, 0, NULL);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"myfilter",sid,dcpl,buf1);
+ assert(ret>=0);
+
+ /* remove the filters from the dcpl */
+ ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL);
+ assert(ret>=0);
+
+/*-------------------------------------------------------------------------
+ * make an external dataset
+ *-------------------------------------------------------------------------
+ */
+ make_external(fid);
+
+/*-------------------------------------------------------------------------
+ * make datasets with fill value combinations
+ *-------------------------------------------------------------------------
+ */
+
+ fillval = -99;
+
+ ret=H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY);
+ assert(ret>=0);
+
+ 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);
+ assert(ret>=0);
+
+ ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"fill never",sid,dcpl,buf1);
+ assert(ret>=0);
+
+ ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"fill ifset",sid,dcpl,buf1);
+ assert(ret>=0);
+
+
+/*-------------------------------------------------------------------------
+ * commit a H5G_TYPE type with a comment
+ *-------------------------------------------------------------------------
+ */
+ tid=H5Tcopy(H5T_STD_B8LE);
+ ret=H5Tcommit(fid, "my type", tid);
+ assert(ret>=0);
+
+ ret=H5Gset_comment(fid,"my type", "This is a commited datatype");
+ assert(ret>=0);
+
+ ret=H5Tclose(tid);
+ assert(ret>=0);
+
+/*-------------------------------------------------------------------------
+ * enum type with nonprintable characters in the name
+ *-------------------------------------------------------------------------
+ */
+ tid = H5Tcreate(H5T_ENUM, sizeof(e_t));
+ H5Tenum_insert(tid, "RED 3 \\n", (val = 0, &val));
+ write_dset(fid,2,dims1,"enum",tid,0);
+ ret=H5Tclose(tid);
+ assert(ret>=0);
+
+/*-------------------------------------------------------------------------
+ * vlen
+ *-------------------------------------------------------------------------
+ */
+
+ buf2[0].len = 1;
+ buf2[0].p = malloc( 1 * sizeof(int));
+ ((int *)buf2[0].p)[0]=1;
+ buf2[1].len = 2;
+ buf2[1].p = malloc( 2 * sizeof(int));
+ ((int *)buf2[1].p)[0]=2;
+ ((int *)buf2[1].p)[1]=3;
+
+ sid1=H5Screate_simple(1,dims2,NULL);
+ tid=H5Tvlen_create(H5T_NATIVE_INT);
+ did=H5Dcreate(fid,"vlen",tid,sid1,H5P_DEFAULT);
+ ret=H5Dwrite(did,tid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf2);
+ assert(ret>=0);
+ ret=H5Tcommit(fid,"myvlen",tid);
+ assert(ret>=0);
+ ret=H5Dvlen_reclaim(tid,sid1,H5P_DEFAULT,buf2);
+ assert(ret>=0);
+ ret=H5Dclose(did);
+ assert(ret>=0);
+ ret=H5Tclose(tid);
+ assert(ret>=0);
+
+/*-------------------------------------------------------------------------
+ * bitfield
+ *-------------------------------------------------------------------------
+ */
+ tid = H5Tcopy(H5T_STD_B8LE);
+ write_dset(fid,1,dims3,"bitfield",tid,buf3);
+ ret=H5Tclose(tid);
+ assert(ret>=0);
+
+/*-------------------------------------------------------------------------
+ * string
+ *-------------------------------------------------------------------------
+ */
+
+ tid=H5Tcopy(H5T_C_S1);
+ ret=H5Tset_size(tid, sizeof(buf3));
+ assert(ret>=0);
+ write_dset(fid,1,dims3,"string",tid,buf3);
+ ret=H5Tclose(tid);
+ assert(ret>=0);
+
+/*-------------------------------------------------------------------------
+ * char array
+ *-------------------------------------------------------------------------
+ */
+ write_dset(fid,1,dims4,"char",H5T_NATIVE_CHAR,buf4);
+
+
+/*-------------------------------------------------------------------------
+ * reference
+ *-------------------------------------------------------------------------
+ */
+ ret=H5Rcreate(&buf5[0],fid,"char",H5R_OBJECT,-1);
+ assert(ret>=0);
+ ret=H5Rcreate(&buf5[1],fid,"string",H5R_OBJECT,-1);
+ assert(ret>=0);
+ write_dset(fid,1,dims2,"reference",H5T_STD_REF_OBJ,buf5);
+
+
+
+/*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+
+ ret=H5Sclose(sid1);
+ assert(ret>=0);
+
+ ret=H5Sclose(sid);
+ assert(ret>=0);
+
+ ret=H5Pclose(dcpl);
+ assert(ret>=0);
+
+ ret=H5Fclose(fid);
+ assert(ret>=0);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: myfilter
+ *
+ * Purpose: filter operation callback function; the filter does nothing
+ *
+ *-------------------------------------------------------------------------
+ */
+static size_t
+myfilter(unsigned int UNUSED flags, size_t UNUSED cd_nelmts,
+ const unsigned int UNUSED *cd_values, size_t nbytes,
+ size_t UNUSED *buf_size, void UNUSED **buf)
+{
+ return nbytes;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: set_local_myfilter
+ *
+ * Purpose: filter operation "set local" callback
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static herr_t
+set_local_myfilter(hid_t dcpl_id, hid_t UNUSED type_id, hid_t UNUSED space_id)
+{
+ unsigned flags; /* Filter flags */
+ size_t cd_nelmts=0; /* Number of filter parameters */
+ unsigned cd_values[2]={5,6}; /* Filter parameters */
+
+ /* Get the filter's current parameters */
+ if(H5Pget_filter_by_id(dcpl_id,MYFILTER_ID,&flags,&cd_nelmts,cd_values,0,NULL)<0)
+ return(FAIL);
+
+ cd_nelmts=2;
+
+ /* Modify the filter's parameters for this dataset */
+ if(H5Pmodify_filter(dcpl_id,MYFILTER_ID,flags, cd_nelmts,cd_values)<0)
+ return(FAIL);
+
+ return(SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
*-------------------------------------------------------------------------
@@ -4396,6 +4924,8 @@ int main(void)
gent_compound_complex();
gent_named_dtype_attr();
+
+ gent_filters();
return 0;
}
diff --git a/tools/h5dump/testh5dump.sh b/tools/h5dump/testh5dump.sh
index 598c32c..fc63188 100755
--- a/tools/h5dump/testh5dump.sh
+++ b/tools/h5dump/testh5dump.sh
@@ -62,8 +62,13 @@ TOOLTEST() {
$RUNSERIAL $DUMPER_BIN $@
) >$actual 2>$actual_err
cat $actual_err >> $actual
-
- if $CMP $expect $actual; then
+
+
+ if [ ! -f $expect ]; then
+ # Create the expect file if it doesn't yet exist.
+ echo " CREATED"
+ cp $actual $expect
+ elif $CMP $expect $actual; then
echo " PASSED"
else
echo "*FAILED*"
@@ -92,7 +97,7 @@ TOOLTEST tgroup-2.ddl --group=/g2 --group / -g /y tgroup.h5
# test for displaying simple space datasets
TOOLTEST tdset-1.ddl tdset.h5
# test for displaying selected datasets
-TOOLTEST tdset-2.ddl -H -d dset1 -d /dset2 -d dset3 --dataset=dset4 tdset.h5
+TOOLTEST tdset-2.ddl -H -d dset1 -d /dset2 --dataset=dset3 tdset.h5
# test for displaying attributes
TOOLTEST tattr-1.ddl tattr.h5
@@ -120,7 +125,7 @@ TOOLTEST tcomp-1.ddl tcompound.h5
# test for named data types
TOOLTEST tcomp-2.ddl -t /type1 --datatype /type2 --datatype=/group1/type3 tcompound.h5
# test for unamed type
-TOOLTEST tcomp-3.ddl -t /#6632 -g /group2 tcompound.h5
+TOOLTEST tcomp-3.ddl -t /#6632:0 -g /group2 tcompound.h5
# test complicated compound datatype
TOOLTEST tcomp-4.ddl tcompound_complex.h5
@@ -191,6 +196,13 @@ 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
+
+
if test $nerrors -eq 0 ; then
echo "All $DUMPER tests passed."
fi