psyclone.domain.lfric.kernel.common_metadata

Module containing the CommonMetadata base class which captures the common functionality for LFRic kernel metadata.

Classes

  • CommonMetadata: Abstract class to capture common LFRic kernel metadata.

class psyclone.domain.lfric.kernel.common_metadata.CommonMetadata

Abstract class to capture common LFRic kernel metadata.

Inheritance

Inheritance diagram of CommonMetadata
static check_fparser2(fparser2_tree, encoding)

Checks that the fparser2 tree is valid.

Parameters:
  • fparser2_tree (fparser.two.Fortran2003.Base) – fparser2 tree capturing a metadata argument.

  • encoding (fparser.two.Fortran2003.Base) – class in which the fparser2 tree should be encoded.

Raises:

TypeError – if the fparser2_tree argument is not of the type specified by the encoding argument.

static create_fparser2(fortran_string, encoding)

Creates an fparser2 tree from a Fortran string. The resultant parent node of the tree will be the same type as the encoding argument if the string conforms to the encoding, otherwise an exception will be raised.

TODO: issue #1965: relocate this method as it is not specific to metadata processing.

Parameters:
  • fortran_string (str) – a string containing the metadata in Fortran.

  • encoding (subclass of fparser.two.Fortran2003.Base) – the parent class with which we will encode the Fortran string.

Returns:

an fparser2 tree containing a metadata argument.

Return type:

subclass of fparser.two.Fortran2003.Base

Raises:

ValueError – if the Fortran string is not in the expected form.

classmethod create_from_fortran_string(fortran_string)

Create an instance of this class from Fortran.

Parameters:

fortran_string (str) – a string containing the metadata in Fortran.

Returns:

an instance of this class.

Return type:

subclass of python.domain.lfric.kernel.CommonMetadata

abstract static create_from_fparser2(fparser2_tree)

Create an instance of this class from an fparser2 tree.

static validate_scalar_value(value, valid_values, name)

Check that the value argument is one of the values supplied in the valid_values list.

Parameters:
  • value (str) – the value being checked.

  • valid_values (List[str]) – a list of valid values.

  • name (str) – the name of the metadata being checked

Raises:
  • TypeError – if the value is not a string.

  • ValueError – if the supplied value is not one of the values in the valid_values list.