Reference Guide  2.5.0
psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor Class Reference
Inheritance diagram for psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor:
Collaboration diagram for psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor:

Public Member Functions

def __init__ (self, arg_type, operates_on, metadata_index)
 
def data_type (self)
 
def function_space_to (self)
 
def function_space_from (self)
 
def function_space (self)
 
def function_spaces (self)
 
def vector_size (self)
 
def __str__ (self)
 
- Public Member Functions inherited from psyclone.parse.kernel.Descriptor
def __init__ (self, access, space, metadata_index, stencil=None, mesh=None, argument_type=None)
 
def access (self)
 
def metadata_index (self)
 
def stencil (self)
 
def mesh (self)
 
def argument_type (self)
 
def __repr__ (self)
 

Detailed Description

This class captures the information specified in one of LFRic API argument
descriptors (scalars, fields and operators).

:param arg_type: LFRic API valid argument type (scalar, \
                 field or operator).
:type arg_type: :py:class:`psyclone.expression.FunctionVar` or \
                :py:class:`psyclone.expression.BinaryOperator`
:param str operates_on: value of operates_on from the parsed kernel \
                        metadata (used for validation).
:param int metadata_index: position of this argument in the list of \
                           arguments specified in the metadata.

:raises ParseError: if a 'meta_arg' entry is not of 'arg_type' type.
:raises ParseError: if the first argument of a 'meta_arg' entry is not \
                    one of LFRic API valid argument types.
:raises ParseError: if the second argument of a 'meta_arg' entry is not \
                    one of LFRic API valid data types.
:raises ParseError: if a 'meta_arg' entry has fewer than 3 args.
:raises ParseError: if the third 'meta_arg' entry is not a valid \
                    access descriptor.
:raises InternalError: if the operates_on from the parsed kernel \
                       metadata is not 'cell_column' or 'dof'.
:raises InternalError: if all the metadata checks fail to catch an \
                       invalid argument type.

Definition at line 61 of file lfric_arg_descriptor.py.

Member Function Documentation

◆ __str__()

def psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor.__str__ (   self)
Creates a string representation of the argument descriptor. This
is type and access for scalars with the addition of function
space(s) for fields and operators.

:returns: string representation of the argument descriptor.
:rtype: str

:raises InternalError: if an invalid argument type is passed in.

Definition at line 716 of file lfric_arg_descriptor.py.

716  def __str__(self):
717  '''
718  Creates a string representation of the argument descriptor. This
719  is type and access for scalars with the addition of function
720  space(s) for fields and operators.
721 
722  :returns: string representation of the argument descriptor.
723  :rtype: str
724 
725  :raises InternalError: if an invalid argument type is passed in.
726 
727  '''
728  const = LFRicConstants()
729  res = "LFRicArgDescriptor object" + os.linesep
730  res += f" argument_type[0]='{self._argument_type}'"
731  if self._vector_size > 1:
732  res += "*" + str(self._vector_size)
733  res += os.linesep
734  res += f" data_type[1]='{self._data_type}'" + os.linesep
735  res += (f" access_descriptor[2]="
736  f"'{self._access_type.api_specific_name()}'"
737  + os.linesep)
738  if self._argument_type in const.VALID_FIELD_NAMES:
739  res += (f" function_space[3]='{self._function_space1}'"
740  + os.linesep)
741  elif self._argument_type in const.VALID_OPERATOR_NAMES:
742  res += (f" function_space_to[3]='{self._function_space1}'"
743  + os.linesep)
744  res += (f" function_space_from[4]='{self._function_space2}'"
745  + os.linesep)
746  elif self._argument_type in const.VALID_SCALAR_NAMES:
747  pass # We have nothing to add if we're a scalar
748  else: # We should never get to here
749  raise InternalError(f"Expected a valid argument type but got "
750  f"'{self._argument_type}'.")
751  return res
752 
753 
754 # Documentation utils: The list of module members that we wish AutoAPI to
755 # generate documentation for (see https://psyclone-ref.readthedocs.io).

References psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._argument_type, psyclone.dynamo0p3.DynKernelArgument._argument_type, psyclone.gocean1p0.GOKernelGridArgument._argument_type, psyclone.gocean1p0.GO1p0Descriptor._argument_type, psyclone.parse.kernel.Descriptor._argument_type, psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._vector_size, and psyclone.dynamo0p3.DynKernelArgument._vector_size.

◆ data_type()

def psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor.data_type (   self)
:returns: intrinsic Fortran (primitive) type of the argument data.
:rtype: str

Definition at line 606 of file lfric_arg_descriptor.py.

606  def data_type(self):
607  '''
608  :returns: intrinsic Fortran (primitive) type of the argument data.
609  :rtype: str
610 
611  '''
612  return self._data_type
613 

References psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._data_type, psyclone.dynamo0p3.DynKernelArgument._data_type, and psyclone.psyGen.Argument._data_type.

◆ function_space()

def psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor.function_space (   self)
Returns the function space name related to this kernel argument
depending on the argument type: a single function space for a field,
function_space_from for an operator and nothing for a scalar.

:returns: function space relating to this kernel argument or \
          None (for a scalar).
:rtype: str or NoneType

:raises InternalError: if an invalid argument type is passed in.

Reimplemented from psyclone.parse.kernel.Descriptor.

Definition at line 655 of file lfric_arg_descriptor.py.

655  def function_space(self):
656  '''
657  Returns the function space name related to this kernel argument
658  depending on the argument type: a single function space for a field,
659  function_space_from for an operator and nothing for a scalar.
660 
661  :returns: function space relating to this kernel argument or \
662  None (for a scalar).
663  :rtype: str or NoneType
664 
665  :raises InternalError: if an invalid argument type is passed in.
666 
667  '''
668  const = LFRicConstants()
669  if self._argument_type in const.VALID_FIELD_NAMES:
670  return self._function_space1
671  if self._argument_type in const.VALID_OPERATOR_NAMES:
672  return self._function_space2
673  if self._argument_type in const.VALID_SCALAR_NAMES:
674  return None
675  raise InternalError(f"Expected a valid argument type but got "
676  f"'{self._argument_type}'.")
677 

References psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._argument_type, psyclone.dynamo0p3.DynKernelArgument._argument_type, psyclone.gocean1p0.GOKernelGridArgument._argument_type, psyclone.gocean1p0.GO1p0Descriptor._argument_type, psyclone.parse.kernel.Descriptor._argument_type, psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._function_space1, and psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._function_space2.

Here is the caller graph for this function:

◆ function_space_from()

def psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor.function_space_from (   self)
Returns the "from" function space for an operator. This is
the second function space specified in the metadata.

:returns: "from" function space for an operator.
:rtype: str

:raises InternalError: if this is not an operator.

Definition at line 635 of file lfric_arg_descriptor.py.

635  def function_space_from(self):
636  '''
637  Returns the "from" function space for an operator. This is
638  the second function space specified in the metadata.
639 
640  :returns: "from" function space for an operator.
641  :rtype: str
642 
643  :raises InternalError: if this is not an operator.
644 
645  '''
646  const = LFRicConstants()
647  if self._argument_type in const.VALID_OPERATOR_NAMES:
648  return self._function_space2
649  raise InternalError(
650  f"In the LFRic API 'function_space_from' only makes sense for one "
651  f"of {const.VALID_OPERATOR_NAMES}, but this is a "
652  f"'{self._argument_type}'.")
653 

References psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._argument_type, psyclone.dynamo0p3.DynKernelArgument._argument_type, psyclone.gocean1p0.GOKernelGridArgument._argument_type, psyclone.gocean1p0.GO1p0Descriptor._argument_type, psyclone.parse.kernel.Descriptor._argument_type, and psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._function_space2.

Here is the caller graph for this function:

◆ function_space_to()

def psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor.function_space_to (   self)
Returns the "to" function space for an operator. This is
the first function space specified in the metadata.

:returns: "to" function space for an operator.
:rtype: str

:raises InternalError: if this is not an operator.

Definition at line 615 of file lfric_arg_descriptor.py.

615  def function_space_to(self):
616  '''
617  Returns the "to" function space for an operator. This is
618  the first function space specified in the metadata.
619 
620  :returns: "to" function space for an operator.
621  :rtype: str
622 
623  :raises InternalError: if this is not an operator.
624 
625  '''
626  const = LFRicConstants()
627  if self._argument_type in const.VALID_OPERATOR_NAMES:
628  return self._function_space1
629  raise InternalError(
630  f"In the LFRic API 'function_space_to' only makes sense for one "
631  f"of {const.VALID_OPERATOR_NAMES}, but this is a "
632  f"'{self._argument_type}'.")
633 

References psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._argument_type, psyclone.dynamo0p3.DynKernelArgument._argument_type, psyclone.gocean1p0.GOKernelGridArgument._argument_type, psyclone.gocean1p0.GO1p0Descriptor._argument_type, psyclone.parse.kernel.Descriptor._argument_type, and psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._function_space1.

Here is the caller graph for this function:

◆ function_spaces()

def psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor.function_spaces (   self)
Returns the function space names related to this kernel argument
as a list depending on the argument type: one function space for
a field, both function spaces ("to"- and then "from"-) for an
operator and an empty list for a scalar.

:returns: function space names related to this kernel argument.
:rtype: list of str

:raises InternalError: if an invalid argument type is passed in.

Definition at line 679 of file lfric_arg_descriptor.py.

679  def function_spaces(self):
680  '''
681  Returns the function space names related to this kernel argument
682  as a list depending on the argument type: one function space for
683  a field, both function spaces ("to"- and then "from"-) for an
684  operator and an empty list for a scalar.
685 
686  :returns: function space names related to this kernel argument.
687  :rtype: list of str
688 
689  :raises InternalError: if an invalid argument type is passed in.
690 
691  '''
692  const = LFRicConstants()
693  if self._argument_type in const.VALID_FIELD_NAMES:
694  return [self.function_space]
695  if self._argument_type in const.VALID_OPERATOR_NAMES:
696  # Return to before from to maintain expected ordering
697  return [self.function_space_to, self.function_space_from]
698  if self._argument_type in const.VALID_SCALAR_NAMES:
699  return []
700  raise InternalError(f"Expected a valid argument type but got "
701  f"'{self._argument_type}'.")
702 

References psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._argument_type, psyclone.dynamo0p3.DynKernelArgument._argument_type, psyclone.gocean1p0.GOKernelGridArgument._argument_type, psyclone.gocean1p0.GO1p0Descriptor._argument_type, psyclone.parse.kernel.Descriptor._argument_type, psyclone.domain.lfric.kernel.field_arg_metadata.FieldArgMetadata.function_space, psyclone.domain.lfric.kernel.meta_funcs_arg_metadata.MetaFuncsArgMetadata.function_space, psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor.function_space(), psyclone.dynamo0p3.DynKernelArgument.function_space(), psyclone.gocean1p0.GOKernelArgument.function_space(), psyclone.parse.kernel.Descriptor.function_space(), psyclone.domain.lfric.kernel.operator_arg_metadata.OperatorArgMetadata.function_space_from, psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor.function_space_from(), psyclone.dynamo0p3.DynKernelArgument.function_space_from(), psyclone.domain.lfric.kernel.operator_arg_metadata.OperatorArgMetadata.function_space_to, psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor.function_space_to(), and psyclone.dynamo0p3.DynKernelArgument.function_space_to().

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

◆ vector_size()

def psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor.vector_size (   self)
Returns the vector size of the argument. This will be 1 if ``*n``
has not been specified for all argument types except scalars
(their vector size is set to 0).

:returns: vector size of the argument.
:rtype: int

Definition at line 704 of file lfric_arg_descriptor.py.

704  def vector_size(self):
705  '''
706  Returns the vector size of the argument. This will be 1 if ``*n``
707  has not been specified for all argument types except scalars
708  (their vector size is set to 0).
709 
710  :returns: vector size of the argument.
711  :rtype: int
712 
713  '''
714  return self._vector_size
715 

References psyclone.domain.lfric.lfric_arg_descriptor.LFRicArgDescriptor._vector_size, and psyclone.dynamo0p3.DynKernelArgument._vector_size.


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