Reference Guide  2.5.0
psyclone.domain.lfric.lfric_builtins.LFRicBuiltInCallFactory Class Reference

Public Member Functions

def __str__ (self)
 

Static Public Member Functions

def create (call, parent=None)
 

Detailed Description

Creates the necessary framework for a call to an LFRic built-in,
This consists of the operation itself and the loop over unique
DoFs.

Definition at line 89 of file lfric_builtins.py.

Member Function Documentation

◆ create()

def psyclone.domain.lfric.lfric_builtins.LFRicBuiltInCallFactory.create (   call,
  parent = None 
)
static
Create the objects needed for a call to the built-in described in
the call (BuiltInCall) object.

:param call: details of the call to this built-in in the \
             Algorithm layer.
:type call: :py:class:`psyclone.parse.algorithm.BuiltInCall`
:param parent: the schedule instance to which the built-in call \
               belongs.
:type parent: :py:class:`psyclone.domain.lfric.LFRicInvokeSchedule`

:raises ParseError: if the name of the function being called is \
                    not a recognised built-in.
:raises InternalError: if the built-in does not iterate over DoFs.

Definition at line 100 of file lfric_builtins.py.

100  def create(call, parent=None):
101  '''
102  Create the objects needed for a call to the built-in described in
103  the call (BuiltInCall) object.
104 
105  :param call: details of the call to this built-in in the \
106  Algorithm layer.
107  :type call: :py:class:`psyclone.parse.algorithm.BuiltInCall`
108  :param parent: the schedule instance to which the built-in call \
109  belongs.
110  :type parent: :py:class:`psyclone.domain.lfric.LFRicInvokeSchedule`
111 
112  :raises ParseError: if the name of the function being called is \
113  not a recognised built-in.
114  :raises InternalError: if the built-in does not iterate over DoFs.
115 
116  '''
117  if call.func_name not in BUILTIN_MAP:
118  raise ParseError(
119  f"Unrecognised built-in call in LFRic API: found "
120  f"'{call.func_name}' but expected one of "
121  f"{list(BUILTIN_MAP_CAPITALISED.keys())}.")
122 
123  # Use our dictionary to get the correct Python object for
124  # this built-in.
125  builtin = BUILTIN_MAP[call.func_name]()
126 
127  # Create the loop over the appropriate entity.
128  # Avoid circular import
129  # pylint: disable=import-outside-toplevel
130  from psyclone.domain.lfric import LFRicLoop
131 
132  if call.ktype.iterates_over == "dof":
133  loop_type = "dof"
134  else:
135  raise InternalError(
136  f"An LFRic built-in must iterate over DoFs but kernel "
137  f"'{call.func_name}' iterates over "
138  f"'{call.ktype.iterates_over}'")
139  dofloop = LFRicLoop(parent=parent, loop_type=loop_type)
140 
141  # Use the call object (created by the parser) to set-up the state
142  # of the infrastructure kernel
143  builtin.load(call, parent=dofloop.loop_body)
144 
145  # Set-up its state
146  dofloop.load(builtin)
147 
148  # As it is the innermost loop it has the kernel as a loop_body
149  # child.
150  dofloop.loop_body.addchild(builtin)
151 
152  # Return the outermost loop
153  return dofloop
154 
155 
Here is the caller graph for this function:

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