-
Notifications
You must be signed in to change notification settings - Fork 49
Align adjoint_tests to linear_model
#123
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
base: main
Are you sure you want to change the base?
Align adjoint_tests to linear_model
#123
Conversation
…j-h/lfric_apps into align_adjoint_tests_to_linear_model
DrTVockerodtMO
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Tom. Changes look fine so far (I checked the trac.log and I can confirm the test failure is a test that's unrelated to the changes here).
I've suggested a few minor changes, and I have some questions as well about the adjoint test parameter changes.
| call create_pressure_solver( pressure_operator, pressure_preconditioner, pressure_solver ) | ||
| call create_mixed_preconditioner( rhs, pressure_solver, mixed_preconditioner ) | ||
|
|
||
| adj_pressure_operator = adj_pressure_operator_type(level=1_i_def) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to keep things tidy and as fast as possible - the adj_pressure_operator_type ctor can be removed, as the create_adj_pressure_preconditioner method features this line.
| call create_mixed_preconditioner( rhs, pressure_solver, mixed_preconditioner ) | ||
| call create_mixed_solver( mixed_preconditioner, mixed_operator, mixed_solver ) | ||
|
|
||
| adj_pressure_operator = adj_pressure_operator_type(level=1_i_def) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto with this line.
|
|
||
| call create_pressure_preconditioner( rhs, pressure_operator, pressure_preconditioner ) | ||
|
|
||
| adj_pressure_operator = adj_pressure_operator_type(level=1_i_def) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
| ! randomly assigned, but in a sensible range | ||
| ! to prevent these issues. | ||
| real(r_def), dimension(2), parameter :: ls_u_range = (/ 0.0_r_def, 10.0_r_def /) | ||
| real(r_def), dimension(2), parameter :: ls_u_range = (/ 0.1_r_def, 10.0_r_def /) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason that the lower range values needed changing? Is it to avoid an LS value of zero because of bugs, or because physically speaking these LS values cannot go to zero?
I think I got the initial values by looking at the initial analytical state fed into the linear_model app, so you may be correct in changing these, I am just curious as to the reason!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting this, this change shouldn't be here.
It's leftover from when I was getting adjoint_tests to run with all the code built at 32-bit. This caused some tests to occasionally fail with infinities. Making the changes you see here stopped that. From looking at where the failures were, my suspicion was that the issue wasn't divide-by-zero, rather divide-by-tiny-number which, at 32-bit, could more easily cause an infinity than at 64-bit. Hence removing the possibility of numbers in the range [0,0.1] fixed it.
I suggest just removing this change, since it's not needed for the 64-bit tests. The alternative is to keep it, and add the 32-bit builds/runs to the test suite. A caveat is that this does require increasing tolerances slightly for some of the tests involving the iterative solver, as might be expected.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for letting me know. I think it's fine to remove the changes for now, and if/when we want 32-bit tests we can introduce it there to keep things agile.
DrTVockerodtMO
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes - looks good to me now!
PR Summary
Sci/Tech Reviewer:
Code Reviewer: @TeranIvy
Align default configuration of
adjoint_teststo that oflinear_model(nwp-gal9). This includes both the canned test and the rose-stem tests.linear_modeluses multigrid preconditioning in the solver, and taking advantage of this in the adjoint requires a minor code change inscience/adjoint/source/algorithm/solver/adj_semi_implicit_solver_alg_mod.x90, and to test this, minor code changes in some of the test algorithms inapplications/adjoint_tests/source/algorithm/solver/linear_modelalso reads linearisation states from file, whereasadjoint_testscurrently sets them up analytically. Moving to reading from file requires some minor changes e.g., to iodef files, but also allows the removal of a lot of the analytical linearisation state setup code in some of the test algorithms.In order to keep the alignment of
adjoint_testswithlinear_modelsimple, any necessary deviations are handled by optional configurations, so that the base configurations (rose-app.conffiles) always remain identical.This work has highlighted a minor bug which can also be dealt with by way of an optional configuration. I have opened #87 for this. Once it is dealt with the optional configuration will simply need to be removed.
For now, adding C224 tests to
adjoint_tests, to match those inlinear_model, is not being done, due to ongoing issues with runningadjoint_testsin parallel (see https://code.metoffice.gov.uk/trac/lfric_apps/ticket/800).Finally, the code/patch changes from #71 (Done!science/adjoint/source/kernel/transport/mol/atl_poly1d_vert_w3_reconstruction_kernel_mod.F90andscience/adjoint/patches/kernel/atl_poly1d_vert_adv_kernel_mod.patch) are required for one of the configuration changes, so they've been duplicated here but need not be reviewed again. This makes #71 a blocker.Also please note I branched from
mainrather thanstableby mistake - apologies for this. I can make a new branch/PR if desired.is blocked-by Fixing adjoint failures with transport log_space config variable set to true #71Code Quality Checklist
Testing
trac.log
Very long - see
~tom.hill/cylc-run/align_adjoint_tests_to_linear_model-developer-postSR1/trac.log.Security Considerations
Performance Impact
AI Assistance and Attribution
Documentation
PSyclone Approval
Sci/Tech Review
Code Review