psyclone.domain.lfric.algorithm
Module to capture LFRic-specific classes for the Algorithm layer.
Submodules
Classes
LFRicAlg
: Encapsulates the functionality for generating an LFRic AlgorithmLFRicAlgorithmInvokeCall
: An invoke call from the LFRic Algorithm layer.LFRicBuiltinFunctor
: Base class which all LFRic builtins subclass. Contains a builtin call,LFRicBuiltinFunctorFactory
: This class is a singleton which generates and stores a Functor class forLFRicFunctor
: Base functor class for all LFRic user-supplied and built-in kernels.LFRicKernelFunctor
: Object containing a call to a user-provided LFRic kernel, a description
- class psyclone.domain.lfric.algorithm.LFRicAlg
Encapsulates the functionality for generating an LFRic Algorithm layer from Kernel metadata.
Inheritance
- construct_kernel_args(prog, kern)
Extends the supplied routine with all the declarations and initialisation required for the arguments of the supplied kernel.
- Parameters:
prog (
psyclone.psyir.nodes.Routine
) – the routine to which to add the declarations etc.kern (
psyclone.domain.lfric.LFRicKern
) – the kernel for which we are to create arguments.
- 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:
- 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:
- 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:
prog (
psyclone.psyir.nodes.Routine
) – the routine to which to add initialisation code.sym (
psyclone.psyir.symbols.DataSymbol
) – the symbol representing the LFRic field.space (str) – the function space of the field.
- 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:
prog (
psyclone.psyir.nodes.Routine
) – the routine to which to add suitable declarations etc.qr_sym (
psyclone.psyir.symbols.DataSymbol
) – the symbol representing a quadrature object.shape (str) – the shape of the quadrature.
- 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:
- Raises:
ValueError – if an LFRic kernel with the specified name cannot be found in the supplied parse tree.
- class psyclone.domain.lfric.algorithm.LFRicAlgorithmInvokeCall(invoke_routine_symbol, index, parent=None, name=None)
An invoke call from the LFRic Algorithm layer.
Inheritance
- class psyclone.domain.lfric.algorithm.LFRicBuiltinFunctor(symbol, parent=None)
Base class which all LFRic builtins subclass. Contains a builtin call, a description of its required interface and the arguments to be passed to it.
Inheritance
- classmethod create(table, arguments)
An appropriate DataTypeSymbol is created and added to the supplied symbol table (if it does not already contain one). This is then passed to the create() method in the base class to create an instance of an LFRic builtin call with the supplied list of arguments.
- Parameters:
table (
psyclone.psyir.symbols.SymbolTable
) – the symbol table to which to add the symbol for this functor.arguments (List[
psyclone.psyir.nodes.DataNode
]) – the arguments to this routine. These are added as child nodes.
- Returns:
a functor object describing an LFRic builtin.
- Return type:
- Raises:
InternalError – if a symbol is found that has the same name as a built-in but does not have the correct properties.
- lower_to_language_level()
Removes the symbol representing this BuiltIn as it only exists in the DSL.
- Returns:
the lowered version of this node.
- Return type:
psyclone.psyir.node.Node
- class psyclone.domain.lfric.algorithm.LFRicBuiltinFunctorFactory
This class is a singleton which generates and stores a Functor class for each built-in supported by LFRic. An instance of one of these classes may be obtained by using the create() method.
- Raises:
ValueError – if an attempt is made to construct a second instance of this class.
Inheritance
- create(name, table, arguments)
Create a BuiltinFunctor for the named LFRic builtin.
- Parameters:
name (str) – the built-in for which a functor is required.
table (
psyclone.psyir.symbols.SymbolTable
) – the symbol table to which to add a corresponding symbol.arguments (List[
psyclone.psyir.nodes.DataNode
]) – the arguments to give to the functor.
- static get()
- Returns:
the singleton instance of this class.
- Return type:
- py:class:
psyclone.domain.lfric.algorithm.psyir.LFRicBuiltinFunctorFactory
- class psyclone.domain.lfric.algorithm.LFRicFunctor(symbol, parent=None)
Base functor class for all LFRic user-supplied and built-in kernels.
Inheritance
- class psyclone.domain.lfric.algorithm.LFRicKernelFunctor(symbol, parent=None)
Object containing a call to a user-provided LFRic kernel, a description of its required interface and the arguments to be passed to it.
Inheritance