next up previous contents index
Next: BLOCK DATA Program Units Up: Common Blocks Previous: Blank Common Blocks

COMMON Statement

 

A program unit may contain any number of COMMON statements, each of which can define contents for any number of different common blocks. COMMON statements are specification statements and have a general form:

COMMON / name/ list-of-items , / name / list-of-items ...

Each name is defined as a common block name, which has global scope. The Fortran Standard allows it to use the same name as an intrinsic function, a local variable, or local array but not that of a named constant or an intrinsic function. Each list of items can contain names of variables and arrays. The array name may be followed by a dimension specification provided that each array is only dimensioned once in each program unit. The comma shown before the second and subsequent block-name is optional.

The name of the blank common block is normally specified as two consecutive slashes (ignoring any intervening blanks) but if it is the first block in the statement then the pair of slashes may be omitted.

The contents of a common block are a concatenation of the all the definitions for it in the program unit. Thus:

 
       COMMON /ONE/ A, B, C, /TWO/ ALPHA, BETA, GAMMA 
       COMMON /TWO/ DELTA

defines two blocks, /ONE/ contains three items while /TWO/ contains four of them.

In procedures, variables which are dummy arguments or which are the same as the function name cannot appear in common blocks.



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