我在fortran中编写了一个简单的子程序,用于更复杂的程序。 我需要读取包含3列数字(X_halo,Y_halo,Z_halo)的文件,并将3列数据输入3个数组。在这个子程序中,我将数据写入文件中,以查看是否可以实际读取它。 我有一个5000000(5百万)行的文件。
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万行的数组,也可以在这台服务器上运行?
# UPDATE:
使用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"
所有代码都太重了吗?我该如何解决?