Newsgroups: comp.lang.fortran
Path: utzoo!utgpu!news-server.csri.toronto.edu!helios.physics.utoronto.ca!alchemy.chem.utoronto.ca!system
From: system@alchemy.chem.utoronto.ca (System Admin (Mike Peterson))
Subject: Re: FORTRAN and (un)SAVEd vars
Message-ID: <1991Mar1.191239.28479@alchemy.chem.utoronto.ca>
Keywords: FORTRAN, SAVE, Toolpack
Organization: University of Toronto Chemistry Department
References: <112@smith.water.ca.gov>
Date: Fri, 1 Mar 1991 19:12:39 GMT

In article <112@smith.water.ca.gov> bsmith@caldwr.water.ca.gov (Bill Smith) writes:
>This severely limits the ability of the FORTRAN 
>compiler to optimize the code. (Apollo FORTRAN).   

On the Apollo system, using -O with f77 does result in a "flow analysis" that
can find some (but not all) variables that need to be saved. Look for
messages like "Use of uninitialized variable:" and "Assignment eliminated,
value never used:" - the former means that the variable is used before the
compiler thinks it got a value, and the former means that a variable appears
on the left side of an assignment but the routine never uses it again.
It can be fooled by conditional statements though, and by ENTRY
statements which expect values from other entry points to be preserved.
This analysis is not done for -g.

It seems to me that finding all such variables is an impossible task
for a routine of any complexity (e.g. containing conditional statements),
though I can see that a list of variables can be produced that do not
need to be saved under any circumstances (because they are always
defined before use in all possible paths throught the routine).
-- 
Mike Peterson, System Administrator, U/Toronto Department of Chemistry
E-mail: system@alchemy.chem.utoronto.ca
Tel: (416) 978-7094                  Fax: (416) 978-8775
