Closed TeranIvy closed 3 weeks ago
@TeranIvy and I discussed this today and have agreed:
nlayers
from field arguments to kernels that operate_on dofs;operates_on=cell_column
, PSyclone will look-up nlayers
for the first argument that is written to.I've grepped through the tests and, AFAICS, nlayers
is only ever looked-up and then supplied to a kernel call so we are free to have a separate variable for each kernel (or, more specifically, the first field that a kernel writes to).
Currently, it is DynCellIterators
that is responsible for looking up nlayers and creating a tagged symbol to store it. This will need to be updated to find the first field/operator that is written to by each kernel in the invoke and create an nlayers symbol for each of them. We must have functionality to do some of this since the cell-column iteration space is determined by looking at the field/op arguments that are written to by a kernel.
LFRic API seems to return different
nlayers
depending on whether invoke calls tosetval_c
built-in and a kernel are joint or not. This was commented on in the LFRic Apps ticket 21,pres_lev_diags_alg_mod.x90
. The example pruned-down code is below.Mock algorithm code
Mock kernel code
Generated PSy-layer code for
nlayers
Note that
setval_c
built-in defines the field access asGH_WRITE
(see https://github.com/stfc/PSyclone/blob/master/src/psyclone/parse/lfric_builtins_mod.f90).When invokes are separate (Case 1 and Case 2),
nlayers
is determined from the first field in the kernel argument list,exner
, which hasGH_READ
access:nlayers = exner_wth_proxy%vspace%get_nlayers()
.When invokes are joint,
nlayers
is determined from the first field in the first kernel or built-in call in the joint invoke. In Case 3 this isnlayers = plev_heaviside_proxy%vspace%get_nlayers()
, and in Case 4 this isnlayers = exner_wth_proxy%vspace%get_nlayers()
.Questions/discussion for @arporter, @sergisiso and @hiker
nlayers
in both user and developer guide and I was not able to find a relevant record.nlayers
is determined from fields that are updated, regardless of the order of metadata? This is already done for loop limits over cells (with continuous writers having priority regardless of the metadata order).