Skip to content
14 changes: 14 additions & 0 deletions bld/build-namelist
Original file line number Diff line number Diff line change
Expand Up @@ -3073,6 +3073,20 @@ if ($cfg->get('microphys') =~ /^mg/) {
add_default($nl, 'forestfileBR');
add_default($nl, 'forestfileBRwarm');
}
add_default($nl, 'rafwbf_on');
if ($nl->get_value('rafwbf_on') =~ m/$TRUE/io) {
if ($nl->get_value('micro_mg_do_cldice') =~ m/$FALSE/io) {
# Generate an error since both of these variables would have to be
# set manually for this condition
die "$ProgName - Error: Cannot set rafwbf_on = .true. if micro_mg_do_cldice = .false.\n";
}
if ( ! $nl->get_value('micro_mg_version') == '2') {
# Generate an error since both of these variables would have to be
# set manually for this condition
die "$ProgName - Error: Cannot set rafwbf_on = .true. if micro_mg_versuin /= 2\n";
}
add_default($nl, 'forestfileWBF');
}
}

# Ice nucleation options
Expand Down
5 changes: 5 additions & 0 deletions bld/namelist_files/namelist_defaults_cam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,11 @@
<forestfileBR>atm/cam/RaFSIP/forestBR.txt</forestfileBR>
<forestfileBRwarm>atm/cam/RaFSIP/forestBRwarm.txt</forestfileBRwarm>

<!-- WBF multiplier -->
<rafwbf_on>.false.</rafwbf_on>
<forestfileWBF>atm/cam/RaFWBF/forestWBF_c260424.txt</forestfileWBF>


<chem_use_chemtrop>.true.</chem_use_chemtrop>

<prescribed_strataero_use_chemtrop>.false.</prescribed_strataero_use_chemtrop>
Expand Down
13 changes: 13 additions & 0 deletions bld/namelist_files/namelist_definition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2770,6 +2770,19 @@ Default: .true.
Default: None
</entry>

<!-- Multiplier for Bergeron process -->
<entry id="rafwbf_on" type="logical" category="microphys"
group="wbf_nl" valid_values="" >
If .true., compute factor for Bergeron using random forests method.
Default: .false.
</entry>

<entry id="forestfileWBF" type="char*256" input_pathname="abs" category="microphys"
group="wbf_nl" valid_values="" >
ML parameters for Damman et al., in preparation to submission to ACP.
Default: None
</entry>

<!-- hkconv Moist Convection -->
<entry id="hkconv_cmftau" type="real" category="conv"
group="hkconv_nl" valid_values="" >
Expand Down
10 changes: 10 additions & 0 deletions cime_config/testdefs/testlist_cam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@
</options>
</test>

<test compset="NF2000climo" grid="f19_f19_mtn14" name="SMS_D_Ln9" testmods="cam/rafwbf">
<machines>
<machine name="betzy" compiler="intel" category="aux_cam_noresm"/>
</machines>
<options>
<option name="comment">Test random forest bergeron factor</option>
<option name="wallclock">00:40:00</option>
</options>
</test>

<test compset="NF1850frc2norbc" grid="f09_f09_mtn14" name="ERP_Ln9" testmods="cam/outfrq9s">
<machines>
<machine name="betzy" compiler="intel" category="aux_cam_noresm"/>
Expand Down
2 changes: 2 additions & 0 deletions cime_config/testdefs/testmods_dirs/cam/rafwbf/shell_commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
./xmlchange ROF_NCPL=\$ATM_NCPL
./xmlchange GLC_NCPL=\$ATM_NCPL
6 changes: 6 additions & 0 deletions cime_config/testdefs/testmods_dirs/cam/rafwbf/user_nl_cam
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mfilt = 1,1,1,1,1,1
ndens = 1,1,1,1,1,1
nhtfrq = 9,9,9,9,9,9
inithist = 'ENDOFRUN'
history_budget = .true.
rafwbf_on = .true.
26 changes: 26 additions & 0 deletions cime_config/testdefs/testmods_dirs/cam/rafwbf/user_nl_clm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
!----------------------------------------------------------------------------------
! Users should add all user specific namelist changes below in the form of
! namelist_var = new_namelist_value
!
! Include namelist variables for drv_flds_in ONLY if -megan and/or -drydep options
! are set in the CLM_NAMELIST_OPTS env variable.
!
! EXCEPTIONS:
! Set use_cndv by the compset you use and the CLM_BLDNML_OPTS -dynamic_vegetation setting
! Set use_vichydro by the compset you use and the CLM_BLDNML_OPTS -vichydro setting
! Set use_cn by the compset you use and CLM_BLDNML_OPTS -bgc setting
! Set use_crop by the compset you use and CLM_BLDNML_OPTS -crop setting
! Set spinup_state by the CLM_BLDNML_OPTS -bgc_spinup setting
! Set irrigate by the CLM_BLDNML_OPTS -irrig setting
! Set dtime with L_NCPL option
! Set fatmlndfrc with LND_DOMAIN_PATH/LND_DOMAIN_FILE options
! Set finidat with RUN_REFCASE/RUN_REFDATE/RUN_REFTOD options for hybrid or branch cases
! (includes $inst_string for multi-ensemble cases)
! Set glc_grid with CISM_GRID option
! Set glc_smb with GLC_SMB option
! Set maxpatch_glcmec with GLC_NEC option
! Set glc_do_dynglacier with GLC_TWO_WAY_COUPLING env variable
!----------------------------------------------------------------------------------
hist_nhtfrq = 9
hist_mfilt = 1
hist_ndens = 1
69 changes: 61 additions & 8 deletions src/NorESM/micro_mg2_0.F90
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ module micro_mg2_0
use module_random_forests, only: max_nodes5, leftchild5, rightchild5, splitfeat5
use module_random_forests, only: thresh5, out51

!RafWBF
use module_random_forests, only: rafwbf_on, jbtb, tupb, tlob
use module_random_forests, only: max_nodesb, leftchildb, rightchildb, splitfeatb
use module_random_forests, only: threshb, outb

implicit none
private
save
Expand Down Expand Up @@ -254,7 +259,7 @@ subroutine micro_mg_init( &
allow_sed_supersat_in, do_sb_physics_in, &
nccons_in, nicons_in, ncnst_in, ninst_in, errstring)

use module_random_forests, only: sec_ice_init
use module_random_forests, only: sec_ice_init, wbf_init
use micro_mg_utils, only: micro_mg_utils_init

!-----------------------------------------------------------------------
Expand Down Expand Up @@ -364,7 +369,10 @@ subroutine micro_mg_init( &
! RaFSIP: INITIALIZE THE RANDOM FOREST PARAMETERS
call sec_ice_init()
end if

if (rafwbf_on) then
! RaFWBF: INITIALIZE THE RANDOM FOREST PARAMETERS
call wbf_init()
end if

end subroutine micro_mg_init

Expand All @@ -373,7 +381,7 @@ end subroutine micro_mg_init

subroutine micro_mg_tend ( &
mgncol, nlev, deltatin, &
t, q, &
t, q, tsk, pblh, &
qcn, qin, &
ncn, nin, &
qrn, qsn, &
Expand Down Expand Up @@ -408,7 +416,7 @@ subroutine micro_mg_tend ( &
qrsedten, qssedten, &
pratot, prctot, &
mnuccctot, mnuccttot, msacwitot, &
psacwstot, bergstot, bergtot, &
psacwstot, bergstot, bergtot, bergf, &
melttot, homotot, &
qcrestot, prcitot, praitot, &
qirestot, mnuccrtot, pracstot, &
Expand Down Expand Up @@ -471,7 +479,7 @@ subroutine micro_mg_tend ( &
evaporate_sublimate_precip, &
bergeron_process_snow

use module_random_forests, only: MDIM5, MDIM6
use module_random_forests, only: MDIM5, MDIM6, MDIMB
use module_random_forests, only: runforestmulti
use module_random_forests, only: runforestriv
use module_random_forests, only: runforest
Expand All @@ -485,6 +493,8 @@ subroutine micro_mg_tend ( &
real(r8), intent(in) :: deltatin ! time step (s)
real(r8), intent(in) :: t(mgncol,nlev) ! input temperature (K)
real(r8), intent(in) :: q(mgncol,nlev) ! input h20 vapor mixing ratio (kg/kg)
real(r8), intent(in) :: tsk(mgncol) ! input skin temperature for RaFWBF (K)
real(r8), intent(in) :: pblh(mgncol) ! input planetary boundary layer for RaFWBF (K)

! note: all input cloud variables are grid-averaged
real(r8), intent(in) :: qcn(mgncol,nlev) ! cloud water mixing ratio (kg/kg)
Expand Down Expand Up @@ -519,6 +529,7 @@ subroutine micro_mg_tend ( &
real(r8), intent(in) :: rndst(:,:,:) ! radius of each dust bin, for contact freezing (from microp_aero_ts) (m)
real(r8), intent(in) :: nacon(:,:,:) ! number in each dust bin, for contact freezing (from microp_aero_ts) (1/m^3)


! output arguments

real(r8), intent(out) :: qcsinksum_rate1ord(mgncol,nlev) ! 1st order rate for
Expand Down Expand Up @@ -581,6 +592,7 @@ subroutine micro_mg_tend ( &
real(r8), intent(out) :: psacwstot(mgncol,nlev) ! collection of cloud water by snow
real(r8), intent(out) :: bergstot(mgncol,nlev) ! bergeron process on snow
real(r8), intent(out) :: bergtot(mgncol,nlev) ! bergeron process on cloud ice
real(r8), intent(out) :: bergf(mgncol,nlev) ! factor for bergeron process in RafWBF
real(r8), intent(out) :: melttot(mgncol,nlev) ! melting of cloud ice
real(r8), intent(out) :: homotot(mgncol,nlev) ! homogeneous freezing cloud water
real(r8), intent(out) :: qcrestot(mgncol,nlev) ! residual cloud condensation due to removal of excess supersat
Expand Down Expand Up @@ -928,6 +940,10 @@ subroutine micro_mg_tend ( &
real(r8) :: FEATURES5(MDIM5),FEATURES6(MDIM6)
real(r8) :: YPRED1,YPRED2,YPRED3,YPRED4,YPRED5

! RaFWBF variables:
real(r8) :: Pb, LWCb, IWCb, Tb, PBLHb, TSKb ! INPUT, dummy
real(r8) :: FEATURESB(MDIMB),YPREDB
real(r8) :: wbf_factor(mgncol,nlev) ! will be applied regardless if RafWBF is ON or OFF


!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
Expand Down Expand Up @@ -1272,7 +1288,18 @@ subroutine micro_mg_tend ( &
SIP_RATE=0._r8
QIRSIP=0._r8
QICSIP=0._r8


! RaFWBF zero vars
Pb = 0._r8
LWCb = 0._r8
IWCb = 0._r8
Tb = 0._r8
PBLHb = 0._r8
TSKb = 0._r8
FEATURESB(:) = 0._r8
YPREDB = 0._r8
wbf_factor(:,:) = 1._r8 ! this should default to 1
bergf=1.0_r8


!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
Expand Down Expand Up @@ -1725,11 +1752,36 @@ subroutine micro_mg_tend ( &
qric(:,k), qsic(:,k), lamr(:,k), n0r(:,k), lams(:,k), n0s(:,k), &
pre(:,k), prds(:,k), am_evp_st(:,k), mgncol)

! RaFWBF parameterisattion:
if (rafwbf_on) then
do i = 1,mgncol
if (t(i,k) >= tlob .and. t(i,k) <= tupb) then
! make inputs:
Pb = p(i,k) ! Pa
! input contents are used to be consistent
! with WRF data used to constract RF
LWCb = qcn(i,k) + qrn(i,k) !kg/kg
IWCb = qin(i,k) + qsn(i,k) !kg/kg
Tb = t(i,k) - 273.15_r8 ! DegC
PBLHb = pblh(i) !m
TSKb = tsk(i) - 273.15 ! DegC
Comment on lines +1765 to +1767
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these constants explicitly supposed to be the same as tupb? tmelt? Given the comment, it seems that these should be replaced with tmelt.

FEATURESB =(/ Pb, LWCb, IWCb, Tb, PBLHb, TSKb /)
call runforest(MDIMB, MAX_NODESB, JBTB, FEATURESB, YPREDB, &
LEFTCHILDB, RIGHTCHILDB, SPLITFEATB, THRESHB, OUTB)
wbf_factor(i,k) = max(0.0_r8, min(1.0_r8,YPREDB))
else
wbf_factor(i,k) = 1.0_r8
end if
end do
else
wbf_factor(:,:) = 1.0_r8
end if

call bergeron_process_snow(t(:,k), rho(:,k), dv(:,k), mu(:,k), sc(:,k), &
qvl(:,k), qvi(:,k), asn(:,k), qcic(1:mgncol,k), qsic(:,k), lams(:,k), n0s(:,k), &
bergs(:,k), mgncol)

bergs(:,k)=bergs(:,k)*micro_mg_berg_eff_factor
bergs(:,k)=bergs(:,k)*micro_mg_berg_eff_factor * wbf_factor(:,k)

!+++PMC 12/3/12 - NEW VAPOR DEP/SUBLIMATION GOES HERE!!!
if (do_cldice) then
Expand All @@ -1738,7 +1790,7 @@ subroutine micro_mg_tend ( &
icldm(:,k), rho(:,k), dv(:,k), qvl(:,k), qvi(:,k), &
berg(:,k), vap_dep(:,k), ice_sublim(:,k), mgncol)

berg(:,k)=berg(:,k)*micro_mg_berg_eff_factor
berg(:,k)=berg(:,k)*micro_mg_berg_eff_factor * wbf_factor(:,k)

where (ice_sublim(:,k) < 0._r8 .and. qi(:,k) > qsmall .and. icldm(:,k) > mincld)
nsubi(:,k) = sublim_factor*ice_sublim(:,k) / qi(:,k) * ni(:,k) / icldm(:,k)
Expand Down Expand Up @@ -2430,6 +2482,7 @@ subroutine micro_mg_tend ( &
psacwstot(i,k) = psacws(i,k)*lcldm(i,k)
bergstot(i,k) = bergs(i,k)*lcldm(i,k)
bergtot(i,k) = berg(i,k)
bergf(i,k) = wbf_factor(i,k)
prcitot(i,k) = prci(i,k)*icldm(i,k)
praitot(i,k) = prai(i,k)*icldm(i,k)
mnuccdtot(i,k) = mnuccd(i,k)*icldm(i,k)
Expand Down
Loading