The purpose of the F2PY --Fortran to Python interface generator-- project is to provide connection between Python and Fortran languages. F2PY is a Python extension tool for creating Python C/API modules from (handwritten or F2PY generated) signature files (or directly from Fortran sources). The generated extension modules facilitate:
In addition, F2PY can build the generated extension modules to shared libraries with one command. F2PY uses the scipy_distutils module from SciPy that supports number of major Fortran compilers.
F2PY generated extension modules depend on NumPy package that provides fast multi-dimensional array language facility to Python.
In order for F2PY to wrap a piece of Fortran code, a Fortran and a C compiler is required. At the moment the GNU set of compilers seems to be the best for cross platform development. They include:
These compiler are usually standard on a Linux based platform.
Alternatively, on a Windows™ platform:
could also be used.
>>> import numpy >>> f2py.main() Usage: 1) To construct extension module sources: f2py [<options>] <fortran files> [[[only:]||[skip:]] \ <fortran functions> ] \ [: <fortran files> ...] 2) To compile fortran files and build extension modules: f2py -c [<options>, <build_flib options>, <extra options>] <fortran files> 3) To generate signature files: f2py -h <filename.pyf> ...< same options as in (1) > Description: This program generates a Python C/API file (<modulename>module.c) that contains wrappers for given fortran functions so that they can be called from Python. With the -c option the corresponding extension modules are built. ...
or directly from the command prompt, by running the python script f2py:
c:\>f2py Usage: ...