This module patches numpy.f2py at runtime, to customise the C code that is generated. We make several changes to f2py:
- Allow the Fortran present() function to work correctly with optional arguments. If an argument to an f2py wrapped function is optional and is not given, replace it with NULL.
- Allow Fortran routines to raise a RuntimeError exception with a message by calling an external function quippy_error_abort(). This is implemented using a setjmp()/ longjmp() trap.
- Allow Fortran routines to be interrupted with Ctrl+C by installing a custom interrupt handler before the call into Fortran is made. After the Fortran routine returns, the previous interrupt handler is restored.