Single precision strikes again!
It’s a rite of passage for every Fortran programmer to get bitten by this issue.
TL;DR
- Add
_wpto every floating point value, no matter how much you don’t want to. The syntax is3.0_wp,10.1e3_wp, etc. - Don’t use
3_wpexpecting it to be a floating point value (if it doesn’t have the.then it is an integer). - Don’t use
3.0without the_wpever under any circumstances. - Don’t declare variables as
realorreal(8)orreal*8under any circumstances, alwaysreal(wp). - Define
wp, for example usinguse iso_fortran_env, only: wp => real64to get double precision. Put it in a module if you want to use it in multiple files.