Templates

F2x uses templates to generate the code. There are a bunch of templates that come bundled with F2x:

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.

ctypes_noerr

@ctypes_noerr/_glue.py.t

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

sphinx

.rst.t

Generates a Sphinx documentation for a module.

Choosing a Template on Command Line

When you use the F2x CLI to wrap your sources, you can select templates by specifying the -t switch. You have three possibilities of accessing template files:

  • The name of a built-in template. These start with an ‘@’ character and are listed in the table above.

  • The full (relative) path to a template file.

  • A path relative to one of the template path directories. You can adjust the template path using the -T switch.