2016-11-22 15:03:20 -08:00
|
|
|
! -*- f90 -*-
|
|
|
|
! Copyright (c) 2009-2013 Cisco Systems, Inc. All rights reserved.
|
|
|
|
! Copyright (c) 2009-2012 Los Alamos National Security, LLC.
|
|
|
|
! All rights reserved.
|
mpi/fortran: use conformant dummy names for Fortran bindings
The MPI spec defines that the "mpi" and "mpi_f08" module Fortran
bindings support passing by parameters by name. Hence, we need to use
the MPI-spec-defined parameter names ("dummy variables", in Fortran
parlance) for the "mpi" and "mpi_f08" modules.
Specifically, Fortran allows calls to procedures to be written with
keyword arguments, e.g., "call mpi_sizeof(x=x,size=rsize,ierror=ier)"
An "explicit interface" for the procedure must be in scope for this to
be allowed in a Fortran program unit. Therefore, the explicit
interface blocks we provide in the "mpi" and "mpi_f08" modules must
match the MPI published standard, including the names of the dummy
variables (i.e., parameter names), as that is how Fortran programs may
call them.
Note that we didn't find this issue previously because even though the
MPI spec *allows* for name-based parameter passing, not many people
actually use it. I suspect that we might have some more incorrect
parameter names -- we should probably do a full "mpi" / "mpi_f08"
module parameter name audit someday.
Thanks to Themos Tsikas for reporting the issue and supplying the
initial fix.
Signed-off-by: themos.tsikas@nag.co.uk
Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
2018-04-27 11:30:01 +01:00
|
|
|
! Copyright (c) 2015-2018 Research Organization for Information Science
|
|
|
|
! and Technology (RIST). All rights reserved.
|
2016-11-22 15:03:20 -08:00
|
|
|
! $COPYRIGHT$
|
|
|
|
|
|
|
|
#include "ompi/mpi/fortran/configure-fortran-output.h"
|
|
|
|
|
|
|
|
module mpi_f08_interfaces_callbacks
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_User_function(invec, inoutvec, len, datatype)
|
|
|
|
USE mpi_f08_types
|
|
|
|
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
|
|
|
|
IMPLICIT NONE
|
|
|
|
TYPE(C_PTR), VALUE :: invec, inoutvec
|
|
|
|
INTEGER :: len
|
|
|
|
TYPE(MPI_Datatype) :: datatype
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
!Example of a user defined callback function
|
|
|
|
!
|
mpi/fortran: use conformant dummy names for Fortran bindings
The MPI spec defines that the "mpi" and "mpi_f08" module Fortran
bindings support passing by parameters by name. Hence, we need to use
the MPI-spec-defined parameter names ("dummy variables", in Fortran
parlance) for the "mpi" and "mpi_f08" modules.
Specifically, Fortran allows calls to procedures to be written with
keyword arguments, e.g., "call mpi_sizeof(x=x,size=rsize,ierror=ier)"
An "explicit interface" for the procedure must be in scope for this to
be allowed in a Fortran program unit. Therefore, the explicit
interface blocks we provide in the "mpi" and "mpi_f08" modules must
match the MPI published standard, including the names of the dummy
variables (i.e., parameter names), as that is how Fortran programs may
call them.
Note that we didn't find this issue previously because even though the
MPI spec *allows* for name-based parameter passing, not many people
actually use it. I suspect that we might have some more incorrect
parameter names -- we should probably do a full "mpi" / "mpi_f08"
module parameter name audit someday.
Thanks to Themos Tsikas for reporting the issue and supplying the
initial fix.
Signed-off-by: themos.tsikas@nag.co.uk
Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
2018-04-27 11:30:01 +01:00
|
|
|
! subroutine my_user_function( invec, inoutvec, len, datatype ) bind(c)
|
2016-11-22 15:03:20 -08:00
|
|
|
! use, intrinsic :: iso_c_binding, only : c_ptr, c_f_pointer
|
|
|
|
! type(c_ptr), value :: invec, inoutvec
|
|
|
|
! integer, intent(in) :: len
|
mpi/fortran: use conformant dummy names for Fortran bindings
The MPI spec defines that the "mpi" and "mpi_f08" module Fortran
bindings support passing by parameters by name. Hence, we need to use
the MPI-spec-defined parameter names ("dummy variables", in Fortran
parlance) for the "mpi" and "mpi_f08" modules.
Specifically, Fortran allows calls to procedures to be written with
keyword arguments, e.g., "call mpi_sizeof(x=x,size=rsize,ierror=ier)"
An "explicit interface" for the procedure must be in scope for this to
be allowed in a Fortran program unit. Therefore, the explicit
interface blocks we provide in the "mpi" and "mpi_f08" modules must
match the MPI published standard, including the names of the dummy
variables (i.e., parameter names), as that is how Fortran programs may
call them.
Note that we didn't find this issue previously because even though the
MPI spec *allows* for name-based parameter passing, not many people
actually use it. I suspect that we might have some more incorrect
parameter names -- we should probably do a full "mpi" / "mpi_f08"
module parameter name audit someday.
Thanks to Themos Tsikas for reporting the issue and supplying the
initial fix.
Signed-off-by: themos.tsikas@nag.co.uk
Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
2018-04-27 11:30:01 +01:00
|
|
|
! type(MPI_Datatype) :: datatype
|
2016-11-22 15:03:20 -08:00
|
|
|
! real, pointer :: invec_r(:), inoutvec_r(:)
|
mpi/fortran: use conformant dummy names for Fortran bindings
The MPI spec defines that the "mpi" and "mpi_f08" module Fortran
bindings support passing by parameters by name. Hence, we need to use
the MPI-spec-defined parameter names ("dummy variables", in Fortran
parlance) for the "mpi" and "mpi_f08" modules.
Specifically, Fortran allows calls to procedures to be written with
keyword arguments, e.g., "call mpi_sizeof(x=x,size=rsize,ierror=ier)"
An "explicit interface" for the procedure must be in scope for this to
be allowed in a Fortran program unit. Therefore, the explicit
interface blocks we provide in the "mpi" and "mpi_f08" modules must
match the MPI published standard, including the names of the dummy
variables (i.e., parameter names), as that is how Fortran programs may
call them.
Note that we didn't find this issue previously because even though the
MPI spec *allows* for name-based parameter passing, not many people
actually use it. I suspect that we might have some more incorrect
parameter names -- we should probably do a full "mpi" / "mpi_f08"
module parameter name audit someday.
Thanks to Themos Tsikas for reporting the issue and supplying the
initial fix.
Signed-off-by: themos.tsikas@nag.co.uk
Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
2018-04-27 11:30:01 +01:00
|
|
|
! if (datatype%MPI_VAL == MPI_REAL%MPI_VAL) then
|
2016-11-22 15:03:20 -08:00
|
|
|
! call c_f_pointer(invec, invec_r, (/ len /) )
|
|
|
|
! call c_f_pointer(inoutvec, inoutvec_r, (/ len /) )
|
|
|
|
! inoutvec_r = invec_r + inoutvec_r
|
|
|
|
! end if
|
|
|
|
! end subroutine my_function
|
|
|
|
!
|
|
|
|
! The MPI library may internally store such callbacks in a global array
|
|
|
|
! All_MPI_Ops:
|
|
|
|
!
|
|
|
|
! type, private :: Internal_MPI_op
|
|
|
|
! procedure(user_function), nopass, pointer :: user_fn
|
|
|
|
! end type
|
|
|
|
! type(Internal_MPI_op), private :: All_MPI_Ops(Max_Operations)
|
|
|
|
!
|
|
|
|
! Within MPI_Op_create, the user_fn is stored in All_MPI_Ops:
|
|
|
|
!
|
|
|
|
! subroutine MPI_Op_create( user_fn, commute, op ) bind(C)
|
|
|
|
! procedure(user_function) :: user_fn
|
|
|
|
! type(MPI_Op), intent(out) :: op
|
|
|
|
! ...
|
|
|
|
! Registered_Operations = Registered_Operations + 1
|
|
|
|
! op%MPI_VAL = Registered_Operations
|
|
|
|
! All_MPI_Ops(Registered_Operations)%user_fn => user_fn
|
|
|
|
!
|
|
|
|
! Within MPI_Reduce, the stored user_fn is used to, e.g., to combine
|
|
|
|
! recvbuf = sendbuf+recvbuf
|
|
|
|
!
|
|
|
|
! subroutine MPI_Reduce( sendbuf, recvbuf, count, datatype, op ) bind(C)
|
|
|
|
! use, intrinsic :: iso_c_binding, only : c_loc
|
|
|
|
! ...
|
|
|
|
! call All_MPI_Ops(op%MPI_VAL)%user_fn(c_loc(sendbuf), c_loc(recvbuf), count, datatype)
|
|
|
|
!
|
|
|
|
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_Comm_copy_attr_function(oldcomm,comm_keyval,extra_state, &
|
|
|
|
attribute_val_in,attribute_val_out,flag,ierror)
|
|
|
|
USE mpi_f08_types
|
|
|
|
IMPLICIT NONE
|
|
|
|
TYPE(MPI_Comm) :: oldcomm
|
|
|
|
INTEGER :: comm_keyval, ierror
|
|
|
|
INTEGER(KIND=MPI_ADDRESS_KIND) :: extra_state, attribute_val_in, attribute_val_out
|
|
|
|
LOGICAL :: flag
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_Comm_delete_attr_function(comm,comm_keyval, &
|
|
|
|
attribute_val, extra_state, ierror)
|
|
|
|
USE mpi_f08_types
|
|
|
|
IMPLICIT NONE
|
|
|
|
TYPE(MPI_Comm) :: comm
|
|
|
|
INTEGER :: comm_keyval, ierror
|
|
|
|
INTEGER(KIND=MPI_ADDRESS_KIND) :: attribute_val, extra_state
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_Win_copy_attr_function(oldwin,win_keyval,extra_state, &
|
|
|
|
attribute_val_in,attribute_val_out,flag,ierror)
|
|
|
|
USE mpi_f08_types
|
|
|
|
IMPLICIT NONE
|
|
|
|
TYPE(MPI_Win) :: oldwin
|
|
|
|
INTEGER :: win_keyval, ierror
|
|
|
|
INTEGER(KIND=MPI_ADDRESS_KIND) :: extra_state, attribute_val_in, attribute_val_out
|
|
|
|
LOGICAL :: flag
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_Win_delete_attr_function(win,win_keyval,attribute_val, &
|
|
|
|
extra_state,ierror)
|
|
|
|
USE mpi_f08_types
|
|
|
|
IMPLICIT NONE
|
|
|
|
TYPE(MPI_Win) :: win
|
|
|
|
INTEGER :: win_keyval, ierror
|
|
|
|
INTEGER(KIND=MPI_ADDRESS_KIND) :: attribute_val, extra_state
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_Type_copy_attr_function(oldtype,type_keyval,extra_state, &
|
|
|
|
attribute_val_in,attribute_val_out,flag,ierror)
|
|
|
|
USE mpi_f08_types
|
|
|
|
IMPLICIT NONE
|
|
|
|
TYPE(MPI_Datatype) :: oldtype
|
|
|
|
INTEGER :: type_keyval, ierror
|
|
|
|
INTEGER(KIND=MPI_ADDRESS_KIND) :: extra_state, attribute_val_in, attribute_val_out
|
|
|
|
LOGICAL :: flag
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_Type_delete_attr_function(datatype,type_keyval, &
|
|
|
|
attribute_val,extra_state,ierror)
|
|
|
|
USE mpi_f08_types
|
|
|
|
IMPLICIT NONE
|
|
|
|
TYPE(MPI_Datatype) :: datatype
|
|
|
|
INTEGER :: type_keyval, ierror
|
|
|
|
INTEGER(KIND=MPI_ADDRESS_KIND) :: attribute_val, extra_state
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_Comm_errhandler_function(comm,error_code)
|
|
|
|
USE mpi_f08_types
|
|
|
|
IMPLICIT NONE
|
|
|
|
TYPE(MPI_Comm) :: comm
|
|
|
|
INTEGER :: error_code
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_Win_errhandler_function(win, error_code)
|
|
|
|
USE mpi_f08_types
|
|
|
|
IMPLICIT NONE
|
|
|
|
TYPE(MPI_Win) :: win
|
|
|
|
INTEGER :: error_code
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_File_errhandler_function(file, error_code)
|
|
|
|
USE mpi_f08_types
|
|
|
|
IMPLICIT NONE
|
|
|
|
TYPE(MPI_File) :: file
|
|
|
|
INTEGER :: error_code
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_Grequest_query_function(extra_state,status,ierror)
|
|
|
|
USE mpi_f08_types
|
|
|
|
IMPLICIT NONE
|
|
|
|
TYPE(MPI_Status) :: status
|
|
|
|
INTEGER :: ierror
|
|
|
|
INTEGER(KIND=MPI_ADDRESS_KIND) :: extra_state
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_Grequest_free_function(extra_state,ierror)
|
|
|
|
USE mpi_f08_types
|
|
|
|
IMPLICIT NONE
|
|
|
|
INTEGER :: ierror
|
|
|
|
INTEGER(KIND=MPI_ADDRESS_KIND) :: extra_state
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_Grequest_cancel_function(extra_state,complete,ierror)
|
|
|
|
USE mpi_f08_types
|
|
|
|
IMPLICIT NONE
|
|
|
|
INTEGER(KIND=MPI_ADDRESS_KIND) :: extra_state
|
|
|
|
LOGICAL :: complete
|
|
|
|
INTEGER :: ierror
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_Datarep_extent_function(datatype, extent, extra_state, ierror)
|
|
|
|
USE mpi_f08_types
|
|
|
|
IMPLICIT NONE
|
|
|
|
TYPE(MPI_Datatype) :: datatype
|
|
|
|
INTEGER :: ierror
|
|
|
|
INTEGER(KIND=MPI_ADDRESS_KIND) :: extent, extra_state
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
OMPI_ABSTRACT INTERFACE
|
|
|
|
SUBROUTINE MPI_Datarep_conversion_function(userbuf, datatype, count, &
|
|
|
|
filebuf, position, extra_state, ierror)
|
|
|
|
USE mpi_f08_types
|
|
|
|
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
|
|
|
|
IMPLICIT NONE
|
|
|
|
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
|
|
|
|
END SUBROUTINE
|
|
|
|
END INTERFACE
|
|
|
|
|
|
|
|
end module mpi_f08_interfaces_callbacks
|