10.3.1. Error Handlers for Communicators

PreviousUpNext
Up: Error Handling Next: Error Handlers for Windows Previous: Error Handling

MPI_COMM_CREATE_ERRHANDLER(comm_errhandler_fn, errhandler)
IN comm_errhandler_fnuser defined error handling procedure (function)
OUT errhandler MPI error handler (handle)
C binding
int MPI_Comm_create_errhandler(MPI_Comm_errhandler_function *comm_errhandler_fn, MPI_Errhandler *errhandler)
Fortran 2008 binding
MPI_Comm_create_errhandler(comm_errhandler_fn, errhandler, ierror)

PROCEDURE(MPI_Comm_errhandler_function) :: comm_errhandler_fn
TYPE(MPI_Errhandler), INTENT(OUT) :: errhandler
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_COMM_CREATE_ERRHANDLER(COMM_ERRHANDLER_FN, ERRHANDLER, IERROR)

EXTERNAL COMM_ERRHANDLER_FN
INTEGER ERRHANDLER, IERROR

Creates an error handler that can be attached to communicators.

The user routine should be, in C, a function of type MPI_Comm_errhandler_function, which is defined as

typedef void MPI_Comm_errhandler_function(MPI_Comm *comm, int *error_code, ...);

The first argument is the communicator in use. The second is the error code to be returned by the MPI routine that raised the error. If the routine would have returned MPI_ERR_IN_STATUS, it is the error code returned in the status for the request that caused the error handler to be invoked. The remaining arguments are ``varargs'' arguments whose number and meaning is implementationdependent. An implementation should clearly document these arguments. Addresses are used so that the handler may be written in Fortran.

With the Fortran mpi_f08 module, the user routine comm_errhandler_fn should be of the form:

ABSTRACT INTERFACE
    SUBROUTINE MPI_Comm_errhandler_function(comm, error_code)

TYPE(MPI_Comm) :: comm
INTEGER :: error_code

With the Fortran mpi module and (deprecated) mpif.h include file, the user routine COMM_ERRHANDLER_FN should be of the form:

SUBROUTINE COMM_ERRHANDLER_FUNCTION(COMM, ERROR_CODE)

INTEGER COMM, ERROR_CODE


Rationale.

The variable argument list is provided because it provides an ISO-standard hook for providing additional information to the error handler; without this hook, ISO C prohibits additional arguments. ( End of rationale.)

Advice to users.

A newly created communicator inherits the error handler that is associated with the ``parent'' communicator. In particular, the user can specify a ``global'' error handler for all communicators by associating this handler with the communicator MPI_COMM_WORLD immediately after initialization. ( End of advice to users.)

MPI_COMM_SET_ERRHANDLER(comm, errhandler)
INOUT commcommunicator (handle)
IN errhandlernew error handler for communicator (handle)
C binding
int MPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler)
Fortran 2008 binding
MPI_Comm_set_errhandler(comm, errhandler, ierror)

TYPE(MPI_Comm), INTENT(IN) :: comm
TYPE(MPI_Errhandler), INTENT(IN) :: errhandler
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_COMM_SET_ERRHANDLER(COMM, ERRHANDLER, IERROR)

INTEGER COMM, ERRHANDLER, IERROR

Attaches a new error handler to a communicator. The error handler must be either a predefined error handler, or an error handler created by a call to MPI_COMM_CREATE_ERRHANDLER.

MPI_COMM_GET_ERRHANDLER(comm, errhandler)
IN commcommunicator (handle)
OUT errhandlererror handler currently associated with communicator (handle)
C binding
int MPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler *errhandler)
Fortran 2008 binding
MPI_Comm_get_errhandler(comm, errhandler, ierror)

TYPE(MPI_Comm), INTENT(IN) :: comm
TYPE(MPI_Errhandler), INTENT(OUT) :: errhandler
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_COMM_GET_ERRHANDLER(COMM, ERRHANDLER, IERROR)

INTEGER COMM, ERRHANDLER, IERROR

Retrieves the error handler currently associated with a communicator. For example, a library function may register at its entry point the current error handler for a communicator, set its own private error handler for this communicator, and restore before exiting the previous error handler.


PreviousUpNext
Up: Error Handling Next: Error Handlers for Windows Previous: Error Handling


Return to MPI-4.1 Standard Index
Return to MPI Forum Home Page

(Unofficial) MPI-4.1 of November 2, 2023
HTML Generated on November 19, 2023