Skip to content

Commit b4338bb

Browse files
PeterHjortLauritzenPeterHjortLauritzen
authored andcommitted
fix energy bug in physics-dynamics coupling
1 parent 64c9fd7 commit b4338bb

5 files changed

Lines changed: 61 additions & 18 deletions

File tree

doc/ChangeLog

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
Tag name: cam6_4_xxx
2+
Originator(s): pel
3+
Date:
4+
One-line Summary: Fix (energy) bug in physics-dynamics coupling
5+
Github PR URL: https://github.com/ESCOMP/CAM/pull/
6+
7+
Purpose of changes (include the issue number and title text for each relevant GitHub issue):
8+
9+
Fix (energy) bug in physics-dynamics coupling -- issue #1551
10+
11+
Describe any changes made to build system: N/A
12+
13+
Describe any changes made to the namelist: N/A
14+
15+
List any changes to the defaults for the boundary datasets: N/A
16+
17+
Describe any substantial timing or memory changes: N/A
18+
19+
Code reviewed by:
20+
21+
List all files eliminated: N/A
22+
23+
List all files added and what they do: N/A
24+
25+
List all existing files that have been modified, and describe the changes:
26+
27+
28+
29+
Expecting failures against baseline for all tests using SE dycore
30+
(only tests without moisture should not fail)
31+
32+
133
===============================================================
234

335
Tag name: cam6_4_171

src/physics/cam/physpkg.F90

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,7 @@ subroutine tphysac (ztodt, cam_in, &
14691469
real(r8) :: tmp_trac (pcols,pver,pcnst) ! tmp space
14701470
real(r8) :: tmp_pdel (pcols,pver) ! tmp space
14711471
real(r8) :: tmp_ps (pcols) ! tmp space
1472+
real(r8) :: tmp_cpcv (pcols,pver) ! tmp space
14721473
real(r8) :: scaling(pcols,pver)
14731474
logical :: moist_mixing_ratio_dycore
14741475

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

19961992
! for dry mixing ratio dycore, physics_dme_adjust is called for energy diagnostic purposes only.
19971993
! So, save off tracers
@@ -2005,10 +2001,17 @@ subroutine tphysac (ztodt, cam_in, &
20052001
tmp_trac(:ncol,:pver,:pcnst) = state%q(:ncol,:pver,:pcnst)
20062002
tmp_pdel(:ncol,:pver) = state%pdel(:ncol,:pver)
20072003
tmp_ps(:ncol) = state%ps(:ncol)
2004+
tmp_cpcv(:ncol,:pver) = cp_or_cv_dycore(:ncol,:pver,lchnk)
20082005
if (trim(cam_take_snapshot_before) == "physics_dme_adjust") then
20092006
call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf,&
20102007
fh2o, surfric, obklen, flx_heat)
2011-
end if
2008+
end if
2009+
!
2010+
! update cp/cv for energy computation based in updated water variables
2011+
!
2012+
call cam_thermo_water_update(state%q(:ncol,:,:), lchnk, ncol, vc_dycore,&
2013+
to_dry_factor=state%pdel(:ncol,:)/state%pdeldry(:ncol,:))
2014+
20122015
call physics_dme_adjust(state, tend, qini, totliqini, toticeini, ztodt)
20132016
if (trim(cam_take_snapshot_after) == "physics_dme_adjust") then
20142017
call cam_snapshot_all_outfld_tphysac(cam_snapshot_after_num, state, tend, cam_in, cam_out, pbuf,&
@@ -2020,6 +2023,7 @@ subroutine tphysac (ztodt, cam_in, &
20202023
state%q(:ncol,:pver,:pcnst) = tmp_trac(:ncol,:pver,:pcnst)
20212024
state%pdel(:ncol,:pver) = tmp_pdel(:ncol,:pver)
20222025
state%ps(:ncol) = tmp_ps(:ncol)
2026+
cp_or_cv_dycore(:ncol,:pver,lchnk) = tmp_cpcv(:ncol,:pver)
20232027
end if
20242028
else
20252029
!

src/physics/cam7/physpkg.F90

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,7 @@ subroutine tphysac (ztodt, cam_in, &
15391539
real(r8) :: tmp_trac (pcols,pver,pcnst) ! tmp space
15401540
real(r8) :: tmp_pdel (pcols,pver) ! tmp space
15411541
real(r8) :: tmp_ps (pcols) ! tmp space
1542+
real(r8) :: tmp_cpcv (pcols,pver) ! tmp space
15421543
real(r8) :: scaling(pcols,pver)
15431544
logical :: moist_mixing_ratio_dycore
15441545

@@ -2497,12 +2498,6 @@ subroutine tphysac (ztodt, cam_in, &
24972498
! FV: convert dry-type mixing ratios to moist here because physics_dme_adjust
24982499
! assumes moist. This is done in p_d_coupling for other dynamics. Bundy, Feb 2004.
24992500
moist_mixing_ratio_dycore = dycore_is('LR').or. dycore_is('FV3')
2500-
!
2501-
! update cp/cv for energy computation based in updated water variables
2502-
!
2503-
call cam_thermo_water_update(state%q(:ncol,:,:), lchnk, ncol, vc_dycore,&
2504-
to_dry_factor=state%pdel(:ncol,:)/state%pdeldry(:ncol,:))
2505-
25062501
! for dry mixing ratio dycore, physics_dme_adjust is called for energy diagnostic purposes only.
25072502
! So, save off tracers
25082503
if (.not.moist_mixing_ratio_dycore) then
@@ -2515,10 +2510,17 @@ subroutine tphysac (ztodt, cam_in, &
25152510
tmp_trac(:ncol,:pver,:pcnst) = state%q(:ncol,:pver,:pcnst)
25162511
tmp_pdel(:ncol,:pver) = state%pdel(:ncol,:pver)
25172512
tmp_ps(:ncol) = state%ps(:ncol)
2513+
tmp_cpcv(:ncol,:pver) = cp_or_cv_dycore(:ncol,:pver,lchnk)
25182514
if (trim(cam_take_snapshot_before) == "physics_dme_adjust") then
25192515
call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf,&
25202516
fh2o, surfric, obklen, flx_heat, cmfmc, dlf, det_s, det_ice, net_flx)
25212517
end if
2518+
!
2519+
! update cp/cv for energy computation based in updated water variables
2520+
!
2521+
call cam_thermo_water_update(state%q(:ncol,:,:), lchnk, ncol, vc_dycore,&
2522+
to_dry_factor=state%pdel(:ncol,:)/state%pdeldry(:ncol,:))
2523+
25222524
call physics_dme_adjust(state, tend, qini, totliqini, toticeini, ztodt)
25232525
if (trim(cam_take_snapshot_after) == "physics_dme_adjust") then
25242526
call cam_snapshot_all_outfld_tphysac(cam_snapshot_after_num, state, tend, cam_in, cam_out, pbuf,&
@@ -2530,6 +2532,7 @@ subroutine tphysac (ztodt, cam_in, &
25302532
state%q(:ncol,:pver,:pcnst) = tmp_trac(:ncol,:pver,:pcnst)
25312533
state%pdel(:ncol,:pver) = tmp_pdel(:ncol,:pver)
25322534
state%ps(:ncol) = tmp_ps(:ncol)
2535+
cp_or_cv_dycore(:ncol,:pver,lchnk) = tmp_cpcv(:ncol,:pver)
25332536
end if
25342537
else
25352538
!

src/physics/simple/physpkg.F90

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ subroutine tphysac (ztodt, cam_in, cam_out, state, tend, pbuf)
543543
real(r8) :: tmp_trac (pcols,pver,pcnst) ! tmp space
544544
real(r8) :: tmp_pdel (pcols,pver) ! tmp space
545545
real(r8) :: tmp_ps (pcols) ! tmp space
546+
real(r8) :: tmp_cpcv (pcols,pver) ! tmp space
546547
real(r8) :: scaling(pcols,pver)
547548
!--------------------------------------------------------------------------
548549

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

618614
if (moist_physics) then
619615
! Scale dry mass and energy
@@ -643,13 +639,21 @@ subroutine tphysac (ztodt, cam_in, cam_out, state, tend, pbuf)
643639
tmp_trac(:ncol,:pver,:pcnst) = state%q(:ncol,:pver,:pcnst)
644640
tmp_pdel(:ncol,:pver) = state%pdel(:ncol,:pver)
645641
tmp_ps(:ncol) = state%ps(:ncol)
642+
tmp_cpcv(:ncol,:pver) = cp_or_cv_dycore(:ncol,:pver,lchnk)
643+
!
644+
! update cp/cv for energy computation based in updated water variables
645+
!
646+
call cam_thermo_water_update(state%q(:ncol,:,:), lchnk, ncol, vc_dycore,&
647+
to_dry_factor=state%pdel(:ncol,:)/state%pdeldry(:ncol,:))
648+
646649
call physics_dme_adjust(state, tend, qini, totliqini, toticeini, ztodt)
647650
call tot_energy_phys(state, 'phAM')
648651
call tot_energy_phys(state, 'dyAM', vc=vc_dycore)
649652
! Restore pre-"physics_dme_adjust" tracers
650653
state%q(:ncol,:pver,:pcnst) = tmp_trac(:ncol,:pver,:pcnst)
651654
state%pdel(:ncol,:pver) = tmp_pdel(:ncol,:pver)
652655
state%ps(:ncol) = tmp_ps(:ncol)
656+
cp_or_cv_dycore(:ncol,:pver,lchnk) = tmp_cpcv(:ncol,:pver)
653657
end if
654658
else
655659
!

src/utils/air_composition.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ module air_composition
107107
real(r8), public, protected, allocatable :: mbarv(:,:,:)
108108
! cp_or_cv_dycore: enthalpy or internal energy scaling factor for
109109
! energy consistency
110-
real(r8), public, protected, allocatable :: cp_or_cv_dycore(:,:,:)
110+
real(r8), public, allocatable :: cp_or_cv_dycore(:,:,:)
111111
!
112112
! Interfaces for public routines
113113
interface get_cp_dry

0 commit comments

Comments
 (0)