--On Tuesday, April 13, 2004 10:04 AM -0400 Aleksandar Donev
<[log in to unmask]> wrote:
> Drew McCormack wrote:
>> Is this legal?
>> real, pointer :: a(:), b(:)
>> allocate( a(10) )
>> b => a
>> deallocate( b )
>
> Essentially as far as Fortran
> is concerned b=>a makes b equivalent to a.
Yes. I think the main point to remember here is one I remind people
of often: a pointer and its target are separate things. The
allocate statement does 2 things
1. Allocates a target
2. Associates the pointer ("a" in this case) with the target.
The critical point here is that these 2 steps are *DISTINCT*.
The target doesn't "know" that it was allocated for the pointer "a".
The target is its own independent thing.
The pointer "a" plays no special role; it just happens to be a pointer
that was at first associated with the target. There is no essential
difference between it and any other pointer that might later become
associated with the same target.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|