Re: suggestions for restricted sharing of variables
I was just looking through some old F77 code which was my motivation for
asking this. There are about a dozen routines, and about 4 pairs of
routines which need to share variables (in addition to some variables
shared by many of the routines, but that is not an issue). Making these
variables global module variables is a bit confusing. Having separate
external modules is a possibility, but is also a bit confusing. (It
does have the advantage that they could also be USEd by the calling
program if necessary.) The most elegant solution really would be a USE
statement in a routine contained in a module which USEs (some of the
local variables in) another routine in the same module. This is
self-documenting. If both routines USE an additional module, then this
is not self-documenting.
I don't know how difficult the implementation would be. However, since
the present situation is that local variables are invisible to all other
routines (except internal routines), and USE applies only to a module,
not a routine, USE ROUTINE, ONLY: X, Y would be orthogonal to existing
usage. (If the routine is PUBLIC, one might even contemplate allowing
whatever USEs the main module to also use some stuff from public
routines within that module.)
|