next up previous contents
Next: Example: Array swapping Up: Pointers and Targets Previous: Pointer Assignment   Contents

Association with Arrays

An array pointer may be associated with the whole target array, or with a regular section of the target (as long as the section has the correct rank).

For example, let

a = reshape((/1,2,3,4,5,6,7,8,9/),(/3,3/))
and define
PtoA =>  a(1:3:2,2:3)
The vector assignment is valid, and we have that SHAPE(PtoA) = (/2,2/), SIZE(PtoA)=4; PtoA(1,1)=a(1,2)=4 and PtoA(2,1)=a(3,2)=6 etc.

We can associate pointers with pointers as follows:

PtoR => PtoA(2,2)
This means that PtoR, PtoA(2,2), a(3,3) are all aliases of the same memory space.

The pointer assignment

PtoA => a(1:3,2)
is not valid, since the rank of the target is not 2.

An array pointer cannot be associated with a vector-subscripted array section. For example, the following is invalid:

v = (/2,3,1/); PtoA => a(v,v)



Subsections

Adrian Sandu 2001-08-26