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 17 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
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@

[submodule "atmos_phys"]
path = src/atmos_phys
url = https://github.com/ESCOMP/atmospheric_physics
fxtag = atmos_phys0_07_001
url = https://github.com/mwaxmonsky/atmospheric_physics
fxtag = 426f759e1a49d1e0d10e7476e4bf69b02da812a6
fxrequired = AlwaysRequired
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics
fxDONOTUSEurl = https://github.com/mwaxmonsky/atmospheric_physics

[submodule "fv3"]
path = src/dynamics/fv3
Expand Down Expand Up @@ -151,7 +151,7 @@ fxDONOTUSEurl = https://github.com/ESMCI/ccs_config_cesm.git
[submodule "cime"]
path = cime
url = https://github.com/ESMCI/cime
fxtag = cime6.1.56
fxtag = ef81824baa69947354f807e83924daf756e12937
fxrequired = ToplevelRequired
fxDONOTUSEurl = https://github.com/ESMCI/cime

Expand Down
1 change: 1 addition & 0 deletions bld/configure
Original file line number Diff line number Diff line change
Expand Up @@ -2336,6 +2336,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
2 changes: 1 addition & 1 deletion src/atmos_phys
Submodule atmos_phys updated 62 files
+1 −1 .github/workflows/unit-tests.yaml
+56 −0 doc/ChangeLog
+255 −174 doc/NamesNotInDictionary.txt
+213 −0 phys_utils/atmos_pbl_utils.F90
+89 −0 schemes/cloud_fraction/cloud_fraction_fice.F90
+49 −0 schemes/cloud_fraction/cloud_fraction_fice.meta
+20 −4 schemes/musica/micm/musica_ccpp_micm.F90
+84 −58 schemes/musica/musica_ccpp.F90
+1 −1 schemes/musica/musica_ccpp.meta
+323 −0 schemes/musica/musica_ccpp_species.F90
+201 −88 schemes/musica/tuvx/musica_ccpp_tuvx.F90
+103 −0 schemes/musica/tuvx/musica_ccpp_tuvx_aerosol_optics.F90
+145 −0 schemes/musica/tuvx/musica_ccpp_tuvx_gas_species.F90
+11 −1 schemes/musica/tuvx/musica_ccpp_tuvx_height_grid.F90
+219 −0 schemes/musica/tuvx/musica_ccpp_tuvx_load_species.F90
+1 −1 schemes/musica/tuvx/musica_ccpp_tuvx_surface_albedo.F90
+68 −0 schemes/sima_diagnostics/zm_convr_tendency_diagnostics.F90
+70 −0 schemes/sima_diagnostics/zm_convr_tendency_diagnostics.meta
+205 −0 schemes/sima_diagnostics/zm_diagnostics.F90
+207 −0 schemes/sima_diagnostics/zm_diagnostics.meta
+81 −0 schemes/sima_diagnostics/zm_evap_tendency_diagnostics.F90
+81 −0 schemes/sima_diagnostics/zm_evap_tendency_diagnostics.meta
+67 −0 schemes/sima_diagnostics/zm_momtran_tendency_diagnostics.F90
+75 −0 schemes/sima_diagnostics/zm_momtran_tendency_diagnostics.meta
+79 −0 schemes/sima_diagnostics/zm_tendency_diagnostics.F90
+69 −0 schemes/sima_diagnostics/zm_tendency_diagnostics.meta
+29 −0 schemes/utilities/to_be_ccppized_temporary.F90
+22 −0 schemes/utilities/to_be_ccppized_temporary.meta
+26 −0 schemes/zhang_mcfarlane/set_deep_conv_fluxes_to_general.F90
+31 −0 schemes/zhang_mcfarlane/set_deep_conv_fluxes_to_general.meta
+46 −0 schemes/zhang_mcfarlane/set_general_conv_fluxes_to_deep.F90
+103 −0 schemes/zhang_mcfarlane/set_general_conv_fluxes_to_deep.meta
+61 −8 schemes/zhang_mcfarlane/zm_conv_convtran.F90
+91 −29 schemes/zhang_mcfarlane/zm_conv_convtran.meta
+29 −50 schemes/zhang_mcfarlane/zm_conv_evap.F90
+84 −68 schemes/zhang_mcfarlane/zm_conv_evap.meta
+14 −9 schemes/zhang_mcfarlane/zm_conv_momtran.F90
+81 −66 schemes/zhang_mcfarlane/zm_conv_momtran.meta
+83 −163 schemes/zhang_mcfarlane/zm_convr.F90
+148 −144 schemes/zhang_mcfarlane/zm_convr.meta
+195 −0 schemes/zhang_mcfarlane/zm_convr_namelist.xml
+47 −1 suites/suite_cam7.xml
+2 −2 test/docker/Dockerfile.musica
+2 −2 test/docker/Dockerfile.musica.no_install
+34 −5 test/musica/CMakeLists.txt
+51 −26 test/musica/test_musica_api.F90
+217 −0 test/musica/test_musica_species.F90
+97 −0 test/musica/tuvx/CMakeLists.txt
+85 −0 test/musica/tuvx/test_tuvx_aerosol_optics.F90
+476 −0 test/musica/tuvx/test_tuvx_gas_species.F90
+10 −1 test/musica/tuvx/test_tuvx_height_grid.F90
+362 −0 test/musica/tuvx/test_tuvx_load_species.F90
+38 −0 test/test_suites/suite_zhang_mcfarlane.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
+1 −1 to_be_ccppized/ccpp_tuvx_utils.F90
+151 −0 to_be_ccppized/error_messages.F90
+6 −0 to_be_ccppized/namelist_utils.F90
+759 −0 to_be_ccppized/wv_sat_methods.F90
+1,483 −0 to_be_ccppized/wv_saturation.F90
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_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 @@ -3493,8 +3494,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_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 @@ -4708,13 +4709,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_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_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_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_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_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_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_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