[LFRic] Support for user-defined kernels that operate on DoFs
Originally we had preliminary support for user-defined kernels that operate on DoFs. However, it produced incorrect code and we removed it until the need arises.
There are several LFRic PSyKAl-lite routines that could be removed with this support, hence this issue. Furthermore, it seems that we need to differentiate between operates_on = DOF and operates_on = DOF_COLUMN.
Following on from our chat in the telco this morning, it sounds as though the random-number initialisation functionality needed for PSyAD should also be a dof-wise kernel. In fact, for the simplest case it could just be a built-in? I guess it depends on what Ben's existing kernel code already does?
Proposed changes:
Allowed metadata types and access
- field (READ, WRITE, READWRITE)
- scalar (READ only)
LFRic Builtins metadata vs User defined kernels metadata
LFRic builtins use the LFRicKernelMetadata to store and validate their metadata. However, user-defined kernels use the newer LFRicKernMetadata, LFRicKern, and LFRicArgDescriptor to store and validate their metadata. This means that no checks are required to be added to LFRicKernelMetadata to validate user-defined kernels that operate on dofs since this isn't touched by LFRicKern.
Changes
- [x] 1. Add
'dof'to the list ofUSER_KERNEL_ITERATION_SPACESin LFRic Constants - [x] 2. Edit LFRicKernCallFactory to check if
iterates_overis equal todofand modifyloop_typeto equaldof. This will then be picked up byLFRicLoopand set the iterator tag todf. - [x] 3.
operates_on = 'dof'is used by Builtins validating their metadata throughLFRicKernelMetadata. Should just add a one line conditional toLFRicKernto check ifself.nameis the name of a builtin. This should add a little bit of protection.
No Change
- Fields are currently only allowed to be READ, WRITE, READWRITE, as defined in
domain/lfric/lfric_arg_descriptor.py:
# Test allowed accesses for fields
field_disc_accesses = [AccessType.READ, AccessType.WRITE,
AcessType.READWRITE]
- Scalars also have the correct access types - only allowed to be READ as defined in
domain/lfric/lfric_arg_descriptor.py:
# Test allowed accesses for scalars (read_only or reduction)
scalar_accesses = [AccessType.READ] + AccessType.get_valid_reduction_modes()
#2556 only added the documentation, not the implementation.
Completed via #2711 and #2712.