Discussion:
[Numpy-discussion] future of f2py and Fortran90+
Eric Firing
2015-07-14 19:55:45 UTC
Permalink
F2py is a great tool, but my impression is that it is being left behind
by the evolution of Fortran from F90 onward. This is unfortunate; it
would be nice to be able to easily wrap new Fortran libraries.

I'm curious: has anyone been looking into what it would take to enable
f2py to handle modern Fortran in general? And into prospects for
getting such an effort funded?

Eric
Sturla Molden
2015-07-15 01:45:40 UTC
Permalink
Post by Eric Firing
I'm curious: has anyone been looking into what it would take to enable
f2py to handle modern Fortran in general? And into prospects for
getting such an effort funded?
No need. Use Cython and Fortran 2003 ISO C bindings. That is the only
portable way to interop between Fortran and C (including CPython) anyway.
David Verelst
2015-12-03 19:49:40 UTC
Permalink
f90wrap [1] extends the functionality of f2py, and can automatically
generate sensible wrappers for certain cases.
[1] https://github.com/jameskermode/f90wrap
Post by Sturla Molden
Post by Eric Firing
I'm curious: has anyone been looking into what it would take to enable
f2py to handle modern Fortran in general? And into prospects for
getting such an effort funded?
No need. Use Cython and Fortran 2003 ISO C bindings. That is the only
portable way to interop between Fortran and C (including CPython) anyway.
_______________________________________________
NumPy-Discussion mailing list
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Yuxiang Wang
2015-12-03 21:08:38 UTC
Permalink
Too add to Sturla - I think this is what he mentioned but in more details:

http://www.fortran90.org/src/best-practices.html#interfacing-with-python

Shawn
Post by Sturla Molden
Post by Eric Firing
I'm curious: has anyone been looking into what it would take to enable
f2py to handle modern Fortran in general? And into prospects for
getting such an effort funded?
No need. Use Cython and Fortran 2003 ISO C bindings. That is the only
portable way to interop between Fortran and C (including CPython) anyway.
_______________________________________________
NumPy-Discussion mailing list
http://mail.scipy.org/mailman/listinfo/numpy-discussion
--
Yuxiang "Shawn" Wang
Gerling Haptics Lab
University of Virginia
***@virginia.edu
+1 (434) 284-0836
https://sites.google.com/a/virginia.edu/yw5aj/
Eric Firing
2015-12-03 21:38:55 UTC
Permalink
Post by Yuxiang Wang
http://www.fortran90.org/src/best-practices.html#interfacing-with-python
Right, but for each function that requires writing two wrappers, one in
Fortran and a second one in cython. Even though they are very simple,
this would be cumbersome for a library with more than a few functions.
Therefore I think there is still a place for f2py and f90wrap, and I am
happy to see development continuing at least on the latter.

Eric
Post by Yuxiang Wang
Shawn
Post by Sturla Molden
Post by Eric Firing
I'm curious: has anyone been looking into what it would take to enable
f2py to handle modern Fortran in general? And into prospects for
getting such an effort funded?
No need. Use Cython and Fortran 2003 ISO C bindings. That is the only
portable way to interop between Fortran and C (including CPython) anyway.
_______________________________________________
NumPy-Discussion mailing list
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Sturla Molden
2015-12-04 10:30:09 UTC
Permalink
Post by Eric Firing
Right, but for each function that requires writing two wrappers, one in
Fortran and a second one in cython.
Yes, you need two wrappers for each function, one in Cython and one in
Fortran 2003. That is what fwrap is supposed to automate, but it has
been abandonware for quite a while.

Sturla

Tim Cera
2015-12-04 01:02:58 UTC
Permalink
Post by Sturla Molden
Post by Eric Firing
I'm curious: has anyone been looking into what it would take to enable
f2py to handle modern Fortran in general? And into prospects for
getting such an effort funded?
No need. Use Cython and Fortran 2003 ISO C bindings. That is the only
portable way to interop between Fortran and C (including CPython) anyway.
For my wdmtoolbox I have a f2py wrapped Fortran 77 library. Works great on
Linux, but because of the 'C' wrapper that f2py creates you run into the
same problem as Cython on Windows.

https://github.com/cython/cython/wiki/CythonExtensionsOnWindows

I guess if you first find a Windows machine, get it all setup, you may not
have to futz with it too much, but I just don't want to do it for such a
niche package. I probably have a handful of users.

So I've been toying with the idea to use ctypes + iso_c_binding. I could
then use MinGW on Windows to compile the code for all versions of Python
that have ctypes. I've tested this approach on a few functions and it
works, but far from done.

My $0.02.

Kindest regards,
Tim
Loading...