Manual Reference Pages  - c_f_procpointer (3fortran)

NAME

C_F_PROCPOINTER(3) - [ISO_C_BINDING] Convert C into Fortran procedure pointer

SYNOPSIS

call c_f_procpointer(cptr, fptr)

         subroutine c_f_procpointer(cptr, fptr )

type(c_funptr),intent(in) :: cprt type(TYPE),pointer,intent(out) :: fprt

CHARACTERISTICS

DESCRIPTION

C_F_PROCPOINTER(3) assigns the target of the C function pointer CPTR to the Fortran procedure pointer FPTR.

OPTIONS

o CPTR : scalar of the type c_funptr. It is INTENT(IN).
o FPTR : procedure pointer interoperable with CPTR. It is INTENT(OUT).

EXAMPLES

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

SEE ALSO

C_LOC(3), C_F_POINTER(3), ISO_C_BINDING(3)

fortran-lang intrinsic descriptions


Nemo Release 3.1 c_f_procpointer (3fortran) April 28, 2024
Generated by manServer 1.08 from 48484e5a-2cd2-44a9-adee-d74117081189 using man macros.