f90wrap.f90wrapgen module¶
- class f90wrap.f90wrapgen.F90WrapperGenerator(prefix, sizeof_fortran_t, string_lengths, abort_func, kind_map, types, default_to_inout, max_length=None, auto_raise=None, default_string_length=None, direct_c_interop=None, toplevel_basename='toplevel')[source]¶
Bases:
FortranVisitor,CodeGeneratorCreates the Fortran90 code necessary to wrap a given Fortran parse tree suitable for input to f2py.
Each node of the tree (Module, Subroutine etc.) is wrapped according to the rules in this class when visited (using F90WrapperGenerator.visit()).
Each module’s wrapper is written to a separate file, with top-level procedures written to another separate file. Derived-types and arrays (both of normal types and derive-types) are specially treated. For each, a number of subroutines allowing the getting/setting of items, and retrieval of array length are written. Furthermore, derived-types are treated as opaque references to enable wrapping with f2py.
- Parameters:
prefix (str) – A string with which to prefix module, subroutine and type names.
sizeof_fortran_t (int) – The size, in bytes, of a pointer to a fortran derived type ??
string_lengths (dict) – This is never used…
abort_func (str) – Name of a Fortran function to be invoked when a fatal error occurs
kind_map (dict) – Dictionary mapping Fortran types and kinds to C-types
types (dict) – Dictionary mapping type names to Fortran modules where they are defined
- visit_Module(node)[source]¶
Wrap modules. Each Fortran module generates one wrapper source file.
Subroutines and elements within each module are properly wrapped.
- write_arg_decl_lines(node, helper_forward=False)[source]¶
Write argument declaration lines to the code
Takes care of argument attributes, and opaque references for derived types, as well as f2py-specific lines.
- write_call_lines(node, func_name, helper_forward=False)[source]¶
Write line that calls a single wrapped Fortran routine
- write_class_lines(cname, recursive=False, *, pointer=False)[source]¶
Write a pointer type for a given class name
- Parameters:
tname (str) – Should be the name of a class in the wrapped code.