Path: utzoo!attcan!uunet!cs.utexas.edu!usc!ucsd!pacbell.com!lll-winken!rogue.llnl.gov From: ray@rogue.llnl.gov (Ray, Scott) Newsgroups: comp.lang.fortran Subject: COMMON and SAVE statements Message-ID: <65861@lll-winken.LLNL.GOV> Date: 3 Aug 90 09:05:43 GMT Sender: usenet@lll-winken.LLNL.GOV Reply-To: ray@rogue.llnl.gov Organization: Lawrence Livermore National Laboratory-Engineering Lines: 28 I have been taught that it is good programming practice to use SAVE statements in conjunction with labeled COMMON blocks to insure that the variables in COMMON get saved when exiting a program module. Apparently, the FORTRAN 77 standard makes no such guarantee unless the SAVE statement is used. Thus, when writing my own codes I religiously stick in the SAVE statement. However, I work with a lot of hand-me-down codes written by other people who take no such precautions and have never encountered any problems that could be traced to the COMMON variables being lost due to the lack of a SAVE statement. So, two questions come to mind: 1. Are there any quasi-FORTRAN 77 compliant compilers on machines in widespread use in the 1990's where COMMON variables can actually become undefined when a program module is exited and a SAVE statement has not been used? In other words, is the SAVE statement really necessary in practice (ignoring the standard)? If so, on which machines and under what conditions? 2. What could possibly be the motivation for the standard allowing variables in COMMON to be become undefined without a SAVE statement? I can't think of a case where this would be desirable behavior. Hence why isn't it built into the COMMON framework? Note that I am restricting these questions to variables in COMMON. Using a SAVE with local variables is a much more understandable issue. Scott Ray ray@icdc.llnl.gov