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

cam6_4_071: PBL_utils atmospheric_physics integration #1235

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
514718e
Initial attempt at calling atmos_phys physics utils layer.
mwaxmonsky Jan 15, 2025
beb93e1
Initial integration of elemental austausch.
mwaxmonsky Jan 21, 2025
f48e48f
Updating atmos_phys to pbl utils branch and updating CIME ref to fix …
mwaxmonsky Jan 21, 2025
e9b8516
Updating to latest atmos_phys fixes. Adding atmos_phys phys_utils di…
mwaxmonsky Jan 22, 2025
e33da71
Initial PBL utils refactor for ccpp-ization.
mwaxmonsky Jan 23, 2025
e295c91
Remove dead code and add missing rrho function that was in calc_ustar.
mwaxmonsky Jan 23, 2025
6987d6a
Re-implement virtual temperature and obukhov length to fix diag_TKE t…
mwaxmonsky Jan 23, 2025
b25f801
Fix incorrect parameters.
mwaxmonsky Jan 23, 2025
7384651
Updating to latest atmos_phys branch.
mwaxmonsky Jan 23, 2025
2b391d2
Merge branch 'cam_development' into feature/pbl-utils-atmos-phys-inte…
mwaxmonsky Jan 24, 2025
ca5df2f
Updating loop whitespace.
mwaxmonsky Jan 24, 2025
eedf005
Updating loop whitespace.
mwaxmonsky Jan 24, 2025
049f657
Spacing updates.
mwaxmonsky Jan 24, 2025
c551de7
Spacing update.
mwaxmonsky Jan 24, 2025
445bcbe
Updating austausch_atm references to new function names.
mwaxmonsky Jan 28, 2025
e8e5d55
Merging in latest changes from atmos_phys.
mwaxmonsky Jan 28, 2025
e910a27
Resolving merge conflict merging 'cam_development' into 'feature/pbl-…
mwaxmonsky Feb 10, 2025
601919c
Resolving merge conflict merging 'cam_development' into 'feature/pbl-…
mwaxmonsky Feb 24, 2025
e776da5
Updating atmos_phys to latest tag.
mwaxmonsky Feb 24, 2025
29f7768
Converting reference from 'calc_rrho' to 'calc_ideal_gas_rrho' from l…
mwaxmonsky Feb 24, 2025
9c324a2
Merge branch 'cam_development' into feature/pbl-utils-atmos-phys-inte…
mwaxmonsky Feb 24, 2025
bb7e7d5
Updating atmos_phys to latest tag.
mwaxmonsky Feb 24, 2025
a1774df
Updating ChangeLog.
mwaxmonsky Feb 26, 2025
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
[submodule "atmos_phys"]
path = src/atmos_phys
url = https://github.com/ESCOMP/atmospheric_physics
fxtag = atmos_phys0_08_000
fxtag = atmos_phys0_09_000
fxrequired = AlwaysRequired
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics

Expand Down
1 change: 1 addition & 0 deletions bld/configure
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,7 @@ sub write_filepath
# in the list of filepaths.
print $fh "$camsrcdir/src/physics/cam\n";
print $fh "$camsrcdir/src/atmos_phys/to_be_ccppized\n";
print $fh "$camsrcdir/src/atmos_phys/phys_utils\n";

#Add the CCPP'ized subdirectories
print $fh "$camsrcdir/src/atmos_phys/schemes/tropopause_find\n";
Expand Down
75 changes: 75 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,80 @@
===============================================================

Tag name: cam6_4_071
Originator(s): mwaxmonsky
Date: 26 February 2025
One-line Summary: PBL_utils atmospheric_physics integration
Github PR URL: https://github.com/ESCOMP/CAM/pull/1235

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

Closes #1235 - Integrates PBL now from atmospheric_physics to enable further
vertical diffusion CCPP-ization

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: nusbaume

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:

M .gitmodules
M src/atmos_phys
- Updates atmos_phys submodule

M bld/configure
- Add phys utils which now contains refactored PBL utils code

M src/physics/cam/clubb_intr.F90
M src/physics/cam/eddy_diff_cam.F90
M src/physics/cam/hb_diff.F90
M src/physics/cam/pbl_utils.F90
M src/physics/cam/vertical_diffusion.F90
- Updates old PBL references to new PBL interface API

M src/physics/cam/physpkg.F90
M src/physics/cam7/physpkg.F90
- Removing `pbl_utils_init()` call as no longer needed


If there were any failures reported from running test_driver.sh on any test
platform, and checkin with these failures has been OK'd by the gatekeeper,
then copy the lines from the td.*.status files for the failed tests to the
appropriate machine below. All failed tests must be justified.

derecho/intel/aux_cam:

ERP_Ln9.f09_f09_mg17.FCSD_HCO.derecho_intel.cam-outfrq9s (Overall: FAIL)
SMS_Ld1.f09_f09_mg17.FCHIST_GC.derecho_intel.cam-outfrq1d (Overall: DIFF)
- pre-existing failures due to HEMCO not having reproducible results (issues #1018 and #856)

SMS_D_Ln9.f19_f19_mg17.FXHIST.derecho_intel.cam-outfrq9s_amie (Overall: FAIL)
SMS_D_Ln9_P1280x1.ne0CONUSne30x8_ne0CONUSne30x8_mt12.FCHIST.derecho_intel.cam-outfrq9s (Overall: FAIL)
- pre-existing failures due to build-namelist error requiring CLM/CTSM external update

derecho/nvhpc/aux_cam: ALL PASS

izumi/nag/aux_cam: ALL PASS

izumi/gnu/aux_cam: ALL PASS

CAM tag used for the baseline comparison tests if different than previous
tag:

Summarize any changes to answers: b4b

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

Tag name: cam6_4_070
Originator(s): patcal, nusbaume
Date: 22 February 2025
Expand Down
2 changes: 1 addition & 1 deletion src/atmos_phys
Submodule atmos_phys updated 35 files
+18 −0 .github/PULL_REQUEST_TEMPLATE/develop-template.md
+6 −0 .github/PULL_REQUEST_TEMPLATE/main-template.md
+4 −0 .github/pull_request_template.md
+1 −1 .github/workflows/unit-tests.yaml
+205 −203 doc/NamesNotInDictionary.txt
+216 −0 phys_utils/atmos_phys_pbl_utils.F90
+1 −1 schemes/check_energy/check_energy_chng.meta
+2 −2 schemes/check_energy/check_energy_gmean/check_energy_gmean.meta
+1 −1 schemes/check_energy/check_energy_save_teout.meta
+12 −12 schemes/musica/musica_ccpp.F90
+7 −2 schemes/musica/musica_ccpp.meta
+3 −3 schemes/musica/musica_ccpp_namelist.xml
+12 −11 schemes/musica/tuvx/musica_ccpp_tuvx.F90
+3 −3 schemes/musica/tuvx/musica_ccpp_tuvx_surface_albedo.F90
+2 −9 schemes/sima_diagnostics/check_energy_diagnostics.F90
+0 −12 schemes/sima_diagnostics/check_energy_diagnostics.meta
+73 −0 schemes/sima_diagnostics/check_energy_fix_diagnostics.F90
+59 −0 schemes/sima_diagnostics/check_energy_fix_diagnostics.meta
+1 −1 schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta
+66 −2 schemes/sima_diagnostics/sima_state_diagnostics.F90
+50 −0 schemes/thermo_water_update/thermo_water_update.F90
+50 −0 schemes/thermo_water_update/thermo_water_update.meta
+7 −3 suites/suite_adiabatic.xml
+0 −202 suites/suite_cam4.xml
+0 −364 suites/suite_cam6.xml
+0 −379 suites/suite_cam6_silhs.xml
+10 −3 suites/suite_cam7.xml
+4 −0 suites/suite_kessler.xml
+3 −0 suites/suite_tj2016.xml
+6 −6 test/musica/test_musica_api.F90
+24 −0 test/test_suites/suite_kessler_test.xml
+9 −0 test/unit-test/CMakeLists.txt
+1 −1 test/unit-test/tests/CMakeLists.txt
+4 −0 test/unit-test/tests/phys_utils/CMakeLists.txt
+25 −0 test/unit-test/tests/phys_utils/test_atmos_pbl_utils.pf
21 changes: 11 additions & 10 deletions src/physics/cam/clubb_intr.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ module clubb_intr
use shr_kind_mod, only: r8=>shr_kind_r8
use ppgrid, only: pver, pverp, pcols, begchunk, endchunk
use phys_control, only: phys_getopts
use physconst, only: cpair, gravit, rga, latvap, latice, zvir, rh2o, karman, pi
use physconst, only: cpair, gravit, rga, latvap, latice, zvir, rh2o, karman, pi, rair
use air_composition, only: rairv, cpairv
use cam_history_support, only: max_fieldname_len

use spmd_utils, only: masterproc
use constituents, only: pcnst, cnst_add
use pbl_utils, only: calc_ustar, calc_obklen
use atmos_phys_pbl_utils,only: calc_friction_velocity, calc_kinematic_heat_flux, calc_ideal_gas_rrho, &
calc_kinematic_water_vapor_flux, calc_kinematic_buoyancy_flux, calc_obukhov_length
use ref_pres, only: top_lev => trop_cloud_top_lev

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

call calc_ustar( state1%t(i,pver), state1%pmid(i,pver), cam_in%wsx(i), cam_in%wsy(i), &
rrho(i), ustar )
rrho(i) = calc_ideal_gas_rrho(rair, state1%t(i,pver), state1%pmid(i,pver))
ustar = calc_friction_velocity(cam_in%wsx(i), cam_in%wsy(i), rrho(i))

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

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

dummy2(:) = 0._r8
dummy3(:) = 0._r8
Expand Down
37 changes: 21 additions & 16 deletions src/physics/cam/eddy_diff_cam.F90
Original file line number Diff line number Diff line change
Expand Up @@ -424,16 +424,16 @@ subroutine compute_eddy_diff( pbuf, lchnk ,
! May. 2008. !
!-------------------------------------------------------------------- !

use diffusion_solver, only: compute_vdiff
use cam_history, only: outfld
use phys_debug_util, only: phys_debug_col
use air_composition, only: cpairv
use pbl_utils, only: calc_ustar, austausch_atm
use error_messages, only: handle_errmsg
use coords_1d, only: Coords1D
use wv_saturation, only: qsat
use eddy_diff, only: trbintd, caleddy
use physics_buffer, only: pbuf_get_field
use diffusion_solver, only: compute_vdiff
use cam_history, only: outfld
use phys_debug_util, only: phys_debug_col
use air_composition, only: cpairv
use atmos_phys_pbl_utils, only: calc_eddy_flux_coefficient, calc_ideal_gas_rrho, calc_friction_velocity
use error_messages, only: handle_errmsg
use coords_1d, only: Coords1D
use wv_saturation, only: qsat
use eddy_diff, only: trbintd, caleddy
use physics_buffer, only: pbuf_get_field

! --------------- !
! Input Variables !
Expand Down Expand Up @@ -670,10 +670,11 @@ subroutine compute_eddy_diff( pbuf, lchnk ,
! I am using updated wind, here.

! Compute ustar
call calc_ustar( ncol, tfd(:ncol,pver), pmid(:ncol,pver), &
taux(:ncol) - ksrftms(:ncol) * ufd(:ncol,pver), & ! Zonal wind stress
tauy(:ncol) - ksrftms(:ncol) * vfd(:ncol,pver), & ! Meridional wind stress
rrho(:ncol), ustar(:ncol))
rrho(:ncol) = calc_ideal_gas_rrho(rair, tfd(:ncol,pver), pmid(:ncol,pver))
ustar(:ncol) = calc_friction_velocity(taux(:ncol) - ksrftms(:ncol) * ufd(:ncol,pver), & ! Zonal wind stress
tauy(:ncol) - ksrftms(:ncol) * vfd(:ncol,pver), & ! Meridional wind stress
rrho(:ncol))

minpblh(:ncol) = 100.0_r8 * ustar(:ncol) ! By construction, 'minpblh' is larger than 1 [m] when 'ustar_min = 0.01'.

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

! Get free atmosphere exchange coefficients. This 'kvf' is not used in UW moist PBL scheme
if (use_kvf) then
call austausch_atm(pcols, ncol, pver, ntop_eddy, nbot_eddy, &
ml2, ri, s2, kvf )
kvf(:ncol,:) = 0.0_r8
do k = ntop_eddy, nbot_eddy-1
do i = 1, ncol
kvf(i,k+1) = calc_eddy_flux_coefficient(ml2(k), ri(i, k), s2(i, k))
end do
end do
else
kvf = 0._r8
end if
Expand Down
63 changes: 40 additions & 23 deletions src/physics/cam/hb_diff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module hb_diff
! Private methods:
! trbintd initializes time dependent variables
! pblintd initializes time dependent variables that depend pbl depth
! austausch_atm computes free atmosphere exchange coefficients
! austausch_pbl computes pbl exchange coefficients
!
!---------------------------Code history--------------------------------
Expand Down Expand Up @@ -150,13 +149,16 @@ subroutine compute_hb_diff(ncol , &
!
!-----------------------------------------------------------------------

use pbl_utils, only: virtem, calc_ustar, calc_obklen, austausch_atm
use atmos_phys_pbl_utils, only: calc_virtual_temperature, calc_friction_velocity, calc_obukhov_length, &
calc_eddy_flux_coefficient, calc_ideal_gas_rrho, calc_kinematic_heat_flux, calc_kinematic_water_vapor_flux, &
calc_kinematic_buoyancy_flux
use physconst, only: zvir, rair, gravit, karman

!------------------------------Arguments--------------------------------
!
! Input arguments
!
integer, intent(in) :: ncol ! number of atmospheric columns
integer, intent(in) :: ncol ! number of atmospheric columns

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

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

! Compute ustar, Obukhov length, and kinematic surface fluxes.
call calc_ustar(ncol, t(:ncol,pver),pmid(:ncol,pver),taux(:ncol),tauy(:ncol), &
rrho(:ncol),ustar(:ncol))
call calc_obklen(ncol, th(:ncol,pver), thv(:ncol,pver), qflx(:ncol), &
shflx(:ncol), rrho(:ncol), ustar(:ncol), &
khfs(:ncol), kqfs(:ncol), kbfs(:ncol), &
obklen(:ncol))
rrho(:ncol) = calc_ideal_gas_rrho(rair, t(:ncol,pver), pmid(:ncol,pver))
ustar(:ncol) = calc_friction_velocity(taux(:ncol),tauy(:ncol), rrho(:ncol))
khfs(:ncol) = calc_kinematic_heat_flux(shflx(:ncol), rrho(:ncol), cpair)
kqfs(:ncol) = calc_kinematic_water_vapor_flux(qflx(:ncol), rrho(:ncol))
kbfs(:ncol) = calc_kinematic_buoyancy_flux(khfs(:ncol), zvir, th(:ncol,pver), kqfs(:ncol))
obklen(:ncol) = calc_obukhov_length(thv(:ncol,pver), ustar(:ncol), gravit, karman, kbfs(:ncol))

! Calculate s2, n2, and Richardson number.
call trbintd(ncol , &
thv ,z ,u ,v , &
Expand All @@ -229,10 +233,15 @@ subroutine compute_hb_diff(ncol , &
ustar ,obklen ,kbfs ,pblh ,wstar , &
zi ,cldn ,ocnfrac ,bge )
!
! Get free atmosphere exchange coefficients
! Get atmosphere exchange coefficients
!
call austausch_atm(pcols, ncol, pver, ntop_turb, nbot_turb, &
ml2, ri, s2, kvf)
kvf(:ncol,:) = 0.0_r8
do k = ntop_turb, nbot_turb-1
do i = 1, ncol
kvf(i,k+1) = calc_eddy_flux_coefficient(ml2(k), ri(i, k), s2(i, k))
end do
end do

!
! Get pbl exchange coefficients
!
Expand Down Expand Up @@ -262,7 +271,10 @@ subroutine compute_hb_free_atm_diff(ncol, &
!
!-----------------------------------------------------------------------

use pbl_utils, only: virtem, calc_ustar, calc_obklen, austausch_atm_free
use atmos_phys_pbl_utils, only: calc_virtual_temperature, calc_friction_velocity, calc_obukhov_length, &
calc_free_atm_eddy_flux_coefficient, calc_ideal_gas_rrho, calc_kinematic_heat_flux, calc_kinematic_water_vapor_flux, &
calc_kinematic_buoyancy_flux
use physconst, only: zvir, rair, gravit, karman

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

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

! Compute ustar, Obukhov length, and kinematic surface fluxes.
call calc_ustar(ncol, t(:ncol,pver),pmid(:ncol,pver),taux(:ncol),tauy(:ncol), &
rrho(:ncol),ustar(:ncol))
call calc_obklen(ncol, th(:ncol,pver), thv(:ncol,pver), qflx(:ncol), &
shflx(:ncol), rrho(:ncol), ustar(:ncol), &
khfs(:ncol), kqfs(:ncol), kbfs(:ncol), &
obklen(:ncol))
rrho(:ncol) = calc_ideal_gas_rrho(rair, t(:ncol,pver), pmid(:ncol,pver))
ustar(:ncol) = calc_friction_velocity(taux(:ncol),tauy(:ncol), rrho(:ncol))
khfs(:ncol) = calc_kinematic_heat_flux(shflx(:ncol), rrho(:ncol), cpair)
kqfs(:ncol) = calc_kinematic_water_vapor_flux(qflx(:ncol), rrho(:ncol))
kbfs(:ncol) = calc_kinematic_buoyancy_flux(khfs(:ncol), zvir, th(:ncol,pver), kqfs(:ncol))
obklen(:ncol) = calc_obukhov_length(thv(:ncol,pver), ustar(:ncol), gravit, karman, kbfs(:ncol))
! Calculate s2, n2, and Richardson number.
call trbintd(ncol , &
thv ,z ,u ,v , &
s2 ,n2 ,ri )
!
! Get free atmosphere exchange coefficients
!
call austausch_atm_free(pcols, ncol, pver, ntop_turb, nbot_turb, &
ml2, ri, s2, kvf)
kvf(:ncol,:) = 0.0_r8
do k = ntop_turb, nbot_turb - 1
do i = 1, ncol
kvf(i,k+1) = calc_free_atm_eddy_flux_coefficient(ml2(k), ri(i, k), s2(i, k))
end do
end do

kvq(:ncol,:) = kvf(:ncol,:)
kvm(:ncol,:) = kvf(:ncol,:)
Expand Down
Loading