Lfric2lfric w2#390
Lfric2lfric w2#390Juan Manuel Castillo Sanchez (ukmo-juan-castillo) wants to merge 36 commits intoMetOffice:mainfrom
Conversation
transformation kernels
DrTVockerodtMO
left a comment
There was a problem hiding this comment.
Thanks for the changes. One minor issue regarding consistent style with the rest of the adjoint tests.
|
I tried running this against LFRic-JEDI, and the JEDI interface build failed with: Any ideas what could be causing this? I've not yet ruled out an error on my part, and I will update if that is the case. |
|
It looks like the build fail is due to the addition of two new arguments ( |
Exactly, that is why there is a lfric_core linked PR. This lfric_core PR is the one modifying the kernel that you observed failing. |
|
Ah, I see the branch for that now. Is there a PR for that one yet? |
Yes, there is a link in the PR description: MetOffice/lfric_core#312. I added a link to the PR in the issue. |
DanStoneMO
left a comment
There was a problem hiding this comment.
Alright given it another shot and JEDI is all good with this. No linked PR will be needed for lfric-jedi.
DrTVockerodtMO
left a comment
There was a problem hiding this comment.
Thanks for making the changes, code owner review passed.
| if (fs == W2) then | ||
| field_src_ptr => u_in_w3_src | ||
| field_dst_ptr => u_in_w3_dst | ||
| call lfric2lfric_map_regrid(field_dst_ptr, field_src_ptr) | ||
| field_src_ptr => v_in_w3_src | ||
| field_dst_ptr => v_in_w3_dst | ||
| call lfric2lfric_map_regrid(field_dst_ptr, field_src_ptr) | ||
| field_src_ptr => w_in_wth_src | ||
| field_dst_ptr => w_in_wth_dst | ||
| call lfric2lfric_map_regrid(field_dst_ptr, field_src_ptr) |
There was a problem hiding this comment.
What's the advantage of setting pointers and then calling lfric2lfric_map_regrid rather than just doing something like:
call lfric2lfric_map_regrid(u_in_w3_dst, u_in_w3_src)
call lfric2lfric_map_regrid(v_in_w3_dst, v_in_w3_src)
call lfric2lfric_map_regrid(w_in_w3_dst, w_in_w3_src)
| field_src_ptr => u_in_w3_src | ||
| field_dst_ptr => u_in_w3_dst | ||
| call lfric2lfric_oasis_regrid(modeldb, oasis_clock, & | ||
| field_dst_ptr, field_src_ptr) | ||
| field_src_ptr => v_in_w3_src | ||
| field_dst_ptr => v_in_w3_dst | ||
| call lfric2lfric_oasis_regrid(modeldb, oasis_clock, & | ||
| field_dst_ptr, field_src_ptr) | ||
| field_src_ptr => w_in_wth_src | ||
| field_dst_ptr => w_in_wth_dst | ||
| call lfric2lfric_oasis_regrid(modeldb, oasis_clock, & | ||
| field_dst_ptr, field_src_ptr) |
There was a problem hiding this comment.
Same question here as above - what's the advantage of setting pointers here?
There was a problem hiding this comment.
Same question here as above - what's the advantage of setting pointers here?
The reason is that, when I tried to remove the pointers, I obtained segmentation faults. I investigated further and it turns out that one only needs to set the algorithm parameters to 'inout' rather than just 'out'. This is now fixed and I send it for a further review. I run all tests successfully and updated the trac.log.
|
Hi Juan - the linked section in the PR summary is meant for linked PRs - i.e. PRs in other repositories that need to go on together, rather than related PRs or PRs that need to go on in sequence. Can you move the #238 mention to the "is related to" section, and clarify whether lfric_core#312 is linked, part of a chain, or just related? |
Lottie Turner (mo-lottieturner)
left a comment
There was a problem hiding this comment.
All looks good, thanks for fixing the pointers :)
There was a problem hiding this comment.
Kgos have changed, most likely due to the change in the geometry/topolgy enumerations used. However, other than a change in KGOs, no evidence is posted on the correctness of the output, Please post plots of the relevant fields that have changed (original and after change would be best).
Other than that, the code appears to fall in line with the PR description
| class(field_parent_type), pointer :: field => null() | ||
| type(field_type), pointer :: field_src => null() | ||
| type(field_type), pointer :: field_dst => null() |
There was a problem hiding this comment.
Don't nullify on declaration, nullify variables after declaration section of code.
| element_order_h, element_order_v, Wtheta) | ||
|
|
||
| ! Get the geometry and topology of the destination mesh | ||
| mesh_dst => mesh_collection%get_mesh(trim(mesh_names(dst))) |
There was a problem hiding this comment.
| mesh_dst => mesh_collection%get_mesh(trim(mesh_names(dst))) | |
| mesh_dst => mesh_collection%get_mesh(trim(mesh_names(dst))) |
| fs = field_src%which_function_space() | ||
| if (fs == W2) then |
There was a problem hiding this comment.
| fs = field_src%which_function_space() | |
| if (fs == W2) then | |
| fs_id = field_src%which_function_space() | |
| if (fs_id == W2) then |
Use fs_id instead as fsis sometimes to refer to the function space object, strictly speaking W0,W1,W3 etc are just integers which identify a space configuration defined by the project.
| select case (regrid_method) | ||
| case (regrid_method_map) | ||
| call lfric2lfric_map_regrid(field_dst, field_src) | ||
| if (fs == W2) then |
There was a problem hiding this comment.
| if (fs == W2) then | |
| if (fs_id == W2) then |
| type(field_type), target :: v_in_w3_src, v_in_w3_dst | ||
| type(field_type), target :: w_in_wth_src, w_in_wth_dst | ||
|
|
||
| integer(kind=i_def) :: fs |
There was a problem hiding this comment.
| integer(kind=i_def) :: fs | |
| integer(kind=i_def) :: fs_id |
| #ifdef MCT | ||
| call lfric2lfric_oasis_regrid(modeldb, oasis_clock, & | ||
| field_dst, field_src) | ||
| if (fs == W2) then |
There was a problem hiding this comment.
| if (fs == W2) then | |
| if (fs_id == W2) then |
| end select | ||
|
|
||
| ! Rebuild the W2 fields from a set of W3 and Wtheta fields | ||
| if (fs == W2) then |
There was a problem hiding this comment.
| if (fs == W2) then | |
| if (fs_id == W2) then |
| !> @param[in] geometry Mesh geometry | ||
| !> @param[in] topology Mesh topology |
There was a problem hiding this comment.
| !> @param[in] geometry Mesh geometry | |
| !> @param[in] topology Mesh topology | |
| !> @param[in] geometry Mesh geometry enumeration value | |
| !> @param[in] topology Mesh topology enumeration value |
| !> @param[in] geometry Mesh geometry | ||
| !> @param[in] topology Mesh topology |
There was a problem hiding this comment.
| !> @param[in] geometry Mesh geometry | |
| !> @param[in] topology Mesh topology | |
| !> @param[in] geometry Mesh geometry enumeration value | |
| !> @param[in] topology Mesh topology enumeration value |
|
All suggested changes have been addressed, I am running again all the tests just in case and will update the trac.log once it is finished. KGOs changes respect to the trunk because before this PR the W2 fields were not processed in lfric2lfric (they just write zeros to the field output), and now they are. I am afraid I do not have any script to plot W2 fields, so if you could provide them (it could take me a good while to write one myself), I would be happy to generate W2 plots. |
I do not have any scripts to plot output, which is why I have requested it on this PR |
|
I have asked around and nobody has successfully plotted the output W2 field, I will need some time to write my own plotting scripts. |
PR Summary
Sci/Tech Reviewer: Ricky Wong (@mo-rickywong)
Code Reviewer: mo-marqh
This is relatively simple change to allow lfric2lfric to regrid W2 fields. The accepted procedure to deal with W2 is to convert them to a set of two W3 and one Wtheta fields, process these fields, and then regenerate back a W2 field with the resulting W3 and Wtheta fields.
This changes will make use of the existing subroutines converting W2 to W3,Wtheta fields, and back.
When we merged this code to the trunk, we discovered that the results were not bit-comparable. After some investigation, it was discovered that the subroutines converting from W2 to W3 and the other way round have implicit dependencies on base_mesh, which have to be removed. This will be done as part of this new PR.
The dependency is in the kernel compute_sample_u_ops_code, which is called by interp_w3wth_to_w2_alg.
Code Quality Checklist
Testing
Test Suite Results - lfric_apps - lfric2lfric_W2/run1
Suite Information
Task Information
✅ succeeded tasks - 1511
⌛ waiting tasks - 1
Security Considerations
Performance Impact
AI Assistance and Attribution
Documentation
PSyclone Approval
Sci/Tech Review
(Please alert the code reviewer via a tag when you have approved the SR)
Code Review