VMS Help FORTRAN, Statements, COMMON *Conan The Librarian (sorry for the slow response - running on an old VAX) |
Defines one or more contiguous blocks of storage shared among separate subprograms. You can define the same common block in different program units of your program. The first COMMON statement in a program unit to name a common block defines it; later COMMON statements that name the block reference it. You can leave one common block (the "blank" common block) unnamed. Statement format: COMMON [/[cb]/]nlist[[,]/[cb]/nlist]... cb Is a symbolic name to identify the common block. nlist Is one or more names of variables, arrays, array declarators, or records to identify elements of the common block. Any common block name, blank or otherwise, can appear more than once in one or more COMMON statements in a program unit. The list following each successive appearance of the same common block name is treated as a continuation of the list for the block associated with that name. You can use array declarators in the COMMON statement to define arrays. A common block can have the same name as a variable, array, record, structure, or field. However, in a program with one or more program units, a common block cannot have the same name as a function, subroutine, or entry name in the executable program. When common blocks from different program units have the same name, they share the same storage area when the units are combined into an executable program. Entities are assigned storage in common blocks on a one-for-one basis. Thus, the entities assigned by a COMMON statement in one program unit should agree with the data type of entities placed in a common block by another program unit; for example, consider a program unit containing the following statement: COMMON CENTS Consider another program unit containing the following statements: INTEGER*2 MONEY COMMON MONEY When these program units are combined into an executable program, incorrect results can occur if the 2-byte integer variable MONEY is made to correspond to the lower-addressed two bytes of the real variable CENTS.
|