Skip to content

Commit d7080a1

Browse files
authored
Merge pull request #1235 from mwaxmonsky/feature/pbl-utils-atmos-phys-integration
cam6_4_071: PBL_utils atmospheric_physics integration
2 parents e8de158 + a1774df commit d7080a1

File tree

11 files changed

+186
-418
lines changed

11 files changed

+186
-418
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
[submodule "atmos_phys"]
3737
path = src/atmos_phys
3838
url = https://github.com/ESCOMP/atmospheric_physics
39-
fxtag = atmos_phys0_08_000
39+
fxtag = atmos_phys0_09_000
4040
fxrequired = AlwaysRequired
4141
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics
4242

bld/configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,7 @@ sub write_filepath
21492149
# in the list of filepaths.
21502150
print $fh "$camsrcdir/src/physics/cam\n";
21512151
print $fh "$camsrcdir/src/atmos_phys/to_be_ccppized\n";
2152+
print $fh "$camsrcdir/src/atmos_phys/phys_utils\n";
21522153

21532154
#Add the CCPP'ized subdirectories
21542155
print $fh "$camsrcdir/src/atmos_phys/schemes/tropopause_find\n";

doc/ChangeLog

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,80 @@
11
===============================================================
22

3+
Tag name: cam6_4_071
4+
Originator(s): mwaxmonsky
5+
Date: 26 February 2025
6+
One-line Summary: PBL_utils atmospheric_physics integration
7+
Github PR URL: https://github.com/ESCOMP/CAM/pull/1235
8+
9+
Purpose of changes (include the issue number and title text for each relevant GitHub issue):
10+
11+
Closes #1235 - Integrates PBL now from atmospheric_physics to enable further
12+
vertical diffusion CCPP-ization
13+
14+
Describe any changes made to build system: N/A
15+
16+
Describe any changes made to the namelist: N/A
17+
18+
List any changes to the defaults for the boundary datasets: N/A
19+
20+
Describe any substantial timing or memory changes: N/A
21+
22+
Code reviewed by: nusbaume
23+
24+
List all files eliminated: N/A
25+
26+
List all files added and what they do: N/A
27+
28+
List all existing files that have been modified, and describe the changes:
29+
30+
M .gitmodules
31+
M src/atmos_phys
32+
- Updates atmos_phys submodule
33+
34+
M bld/configure
35+
- Add phys utils which now contains refactored PBL utils code
36+
37+
M src/physics/cam/clubb_intr.F90
38+
M src/physics/cam/eddy_diff_cam.F90
39+
M src/physics/cam/hb_diff.F90
40+
M src/physics/cam/pbl_utils.F90
41+
M src/physics/cam/vertical_diffusion.F90
42+
- Updates old PBL references to new PBL interface API
43+
44+
M src/physics/cam/physpkg.F90
45+
M src/physics/cam7/physpkg.F90
46+
- Removing `pbl_utils_init()` call as no longer needed
47+
48+
49+
If there were any failures reported from running test_driver.sh on any test
50+
platform, and checkin with these failures has been OK'd by the gatekeeper,
51+
then copy the lines from the td.*.status files for the failed tests to the
52+
appropriate machine below. All failed tests must be justified.
53+
54+
derecho/intel/aux_cam:
55+
56+
ERP_Ln9.f09_f09_mg17.FCSD_HCO.derecho_intel.cam-outfrq9s (Overall: FAIL)
57+
SMS_Ld1.f09_f09_mg17.FCHIST_GC.derecho_intel.cam-outfrq1d (Overall: DIFF)
58+
- pre-existing failures due to HEMCO not having reproducible results (issues #1018 and #856)
59+
60+
SMS_D_Ln9.f19_f19_mg17.FXHIST.derecho_intel.cam-outfrq9s_amie (Overall: FAIL)
61+
SMS_D_Ln9_P1280x1.ne0CONUSne30x8_ne0CONUSne30x8_mt12.FCHIST.derecho_intel.cam-outfrq9s (Overall: FAIL)
62+
- pre-existing failures due to build-namelist error requiring CLM/CTSM external update
63+
64+
derecho/nvhpc/aux_cam: ALL PASS
65+
66+
izumi/nag/aux_cam: ALL PASS
67+
68+
izumi/gnu/aux_cam: ALL PASS
69+
70+
CAM tag used for the baseline comparison tests if different than previous
71+
tag:
72+
73+
Summarize any changes to answers: b4b
74+
75+
===============================================================
76+
===============================================================
77+
378
Tag name: cam6_4_070
479
Originator(s): patcal, nusbaume
580
Date: 22 February 2025

src/atmos_phys

Submodule atmos_phys updated 35 files

src/physics/cam/clubb_intr.F90

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ module clubb_intr
2020
use shr_kind_mod, only: r8=>shr_kind_r8
2121
use ppgrid, only: pver, pverp, pcols, begchunk, endchunk
2222
use phys_control, only: phys_getopts
23-
use physconst, only: cpair, gravit, rga, latvap, latice, zvir, rh2o, karman, pi
23+
use physconst, only: cpair, gravit, rga, latvap, latice, zvir, rh2o, karman, pi, rair
2424
use air_composition, only: rairv, cpairv
2525
use cam_history_support, only: max_fieldname_len
2626

2727
use spmd_utils, only: masterproc
2828
use constituents, only: pcnst, cnst_add
29-
use pbl_utils, only: calc_ustar, calc_obklen
29+
use atmos_phys_pbl_utils,only: calc_friction_velocity, calc_kinematic_heat_flux, calc_ideal_gas_rrho, &
30+
calc_kinematic_water_vapor_flux, calc_kinematic_buoyancy_flux, calc_obukhov_length
3031
use ref_pres, only: top_lev => trop_cloud_top_lev
3132

3233
#ifdef CLUBB_SGS
@@ -3491,8 +3492,8 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
34913492
ubar = sqrt(state1%u(i,pver)**2+state1%v(i,pver)**2)
34923493
if (ubar < 0.25_r8) ubar = 0.25_r8
34933494

3494-
call calc_ustar( state1%t(i,pver), state1%pmid(i,pver), cam_in%wsx(i), cam_in%wsy(i), &
3495-
rrho(i), ustar )
3495+
rrho(i) = calc_ideal_gas_rrho(rair, state1%t(i,pver), state1%pmid(i,pver))
3496+
ustar = calc_friction_velocity(cam_in%wsx(i), cam_in%wsy(i), rrho(i))
34963497

34973498
upwp_sfc(i) = -state1%u(i,pver)*ustar**2/ubar
34983499
vpwp_sfc(i) = -state1%v(i,pver)*ustar**2/ubar
@@ -4706,13 +4707,13 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
47064707
enddo
47074708

47084709
! diagnose surface friction and obukhov length (inputs to diagnose PBL depth)
4709-
rrho(1:ncol) = (rga)*(state1%pdel(1:ncol,pver)/dz_g(1:ncol,pver))
4710-
call calc_ustar( ncol, state1%t(1:ncol,pver), state1%pmid(1:ncol,pver), cam_in%wsx(1:ncol), cam_in%wsy(1:ncol), &
4711-
rrho(1:ncol), ustar2(1:ncol))
4710+
rrho (1:ncol) = calc_ideal_gas_rrho(rair, state1%t(1:ncol,pver), state1%pmid(1:ncol,pver))
4711+
ustar2 (1:ncol) = calc_friction_velocity(cam_in%wsx(1:ncol), cam_in%wsy(1:ncol), rrho(1:ncol))
47124712
! use correct qflux from coupler
4713-
call calc_obklen( ncol, th(1:ncol,pver), thv(1:ncol,pver), cam_in%cflx(1:ncol,1), cam_in%shf(1:ncol), &
4714-
rrho(1:ncol), ustar2(1:ncol), kinheat(1:ncol), kinwat(1:ncol), kbfs(1:ncol), &
4715-
obklen(1:ncol))
4713+
kinheat(1:ncol) = calc_kinematic_heat_flux(cam_in%shf(1:ncol), rrho(1:ncol), cpair)
4714+
kinwat (1:ncol) = calc_kinematic_water_vapor_flux(cam_in%cflx(1:ncol,1), rrho(1:ncol))
4715+
kbfs (1:ncol) = calc_kinematic_buoyancy_flux(kinheat(1:ncol), zvir, th(1:ncol,pver), kinwat(1:ncol))
4716+
obklen (1:ncol) = calc_obukhov_length(thv(1:ncol,pver), ustar2(1:ncol), gravit, karman, kbfs(1:ncol))
47164717

47174718
dummy2(:) = 0._r8
47184719
dummy3(:) = 0._r8

src/physics/cam/eddy_diff_cam.F90

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -424,16 +424,16 @@ subroutine compute_eddy_diff( pbuf, lchnk ,
424424
! May. 2008. !
425425
!-------------------------------------------------------------------- !
426426

427-
use diffusion_solver, only: compute_vdiff
428-
use cam_history, only: outfld
429-
use phys_debug_util, only: phys_debug_col
430-
use air_composition, only: cpairv
431-
use pbl_utils, only: calc_ustar, austausch_atm
432-
use error_messages, only: handle_errmsg
433-
use coords_1d, only: Coords1D
434-
use wv_saturation, only: qsat
435-
use eddy_diff, only: trbintd, caleddy
436-
use physics_buffer, only: pbuf_get_field
427+
use diffusion_solver, only: compute_vdiff
428+
use cam_history, only: outfld
429+
use phys_debug_util, only: phys_debug_col
430+
use air_composition, only: cpairv
431+
use atmos_phys_pbl_utils, only: calc_eddy_flux_coefficient, calc_ideal_gas_rrho, calc_friction_velocity
432+
use error_messages, only: handle_errmsg
433+
use coords_1d, only: Coords1D
434+
use wv_saturation, only: qsat
435+
use eddy_diff, only: trbintd, caleddy
436+
use physics_buffer, only: pbuf_get_field
437437

438438
! --------------- !
439439
! Input Variables !
@@ -670,10 +670,11 @@ subroutine compute_eddy_diff( pbuf, lchnk ,
670670
! I am using updated wind, here.
671671

672672
! Compute ustar
673-
call calc_ustar( ncol, tfd(:ncol,pver), pmid(:ncol,pver), &
674-
taux(:ncol) - ksrftms(:ncol) * ufd(:ncol,pver), & ! Zonal wind stress
675-
tauy(:ncol) - ksrftms(:ncol) * vfd(:ncol,pver), & ! Meridional wind stress
676-
rrho(:ncol), ustar(:ncol))
673+
rrho(:ncol) = calc_ideal_gas_rrho(rair, tfd(:ncol,pver), pmid(:ncol,pver))
674+
ustar(:ncol) = calc_friction_velocity(taux(:ncol) - ksrftms(:ncol) * ufd(:ncol,pver), & ! Zonal wind stress
675+
tauy(:ncol) - ksrftms(:ncol) * vfd(:ncol,pver), & ! Meridional wind stress
676+
rrho(:ncol))
677+
677678
minpblh(:ncol) = 100.0_r8 * ustar(:ncol) ! By construction, 'minpblh' is larger than 1 [m] when 'ustar_min = 0.01'.
678679

679680
! Calculate (qt,sl,n2,s2,ri) from a given set of (t,qv,ql,qi,u,v)
@@ -694,8 +695,12 @@ subroutine compute_eddy_diff( pbuf, lchnk ,
694695

695696
! Get free atmosphere exchange coefficients. This 'kvf' is not used in UW moist PBL scheme
696697
if (use_kvf) then
697-
call austausch_atm(pcols, ncol, pver, ntop_eddy, nbot_eddy, &
698-
ml2, ri, s2, kvf )
698+
kvf(:ncol,:) = 0.0_r8
699+
do k = ntop_eddy, nbot_eddy-1
700+
do i = 1, ncol
701+
kvf(i,k+1) = calc_eddy_flux_coefficient(ml2(k), ri(i, k), s2(i, k))
702+
end do
703+
end do
699704
else
700705
kvf = 0._r8
701706
end if

src/physics/cam/hb_diff.F90

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module hb_diff
1111
! Private methods:
1212
! trbintd initializes time dependent variables
1313
! pblintd initializes time dependent variables that depend pbl depth
14-
! austausch_atm computes free atmosphere exchange coefficients
1514
! austausch_pbl computes pbl exchange coefficients
1615
!
1716
!---------------------------Code history--------------------------------
@@ -150,13 +149,16 @@ subroutine compute_hb_diff(ncol , &
150149
!
151150
!-----------------------------------------------------------------------
152151

153-
use pbl_utils, only: virtem, calc_ustar, calc_obklen, austausch_atm
152+
use atmos_phys_pbl_utils, only: calc_virtual_temperature, calc_friction_velocity, calc_obukhov_length, &
153+
calc_eddy_flux_coefficient, calc_ideal_gas_rrho, calc_kinematic_heat_flux, calc_kinematic_water_vapor_flux, &
154+
calc_kinematic_buoyancy_flux
155+
use physconst, only: zvir, rair, gravit, karman
154156

155157
!------------------------------Arguments--------------------------------
156158
!
157159
! Input arguments
158160
!
159-
integer, intent(in) :: ncol ! number of atmospheric columns
161+
integer, intent(in) :: ncol ! number of atmospheric columns
160162

161163
real(r8), intent(in) :: th(pcols,pver) ! potential temperature [K]
162164
real(r8), intent(in) :: t(pcols,pver) ! temperature (used for density)
@@ -203,20 +205,22 @@ subroutine compute_hb_diff(ncol , &
203205
real(r8) :: n2(pcols,pver) ! brunt vaisaila frequency
204206
real(r8) :: bge(pcols) ! buoyancy gradient enhancment
205207
integer :: ktopbl(pcols) ! index of first midpoint inside pbl
208+
integer :: i,k
206209
!
207210
! Initialize time dependent variables that do not depend on pbl height
208211
!
209212

210213
! virtual temperature
211-
call virtem(ncol, (pver-ntop_turb+1), th(:ncol,ntop_turb:),q(:ncol,ntop_turb:), thv(:ncol,ntop_turb:))
214+
thv(:ncol,ntop_turb:) = calc_virtual_temperature(th(:ncol,ntop_turb:),q(:ncol,ntop_turb:), zvir)
212215

213216
! Compute ustar, Obukhov length, and kinematic surface fluxes.
214-
call calc_ustar(ncol, t(:ncol,pver),pmid(:ncol,pver),taux(:ncol),tauy(:ncol), &
215-
rrho(:ncol),ustar(:ncol))
216-
call calc_obklen(ncol, th(:ncol,pver), thv(:ncol,pver), qflx(:ncol), &
217-
shflx(:ncol), rrho(:ncol), ustar(:ncol), &
218-
khfs(:ncol), kqfs(:ncol), kbfs(:ncol), &
219-
obklen(:ncol))
217+
rrho(:ncol) = calc_ideal_gas_rrho(rair, t(:ncol,pver), pmid(:ncol,pver))
218+
ustar(:ncol) = calc_friction_velocity(taux(:ncol),tauy(:ncol), rrho(:ncol))
219+
khfs(:ncol) = calc_kinematic_heat_flux(shflx(:ncol), rrho(:ncol), cpair)
220+
kqfs(:ncol) = calc_kinematic_water_vapor_flux(qflx(:ncol), rrho(:ncol))
221+
kbfs(:ncol) = calc_kinematic_buoyancy_flux(khfs(:ncol), zvir, th(:ncol,pver), kqfs(:ncol))
222+
obklen(:ncol) = calc_obukhov_length(thv(:ncol,pver), ustar(:ncol), gravit, karman, kbfs(:ncol))
223+
220224
! Calculate s2, n2, and Richardson number.
221225
call trbintd(ncol , &
222226
thv ,z ,u ,v , &
@@ -229,10 +233,15 @@ subroutine compute_hb_diff(ncol , &
229233
ustar ,obklen ,kbfs ,pblh ,wstar , &
230234
zi ,cldn ,ocnfrac ,bge )
231235
!
232-
! Get free atmosphere exchange coefficients
236+
! Get atmosphere exchange coefficients
233237
!
234-
call austausch_atm(pcols, ncol, pver, ntop_turb, nbot_turb, &
235-
ml2, ri, s2, kvf)
238+
kvf(:ncol,:) = 0.0_r8
239+
do k = ntop_turb, nbot_turb-1
240+
do i = 1, ncol
241+
kvf(i,k+1) = calc_eddy_flux_coefficient(ml2(k), ri(i, k), s2(i, k))
242+
end do
243+
end do
244+
236245
!
237246
! Get pbl exchange coefficients
238247
!
@@ -262,7 +271,10 @@ subroutine compute_hb_free_atm_diff(ncol, &
262271
!
263272
!-----------------------------------------------------------------------
264273

265-
use pbl_utils, only: virtem, calc_ustar, calc_obklen, austausch_atm_free
274+
use atmos_phys_pbl_utils, only: calc_virtual_temperature, calc_friction_velocity, calc_obukhov_length, &
275+
calc_free_atm_eddy_flux_coefficient, calc_ideal_gas_rrho, calc_kinematic_heat_flux, calc_kinematic_water_vapor_flux, &
276+
calc_kinematic_buoyancy_flux
277+
use physconst, only: zvir, rair, gravit, karman
266278

267279
!------------------------------Arguments--------------------------------
268280
!
@@ -303,26 +315,31 @@ subroutine compute_hb_free_atm_diff(ncol, &
303315
real(r8) :: kvf(pcols,pverp) ! free atmospheric eddy diffsvty [m2/s]
304316
real(r8) :: s2(pcols,pver) ! shear squared
305317
real(r8) :: n2(pcols,pver) ! brunt vaisaila frequency
318+
integer :: i, k
306319

307320
! virtual potential temperature
308-
call virtem(ncol, (pver-ntop_turb+1), th(:ncol,ntop_turb:),q(:ncol,ntop_turb:), thv(:ncol,ntop_turb:))
321+
thv(:ncol,ntop_turb:) = calc_virtual_temperature(th(:ncol,ntop_turb:),q(:ncol,ntop_turb:), zvir)
309322

310323
! Compute ustar, Obukhov length, and kinematic surface fluxes.
311-
call calc_ustar(ncol, t(:ncol,pver),pmid(:ncol,pver),taux(:ncol),tauy(:ncol), &
312-
rrho(:ncol),ustar(:ncol))
313-
call calc_obklen(ncol, th(:ncol,pver), thv(:ncol,pver), qflx(:ncol), &
314-
shflx(:ncol), rrho(:ncol), ustar(:ncol), &
315-
khfs(:ncol), kqfs(:ncol), kbfs(:ncol), &
316-
obklen(:ncol))
324+
rrho(:ncol) = calc_ideal_gas_rrho(rair, t(:ncol,pver), pmid(:ncol,pver))
325+
ustar(:ncol) = calc_friction_velocity(taux(:ncol),tauy(:ncol), rrho(:ncol))
326+
khfs(:ncol) = calc_kinematic_heat_flux(shflx(:ncol), rrho(:ncol), cpair)
327+
kqfs(:ncol) = calc_kinematic_water_vapor_flux(qflx(:ncol), rrho(:ncol))
328+
kbfs(:ncol) = calc_kinematic_buoyancy_flux(khfs(:ncol), zvir, th(:ncol,pver), kqfs(:ncol))
329+
obklen(:ncol) = calc_obukhov_length(thv(:ncol,pver), ustar(:ncol), gravit, karman, kbfs(:ncol))
317330
! Calculate s2, n2, and Richardson number.
318331
call trbintd(ncol , &
319332
thv ,z ,u ,v , &
320333
s2 ,n2 ,ri )
321334
!
322335
! Get free atmosphere exchange coefficients
323336
!
324-
call austausch_atm_free(pcols, ncol, pver, ntop_turb, nbot_turb, &
325-
ml2, ri, s2, kvf)
337+
kvf(:ncol,:) = 0.0_r8
338+
do k = ntop_turb, nbot_turb - 1
339+
do i = 1, ncol
340+
kvf(i,k+1) = calc_free_atm_eddy_flux_coefficient(ml2(k), ri(i, k), s2(i, k))
341+
end do
342+
end do
326343

327344
kvq(:ncol,:) = kvf(:ncol,:)
328345
kvm(:ncol,:) = kvf(:ncol,:)

0 commit comments

Comments
 (0)