From c62c0eb9d258f67c512ee9ddf6a5905bdf30642f Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Tue, 25 May 2004 15:45:01 -0500 Subject: [svn-r8574] Purpose: h5dump new features Description: added the code for new features. dump of 1) filters 2) storage layout 3) fill value 4) comments 5) file super block 6) file contents 7) array indices Solution: Platforms tested: linux AIX solaris Misc. update: --- tools/h5dump/h5dump.c | 805 ++++++++++++++++++++++++++++++++++---- tools/h5dump/h5dumpgentest.c | 80 ---- tools/h5dump/testh5dump.sh | 11 +- tools/h5dump/testh5dumpxml.sh | 9 +- tools/lib/h5diff.c | 2 +- tools/lib/h5tools.c | 14 +- tools/lib/h5tools.h | 24 +- tools/lib/h5tools_str.c | 1 + tools/testfiles/tvldtypes4.h5.xml | 4 +- tools/testfiles/tvldtypes5.h5.xml | 4 +- tools/testfiles/tvlstr.h5.xml | 8 +- 11 files changed, 791 insertions(+), 171 deletions(-) diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 601b3bd..f1c0a65 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -18,10 +18,21 @@ #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 +43,16 @@ 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 ** @@ -66,6 +80,7 @@ struct ref_path_table_entry_t { /** 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); @@ -236,7 +251,7 @@ static const dump_header standardformat = { "standardformat", /*name */ "HDF5", /*fileebgin */ "", /*fileend */ - BOOT_BLOCK, /*bootblockbegin */ + SUPER_BLOCK, /*bootblockbegin */ "", /*bootblockend */ GROUPNAME, /*groupbegin */ "", /*groupend */ @@ -335,11 +350,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' }, @@ -471,7 +488,12 @@ 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 */ @@ -481,7 +503,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 ** @@ -496,7 +518,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 */ @@ -547,6 +569,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"); @@ -555,6 +578,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"); @@ -562,7 +586,7 @@ usage(const char *prog) 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 (default)\n"); - fprintf(stdout, " -u, --use-dtd Output in XML using DTD\n"); + fprintf(stdout, " -u, --use-dtd Output in XML using DTD\n"); fprintf(stdout, " -D U, --xml-dtd=U Use the DTD or schema at U\n"); fprintf(stdout, " -X S, --xml-ns=S (XML Schema) Use qualified names n the XML\n"); fprintf(stdout, " \":\": no namespace, default: \"hdf5:\"\n"); @@ -929,25 +953,6 @@ 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 @@ -1087,7 +1092,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); @@ -1197,7 +1202,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); @@ -1540,11 +1545,13 @@ dump_named_datatype(hid_t type, const char *name) indentation(indent + COL); print_datatype(type,1); printf(";\n"); + dump_comment(type); } end_obj(dump_header_format->datatypeend, dump_header_format->datatypeblockend); } + /*------------------------------------------------------------------------- * Function: dump_group * @@ -1565,7 +1572,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); @@ -1576,15 +1583,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 */ @@ -1640,25 +1641,32 @@ dump_group(hid_t gid, const char *name) * * Programmer: Ruey-Hsia Li * - * Modifications: + * Modifications: pvn, 2004, added dcpl dump * *------------------------------------------------------------------------- */ 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); + 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)) { @@ -1677,7 +1685,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: @@ -1689,6 +1697,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); @@ -1838,12 +1847,12 @@ dump_subsetting_header(struct subset_t *sset, int dims) * * Programmer: Ruey-Hsia Li * - * Modifications: + * Modifications: pvn, print the matrix indices * *------------------------------------------------------------------------- */ 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; @@ -1913,8 +1922,21 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset) outputformat = &string_dataformat; } - status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, sset, depth); - H5Tclose(f_type); + /* print the matrix indices */ + if (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 { /* need to call h5tools_dump_mem for the attribute data */ type = H5Aget_type(obj_id); @@ -1980,6 +2002,512 @@ dump_oid(hid_t oid) } /*------------------------------------------------------------------------- + * 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; + int nelmts=1; + h5dump_t *outputformat = &dataformat; + + memset(&ctx, 0, sizeof(ctx)); + 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 ", storage_size); + rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize); + printf("%s %d", dump_header_format->dataspacedimbegin, chsize[0]); + for ( i=1; idataspacedimend); + /*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", 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; ifilebegin, fname, @@ -2923,8 +3460,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) { @@ -4227,7 +4775,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; @@ -4356,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: @@ -4376,7 +4924,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data) case H5T_COMPOUND: indentation(indent); printf("\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: @@ -4399,7 +4947,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data) case H5T_VLEN: printf("\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); @@ -5044,13 +5592,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) { @@ -5096,7 +5638,7 @@ static void xml_dump_fill_value(hid_t dcpl, hid_t type) size_t sz; size_t i; hsize_t space; -void * buf; +void * buf=NULL; char * path; char * name; indent += COL; @@ -5413,7 +5955,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: @@ -5432,7 +5974,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) case H5T_COMPOUND: indentation(indent); printf("\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: @@ -5455,7 +5997,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) case H5T_VLEN: printf("\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); @@ -5596,3 +6138,128 @@ 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; + hsize_t fam_size = 100*1024*1024; /*100 MB*/ +#ifdef H5_WANT_H5_V1_4_COMPAT + long verbosity = 1; +#else /* H5_WANT_H5_V1_4_COMPAT */ + long log_flags = H5FD_LOG_LOC_IO; +#endif /* H5_WANT_H5_V1_4_COMPAT */ + H5FD_mem_t mt; + + /* 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]; + + 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 -#include - -#define COMMIT_CMPD_DATATYPE 1 - -typedef struct cmpdStruct - { - int a; - int b; - hvl_t string; - } cmpdStruct; - -int main( void ) -{ - hid_t h5File, cmpdType, dataSetID, dataSpaceID; - hsize_t dataSpaceSize; - cmpdStruct myStruct; - herr_t status; - - myStruct.a = 2; - myStruct.b = 6; - myStruct.string.p = (char *)malloc( sizeof(char) * 4 ); - myStruct.string.len = 4; - strcpy( myStruct.string.p, "adsf" ); - - - /* create hdf file */ - h5File = H5Fcreate( "vlen.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); - printf ("%i\n", h5File); - - /* create compound datatype */ - cmpdType = H5Tcreate( H5T_COMPOUND, sizeof(cmpdStruct) ); - printf ("%i\n", cmpdType); - status = H5Tinsert( cmpdType, "a", HOFFSET(cmpdStruct, a), H5T_NATIVE_INT ); - printf ("%i\n", status); - status = H5Tinsert( cmpdType, "b", HOFFSET(cmpdStruct, b), H5T_NATIVE_INT ); - printf ("%i\n", status); -/* - status =H5Tinsert( cmpdType, "string", HOFFSET(cmpdStruct, string), - H5Tvlen_create( H5T_NATIVE_CHAR ) ); -*/ - - status =H5Tinsert( cmpdType, "string", HOFFSET(cmpdStruct, string), - H5Tvlen_create( H5T_C_S1 ) ); - - printf ("%i\n", status); - -#if (COMMIT_CMPD_DATATYPE == 1) - /* commit datatype */ - status =H5Tcommit( h5File, "cmpdType", cmpdType ); - printf ("%i\n", status); -#endif - - /* create dataspace ID */ - dataSpaceID = H5Screate_simple( 1, (dataSpaceSize=1, &dataSpaceSize), NULL ); - /* create dataset ID */ - printf ("%i\n", dataSpaceID); - dataSetID = H5Dcreate( h5File, "cmpdStruct", cmpdType, dataSpaceID, H5P_DEFAULT ); - printf ("%i\n", dataSetID); - - /* write dataset */ - status = H5Dwrite( dataSetID, cmpdType, H5S_ALL, H5S_ALL, H5P_DEFAULT, &myStruct ); - printf ("%i\n", status); - - status = H5Tclose (cmpdType); - printf ("%i\n", status); - status = H5Dclose (dataSetID); - printf ("%i\n", status); - status = H5Sclose (dataSpaceID); - printf ("%i\n", status); - status = H5Fclose (h5File); - printf ("%i\n", status); - - return( 0 ); -} - -#endif \ No newline at end of file diff --git a/tools/h5dump/testh5dump.sh b/tools/h5dump/testh5dump.sh index 78e2f03..2119101 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*" @@ -191,6 +196,8 @@ TOOLTEST tchar1.ddl -r tchar.h5 # Missing file name TOOLTEST tnofilename.ddl + + if test $nerrors -eq 0 ; then echo "All $DUMPER tests passed." fi diff --git a/tools/h5dump/testh5dumpxml.sh b/tools/h5dump/testh5dumpxml.sh index d5e3ad5..c6b4c6a 100755 --- a/tools/h5dump/testh5dumpxml.sh +++ b/tools/h5dump/testh5dumpxml.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*" diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index a84a9b5..e9160ee 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -19,7 +19,7 @@ /*------------------------------------------------------------------------- * Function: h5diff * - * Purpose: public function, can be called in an applicattion program. + * Purpose: public function, can be called in an application program. * return differences between 2 HDF5 files * * Return: Number of differences found; -1 for error. diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 50d17d3..213e9dc 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -43,9 +43,6 @@ #define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z)) -#define START_OF_DATA 0x0001 -#define END_OF_DATA 0x0002 - /* global variables */ int indent; int compound_data; @@ -378,9 +375,9 @@ h5tools_simple_prefix(FILE *stream, const h5dump_t *info, /* Terminate previous line, if any */ if (ctx->cur_column) { - fputs(OPT(info->line_suf, ""), stream); - putc('\n', stream); - fputs(OPT(info->line_sep, ""), stream); + fputs(OPT(info->line_suf, ""), stream); + putc('\n', stream); + fputs(OPT(info->line_sep, ""), stream); } /* Calculate new prefix */ @@ -452,7 +449,7 @@ h5tools_simple_prefix(FILE *stream, const h5dump_t *info, * handled correctly. *------------------------------------------------------------------------- */ -static void +void h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, h5tools_context_t *ctx/*in,out*/, unsigned flags, hsize_t nelmts, hid_t type, void *_mem) @@ -485,7 +482,8 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, 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); + + h5tools_str_sprint(&buffer, info, container, type, mem + i * size, ctx); if (i + 1 < nelmts || (flags & END_OF_DATA) == 0) h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ",")); diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index f4fbb3d..c1d231a 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -30,6 +30,8 @@ #define ESCAPE_HTML 1 #define OPT(X,S) ((X) ? (X) : (S)) #define OPTIONAL_LINE_BREAK "\001" /* Special strings embedded in the output */ +#define START_OF_DATA 0x0001 +#define END_OF_DATA 0x0002 /* * Information about how to format output. @@ -104,6 +106,7 @@ typedef struct h5dump_t { * str_repeat: If set to non-zero then any character value repeated N * or more times is printed as 'C'*N * + * * Numeric data is also subject to the formats for individual elements. */ hbool_t raw; @@ -441,7 +444,7 @@ extern FILE *rawdatastream; /*output stream for raw data */ /* taken from h5dump.h*/ #define ATTRIBUTE "ATTRIBUTE" #define BLOCK "BLOCK" -#define BOOT_BLOCK "BOOT_BLOCK" +#define SUPER_BLOCK "SUPER_BLOCK" #define COMPRESSION "COMPRESSION" #define CONCATENATOR "//" #define COMPLEX "COMPLEX" @@ -468,6 +471,22 @@ extern FILE *rawdatastream; /*output stream for raw data */ #define STRSIZE "STRSIZE" #define STRPAD "STRPAD" #define SUBSET "SUBSET" +#define FILTERS "FILTERS" +#define DEFLATE "COMPRESSION DEFLATE" +#define DEFLATE_LEVEL "LEVEL" +#define SHUFFLE "PREPROCESSING SHUFFLE" +#define FLETCHER32 "CHECKSUM FLETCHER32" +#define SZIP "COMPRESSION SZIP" +#define UNKNOWN_FILTER "UNKNOWN_FILTER" +#define STORAGE_LAYOUT "STORAGE_LAYOUT" +#define CONTIGUOUS "CONTIGUOUS" +#define COMPACT "COMPACT" +#define CHUNKED "CHUNKED" +#define EXTERNAL_FILE "EXTERNAL_FILE" +#define FILLVALUE "FILLVALUE" +#define FILE_CONTENTS "FILE_CONTENTS" + + #define BEGIN "{" #define END "}" @@ -481,6 +500,9 @@ extern int h5tools_dump_dset(FILE *stream, const h5dump_t *info, hid_t dset hid_t p_typ, struct subset_t *sset, int indentlevel); extern int h5tools_dump_mem(FILE *stream, const h5dump_t *info, hid_t obj_id, hid_t type, hid_t space, void *mem, int indentlevel); +extern void h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, + h5tools_context_t *ctx/*in,out*/, unsigned flags, + hsize_t nelmts, hid_t type, void *_mem); extern int h5tools_canreadf(const char* name, hid_t dcpl_id); diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 970a46b..3d9aaf7 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -1051,3 +1051,4 @@ h5tools_is_zero(const void *_mem, size_t size) return TRUE; } + diff --git a/tools/testfiles/tvldtypes4.h5.xml b/tools/testfiles/tvldtypes4.h5.xml index 6a31194..f490341 100644 --- a/tools/testfiles/tvldtypes4.h5.xml +++ b/tools/testfiles/tvldtypes4.h5.xml @@ -3,8 +3,8 @@ Expected output for 'h5dump --xml tvldtypes4.h5' ############################# - - + + diff --git a/tools/testfiles/tvldtypes5.h5.xml b/tools/testfiles/tvldtypes5.h5.xml index f2452a7..ebb3836 100644 --- a/tools/testfiles/tvldtypes5.h5.xml +++ b/tools/testfiles/tvldtypes5.h5.xml @@ -3,8 +3,8 @@ Expected output for 'h5dump --xml tvldtypes5.h5' ############################# - - + + diff --git a/tools/testfiles/tvlstr.h5.xml b/tools/testfiles/tvlstr.h5.xml index 7d9fb5b..1dffb77 100644 --- a/tools/testfiles/tvlstr.h5.xml +++ b/tools/testfiles/tvlstr.h5.xml @@ -3,26 +3,26 @@ Expected output for 'h5dump --xml tvlstr.h5' ############################# - + - + "This is the string for the attribute" - + - + -- cgit v0.12