[UP]


Manual Reference Pages  - c_f_pointer (3)

NAME

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

CONTENTS

Syntax
Description
Arguments
Example
Standard
Class
See Also

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]], [[c_f_procpointer]], [[iso_c_binding]]


c_f_pointer (3) March 18, 2019
Generated by manServer 1.08 from f31f8691-19db-4d18-b458-ef5206a2352d using man macros.