`重定位被截断以适应Fortran中带有大数组的`错误

`重定位被截断以适应Fortran中带有大数组的`错误,fortran,fortran90,gfortran,Fortran,Fortran90,Gfortran,我已经写了一个Fortran 90代码来从分子模拟数据中提取角度。 在这段代码中,我使用了一个名为all\u parameter的模块。在这个模块中,我定义了一个数组,例如:CH_Angles INTEGER,PARAMETER :: totalFrames = 32000 INTEGER,PARAMETER :: AAA=75 REAL,DIMENSION(45:AAA,1:256,1:totalFrames) :: CH_Angles 如果我使用AAA=75的值,我可以毫无错误地编译这

我已经写了一个Fortran 90代码来从分子模拟数据中提取角度。 在这段代码中,我使用了一个名为
all\u parameter
的模块。在这个模块中,我定义了一个数组,例如:
CH_Angles

INTEGER,PARAMETER :: totalFrames = 32000  
INTEGER,PARAMETER :: AAA=75
REAL,DIMENSION(45:AAA,1:256,1:totalFrames) :: CH_Angles
如果我使用
AAA=75
的值,我可以毫无错误地编译这段代码,并且可以得到我想要的值。但是如果我将
AAA
的值更改为
AAA=105
,则会收到一些错误消息,如下所示:

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
我还尝试用不同的AAA值编译这段代码。如果值为80,则编译不会出错。但是,如果AAA为85,则编译将停止并显示错误消息

我发现AAA=82是极限值。AAA的任何值超过82,都会产生错误

我想不出是什么原因造成了这个错误

有没有办法找到解决这个问题的办法


注意:我使用的是Ubuntu11.10 64位gfortran编译器,内存为16GB。

您的数组
Chu Angles
的大小超过了1GB,因此索引算法将超过32位限制。
如果我没记错的话,gfortran,像大多数当前的Fortran编译器一样,即使在64位硬件上,仍然默认为4字节整数。这意味着,除其他外,最大的数组索引将是
2^31
2^32
。由于多秩数组只是秩1数组的一个方便的包装器,所以我(或@MikeDunlavey)毫不奇怪,您的编译器在分配一个包含您想要的那么多元素的数组时会遇到困难

尝试使用64位整数进行数组索引。您可以通过显式设置它们的种类来实现这一点,例如

或者使用编译器标志将整数的默认大小设置为64位。对于gfortran,这将是
-fdefault-integer-8


我不能保证这对gfortran有效,因为gfortran不是我经常使用的编译器,但对Intel Fortran有效。

链接器返回您得到的错误,因为静态分配的块的大小超出了32位寻址指令可以寻址的范围,即2 GB。这与是否使用32位或64位整数为数组编制索引无关-问题与静态分配数组的总大小有关。以下将对此进行详细说明:

为了解决这个问题,正如您所注意到的,您可以使用
-mcmodel=medium
-mcmodel=large
编译代码。然后允许静态分配大于2 GB的阵列


处理此问题的更好方法是动态分配任何大型阵列,但需要更多的工作。

您将在这个问题的答案中找到问题的解决方案和详细的解释:您能否提供一个最小但完整的代码示例来重现错误?请研究如何使阵列
可计算。
。亲爱的Mark,我使用的(-mcmodel=large)发布在。这个很好用。谢谢你给我一些提示。顺便说一句,这将是帮助充分,我可以得到一些关于(mcmodel=large)使用的解释。这实际上是做什么的?互联网上充斥着解释mcmodel是关于什么、如何以及为什么使用它的网站。由于我的回答没有提及mcmodel(尽管它可能应该这样做),我没有责任向您解释。我所能提供的任何解释都是不充分的,而且很可能是不正确的,让你最喜欢的搜索引擎来帮助你。@user669212你有没有注意到我在上面的问题评论中发布的链接?这里的答案很好地解释了
-mcmodel
的作用以及在您的案例中为什么需要它。感谢您的解释。现在我能理解“mcmodel”的用法了。
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