Open axch opened 7 years ago
I agree. I'd put this fairly low down the priority list though - I've not had a simulation in which the model was able to carry around infinities without producing NaN values very quickly. The way that these bad values propagate quickly from one variable to the others is the reason why the code only checks for NaNs in the h
field. https://github.com/edoddridge/MIM/blob/master/MIM.f90#L760
It is also highly likely that there is a more efficient way of testing for bad values than the one currently implemented. This subroutine is from my very early days with Fortran.
There is a second question here, prompted by the observation that the code that writes out the average value dumps checks the h
array for NaNs (again), rather than hav
. The question is, where do we want to be on the spectrum between catching invalid values early vs spending little effort on validity checks?
Reasonable choices include:
The options described above could be tagged to the debug_level
parameter: as the debug_level
is increased, the model becomes stricter about checking for invalid values. This would obviate any speed concerns associated with regularly checking arrays, while still providing the ability to detect the first NaN, if the user desires that behaviour.
Self-checking for infinities as well as NaN seems like a reasonable sanity precaution to take, and maintain in the production system.