Dr W.W. Schulz wrote:
>
> This is intended as a survey.
>
> Fortran 90 allows us to initialize variables, a nice and useful feature but
> initialized variables are automatically SAVEd.
> I find this rule somewhat annoying and even potentially dangerous in
> parallel and object-oriented programming.
> When calling a procedure with an initialized variable, e.g. to set proper
> default values (which is probably the right way of thinking about initial
> values in most cases), any change to this variable SAVEs the new value.
> At any subsequent call this new value is used. However, it is not always
> clear in which order procedure calls will occur and so I have to revert to
> the old style and initialize variables in separate statements to enforce
> the defaults.
>
> In my view the default SAVE rule should be scrapped. If the variable must be
> saved, an explicit SAVE can be added as an attribute. This seems to be a much
> cleaner and safer solution.
>
> What are your opinions about this? If there is overwhelming support for my
> position could the standard by changed? What arguments speack against my
> position (beyond backward compatibility)?
>
I agree with your objections to this rule, BUT it is not so unintuitive
if
you take into account that in Fortran, anything in the declaration part
of
a subroutine is NOT an executable statement, but is only effective at
compile-time. With this point of view the only way to set default values
valid at each call is to include explicit statements. And with this
point
of view an initialization makes sense only if the variable is SAVEd.
Regards
--
Pierre Hugonnet Seismic Data Processing R&D
COMPAGNIE GENERALE DE GEOPHYSIQUE
mail: 1 rue Leon Migaux phone.....(33) 164 47 45 59
91341 MASSY fax.......(33) 164 47 32 49
FRANCE [log in to unmask]
My opinions are not necessarily those of CGG (nor those of JPII)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|