Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Current best method for wrapping Modern Fortran code with Python

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?

like image 394
James Tocknell Avatar asked May 19 '12 13:05

James Tocknell


1 Answers

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

  • FortWrap
  • pyfortran
  • F2PY
  • f90wrap

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).

like image 101
Ken Avatar answered Sep 21 '22 15:09

Ken