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)[source]#

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

Parameters:

node (psyclone.lfric.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)[source]#

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)[source]#

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)[source]#

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

extent_value(arg)[source]#

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.lfric.LFRicKernelArgument) – the argument with which the stencil is associated.

Return type:

DataNode

Returns:

the content of the stencil extent.

initialise(cursor)[source]#

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

Parameters:

cursor (int) – position where to add the next initialisation statements.

Return type:

int

Returns:

Updated cursor value.

Raises:

GenerationError – if an unsupported stencil type is encountered.

invoke_declarations()[source]#

Declares all stencil maps, extent and direction arguments passed into the PSy layer.

map_name(arg)[source]#

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

Parameters:

arg (psyclone.lfric.LFRicKernelArgument) – 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(symtab, arg)[source]#

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:
Return type:

DataSymbol

Returns:

the symbol representing the max stencil branch length.

static stencil_unique_str(arg, context)[source]#

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.lfric.LFRicKernelArgument) – 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.

stub_declarations()[source]#

Declares all stencil-related quanitites for a Kernel stub.

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