Skip to content

Commit

Permalink
Merge branch 'ufs/dev' of https://github.com/ufs-community/ccpp-physics
Browse files Browse the repository at this point in the history
… into feature/gfdlmpv3
  • Loading branch information
dustinswales committed Dec 16, 2024
2 parents 7496933 + dab57fc commit 945bd99
Show file tree
Hide file tree
Showing 13 changed files with 3,667 additions and 3,546 deletions.
7 changes: 2 additions & 5 deletions physics/Interstitials/UFS_SCM_NEPTUNE/sgscloud_radpre.F90
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ subroutine sgscloud_radpre_run( &
nlay, plyr, xlat, dz,de_lgth, &
cldsa,mtopa,mbota, &
imp_physics, imp_physics_gfdl,&
imp_physics_fa, &
imp_physics_fa, conv_cf_opt, &
iovr, &
errmsg, errflg )

Expand All @@ -75,7 +75,7 @@ subroutine sgscloud_radpre_run( &
real(kind=kind_phys) :: gfac
integer, intent(in) :: im, levs, imfdeepcnv, imfdeepcnv_gf, &
& nlay, imfdeepcnv_sas, imfdeepcnv_c3, imp_physics, &
& imp_physics_gfdl, imp_physics_fa
& imp_physics_gfdl, imp_physics_fa, conv_cf_opt
logical, intent(in) :: flag_init, flag_restart, do_mynnedmf

real(kind=kind_phys), dimension(:,:), intent(inout) :: qc, qi
Expand Down Expand Up @@ -120,9 +120,6 @@ subroutine sgscloud_radpre_run( &
real :: a, f, sigq, qmq, qt, xl, th, thl, rsl, cpm, cb_cf
real(kind=kind_phys) :: tlk

!Option to convective cloud fraction
integer, parameter :: conv_cf_opt = 0 !0: C-B, 1: X-R

! Initialize CCPP error handling variables
errmsg = ''
errflg = 0
Expand Down
7 changes: 7 additions & 0 deletions physics/Interstitials/UFS_SCM_NEPTUNE/sgscloud_radpre.meta
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@
dimensions = ()
type = integer
intent = in
[conv_cf_opt]
standard_name = option_for_convection_scheme_cloud_fraction_computation
long_name = option for convection scheme cloud fraction computation
units = flag
dimensions = ()
type = integer
intent = in
[qc_save]
standard_name = cloud_condensed_water_mixing_ratio_save
long_name = ratio of mass of cloud water to mass of dry air plus vapor (without condensates) before entering a physics scheme
Expand Down
6,196 changes: 3,112 additions & 3,084 deletions physics/MP/Thompson/module_mp_thompson.F90

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
!>\ingroup aathompson
module module_mp_thompson_make_number_concentrations

use physcons, only: PI => con_pi
use module_mp_thompson, only: PI

implicit none

Expand Down Expand Up @@ -137,13 +137,15 @@ elemental real function make_DropletNumber (Q_cloud, qnwfa)
real, intent(in):: Q_cloud, qnwfa

!real, parameter:: PI = 3.1415926536
real, parameter:: am_r = PI*1000./6.
real :: am_r
real, dimension(15), parameter:: g_ratio = (/24,60,120,210,336, &
& 504,720,990,1320,1716,2184,2730,3360,4080,4896/)
double precision:: lambda, qnc
real:: q_nwfa, x1, xDc
integer:: nu_c

am_r = PI*1000./6.

if (Q_cloud == 0) then
make_DropletNumber = 0
return
Expand Down Expand Up @@ -176,7 +178,9 @@ elemental real function make_RainNumber (Q_rain, temp)
real, intent(in):: Q_rain, temp
double precision:: lambda, N0, qnr
!real, parameter:: PI = 3.1415926536
real, parameter:: am_r = PI*1000./6.
real :: am_r

am_r = PI*1000./6.

if (Q_rain == 0) then
make_RainNumber = 0
Expand Down
66 changes: 63 additions & 3 deletions physics/MP/Thompson/mp_thompson.F90
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ module mp_thompson
!! \section arg_table_mp_thompson_init Argument Table
!! \htmlinclude mp_thompson_init.html
!!
subroutine mp_thompson_init(ncol, nlev, con_g, con_rd, con_eps, &
subroutine mp_thompson_init(ncol, nlev, con_pi, con_t0c, con_rv, &
con_cp, con_rgas, con_boltz, con_amd, &
con_amw, con_avgd, con_hvap, con_hfus, &
con_g, con_rd, con_eps, &
restart, imp_physics, &
imp_physics_thompson, convert_dry_rho, &
spechum, qc, qr, qi, qs, qg, ni, nr, &
Expand All @@ -39,13 +42,17 @@ subroutine mp_thompson_init(ncol, nlev, con_g, con_rd, con_eps, &
aerfld, mpicomm, mpirank, mpiroot, &
threads, ext_diag, diag3d, &
is_initialized, errmsg, errflg)

use module_mp_thompson, only : PI, T_0, Rv, R, RoverRv, Cp
use module_mp_thompson, only : R_uni, k_b, M_w, M_a, N_avo, lvap0, lfus

implicit none

! Interface variables
integer, intent(in ) :: ncol
integer, intent(in ) :: nlev
real(kind_phys), intent(in ) :: con_g, con_rd, con_eps
real(kind_phys), intent(in ) :: con_pi, con_t0c, con_rv, con_cp, con_rgas, &
con_boltz, con_amd, con_amw, con_avgd, &
con_hvap, con_hfus, con_g, con_rd, con_eps
logical, intent(in ) :: restart
logical, intent(inout) :: is_initialized
integer, intent(in ) :: imp_physics
Expand Down Expand Up @@ -103,6 +110,21 @@ subroutine mp_thompson_init(ncol, nlev, con_g, con_rd, con_eps, &

if (is_initialized) return

! Set local Thompson MP module constants from host model
PI = con_pi
T_0 = con_t0c
Rv = con_Rv
R = con_rd
RoverRv = con_eps
Cp = con_cp
R_uni = con_rgas
k_b = con_boltz
M_w = con_amw*1.0E-3 !module_mp_thompson expects kg/mol
M_a = con_amd*1.0E-3 !module_mp_thompson expects kg/mol
N_avo = con_avgd
lvap0 = con_hvap
lfus = con_hfus

! Consistency checks
if (imp_physics/=imp_physics_thompson) then
write(errmsg,'(*(a))') "Logic error: namelist choice of microphysics is different from Thompson MP"
Expand Down Expand Up @@ -687,6 +709,44 @@ subroutine mp_thompson_run(ncol, nlev, con_g, con_rd, &
nrten3 => diag3d(:,:,35:35)
ncten3 => diag3d(:,:,36:36)
qcten3 => diag3d(:,:,37:37)
else
allocate(prw_vcdc (0,0,0))
allocate(prw_vcde (0,0,0))
allocate(tpri_inu (0,0,0))
allocate(tpri_ide_d (0,0,0))
allocate(tpri_ide_s (0,0,0))
allocate(tprs_ide (0,0,0))
allocate(tprs_sde_d (0,0,0))
allocate(tprs_sde_s (0,0,0))
allocate(tprg_gde_d (0,0,0))
allocate(tprg_gde_s (0,0,0))
allocate(tpri_iha (0,0,0))
allocate(tpri_wfz (0,0,0))
allocate(tpri_rfz (0,0,0))
allocate(tprg_rfz (0,0,0))
allocate(tprs_scw (0,0,0))
allocate(tprg_scw (0,0,0))
allocate(tprg_rcs (0,0,0))
allocate(tprs_rcs (0,0,0))
allocate(tprr_rci (0,0,0))
allocate(tprg_rcg (0,0,0))
allocate(tprw_vcd_c (0,0,0))
allocate(tprw_vcd_e (0,0,0))
allocate(tprr_sml (0,0,0))
allocate(tprr_gml (0,0,0))
allocate(tprr_rcg (0,0,0))
allocate(tprr_rcs (0,0,0))
allocate(tprv_rev (0,0,0))
allocate(tten3 (0,0,0))
allocate(qvten3 (0,0,0))
allocate(qrten3 (0,0,0))
allocate(qsten3 (0,0,0))
allocate(qgten3 (0,0,0))
allocate(qiten3 (0,0,0))
allocate(niten3 (0,0,0))
allocate(nrten3 (0,0,0))
allocate(ncten3 (0,0,0))
allocate(qcten3 (0,0,0))
end if set_extended_diagnostic_pointers
!> - Call mp_gt_driver() with or without aerosols, with or without effective radii, ...
if (is_aerosol_aware) then
Expand Down
88 changes: 88 additions & 0 deletions physics/MP/Thompson/mp_thompson.meta
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,94 @@
dimensions = ()
type = integer
intent = in
[con_pi]
standard_name = pi
long_name = ratio of a circle's circumference to its diameter
units = none
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_t0c]
standard_name = temperature_at_zero_celsius
long_name = temperature at 0 degrees Celsius
units = K
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_rv]
standard_name = gas_constant_water_vapor
long_name = ideal gas constant for water vapor
units = J kg-1 K-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_cp]
standard_name = specific_heat_of_dry_air_at_constant_pressure
long_name = specific heat of dry air at constant pressure
units = J kg-1 K-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_rgas]
standard_name = molar_gas_constant
long_name = universal ideal molar gas constant
units = J K-1 mol-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_boltz]
standard_name = boltzmann_constant
long_name = Boltzmann constant
units = J K-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_amd]
standard_name = molecular_weight_of_dry_air
long_name = molecular weight of dry air
units = g mol-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_amw]
standard_name = molecular_weight_of_water_vapor
long_name = molecular weight of water vapor
units = g mol-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_avgd]
standard_name = avogadro_consant
long_name = Avogadro constant
units = mol-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_hvap]
standard_name = latent_heat_of_vaporization_of_water_at_0C
long_name = latent heat of evaporation/sublimation
units = J kg-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_hfus]
standard_name = latent_heat_of_fusion_of_water_at_0C
long_name = latent heat of fusion
units = J kg-1
dimensions = ()
type = real
kind = kind_phys
intent = in
[con_g]
standard_name = gravitational_acceleration
long_name = gravitational acceleration
Expand Down
38 changes: 19 additions & 19 deletions physics/PBL/MYNN_EDMF/module_bl_mynn.F90
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ MODULE module_bl_mynn
! Note that the following mixing-length constants are now specified in mym_length
! &cns=3.5, alp1=0.23, alp2=0.3, alp3=3.0, alp4=10.0, alp5=0.2

real(kind_phys), parameter :: gpw=5./3., qcgmin=1.e-8, qkemin=1.e-12
real(kind_phys), parameter :: qkemin=1.e-4
real(kind_phys), parameter :: tliq = 269. !all hydrometeors are liquid when T > tliq

! Constants for cloud PDF (mym_condensation)
Expand Down Expand Up @@ -1937,11 +1937,11 @@ SUBROUTINE mym_length ( &
h1=MIN(h1,maxdz) ! 1/2 transition layer depth
h2=h1/2.0 ! 1/4 transition layer depth

qkw(kts) = SQRT(MAX(qke(kts),1.0e-10))
qkw(kts) = SQRT(MAX(qke(kts), qkemin))
DO k = kts+1,kte
afk = dz(k)/( dz(k)+dz(k-1) )
abk = 1.0 -afk
qkw(k) = SQRT(MAX(qke(k)*abk+qke(k-1)*afk,1.0e-3))
qkw(k) = SQRT(MAX(qke(k)*abk+qke(k-1)*afk, qkemin))
END DO

elt = 1.0e-5
Expand All @@ -1961,7 +1961,7 @@ SUBROUTINE mym_length ( &

elt = alp1*elt/vsc
vflx = ( vt(kts)+1.0 )*flt +( vq(kts)+tv0 )*flq
vsc = ( gtr*elt*MAX( vflx, 0.0 ) )**(1.0/3.0)
vsc = ( gtr*elt*MAX( vflx, 0.0 ) )**onethird

! ** Strictly, el(i,k=1) is not zero. **
el(kts) = 0.0
Expand Down Expand Up @@ -2019,14 +2019,14 @@ SUBROUTINE mym_length ( &
h1=MIN(h1,600.) ! 1/2 transition layer depth
h2=h1/2.0 ! 1/4 transition layer depth

qtke(kts)=MAX(0.5*qke(kts), 0.01) !tke at full sigma levels
qtke(kts)=MAX(0.5*qke(kts), 0.5*qkemin) !tke at full sigma levels
thetaw(kts)=theta(kts) !theta at full-sigma levels
qkw(kts) = SQRT(MAX(qke(kts),1.0e-10))
qkw(kts) = SQRT(MAX(qke(kts), qkemin))

DO k = kts+1,kte
afk = dz(k)/( dz(k)+dz(k-1) )
abk = 1.0 -afk
qkw(k) = SQRT(MAX(qke(k)*abk+qke(k-1)*afk,1.0e-3))
qkw(k) = SQRT(MAX(qke(k)*abk+qke(k-1)*afk, qkemin))
qtke(k) = 0.5*(qkw(k)**2) ! q -> TKE
thetaw(k)= theta(k)*abk + theta(k-1)*afk
END DO
Expand All @@ -2039,14 +2039,14 @@ SUBROUTINE mym_length ( &
zwk = zw(k)
DO WHILE (zwk .LE. zi2+h1)
dzk = 0.5*( dz(k)+dz(k-1) )
qdz = min(max( qkw(k)-qmin, 0.02 ), 30.0)*dzk
qdz = min(max( qkw(k)-qmin, 0.01 ), 30.0)*dzk
elt = elt +qdz*zwk
vsc = vsc +qdz
k = k+1
zwk = zw(k)
END DO

elt = MIN( MAX( alp1*elt/vsc, 10.), 400.)
elt = MIN( MAX( alp1*elt/vsc, 8.), 400.)
!avoid use of buoyancy flux functions which are ill-defined at the surface
!vflx = ( vt(kts)+1.0 )*flt + ( vq(kts)+tv0 )*flq
vflx = fltv
Expand Down Expand Up @@ -2122,13 +2122,13 @@ SUBROUTINE mym_length ( &
h1=MIN(h1,600.)
h2=h1*0.5 ! 1/4 transition layer depth

qtke(kts)=MAX(0.5*qke(kts),0.01) !tke at full sigma levels
qkw(kts) = SQRT(MAX(qke(kts),1.0e-4))
qtke(kts)=MAX(0.5*qke(kts), 0.5*qkemin) !tke at full sigma levels
qkw(kts) = SQRT(MAX(qke(kts), qkemin))

DO k = kts+1,kte
afk = dz(k)/( dz(k)+dz(k-1) )
abk = 1.0 -afk
qkw(k) = SQRT(MAX(qke(k)*abk+qke(k-1)*afk,1.0e-3))
qkw(k) = SQRT(MAX(qke(k)*abk+qke(k-1)*afk, qkemin))
qtke(k) = 0.5*qkw(k)**2 ! qkw -> TKE
END DO

Expand Down Expand Up @@ -3361,8 +3361,8 @@ SUBROUTINE mym_predict (kts,kte, &
CALL tridiag2(kte,a,b,c,d,x)

DO k=kts,kte
! qke(k)=max(d(k-kts+1), 1.e-4)
qke(k)=max(x(k), 1.e-4)
! qke(k)=max(d(k-kts+1), qkemin)
qke(k)=max(x(k), qkemin)
qke(k)=min(qke(k), 150.)
ENDDO

Expand Down Expand Up @@ -6509,11 +6509,11 @@ SUBROUTINE DMP_mf( &
do k=kts,kte-1
do I=1,nup
edmf_a(K) =edmf_a(K) +UPA(K,i)
edmf_w(K) =edmf_w(K) +rhoz(k)*UPA(K,i)*UPW(K,i)
edmf_qt(K) =edmf_qt(K) +rhoz(k)*UPA(K,i)*UPQT(K,i)
edmf_thl(K)=edmf_thl(K)+rhoz(k)*UPA(K,i)*UPTHL(K,i)
edmf_ent(K)=edmf_ent(K)+rhoz(k)*UPA(K,i)*ENT(K,i)
edmf_qc(K) =edmf_qc(K) +rhoz(k)*UPA(K,i)*UPQC(K,i)
edmf_w(K) =edmf_w(K) +UPA(K,i)*UPW(K,i)
edmf_qt(K) =edmf_qt(K) +UPA(K,i)*UPQT(K,i)
edmf_thl(K)=edmf_thl(K)+UPA(K,i)*UPTHL(K,i)
edmf_ent(K)=edmf_ent(K)+UPA(K,i)*ENT(K,i)
edmf_qc(K) =edmf_qc(K) +UPA(K,i)*UPQC(K,i)
enddo
enddo
do k=kts,kte-1
Expand Down
Loading

0 comments on commit 945bd99

Please sign in to comment.