summaryrefslogtreecommitdiffstats
path: root/testpar/testphdf5.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>1999-06-30 22:04:22 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>1999-06-30 22:04:22 (GMT)
commit76ca6e67a7d5e395d018bd97e4a9ad8a4d986311 (patch)
tree8dfdb46f2b7d5d9eeea4857ad2dc950db95015ef /testpar/testphdf5.c
parentcc2be92e781c093f333e35742c4eda3141afced3 (diff)
downloadhdf5-76ca6e67a7d5e395d018bd97e4a9ad8a4d986311.zip
hdf5-76ca6e67a7d5e395d018bd97e4a9ad8a4d986311.tar.gz
hdf5-76ca6e67a7d5e395d018bd97e4a9ad8a4d986311.tar.bz2
[svn-r1398] Purpose:
new feature Makefile.in: Added the dependence of *.c on the testphdf5.h t_dset.c: testphdf5.c: testphdf5.h: testphdf5 now takes optional arguements for dataset dimension sizes. That allows testing with different dimension sizes without recompiling the whole thing. Platform tested: O2K
Diffstat (limited to 'testpar/testphdf5.c')
-rw-r--r--testpar/testphdf5.c59
1 files changed, 44 insertions, 15 deletions
diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c
index 70504f5..afbc9fb 100644
--- a/testpar/testphdf5.c
+++ b/testpar/testphdf5.c
@@ -7,6 +7,8 @@
#include <testphdf5.h>
/* global variables */
+int dim0 = DIM0;
+int dim1 = DIM1;
int nerrors = 0; /* errors count */
int verbose = 0; /* verbose, default as no. */
@@ -81,12 +83,14 @@ void pause_proc(MPI_Comm comm, int argc, char **argv)
void
usage(void)
{
- printf("Usage: testphdf5 [-r] [-w] [-v] [-f <prefix>]\n");
- printf("\t-f <prefix>\tfilename prefix\n");
+ printf("Usage: testphdf5 [-r] [-w] [-v] [-f <prefix>] [-d <dim0> <dim1>]\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("\t-f <prefix>\tfilename prefix\n");
+ printf("\t-d <dim0> <dim1>\tdataset dimensions\n");
+ printf("\tDefault: do write then read with dimensions %dx%d\n",
+ DIM0, DIM1);
printf("\n");
}
@@ -95,7 +99,13 @@ usage(void)
* parse the command line options
*/
int
-parse_options(int argc, char **argv){
+parse_options(int argc, char **argv)
+{
+ int mpi_size, mpi_rank; /* mpi variables */
+
+ MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
+
while (--argc){
if (**(++argv) != '-'){
break;
@@ -107,7 +117,7 @@ parse_options(int argc, char **argv){
break;
case 'v': verbose = 1;
break;
- case 'f': if (--argc <= 0) {
+ case 'f': if (--argc < 1) {
nerrors++;
return(1);
}
@@ -117,12 +127,39 @@ parse_options(int argc, char **argv){
}
fileprefix = *argv;
break;
+ case 'd': /* dimensizes */
+ if (--argc < 2){
+ nerrors++;
+ return(1);
+ }
+ dim0 = atoi(*(++argv));
+ argc--;
+ dim1 = atoi(*(++argv));
+ break;
+ case 'h': /* print help message--return with nerrors set */
+ return(1);
default: nerrors++;
return(1);
}
}
} /*while*/
+ /* check validity of dimension sizes */
+ if (dim0 <= 0 || dim1 <= 0){
+ printf("Illegal dim sizes (%d, %d)\n", dim0, dim1);
+ nerrors++;
+ return(1);
+ }
+
+ /* Make sure datasets can be divided into equal portions by the processes */
+ if ((dim0 % mpi_size) || (dim1 % mpi_size)){
+ if (MAINPROCESS)
+ printf("dim0(%d) and dim1(%d) must be multiples of processes(%d)\n",
+ dim0, dim1, mpi_size);
+ nerrors++;
+ return(1);
+ }
+
/* compose the filenames if file prefix is defined */
if (fileprefix != NULL) {
char *tmpptr;
@@ -161,21 +198,13 @@ main(int argc, char **argv)
printf("===================================\n");
}
- /* Make sure datasets can be divided into equal chunks by the processes */
- if ((DIM1 % mpi_size) || (DIM2 % mpi_size)){
- if (MAINPROCESS)
- printf("DIM1(%d) and DIM2(%d) must be multiples of processes(%d)\n",
- DIM1, DIM2, mpi_size);
- nerrors++;
- goto finish;
- }
-
#ifdef USE_PAUSE
pause_proc(MPI_COMM_WORLD, argc, argv);
#endif
if (parse_options(argc, argv) != 0){
- usage();
+ if (MAINPROCESS)
+ usage();
goto finish;
}