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

dtend: add missing tendencies and fix bugs in convection tendencies #92

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
branch = gsl/develop
[submodule "ccpp/physics"]
path = ccpp/physics
url = https://github.com/NOAA-GSL/ccpp-physics
branch = gsl/develop
url = https://github.com/SamuelTrahanNOAA/ccpp-physics
branch = bugfix/dtend-man-bugs
95 changes: 61 additions & 34 deletions ccpp/data/GFS_typedefs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@ module GFS_typedefs
real (kind=kind_phys), pointer :: cwm (:,:) => null() !<

!-- 3D diagnostics
integer :: rtg_ozone_index
integer :: rtg_ozone_index, rtg_tke_index

contains
procedure :: create => interstitial_create !< allocate array data
Expand Down Expand Up @@ -3600,7 +3600,7 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
integer :: ncnvcld3d = 0 !< number of convective 3d clouds fields

integer :: itrac, ipat, ichem
logical :: have_pbl, have_dcnv, have_scnv, have_mp, have_oz_phys, have_samf, have_pbl_edmf
logical :: have_pbl, have_dcnv, have_scnv, have_mp, have_oz_phys, have_samf, have_pbl_edmf, have_cnvtrans, have_rdamp
character(len=20) :: namestr
character(len=44) :: descstr

Expand Down Expand Up @@ -4450,14 +4450,21 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &

if(ldiag3d) then
! Flags used to turn on or off tracer "causes"
have_pbl_edmf = Model%hybedmf .or. Model%satmedmf .or. do_mynnedmf
have_pbl_edmf = Model%hybedmf .or. Model%satmedmf .or. Model%do_mynnedmf
have_samf = Model%satmedmf .or. Model%trans_trac .or. Model%ras .or. Model%do_shoc
have_pbl = .true.
have_dcnv = Model%imfdeepcnv>=0 !Model%ras .or. Model%cscnv .or. Model%do_deep .or. Model%hwrf_samfdeep
have_scnv = Model%imfshalcnv>=0 !Model%shal_cnv
have_dcnv = Model%imfdeepcnv>0 !Model%ras .or. Model%cscnv .or. Model%do_deep .or. Model%hwrf_samfdeep
have_scnv = Model%imfshalcnv>0 !Model%shal_cnv
have_mp = Model%imp_physics>0
have_oz_phys = Model%oz_phys .or. Model%oz_phys_2015


! Rayleigh damping flag must match logic in rayleigh_damp.f
have_rdamp = .not. (Model%lsidea .or. Model%ral_ts <= 0.0 .or. Model%prslrd0 == 0.0)

! have_cnvtrans flag must match logic elsewhere in GFS_typedefs and suite interstitials.
have_cnvtrans = (have_dcnv .or. have_scnv) .and. &
(cscnv .or. satmedmf .or. trans_trac .or. ras)

! Increment idtend and fill dtidx:
allocate(Model%dtend_var_labels(Model%ntracp100))
allocate(Model%dtend_process_labels(Model%nprocess))
Expand Down Expand Up @@ -4552,7 +4559,7 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
call fill_dtidx(Model,dtend_select,Model%index_of_temperature,Model%index_of_process_scnv,have_scnv)
call fill_dtidx(Model,dtend_select,Model%index_of_temperature,Model%index_of_process_mp,have_mp)
call fill_dtidx(Model,dtend_select,Model%index_of_temperature,Model%index_of_process_orographic_gwd)
call fill_dtidx(Model,dtend_select,Model%index_of_temperature,Model%index_of_process_rayleigh_damping)
call fill_dtidx(Model,dtend_select,Model%index_of_temperature,Model%index_of_process_rayleigh_damping,have_rdamp)
call fill_dtidx(Model,dtend_select,Model%index_of_temperature,Model%index_of_process_nonorographic_gwd)
call fill_dtidx(Model,dtend_select,Model%index_of_temperature,Model%index_of_process_physics)
call fill_dtidx(Model,dtend_select,Model%index_of_temperature,Model%index_of_process_non_physics)
Expand All @@ -4565,8 +4572,8 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
call fill_dtidx(Model,dtend_select,Model%index_of_y_wind,Model%index_of_process_dcnv,have_dcnv)
call fill_dtidx(Model,dtend_select,Model%index_of_x_wind,Model%index_of_process_nonorographic_gwd)
call fill_dtidx(Model,dtend_select,Model%index_of_y_wind,Model%index_of_process_nonorographic_gwd)
call fill_dtidx(Model,dtend_select,Model%index_of_x_wind,Model%index_of_process_rayleigh_damping)
call fill_dtidx(Model,dtend_select,Model%index_of_y_wind,Model%index_of_process_rayleigh_damping)
call fill_dtidx(Model,dtend_select,Model%index_of_x_wind,Model%index_of_process_rayleigh_damping,have_rdamp)
call fill_dtidx(Model,dtend_select,Model%index_of_y_wind,Model%index_of_process_rayleigh_damping,have_rdamp)
call fill_dtidx(Model,dtend_select,Model%index_of_x_wind,Model%index_of_process_scnv,have_scnv)
call fill_dtidx(Model,dtend_select,Model%index_of_y_wind,Model%index_of_process_scnv,have_scnv)
call fill_dtidx(Model,dtend_select,Model%index_of_x_wind,Model%index_of_process_physics)
Expand All @@ -4575,25 +4582,30 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
call fill_dtidx(Model,dtend_select,Model%index_of_y_wind,Model%index_of_process_non_physics)

if(qdiag3d) then
if(have_samf) then
do itrac=1,Model%ntrac
if(itrac==Model%ntchs) exit ! remaining tracers are chemical
if(itrac==Model%ntke) cycle ! TKE is handled by convective transport (see below)
call fill_dtidx(Model,dtend_select,100+itrac,Model%index_of_process_dcnv,have_dcnv)
call fill_dtidx(Model,dtend_select,100+itrac,Model%index_of_process_scnv,have_scnv)
enddo
else
call fill_dtidx(Model,dtend_select,100+Model%ntqv,Model%index_of_process_dcnv,have_dcnv)
call fill_dtidx(Model,dtend_select,100+Model%ntqv,Model%index_of_process_scnv,have_scnv)
call fill_dtidx(Model,dtend_select,100+Model%ntcw,Model%index_of_process_dcnv,have_dcnv)
call fill_dtidx(Model,dtend_select,100+Model%ntcw,Model%index_of_process_scnv,have_scnv)
call fill_dtidx(Model,dtend_select,100+Model%ntiw,Model%index_of_process_dcnv,have_dcnv)
call fill_dtidx(Model,dtend_select,100+Model%ntiw,Model%index_of_process_scnv,have_scnv)
call fill_dtidx(Model,dtend_select,100+Model%ntqv,Model%index_of_process_scnv,have_scnv)
call fill_dtidx(Model,dtend_select,100+Model%ntqv,Model%index_of_process_dcnv,have_dcnv)

if(have_cnvtrans) then
do itrac=2,Model%ntrac
if(itrac==Model%ntchs) exit ! remaining tracers are chemical
if ( itrac /= Model%ntcw .and. itrac /= Model%ntiw .and. itrac /= Model%ntclamt .and. &
itrac /= Model%ntrw .and. itrac /= Model%ntsw .and. itrac /= Model%ntrnc .and. &
itrac /= Model%ntsnc .and. itrac /= Model%ntgl .and. itrac /= Model%ntgnc) then
call fill_dtidx(Model,dtend_select,100+itrac,Model%index_of_process_scnv,have_scnv)
call fill_dtidx(Model,dtend_select,100+itrac,Model%index_of_process_dcnv,have_dcnv)
else if(Model%ntchs<=0 .or. itrac<Model%ntchs) then
call fill_dtidx(Model,dtend_select,100+itrac,Model%index_of_process_conv_trans)
endif
enddo
else if(have_scnv .or. have_dcnv) then
do itrac=2,Model%ntrac
if(itrac==Model%ntchs) exit ! remaining tracers are chemical
call fill_dtidx(Model,dtend_select,100+itrac,Model%index_of_process_scnv,have_scnv)
call fill_dtidx(Model,dtend_select,100+itrac,Model%index_of_process_dcnv,have_dcnv)
enddo
endif
call fill_dtidx(Model,dtend_select,100+Model%ntke,Model%index_of_process_conv_trans,have_scnv.or.have_dcnv)
call fill_dtidx(Model,dtend_select,100+Model%ntclamt,Model%index_of_process_conv_trans,have_scnv.or.have_dcnv)

call fill_dtidx(Model,dtend_select,100+Model%ntoz,Model%index_of_process_pbl,have_pbl .and. have_oz_phys)
call fill_dtidx(Model,dtend_select,100+Model%ntoz,Model%index_of_process_pbl,have_pbl)
call fill_dtidx(Model,dtend_select,100+Model%ntoz,Model%index_of_process_prod_loss,have_oz_phys)
call fill_dtidx(Model,dtend_select,100+Model%ntoz,Model%index_of_process_ozmix,have_oz_phys)
call fill_dtidx(Model,dtend_select,100+Model%ntoz,Model%index_of_process_temp,have_oz_phys)
Expand All @@ -4612,12 +4624,14 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
do itrac=1,Model%ntrac
if(itrac==Model%ntchs) exit ! remaining tracers are chemical
if(itrac==Model%ntoz) cycle ! already took care of ozone
call fill_dtidx(Model,dtend_select,100+itrac,Model%index_of_process_mp,have_mp)
if(have_pbl_edmf) then
if(Model%do_mynnedmf .or. Model%satmedmf) then
call fill_dtidx(Model,dtend_select,100+itrac,Model%index_of_process_pbl,have_pbl)
endif
call fill_dtidx(Model,dtend_select,100+itrac,Model%index_of_process_physics,.true.)
call fill_dtidx(Model,dtend_select,100+itrac,Model%index_of_process_non_physics,.true.)
if(itrac/=Model%ntke) then
call fill_dtidx(Model,dtend_select,100+itrac,Model%index_of_process_mp,have_mp)
endif
enddo
endif
end if
Expand Down Expand Up @@ -5963,20 +5977,33 @@ subroutine fill_dtidx(Model,dtend_select,itrac,icause,flag)
logical, intent(in), optional :: flag

character(len=100) :: name
logical :: flag2

flag2=.true.
if(present(flag)) flag2=flag
if(present(flag)) then
if(.not. flag) return
endif

if(icause>0 .and. itrac>0) then
if(Model%dtidx(itrac,icause)>0) then
return ! This tendency is already allocated.
endif

if(icause>0 .and. flag2 .and. itrac>0) then
name = 'dtend_'//trim(Model%dtend_var_labels(itrac)%name)//'_'//trim(Model%dtend_process_labels(icause)%name)

if(fglob_list(dtend_select,trim(name))) then
Model%ndtend = Model%ndtend+1
Model%dtidx(itrac,icause) = Model%ndtend
if(Model%me==Model%master) then
print 308,'selected',trim(Model%dtend_process_labels(icause)%mod_name), trim(name), &
trim(Model%dtend_var_labels(itrac)%desc), trim(Model%dtend_process_labels(icause)%desc), &
trim(Model%dtend_var_labels(itrac)%unit)
endif
elseif(Model%me==Model%master) then
print '(A,A,A)','Skipping ',trim(name),' due to mismatch with dtend_select.'
print 308,'disabled',trim(Model%dtend_process_labels(icause)%mod_name), trim(name), &
trim(Model%dtend_var_labels(itrac)%desc), trim(Model%dtend_process_labels(icause)%desc), &
trim(Model%dtend_var_labels(itrac)%unit)
endif
endif
308 format('dtend ',A,': ',A,' ',A,' = ',A,' ',A,' (',A,')')
end subroutine fill_dtidx

recursive function fglob(pattern,string) result(match)
Expand Down Expand Up @@ -6006,7 +6033,7 @@ recursive function fglob(pattern,string) result(match)
istr=1 ! First string character not yet matched
outer: do while(ipat<=npat)
if_glob: if(pattern(ipat:ipat)=='*' .or. pattern(ipat:ipat)=='?') then
! Collect sequences of * and ? to avoid pathalogical cases.
! Collect sequences of * and ? to avoid pathological cases.
min_match=0 ! Number of "?" which is minimum number of chars to match
match_infinity=.false. ! Do we see a "*"?
glob_collect: do while(ipat<=npat)
Expand Down
21 changes: 21 additions & 0 deletions ccpp/data/GFS_typedefs.meta
Original file line number Diff line number Diff line change
Expand Up @@ -9261,6 +9261,13 @@
dimensions = (horizontal_loop_extent,vertical_dimension)
type = real
kind = kind_phys
[save_q(:,:,index_for_turbulent_kinetic_energy)]
standard_name = turbulent_kinetic_energy_save
long_name = turbulent kinetic energy before entering a physics scheme
units = kg kg-1
dimensions = (horizontal_loop_extent,vertical_dimension)
type = real
kind = kind_phys
[save_q(:,:,index_for_liquid_cloud_condensate)]
standard_name = cloud_condensed_water_mixing_ratio_save
long_name = ratio of mass of cloud water to mass of dry air plus vapor (without condensates) before entering a physics scheme
Expand All @@ -9282,6 +9289,20 @@
dimensions = (horizontal_loop_extent,vertical_dimension)
type = real
kind = kind_phys
[save_q(:,:,index_for_liquid_cloud_number_concentration)]
standard_name = liquid_cloud_number_concentration_save
long_name = liquid cloud number concentration before entering a physics scheme
units = kg kg-1
dimensions = (horizontal_loop_extent,vertical_dimension)
type = real
kind = kind_phys
[save_q(:,:,index_for_ice_cloud_number_concentration)]
standard_name = ice_cloud_number_concentration_save
long_name = ice cloud number concentration before entering a physics scheme
units = kg kg-1
dimensions = (horizontal_loop_extent,vertical_dimension)
type = real
kind = kind_phys
[save_q]
standard_name = tracer_concentration_save
long_name = tracer concentration before entering a physics scheme
Expand Down
4 changes: 0 additions & 4 deletions ccpp/driver/GFS_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ subroutine add_dtend(Model,ExtDiag,IntDiag,idx,nblks,itrac,iprocess,desc,unit)
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var3 => IntDiag(nb)%dtend(:,:,idtend)
enddo
if(Model%me==Model%master .and. Model%ldiag3d) then
307 format('ExtDiag(',I4,') = dtend(:,:,',I4,') = ',A,' (',A,': ',A,')')
print 307,idx,idtend,trim(ExtDiag(idx)%name),trim(ExtDiag(idx)%mod_name),trim(ExtDiag(idx)%desc)
endif
endif
end subroutine add_dtend

Expand Down
1 change: 1 addition & 0 deletions ccpp/suites/suite_FV3_GSD_SAR.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<group name="stochastics">
<subcycle loop="1">
<scheme>GFS_stochastics</scheme>
<scheme>phys_tend</scheme>
</subcycle>
</group>
<!-- <finalize></finalize> -->
Expand Down
1 change: 1 addition & 0 deletions ccpp/suites/suite_FV3_HRRR.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<group name="stochastics">
<subcycle loop="1">
<scheme>GFS_stochastics</scheme>
<scheme>phys_tend</scheme>
</subcycle>
</group>
<!-- <finalize></finalize> -->
Expand Down
1 change: 1 addition & 0 deletions ccpp/suites/suite_FV3_RAP.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<group name="stochastics">
<subcycle loop="1">
<scheme>GFS_stochastics</scheme>
<scheme>phys_tend</scheme>
</subcycle>
</group>
<!-- <finalize></finalize> -->
Expand Down