Skip to content

Commit

Permalink
Merge pull request #1060 from grantfirl/ufs-dev-PR155
Browse files Browse the repository at this point in the history
UFS-dev PR#155
  • Loading branch information
grantfirl authored Mar 28, 2024
2 parents e1f97ad + 72ab0a6 commit 6b0599e
Show file tree
Hide file tree
Showing 13 changed files with 358 additions and 33 deletions.
8 changes: 4 additions & 4 deletions physics/Interstitials/UFS_SCM_NEPTUNE/scm_sfc_flux_spec.F90
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ subroutine scm_sfc_flux_spec_run (im, u1, v1, z1, t1, q1, p1, roughness_length,
integer, intent(in) :: im, lkm
integer, intent(inout) :: islmsk(:), use_lake_model(:)
logical, intent(in) :: cplflx, cplice
logical, intent(inout) :: dry(:), icy(:), flag_cice(:), wet(:)
logical, intent(inout) :: dry(:), icy(:), flag_cice(:), wet(:)
real(kind=kind_phys), intent(in) :: cp, grav, hvap, rd, fvirt, vonKarman, min_seaice, tgice, min_lakeice
real(kind=kind_phys), intent(in) :: u1(:), v1(:), z1(:), t1(:), q1(:), p1(:), roughness_length(:), &
spec_sh_flux(:), spec_lh_flux(:), exner_inverse(:), T_surf(:), oceanfrac(:), lakefrac(:), lakedepth(:)
Expand Down Expand Up @@ -212,12 +212,12 @@ subroutine scm_sfc_flux_spec_run (im, u1, v1, z1, t1, q1, p1, roughness_length,
do i = 1, im
if ((wet(i) .or. icy(i)) .and. lakefrac(i) > 0.0_kind_phys) then
if (lkm == 1 .and. lakefrac(i) >= 0.15 .and. lakedepth(i) > 1.0_kind_phys) then
use_lake_model(i) = .true.
use_lake_model(i) = 1
else
use_lake_model(i) = .false.
use_lake_model(i) = 0
endif
else
use_lake_model(i) = .false.
use_lake_model(i) = 0
endif
enddo
!
Expand Down
48 changes: 42 additions & 6 deletions physics/MP/NSSL/mp_nssl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module mp_nssl

private
logical :: is_initialized = .False.
logical :: missing_vars_global = .False.
real :: nssl_qccn

contains
Expand All @@ -26,7 +27,9 @@ module mp_nssl
!! \htmlinclude mp_nssl_init.html
!!
subroutine mp_nssl_init(ncol, nlev, errflg, errmsg, threads, restart, &
mpirank, mpiroot, &
mpirank, mpiroot,mpicomm, &
qc, qr, qi, qs, qh, &
ccw, crw, cci, csw, chw, vh, &
con_g, con_rd, con_cp, con_rv, &
con_t0c, con_cliq, con_csol, con_eps, &
imp_physics, imp_physics_nssl, &
Expand All @@ -36,6 +39,9 @@ subroutine mp_nssl_init(ncol, nlev, errflg, errmsg, threads, restart, &


use module_mp_nssl_2mom, only: nssl_2mom_init, nssl_2mom_init_const
#ifdef MPI
use mpi
#endif

implicit none

Expand All @@ -50,16 +56,32 @@ subroutine mp_nssl_init(ncol, nlev, errflg, errmsg, threads, restart, &

integer, intent(in) :: mpirank
integer, intent(in) :: mpiroot
integer, intent(in) :: mpicomm
integer, intent(in) :: imp_physics
integer, intent(in) :: imp_physics_nssl
real(kind_phys), intent(in) :: nssl_cccn, nssl_alphah, nssl_alphahl
real(kind_phys), intent(in) :: nssl_alphar, nssl_ehw0, nssl_ehlw0
logical, intent(in) :: nssl_ccn_on, nssl_hail_on, nssl_invertccn, nssl_3moment

real(kind_phys), intent(inout) :: qc (:,:) !(1:ncol,1:nlev)
real(kind_phys), intent(inout) :: qr (:,:) !(1:ncol,1:nlev)
real(kind_phys), intent(inout) :: qi (:,:) !(1:ncol,1:nlev)
real(kind_phys), intent(inout) :: qs (:,:) !(1:ncol,1:nlev)
real(kind_phys), intent(inout) :: qh (:,:) !(1:ncol,1:nlev) graupel
real(kind_phys), intent(inout) :: ccw(:,:) !(1:ncol,1:nlev)
real(kind_phys), intent(inout) :: crw(:,:) !(1:ncol,1:nlev)
real(kind_phys), intent(inout) :: cci(:,:) !(1:ncol,1:nlev)
real(kind_phys), intent(inout) :: csw(:,:) !(1:ncol,1:nlev)
real(kind_phys), intent(inout) :: chw(:,:) !(1:ncol,1:nlev) graupel number
real(kind_phys), intent(inout) :: vh (:,:) !(1:ncol,1:nlev) graupel volume

! Local variables: dimensions used in nssl_init
integer :: ims,ime, jms,jme, kms,kme, nx, nz, i,k
real :: nssl_params(20)
real(kind_phys) :: nssl_params(20)
integer :: ihailv,ipc
real(kind_phys), parameter :: qmin = 1.e-12
integer :: ierr
logical :: missing_vars = .False.


! Initialize the CCPP error handling variables
Expand Down Expand Up @@ -143,6 +165,19 @@ subroutine mp_nssl_init(ncol, nlev, errflg, errmsg, threads, restart, &

! For restart runs, the init is done here
if (restart) then

! For restart, check if the IC is from a different scheme that does not have all the needed variables
missing_vars = .False.
IF ( Any( qc > qmin .and. ccw == 0.0 ) ) missing_vars = .true.
IF ( .not. missing_vars .and. Any( qi > qmin .and. cci == 0.0 ) ) missing_vars = .true.
IF ( .not. missing_vars .and. Any( qs > qmin .and. csw == 0.0 ) ) missing_vars = .true.
IF ( .not. missing_vars .and. Any( qr > qmin .and. crw == 0.0 ) ) missing_vars = .true.
IF ( .not. missing_vars .and. Any( qh > qmin .and. (chw == 0.0 .or. vh == 0.0) ) ) missing_vars = .true.

#ifdef MPI
call MPI_Allreduce(missing_vars, missing_vars_global, 1, MPI_LOGICAL, MPI_LOR, mpicomm, ierr)
#endif

is_initialized = .true.
return
end if
Expand Down Expand Up @@ -312,13 +347,14 @@ subroutine mp_nssl_run(ncol, nlev, con_g, con_rd, mpirank, &
its,ite, jts,jte, kts,kte, i,j,k
integer :: itimestep ! timestep counter
integer :: ntmul, n
real, parameter :: dtpmax = 60. ! allow up to dt=75 (1.25*60)
real(kind_phys), parameter :: dtpmax = 60. ! allow up to dt=75 (1.25*60)
real(kind_phys) :: dtptmp
integer, parameter :: ndebug = 0
logical :: invertccn
real :: cwmas
real(kind_phys) :: cwmas

real(kind_phys), allocatable :: an(:,:,:,:) ! temporary scalar array



errflg = 0
Expand Down Expand Up @@ -529,8 +565,8 @@ subroutine mp_nssl_run(ncol, nlev, con_g, con_rd, mpirank, &
dtptmp = dtp
ntmul = 1
ENDIF
IF ( first_time_step .and. .not. restart ) THEN

IF ( first_time_step .and. ( .not. restart .or. missing_vars_global ) ) THEN
itimestep = 0 ! gets incremented to 1 in call loop
IF ( nssl_ccn_on ) THEN
IF ( invertccn ) THEN
Expand Down
95 changes: 95 additions & 0 deletions physics/MP/NSSL/mp_nssl.meta
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,101 @@
dimensions = ()
type = integer
intent = in
[mpicomm]
standard_name = mpi_communicator
long_name = MPI communicator
units = index
dimensions = ()
type = integer
intent = in
[qc]
standard_name = cloud_liquid_water_mixing_ratio
long_name = cloud water mixing ratio wrt dry+vapor (no condensates)
units = kg kg-1
dimensions = (horizontal_dimension ,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
[qr]
standard_name = rain_mixing_ratio
long_name = rain water mixing ratio wrt dry+vapor (no condensates)
units = kg kg-1
dimensions = (horizontal_dimension,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
[qi]
standard_name = cloud_ice_mixing_ratio
long_name = ice water mixing ratio wrt dry+vapor (no condensates)
units = kg kg-1
dimensions = (horizontal_dimension,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
[qs]
standard_name = snow_mixing_ratio
long_name = snow water mixing ratio wrt dry+vapor (no condensates)
units = kg kg-1
dimensions = (horizontal_dimension,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
[qh]
standard_name = graupel_mixing_ratio
long_name = graupel mixing ratio wrt dry+vapor (no condensates)
units = kg kg-1
dimensions = (horizontal_dimension,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
[ccw]
standard_name = mass_number_concentration_of_cloud_liquid_water_particles_in_air
long_name = cloud droplet number concentration
units = kg-1
dimensions = (horizontal_dimension,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
[crw]
standard_name = mass_number_concentration_of_rain_water_in_air
long_name = rain number concentration
units = kg-1
dimensions = (horizontal_dimension,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
[cci]
standard_name = mass_number_concentration_of_cloud_ice_water_crystals_in_air
long_name = ice number concentration
units = kg-1
dimensions = (horizontal_dimension,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
[csw]
standard_name = mass_number_concentration_of_snow_in_air
long_name = snow number concentration
units = kg-1
dimensions = (horizontal_dimension,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
[chw]
standard_name = mass_number_concentration_of_graupel_in_air
long_name = graupel number concentration
units = kg-1
dimensions = (horizontal_dimension,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
[vh]
standard_name = graupel_volume
long_name = graupel particle volume
units = m3 kg-1
dimensions = (horizontal_dimension,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
[con_g]
standard_name = gravitational_acceleration
long_name = gravitational acceleration
Expand Down
17 changes: 13 additions & 4 deletions physics/PBL/SATMEDMF/satmedmfvdifq.F
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ end subroutine satmedmfvdifq_init
!! \section detail_satmedmfvidfq GFS satmedmfvdifq Detailed Algorithm
subroutine satmedmfvdifq_run(im,km,ntrac,ntcw,ntrw, &
& ntiw,ntke,grav,rd,cp,rv,hvap,hfus,fv,eps,epsm1, &
& dv,du,tdt,rtg,u1,v1,t1,q1,swh,hlw,xmu, &
& garea,zvfun,sigmaf, &
& dv,du,tdt,rtg,u1,v1,t1,q1,usfco,vsfco,icplocn2atm, &
& swh,hlw,xmu,garea,zvfun,sigmaf, &
& psk,rbsoil,zorl,u10m,v10m,fm,fh, &
& tsea,heat,evap,stress,spd1,kpbl, &
& prsi,del,prsl,prslk,phii,phil,delt, &
Expand Down Expand Up @@ -110,6 +110,7 @@ subroutine satmedmfvdifq_run(im,km,ntrac,ntcw,ntrw, &
& tdt(:,:), rtg(:,:,:)
real(kind=kind_phys), intent(in) :: &
& u1(:,:), v1(:,:), &
& usfco(:), vsfco(:), &
& t1(:,:), q1(:,:,:), &
& swh(:,:), hlw(:,:), &
& xmu(:), garea(:), &
Expand All @@ -126,6 +127,7 @@ subroutine satmedmfvdifq_run(im,km,ntrac,ntcw,ntrw, &
real(kind=kind_phys), intent(inout), dimension(:,:,:) :: dtend
integer, intent(in) :: dtidx(:,:), index_of_temperature, &
& index_of_x_wind, index_of_y_wind, index_of_process_pbl
integer, intent(in) :: icplocn2atm
real(kind=kind_phys), intent(out) :: &
& dusfc(:), dvsfc(:), &
& dtsfc(:), dqsfc(:), &
Expand All @@ -142,6 +144,7 @@ subroutine satmedmfvdifq_run(im,km,ntrac,ntcw,ntrw, &
!----------------------------------------------------------------------
!***
!*** local variables
real(kind=kind_phys) spd1_m
!***
integer i,is,k,n,ndt,km1,kmpbl,kmscu,ntrac1,idtend
integer kps,kbx,kmx
Expand Down Expand Up @@ -2376,8 +2379,14 @@ subroutine satmedmfvdifq_run(im,km,ntrac,ntcw,ntrw, &
enddo
enddo
do i = 1,im
dusfc(i) = -1.*rho_a(i)*stress(i)*u1(i,1)/spd1(i)
dvsfc(i) = -1.*rho_a(i)*stress(i)*v1(i,1)/spd1(i)
if(icplocn2atm == 0) then
dusfc(i) = -1.*rho_a(i)*stress(i)*u1(i,1)/spd1(i)
dvsfc(i) = -1.*rho_a(i)*stress(i)*v1(i,1)/spd1(i)
else if (icplocn2atm ==1) then
spd1_m=sqrt( (u1(i,1)-usfco(i))**2+(v1(i,1)-vsfco(i))**2 )
dusfc(i) = -1.*rho_a(i)*stress(i)*(u1(i,1)-usfco(i))/spd1_m
dvsfc(i) = -1.*rho_a(i)*stress(i)*(v1(i,1)-vsfco(i))/spd1_m
endif
enddo
!
if(ldiag3d .and. .not. gen_tend) then
Expand Down
23 changes: 23 additions & 0 deletions physics/PBL/SATMEDMF/satmedmfvdifq.meta
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,29 @@
type = real
kind = kind_phys
intent = in
[usfco]
standard_name = x_ocean_current
long_name = zonal current at ocean surface
units = m s-1
dimensions = (horizontal_loop_extent)
type = real
kind = kind_phys
intent = in
[vsfco]
standard_name = y_ocean_current
long_name = meridional current at ocean surface
units = m s-1
dimensions = (horizontal_loop_extent)
type = real
kind = kind_phys
intent = in
[icplocn2atm]
standard_name = control_for_air_sea_flux_computation_over_water
long_name = air-sea flux option
units = 1
dimensions = ()
type = integer
intent = in
[t1]
standard_name = air_temperature
long_name = layer mean air temperature
Expand Down
12 changes: 10 additions & 2 deletions physics/SFC_Layer/UFS/sfc_diag.f
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ subroutine sfc_diag_run (im,xlat_d,xlon_d, &
& lsm,lsm_ruc,grav,cp,eps,epsm1,con_rocp, &
& con_karman, &
& shflx,cdq,wind, &
& usfco,vsfco,icplocn2atm, &
& zf,ps,u1,v1,t1,q1,prslki,evap,fm,fh,fm10,fh2, &
& ust,tskin,qsurf,thsfc_loc,diag_flux,diag_log, &
& use_lake_model,iopt_lake,iopt_lake_clm, &
Expand All @@ -31,13 +32,15 @@ subroutine sfc_diag_run (im,xlat_d,xlon_d, &
!
integer, intent(in) :: im, lsm, lsm_ruc, iopt_lake, iopt_lake_clm
logical, intent(in) :: use_lake2m
integer, intent(in) :: icplocn2atm
logical, intent(in) :: thsfc_loc ! Flag for reference pot. temp.
logical, intent(in) :: diag_flux ! Flag for flux method in 2-m diagnostics
logical, intent(in) :: diag_log ! Flag for 2-m log diagnostics under stable conditions
real(kind=kind_phys), intent(in) :: grav,cp,eps,epsm1,con_rocp
real(kind=kind_phys), intent(in) :: con_karman
real(kind=kind_phys), dimension(:), intent( in) :: &
& zf, ps, u1, v1, t1, q1, ust, tskin, &
& usfco, vsfco, &
& qsurf, prslki, evap, fm, fh, fm10, fh2, &
& shflx, cdq, wind, xlat_d, xlon_d
real(kind=kind_phys), dimension(:), intent(out) :: &
Expand Down Expand Up @@ -89,8 +92,13 @@ subroutine sfc_diag_run (im,xlat_d,xlon_d, &

do i = 1, im
f10m(i) = fm10(i) / fm(i)
u10m(i) = f10m(i) * u1(i)
v10m(i) = f10m(i) * v1(i)
if (icplocn2atm ==0) then
u10m(i) = f10m(i) * u1(i)
v10m(i) = f10m(i) * v1(i)
else if (icplocn2atm ==1) then
u10m(i) = usfco(i)+f10m(i) * (u1(i)-usfco(i))
v10m(i) = vsfco(i)+f10m(i) * (v1(i)-vsfco(i))
endif
have_2m = use_lake_model(i)>0 .and. use_lake2m .and. &
& iopt_lake==iopt_lake_clm
if(have_2m) then
Expand Down
23 changes: 23 additions & 0 deletions physics/SFC_Layer/UFS/sfc_diag.meta
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,29 @@
type = real
kind = kind_phys
intent = in
[usfco]
standard_name = x_ocean_current
long_name = zonal current at ocean surface
units = m s-1
dimensions = (horizontal_loop_extent)
type = real
kind = kind_phys
intent = in
[vsfco]
standard_name = y_ocean_current
long_name = meridional current at ocean surface
units = m s-1
dimensions = (horizontal_loop_extent)
type = real
kind = kind_phys
intent = in
[icplocn2atm]
standard_name = control_for_air_sea_flux_computation_over_water
long_name = air-sea flux option
units = 1
dimensions = ()
type = integer
intent = in
[t1]
standard_name = air_temperature_at_surface_adjacent_layer
long_name = 1st model layer air temperature
Expand Down
Loading

0 comments on commit 6b0599e

Please sign in to comment.