COMMON statement

Standard: F77 F90 F95 F2003 F2008 F2018


<Syntax>

COMMON [ cblock ] objlist [ [ , ] cblock objlist ]...

cblock ::= / [ common-block-name ] /
objlist ::= object [ , object ]...
object ::= variable-name [ ( array-spec ) ]

<Semantics>

The COMMON statement declares one or more common blocks. One common block may be unnamed ("blank common"), all the others must have names. Multiple COMMON statements for a single common block are interpreted by concatenating the lists of variables.

A common block is a global entity; a common block cannot have the same name as an external procedure. A named common block must be declared to have the same size in every subprogram that uses it.

A common block can be given the BIND attribute; in this case it interoperates with an extern C structure whose members are compatible with the variables in the common block. This works as if the common block were a BIND(C) derived-type variable.

Because the use of common blocks is very error-prone, it is recommended to use MODULEs instead.

COMMON is considered obsolescent in Fortran 2018.

<Related>

BIND attribute, BLOCK DATA subprogram, MODULE statement