LehreWiki

Python/F2PY

Create a file hello.f:

C File hello.f
      subroutine foo (a)
      integer a
      print*, "Hello from Fortran!"
      print*, "a=",a
      end

Run f2py -c -m hello hello.f

Now in IPython try:

In [1]: import hello
In [2]: hello.foo(4)
 Hello from Fortran!
 a=           4

Example taken from

LehreWiki: PythonCourse/F2PY (last edited 2012-07-05 14:08:44 by anonymous)