Issue with spectrum sampling using source.f

Dear FLUKA experts,

I am trying to run a simple simulation where an electron beam with an energy spectrum given by values in a dat file is converted to bremsstrahlung. The fortran file compiles without error and on running, no errors are flagged by FLUKA/FLAIR. However, the runtime is a few seconds, even with 1.e5 primaries over 5 cycles, and although the .out file shows that the correct number of particles have been processed, no region has any event activity nor does the scoring contain any non-zero data (USRBDX and USRBIN). I have also checked that the source.f correctly samples the correct values for energy, momentum, direction cosines and beam location; it seems that although the feeder processes the particles correctly, none propagate through the geometry. Without a user source (i.e. just a monochromatic beam), the simulation works fine, with the scoring producing what would be expected.

Additionally, if the number of primaries exceeds 1.e6, the run fails with error code 2, returning the error “Fortran runtime error: Index ‘-1073741824’ of dimension 1 of array ‘iloflk’ below lower bound of 0” - this seems like a memory error of some sort.

I am a little confused by this as I have never had this problem when using a source.f routine before for sampling from a file, so any help would be much appreciated.
My gfortran version is 10.2.0, with the gfortran 9, 64 bit compatible FLUKA version for LINUX.
I have also included the input file, source routine and an example .out file for a run in case that is useful.

Many thanks and best regards,
Kyle
GEMINI_LWFA005.out (78.6 KB)
GEMINI_LWFA.inp (1.7 KB)
SpectrumSource.f (9.7 KB)
eSpec_20210308_run03_Shots_13_15_r1.dat (39.6 KB)

Dear Kyle,

unfortunately I can’t reproduce the issue, your source routine is working for me. Maybe you forget to recompile after a change?

I noticed that your spectrum file contains negative weight values. This could also lead to problems.

I also suggest to update your FLUKA to the latest 4-1.1 version.

Cheers,
David

Dear David,

Thank you very much for your reply. It’s odd that it works for you but not me - it is possibly something to do with my installation then. I have updated to FLUKA 4-1.1 but the problem still occurs. I also don’t think it’s a compilation issue as I have tried building and recompiling the source file after any changes…

Many thanks,
Kyle

Dear Kyle,

what operating system are you using?
Did you used a .deb, .rpm. or .tar package to install FLUKA?

Dear David,

I’m using Ubuntu 20.04 and I installed FLUKA using the pre-compiled .tar package.

Hi Kyle,

The default gfortran version on Ubuntu 20.04 is 9.3.0. You mentioned you have 10.2.0.

Did you compile gfortran 10 from source, or did you use another method to install it?
Could you try compiling your source routine with the default compiler?

Cheers,
David

Hi David,

Thank you very much - I compiled the source with gfortran 9.3 and it seems to be running properly now (FLAIR’s ETA is 26 min, rather than finishing immediately). I didn’t think to change the complier version I was using.

I installed gfortran-10 from apt-get as I thought that the gfortran 9.3 compatible version of FLUKA was also compatible with gfortran 10.

Thanks very much,
Kyle

Dear Kyle,

the FLUKA gfortran 9 package is compatible with the gfortran compiler versions 8, 9, 10 and 11 (on Linux)

I tried installing gfortran-10 on my Ubuntu 20.04, but even with that I couldn’t reproduce the issue. I assume something got mixed up in your system.

Cheers,
David