Some of the early Sun compilers did not reliably in my experience obey this
rule, so I was forced at times to redeclare subroutines even though they
were ostensibly already in the scope. I wanted to verify that that was a
compiler problem.
Alvaro
-----Original Message-----
From: Fortran 90 List [mailto:[log in to unmask]]On Behalf
Of Richard Maine
Sent: Wednesday, July 16, 2003 1:28 PM
To: [log in to unmask]
Subject: Modules USEing modules
Alvaro Fernandez writes:
> Say module A uses module B, and module B uses module C. If a subroutine
is
> declared public in C, is it therefore available _in A_ without any
further
> work? Or do I have to do something special, like redeclare the subroutine
in
> B first? Assume all modules are default public (not my choice).
As Craig said, it is available in A without any further work. I want
to elaborate only on one point:
Attempting to redeclare the subroutine in B is not only unnecessary,
it is not allowed and will cause problems. I'm not even quite sure
what you mean by "redeclare the subroutine", but if module B uses
module C and then also has an external statement or interface body for
the subroutine, that should cause a compilation error. There is only
a *VERY* limited set of special attributes that you can redeclare for
something that you USE from a module - in f95, the PUBLIC and PRIVATE
attributes are the only ones, unless I forget something, though f2k
adds a few more. You can declare the name to be PUBLIC in module B,
though that is not required (because you said that the default in
module B is already PUBLIC).
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|