Open JessicaNeedham opened 1 year ago
I guess it depends... If it is a tiny negative number, then I think it makes sense to assume this is just truncation error and set q=0
. If not, then I think the model should crash.
Per the software meeting today, @JessicaNeedham noted that the sqrt number is on the order of -1e-7
, so this isn't numerical precision.
We should add a check inside the function to make sure that we check b*b-4*a*c
and output diagnostic warnings (i.e. values of a, b, and c), but from discussion we need to diagnose why we're getting a combo of these values in upstream code.
I’m getting a crash and the error “SIGFPE floating-point exception - erroneous arithmetic operation” when running with Medlyn stomatal conductance and DEBUG=TRUE, on Perlmutter CPUs, gnu compiler (global 4x5 run). With DEBUG=FALSE it runs but I get a lot of warnings “ FATESWARN: 1 m: Stomatal conductance error check - weak convergence: 0.168128E+06 0.159592E+06 “
The error with DEBUG=TRUE is being triggered here: https://github.com/NGEET/fates/blob/44ba97a81e72cfa83b1f9fdc57b9bcde3406af4a/biogeophys/FatesPlantRespPhotosynthMod.F90#L1812
because
( b*b - 4._r8*a*c)
is negative and we’re asking for a square root.My parameter values are: fates_leaf_stomatal_intercept = 10000, 10000, 10000, 10000, 10000, 10000,
10000, 10000, 10000, 10000, 10000, 40000 ;
fates_leaf_stomatal_slope_medlyn = 4.12, 2.35, 2.35, 4.12, 4.45, 4.45,
4.7, 4.7, 4.7, 2.22, 5.25, 1.62 ;
Can we wrap it in a max(0, ) term or should the model crash if this term becomes negative?