Conversation
|
Is this for speed or correctness? There should already be a limiter in place, clipping negative rain values to 0. One thing to watch out for is that early returns may interfere with statistics, not sure if that applies here. EDIT: I see the early return is safe for statistics (this is in a per-gridpoint function). |
Good to know. I added this return simply because I was getting a division-by-zero error when running in debug mode. Debug mode is usually more picky, and after adding this procedure here, the error stopped occurring. |
|
Ok, if the debug mode catches a division by 0 there, we're doing something wrong. Do you happen to know where exactly it occurred? I can imagine that if qr or Nr is 0 (which is allowed), some of those derived quantities D, mu, are not defined. As I remember it many of them also have limiters to deal with this, perhaps not all. |
I checked again with the up-to-date dev version, and it no longer complains about this issue (at least with my current setup). So it was probably fixed elsewhere, and this short-circuit may no longer be necessary. However, when running in debug mode I still encountered two crashes that do not appear in the normal run. The first one occurred in the new lD80R subgrid scheme: [tcn688:2508765:0:2508765] Caught signal 8 (Floating point exception: floating-point divide by zero) I addressed it by adding guards against very small values: The second crash appeared in modlsm.f90: [tcn790:2231322:0:2231322] Caught signal 8 (Floating point exception: floating-point divide by zero) I handled this by protecting the Newton update from a zero derivative: After these fixes, the debug run completes without crashes. |
Summary
Add an early return in
calc_sed_qr_sbto ensure zero rain sedimentation when no rain water is present.Details
The sedimentation rate of rain water is proportional to the rain water content (
qr).When
qr ≤ 0, sedimentation should therefore be zero by definition.This PR adds a short-circuit at the top of the elemental function to:
sed_qr = 0forqr ≤ 0Impact