Build Strategies

F2x extends the numpy build system using strategies that interact with the build environment at defined points during the build process. This allows to decouple specific tweaks that are done from the overall build process. In general, every set of templates needs a specific build strategy. In return, every build strategy usally has it’s specific set of templates that it needs to successfully build a Python extension.

The base BuildStrategy defines the seqence when it can interact with the build process.

Available Strategies

A set of strategies come bundled with F2x:

lib

@bindc/_glue.f90.t, @cerr/_cerr.c.t, @ctypes/_glue.py.t

not documented yet

lib_noerr

_glue.f90.t, _glue.py.t

not documented yet

Error Handling

Ususally, error handling should be done using return values etc. However, in many cases Fortran programs seem to simply STOP running if they face a condition. This is a big show stopper for Python as the whole process will be killed. To accomodate this problem, F2x implements a thin C wrapper using F2x.template.cerr that qualifies as longjmp traget. This allows us to replace all the calls to STOP by a calls to F2X_ERR_HANDLE(). This triggers the longjmp and program flow returns to Python.

To support this method, you need to make sure to use the correct strategy or templates:

Strategies with error handling:

lib

@bindc/_glue.f90.t, @cerr/_cerr.c.t, @ctypes/_glue.py.t

not documented yet

Templates with error handling:

bindc

@bindc/_glue.f90.t

Generate a ISO C compliant interface to a Fortran module using BIND(C).

cerr

@cerr/_cerr.c.t

Generates a thin C layer that is used as clean stack snapshot for longjmp error handling.

ctypes

@ctypes/_glue.py.t

Generates a Python module that interacts with a ISO C interface generated by ‘bindc’ template using ctypes including error handling using ‘cerr’ template.