python调用fortran模块

foo.f90python

subroutine hello (a)

integer a

    write(*,*)'Hello from Fortran90!!!',a

end subroutine hello

编译linux

f2py -m foo -c foo.f90 shell

运行code

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
>>> foo.hello(15)
 Hello from Fortran90!!!          15

若是python3则用orm

f2py2 -m foo -c foo.f90

这时编译后产生foo.cpython-34m.so 而不是foo.soit

相关文章
相关标签/搜索