Re: Allocating arrays inside a subroutine.
- From: Ron Shepard <ron-shepard@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Aug 2006 10:07:58 -0500
In article <1156841260.541988.5840@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
deltaquattro@xxxxxxxxx wrote:
[replace dummy argument with module array...]
Since no one else suggested this, I wonder if that's the best way to
get the job done (my compiler doesn't support "extended allocatables",
even though I'm trying to have this fixed).
Yes, that is a correct solution. It has the disadvantage that the
subroutine can allocate only that single array, whereas if it were a
dummy argument (pointer, or allocatable with the allocatable TR) it
could be called multiple times with different array arguments.
Fortran 90 and 95 were designed originally for such things to be
done with pointers, but the use of pointers has some disadvantages
(both performance and semantics). Most of us think that this was a
design mistake. It was later corrected (in the f95 allocatable TR
and in 2003), but these are not yet universally supported, so we are
still suffering from the original bad decision 15 years later. You
still need pointers in the language (e.g. for linked lists), but
almost everything else can be done better, cleaner, and more
efficiently with TR-style allocatable arrays.
In my own programming when this decision comes up, I usually use a
pointer array, and I leave a comment to myself to change it to an
allocatable array at some point in the future when the feature is
more universally supported. The same issue arises for allocatable
components of user defined data types.
$.02 -Ron Shepard
.
- Follow-Ups:
- Re: Allocating arrays inside a subroutine.
- From: Jan Vorbrüggen
- Re: Allocating arrays inside a subroutine.
- References:
- Allocating arrays inside a subroutine.
- From: Timothy Hume
- Re: Allocating arrays inside a subroutine.
- From: deltaquattro
- Allocating arrays inside a subroutine.
- Prev by Date: Re: closing unit=5 and unit=6 and print *
- Next by Date: Re: How to USE modules in a different directory?
- Previous by thread: Re: Allocating arrays inside a subroutine.
- Next by thread: Re: Allocating arrays inside a subroutine.
- Index(es):
Relevant Pages
|