Something equivalent to Gfortran's "no-automatic"

I have some very old code which uses this “implicit save” attribute. Basically, all the local variables are static. I am wondering if PGfortran has something equivalent to Gfortran’s “no-automatic” option? Thanks.

Someone at explains the situation:

In Fortran 77 & 90/95/2003, if you want the value of a variable local to a subroutine preserved across subroutine calls, you should declare it the “save” attribute,…

This is one area in which experiments could be misleading – they will tell you what a particular compiler does, but perhaps not what the Fortran 77 language standard is, nor what other compilers did. > Many old Fortran 77 compilers didn’t place local variables on the stack and implicitly all variables had the save attribute, without the programming having used that declaration> . This, for example, was the case with the popular DEC Fortran compilers. It is common for legacy Fortran 77 programs that were used only with a particular compiler of this type to malfunction with a modern compiler because programmers forgot to use the save attribute on variables that needed it. Originally this didn’t cause a problem because all variables effectively had the save attribute. Most modern compilers place local variables without save on the stack, and these programs frequently malfunction because some variables that need “save” “forget” their values across subroutine calls. This can be fixed by identifying the problem variables and adding save (work), adding a save statement to every subroutine (less work), or > many compilers have an option (e.g., -fno-automatic in gfortran) to restore the old behavior (easy)> .

Hi sectionboy,

Use “-Msave”.

% pgfortran -help -Msave
-M[no]save Assume all variables have SAVE attribute

Hope this helps,

Thanks a lot!