[log in to unmask] wrote:
> Dear Members:
>
> I have the following questions
>
> a)Is there any difference between nullify and deallocate an associated
> pointer in order to dissociate it(see example bellow)?
Yes.
Nullify initialized the pointer so that it does not associated to any target.
It does not free the memory as deallocate does.
On the other hand, deallocate (I think) does not de-associate the pointer from
the target. The pointer still points to the memory that is now free and not
under the program control. You need to nullify the pointer for the associated
check.
This is how I used them:
...
allocate(x)
...
deallocate(x)
nullify(x)
...
if (associated(x)) then
...
endif
>
> A simple example:
>
> subroutine foo()
> integer,pointer :: x
>
> allocate(x)
> .
> .
> .
> nullify(x)
> end subroutine foo
>
> and
>
> subroutine foo()
> integer,pointer :: x
>
> allocate(x)
> .
> .
> .
> deallocate(xx)
> end subroutine foo
>
> Are these situations equivalents?
No. See above.
> b)What are the rules for controling the garbage memory?
Sorry! Can't help you with this one.
Hope this help.
Shyan Lam
[log in to unmask]
____________________________________________________________________
Get free e-mail and a permanent address at http://www.netaddress.com/?N=1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|