36 '''Module containing the ShapesMetadata class which captures the
37 values for the LFRic kernel GH_SHAPE metadata.
40 from fparser.two
import Fortran2003
44 CommonDeclarationMetadata
48 '''Class to capture the values of the LFRic kernel GH_SHAPE metadata.
49 This class supports the creation, modification and Fortran output
52 If an LFRic kernel requires basis or differential-basis functions
53 then the metadata must also specify the set of points on which
54 these functions are required. This information is provided by the
55 GH_SHAPE component of the metadata.
57 :param shapes: a list of shape values
58 :type shapes: List[str]
61 def __init__(self, shapes):
67 :returns: the shapes metadata as Fortran.
71 return ShapesMetadata.scalar_declaration_string(
73 return ShapesMetadata.array_declaration_string(
78 '''Create an instance of ShapesMetadata from an fparser2 tree.
80 LFRic shape metadata can have a scalar and array form. Two
81 versions of the array form are supported:
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 /)
89 :param fparser2_tree: fparser2 tree capturing the shapes metadata
90 :type fparser2_tree: :py:class:`fparser.two.Fortran2003.\
91 Data_Component_Def_Stmt`
93 :returns: an instance of ShapesMetadata.
94 :rtype: :py:class:`psyclone.domain.lfric.kernel.ShapesMetadata`
105 ShapesMetadata.validate_node(
106 fparser2_tree, Fortran2003.Data_Component_Def_Stmt)
107 ShapesMetadata.validate_name_value(
108 fparser2_tree,
"GH_SHAPE")
111 valid_values = const.VALID_EVALUATOR_SHAPES
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]:
117 shapes_list = ShapesMetadata.get_intrinsic_array_declaration(
118 fparser2_tree,
"INTEGER",
"GH_SHAPE", valid_values)
121 shapes_value = ShapesMetadata.\
123 fparser2_tree,
"INTEGER",
"GH_SHAPE", valid_values)
124 shapes_list = [shapes_value]
131 :returns: a list of shape values
139 def shapes(self, values):
141 :param values: set the shapes metdata to the supplied list of \
143 :type values: List[str]
146 ShapesMetadata.validate_list(values, str)
148 ShapesMetadata.validate_scalar_value(
149 value, const.VALID_EVALUATOR_SHAPES,
"shape")
152 self.
_shapes_shapes = [value.lower()
for value
in values]
155 __all__ = [
"ShapesMetadata"]
def get_intrinsic_scalar_declaration(fparser2_tree, datatype, name, valid_values)
def create_from_fparser2(fparser2_tree)