Re: Derived types with allocatable arrays; more problems
- From: "Arno" <arnoinperu@xxxxxxxxxxx>
- Date: 14 Apr 2006 04:24:48 -0700
Thanks for your swift reply.
If you explicitly write
do i = 1, n
a%b(i) = b(i)
end do
it works.
If b(i)%c=c (=integer array) works fine, why shouldn't a%b=b (=derived
type array) work in the same way?
Also it seems that you allocated a%b(n) but you did not allocate
a%b(i)%c(n)
If a derived type (b(i) in this case) contains an allocatable array, it
will automatically become allocated in an assignment, as far as I
understood. So, if I understood correctly, I do not need to explicitly
allocate a%b(i)%c(n).
I think that the problem is in the assignment between two derived
types. You'd better define your own assignment operator (=).
I used to have that when I was still using pointers, but now I switched
to allocatable arrays in derived types and thought/hoped I could live
without my own assignment operators.
I just don't understand why the code doesn't work, and before altering
(large chunks of) code, I would like to know what is going on. I will
keep in mind the extra loop you suggested.
Arno
.
- References:
- Prev by Date: Re: can't find libg2c on FC4
- Next by Date: Re: getting env. variables in gfortran...
- Previous by thread: Re: Derived types with allocatable arrays; more problems
- Next by thread: Re: Derived types with allocatable arrays; more problems
- Index(es):
Relevant Pages
|