gpt4 book ai didi

fortran - 大型数组的 Fortran 中出现 `Relocation truncated to fit` 错误

转载 作者:行者123 更新时间:2023-12-02 11:00:41 28 4
gpt4 key购买 nike

我编写了一个 Fortran 90 代码来从分子模拟数据中提取角度。在此代码中,我使用了名为 all_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,都会出错。

我无法找出导致错误的原因。

有办法解决这个问题吗?

注意:我使用 Ubuntu 11.10 64 位的 gfortran 编译器,具有 16 GB RAM 内存。

最佳答案

您收到的错误是由链接器返回的,因为静态分配 block 的大小超出了 32 位寻址指令可以寻址的范围,即 2 GB。这与您使用 32 位还是 64 位整数对数组进行索引无关 - 该问题与静态分配数组的总大小有关。这里有详细解释:

gfortran for dummies: What does mcmodel=medium do exactly?

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

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

关于fortran - 大型数组的 Fortran 中出现 `Relocation truncated to fit` 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20687170/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com