我在 fortran 中为更复杂的程序编写了一个简单的子程序。我需要读取一个包含 3 列数字(X_halo、Y_halo、Z_halo)的文件,并将 3 列数据输入到 3 个数组中。在这个子程序中,我将数据写入一个文件,看看我是否可以真正读取它。我有一个 5000000(500 万)行的文件。
SUBROUTINE halo_power
INTEGER, PARAMETER :: ARRAYLEN=5000000
CHARACTER(120) :: filename
REAL*4, DIMENSION (ARRAYLEN) :: X_halo, Y_halo, Z_halo
INTEGER :: i, istat
filename = '/path_to/xyz.dat'
OPEN (UNIT=10, FILE=filename, STATUS='old', ACTION='read')
OPEN (UNIT=11, FILE='copia.dat', FORM='formatted')
DO i=1,ARRAYLEN
READ (10, *) X_halo(i), Y_halo(i), Z_halo(i)
WRITE (11,*) X_halo(i), Y_halo(i), Z_halo(i)
END DO
CLOSE (10)
CLOSE (11)
END SUBROUTINE halo_power
问题是在我的 Mac 上它可以工作,但我必须在给我错误的服务器(超级计算机)上启动它:
power.f90:(.text+0x2ea): relocation truncated to fit: R_X86_64_PC32 against ".bss"
power.f90:(.text+0x2f1): relocation truncated to fit: R_X86_64_PC32 against ".bss"
power.f90:(.text+0x2f8): relocation truncated to fit: R_X86_64_PC32 against ".bss"
power.f90:(.text+0x3e3): relocation truncated to fit: R_X86_64_PC32 against ".bss"
但是,如果我将行数减少到 5000,它就可以工作。这怎么可能?有没有办法创建一个同样适用于该服务器的 500 万行数组?
# 更新:
使用 ALLOCATE 子程序单独工作(如果用作程序),但如果我将它作为子程序插入程序中(它也单独工作),我又遇到了同样的问题。
power.f90:(.text+0x2ea): relocation truncated to fit: R_X86_64_PC32 against ".bss"
power.f90:(.text+0x2f1): relocation truncated to fit: R_X86_64_PC32 against ".bss"
power.f90:(.text+0x2f8): relocation truncated to fit: R_X86_64_PC32 against ".bss"
power.f90:(.text+0x3e3): relocation truncated to fit: R_X86_64_PC32 against ".bss"
是不是所有的代码都太重了?我该如何解决?