loki.transformations.extract.outline

Functions

order_variables_by_type(variables[, imports])

Apply a default ordering to variables based on their type, so that their use in declaration lists is unified.

outline_pragma_regions(routine)

Convert regions annotated with !$loki outline pragmas to subroutine calls.

outline_region(region, name, imports[, ...])

Creates a new Subroutine object from a given PragmaRegion.

outline_region(region, name, imports, intent_map=None)

Creates a new Subroutine object from a given PragmaRegion.

Parameters:
  • region (PragmaRegion) – The region that holds the body for which to create a subroutine.

  • name (str) – Name of the new subroutine

  • imports (tuple of Import, optional) – List of imports to replicate in the new subroutine

  • intent_map (dict, optional) – Mapping of instent strings to list of variables to override intents

Returns:

The newly created call and respectice subroutine.

Return type:

tuple of CallStatement and Subroutine

outline_pragma_regions(routine)

Convert regions annotated with !$loki outline pragmas to subroutine calls.

The pragma syntax for regions to convert to subroutines is !$loki outline [name(...)] [in(...)] [out(...)] [inout(...)] and !$loki end outline.

A new subroutine is created with the provided name (or an auto-generated default name derived from the current subroutine name) and the content of the pragma region as body.

Variables provided with the in, out and inout options are used as arguments in the routine with the corresponding intent, all other variables used in this region are assumed to be local variables.

The pragma region in the original routine is replaced by a call to the new subroutine.

Parameters:

routine (Subroutine) – The routine from which to extract marked pragma regions.

Returns:

the list of newly created subroutines.

Return type:

list of Subroutine