# 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 languages. F2PY is a part of NumPy (`numpy.f2py`) and also available as a standalone command line tool `f2py` when `numpy` is installed that 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 `COMMON` blocks and Fortran 90/95 module data, including allocatable arrays

from Python.

- Using F2PY
  - Command `f2py`
  - Python module `numpy.f2py`
- Three ways to wrap - getting started
  - The quick way
  - The smart way
  - The quick and smart way
- Using F2PY bindings in Python
  - Scalar arguments
  - String arguments
  - Array arguments
  - Call-back arguments
  - Resolving arguments to call-back functions
  - Common blocks
  - Fortran 90 module data
  - Allocatable arrays
- Signature file
  - Python module block
  - Fortran/C routine signatures
  - Type declarations
  - Statements
  - Attributes
  - Extensions
- F2PY and Build Systems
  - Basic Concepts
  - Build Systems
- Advanced F2PY use cases
  - Adding user-defined functions to F2PY generated modules
  - Adding user-defined variables
  - Dealing with KIND specifiers

previous

For downstream package authors

next

Using F2PY