1

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)?

francescalus
  • 30,576
  • 16
  • 61
  • 96
ron
  • 967
  • 6
  • 23
  • Which compiler/OS do you use? – francescalus Apr 11 '16 at 15:03
  • I am using Intel Parallel Studio XE 2016, where ifort --version reports 16.0.0. I have edited the code to now be syntactically compatible with gfortran-4.8 but i get runtime errors. So i plan on sticking with Intel ifort. – ron Apr 11 '16 at 15:30
  • To be honest if you can't get it to work with both gfortran and the intel compiler I fear you have larger problems than the above. With intel you are compiling with all debugging options turned on? – Ian Bush Apr 11 '16 at 15:36
  • I had compiled with both gfortran-4.8 and ifort with -warn all and got what was over 100 warnings down to less than 10 which are now just "this variable has not been used" because of the way variables were grouped into include files and are only used within IF statements in files. Forgot to mention, operating system is linux. Suse 11. – ron Apr 11 '16 at 16:57
  • 2
    Have a read of http://stackoverflow.com/questions/12916176/gfortran-for-dummies-what-does-mcmodel-medium-do-exactly It also applies to the Intel compiler. – IanH Apr 11 '16 at 19:24

0 Answers0