Alexei Matveev writes:
> Can anybody explain me what should happen after assignment...
> type :: TYP
> real,pointer :: p(:)
> real,allocatable :: a(:)
> end type
>
> type(TYP) :: x,y
>
> call allocate_and_place_some_data(y)
>
> x = y
Well, in standard f90 or f95, you should get a compilation error for
having an allocatable component. If you are using a compiler that
implements the ISO TR on allocatable stuff, and assuming that you
have not defined your own assignment for the type, you should get
x%p is a pointer pointing to *THE SAME TARGET* as y%p. There is
only one actual copy of this data. So subsequent changes in the
data pointed to by either x%p or y%p will be reflected in the other.
It is the pointer that got copied from y to x - not the target of
the pointer.
x%a is a *COPY* of the data from y%a. After this assignment, you
have two separate copies of the data.
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|