psyclone.domain.lfric.kernel.common_meta_arg_metadata

Module containing the abstract CommonMetaArgMetadata class which captures the metadata associated with an LFRic meta_arg argument. Supports the creation, modification and Fortran output of such an argument.

Classes

class psyclone.domain.lfric.kernel.common_meta_arg_metadata.CommonMetaArgMetadata(datatype, access)

Abstract class to capture common aspects of LFRic kernel metadata.

Parameters:
  • datatype (Optional[str]) – the datatype of this argument.

  • access (Optional[str]) – the way the kernel accesses this argument.

Inheritance

Inheritance diagram of CommonMetaArgMetadata
property access
Returns:

the access descriptor for this argument.

Return type:

str

abstract static check_access(value)

Check that value is a valid value for the access descriptor.

abstract static check_datatype(value)

Check that value is a valid datatype.

classmethod check_first_arg(fparser2_tree)

Check that the first metadata argument has the expected value.

Parameters:

fparser2_tree (fparser.two.Fortran2003.Part_Ref | fparser.two.Fortran2003.Structure_Constructor) – the metadata encoded in an fparser2_tree

Raises:

ValueError – if the first metadata argument has an incorrect value.

classmethod check_nargs(fparser2_tree)

Check that the metadata has the expected number of arguments, otherwise an exception is raised.

Parameters:

fparser2_tree (fparser.two.Fortran2003.Part_Ref | fparser.two.Fortran2003.Structure_Constructor) – fparser2 tree capturing a metadata argument.

classmethod check_remaining_args(fparser2_tree, *metadata_args)

Check that the remaining untested metadata arguments have the expected value. If they do not then re-raise the exception from the class constructor, adding in positional information and the metadata arguments to make it clearer where the exception occured.

Parameters:
  • fparser2_tree (fparser.two.Fortran2003.Part_Ref or fparser.two.Fortran2003.Structure_Constructor) – the metadata encoded in an fparser2_tree.

  • metadata_args (unwrapped dict) – the metadata arguments required to create an instance of the class provided by the ‘cls’ argument.

Raises:
  • ValueError – if the metadata has an incorrect value.

  • InternalError – if an unrecognised exception message is found.

classmethod create_from_fparser2(fparser2_tree)

Create an instance of the class from an fparser2 tree.

Parameters:

fparser2_tree (fparser.two.Fortran2003.Part_Ref) – fparser2 tree containing the metadata for this argument.

Returns:

an instance of the class.

Return type:

subclass of psyclone.domain.lfric.kernel.CommonMetaArgMetadata

property datatype
Returns:

the datatype for this metadata argument.

Return type:

str

classmethod get_vector_length(fparser2_tree)

Retrieves the vector length metadata value found within the supplied fparser2 tree and checks that it is valid.

Parameters:

fparser2_tree (fparser.two.Fortran2003.Part_Ref) – fparser2 tree capturing the required metadata.

Returns:

the vector length value extracted from the fparser2 tree.

Return type:

str

Raises:

TypeError – if the vector length metadata is not in the expected form.