Visible to Intel only — GUID: GUID-B9CF95CB-7028-424A-B0A1-632A42F0B184
Visible to Intel only — GUID: GUID-B9CF95CB-7028-424A-B0A1-632A42F0B184
LOC
Inquiry Intrinsic Function (Generic): Returns the internal address of a storage item. This function cannot be passed as an actual argument.
result = LOC (x)
x |
(Input) Is a variable, an array or record field reference, a procedure, or a constant; it can be of any data type. It must not be the name of a statement function. If it is a pointer, it must be defined and associated with a target. |
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The value of the result represents the address of the data object or, in the case of pointers, the address of its associated target. If the argument is not valid, the result is undefined.
This function performs the same function as the %LOC built-in function.
The Fortran standard provides the C_LOC intrinsic module function as an alternative to the non-standard LOC. For more information, see the descriptions of C_LOC, C_FUNLOC, C_F_POINTER and C_F_PROCPOINTER.
! Example of using the LOC intrinsic
integer :: array(2) = [10,20]
integer :: t
pointer (p,t) ! Integer pointer extension
! p is pointer, t is pointee (target)
! This declares p as an address-sized integer
p = loc(array(1)) ! Address of array(1)
print *, t ! Prints 10
p = loc(array(2)) ! Address of array(2)
print *, t ! Prints 20