Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

C_F_POINTER

Intrinsic Module Subroutine: Associates a data pointer with the target of a C pointer and specifies its shape.

Module

USE, INTRINSIC :: ISO_C_BINDING

Syntax

CALL C_F_POINTER(cptr, fptr [,shape])

cptr

(Input) Is a scalar of derived type C_PTR. Its value is the C address of an interoperable data entity, or the result of a reference to function C_LOC with a noninteroperable argument. If the value of cptr is the C address of a Fortran variable, it must have the TARGET attribute.

fptr

(Output) Is a data pointer. If it is an array, shape must be specified.

shape

(Optional, input) Must be of type integer and rank one. Its size equals the rank of fptr.

If the value of cptr is the C address of an interoperable data entity, fptr must be a data pointer with type and type parameters interoperable with the type of the entity. In this case, fptr becomes pointer-associated with the target of cptr.

If fptr is an array, it has the shape specified by shape and each lower bound is 1.

If the value of cptr is the result of a reference to C_LOC with a noninteroperable argument x, the following rules apply:

  • C_LOC argument x (or its target) must not have been deallocated or have become undefined due to the execution of a RETURN or END statement since the reference to C_LOC.

  • fptr is a scalar pointer with the same type and type parameters as x. fptr becomes pointer-associated with x, or it becomes pointer-associated with its target if x is a pointer.

Since the resulting data pointer fptr could point to a target that was not allocated with an ALLOCATE statement, fptr cannot be freed with a DEALLOCATE statement.