BOUT-dev icon indicating copy to clipboard operation
BOUT-dev copied to clipboard

Solver return status

Open d7919 opened this issue 9 years ago • 2 comments

Currently most solvers typically ignore the return value of run_rhs and likewise the solver parent class does not use the status code provided by run inside the main solve call.

It would be useful if we could update the solver parent and the different impls to ensure that we can pass this status through the various calls, this would in principle allow models to indicate they want to stop (e.g. if max(field)>1e20) without having to throw an exception.

There's currently a work around where the user can attach a timestep monitor which does the required checking/decision making as the return status of the monitor is usually acted on.

d7919 avatar Oct 19 '16 11:10 d7919

I would be in favor of changing the signature and remove the return value. Returning a non zero value to indicate an error isn't really C++ style.

I would rather add a function to set the flag, provided by #343 to request an exit. This has not only the advantage that we don't need to change all solver, but also right know I assume in the physics model you set a flag, to change the return value. Directly changing the flag would be in my opinion favorable.

dschwoerer avatar Dec 07 '16 16:12 dschwoerer

Agree, probably best to remove return code and just throw exception. A breaking change to the API, so for 5.0

bendudson avatar Nov 23 '17 14:11 bendudson