How FORTRAN allocates addresses for COMMON blocks?
Andrew Klossner
andrew at frip.gwd.tek.com
Wed Jul 27 02:18:35 AEST 1988
[]
"Does anybody out there have any idea how the different FORTRAN
compilers for UNIX assign addresses to COMMON blocks?"
Unix compilers don't assign addresses to COMMON blocks. The loader
does this. It does not guarantee any particular order on those blocks,
and the programmer cannot depend on an order.
One way to force an order to common blocks is to create an assembly
file which establishes the contents of those blocks in a particular
order and exports them. Your example:
COMMON /A/ IA(1)
COMMON /B/ IAVAIL(99),LWRD
might give rise to an ordering assembly file such as the following:
.data
.global _A_
_A_: .long 1 /* IA(1) */
.global _B_
_B_: .long 99 /* IAVAIL(99) */
.long 1 /* LWRD */
(Your assembler pseudo-ops may vary.)
Needless to say, this sort of programming is fragile and hard to
maintain. If you could reorganize your program not to depend on common
block ordering (perhaps by putting everything into one big common
block), you would be better off.
-=- Andrew Klossner (decvax!tektronix!tekecs!andrew) [UUCP]
(andrew%tekecs.tek.com at relay.cs.net) [ARPA]
More information about the Comp.unix.wizards
mailing list