psyclone.domain.lfric.algorithm.lfric_alg

This module contains the LFRicAlg class which encapsulates tools for creating standalone LFRic algorithm-layer code.

Classes

  • LFRicAlg: Encapsulates the functionality for generating an LFRic Algorithm

class psyclone.domain.lfric.algorithm.lfric_alg.LFRicAlg

Encapsulates the functionality for generating an LFRic Algorithm layer from Kernel metadata.

Inheritance

Inheritance diagram of LFRicAlg
construct_kernel_args(prog, kern)

Extends the supplied routine with all the declarations and initialisation required for the arguments of the supplied kernel.

Parameters:
Returns:

object capturing all of the kernel arguments.

Return type:

psyclone.domain.lfric.KernCallInvokeArgList

static create_alg_routine(name)

Creates an LFRic algorithm subroutine within a module. The generated subroutine has three arguments:

  • mesh: pointer to the LFRic mesh object.

  • chi: coordinate field (optional).

  • panel_id: field mapping cells to panel IDs (optional).

Parameters:

name (str) – the name to give the created routine. The associated container will have “_mod” appended to this name.

Returns:

a container.

Return type:

psyclone.psyir.nodes.Container

Raises:

TypeError – if the ‘name’ argument is of the wrong type.

create_from_kernel(name, kernel_path)

Generates LFRic algorithm PSyIR that calls the supplied kernel through an ‘invoke’. All of the arguments required by the kernel are constructed and intialised appropriately. Fields and scalars are all set to unity.

Parameters:
  • name (str) – name to use for the algorithm subroutine.

  • kernel_path (str) – location of Kernel source code.

Returns:

LFRic algorithm PSyIR.

Return type:

psyclone.psyir.nodes.Container

Raises:

NotImplementedError – if the specified kernel file does not follow the LFRic naming convention by having a module with a name ending in ‘_mod’.

static initialise_field(prog, sym, space)

Creates the PSyIR for initialisation of the field or field vector represented by the supplied symbol and adds it to the supplied routine.

Parameters:
Raises:

InternalError – if the supplied symbol is of the wrong type.

static initialise_operator(prog, sym, from_space, to_space)

Creates the PSyIR for initialisation of the operator represented by the supplied symbol and adds it to the supplied routine.

Parameters:
  • prog (psyclone.psyir.nodes.Routine) – the routine to which to add initialisation code.

  • sym (psyclone.psyir.symbols.DataSymbol) – the symbol representing the LFRic operator.

  • from_space (str) – the function space that the operator maps from.

  • to_space (str) – the function space that the operator maps to.

Raises:

InternalError – if the supplied symbol is of the wrong type.

static initialise_quadrature(prog, qr_sym, shape)

Adds the necessary declarations and intialisation for the supplied quadrature to the supplied routine.

Parameters:
Raises:

NotImplementedError – if the quadrature shape is anything other than gh_quadrature_xyoz.

static kernel_from_metadata(parse_tree, kernel_name)

Given an fparser1 parse tree for an LFRic kernel, creates and returns a LFRicKern object.

Parameters:
  • parse_tree (fparser.one.block_statements.BeginSource) – the fparser1 parse tree for the LFRic kernel.

  • kernel_name (str) – the name of the kernel contained in the supplied parse tree for which a LFRicKern is to be created.

Returns:

a LFRicKern object describing the LFRic kernel.

Return type:

psyclone.domain.lfric.LFRicKern

Raises:

ValueError – if an LFRic kernel with the specified name cannot be found in the supplied parse tree.