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

Regain bit-for-bit identical results between IPD and CCPP for coupled model runs #86

Merged
merged 13 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from 9 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
6 changes: 4 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
branch = master
[submodule "ccpp/physics"]
path = ccpp/physics
url = https://github.com/NCAR/ccpp-physics
branch = master
#url = https://github.com/NCAR/ccpp-physics
#branch = master
url = https://github.com/climbfuji/ccpp-physics
branch = coupled_model_ipd_ccpp_b4b
87 changes: 87 additions & 0 deletions ccpp/suites/suite_FV3_GFS_2017_coupled_satmedmf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>

<suite name="FV3_GFS_2017_coupled_satmedmf" lib="ccppphys" ver="3">
<!-- <init></init> -->
<group name="time_vary">
<subcycle loop="1">
<scheme>GFS_time_vary_pre</scheme>
<scheme>GFS_rrtmg_setup</scheme>
<scheme>GFS_rad_time_vary</scheme>
<scheme>GFS_phys_time_vary</scheme>
</subcycle>
</group>
<group name="radiation">
<subcycle loop="1">
<scheme>GFS_suite_interstitial_rad_reset</scheme>
<scheme>GFS_rrtmg_pre</scheme>
<scheme>rrtmg_sw_pre</scheme>
<scheme>rrtmg_sw</scheme>
<scheme>rrtmg_sw_post</scheme>
<scheme>rrtmg_lw_pre</scheme>
<scheme>rrtmg_lw</scheme>
<scheme>rrtmg_lw_post</scheme>
<scheme>GFS_rrtmg_post</scheme>
</subcycle>
</group>
<group name="physics">
<subcycle loop="1">
<scheme>GFS_suite_interstitial_phys_reset</scheme>
<scheme>GFS_suite_stateout_reset</scheme>
<scheme>get_prs_fv3</scheme>
<scheme>GFS_suite_interstitial_1</scheme>
<scheme>GFS_surface_generic_pre</scheme>
<scheme>GFS_surface_composites_pre</scheme>
<scheme>dcyc2t3</scheme>
<scheme>GFS_surface_composites_inter</scheme>
<scheme>GFS_suite_interstitial_2</scheme>
</subcycle>
<!-- Surface iteration loop -->
<subcycle loop="2">
<scheme>sfc_diff</scheme>
<scheme>GFS_surface_loop_control_part1</scheme>
<scheme>sfc_ocean</scheme>
<scheme>lsm_noah</scheme>
<scheme>sfc_cice</scheme>
<scheme>sfc_sice</scheme>
<scheme>GFS_surface_loop_control_part2</scheme>
</subcycle>
<!-- End of surface iteration loop -->
<subcycle loop="1">
<scheme>GFS_surface_composites_post</scheme>
<scheme>sfc_diag</scheme>
<scheme>sfc_diag_post</scheme>
<scheme>GFS_surface_generic_post</scheme>
<scheme>GFS_PBL_generic_pre</scheme>
<scheme>satmedmfvdif</scheme>
<scheme>GFS_PBL_generic_post</scheme>
<scheme>GFS_GWD_generic_pre</scheme>
<scheme>cires_ugwp</scheme>
<scheme>cires_ugwp_post</scheme>
<scheme>GFS_GWD_generic_post</scheme>
<scheme>rayleigh_damp</scheme>
<scheme>GFS_suite_stateout_update</scheme>
<scheme>ozphys</scheme>
<scheme>GFS_DCNV_generic_pre</scheme>
<scheme>get_phi_fv3</scheme>
<scheme>GFS_suite_interstitial_3</scheme>
<scheme>samfdeepcnv</scheme>
<scheme>GFS_DCNV_generic_post</scheme>
<scheme>GFS_SCNV_generic_pre</scheme>
<scheme>samfshalcnv</scheme>
<scheme>GFS_SCNV_generic_post</scheme>
<scheme>GFS_suite_interstitial_4</scheme>
<scheme>cnvc90</scheme>
<scheme>GFS_MP_generic_pre</scheme>
<scheme>zhaocarr_gscond</scheme>
<scheme>zhaocarr_precpd</scheme>
<scheme>GFS_MP_generic_post</scheme>
<scheme>maximum_hourly_diagnostics</scheme>
</subcycle>
</group>
<group name="stochastics">
<subcycle loop="1">
<scheme>GFS_stochastics</scheme>
</subcycle>
</group>
<!-- <finalize></finalize> -->
</suite>
84 changes: 46 additions & 38 deletions gfsphysics/GFS_layer/GFS_physics_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -678,16 +678,20 @@ subroutine GFS_physics_driver &
real :: pshltr,QCQ,rh02
real(kind=kind_phys), allocatable, dimension(:,:) :: den

!! Initialize local variables (mainly for debugging purposes, because the
!! corresponding variables Interstitial(nt)%... are reset to zero every time);
!! these variables are only modified over parts of the entire domain (related
!! to land surface mask etc.)
!snowmt = 0.
!gamq = 0.
!gamt = 0.
!gflx = 0.
!hflx = 0.
!
! Initialize local variables. Some of these are mainly for debugging
! purposes, because the corresponding variables Interstitial(nt)%...
! are reset to zero every time. For some, however, it is required
! because they may be used uninitialized otherwise!
snowmt = 0.
gamq = 0.
gamt = 0.
gflx = 0.
hflx = 0.
dusfc_cice = 0.
dvsfc_cice = 0.
dtsfc_cice = 0.
dqsfc_cice = 0.

!! Strictly speaking, this is not required. But when
!! hunting for bit-for-bit differences, doing the same as
!! in GFS_suite_stateout_reset makes life a lot easier.
Expand Down Expand Up @@ -911,10 +915,6 @@ subroutine GFS_physics_driver &
! --- set initial quantities for stochastic physics deltas
if (Model%do_sppt) then
Tbd%dtdtr = zero
do i=1,im
Tbd%drain_cpl(i) = Coupling%rain_cpl (i)
Tbd%dsnow_cpl(i) = Coupling%snow_cpl (i)
enddo
endif

! mg, sfc-perts
Expand Down Expand Up @@ -1145,9 +1145,8 @@ subroutine GFS_physics_driver &
endif
endif
if (fice(i) < one) then
wet(i)=.true. !some open ocean/lake water exists
wet(i)=.true. ! some open ocean/lake water exists
if (.not. Model%cplflx) Sfcprop%tsfco(i) = max(Sfcprop%tsfco(i), Sfcprop%tisfc(i), tgice)

end if
else
fice(i) = zero
Expand Down Expand Up @@ -1659,13 +1658,14 @@ subroutine GFS_physics_driver &
sbsno(i) = zero
snowc(i) = zero
snohf(i) = zero
!## CCPP ##* GFS_surface_generic.F90/GFS_surface_generic_pre_run
Diag%zlvl(i) = Statein%phil(i,1) * onebg
Diag%smcwlt2(i) = zero
Diag%smcref2(i) = zero

wind(i) = max(sqrt(Statein%ugrs(i,1)*Statein%ugrs(i,1) + &
Statein%vgrs(i,1)*Statein%vgrs(i,1)) &
+ max(zero, min(Tbd%phy_f2d(i,Model%num_p2d), 30.0)), one)
!*## CCPP ##
enddo
!*## CCPP ##

Expand Down Expand Up @@ -1909,6 +1909,30 @@ subroutine GFS_physics_driver &

endif !lsm

!! Strictly speaking, this is not required. But when
!! hunting for bit-for-bit differences, updating the
!! subsurface variables in the Sfcprop DDT makes
!! life a lot easier
!if (Model%frac_grid) then
! do k=1,lsoil
! do i=1,im
! if (dry(i)) then
! Sfcprop%smc(i,k) = smsoil(i,k)
! Sfcprop%stc(i,k) = stsoil(i,k)
! Sfcprop%slc(i,k) = slsoil(i,k)
! endif
! enddo
! enddo
!else
! do k=1,lsoil
! do i=1,im
! Sfcprop%smc(i,k) = smsoil(i,k)
! Sfcprop%stc(i,k) = stsoil(i,k)
! Sfcprop%slc(i,k) = slsoil(i,k)
! enddo
! enddo
!endif

! if (lprnt) write(0,*)' tseabeficemodel =',Sfcprop%tsfc(ipr),' me=',me &
! &, ' kdt=',kdt,' tsfc32=',tsfc3(ipr,2),' fice=',fice(ipr) &
! &,' stsoil=',stsoil(ipr,:)
Expand Down Expand Up @@ -2103,15 +2127,11 @@ subroutine GFS_physics_driver &
ep1d(i) = ep1d3(i,k)
Sfcprop%weasd(i) = weasd3(i,k)
Sfcprop%snowd(i) = snowd3(i,k)

evap(i) = evap3(i,k)
hflx(i) = hflx3(i,k)
qss(i) = qss3(i,k)
Sfcprop%tsfc(i) = tsfc3(i,k)

Diag%cmm(i) = cmm3(i,k)
Diag%chh(i) = chh3(i,k)

Sfcprop%zorll(i) = zorl3(i,1)
Sfcprop%zorlo(i) = zorl3(i,3)

Expand All @@ -2120,7 +2140,6 @@ subroutine GFS_physics_driver &
txo = one - txi
evap(i) = txi * evap3(i,2) + txo * evap3(i,3)
hflx(i) = txi * hflx3(i,2) + txo * hflx3(i,3)
! Sfcprop%tsfc(i) = txi * tice(i) + txo * tsfc3(i,3)
Sfcprop%tsfc(i) = txi * tsfc3(i,2) + txo * tsfc3(i,3)
else ! return updated lake ice thickness & concentration to global array
if (islmsk(i) == 2) then
Expand Down Expand Up @@ -2856,8 +2875,6 @@ subroutine GFS_physics_driver &
endif
Coupling%dtsfci_cpl(i) = con_cp * rho * hflx3(i,3) ! sensible heat flux over open ocean
Coupling%dqsfci_cpl(i) = con_hvap * rho * evap3(i,3) ! latent heat flux over open ocean
! if (lprnt .and. i == ipr) write(0,*)' hflx33=',hflx3(i,3),' evap33=',evap3(i,3), &
! ' con_cp=',con_cp,' rho=',rho,' con_hvap=',con_hvap
else ! use results from PBL scheme for 100% open ocean
Coupling%dusfci_cpl(i) = dusfc1(i)
Coupling%dvsfci_cpl(i) = dvsfc1(i)
Expand Down Expand Up @@ -5283,7 +5300,7 @@ subroutine GFS_physics_driver &
!*## CCPP ##
!## CCPP ##* GFS_MP_generic.F90/GFS_MP_generic_post_run
Diag%rain(:) = Diag%rainc(:) + frain * rain1(:) ! total rain per timestep

! --- get the amount of different precip type for Noah MP
! --- convert from m/dtp to mm/s
if (Model%lsm==Model%lsm_noahmp) then
Expand Down Expand Up @@ -5463,10 +5480,10 @@ subroutine GFS_physics_driver &

if (Model%cplflx .or. Model%cplchm) then
do i = 1, im
Coupling%rain_cpl(i) = Coupling%rain_cpl(i) &
+ Diag%rain(i) * (one-Sfcprop%srflag(i))
Coupling%snow_cpl(i) = Coupling%snow_cpl(i) &
+ Diag%rain(i) * Sfcprop%srflag(i)
Tbd%drain_cpl(i)= Diag%rain(i) * (one-Sfcprop%srflag(i))
junwang-noaa marked this conversation as resolved.
Show resolved Hide resolved
Tbd%dsnow_cpl(i)= Diag%rain(i) * Sfcprop%srflag(i)
Coupling%rain_cpl(i) = Coupling%rain_cpl(i) + Tbd%drain_cpl(i)
Coupling%snow_cpl(i) = Coupling%snow_cpl(i) + Tbd%dsnow_cpl(i)
enddo
endif

Expand Down Expand Up @@ -5557,15 +5574,6 @@ subroutine GFS_physics_driver &
if (Model%do_sppt) then
!--- radiation heating rate
Tbd%dtdtr(1:im,:) = Tbd%dtdtr(1:im,:) + dtdtc(1:im,:)*dtf
do i = 1, im
if (t850(i) > 273.16) then
!--- change in change in rain precip
Tbd%drain_cpl(i) = Diag%rain(i) - Tbd%drain_cpl(i)
else
!--- change in change in snow precip
Tbd%dsnow_cpl(i) = Diag%rain(i) - Tbd%dsnow_cpl(i)
endif
enddo
endif
!*## CCPP ##
!## CCPP ##* This block is not in the CCPP since it is not needed in the CCPP.
Expand Down
14 changes: 8 additions & 6 deletions gfsphysics/GFS_layer/GFS_typedefs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ module GFS_typedefs
#endif
real (kind=kind_phys), pointer :: q2m (:) => null() !< 2 meter humidity

! -- In/Out for Noah MP
real (kind=kind_phys), pointer :: snowxy (:) => null() !
! -- In/Out for Noah MP
real (kind=kind_phys), pointer :: snowxy (:) => null() !<
real (kind=kind_phys), pointer :: tvxy (:) => null() !< veg temp
real (kind=kind_phys), pointer :: tgxy (:) => null() !< ground temp
real (kind=kind_phys), pointer :: canicexy(:) => null() !<
Expand All @@ -312,7 +312,7 @@ module GFS_typedefs
real (kind=kind_phys), pointer :: xlaixy (:) => null() !<
real (kind=kind_phys), pointer :: taussxy (:) => null() !<
real (kind=kind_phys), pointer :: smcwtdxy(:) => null() !<
real (kind=kind_phys), pointer :: deeprechxy(:) => null() !<
real (kind=kind_phys), pointer :: deeprechxy(:)=> null() !<
real (kind=kind_phys), pointer :: rechxy (:) => null() !<

real (kind=kind_phys), pointer :: snicexy (:,:) => null() !<
Expand Down Expand Up @@ -2582,7 +2582,7 @@ subroutine coupling_create (Coupling, IM, Model)
Coupling%ca_turb = clear_val
Coupling%ca_shal = clear_val
Coupling%ca_rad = clear_val
Coupling%ca_micro = clear_val
Coupling%ca_micro = clear_val
Coupling%cape = clear_val
Coupling%tconvtend = clear_val
Coupling%qconvtend = clear_val
Expand Down Expand Up @@ -4833,6 +4833,8 @@ subroutine tbd_create (Tbd, IM, Model)
if ( Model%isubc_lw == 2 .or. Model%isubc_sw == 2 ) then
allocate (Tbd%icsdsw (IM))
allocate (Tbd%icsdlw (IM))
Tbd%icsdsw = zero
Tbd%icsdlw = zero
endif

!--- ozone and stratosphere h2o needs
Expand Down Expand Up @@ -5427,8 +5429,8 @@ subroutine diag_phys_zero (Diag, Model, linit, iauwindow_center)
Diag%u10max = zero
Diag%v10max = zero
Diag%spd10max = zero
! Diag%rain = zero
! Diag%rainc = zero
Diag%rain = zero
Diag%rainc = zero
Diag%ice = zero
Diag%snow = zero
Diag%graupel = zero
Expand Down
24 changes: 21 additions & 3 deletions gfsphysics/physics/GFS_debug.F90
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,12 @@ subroutine GFS_diagtoscreen_run (Model, Statein, Stateout, Sfcprop, Coupling,
call print_var(mpirank,omprank, blkno, 'Coupling%rain_cpl', Coupling%rain_cpl)
call print_var(mpirank,omprank, blkno, 'Coupling%snow_cpl', Coupling%snow_cpl)
end if
if (Model%cplwav2atm) then
call print_var(mpirank,omprank, blkno, 'Coupling%zorlwav_cpl' , Coupling%zorlwav_cpl )
end if
if (Model%cplflx) then
call print_var(mpirank,omprank, blkno, 'Coupling%oro_cpl' , Coupling%oro_cpl )
call print_var(mpirank,omprank, blkno, 'Coupling%slmsk_cpl' , Coupling%slmsk_cpl )
call print_var(mpirank,omprank, blkno, 'Coupling%slimskin_cpl', Coupling%slimskin_cpl )
call print_var(mpirank,omprank, blkno, 'Coupling%dusfcin_cpl ', Coupling%dusfcin_cpl )
call print_var(mpirank,omprank, blkno, 'Coupling%dvsfcin_cpl ', Coupling%dvsfcin_cpl )
Expand Down Expand Up @@ -458,11 +463,24 @@ subroutine GFS_diagtoscreen_run (Model, Statein, Stateout, Sfcprop, Coupling,
call print_var(mpirank,omprank, blkno, 'Coupling%shum_wts', Coupling%shum_wts)
end if
if (Model%do_skeb) then
call print_var(mpirank,omprank, blkno, 'Coupling%skebu_wts', Coupling%skebu_wts)
call print_var(mpirank,omprank, blkno, 'Coupling%skebv_wts', Coupling%skebv_wts)
call print_var(mpirank,omprank, blkno, 'Coupling%skebu_wts', Coupling%skebu_wts )
call print_var(mpirank,omprank, blkno, 'Coupling%skebv_wts', Coupling%skebv_wts )
end if
if (Model%do_sfcperts) then
call print_var(mpirank,omprank, blkno, 'Coupling%sfc_wts', Coupling%sfc_wts)
call print_var(mpirank,omprank, blkno, 'Coupling%sfc_wts' , Coupling%sfc_wts )
end if
if (Model%do_ca) then
call print_var(mpirank,omprank, blkno, 'Coupling%tconvtend', Coupling%tconvtend )
call print_var(mpirank,omprank, blkno, 'Coupling%qconvtend', Coupling%qconvtend )
call print_var(mpirank,omprank, blkno, 'Coupling%uconvtend', Coupling%uconvtend )
call print_var(mpirank,omprank, blkno, 'Coupling%vconvtend', Coupling%vconvtend )
call print_var(mpirank,omprank, blkno, 'Coupling%ca_out ', Coupling%ca_out )
call print_var(mpirank,omprank, blkno, 'Coupling%ca_deep ', Coupling%ca_deep )
call print_var(mpirank,omprank, blkno, 'Coupling%ca_turb ', Coupling%ca_turb )
call print_var(mpirank,omprank, blkno, 'Coupling%ca_shal ', Coupling%ca_shal )
call print_var(mpirank,omprank, blkno, 'Coupling%ca_rad ', Coupling%ca_rad )
call print_var(mpirank,omprank, blkno, 'Coupling%ca_micro ', Coupling%ca_micro )
call print_var(mpirank,omprank, blkno, 'Coupling%cape ', Coupling%cape )
end if
if(Model%imp_physics == Model%imp_physics_thompson .and. Model%ltaerosol) then
call print_var(mpirank,omprank, blkno, 'Coupling%nwfa2d', Coupling%nwfa2d)
Expand Down
Loading