Skip to content

Commit d991801

Browse files
authored
Merge pull request #1415 from PeterHjortLauritzen/frontogenesis-bug
cam6_4_126: Fix frontogenesis bug (SE dycore only)
2 parents 0470b80 + f92a9d5 commit d991801

File tree

5 files changed

+206
-21
lines changed

5 files changed

+206
-21
lines changed

.gitmodules

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@
107107
fxtag = clubb_4ncar_20240605_73d60f6_gpufixes_posinf
108108
fxDONOTUSEurl = https://github.com/larson-group/clubb_release
109109

110-
[submodule "cism"]
111-
path = components/cism
112-
url = https://github.com/ESCOMP/CISM-wrapper
113-
fxtag = cismwrap_2_2_010
114-
fxrequired = ToplevelRequired
115-
fxDONOTUSEurl = https://github.com/ESCOMP/CISM-wrapper
116-
117110
[submodule "rtm"]
118111
path = components/rtm
119112
url = https://github.com/ESCOMP/RTM

cime_config/config_compsets.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@
423423
</compset>
424424
<compset>
425425
<alias>FCHIST_GC</alias>
426-
<lname>HIST_CAM60%GEOSCHEM%HEMCO_CLM50%SP_CICE%PRES_DOCN%DOM_MOSART_CISM2%NOEVOLVE_SWAV</lname>
426+
<lname>HIST_CAM60%GEOSCHEM%HEMCO_CLM50%SP_CICE%PRES_DOCN%DOM_MOSART_SGLC_SWAV</lname>
427427
</compset>
428428

429429
<compset>

components/cism

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/ChangeLog

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,97 @@
11
===============================================================
22

3+
Tag name: cam6_4_126
4+
Originator(s): Walter Hannah, Jack Chen, Peter Lauritzen, Cheryl Craig
5+
Date: Oct 16, 2025
6+
One-line Summary: Fix frontogenesis function bug and Change CISM2 to SGLC in FCHIST_GC compset
7+
Github PR URL: https://github.com/ESCOMP/pull/1415 and 1417
8+
9+
Purpose of changes (include the issue number and title text for each relevant GitHub issue):
10+
- Fix bug in frontogenesis function computation: https://github.com/ESCOMP/CAM/issues/1414
11+
- Change CISM2 to SGLC in FCHIST_GC compset: https://github.com/ESCOMP/CAM/issues/1416 and 1412
12+
13+
Describe any changes made to build system: Using SGLC for FCHIST_GC compset
14+
15+
Describe any changes made to the namelist: N/A
16+
17+
List any changes to the defaults for the bound N/Aary datasets:
18+
19+
Describe any substantial timing or memory changes: N/A
20+
21+
Code reviewed by: Peter Lauritzen, Jack Chen, cacraigucar
22+
23+
List all files eliminated:
24+
D components/cism
25+
- CISM external removed from CAM checkouts
26+
27+
List all files added and what they do: N/A
28+
29+
List all existing files that have been modified, and describe the changes:
30+
M .gitmodules
31+
- CISM external removed from CAM checkouts
32+
33+
M cime_config/config_compsets.xml
34+
- FCHIST_GC compset now uses data ice
35+
36+
M src/dynamics/se/gravity_waves_sources.F90
37+
- bug fixes for frontogenesis
38+
39+
If there were any failures reported from running test_driver.sh on any test
40+
platform, and checkin with these failures has been OK'd by the gatekeeper,
41+
then copy the lines from the td.*.status files for the failed tests to the
42+
appropriate machine below. All failed tests must be justified.
43+
44+
derecho/intel/aux_cam:
45+
ERC_D_Ln9.ne30pg2_ne30pg2_mt232.QPC7.derecho_intel.cam-outfrq9s (Overall: DIFF) details:
46+
ERC_D_Ln9.ne30pg3_ne30pg3_mt232.F1850C_LTso.derecho_intel.cam-outfrq9s (Overall: DIFF) details:
47+
ERI_D_Ln18.ne30pg3_ne30pg3_mt232.FHISTC_LTso.derecho_intel.cam-outfrq3s_eri (Overall: DIFF) details:
48+
ERP_D_Ln9.ne30pg3_ne30pg3_mt232.F1850C_MTso.derecho_intel.cam-outfrq9s (Overall: DIFF) details:
49+
ERP_Ld3.ne16pg3_ne16pg3_mg17.FHISTC_WAt1ma.derecho_intel.cam-reduced_hist1d (Overall: DIFF) details:
50+
ERP_Ld3.ne30pg3_ne30pg3_mt232.FHISTC_MTt4s.derecho_intel.cam-outfrq1d_aoa (Overall: DIFF) details:
51+
ERP_Ln9.ne30pg3_ne30pg3_mg17.FCnudged.derecho_intel.cam-outfrq9s (Overall: DIFF) details :
52+
ERP_Ln9.ne30pg3_ne30pg3_mg17.FHISTC_WAma.derecho_intel.cam-outfrq9s (Overall: DIFF) details:
53+
ERS_Ln9.ne30pg3_ne30pg3_mg17.FHISTC_WXma.derecho_intel.cam-outfrq9s_ctem (Overall: DIFF) details:
54+
SMS_C2_D_Ln9.ne16pg3_ne16pg3_mg17.FHISTC_WXma.derecho_intel.cam-outfrq9s (Overall: DIFF) details:
55+
SMS_D_Ln9.ne16_ne16_mg17.QPX2000.derecho_intel.cam-outfrq9s_amie (Overall: DIFF) details:
56+
SMS_D_Ln9.ne30pg3_ne30pg3_mt232.FHISTC_MTso.derecho_intel.cam-outfrq9s (Overall: DIFF) details:
57+
SMS_D_Ln9_P1280x1.ne0CONUSne30x8_ne0CONUSne30x8_mt12.FCHIST.derecho_intel.cam-outfrq9s (Overall: DIFF) details:
58+
SMS_D_Ln9_P1280x1.ne30pg3_ne30pg3_mt232.FHISTC_MTt1s.derecho_intel.cam-outfrq9s_Leung_dust (Overall: DIFF) details:
59+
SMS_Ld1.ne30pg3_ne30pg3_mg17.FC2010climo.derecho_intel.cam-outfrq1d (Overall: DIFF) details:
60+
SMS_Ln9.ne30pg3_ne30pg3_mg17.FW2000climo.derecho_intel.cam-outfrq9s_rrtmgp (Overall: DIFF) details:
61+
- All CAM7 and WACCM tests with SE dycore should have answer changes.
62+
63+
SMS_Ld1.f09_f09_mg17.FCHIST_GC.derecho_intel.cam-outfrq1d (Overall: DIFF) details:
64+
- Answer and namelist changes due to changing CISM to be data ice
65+
66+
derecho/nvhpc/aux_cam:
67+
ERS_Ln9.ne30pg3_ne30pg3_mt232.FHISTC_LTso.derecho_nvhpc.cam-outfrq9s_gpu_default (Overall: DIFF) details:
68+
- All CAM7 and WACCM tests with SE dycore should have answer changes.
69+
70+
izumi/nag/aux_cam:
71+
SMS_D_Ln3.ne5pg3_ne5pg3_mg37.QPX2000.izumi_nag.cam-outfrq3s (Overall: DIFF) details:
72+
SMS_D_Ln6.ne5_ne5_mg37.QPWmaC4.izumi_nag.cam-outfrq3s_physgrid_tem (Overall: DIFF) details:
73+
- All CAM7 and WACCM tests with SE dycore should have answer changes.
74+
75+
76+
izumi/gnu/aux_cam: all BFB
77+
78+
Summarize any changes to answers, i.e.,
79+
- what code configurations:
80+
- All CAM7 and WACCM tests with SE dycore should have answer changes due to using the frontal scheme
81+
82+
- what platforms/compilers:
83+
- all
84+
85+
- nature of change (roundoff; larger than roundoff but same climate; new
86+
climate): climate changing
87+
88+
If this tag changes climate describe the run(s) done to evaluate the new
89+
climate in enough detail that it(they) could be reproduced, i.e.,
90+
- Answers were scientifically verified by Peter and Julio
91+
92+
===============================================================
93+
===============================================================
94+
395
Tag name: cam6_4_125
496
Originator(s): eaton
597
Date: 9 October 2025
@@ -92,7 +184,7 @@ src/physics/cam/macrop_driver.F90
92184
src/physics/cam/micro_pumas_cam.F90
93185
src/physics/cam7/micro_pumas_cam.F90
94186
. remove pbuf fields am_evp_st, evprain_st, evpsnow_st. these are only used by
95-
unicon.
187+
unicon.
96188

97189
src/physics/cam/physpkg.F90
98190
. remove call to unicon_cam_org_diags

src/dynamics/se/gravity_waves_sources.F90

Lines changed: 112 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ subroutine compute_frontogenesis(frontgf,frontga,tl,tlq,elem,ederiv,hybrid,nets,
247247
! Integrated into gravity_waves_sources module, several arguments made global
248248
! to prevent repeated allocation/initialization
249249
!
250+
! Frontogenesis function correction by Walter Hannah, Mark Taylor, and Jack Chen. October 2025
251+
!
250252
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
251253
use physconst, only: cappa
252254
use air_composition,only: dry_air_species_num, thermodynamic_active_species_num
@@ -273,14 +275,46 @@ subroutine compute_frontogenesis(frontgf,frontga,tl,tlq,elem,ederiv,hybrid,nets,
273275
real(r8) :: frontga_gll(np,np,nlev,nets:nete)
274276
integer :: k,kptr,i,j,ie,component,h,nq,m_cnst
275277
real(r8) :: gradth(np,np,2,nlev,nets:nete) ! grad(theta)
276-
real(r8) :: p(np,np) ! pressure at mid points
277-
real(r8) :: pint(np,np) ! pressure at interface points
278-
real(r8) :: theta(np,np) ! potential temperature at mid points
278+
279+
real(r8) :: p(np,np,nlev) ! pressure at mid points
280+
real(r8) :: pint(np,np,nlev+1) ! pressure at interface points
281+
real(r8) :: gradp(np,np,2) ! grad(pressure)
282+
real(r8) :: theta(np,np,nlev) ! potential temperature at mid points
283+
real(r8) :: dtheta_dp(np,np,nlev) ! d(theta)/dp for eta to pressure surface correction
284+
real(r8) :: dum_grad(np,np,2) ! ?
285+
real(r8) :: dum_cart(np,np,3,nlev) ! d/dp of ?
286+
real(r8) :: ddp_dum_cart(np,np,3,nlev) ! ?
279287
real(r8) :: C(np,np,2), sum_water(np,np)
280288

289+
! By Mark Taylor
290+
! For a vector velocity "v", a tensor "grad(v)", and a vector "grad(theta)",
291+
! this loop computes the vector "grad(theta)*grad(v)"
292+
!
293+
! Representing the tensor "grad(v)" in spherical coordinates is difficult. This routine
294+
! avoids this by computing a mathematically equivalent form using a mixture of
295+
! Cartesian and spherical coordinates
296+
!
297+
! This routine is a modified version of derivative_mod.F90:ugradv_sphere() in that the
298+
! grad(v) term is modified to compute grad_p(v) - the gradient on p-surfaces expressed
299+
! in terms of the gradient on model surfaces and a vertical pressure gradient.
300+
!
301+
! First, v is represented in cartesian coordinates v(c) for c=1,2,3
302+
! For each v(c), we compute its gradient on p-surfaces via:
303+
! grad(v(c)) - d(v(c))/dz grad(p)
304+
! Each of these gradients is represented in *spherical* coordinates (i=1,2)
305+
!
306+
! We then dot each of these vectors with grad(theta). This dot product is computed
307+
! in spherical coordinates. The end result is dum_cart(c), for c=1,2,3
308+
! These three scalars are the three Cartesian coefficients of
309+
! the vector "grad(theta)*grad(v)"
310+
!
311+
! This Cartesian vector is then transformed back to spherical coordinates
312+
!
313+
281314
do ie=nets,nete
282315
! pressure at model top
283-
pint(:,:) = hvcoord%hyai(1)*hvcoord%ps0
316+
pint(:,:,1) = hvcoord%hyai(1)*hvcoord%ps0
317+
284318
do k=1,nlev
285319
! moist pressure at mid points
286320
sum_water(:,:) = 1.0_r8
@@ -291,15 +325,49 @@ subroutine compute_frontogenesis(frontgf,frontga,tl,tlq,elem,ederiv,hybrid,nets,
291325
!
292326
sum_water(:,:) = sum_water(:,:) + elem(ie)%state%Qdp(:,:,k,m_cnst,tlq)/elem(ie)%state%dp3d(:,:,k,tl)
293327
end do
294-
p(:,:) = pint(:,:) + 0.5_r8*sum_water(:,:)*elem(ie)%state%dp3d(:,:,k,tl)
328+
p(:,:,k) = pint(:,:,k) + 0.5_r8*sum_water(:,:)*elem(ie)%state%dp3d(:,:,k,tl)
295329
! moist pressure at interface for next iteration
296-
pint(:,:) = pint(:,:)+elem(ie)%state%dp3d(:,:,k,tl)
330+
pint(:,:,k+1) = pint(:,:,k)+elem(ie)%state%dp3d(:,:,k,tl)
297331
!
298-
theta(:,:) = elem(ie)%state%T(:,:,k,tl)*(psurf_ref / p(:,:))**cappa
299-
! gradth(:,:,:,k,ie) = gradient_sphere(theta,ederiv,elem(ie)%Dinv)
300-
call gradient_sphere(theta,ederiv,elem(ie)%Dinv,gradth(:,:,:,k,ie))
301-
! compute C = (grad(theta) dot grad ) u
302-
C(:,:,:) = ugradv_sphere(gradth(:,:,:,k,ie), elem(ie)%state%v(:,:,:,k,tl),ederiv,elem(ie))
332+
theta(:,:,k) = elem(ie)%state%T(:,:,k,tl)*(psurf_ref / p(:,:,k))**cappa
333+
end do
334+
335+
call compute_vertical_derivative(pint,p,theta,dtheta_dp)
336+
337+
do k=1,nlev
338+
call gradient_sphere(theta(:,:,k),ederiv,elem(ie)%Dinv,gradth(:,:,:,k,ie))
339+
340+
call gradient_sphere(p(:,:,k),ederiv,elem(ie)%Dinv,gradp)
341+
342+
do component=1,2
343+
gradth(:,:,component,k,ie) = gradth(:,:,component,k,ie) - dtheta_dp(:,:,k) * gradp(:,:,component)
344+
end do
345+
end do
346+
347+
do k=1,nlev
348+
do component=1,3
349+
dum_cart(:,:,component,k) = sum( elem(ie)%vec_sphere2cart(:,:,component,:) * elem(ie)%state%v(:,:,:,k,tl),3 )
350+
end do
351+
end do
352+
353+
do component=1,3
354+
call compute_vertical_derivative(pint,p,dum_cart(:,:,component,:),ddp_dum_cart(:,:,component,:))
355+
end do
356+
do k=1,nlev
357+
call gradient_sphere(p(:,:,k),ederiv,elem(ie)%Dinv,gradp)
358+
359+
do component=1,3
360+
call gradient_sphere(dum_cart(:,:,component,k),ederiv,elem(ie)%Dinv,dum_grad)
361+
do i=1,2
362+
dum_grad(:,:,i) = dum_grad(:,:,i) - ddp_dum_cart(:,:,component,k) * gradp(:,:,i)
363+
end do
364+
dum_cart(:,:,component,k) = sum( gradth(:,:,:,k,ie) * dum_grad , 3 )
365+
end do
366+
367+
do i=1,2
368+
C(:,:,i) = sum(dum_cart(:,:,:,k)*elem(ie)%vec_sphere2cart(:,:,:,i), 3)
369+
end do
370+
303371
! gradth dot C
304372
frontgf_gll(:,:,k,ie) = -( C(:,:,1)*gradth(:,:,1,k,ie) + C(:,:,2)*gradth(:,:,2,k,ie) )
305373
! apply mass matrix
@@ -351,5 +419,38 @@ subroutine compute_frontogenesis(frontgf,frontga,tl,tlq,elem,ederiv,hybrid,nets,
351419
enddo
352420
end subroutine compute_frontogenesis
353421

422+
subroutine compute_vertical_derivative(pint,pmid,data,ddata_dp)
423+
!---------------------------------------------------------------------------
424+
real(r8), intent(in ) :: pint(np,np,nlev+1)
425+
real(r8), intent(in ) :: pmid(np,np,nlev)
426+
real(r8), intent(in ) :: data(np,np,nlev)
427+
real(r8), intent(out) :: ddata_dp(np,np,nlev)
428+
!---------------------------------------------------------------------------
429+
integer :: k
430+
real(r8) :: pint_above(np,np) ! pressure interpolated to interface above the current k mid-point
431+
real(r8) :: pint_below(np,np) ! pressure interpolated to interface below the current k mid-point
432+
real(r8) :: dint_above(np,np) ! data interpolated to interface above the current k mid-point
433+
real(r8) :: dint_below(np,np) ! data interpolated to interface below the current k mid-point
434+
!---------------------------------------------------------------------------
435+
do k = 1,nlev
436+
if (k==1) then
437+
pint_above = pmid(:,:,k)
438+
pint_below = pint(:,:,k+1)
439+
dint_above = data(:,:,k)
440+
dint_below = ( data(:,:,k+1) + data(:,:,k) ) / 2.0_r8
441+
elseif (k==nlev) then
442+
pint_above = pint(:,:,k)
443+
pint_below = pmid(:,:,k)
444+
dint_above = ( data(:,:,k-1) + data(:,:,k) ) / 2.0_r8
445+
dint_below = data(:,:,k)
446+
else
447+
pint_above = pint(:,:,k)
448+
pint_below = pint(:,:,k+1)
449+
dint_above = ( data(:,:,k-1) + data(:,:,k) ) / 2.0_r8
450+
dint_below = ( data(:,:,k+1) + data(:,:,k) ) / 2.0_r8
451+
end if
452+
ddata_dp(:,:,k) = ( dint_above - dint_below ) / ( pint_above - pint_below )
453+
end do
454+
end subroutine compute_vertical_derivative
354455

355456
end module gravity_waves_sources

0 commit comments

Comments
 (0)