Reference Guide  2.5.0
meta_funcs_metadata.py
1 # -----------------------------------------------------------------------------
2 # BSD 3-Clause License
3 #
4 # Copyright (c) 2022-2024, Science and Technology Facilities Council
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are met:
9 #
10 # * Redistributions of source code must retain the above copyright notice, this
11 # list of conditions and the following disclaimer.
12 #
13 # * Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16 #
17 # * Neither the name of the copyright holder nor the names of its
18 # contributors may be used to endorse or promote products derived from
19 # this software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
33 # -----------------------------------------------------------------------------
34 # Author R. W. Ford, STFC Daresbury Lab
35 
36 '''Module containing the MetaFuncsMetadata class which captures
37 the values for the LFRic kernel meta_funcs metadata.
38 
39 '''
41  CommonDeclarationMetadata
43  MetaFuncsArgMetadata
44 
45 
47  '''Class to capture the values of the LFRic kernel
48  meta_funcs metadata. This class supports the creation,
49  modification and Fortran output of this metadata.
50 
51  meta_funcs metadata specifies whether any quadrature or evaluator
52  data is required for a given function space.
53 
54  :param meta_funcs_args: a list of meta_funcs arguments.
55  :type meta_funcs_args: List[:py:class:`psyclone.domain.lfric.kernel.\
56  MetaFuncsArgMetadata`]
57 
58  '''
59  def __init__(self, meta_funcs_args):
60  super().__init__()
61  self.meta_funcs_argsmeta_funcs_argsmeta_funcs_argsmeta_funcs_args = meta_funcs_args
62 
63  def fortran_string(self):
64  '''
65  :returns: the meta_funcs metadata as Fortran.
66  :rtype: str
67  '''
68  return self.type_declaration_stringtype_declaration_string(
69  "FUNC_TYPE", "META_FUNCS", self._meta_funcs_args_meta_funcs_args)
70 
71  @staticmethod
72  def create_from_fparser2(fparser2_tree):
73  '''Create an instance of MetaFuncsMetadata from an fparser2
74  tree.
75 
76  :param fparser2_tree: fparser2 tree capturing the meta \
77  funcs metadata.
78  :type fparser2_tree: :py:class:`fparser.two.Fortran2003.\
79  Data_Component_Def_Stmt`
80 
81  :returns: an instance of MetaFuncsMetadata.
82  :rtype: :py:class:`psyclone.domain.lfric.kernel.\
83  MetaFuncsMetadata`
84 
85  '''
86  values_list = MetaFuncsMetadata.get_derived_array_declaration(
87  fparser2_tree, "FUNC_TYPE", "META_FUNCS")
88  meta_obj_list = []
89  for value in values_list:
90  meta_obj_list.append(
91  MetaFuncsArgMetadata.create_from_fortran_string(value))
92  return MetaFuncsMetadata(meta_obj_list)
93 
94  @property
95  def meta_funcs_args(self):
96  '''
97  :returns: a list of meta funcs argument objects.
98  :rtype: List[:py:class:`psyclone.domain.lfric.kernel.\
99  MetaFuncsArgMetadata`]
100  '''
101  return self._meta_funcs_args_meta_funcs_args[:]
102 
103  @meta_funcs_args.setter
104  def meta_funcs_args(self, values):
105  '''
106  :param values: set the meta_funcs metadata to the \
107  supplied list of values.
108  :type values: List[:py:class:`psyclone.domain.lfric.kernel.\
109  MetaFuncsArgMetadata`]
110 
111  '''
112  self.validate_listvalidate_list(values, MetaFuncsArgMetadata)
113  # Take a copy of the list so that it can't be modified
114  # externally.
115  self._meta_funcs_args_meta_funcs_args = values[:]
116 
117 
118 __all__ = ["MetaFuncsMetadata"]