David,
I believe that module variables that are initialized, as in
integer :: x=0
will automatically get SAVEd, though I don't have the standard right here
at the moment. Certainly local variables in procedures do. This I suspect
is a historical legacy that must be kept due to backward compatibility. I
consider it a very bad "feature". Namely, there is a perfectly reasonable
semantics to a local procedure variable not being saved---the variable
gets (re)initialized every time the procedure is executed. In fact, this
is what the standard does for local variables of
derived type that has default initialized components (which btw is a
Fortran 95 feature, probably the only important one :-). So I suspect that
module variables were done so that they behave similarly to procedure
local variables, but I was too young back then to remember :-)
I often miss the ability to have local procedure variables that get
reinitialized every time the procedure executes. One can of course do it
by putting the initialization as the first executable statement in the
procedure body, but why? Again, I suspect in the good old days when all
local vars were static and not on the stack it made sense to implicitly
give them the SAVE attribute. It certainly makes no sense to me today...
Best,
Aleks
--
|