Skip to content

Commit

Permalink
#2711 Remove DoF Kernel notes from docs and add test for multiple writes
Browse files Browse the repository at this point in the history
  • Loading branch information
oakleybrunt committed Sep 19, 2024
1 parent 39c0211 commit 0cadb92
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
14 changes: 3 additions & 11 deletions doc/user_guide/dynamo0p3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -796,9 +796,6 @@ support for i-first kernels
point the looping (and associated parallelisation) will be put
back into the PSy layer.

.. note:: Support for DoF kernels have not yet been implemented in PSyclone
(see PSyclone issue #1351 for progress).

.. _lfric-user-kernel-rules:

Rules for all User-Supplied Kernels that Operate on Cell-Columns
Expand Down Expand Up @@ -981,9 +978,6 @@ on a ``CELL_COLUMN`` without CMA Operators. Specifically:
Rules for all User-Supplied Kernels that Operate on DoFs (DoF Kernels)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. note:: Support for DoF kernels have not yet been implemented in PSyclone
(see PSyclone issue #1351 for progress).

Kernels that have ``operates_on = DOF`` and
:ref:`LFRic Built-ins<lfric-built-ins>` overlap significantly in their
scope, and the conventions that DoF Kernels must follow are influenced
Expand Down Expand Up @@ -1015,8 +1009,9 @@ The list of rules for DoF Kernels is as follows:
to do this.) Any scalar arguments must therefore be declared in the metadata
as `GH_READ` - see :ref:`below<lfric-kernel-valid-access>`

6) Kernels must be written to operate on a single DoF, such that single DoFs
can be provided to the Kernel within a loop over the DoFs of a field.
6) Kernels must be written to operate on a single DoF, such that field values
at the same dof location/index can be provided to the Kernel within a loop
over the DoFs of given fields.

.. _lfric-api-kernel-metadata:

Expand Down Expand Up @@ -2475,9 +2470,6 @@ as the second argument to the kernel (after ``nlayers``).
Rules for DoF Kernels
#####################

.. note:: Support for DoF kernels have not yet been implemented in PSyclone
(see PSyclone issue #1351 for progress).

The rules for kernels that have ``operates_on = DOF`` are similar to those for
general-purpose kernels but, due to the restriction that only fields and
scalars can be passed to them, are much fewer. The full set of rules, along
Expand Down
30 changes: 30 additions & 0 deletions src/psyclone/tests/domain/lfric/dofkern_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,36 @@ def test_is_dofkern():
assert kern.is_dofkern


def test_multiple_write_args():
'''
Check that a user-defined dof kernel raises no errors when more than one
metadata arg of type 'gh_field' have an access type of 'gh_write'.
'''
# Substitute field for field vector
code = CODE.replace(
"""
type(arg_type), dimension(2) :: meta_args = &
(/ arg_type(gh_field, gh_real, gh_write, w1), &
arg_type(gh_field, gh_real, gh_read, w2) &
""",
"""
type(arg_type), dimension(3) :: meta_args = &
(/ arg_type(gh_field, gh_real, gh_write, w1), &
arg_type(gh_field, gh_real, gh_write, w1), &
arg_type(gh_field, gh_real, gh_read, w1) &
""",
1)
ast = fpapi.parse(code, ignore_comments=False)
name = "testkern_dofs_type"
# Load the metadata into an empty kernel
md = LFRicKernMetadata(ast, name=name)
kern = LFRicKern()
kern.load_meta(ktype=md)
# Assert that the identifier is set
assert kern.is_dofkern


def test_upper_bound_undf():
'''
Checks that the correct upper bound is generated for a dof-kernel when
Expand Down

0 comments on commit 0cadb92

Please sign in to comment.