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

Implementation of CCPP-ized tropopause_find #112

Merged
merged 33 commits into from
Sep 30, 2024

Conversation

jimmielin
Copy link
Member

@jimmielin jimmielin commented Aug 23, 2024

Implements CCPP-compliant tropopause_find.

Major changes to code

This is my first time doing this, so please feel free to suggest alternative approaches!

  1. Standard CCPP-ization procedures, metadata, explicit use of fields instead of physics state, only passing active :ncol fields, ... was made.
  2. tropopause_find accepted "primary" and "backup" methods for finding the tropopause. All the methods known to be used in CAM are now calculated at the same time in the tropopause_find_run main driver routine; it calls the underlying logic as appropriate with and populates the appropriate standard name physics fields. Because the same physical quantities for tropopause level, height, pressure, temperature, etc. using different methods are used throughout the CAM physics and simultaneously output in the history tape, the same standard names with a suffix are used to differentiate between these quantities computed by different methods. e.g.,
- model_level_number_at_tropopause
- model_level_number_at_tropopause_assuming_climatology
- model_level_number_at_tropopause_assuming_cold_point
- model_level_number_at_tropopause_assuming_hybridstobie_and_climatology
- model_level_number_at_tropopause_assuming_lapse_rate
- model_level_number_at_tropopause_for_chemistry

The naming should probably be changed! I'm open to suggestions.

  1. tropopause_read_file, which provides climatological data used as the default "backup" method to compute the tropopause (tropp_p_loc and tropp_days), has been moved to a utility module in CAM-SIMA to read, regrid, and provide this climatology to the CCPP-ized physics; it also removes lchnk indexing since they're no longer used in CAM-SIMA.
  2. tropopause_find used to accept (optional) arguments for returning tropT, tropZ, tropP (tropopause temperature, height, and pressure) which are no longer optional per the CAM-SIMA port guide.

A "shim" in current CAM's tropopause.F90 was made to use the CCPP-ized routines, but preserve all existing behavior and functionality (b4b) as expected in current CAM. In CAM-SIMA all of this are not needed.

Smaller changes

  • get_curr_calday() is now provided in the registry as fractional_calendar_days_on_end_of_current_timestep

Outstanding issues/notes

  • Tropopause_find cannot be tested using snapshots within CAM-SIMA: In regular CAM, tropopause_find itself does not update physics state/tendencies; its use in regular CAM is just providing the tropopause level, height, pressure, and temperature to the calling physics package; a final run of tropopause_output will then write out to history the computed tropopause properties using the primary method. This means if snapshots cannot verify what tropopause_find is doing within CAM-SIMA.

  • How to make standard names for the same physical quantities computed using different methods that have to co-exist in one model run

Answer check

For existing CAM

  • for CAM tested with QPC6 (which uses CLUBB that uses tropopause_find) answers match bit-for-bit for history (h0i) and snapshot files before and after clubb_tend_cam. I can run more detailed regression tests for the CAM tag.

For CAM-SIMA

  • Note: to test the CAM-SIMA functionality, the history infrastructure should be manually merged in: Instantaneous CAM-SIMA history infrastructure CAM-SIMA#274
  • Because the tropopause calculated values are only in the history tape and not physics state in CAM, snapshots won't be able to verify answers.

Tricky way to verify answers

We can validate the answer fields of TROP_P, TROP_T, and TROP_Z can be against the output of CAM by running CAM-SIMA from a CAM snapshot and using history to write out these fields (instantaneously) at the first timestep. Note that ndens has to be set to 1 in CAM (for double) output, and a user_set snapshot should be taken for use before tropopause_output in physpkg.F90 for use in ncdata.

nusbaume and others added 23 commits July 24, 2024 18:35
Bring dry adiabatic adjustment (dadadj) physics scheme into main branch
- Rename to tropopause_find, _init, _run routines
- Remove most uses of physics_state and clean argument lists
- Remove use statements for physconst
- Comment out history addfld/outfld calls for CAM-SIMA
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Great work on your first major CCPP-effort @jimmielin! I have several comments, but they should almost all relate to standard names or changes to code comments. Of course please let me know if you have any issues or concerns with anything I requested. Thanks!

cam_diagnostics/tropopause_diagnostics.F90 Outdated Show resolved Hide resolved
cam_diagnostics/tropopause_diagnostics.F90 Outdated Show resolved Hide resolved
cam_diagnostics/tropopause_diagnostics.F90 Outdated Show resolved Hide resolved
cam_diagnostics/tropopause_diagnostics.F90 Outdated Show resolved Hide resolved
cam_diagnostics/tropopause_diagnostics.F90 Outdated Show resolved Hide resolved
tropopause_find/tropopause_find.F90 Outdated Show resolved Hide resolved
tropopause_find/tropopause_find.F90 Outdated Show resolved Hide resolved
tropopause_find/tropopause_find.F90 Show resolved Hide resolved
tropopause_find/tropopause_find.F90 Outdated Show resolved Hide resolved
tropopause_find/tropopause_find.meta Outdated Show resolved Hide resolved
@jimmielin
Copy link
Member Author

Updated history field list with new CCPP field names:

  ***************** HISTORY FIELD LIST ******************
          TROP_P           Pa  avg  tropopause_air_pressure
          TROP_T            K  avg  tropopause_air_temperature
          TROP_Z            m  avg  tropopause_geopotential_height_wrt_surface
         TROP_DZ            m  avg  geopotential_height_difference_between_atmosphere_layer_and_tropopause
         TROP_PD  probability  avg  probability_distribution_of_tropopause_vertical_layer_index
         TROP_FD  probability  avg  tropopause_found
         TROPP_P           Pa  avg  tropopause_air_pressure_from_lapse_rate_method
         TROPP_T            K  avg  tropopause_air_temperature_from_lapse_rate_method
         TROPP_Z            m  avg  tropopause_geopotential_height_wrt_surface_from_lapse_rate_method
        TROPP_DZ            m  avg  geopotential_height_difference_between_atmosphere_layer_and_tropopause_from_lapse_rate_method
        TROPP_PD  probability  avg  probability_distribution_of_tropopause_vertical_layer_index_from_lapse_rate_method
        TROPP_FD  probability  avg  tropopause_found_from_lapse_rate_method
         TROPF_P           Pa  avg  tropopause_air_pressure_from_cold_point_method
         TROPF_T            K  avg  tropopause_air_temperature_from_cold_point_method
         TROPF_Z            m  avg  tropopause_geopotential_height_wrt_surface_from_cold_point_method
        TROPF_DZ            m  avg  geopotential_height_difference_between_atmosphere_layer_and_tropopause_from_cold_point_method
        TROPF_PD  probability  avg  probability_distribution_of_tropopause_vertical_layer_index_from_cold_point_method
        TROPF_FD  probability  avg  tropopause_found_from_cold_point_method
         TROPC_P           Pa  avg  tropopause_air_pressure_from_climatological_method
         TROPC_T            K  avg  tropopause_air_temperature_from_climatological_method
         TROPC_Z            m  avg  tropopause_geopotential_height_wrt_surface_from_climatological_method
        TROPC_DZ            m  avg  geopotential_height_difference_between_atmosphere_layer_and_tropopause_from_climatological_method
        TROPC_PD  probability  avg  probability_distribution_of_tropopause_vertical_layer_index_from_climatological_method
        TROPC_FD  probability  avg  tropopause_found_from_climatological_method
    hstobie_trop fraction of   ins  vertical_layer_index_lower_bound_from_hybrid_stobie_linoz_with_climatological_backup_method_for_stratospheric_chemistry
   hstobie_linoz fraction of   ins  vertical_layer_index_lower_bound_from_hybrid_stobie_linoz_with_climatological_backup_method_for_linearized_ozone_chemistry
  hstobie_tropop fraction of   ins  tropopause_vertical_layer_index_from_hybrid_stobie_linoz_with_climatological_backup_method_for_chemistry
  *************** END HISTORY FIELD LIST ****************

dimensions = ()
intent = in
[ tropp_p_loc ]
standard_name = tropopause_air_pressure_from_climatology
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the input climatological dataset from tropopause_read_file. Does this standard name look fine? I am a little concerned it looks too similar to tropopause_air_pressure_from_climatological_method, so I was thinking if it would be good to change to tropopause_air_pressure_from_climatology_dataset.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like using tropopause_air_pressure_from_climatology_dataset

cam_diagnostics/tropopause_diagnostics.meta Outdated Show resolved Hide resolved
@jimmielin
Copy link
Member Author

jimmielin commented Sep 3, 2024

Thanks @nusbaume for your review comments. I have updated standard names and updated comments throughout to address your comments, and requested a re-review.

Tests on Derecho show changes here are b4b with the original PR.

There is one exception for fillvalue as I'm not quite sure where we would set its value after defining it in the registry for it to be available in both the CCPP physics and cam_history_support. I noted an alternative approach in the PR comment thread. Could you and @peverwhee perhaps provide some additional guidance? Thank you!

Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Thanks for implementing all of my change requests! There was one last comment change request I missed the first time, but otherwise everything looks good (so no need to request a re-review). Thanks!

tropopause_find/tropopause_find.F90 Outdated Show resolved Hide resolved
Co-authored-by: Jesse Nusbaumer <nusbaume@ucar.edu>
@jimmielin
Copy link
Member Author

jimmielin commented Sep 10, 2024

Thanks @nusbaume for the review! I've committed your suggested change.

Can I push the big green button to merge in the pull request into development now or are there any steps to complete? https://github.com/ESCOMP/atmospheric_physics/wiki/Tagging-Instructions mentions a tag should be made as well but I don't see any development tags, tags seem to be made based on main. Thanks! Will hold off until the CAM PR is reviewed!

Copy link
Collaborator

@cacraigucar cacraigucar left a comment

Choose a reason for hiding this comment

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

Impressive conversion. Great job!

We'll need to make sure this code is tested in ESCOMP/CAM regression tests before it can be committed into this repo.

tropopause_find/tropopause_find.F90 Show resolved Hide resolved
tropopause_find/tropopause_find.F90 Outdated Show resolved Hide resolved
tropopause_find/tropopause_find.F90 Outdated Show resolved Hide resolved
tropopause_find/tropopause_find.F90 Outdated Show resolved Hide resolved
tropopause_find/tropopause_find.F90 Outdated Show resolved Hide resolved
cam_diagnostics/tropopause_diagnostics.F90 Outdated Show resolved Hide resolved
cam_diagnostics/tropopause_diagnostics.F90 Show resolved Hide resolved
cam_diagnostics/tropopause_diagnostics.F90 Outdated Show resolved Hide resolved
cam_diagnostics/tropopause_diagnostics.F90 Show resolved Hide resolved
doc/ChangeLog Outdated Show resolved Hide resolved
Copy link
Collaborator

@cacraigucar cacraigucar left a comment

Choose a reason for hiding this comment

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

Minor mods requested

tropopause_find/tropopause_find.F90 Outdated Show resolved Hide resolved
dimensions = ()
intent = in
[ tropp_p_loc ]
standard_name = tropopause_air_pressure_from_climatology
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like using tropopause_air_pressure_from_climatology_dataset

@jimmielin
Copy link
Member Author

Thanks @cacraigucar, comment updated (also in CAM-SIMA) and standard name for tropp_p_loc changed to tropopause_air_pressure_from_climatology_dataset.

jimmielin and others added 3 commits September 23, 2024 13:12
This avoids a regression in CAM where tropZ is attempted to be interpolated
when geopotential height is unavailable. This would not be an issue in
CCPP as the framework would check for the fields.
@jimmielin
Copy link
Member Author

I ended up adding OPTIONAL back to the tropopause_findChemTrop and tropopause_findWithBackup subroutines (these are not the main CCPP tropopause_find_run run subroutine) to address an incompatibility with CAM where state%zm is unavailable (Infinity) in SMS_D_Ld5.f19_f19_mg17.PC4.derecho_intel.cam-cam4_port5d.GC.aux_cam_intel and interpolation to the optional (but unused) argument tropZ would lead to a floating invalid error.

Re-running the tests now to see if tests pass now with this change.

@jimmielin
Copy link
Member Author

Hi @cacraigucar I ran the regression tests with the CCPP-ized tropopause_find. Tests on Izumi NAG match pre-existing failures; GNU all passed as expected. All tests on Derecho match pre-existing failures except for the SMS FCHIST_GC test:

➜  aux_cam_intel_20240925232609 ./cs.status.aux_cam_intel_20240925232609 | testgrep
aux_cam_intel_20240925232609: 63 tests
  ERP_Ln9.f09_f09_mg17.FCSD_HCO.derecho_intel.cam-outfrq9s (Overall: FAIL) details:
    FAIL ERP_Ln9.f09_f09_mg17.FCSD_HCO.derecho_intel.cam-outfrq9s COMPARE_base_rest
  SMS_D_Ln9_P1280x1.ne0CONUSne30x8_ne0CONUSne30x8_mt12.FCHIST.derecho_intel.cam-outfrq9s (Overall: PEND) details:
    PEND SMS_D_Ln9_P1280x1.ne0CONUSne30x8_ne0CONUSne30x8_mt12.FCHIST.derecho_intel.cam-outfrq9s SHAREDLIB_BUILD
  SMS_Ld1.f09_f09_mg17.FCHIST_GC.derecho_intel.cam-outfrq1d (Overall: DIFF) details:
    FAIL SMS_Ld1.f09_f09_mg17.FCHIST_GC.derecho_intel.cam-outfrq1d BASELINE /glade/campaign/cesm/community/amwg/cam_baselines/cam6_4_035_intel: DIFF

Upon further investigation of the FCHIST_GC test output, the results of the FCHIST_GC match the baselines of cam6_4_034_intel (and cam6_4_036_intel) but not cam6_4_035_intel; the cam6_4_035 changelog marks FCHIST_GC as a pre-existing failure but I'm not aware of the SMS test for FCHIST_GC failing before. Maybe there was a machine hiccup when running the cam6_4_035 tests that resulted in a DIFF.

When I ran this only cam6_4_035 was tagged and not cam6_4_036. Given that we will run the regression tests again when merging the CAM PR, and results on cam6_4_035 look as expected, I would suggest we could merge into atmospheric_physics first then run the CAM tests again when ready for a tag?

Thanks!

@jimmielin jimmielin merged commit b8d2539 into ESCOMP:development Sep 30, 2024
1 check passed
jimmielin added a commit that referenced this pull request Sep 30, 2024
Bring in development #108 (TUV-x) #112 (tropopause_find) to main
jimmielin added a commit to ESCOMP/CAM-SIMA that referenced this pull request Oct 7, 2024
Companion PR: ESCOMP/atmospheric_physics#112

Note: I think I brought in more changes than necessary in `ncar_ccpp`
due to the my `atmospheric_physics` branch being based off `development`
rather than the released used in CAM-SIMA. I can do a rebase if
necessary...

## Changes made to support CCPP-ized tropopause_find
* Copied utility module `interpolate_data.F90` from CAM
* Added utility module `tropopause_read_file.F90` to provide
climatological tropopause data to tropopause_find from CAM-SIMA
* `&tropopause_nl tropopause_climo_file` is read from
`tropopause_read_file.F90` inside SIMA and not in the parameterization,
to avoid passing this file name back and forth between the
parameterization to CAM-SIMA
* Adds `get_curr_calday()` result to new standard name variable
`fractional_calendar_days_on_end_of_current_timestep`
* Submodule update (possibly need a rebase?)

I recommend manually merging in the history PR for testing. It might be
easier to merge my branch (`jimmielin:hplin/tropopause_find`) into
`peverwhee:history_court`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Tag
Development

Successfully merging this pull request may close these issues.

3 participants