loc(3I)

LOC - Obtains the address of a variable

As shipped in IRIX 6.5.5. Last changed in IRIX 6.5.5.

NAME
     LOC - Obtains the address of a variable

SYNOPSIS
     LOC ([I=]i)

IMPLEMENTATION
     UNICOS, UNICOS/mk, IRIX systems

     CF90, MIPSpro 7 Fortran 90, MIPSpro Fortran 77

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.  UNICOS/mk systems, unlike UNICOS
     systems, have several address spaces (called memory segments), and
     memory references with offsets outside of the segment are not allowed.
     If the arrays are in different memory segments, the corresponding
     offset generates memory references outside of the segment.  These
     references cause run-time Translation Not Valid errors.

RETURN VALUES
     On UNICOS systems, the address returned is a word address.  On
     UNICOS/mk and IRIX systems, the address returned is a byte address.

     On UNICOS and UNICOS/mk systems, the value returned is of type Cray
     Pointer.  On IRIX systems, the address returned is of type integer.
     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 will print as 2.0 even though
     it was assigned 1.0.

SEE ALSO
     Intrinsic Procedures Reference Manual for the printed version of this
     man page.