I have an old Fortran 77 code written around many subroutines, each subroutine in a separate file, and they make extensive use of COMMON
statements. I've profiled the code, out of the 18 total include files I found two that are the heavy hitters which declare the largest static arrays.
For example, my global.par
parameter file defines
C keep nodes/elements below 400000 / 600000 to prevent relocation
C truncated to fit compiler error
INTEGER MAXNODES
PARAMETER ( MAXNODES = 1000000 )
INTEGER MAXELEMS
PARAMETER ( MAXELEMS = 4000000 )
then this parameter file I now include in two re-written include files that I turned into modules. However each of these new module files does everything the same as before in regards to declaring static arrays such as
C this module file name is aa_module.f
MODULE AA
IMPLICIT NONE
INCLUDE 'global.par'
REAL NODES (3, MAXNODES)
REAL NODES2 (3, MAXNODES)
INTEGER EL1 (12, MAXELEMS)
INTEGER EL2 (12, MAXELEMS)
C and so on, many more arrays based around MAXNODES & MAXELEMS
END MODULE AA
When I compile and link the program, if I keep the MAXNODES
and MAXELEMS
small things will work. But I need to handle large models so when I jack up those values I still get the message
relocation truncated to fit: R_X86_64_32S against symbol... defined in COMMON section in AA_module.o.
What is the best solution to this? My knowledge of Fortran is limited.
If I create a new subroutine, called Init_big_arrays
for example, and ALLOCATE
all those arrays in Module AA at runtime will that solve this problem, keeping in mind there are still 16 or so other include files that declare a bunch of static integer and real arrays based on parameters in the global.par
file but the worst of those is something like INTEGER ID(256,256)
and CHARACTER*256 NAME(3,256)
?