Fortran


Up: Configuring mpich Next: What if there is no Fortran compiler? Previous: Preparing mpich for TotalView debugging

Mpich provides support for both Fortran 77 and Fortran 90. Because mpich is implemented in C, using mpich from Fortran can sometimes require special options. This section discusses some of the issues.



Up: Configuring mpich Next: What if there is no Fortran compiler? Previous: Preparing mpich for TotalView debugging


What if there is no Fortran compiler?


Up: Fortran Next: Fortran 90 Previous: Fortran

The configure program should discover that there is no Fortran compiler. You can force configure to not build the Fortran parts of the code with the option -disable-f77. In this case, only the C programs will be built and tested.



Up: Fortran Next: Fortran 90 Previous: Fortran


Fortran 90


Up: Fortran Next: Fortran 77 and Fortran 90 Previous: What if there is no Fortran compiler?

During configuration, a number of F90-specific arguments can be specified. See the output of configure -help. In particular, when using the NAG Fortran 90 compiler, you whould specify -f90nag.



Up: Fortran Next: Fortran 77 and Fortran 90 Previous: What if there is no Fortran compiler?


Fortran 77 and Fortran 90


Up: Fortran Next: Fortran 90 Modules Previous: Fortran 90

Selecting Fortran 90 with Fortran 77 should be done only when the two compilers are compatible, supporting the same datatypes and calling conventions. In particular, if the Fortran 90 compiler supports an 8-byte integer type, the Fortran 77 compiler must support integer*8 (this is needed by the MPI-IO routines for the MPI_OFFSET_KIND values). In addition, both compilers must support the same functions for accessing the command line, and the code for those commands must reside in the same library. If the two Fortran compilers are not compatible, you should either select the Fortran 90 compiler as both the Fortran 77 and Fortran 90 compiler (relying on the upward compatibility of Fortran), or build two separate configurations of mpich. For example,

  configure -fc=f90 -f90=f90 

will use f90 for both Fortran 77 and Fortran 90 programs. In many systems, this will work well. If there are reasons to have separate Fortran 90 and Fortran 77 builds, then execute the following commands (where mpich is to be installed into the directory /usr/local):
  configure -fc=f77 --disable-f90 -prefix=/usr/local/mpich-1.2/f77-nof90 

  make 

  make install 

configure -fc=f90 -f90=f90 -prefix=/usr/local/mpich-1.2/f90 make make install

This sequence of commands will build and install two versions of mpich.



Up: Fortran Next: Fortran 90 Modules Previous: Fortran 90


Fortran 90 Modules


Up: Fortran Next: Configuring with the Absoft Fortran Compiler Previous: Fortran 77 and Fortran 90

If configure finds a Fortran 90 compiler, by default mpich will try to create a Fortran 90 module. In fact, it will create two versions of an mpi module: one that includes only the MPI routines that do not take ``choice'' arguments and one that does include choice argument. A choice argument is an argument that can take any datatype; typically, these are the buffers in MPI communication routines such as MPI_Send and MPI_Recv.

The two different modules can be accessed with the -nochoice and -choice option to mpif90 respectively. The choice version of the module supports a limited set of datatypes (numeric scalars and numeric one- and two-dimensional arrays). This is an experimental feature; please send mail to mpi-bugs@mcs.anl.gov if you have any trouble.

The reason for having two versions of the MPI module is that it is very difficult to provide a completely correct module that includes all of the functions with choice arguments. As it is, on many systems, the size of the Fortran 90 module to handle the routines with choice arguments will be larger than the entire C version of the MPI library. If you are uninterested in the Fortran 90 MPI module, or you wish to keep the installed version of mpich small, you can turn off the creation of the Fortran 90 MPI module with the configure option --disable-f90modules.



Up: Fortran Next: Configuring with the Absoft Fortran Compiler Previous: Fortran 77 and Fortran 90


Configuring with the Absoft Fortran Compiler


Up: Fortran Next: Configuring for Multiple Fortran Compilers Previous: Fortran 90 Modules

The Absoft compiler can be told to generate external symbols that are uppercase, lowercase, and lowercase with a trailing underscore (the most common case for other Unix Fortran compilers), or use mixed case (an extension of Fortran, which is only monocase). Each of these choices requires a separate mpich configure and build step. Mpich has been tested in the mode where monocase names are generated; this case is supported because only this case supports common (and necessary for mpich) extensions such as getarg and iargc. By default, mpich forces the Absoft compiler to use lowercase; this matches most Unix Fortran compilers. Mpich will find the appropriate versions of getarg and iargc for this case. Because the examples and the test suite assume that the Fortran compiler is case-insensitive; the Fortran library produced by mpich will only work with source code that uses monocase (either upper or lower) for all MPI calls.

In addition, you may need to use -N90 if you use character data, because the mpich Fortran interface expects the calling convention used by virtually all Unix Fortran systems (Cray UNICOS is handled separately). If you are building shared libraries, you will also need to set the environment variable FC_SHARED_OPT to none.

Early versions of the Absoft compiler could not handle multiple -I options. If you have trouble with this, you should get an update from Absoft.



Up: Fortran Next: Configuring for Multiple Fortran Compilers Previous: Fortran 90 Modules


Configuring for Multiple Fortran Compilers


Up: Fortran Next: Special issues for heterogeneous networks Previous: Configuring with the Absoft Fortran Compiler

In some environments, there are several different Fortran compilers, all of which define Fortran datatypes of the same size, and which can be used with the same C libraries. These compilers may make different choices for Fortran name mappings (e.g., the external format of the names given to the linker) and use different approaches to access the command line. This section describes how to configure mpich to support multiple Fortran compilers. However, if any of these steps fails, the best approach is to build a separate mpich installation for each Fortran compiler.

The first step is to configure mpich with the --with-flibname option. For example, if one of the compilers is g77, use

    ./configure -fc=g77 --with-flibname=mpich-g77 ... other options ... 

After you build, test, and install this version of mpich, you can configure support for additional Fortran compilers as follows:
    1. Change directory to src/fortran
    2. Execute
        setenv F77 pgf77 
    
        ./configure --with-mpichconfig --with-flibname=mpich-pgf77  
    
        make 
    
        make install-alt 
    
    
To use a particular Fortran compiler, either select it on the mpif77 command line with the -config=name option (e.g., -config=pgf77) or by selecting a particular mpif77 command (e.g., mpif77-pgf77.



Up: Fortran Next: Special issues for heterogeneous networks Previous: Configuring with the Absoft Fortran Compiler