"relocation truncated to fit" compilation error
From Planets
Revision as of 17:11, 6 July 2023 by Emillour (talk | contribs) (Created page with "== The symptoms == If when you compile the PCM you get an error message of the likes of <pre> ... relocation truncated to fit: R_X86_64_PC32 against symbol ... </pre> while c...")
The symptoms
If when you compile the PCM you get an error message of the likes of
... relocation truncated to fit: R_X86_64_PC32 against symbol ...
while compiling the lon-lat PCM with a large grid (e.g. 360x180x...), this is because all the static arrays defined in the code are so large that in the end indexing from one location of the executable to another can no longer be supported by integers, which is the default way to proceed.
The cure
With adequate compiling and linking options this can be solved. In practice with the gfortran compiler you 'll need to add
-mcmodel=medium
And with the ifort compiler
-mcmodel=large -shared-intel
will do the trick.
The gory details
This page https://stackoverflow.com/questions/12916176/gfortran-for-dummies-what-does-mcmodel-medium-do-exactly#12957457 actually sum it all nicely