Commands for compiling and linking programs


Up: The mpich Programming Environment Next: mpireconfig, a way to create Makefiles Previous: mpirun, a Portable Startup Script

The mpich implementation provides two commands for compiling and linking C, C++, Fortran-77, and Fortran-90 programs. You may use these commands instead of the Makefile.in versions, particularly for programs contained in a small number of files. In addition, they have a simple interface to the profiling and visualization libraries described in [14]. This is a program to compile or link MPI programs. In addition, the following special options are supported:

-mpilog
Build version that generates MPE log files.
-mpitrace
Build version that generates traces.
-mpianim
Build version that generates real-time animation.
-show
Show the commands that would be used without actually running them.

Use this just like the usual compilers. For example,
    mpicc -c foo.c  

    mpiCC -c foo.C 

    mpif77 -c foo.f 

    mpif90 -c foo.f90 

and
    mpicc -o foo foo.o 

    mpiCC -o foo foo.o 

    mpif77 -o foo foo.o 

    mpif90 -o foo foo.o 

Note that for Fortran 90, different systems may require different suffixes. For example, AIX systems do not support f90 as a file suffix for Fortran 90 programs.

Commands for the linker may include additional libraries. For example, to use some routines from the MPE library, enter

    mpicc -o foo foo.o -lmpe 

Combining compilation and linking in a single command, as shown here,
    mpicc -o foo foo.c 

    mpiCC -o foo foo.C 

    mpif77 -o foo foo.f 

    mpif90 -o foo foo.f90 

may not work on some systems, and is not recommended.

You can override the choice of compiler by specifying the environment variable MPICH_CC, MPICH_F77, MPICH_CCC, or MPICH_F90. However, be warned that this will work only if the alternate compiler is compatible with the default one (by compatible, we mean that is uses the same sizes for all datatypes and layouts, and generates object code that can be used with the mpich libraries). If you wish to override the linker, use the environment variables MPICH_CLINKER, MPICH_F77LINKER, MPICH_CCLINKER, or MPICH_F90LINKER.



Up: The mpich Programming Environment Next: mpireconfig, a way to create Makefiles Previous: mpirun, a Portable Startup Script