From 0cadb92b263b2d7080b540d9b8fa6c8e70d99dc5 Mon Sep 17 00:00:00 2001 From: "oakley.brunt" Date: Thu, 19 Sep 2024 15:24:47 +0100 Subject: [PATCH] #2711 Remove DoF Kernel notes from docs and add test for multiple writes --- doc/user_guide/dynamo0p3.rst | 14 ++------- .../tests/domain/lfric/dofkern_test.py | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/doc/user_guide/dynamo0p3.rst b/doc/user_guide/dynamo0p3.rst index 8d67a90fc9..df1849707a 100644 --- a/doc/user_guide/dynamo0p3.rst +++ b/doc/user_guide/dynamo0p3.rst @@ -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 @@ -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` overlap significantly in their scope, and the conventions that DoF Kernels must follow are influenced @@ -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` -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: @@ -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 diff --git a/src/psyclone/tests/domain/lfric/dofkern_test.py b/src/psyclone/tests/domain/lfric/dofkern_test.py index 678276a33f..eb9cd08513 100644 --- a/src/psyclone/tests/domain/lfric/dofkern_test.py +++ b/src/psyclone/tests/domain/lfric/dofkern_test.py @@ -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