sandbox/bugs/FloatingPoint

    Floating Point exception for tsunami run with openMP

    There are some floating point exceptions when running the tsunami example with openmp. They are not bad enough to cause problems unless you have the debug and catch flags on but might create issues down the track? If I compile tsunami.c using

    qcc -O2 -fopenmp -g -Wall -o tsunami/tsunami tsunami.c -lm -L$BASILISK/kdt -lkdt

    It works fine. When I include the catch flag

    qcc -O2 -fopenmp -g -Wall -catch -o tsunami/tsunami tsunami.c -lm -L$BASILISK/kdt -lkdt

    I get

    laneem@niwa-36410:~/basilisk/update/basilisk/src/examples/tsunami> ./tsunami 
    Caught signal 8 (Floating Point Exception)
    Caught signal 8 (Floating Point Exception)
    Caught signal 6 (Aborted)
    Aborted (core dumped)

    And looking in the core gives:

    laneem@niwa-36410:~/basilisk/update/basilisk/src/examples/tsunami> gdb ./tsunami core
    Core was generated by `./tsunami'.
    Program terminated with signal 6, Aborted.
    #0  0x00007f4928b1a885 in raise () from /lib64/libc.so.6
    (gdb) where
    #0  0x00007f4928b1a885 in raise () from /lib64/libc.so.6
    #1  0x00007f4928b1be61 in abort () from /lib64/libc.so.6
    #2  0x000000000040e9ae in caught_fpe (sig=<optimized out>) at /home/laneem/basilisk/update/basilisk/src/grid/fpe.h:17
    #3  <signal handler called>
    #4  0x00000000004031f3 in boundary_tangential_x (point=..., cond=0x403970 <retrue>, list=0x6ab780)
        at /home/laneem/basilisk/update/basilisk/src/grid/quadtree.h:914
    #5  0x0000000000418959 in box_boundary_halo_prolongation.omp_fn.52 (.omp_data_i=0x7fffa52c3b10)
        at /home/laneem/basilisk/update/basilisk/src/grid/quadtree.h:1049
    #6  0x00007f49290870ca in ?? () from /usr/lib64/libgomp.so.1
    #7  0x00007f4928e68806 in start_thread () from /lib64/libpthread.so.0
    #8  0x00007f4928bc402d in clone () from /lib64/libc.so.6
    #9  0x0000000000000000 in ?? ()

    Without the openmp flag it also works fine, i.e.

    qcc -O2 -g -Wall -catch -o tsunami/tsunami tsunami.c -lm -L$BASILISK/kdt -lkdt

    If I have the -DTRASH=1 flag instead of the -catch flag it picks up the same issue.