Required for all programs that make MPI library calls.
C include file | Fortran include file |
---|---|
#include "mpi.h" | include 'mpif.h' |
With MPI-3 Fortran, the USE mpi_f08
module is preferred over using the include file shown above.
C names are case sensitive; Fortran names are not.
Programs must not declare variables or functions with names beginning with the prefix MPI_
or PMPI_
(profiling interface).
C Binding | |
---|---|
Format: | rc = MPI_Xxxxx(parameter, ... ) |
Example: | rc = MPI_Bsend(&buf,count,type,dest,tag,comm) |
Error code: | Returned as "rc". MPI_SUCCESS if successful |
Fortran Binding | |
Format: | CALL MPI_XXXXX(parameter,..., ierr) call mpi_xxxxx(parameter,..., ierr) |
Example: | CALL MPI_BSEND(buf,count,type,dest,tag,comm,ierr) |
Error code: | Returned as "ierr" parameter. MPI_SUCCESS if successful |
MPI uses objects called communicators and groups to define which collection of processes may communicate with each other.
Most MPI routines require you to specify a communicator as an argument.
Communicators and groups will be covered in more detail later. For now, simply use MPI_COMM_WORLD
whenever a communicator is required - it is the predefined communicator that includes all of your MPI processes.
Within a communicator, every process has its own unique, integer identifier assigned by the system when the process initializes. A rank is sometimes also called a “task ID”. Ranks are contiguous and begin at zero.
Used by the programmer to specify the source and destination of messages. Often used conditionally by the application to control program execution (if rank=0 do this / if rank=1 do that).
Most MPI routines include a return/error code parameter, as described in the “Format of MPI Calls” section above.
However, according to the MPI standard, the default behavior of an MPI call is to abort if there is an error. This means you will probably not be able to capture a return/error code other than MPI_SUCCESS (zero).
The standard does provide a means to override this default error handler. A discussion on how to do this is available HERE. You can also consult the error handling section of the relevant MPI Standard documentation located at http://www.mpi-forum.org/docs/.
The types of errors displayed to the user are implementation dependent.