I have a code that has two Python functions, run(), and dudt(u, t, ...). run calls a C function, odepack_odeint, which calls a Fortran subroutine, LSODA, which calls another C function, ode_function, which calls dudt. If there is an error in dudt, it can be printed by ode_function using PyErr_Print(), but I can't figure out how to tell the code to stop execution. I tried,
PyErr_Print()
PyErr_SetString(errobj, message)
in ode_function, but then the code segfaults. As I understand it, what's supposed to happen next is for ode_function to return NULL or -1 or something. However, LSODA expects ode_function to be void.
This is an attempt to patch scipy.integrate.odeint, based on this question that I asked previously.