Next: , Previous: Variables Assumed To Be Zero, Up: Working Programs


14.4.3 Variables Assumed To Be Saved

Many Fortran programs were developed on systems that saved the values of all, or some, variables and arrays across procedure calls. As a result, many of these programs depend, sometimes inadvertently, on being able to assign a value to a variable, perform a RETURN to a calling procedure, and, upon subsequent invocation, reference the previously assigned variable to obtain the value.

They expect this despite not using the SAVE statement to specify that the value in a variable is expected to survive procedure returns and calls. Depending on variables and arrays to retain values across procedure calls without using SAVE to require it violates the Fortran standards.

You can ask g77 to assume SAVE is specified for all relevant (local) variables and arrays by using the -fno-automatic option.

Note that a program that works better when compiled with the -fno-automatic option is almost certainly depending on not having to use the SAVE statement as required by the Fortran standard. It might be worthwhile finding such cases and fixing them, using techniques such as compiling with the `-O -Wuninitialized' options using g77.