Top: f77 Up: 13 - Statements
Previous: 13,12 - CLOSE Next: 13,14 - CONTINUE


Section 13,13: COMMON

 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;
 subsequent 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.

                                NOTE

         Note that on U*X on  RISC  systems,  when  multiple
         object modules declare the same named COMMON block,
         all modules must declare the COMMON block to be the
         same  size,  or  the  module that gets loaded first
         must declare the COMMON block  to  be  its  maximum
         defined length.  If the common block is initialized
         by a DATA statement, then the module containing the
         initialization  must declare the common block to be
         its maximum defined length.

         This limitation does not apply if you  compile  all
         source  modules  together  using full optimization,
         which allows  interprocedural  analysis  to  handle
         COMMON  block size differences.  Loading of modules
         occurs in the order in which they are specified  on
         the compiler command line.


Top: f77 Up: 13 - Statements
Previous: 13,12 - CLOSE Next: 13,14 - CONTINUE