Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29249 Discussions

How do I get a value from an address

weichao
Beginner
701 Views
I know LOC Function can return a memory address of a value. Reversely, how do I get the value from the address?
0 Kudos
1 Reply
anthonyrichards
New Contributor III
701 Views
BY using a pointer. If you look at the Help for LOC (or %loc) intrinsic functions, you will 
find the following 
You can give values to pointers by doing the following:

  • Retrieve addresses by using the LOC intrinsic function (or the %LOC built-in function)

Allocate storage for an object by using the MALLOC intrinsic function (or by using malloc(3f) on Tru64 UNIX or Linux systems, or LIB$GET_VM on OpenVMS systems)

For exampleUsing %LOC:                  Using MALLOC:

INTEGER I(10)                INTEGER I(10)
INTEGER I1(10) /10*10/       POINTER (P,I)
POINTER (P,I)                P = MALLOC(40)
P = %LOC(I1)                 I(2) = I(2) + 1
I(2) = I(2) + 1

The value in a pointer is used as the pointee's base address

Message Edited by anthonyrichards on 07-08-2005 03:11 AM

0 Kudos
Reply