Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!helios!bcm!dimacs.rutgers.edu!seismo!uunet!mcsun!hp4nl!charon!dik From: dik@cwi.nl (Dik T. Winter) Newsgroups: comp.lang.fortran Subject: Re: SAVEing FORTRAN variables Message-ID: <2947@charon.cwi.nl> Date: 15 Feb 91 02:02:20 GMT References: <1991Feb15.000230.18585@news.arc.nasa.gov> Sender: news@cwi.nl Organization: CWI, Amsterdam Lines: 31 In article <1991Feb15.000230.18585@news.arc.nasa.gov> chau@xenon.arc.nasa.gov writes: > I am looking for a tool which scans FORTRAN source code and identifies > variables which should be saved. I do not think you need *that*. > > This is a simple example of a FORTRAN source code that needs to scan > and insert a SAVE statement: > subroutine sub (val) > integer val, i > data i/10/ > 10 val = val * i > i = i -1 > goto 10 > return > end > When subroutine sub is called the second time the value of i may not be the > same. I do not think the routine will be called a second time! :-) > Therefore, it needs to have a SAVE statement to make i become static. This conclusion is not valid. Changes to variables that are initialized through data statements are either on purpose, or not. In the second case you do not want an inclusion of a SAVE statement. What you want is a tool that signals all places where a variable becomes undefined (like I in your example on execution of the RETURN statement; if ever). I believe there are programs floating around that do that. The names 'FCHECK', 'TOOLPACK' appear to have some place in my memory. (Although I just mailed somebody about the non-portability of 'TOOLPACK', it is very useful if you can get it working.) -- dik t. winter, cwi, amsterdam, nederland dik@cwi.nl