Intel® Fortran Compiler 16.0 User and Reference Guide
Intrinsic Module Subroutine: Associates a Fortran procedure pointer with the target of a C function pointer.
USE, INTRINSIC :: ISO_C_BINDING
CALL C_F_POINTER(cptr, fptr)
cptr |
(Input) Is a scalar of derived type C_FUNPTR. Its value is the C address of a procedure. |
fptr |
(Output) Is a Fortran procedure pointer. It becomes pointer-associated with the target of cptr. |
The following Fortran subroutine can be called from a C program that passes a pointer to a C function to be called:
SUBROUTINE CallIt (cp) BIND(C) USE, INTRINSIC :: ISO_C_BINDING TYPE(C_FUNPTR), INTENT(IN) :: cp ABSTRACT INTERFACE SUBROUTINE Add_Int (i) BIND(C) IMPORT INTEGER(C_INT), INTENT(INOUT) :: i END SUBROUTINE Add_Int END INTERFACE PROCEDURE(Add_Int), POINTER :: fp INTEGER(C_INT) :: j CALL C_F_PROCPOINTER (cp, fp) j = 1 CALL fp(j) ...