Skip to content

Commit

Permalink
Merge pull request NCAR#21 from climbfuji/tendencies_sam_with_dom_mods
Browse files Browse the repository at this point in the history
Bug fixes to 3D diagnostic tendencies (based on NCAR#18)
  • Loading branch information
DomHeinzeller authored Apr 22, 2020
2 parents fadc3cd + 43f107c commit 314c5f5
Show file tree
Hide file tree
Showing 30 changed files with 1,553 additions and 149 deletions.
23 changes: 15 additions & 8 deletions physics/GFS_DCNV_generic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ end subroutine GFS_DCNV_generic_pre_finalize
!! \htmlinclude GFS_DCNV_generic_pre_run.html
!!
#endif
subroutine GFS_DCNV_generic_pre_run (im, levs, ldiag3d, do_cnvgwd, do_ca, cplchm,&
subroutine GFS_DCNV_generic_pre_run (im, levs, ldiag3d, qdiag3d, do_cnvgwd, do_ca, cplchm,&
isppt_deep, gu0, gv0, gt0, gq0_water_vapor, &
save_u, save_v, save_t, save_qv, ca_deep, &
dqdti, errmsg, errflg)
Expand All @@ -27,7 +27,7 @@ subroutine GFS_DCNV_generic_pre_run (im, levs, ldiag3d, do_cnvgwd, do_ca, cplchm
implicit none

integer, intent(in) :: im, levs
logical, intent(in) :: ldiag3d, do_cnvgwd, do_ca, cplchm, isppt_deep
logical, intent(in) :: ldiag3d, do_cnvgwd, do_ca, cplchm, isppt_deep, qdiag3d
real(kind=kind_phys), dimension(im,levs), intent(in) :: gu0
real(kind=kind_phys), dimension(im,levs), intent(in) :: gv0
real(kind=kind_phys), dimension(im,levs), intent(in) :: gt0
Expand Down Expand Up @@ -73,7 +73,7 @@ subroutine GFS_DCNV_generic_pre_run (im, levs, ldiag3d, do_cnvgwd, do_ca, cplchm
enddo
endif

if (ldiag3d .or. cplchm .or. isppt_deep) then
if ((ldiag3d.and.qdiag3d) .or. cplchm .or. isppt_deep) then
do k=1,levs
do i=1,im
save_qv(i,k) = gq0_water_vapor(i,k)
Expand Down Expand Up @@ -102,19 +102,20 @@ end subroutine GFS_DCNV_generic_post_finalize
!> \section arg_table_GFS_DCNV_generic_post_run Argument Table
!! \htmlinclude GFS_DCNV_generic_post_run.html
!!
subroutine GFS_DCNV_generic_post_run (im, levs, lssav, ldiag3d, ras, cscnv, do_ca, &
subroutine GFS_DCNV_generic_post_run (im, levs, lssav, ldiag3d, qdiag3d, ras, cscnv, do_ca, &
isppt_deep, frain, rain1, dtf, cld1d, save_u, save_v, save_t, save_qv, gu0, gv0, gt0, &
gq0_water_vapor, ud_mf, dd_mf, dt_mf, con_g, clw_ice, clw_liquid, npdf3d, num_p3d, ncnvcld3d, &
rainc, cldwrk, dt3dt, dq3dt, du3dt, dv3dt, upd_mf, dwn_mf, det_mf, &
cnvw, cnvc, cnvw_phy_f3d, cnvc_phy_f3d, &
cnvw, cnvc, cnvw_phy_f3d, cnvc_phy_f3d, flag_for_dcnv_generic_tend, &
cape, tconvtend, qconvtend, uconvtend, vconvtend, errmsg, errflg)

use machine, only: kind_phys

implicit none

integer, intent(in) :: im, levs
logical, intent(in) :: lssav, ldiag3d, ras, cscnv, do_ca, isppt_deep
logical, intent(in) :: lssav, ldiag3d, ras, cscnv, do_ca, isppt_deep, qdiag3d
logical, intent(in) :: flag_for_dcnv_generic_tend

real(kind=kind_phys), intent(in) :: frain, dtf
real(kind=kind_phys), dimension(im), intent(in) :: rain1, cld1d
Expand Down Expand Up @@ -182,11 +183,10 @@ subroutine GFS_DCNV_generic_post_run (im, levs, lssav, ldiag3d, ras, cscnv, do_c
cldwrk (i) = cldwrk (i) + cld1d(i) * dtf
enddo

if (ldiag3d) then
if (ldiag3d .and. flag_for_dcnv_generic_tend) then
do k=1,levs
do i=1,im
dt3dt(i,k) = dt3dt(i,k) + (gt0(i,k)-save_t(i,k)) * frain
! dq3dt(i,k) = dq3dt(i,k) + (gq0_water_vapor(i,k)-save_qv(i,k)) * frain
du3dt(i,k) = du3dt(i,k) + (gu0(i,k)-save_u(i,k)) * frain
dv3dt(i,k) = dv3dt(i,k) + (gv0(i,k)-save_v(i,k)) * frain

Expand All @@ -195,6 +195,13 @@ subroutine GFS_DCNV_generic_post_run (im, levs, lssav, ldiag3d, ras, cscnv, do_c
! det_mf(i,k) = det_mf(i,k) + dt_mf(i,k) * (con_g*frain)
enddo
enddo
if(qdiag3d) then
do k=1,levs
do i=1,im
dq3dt(i,k) = dq3dt(i,k) + (gq0_water_vapor(i,k)-save_qv(i,k)) * frain
enddo
enddo
endif
endif ! if (ldiag3d)

endif ! if (lssav)
Expand Down
23 changes: 23 additions & 0 deletions physics/GFS_DCNV_generic.meta
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
type = logical
intent = in
optional = F
[qdiag3d]
standard_name = flag_tracer_diagnostics_3D
long_name = flag for 3d tracer diagnostic fields
units = flag
dimensions = ()
type = logical
intent = in
optional = F
[do_cnvgwd]
standard_name = flag_for_convective_gravity_wave_drag
long_name = flag for convective gravity wave drag (gwd)
Expand Down Expand Up @@ -201,6 +209,14 @@
type = logical
intent = in
optional = F
[qdiag3d]
standard_name = flag_tracer_diagnostics_3D
long_name = flag for 3d tracer diagnostic fields
units = flag
dimensions = ()
type = logical
intent = in
optional = F
[ras]
standard_name = flag_for_ras_deep_convection
long_name = flag for ras convection scheme
Expand Down Expand Up @@ -545,6 +561,13 @@
kind = kind_phys
intent = inout
optional = F
[flag_for_dcnv_generic_tend]
standard_name = flag_for_generic_deep_convection_tendency
long_name = true if GFS_DCNV_generic should calculate tendencies
units = flag
dimensions = ()
type = logical
intent = in
[tconvtend]
standard_name = tendency_of_air_temperature_due_to_deep_convection_for_coupling_on_physics_timestep
long_name = tendency of air temperature due to deep convection
Expand Down
19 changes: 11 additions & 8 deletions physics/GFS_GWD_generic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ subroutine GFS_GWD_generic_pre_run( &
& im, levs, nmtvr, mntvar, &
& oc, oa4, clx, theta, &
& sigma, gamma, elvmax, lssav, ldiag3d, &
& dtdt, dt3dt, dtf, errmsg, errflg)
& dudt, dvdt, dtdt, du3dt, dv3dt, dt3dt, dtf, &
& flag_for_gwd_generic_tend, errmsg, errflg)

use machine, only : kind_phys
implicit none
Expand All @@ -31,10 +32,10 @@ subroutine GFS_GWD_generic_pre_run( &
& oc(im), oa4(im,4), clx(im,4), &
& theta(im), sigma(im), gamma(im), elvmax(im)

logical, intent(in) :: lssav, ldiag3d
real(kind=kind_phys), intent(in) :: dtdt(im,levs)
logical, intent(in) :: lssav, ldiag3d, flag_for_gwd_generic_tend
real(kind=kind_phys), intent(in) :: dtdt(im,levs), dudt(im,levs), dvdt(im,levs)
! dt3dt only allocated only if ldiag3d is .true.
real(kind=kind_phys), intent(inout) :: dt3dt(:,:)
real(kind=kind_phys), intent(inout) :: dt3dt(:,:), du3dt(:,:), dv3dt(:,:)
real(kind=kind_phys), intent(in) :: dtf

character(len=*), intent(out) :: errmsg
Expand Down Expand Up @@ -91,10 +92,12 @@ subroutine GFS_GWD_generic_pre_run( &
endif ! end if_nmtvr

if (lssav) then
if (ldiag3d) then
if (ldiag3d .and. flag_for_gwd_generic_tend) then
do k=1,levs
do i=1,im
dt3dt(i,k) = dt3dt(i,k) - dtdt(i,k)*dtf
du3dt(i,k) = du3dt(i,k) - dudt(i,k)*dtf
dv3dt(i,k) = dv3dt(i,k) - dvdt(i,k)*dtf
enddo
enddo
endif
Expand Down Expand Up @@ -125,12 +128,12 @@ end subroutine GFS_GWD_generic_post_init
!! \section detailed Detailed Algorithm
!! @{
subroutine GFS_GWD_generic_post_run(lssav, ldiag3d, dtf, dusfcg, dvsfcg, dudt, dvdt, dtdt, &
& dugwd, dvgwd, du3dt, dv3dt, dt3dt, errmsg, errflg)
& dugwd, dvgwd, du3dt, dv3dt, dt3dt, flag_for_gwd_generic_tend, errmsg, errflg)

use machine, only : kind_phys
implicit none

logical, intent(in) :: lssav, ldiag3d
logical, intent(in) :: lssav, ldiag3d, flag_for_gwd_generic_tend

real(kind=kind_phys), intent(in) :: dusfcg(:), dvsfcg(:)
real(kind=kind_phys), intent(in) :: dudt(:,:), dvdt(:,:), dtdt(:,:)
Expand All @@ -150,7 +153,7 @@ subroutine GFS_GWD_generic_post_run(lssav, ldiag3d, dtf, dusfcg, dvsfcg, dudt, d
dugwd(:) = dugwd(:) + dusfcg(:)*dtf
dvgwd(:) = dvgwd(:) + dvsfcg(:)*dtf

if (ldiag3d) then
if (ldiag3d .and. flag_for_gwd_generic_tend) then
du3dt(:,:) = du3dt(:,:) + dudt(:,:) * dtf
dv3dt(:,:) = dv3dt(:,:) + dvdt(:,:) * dtf
dt3dt(:,:) = dt3dt(:,:) + dtdt(:,:) * dtf
Expand Down
45 changes: 45 additions & 0 deletions physics/GFS_GWD_generic.meta
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@
type = logical
intent = in
optional = F
[dudt]
standard_name = tendency_of_x_wind_due_to_model_physics
long_name = zonal wind tendency due to model physics
units = m s-2
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = inout
[dvdt]
standard_name = tendency_of_y_wind_due_to_model_physics
long_name = meridional wind tendency due to model physics
units = m s-2
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = inout
[dtdt]
standard_name = tendency_of_air_temperature_due_to_model_physics
long_name = updated tendency of the temperature
Expand All @@ -127,6 +143,22 @@
kind = kind_phys
intent = in
optional = F
[du3dt]
standard_name = cumulative_change_in_x_wind_due_to_orographic_gravity_wave_drag
long_name = cumulative change in x wind due to orographic gravity wave drag
units = m s-1
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = inout
[dv3dt]
standard_name = cumulative_change_in_y_wind_due_to_orographic_gravity_wave_drag
long_name = cumulative change in y wind due to orographic gravity wave drag
units = m s-1
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = inout
[dt3dt]
standard_name = cumulative_change_in_temperature_due_to_orographic_gravity_wave_drag
long_name = cumulative change in temperature due to orographic gravity wave drag
Expand All @@ -145,6 +177,13 @@
kind = kind_phys
intent = in
optional = F
[flag_for_gwd_generic_tend]
standard_name = flag_for_generic_gravity_wave_drag_tendency
long_name = true if GFS_GWD_generic should calculate tendencies
units = flag
dimensions = ()
type = logical
intent = in
[errmsg]
standard_name = ccpp_error_message
long_name = error message for error handling in CCPP
Expand Down Expand Up @@ -287,6 +326,12 @@
kind = kind_phys
intent = inout
optional = F
[flag_for_gwd_generic_tend]
standard_name = flag_for_generic_gravity_wave_drag_tendency
long_name = true if GFS_GWD_generic should calculate tendencies
units = flag
dimensions = ()
type = logical
[errmsg]
standard_name = ccpp_error_message
long_name = error message for error handling in CCPP
Expand Down
43 changes: 31 additions & 12 deletions physics/GFS_MP_generic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ end subroutine GFS_MP_generic_pre_init
!> \section arg_table_GFS_MP_generic_pre_run Argument Table
!! \htmlinclude GFS_MP_generic_pre_run.html
!!
subroutine GFS_MP_generic_pre_run(im, levs, ldiag3d, do_aw, ntcw, nncl, ntrac, gt0, gq0, save_t, save_q, errmsg, errflg)
subroutine GFS_MP_generic_pre_run(im, levs, ldiag3d, qdiag3d, do_aw, ntcw, nncl, ntrac, gt0, gq0, save_t, save_qv, save_q, errmsg, errflg)
!
use machine, only: kind_phys

implicit none
integer, intent(in) :: im, levs, ntcw, nncl, ntrac
logical, intent(in) :: ldiag3d, do_aw
logical, intent(in) :: ldiag3d, qdiag3d, do_aw
real(kind=kind_phys), dimension(im, levs), intent(in) :: gt0
real(kind=kind_phys), dimension(im, levs, ntrac), intent(in) :: gq0

real(kind=kind_phys), dimension(im, levs), intent(inout) :: save_t
real(kind=kind_phys), dimension(im, levs), intent(inout) :: save_t, save_qv
real(kind=kind_phys), dimension(im, levs, ntrac), intent(inout) :: save_q

character(len=*), intent(out) :: errmsg
Expand All @@ -42,12 +42,24 @@ subroutine GFS_MP_generic_pre_run(im, levs, ldiag3d, do_aw, ntcw, nncl, ntrac, g
do k=1,levs
do i=1,im
save_t(i,k) = gt0(i,k)
save_q(1:im,:,1) = gq0(1:im,:,1)
enddo
enddo
do n=ntcw,ntcw+nncl-1
save_q(1:im,:,n) = gq0(1:im,:,n)
enddo
if(qdiag3d) then
do k=1,levs
do i=1,im
! Here, gq0(...,1) is used instead of gq0_water_vapor
! to be consistent with the GFS_MP_generic_post_run
! code.
save_qv(i,k) = gq0(i,k,1)
enddo
enddo
endif
if(do_aw) then
save_q(1:im,:,1) = gq0(1:im,:,1)
do n=ntcw,ntcw+nncl-1
save_q(1:im,:,n) = gq0(1:im,:,n)
enddo
endif
endif

end subroutine GFS_MP_generic_pre_run
Expand Down Expand Up @@ -81,7 +93,7 @@ end subroutine GFS_MP_generic_post_init
!> \section gfs_mp_gen GFS MP Generic Post General Algorithm
!> @{
subroutine GFS_MP_generic_post_run(im, ix, levs, kdt, nrcm, ncld, nncl, ntcw, ntrac, imp_physics, imp_physics_gfdl, &
imp_physics_thompson, imp_physics_mg, imp_physics_fer_hires, cal_pre, lssav, ldiag3d, cplflx, cplchm, con_g, dtf, frain, rainc, rain1, &
imp_physics_thompson, imp_physics_mg, imp_physics_fer_hires, cal_pre, lssav, ldiag3d, qdiag3d, cplflx, cplchm, con_g, dtf, frain, rainc, rain1, &
rann, xlat, xlon, gt0, gq0, prsl, prsi, phii, tsfc, ice, snow, graupel, save_t, save_qv, rain0, ice0, snow0, &
graupel0, del, rain, domr_diag, domzr_diag, domip_diag, doms_diag, tprcp, srflag, sr, cnvprcp, totprcp, totice, &
totsnw, totgrp, cnvprcpb, totprcpb, toticeb, totsnwb, totgrpb, dt3dt, dq3dt, rain_cpl, rainc_cpl, snow_cpl, pwat, &
Expand All @@ -94,7 +106,7 @@ subroutine GFS_MP_generic_post_run(im, ix, levs, kdt, nrcm, ncld, nncl, ntcw, nt

integer, intent(in) :: im, ix, levs, kdt, nrcm, ncld, nncl, ntcw, ntrac
integer, intent(in) :: imp_physics, imp_physics_gfdl, imp_physics_thompson, imp_physics_mg, imp_physics_fer_hires
logical, intent(in) :: cal_pre, lssav, ldiag3d, cplflx, cplchm
logical, intent(in) :: cal_pre, lssav, ldiag3d, qdiag3d, cplflx, cplchm

real(kind=kind_phys), intent(in) :: dtf, frain, con_g
real(kind=kind_phys), dimension(im), intent(in) :: rainc, rain1, xlat, xlon, tsfc
Expand All @@ -110,8 +122,9 @@ subroutine GFS_MP_generic_post_run(im, ix, levs, kdt, nrcm, ncld, nncl, ntcw, nt
srflag, cnvprcp, totprcp, totice, totsnw, totgrp, cnvprcpb, &
totprcpb, toticeb, totsnwb, totgrpb, rain_cpl, rainc_cpl, &
snow_cpl, pwat
! These arrays are only allocated if ldiag3d is .true.
real(kind=kind_phys), dimension(:,:), intent(inout) :: dt3dt, dq3dt

real(kind=kind_phys), dimension(:,:), intent(inout) :: dt3dt ! only if ldiag3d
real(kind=kind_phys), dimension(:,:), intent(inout) :: dq3dt ! only if ldiag3d and qdiag3d

! Stochastic physics / surface perturbations
logical, intent(in) :: do_sppt
Expand Down Expand Up @@ -270,9 +283,15 @@ subroutine GFS_MP_generic_post_run(im, ix, levs, kdt, nrcm, ncld, nncl, ntcw, nt
do k=1,levs
do i=1,im
dt3dt(i,k) = dt3dt(i,k) + (gt0(i,k)-save_t(i,k)) * frain
! dq3dt(i,k) = dq3dt(i,k) + (gq0(i,k,1)-save_qv(i,k)) * frain
enddo
enddo
if (qdiag3d) then
do k=1,levs
do i=1,im
dq3dt(i,k) = dq3dt(i,k) + (gq0(i,k,1)-save_qv(i,k)) * frain
enddo
enddo
endif
endif
endif

Expand Down
25 changes: 25 additions & 0 deletions physics/GFS_MP_generic.meta
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
type = logical
intent = in
optional = F
[qdiag3d]
standard_name = flag_tracer_diagnostics_3D
long_name = logical flag for 3D tracer diagnostics
units = flag
dimensions = ()
type = logical
intent = in
optional = F
[do_aw]
standard_name = flag_for_Arakawa_Wu_adjustment
long_name = flag for Arakawa Wu scale-aware adjustment
Expand Down Expand Up @@ -89,6 +97,15 @@
kind = kind_phys
intent = inout
optional = F
[save_qv]
standard_name = water_vapor_specific_humidity_save
long_name = water vapor specific humidity before entering a physics scheme
units = kg kg-1
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = out
optional = F
[save_q]
standard_name = tracer_concentration_save
long_name = tracer concentration before entering a physics scheme
Expand Down Expand Up @@ -266,6 +283,14 @@
type = logical
intent = in
optional = F
[qdiag3d]
standard_name = flag_tracer_diagnostics_3D
long_name = logical flag for 3D tracer diagnostics
units = flag
dimensions = ()
type = logical
intent = in
optional = F
[cplflx]
standard_name = flag_for_flux_coupling
long_name = flag controlling cplflx collection (default off)
Expand Down
Loading

0 comments on commit 314c5f5

Please sign in to comment.