Re: Allocatable arrays in derived types
- From: relaxmike <michael.baudin@xxxxxxxxx>
- Date: Tue, 29 Apr 2008 02:03:17 -0700 (PDT)
Hi,
I don't remember exactly where I read it on this forum,
but I remember that the difference between allocatable and pointer
arrays is that, when an allocatable array goes out of scope,
it is automatically deallocated.
A pointer which goes out of scope is not automatically deallocated,
because it may happen that another pointer keeps a reference
to the pointee, so that an automatic deallocation would lost
the reference.
This is the main reason for the overhead of a allocatable
array (and is also the main reason for some bugs in the
implementation of allocatable in fortran compilers, which is
tricky in complicated situations, like derived type, recursive
function, etc...).
But what would be the size if the derived type would only contain
the array, and not the integer :
type cell_data
integer, allocatable, dimension(:) :: mydata
end type cell_data
7 ? Or not, it there is also an additional bookkeeping
for the derived type itself ?
And what if one computes directly the size of the allocatable
array ? I expect it to be 1, but is that true ?
Regards,
Michaël
.
- Follow-Ups:
- Re: Allocatable arrays in derived types
- From: Jugoslav Dujic
- Re: Allocatable arrays in derived types
- From: Richard Maine
- Re: Allocatable arrays in derived types
- References:
- Allocatable arrays in derived types
- From: Gib Bogle
- Re: Allocatable arrays in derived types
- From: Arjen Markus
- Allocatable arrays in derived types
- Prev by Date: Re: Allocatable arrays in derived types
- Next by Date: Re: Allocatable arrays in derived types
- Previous by thread: Re: Allocatable arrays in derived types
- Next by thread: Re: Allocatable arrays in derived types
- Index(es):
Relevant Pages
|
|