NCAR / ccpp-framework

Common Community Physics Package (CCPP)
http://www.dtcenter.org/community-code/common-community-physics-package-ccpp/
Other
26 stars 63 forks source link

Bug fix and improvement for ccpp_track_variables tool #451

Closed mkavulich closed 2 years ago

mkavulich commented 2 years ago

This PR changes the output slightly, so that the ordered lists of schemes are now broken down by group. This is done because different groups in a physics suite can be called in different orders depending on the logic of the host model, so only within each group is a set of schemes guaranteed to be called in that order.

This PR also fixes a bug in ccpp_track_variables.py that double-counted variables in schemes that have .meta files containing descriptions of more than one scheme.

Finally, this PR has some small improvements suggested by pylint, including removing trailing whitespace and trimming long lines.

Cases with partial matches or no matches found will not be affected by this change.

User interface changes?: No

Fixes: #450 (duplicate counting of schemes)

Testing: Ran script against multiple xmls and confirmed new behavior removes duplicate schemes in script output. Also output is now broken down by group.

Here is an example of old output vs new:

Old

framework/scripts/ccpp_track_variables.py --config=config/ccpp_prebuild_config.py -s=suites/suite_FV3_GFS_v16_noahmp.xml -v air_temperature_of_new_state -m ./physics/physics/
WARNING:root:Encountered closing statement "end type" without type name; assume type_name is ty_gas_optics_rrtmgp
WARNING:root:Encountered closing statement "end type" without type name; assume type_name is ty_optical_props
WARNING:root:Encountered closing statement "end type" without type name; assume type_name is ty_optical_props_arry
WARNING:root:Encountered closing statement "end type" without type name; assume type_name is ty_optical_props_1scl
WARNING:root:Encountered closing statement "end type" without type name; assume type_name is ty_optical_props_2str
WARNING:root:Encountered closing statement "end type" without type name; assume type_name is ty_optical_props_nstr
For suite suites/suite_FV3_GFS_v16_noahmp.xml, the following schemes (in order) use the variable air_temperature_of_new_state:
GFS_suite_stateout_reset_run (intent out)
GFS_suite_stateout_update_run (intent out)
GFS_suite_interstitial_3_run (intent in)
GFS_suite_stateout_reset_run (intent out)
GFS_suite_stateout_update_run (intent out)
GFS_suite_interstitial_3_run (intent in)
GFS_suite_stateout_reset_run (intent out)
GFS_suite_stateout_update_run (intent out)
GFS_suite_interstitial_3_run (intent in)
get_phi_fv3_run (intent in)
GFS_suite_stateout_reset_run (intent out)
GFS_suite_stateout_update_run (intent out)
GFS_suite_interstitial_3_run (intent in)
dcyc2t3_run (intent in)
GFS_suite_stateout_reset_run (intent out)
GFS_suite_stateout_update_run (intent out)
GFS_suite_interstitial_3_run (intent in)
GFS_suite_stateout_reset_run (intent out)
GFS_suite_stateout_update_run (intent out)
GFS_suite_interstitial_3_run (intent in)
ozphys_2015_run (intent in)
get_phi_fv3_run (intent in)
GFS_suite_stateout_reset_run (intent out)
GFS_suite_stateout_update_run (intent out)
GFS_suite_interstitial_3_run (intent in)
GFS_DCNV_generic_pre_run (intent in)
GFS_DCNV_generic_post_run (intent in)
samfdeepcnv_run (intent inout)
GFS_DCNV_generic_pre_run (intent in)
GFS_DCNV_generic_post_run (intent in)
GFS_SCNV_generic_pre_run (intent in)
GFS_SCNV_generic_post_run (intent in)
samfshalcnv_run (intent inout)
GFS_SCNV_generic_pre_run (intent in)
GFS_SCNV_generic_post_run (intent in)
GFS_suite_stateout_reset_run (intent out)
GFS_suite_stateout_update_run (intent out)
GFS_suite_interstitial_3_run (intent in)
GFS_MP_generic_pre_run (intent in)
GFS_MP_generic_post_run (intent in)
gfdl_cloud_microphys_run (intent inout)
GFS_MP_generic_pre_run (intent in)
GFS_MP_generic_post_run (intent in)
maximum_hourly_diagnostics_run (intent in)
GFS_stochastics_run (intent inout)

New

framework/scripts/ccpp_track_variables.py --config=config/ccpp_prebuild_config.py -s=suites/suite_FV3_GFS_v16_noahmp.xml -v air_temperature_of_new_state -m ./physics/physics/
WARNING:root:Encountered closing statement "end type" without type name; assume type_name is ty_gas_optics_rrtmgp
WARNING:root:Encountered closing statement "end type" without type name; assume type_name is ty_optical_props
WARNING:root:Encountered closing statement "end type" without type name; assume type_name is ty_optical_props_arry
WARNING:root:Encountered closing statement "end type" without type name; assume type_name is ty_optical_props_1scl
WARNING:root:Encountered closing statement "end type" without type name; assume type_name is ty_optical_props_2str
WARNING:root:Encountered closing statement "end type" without type name; assume type_name is ty_optical_props_nstr
For suite suites/suite_FV3_GFS_v16_noahmp.xml, the following schemes (in order for each group) use the variable air_temperature_of_new_state:
In group physics
  GFS_suite_stateout_reset_run (intent out)
  dcyc2t3_run (intent in)
  GFS_suite_stateout_update_run (intent out)
  ozphys_2015_run (intent in)
  get_phi_fv3_run (intent in)
  GFS_suite_interstitial_3_run (intent in)
  GFS_DCNV_generic_pre_run (intent in)
  samfdeepcnv_run (intent inout)
  GFS_DCNV_generic_post_run (intent in)
  GFS_SCNV_generic_pre_run (intent in)
  samfshalcnv_run (intent inout)
  GFS_SCNV_generic_post_run (intent in)
  GFS_MP_generic_pre_run (intent in)
  gfdl_cloud_microphys_run (intent inout)
  GFS_MP_generic_post_run (intent in)
  maximum_hourly_diagnostics_run (intent in)
In group stochastics
  GFS_stochastics_run (intent inout)