f90wrap
f90wrap copied to clipboard
Auto error raise
Add a flag to automatically generate calls to the abort function in the f90wrap Fortran wrappers to raise Python RuntimeErrors.
To my knowledge, there is no standard way of handling errors in Fortran; this feature matches the way we handle errors in our code and might match the way others handle errors.
In our Fortran code, subroutines use one integer variable that holds the error code and one character variable that holds the error message. If the error code is different from 0, the program stops, and a call stack is built via the error character variable.
The flag allows specifying the variable names used in the wrapped code for error handling and generates a call to f90wrap_abort in the f90wrap Fortran wrappers, which is called if the error code is different from 0.
The added examples might give a clearer idea of this explanation.
This enables us to avoid having to add calls to f90wrap_abort in the wrapped code and still get the Fortran error raised in the Python wrappers.
Seems to be seg-faulting on Linux: https://github.com/jameskermode/f90wrap/actions/runs/12695283560/job/35386858383?pr=247#step:4:23025
Right I forget to update the meson makefile
Hi @jameskermode Is this a feature that you would merge? Should I add something to the PR?
Hi @danbeibei, yes, sorry for the delay, I must have missed your update to fix the build. I'll aim to review this soon and am certainly interested in merging it.
In fact I see that I already reviewed it and was just waiting for the CI fix. Thank you!