Allocatable arrays in derived types
- From: Gib Bogle <bogle@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Apr 2008 19:57:51 +1200
Consider a derived type used thus:
type mytype
integer :: a,b,c
real :: x,y,z
real, allocatable :: mydata(:)
end type
type(mytype), allocatable :: cell(:)
type(mytype) :: acell
allocate(cell(1000))
do i = 1,1000
if (i <= 500) then
allocate(cell(i)%mydata(10))
else
allocate(cell(i)%mydata(100))
endif
enddo
acell = cell(100)
....
acell = cell(600)
Something like this seems to work fine, so I guess it's OK. I'm uncertain about how/where mydata is stored. Perhaps I shouldn't even be thinking about this, but old habits die hard. When cell is allocated how much space is reserved for mydata? I suppose this is compiler-dependent, but what would be a typical number? When mydata is allocated, where is it stored? Finally, when acell is equated to an element of the cell array, where is its mydata?
Thanks in advance for a free Fortran lesson :-)
.
- Follow-Ups:
- Re: Allocatable arrays in derived types
- From: paul . richard . thomas
- Re: Allocatable arrays in derived types
- From: Arjen Markus
- Re: Allocatable arrays in derived types
- Prev by Date: Re: GUIs with Dislin -more examples
- Next by Date: Re: Allocatable arrays in derived types
- Previous by thread: GUIs with Dislin -more examples
- Next by thread: Re: Allocatable arrays in derived types
- Index(es):