PSS ID Number: 102691
Article Last Modified on 11/6/1999
If the data in a COMMON block is not initialized in any routine,
COMMON block declarations with different sizes should not cause any
problems and you can link the object files with the varying
declarations in any order. Each declaration must be in a separate
source file or the FORTRAN compiler generates an error.
The application should initialize the COMMON block in only one
location. LINK32 ignores subsequent COMDAT records and does not
adjust the amount of storage set aside for the COMMON block. If the
first COMDAT record in the file is smaller than subsequent COMDAT
records, LINK32 does not generate an error message. However, when
you run the application it could corrupt memory. Generating
debugging information with the /4Yb compiler option switch does not
catch this condition because each array in a COMMON block is
correctly dimensioned in each object module.
If LINK32 encounters a COMDEF record before a COMDAT record, the
size of the COMDEF record must agree with the size of the COMDAT
record. Otherwise, LINK32 generates the LNK2133 error and the link
fails.
C Compiler options needed: /c
program tester
integer arr
common /testblk/ arr(1)
data arr /11/
call sub1
print*, arr(1000000)
end
C Compiler options needed: /c
subroutine sub1
integer arr
common /testblk/ arr(1000000)
arr(1000000) = 99
end
C Compile options needed: /c
subroutine sub1
integer arr
common /testblk/ arr(1000000)
data arr /1000000*77/
arr(1000000) = 99
end
Additional query words: 1.00
Keywords: KB102691
Technology: kbAudDeveloper kbFORTRANPower100DOS kbFortranSearch kbZNotKeyword3