| Re: Passing an allocatable array to a subroutine |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.fortran · Group Profile
Author: nospamnospam Date: Sep 15, 2008 13:58
deadpickle gmail.com> wrote:
> I have been trying to pass an allocatable array around to a few
> subroutines.....
This is one of a class of frequently asked questions that all have the
same answer, namely that what you are doing requires an explicit
interface. There are many things that require an explicit interface -
pretty much anything that was added in f90 or later and has anything to
do with procedure arguments.
I consider it strongly recommended practice to just routinely provide an
explicit interface for all procedures. That way you don't have to
memorize the list of things that require it. Besides, there are other
side benefits of having explicit interfaces (such as better argument
agreement checking).
In your particular case, the feature in question is the allocatable
dummy argument (which isn't actually standard until f95+TR or f2003,
though most current compilers do now support the TR). Allocatable actual
arguments don't trigger the requirement, but allocatable dummy arguments
do.
To provide an explicit interface, I suggest you put the procedure in a
module and then USE the module. That's generally the simplest way. An
alternative is to make the procedure an internal procedure; that is
usually only practical in small codes. The last alternative is to write
an interface body for the procedure; I recommend against that one, as it
is laborious and error prone.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
|