From e4961068312b5e15e88d0e8200742ec7f395eb55 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 26 Feb 2002 19:22:12 -0500 Subject: [svn-r5014] Purpose: fetures Description: The example code used to just run parallel I/O test in the current directory which is most likely where the program is compiled. In general, this directory is most likely not a parallel file system. Therefore, the example code often fails. Solution: Add an option "-f " for specifying the correct test files pathname prefix. The program now requires an explicite file prefix either via the "-f" option or the environment variable $HDF5_PARAPREFIX. (With the proper setup of $HDF5_PARAPREFIX, the example code can run automatically in situtaions such as batch job or gmake check.) Also added feature to cleaup up the test files created. Of course, an added option "-c" to turn OFF the cleanup action. Platforms tested: eirene, modi4, dangermouse (all parallel modes). modi4 (serial) just to verify it can compile. --- examples/ph5example.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 126 insertions(+), 10 deletions(-) diff --git a/examples/ph5example.c b/examples/ph5example.c index 71802d8..9d2142d 100644 --- a/examples/ph5example.c +++ b/examples/ph5example.c @@ -11,10 +11,20 @@ * and the two datasets in it. Then each process reads a hyperslab from * each dataset in an independent mode and prints them out. * All processes collectively close the datasets and the file. + * + * The need of requirement of parallel file prefix is that in general + * the current working directory in which compiling is done, is not suitable + * for parallel I/O and there is no standard pathname for parallel file + * systems. In some cases, the parallel file name may even needs some + * parallel file type prefix such as: "pfs:/GF/...". Therefore, this + * example requires an explicite parallel file prefix. See the usage + * for more detail. */ #include #include "hdf5.h" +#include +#include #ifdef H5_HAVE_PARALLEL /* Temporary source code */ @@ -48,12 +58,19 @@ #define BYROW 1 /* divide into slabs of rows */ #define BYCOL 2 /* divide into blocks of columns */ +#define PARAPREFIX "HDF5_PARAPREFIX" /* file prefix environment variable name */ + /* dataset data type. Int's can be easily octo dumped. */ typedef int DATATYPE; /* global variables */ int nerrors = 0; /* errors count */ +#ifndef PATH_MAX +#define PATH_MAX 512 +#endif /* !PATH_MAX */ +char testfiles[2][PATH_MAX]; + int mpi_size, mpi_rank; /* mpi variables */ @@ -61,6 +78,7 @@ int mpi_size, mpi_rank; /* mpi variables */ int verbose = 0; /* verbose, default as no. */ int doread=1; /* read test */ int dowrite=1; /* write test */ +int docleanup=1; /* cleanup */ /* Prototypes */ void slab_set(hssize_t start[], hsize_t count[], hsize_t stride[], int mode); @@ -71,8 +89,11 @@ void phdf5writeInd(char *filename); void phdf5readInd(char *filename); void phdf5writeAll(char *filename); void phdf5readAll(char *filename); -void test_split_comm_access(char *filenames[]); +void test_split_comm_access(char filenames[][PATH_MAX]); int parse_options(int argc, char **argv); +void usage(void); +int mkfilenames(char *prefix); +void cleanup(void); /* @@ -826,7 +847,7 @@ if (verbose) * sooner or later due to barrier mixed up. */ void -test_split_comm_access(char *filenames[]) +test_split_comm_access(char filenames[][PATH_MAX]) { MPI_Comm comm; MPI_Info info = MPI_INFO_NULL; @@ -884,7 +905,11 @@ test_split_comm_access(char *filenames[]) void usage() { - printf("Usage: testphdf5 [-r] [-w] [-v]\n"); + printf("Usage: testphdf5 -f [-r] [-w] [-v]\n"); + printf("\t-f\tfile prefix for parallel test files.\n"); + printf("\t \te.g. pfs:/PFS/myname\n"); + printf("\t \tcan be set via $" PARAPREFIX ".\n"); + printf("\t-c\tno cleanup\n"); printf("\t-r\tno read\n"); printf("\t-w\tno write\n"); printf("\t-v\tverbose on\n"); @@ -894,15 +919,68 @@ usage() /* + * compose the test filename with the prefix supplied. + * return code: 0 if no error + * 1 otherwise. + */ +int +mkfilenames(char *prefix) +{ + int i, n; + size_t strsize; + + /* filename will be prefix/ParaEgN.h5 where N is 0 to 9. */ + /* So, string must be big enough to hold the prefix, / and 10 more chars */ + /* and the terminating null. */ + strsize = strlen(prefix) + 12; + if (strsize > PATH_MAX){ + printf("File prefix too long; Use a short path name.\n"); + return(1); + } + n = sizeof(testfiles)/sizeof(testfiles[0]); + if (n > 9){ + printf("Warning: Too many entries in testfiles. " + "Need to adjust the code to accommodate the large size.\n"); + } + for (i=0; i