Reference Guide  2.5.0
psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata Class Reference
Inheritance diagram for psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata:
Collaboration diagram for psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata:

Public Member Functions

def __init__ (self, datatype, access, function_space, stencil=None)
 
def get_stencil (cls, fparser2_tree)
 
def fortran_string (self)
 
def function_space (self)
 
def function_space (self, value)
 
def stencil (self)
 
def stencil (self, value)
 

Static Public Member Functions

def check_datatype (value)
 
def check_access (value)
 

Public Attributes

 function_space
 
 stencil
 

Static Public Attributes

string form = "gh_field"
 
int form_arg_index = 0
 
int datatype_arg_index = 1
 
int access_arg_index = 2
 
int function_space_arg_index = 3
 
int stencil_arg_index = 4
 
string check_name = "field"
 
tuple nargs = (4, 5)
 

Detailed Description

Class to capture LFRic kernel metadata information for a field
argument.

:param str datatype: the datatype of this field (GH_INTEGER, ...).
:param str access: the way the kernel accesses this field (GH_WRITE, ...).
:param str function_space: the function space that this field is \
    on (W0, ...).
:param Optional[str] stencil: the type of stencil used by the \
    kernel when accessing this field.

Definition at line 46 of file field_arg_metadata.py.

Member Function Documentation

◆ check_access()

def psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata.check_access (   value)
static
:param str value: the access descriptor to validate.

Reimplemented from psyclone.domain.lfric.kernel.scalar_arg_metadata.ScalarArgMetadata.

Definition at line 156 of file field_arg_metadata.py.

156  def check_access(value):
157  '''
158  :param str value: the access descriptor to validate.
159  '''
160  const = LFRicConstants()
161  FieldArgMetadata.validate_scalar_value(
162  value, const.VALID_FIELD_ACCESS_TYPES, "access descriptor")
163 
Here is the caller graph for this function:

◆ check_datatype()

def psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata.check_datatype (   value)
static
:param str value: the datatype to check for validity.

:raises ValueError: if the provided value is not a valid \
    datatype descriptor.

Reimplemented from psyclone.domain.lfric.kernel.scalar_arg_metadata.ScalarArgMetadata.

Definition at line 143 of file field_arg_metadata.py.

143  def check_datatype(value):
144  '''
145  :param str value: the datatype to check for validity.
146 
147  :raises ValueError: if the provided value is not a valid \
148  datatype descriptor.
149 
150  '''
151  const = LFRicConstants()
152  FieldArgMetadata.validate_scalar_value(
153  value, const.VALID_FIELD_DATA_TYPES, "datatype descriptor")
154 
Here is the caller graph for this function:

◆ fortran_string()

def psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata.fortran_string (   self)
:returns: the metadata represented by this class as Fortran.
:rtype: str

Reimplemented from psyclone.domain.lfric.kernel.scalar_arg_metadata.ScalarArgMetadata.

Reimplemented in psyclone.domain.lfric.kernel.inter_grid_vector_arg_metadata.InterGridVectorArgMetadata, psyclone.domain.lfric.kernel.inter_grid_arg_metadata.InterGridArgMetadata, and psyclone.domain.lfric.kernel.field_vector_arg_metadata.FieldVectorArgMetadata.

Definition at line 131 of file field_arg_metadata.py.

131  def fortran_string(self):
132  '''
133  :returns: the metadata represented by this class as Fortran.
134  :rtype: str
135  '''
136  if self.stencil:
137  return (f"arg_type({self.form}, {self.datatype}, {self.access}, "
138  f"{self.function_space}, stencil({self.stencil}))")
139  return (f"arg_type({self.form}, {self.datatype}, {self.access}, "
140  f"{self.function_space})")
141 

References psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.FieldArg.stencil(), psyclone.dynamo0p3.DynKernelArgument.stencil(), psyclone.parse.kernel.Descriptor.stencil(), psyclone.psyGen.KernelArgument.stencil(), psyclone.domain.lfric.arg_ordering.ArgOrdering.stencil(), psyclone.domain.lfric.kern_call_acc_arg_list.KernCallAccArgList.stencil(), psyclone.domain.lfric.kern_call_arg_list.KernCallArgList.stencil(), psyclone.domain.lfric.kern_call_invoke_arg_list.KernCallInvokeArgList.stencil(), psyclone.domain.lfric.kern_stub_arg_list.KernStubArgList.stencil(), psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata.stencil, psyclone.domain.lfric.kernel_interface.KernelInterface.stencil(), and psyclone.domain.lfric.lfric_invoke.LFRicInvoke.stencil.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ function_space() [1/2]

def psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata.function_space (   self)
:returns: the function space for this field argument.
:rtype: str

Definition at line 165 of file field_arg_metadata.py.

165  def function_space(self):
166  '''
167  :returns: the function space for this field argument.
168  :rtype: str
169  '''
170  return self._function_space
171 

References psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata._function_space, psyclone.domain.lfric.kernel.meta_funcs_arg_metadata.MetaFuncsArgMetadata._function_space, and psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._function_space.

Here is the caller graph for this function:

◆ function_space() [2/2]

def psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata.function_space (   self,
  value 
)
:param str value: set the function space to the \
    specified value.

Definition at line 173 of file field_arg_metadata.py.

173  def function_space(self, value):
174  '''
175  :param str value: set the function space to the \
176  specified value.
177  '''
178  const = LFRicConstants()
179  FieldArgMetadata.validate_scalar_value(
180  value, const.VALID_FUNCTION_SPACE_NAMES, "function space")
181  self._function_space = value.lower()
182 

References psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata._function_space, psyclone.domain.lfric.kernel.meta_funcs_arg_metadata.MetaFuncsArgMetadata._function_space, and psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._function_space.

Here is the caller graph for this function:

◆ get_stencil()

def psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata.get_stencil (   cls,
  fparser2_tree 
)
Retrieves the stencil metadata value found within the supplied
fparser2 tree (if there is one) and checks that it is valid.

:param fparser2_tree: fparser2 tree capturing the required metadata.
:type fparser2_tree: :py:class:`fparser.two.Fortran2003.Part_Ref`

:returns: the stencil value extracted from the fparser2 tree \
    if there is one, or None if not.
:rtype: Optional[str]

:raises TypeError: if the stencil metadata is not in the \
    expected form.

Definition at line 104 of file field_arg_metadata.py.

104  def get_stencil(cls, fparser2_tree):
105  '''Retrieves the stencil metadata value found within the supplied
106  fparser2 tree (if there is one) and checks that it is valid.
107 
108  :param fparser2_tree: fparser2 tree capturing the required metadata.
109  :type fparser2_tree: :py:class:`fparser.two.Fortran2003.Part_Ref`
110 
111  :returns: the stencil value extracted from the fparser2 tree \
112  if there is one, or None if not.
113  :rtype: Optional[str]
114 
115  :raises TypeError: if the stencil metadata is not in the \
116  expected form.
117 
118  '''
119  raw_stencil_text = FieldArgMetadata.get_arg(
120  fparser2_tree, cls.stencil_arg_index)
121  if not raw_stencil_text:
122  return None
123  raw_stencil_text = raw_stencil_text.strip().lower()
124  if not (raw_stencil_text.startswith("stencil(") and
125  raw_stencil_text.endswith(")") and len(raw_stencil_text) > 9):
126  raise TypeError(f"The stencil metadata should be in the form "
127  f"'stencil(type)' but found '{raw_stencil_text}'.")
128  stencil = raw_stencil_text[8:-1]
129  return stencil
130 

References psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata.stencil_arg_index, and psyclone.domain.lfric.kernel.inter_grid_arg_metadata.InterGridArgMetadata.stencil_arg_index.

◆ stencil() [1/2]

def psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata.stencil (   self)
:returns: the stencil for this field argument, or None if there
    isn't one.
:rtype: Optional[str]

Definition at line 184 of file field_arg_metadata.py.

184  def stencil(self):
185  '''
186  :returns: the stencil for this field argument, or None if there
187  isn't one.
188  :rtype: Optional[str]
189 
190  '''
191  return self._stencil
192 

References psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.FieldArg._stencil, psyclone.domain.lfric.arg_index_to_metadata_index.ArgIndexToMetadataIndex._stencil(), psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata._stencil, psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._stencil, psyclone.domain.lfric.metadata_to_arguments_rules.MetadataToArgumentsRules._stencil(), psyclone.dynamo0p3.DynKernelArgument._stencil, psyclone.gocean1p0.GOStencil._stencil, and psyclone.parse.kernel.Descriptor._stencil.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stencil() [2/2]

def psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata.stencil (   self,
  value 
)
:param str value: set the stencil to the specified value.

Definition at line 194 of file field_arg_metadata.py.

194  def stencil(self, value):
195  '''
196  :param str value: set the stencil to the specified value.
197  '''
198  if value is None:
199  self._stencil = None
200  else:
201  const = LFRicConstants()
202  FieldArgMetadata.validate_scalar_value(
203  value, const.VALID_STENCIL_TYPES, "stencil")
204  self._stencil = value.lower()
205 
206 

References psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.FieldArg._stencil, psyclone.domain.lfric.arg_index_to_metadata_index.ArgIndexToMetadataIndex._stencil(), psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata._stencil, psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._stencil, psyclone.domain.lfric.metadata_to_arguments_rules.MetadataToArgumentsRules._stencil(), psyclone.dynamo0p3.DynKernelArgument._stencil, psyclone.gocean1p0.GOStencil._stencil, and psyclone.parse.kernel.Descriptor._stencil.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: