Skip to content
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

GitHub Issue NOAA-EMC/GSI#118. EFSOI additions to src/gsi and src/enkf directories. #143

Merged

Conversation

AndrewEichmann-NOAA
Copy link
Contributor

Modified following files in src/enkf for EFSOI implementation

modified:   enkf.f90
modified:   enkf_main.f90
modified:   enkf_obs_sensitivity.f90
modified:   gridio_gfs.f90
modified:   loadbal.f90
modified:   params.f90

@AndrewEichmann-NOAA
Copy link
Contributor Author

PS - sorry for the bad PR title

@AndrewEichmann-NOAA
Copy link
Contributor Author

tagging @aerorahul @CatherineThomas-NOAA @MichaelLueken-NOAA (Liaofan not taggable)

@@ -712,6 +761,23 @@ subroutine read_namelist()
corrlengthtr = corrlengthtr * 1.e3_r_single/rearth
corrlengthsh = corrlengthsh * 1.e3_r_single/rearth

if(efsoi_cycling) then
letkf_flag = .false.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndrewEichmann-NOAA Do you understand what's happening here? Is LETKF turned off if you use EFSOI? I seem to remember Liaofan using LETKF in his tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, I hadn't noticed that. The same lines are in Liao-Fan's fork. He might not have noticed either. I'll ask him.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CatherineThomas-NOAA @aerorahul

Apparently what was taken as evidence that LETKF has been running was actually the report of the namelist settings, but then after that these lines turn LETKF off. Grepping the stdout for "min/max/mean time to do letkf update" is more definitive. So apparently LETKF has not been run with EFSOI up to now. Removing these lines allows running LETKF and I have an EFSOI experiment running it transparently right now. However:

  • The initial osense files are identical between LETKF off and on, and contain the saved variable anal_obs. In the enkf code, anal_obs is reassigned only if efsoi_cycling=.true., and that's after an mpi send/receive with anal_obschunk, which does get updated in the preceding code. I presume that the mpi happens because EFSOI needs anal_obs, and the enkf code updates it (locally, as anal_obschunk) for its own use.

  • One difference between running EFSOI update with LETKF and not is that apparently the increments (atminc) in the ensemble members are set to zero when LETKF is turned off by this line. Which raises the question how we ever got any sensible results with v16. They are non-zero with the lines removed; ie it seems to be at least non-pathological with LETKF.

  • LETKF assigns anal_obs to the sensibly named hxens, which then goes on to be modified. The original anal_obs is left undisturbed, and output to the osense file.

  • The upshot is that the current code uses ensrf by accident, in a bad way that doesn't update anal_obs, which then gets saved to the osense file; whereas taking the lines out uses letkf, which doesn't update anal_obs because it's not expected to, does the same. That's why the osense files are identical between the two, and perhaps why the increments are zero with the accidentally run ensrf.

So I suspect what needs to be changed, aside from the elimination of these two lines, is, in the LETKF code, to send hxens (or something derived from it) back to anal_obs to be output into the osense file. If Ensrf is being broken as I suspect, is making sure it can work a concern? Three-day weekend, hello.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CatherineThomas-NOAA @aerorahul I think I understand some of what I have to do - what I need in the obsense file after the ensemble update is the product of the updated analysis perturbations in observation space and the inverse of R. In the enkf code if fso/efsoi_cycling is true after updating anal_obchunk, anal_obchunk gets gathered back into anal_ob, then later written to the osense file (this part is already in the master). In LETKF, it's not obvious to me how to get that, esp. since most of the final work seems to be in model space. Will keep looking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CatherineThomas-NOAA @aerorahul From looking at the literature it looks like I can apply the same output from letkf_core to HXb to get HXa as is applied to Xb to get Xa, assuming H is linear. So approximately do to anal_ob_chunk what is already done to anal_chunk. Does that sound right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CatherineThomas-NOAA I removed the lines that switched off LETKF when EFSOI is running. Now if letkf_flag and efsoi_cycling are true, the osense file will be saved with the observation space ensemble prior (when EFSOI wants the posterior). To run the serial filter and get the posterior out of that, lupd_obspace_serial must be true: this runs the serial filter, then the LETKF. This is fine unless efsoi_cycling is true, because that updates anal_ob with the posterior to write out to the osense file. The problem with that is that the LETKF then uses anal_ob as the prior. So I introduced a new array, anal_ob_post, which is declared in enkf_obsmod and allocated in the serial filter only if efsoi_cycling equals true. The posterior is copied into it from anal_ob_chunk to be written to the obsense, and anal_ob is left unchanged. It shouldn't affect anything else.
Also, I had to add gsi/constants.f90, which had some changes that I missed when making this PR.

@CatherineThomas-NOAA
Copy link
Collaborator

@AndrewEichmann-NOAA It looks like something got messed up with this PR. It now says there are 203 files changed instead of 6. Maybe it's just not up to date with the master?

@AndrewEichmann-NOAA
Copy link
Contributor Author

@CatherineThomas-NOAA Should be fixed now - the 7th file is src/gsi/constants.f90, which was neglected in the original PR

Copy link
Collaborator

@CatherineThomas-NOAA CatherineThomas-NOAA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not the most consistent solution to use the EnSRF for the EFSOI but the LETKF to cycle, but it's a straightforward implementation at least. We can note the caveat when analyzing results and improve upon this later.

@AndrewEichmann-NOAA
Copy link
Contributor Author

I kind of hate it tbh, but for now and for the application it seems like the best solution.

@MichaelLueken
Copy link
Contributor

@AndrewEichmann-NOAA - To reduce the number of commits from 12 to 1, and update your branch to the latest authoritative repo master, please use the following commands:

  1. git clone --recursive git@github.com:AndrewEichmann-NOAA/GSI.git update
  2. cd update

To merge the latest authoritative master into your PR branch:

  1. git checkout EXP-efso_fv3_PR_src_enkf
  2. git remote add upstream https://github.com/NOAA-EMC/GSI.git
  3. git remote update
  4. git rebase upstream/master
  5. git add fix
  6. git rebase --continue
  7. git reset HEAD CMakeLists.txt jobs/JGDAS_EFSOI jobs/JGDAS_EFSOI_FCST util/EFSOI_Utilities/scripts/README_fv3gfs util/EFSOI_Utilities/src/CMakeLists.txt util/EFSOI_Utilities/src/efsoi.f90 util/EFSOI_Utilities/src/efsoi_main.f90 util/EFSOI_Utilities/src/gridio_efsoi.f90 util/EFSOI_Utilities/src/loadbal_efsoi.f90 util/EFSOI_Utilities/src/loc_advection.f90 util/EFSOI_Utilities/src/scatter_chunks_efsoi.f90 util/EFSOI_Utilities/src/statevec_efsoi.f90 scripts/exgdas_efsoi.sh scripts/exgdas_efsoi_update.sh
  8. git checkout -- CMakeLists.txt jobs/JGDAS_EFSOI jobs/JGDAS_EFSOI_FCST util/EFSOI_Utilities/scripts/README_fv3gfs util/EFSOI_Utilities/src/CMakeLists.txt util/EFSOI_Utilities/src/efsoi.f90 util/EFSOI_Utilities/src/efsoi_main.f90 util/EFSOI_Utilities/src/gridio_efsoi.f90 util/EFSOI_Utilities/src/loadbal_efsoi.f90 util/EFSOI_Utilities/src/loc_advection.f90 util/EFSOI_Utilities/src/scatter_chunks_efsoi.f90 util/EFSOI_Utilities/src/statevec_efsoi.f90 scripts/exgdas_efsoi.sh scripts/exgdas_efsoi_update.sh
  9. git rebase --continue
  10. git reset HEAD CMakeLists.txt jobs/JGDAS_EFSOI jobs/JGDAS_EFSOI_FCST util/EFSOI_Utilities/scripts/README_fv3gfs util/EFSOI_Utilities/src/CMakeLists.txt util/EFSOI_Utilities/src/efsoi.f90 util/EFSOI_Utilities/src/efsoi_main.f90 util/EFSOI_Utilities/src/gridio_efsoi.f90 util/EFSOI_Utilities/src/loadbal_efsoi.f90 util/EFSOI_Utilities/src/loc_advection.f90 util/EFSOI_Utilities/src/scatter_chunks_efsoi.f90 util/EFSOI_Utilities/src/statevec_efsoi.f90 scripts/exgdas_efsoi.sh scripts/exgdas_efsoi_update.sh
  11. git checkout -- CMakeLists.txt
  12. git rebase --continue
  13. git reset HEAD util/EFSOI_Utilities/src/CMakeLists.txt util/EFSOI_Utilities/src/efsoi.f90 util/EFSOI_Utilities/src/efsoi_main.f90 util/EFSOI_Utilities/src/gridio_efsoi.f90 util/EFSOI_Utilities/src/loadbal_efsoi.f90 util/EFSOI_Utilities/src/loc_advection.f90 util/EFSOI_Utilities/src/scatter_chunks_efsoi.f90 util/EFSOI_Utilities/src/statevec_efsoi.f90
  14. git checkout -- util/EFSOI_Utilities/src/CMakeLists.txt util/EFSOI_Utilities/src/efsoi.f90 util/EFSOI_Utilities/src/efsoi_main.f90 util/EFSOI_Utilities/src/gridio_efsoi.f90 util/EFSOI_Utilities/src/loadbal_efsoi.f90 util/EFSOI_Utilities/src/loc_advection.f90 util/EFSOI_Utilities/src/scatter_chunks_efsoi.f90 util/EFSOI_Utilities/src/statevec_efsoi.f90
  15. git rebase --continue
  16. git reset HEAD util/EFSOI_Utilities/src/efsoi.f90 util/EFSOI_Utilities/src/gridio_efsoi.f90 util/EFSOI_Utilities/src/loadbal_efsoi.f90 util/EFSOI_Utilities/src/loc_advection.f90 util/EFSOI_Utilities/src/scatter_chunks_efsoi.f90 util/EFSOI_Utilities/src/statevec_efsoi.f90
  17. git checkout -- util/EFSOI_Utilities/src/efsoi.f90 util/EFSOI_Utilities/src/gridio_efsoi.f90 util/EFSOI_Utilities/src/loadbal_efsoi.f90 util/EFSOI_Utilities/src/loc_advection.f90 util/EFSOI_Utilities/src/scatter_chunks_efsoi.f90 util/EFSOI_Utilities/src/statevec_efsoi.f90
  18. git rebase --continue
  19. git reset HEAD util/EFSOI_Utilities/src/gridio_efsoi.f90 util/EFSOI_Utilities/src/scatter_chunks_efsoi.f90 util/EFSOI_Utilities/src/statevec_efsoi.f90
  20. git rebase --continue
  21. git reset HEAD util/EFSOI_Utilities/src/gridio_efsoi.f90 util/EFSOI_Utilities/src/scatter_chunks_efsoi.f90 util/EFSOI_Utilities/src/statevec_efsoi.f90
  22. git rebase --skip
  23. git reset HEAD util/EFSOI_Utilities/src/gridio_efsoi.f90 util/EFSOI_Utilities/src/scatter_chunks_efsoi.f90 util/EFSOI_Utilities/src/statevec_efsoi.f90
  24. git checkout -- util/EFSOI_Utilities/src/gridio_efsoi.f90 util/EFSOI_Utilities/src/scatter_chunks_efsoi.f90 util/EFSOI_Utilities/src/statevec_efsoi.f90
  25. git rebase --continue
  26. git reset HEAD util/EFSOI_Utilities/src/gridio_efsoi.f90 util/EFSOI_Utilities/src/scatter_chunks_efsoi.f90 util/EFSOI_Utilities/src/statevec_efsoi.f90
  27. git rebase --continue
  28. git reset HEAD util/Conventional_Monitor/image_gen/exec/.gitignore util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/exec/.gitignore util/Ozone_Monitor/nwprod/oznmon_shared/exec/.gitignore util/Radiance_Monitor/image_gen/src/radmon_ig_horiz.fd/update_ctl_horiz.f90
  29. git checkout -- util/Ozone_Monitor/nwprod/oznmon_shared/exec/.gitignore
  30. git rebase --continue

Shorten commits to a single commit:

  1. git reset --soft HEAD~1
  2. git reset --soft HEAD~1
  3. git reset --soft HEAD~1
  4. git reset --soft HEAD~1
  5. git reset --soft HEAD~1
  6. git reset --soft HEAD~1
  7. git reset --soft HEAD~1
  8. git reset --soft HEAD~1
  9. git reset --soft HEAD~1
  10. git reset --soft HEAD~1
  11. git reset --soft HEAD~1
  12. git reset --soft HEAD~1
  13. git reset --soft HEAD~1
  14. git reset HEAD scripts/exgdas_efsoi_fcst.sh
  15. git checkout -- scripts/exgdas_efsoi_fcst.sh

Commit and push:

1) git commit -m "GitHub Issue NOAA-EMC/GSI#118. EFSOI additions to src/gsi and src/enkf directories."
2) git push origin EXP-efso_fv3_PR_src_enkf --force

Once these steps are complete, I will be able to send this work to the review committee.

@AndrewEichmann-NOAA
Copy link
Contributor Author

@MichaelLueken-NOAA I believe I have finished applying these steps

@MichaelLueken
Copy link
Contributor

@AndrewEichmann-NOAA Thanks, Andrew. Everything looks good. I will now send this work to the review committee.

@MichaelLueken MichaelLueken linked an issue Jul 30, 2021 that may be closed by this pull request
@MichaelLueken MichaelLueken changed the title Exp efso fv3 pr src enkf GitHub Issue NOAA-EMC/GSI#118. EFSOI additions to src/gsi and src/enkf directories. Aug 6, 2021
@MichaelLueken
Copy link
Contributor

There has been no feedback from the review committee, so I will now give final approval to these changes and merge them to the authoritative master.

@MichaelLueken MichaelLueken merged commit c5c0a9e into NOAA-EMC:master Aug 6, 2021
@AndrewEichmann-NOAA AndrewEichmann-NOAA deleted the EXP-efso_fv3_PR_src_enkf branch April 13, 2022 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement EFSOI process in FV3 GFS workflow (2nd try)
3 participants