psyclone.domain.gocean.kernel.psyir

This module contains PSyclone Kernel-layer-specific PSyIR classes for the GOcean API.

Classes

class psyclone.domain.gocean.kernel.psyir.GOceanContainer(name, metadata, **kwargs)

A GOcean-specific Container. This specialises the generic Container node and adds in any domain-specific information.

Parameters:
  • name (str) – the name of the container.

  • metadata (psyclone.domain.gocean.kernel.psyir.        GOceanKernelMetadata) – the metadata object.

  • parent (psyclone.psyir.nodes.Node) – optional parent node of this Container in the PSyIR.

  • symbol_table (Optional[psyclone.psyir.symbols.SymbolTable]) – initialise the node with a given symbol table.

Inheritance

Inheritance diagram of GOceanContainer
classmethod create(name, metadata, symbol_table, children)

Create a GOceanContainer instance given a name, metadata, a symbol table and a list of child nodes. A GOcean-specific kernel is created with the metadata describing the kernel interface for a single kernel routine within the container.

Parameters:
Returns:

an instance of cls.

Return type:

psyclone.psyir.nodes.Container or subclass thereof

lower_to_language_level()

Lower this GOcean-specific container to language level psyir.

Returns:

the lowered version of this node.

Return type:

psyclone.psyir.node.Node

property metadata

:returns the GOcean metadata object. :rtype: psyclone.domain.gocean.kernel.psyir.            GOceanKernelMetadata

class psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata(iterates_over=None, index_offset=None, meta_args=None, procedure_name=None, name=None)

Contains GOcean 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:
  • iterates_over (Optional[str]) – the name of the quantity that this kernel is intended to iterate over.

  • index_offset (Optional[str]) – the name of the quantity that specifies the index offset (how different field indices relate to each other).

  • meta_args (Optional[List[GridArg | FieldArg | ScalarArg]]) – a list of ‘meta_arg’ objects which capture the metadata values of the kernel arguments.

  • 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 GOceanKernelMetadata
class FieldArg(meta_arg, parent)

Internal class to capture Kernel metadata information for a field argument.

Parameters:
  • meta_arg (fparser.two.Fortran2003.Part_Ref) – an fparser2 tree representation of the metadata.

  • parent (:py:class`psyclone.psyir.common.kernel. KernelMetadataSymbol`) – a KernelMetadataSymbol instance that captures other parts of the metadata and references this instance.

Raises:

ParseError – if the metadata does not contain three arguments.

property access
Returns:

the access descriptor for this field argument.

Return type:

str

property form
Returns:

the form of access for the field (pointwise, stencil, …).

Return type:

str

fortran_string()
Returns:

the metadata represented by this class as a Fortran string.

Return type:

str

property grid_point_type
Returns:

the value of the grid point type (go_ct, …) for the field argument.

Return type:

str

property stencil
Returns:

the stencil value, or None if there is no stencil.

Return type:

Optional[List[str]]

class GridArg(meta_arg, parent)

Internal class to capture Kernel metadata argument information for a grid property.

Parameters:
  • meta_arg (fparser.two.Fortran2003.Part_Ref) – an fparser2 tree representation of the metadata.

  • parent (:py:class`psyclone.psyir.common.kernel. KernelMetadataSymbol`) – a KernelMetadataSymbol instance that captures other parts of the metadata and references this instance.

Raises:

ParseError – if the metadata does not contain two arguments.

property access
Returns:

the value of the access descriptor. This specifies how the grid property is accessed (read, write, readwrite).

Return type:

str

fortran_string()
Returns:

the metadata represented by this class as a Fortran string.

Return type:

str

property name
Returns:

the grid property name as specified by the metadata.

Return type:

str

class ScalarArg(meta_arg, parent)

Internal class to capture Kernel metadata information for a scalar argument.

Parameters:
  • meta_arg (fparser.two.Fortran2003.Part_Ref) – an fparser2 tree representation of the metadata.

  • parent (:py:class`psyclone.psyir.common.kernel. KernelMetadataSymbol`) – a KernelMetadataSymbol instance that captures other parts of the metadata and references this instance.

Raises:

ParseError – if the metadata does not contain three arguments.

property access
Returns:

the access descriptor for this scalar argument.

Return type:

str

property datatype
Returns:

the datatype of the scalar argument.

Return type:

str

property form
Returns:

the form of access for the scalar (pointwise …).

Return type:

str

fortran_string()
Returns:

the metadata represented by this class as a Fortran string.

Return type:

str

static create_from_fortran_string(fortran_string)

Create a new instance of GOceanKernelMetadata populated with metadata stored in a fortran string.

Parameters:

fortran_string (str) – the metadata stored as Fortran.

Returns:

an instance of GOceanKernelMetadata.

Return type:

psyclone.domain.gocean.kernel.psyir.            GOceanKernelMetadata

Raises:
  • ValueError – if the string does not contain a fortran derived type.

  • ParseError – if the metadata has an unexpected format.

static create_from_psyir(symbol)

Create a new instance of GOceanKernelMetadata 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 GOceanKernelMetadata.

Return type:

psyclone.domain.gocean.kernel.psyir.            GOceanKernelMetadata

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

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

fortran_string()
Returns:

the metadata represented by this instance as Fortran.

Return type:

str

property index_offset
Returns:

the name of the quantity that specifies the index offset (how different field indices relate to each other).

Return type:

str

property iterates_over
Returns:

the name of the quantity that this kernel is intended to iterate over.

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:

List[psyclone.psyir.common.kernel.            KernelMetadataSymbol.KernelMetadataArg]

property name
Returns:

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

Return type:

str

property procedure_name
Returns:

the kernel procedure name specified by the metadata.

Return type:

str