Command-Line Arguments and Standard I/O


Up: Toward a Portable Parallel Programming Environment Next: Support for Performance Analysis and Debugging Previous: The MPE Extension Library

The MPI standard says little about command-line arguments to programs, other than that in C they are to be passed to MPI_Init, which removes the command line arguments it recognizes. MPICH ensures that on each process, the command-line arguments returned from MPI_Init are the same on all processes, thus relieving the user of the necessity of broadcasting the command-line arguments to the rest of the processes from whichever process actually was passed them as arguments to main.

The MPI Standard also says little about I/O, other than that if at least one process has access to stdin, stdout, and stderr, the user can find out which process this is by querying the attribute MPI_IO on MPI_COMM_WORLD. In MPICH, all processes have access to stdin, stdout, and stderr, and on networks these I/O streams are routed back to the process with rank 0 in MPI_COMM_WORLD. On most systems, these streams also can be redirected through mpirun, as follows.

mpirun -np 64 myprog -myarg 13 < data.in > results.out 
Here we assume that ``-myarg 13'' are command-line arguments processed by the application myprog. After MPI_Init, each process will have these arguments in its argv. (This is an MPICH feature, not an MPI requirement.) On batch systems where stdin may not be available, one can use an argument to mpirun, as follows.
mpirun -np 64  -stdin data.in myprog -myarg 13 > results.out 
The latter form may always be used.



Up: Toward a Portable Parallel Programming Environment Next: Support for Performance Analysis and Debugging Previous: The MPE Extension Library