loki.transform.fortran_c_transform

Classes

FortranCTransformation([header_modules, ...])

Fortran-to-C transformation that translates the given routine into C and generates the corresponding ISO-C wrappers.

class FortranCTransformation(header_modules=None, inline_elementals=True)

Bases: Transformation

Fortran-to-C transformation that translates the given routine into C and generates the corresponding ISO-C wrappers.

transform_file(sourcefile, **kwargs)

Defines the transformation to apply to Sourcefile items.

For transformations that modify Sourcefile objects, this method should be implemented. It gets called via the dispatch method apply().

Parameters:
  • sourcefile (Sourcefile) – The sourcefile to be transformed.

  • **kwargs (optional) – Keyword arguments for the transformation.

transform_module(module, **kwargs)

Defines the transformation to apply to Module items.

For transformations that modify Module objects, this method should be implemented. It gets called via the dispatch method apply().

Parameters:
  • module (Module) – The module to be transformed.

  • **kwargs (optional) – Keyword arguments for the transformation.

transform_subroutine(routine, **kwargs)

Defines the transformation to apply to Subroutine items.

For transformations that modify Subroutine objects, this method should be implemented. It gets called via the dispatch method apply().

Parameters:
  • routine (Subroutine) – The subroutine to be transformed.

  • **kwargs (optional) – Keyword arguments for the transformation.

classmethod c_struct_typedef(derived)

Create the TypeDef for the C-wrapped struct definition.

static iso_c_intrinsic_import(scope)
static iso_c_intrinsic_kind(_type, scope)
static c_intrinsic_kind(_type, scope)
classmethod generate_iso_c_wrapper_routine(routine, c_structs, bind_name=None)
classmethod generate_iso_c_wrapper_module(module)

Generate the ISO-C wrapper module for a raw Fortran module.

Note, we only create getter functions for module variables here, since certain type definitions cannot be used in ISO-C interfaces due to pointer variables, etc.

classmethod generate_iso_c_interface(routine, bind_name, c_structs, scope)

Generate the ISO-C subroutine interface

generate_c_header(module, **kwargs)

Re-generate the C header as a module with all pertinent nodes, but not Fortran-specific intrinsics (eg. implicit none or save).

generate_c_kernel(routine, **kwargs)

Re-generate the C kernel and insert wrapper-specific peculiarities, such as the explicit getter calls for imported module-level variables.