# loki.transformations.build_system.module_wrap module

class ModuleWrapTransformation(module_suffix, replace_ignore_items=True)

  Bases: `Transformation`

  Utility transformation that ensures all transformed kernel subroutines are wrapped in a module

  The module name is derived from the subroutine name and `module_suffix`.

  Any previous import of wrapped subroutines via interfaces or C-style header imports of interface blocks is replaced by a Fortran import (`USE`).

  Parameters:

    - module_suffix (str) – Special suffix to signal module names like _MOD

    - replace_ignore_items (bool) – Debug flag to toggle the replacement of calls to subroutines in the `ignore`. Default is `True`.

  traverse_file_graph = True
  recurse_to_modules = True
  recurse_to_procedures = True
  recurse_to_internal_procedures = False
  renames_items = True
  creates_items = True
  transform_file(sourcefile, **kwargs)

    For kernel routines, wrap each subroutine in the current file in a module

  transform_module(module, **kwargs)

    Update imports of wrapped subroutines

  transform_subroutine(routine, **kwargs)

    Update imports of wrapped subroutines

  module_wrap(sourcefile)

    Wrap target subroutines in modules and replace in source file.

  update_imports(source, imports, **kwargs)

    Update imports of wrapped subroutines.

  replace_interfaces(source, intfs, **kwargs)

    Update explicit interfaces to actively transformed subroutines.