Re: floating overflow with Periml

From: Johnny Chang <Johnny.Chang_at_nyahnyahspammersnyahnyah>
Date: Sun Mar 20 2011 - 21:19:22 MDT

Hi Jemma,

No. Without the -fpe0 flag, you will just get NaN's if the program's
execution path has floating point exceptions. One typically turns on
-fpe0 only for debugging NaNs.

Johnny

On 3/20/11 7:17 PM, Jemma Wu wrote:
> Hi Johnny,
>
> Thank you for your help!
>
> If the Intel compiler does floating point speculation by default, does this mean
> that I can turn off the fpe0 and the compiler could still throw floating
> overflow exception if the branch that will be executed has an floating point
> overflow? Actually, my program can run correctly if I don't turn on the fpe0.
>
>
> On Mon, Mar 21, 2011 at 11:33 AM, Johnny Chang <Johnny.Chang@nasa.gov
> <mailto:Johnny.Chang@nasa.gov>> wrote:
>
> Hi Jemma,
>
> The floating overflow is most likely a "false positive." The Intel compiler
> does floating point speculation by default. What this means is that if you
> have an if-then-else-endif block, the compiler can issue instructions for
> both branches to be executed *before* the if condition has been evaluated.
> After the if condition has been resolved, then the floating point operations
> in one of the branches is thrown away.
>
> For example,
>
> if (cos(x) .ne. 0.0) then
> y = 1.0/cos(x)
> else
> y = cos(x)
> endif
>
> When you turn on -fpe0 for your Fortran program, it turns off floating point
> speculation for the Fortran program, but not for the ncarg libraries!! So,
> the divide by zero in the example above, which most likely is also present
> in the ncarg library, will cause your program to stop even though it would
> not be used in the actual execution path of the program.
>
> The solution is to build a version of ncarg with -fpe0 or
> -fp-speculation=safe for debugging purposes. If you are interested in
> tracking down the actual
> line in the ncarg source that's causing the problem, then rebuild ncarg with
> the -traceback -g options (in addition to the other optimization options).
> Then your stack trace below will give you the line number in the ncarg source
> that's causing the floating overflow.
>
> Johnny
>
>
>
> On 3/20/11 4:44 PM, Jemma Wu wrote:
>
> Hi all,
>
> I have built and installed ncarg.v5.2.1 under OpenSUSE 11 with Intel
> compilers.
> Now I have a problem with calling Periml (Gridal package) in my fortran
> program.
> The program can be compiled and run (appears correctly) if I don't add
> the float
> point exception flag (fpe0). However, if I add the fpe0 flag and compile
> and run
> it, then it will stop with a floating overflow. I debugged it and found
> it is
> with the Periml call.
>
> I then found an example (tgrida) in ncarg with Periml and tested it with
> adding
> the fpe0 option, and it also have the float overflow problem. My compilation
> options are as follows.
>
> ifort fpe0 -traceback -O0 -o tgrida tgrida.f -L/usr/local/ncarg_build/lib
> -lncarg -lncarg_gks -lncarg_c -lX11 -lXext,
>
> and the running results are
>
> ~/model/ncl_ncarg-5.2.1> ./tgrida
> forrtl: error (72): floating overflow
> Image PC Routine Line Source
> tgrida 00000000004FCDFB Unknown Unknown Unknown
> tgrida 000000000040688E Unknown Unknown Unknown
> tgrida 0000000000406330 Unknown Unknown Unknown
> tgrida 00000000004054FC grida_ 85 tgrida.f
> tgrida 0000000000405339 MAIN__ 22 tgrida.f
> tgrida 000000000040529C Unknown Unknown Unknown
> libc.so.6 00007F539004AB7D Unknown Unknown Unknown
> tgrida 0000000000405199 Unknown Unknown Unknown
> Aborted
>
>
> Does anyone know what's wrong?
>
> Any comments would be appreciated.
>
> --
> Regards,
> Jemma
>
>
>
> --
> Johnny Chang
> 650-604-4356
>
>
>
>
> --
> Regards,
> Jemma
>

-- 
Johnny Chang
650-604-4356
_______________________________________________
ncl-install mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-install
Received on Sun Mar 20 21:43:49 2011

This archive was generated by hypermail 2.1.8 : Tue Apr 05 2011 - 09:03:04 MDT