On this page
F2PY user guide and reference manual
The purpose of the F2PY –Fortran to Python interface generator– utility is to provide a connection between Python and Fortran. F2PY is a part of NumPy (numpy.f2py) and also available as a standalone command line tool.
F2PY facilitates creating/building Python C/API extension modules that make it possible
- to call Fortran 77/90/95 external subroutines and Fortran 90/95 module subroutines as well as C functions;
- to access Fortran 77
COMMONblocks and Fortran 90/95 module data, including allocatable arrays
from Python.
F2PY can be used either as a command line tool f2py or as a Python module numpy.f2py. While we try to provide the command line tool as part of the numpy setup, some platforms like Windows make it difficult to reliably put the executables on the PATH. If the f2py command is not available in your system, you may have to run it as a module:
python -m numpy.f2py
If you run f2py with no arguments, and the line numpy Version at the end matches the NumPy version printed from python -m numpy.f2py, then you can use the shorter version. If not, or if you cannot run f2py, you should replace all calls to f2py mentioned in this guide with the longer version.
- Three ways to wrap - getting started
- F2PY user guide
- F2PY reference manual
- Using F2PY
- Using F2PY bindings in Python
- Signature file
- F2PY and Build Systems
- Advanced F2PY use cases
- F2PY and Windows
© 2005–2022 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/1.23/f2py/index.html