[UP]


Manual Reference Pages  - c_f_pointer (3)

NAME

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

SYNTAX

call c_f_pointer(cptr, fptr[, shape])

DESCRIPTION

c_f_pointer(cptr, fptr[, shape]) Assign the target, the C pointer, CPTR to the Fortran pointer FPTR and specify its shape.

ARGUMENTS

CPTR scalar of the type c_ptr. It is intent(in).
FPTR pointer interoperable with CPTR. It is intent(out).
SHAPE (Optional) Rank-one array of type INTEGER with intent(in). It shall be present if and only if FPTR is an array. The size must be equal to the rank of FPTR.

EXAMPLE

Sample program:

    program demo_c_f_pointer
    use iso_c_binding
    implicit none
    interface
       subroutine my_routine(p) bind(c,name=’myC_func’)
          import :: c_ptr
          type(c_ptr), intent(out) :: p
       end subroutine
    end interface
    type(c_ptr) :: cptr
    real,pointer :: a(:)
       call my_routine(cptr)
       call c_f_pointer(cptr, a, [12])
    end program demo_c_f_pointer

STANDARD

[[Fortran 2003]] and later

CLASS

Subroutine

SEE ALSO

c_loc(3), c_f_procpointer(3), iso_c_binding(3)


c_f_pointer (3) March 11, 2021
Generated by manServer 1.08 from b965e1fd-ef2e-4c84-9889-ed23f49b575e using man macros.