Next: Faster Programs, Previous: Working Programs, Up: Collected Fortran Wisdom
These options should be used only as a quick-and-dirty way to determine how well your program will run under different compilation models without having to change the source. Some are more problematic than others, depending on how portable and maintainable you want the program to be (and, of course, whether you are allowed to change it at all is crucial).
You should not continue to use these command-line options to compile a given program, but rather should make changes to the source code:
-finit-local-zero
Many other compilers do this automatically, which means lots of Fortran code developed with those compilers depends on it.
It is safer (and probably
would produce a faster program) to find the variables and arrays that
need such initialization and provide it explicitly via DATA
, so that
-finit-local-zero is not needed.
Consider using -Wuninitialized (which requires -O) to find likely candidates, but do not specify -finit-local-zero or -fno-automatic, or this technique won't work.
-fno-automatic
SAVE
statements.)
Many other compilers do this automatically, which means lots of Fortran code developed with those compilers depends on it.
The effect of this is that all non-automatic variables and arrays
are made static, that is, not placed on the stack or in heap storage.
This might cause a buggy program to appear to work better.
If so, rather than relying on this command-line option (and hoping all
compilers provide the equivalent one), add SAVE
statements to some or all program unit sources, as appropriate.
Consider using -Wuninitialized (which requires -O)
to find likely candidates, but
do not specify -finit-local-zero or -fno-automatic,
or this technique won't work.
The default is -fautomatic, which tells g77 to try and put variables and arrays on the stack (or in fast registers) where possible and reasonable. This tends to make programs faster.
Note: Automatic variables and arrays are not affected
by this option.
These are variables and arrays that are necessarily automatic,
either due to explicit statements, or due to the way they are
declared.
Examples include local variables and arrays not given the
SAVE
attribute in procedures declared RECURSIVE
,
and local arrays declared with non-constant bounds (automatic
arrays).
Currently, g77 supports only automatic arrays, not
RECURSIVE
procedures or other means of explicitly
specifying that variables or arrays are automatic.
-f
group-intrinsics-hide
EXTERNAL
for any external procedure
that might be the name of an intrinsic.
It is easy to find these using -fgroup-intrinsics-disable.