diff --git a/src/psyclone/domain/lfric/__init__.py b/src/psyclone/domain/lfric/__init__.py index fc2eeb3547..2bedb0db84 100644 --- a/src/psyclone/domain/lfric/__init__.py +++ b/src/psyclone/domain/lfric/__init__.py @@ -63,9 +63,11 @@ from psyclone.domain.lfric.arg_index_to_metadata_index import \ ArgIndexToMetadataIndex from psyclone.domain.lfric.lfric_collection import LFRicCollection +from psyclone.domain.lfric.lfric_stencil import LFRicArgStencil from psyclone.domain.lfric.lfric_loop_bounds import LFRicLoopBounds + __all__ = [ 'ArgOrdering', 'FunctionSpace', @@ -79,4 +81,6 @@ 'LFRicExtractDriverCreator', 'LFRicInvoke', 'LFRicLoopBounds', - 'LFRicSymbolTable'] \ No newline at end of file + 'LFRicArgStencil', + 'LFRicSymbolTable'] + diff --git a/src/psyclone/domain/lfric/lfric_stencil.py b/src/psyclone/domain/lfric/lfric_stencil.py new file mode 100644 index 0000000000..f7173fe1cf --- /dev/null +++ b/src/psyclone/domain/lfric/lfric_stencil.py @@ -0,0 +1,98 @@ +# ----------------------------------------------------------------------------- +# BSD 3-Clause License +# +# Copyright (c) 2017-2023, Science and Technology Facilities Council. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# ----------------------------------------------------------------------------- +# Authors R. W. Ford, A. R. Porter and S. Siso, STFC Daresbury Lab +# Modified I. Kavcic, A. Coughtrie, L. Turner and O. Brunt, Met Office +# Modified J. Henrichs, Bureau of Meteorology +# Modified A. B. G. Chalk and N. Nobre, STFC Daresbury Lab + +''' This module contains the LFRicArgStencil class which provides stencil +information about an LFRic kernel agrument. LFRicArgStencil can provide the extent, +algorithm argument for the extent, and the direction argument of a +stencil or set any of these properties.''' + +# pylint: disable=too-many-lines + +class LFRicArgStencil(): + ''' + Provides stencil information about an LFRic kernel argument + :param str name: the name of the stencil + ''' + def __init__(self, name): + self._name = name + self._extent = None + self._extent_arg = None + self._direction_arg = None + + @property + def extent(self): + ''' + :returns: the extent of the stencil if it is known. It will be known + if it is specified in the metadata. + :rtype: string + ''' + return self._extent + + @property + def extent_arg(self): + ''' + :returns: the algorithm argument associated with the extent value if + extent has not been provided in the metadata. + :rtype: :py:class:`psyclone.dynamo0p3.DynKernelArgument` + ''' + return self._extent_arg + + @extent_arg.setter + def extent_arg(self, value): + ''' sets the extent_arg argument. ''' + self._extent_arg = value + + @property + def direction_arg(self): + ''' + :returns: the direction argument associated with the direction of + the stencil if the direction of the stencil is not known + :rtype: :py:class:`psyclone.dynamo0p3.DynKernelArgument` + ''' + return self._direction_arg + + @direction_arg.setter + def direction_arg(self, value): + ''' sets the direction_arg argument. ''' + self._direction_arg = value + + +# ---------- Documentation utils -------------------------------------------- # +# The list of module members that we wish AutoAPI to generate +# documentation for. (See https://psyclone-ref.readthedocs.io) +__all__ = ['LFRicArgStencil'] diff --git a/src/psyclone/dynamo0p3.py b/src/psyclone/dynamo0p3.py index 6bba02d9cb..9d1622c141 100644 --- a/src/psyclone/dynamo0p3.py +++ b/src/psyclone/dynamo0p3.py @@ -61,7 +61,7 @@ LFRicArgDescriptor, KernelInterface, LFRicCollection, LFRicConstants, LFRicSymbolTable, LFRicInvoke, - LFRicKernCallFactory) + LFRicKernCallFactory, LFRicArgStencil) from psyclone.errors import GenerationError, InternalError, FieldNotFoundError from psyclone.f2pygen import (AllocateGen, AssignGen, CallGen, CommentGen, DeallocateGen, DeclGen, DoGen, IfThenGen, @@ -8499,43 +8499,6 @@ def check_args(call): f"qr_arguments'") -class DynStencil(): - ''' Provides stencil information about a Dynamo argument ''' - def __init__(self, name): - self._name = name - self._extent = None - self._extent_arg = None - self._direction_arg = None - - @property - def extent(self): - '''Returns the extent of the stencil if it is known. It will be known - if it is specified in the metadata.''' - return self._extent - - @property - def extent_arg(self): - '''Returns the algorithm argument associated with the extent value if - extent has not been provided in the metadata.''' - return self._extent_arg - - @extent_arg.setter - def extent_arg(self, value): - ''' sets the extent_arg argument. ''' - self._extent_arg = value - - @property - def direction_arg(self): - '''returns the direction argument associated with the direction of - the stencil if the direction of the stencil is not known''' - return self._direction_arg - - @direction_arg.setter - def direction_arg(self, value): - ''' sets the direction_arg argument. ''' - self._direction_arg = value - - class DynKernelArguments(Arguments): ''' Provides information about Dynamo kernel call arguments @@ -8573,14 +8536,14 @@ def __init__(self, call, parent_call, check=True): if dyn_argument.descriptor.stencil: # Create a stencil object and store a reference to it in our # new DynKernelArgument object. - stencil = DynStencil(dyn_argument.descriptor.stencil['type']) + stencil = LFRicArgStencil(dyn_argument.descriptor.stencil['type']) dyn_argument.stencil = stencil if dyn_argument.descriptor.stencil['extent']: raise GenerationError("extent metadata not yet supported") # if supported we would add the following # line. However, note there is currently no setter - # for extent in DynStencil so this would need to + # for extent in LFRicArgStencil so this would need to # be added. stencil.extent = # dyn_argument.descriptor.stencil['extent'] # An extent argument has been added. @@ -9603,7 +9566,7 @@ def discontinuous(self): def stencil(self): ''' :returns: stencil information for this argument if it exists. - :rtype: :py:class:`psyclone.dynamo0p3.DynStencil` + :rtype: :py:class:`psyclone.domain.lfric.LFRicArgStencil` ''' return self._stencil @@ -9613,7 +9576,7 @@ def stencil(self, value): Sets stencil information for this kernel argument. :param value: stencil information for this argument. - :type value: :py:class:`psyclone.dynamo0p3.DynStencil` + :type value: :py:class:`psyclone.domain.lfric.LFRicArgStencil` ''' self._stencil = value @@ -9764,7 +9727,6 @@ def data_on_device(self, _): 'DynKern', 'FSDescriptor', 'FSDescriptors', - 'DynStencil', 'DynKernelArguments', 'DynKernelArgument', 'DynACCEnterDataDirective']