psyclone.domain.lfric.lfric_stencils

This module implements the stencil information and code generation associated with a PSy-layer routine or Kernel stub in the LFRic API.

Classes

  • LFRicStencils: Stencil information and code generation associated with a PSy-layer

class psyclone.domain.lfric.lfric_stencils.LFRicStencils(node)

Stencil information and code generation associated with a PSy-layer routine or Kernel stub.

Parameters:

node (psyclone.dynamo0p3.LFRicInvoke or psyclone.domain.lfric.LFRicKern) – the Invoke or Kernel stub for which to provide stencil info.

Raises:

GenerationError – if a literal has been supplied for a stencil direction.

Inheritance

Inheritance diagram of LFRicStencils
static direction_name(symtab, arg)

Creates a Fortran variable name to hold the direction of the stencil associated with the supplied kernel argument.

Parameters:
Returns:

a Fortran variable name for the stencil direction.

Return type:

str

static dofmap_size_symbol(symtab, arg)

Create a valid symbol for the size (in cells) of a stencil dofmap in the PSy layer.

Parameters:
Returns:

a symbol for the stencil size.

Return type:

psyclone.psyir.symbols.Symbol

static dofmap_symbol(symtab, arg)

Creates and registers a symbol for the stencil dofmap associated with the supplied kernel argument.

Parameters:
Returns:

a dofmap symbol for a stencil in the PSy layer.

Return type:

psyclone.psyir.symbols.Symbol

static extent_value(arg)

Returns the content of the stencil extent which may be a literal value (a number) or a variable name. This function simplifies this problem by returning a string in either case.

Parameters:

arg (psyclone.dynamo0p3.DynKernelArgument) – the argument with which the stencil is associated.

Returns:

the content of the stencil extent.

Return type:

str

initialise(parent)

Adds in the code to initialise stencil dofmaps to the PSy layer.

Parameters:

parent (psyclone.f2pygen.SubroutineGen) – the node in the f2pygen AST to which to add the initialisations.

Raises:

GenerationError – if an unsupported stencil type is encountered.

map_name(arg)

Creates and registers a name for the stencil map associated with the supplied kernel argument.

Parameters:

arg (psyclone.dynamo0p3.DynKernelArgument) – kernel argument with which the stencil is associated.

Returns:

a valid unique map name for a stencil in the PSy layer.

Return type:

str

static max_branch_length_name(symtab, arg)

Create a valid unique name for the maximum length of a stencil branch (in cells) of a 2D stencil dofmap in the PSy layer. This is required in the kernels for defining the maximum possible length of one of the dofmap array dimensions.

Parameters:
Returns:

a Fortran variable name for the max stencil branch length.

Return type:

str

static stencil_unique_str(arg, context)

Creates a unique identifier for a stencil. As a stencil differs due to the function space it operates on, type of stencil and extent of stencil, we concatenate these things together to create a unique string.

Parameters:
  • arg (psyclone.dynamo0p3.DynKernelArgument) – kernel argument with which stencil is associated.

  • context (str) – a context for this stencil (e.g. “size” or “direction”).

Returns:

unique string identifying the stencil for this argument.

Return type:

str

Raises:

GenerationError – if an explicit stencil extent is found in the metadata for the kernel argument.

property unique_alg_vars
Returns:

list of the names of the extent and direction arguments supplied to the PSy routine from the Algorithm layer.

Return type:

list of str