COMMON blocks in Fortran

Peter Kahn
Mon Jun 7 13:50:00 GMT 2010

Dear Gnu People:

    I've downloaded g95 for Linux and am trying to get a program from 
the 1980s to run.  Although originally written for a Vax, I converted it 
for SGI Unix, and it has run without problems for years. Our remaining 
SGIs, however, are being replaced by machines running Linux.  Presumably 
the program was compiled under an SGI version of Fortran 77.

    The program consists of a main and several subroutines.  A set of 
COMMON blocks is inserted into each of these via an INCLUDE statement.  
The included file is attached.  When I compile under g95, the compiler 
gives an error message, saying that COMMON ACCESS is already initialized 
in another programming unit.  This message arises on encountering the 
first subroutine, the INCLUDE statement having occurred first in the 
main program and then in the subroutine.  Preceding COMMON ACCESS is 
another block, BLOCK3, but the compiler does not complain about that.  
This is perplexing; why did it not complain?

    I've read in a manual that COMMON blocks are no longer preferred and 
that MODULES are to be used to replace them.  The grounds given for this 
are that COMMONS can be used to hide a multitude of programming sins.  
These don't, and I'd like to avoid as much re-coding as possible.  How 
can I circumvent the error message?  One way might be to break the 
program into a set of separate files, each containing a subroutine or 
the main and compiling them separately, but that would be annoying, and 
I'm not sure it would work. What do you suggest?

Peter Kahn

Peter C. Kahn, Ph.D.
Professor of Biochemistry
Department of Biochemistry & Microbiology
Rutgers University
76 Lipman Drive
New Brunswick, NJ 08901

Telephone:  732-932-9255, ext. 120
Telefax:    732-932-8965
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: accesswork.cmn
URL: <>

More information about the Gcc-help mailing list