PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Something equivalent to Gfortran's "no-automatic"

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
sectionboy



Joined: 13 Nov 2011
Posts: 5

PostPosted: Thu Mar 22, 2012 3:24 pm    Post subject: Something equivalent to Gfortran's "no-automatic" Reply with quote

Hello,
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 stackoverflow.com explains the situation:
Quote:
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).
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6218
Location: The Portland Group Inc.

PostPosted: Thu Mar 22, 2012 3:44 pm    Post subject: Reply with quote

Hi sectionboy,

Use "-Msave".
Quote:

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


Hope this helps,
Mat
Back to top
View user's profile
sectionboy



Joined: 13 Nov 2011
Posts: 5

PostPosted: Thu Mar 22, 2012 3:48 pm    Post subject: Reply with quote

Thanks a lot!
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group