39 ''' This module implements PSyclone LFRic (Dynamo 0.3) API by specialising the
40 base class for managing the declaration and initialisation of a group of
41 related entities within an Invoke or Kernel stub.'''
52 Base class for managing the declaration and initialisation of a
53 group of related entities within an Invoke or Kernel stub
55 :param node: the Kernel or Invoke for which to manage variable \
56 declarations and initialisation.
57 :type node: :py:class:`psyclone.domain.lfric.LFRicInvoke` or \
58 :py:class:`psyclone.domain.lfric.LFRicKern`
60 :raises InternalError: if the supplied node is not an LFRicInvoke or an \
64 def __init__(self, node):
65 if isinstance(node, LFRicInvoke):
71 self.
_calls_calls = node.schedule.kernels()
72 elif isinstance(node, LFRicKern):
82 raise InternalError(f
"LFRicCollection takes only an LFRicInvoke "
83 f
"or an LFRicKern but got: {type(node)}")
94 Insert declarations for all necessary variables into the AST of
95 the generated code. Simply calls either '_invoke_declarations()' or
96 '_stub_declarations()' depending on whether we're handling an Invoke
99 :param parent: the node in the f2pygen AST representing the routine \
100 in which to insert the declarations.
101 :type parent: :py:class:`psyclone.f2pygen.SubroutineGen`
103 :raises InternalError: if neither 'self._invoke' nor 'self._kernel' \
113 "nor an Invoke - should be impossible.")
117 Add code to initialise the entities being managed by this class.
118 We do nothing by default - it is up to the sub-class to override
119 this method if initialisation is required.
121 :param parent: the node in the f2pygen AST to which to add \
123 :type parent: :py:class:`psyclone.f2pygen.SubroutineGen`
128 def _invoke_declarations(self, parent):
130 Add all necessary declarations for an Invoke.
132 :param parent: node in the f2pygen AST representing the Invoke to \
133 which to add declarations.
134 :type parent: :py:class:`psyclone.f2pygen.SubroutineGen`
138 def _stub_declarations(self, parent):
140 Add all necessary declarations for a Kernel stub. Not abstract because
141 not all entities need representing within a Kernel.
143 :param parent: node in the f2pygen AST representing the Kernel stub \
144 to which to add declarations.
145 :type parent: :py:class:`psyclone.f2pygen.SubroutineGen`
153 __all__ = [
'LFRicCollection']
def initialise(self, parent)
def _invoke_declarations(self, parent)
def _stub_declarations(self, parent)
def declarations(self, parent)