-save compiler option question

-save compiler option question

Operating System: Red Hat Enterprise Linux 5.3
Intel Fortran Compiler: ifort (IFORT) 13.0.1 20121010

According to the Intel Fortran documentation, the –save compiler option saves all variables in static allocation except local variables within a recursive routine and variables declared as AUTOMATIC. I recently discovered what appears to be a difference in the interpretation of this option between two different computer systems.

Consider the following code segment which is called multiple times:

DOUBLE PRECISION Function GetValue(a, b, c, d)
WRITE(6,10) GetValue
10 FORMAT(F8.4)
GetValue = a + b + c + d

On a SGI UNIX system with the code segment compiled with the -static option (equivalent to -save and -zero), the previous value of GetValue has been saved and is printed out. Under RHEL 5.3 with the code segment compiled with the –save and -zero options, the previous value of GetValue has not been saved and is printed as zero. Is this a compiler bug?


2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

GetValue here is a function result, not a variable. It may well be that -save doesn't apply to it. You're not allowed to SAVE a function result, so it would not astonish me if -save didn't work here either. Please don't make assumptions on how -save is implemented. I think you are on very shaky ground trying to depend on this behavior.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today