ESCOMP / atmospheric_physics

CCPP-enabled Atmospheric Physics
Apache License 2.0
4 stars 19 forks source link

Implementation of CCPP-ized tropopause_find #112

Closed jimmielin closed 5 days ago

jimmielin commented 1 month ago

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.

  3. 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.

  4. 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

Outstanding issues/notes

Answer check

For existing CAM

For CAM-SIMA

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.

jimmielin commented 1 month ago

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 ****************
jimmielin commented 1 month ago

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!

jimmielin commented 3 weeks ago

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!

jimmielin commented 2 weeks ago

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

jimmielin commented 1 week ago

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 commented 1 week ago

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!