Manual Reference Pages  - c_f_pointer (3fortran)

NAME

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

SYNOPSIS

call c_f_pointer(cptr, fptr [,shape] )

         subroutine c_f_pointer(cptr, fptr ,shape )

type(c_ptr),intent(in) :: cprt type(TYPE),pointer,intent(out) :: fprt integer,intent(in),optional :: shape(:)

CHARACTERISTICS

The Fortran pointer FPRT must be interoperable with CPTR

SHAPE is only specified if FPTR is an array.

DESCRIPTION

C_F_POINTER(3) assigns the target (the C pointer CPTR) to the Fortran pointer FPTR and specifies its shape if FPTR points to an array.

OPTIONS

o CPTR : scalar of the type c_ptr. It is INTENT(IN).
o FPTR : pointer interoperable with CPTR. it is INTENT(OUT).
o 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.

EXAMPLES

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

SEE ALSO

C_LOC(3), C_F_PROCPOINTER(3), ISO_C_BINDING(3)

Fortran intrinsic descriptions


Nemo Release 3.1 c_f_pointer (3fortran) November 02, 2024
Generated by manServer 1.08 from 50a7b116-214d-4f83-bdbd-83cfa91c5f4d using man macros.