Defining Variables, Arrays, And Memory |
The items in 'nlist' following a common block name (or omitted name) are declared to be in that block (or in blank common). If a common block name is omitted, the statement refers to the blank common block. If the first common block name is omitted in the above format, the slashes may be omitted also. The slashes must be present, however, if blank common is specified as other than the first common block.
The same common block name (or blank) can appear in other COMMON statements, either in the same program unit or in other program units. This is how items in different program units are associated in memory. All common blocks hav- ing the same name also have the same starting address in memory. The same is true of all declarations of blank common. Only one blank common can exist in the final linked program.
3.4.2.1 Common Block Memory Sequence.
A common block memory sequence consists of the memory of all items listed in the COMMON statement(s) for that common block, in the order of their appearance within the COMMON statement(s).
An EQUIVALENCE statement may cause a common block to be extended. This is done by adding memory beyond the highest location in the common block. An EQUIV ALENCE statement must not cause two different common blocks in the same program unit to be associated. Names associated with a name in a common block are considered to be part of that common block.
3.4.2.2 Named and Blank Common Blocks.
Named and blank common blocks are treated differently in several respects.
•Within a program, all common blocks having the same name must also be the same size. Blank common
•Executing a RETURN or END statement sometimes causes items in named common blocks to become undefined. This cannot occur with blank common.
•DATA statements in a BLOCK DATA subprogram can only initialize items in named common blocks.
Examples:
COMMON IBLOCK1/A,B,ROOTS /I TABLES(3,3) LOGICAL LOGICS(3,3),Z
COMMON X,Y,Z
C PREVIOUS STATEMENT EXTENDS BLANK COMMON COMMON IBLOCK1/C
C 'BLOCK1'IS NOW EXTENDED BY LENGTH OF 'C' EQUIVALENCE (Z,LOGICS(1, 1))
CBLANK COMMON EXTENDED
3.4.3BLOCK DATA Subprograms
BLOCK DATA subprograms are used to initialize variables and array elements in named common blocks. The first statement of such a subprogram is the BLOCK DATA statement, which mayor may not name the BLOCK DATA subprogram. The last statement must be the END statement. The only other statements permitted in a BLOCK DATA subprogram are IMPLICIT, DIMENSION, COMMON, SAVE, EQUIVALENCE, DATA, and the type statements.