PSyclone icon indicating copy to clipboard operation
PSyclone copied to clipboard

[LFRic] Allow writable scalars in user-defined kernels

Open TeranIvy opened this issue 3 years ago • 2 comments

LFRic API currently only support read-only user-defined scalars. Global sums that PSyclone generates can be written to, but nothing user-defined. This issue adds support for writable scalars in LFRic API.

Access and intent:

  • GH_WRITE, intent(out)
  • GH_READWRITE, intent(inout) - do we need this one?

TeranIvy avatar Jul 28 '22 12:07 TeranIvy

I guess this is a request from the scientists but it is non-intuitive to me. User-written kernels operate on a single column and the assumption is that PSyclone calls these kernels for all columns. How are we going to write to a scalar in this scenario, unless all kernels write the same value, or the kernels know something about which column they are on?

rupertford avatar Jul 29 '22 14:07 rupertford

We talked about this and came to conclusion that it would be allowed for kernels that operate on the entire domain. However, it is not yet clear whether this is required for use cases other than writing a modified scalar into restart/IO files by including them into the model state. Hence, this requirement is not urgent for now and will be revisited.

In case of kernels that operate on columns, we would need to make the assumption that all kernels write the same value unless the kernels know something about which column the scalars are on, as noted in @rupertford's comment. However, as Mike pointed out, how can we be sure that the currently allowed read-only scalars have the same value for each column that a kernel operates on? We just assume that they do - there are no checks.

TeranIvy avatar Aug 03 '22 13:08 TeranIvy