Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

-zero and -save

cjosefy
Beginner
532 Views
Using 8.1.023:
Could someone provide an example where -zero makes a difference in their output? I've been trying to do a sanity check, but I must be off someplace.
Using the following code:
Code:
PROGRAM ZERO_SAVE

WRITE(*,*) IA

END
If I compile WITHOUT -save, I get the output:
0
I guess intrinsic variables that aren't save get initialized to zero?
If I compile with -save, I get the output:
0
This time, the variable IA is statically allocated (verified with nm).
So, is there a short example where you do need to use -zero? I can't seem to get the code to output bad results. When I compile with g77 I get nonsense output which is what I was expecting to get from ifort, since I never compiled with -zero.
Thanks!
0 Kudos
2 Replies
cjosefy
Beginner
532 Views
bump
0 Kudos
Steven_L_Intel1
Employee
532 Views
It is more likely to affect subroutines, and can depend on optimization choices. My advice is to always explicitly initialize your variables and don't depend on values starting as zero.
0 Kudos
Reply