Print

Print


To answer my own question,

> When one has nested data-types with some allocatable
> components, as in:
>
> type test
>     real, dimension(:), allocatable :: x,y,z
> end type test
> type(test), pointer :: instance
> allocate(instance)
>
> then does deallocate(instance) do any kind of automatic deallocation or
> should I manually deallocate x, y and z. How about pointer components that
> were allocated with allocate?

I just found the sentence in the TR the says:

"Deallocation of a variable containing an ultimate allocatable array
component automatically deallocates all such components of the variable that
are currently allocated."

Is there a similar rule in F95 for pointer components, i.e. does
deallocation or nullification (if a pointer) of a derived data type object
containing a pointer component automatically nullify that component?

Concerning my other question:

> For a code such as:
> type cg_solver
>     real, dimension(:), allocatable :: x
> end type cg_solver
>
> type system
>     type(cg_solver), POINTER :: solver=>NULL() ! LINE XXX
> end type system
>
> I get the following error:
>
> 1648-S: "DualNewton.f90", line XXX: An initialized object solver shall not
> be of a derived type containing an allocatable array as an ultimate
> component.

I did not find anything in the TR on this in the second reading. There is
something about type constructors where it says a =>NULL() can be used in
the constructors for the allocatable arrays, but could not find anything
about initialization. Where did Lahey get the above message from?

Thanks,
Aleksandar

_____________________________________________
Aleksandar Donev
http://www.pa.msu.edu/~donev/
[log in to unmask]
(517) 432-6770
Department of Physics and Astronomy
Michigan State University
East Lansing, MI 48824-1116
_____________________________________________