-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass read-only arrays of scalars to kernels #1312
Comments
Example PSyKAl-lite code using the above implementation can be found in um_physics/source/psy/psykal_lite_phys_mod.F90 on the LFRic trunk, this is used as part of the Stochastic physics forcing pattern. |
Priority wise, how does this compare with the 'stencils for domain (i-first) kernels' issue @andrewcoughtrie and @TeranIvy ? |
Link to PSyKAl-lite code.. @arporter, stencils are currently a priority because of optimisations that the relevant code introduces. |
As far as i know we don't have an urgent need for this to be implemented, the current PSyKAl-lite code is only in one place that I know of and is unlikely to expand. |
Thanks both :-) |
I have discovered a case of an alternative workaround whereby global scope module variables are being used to pass arrays "around the side" of the argument list. Clearly this is bad. For those interested check out Gung Ho's |
Can you put a comment next to this usage with the PR reference number please @MatthewHambley, just to make it easy to search for places it needs changing when we have the functionality. |
It is already marked with a Doxygen "todo" comment. That's how I knew this PR existed. |
Thanks @MatthewHambley. It looks like the case you are talking about is in the algorithm layer. Is that right? |
…my mind on some styling changes
We have had repeated requests for passing arrays of scalars to kernels. The design is outlined below.
Note: The code in the examples was successfully tested with Intel 19.0.1 and Gnu 11.2.0 compilers.
Kernel layer
Full example: scalar_arrays_kernel_mod.f90.txt
Metadata and argument access
GH_ARRAY
GH_SCALAR_ARRAY
. We also need to specify the number of ranks as an integer.We broadly agreed onThe new keyword for scalar array will need to be added toNRANKS
as a keyword for ranks (rank
is a Fortran intrinsic so cannot be used here).argument_mod.F90
where LFRic stores metadata IDs.suggestedmetadata design updated after the metadata review that compiles is as follows:Note: We are not allowing kernels with no fields so this example is just for illustration.
Arguments
AnThis is not required as it is read from the metadata.integer
scalar of kindi_def
for the number of ranks,nranks_<array_name>
;integer
array of kindi_def
and sizenranks_<array_name>
containing the upper bounds for each rank,dims_<array_name>
(lower bound is assumed to be 1 as this is how Fortran passes array slices to subroutines by default).The argument list for the metadata above would look something like:
and the declarations
PSy layer
Full example: pass_scalar_array_mod_psy.f90.txt
Note: As the array rank is known from the metadata, we can simply do
Deprecated
We can declare scalar arrays as assumed shape (the rank is known from the metadata), e.g.The number of ranks and dimensions can then be retrieved usingrank
andsize
intrinsics, e.g.Algorithm layer
Full example: pass_scalar_array_alg.f90.txt
An invoke call would simply pass the name of the scalar arrays, as for other arguments, e.g.
The text was updated successfully, but these errors were encountered: