# Re: R: RE: Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation.

From: Alberto Fasso' <fasso_at_SLAC.Stanford.EDU>
Date: Tue, 14 May 2013 06:15:57 -0700 (PDT)

Dear Francesca,

I have noticed in your source.f file a few "unclean" things that in some
rare cases could give you trouble. Although the following are probably not
the cause of your problem, I suggest that you correct them.

1) There is an IF which starts this way:
IF (TEGR(I+1) .GT. XYZ...
If you are unlucky, it can happen that TEGR(I+1) is exactly equal to XYZ:
in that case the IF will be never true. Replace it by
IF (TEGR(I+1) .GE. XYZ...

2) The DATA statements concerning the ENEDGE, FLUX and RATIO arrays are
written as if those data were in single precision (with an "e" instead of
a "d", or without anything at all). The same happens at several points
inside the routine, for instance:
IF (ENE.GE.1.0e-11.AND.ENE.LE.2.15443e-11) THEN
X1 = GAUSS1*5.67161e-01
Y1 = GAUSS2*5.39079e-01
Force all floating point numbers to be in double precision using "d" in
the exponent:
IF (ENE.GE.1.0d-11.AND.ENE.LE.2.15443d-11) THEN
X1 = GAUSS1*5.67161d-01
Y1 = GAUSS2*5.39079d-01
etc.

3) There are 4 cases where a message is written on "LNUOUT". You will
probably never see those messages. The name of output logical unit
is LUNOUT.

4) This is not an error, but something that will make your routine
unnecessarily inefficient: the calculation of the cumulative distribution
is done again and again every time the source is called. Put it inside
the initial IF: IF ( LFIRST ) THEN... after the comment
"User initialization", so that it wil be done just once, the first time.

Best regards,

Alberto

On Mon, 13 May 2013, francesca.belloni_at_libero.it wrote:

> Dear all,
> I found some mistakes and in attachment are the corrected files. But
> the same error is given.
>
> Could anyone give a look, please?
>
> Thank you,
> best regards,
> Francesca Belloni
Received on Tue May 14 2013 - 16:04:03 CEST

This archive was generated by hypermail 2.3.0 : Tue May 14 2013 - 16:04:03 CEST