Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation

Dear Fluka experts,

I’m running a simulation sampling from a phase space file, however from time to time the run stops.
So, when I run multiple simulation with 100k primaries, only 60% of the runs get to completion.
Thus If I try to increase the primaries per run the number of the runs that get to completion decreases.

I did not maneged to dubug the error:

Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation.

Backtrace for this error:
#0  0x2b1f144683ff in ???
#1  0x910fda in kasneu_
	at lowneu/kasneu.f:646
#2  0x7e6854 in kaskad_
	at cascade/kaskad.f:4298
#3  0x639ea0 in feeder_
	at cascade/feeder.f:277
#4  0x5834d0 in flukam_
	at main/flukam.f:2796
#5  0x407160 in fluka
	at main/fluka.f:77
#6  0x407160 in main
	at /shared/src/usflmd.inc:15

Can you help me find what I’m doing wrong?

I’m also using custom a mgdraw.f troutine o score particles and a ftelos.f routine to print the summary of the simulation.

I’m attaching the output of a run that failed and the custom code.

Thanks in advance,
Antonino

Archive.zip (452.6 KB)

Dear @antonino.fulci
for some reason a neutron has zero speed and the program fails in calculating the age of the neutron.
Unfortunately with the files you sent the phase_space file is missing so I cannot reproduce the crash. Could you please send us also the missing files

Hi Vasilis,
sorry for not uploading the phase space file.

I’ll explain how I get this file:

  • Run a simulation using an electron beam or a phase space file containing neutrons
  • Rample neutrons exiting the concrete around the beam-dump
  • Create a ROOT multi dimensional histogram (THnSparse)
  • Use the function GetRandom to regenerate the distributions and print a phase space file

Here the distributions of the original simulation in a .root format
NDistribution.root.zip (3.3 MB)

Here the phase space file I use:

Thanks in advance,
Antonino

I’ve tried the 4.3.2 version compiled with your routines (and DPMJET which is not needed in your case). However I saw that the phase space you send me do not correspond to the one you had the crash (you are reporting the first 100 values and they are totally different)

From the crash you reported output fluka_82026/HallA_2023-03-21_6_0009001.out

# Particle    E [GeV]        X [cm]         Y [cm]         Z [cm]         Cosx           Cosy           Cosz           Weight
         8  2.0351600E-05  1.9742600E+02  2.6533100E+02  4.5620100E+03  9.3645300E-01  2.7032500E-01 -2.1159100E-01  1.0000000E+00
         8  1.2054100E-03  2.8833200E+02  3.0246300E+01  4.5745300E+03  8.1505000E-01  2.3049800E-01 -5.2818000E-01  1.0000000E+00
         8  1.9905400E-01 -2.2541500E+02  1.1815100E+02  4.5101500E+03 -9.7317300E-01  2.1522300E-01 -5.4568100E-02  1.0000000E+00

The file you send now source500.txt

 # Particle    E [GeV]        X [cm]         Y [cm]         Z [cm]         Cosx           Cosy           Cosz           Weight
          8  3.2582000E-04  2.6528300E+02  3.6394700E+02  5.1161000E+03 -2.7515000E-01  8.7957500E-01  3.9744300E-01  1.0000000E+00
          8  1.5198900E-03  7.8658600E+01  2.1331600E+02  4.4996000E+03  6.0519700E-01  6.1685700E-02 -7.9524500E-01  1.0000000E+00
          8  4.2638100E-04 -6.3969700E+01  2.7133400E+02  4.5703400E+03 -2.3056300E-01  2.7579900E-01 -9.3101700E-01  1.0000000E+00

Running with the file you send me, I do not have any crash.

Could you please send us the phase space file corresponding to the crash. Also it would be nice if you could tell us which fortran version you are using?

I’ve tried the 4.3.2 version compiled with your routines (and DPMJET which is not needed in your case).

Oh, ok. Next time i’ll try to compile the exe without it. I think I compiled it using the same command for when I run using the electron beam.

However I saw that the phase space you send me do not correspond to the one you had the crash (you are reporting the first 100 values and they are totally different)

I checked and the file is the same. I think that those lines does not correspond because I set read_phase_space_file’s “sequential_logical_flag” to false:

call read_phase_space_file("source500.txt", "GeV", "cm", phase_space_entry, .false., nomore)

Running with the file you send me, I do not have any crash.

Yes, I also have some runs that gets to the end just fine. However, from time to time, some runs stop and return me that error. For example, last time I run 5000 runs and in the end I had only ~3000 run that didn’t crash, all the remaing ones had that error.

Also it would be nice if you could tell us which fortran version you are using?

Sure, typing gfortran --version returns:

GNU Fortran (GCC) 12.2.1 20221030

Form what you said earlier:

for some reason a neutron has zero speed and the program fails in calculating the age of the neutron.

could it be that in my phase space file there are values of the momentum that are too small?

By mistake I posted it on a wrong thread :slight_smile:

Indeed this is the problem, too small momentum. Looking into the source500.txt file I saw an entry with a very very small momentum value 9.93768e-09 . This value will be converted to zero kinetic energy in the source_newgen.f
The lowest neutron energy in FLUKA is 1e-14 GeV, which is roughly 1e-7 GeV/c in momentum.
I would advice to filter out any neutron with less momentum. Or at least give it the lowest momentum, but even better to understand who produced such a neutron!

Thanks a lot Vasilis,
I’ll fix that right away. First I’ll check my initial distribution to see if indeed there were initially such muons, but I suspect that the subsquent extraction using the function GetRandom() might be the culprit.
Thanks again!