cc_staff
153
edits
m (Add Fortran 2008 tabs) |
m (Fortran 2008 updates) |
||
Line 104: | Line 104: | ||
=== Framework === <!--T:18--> | === Framework === <!--T:18--> | ||
Each MPI program must include the relevant header file (<tt>mpi.h</tt> for C/C++, <tt>mpif.h</tt> for Fortran), and be compiled and linked against the desired MPI implementation. Most MPI implementations provide a handy script, often called a ''compiler wrapper'', that handles all set-up issues with respect to <code>include</code> and <code>lib</code> directories, linking flags, ''etc.'' Our examples will all use these compiler wrappers: | Each MPI program must include the relevant header file or use the relevant module (<tt>mpi.h</tt> for C/C++, <tt>mpif.h</tt>, <tt>use mpi</tt>, or <tt>use mpi_f08</tt> for Fortran, where <tt>mpif.h</tt> is strongly discouraged and <tt>mpi_f08</tt> recommended for new Fortran 2008 code), and be compiled and linked against the desired MPI implementation. Most MPI implementations provide a handy script, often called a ''compiler wrapper'', that handles all set-up issues with respect to <code>include</code> and <code>lib</code> directories, linking flags, ''etc.'' Our examples will all use these compiler wrappers: | ||
* C language wrapper: <tt>mpicc</tt> | * C language wrapper: <tt>mpicc</tt> | ||
* Fortran: <tt>mpif90</tt> | * Fortran: <tt>mpif90</tt> | ||
Line 138: | Line 138: | ||
<translate> | <translate> | ||
<!--T:20--> | <!--T:20--> | ||
The arguments to the C <code>MPI_Init</code> are pointers to the <code>argc</code> and <code>argv</code> variables that represent the command-line arguments to the program. Like all C MPI functions, the return value represents the error status of the function. Fortran MPI subroutines return the error status in an additional argument, <code>IERR</code>. | The arguments to the C <code>MPI_Init</code> are pointers to the <code>argc</code> and <code>argv</code> variables that represent the command-line arguments to the program. Like all C MPI functions, the return value represents the error status of the function. Fortran MPI subroutines return the error status in an additional argument, <code>IERR</code>, which is optional if you <tt>use mpi_f08</tt>. | ||
<!--T:21--> | <!--T:21--> | ||
Line 268: | Line 268: | ||
MPI_COMM_RANK(COMM, RANK, IERR) | MPI_COMM_RANK(COMM, RANK, IERR) | ||
INTEGER :: COMM, RANK, IERR | INTEGER :: COMM, RANK, IERR | ||
</source> | |||
</tab> | |||
<tab name="Fortran 2008"> | |||
<source lang="fortran"> | |||
MPI_Comm_size(comm, size, ierr) | |||
TYPE(MPI_Comm), INTENT(IN) :: comm | |||
INTEGER, INTENT(OUT) :: size | |||
INTEGER, OPTIONAL, INTENT(OUT) :: ierr | |||
MPI_Comm_rank(comm, rank, ierr) | |||
TYPE(MPI_Comm), INTENT(IN) :: comm | |||
INTEGER, INTENT(OUT) :: rank | |||
INTEGER, OPTIONAL, INTENT(OUT) :: ier | |||
</source> | </source> | ||
</tab> | </tab> |