NOAA-GFDL / FMS

GFDL's Flexible Modeling System
Other
96 stars 136 forks source link

Potential issue with `Where` statements in debug mode #1614

Open JosephMouallem opened 6 days ago

JosephMouallem commented 6 days ago

Hi all,

I am encountering issues with where statements when running SHiELD/MOM6 in debug mode. For example, the model performs a division by zero and crashes in xgrid.F90 when computing the inverse area, where grid%area>0 so not sure how the division by zero is happening in this context: https://github.com/NOAA-GFDL/FMS/blob/23df6d7a905aaa9618e597b82c49b56009a0caa2/exchange/xgrid.F90#L1973-L1976

A similar issue arises in the monin obukhov routine: https://github.com/NOAA-GFDL/FMS/blob/23df6d7a905aaa9618e597b82c49b56009a0caa2/monin_obukhov/include/monin_obukhov_inter.inc#L248-L253

I am using the standard SHiELD template and compile flags: https://github.com/NOAA-GFDL/SHiELD_build/blob/main/site/intel.mk.

These issues are specific to DEBUG mode; everything works fine when compiling in REPRO mode.

bensonr commented 2 hours ago

There are some nuances with respect to where statements and the order things are evaluated leading to FPEs when you would expect to be protected against them. Whether you hit them or not is completely up to how the compiler is implemented.