FORTRAN 77 Language Reference

Address by LOC() Function

You can obtain the address from the intrinsic function LOC().

Example: Use the LOC() function to get an address:

* ptr1.f: Assign an address via LOC() 
	POINTER ( P, V ) 
	CHARACTER A*12, V*12 
	P = LOC( A ) 
	PRINT *, V(5:5) 

In the above example, the CHARACTER statement allocates 12 bytes of storage for A, but no storage for V. It merely specifies the type of V because V is a pointer-based variable, then assign the address of A to P, so now any use of V will refer to A by the pointer P. The program prints an E.

When compiled for 64-bit environments, LOC() returns an INTEGER*8 value. The receiving variable must be either a pointer or an INTEGER*8 variable to avoid possible address truncation.