7.5. Startup


Up: MPI Environmental Management Next: Profiling Interface Previous: Timers and synchronization

One goal of MPI is to achieve source code portability. By this we mean that a program written using MPI and complying with the relevant language standards is portable as written, and must not require any source code changes when moved from one system to another. This explicitly does not say anything about how an MPI program is started or launched from the command line, nor what the user must do to set up the environment in which an MPI program will run. However, an implementation may require some setup to be performed before other MPI routines may be called. To provide for this, MPI includes an initialization routine MPI_INIT.

MPI_INIT()

int MPI_Init(int *argc, char ***argv)

MPI_INIT(IERROR)
INTEGER IERROR

This routine must be called before any other MPI routine. It must be called at most once; subsequent calls are erroneous (see MPI_INITIALIZED).

All MPI programs must contain a call to MPI_INIT; this routine must be called before any other MPI routine (apart from MPI_INITIALIZED) is called. The version for ANSI C accepts the argc and argv that are provided by the arguments to main:

int main(argc, argv) 
int argc; 
char **argv; 
{ 
    MPI_Init(&argc, &argv); 

/* parse arguments */ /* main program */

MPI_Finalize(); /* see below */ }

The Fortran version takes only IERROR.

An MPI implementation is free to require that the arguments in the C binding must be the arguments to main.


[] Rationale.

The command line arguements are provided to MPI_Init to allow an MPI implementation to use them in initializing the MPI environment. They are passed by reference to allow an MPI implementation to provide them in environments where the command-line arguments are not provided to main. ( End of rationale.)

MPI_FINALIZE()

int MPI_Finalize(void)

MPI_FINALIZE(IERROR)
INTEGER IERROR

This routines cleans up all MPI state. Once this routine is called, no MPI routine (even MPI_INIT) may be called. The user must ensure that all pending communications involving a process completes before the process calls MPI_FINALIZE.

MPI_INITIALIZED( flag )
[ OUT flag] Flag is true if MPI_INIT has been called and false otherwise.

int MPI_Initialized(int *flag)

MPI_INITIALIZED(FLAG, IERROR)
LOGICAL FLAG
INTEGER IERROR

This routine may be used to determine whether MPI_INIT has been called. It is the only routine that may be called before MPI_INIT is called.

MPI_ABORT( comm, errorcode )
[ IN comm] communicator of tasks to abort
[ IN errorcode] error code to return to invoking environment

int MPI_Abort(MPI_Comm comm, int errorcode)

MPI_ABORT(COMM, ERRORCODE, IERROR)
INTEGER COMM, ERRORCODE, IERROR

This routine makes a ``best attempt'' to abort all tasks in the group of comm. This function does not require that the invoking environment take any action with the error code. However, a Unix or POSIX environment should handle this as a return errorcode from the main program or an abort(errorcode).

MPI implementations are required to define the behavior of MPI_ABORT at least for a comm of MPI_COMM_WORLD. MPI implementations may ignore the comm argument and act as if the comm was MPI_COMM_WORLD.


[] Rationale.

The communicator argument is provided to allow for future extensions of MPI to environments with, for example, dynamic process management. In particular, it allows but does not require an MPI implementation to abort a subset of MPI_COMM_WORLD. ( End of rationale.)



Up: MPI Environmental Management Next: Profiling Interface Previous: Timers and synchronization


Return to MPI 1.1 Standard Index
Return to MPI-2 Standard Index
Return to MPI Forum Home Page

MPI-1.1 of June 12, 1995
HTML Generated on August 6, 1997