LOC

Inquiry Intrinsic Function (Generic): Returns the internal address of a storage item. This function cannot be passed as an actual argument.

Syntax

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 an internal procedure or statement function. If it is a pointer, it must be defined and associated with a target.

Results:

The result is of type INTEGER(4) on ia32 processors; INTEGER(8) on Alpha and ia64 processors. 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.

LOC performs the same function as the %LOC built-in function.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

Example

! Mixed language example passing Integer Pointer to C

! Fortran main program
      INTERFACE
         SUBROUTINE Ptr_Sub (p)
!DEC$      ATTRIBUTES C, ALIAS:'_Ptr_Sub' :: Ptr_Sub
           INTEGER p
         END SUBROUTINE Ptr_Sub
      END INTERFACE

      REAL A[10], VAR[10]
      POINTER (p, VAR)  ! VAR is the pointer-based
                        ! variable, p is the integer
                        ! pointer
      p = LOC(A)

      CALL Ptr_Sub (p)
      WRITE(*,*) "A(4) = ", A(4)
      END

! C subprogram
void Ptr_Sub (int *p)
{
  float a[10];
  a[3] = 23.5;
  *p = a;
}