Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install f2py with python3

I need to call routines from Fortran modules within Python. I did it with f2py and python2.7. It worked pretty well.

Now, I have to use it with python3 but f2py does not seem to be compatible with python3.

I see that some people use a version called f2py3, but it is neither available through pip, not through macports (I am using a Mac). Also, python3+numpy+f2py seem to be already integrated in Fedora.

Does anyone have managed to use f2py3 (or its equivalent) with python3 on a Mac? If not, what alternate solution do you propose to link Fortran libraries with python3?

like image 401
jvtrudel Avatar asked May 02 '15 09:05

jvtrudel


2 Answers

As an alternative, you can use ctypes and fortran-iso-c-binding to call Fortran routines without relying on f2py. The downside of this approach is that you need to specify the interfaces yourself.

Here is an example I posted on SO some time ago.

like image 96
Alexander Vogt Avatar answered Nov 12 '22 12:11

Alexander Vogt


f2py comes with numpy and based on this January 2020 activity on github, it seems clear that f2py is currently maintained.

like image 1
Christopher Bottoms Avatar answered Nov 12 '22 13:11

Christopher Bottoms