390. Prototype Definitions

PreviousUpNext
Up: Defined Values and Handles Next: C Bindings Previous: Types


PreviousUpNext
Up: Defined Values and Handles Next: C Bindings Previous: Types


390.1. C Bindings

PreviousUpNext
Up: Prototype Definitions Next: Fortran 2008 Bindings with the mpi_f08 Module Previous: Prototype Definitions

The following are defined C typedefs for user-defined functions, also included in the file mpi.h.

Image file


PreviousUpNext
Up: Prototype Definitions Next: Fortran 2008 Bindings with the mpi_f08 Module Previous: Prototype Definitions


390.2. Fortran 2008 Bindings with the mpi_f08 Module

PreviousUpNext
Up: Prototype Definitions Next: Fortran Bindings with mpif.h or the mpi Module Previous: C Bindings

The callback prototypes when using the Fortran mpi_f08 module are shown below:

The user-function argument to MPI_Op_create should be declared according to:

SUBROUTINE MPI_User_function(invec, inoutvec, len, datatype)
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
TYPE(C_PTR), VALUE :: invec, inoutvec
INTEGER :: len
TYPE(MPI_Datatype) :: datatype

The copy and delete function arguments to MPI_Comm_create_keyval should be declared according to:

SUBROUTINE MPI_Comm_copy_attr_function(oldcomm, comm_keyval, extra_state, attribute_val_in, attribute_val_out, flag, ierror)
TYPE(MPI_Comm) :: oldcomm
INTEGER :: comm_keyval, ierror
INTEGER(KIND=MPI_ADDRESS_KIND) :: extra_state, attribute_val_in, attribute_val_out
LOGICAL :: flag
SUBROUTINE MPI_Comm_delete_attr_function(comm, comm_keyval, attribute_val, extra_state, ierror)
TYPE(MPI_Comm) :: comm
INTEGER :: comm_keyval, ierror
INTEGER(KIND=MPI_ADDRESS_KIND) :: attribute_val, extra_state

The copy and delete function arguments to MPI_Win_create_keyval should be declared according to:

SUBROUTINE MPI_Win_copy_attr_function(oldwin, win_keyval, extra_state, attribute_val_in, attribute_val_out, flag, ierror)
TYPE(MPI_Win) :: oldwin
INTEGER :: win_keyval, ierror
INTEGER(KIND=MPI_ADDRESS_KIND) :: extra_state, attribute_val_in, attribute_val_out
LOGICAL :: flag
SUBROUTINE MPI_Win_delete_attr_function(win, win_keyval, attribute_val, extra_state, ierror)
TYPE(MPI_Win) :: win
INTEGER :: win_keyval, ierror
INTEGER(KIND=MPI_ADDRESS_KIND) :: attribute_val, extra_state

The copy and delete function arguments to MPI_Type_create_keyval should be declared according to:

SUBROUTINE MPI_Type_copy_attr_function(oldtype, type_keyval, extra_state, attribute_val_in, attribute_val_out, flag, ierror)
TYPE(MPI_Datatype) :: oldtype
INTEGER :: type_keyval, ierror
INTEGER(KIND=MPI_ADDRESS_KIND) :: extra_state, attribute_val_in, attribute_val_out
LOGICAL :: flag
SUBROUTINE MPI_Type_delete_attr_function(datatype, type_keyval, attribute_val, extra_state, ierror)
TYPE(MPI_Datatype) :: datatype
INTEGER :: type_keyval, ierror
INTEGER(KIND=MPI_ADDRESS_KIND) :: attribute_val, extra_state

The handler-function argument to MPI_Comm_create_errhandler should be declared like this:

SUBROUTINE MPI_Comm_errhandler_function(comm, error_code)
TYPE(MPI_Comm) :: comm
INTEGER :: error_code

The handler-function argument to MPI_Win_create_errhandler should be declared like this:

SUBROUTINE MPI_Win_errhandler_function(win, error_code)
TYPE(MPI_Win) :: win
INTEGER :: error_code

The handler-function argument to MPI_File_create_errhandler should be declared like this:

SUBROUTINE MPI_File_errhandler_function(file, error_code)
TYPE(MPI_File) :: file
INTEGER :: error_code

The query, free, and cancel function arguments to MPI_Grequest_start should be declared according to:

SUBROUTINE MPI_Grequest_query_function(extra_state, status, ierror)
TYPE(MPI_Status) :: status
INTEGER :: ierror
INTEGER(KIND=MPI_ADDRESS_KIND) :: extra_state
SUBROUTINE MPI_Grequest_free_function(extra_state, ierror)
INTEGER :: ierror
INTEGER(KIND=MPI_ADDRESS_KIND) :: extra_state
SUBROUTINE MPI_Grequest_cancel_function(extra_state, complete, ierror)
INTEGER :: ierror
INTEGER(KIND=MPI_ADDRESS_KIND) :: extra_state
LOGICAL :: complete

The extent and conversion function arguments to MPI_Register_datarep should be declared according to:

SUBROUTINE MPI_Datarep_extent_function(datatype, extent, extra_state, ierror)
TYPE(MPI_Datatype) :: datatype
INTEGER(KIND=MPI_ADDRESS_KIND) :: extent, extra_state
INTEGER :: ierror

SUBROUTINE MPI_Datarep_conversion_function(userbuf, datatype, count, filebuf, position, extra_state, ierror)
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
TYPE(C_PTR), VALUE :: userbuf, filebuf
TYPE(MPI_Datatype) :: datatype
INTEGER :: count, ierror
INTEGER(KIND=MPI_OFFSET_KIND) :: position
INTEGER(KIND=MPI_ADDRESS_KIND) :: extra_state


PreviousUpNext
Up: Prototype Definitions Next: Fortran Bindings with mpif.h or the mpi Module Previous: C Bindings


390.3. Fortran Bindings with mpif.h or the mpi Module

PreviousUpNext
Up: Prototype Definitions Next: Deprecated Prototype Definitions Previous: Fortran 2008 Bindings with the mpi_f08 Module

With the Fortran mpi module or mpif.h, here are examples of how each of the user-defined subroutines should be declared.

The user-function argument to MPI_OP_CREATE should be declared like this:

SUBROUTINE USER_FUNCTION(INVEC, INOUTVEC, LEN, DATATYPE) 
   <type> INVEC(LEN), INOUTVEC(LEN) 
   INTEGER LEN, DATATYPE 
The copy and delete function arguments to MPI_COMM_CREATE_KEYVAL should be declared like these:


SUBROUTINE COMM_COPY_ATTR_FUNCTION(OLDCOMM, COMM_KEYVAL, EXTRA_STATE, 
             ATTRIBUTE_VAL_IN, ATTRIBUTE_VAL_OUT, FLAG, IERROR) 
   INTEGER OLDCOMM, COMM_KEYVAL, IERROR 
   INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATE, ATTRIBUTE_VAL_IN, 
             ATTRIBUTE_VAL_OUT 
   LOGICAL FLAG 
 
SUBROUTINE COMM_DELETE_ATTR_FUNCTION(COMM, COMM_KEYVAL, ATTRIBUTE_VAL, 
             EXTRA_STATE, IERROR) 
   INTEGER COMM, COMM_KEYVAL, IERROR 
   INTEGER(KIND=MPI_ADDRESS_KIND) ATTRIBUTE_VAL, EXTRA_STATE 
The copy and delete function arguments to MPI_WIN_CREATE_KEYVAL should be declared like these:


SUBROUTINE WIN_COPY_ATTR_FUNCTION(OLDWIN, WIN_KEYVAL, EXTRA_STATE, 
             ATTRIBUTE_VAL_IN, ATTRIBUTE_VAL_OUT, FLAG, IERROR) 
   INTEGER OLDWIN, WIN_KEYVAL, IERROR 
   INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATE, ATTRIBUTE_VAL_IN, 
             ATTRIBUTE_VAL_OUT 
   LOGICAL FLAG 
 
SUBROUTINE WIN_DELETE_ATTR_FUNCTION(WIN, WIN_KEYVAL, ATTRIBUTE_VAL, 
             EXTRA_STATE, IERROR) 
   INTEGER WIN, WIN_KEYVAL, IERROR 
   INTEGER(KIND=MPI_ADDRESS_KIND) ATTRIBUTE_VAL, EXTRA_STATE 
The copy and delete function arguments to MPI_TYPE_CREATE_KEYVAL should be declared like these:


SUBROUTINE TYPE_COPY_ATTR_FUNCTION(OLDTYPE, TYPE_KEYVAL, EXTRA_STATE, 
              ATTRIBUTE_VAL_IN, ATTRIBUTE_VAL_OUT, FLAG, IERROR) 
   INTEGER OLDTYPE, TYPE_KEYVAL, IERROR 
   INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATE, 
              ATTRIBUTE_VAL_IN, ATTRIBUTE_VAL_OUT 
   LOGICAL FLAG 
 
SUBROUTINE TYPE_DELETE_ATTR_FUNCTION(DATATYPE, TYPE_KEYVAL, ATTRIBUTE_VAL, 
              EXTRA_STATE, IERROR) 
   INTEGER DATATYPE, TYPE_KEYVAL, IERROR 
   INTEGER(KIND=MPI_ADDRESS_KIND) ATTRIBUTE_VAL, EXTRA_STATE 
The handler-function argument to MPI_COMM_CREATE_ERRHANDLER should be declared like this:


SUBROUTINE COMM_ERRHANDLER_FUNCTION(COMM, ERROR_CODE) 
   INTEGER COMM, ERROR_CODE 
The handler-function argument to MPI_WIN_CREATE_ERRHANDLER should be declared like this:


SUBROUTINE WIN_ERRHANDLER_FUNCTION(WIN, ERROR_CODE)  
   INTEGER WIN, ERROR_CODE 
The handler-function argument to MPI_FILE_CREATE_ERRHANDLER should be declared like this:


SUBROUTINE FILE_ERRHANDLER_FUNCTION(FILE, ERROR_CODE) 
   INTEGER FILE, ERROR_CODE 
The query, free, and cancel function arguments to MPI_GREQUEST_START should be declared like these:


SUBROUTINE GREQUEST_QUERY_FUNCTION(EXTRA_STATE, STATUS, IERROR) 
   INTEGER STATUS(MPI_STATUS_SIZE), IERROR 
   INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATE 
  
SUBROUTINE GREQUEST_FREE_FUNCTION(EXTRA_STATE, IERROR) 
   INTEGER IERROR 
   INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATE 
  
SUBROUTINE GREQUEST_CANCEL_FUNCTION(EXTRA_STATE, COMPLETE, IERROR) 
   INTEGER IERROR 
   INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATE 
   LOGICAL COMPLETE 
The extent and conversion function arguments to MPI_REGISTER_DATAREP should be declared like these:


SUBROUTINE DATAREP_EXTENT_FUNCTION(DATATYPE, EXTENT, EXTRA_STATE, IERROR) 
    INTEGER DATATYPE, IERROR  
    INTEGER(KIND=MPI_ADDRESS_KIND) EXTENT, EXTRA_STATE 
  
SUBROUTINE DATAREP_CONVERSION_FUNCTION(USERBUF, DATATYPE, COUNT, FILEBUF,  
             POSITION, EXTRA_STATE, IERROR) 
    <TYPE> USERBUF(*), FILEBUF(*)  
    INTEGER COUNT, DATATYPE, IERROR  
    INTEGER(KIND=MPI_OFFSET_KIND) POSITION  
    INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATE 


PreviousUpNext
Up: Prototype Definitions Next: Deprecated Prototype Definitions Previous: Fortran 2008 Bindings with the mpi_f08 Module


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

(Unofficial) MPI-3.1 of June 4, 2015
HTML Generated on June 4, 2015