Skip to content
Merged
32 changes: 32 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
Tag name: cam6_4_xxx
Originator(s): pel
Date:
One-line Summary: Fix (energy) bug in physics-dynamics coupling
Github PR URL: https://github.com/ESCOMP/CAM/pull/

Purpose of changes (include the issue number and title text for each relevant GitHub issue):

Fix (energy) bug in physics-dynamics coupling -- issue #1551

Describe any changes made to build system: N/A

Describe any changes made to the namelist: N/A

List any changes to the defaults for the boundary datasets: N/A

Describe any substantial timing or memory changes: N/A

Code reviewed by:

List all files eliminated: N/A

List all files added and what they do: N/A

List all existing files that have been modified, and describe the changes:



Expecting failures against baseline for all tests using SE dycore
(only tests without moisture should not fail)


===============================================================

Tag name: cam6_4_171
Expand Down
16 changes: 10 additions & 6 deletions src/physics/cam/physpkg.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,7 @@ subroutine tphysac (ztodt, cam_in, &
real(r8) :: tmp_trac (pcols,pver,pcnst) ! tmp space
real(r8) :: tmp_pdel (pcols,pver) ! tmp space
real(r8) :: tmp_ps (pcols) ! tmp space
real(r8) :: tmp_cpcv (pcols,pver) ! tmp space
real(r8) :: scaling(pcols,pver)
logical :: moist_mixing_ratio_dycore

Expand Down Expand Up @@ -1987,11 +1988,6 @@ subroutine tphysac (ztodt, cam_in, &
! FV: convert dry-type mixing ratios to moist here because physics_dme_adjust
! assumes moist. This is done in p_d_coupling for other dynamics. Bundy, Feb 2004.
moist_mixing_ratio_dycore = dycore_is('LR').or. dycore_is('FV3')
!
! update cp/cv for energy computation based in updated water variables
!
call cam_thermo_water_update(state%q(:ncol,:,:), lchnk, ncol, vc_dycore,&
to_dry_factor=state%pdel(:ncol,:)/state%pdeldry(:ncol,:))

! for dry mixing ratio dycore, physics_dme_adjust is called for energy diagnostic purposes only.
! So, save off tracers
Expand All @@ -2005,10 +2001,17 @@ subroutine tphysac (ztodt, cam_in, &
tmp_trac(:ncol,:pver,:pcnst) = state%q(:ncol,:pver,:pcnst)
tmp_pdel(:ncol,:pver) = state%pdel(:ncol,:pver)
tmp_ps(:ncol) = state%ps(:ncol)
tmp_cpcv(:ncol,:pver) = cp_or_cv_dycore(:ncol,:pver,lchnk)
if (trim(cam_take_snapshot_before) == "physics_dme_adjust") then
call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf,&
fh2o, surfric, obklen, flx_heat)
end if
end if
!
! update cp/cv for energy computation based in updated water variables
!
call cam_thermo_water_update(state%q(:ncol,:,:), lchnk, ncol, vc_dycore,&
to_dry_factor=state%pdel(:ncol,:)/state%pdeldry(:ncol,:))

call physics_dme_adjust(state, tend, qini, totliqini, toticeini, ztodt)
if (trim(cam_take_snapshot_after) == "physics_dme_adjust") then
call cam_snapshot_all_outfld_tphysac(cam_snapshot_after_num, state, tend, cam_in, cam_out, pbuf,&
Expand All @@ -2020,6 +2023,7 @@ subroutine tphysac (ztodt, cam_in, &
state%q(:ncol,:pver,:pcnst) = tmp_trac(:ncol,:pver,:pcnst)
state%pdel(:ncol,:pver) = tmp_pdel(:ncol,:pver)
state%ps(:ncol) = tmp_ps(:ncol)
cp_or_cv_dycore(:ncol,:pver,lchnk) = tmp_cpcv(:ncol,:pver)
end if
else
!
Expand Down
15 changes: 9 additions & 6 deletions src/physics/cam7/physpkg.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,7 @@ subroutine tphysac (ztodt, cam_in, &
real(r8) :: tmp_trac (pcols,pver,pcnst) ! tmp space
real(r8) :: tmp_pdel (pcols,pver) ! tmp space
real(r8) :: tmp_ps (pcols) ! tmp space
real(r8) :: tmp_cpcv (pcols,pver) ! tmp space
real(r8) :: scaling(pcols,pver)
logical :: moist_mixing_ratio_dycore

Expand Down Expand Up @@ -2497,12 +2498,6 @@ subroutine tphysac (ztodt, cam_in, &
! FV: convert dry-type mixing ratios to moist here because physics_dme_adjust
! assumes moist. This is done in p_d_coupling for other dynamics. Bundy, Feb 2004.
moist_mixing_ratio_dycore = dycore_is('LR').or. dycore_is('FV3')
!
! update cp/cv for energy computation based in updated water variables
!
call cam_thermo_water_update(state%q(:ncol,:,:), lchnk, ncol, vc_dycore,&
to_dry_factor=state%pdel(:ncol,:)/state%pdeldry(:ncol,:))

! for dry mixing ratio dycore, physics_dme_adjust is called for energy diagnostic purposes only.
! So, save off tracers
if (.not.moist_mixing_ratio_dycore) then
Expand All @@ -2515,10 +2510,17 @@ subroutine tphysac (ztodt, cam_in, &
tmp_trac(:ncol,:pver,:pcnst) = state%q(:ncol,:pver,:pcnst)
tmp_pdel(:ncol,:pver) = state%pdel(:ncol,:pver)
tmp_ps(:ncol) = state%ps(:ncol)
tmp_cpcv(:ncol,:pver) = cp_or_cv_dycore(:ncol,:pver,lchnk)
if (trim(cam_take_snapshot_before) == "physics_dme_adjust") then
call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf,&
fh2o, surfric, obklen, flx_heat, cmfmc, dlf, det_s, det_ice, net_flx)
end if
!
! update cp/cv for energy computation based in updated water variables
!
call cam_thermo_water_update(state%q(:ncol,:,:), lchnk, ncol, vc_dycore,&
to_dry_factor=state%pdel(:ncol,:)/state%pdeldry(:ncol,:))

call physics_dme_adjust(state, tend, qini, totliqini, toticeini, ztodt)
if (trim(cam_take_snapshot_after) == "physics_dme_adjust") then
call cam_snapshot_all_outfld_tphysac(cam_snapshot_after_num, state, tend, cam_in, cam_out, pbuf,&
Expand All @@ -2530,6 +2532,7 @@ subroutine tphysac (ztodt, cam_in, &
state%q(:ncol,:pver,:pcnst) = tmp_trac(:ncol,:pver,:pcnst)
state%pdel(:ncol,:pver) = tmp_pdel(:ncol,:pver)
state%ps(:ncol) = tmp_ps(:ncol)
cp_or_cv_dycore(:ncol,:pver,lchnk) = tmp_cpcv(:ncol,:pver)
end if
else
!
Expand Down
14 changes: 9 additions & 5 deletions src/physics/simple/physpkg.F90
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ subroutine tphysac (ztodt, cam_in, cam_out, state, tend, pbuf)
real(r8) :: tmp_trac (pcols,pver,pcnst) ! tmp space
real(r8) :: tmp_pdel (pcols,pver) ! tmp space
real(r8) :: tmp_ps (pcols) ! tmp space
real(r8) :: tmp_cpcv (pcols,pver) ! tmp space
real(r8) :: scaling(pcols,pver)
!--------------------------------------------------------------------------

Expand Down Expand Up @@ -609,11 +610,6 @@ subroutine tphysac (ztodt, cam_in, cam_out, state, tend, pbuf)
! other dynamics. Bundy, Feb 2004.
!
moist_mixing_ratio_dycore = dycore_is('LR').or. dycore_is('FV3')
!
! update cp/cv for energy computation based in updated water variables
!
call cam_thermo_water_update(state%q(:ncol,:,:), lchnk, ncol, vc_dycore,&
to_dry_factor=state%pdel(:ncol,:)/state%pdeldry(:ncol,:))

if (moist_physics) then
! Scale dry mass and energy
Expand Down Expand Up @@ -643,13 +639,21 @@ subroutine tphysac (ztodt, cam_in, cam_out, state, tend, pbuf)
tmp_trac(:ncol,:pver,:pcnst) = state%q(:ncol,:pver,:pcnst)
tmp_pdel(:ncol,:pver) = state%pdel(:ncol,:pver)
tmp_ps(:ncol) = state%ps(:ncol)
tmp_cpcv(:ncol,:pver) = cp_or_cv_dycore(:ncol,:pver,lchnk)
!
! update cp/cv for energy computation based in updated water variables
!
call cam_thermo_water_update(state%q(:ncol,:,:), lchnk, ncol, vc_dycore,&
to_dry_factor=state%pdel(:ncol,:)/state%pdeldry(:ncol,:))

call physics_dme_adjust(state, tend, qini, totliqini, toticeini, ztodt)
call tot_energy_phys(state, 'phAM')
call tot_energy_phys(state, 'dyAM', vc=vc_dycore)
! Restore pre-"physics_dme_adjust" tracers
state%q(:ncol,:pver,:pcnst) = tmp_trac(:ncol,:pver,:pcnst)
state%pdel(:ncol,:pver) = tmp_pdel(:ncol,:pver)
state%ps(:ncol) = tmp_ps(:ncol)
cp_or_cv_dycore(:ncol,:pver,lchnk) = tmp_cpcv(:ncol,:pver)
end if
else
!
Expand Down
2 changes: 1 addition & 1 deletion src/utils/air_composition.F90
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module air_composition
real(r8), public, protected, allocatable :: mbarv(:,:,:)
! cp_or_cv_dycore: enthalpy or internal energy scaling factor for
! energy consistency
real(r8), public, protected, allocatable :: cp_or_cv_dycore(:,:,:)
real(r8), public, allocatable :: cp_or_cv_dycore(:,:,:)
!
! Interfaces for public routines
interface get_cp_dry
Expand Down
Loading