ukaea/ReMKiT1D

FPE in debug mode

SMijin opened this issue · 2 comments

SMijin commented

A number of spurious floating point errors get caught by the stringent error checking in debug mode, where the release build performs fine. This has previously been addressed partially, but some cases still cause issues. This is likely due to divide-by-zero errors in some halos, which would normally be discarded in release mode.

This should be investigated further. Examples of config.json files which produce these errors should be submitted as and when they are discovered.

Error encountered in following config.json file
config.json

SMijin commented

The previous look into this bug identified it as being caused by derivations that include division and halo values of variables in the denominator that are equal to 0. When it was partially addressed in a development build of v1.1.0 the solution was to initialize halo values of all variables to 1.

However, in the config.json submitted above, there is a variable derived as a ratio of two variables - 1. This leads to that variable having 0 halo values. A workaround would be to set different variable values in halos to random numbers. This might be implemented as a fix for debug mode in either v1.1.x or v1.2.0. While the proposed solution does not guarantee that all caught FPEs would come from issues unrelated to halos, it should reduce the number of "false positives".