Aspects of the environment required for correct compilation and linking are encapsulated in the Makefiles produced when the user runs configure. Users may set up Makefile for their own applications by copying one from an MPI examples directory and modifying it as needed. The resultant Makefile may not be portable, but this may not be a primary consideration.
An even easier and more portable way to build a simple application, and one
that fits within existing complex Makefiles, is to use the commands
mpicc or mpif77, constructed in the MPICH bin directory by
configure. These scripts are used like the usual commands to invoke the C
and Fortran compilers and the linker. Extra arguments to these commands link
with the designated versions of profiling libraries. For example,
mpicc -c myprog.ccompiles a C program, automatically finding the include libraries that were configured when MPICH was installed. The command
mpif77 -mpilog -o myprog myprog.fcompiles and links a Fortran program that, when run, will produce a log file that can be examined with upshot. The command
mpicc -mpitrace -o myprog myprog.ccompiles and links a C program that displays a trace of its execution on stdout.
The mpirun command has already been mentioned. It has more flexibility
than we have described so far. In particular, in heterogeneous environments,
the command
mpirun -arch sun4 -np 4 -arch rs6000 -np 3 myprogstarts myprog on four Sun4's and three RS/6000's, where the specific hosts have been stored in MPICH's ``machines'' file.
Special arguments for the application program can be used to make MPICHprovide helpful debugging information. For example,
mpirun -np 4 myprog -mpedbg -mpiqueueautomatically installs the error handler described in Section Profiling Libraries that starts dbx on errors, and display all message queues when MPI_Finalize is called. This latter option is useful in locating ``lost'' messages.
Details on all of these commands can be found in the user's guide [27].