インテル® Fortran コンパイラー 19.0 デベロッパー・ガイドおよびリファレンス
Statement: Establishes pairs of objects and pointers, in which each pointer contains the address of its paired object. This statement is different from the Fortran POINTER statement.
POINTER (pointer,pointee) [,(pointer,pointee)] . . .
pointer |
Is a variable whose value is used as the address of the pointee. |
pointee |
Is a variable; it can be an array name or array specification. It can also be a procedure named in an EXTERNAL statement or in a specific (non-generic) procedure interface block. |
The following are pointer rules and behavior:
Two pointers can have the same value, so pointer aliasing is allowed.
When used directly, a pointer is treated like an integer variable. On IA-32 architecture, a pointer occupies one numeric storage unit, so it is a 32-bit quantity (INTEGER(4)). On Intel® 64 architecture, a pointer occupies two numeric storage units, so it is a 64-bit quantity (INTEGER(8)).
A pointer cannot be a pointee.
A pointer cannot appear in an ASSIGN statement and cannot have the following attributes:
ALLOCATABLE |
INTRINSIC |
POINTER |
EXTERNAL |
PARAMETER |
TARGET |
A pointer can appear in a DATA statement with integer literals only.
Integers can be converted to pointers, so you can point to absolute memory locations.
A pointer variable cannot be declared to have any other data type.
A pointer cannot be a function return value.
You can give values to pointers by doing the following:
Retrieve addresses by using the LOC intrinsic function (or the %LOC built-in function)
Allocate storage for an object by using the MALLOC intrinsic function (or by using malloc(3f) on Linux* and macOS* systems)
For example:
Using %LOC: Using MALLOC: INTEGER I(10) INTEGER I(10) INTEGER I1(10) /10*10/ POINTER (P,I) POINTER (P,I) P = MALLOC(40) P = %LOC(I1) I = 10 I(2) = I(2) + 1 I(2) = I(2) + 1
The value in a pointer is used as the pointee's base address.
The following are pointee rules and behavior:
A pointee is not allocated any storage. References to a pointee look to the current contents of its associated pointer to find the pointee's base address.
A pointee cannot be data-initialized or have a record structure that contains data-initialized fields.
A pointee can appear in only one integer POINTER statement.
A pointee array can have fixed, adjustable, or assumed dimensions.
A pointee cannot appear in a COMMON, DATA, EQUIVALENCE, or NAMELIST statement, and it cannot have the following attributes:
ALLOCATABLE |
OPTIONAL |
SAVE |
AUTOMATIC |
PARAMETER |
STATIC |
INTENT |
POINTER |
A pointee cannot be:
A dummy argument
A function return value
A record field or an array element
Zero-sized
An automatic object
The name of a generic interface block
If a pointee is of derived type, it must be of sequence type.
POINTER (p, k)
INTEGER j(2)
! This has the same effect as j(1) = 0, j(2) = 5
p = LOC(j)
k = 0
p = p + SIZEOF(k) ! 4 for 4-byte integer
k = 5