Re: save statement in a module



Gib Bogle wrote:
....
What is the effect of the module-level SAVE? I thought all module
variables were automatically SAVEd.

Nope. That's what I've usually argued *should* be the rule,
but Fortran doesn't say that. Unless you have the save attribute,
all module variables become officially undefined when the
last USE for the module (the one highest in your call sequence)
goes out of scope.

Having to remember whether a module USE is still in scope
or not is something many users are not particularly good at.
Those that *can* keep track of such things would rather
not be required to do so. That's why I think module variables
should always be considered SAVEd. The definition of
Fortran should be changes to require it.


--
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare


.



Relevant Pages

  • Re: Coding guidelines question
    ... have scope in the entire module in order that your module ... I also want some way to block host ... Fortran used to have a useful characteristic: ... no deficiencies and the other way is to make it so complicated ...
    (comp.lang.fortran)
  • Re: How to determine if a module is in scope
    ... whoever wrote that part of the standard clearly intended ... Since a is in scope, ... Fortran 90 and later versions of Fortran of which I am aware ... treats module variables as if they have the SAVE attribute. ...
    (comp.lang.fortran)
  • Re: How to determine if a module is in scope
    ... The Fortran 2003 standard clearly intends that if the ... Since a is in scope, ... Fortran 90 and later versions of Fortran of which I am aware ... treats module variables as if they have the SAVE attribute. ...
    (comp.lang.fortran)
  • Re: save attribute for module variables
    ... > require "reinitialization" of objects when they go out of scope. ... > it is not a test of the standard. ... initialization to have the SAVE attribute: ... to be consistent with the above about module variables, ...
    (comp.lang.fortran)
  • Re: save attribute for module variables
    ... In that event, every time the | variable comes into scope after being out of scope, the default ... | initialization should be applied. ... with CVF6.6C and presence of SAVE made no difference (nor the compiler complained about it, ... As the standard did not want this implementation difference to become visible - this is what I believe is called a post hoc rationalization - the standard says that initialized module variables - as indeed, if I'm not mistaken, all initialized variables - automatically acquire the SAVE attribute. ...
    (comp.lang.fortran)