loc

Date:

10-12-2011

NAME

LOC - Obtains the address of a variable

SYNOPSIS

LOC ([I=]i)

IMPLEMENTATION

Cray Linux Environment (CLE)

STANDARDS

Fortran extension

DESCRIPTION

LOC returns a byte address of a variable, constant, or array. It accepts the following arguments:

i

The variable for which the address is being requested. Specify a variable of any data type.

LOC can be used to define a Cray pointer. Just like a variable in common storage, a Cray pointee, Cray pointer, or the argument to LOC is stored in memory before a call to an external procedure and is read out of memory at its next reference. The variable is also stored before a RETURN or END statement of a subprogram.

The name of this intrinsic cannot be passed as an argument.

EXAMPLES

Example 1: Consider the following code:

SUBROUTINE SUB(N)
COMMON POOL(100000)
INTEGER BLK(128), WORD64
REAL A(1000), B(N), C(100000-N-1000)
POINTER(PBLK,BLK),(IA,A),(IB,B),(IC,C),(ADDRESS,WORD64)
DATA ADDRESS /64/
PBLK = 0
IA = LOC(POOL)
IB = IA + 1000
IC = IB + N

In effect, WORD64 in this example refers to the contents of absolute address 64; BLK is an array occupying the first 128 words of memory; A is an array of length 1000 located in blank common; B follows A and is of length N; C follows B. A, B, and C are associated with POOL. Similarly, WORD64 is the same as BLK() because BLK() is at address 0.

Example 2: Consider the following code:

POINTER (P,B),(P,C)
REAL X,B,C
P = LOC(X)
B = 1.0
C = 2.0
PRINT *,B

Because B and C have the same Cray pointer, the assignment of 2.0 to C gives the same value to B. Therefore, B prints as 2.0, even though it was assigned 1.0.