36 '''Module containing the InterGridVectorArgMetadata class which captures the
37 metadata associated with a intergrid vector argument. Supports the
38 creation, modification and Fortran output of an InterGridVector
47 '''Class to capture LFRic kernel metadata information for an
48 InterGridVector argument.
50 :param str datatype: the datatype of this InterGridVector argument \
52 :param str access: the way the kernel accesses this InterGridVector \
53 argument (GH_WRITE, ...).
54 :param str function_space: the function space that this \
55 InterGridVector argument is on (W0, ...).
56 :param str mesh_arg: the type of mesh that this InterGrid arg \
57 is on (coarse or fine).
58 :param str vector_length: the size of the vector.
59 :param Optional[str] stencil: the type of stencil used by the \
60 kernel when accessing this InterGrid arg.
70 vector_length_arg_index = 0
72 check_name =
"inter-grid-vector"
76 def __init__(self, datatype, access, function_space, mesh_arg,
77 vector_length, stencil=None):
79 datatype, access, function_space, mesh_arg, stencil=stencil)
83 def _get_metadata(cls, fparser2_tree):
84 '''Extract the required metadata from the fparser2 tree and return it
85 as strings. Also check that the metadata is in the expected
86 form (but do not check the metadata values as that is done
89 :param fparser2_tree: fparser2 tree containing the metadata \
91 :type fparser2_tree: \
92 :py:class:`fparser.two.Fortran2003.Structure_Constructor`
94 :returns: a tuple containing the datatype, access, function \
95 space, mesh, vector-length and stencil metadata.
96 :rtype: Tuple[str, str, str, str, str, Optional[str]]
99 datatype, access, function_space, mesh_arg, stencil = \
100 super()._get_metadata(fparser2_tree)
102 return (datatype, access, function_space, mesh_arg, vector_length,
107 :returns: the metadata represented by this class as Fortran.
111 return (f
"arg_type({self.form}*{self.vector_length}, "
112 f
"{self.datatype}, {self.access}, {self.function_space}, "
113 f
"stencil({self.stencil}), mesh_arg={self.mesh_arg})")
114 return (f
"arg_type({self.form}*{self.vector_length}, "
115 f
"{self.datatype}, {self.access}, {self.function_space}, "
116 f
"mesh_arg={self.mesh_arg})")
119 def vector_length(self):
121 :returns: the vector length of this intergrid vector \
127 @vector_length.setter
128 def vector_length(self, value):
130 :param str value: set the intergrid vector length to the specified \
133 :raises TypeError: if the provided value is not of type str.
134 :raises ValueError: if the provided value is not a string \
135 containing an integer.
136 :raises ValueError: if the provided value is not greater than 1.
139 if not isinstance(value, str):
140 raise TypeError(f
"The vector size should be a string but found "
141 f
"{type(value).__name__}.")
143 int_value = int(value)
144 except ValueError
as info:
146 f
"The vector size should be a string containing an integer, "
147 f
"but found '{value}'.")
from info
150 raise ValueError(f
"The vector size should be an integer greater "
151 f
"than 1 but found {value}.")
155 __all__ = [
"InterGridVectorArgMetadata"]
def get_vector_length(cls, fparser2_tree)
def vector_length(self, value)