Current best method for wrapping Modern Fortran code with Python

7.2k views Asked by At

I know of, and have used f2py2e to wrap some old Fortran 77 code, but my understanding is that it does not work with newer Fortran 95 code. I've researched what I should use, and have come across fwrap and G3 f2py, neither of which seem to give any explanation of their current state, or how to use them. I have seen that the version of f2py has the option to use the third generation f2py, but it is commented as being non-functional. Given this, I don't know which project I should use. Which one should I use?

This question has now been cross-posted to (and answered at) Computational Science stack exchange site as Which package should I use to wrap Modern Fortran Code with Python?

1

There are 1 answers

2
Ken On

I have used SWIG to wrap some C/C++ code before but they don't support Fortran. They link to the following, though

At least FortWrap states that they support Fortran95, but you might have to use FortWrap to get C/C++ wrappers and SWIG for the Python wrappers. f90wrap will automatically generate the Python wrappers based on the f90 sources (and supports derived types).