COMMON blocks in Fortran

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

Thanks,
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
Email:      kahn@xxxxxxxxxxxxxxxxx
C**  ACCESS.CMN
C**  COMMON BLOCKS FOR AREA AND VOLUME PROGRAMS.
C**  PRESENT VERSION:  2 MARCH 83
C
	PARAMETER (COVDFT = 0.77)
	PARAMETER (VDWDFT = 1.80)
	PARAMETER (MAXFIL = 2)
	PARAMETER (MAXATM = 15000)
	PARAMETER (ICT    = 2000)
	PARAMETER (NEDGEX  = 14)
	PARAMETER (NEDGEY  = 14)
	PARAMETER (NEDGEZ  = 14)
C
	DATA PROBE /1.40/
	DATA ZSTEP /0.25/
C
c     This COMMON removed to main program. PCK 9/9 1998
c  	COMMON /FILES/  FNAME
C
c       FTYPE, RES3, ATM set to character*4 to comply with g95.  PCK 6/4/2010
        character*4 ftype, res3, atm
 	COMMON /BLOCK3/  NFILES,FTYPE(MAXFIL),IFLAG(MAXATM,4),
     1                RES3(MAXATM),ATM(MAXATM)
C
	COMMON /ACCESS/  X(MAXATM),Y(MAXATM),Z(MAXATM),RADIUS(MAXATM),
     1                VDWRAD(MAXATM),COVRAD(MAXATM),ERADSQ(MAXATM),
     2		 KEY(MAXATM),RMAX,XMIN,YMIN,ZMIN,XMAX,YMAX,
     3		 ZMAX,PROBE,ZSTEP
C 
 	COMMON /CUBES/   ITAB(MAXATM),CUBE(NEDGEX,NEDGEY,NEDGEZ,2),
     1		 ICUBE(MAXATM)
C
	COMMON /OUTPUT/  NLT,NEQ,NGT,NTOTAL
C
	COMMON /AREA/    INOV(ICT),ARCI(ICT),ARCF(ICT),
     1                DX(ICT),DY(ICT),D(ICT),DSQ(ICT)
C
	COMMON /ETC/     KARC,II,IR,RR,RSECR,PI,PIX2
C
	INTEGER CUBE

C**  old pareameters...   ICT 2000

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux