-
Notifications
You must be signed in to change notification settings - Fork 159
Fix ITP & improve performance #892
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?
Conversation
Fix ITP & improve performance This commit does two main things. First, the ITP algorithm in the rootfinding mod is fixed. The original version was based on Eq (15) from their paper, which was a typo. The buggy version still converged but was slow. Second, several changes have been made to improve performance. - In the rootfinding mod, for bounded cases we don't immediately go to ITP, which was inefficient. - In the kde distribution mod the quadrature has been switched from ninth-order to fifth order. This could degrade accuracy for small ensembles, but significantly improves performance. - In the kde distribution mod the logic associated with the boundary correction has been updated to reduce unnecessary computation. This doesn't change answers but significantly improves performance.
Right now I've switched the quadrature from fifth to third order, but left the fifth order code in there, inactive. It would be nice to control this using a namelist parameter, but I'm not sure how to do that for a module. Is there a way to read a namelist variable directly into this module? If so, then I can set up the logic to use third or fifth order based on that variable. |
For a namelist in a module, you'll need to add a check for the namelist being read for any routine that needs the namlist option. DART follows this pattern, where there is an initializing routine (e.g. "rootfinding_init") called to read the namelist on the first call. Pseudo code:
You can take a look at
|
Thanks! I will give this a shot. |
I'm working on using a namelist to set the quadrature order, and I think it's working. Is there a way to set it up so that if |
This commit enables the choice of either fifth order (3-point) or ninth order (5 point) Gauss-Legendre quadrature via a namelist. The namelist name is kde_nml and the variable in the namelist is quadrature_order, which can be either 5 or 9.
My opinion is that optional namelists are a good idea, particularly for "advanced" user features or even experimental features, because otherwise all input.nmls have to have every namelist. The change would be here, e.g. having an optional argument DART/assimilation_code/modules/utilities/utilities_mod.f90 Lines 425 to 430 in d908222
Do you want to be the first optional namelist in dart? |
I tried skipping the error message, but then it just hangs. The subroutine returns |
ok thanks, I'll take a look. |
optional arguement to find_namelist_in_file optional_nml = .true. for optional namelists pass back iunit as NAMELIST_NOT_PRESSENT when the namelist is not found input.nml
Hi Ian, I put an optional namelist in for kde in https://github.com/iangrooms/DART/pull/1/files The namelist values still get logged with the default values if the namelist is not found in input.nml Up to you whether you want to make this namelist required or optional. |
optional namelist for kde
Thanks! Rather than forcing users to add this namelist, I think I'd rather update the docs to let them know that there is an option to change the quadrature order via a namelist and thus reduce computational cost, potentially at the cost of reduced accuracy in situations where the observation error is much smaller than the distance between ensemble members in observation space. |
This commit adds seventh-order quadrature as an option. It also deletes the un-used function integrate_pdf. Since that function was part of the test suite, the tests have also been updated. The number of expected 'PASS' results is the same though.
Description:
This PR does two main things. First, the ITP algorithm in the rootfinding mod is fixed. The original version was based on Eq (15) from their paper, which was a typo. The buggy version still converged but was slow.
Second, several changes have been made to improve performance.
kde_nml
which has a single entryquadrature_order
equal to 5, 7, or 9. Documentation has been updated to reflect this option.integrate_pdf
. Since this function was part of the test suite I also changed the test suite to test the quadrature approximation to the cdf. The expected number of 'PASS' results is the same.Types of changes
Performance improvement isn't on this list, but that's a big part of this PR.
Documentation changes needed?
Tests
I ran the kde distribution test, which passes with both the rootfinding mod version of inv_cdf and the normal distribution mod version of inv_cdf. I tested performance by just looping that test 4000 times.
Checklist for merging
Checklist for release
Testing Datasets