HugoMVale / fortran-in-python

Examples of how to build/call Fortran modules in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Description

A few examples to illustrate the main steps required to build and call Fortran code from Python with the following tools:

Tool Pros Cons
ctypes
  • Allows for tailor-made wrappers.
  • C-API as byproduct.
  • C-bindings and Python-bindings must be written for all data types and procedures (besides the manual effort, some aspects are not intuitive at all).
  • f2py
  • Little/no manual work.
  • Fortran procedures are automatically given a Pythonic signature.
  • Array dimensions become optional arguments.
  • No support for derived data types, abstract interfaces, etc.
  • No possibility for wrapper customization.
  • f90wrap
  • Support for derived data types, abstract interfaces, etc.
  • Can parse Doxygen (but not FORD) docstrings.
  • Procedure signatures remain unchanged (Fortranic, not Pythonic).
  • Procedures with callbacks are excluded (bug?).
  • Support seems limited (just an impression).
  • gfort2py
  • to do!
  • to do!
  • A rather comprehensive list of tools to invoke Fortran code from Python can be found here.

    About

    Examples of how to build/call Fortran modules in Python

    License:MIT License


    Languages

    Language:Fortran 54.4%Language:Python 41.1%Language:Batchfile 3.5%Language:C 1.1%