Reference Guide  2.5.0
psyclone.domain.lfric.kernel.shapes_metadata.ShapesMetadata Class Reference
Inheritance diagram for psyclone.domain.lfric.kernel.shapes_metadata.ShapesMetadata:
Collaboration diagram for psyclone.domain.lfric.kernel.shapes_metadata.ShapesMetadata:

Public Member Functions

def __init__ (self, shapes)
 
def fortran_string (self)
 
def shapes (self)
 
def shapes (self, values)
 

Static Public Member Functions

def create_from_fparser2 (fparser2_tree)
 

Public Attributes

 shapes
 

Additional Inherited Members

Detailed Description

Class to capture the values of the LFRic kernel GH_SHAPE metadata.
This class supports the creation, modification and Fortran output
of this metadata.

If an LFRic kernel requires basis or differential-basis functions
then the metadata must also specify the set of points on which
these functions are required. This information is provided by the
GH_SHAPE component of the metadata.

:param shapes: a list of shape values
:type shapes: List[str]

Definition at line 47 of file shapes_metadata.py.

Member Function Documentation

◆ create_from_fparser2()

def psyclone.domain.lfric.kernel.shapes_metadata.ShapesMetadata.create_from_fparser2 (   fparser2_tree)
static
Create an instance of ShapesMetadata from an fparser2 tree.

LFRic shape metadata can have a scalar and array form. Two
versions of the array form are supported:
::

    integer :: gh_shape = gh_quadrature_face
    integer :: gh_shape(2) = (/ gh_quadrature_face, gh_evaluator /)
    integer, dimension(2) :: gh_shape = &
             (/ gh_quadrature_face, gh_evaluator /)

:param fparser2_tree: fparser2 tree capturing the shapes metadata
:type fparser2_tree: :py:class:`fparser.two.Fortran2003.\
    Data_Component_Def_Stmt`

:returns: an instance of ShapesMetadata.
:rtype: :py:class:`psyclone.domain.lfric.kernel.ShapesMetadata`

Reimplemented from psyclone.domain.lfric.kernel.common_metadata.CommonMetadata.

Definition at line 77 of file shapes_metadata.py.

77  def create_from_fparser2(fparser2_tree):
78  '''Create an instance of ShapesMetadata from an fparser2 tree.
79 
80  LFRic shape metadata can have a scalar and array form. Two
81  versions of the array form are supported:
82  ::
83 
84  integer :: gh_shape = gh_quadrature_face
85  integer :: gh_shape(2) = (/ gh_quadrature_face, gh_evaluator /)
86  integer, dimension(2) :: gh_shape = &
87  (/ gh_quadrature_face, gh_evaluator /)
88 
89  :param fparser2_tree: fparser2 tree capturing the shapes metadata
90  :type fparser2_tree: :py:class:`fparser.two.Fortran2003.\
91  Data_Component_Def_Stmt`
92 
93  :returns: an instance of ShapesMetadata.
94  :rtype: :py:class:`psyclone.domain.lfric.kernel.ShapesMetadata`
95 
96  '''
97  # As both scalar and array forms are supported we need the
98  # validation from both get_intrinsic_array_declaration and
99  # get_intrinsic_scalar_declaration. However, we can't call
100  # these functions separately as both might raise an exception
101  # and we won't know which exception to return. Instead we call
102  # the validation that is common to both first and then test
103  # for an array declaration to determine whether to call the
104  # array or scalar validation.
105  ShapesMetadata.validate_node(
106  fparser2_tree, Fortran2003.Data_Component_Def_Stmt)
107  ShapesMetadata.validate_name_value(
108  fparser2_tree, "GH_SHAPE")
109 
110  const = LFRicConstants()
111  valid_values = const.VALID_EVALUATOR_SHAPES
112 
113  component_decl_list = fparser2_tree.children[2]
114  gh_shape_declaration = component_decl_list.children[0]
115  if fparser2_tree.children[1] or gh_shape_declaration.children[1]:
116  # This is not the scalar form so check for the array form.
117  shapes_list = ShapesMetadata.get_intrinsic_array_declaration(
118  fparser2_tree, "INTEGER", "GH_SHAPE", valid_values)
119  else:
120  # Check for the scalar form.
121  shapes_value = ShapesMetadata.\
122  get_intrinsic_scalar_declaration(
123  fparser2_tree, "INTEGER", "GH_SHAPE", valid_values)
124  shapes_list = [shapes_value]
125 
126  return ShapesMetadata(shapes_list)
127 

References psyclone.domain.lfric.kernel.common_declaration_metadata.CommonDeclarationMetadata.get_intrinsic_scalar_declaration().

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

◆ fortran_string()

def psyclone.domain.lfric.kernel.shapes_metadata.ShapesMetadata.fortran_string (   self)
:returns: the shapes metadata as Fortran.
:rtype: str

Definition at line 65 of file shapes_metadata.py.

65  def fortran_string(self):
66  '''
67  :returns: the shapes metadata as Fortran.
68  :rtype: str
69  '''
70  if len(self.shapes) == 1:
71  return ShapesMetadata.scalar_declaration_string(
72  "INTEGER", "GH_SHAPE", self.shapes[0])
73  return ShapesMetadata.array_declaration_string(
74  "INTEGER", "GH_SHAPE", self.shapes)
75 

References psyclone.domain.lfric.kernel.lfric_kernel_metadata.LFRicKernelMetadata.shapes(), and psyclone.domain.lfric.kernel.shapes_metadata.ShapesMetadata.shapes.

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

◆ shapes() [1/2]

def psyclone.domain.lfric.kernel.shapes_metadata.ShapesMetadata.shapes (   self)
:returns: a list of shape values
:rtype: List[str]

Definition at line 129 of file shapes_metadata.py.

129  def shapes(self):
130  '''
131  :returns: a list of shape values
132  :rtype: List[str]
133  '''
134  # Return a copy of the list so it can't be modified
135  # externally.
136  return self._shapes[:]
137 

References psyclone.domain.lfric.kernel.lfric_kernel_metadata.LFRicKernelMetadata._shapes, and psyclone.domain.lfric.kernel.shapes_metadata.ShapesMetadata._shapes.

Here is the caller graph for this function:

◆ shapes() [2/2]

def psyclone.domain.lfric.kernel.shapes_metadata.ShapesMetadata.shapes (   self,
  values 
)
:param values: set the shapes metdata to the supplied list of \
    values.
:type values: List[str]

Definition at line 139 of file shapes_metadata.py.

139  def shapes(self, values):
140  '''
141  :param values: set the shapes metdata to the supplied list of \
142  values.
143  :type values: List[str]
144  '''
145  const = LFRicConstants()
146  ShapesMetadata.validate_list(values, str)
147  for value in values:
148  ShapesMetadata.validate_scalar_value(
149  value, const.VALID_EVALUATOR_SHAPES, "shape")
150  # Take a copy of the list so that it can't be modified
151  # externally. Also make all values lower case.
152  self._shapes = [value.lower() for value in values]
153 
154 

References psyclone.domain.lfric.kernel.lfric_kernel_metadata.LFRicKernelMetadata._shapes, and psyclone.domain.lfric.kernel.shapes_metadata.ShapesMetadata._shapes.

Here is the caller graph for this function:

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