fortran: relocation truncated to fit, i can't create big arrays on server [duplicate]

核能气质少年 提交于 2020-01-06 05:50:52

问题


I write a simple subroutine in fortran for a more complicated program. I need to read a file containing 3 columns of numbers (X_halo, Y_halo, Z_halo) and enter the 3 columns data into 3 arrays. In this subroutine I write the data in a file to see if I can actually read it. I have a file of 5000000 (5 millions) rows.

  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

The problem is that on my Mac it works, but I have to launch it on a server (a supercomputer) that gives me the error:

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"

But if I reduce the rows to 5000 it works. How is it possible? Is there a way to create an array of 5 million rows that also works on this server?

# UPDATE:

With ALLOCATE the subroutine alone works (if used as a program), but if I insert it as subroutine within a program (which also works alone), I have the same problem again.

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"

Is all the code too heavy? How can I fix it?

来源:https://stackoverflow.com/questions/45648934/fortran-relocation-truncated-to-fit-i-cant-create-big-arrays-on-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!