|
This section takes you through compiling and linking csWMPI II applications
with different Fortran compilers. 32 and 64 bit versions of Fortran 77, 90
and 95 compilers from major vendors are fully supported, and since all
bindings are compiled directly into the csWMPI II binaries, there is a good
chance that other Fortran compilers are supported as well.
This section contains the steps necessary for compiling and linking programs Fotran 77 programs using csWMPI II:
- Include the files mpif.h and mpi_init.f
- Set the correct include path
- Link with the library csWMPI II2
Step 1: Include the files mpif.h and mpi_init.f
In order to use csWMPI II in Fortran 77 programs you MUST include the file
mpi_init.f before the program statement. Moreover, you should
include the file mpif.h after program statement. See the example
below:
...
include "mpi_init.f"
program main
implicit none
include 'mpif.h'
...
|
In case you do not include mpi_init.f you will experience
link errors.
Step 2: Set the correct include path
When compiling Fortran programs you must add the path in which the files
mpif.h and mpi_init.f are
located to the include path. In case you installed csWMPI II using the default
directories suggested by the install script, the directory is:
/usr/local/include/csWMPI II2/fortran
However, if you are using g77 or ifc,
then you should use the following directory:
/usr/local/include/csWMPI II2/fortran/gcc
For most compilers this can be adding the following switch when compiling/linking:
-I/usr/local/include/csWMPI II2/fortran
Or:
-I/usr/local/include/csWMPI II2/fortran/gcc
for g77 and ifc.
Step 3: Link with the library csWMPI II2
In order to link Fortran programs with the csWMPI II library:
csWMPI II2. The following
switch should be supplied with linking (or compiling and linking):
-lcsWMPI II2
Example:
g77 -o myapp myapp.f -I/usr/include/csWMPI II2/fortran/gcc -lcsWMPI II2
Some additional options might be necessary for your compiler. Please see the appropriate section below.
This section contains the steps necessary for compiling and linking programs Fotran 90 programs using csWMPI II:
- Include the file mpif.f90
- Set the correct include path
- Link with the library csWMPI II2
Step 1: Include the file mpif.f90
In the beginning of your source code file, simply include the file outside
any subroutine:
...
include "mpif.f90"
...
|
And you will be able to use the MPI Fortran 90 module and all the MPI calls
in your subroutines.
Step 2: Set the correct include path
When compiling Fortran programs you must add the path in which the file
mpif.f90 is located to the include path. In case
you installed csWMPI II using the default directories suggested by the install
script, the directory is:
/usr/local/include/csWMPI II2/fortran
For most compilers this can be adding the following switch when compiling/linking:
-I/usr/local/include/csWMPI II2/fortran
Step 3: Link with the library csWMPI II2
In order to link Fortran programs with the library csWMPI II2.
The following switch should be supplied with linking (or compiling and linking):
-lcsWMPI II2
Example (Lahey Fortran):
lf95 -o myapp myapp.f90 -I/usr/include/csWMPI II2/fortran -lcsWMPI II2
Some additional options might be necessary for your compiler. Please see the appropriate section below.
csWMPI II supports Intel's Fortran compiler ifc for both Fortran 77
and Fortran 90 programs. csWMPI II has been tested with version 7.1 of Intel's Fortran Compiler for Linux.
For Fortran 77 programs, the Intel compiler is rather pedantic and therefore it uses the same
header files as gcc/g77. If you have installed csWMPI II in the default installation directories the
include files for Fortran 77 programs can be found in:
/usr/include/csWMPI II2/fortran/gcc
Moreover, you will have to link with Intel's portability library, which is done by adding the
switch -Vaxlib when compiling.
Thus, if you want to compile the Fortran 77 Hello World example from command-line you have to
execute the following command:
ifc -o hello_world hello_world.f -I/usr/include/csWMPI II2/fortran/gcc -Vaxlib -lcsWMPI II2
Further more, you can add the -cm switch if you do not want the compiler to display comments.
For Fortran 90 programs you will have to supply the same set of switches as for Fortran 77 programs, however,
the include directory has to be changed to:
/usr/include/csWMPI II2/fortran
Thus, if you want to compile the Fortran 90 Hello World example from command-line you have to execute
the following command:
ifc -o hello_world hello_world.f90 -I/usr/include/csWMPI II2/fortran -Vaxlib -lcsWMPI II2
csWMPI II supports Absoft Fortran compiler f77/f90 for both Fortran 77
and Fortran 90 programs. csWMPI II has been tested with version 9.0 of Absoft Fortran for Linux.
Compiling Fortran 77 and 90 programs follow the same pattern and the same switches have to be used.
The include directory has to be set to:
/usr/include/csWMPI II2/fortran
Provided that you have installed csWMPI II in the default directories. Moreover, a compiler
specific library (U77) has to be linked into the executable. This is done by adding the switch
-lU77 when compiling. Thus, if you want to compile the Fortran 90
Hello World example from command-line you have to execute the following command:
f90 -o hello_world hello_world.f90 -I/usr/include/csWMPI II2/fortran -lU77 -lcsWMPI II2
And if you want to compile the Fortran 77 Hello World example from command-line you have to
execute the following command:
f77 -o hello_world hello_world.f -I/usr/include/csWMPI II2/fortran -lU77 -lcsWMPI II2
(Actually, the f90 can be used for both Fortran 77 and Fortran 90 programs.)
csWMPI II supports Lahey's Fortran compiler lf95 for both Fortran 77
and Fortran 90 programs. csWMPI II has been tested with version 6.20 of Lahey Fortran for Linux.
In order to compile Fortran programs with lf95 you have to add the
path of the csWMPI II Fortran header files. If you have installed csWMPI II in the default location the
include files can be found in:
/usr/include/csWMPI II2/fortran
Thus, if you want to compile the Fortran 90 Hello World example from command-line you have
to execute the following command:
lf95 -o hello_world hello_world.f90 -I/usr/include/csWMPI II2/fortran -lcsWMPI II2
And if you want to compile the Fortran 77 Hello World example from command-line you have to
execute the following command:
lf95 -o hello_world hello_world.f -I/usr/include/csWMPI II2/fortran -lcsWMPI II2
|