Synopsis
int MPI_Init(int *argc, char ***argv)
Input/Output Parameters
- argc
-
argc (None)
- argv
-
argv (None)
Description
MPI_Init initializes the MPI execution environment using the World Process Model.
This call creates an initial set of MPI processes related by their membership in the MPI_COMM_WORLD communicator. An MPI program using the World Process Model must contain exactly one call to MPI_INIT or MPI_INIT_THREAD, and subsequent calls to either initialization routine are erroneous. A call to MPI_Init has the same effect as a call to MPI_INIT_THREAD with MPI_THREAD_SINGLE. MPI_COMM_WORLD and MPI_COMM_SELF are not valid for use as communicators prior to invocation of MPI_INIT or MPI_INIT_THREAD. After MPI is initialized, the application can access information about the execution environment by querying the predefined info object MPI_INFO_ENV.
The C procedures accept either the argc and argv provided by the arguments to main or NULL. Failures in MPI operations prior to or during MPI initialization are reported by invoking the initial error handler; users may use the mpi_initial_errhandler info key during the launch of MPI processes to set a nonfatal initial error handler before MPI initialization.
Notes
The MPI standard does not say what a program can do before an MPI_INIT or
after an MPI_FINALIZE. In the MPICH implementation, you should do
as little as possible. In particular, avoid anything that changes the
external state of the program, such as opening files, reading standard
input or writing to standard output.
Thread Level
MPICH by default set thread level to MPI_THREAD_SINGLE. This can be changed
by setting MPIR_CVAR_DEFAULT_THREAD_LEVEL.
Thread and Signal Safety
This routine must be called by one thread only. That thread is called
the main thread and must be the thread that calls MPI_Finalize.
Notes for C
As of MPI-2, MPI_Init will accept NULL as input parameters. Doing so
will impact the values stored in MPI_INFO_ENV.
Notes for Fortran
The Fortran binding for MPI_Init has only the error return
subroutine MPI_INIT(ierr)
integer ierr
Notes for Fortran
All MPI routines in Fortran (except for 'MPI_WTIME' and 'MPI_WTICK') have an additional argument 'ierr' at the end of the argument list. 'ierr' is an integer and has the same meaning as the return value of the routine in C. In Fortran, MPI routines are subroutines, and are invoked with the 'call' statement.
All MPI objects (e.g., 'MPI_Datatype', 'MPI_Comm') are of type 'INTEGER' in Fortran.
Errors
All MPI routines (except 'MPI_Wtime' and 'MPI_Wtick') return an error value;
C routines as the value of the function and Fortran routines in the last
argument. Before the value is returned, the current MPI error handler is
called. By default, this error handler aborts the MPI job. The error handler
may be changed with 'MPI_Comm_set_errhandler' (for communicators),
'MPI_File_set_errhandler' (for files), and 'MPI_Win_set_errhandler' (for
RMA windows). The MPI-1 routine 'MPI_Errhandler_set' may be used but
its use is deprecated. The predefined error handler
'MPI_ERRORS_RETURN' may be used to cause error values to be returned.
Note that MPI does not guarantee that an MPI program can continue past
an error; however, MPI implementations will attempt to continue whenever
possible.
-
MPI_SUCCESS - No error; MPI routine completed successfully.
-
MPI_ERR_OTHER - Other error; use 'MPI_Error_string' to get more information about this error code.