psyclone.domain.lfric.transformations.raise_psyir_2_lfric_kern_trans
Raise generic PSyIR representing a kernel-layer routine to LFRic kernel-layer-specific PSyIR which uses specialised classes.
Functions
find_symbol()
: Utility method to find the symbol associated with the supplied
- psyclone.domain.lfric.transformations.raise_psyir_2_lfric_kern_trans.find_symbol(node, name)
Utility method to find the symbol associated with the supplied name. The supplied node and all of its descendants are searched and the symbol and its scoping node are returned if the symbol is found. If not found, None is returned for the symbol and scoping node.
- Parameters:
node – the starting node for the search.
name (str) – the name of the symbol being searched.
- Type:
- Returns:
a tuple containing the symbol with the same name as the supplied name and the scoping node for that symbol.
- Return type:
Tuple[Optional[
psyclone.psyir.symbols.datasymbol], Optional[:py:class:`psyclone.psyir.nodes.node
]]
Classes
RaisePSyIR2LFRicKernTrans
: Raise a generic PSyIR representation of a kernel-layer routine and
- class psyclone.domain.lfric.transformations.raise_psyir_2_lfric_kern_trans.RaisePSyIR2LFRicKernTrans
Raise a generic PSyIR representation of a kernel-layer routine and metadata to an LFRic version with specialised domain-specific nodes and symbols. This is currently limited to the specialisation of kernel metadata.
>>> from psyclone.domain.lfric.transformations import RaisePSyIR2LFRicKernTrans >>> from psyclone.psyir.frontend.fortran import FortranReader >>> CODE = (""" ... MODULE example ... TYPE, EXTENDS(kernel_type) :: compute_cu ... TYPE(arg_type), DIMENSION(4) :: meta_args = (/ & ... arg_type(GH_FIELD, GH_REAL, GH_INC, W1), & ... arg_type(GH_FIELD, GH_REAL, GH_READ, W3), & ... arg_type(GH_FIELD, GH_REAL, GH_READ, W3), & ... arg_type(GH_FIELD, GH_REAL, GH_READ, W3)/) ... INTEGER :: OPERATES_ON = CELL_COLUMN ... CONTAINS ... PROCEDURE, NOPASS :: code => compute_cu_code ... END TYPE compute_cu ... contains ... subroutine compute_cu_code() ... end subroutine ... end module""") >>> fortran_reader = FortranReader() >>> kernel_container = fortran_reader.psyir_from_source(CODE) >>> trans = RaisePSyIR2LFRicKernTrans() >>> trans.apply(kernel_container, {"metadata_name": "compute_cu"})
Inheritance
- apply(node, options=None)
Raise the supplied language-level kernel to LFRic-specific kernel PSyIR. Specialises the kernel container to an LFRic-specific subclass, populates this subclass with the kernel metadata extracted from the metadata symbol as specified in metadata_name (which is supplied via the options argument) and removes the symbol from the symbol table.
- Parameters:
node (
psyclone.psyir.node.Container
) – a kernel represented in generic PSyIR.options (Optional[Dict[str: str]]) – a dictionary with options for transformations. This is expected to contain the metadata_name.
- validate(node, options=None)
Validate the supplied PSyIR tree.
- Parameters:
node (
psyclone.psyir.node.Container
) – a PSyIR node that is the root of a PSyIR tree.options (Optional[Dict[str: str]]) – a dictionary with options for transformations.
- Raises:
TransformationError – if the supplied node is not a Container.
TransformationError – if the supplied node argument has a parent.
TransformationError – if the metadata name has not been provided in the options argument.
TransformationError – if the metadata name has not been set or does not exist in the code.
TransformationError – if the metadata symbol does not reside in a Container (as opposed to a FileContainer).