Source.f max number of lines

Dear all
I’m trying to load particles from an external file using the source.f user routine
the problem arise when I define the number of lines in the file to be over 30000000
I suppose it is related to variable definition, but I was not hable to solve it
(I tried to change declaration and something like this ( 64 bit integer in FORTRAN77 )

The external file is quite huge (39 Gb), 486203830 lines formatted as
7 0.933549E-03 -.162537E+00 0.136150E-01 -.4791E+01 0.3356E+00 0.2900E+02

I load and run it in this way (only if NLINES < 30000000)
source.f (9.6 KB)

  PARAMETER(NLINES=30000000)                                                                                                                                                            
  DIMENSION  ID(NLINES),E(NLINES), X(NLINES), Y(NLINES),
 &           Z(NLINES), COSX(NLINES), COSY(NLINES)

[…]

OPEN(UNIT=88,FILE="…/…/…/gene_r20.txt",STATUS=“OLD”)
DO I = 1, NLINES
READ(88,*,IOSTAT=iostat) ID(I),E(I),
& COSX(I), COSY(I), X(I), Y(I), Z(I)
END DO
[…]

Otherwise this error appears

*Error *
- Compiling: /usr/local/fluka/bin/fff source.f
gfortran -c -I/usr/local/fluka/include -g -cpp -O3 -fd-lines-as-comments -Wall -Waggregate-return -Wcast-align -Wline-truncation -Wno-conversion -Wno-integer-division -Wno-tabs -Wno-unused-dummy-argument -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wsystem-headers -Wuninitialized -Wunused-label -mtune=generic -msse2 -mfpmath=sse -fPIC -fexpensive-optimizations -funroll-loops -fstrength-reduce -fno-automatic -finit-local-zero -ffixed-line-length-132 -fbackslash -funderscoring -frecord-marker=4 -falign-commons -fbacktrace -frange-check -fbounds-check -fdump-core -ftrapping-math -ffpe-trap=invalid,zero,overflow -o source.o source.f

- Linking: /usr/local/fluka/bin/lfluka -o adfas source.o
gfortran -o adfas source.o -L/usr/local/fluka/lib -lfluka
/usr/bin/ld: /usr/local/fluka/lib/libfluka.a(fpe.o): in function timer':* *(.text+0xa): relocation truncated to fit: R_X86_64_PC32 against .bss’
/usr/bin/ld: (.text+0x21): relocation truncated to fit: R_X86_64_PC32 against .bss'* */usr/bin/ld: (.text+0x39): relocation truncated to fit: R_X86_64_PC32 against .bss’
/usr/bin/ld: /usr/local/fluka/lib/libfluka.a(fpe.o): in function fpenab_':* *(.text+0x84): relocation truncated to fit: R_X86_64_PC32 against .bss’
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status

Dear Andrea,

the issue is that you try to statically allocate more than 2 GB of memory. (Your source routine’s + FLUKA’s static memory usage should be less then the limit).

You have two option:

  1. You allocate your arrays dynamically, or
  2. Add the -mcmodel=medium flag, to the FFLAGS variable in the <path_to_fluka>/bin/fluka-config script.

See:

and

Cheers,
David

P.S.: If you plan to run multiple jobs parallel, please make sure you have enough memory for all of them, otherwise your computer will crash.

thanks David
now seems to work :slight_smile: