I have written a Fortran 90 code to extract angles from molecular simulation data.
In this code I used a module with name all_parameter
. In this module I defined an array such as: CH_Angles
INTEGER,PARAMETER :: totalFrames = 32000
INTEGER,PARAMETER :: AAA=75
REAL,DIMENSION(45:AAA,1:256,1:totalFrames) :: CH_Angles
If I use the value of AAA = 75
, I can compile this code without any error and I can get the values I wanted. But if I change the value of AAA
to be AAA=105
, then I get some error messages as shown below:
gfortran lipid-Tilt-Magnitude-thermo-cello.f90
/tmp/ccXOhMqQ.o: In function `__all_parameter_MOD_find_angle_ch':
lipid-Tilt-Magnitude-thermo-cello.f90:(.text+0x35): relocation truncated to fit: R_X86_64_32S against symbol `__all_parameter_MOD_x' defined in .bss section in /tmp/ccXOhMqQ.o
lipid-Tilt-Magnitude-thermo-cello.f90:(.text+0x48): relocation truncated to fit: R_X86_64_32S against symbol `__all_parameter_MOD_y' defined in .bss section in /tmp/ccXOhMqQ.o
lipid-Tilt-Magnitude-thermo-cello.f90:(.text+0x5b): relocation truncated to fit: R_X86_64_32S against symbol `__all_parameter_MOD_z' defined in .bss section in /tmp/ccXOhMqQ.o
lipid-Tilt-Magnitude-thermo-cello.f90:(.text+0x6e): relocation truncated to fit: R_X86_64_32S against symbol `__all_parameter_MOD_x' defined in .bss section in /tmp/ccXOhMqQ.o
lipid-Tilt-Magnitude-thermo-cello.f90:(.text+0x81): relocation truncated to fit: R_X86_64_32S against symbol `__all_parameter_MOD_y' defined in .bss section in /tmp/ccXOhMqQ.o
lipid-Tilt-Magnitude-thermo-cello.f90:(.text+0x94): relocation truncated to fit: R_X86_64_32S against symbol `__all_parameter_MOD_z' defined in .bss section in /tmp/ccXOhMqQ.o
/tmp/ccXOhMqQ.o: In function `__all_parameter_MOD_find_mid_point_vector':
lipid-Tilt-Magnitude-thermo-cello.f90:(.text+0x126): relocation truncated to fit: R_X86_64_32S against symbol `__all_parameter_MOD_x' defined in .bss section in /tmp/ccXOhMqQ.o
lipid-Tilt-Magnitude-thermo-cello.f90:(.text+0x139): relocation truncated to fit: R_X86_64_32S against symbol `__all_parameter_MOD_y' defined in .bss section in /tmp/ccXOhMqQ.o
lipid-Tilt-Magnitude-thermo-cello.f90:(.text+0x14c): relocation truncated to fit: R_X86_64_32S against symbol `__all_parameter_MOD_z' defined in .bss section in /tmp/ccXOhMqQ.o
lipid-Tilt-Magnitude-thermo-cello.f90:(.text+0x15f): relocation truncated to fit: R_X86_64_32S against symbol `__all_parameter_MOD_x' defined in .bss section in /tmp/ccXOhMqQ.o
lipid-Tilt-Magnitude-thermo-cello.f90:(.text+0x172): additional relocation overflows omitted from the output
collect2: ld returned 1 exit status
vijay@glycosim:~/Simulation-Folder-Feb2013/chapter5-thermo-paper2-Vj/thermo2-Analysis/analysis-bcm-/23_acf-tail-tilt-angle-bcm-thermo2/chain1/acf-chain1-CH-bcm-thermo-all-layers$ gfortran lipid-Tilt-Magnitude-thermo-cello.f90
I also tried compiling this code with different values for AAA. With a value 80, the compilation goes without error. But, if the AAA is 85, then the compilation stop with error messages.
I found the AAA=82 is the limiting value. Any value of AAA more than 82, it gives error.
I can not figure out what causes the error.
Is there anyway to find solution for this issue?
Note: I am using gfortran compiler from Ubuntu 11.10 64 bit with 16 GB RAM memory.
The error you get is returned by the linker because the size of the statically-allocated block exceeds the range of what can be addressed by a 32-bit addressing instruction, which is 2 GB. This is irrelevant of whether you index your array using 32-bit or 64-bit integers - the problem is related to the total size of a statically-allocated array. This is explained in details here:
gfortran for dummies: What does mcmodel=medium do exactly?
In order to work around this, as you have noticed, you can compile your code with -mcmodel=medium
or -mcmodel=large
. Statically-allocated arrays larger than 2 GB are then allowed.
A better way to deal with this, but involves more work, is to dynamically allocate any large arrays.
If I remember aright, gfortran, like most current Fortran compilers, still defaults to 4-byte integers even on 64-bit hardware. This means, inter alia, that the largest array index will be 2^31
or 2^32
. Since multi-rank arrays are just a convenient wrapper for rank-1 arrays it's no surprise to me (or to @MikeDunlavey) that your compiler baulks at allocating an array with so many elements as you want.
Try using 64-bit integers for array indexing. You could do this either by explicitly setting the kind for them, eg
use, intrinsic :: iso_fortran_env, only : int64
...
INTEGER(int64),PARAMETER :: totalFrames = 32000
INTEGER(int64),PARAMETER :: AAA=75
REAL,DIMENSION(45_int64:AAA,1_int64:256_int64,1_int64:totalFrames) :: CH_Angles
or by using a compiler flag to set the default size of integers to 64 bits. For gfortran this would be -fdefault-integer-8
.
I won't guarantee that this will work for gfortran, which is not a compiler I use regularly, but it does for Intel Fortran.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With