36 '''Module containing the OperatorArgMetadata class which captures the metadata
37 associated with an operator argument. Supports the creation, modification
38 and Fortran output of a Operator argument.
46 '''Class to capture LFRic kernel metadata information for an operator
49 :param str datatype: the datatype of this operator (GH_INTEGER, ...).
50 :param str access: the way the kernel accesses this operator \
52 :param str function_space_to: the function space that this operator \
54 :param str function_space_from: the function space that this \
55 operator maps from (W0, ...).
68 function_space_to_arg_index = 3
69 function_space_from_arg_index = 4
71 check_name =
"operator"
75 def __init__(self, datatype, access, function_space_to,
77 super().__init__(datatype, access)
82 def _get_metadata(cls, fparser2_tree):
83 '''Extract the required metadata from the fparser2 tree and return it
84 as strings. Also check that the metadata is in the expected
85 form (but do not check the metadata values as that is done
88 :param fparser2_tree: fparser2 tree containing the metadata \
90 :type fparser2_tree: :py:class:`fparser.two.Fortran2003.Part_Ref`
92 :returns: a tuple containing the datatype, access \
93 function_space_to and function_space_from metadata.
94 :rtype: Tuple[str, str, str, str]
97 datatype, access = super()._get_metadata(fparser2_tree)
98 function_space_to = cls.
get_argget_arg(
100 function_space_from = cls.
get_argget_arg(
102 return (datatype, access, function_space_to, function_space_from)
106 :returns: the metadata represented by this class as Fortran.
109 return (f
"arg_type({self.form}, {self.datatype}, {self.access}, "
110 f
"{self.function_space_to}, {self.function_space_from})")
115 :param str value: the datatype to check for validity.
118 OperatorArgMetadata.validate_scalar_value(
119 value, const.VALID_OPERATOR_DATA_TYPES,
"datatype descriptor")
124 :param str value: the access descriptor to validate.
127 OperatorArgMetadata.validate_scalar_value(
128 value, const.VALID_OPERATOR_ACCESS_TYPES,
"access descriptor")
131 def function_space_to(self):
133 :returns: the first function space for this operator \
134 argument (that this operator maps to).
139 @function_space_to.setter
140 def function_space_to(self, value):
142 :param str value: set the function space to the \
145 raises ValueError: if the provided value is not a valid \
151 value, const.VALID_FUNCTION_SPACE_NAMES,
"function_space_to")
155 def function_space_from(self):
157 :returns: the second function space for this operator \
158 argument (that this operator maps from).
163 @function_space_from.setter
164 def function_space_from(self, value):
166 :param str value: set the function space to the \
171 value, const.VALID_FUNCTION_SPACE_NAMES,
"function_space_from")
175 __all__ = [
"OperatorArgMetadata"]
def get_arg(fparser2_tree, index)
def validate_scalar_value(value, valid_values, name)
int function_space_from_arg_index
int function_space_to_arg_index
def function_space_from(self)
def check_datatype(value)
def function_space_to(self, value)
def function_space_from(self, value)
def function_space_to(self)