Re: association of pointers
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Tue, 13 Nov 2007 16:16:39 -0800
John Harper wrote:
PROGRAM testassoc3
INTEGER, TARGET :: beast = 666
beast has value 666 and may be the target of a pointer
INTEGER, POINTER :: ptr => NULL()
ALLOCATE(ptr)
A new variable is allocated, pointed to by ptr.
ptr = beast
The value of beast is copied to the variable pointed
to by ptr.
PRINT "(A,I4)",' After ptr = beast, ptr is',ptr
PRINT "(A,L2)",' associated(ptr,beast) is',associated(ptr,beast)
PRINT "(A,L2)",' associated(ptr) is',associated(ptr)
ptr and beast point to different variables, so are not associated.
After ptr = beast, ptr is 666
associated(ptr,beast) is F
associated(ptr) is T
That appears to suggest that ptr was associated with something at the time of printing, but not with beast even though its value was that of beast. What was ptr associated with?
Instead of allocate(ptr) do
ptr => beast
-- glen
.
- References:
- association of pointers
- From: John Harper
- association of pointers
- Prev by Date: Re: How to Make F77 Program Faster (g95 compiler) ??
- Next by Date: speed up calculation suggestions
- Previous by thread: association of pointers
- Next by thread: Re: association of pointers
- Index(es):
Relevant Pages
|