next up previous contents index
Next: Restrictions Up: Using Common Blocks Previous: Storage Units

SAVE Statements and Common Blocks

 

Items in common blocks may become undefined when a procedure returns control to the calling unit just like local variables and arrays. This will not, however, occur in the case of the blank common block nor in any common block which is also declared in a program unit which is higher up the current chain of procedure calls. Since the main program unit is always at the top of the chain any common block declared in the main program can never become undefined in this way. In all other cases it is prudent to use SAVE statements.

The individual items in common blocks cannot be specified in a SAVE statement, only the common block name itself. Thus:

 
       SAVE /SAME/, /DEMO/

If a common block is saved in any program unit then it must be saved in all of them. The SAVE statement ought therefore to be included with the COMMON and associated type statements if INCLUDE statements are used. If the program is later modified so that the common block is also declared in the main program this will bring a SAVE statement into the main program unit, but although it then has no effect, it does no harm.



Mario Storti
Wed Nov 4 19:32:56 ART 1998