A compile-time diagnostic that a standard-conforming processor shall be required to detect and report in a future revision of the standard. Consider the following:
real, save :: x = 1.0 !<-- ok, conforming
real :: x = 1.0 !<-- NOT ok, compiler shall be required to detect and report the missing SAVE attribute
And I fully agree, this is an incompatible change in that codes which conform now will be deemed nonconforming in a future version of the compiler.
But it is one that I ask the Fortran Community to willingly accept because the implied SAVE aspect behind a statement such as real :: x = 1.0
is rather pernicious.
No, that is not what I am after - see my code snippet above. My intention is to simply require the SAVE
attribute in explicit initialization statements and thus eliminate the implied SAVE
that way.
What you write is irrelevant. As suggested above, my proposal will be very brief. It will call for the programmer to explicitly declare the SAVE attribute if they employ explicit initialization. Thus variables in standard Fortran will continue to have the option to have the SAVE attribute. And it will be a must if the programmer chooses explicit initialization. That is it.
But the programmers, once they realize what explicit initialization entails, will mostly avoid it and that will be a good thing. On the other hand, I do have other ideas for “default initialization” of local objects in Fortran subprograms ( somewhat like derived components) but that is a discussion for another thread, some other day - but I don’t see any backward compatibility issue with this other idea.
My proposal will involve no changes to DATA
, I will leave the DATA
statements as they are - unchanged, whatever be their warts. In a subtle manner though, I am decoupling the DATA
from explicit initialization with implied SAVE
i.e., undoing the damage from the Fortran 90 revision. So Fortran 90 did the following:
..
real :: x
data x / 1.0 /
is considered to be equivalent to
real :: x = 1.0
Instead my change will require the equivalent statement to the DATA
one to be:
real, save :: x = 1.0 !<-- must have to declare the explicit SAVE attribute
I do use a lot of technical and simulation codes written in Fortran and other languages in a consulting capacity, do help improve some of them, and also help troubleshoot issues with them.
However a bigger responsibility for me is to decode many of the existing Fortran programs - some I had authored using Fortran 2003 thru’ 2018 - in plain engineering / scientific / mathematical / algorithmic terms, so that those with predominantly IT backgrounds in C++, C#, VB, Python, C, etc. can migrate the codes away from Fortran and write them in other languages as chosen by powers-that-be.
I don’t get to write much code myself any more, mostly I author small, illustrative examples in modern C++, C#, etc. (occasionally modern Fortran) to help other younger engineers with numerical algorithm development and technical code designs.