FORTRAN Reference Manual
Program Units
FORTRAN Reference Manual—528615-001
4-14
Using Common Blocks
If the actual argument is an array name, the length of the associated dummy argument
is the length of an array element in the actual argument array.
Using Common Blocks
Common blocks define a common storage area whose contents can be referenced by
two or more program units. All subprograms that contain a declaration of the same
common block can define and reference the entities included in that common block.
The use of common blocks can reduce memory requirements as well as execution
time.
You can declare common blocks either as blank common or named common blocks:
COMMON name-list <-- blank common
COMMON / block-name/ name-list <-- named common
A program can contain more than one named common block, but only one unnamed
common block. The list of names in the common statement specifies the variables and
arrays that you can access from any program unit that declares that common block.
FORTRAN associates entities in common blocks by storage rather than by name. This
means that the order of names in COMMON statements determines which variable
names or array element names are associated among program units. In the following
example, FORTRAN associates the variable JDEPT in the main program with the
variable LOC in the subroutine; it associates SALARY with WAGE, and VACATION
with TIME OFF:
PROGRAM MAIN
COMMON /employee/jdept, salary, vacation
SUBROUTINE overtime
COMMON /employee/loc, wage, time off
Considerations
•
Associated entities in common blocks must correspond with respect to type.
•
If a common block contains a character variable or character array, all names in
that block must store character values.
•
COMMON statements are nonexecutable and must precede all DATA and
executable statements in the program unit.
•
HP FORTRAN allows a common block to have the same name as a program unit.
The ANSI standard does not permit this.










