From 180ff4da213ca218cb702cfaf14da997f46e30f9 Mon Sep 17 00:00:00 2001 From: Brian Eaton Date: Fri, 9 Aug 2024 10:16:37 -0400 Subject: [PATCH] fix issue #1108 --- bld/build-namelist | 16 +++++++--- doc/ChangeLog | 62 +++++++++++++++++++++++++++++++++++++ src/physics/cam/gw_drag.F90 | 8 ++++- 3 files changed, 80 insertions(+), 6 deletions(-) diff --git a/bld/build-namelist b/bld/build-namelist index 7a5c8c1132..61b912c29d 100755 --- a/bld/build-namelist +++ b/bld/build-namelist @@ -3187,9 +3187,10 @@ if (($chem ne 'none') and ($chem ne 'terminator') and !($chem =~ /geoschem/)) { # Deep convection scheme add_default($nl, 'deep_scheme'); +my $deep_scheme = $nl->get_value('deep_scheme'); # Aerosol convective processes -if (($phys =~ /cam6/ or $phys =~ /cam7/) and $nl->get_value('deep_scheme') =~ /ZM/) { +if (($phys =~ /cam6/ or $phys =~ /cam7/) and $deep_scheme =~ /ZM/) { add_default($nl, 'convproc_do_aer', 'val'=>'.true.'); add_default($nl, 'convproc_do_evaprain_atonce', 'val'=>'.true.'); add_default($nl, 'convproc_pom_spechygro', 'val'=>'0.2D0'); @@ -3197,7 +3198,7 @@ if (($phys =~ /cam6/ or $phys =~ /cam7/) and $nl->get_value('deep_scheme') =~ /Z } # cam7 specific namelists -if ($phys =~ /cam7/ and $nl->get_value('deep_scheme') =~ /ZM/) { +if ($phys =~ /cam7/ and $deep_scheme =~ /ZM/) { add_default($nl, 'zmconv_parcel_pbl', 'val'=>'.true.'); } else { add_default($nl, 'zmconv_parcel_pbl', 'val'=>'.false.'); @@ -3791,12 +3792,13 @@ if (!$simple_phys) { add_default($nl, 'gw_rdg_do_divstream' , 'val'=>'.true.'); } +my $use_gw_convect_dp = '.false.'; if ($waccm_phys or (!$simple_phys and $cfg->get('model_top') eq 'mt')) { # Spectral gravity waves are part of WACCM physics, and also drive the # QBO in the high vertical resolution configuration. add_default($nl, 'use_gw_front' , 'val'=>'.true.'); - add_default($nl, 'use_gw_convect_dp', 'val'=>'.true.'); + $use_gw_convect_dp = '.true.'; my $hdepth_scaling = '0.25D0' ; my $qbo_forcing = '.false.'; if ($dyn eq 'fv') { @@ -3818,12 +3820,16 @@ if ($waccm_phys or } elsif ($phys =~ /cam7/) { # cam7 settings for model_top = 'lt' add_default($nl, 'use_gw_front' , 'val'=>'.true.'); - add_default($nl, 'use_gw_convect_dp', 'val'=>'.true.'); + $use_gw_convect_dp = '.true.'; add_default($nl, 'gw_qbo_hdepth_scaling', 'val'=>'1.0D0'); } else { add_default($nl, 'use_gw_front' , 'val'=>'.false.'); - add_default($nl, 'use_gw_convect_dp', 'val'=>'.false.'); } +# Check if deep convection scheme used. If not set use_gw_convect_dp=.false. +if ($deep_scheme =~ /off/) { + $use_gw_convect_dp = '.false.'; +} +add_default($nl, 'use_gw_convect_dp', 'val'=>$use_gw_convect_dp); # We need a lot of logic to use these below, so make flags for them. my $do_gw_oro = ($nl->get_value('use_gw_oro') =~ /$TRUE/io); diff --git a/doc/ChangeLog b/doc/ChangeLog index 93142a1a4a..e3751184bd 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,67 @@ =============================================================== +Tag name: +Originator(s): eaton +Date: +One-line Summary: fix issues #1108, +Github PR URL: + +Purpose of changes (include the issue number and title text for each relevant GitHub issue): + +Issue #1108 - More robust logic in gw_drag.F90 when deep_scheme='off' +- Modify build-namelist to set use_gw_convect_dp=.false. when + deep_scheme='off'. In gw_drag::gw_tend check whether field TTEND_DP is + in the pbuf. If so then associate the ttend_dp pointer. If not then + allocate the ttend_dp pointer and set to zero. + + + +Describe any changes made to build system: + +Describe any changes made to the namelist: +. build-namelist now sets use_gw_convect_dp=.false. when deep_scheme='off'. + +List any changes to the defaults for the boundary datasets: + +Describe any substantial timing or memory changes: + +Code reviewed by: + +List all files eliminated: + +List all files added and what they do: + +List all existing files that have been modified, and describe the changes: + +bld/build-namelist +. add check to set use_gw_convect_dp=.false. when deep_scheme='off'. + +src/physics/cam/gw_drag.F90 +. check that field TTEND_DP is in the pbuf before trying to associate the + pointer ttend_dp. If TTEND_DP is not in pbuf then allocate the ttend_dp + pointer and fill with zeros. + + + +If there were any failures reported from running test_driver.sh on any test +platform, and checkin with these failures has been OK'd by the gatekeeper, +then copy the lines from the td.*.status files for the failed tests to the +appropriate machine below. All failed tests must be justified. + +derecho/intel/aux_cam: + +izumi/nag/aux_cam: + +izumi/gnu/aux_cam: + +CAM tag used for the baseline comparison tests if different than previous +tag: + +Summarize any changes to answers: + +=============================================================== +=============================================================== + Tag name: cam6_4_018 Originator(s): peverwhee, jedwards4b Date: 30 July 2024 diff --git a/src/physics/cam/gw_drag.F90 b/src/physics/cam/gw_drag.F90 index aeab27a5c6..e861d2173e 100644 --- a/src/physics/cam/gw_drag.F90 +++ b/src/physics/cam/gw_drag.F90 @@ -1716,7 +1716,13 @@ subroutine gw_tend(state, pbuf, dt, ptend, cam_in, flx_heat) call alloc_err(istat,'gw_tend','phase_speeds',ncol*band_movmtn%ngwv**2+1) ! Set up heating - call pbuf_get_field(pbuf, ttend_dp_idx, ttend_dp) + if (ttend_dp_idx > 0) then + call pbuf_get_field(pbuf, ttend_dp_idx, ttend_dp) + else + allocate(ttend_dp(pcols,pver), stat=istat) + call alloc_err(istat, 'gw_tend', 'ttend_dp', pcols*pver) + ttend_dp = 0.0_r8 + end if ! New couplings from CLUBB call pbuf_get_field(pbuf, ttend_clubb_idx, ttend_clubb)