edoddridge / aronnax

An idealised isopycnal model that can be run either with n+1/2 layers, or with n layers and variable bathymetry.
http://aronnax.readthedocs.io/en/latest/
MIT License
24 stars 5 forks source link

Mim should validate its inputs #57

Open axch opened 7 years ago

axch commented 7 years ago

MIM should check each of the invariants that it expects about its inputs, and emit a friendly error message if they are violated. The general principle is, don't allow the user to wait a day for the simulation to complete before discovering that they made a mistake in the configuration, if that mistake can be detected ahead of time. For this software, I think it's better to be very pedantic about being very sure the inputs correspond to the user's intentions, because that iteration loop is so much faster than configure-run-plot.

The invariants I am aware of now are:

axch commented 7 years ago

The shape of the solution to this depends somewhat on the packaging we want. In the current packaging, it makes sense for the MIM core to check these things. However, if we move to a more Python-wrapped packaging, we can write the input validation in Python, and let the core just trust that its inputs will be well-formed (and validate that trust with integration testing, to make sure the user cannot trick the Python wrapper into synthesizing an input that will cause the core to misbehave or to crash with a bad message).

axch commented 7 years ago

Should also validate that all the input parameters are, in fact, present, or set them to reasonable and documented default values. Fortran namelist input appears to be defined to leave alone variables that are not mentioned in the input file, which will currently have the effect of leaving them uninitialized.

There is a style issue here about how pedantic to be about inputs that are not used, such as the botDrag coefficient in reduced gravity mode. On the one hand, it's nice not to demand the user to supply currently-irrelevant configuration parameters; on the other hand, it's also nice to guarantee that configuration changes are all local (i.e., flipping the RedGrav flag preserves validity of a configuration).