diff options
author | Paul Harten <pharten@ncsa.uiuc.edu> | 1998-08-03 20:22:23 (GMT) |
---|---|---|
committer | Paul Harten <pharten@ncsa.uiuc.edu> | 1998-08-03 20:22:23 (GMT) |
commit | 96106282bb72eb635f4da5bbb8a2e887b1bd7cb8 (patch) | |
tree | 4fd11ee0d40a99af0ad50076b2c040ef85b6dbbf /testpar/testphdf5.c | |
parent | 6c6d0c90a277fc86578761c59ccfea7cbef5765e (diff) | |
download | hdf5-96106282bb72eb635f4da5bbb8a2e887b1bd7cb8.zip hdf5-96106282bb72eb635f4da5bbb8a2e887b1bd7cb8.tar.gz hdf5-96106282bb72eb635f4da5bbb8a2e887b1bd7cb8.tar.bz2 |
[svn-r564] Purpose:
New feature
Problem:
Source code must be modified prior to compiling to allow full
filenames to contain preferred user directories. Source must be
recompiled everytime the preferred user directory changes.
Solution:
Instead, allow file prefixes preferred by user to be passed at
runtime using the arguments "-f <prefix>". The "-f" to signal the
next argument is to be a file prefix, and the "<prefix>" to be the
actual prefix used.
Platform tested:
ASCI Red
Diffstat (limited to 'testpar/testphdf5.c')
-rw-r--r-- | testpar/testphdf5.c | 72 |
1 files changed, 62 insertions, 10 deletions
diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c index a24e0df..cdadb7b 100644 --- a/testpar/testphdf5.c +++ b/testpar/testphdf5.c @@ -9,6 +9,15 @@ /* global variables */ int nerrors = 0; /* errors count */ int verbose = 0; /* verbose, default as no. */ + +#ifdef POOMA_ARCH +char *fileprefix = "pfs:/pfs/multi/tmp_1/your_own"; +int fileprefixlen = 29; +#else +char *fileprefix = NULL; /* file prefix, default as NULL */ +int fileprefixlen = 0; /* file prefix length, default as 0 */ +#endif + herr_t (*old_func)(void*); /* previous error handler */ void *old_client_data; /* previous error handler arg.*/ @@ -69,10 +78,11 @@ void pause_proc(MPI_Comm comm, int argc, char **argv) void usage() { - printf("Usage: testphdf5 [-r] [-w] [-v]\n"); - printf("\t-r\tno read\n"); - printf("\t-w\tno write\n"); - printf("\t-v\tverbose on\n"); + printf("Usage: testphdf5 [-r] [-w] [-v] [-f <prefix>]\n"); + printf("\t-f <prefix>\tfilename prefix\n"); + printf("\t-r\t\tno read\n"); + printf("\t-w\t\tno write\n"); + printf("\t-v\t\tverbose on\n"); printf("\tdefault do write then read\n"); printf("\n"); } @@ -94,6 +104,36 @@ parse_options(int argc, char **argv){ break; case 'v': verbose = 1; break; + case 'f': if (--argc <= 0) { + nerrors++; + return(1); + } else if (**(++argv) == '-') { + nerrors++; + return(1); + } else if (**(argv) == '"') { + fileprefixlen = strlen(*(argv)+1)-1; + fileprefix = (char *)HDmalloc(fileprefixlen+1); + if (!fileprefix) { + printf("%s\n","memory allocation failed"); + nerrors++; + return(1); + } + fileprefix = strncpy(fileprefix,*(argv)+1,fileprefixlen); + } else { + fileprefixlen = strlen(*(argv)); + fileprefix = (char *)HDmalloc(fileprefixlen+1); + if (!fileprefix) { + printf("%s\n","memory allocation failed"); + nerrors++; + return(1); + } + fileprefix = strncpy(fileprefix,*(argv),fileprefixlen); + } + if (fileprefixlen < 5) { + nerrors++; + return(1); + } + break; default: usage(); nerrors++; return(1); @@ -106,17 +146,13 @@ parse_options(int argc, char **argv){ main(int argc, char **argv) { -#ifdef POOMA_ARCH - char *filenames[]={ "pfs:/pfs/multi/tmp_1/your_own/ParaEg1.h5f", - "pfs:/pfs/multi/tmp_1/your_own/ParaEg2.h5f", - "pfs:/pfs/multi/tmp_1/your_own/ParaEg3.h5f" }; -#else char *filenames[]={ "ParaEg1.h5f", "ParaEg2.h5f", "ParaEg3.h5f" }; -#endif int mpi_size, mpi_rank; /* mpi variables */ + int i; + char *tmpptr; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); @@ -144,6 +180,22 @@ main(int argc, char **argv) if (parse_options(argc, argv) != 0) goto finish; + if (fileprefix != NULL) { + for (i=0;i<3;i++) { + tmpptr = filenames[i]; + filenames[i] = (char *)HDmalloc ( fileprefixlen + strlen(tmpptr) + 2); + if (!filenames[i]) { + printf("%s\n","memory allocation failed"); + nerrors++; + goto finish; + } + filenames[i] = strcpy(filenames[i],fileprefix); + if (fileprefix[fileprefixlen-1] != '/') filenames[i] = strcat(filenames[i],"/"); + filenames[i] = strcat(filenames[i],tmpptr); + H5MM_xfree(tmpptr); + } + } + if (dowrite){ MPI_BANNER("testing dataset using split communicators..."); test_split_comm_access(filenames); |