[UP]


Manual Reference Pages  - c_f_procpointer (3)

NAME

c_f_procpointer(3f) - [FORTRAN:INTRINSIC:ISO_C_BINDING] Convert C into Fortran procedure pointer

SYNTAX

call c_f_procpointer(cptr, fptr)

DESCRIPTION

c_f_procpointer(cptr, fptr) assigns the target of the C function pointer CPTR to the Fortran procedure pointer FPTR.

ARGUMENTS

CPTR scalar of the type c_funptr. It is intent(in).
FPTR procedure pointer interoperable with CPTR. It is intent(out).

EXAMPLE

Sample program:

    program demo_c_f_procpointer
    use iso_c_binding
    implicit none
    abstract interface
       function func(a)
       import :: c_float
       real(c_float), intent(in) :: a
       real(c_float) :: func
       end function
    end interface
    interface
       function getIterFunc() bind(c,name="getIterFunc")
       import :: c_funptr
       type(c_funptr) :: getIterFunc
       end function
    end interface
    type(c_funptr) :: cfunptr
    procedure(func), pointer :: myFunc
       cfunptr = getIterFunc()
       call c_f_procpointer(cfunptr, myFunc)
    end program demo_c_f_procpointer

STANDARD

[[Fortran 2003]] and later

CLASS

Subroutine

SEE ALSO

c_loc(3), c_f_pointer(3), iso_c_binding(3)


c_f_procpointer (3) March 11, 2021
Generated by manServer 1.08 from 2c51d357-00de-4953-995e-f31058eb4c02 using man macros.