loc(3I)

LOC - Obtains the address of a variable

Showing IRIX 6.5.30 (default release). Last changed in IRIX 6.5.19.

NAME
     LOC - Obtains the address of a variable

SYNOPSIS
     LOC ([I=]i)

STANDARDS
     Fortran extension

DESCRIPTION
     LOC returns the 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.

WARNINGS
     LOC is often used to compute the difference of two addresses as an
     offset.  The offset is then used to access one of the arrays by
     overindexing the other array.

RETURN VALUES
     The hardware architecture determines what is returned; on byte-
     addressable machines LOC returns a byte address and on word-
     addressable machines LOC returns a word address. If the -64 compiler
     option is in effect, the value returned is a KIND=8 value; otherwise,
     the value returned is a KIND=4 value.

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(65), because BLK(1) 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.