psyclone.domain.lfric.kernel.lfric_kernel_metadata

Module containing the LFRicKernelMetadata kernel-layer-specific class that captures the LFRic kernel metadata.

Classes

class psyclone.domain.lfric.kernel.lfric_kernel_metadata.LFRicKernelMetadata(operates_on=None, shapes=None, evaluator_targets=None, meta_args=None, meta_funcs=None, meta_ref_element=None, meta_mesh=None, procedure_name=None, name=None)

Contains LFRic kernel metadata. This class supports kernel metadata creation, modification, loading from a fortran string, writing to a fortran string, raising from existing language-level PSyIR and lowering to language-level PSyIR.

Parameters:
  • operates_on (Optional[str]) – the name of the quantity that this kernel is intended to iterate over.

  • shapes (Optional[List[str]]) – if a kernel requires basis or differential-basis functions then the metadata must also specify the set of points on which these functions are required. This information is provided by the gh_shape component of the metadata.

  • evaluator_targets (Optional[List[str]]) – the function spaces on which an evaluator is required.

  • meta_args (Optional[List[psyclone.domain.lfric.kernel.        CommonArgMetadata]]) – a list of ‘meta_arg’ objects which capture the metadata values of the kernel arguments.

  • meta_funcs (Optional[List[psyclone.domain.lfric.kernel.        MetaFuncsArgMetadata]]) – a list of ‘meta_func’ objects which capture whether quadrature or evaluator data is required for a given function space.

  • meta_ref_element (Optional[psyclone.domain.lfric.kernel.        RefElementArgMetadata]) – a kernel that requires properties of the reference element in LFRic specifies those properties through the meta_reference_element metadata entry.

  • meta_mesh (Optional[psyclone.domain.lfric.kernel.        MetaMeshArgMetadata]) – a kernel that requires properties of the LFRic mesh object specifies those properties through the meta_mesh metadata entry.

  • procedure_name (Optional[str]) – the name of the kernel procedure to call.

  • name (Optional[str]) – the name of the symbol to use for the metadata in language-level PSyIR.

Inheritance

Inheritance diagram of LFRicKernelMetadata
static create_from_fparser2(fparser2_tree)

Create an instance of this class from an fparser2 tree.

Parameters:

fparser2_tree (fparser.two.Fortran2003.Derived_Type_Ref) – fparser2 tree containing the metadata for an LFRic Kernel.

Returns:

an instance of LFRicKernelMetadata.

Return type:

psyclone.domain.lfric.kernel.psyir.            LFRicKernelMetadata

Raises:
  • ParseError – if one of the meta_args entries is an unexpected type.

  • ParseError – if the metadata type does not extend kernel_type.

static create_from_psyir(symbol)

Create a new instance of LFRicKernelMetadata populated with metadata from a kernel in language-level PSyIR.

Parameters:

symbol (psyclone.psyir.symbols.DataTypeSymbol) – the symbol in which the metadata is stored in language-level PSyIR.

Returns:

an instance of LFRicKernelMetadata.

Return type:

psyclone.domain.lfric.kernel.psyir.            LFRicKernelMetadata

Raises:
  • TypeError – if the symbol argument is not the expected type.

  • InternalError – if the datatype of the provided symbol is not the expected type.

property evaluator_targets
Returns:

a list of evaluator_targets metadata values.

Return type:

Optional[List[str]]

field_meta_args_on_fs(arg_types, function_space)

Utility function to return any field (plus field vector, intergrid or intergrid vector) meta_args in metadata that have the same type as those specified in arg_types and are on the function space specified in function_space.

Parameters:
  • arg_types (List[ psyclone.domain.lfric.kernel.CommonMetaArgMetadata]) – meta_arg classes indicating which meta_arg arguments to check.

  • function_space (str) – the specified function space.

Returns:

a list of meta_args.

fortran_string()
Returns:

the metadata represented by this instance as Fortran.

Return type:

str

Raises:

ValueError – if the values for name, meta_arg, operates_on and procedure_name have not been set.

fparser2_class

alias of Derived_Type_Def

property kernel_type
Returns:

the type of kernel that this is.

Return type:

str

lower_to_psyir()

Lower the metadata to language-level PSyIR.

Returns:

metadata as stored in language-level PSyIR.

Return type:

psyclone.psyir.symbols.DataTypeSymbol

property meta_args
Returns:

a list of ‘meta_arg’ objects which capture the metadata values of the kernel arguments.

Return type:

Optional[List[psyclone.domain.lfric.kernel.            CommonArg]]

meta_args_get(types)

Return a list of meta_args entries with names that match the ‘types’ argument.

Parameters:

types – a meta_arg type or list of meta_arg types.

Returns:

a list of meta_args entries.

Return type:

List[ py:class:psyclone.domain.lfric.kernel.CommonMetaArgMetadata]

Raises:

TypeError – if the types argument is not of the correct type.

property meta_funcs
Returns:

a list of meta_funcs metadata values.

Return type:

Optional[List[psyclone.domain.lfric.kernel.            MetaFuncsArgMetadata]]

property meta_mesh
Returns:

a list of meta_mesh metadata values.

Return type:

Optional[List[psyclone.domain.lfric.kernel.            MetaMeshArgMetadata]]

property meta_ref_element
Returns:

a list of meta_reference_element metadata values.

Return type:

Optional[List[psyclone.domain.lfric.kernel.            MetaRefElementArgMetadata]]

property name
Returns:

the name of the symbol that will contain the metadata when lowering.

Return type:

str

property operates_on
Returns:

the kernel operates_on property specified by the metadata.

Return type:

str

operator_meta_args_on_fs(arg_types, function_space)

Utility function to return any operator meta_args in metadata that have the same type as those specified in arg_types and their from or to function spaces are the same as the function space specified in function_space.

Parameters:
  • arg_types (List[ psyclone.domain.lfric.kernel.CommonMetaArgMetadata]) – meta_arg classes indicating which meta_arg arguments to check.

  • function_space (str) – the specified function space.

Returns:

a list of meta_args.

property procedure_name
Returns:

the kernel procedure name specified by the metadata.

Return type:

str

property shapes
Returns:

a list of shape metadata values.

Return type:

Optional[List[str]]

validate()

Only certain metadata combinations are allowed in LFRic. This routine checks that any such constraints are respected.

Raises:

ParseError – if any validation checks fail.