diff options
-rw-r--r-- | release_docs/RELEASE.txt | 4 | ||||
-rw-r--r-- | tools/h5dump/h5dump.c | 66 | ||||
-rw-r--r-- | tools/h5ls/h5ls.c | 361 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 40 | ||||
-rw-r--r-- | tools/lib/h5tools.h | 4 | ||||
-rw-r--r-- | tools/testfiles/help-1.ls | 1 | ||||
-rw-r--r-- | tools/testfiles/help-2.ls | 1 | ||||
-rw-r--r-- | tools/testfiles/help-3.ls | 1 |
8 files changed, 293 insertions, 185 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 7252b88..16b7641 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -77,6 +77,10 @@ New Features Tools: ------ + - Added the MPI-I/O and MPI-POSIX drivers to the list of VFL drivers + available for h5dump and h5ls + - Added option --vfd= to h5ls to allow a VFL driver to be selected + by a user. - Added option -showconfig to compiler tools (h5cc,h5fc,h5c++). AKC - 2004/01/08 - Install the "h5cc" and "h5fc" tools as "h5pcc" and "h5pfc" diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index d79f4ee..b69d3b9 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -524,6 +524,32 @@ static const dump_functions xml_function_table = { */ static const dump_functions *dump_function_table; + +/*------------------------------------------------------------------------- + * Function: leave + * + * Purpose: Shutdown MPI & HDF5 and call exit() + * + * Return: Does not return + * + * Programmer: Quincey Koziol + * Saturday, 31. January 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +leave(int ret) +{ + H5close(); +#ifdef H5_HAVE_PARALLEL + MPI_Finalize(); +#endif + exit(ret); +} + + /*------------------------------------------------------------------------- * Function: usage * @@ -2483,7 +2509,7 @@ parse_start: break; case 'V': print_version(progname); - exit(EXIT_SUCCESS); + leave(EXIT_SUCCESS); break; case 'w': nCols = atoi(opt_arg); @@ -2558,7 +2584,7 @@ parse_start: if (set_output_file(opt_arg) < 0){ /* failed to set output file */ usage(progname); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } usingdasho = TRUE; @@ -2590,7 +2616,7 @@ parse_start: /* To Do: check format of this value? */ if (!useschema) { usage(progname); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } if (strcmp(opt_arg,":") == 0) { xmlnsprefix = ""; @@ -2611,7 +2637,7 @@ parse_start: error_msg(progname, "option `-%c' can only be used after --dataset option\n", opt); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } if (last_dset->subset_info) { @@ -2657,11 +2683,11 @@ end_collect: case 'h': usage(progname); - exit(EXIT_SUCCESS); + leave(EXIT_SUCCESS); case '?': default: usage(progname); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } } @@ -2670,7 +2696,7 @@ parse_end: if (argc <= opt_ind) { error_msg(progname, "missing file name\n"); usage(progname); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } return hand; } @@ -2758,6 +2784,10 @@ main(int argc, const char *argv[]) struct handler_t *hand; int i; +#ifdef H5_HAVE_PARALLEL + MPI_Init(&argc, &argv); +#endif + dump_header_format = &standardformat; dump_function_table = &ddl_function_table; @@ -2779,23 +2809,23 @@ main(int argc, const char *argv[]) if (!display_all) { error_msg(progname, "option \"%s\" not available for XML\n", "to display selected objects"); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } else if (display_bb) { error_msg(progname, "option \"%s\" not available for XML\n", "--boot-block"); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } else if (display_oid == 1) { error_msg(progname, "option \"%s\" not available for XML\n", "--object-ids"); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } else if (display_char == TRUE) { error_msg(progname, "option \"%s\" not available for XML\n", "--string"); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } else if (usingdasho) { error_msg(progname, "option \"%s\" not available for XML\n", "--output"); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } } else { if (xml_dtd_uri) { @@ -2807,7 +2837,7 @@ main(int argc, const char *argv[]) if (argc <= opt_ind) { error_msg(progname, "missing file name\n"); usage(progname); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } fname = argv[opt_ind]; @@ -2815,7 +2845,7 @@ main(int argc, const char *argv[]) if (fid < 0) { error_msg(progname, "unable to open file \"%s\"\n", fname); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } /* allocate and initialize internal data structure */ @@ -2862,7 +2892,7 @@ main(int argc, const char *argv[]) } else { if (useschema && strcmp(xmlnsprefix,"")) { error_msg(progname, "Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } } } @@ -2986,6 +3016,12 @@ done: #else H5Eset_auto(H5E_DEFAULT, func, edata); #endif /* H5_WANT_H5_V1_6_COMPAT */ + + H5close(); +#ifdef H5_HAVE_PARALLEL + MPI_Finalize(); +#endif + return d_status; } diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index 267e40f..9302ca8 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -112,6 +112,7 @@ usage: %s [OPTIONS] [OBJECTS...]\n\ -wN, --width=N Set the number of columns of output\n\ -v, --verbose Generate more verbose output\n\ -V, --version Print version number and exit\n\ + --vfd=DRIVER Use the specified virtual file driver\n\ -x, --hexdump Show raw data in hexadecimal format\n\ \n\ OBJECTS\n\ @@ -1957,6 +1958,31 @@ get_width(void) /*------------------------------------------------------------------------- + * Function: leave + * + * Purpose: Close HDF5 and MPI and call exit() + * + * Return: Does not return + * + * Programmer: Quincey Koziol + * Saturday, January 31, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +leave(int ret) +{ + H5close(); +#ifdef H5_HAVE_PARALLEL + MPI_Finalize(); +#endif + exit(ret); +} + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Opens a file and lists the specified group @@ -1985,6 +2011,11 @@ main (int argc, char *argv[]) iter_t iter; static char root_name[] = "/"; char drivername[50]; + char *preferred_driver=NULL; + +#ifdef H5_HAVE_PARALLEL + MPI_Init(&argc, &argv); +#endif /* Initialize h5tools lib */ h5tools_init(); @@ -2010,132 +2041,134 @@ main (int argc, char *argv[]) /* Switches come before non-switch arguments */ for (argno=1; argno<argc && '-'==argv[argno][0]; argno++) { - if (!strcmp(argv[argno], "--")) { - /* Last switch */ - argno++; - break; - } else if (!strcmp(argv[argno], "--help")) { - usage(progname); - exit(0); - } else if (!strcmp(argv[argno], "--address")) { - address_g = TRUE; - } else if (!strcmp(argv[argno], "--data")) { - data_g = TRUE; - } else if (!strcmp(argv[argno], "--errors")) { - show_errors_g = TRUE; - } else if (!strcmp(argv[argno], "--full")) { - fullname_g = TRUE; - } else if (!strcmp(argv[argno], "--group")) { - grp_literal_g = TRUE; - } else if (!strcmp(argv[argno], "--label")) { - label_g = TRUE; - } else if (!strcmp(argv[argno], "--recursive")) { - recursive_g = TRUE; - fullname_g = TRUE; - } else if (!strcmp(argv[argno], "--simple")) { - simple_output_g = TRUE; - } else if (!strcmp(argv[argno], "--string")) { - string_g = TRUE; - } else if (!strncmp(argv[argno], "--width=", 8)) { - width_g = (int)strtol(argv[argno]+8, &rest, 0); - if (width_g<=0 || *rest) { - usage(progname); - exit(1); - } - } else if (!strcmp(argv[argno], "--width")) { - if (argno+1>=argc) { - usage(progname); - exit(1); - } else { - s = argv[++argno]; - } - width_g = (int)strtol(s, &rest, 0); - if (width_g<=0 || *rest) { - usage(progname); - exit(1); - } - } else if (!strcmp(argv[argno], "--verbose")) { - verbose_g++; - } else if (!strcmp(argv[argno], "--version")) { + if (!strcmp(argv[argno], "--")) { + /* Last switch */ + argno++; + break; + } else if (!strcmp(argv[argno], "--help")) { + usage(progname); + leave(0); + } else if (!strcmp(argv[argno], "--address")) { + address_g = TRUE; + } else if (!strcmp(argv[argno], "--data")) { + data_g = TRUE; + } else if (!strcmp(argv[argno], "--errors")) { + show_errors_g = TRUE; + } else if (!strcmp(argv[argno], "--full")) { + fullname_g = TRUE; + } else if (!strcmp(argv[argno], "--group")) { + grp_literal_g = TRUE; + } else if (!strcmp(argv[argno], "--label")) { + label_g = TRUE; + } else if (!strcmp(argv[argno], "--recursive")) { + recursive_g = TRUE; + fullname_g = TRUE; + } else if (!strcmp(argv[argno], "--simple")) { + simple_output_g = TRUE; + } else if (!strcmp(argv[argno], "--string")) { + string_g = TRUE; + } else if (!strncmp(argv[argno], "--vfd=", 6)) { + preferred_driver = argv[argno]+6; + } else if (!strncmp(argv[argno], "--width=", 8)) { + width_g = (int)strtol(argv[argno]+8, &rest, 0); + if (width_g<=0 || *rest) { + usage(progname); + leave(1); + } + } else if (!strcmp(argv[argno], "--width")) { + if (argno+1>=argc) { + usage(progname); + leave(1); + } else { + s = argv[++argno]; + } + width_g = (int)strtol(s, &rest, 0); + if (width_g<=0 || *rest) { + usage(progname); + leave(1); + } + } else if (!strcmp(argv[argno], "--verbose")) { + verbose_g++; + } else if (!strcmp(argv[argno], "--version")) { print_version(progname); - exit(0); - } else if (!strcmp(argv[argno], "--hexdump")) { - hexdump_g = TRUE; - } else if (!strncmp(argv[argno], "-w", 2)) { - if (argv[argno][2]) { - s = argv[argno]+2; - } else if (argno+1>=argc) { - usage(progname); - exit(1); - } else { - s = argv[++argno]; - } - width_g = (int)strtol(s, &rest, 0); - if (width_g<=0 || *rest) { - usage(progname); - exit(1); - } - } else if ('-'!=argv[argno][1]) { - /* Single-letter switches */ - for (s=argv[argno]+1; *s; s++) { - switch (*s) { - case '?': - case 'h': /* --help */ - usage(progname); - exit(0); - case 'a': /* --address */ - address_g = TRUE; - break; - case 'd': /* --data */ - data_g = TRUE; - break; - case 'e': /* --errors */ - show_errors_g = TRUE; - break; - case 'f': /* --full */ - fullname_g = TRUE; - break; - case 'g': /* --group */ - grp_literal_g = TRUE; - break; - case 'l': /* --label */ - label_g = TRUE; - break; - case 'r': /* --recursive */ - recursive_g = TRUE; - fullname_g = TRUE; - break; - case 'S': /* --simple */ - simple_output_g = TRUE; - break; - case 's': /* --string */ - string_g = TRUE; - break; - case 'v': /* --verbose */ - verbose_g++; - break; - case 'V': /* --version */ - print_version(progname); - exit(0); - case 'x': /* --hexdump */ - hexdump_g = TRUE; - break; - default: - usage(progname); - exit(1); - } - } - } else { - usage(progname); - exit(1); - } + leave(0); + } else if (!strcmp(argv[argno], "--hexdump")) { + hexdump_g = TRUE; + } else if (!strncmp(argv[argno], "-w", 2)) { + if (argv[argno][2]) { + s = argv[argno]+2; + } else if (argno+1>=argc) { + usage(progname); + leave(1); + } else { + s = argv[++argno]; + } + width_g = (int)strtol(s, &rest, 0); + if (width_g<=0 || *rest) { + usage(progname); + leave(1); + } + } else if ('-'!=argv[argno][1]) { + /* Single-letter switches */ + for (s=argv[argno]+1; *s; s++) { + switch (*s) { + case '?': + case 'h': /* --help */ + usage(progname); + leave(0); + case 'a': /* --address */ + address_g = TRUE; + break; + case 'd': /* --data */ + data_g = TRUE; + break; + case 'e': /* --errors */ + show_errors_g = TRUE; + break; + case 'f': /* --full */ + fullname_g = TRUE; + break; + case 'g': /* --group */ + grp_literal_g = TRUE; + break; + case 'l': /* --label */ + label_g = TRUE; + break; + case 'r': /* --recursive */ + recursive_g = TRUE; + fullname_g = TRUE; + break; + case 'S': /* --simple */ + simple_output_g = TRUE; + break; + case 's': /* --string */ + string_g = TRUE; + break; + case 'v': /* --verbose */ + verbose_g++; + break; + case 'V': /* --version */ + print_version(progname); + leave(0); + case 'x': /* --hexdump */ + hexdump_g = TRUE; + break; + default: + usage(progname); + leave(1); + } + } + } else { + usage(progname); + leave(1); + } } /* If no arguments remain then print a usage message (instead of doing * absolutely nothing ;-) */ if (argno>=argc) { - usage(progname); - exit(1); + usage(progname); + leave(1); } /* Turn off HDF5's automatic error printing unless you're debugging h5ls */ @@ -2160,58 +2193,62 @@ main (int argc, char *argv[]) * doesn't exist). */ show_file_name_g = (argc-argno > 1); /*show file names if more than one*/ while (argno<argc) { - fname = argv[argno++]; - oname = NULL; - file = -1; - - while (fname && *fname) { - file = h5tools_fopen(fname, NULL, drivername, sizeof drivername); - - if (file>=0) { - if (verbose_g) { - printf("Opened \"%s\" with %s driver.\n", - fname, drivername); - } - break; /*success*/ - } - - /* Shorten the file name; lengthen the object name */ - x = oname; - oname = strrchr(fname, '/'); - if (x) *x = '/'; - if (!oname) break; - *oname = '\0'; - } - if (file<0) { - fprintf(stderr, "%s: unable to open file\n", argv[argno-1]); + fname = argv[argno++]; + oname = NULL; + file = -1; + + while (fname && *fname) { + file = h5tools_fopen(fname, preferred_driver, drivername, sizeof drivername); + + if (file>=0) { + if (verbose_g) { + printf("Opened \"%s\" with %s driver.\n", + fname, drivername); + } + break; /*success*/ + } + + /* Shorten the file name; lengthen the object name */ + x = oname; + oname = strrchr(fname, '/'); + if (x) *x = '/'; + if (!oname) break; + *oname = '\0'; + } + if (file<0) { + fprintf(stderr, "%s: unable to open file\n", argv[argno-1]); continue; - } - if (oname) oname++; - if (!oname || !*oname) oname = root_name; + } + if (oname) oname++; + if (!oname || !*oname) oname = root_name; - /* Open the object and display it's information */ - if (H5Gget_objinfo(file, oname, TRUE, &sb)>=0 && - H5G_GROUP==sb.type && !grp_literal_g) { + /* Open the object and display it's information */ + if (H5Gget_objinfo(file, oname, TRUE, &sb)>=0 && + H5G_GROUP==sb.type && !grp_literal_g) { /* Specified name is a group. List the complete contents of the * group. */ - sym_insert(&sb, oname); + sym_insert(&sb, oname); iter.container = container = fix_name(show_file_name_g?fname:"", oname); - H5Giterate(file, oname, NULL, list, &iter); - free(container); + H5Giterate(file, oname, NULL, list, &iter); + free(container); - } else if ((root=H5Gopen(file, "/"))<0) { - exit(1); /*major problem!*/ - - } else { + } else if ((root=H5Gopen(file, "/"))<0) { + leave(1); /*major problem!*/ + + } else { /* Specified name is a non-group object -- list that object. The - * container for the object is everything up to the base name. */ + * container for the object is everything up to the base name. */ iter.container = show_file_name_g ? fname : "/"; - list(root, oname, &iter); - if (H5Gclose(root)<0) exit(1); - } - H5Fclose(file); + list(root, oname, &iter); + if (H5Gclose(root)<0) leave(1); + } + H5Fclose(file); } h5tools_close(); + H5close(); +#ifdef H5_HAVE_PARALLEL + MPI_Finalize(); +#endif return 0; } diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index d2be237..95d64e4 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -181,6 +181,10 @@ h5tools_fopen(const char *fname, const char *driver, char *drivername, #ifdef H5_HAVE_STREAM ,{ "stream", FAIL } #endif /* H5_HAVE_STREAM */ +#ifdef H5_HAVE_PARALLEL + ,{ "mpio", FAIL } + ,{ "mpiposix", FAIL } +#endif /* H5_HAVE_PARALLEL */ }; /* This enum should match the entries in the above drivers_list since they * are indexes into the drivers_list array. */ @@ -192,15 +196,17 @@ h5tools_fopen(const char *fname, const char *driver, char *drivername, #ifdef H5_HAVE_STREAM ,STREAM_IDX #endif /* H5_HAVE_STREAM */ +#ifdef H5_HAVE_PARALLEL + ,MPIO_IDX + ,MPIPOSIX_IDX +#endif /* H5_HAVE_PARALLEL */ }; #define NUM_DRIVERS (sizeof(drivers_list) / sizeof(struct d_list)) static int initialized = 0; register unsigned drivernum; hid_t fid = FAIL; -#ifndef VERSION12 hid_t fapl = H5P_DEFAULT; -#endif /* !VERSION12 */ if (!initialized) { /* Build a list of file access property lists which we should try @@ -211,7 +217,6 @@ h5tools_fopen(const char *fname, const char *driver, char *drivername, /* SEC2 Driver */ drivers_list[SEC2_IDX].fapl = H5P_DEFAULT; -#ifndef VERSION12 /* FAMILY Driver */ drivers_list[FAMILY_IDX].fapl = fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_family(fapl, (hsize_t)0, H5P_DEFAULT); @@ -229,7 +234,16 @@ h5tools_fopen(const char *fname, const char *driver, char *drivername, drivers_list[STREAM_IDX].fapl = fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_stream(fapl, NULL); #endif /* H5_HAVE_STREAM */ -#endif /* !VERSION12 */ + +#ifdef H5_HAVE_PARALLEL + /* MPI-IO Driver */ + drivers_list[MPIO_IDX].fapl = fapl = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, MPI_INFO_NULL); + + /* MPI-POSIX Driver */ + drivers_list[MPIPOSIX_IDX].fapl = fapl = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_mpiposix(fapl, MPI_COMM_WORLD, TRUE); +#endif /* H5_HAVE_PARALLEL */ } if (driver && *driver) { @@ -287,6 +301,24 @@ h5tools_fopen(const char *fname, const char *driver, char *drivername, drivernum = STREAM_IDX; #endif /* H5_HAVE_STREAM */ +#ifdef H5_HAVE_PARALLEL + } else if (!strcmp(driver, drivers_list[MPIO_IDX].name)) { + H5E_BEGIN_TRY { + fid = H5Fopen(fname, H5F_ACC_RDONLY, + drivers_list[MPIO_IDX].fapl); + } H5E_END_TRY; + if (fid == FAIL) + goto done; + drivernum = MPIO_IDX; + } else if (!strcmp(driver, drivers_list[MPIPOSIX_IDX].name)) { + H5E_BEGIN_TRY { + fid = H5Fopen(fname, H5F_ACC_RDONLY, + drivers_list[MPIO_IDX].fapl); + } H5E_END_TRY; + if (fid == FAIL) + goto done; + drivernum = MPIPOSIX_IDX; +#endif /* H5_HAVE_PARALLEL */ } else { goto done; } diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 96e2bd1..5ba9798 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -23,10 +23,6 @@ #include "hdf5.h" -#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 2 -#define VERSION12 -#endif /* H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 2 */ - #define ESCAPE_HTML 1 #define OPT(X,S) ((X) ? (X) : (S)) #define OPTIONAL_LINE_BREAK "\001" /* Special strings embedded in the output */ diff --git a/tools/testfiles/help-1.ls b/tools/testfiles/help-1.ls index 3fc1a7d..94a9976 100644 --- a/tools/testfiles/help-1.ls +++ b/tools/testfiles/help-1.ls @@ -16,6 +16,7 @@ usage: h5ls [OPTIONS] [OBJECTS...] -wN, --width=N Set the number of columns of output -v, --verbose Generate more verbose output -V, --version Print version number and exit + --vfd=DRIVER Use the specified virtual file driver -x, --hexdump Show raw data in hexadecimal format OBJECTS diff --git a/tools/testfiles/help-2.ls b/tools/testfiles/help-2.ls index 5b68c4d..ee7de9e 100644 --- a/tools/testfiles/help-2.ls +++ b/tools/testfiles/help-2.ls @@ -16,6 +16,7 @@ usage: h5ls [OPTIONS] [OBJECTS...] -wN, --width=N Set the number of columns of output -v, --verbose Generate more verbose output -V, --version Print version number and exit + --vfd=DRIVER Use the specified virtual file driver -x, --hexdump Show raw data in hexadecimal format OBJECTS diff --git a/tools/testfiles/help-3.ls b/tools/testfiles/help-3.ls index 4d1e103..65c0bd8 100644 --- a/tools/testfiles/help-3.ls +++ b/tools/testfiles/help-3.ls @@ -16,6 +16,7 @@ usage: h5ls [OPTIONS] [OBJECTS...] -wN, --width=N Set the number of columns of output -v, --verbose Generate more verbose output -V, --version Print version number and exit + --vfd=DRIVER Use the specified virtual file driver -x, --hexdump Show raw data in hexadecimal format OBJECTS |