psyclone.domain.lfric.kernel.common_arg_metadata
Module containing the abstract CommonArgMetadata class which captures the metadata associated with a generic LFRic argument. Supports the creation, modification and Fortran output of such an argument.
Classes
CommonArgMetadata
: Class to capture common LFRic kernel argument metadata.
- class psyclone.domain.lfric.kernel.common_arg_metadata.CommonArgMetadata
Class to capture common LFRic kernel argument metadata.
Inheritance
- static check_boolean(value, name)
- Parameters:
value (bool) – the value to validate.
name (str) – the name of the entity being checked.
- Raises:
TypeError – if the provided value is not a boolean.
- classmethod check_fparser2_arg(fparser2_tree, type_name)
Checks that the fparser2 tree is valid. The metadata will be in the form of a Fortran2003 Part_Ref or a Fortran2003 Structure_Constructor which captures a metadata argument.
- Parameters:
fparser2_tree (
fparser.two.Fortran2003.Part_Ref
|fparser.two.Fortran2003.Structure_Constructor
) – fparser2 tree capturing a metadata argument.type_name (str) – the name of the argument datatype.
- Raises:
ValueError – if the kernel metadata is not in the form arg_type(…).
- static check_nargs(fparser2_tree, nargs)
Checks that the metadata has the number of arguments specified by the ‘nargs’ argument, otherwise an exception is raised.
- Parameters:
fparser2_tree (
fparser.two.Fortran2003.Part_Ref
|fparser.two.Fortran2003.Structure_Constructor
) – fparser2 tree capturing a metadata argument.nargs (int or Tuple[int, int]) – the number of expected arguments. This can either be a single value or a list containing a lower and an upper value.
- Raises:
ValueError – if the kernel metadata does not contain the expected number of arguments (nargs).
- fparser2_class
alias of
Part_Ref
- static get_arg(fparser2_tree, index)
Retrieves the metadata value found at the position specified by the index argument within the supplied fparser2 tree.
- Parameters:
fparser2_tree (
fparser.two.Fortran2003.Part_Ref
) – fparser2 tree capturing the required metadata.index (int) – the position of the metadata argument.
- Returns:
the metadata value extracted from the fparser2 tree or None if it does not exist.
- Return type:
Optional[str]
- static get_nargs(fparser2_tree)
Returns the number of metadata arguments found in the fparser2 tree.
- Parameters:
fparser2_tree (
fparser.two.Fortran2003.Part_Ref
) – fparser2 tree capturing the required metadata.