c_f_pointer(3f) - [FORTRAN:INTRINSIC:ISO_C_BINDING] Convert C into Fortran pointer
call c_f_pointer(cptr, fptr[, shape])
c_f_pointer(cptr, fptr[, shape]) Assign the target, the C pointer, CPTR to the Fortran pointer FPTR and specify its shape.
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.
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
[[Fortran 2003]] and later
Subroutine
c_loc(3), c_f_procpointer(3), iso_c_binding(3)
c_f_pointer (3) | March 11, 2021 |