Compiling multiple modules with f2py
For an intro to f2py
see here.
It’s possible to combine multiple Fortran modules into a single shared library to be used by Python using f2py
. It’s actually pretty easy, but I’m writing a note about it because I’ll likely forget how to do it in the future.
Let’s suppose we have two modules, one.f90
and two.f90
. one
uses two
, and we only explicitly want to use the functions in one
from Python.
For example, one.f90
might contain:
… while in two.f90
:
To compile, execute:
Now, check that it works in python