1 !WRF:MODEL_LAYER:PHYSICS
3 ! prepocessed on "Aug 14 2023" at "16:15:23"
11 !---------------------------------------------------------------------
12 ! IMPORTANT: Best results are attained using the 5th-order WENO (Weighted Essentially Non-Oscillatory) advection option (4) for scalars:
14 ! scalar_adv_opt = 4, (can also use option 3, which is WENO without the positive definite filter)
15 ! The WENO-5 scheme provides a 5th-order (horizontal and vertical) adaptive weighting of components that
16 ! better preserve monotinicity in strong gradients. The standard 5th-order formulation is prone to undershoots
17 ! (negative values) of mass and number concentrations at cloud edges. The WENO scheme helps
18 ! to prevent undershoots and results in less noise at cloud and reflectivity boundaries. This is particularly
19 ! useful for multi-moment schemes to preserve relationships between mass and number concentration. An option is also available
20 ! for WENO-5 advection of momentum, but this can result in excessive damping of poorly-resolved features. For both scalar and momentum
21 ! the steps 1 and 2 of the Runge-Kutta time integration use standare 5th-order advection, and the WENO-5 is applied on the 3rd (final)
22 ! RK step. Option 3 applies the WENO-5, and option 4 adds the positive definite filter (as also used in option 1).
24 ! WENO references: Jiang and Shu, 1996, J. Comp. Phys. v. 126, 202-223; Shu 2003, Int. J. Comp. Fluid Dyn. v. 17 107-118;
26 !! This module provides a 1/2/3-moment bulk microphysics scheme based on a combination of
27 !! Straka and Mansell (2005, JAM) and Zeigler (1985, JAS) and modified/upgraded in
28 !! in Mansell, Zeigler, and Bruning (2010, JAS). Two-moment adaptive sedimentation
29 !! follows Mansell (2010, JAS), using parameter infall = 4.
31 !! Added info on graupel density and soaking is in Mansell and Ziegler (2013, JAS)
33 !! Average graupel and hail particle densities are predicted, which affects fall speed as well.
35 !! Maintainer: Ted Mansell, National Severe Storms Laboratory <ted.mansell@noaa.gov>
37 !! Microphysics References:
39 !! Mansell, E. R., C. L. Ziegler, and E. C. Bruning, 2010: Simulated electrification of a small
40 !! thunderstorm with two-moment bulk microphysics. J. Atmos. Sci., 67, 171-194, doi:10. 1175/2009JAS2965.1.
42 !! Mansell, E. R. and C. L. Ziegler, 2013: Aerosol effects on simulated storm electrification and
43 !! precipitation in a two-moment bulk microphysics model. J. Atmos. Sci., 70 (7), 2032-2050,
44 !! doi:10.1175/JAS-D-12-0264.1.
46 !! Ziegler, C. L., 1985: Retrieval of thermal and microphysical variables in observed convective storms.
47 !! Part I: Model development and preliminary testing. J. Atmos. Sci., 42, 1487-1509.
49 !! Sedimentation reference:
51 !! Mansell, E. R., 2010: On sedimentation and advection in multimoment bulk microphysics.
52 !! J. Atmos. Sci., 67, 3084-3094, doi:10.1175/2010JAS3341.1.
54 ! Possible parameters to adjust:
56 ! ccn : base cloud condensation nuclei concentration (use namelist.input value "nssl_cccn")
57 ! alphah, alphahl : Size distribution shape parameters for graupel (h) and hail (hl)
58 ! infall : changes sedimentation options to see effects (see below)
60 ! lightning model references:
62 ! Fierro, A. O., E.R. Mansell, C. Ziegler and D. R. MacGorman 2013: The
63 ! implementation of an explicit charging and discharge lightning scheme
64 ! within the WRF-ARW model: Benchmark simulations of a continental squall line, a
65 ! tropical cyclone and a winter storm. Monthly Weather Review, Volume 141, 2390-2415
67 ! Mansell et al. 2005: Charge structure and lightning sensitivity in a simulated
68 ! multicell thunderstorm. J. Geophys. Res., 110, D12101, doi:10.1029/2004JD005287
70 ! Note: Some parameters below apply to unreleased features.
73 !---------------------------------------------------------------------
75 ! - Update to 3-moment for rain, graupel, and hail
76 ! - Change default graupel/hail fall speeds to icdx/icdxhl=6 (Milbrandt & Morrison 2013)
77 ! and also set default ehw0=0.9 and ehlw0=0.9 to compensate for lower fall speeds.
78 ! - Change default hail conversion to ihlcnh=-1, and then =1 for 2-mom or =3 for 3-mom,
79 ! using wet growth diameter to convert large graupel
80 !---------------------------------------------------------------------
83 ! Restored previous formulation of snow reflectivity, as it was realized that the last change incorrectly assumed a fixed
84 ! density independent of size. Generally lower snow reflectivity values as a result (no effect on microphysics)
86 ! Generic fall speed coeffecients (axx,bxx) to accomodate future frozen drops category (no effect)
87 ! Reordered collection coefficients (dab1lh) to be consistent (no effect)
88 ! Switched to full calculation of rain number loss via collection by graupel (chacr; to be consisted with collection by hail) (minor effects)
89 !---------------------------------------------------------------------
92 ! Fall speed air density factor limited to air density of 0.05 (for very high model top) to mitigate excessive fall speeds
93 ! Fixed issue of spurious creation of large concentrations of very small droplets and transient large condensation (also increased minimum droplet size)
94 ! Fixed issue of negligible "seed" values of graupel from Bigg freezing at relatively high temperatures (thanks to S. Lasher-Trapp)
95 ! Minor bug fix in effective radius calculation of snow. (thanks to T. Iguchi)
97 ! Enabled regeneration of CCN by droplet evaporation and background restore (default time constant of 3600s)
98 ! Updated the routine that handles single-moment variables on the first time step. This sets a higher threshold for meaningful mixing ratios and sets a more realistic droplet concentration (also activating CCN as needed).
99 ! Enabled radar reflectivity from cloud ice (new formulation) ( idbzci = 1 )
100 ! Added internal option for ice crystal nucleation by DeMott et al. (2010, PNAS) (inucopt=4)
101 ! Allow greater fraction of hail to melt in one time step
102 ! Reduced minimum number concentration from 1e-4 to 1e-8 (based on CAPS input)
103 ! Added internal namelist for easier access to internal variables for development/testing and easier setup for ensemble microphysics diversity
104 ! (namelist read is disabled by default)
105 ! Increased resolution of lookup table for incomplete gamma functions
107 !---------------------------------------------------------------------
110 ! - Effective radius calculation was only done at history times. Now every time step (though should be just before radiation is called)
111 ! - Snow reflectivity: Previous "fix" was incorrect and yields snow dBZ that is too low. Reverted to old version which was correct
112 ! - Incorrectly updated a state value in the reflectivity code. (Could cause small differences if reflectivity is not calculated)
114 ! - Added code hints to use the "axtra2d" array to communicate rates from the microphysics routine into any 3d arrays that are passed in to the driver.
115 ! - Graupel and hail drag coefficients are returned from fall speed subroutine to use in ventilation coeffs. for consistency (minor change)
116 ! - Added (compile) option flag to turn on diagnosis of cloud droplet shape parameter based on number concentration
117 ! - Added (compile) option flag icracr to turn off rain self-collection
118 ! - Added compile options 'depfac' and 'meltfac' to adjust deposition/sublimation and melting (not freezing) rates of graupel/hail by a constant factor (for experimentation). Default value is 1.0
119 ! - Put limit on snow volume (2 cm) in aggregation rate
120 !---------------------------------------------------------------------
123 ! Fixed excessive sublimation that could occur in very strong downdrafts (3.9.1.1 update)
126 ! icefallopt=3 : New ice crystal fall speed that has faster speeds for small ice particles. Main effect
127 ! is on anvil clouds to help them decay a bit faster. Old behavior can be recovered with icefallopt=1
128 ! Cosmetic: removed stray single quotes because some preprocessors complain about unclosed quotes even in comments
130 !---------------------------------------------------------------------
131 ! WRF 3.9.1.1 update:
133 ! Added a check on overdepletion of ice by sublimation, which could sometimes result in water supersaturation
134 ! Bug fix: setting of t7 used 'dn' instead of 'dn1' (Thanks to Chunxi Zhang)
136 !---------------------------------------------------------------------
139 ! 2-moment scheme now creates number concentration tendencies from cumulus scheme mass mixing ratio rates
140 ! Renamed internal gamma function routine from 'gamma' to 'gamma_sp' to avoid name conflicts
141 ! Restored older settings that allow snow aggregation starting at T > -25C
142 ! Adjusted Meyers number of activated nuclei by the local air density to compensate for using data at surface
143 ! Minor updates to rain-ice crystal and hail-rain collection efficiencies
146 ! Reduced minimum mean snow diameter from 100 microns to 10 microns
148 !---------------------------------------------------------------------
150 ! Fixed issue with reflectivity conservation for graupel melting into rain. Rain number concentrations were too low,
151 ! resulting in excessive reflectivity of a couple dBZ
152 ! Changed default value of iusewetgraupel to 1 (turns off diagnostic meltwater on graupel for reflectivity)
153 ! Apply a 70 m/s fall speed limit for sedimentation
154 ! Changed vapor ice nucleation to Meyers-Ferrier method (original scheme)
155 ! New method for Bigg freezing (ibiggopt=2)
156 ! Reduced snow aggregration efficiency and restricted aggregation to higher temperatures (assuming dendrites and mechanical aggregation)
157 ! Increased maximum graupel-droplet collection efficiency when hail is turned off (nssl_2momg)
158 ! Updates for compatibility with WRF-NMM
159 ! Added calculation of hail number concentration in calcnfromq (creates number concentration from mixing ratio
160 ! when starting from an analysis). And fixed error in graupel intercept
161 ! Bug fix in snow fall speeds
162 ! Further fix in snow reflectivity
163 ! Use diameter of maximum mass rather than mean diamter when checking maximum size
164 ! Helped performance in sedimentation with flag "do_accurate_sedimentation" to control recalculation of fall speeds when
165 ! more than one sub-time step is needed (often happens with large time steps and small dz near the ground):
166 ! = .true. : recalculates fall speed after each substep (more accurate)
167 ! = .false. : (default) reuses fall speeds calculated on the first substep (typical for most schemes), theoretically could cause an occasional glitch, but none seen in practice
168 ! Increased maximum mean droplet radius from 40 to 60 microns, which alleviates spurious number concentration increases at low CCN concentration.
169 ! Removed a duplicate factor from hail reflectivity that was causing a loss of about 6 dBZ (since WRF 3.5).
171 !---------------------------------------------------------------------
175 MODULE module_mp_nssl_2mom
178 public nssl_2mom_driver
179 public nssl_2mom_init
180 private gamma_sp,gamxinf,GAML02, GAML02d300, GAML02d500, fqvs, fqis
181 private gamma_dp, gamxinfdp, gamma_dpr
182 private delbk, delabk
185 logical, private :: cleardiag = .false.
188 #if ( WRF_CHEM == 1 )
189 integer, parameter :: wrfchem_flag = 1
191 integer, parameter :: wrfchem_flag = 0
194 LOGICAL, PRIVATE:: is_aerosol_aware = .false.
196 logical, private :: turn_on_cin = .false.
198 integer, private :: eqtset = 1 ! Flag for use with cm1 to use alternate equation set (changes latent heating rates)
199 ! value of > 2 invokes the equivalent version of eqtset=2 that applies updates to both theta and Pi.
200 double precision, parameter, public :: zscale = 1.0d0 ! 1.000e-10
201 double precision, parameter, public :: zscaleinv = 1.0d0/zscale ! 1.000e-10
204 real, parameter :: warmonly = 0.0 ! testing parameter, set to 1.0 to reduce to warm-rain physics (ice variables stay zero)
206 logical, parameter :: lwsm6 = .false. ! act like wsm6 for some single moment interactions
208 ! some constants from WSM6
209 real, parameter :: dimax = 500.e-6 ! limited maximum value for the cloud-ice diamter
210 real, parameter :: roqimax = 2.08e22*dimax**8
213 integer :: iuseferrier = 1 ! =1: use dry graupel only from Ferrier 1994; = 0: Use Smith (wet graupel)
214 integer :: idbzci = 1
215 integer :: iusewetgraupel = 1 ! =1 to turn on use of QHW for graupel reflectivity (only for ZVDM -- mixedphase)
216 ! =2 turn on for graupel density less than 300. only
217 integer :: iusewethail = 0 ! =1 to turn on use of QHW for graupel reflectivity (only for ZVDM -- mixedphase)
218 integer :: iusewetsnow = 0 ! =1 to turn on diagnosed bright band; =2 'old' snow reflectivity (dry), =3 'old' snow dbz + brightband
221 real, private :: rho_qr = 1000., cnor = 8.0e5 ! cnor is set in namelist!! rain params
222 real, private :: rho_qs = 100., cnos = 3.0e6 ! set in namelist!! snow params
223 real, private :: rho_qh = 500., cnoh = 4.0e5 ! set in namelist!! graupel params
224 real, private :: rho_qhl= 800., cnohl = 4.0e4 ! set in namelist!! hail params
226 real, private :: hdnmn = 170.0 ! minimum graupel density (for variable density graupel)
227 real, private :: hldnmn = 500.0 ! minimum hail density (for variable density hail)
229 real :: cnohmn = 1.e-2 ! minimum intercept for 2-moment graupel (alphah < 0.5)
230 real :: cnohlmn = 1.e-2 ! minimum intercept for 2-moment hail (alphahl < 0.5)
232 ! Autoconversion parameters
234 real , private :: qcmincwrn = 2.0e-3 ! qc threshold for autonconversion (LFO; for 10ICE use qminrncw for ircnw != 5)
235 real , private :: cwdiap = 20.0e-6 ! threshold diameter of cloud drops (Ferrier 1994 autoconversion)
236 real , private :: cwdisp = 0.15 ! assume droplet dispersion parameter (can be 0.3 for maritime)
237 real , private :: ccn = 0.6e+09 ! set in namelist!! Central plains CCN value
238 real , private :: ccnuf = 0 ! set in namelist!! Central plains CCN value
239 real , public :: qccn, qccnuf ! ccn "mixing ratio"
240 real , private :: old_qccn = -1.0
241 integer, private :: iauttim = 1 ! 10-ice rain delay flag
242 real , private :: auttim = 300. ! 10-ice rain delay time
243 real , private :: qcwmntim = 1.0e-5 ! 10-ice rain delay min qc for time accrual
246 ! NMM WRF core does not have special boundary conditions for CCN, therefore set invertccn to true
247 logical, parameter :: invertccn = .true. ! =true for base state of ccn=0, =false for ccn initialized in the base state
249 logical, private :: invertccn = .false. ! =true for base state of ccn=0, =false for ccn initialized in the base state
251 logical :: switchccn = .false.
252 real :: old_cccn = -1.0
253 logical :: restoreccn = .true. ! whether or not to nudge CCN back to base state (qccn) (only applies if CCNA is NOT predicted)
254 real :: ccntimeconst = 3600. ! time constant for CCN restore (either for CCNA or when restoreccn = true)
255 real, private :: restoreccnfrac = 1.0 ! fraction of evaporated droplets that restore CCN
256 real :: ufccntimeconst = 6.*3600. ! time constant for UFCCN decay (Blossey et al. 2018)
257 real :: ufbackground = 0.1e9 ! background ccnuf value (Blossey et al.)
258 logical :: decayufccn = .false.
259 integer :: i_uf_or_ccn = 0 ! 0 = ship adds UF; 1 = treat UF as regular ccn (add to qccn)
261 ! sedimentation flags
262 ! itfall -> 0 = 1st order fallout (other options removed)
263 ! iscfall, infall -> fallout options for charge and number concentration, respectively
264 ! 1 = mass-weighted fall speed; 2 = number-weighted fallspeed.
265 integer, private :: itfall = 0
266 integer, private :: iscfall = 1
267 integer, private :: irfall = -1
268 integer, private :: isfall = 2 ! default limit with method II (more restrictive)
269 logical, private :: do_accurate_sedimentation = .false. ! if true, recalculate fall speeds on sub time steps; (more expensive)
270 ! if false, reuse fall speeds on multiple steps (can have a noticeable speedup)
271 ! Mainly is an issue for small dz near the surface.
272 integer, private :: interval_sedi_vt = 1 ! interval for recalculating Vt in sedimentation subloop (only when do_accurate_sedimentation = .true.)
273 integer, private :: infall = 4 ! 0 -> uses number-wgt for N; NO correction applied (results in excessive size sorting)
274 ! 1 -> uses mass-weighted fallspeed for N ALWAYS
275 ! 2 -> uses number-wgt for N and mass-weighted correction for N (Method II in Mansell, 2010 JAS)
276 ! 3 -> uses number-wgt for N and Z-weighted correction for N (Method I in Mansell, 2010 JAS)
277 ! 4 -> Hybrid of 2 and 3: Uses minimum N from each method (z-wgt and m-wgt corrections) (Method I+II in Mansell, 2010 JAS)
278 ! 5 -> uses number-wgt for N and uses average of N-wgt and q-wgt instead of Max.
279 integer :: imydiagalpha = 0 ! apply MY diagnostic shape parameter for fall speeds (1=for fall speed only; 2=also for microphysics rates)
280 real, private :: rainfallfac = 1.0 ! factor to adjust rain fall speed (single moment only)
281 real, private :: icefallfac = 1.0 ! factor to adjust ice fall speed
282 real, private :: snowfallfac = 1.0 ! factor to adjust snow fall speed
283 real, private :: graupelfallfac = 1.0 ! factor to adjust graupel fall speed
284 real, private :: hailfallfac = 1.0 ! factor to adjust hail fall speed
285 integer, private :: icefallopt = 3 ! 1= default, 2 = Ferrier ice fall speed; 3 = adjusted Ferrier (slightly high Vt)
286 integer, private :: icdx = 6 ! (graupel) 0=Ferrier; 1=leave drag coef. cd fixed; 2=vary by density, 4=set by user with cdxmin,cdxmax,etc.
287 ! 6= Milbrandt and Morrison (2013) density-based fall speed
288 integer, private :: icdxhl = 6 ! (hail) 0=Ferrier; 1=leave drag coef. cd fixed; 2=vary by density, 4=set by user with cdxmin,cdxmax,etc.
289 ! 6= Milbrandt and Morrison (2013) density-based fall speed
290 real :: axh = 75.7149, bxh = 0.5
291 real :: axf = 75.7149, bxf = 0.5
292 real :: axhl = 206.984, bxhl = 0.6384
293 real , private :: cdhmin = 0.45, cdhmax = 0.8 ! defaults for graupel (icdx=4)
294 real , private :: cdhdnmin = 500., cdhdnmax = 800.0 ! defaults for graupel (icdx=4)
295 real , private :: cdhlmin = 0.45, cdhlmax = 0.6 ! defaults for hail (icdx=4)
296 real , private :: cdhldnmin = 500., cdhldnmax = 800.0 ! defaults for hail (icdx=4)
297 real , private :: vtmaxsed = 70. ! Limit on fall speed (m/s, all moments) for sedimentation calculations. Not applied to fall speeds for microphysical rates
299 integer :: rssflg = 1 ! Rain size-sorting allowed (1, default), or disallowed (0). If 0, sets N and Z-weighted fall speeds to q-weighted value
300 integer :: sssflg = 1 ! As above but for snow
301 integer :: hssflg = 1 ! As above but for graupel
302 integer :: hlssflg = 1 ! As above but for hail
306 integer, private :: ndebug = -1, ncdebug = 0
307 integer, private :: ipconc = 5
308 integer, private :: inucopt = 0
309 integer, private :: ichaff = 0
310 integer, parameter :: ilimit = 0
312 real, private :: constccw = -1.
314 real, private :: cimn = 1.0e3, cimx = 1.0e6
316 real , private :: rhofrz = 900 ! density of freezing drops
317 real , private :: ifrzg = 1.0 ! fraction of frozen drops (Bigg freezing) going to graupel. 1=freeze all rain to graupel, 0=freeze all to hail
318 real , private :: ifiacrg = 1.0 ! fraction of frozen drops (3-component freezing qiacr) going to graupel. 1=freeze all rain to graupel, 0=freeze all to hail
319 real , private :: ifrzs = 1.0 ! fraction of small frozen drops going to snow. 1=freeze rain to snow, 0=freeze to cloud ice
320 real , private :: ffrzs = 0.0 ! fraction of other initiated cloud ice going to snow. 1=freeze rain to snow, 0=freeze to cloud ice
321 real , private :: f2h = 1.0 ! fraction of cloud ice conversion going to graupel (vs. frozen drops). For testing
322 integer, private :: irwfrz = 1 ! compute total rain that can freeze (checks heat budget)
323 integer, private :: irimtim = 0 ! future use
324 ! integer, private :: infdo = 1 ! 1 = calculate number-weighted fall speeds
326 integer, private :: irimdenopt = 1 ! = 1 for default Heymsfield and Pflaum (1985); = 2 for experimental Cober and List (1993); = 3 Macklin
327 real , private :: rimc1 = 300.0, rimc2 = 0.44 ! rime density coeff. and power (Default Heymsfield and Pflaum, 1985)
328 real , private :: rimc3 = 170.0 ! minimum rime density
329 real :: rimc4 = 900.0 ! maximum rime density
330 real , private :: rimtim = 120.0 ! cut-off rime time (10ICE)
331 real , private :: eqtot = 1.0e-9 ! threshold for mass budget reporting
332 real, private :: rimdenvwgt = 0.0 ! weight (0-1) given to number-weighted fall speed when calculating rime density
334 integer, private :: ireadmic = 0
336 integer, private :: idiagnosecnu = 0 ! =1 to diagnose cnu based on Chandrakar et al. 2016 data; =2 for Geoffroy et al. (2010, ACP)
337 integer, private :: iccwflg = 1 ! sets max size of first droplets in parcel to 4 micron radius (in two-moment liquid)
338 ! (first nucleation is done with a KW sat. adj. step)
339 integer, private :: issfilt = 0 ! flag to turn on filtering of supersaturation field
340 integer, private :: icnuclimit = 0 ! limit droplet nucleation based on Konwar et al. (2012) and Chandrakar et al. (2016)
341 integer, private :: irenuc = 2 ! =1 to always allow renucleation of droplets within the cloud (do no use, obsolete)
342 ! =2 renucleation following Twomey/Cohard&Pinty
343 ! =7 New renucleation that requires prediction of the number of activated nuclei
344 ! i.e., not only at cloud base
345 integer, private :: irenuc3d = 0 ! =1 to include horizontal gradient in renucleation of droplets within the cloud
346 real :: renucfrac = 0.0 ! = 0 : cnuc = cwccn
347 ! = 1 : cnuc = actual available CCN
348 ! otherwise cnuc = cwccn*(1. - renufrac) + ccnc(1:ngscnt)*renucfrac
349 real :: ssf2kmax = 10. ! max value for ssf**cck in irenuc=4 or 5
350 real , private :: cck = 0.6 ! exponent in Twomey expression
351 real , private :: ciintmx = 1.0e6 ! limit on ice concentration from primary nucleation
353 real , private :: cwccn ! , cwmasn,cwmasx
354 real , private :: ccwmx
356 integer, private :: idocw = 1, idorw = 1, idoci = 1, idoir = 1, idoip = 1, idosw = 1
357 integer, private :: idogl = 1, idogm = 1, idogh = 1, idofw = 1, idohw = 1, idohl = 1
358 ! integer, private :: ido(3:14) = / 12*1 /
361 ! 0,2, 5.00e-10, 1, 0, 0, 0 : itype1,itype2,cimas0,icfn,ihrn,ibfc,iacr
362 integer, private :: itype1 = 0, itype2 = 2 ! controls Hallett-Mossop process
363 integer, private :: in_freeze_rain_first = 0 ! =1 use IN to freezed rain drops (if none, then freeze droplets)
364 integer, private :: icenucopt = 1 ! =1 Meyers/Ferrier primary ice nucleation; =2 Thompson/Cooper, =3 Phillips (Meyers/Demott), =4 DeMott (2010)
365 real, private :: naer = 1.0e6 ! background large aerosol conc. for DeMott
366 integer, private :: icfn = 2 ! contact freezing: 0 = off; 1 = hack (ok for single moment); 2 = full Cotton/Meyers version
367 integer, private :: ihrn = 0 ! Hobbs-Rangno ice multiplication (Ferrier, 1994; use in 10-ice only)
368 integer, private :: ibfc = 1 ! Flag to use Bigg freezing on droplets (0 = off (uses alternate freezing), 1 = on)
369 real, private :: cwfrz2snowfrac = 0.0 ! fraction of freezing droplet mass to send to snow
370 real, private :: cwfrz2snowratio = 5. ! Assumed number of frozen droplets in a cluster
371 integer, private :: iremoveqwfrz = 1 ! Whether to remove (=1) or not (=0) the newly-frozen cloud droplets (ibfc=1) from the CWC used for charge separation
372 integer, private :: iacr = 2 ! Flag for drop contact freezing with crytals
373 ! (0=off; 1=drops > 500micron diameter; 2 = > 300micron)
374 integer, private :: icrcev = 1 ! 1 = old crcev; 2 = crcev scaled by vtrain ratio (num/mass); 3 = set to zero
375 integer, private :: icracr = 1 ! Flag to turn rain self-collection on/off (=0 to turn off)
376 integer, private :: icracrthresh = 1 ! For rain self-coll. thresh. use: 1 = mean diam of 2mm; 2 = rain median volume diam of 1.9mm
377 integer, private :: ibfr = 2 ! Flag for Bigg freezing conversion of freezing drops to graupel
378 ! (1=min graupel size is vr1mm; 2=use min size of dfrz, 5= as for 2 and apply dbz conservation)
379 integer, private :: ibiggopt = 2 ! 1 = old Bigg; 2 = experimental Bigg (only for imurain = 1, however)
380 integer :: ibiggsmallrain = 0 ! 1 = When rain is too small, freeze none to graupel and send all to snow (experimental)
381 integer, private :: iacrsize = 5 ! assumed min size of drops freezing by capture
382 ! 1: > 500 micron diam
386 ! 5: > 150 micron (only for imurain = 1)
387 real , private :: cimas0 = 6.62e-11 ! default mass of Hallett-Mossop crystals
388 ! 6.62e-11kg results in half the diam. (60 microns) of old default value of 5.0e-10
389 real , private :: cimas1 = 6.88e-13 ! default mass of new ice crystals
390 real , private :: splintermass = 6.88e-13
391 real , private :: cfnfac = 0.1 ! Hack factor that goes with icfn=1
392 integer, private :: iscni = 4 ! default option for ice crystal aggregation/conversion to snow
393 real , private :: fscni = 1.0 ! factor for calculating cscni
394 logical, private :: imeyers5 = .false. ! .false.=off, true=on for Meyers ice nucleation for temp > -5 C
395 real , private :: dmincw = 15.0e-6 ! minimum droplet diameter for collection for iehw=3
396 integer, private :: iehw = 1 ! 0 -> ehw=ehw0; 1 -> old ehw; 2 -> test ehw with Mason table data
397 integer, private :: iefw = 1 ! 0 -> ehw=ehw0; 1 -> old ehw; 2 -> test ehw with Mason table data
398 integer, private :: iehlw = 1 ! 0 -> ehlw=ehlw0; 1 -> old ehlw; 2 -> test ehlw with Mason table data
399 ! For ehw/ehlw = 1, ehw0/ehlw0 act as maximum limit on collection efficiency (defaults are 1.0)
400 integer, private :: ierw = 1 ! for single-moment rain (LFO/Z)
401 integer, private :: iehr0c = 0 ! 0 -> no collection for T > 0C; 1 -> turn on collection/shedding for T > 0C
402 integer, private :: iehlr0c = 0 ! 0 -> no collection for T > 0C; 1 -> turn on collection/shedding for T > 0C
403 real , private :: ehw0 = 0.9 ! 0.5 ! constant or max assumed graupel-droplet collection efficiency
404 real , private :: erw0 = 1.0 ! constant assumed rain-droplet collection efficiency
405 real , private :: ehlw0 = 0.9 ! 0.75 ! constant or max assumed hail-droplet collection efficiency
406 real , private :: efw0 = 0.5 ! constant or max assumed graupel-droplet collection efficiency
407 real :: ehr0 = 1.0 ! constant or max assumed graupel-rain collection efficiency
408 real :: efr0 = 1.0 ! constant or max assumed graupel-rain collection efficiency
409 real :: ehlr0 = 1.0 ! constant or max assumed hail-rain collection efficiency
410 real , private :: exwmindiam = 0.0 ! minimum diameter of droplets for riming. If set > 0, will exclude that fraction of mass/number from accretion (idea from Furtado and Field 2017 JAS but also Fierro and Mansell 2017)
413 real , private :: esilfo0 = 1.0 ! factor for LFO collection efficiency of snow for cloud ice.
414 real , private :: ehslfo0 = 1.0 ! factor for LFO collection efficiency of hail/graupel for snow.
416 integer, private :: ircnw = 5 ! single-moment warm-rain autoconversion option. 5= Ferrier 1994.
417 real , private :: qminrncw = 2.0e-3 ! qc threshold for rain autoconversion (NA for ircnw=5)
419 integer, private :: iqcinit = 2 ! For ZVDxx schemes, flag to choose which way to initialize droplets
420 ! 1 = Soong-Ogura adjustment
421 ! 2 = Saturation adjustment to value of ssmxinit
424 real , private :: ssmxinit = 0.4 ! saturation percentage to adjust down to for initial cloud
425 ! formation (ZVDxx scheme only)
427 real , private :: ewfac = 1.0 ! hack factor applied to graupel and hail collection eff. for droplets
428 real , private :: eii0 = 0.1 ,eii1 = 0.1 ! graupel-crystal coll. eff. parameters: eii0*exp(eii1*min(temcg(mgs),0.0))
429 ! set eii1 = 0 to get a constant value of eii0
430 real , private :: eii0hl = 0.2 ,eii1hl = 0.0 ! hail-crystal coll. eff. parameters: eii0hl*exp(eii1hl*min(temcg(mgs),0.0))
431 ! set eii1hl = 0 to get a constant value of eii0hl
432 real, private :: ewi_dcmin = 15.0e-06 ! minimum droplet diameter for nonzero ewi
433 real, private :: ewi_dimin = 30.0e-06 ! minimum ice crystal diameter for nonzero ewi
434 real , private :: eri0 = 0.1 ! rain efficiency to collect ice crystals
435 real , private :: eri_cimin = 10.e-6 ! minimum ice crystal diameter for collection by rain
436 real , private :: esi0 = 0.1 ! linear factor in snow-ice collection efficiency
437 real , private :: ehs0 = 0.1, ehs1 = 0.1 ! graupel-snow coll. eff. parameters: ehs0*exp(ehs1*min(temcg(mgs),0.0))
438 ! set ehs1 = 0 to get a constant value of ehs0
439 integer :: iessopt = 1 ! 1 = Original (no factor); 2 = factor based on wvel; 3 = factor based on SSI
440 ! 4 = as 3 but sets min factor of 0.1 and goes to full value at 0.5% SSI
441 real , private :: ess0 = 0.5, ess1 = 0.05 ! snow aggregation coefficients: ess0*exp(ess1*min(temcg(mgs),0.0))
442 ! set ess1 = 0 to get a constant value of ess0
443 real , private :: esstem1 = -15. ! lower temperature where snow aggregation turns on
444 real , private :: esstem2 = -10. ! higher temperature for linear ramp of ess from zero at esstem1 to formula value at esstem2
445 real , private :: essrmax = 0.02 ! maximum snow radius (meters) for csacs
446 real , private :: essfrac1 = 0.5 ! snow mass fraction 1 for aggregation roll-off
447 real , private :: essfrac2 = 0.75 ! snow mass fraction 2 for aggregation roll-off
448 integer, private :: iessec0flag = 0 ! flag to activate aggregation roll-off
449 real , private :: ehsfrac = 1.0 ! multiplier for graupel collection efficiency in wet growth
450 real , private :: ehimin = 0.0 ! Minimum collection efficiency (graupel - ice crystal)
451 real , private :: ehimax = 1.0 ! Maximum collection efficiency (graupel - ice crystal)
452 real , private :: ehsmax = 0.5 ! Maximum collection efficiency (graupel - snow)
453 real , private :: ecollmx = 0.5 ! Maximum collision efficiency for graup/hail with ice; used only for charging rates
454 integer, private :: iglcnvi = 1 ! flag for riming conversion from cloud ice to rimed ice/graupel
455 integer, private :: iglcnvs = 2 ! flag for conversion from snow to rimed ice/graupel
457 real , private :: rz ! reflectivity conservation factor for graupel/rain
458 ! now calculated in icezvd_dr.F from alphah and rnu
459 ! currently only used for graupel melting to rain
460 real , private :: rzhl ! reflectivity conservation factor for hail/rain
461 ! now calculated in icezvd_dr.F from alphahl and rnu
463 real , private :: rzs ! reflectivity conservation factor for snow(imusnow=3) with rain (imurain=1)
465 real , private :: alphahacx = 0.0 ! assumed minimum shape parameter for zhacw and zhacr
467 real , private :: fconv = 1.0 ! factor to boost max graupel depletion by riming conversions in 10ICE
469 real , private :: rg0 = 400.0 ! reference graupel density for graupel fall speed
471 integer, private :: rcond = 2 ! (Z only) rcond = 2 includes rain condensation in loop with droplet condensation
472 ! 0 = no condensation on rain; 1 = bulk condensation on rain
473 integer, parameter, private :: icond = 1 ! (Z only) icond = 1 calculates ice deposition (crystals and snow) BEFORE droplet condensation
474 ! icond = 2 does not work (intended to calc. dep in loop with droplet cond.)
475 integer, private :: iqis0 = 2 ! = 1 for normal qis; = 2 to set qis to use T = 0C when T > 0C
477 real , private :: dfrz = 0.15e-3 ! 0.25e-3 ! minimum diameter of frozen drops from Bigg freezing (used for vfrz) for iacr > 1
478 ! and for ciacrf for iacr=4
479 real , private :: dmlt = 3.0e-3 ! maximum diameter for rain melting from graupel and hail
480 real , private :: dshd = 1.0e-3 ! nominal diameter for rain drops shed from graupel/hail
481 integer, private :: ivshdgs = 1 ! 0 = use 1mm for all shedding (non-mixedphase); 1 = use vshdgs with sheddiam
482 integer, private :: ished2cld = 0 ! 1: Send shed liquid (from wet growth) to cloud droplets
484 integer, private :: ihmlt = 2 ! 1=old melting with vmlt; 2=new melting using mean volume diam of graupel/hail
485 integer, private :: imltshddmr = 2 ! 0 (default)=mean diameter of drops produced during melting+shedding as before (using mean diameter of graupel/hail
486 ! and max mean diameter of rain)
487 ! 1=new method where mean diameter of rain during melting is adjusted linearly downward
488 ! toward 3 mm for large (> sheddiam) graupel and hail, to take into account shedding of
489 ! smaller drops. sheddiam0 controls the size of graupel/hail above which the assumed
490 ! mean diameter of rain is set to 3 mm
491 ! Only valid for ihmlt = 2 for ZVD(H) but also applies to ZVD(H)M
492 ! 2 = method that sets the resulting rain size ( vshdgs ) according to the mass-weighted diameter of the ice
494 real :: mltdiam1 = 9.0e-3, mltdiam2 = 16.0e-3, mltdiam3 = 19.0e-3, mltdiam4 = 200.0e-3, mltdiam05 = 4.5e-3
496 integer, private :: nsplinter = 0 ! number of ice splinters per freezing drop, if negative, then per resulting graupel particle
497 real, private :: lawson_splinter_fac = 2.5e-11 ! constant in Lawson et al. (2015, JAS) for ice particle production from freezing drops
498 integer, private :: isnwfrac = 0 ! 0= no snow fragmentation; 1 = turn on snow fragmentation (Schuur, 2000)
500 ! integer, private :: denscale = 1 ! 1=scale num. conc. and charge by air density for advection, 0=turn off for comparison
502 real, private :: qhdpvdn = -1.
503 real, private :: qhacidn = -1.
505 integer, private :: iraintypes = 0
506 logical, private :: mixedphase = .false. ! .false.=off, true=on to include mixed phase graupel
507 integer, private :: imixedphase = 0
508 logical, private :: qsdenmod = .false. ! true = modify snow density by linear interpolation of snow and rain density
509 logical, private :: qhdenmod = .false. ! true = modify graupel density by linear interpolation of graupel and rain density
510 logical, private :: qsvtmod = .false. ! true = modify snow fall speed by linear interpolation of snow and rain vt
511 real , private :: sheddiam = 8.0e-03 ! minimum diameter of graupel before shedding occurs
512 real :: sheddiamlg = 10.0e-03 ! diameter of hail to use fwmlarge
513 real :: sheddiam0 = 20.0e-03 ! diameter of hail at which all water is shed
515 integer :: ifwmhopt = 2 ! option for calculating maximum liquid fraction when fwmh and/or fwmhl is set to -1
516 ! 1 = maximum based on size of maximum mass diameter
517 ! 2 = integrate over spectrum for maximum liquid (experimental)
519 integer :: ihxw2rain = 0 ! = 0 no transfer
520 ! = 1 transfer completely melted (99.5%) graupel/hail to rain when fwmh/fwmhl is set to -1.
522 real , private :: fwms = 0.5 ! maximum liquid water fraction on snow
523 real , private :: fwmh = 0.5 ! maximum liquid water fraction on graupel
524 real , private :: fwmhl = 0.5 ! maximum liquid water fraction on hail
525 real :: fwmlarge = 0.2 ! maximum liquid water fraction on hail larger than sheddiam
526 integer :: ifwmfall = 0 ! whether to interpolate toward rain fall speed for graupel and hail
527 ! when diam < sheddiam and liquid fraction is predicted (0=no, 1=yes)
529 logical :: rescale_high_alpha = .false. ! whether to rescale number. conc. when alpha = alphamax (3-moment only)
530 logical :: rescale_low_alpha = .true. ! whether to rescale Z (graupel/hail) when alpha = alphamin (3-moment only)
531 logical :: rescale_low_alphar = .true. ! whether to rescale Z for rain when alpha = alphamin (3-moment only)
532 logical :: rescale_low_alphah = .true. ! whether to rescale Z for rain when alpha = alphamin (3-moment only)
533 logical :: rescale_low_alphahl = .true. ! whether to rescale Z for rain when alpha = alphamin (3-moment only)
535 real, parameter :: alpharmax = 8. ! limited for rwvent calculation
537 integer, private :: ihlcnh = -1 ! which graupel -> hail conversion to use
538 ! 1 = Milbrandt and Yau (2005) using Ziegler 1985 wet growth diameter
539 ! 2 = Straka and Mansell (2005) conversion using size threshold
540 ! 3 = Conversion using wet growth diameter
541 real, private :: hlcnhdia = 1.e-3 ! threshold diameter for graupel -> hail conversion for ihlcnh = 1 option.
542 real, private :: hlcnhqmin = 0.1e-3 ! minimum graupel mass content for graupel -> hail conversion (ihlcnh = 1)
543 real , private :: hldia1 = 10.0e-3 ! threshold diameter for graupel -> hail conversion for ihlcnh = 2 option.
544 integer, private :: incwet = 0 ! flag to do wet growth only on D > D_wet
545 integer, private :: iusedw = 0 ! flag to use experimental wet growth ice diameter for gr -> hl conversion (=1 turns on)
546 real , private :: dwmin = 5.0e-3 ! Minimum diameter with iusedw (can stay at 0 or be set to something larger)
547 real , private :: dwetmin = 5.0e-3 ! Minimum diameter with iusedw (can stay at 0 or be set to something larger)
548 real , private :: dwmax = 15.e-3 ! for ihlcnh, always convert this size and larger whether or not there is wet growth
549 real , private :: dwtempmin = 242. ! lowest temperature to allow wet growth conversion to hail
550 real , private :: dwehwmin = 0. ! Minimum ehw to use to find wet growth diameter (if > ehw0, then wet growth diam becomes smaller)
551 real , private :: dg0thresh = 0.15 ! graupel wet growth diameter above which we say do not bother
552 integer :: ifddenfac = 0 ! = 1 to use density threshold to count FD as GR when converting to HL
553 real :: fddenthresh = 500. ! if ifddenfac > 0, then hail from FD with lower density are considered to come from graupel
554 integer :: icvhl2h = 0 ! allow conversion of hail back to graupel when hail density gets close to minimum allowed
556 integer, private :: imurain = 1 ! 3 for gamma-volume, 1 for gamma-diameter DSD for rain.
557 integer, private :: imusnow = 3 ! 3 for gamma-volume, 1 for gamma-diameter DSD for snow (=1 NOT IMPLEMENTED!!).
558 integer, private :: iturbenhance = 0 ! warm-rain collision enhancement
559 ! 1 = enhance autoconversion only
560 ! 2 = add rain collection of cloud
561 ! 3 = add rain self-collection
562 integer, private :: isedonly = 0 ! 1= only do sedimentation and skip other microphysics
563 integer, private :: iferwisventr = 2 ! =1 for Ferrier rwvent, =2 for Wisner rwvent (imurain=1)
564 integer, private :: izwisventr = 2 ! =1 for old Ziegler rwvent, =2 for Wisner-style rwvent (imurain=3)
565 integer :: iresetmoments = 0 ! if >0, then set all moments to zero when one of them is zero (3-moment only)
566 integer, private :: imaxdiaopt = 3
567 ! = 1 use mean diameter for breakup
568 ! = 2 use maximum mass diameter for breakup
569 ! = 3 use mass-weighted diameter for breakup
570 integer :: iraintailbreak = 0 ! 1 = on
571 real :: draintail = 8.e-3 ! starting size for rain breakup
572 integer, private :: dmrauto = 0
573 ! = -1 no limiter on crcnw
574 ! = 0 limit crcnw when qr > 1.2*L (Cohard-Pinty 2002)
575 ! = 1 DTD version based on MY code
576 ! = 2 DTD mass-weighted version based on MY code
577 ! = 3 Milbrandt version (from Cohard and Pinty code
578 integer :: dmropt = 0 ! extra option for crcnw
579 integer :: dmhlopt = 0 ! options for graupel -> hail conversion
580 integer :: irescalerainopt = 3 ! 0 = default option
581 ! 1 = qx(mgs,lc) > qxmin(lc)
582 ! 2 = qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < 3.0
583 ! 3 = temcg(mgs) > 0.0.and. qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < 3.0
584 real :: rescale_wthresh = 3.0
585 real :: rescale_tempthresh = 0.0
586 real, parameter :: alpharaut = 0.0 ! MY2005 for autoconversion
587 real :: cxmin = 1.e-8 ! threshold cutoff for number concentration
588 real :: zxmin = 1.e-28 ! threshold cutoff for reflectivity moment
590 integer :: ithompsoncnoh = 0 ! For single moment graupel only
591 ! 0 = fixed intercept
592 ! 1 = intercept based on graupel mass
594 integer :: ivhmltsoak = 1 ! 0=off, 1=on : flag to simulate soaking (graupel/hail) during melting
595 ! when liquid fraction is not predicted
596 logical, private :: iwetsoak = .true. ! soak and freeze during wet growth or not
597 integer, private :: ioldlimiter = 0 ! test switch for new(=0) or old(=1) size limiter at the end of GS for 3-moment categories
598 integer, private :: isnowfall = 2 ! Option for choosing between snow fall speed parameters
599 ! 1 = original Zrnic et al. (Mansell et al. 2010)
600 ! 2 = Ferrier 1994 (results in slower fall speeds)
602 integer, private :: isnowdens = 1 ! Option for choosing between snow density options
603 ! 1 = constant of 100 kg m^-3
604 ! 2 = Option based on Cox
606 integer, private :: ibiggsnow = 3 ! 1 = switch conversion over to snow for small frozen drops from Bigg freezing
607 ! 2 = switch conversion over to snow for small frozen drops from rain-ice interaction
608 ! 3 = switch conversion over to snow for small frozen drops from both
609 real :: biggsnowdiam = -1.0 ! If >0, use for ibiggsnow threshold
611 integer, private :: ixtaltype = 1 ! =1 column, =2 disk (similar to Takahashi)
613 real, private :: takshedsize1 = 0.15 ! diameter (cm) of drop shed from ice with D > 1.9 cm
614 real, private :: takshedsize2 = 0.3 ! diameter (cm) of drop shed from ice with D < 1.9 cm and D > 0.8 cm
615 real, private :: takshedsize3 = 0.45 ! diameter (cm) of drop shed from ice with D < 1.6 cm and D > 0.8 cm
616 integer, private :: numshedregimes = 3
618 real, private :: evapfac = 1.0 ! Multiplier on rain evaporation rate
619 real, private :: depfac = 1.0 ! Multiplier on graupel/hail deposition/sublimation rate
620 real,private,parameter :: meltfac = 1.0 ! Multiplier on graupel/hail melting rate
622 integer, private :: ibinhmlr = 0 ! =1 use incomplete gammas to determine melting from larger and smaller sizes of graupel, and appropriate shed drop sizes
623 ! =2 to test melting by temporary bins
624 integer, private :: ibinhlmlr = 0 ! =1 use incomplete gammas to determine melting from larger and smaller sizes of hail, and appropriate shed drop sizes
625 ! =2 to test melting by temporary bins
626 integer, private :: ibinnum = 2 ! number of bins for melting of smaller ice (for ibinhmlr = 1)
627 integer, private :: iqhacrmlr = 1 ! turn on/off qhacrmlr
628 integer, private :: iqhlacrmlr = 1 ! turn on/off qhlacrmlr
629 integer, private :: iqhacwshr = 1 ! turn on/off qhacw for T > 0
630 integer, private :: iqhlacwshr = 1 ! turn on/off qhlacw for T > 0
631 real, private :: binmlrmxdia = 40.e-3 ! threshold diameter (graupel/hail) to switch bin-bulk melting to use standard chmlr
632 real, private :: binmlrzrrfac = 1.0 ! factor for reflectivity change ice that sheds while melting
633 real, private :: snowmeltdia = 0 ! If nonzero, sets the size of rain drops from melting snow.
634 real, private :: alphasmlr0 = 14.0 ! shape parameter for drops formed from melting/shedding snow
635 real, private :: delta_alphamlr = 0.5 ! offset from alphamax at which melting does not further collapse the shape parameter
637 integer :: iqvsopt = 0 ! =0 use old default for tabqvs; =1 use Bolton formulation (Rogers and Yau)
639 integer :: imaxsupopt = 4 ! how to treat saturation adjustment in two-moment droplets
640 ! 1 = add droplets with same mean mass as current droplets
641 ! 2 = add droplets with minimum radius of 30 microns
642 ! 3 = only add 1.5*cxmin to number concentration (allow max size to apply)
643 ! 4 = add droplets with minimum radius of 20 microns
644 real :: maxsupersat = 1.9 ! maximum supersaturation ratio, above which a saturation adustment is done
645 real :: maxlowtempss = 1.08 ! Sat. ratio threshold for allowing droplet nucleation at T < tfrh
646 real :: ssmxuf = 4.0 ! supersaturation at which to start using "ultrafine" CCN (if ccnuf > 0.)
649 integer, parameter :: icespheres = 0 ! turn ice spheres (frozen droplets) on (1) or off (0). NOT COMPLETE IN WRF/ARPS/CM1 CODE!
650 integer, parameter :: lqmx = 30
651 integer, parameter :: lt = 1
652 integer, parameter :: lv = 2
653 integer, parameter :: lc = 3
654 integer, parameter :: lr = 4
655 integer, parameter :: li = 5
656 integer, private :: lis = 0
657 integer, private :: ls = 6
658 integer, private :: lh = 7
659 integer, private :: lf = 0
660 integer, private :: lhl = 0
662 integer, private :: lccn = 9 ! 0 or 9, other indices adjusted accordingly
663 integer, private :: lccnuf = 0
664 integer, private :: lccna = 0
665 integer, private :: lcina = 0
666 integer, private :: lcin = 0
667 integer, private :: lnc = 9
668 integer, private :: lnr = 10
669 integer, private :: lni = 11
670 integer, private :: lnis = 0
671 integer, private :: lns = 12
672 integer, private :: lnh = 13
673 integer, private :: lnf = 0
674 integer, private :: lnhl = 0
675 integer, private :: lnhf = 0
676 integer, private :: lnhlf = 0
677 integer, private :: lss = 0
680 integer, private :: lhab = 8
681 integer, private :: lg = 7
691 ! integer :: lvh = 16
694 ! liquid water fraction (not predicted here but tested for)
700 integer :: lhlwlg = 0
702 ! reflectivity (6th moment) ! not predicted here but may be tested against
727 integer :: lscpli = 0
728 integer :: lscnli = 0
729 integer :: lschab = 0
735 ! integer, parameter :: lscmx = 100
737 integer :: lne = 0 ! last varible for transforming
739 real :: cnoh0 = 4.0e+5
740 real :: hwdn1 = 700.0
742 real :: alphai = 0.0 ! shape parameter for ZIEG ice crystals ! not currently used
743 real :: alphas = 0.0 ! shape parameter for ZIEG snow ! used only for single moment
744 real :: alphar = 0.0 ! shape parameter for rain (imurain=1 only)
745 real, private :: alphah = 0.0 ! set in namelist!! shape parameter for ZIEG graupel
746 real, private :: alphahl = 1.0 ! set in namelist!! shape parameter for ZIEG hail
748 real :: dmuh = 1.0 ! power in exponential part (graupel)
749 real :: dmuhl = 1.0 ! power in exponential part (hail)
751 real, private :: alphamax = 15.
752 real, private :: alphamin = 0.
753 real, parameter :: rnumin = -0.8
754 real, parameter :: rnumax = 15.0
757 real :: cnu = 0.0 ! default value of droplet shape parameter. Can be diagnosed by setting idiagnosecnu=1
758 real, parameter :: rnu = -0.8, snu = -0.8, cinu = 0.0
759 ! parameter ( cnu = 0.0, rnu = -0.8, snu = -0.8, cinu = 0.0 )
761 real xnu(lc:lqmx) ! 1st shape parameter (mass)
762 real xmu(lc:lqmx) ! 2nd shape parameter (mass)
763 real dnu(lc:lqmx) ! 1st shape parameter (diameter)
764 real dmu(lc:lqmx) ! 2nd shape parameter (diameter)
770 real da0 (lc:lqmx) ! collection coefficients from Seifert 2005
771 real dab0(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
772 real dab1(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
773 real da1 (lc:lqmx) ! collection coefficients from Seifert 2005
777 ! put ipelec here for now....
778 integer :: ipelec = 0
779 integer :: isaund = 0
780 logical :: idoniconly = .false.
781 integer, private :: elec_on_time = -1 ! time (seconds) to turn on charge separation.
782 integer, private :: elec_ramp_time = 0 ! time (interval) for linear ramp after elec_on_time
783 ! (i.e., linear factor on chg sep to smoothly turn on elec)
784 ! full charging rate is achieved at time = elec_on_time + elec_ramp_time
785 integer :: jchgs = 3 ! number of points near boundary where charging is turned off (to keep lightning from getting wonky)
789 real :: charging_border = 4000. ! width of no-charging zone from boundary
790 real, private :: delqnw = -1.0e-10!-1.0e-12 !
791 real, private :: delqxw = 1.0e-10! 1.0e-12 !
792 real :: tindmn = 233, tindmx = 298.0 ! min and max temperatures where inductive charging is allowed
795 ! gamma function lookup table
797 integer ngm0,ngm1,ngm2
798 parameter (ngm0=3001,ngm1=500,ngm2=500)
799 double precision, parameter :: dgam = 0.01, dgami = 100.
800 double precision gmoi(0:ngm0) ! ,gmod(0:ngm1,0:ngm2),gmdi(0:ngm1,0:ngm2)
802 integer, parameter :: nqiacralpha = 300 !480 ! 240 ! 120 ! 15
803 integer, parameter :: nqiacrratio = 400 ! 500 !50 ! 25
804 ! real, parameter :: maxratiolu = 25.
805 real, parameter :: maxratiolu = 100. ! 25.
806 real, parameter :: maxalphalu = 15.
807 real, parameter :: minalphalu = -0.95
808 real, parameter :: dqiacralpha = maxalphalu/Float(nqiacralpha), dqiacrratio = maxratiolu/Float(nqiacrratio)
809 real, parameter :: dqiacrratioinv = 1./dqiacrratio, dqiacralphainv = 1./dqiacralpha
810 integer, parameter :: ialpstart = minalphalu*dqiacralphainv
811 real :: ciacrratio(0:nqiacrratio,ialpstart:nqiacralpha)
812 real :: qiacrratio(0:nqiacrratio,ialpstart:nqiacralpha)
813 real :: ziacrratio(0:nqiacrratio,ialpstart:nqiacralpha)
814 double precision :: gamxinflu(0:nqiacrratio,ialpstart:nqiacralpha,12,2) ! last index for graupel (1) or hail (2)
815 ! real :: ciacrratio(0:nqiacrratio,0:nqiacralpha)
816 ! real :: qiacrratio(0:nqiacrratio,0:nqiacralpha)
817 ! real :: ziacrratio(0:nqiacrratio,0:nqiacralpha)
818 ! double precision :: gamxinflu(0:nqiacrratio,0:nqiacralpha,12,2) ! last index for graupel (1) or hail (2)
820 ! for 3-moment collection coefficients
821 real, save :: dab0lu(ialpstart:nqiacralpha,ialpstart:nqiacralpha,lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
822 real, save :: dab1lu(ialpstart:nqiacralpha,ialpstart:nqiacralpha,lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
824 integer, parameter :: ngdnmm = 9
825 real :: mmgraupvt(ngdnmm,3) ! Milbrandt and Morrison (2013) fall speed coefficients for graupel/hail
827 DATA mmgraupvt(:,1) / 50., 150., 250., 350., 450., 550., 650., 750., 850./
828 DATA mmgraupvt(:,2) / 62.923, 94.122, 114.74, 131.21, 145.26, 157.71, 168.98, 179.36, 189.02 /
829 DATA mmgraupvt(:,3) / 0.67819, 0.63789, 0.62197, 0.61240, 0.60572, 0.60066, 0.59663, 0.59330, 0.59048 /
834 integer lvol(lc:lqmx)
836 integer lliq(li:lqmx)
837 integer denscale(lc:lqmx) ! flag for density scaling (mixing ratio conversion)
843 real xdnmx(lc:lqmx), xdnmn(lc:lqmx)
846 real xvmn(lc:lqmx), xvmx(lc:lqmx)
848 real qxmin_init(lc:lqmx)
851 parameter (nqsat=1000001) ! (nqsat=20001)
853 parameter (fqsat=0.002,fqsati=1./fqsat)
854 real tabqvs(nqsat),tabqis(nqsat),dtabqvs(nqsat),dtabqis(nqsat)
859 real, parameter :: ar = 841.99666 ! rain terminal velocity power law coefficient (LFO)
860 real, parameter :: br = 0.8 ! rain terminal velocity power law coefficient (LFO)
861 real, parameter :: aradcw = -0.27544 !
862 real, parameter :: bradcw = 0.26249e+06 !
863 real, parameter :: cradcw = -1.8896e+10 !
864 real, parameter :: dradcw = 4.4626e+14 !
865 real, parameter :: bta1 = 0.6 ! beta-1 constant used for ice nucleation by deposition (Ferrier 94, among others)
866 real, parameter :: cnit = 1.0e-02 ! No for ice nucleation by deposition (Cotton et al. 86)
867 real, parameter :: dragh = 0.60 ! coefficient used to adjust fall speed for hail versus graupel (Pruppacher and Klett 78)
868 real, parameter :: dnz00 = 1.225 ! reference/MSL air density
869 real, parameter :: rho00 = 1.225 ! reference/MSL air density
870 ! cs = 4.83607122 ! snow terminal velocity power law coefficient (LFO)
871 ! ds = 0.25 ! snow terminal velocity power law coefficient (LFO)
872 ! new values for cs and ds
873 real, parameter :: cs = 12.42 ! snow terminal velocity power law coefficient
874 real, parameter :: ds = 0.42 ! snow terminal velocity power law coefficient
875 real, parameter :: cp608 = 0.608 ! constant used in conversion of T to Tv
877 real, parameter :: gr = 9.8
879 real, parameter :: pi = 3.141592653589793
880 real, parameter :: piinv = 1./pi
881 real, parameter :: pid4 = pi/4.0
884 ! max and min mean volumes
886 real xvrmn, xvrmx0 ! min, max rain volumes
887 real xvsmn, xvsmx ! min, max snow volumes
888 real xvfmn, xvfmx ! min, max frozen drop volumes
889 real xvgmn, xvgmx ! min, max graupel volumes
890 real xvhmn, xvhmn0, xvhmx, xvhmx0 ! min, max hail volumes
891 real xvhlmn, xvhlmx ! min, max lg hail volumes
893 real, parameter :: dhlmn = 0.3e-3, dhlmx = 40.e-3
894 real, parameter :: dhmn0 = 0.3e-3
895 real, private :: dhmn = dhmn0, dhmx = -1.
897 real, parameter :: cwradn = 2.0e-6, xcradmn = cwradn ! minimum radius
898 real, parameter :: cwradx = 60.e-6, xcradmx = cwradx ! maximum radius
899 real, parameter :: cwc1 = 6.0/(pi*1000.)
901 ! parameter( xvcmn=4.188e-18 ) ! mks min volume = 3 micron radius
902 real, parameter :: xvcmn=0.523599*(2.*cwradn)**3 ! mks min volume = 2.5 micron radius
903 real, parameter :: xvcmx=0.523599*(2.*xcradmx)**3 ! mks max volume = 60 micron radius
904 real, parameter :: cwmasn = 1000.*xvcmn ! minimum mass, defined by radius of 5.0e-6
905 real, parameter :: cwmasx = 1000.*xvcmx ! maximum mass, defined by radius of 50.0e-6
906 real, parameter :: cwmasn5 = 1000.*0.523599*(2.*5.0e-6)**3 ! 5.23e-13
908 real, parameter :: xvimn=0.523599*(2.*5.e-6)**3 ! mks min volume = 5 micron radius
909 real, parameter :: xvimx=0.523599*(2.*1.e-3)**3 ! mks max volume = 1 mm radius (solid sphere approx)
911 real, private :: xvdmx = -1.0 ! 3.0e-3
913 parameter( xvrmn=0.523599*(80.e-6)**3, xvrmx0=0.523599*(6.e-3)**3 ) !( was 4.1887e-9 ) ! mks
914 parameter( xvsmn=0.523599*(0.01e-3)**3, xvsmx=0.523599*(10.e-3)**3 ) !( was 4.1887e-9 ) ! mks
915 parameter( xvfmn=0.523599*(0.1e-3)**3, xvfmx=0.523599*(10.e-3)**3 ) ! mks xvfmx = (pi/6)*(10mm)**3
916 parameter( xvgmn=0.523599*(0.1e-3)**3, xvgmx=0.523599*(10.e-3)**3 ) ! mks xvfmx = (pi/6)*(10mm)**3
917 parameter( xvhmn0=0.523599*(0.3e-3)**3, xvhmx0=0.523599*(20.e-3)**3 ) ! mks xvfmx = (pi/6)*(20mm)**3
918 parameter( xvhlmn=0.523599*(dhlmn)**3, xvhlmx=0.523599*(dhlmx)**3 ) ! mks xvfmx = (pi/6)*(40mm)**3
921 ! electrical permitivity of air C / (N m**2) - check the units
924 parameter (eperao = 8.8592e-12 )
926 real ec,eci ! fundamental unit of charge
927 parameter (ec = 1.602e-19)
928 parameter (eci = 1.0/ec)
930 real :: scwppmx = 20.0e-12
931 real :: scippmx = 20.0e-12
935 real, parameter :: c1f3 = 1.0/3.0
937 real, parameter :: cai = 21.87455
938 real, parameter :: caw = 17.2693882
939 real, parameter :: cbi = 7.66
940 real, parameter :: cbw = 35.86
942 real, parameter :: cbwbolton = 29.65 ! constants for Bolton formulation
943 real, parameter :: cawbolton = 17.67
945 real, parameter :: tfrh = 233.15
946 real, parameter :: tfr = 273.15
948 real, parameter :: cp = 1004.0, rd = 287.04
949 real, parameter :: rw = 461.5 ! gas const. for water vapor
950 real, parameter :: cpl = 4190.0
951 real, parameter :: cpigb = 2106.0
952 real, parameter :: cpi = 1./cp
953 real, parameter :: cap = rd/cp
954 real, parameter :: tfrcbw = tfr - cbw
955 real, parameter :: tfrcbi = tfr - cbi
956 real, parameter :: rovcp = rd/cp
957 real :: rdorv = 0.622
958 real, parameter :: poo = 1.0e+05
959 real, parameter :: advisc0 = 1.832e-05 ! reference dynamic viscosity (SMT; see Beard & Pruppacher 71)
960 real, parameter :: advisc1 = 1.718e-05 ! dynamic viscosity constant used in thermal conductivity calc
961 real, parameter :: tka0 = 2.43e-02 ! reference thermal conductivity
963 ! GHB: Needed for eqtset=2 in cm1
964 ! REAL, PRIVATE :: cv = cp - rd
965 real, private, parameter :: cv = 717.0 ! specific heat at constant volume - air
966 REAL, PRIVATE, parameter :: cvv = 1408.5
969 real, parameter :: bfnu0 = (rnu + 2.0)/(rnu + 1.0)
970 real :: ventr, ventrn, ventc, c1sw
973 real :: cckm,ccne,ccnefac,cnexp,CCNE0
977 real gf4p5, gf4ds, gf4br
978 real gsnow1, gsnow53, gsnow73
979 real gfcinu1, gfcinu1p47, gfcinu2p47
980 real gfcinu1p22,gfcinu2p22
981 real gfcinu1p18,gfcinu2p18
983 real :: cwchtmp0 = 1.0
984 real :: cwchltmp0 = 1.0
986 real :: esctot = 1.0e-13
988 integer iexy(lc:lqmx,lc:lqmx)
989 integer :: ieswi = 1, ieswc = 1, ieswr = 0
990 integer :: iehlsw = 1, iehli = 1, iehlc = 1, iehlr = 0
991 integer :: iehwsw = 1, iehwi = 1, iehwc = 1, iehwr = 0
993 logical, parameter :: do_satadj_for_wrfchem = .true.
995 integer, parameter :: ac_opt = 0 ! option flag for alternate aerosol (for NUWRF only)
996 logical, private :: nuaccoinp = .false.
998 ! Note to users: Many of these options are for development and not guaranteed to perform well.
999 ! Some may not be functional depending on the version of the code.
1000 ! Some may be useful for ensemble physics diversity. Feel free to contact Ted Mansell if you have questions
1002 NAMELIST /nssl_mp_params/ &
1010 infall,irfall,isfall, &
1015 irimdenopt,rimdenvwgt, &
1016 rimc1, rimc2, rimc3, rimc4, &
1020 restoreccn, ccntimeconst, cck, &
1021 decayufccn, ufccntimeconst, &
1022 switchccn, old_cccn, &
1025 icenucopt, in_freeze_rain_first, &
1028 ibfc, iacr, icracr, &
1030 cwfrz2snowfrac, cwfrz2snowratio, &
1037 cimas0, cimas1, cfnfac, &
1045 ess0, ess1, iessopt, &
1047 ircnw, qminrncw,& ! single-moment only
1059 alphas, & ! note that alphah and alphahl come through physics namelist
1071 axh,bxh,axf,bxf,axhl,bxhl, &
1073 cdhdnmin, cdhdnmax, &
1075 cdhldnmin, cdhldnmax, &
1086 lawson_splinter_fac, &
1097 qsdenmod,qhdenmod, &
1099 alphamin,alphamax, &
1101 rescale_low_alpha, &
1102 rescale_low_alphar, &
1103 rescale_low_alphah, &
1104 rescale_low_alphahl, &
1105 rescale_high_alpha, &
1106 ihlcnh, hldia1,iusedw, dwehwmin, dwmin, dwmax, dwtempmin, dg0thresh, &
1107 icvhl2h, hldnmn,hdnmn, &
1108 hlcnhdia, hlcnhqmin, &
1117 sheddiam,sheddiamlg, &
1119 mltdiam1,mltdiam2,mltdiam3,mltdiam4,mltdiam05, &
1131 dmrauto,irescalerainopt, dmropt,dmhlopt, &
1132 rescale_tempthresh, rescale_wthresh, &
1133 ibinhmlr,ibinhlmlr,imltshddmr, binmlrmxdia, binmlrzrrfac,ibinnum, &
1134 iqhacrmlr, iqhlacrmlr, &
1139 do_accurate_sedimentation, interval_sedi_vt
1140 ! #####################################################################
1141 ! #####################################################################
1145 ! #####################################################################
1146 ! #####################################################################
1149 REAL FUNCTION fqvs(t)
1152 fqvs = exp(caw*(t-273.15)/(t-cbw))
1155 REAL FUNCTION fqis(t)
1158 fqis = exp(cai*(t-273.15)/(t-cbi))
1166 ! #####################################################################
1167 ! #####################################################################
1168 SUBROUTINE nssl_2mom_init( &
1169 & ims,ime, jms,jme, kms,kme, nssl_params, ipctmp, mixphase,ihvol,idoniconlytmp, &
1170 & nssl_graupelfallfac, &
1171 & nssl_hailfallfac, &
1176 & nssl_icefallfac, &
1177 & nssl_snowfallfac, &
1183 & nssl_density_on, nssl_hail_on, nssl_ccn_on, nssl_icecrystals_on, ccn_is_ccna, &
1190 real, intent(in), optional :: &
1191 & nssl_graupelfallfac, &
1192 & nssl_hailfallfac, &
1195 & nssl_icefallfac, &
1196 & nssl_snowfallfac, &
1201 integer, intent(in), optional :: &
1203 & nssl_icdxhl, myrank, mpiroot, &
1205 logical, intent(in), optional :: nssl_density_on, nssl_hail_on, nssl_ccn_on, nssl_icecrystals_on
1206 integer, intent(inout), optional :: ccn_is_ccna
1208 integer, intent(in),optional :: infileunit
1210 integer, intent(in), optional :: ims,ime, jms,jme, kms,kme
1212 real, intent(in), dimension(20), optional :: nssl_params
1216 integer, intent(in) :: ipctmp,mixphase
1217 integer, optional, intent(in) :: ihvol
1218 logical, optional, intent(in) :: idoniconlytmp
1220 integer :: igvol_local = 1
1221 logical :: wrote_namelist = .false.
1222 logical :: wrf_dm_on_monitor
1223 integer :: hail_on = -1, density_on = -1, icecrystals_on = 1
1224 integer :: ccn_on = -1
1226 double precision :: arg
1235 double precision :: x,y,y2,y7
1236 logical :: turn_on_ccna, turn_on_cina
1237 integer :: iufccn = 0
1240 real :: alpjj, alpii, xnuii, xnujj
1244 turn_on_ccna = .false.
1245 turn_on_cina = .false.
1247 ! IF ( present( igvol ) ) THEN
1248 ! igvol_local = igvol
1251 IF ( present( nssl_hail_on ) ) THEN
1252 IF ( nssl_hail_on ) THEN
1259 IF ( present( nssl_density_on ) ) THEN
1260 IF ( nssl_density_on ) THEN
1267 IF ( present( nssl_icecrystals_on ) ) THEN
1268 IF ( nssl_icecrystals_on ) THEN
1272 ! renucfrac = 1.0 ! why was this set to 1?
1279 ! set some global values from namelist input
1282 IF ( present( nssl_params ) ) THEN
1283 ccn = Abs( nssl_params(1) )
1284 alphah = nssl_params(2)
1285 alphahl = nssl_params(3)
1286 cnoh = nssl_params(4)
1287 cnohl = nssl_params(5)
1288 cnor = nssl_params(6)
1289 cnos = nssl_params(7)
1290 rho_qh = nssl_params(8)
1291 rho_qhl = nssl_params(9)
1292 rho_qs = nssl_params(10)
1293 IF ( Nint(nssl_params(13)) == 1 ) THEN
1294 ! hack to switch CCN field to CCNA (activated ccn)
1295 ! invertccn = .true.
1296 turn_on_ccna = .true.
1299 ccnuf = Abs( nssl_params(14) )
1300 IF ( present(nssl_ufccn) ) iufccn = nssl_ufccn
1303 ! ipelec = Nint(nssl_params(11))
1304 ! isaund = Nint(nssl_params(12))
1307 IF ( present(nssl_graupelfallfac) ) graupelfallfac = nssl_graupelfallfac
1308 IF ( present(nssl_hailfallfac) ) hailfallfac = nssl_hailfallfac
1309 IF ( present(nssl_ehw0) ) THEN
1310 IF ( nssl_ehw0 > 0.0 ) ehw0 = nssl_ehw0
1312 IF ( present(nssl_ehlw0) ) THEN
1313 IF ( nssl_ehlw0 > 0.0 ) ehlw0 = nssl_ehlw0
1315 IF ( present(nssl_icdx) ) icdx = nssl_icdx
1316 IF ( present(nssl_icdxhl) ) icdxhl = nssl_icdxhl
1317 IF ( present(nssl_icefallfac) ) icefallfac = nssl_icefallfac
1318 IF ( present(nssl_snowfallfac) ) snowfallfac = nssl_snowfallfac
1319 IF ( present(nssl_cccn) ) THEN
1320 IF (nssl_cccn > 1 ) ccn = nssl_cccn
1322 IF ( present(nssl_alphah) ) THEN
1323 IF ( nssl_alphah > -1. ) alphah = nssl_alphah
1325 IF ( present(nssl_alphahl) ) THEN
1326 IF ( nssl_alphahl > -1. ) alphahl = nssl_alphahl
1328 IF ( present(nssl_alphar) ) THEN
1329 IF ( nssl_alphar > -1.0 ) alphar = nssl_alphar
1335 IF ( ipconc < 5 ) THEN
1339 IF ( ihlcnh <= 0 ) THEN
1340 IF ( ipconc == 5 ) THEN
1342 ELSEIF ( ipconc >= 6 ) THEN
1351 IF ( .true. ) THEN ! set to true to enable internal namelist read
1352 open(15,file='namelist.input',status='old',form='formatted',action='read')
1354 read(15,NML=nssl_mp_params,iostat=istat)
1356 IF ( istat /= 0 ) THEN
1358 IF ( wrf_dm_on_monitor() ) THEN
1359 write(0,*) 'NSSL_2MOM_INIT: PROBLEM WITH NSSL_MP_PARAMS namelist: not found or bad token'
1362 ! write(0,*) 'NSSL_2MOM_INIT: PROBLEM WITH NSSL_MP_PARAMS namelist: not found or bad token'
1365 IF ( wrf_dm_on_monitor() .and. .not. wrote_namelist ) THEN
1366 open(15,file='namelist.output',status='old',action='readwrite', position='append',form='formatted')
1367 write(15,NML=nssl_mp_params)
1369 wrote_namelist = .true.
1375 IF ( iufccn > 0 ) THEN ! make sure to use option that uses UF ccn
1377 IF ( ccnuf <= 0.0 ) decayufccn = .true. ! assume surface emission and need decay
1378 IF ( i_uf_or_ccn > 0 ) THEN
1380 ccntimeconst = ufccntimeconst
1384 IF ( present( nssl_ccn_on ) ) THEN
1385 IF ( nssl_ccn_on ) THEN
1393 IF ( irenuc >= 5 ) THEN
1394 turn_on_ccna = .true.
1395 IF ( present( nssl_ccn_on ) ) THEN
1396 IF ( .not. nssl_ccn_on ) THEN
1397 write(0,*) 'NSSL_MP Error: Must have nssl_ccn_on=1 for irenuc >= 5!'
1403 IF ( present( ccn_is_ccna ) .and. ccn_on == 1 ) THEN
1404 IF ( ccn_is_ccna > 0 ) THEN
1405 turn_on_ccna = .true.
1407 IF ( irenuc >= 5 ) THEN
1417 IF ( icespheres >= 1 ) THEN
1424 IF ( hail_on == -1 ) THEN ! hail_on is not set
1426 IF ( ihvol <= -1 .or. ihvol == 2 ) THEN
1427 IF ( ihvol == -1 .or. ihvol == -2 ) THEN
1428 lhab = lhab - 1 ! turns off hail
1431 ! past me thought it would be a good idea to change graupel factors when hail is off....
1434 ! dfrz = Max( dfrz, 0.5e-3 )
1436 IF ( ihvol == -2 .or. ihvol == 2 .or. icecrystals_on == 0 ) THEN ! ice crystals are turned off
1437 ! a value of 2? means to turn off ice crystals but turn on hail
1438 ! renucfrac = 1.0 ! why?
1440 ! idoci = 0 ! try this later
1444 ELSE ! hail_on is set
1445 IF ( hail_on == 0 ) THEN
1446 lhab = lhab - 1 ! turns off hail
1449 ! assume default that hail is on
1453 IF ( density_on == -1 ) THEN ! density flag not set, so default is to predict it
1458 ! write(0,*) 'wrf_init: lhab,lhl,hail_on,density_on = ',lhab,lhl,hail_on,density_on
1460 ! IF ( ipelec > 0 ) idonic = .true.
1463 ! Build lookup table for saturation mixing ratio (Soong and Ogura 73)
1467 temq = 163.15 + (l-1)*fqsat
1468 IF ( iqvsopt == 0 ) THEN
1469 tabqvs(l) = exp(caw*(temq-273.15)/(temq-cbw))
1470 dtabqvs(l) = ((-caw*(-273.15 + temq))/(temq - cbw)**2 + &
1471 & caw/(temq - cbw))*tabqvs(l)
1473 tabqvs(l) = exp(caw*(temq-273.15)/(temq-cbw))
1474 dtabqvs(l) = ((-cawbolton*(-273.15 + temq))/(temq - cbwbolton)**2 + &
1475 & cawbolton/(temq - cbwbolton))*tabqvs(l)
1477 tabqis(l) = exp(cai*(temq-273.15)/(temq-cbi))
1478 dtabqis(l) = ((-cai*(-273.15 + temq))/(temq - cbi)**2 + &
1479 & cai/(temq - cbi))*tabqis(l)
1487 IF ( icdx == 6 ) THEN
1488 bx(lh) = 0.6 ! Milbrandt and Morrison (2013) for density of 550.
1490 ! ELSEIF ( icdx == 1 ) THEN
1493 ELSEIF ( icdx > 1 ) THEN
1496 ELSEIF ( icdx == 0 ) THEN
1497 bx(lh) = 0.37 ! 0.6 ! Ferrier 1994 graupel
1500 ! ax(lh) = 206.984 ! Ferrier 1994 hail/frozen drops
1508 IF ( lhl .gt. 1 ) THEN
1509 IF ( icdxhl == 6 ) THEN
1510 bx(lhl) = 0.593 ! Milbrandt and Morrison (2013) for density of 750.
1512 ELSEIF (icdxhl == 0 ) THEN
1513 ax(lhl) = 206.984 ! Ferrier 1994
1515 ELSEIF (icdxhl > 0 ) THEN
1524 ! fill in the complete gamma function lookup table
1528 gmoi(igam) = gamma_dp(arg)
1531 ! build lookup table to compute the number and mass fractions of rain drops
1532 ! (imurain=1) greater than a given diameter. Used for qiacr and ciacr
1533 ! Uses incomplete gamma functions
1534 ! The terms with bxh or bxhl will be off if the actual bxh or bxhl is different from the base value (icdx=6 option)
1537 bxhl1 = bx(Max(lh,lhl))
1539 ! DO j = 0,nqiacralpha
1540 DO j = ialpstart,nqiacralpha
1541 alp = float(j)*dqiacralpha
1542 y = gamma_dpr(1.+alp)
1543 y2 = gamma_dpr(2.+alp)
1544 DO i = 0,nqiacrratio
1545 ratio = float(i)*dqiacrratio
1546 x = gamxinfdp( 1.+alp, ratio )
1547 ! write(0,*) 'i, x/y = ',i, x/y
1548 ciacrratio(i,j) = x/y
1551 gamxinflu(i,j,1,1) = x/y
1552 gamxinflu(i,j,2,1) = gamxinfdp( 2.0+alp, ratio )/y
1553 gamxinflu(i,j,3,1) = gamxinfdp( 2.5+alp+0.5*bxh1, ratio )/y
1554 gamxinflu(i,j,5,1) = (gamma_dpr(5.0+alp) - gamxinfdp( 5.0+alp, ratio ))/y
1555 gamxinflu(i,j,6,1) = (gamma_dpr(5.5+alp+0.5*bxh1) - gamxinfdp( 5.5+alp+0.5*bxh1, ratio ))/y
1556 gamxinflu(i,j,9,1) = gamxinfdp( 1.0+alp, ratio )/y
1557 gamxinflu(i,j,10,1)= gamxinfdp( 4.0+alp, ratio )/y
1559 gamxinflu(i,j,12,1) = gamxinfdp( 2.0+alp, ratio )/y2
1562 gamxinflu(i,j,1,2) = gamxinflu(i,j,1,1)
1563 gamxinflu(i,j,2,2) = gamxinflu(i,j,2,1)
1564 gamxinflu(i,j,3,2) = gamxinfdp( 2.5+alp+0.5*bxhl1, ratio )/y
1565 gamxinflu(i,j,5,2) = gamxinflu(i,j,5,1)
1566 gamxinflu(i,j,6,2) = (gamma_dpr(5.5+alp+0.5*bxhl1) - gamxinfdp( 5.5+alp+0.5*bxhl1, ratio ))/y
1567 gamxinflu(i,j,9,2) = gamxinflu(i,j,9,1)
1568 gamxinflu(i,j,10,2)= gamxinflu(i,j,10,1)
1570 IF ( alp > 1.1 ) THEN
1571 ! gamxinflu(i,j,7,1) = gamxinfdp( alp - 1., ratio )/y
1572 gamxinflu(i,j,7,1) = (gamma_dpr(alp - 1.) - gamxinfdp( alp - 1., ratio ))/y
1573 ! gamxinflu(i,j,8,1) = gamxinfdp( alp - 0.5 + 0.5*bxh, ratio )/y
1574 gamxinflu(i,j,8,1) = (gamma_dpr(alp - 0.5 + 0.5*bxh1) - gamxinfdp( alp - 0.5 + 0.5*bxh1, ratio ))/y
1575 ! gamxinflu(i,j,8,2) = gamxinfdp( alp - 0.5 + 0.5*bxhl1, ratio )/y
1576 gamxinflu(i,j,8,2) = (gamma_dpr(alp - 0.5 + 0.5*bxhl1) - gamxinfdp( alp - 0.5 + 0.5*bxhl1, ratio ))/y
1578 ! gamxinflu(i,j,7,1) = gamxinfdp( .1, ratio )/y
1579 gamxinflu(i,j,7,1) = (gamma_dpr(0.1) - gamxinfdp( 0.1, ratio ) )/y
1580 ! gamxinflu(i,j,8,1) = gamxinfdp( 1.1 - 0.5 + 0.5*bxh1, ratio )/y
1581 ! gamxinflu(i,j,8,2) = gamxinfdp( 1.1 - 0.5 + 0.5*bxhl1, ratio )/y
1582 gamxinflu(i,j,8,1) = (gamma_dpr(1.1 - 0.5 + 0.5*bxh1) - gamxinfdp( 1.1 - 0.5 + 0.5*bxh1, ratio ) )/y
1583 gamxinflu(i,j,8,2) = (gamma_dpr(1.1 - 0.5 + 0.5*bxhl1) - gamxinfdp( 1.1 - 0.5 + 0.5*bxhl1, ratio ) )/y
1586 gamxinflu(i,j,7,2) = gamxinflu(i,j,7,1)
1590 ciacrratio(0,:) = 1.0
1592 DO j = ialpstart,nqiacralpha
1593 alp = float(j)*dqiacralpha
1594 y = gamma_sp(4.+alp)
1595 y7 = gamma_sp(7.+alp)
1596 DO i = 0,nqiacrratio
1597 ratio = float(i)*dqiacrratio
1600 x = gamxinfdp( 4.+alp, ratio )
1601 ! write(0,*) 'i, x/y = ',i, x/y
1602 qiacrratio(i,j) = x/y
1603 gamxinflu(i,j,4,1) = x/y
1604 gamxinflu(i,j,4,2) = x/y
1606 ! reflectivity fraction
1607 x = gamxinfdp( 7.+alp, ratio )
1608 ziacrratio(i,j) = x/y7
1609 gamxinflu(i,j,11,1) = x/y7
1610 gamxinflu(i,j,11,2) = x/y7
1614 qiacrratio(0,:) = 1.0
1641 IF ( ipconc == 0 ) THEN
1642 IF ( hail_on == 1 ) THEN ! turn on graupel density for 1-moment scheme
1646 ELSE ! no hail, 'LFO' scheme
1650 ELSEIF ( ipconc == 5 ) THEN
1652 IF ( iufccn > 0 ) THEN
1655 denscale(lccnuf) = 1
1664 IF ( hail_on == 1 ) THEN
1666 lnhl = ltmp ! lhab+7 ! 15
1668 IF ( density_on >= 1 ) THEN
1670 lvh = ltmp ! lhab+8 + isub ! 16 + isub ! isub adjusts to 15 if hail is off
1673 denscale(lccn:ltmp) = 1
1674 IF ( density_on == 1 .and. hail_on == 1 ) THEN
1680 IF ( mixedphase ) THEN
1691 ELSEIF ( ipconc >= 6 ) THEN
1693 IF ( iufccn > 0 ) THEN
1696 denscale(lccnuf) = 1
1708 lnhl = ltmp ! lhab+7 ! 15
1710 IF ( density_on == 1 ) THEN
1712 lvh = ltmp ! lhab+8 + isub ! 16 + isub ! isub adjusts to 15 if hail is off
1715 denscale(lccn:ltmp) = 1
1716 IF ( density_on == 1 .and. hail_on == 1 ) THEN
1723 IF ( ipconc == 6 ) THEN
1726 ELSEIF ( ipconc == 7 ) THEN
1731 ELSEIF ( ipconc == 8 ) THEN
1740 ! write(0,*) 'ipcon,lzr = ',ipconc,lzr,lzh,lzhl
1743 ! denscale(lccn:lvh) = 1
1744 IF ( mixedphase ) THEN
1756 CALL wrf_error_fatal( 'nssl_2mom_init: Invalid value of ipctmp' )
1761 ! write(0,*) 'wrf_init: lh,lhl,lzh,lzhl = ',lh,lhl,lzh,lzhl
1762 ! write(0,*) 'wrf_init: ipconc = ',ipconc
1763 ! write(0,*) 'wrf_init: irenuc, turn_on_ccna = ',irenuc, turn_on_ccna
1764 IF ( turn_on_ccna ) THEN
1770 IF ( turn_on_cina ) THEN
1776 IF ( turn_on_cin .or. is_aerosol_aware ) THEN
1780 !debug write(0,*) 'Setting lcin to ',lcin
1789 IF ( lhl .gt. 1 ) ln(lhl) = lnhl
1796 IF ( lhl .gt. 1 ) ipc(lhl) = 5
1803 IF ( lhl .gt. 1 .and. lvhl .gt. 1 ) lvol(lhl) = lvhl
1816 IF ( lhl .gt. 1 ) lsc(lhl) = lschl
1820 ldovol = ldovol .or. ( lvol(il) .gt. 1 )
1823 ! write(0,*) 'nssl_2mom_init: ldovol = ',ldovol
1830 IF ( lhl .gt. 1 .and. lzhl > 1 ) lz(lhl) = lzhl
1835 IF ( lhl .gt. 1 ) lliq(lhl) = lhlw
1836 IF ( mixedphase ) THEN
1837 ! write(0,*) 'lsw,lhw,lhlw = ',lsw,lhw,lhlw
1845 IF ( imurain == 3 ) THEN
1848 ELSEIF ( imurain == 1 ) THEN
1849 xnu(lr) = (alphar - 2.0)/3.0
1856 IF ( lis >= 1 ) THEN
1861 dnu(lc) = 3.*xnu(lc) + 2. ! alphac
1862 dmu(lc) = 3.*xmu(lc)
1864 dnu(lr) = 3.*xnu(lr) + 2. ! alphar
1865 dmu(lr) = 3.*xmu(lr)
1870 dnu(ls) = 3.*xnu(ls) + 2. ! -0.4 ! alphas
1871 dmu(ls) = 3.*xmu(ls)
1877 xnu(lh) = (dnu(lh) - 2.)/3.
1881 IF ( imurain == 3 ) THEN ! rain is gamma of volume
1882 rz = ((4. + alphah)*(5. + alphah)*(6. + alphah)*(1. + xnu(lr)))/ &
1883 & ((1 + alphah)*(2 + alphah)*(3 + alphah)*(2. + xnu(lr)))
1885 ! IF ( ipconc .lt. 5 ) alphahl = alphah
1887 rzhl = ((4. + alphahl)*(5. + alphahl)*(6. + alphahl)*(1. + xnu(lr)))/ &
1888 & ((1. + alphahl)*(2. + alphahl)*(3. + alphahl)*(2. + xnu(lr)))
1890 rzs = 1. ! assume rain and snow are both gamma volume
1892 ELSE ! rain is gamma of diameter
1894 rz = ((4. + alphah)*(5. + alphah)*(6. + alphah)*(1. + alphar)*(2. + alphar)*(3. + alphar))/ &
1895 & ((1 + alphah)*(2 + alphah)*(3 + alphah)*(4. + alphar)*(5. + alphar)*(6. + alphar))
1897 rzhl = ((4. + alphahl)*(5. + alphahl)*(6. + alphahl)*(1. + alphar)*(2. + alphar)*(3. + alphar))/ &
1898 & ((1 + alphahl)*(2 + alphahl)*(3 + alphahl)*(4. + alphar)*(5. + alphar)*(6. + alphar))
1902 & ((1. + alphar)*(2. + alphar)*(3. + alphar)*(2. + xnu(ls)))/ &
1903 & ((4. + alphar)*(5. + alphar)*(6. + alphar)*(1. + xnu(ls)))
1908 IF ( ipconc <= 5 ) THEN
1909 imltshddmr = Min(1, imltshddmr)
1914 IF ( ipconc > 5 .and. (ibinhmlr == 0 .and. ibinhlmlr == 0 ) ) THEN
1915 imltshddmr = Min(1, imltshddmr)
1918 ! write(0,*) 'rz,rzhl = ', rz,rzhl
1920 IF ( ipconc .lt. 4 ) THEN
1925 xnu(ls) = (dnu(ls) - 2.)/3.
1931 IF ( lhl .gt. 1 ) THEN
1936 xnu(lhl) = (dnu(lhl) - 2.)/3.
1942 IF ( li .gt. 1 ) cno(li) = 1.0e+08
1944 IF ( ls .gt. 1 ) cno(ls) = cnos ! 8.0e+06
1945 IF ( lh .gt. 1 ) cno(lh) = cnoh ! 4.0e+05
1946 IF ( lhl .gt. 1 ) cno(lhl) = cnohl ! 4.0e+05
1948 ! density maximums and minimums
1957 IF ( lhl .gt. 1 ) xdnmx(lhl) = 900.0
1966 IF ( lhl .gt. 1 ) xdnmn(lhl) = hldnmn
1973 xdn0(ls) = rho_qs ! 100.0
1974 xdn0(lh) = rho_qh ! (0.5)*(xdnmn(lh)+xdnmx(lh))
1975 IF ( lhl .gt. 1 ) xdn0(lhl) = rho_qhl ! 800.0
1978 ! Set terminal velocities...
1979 ! also set drag coefficients
1982 cdx(lh) = 0.8 ! 1.0 ! 0.45
1984 IF ( lhl .gt. 1 ) cdx(lhl) = 0.45
1991 IF ( lhl .gt. 1 ) ido(lhl) = idohl
1993 IF ( irfall .lt. 0 ) irfall = infall
1994 IF ( isfall .lt. 0 ) isfall = infall
1995 IF ( lzr > 0 ) irfall = 0
1998 qccnuf = ccnuf/rho00
1999 IF ( old_cccn > 0.0 ) THEN
2000 old_qccn = old_cccn/rho00
2004 ! xvcmx = (4./3.)*pi*xcradmx**3
2006 ! set max rain diameter
2007 IF ( xvdmx .gt. 0.0 ) THEN
2008 xvrmx = 0.523599*(xvdmx)**3
2013 IF ( dhmn <= 0.0 ) THEN
2015 ! xvhmn = Min(xvhmn0, 0.523599*(dfrz)**3 )
2017 xvhmn = 0.523599*(dhmn)**3
2018 ! xvhmn = 0.523599*(Min(dhmn,dfrz))**3
2021 IF ( dhmx <= 0.0 ) THEN
2024 xvhmx = 0.523599*(dhmx)**3
2027 IF ( qhdpvdn < 0. ) qhdpvdn = xdnmn(lh)
2028 IF ( qhacidn < 0. ) qhacidn = xdnmn(lh)
2030 ! load max/min diameters
2043 IF ( lhl .gt. 1 ) THEN
2049 ! cloud water constants in mks units
2051 ! cwmasn = 4.25e-15 ! radius of 1.0e-6
2052 ! cwmasn = 5.23e-13 ! minimum mass, defined by radius of 5.0e-6
2053 ! cwmasn5 = 5.23e-13
2054 ! cwradn = 5.0e-6 ! minimum radius
2055 ! cwmasx = 5.25e-10 ! maximum mass, defined by radius of 50.0e-6
2056 ! mwfac = 6.0**(1./3.)
2057 IF ( ipconc .ge. 2 ) THEN
2058 ! cwmasn = xvmn(lc)*1000. ! minimum mass, defined by minimum droplet volume
2059 ! cwradn = 1.0e-6 ! minimum radius
2060 ! cwmasx = xvmx(lc)*1000. ! maximum mass, defined by maximum droplet volume
2063 ! rwmasn = xvmn(lr)*1000. ! minimum mass, defined by minimum rain volume
2064 ! rwmasx = xvmx(lr)*1000. ! maximum mass, defined by maximum rain volume
2066 IF ( lhl < 1 ) ifrzg = 1
2069 IF ( imurain == 3 ) THEN
2070 ! IF ( izwisventr == 1 ) THEN
2071 ventr = Gamma_sp(rnu + 4./3.)/((rnu + 1.)**(1./3.)*Gamma_sp(rnu + 1.)) ! Ziegler 1985
2073 ventrn = Gamma_sp(rnu + 1.5 + br/6.)/(Gamma_sp(rnu + 1.)*(rnu + 1.)**((1.+br)/6. + 1./3.) ) ! adapted from Wisner et al. 1972; for second term in rwvent
2074 ! ventr = Gamma_sp(rnu + 4./3.)/((rnu + 1.)**(1./3.)*Gamma_sp(rnu + 1.)) ! Ziegler 1985, still use for first term in rwvent
2075 ! ventr = Gamma_sp(rnu + 4./3.)/Gamma_sp(rnu + 1.)
2078 ! IF ( iferwisventr == 1 ) THEN
2079 ventr = Gamma_sp(2. + alphar) ! Ferrier 1994
2080 ! ELSEIF ( iferwisventr == 2 ) THEN
2081 ventrn = Gamma_sp(alphar + 2.5 + br/2.)/Gamma_sp(alphar + 1.) ! adapted from Wisner et al. 1972
2084 ventc = Gamma_sp(cnu + 4./3.)/(cnu + 1.)**(1./3.)/Gamma_sp(cnu + 1.)
2085 c1sw = Gamma_sp(snu + 4./3.)*(snu + 1.0)**(-1./3.)/gamma_sp(snu + 1.0)
2087 ! set threshold mixing ratios
2093 IF ( li > 1 ) qxmin(li) = 1.e-12
2094 IF ( ls > 1 ) qxmin(ls) = 1.e-7
2095 IF ( lh > 1 ) qxmin(lh) = 1.e-7
2096 IF ( lhl .gt. 1 ) qxmin(lhl) = 1.e-7
2098 IF ( lc .gt. 1 .and. lnc .gt. 1 ) qxmin(lc) = 1.0e-13
2099 IF ( lr .gt. 1 .and. lnr .gt. 1 ) qxmin(lr) = 1.0e-12
2101 IF ( li .gt. 1 .and. lni .gt. 1 ) qxmin(li ) = 1.0e-13
2102 IF ( ls .gt. 1 .and. lns .gt. 1 ) qxmin(ls ) = 1.0e-13
2103 IF ( lh .gt. 1 .and. lnh .gt. 1 ) qxmin(lh ) = 1.0e-12
2104 IF ( lhl.gt. 1 .and. lnhl.gt. 1 ) qxmin(lhl) = 1.0e-12
2106 qxmin_init(:) = 1.0e-8 ! threshold for considering single-moment initial condition mixing ratios
2107 ! constants for droplet nucleation
2110 ccnefac = (1.63/(cck * beta(3./2., cck/2.)))**(cck/(cck + 2.0))
2111 cnexp = (3./2.)*cck/(cck+2.0)
2112 ! ccne is all the factors with w in eq. A7 in Mansell et al. 2010 (JAS). The constant changes
2113 ! if k (cck) is changed!
2114 ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
2115 ccne0 = ccnefac*1.e6*(1.e-6)**(2./(2.+cck))
2116 ! write(0,*) 'cwccn, cck, ccne = ',cwccn,cck,ccne,ccnefac,cnexp
2117 IF ( cwccn .lt. 0.0 ) THEN
2119 ccwmx = 50.e9 ! cwccn
2121 ccwmx = 50.e9 ! cwccn ! *1.4
2126 ! Set collection coefficients (Seifert and Beheng 05)
2131 da0(il) = delbk(bb(il), xnu(il), xmu(il), 0)
2132 da1(il) = delbk(bb(il), xnu(il), xmu(il), 1)
2134 ! write(0,*) 'il, da0, da1, xnu, xmu = ', il, da0(il), da1(il), xnu(il), xmu(il)
2142 IF ( il .ne. j ) THEN
2144 dab0(il,j) = delabk(bb(il), bb(j), xnu(il), xnu(j), xmu(il), xmu(j), 0)
2145 dab1(il,j) = delabk(bb(il), bb(j), xnu(il), xnu(j), xmu(il), xmu(j), 1)
2147 ! write(0,*) 'il, j, dab0, dab1 = ',il, j, dab0(il,j), dab1(il,j)
2152 dab0lu(:,:,:,:) = 0.0
2153 dab1lu(:,:,:,:) = 0.0
2155 IF ( ipconc >= 6 ) THEN
2156 DO il = lc,lhab ! collector
2157 DO j = lc,lhab ! collected
2158 IF ( il .ne. j ) THEN
2160 DO jj = ialpstart,nqiacralpha
2161 alpjj = float(jj)*dqiacralpha
2162 xnujj = (alpjj - 2.)/3.
2163 DO ii = ialpstart,nqiacralpha
2164 alpii = float(ii)*dqiacralpha
2165 xnuii = (alpii - 2.)/3.
2167 dab0lu(ii,jj,il,j) = delabk(bb(il), bb(j), xnuii, xnujj, xmu(il), xmu(j), 0)
2168 dab1lu(ii,jj,il,j) = delabk(bb(il), bb(j), xnuii, xnujj, xmu(il), xmu(j), 1)
2172 ! write(0,*) 'il, j, dab0, dab1 = ',il, j, dab0(il,j), dab1(il,j)
2179 gf4br = gamma_sp(4.0+br)
2180 gf4ds = gamma_sp(4.0+ds)
2181 gf4p5 = gamma_sp(4.0+0.5)
2182 gfcinu1 = gamma_sp(cinu + 1.0)
2183 gfcinu1p47 = gamma_sp(cinu + 1.47167)
2184 gfcinu2p47 = gamma_sp(cinu + 2.47167)
2185 gfcinu1p22 = gamma_sp(cinu + 1.22117)
2186 gfcinu2p22 = gamma_sp(cinu + 2.22117)
2187 gfcinu1p18 = gamma_sp(cinu + 1.18333)
2188 gfcinu2p18 = gamma_sp(cinu + 2.18333)
2190 gsnow1 = gamma_sp(snu + 1.0)
2191 gsnow53 = gamma_sp(snu + 5./3.)
2192 gsnow73 = gamma_sp(snu + 7./3.)
2194 IF ( lh .gt. 1 ) cwchtmp0 = 6.0/pi*gamma_sp( (xnu(lh) + 1.)/xmu(lh) )/gamma_sp( (xnu(lh) + 2.)/xmu(lh) )
2195 IF ( lhl .gt. 1 ) cwchltmp0 = 6.0/pi*gamma_sp( (xnu(lhl) + 1)/xmu(lhl) )/gamma_sp( (xnu(lhl) + 2)/xmu(lhl) )
2198 iexy(:,:)=0; ! sets to zero the ones Imight have forgotten
2202 iexy(ls,lc) = ieswc ; iexy(ls,lr) = ieswr ;
2205 iexy(lh,ls) = iehwsw ; iexy(lh,li) = iehwi ;
2206 iexy(lh,lc) = iehwc ; iexy(lh,lr) = iehwr ;
2209 IF (lhl .gt. 1 ) THEN
2210 iexy(lhl,ls) = iehlsw ; iexy(lhl,li) = iehli ;
2211 iexy(lhl,lc) = iehlc ; iexy(lhl,lr) = iehlr ;
2214 ! IF ( icefallfac /= 1.0 ) write(0,*) 'icefallfac = ',icefallfac
2215 ! IF ( snowfallfac /= 1.0 ) write(0,*) 'snowfallfac = ',snowfallfac
2219 END SUBROUTINE nssl_2mom_init
2221 ! #####################################################################
2222 ! #####################################################################
2224 SUBROUTINE nssl_2mom_driver(qv, qc, qr, qi, qs, qh, qhl, ccw, crw, cci, csw, chw, chl, &
2225 cn, vhw, vhl, cna, cni, f_cn, f_cna, f_cina, &
2226 f_qc, f_qr, f_qi, f_qs, f_qh, f_qhl, &
2228 zrw, zhw, zhl, f_zrw, f_zhw, f_zhl, f_vhw, f_vhl, &
2230 tt, th, pii, p, w, dn, dz, dtp, itimestep, &
2232 ntmul, ntcnt, lastloop, &
2236 SNOWNC, SNOWNCV, GRPLNC, GRPLNCV, &
2237 SR,HAILNC, HAILNCV, &
2238 hail_maxk1, hail_max2d, nwp_diagnostics, &
2240 re_cloud, re_ice, re_snow, re_rain, &
2241 re_graup, re_hail, &
2242 has_reqc, has_reqi, has_reqs, has_reqr, &
2243 has_reqg, has_reqh, &
2244 rainncw2, rainnci2, &
2246 rscghis_2d,rscghis_2dp,rscghis_2dn, &
2247 scr,scw,sci,scs,sch,schl,sctot, &
2249 induc,elecz,scion,sciona, &
2250 noninduc,noninducp,noninducn, &
2251 pcc2, pre2, depsubr, &
2252 mnucf2, melr2, ctr2, &
2253 rim1_2, rim2_2,rim3_2, &
2254 nctr2, nnuccd2, nnucf2, &
2255 effc2,effr2,effi2, &
2257 fc2, fr2,fi2,fs2,fg2, &
2258 fnc2, fnr2,fni2,fns2,fng2, &
2259 ! qcond,qdep,qfrz,qrauto,qhcnvi,qhcollw,qscollw, &
2260 ! ncauto, niinit,nifrz, &
2261 ! re_liquid, re_graupel, re_hail, re_icesnow, &
2262 ! vtcloud, vtrain, vtsnow, vtgraupel, vthail, &
2265 nssl_progn, & ! wrf-chem
2266 ! 20130903 acd_mb_washout start
2267 wetscav_on, rainprod, evapprod, & ! wrf-chem
2268 ! 20130903 acd_mb_washout end
2269 cu_used, qrcuten, qscuten, qicuten, qccuten, & ! hm added
2270 ids,ide, jds,jde, kds,kde, & ! domain dims
2271 ims,ime, jms,jme, kms,kme, & ! memory dims
2272 its,ite, jts,jte, kts,kte) ! tile dims
2281 !Subroutine arguments:
2283 integer, intent(in):: &
2284 ids,ide, jds,jde, kds,kde, &
2285 ims,ime, jms,jme, kms,kme, &
2286 its,ite, jts,jte, kts,kte
2287 real, dimension(ims:ime, kms:kme, jms:jme), intent(inout):: &
2289 ! tt is air temperature -- used by CCPP instead of th (theta)
2290 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2294 qi,qhl,ccw,crw,cci,csw,chw,chl,vhw,vhl
2295 integer, optional, intent(in) :: is_theta_or_temp
2296 logical, optional, intent(in) :: f_zrw, f_zhw, f_zhl, f_vhw, f_vhl ! not used yet
2297 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: dbz, vzf, cn, cna, cni, cnuf
2298 real, dimension(ims:ime, jms:jme), optional, intent(inout):: compdbz
2299 real, dimension(ims:ime, jms:jme), optional, intent(inout):: rscghis_2d, & ! 2D accumulation arrays for vertically-integrated charging rate
2300 rscghis_2dp, & ! 2D accumulation arrays for vertically-integrated charging rate (positive only)
2301 rscghis_2dn ! 2D accumulation arrays for vertically-integrated charging rate (negative only)
2302 ! real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout)::rscghis_3d
2303 integer, optional, intent(in) :: elec_physics
2304 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2305 scr,scw,sci,scs,sch,schl,sciona,sctot ! space charge
2306 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2307 induc,noninduc,noninducp,noninducn ! charging rates: inductive, noninductive (all, positive, negative to graupel)
2308 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(in) :: elecz ! elecsave = Ez
2309 real, dimension(ims:ime, kms:kme, jms:jme,2),optional, intent(inout) :: scion
2310 real, dimension(ims:ime, kms:kme, jms:jme), intent(in):: p,w,dz,dn
2312 real, dimension(ims:ime, kms:kme, jms:jme), intent(in):: pii
2313 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2314 pcc2, pre2, depsubr, &
2315 mnucf2, melr2, ctr2, &
2316 rim1_2, rim2_2,rim3_2, &
2317 nctr2, nnuccd2, nnucf2, &
2318 effc2,effr2,effi2, &
2320 fc2, fr2,fi2,fs2,fg2, &
2321 fnc2, fnr2,fni2,fns2,fng2
2322 ! qcond,qdep,qfrz,qrauto,qhcnvi,qhcollw,qscollw, &
2323 ! ncauto, niinit,nifrz, &
2324 ! re_liquid, re_graupel, re_hail, re_icesnow, &
2325 ! vtcloud, vtrain, vtsnow, vtgraupel, vthail
2327 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout) :: axtra
2330 real, dimension(ims:ime, jms:jme) :: &
2331 RAINNC,RAINNCV ! accumulated precip (NC) and rate (NCV)
2332 real, dimension(ims:ime, jms:jme), optional, intent(inout):: &
2333 SNOWNC,SNOWNCV,GRPLNC,GRPLNCV,SR ! accumulated precip (NC) and rate (NCV)
2334 real, dimension(ims:ime, jms:jme), optional, intent(inout):: &
2335 HAILNC,HAILNCV ! accumulated precip (NC) and rate (NCV)
2336 real, dimension(ims:ime, jms:jme), optional, intent(inout) :: hail_maxk1, hail_max2d
2337 integer, optional, intent(in) :: nwp_diagnostics
2338 ! for cm1, set nproctot=44 (or as needed) to get domain total rates
2339 integer, parameter :: nproc = 1
2340 double precision :: proctot(nproc),proctotmpi(nproc)
2341 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional, INTENT(INOUT):: re_cloud, re_ice, re_snow, &
2342 re_rain, re_graup, re_hail
2343 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional, INTENT(IN):: tkediss
2344 INTEGER, INTENT(IN), optional :: has_reqc, has_reqi, has_reqs, has_reqr, has_reqg, has_reqh
2345 real, dimension(ims:ime, jms:jme), intent(out), optional :: &
2346 rainncw2, rainnci2 ! liquid rain, ice, accumulation rates
2347 real, optional, intent(in) :: dx,dy
2348 real, intent(in):: dtp
2349 integer, intent(in):: itimestep !, ccntype
2350 integer, intent(in), optional :: ntmul, ntcnt
2351 logical, optional, intent(in) :: lastloop
2352 logical, optional, intent(in) :: diagflag, f_cna, f_cn, f_cina, f_cnuf
2353 logical, optional, intent(in) :: f_qc, f_qr, f_qi, f_qs, f_qh, f_qhl
2354 integer, optional, intent(in) :: ipelectmp, ke_diag
2357 LOGICAL, INTENT(IN), OPTIONAL :: nssl_progn ! flags for wrf-chem
2359 ! REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional,INTENT(INOUT):: qndrop
2360 LOGICAL :: flag_qndrop ! wrf-chem
2361 LOGICAL :: flag_qnifa , flag_qnwfa
2362 logical :: flag_cnuf = .false.
2363 logical :: flag_ccn = .false.
2364 logical :: flag_qi = .true.
2365 logical :: has_reqr_local = .false., has_reqg_local = .false., has_reqh_local = .false.
2367 logical :: nwp_diagflag = .false.
2368 real :: cinchange, t7max,testmax,wmax
2370 ! 20130903 acd_ck_washout start
2371 ! rainprod - total tendency of conversion of cloud water/ice and graupel to rain (kg kg-1 s-1)
2372 ! evapprod - tendency of evaporation of rain (kg kg-1 s-1)
2373 ! 20130903 acd_ck_washout end
2374 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional,INTENT(INOUT):: rainprod, evapprod
2376 ! qrcuten, rain tendency from parameterized cumulus convection
2377 ! qscuten, snow tendency from parameterized cumulus convection
2378 ! qicuten, cloud ice tendency from parameterized cumulus convection
2379 ! mu : air mass in column
2380 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional, INTENT(IN):: qrcuten, qscuten, qicuten, qccuten
2381 INTEGER, optional, intent(in) :: cu_used
2382 LOGICAL, optional, intent(in) :: wetscav_on
2387 real, dimension(its:ite, 1, kts:kte) :: elec2 ! ez = elecsave slab
2388 ! real, dimension(its:ite, 1, kts:kte,2) :: scion2 ! 1=- , 2=+
2389 real, dimension(its:ite, kts:kte) :: rainprod2d, evapprod2d,tke2d
2390 real, dimension(its:ite, 1, kts:kte, na) :: an, ancuten
2391 real, dimension(its:ite, 1, kts:kte, nxtra) :: axtra2d
2392 real, dimension(its:ite, 1, kts:kte, 3) :: alpha2d
2393 real, dimension(its:ite, 1, kts:kte) :: t0,t1,t2,t3,t4,t5,t6,t7,t8,t9
2394 real, dimension(its:ite, 1, kts:kte) :: dn1,t00,t77,ssat,pn,wn,dz2d,dz2dinv,dbz2d,vzf2d
2395 real, dimension(its:ite, 1, na) :: xfall
2396 real, dimension(its:ite, 1) :: hailmax1d,hailmaxk1
2397 real, dimension(kts:kte, nproc) :: thproclocal
2398 integer, parameter :: nor = 0, ng = 0
2399 integer :: nx,ny,nz,ngs
2400 integer ix,jy,kz,i,j,k,il,n
2402 real :: ssival, ssifac, t8s, t9s, qvapor
2404 double precision :: dp1
2408 integer :: vzflag0 = 0
2411 real, parameter :: cnin20 = 1.0e3
2412 real, parameter :: cnin10 = 5.0e1
2413 real, parameter :: cnin1a = 4.5
2414 real, parameter :: cnin2a = 12.96
2415 real, parameter :: cnin2b = 0.639
2417 double precision :: cwmass1,cwmass2
2418 double precision :: rwmass1,rwmass2
2419 double precision :: icemass1,icemass2
2420 double precision :: swmass1,swmass2
2421 double precision :: grmass1,grmass2
2422 double precision :: hlmass1,hlmass2
2423 double precision :: wvol5,wvol10
2424 real :: tmp,dv,dv1,tmpchg
2427 double precision :: dt1,dt2
2428 double precision :: timesed,timesed1,timesed2,timesed3, timegs, timenucond, timedbz,zmaxsed
2429 double precision :: timevtcalc,timesetvt
2431 logical :: f_cnatmp, f_cinatmp
2432 logical :: has_wetscav
2434 integer :: kediagloc
2437 real :: ycent, y, emissrate, emissrate0, emissrate1, z, fac, factot
2438 real :: fach(kts:kte)
2440 logical, parameter :: debugdriver = .false.
2442 integer :: loopcnt, loopmax, outerloopcnt
2443 logical :: lastlooptmp
2446 ! -------------------------------------------------------------------
2451 IF ( debugdriver ) write(0,*) 'N2M: entering routine'
2453 flag_qndrop = .false.
2454 flag_qnifa = .false.
2455 flag_qnwfa = .false.
2458 nwp_diagflag = .false.
2460 IF ( PRESENT ( nssl_progn ) ) flag_qndrop = nssl_progn
2461 IF ( present ( f_cnuf ) ) flag_cnuf = f_cnuf
2462 IF ( present ( nwp_diagnostics ) ) nwp_diagflag = ( nwp_diagnostics > 0 )
2464 IF ( present ( f_cn ) .and. present( cn ) ) THEN
2466 ELSEIF ( present( cn ) ) THEN
2470 IF ( present( f_qi ) ) THEN
2473 IF ( ffrzs < 1.0 ) THEN
2480 IF ( .not. flag_qi .and. ffrzs < 1.0 ) ffrzs = 1.0
2483 IF ( PRESENT ( has_reqr ) ) has_reqr_local = has_reqr > 0
2484 IF ( PRESENT ( has_reqg ) ) has_reqg_local = has_reqg > 0
2485 IF ( PRESENT ( has_reqh ) ) has_reqh_local = has_reqh > 0
2489 lastlooptmp = .true.
2490 IF ( present( ntmul ) .and. present( ntcnt ) .and. present( lastloop ) ) THEN
2492 outerloopcnt = ntcnt
2493 lastlooptmp = lastloop
2497 has_wetscav = .false.
2498 IF ( wrfchem_flag > 0 ) THEN
2499 IF ( PRESENT( wetscav_on ) ) THEN
2500 has_wetscav = wetscav_on
2504 IF ( present( f_cna ) ) THEN
2510 IF ( present( f_cina ) ) THEN
2516 IF ( present( vzf ) ) vzflag0 = 1
2518 IF ( present( ipelectmp ) ) THEN
2523 ! IF ( present( dbz ) ) THEN
2527 ! dbz(ix,kz,jy) = 0.0
2533 IF ( present( dx ) .and. present( dy ) ) THEN
2543 IF ( present( diagflag ) ) THEN
2544 makediag = diagflag .or. itimestep == 1
2547 IF ( debugdriver ) write(0,*) 'N2M: makediag = ',makediag
2551 ny = 1 ! set up as 2D slabs
2555 IF ( .not. flag_ccn ) THEN
2560 ! set up CCN array and some other static local values
2561 IF ( itimestep == 1 .and. .not. invertccn .and. flag_ccn ) THEN
2562 ! this is not needed for WRF 3.8 and later because it is done in physics_init,
2563 ! but kept for backwards compatibility with earlier versions
2564 IF ( lccna > 1 .and. .not. ( present( cna ) .and. f_cnatmp ) ) THEN
2565 ! using cn array for cna and use background qccn for local cn array
2574 ELSEIF ( cn((ite+its)/2,(kte+kts)/2,(jte+jts)/2) < 10.0 ) THEN ! initialize ccn if not already done
2584 IF ( lccnuf > 1 .and. flag_cnuf .and. ccnuf > 1.0 ) THEN
2585 ! write(0,*) 'set cnuf1'
2589 cnuf(ix,kz,jy) = qccnuf
2597 IF ( itimestep == 1 .and. invertccn .and. flag_ccn ) THEN
2598 ! this is not needed for WRF 3.8 and later because it is done in physics_init,
2599 ! but kept for backwards compatibility with earlier versions
2609 IF ( invertccn .and. flag_ccn ) THEN ! hack for WRF to convert activated ccn to unactivated, then do not have to
2610 ! worry about initial and boundary conditions - they are zero
2614 cn(ix,kz,jy) = Max( 0.0, qccn - cn(ix,kz,jy) )
2619 IF ( lccnuf > 1 .and. flag_cnuf .and. ccnuf > 1.0 ) THEN
2620 ! write(0,*) 'set cnuf (invertccn)'
2624 cnuf(ix,kz,jy) = qccnuf - cnuf(ix,kz,jy)
2633 ! ENDIF ! itimestep == 1
2636 ! sedimentation settings
2640 IF ( infall .ne. 1 .or. iscfall .ge. 2 ) THEN
2646 IF ( infall .ge. 3 .or. ipconc .ge. 6 ) THEN
2651 IF ( present( HAILNCV ) .and. lhl < 1 ) THEN ! for WRF 3.1 compatibility
2652 HAILNCV(its:ite,jts:jte) = 0.
2655 tke2d(:,:) = 0.0 ! initialize if not used
2657 lnb = Max(lh,lhl)+1 ! lnc
2658 ! IF ( lccn > 1 ) lnb = lccn
2662 IF ( present( compdbz ) .and. makediag ) THEN
2665 compdbz(ix,jy) = -3.0
2682 IF ( debugdriver ) write(0,*) 'N2M: jy loop 1, lhl,na = ',lhl,na,present(qhl)
2684 ancuten(its:ite,1,kts:kte,:) = 0.0
2685 thproclocal(:,:) = 0.0
2690 ! write(0,*) 'N2M: load an, jy,lccn = ',jy,lccn,qccn
2692 IF ( present( pcc2 ) .and. makediag ) THEN
2693 axtra2d(its:ite,1,kts:kte,:) = 0.0
2696 IF ( nwp_diagflag ) THEN
2697 alpha2d(its:ite,1,kts:kte,1) = alphar
2698 alpha2d(its:ite,1,kts:kte,2) = alphah
2699 alpha2d(its:ite,1,kts:kte,3) = alphahl
2703 ! copy from 3D array to 2D slab
2707 an(ix,1,kz,lt) = th(ix,kz,jy)
2708 an(ix,1,kz,lv) = qv(ix,kz,jy)
2709 an(ix,1,kz,lc) = qc(ix,kz,jy)
2710 an(ix,1,kz,lr) = qr(ix,kz,jy)
2712 an(ix,1,kz,li) = qi(ix,kz,jy)
2714 an(ix,1,kz,li) = 0.0
2716 an(ix,1,kz,ls) = qs(ix,kz,jy)
2717 an(ix,1,kz,lh) = qh(ix,kz,jy)
2718 IF ( lhl > 1 ) an(ix,1,kz,lhl) = qhl(ix,kz,jy)
2719 IF ( lccn > 1 ) THEN
2720 IF ( is_aerosol_aware .and. flag_qnwfa ) THEN
2722 ELSEIF ( flag_ccn ) THEN
2723 IF ( lccna > 1 .and. .not. ( present( cna ) .and. f_cnatmp ) ) THEN
2724 an(ix,1,kz,lccna) = cn(ix,kz,jy)
2725 an(ix,1,kz,lccn) = qccn ! cn(ix,kz,jy)
2727 an(ix,1,kz,lccn) = cn(ix,kz,jy)
2729 IF ( i_uf_or_ccn > 0 .and. lccnuf > 1 ) THEN ! UF ccn are extra regular ccn
2730 an(ix,1,kz,lccn) = an(ix,1,kz,lccn) + cnuf(ix,kz,jy)
2733 IF ( lccna == 0 .and. ( .not. f_cnatmp ) ) THEN
2734 an(ix,1,kz,lccn) = qccn - ccw(ix,kz,jy)
2736 an(ix,1,kz,lccn) = qccn
2742 IF ( lccnuf > 0 .and. flag_cnuf ) THEN
2743 IF ( i_uf_or_ccn == 0 ) THEN ! UF are UF
2744 an(ix,1,kz,lccnuf) = Max(0.0, cnuf(ix,kz,jy) )
2745 ELSE ! UF were added to lccn
2746 an(ix,1,kz,lccnuf) = 0.0
2750 IF ( lccna > 1 ) THEN
2751 IF ( present( cna ) .and. f_cnatmp ) THEN
2752 an(ix,1,kz,lccna) = cna(ix,kz,jy)
2756 IF ( lcina > 1 ) THEN
2757 IF ( present( cni ) .and. f_cinatmp ) THEN
2758 an(ix,1,kz,lcina) = cni(ix,kz,jy)
2762 IF ( ipconc >= 5 ) THEN
2763 an(ix,1,kz,lnc) = ccw(ix,kz,jy)
2764 IF ( constccw > 0.0 ) THEN
2765 an(ix,1,kz,lnc) = constccw
2767 an(ix,1,kz,lnr) = crw(ix,kz,jy)
2768 IF ( present( cci ) ) THEN
2769 an(ix,1,kz,lni) = cci(ix,kz,jy)
2771 an(ix,1,kz,lni) = 0.0
2773 an(ix,1,kz,lns) = csw(ix,kz,jy)
2774 an(ix,1,kz,lnh) = chw(ix,kz,jy)
2775 IF ( lhl > 1 ) an(ix,1,kz,lnhl) = chl(ix,kz,jy)
2777 IF ( lvh > 0 ) an(ix,1,kz,lvh) = vhw(ix,kz,jy)
2778 IF ( lvhl > 0 .and. present( vhl ) ) an(ix,1,kz,lvhl) = vhl(ix,kz,jy)
2780 IF ( ipconc >= 6 ) THEN
2781 IF ( lzr > 0 ) an(ix,1,kz,lzr) = zrw(ix,kz,jy)*zscale
2782 IF ( lzh > 0 ) an(ix,1,kz,lzh) = zhw(ix,kz,jy)*zscale
2783 IF ( lzhl > 0 ) an(ix,1,kz,lzhl) = zhl(ix,kz,jy)*zscale
2795 t0(ix,1,kz) = th(ix,kz,jy)*pii(ix,kz,jy) ! temperature (Kelvin)
2796 t00(ix,1,kz) = 380.0/p(ix,kz,jy)
2797 t77(ix,1,kz) = pii(ix,kz,jy)
2798 dbz2d(ix,1,kz) = 0.0
2799 vzf2d(ix,1,kz) = 0.0
2804 RAINNCV(ix,jy) = 0.0
2805 IF ( present( GRPLNCV ) ) GRPLNCV(ix,jy) = 0.0
2806 IF ( present( HAILNCV ) ) HAILNCV(ix,jy) = 0.0
2807 IF ( present( SNOWNCV ) ) SNOWNCV(ix,jy) = 0.0
2810 DO loopcnt = 1,loopmax
2826 pn(ix,1,kz) = p(ix,kz,jy)
2827 wn(ix,1,kz) = w(ix,kz,jy)
2828 dn1(ix,1,kz) = dn(ix,kz,jy)
2829 ! wmax = Max(wmax,wn(ix,1,kz))
2830 dz2d(ix,1,kz) = dz(ix,kz,jy)
2831 dz2dinv(ix,1,kz) = 1./dz(ix,kz,jy)
2833 ltemq = Int( (t0(ix,1,kz)-163.15)/fqsat+1.5 )
2834 ltemq = Min( nqsat, Max(1,ltemq) )
2836 ! saturation mixing ratio
2838 t8s = t00(ix,1,kz)*tabqvs(ltemq) !saturation mixing ratio wrt water
2839 t9s = t00(ix,1,kz)*tabqis(ltemq) !saturation mixing ratio wrt ice
2842 ! calculate rate of nucleation
2844 ssival = Min(t8s,max(an(ix,1,kz,lv),0.0))/t9s ! qv/qvi
2847 if ( ssival .gt. 1.0 ) then
2849 IF ( icenucopt == 1 ) THEN
2851 if ( t0(ix,1,kz).le.268.15 ) then
2853 dp1 = dn1(ix,1,kz)/rho00*cnin20*exp( Min( 57.0 ,(cnin2a*(ssival-1.0)-cnin2b) ) )
2854 t7(ix,1,kz) = Min(dp1, 1.0d30)
2858 ! Default value of imeyers5 turns off nucleation by Meyer at higher temperatures
2859 ! This is really from Ferrier (1994), eq. 4.31 - 4.34
2860 IF ( imeyers5 ) THEN
2861 if ( t0(ix,1,kz).lt.tfr .and. t0(ix,1,kz).gt.268.15 ) then
2862 qvapor = max(an(ix,1,kz,lv),0.0)
2864 if ( (qvapor-t9s) .gt. 1.0e-5 ) then
2865 if ( (t8s-t9s) .gt. 1.0e-5 ) then
2866 ssifac = (qvapor-t9s) /(t8s-t9s)
2867 ssifac = ssifac**cnin1a
2870 t7(ix,1,kz) = dn1(ix,1,kz)/rho00*cnin10*ssifac*exp(-(t0(ix,1,kz)-tfr)*bta1)
2874 ! t7max = Max(t7max, t7(ix,1,kz) )
2876 ELSEIF ( icenucopt == 2 ) THEN ! Thompson/Cooper; Note Thompson 2004 has constants of
2877 ! 0.005 and 0.304 because the line function was estimated from Cooper plot
2878 ! Here, the fit line values from Cooper 1986 are converted. Very little difference
2881 t7(ix,1,kz) = 1000.*0.00446684*exp(0.3108*(273.16 - Max(233.0, t0(ix,1,kz) ) ) ) ! factor of 1000 to convert L**-1 to m**-3
2883 ! write(0,*) 'Cooper t7,ssival = ',ix,kz,t7(ix,1,kz),ssival
2885 ELSEIF ( icenucopt == 3 ) THEN ! Phillips (Meyers/DeMott)
2887 if ( t0(ix,1,kz).le.268.15 .and. t0(ix,1,kz) > 243.15 ) then ! Meyers with factor of Psi=0.06
2889 dp1 = 0.06*cnin20*exp( Min( 57.0 ,(cnin2a*(ssival-1.0)-cnin2b) ) )
2890 t7(ix,1,kz) = Min(dp1, 1.0d30)
2891 elseif ( t0(ix,1,kz) <= 243.15 ) then ! Phillips estimate of DeMott et al (2003) data
2892 dp1 = 1000.*( exp( Min( 57.0 ,cnin2a*(ssival-1.1) ) ) )**0.3
2893 t7(ix,1,kz) = Min(dp1, 1.0d30)
2897 ELSEIF ( icenucopt == 4 ) THEN ! DeMott 2010
2899 IF ( t0(ix,1,kz) < 268.16 .and. t0(ix,1,kz) > 223.15 .and. ssival > 1.001 ) THEN !
2901 ! a = 0.0000594, b = 3.33, c = 0.0264, d = 0.0033,
2902 ! nint = a*(-Tc)**b * naer**(c*(-Tc) + d)
2903 ! nint has units of per (standard) liter, so mult by 1.e3 and scale by dn/rho00
2904 ! naer needs units of cm**-3, so mult by 1.e-6
2906 ! dp1 = 1.e3*0.0000594*(273.16 - t0(ix,1,kz))**3.33 * (1.e-6*cin*dn(ix,1,kz))**(0.0264*(273.16 - t0(ix,1,kz)) + 0.0033)
2908 dp1 = 1.e3*dn1(ix,1,kz)/rho00*0.0000594*(273.16 - t0(ix,1,kz))**3.33 * tmp**(0.0264*(273.16 - t0(ix,1,kz)) + 0.0033)
2909 t7(ix,1,kz) = Min(dp1, 1.0d30)
2919 end if ! ( ssival .gt. 1.0 )
2925 IF ( wrfchem_flag > 0 ) THEN
2926 IF ( has_wetscav ) THEN
2927 IF ( PRESENT( rainprod ) ) rainprod2d(its:ite,kts:kte) = 0
2928 IF ( PRESENT( evapprod ) ) evapprod2d(its:ite,kts:kte) = 0
2933 ! transform from number mixing ratios to number conc.
2935 IF ( loopcnt == 1 ) THEN
2937 IF ( denscale(il) == 1 ) THEN
2940 an(ix,1,kz,il) = an(ix,1,kz,il)*dn1(ix,1,kz) ! dn(ix,kz,jy)
2952 ! IF ( .true. ) THEN
2956 ! for real cases when hydrometeor mixing ratios have been initialized without concentrations
2957 IF ( itimestep == 1 .and. ipconc > 0 .and. loopcnt == 1 ) THEN
2958 call calcnfromq(nx,ny,nz,an,na,nor,nor,dn1)
2962 IF ( present(cu_used) .and. &
2963 ( present( qrcuten ) .or. present( qscuten ) .or. &
2964 present( qicuten ) .or. present( qccuten ) ) ) THEN !{
2966 IF ( cu_used == 1 ) THEN !{
2970 IF ( present( qrcuten ) ) ancuten(ix,1,kz,lr) = dtp*qrcuten(ix,kz,jy)
2971 IF ( present( qscuten ) ) ancuten(ix,1,kz,ls) = dtp*qscuten(ix,kz,jy)
2972 IF ( present( qicuten ) ) ancuten(ix,1,kz,li) = dtp*qicuten(ix,kz,jy)
2973 IF ( present( qccuten ) ) ancuten(ix,1,kz,lc) = dtp*qccuten(ix,kz,jy)
2978 call calcnfromcuten(nx,ny,nz,ancuten,an,na,nor,nor,dn1)
2984 IF ( ipconc >= 6 ) THEN
2985 ! IF ( lzr > 0 ) an(ix,1,kz,lzr) = an(ix,1,kz,lzr) + ancuten(ix,1,kz,lzr)
2998 call sediment1d(dtp,nx,ny,nz,an,na,nor,nor,xfall,dn1,dz2d,dz2dinv, &
2999 & t0,t7,infdo,jy,its,jts &
3000 & ,timesed1,timesed2,timesed3,zmaxsed,timesetvt)
3003 ! copy xfall to appropriate places...
3005 IF ( debugdriver ) write(0,*) 'N2M: end sediment, jy = ',jy
3009 RAINNCV(ix,jy) = RAINNCV(ix,jy) + &
3010 dtp*dn1(ix,1,1)*(xfall(ix,1,lr) + xfall(ix,1,ls)*1000./xdn0(lr) + &
3011 & xfall(ix,1,lh)*1000./xdn0(lr) + xfall(ix,1,lhl)*1000./xdn0(lr) )
3013 RAINNCV(ix,jy) = RAINNCV(ix,jy) + &
3014 dtp*dn1(ix,1,1)*(xfall(ix,1,lr) + xfall(ix,1,ls)*1000./xdn0(lr) + &
3015 & xfall(ix,1,lh)*1000./xdn0(lr) )
3017 IF ( present ( rainncw2 ) ) THEN ! rain only
3018 rainncw2(ix,jy) = rainncw2(ix,jy) + dtp*dn1(ix,1,1)*xfall(ix,1,lr)
3020 IF ( present ( rainnci2 ) ) THEN ! ice only
3022 rainnci2(ix,jy) =rainnci2(ix,jy) + dtp*dn1(ix,1,1)*(xfall(ix,1,ls)*1000./xdn0(lr) + &
3023 & xfall(ix,1,lh)*1000./xdn0(lr) + xfall(ix,1,lhl)*1000./xdn0(lr) )
3025 rainnci2(ix,jy) = rainnci2(ix,jy) + dtp*dn1(ix,1,1)*(xfall(ix,1,ls)*1000./xdn0(lr) + &
3026 & xfall(ix,1,lh)*1000./xdn0(lr) )
3029 IF ( present( SNOWNCV ) ) SNOWNCV(ix,jy) = SNOWNCV(ix,jy) + dtp*dn1(ix,1,1)*xfall(ix,1,ls)*1000./xdn0(lr)
3030 IF ( present( GRPLNCV ) ) THEN
3031 IF ( lhl > 1 .and. .not. present( HAILNC) ) THEN ! if no separate hail accum, then add to graupel
3032 GRPLNCV(ix,jy) = GRPLNCV(ix,jy) + dtp*dn1(ix,1,1)*(xfall(ix,1,lh) + xfall(ix,1,lhl)) *1000./xdn0(lr)
3034 GRPLNCV(ix,jy) = GRPLNCV(ix,jy) + dtp*dn1(ix,1,1)*xfall(ix,1,lh)*1000./xdn0(lr)
3037 IF ( loopcnt == loopmax ) RAINNC(ix,jy) = RAINNC(ix,jy) + RAINNCV(ix,jy)
3039 IF ( present (SNOWNC) .and. present (SNOWNCV) .and. loopcnt == loopmax ) THEN
3040 SNOWNC(ix,jy) = SNOWNC(ix,jy) + SNOWNCV(ix,jy)
3044 ! IF ( .true. ) THEN
3046 IF ( present( HAILNC ) ) THEN
3048 HAILNCV(ix,jy) = dtp*dn1(ix,1,1)*xfall(ix,1,lhl)*1000./xdn0(lr)
3049 IF ( loopcnt == loopmax ) HAILNC(ix,jy) = HAILNC(ix,jy) + HAILNCV(ix,jy)
3050 ! ELSEIF ( present( GRPLNCV ) ) THEN ! if no separate hail accum, then add to graupel
3051 ! GRPLNCV(ix,jy) = GRPLNCV(ix,jy) + dtp*dn1(ix,1,1)*xfall(ix,1,lhl)*1000./xdn0(lr)
3054 IF ( present( GRPLNCV ) .and. loopcnt == loopmax ) THEN
3055 GRPLNC(ix,jy) = GRPLNC(ix,jy) + GRPLNCV(ix,jy)
3057 IF ( present( SR ) .and. present (SNOWNCV) .and. present(GRPLNCV) .and. loopcnt == loopmax ) THEN
3058 IF ( present( HAILNC ) ) THEN
3059 SR(ix,jy) = (SNOWNCV(ix,jy)+HAILNCV(ix,jy)+GRPLNCV(ix,jy))/(RAINNCV(ix,jy)+1.e-12)
3061 SR(ix,jy) = (SNOWNCV(ix,jy)+GRPLNCV(ix,jy))/(RAINNCV(ix,jy)+1.e-12)
3068 IF ( isedonly /= 1 ) THEN
3069 ! call nssl_2mom_gs: main gather-scatter routine to calculate microphysics
3071 IF ( debugdriver ) write(0,*) 'N2M: gs, jy = ',jy
3072 ! IF ( isedonly /= 2 ) THEN
3079 & ,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9 &
3083 & ventr,ventc,c1sw,1,ido, &
3085 ! & ln,ipc,lvol,lz,lliq, &
3087 & xdn0,dbz2d,tke2d, &
3088 & thproclocal,nproc,dx1,dy1,ngs, &
3089 & timevtcalc,axtra2d, makediag &
3090 & ,has_wetscav, rainprod2d, evapprod2d, alpha2d &
3091 & ,elec2,its,ids,ide,jds,jde &
3098 ENDIF ! isedonly /= 1
3100 ! droplet nucleation/condensation/evaporation
3110 & ,axtra2d, makediag &
3111 & ,ssat,t00,t77,flag_qndrop)
3120 ENDDO ! loopcnt=1,loopmax
3121 IF ( present( pcc2 ) .and. makediag ) THEN
3124 ! example of using the 'axtra2d' array to get rates out of the microphysics routine for output.
3125 ! Search for 'axtra' to find example code below
3126 ! pcc2(ix,kz,jy) = axtra2d(ix,1,kz,1)
3132 ! compute diagnostic S-band reflectivity if needed
3133 IF ( present( dbz ) .and. makediag .and. lastlooptmp ) THEN
3137 IF ( present(ke_diag) ) THEN
3142 call radardd02(nx,ny,nz,nor,na,an,t0, &
3143 & dbz2d,dn1,nz,cnoh,rho_qh,ipconc,kediagloc, 0)
3147 DO kz = kts,kediagloc ! kte
3149 dbz(ix,kz,jy) = dbz2d(ix,1,kz)
3150 IF ( present( vzf ) ) THEN
3151 vzf(ix,kz,jy) = vzf2d(ix,1,kz)
3152 IF ( dbz2d(ix,1,kz) <= 0.0 ) THEN
3154 ELSEIF ( dbz2d(ix,1,kz) <= 15.0 ) THEN
3155 refl = 10**(0.1*dbz2d(ix,1,kz))
3156 vzf(ix,kz,jy) = Min( vzf2d(ix,1,kz), 2.6 * Max(0.0,refl)**0.107 * (1.2/dn1(ix,1,kz))**0.4 )
3159 IF ( present( compdbz ) ) THEN
3160 compdbz(ix,jy) = Max( compdbz(ix,jy), dbz2d(ix,1,kz) )
3169 ! Following Greg Thompson, calculation for effective radii. Used by RRTMG LW/SW schemes if enabled in module_physics_init.F
3170 IF ( present( has_reqc ).and. present( has_reqi ) .and. present( has_reqs ) .and. &
3171 present( re_cloud ).and. present( re_ice ) .and. present( re_snow ) .and. &
3173 IF ( has_reqc.ne.0 .or. has_reqi.ne.0 .or. has_reqs.ne.0) THEN
3176 re_cloud(ix,kz,jy) = 2.51E-6
3177 re_ice(ix,kz,jy) = 10.01E-6
3178 re_snow(ix,kz,jy) = 25.E-6
3179 t1(ix,1,kz) = 2.51E-6
3180 t2(ix,1,kz) = 10.01E-6
3181 t3(ix,1,kz) = 25.E-6
3182 t4(ix,1,kz) = 50.e-6
3187 call calc_eff_radius &
3190 & ,t1=t1,t2=t2,t3=t3,t4=t4,t5=t5,t6=t6 &
3191 & ,f_t4=has_reqr_local,f_t5=has_reqg_local, f_t6=has_reqh_local &
3196 re_cloud(ix,kz,jy) = MAX(2.51E-6, MIN(t1(ix,1,kz), 50.E-6))
3197 re_ice(ix,kz,jy) = MAX(10.01E-6, MIN(t2(ix,1,kz), 125.E-6))
3198 re_snow(ix,kz,jy) = MAX(25.E-6, MIN(t3(ix,1,kz), 999.E-6))
3199 ! check for case where snow needs to be treated as cloud ice (for rrtmg radiation)
3200 IF ( .not. present(qi) ) re_ice(ix,kz,jy) = MAX(10.E-6, MIN(t3(ix,1,kz), 125.E-6))
3204 IF ( present(has_reqr) .and. present( re_rain ) ) THEN
3205 IF ( has_reqr /= 0 ) THEN
3208 re_rain(ix,kz,jy) = MAX(50.E-6, MIN(t4(ix,1,kz), 2999.E-6))
3214 IF ( present(has_reqg) .and. present( re_graup ) ) THEN
3215 IF ( has_reqg /= 0 ) THEN
3218 re_graup(ix,kz,jy) = MAX(50.E-6, MIN(t5(ix,1,kz), 10.E-3))
3224 IF ( present(has_reqh) .and. present( re_hail ) ) THEN
3225 IF ( has_reqh /= 0 ) THEN
3228 re_hail(ix,kz,jy) = MAX(50.E-6, MIN(t5(ix,1,kz), 40.E-3))
3238 IF ( present( hail_maxk1 ) .and. present( hail_max2d ) .and. nwp_diagflag ) THEN
3240 hailmax1d(ix,1) = hail_max2d(ix,jy)
3241 hailmaxk1(ix,1) = hail_maxk1(ix,jy)
3244 call hailmaxd(dtp,nx,ny,nz,an,na,nor,nor,alpha2d,dn1, &
3245 hailmax1d,hailmaxk1,1 )
3248 hail_max2d(ix,jy) = hailmax1d(ix,1)
3249 hail_maxk1(ix,jy) = hailmaxk1(ix,1)
3254 ! transform concentrations back to mixing ratios
3256 IF ( denscale(il) == 1 ) THEN
3259 an(ix,1,kz,il) = an(ix,1,kz,il)/dn1(ix,1,kz) ! dn(ix,kz,jy)
3265 ! copy 2D slabs back to 3D
3271 th(ix,kz,jy) = an(ix,1,kz,lt)
3273 qv(ix,kz,jy) = an(ix,1,kz,lv)
3274 qc(ix,kz,jy) = an(ix,1,kz,lc)
3275 qr(ix,kz,jy) = an(ix,1,kz,lr)
3276 IF ( flag_qi ) qi(ix,kz,jy) = an(ix,1,kz,li)
3277 qs(ix,kz,jy) = an(ix,1,kz,ls)
3278 qh(ix,kz,jy) = an(ix,1,kz,lh)
3279 IF ( lhl > 1 ) qhl(ix,kz,jy) = an(ix,1,kz,lhl)
3281 IF ( lccn > 1 .and. is_aerosol_aware .and. flag_qnwfa ) THEN
3283 ELSEIF ( flag_ccn .and. lccn > 1 .and. .not. flag_qndrop) THEN
3284 IF ( lccna > 1 .and. .not. ( present( cna ) .and. f_cnatmp ) ) THEN
3285 cn(ix,kz,jy) = Max(0.0, an(ix,1,kz,lccna) )
3287 cn(ix,kz,jy) = an(ix,1,kz,lccn)
3290 IF ( lccna > 1 ) THEN
3291 IF ( present( cna ) .and. f_cnatmp ) THEN
3292 cna(ix,kz,jy) = Max(0.0, an(ix,1,kz,lccna) )
3296 IF ( lcina > 1 ) THEN
3297 IF ( present( cni ) .and. f_cinatmp ) THEN
3298 cni(ix,kz,jy) = Max(0.0, an(ix,1,kz,lcina) )
3302 IF ( lccnuf > 0 .and. flag_cnuf ) THEN
3303 IF ( i_uf_or_ccn > 0 ) THEN ! UF are ccn and lccnuf is zero, so put cnuf into lccnuf to do decay
3304 an(ix,1,kz,lccnuf) = Max(0.0, cnuf(ix,kz,jy) )
3306 IF ( decayufccn ) THEN
3307 IF ( an(ix,1,kz,lccnuf) > ufbackground ) THEN
3308 an(ix,1,kz,lccnuf) = an(ix,1,kz,lccnuf) - (an(ix,1,kz,lccnuf) - &
3309 ufbackground)*(1.0 - exp(-dtp/ufccntimeconst))
3312 cnuf(ix,kz,jy) = an(ix,1,kz,lccnuf)
3317 IF ( ipconc >= 5 ) THEN
3319 ccw(ix,kz,jy) = an(ix,1,kz,lnc)
3320 crw(ix,kz,jy) = an(ix,1,kz,lnr)
3321 IF ( present( cci ) ) cci(ix,kz,jy) = an(ix,1,kz,lni)
3322 csw(ix,kz,jy) = an(ix,1,kz,lns)
3323 chw(ix,kz,jy) = an(ix,1,kz,lnh)
3324 IF ( lhl > 1 ) chl(ix,kz,jy) = an(ix,1,kz,lnhl)
3327 IF ( ipconc >= 6 ) THEN
3328 IF ( lzr > 0 ) zrw(ix,kz,jy) = an(ix,1,kz,lzr) *zscaleinv
3329 IF ( lzh > 0 ) zhw(ix,kz,jy) = an(ix,1,kz,lzh) *zscaleinv
3330 IF ( lzhl > 0 ) zhl(ix,kz,jy) = an(ix,1,kz,lzhl)*zscaleinv
3335 IF ( lvh > 0 ) vhw(ix,kz,jy) = an(ix,1,kz,lvh)
3336 IF ( lvhl > 0 .and. present( vhl ) ) vhl(ix,kz,jy) = an(ix,1,kz,lvhl)
3338 #if ( WRF_CHEM == 1 )
3339 IF ( has_wetscav ) THEN
3340 IF ( loopmax > 1 ) THEN
3341 ! wrferror not supported
3343 IF ( PRESENT( rainprod ) ) rainprod(ix,kz,jy) = rainprod2d(ix,kz)
3344 IF ( PRESENT( evapprod ) ) evapprod(ix,kz,jy) = evapprod2d(ix,kz)
3357 IF ( invertccn .and. flag_ccn ) THEN ! hack to convert unactivated ccn back to activated
3361 cn(ix,kz,jy) = Max( 0.0, qccn - cn(ix,kz,jy) )
3367 IF ( lccnuf > 1 .and. flag_cnuf .and. ccnuf > 1.0 ) THEN
3371 cnuf(ix,kz,jy) = qccnuf - cnuf(ix,kz,jy)
3383 END SUBROUTINE nssl_2mom_driver
3385 ! #####################################################################
3386 ! #####################################################################
3388 REAL FUNCTION GAMMA_SP(xx)
3394 ! Double precision ser,stp,tmp,x,y,cof(6)
3396 real*8 ser,stp,tmp,x,y,cof(6)
3398 DATA cof,stp/76.18009172947146d+0, &
3399 & -86.50532032941677d0, &
3400 & 24.01409824083091d0, &
3401 & -1.231739572450155d0, &
3402 & 0.1208650973866179d-2,&
3403 & -0.5395239384953d-5, &
3404 & 2.5066282746310005d0/
3406 IF ( xx <= 0.0 ) THEN
3407 write(0,*) 'Argument to gamma must be > 0!! xx = ',xx
3414 tmp = (x + 0.5d0)*Log(tmp) - tmp
3415 ser = 1.000000000190015d0
3418 ser = ser + cof(j)/y
3420 gamma_sp = Exp(tmp + log(stp*ser/x))
3423 END FUNCTION GAMMA_SP
3425 ! #####################################################################
3427 DOUBLE PRECISION FUNCTION GAMMA_DPR(x)
3428 ! dp gamma with real input
3431 double precision :: xx
3435 gamma_dpr = gamma_dp(xx)
3438 end FUNCTION GAMMA_DPR
3443 ! #####################################################################
3445 real function GAMXINF(A1,X1)
3447 ! ===================================================
3448 ! Purpose: Compute the incomplete gamma function
3449 ! from x to infinity
3450 ! Input : a --- Parameter ( a 170 )
3452 ! Output: GIM --- gamma(a,x) t=x,Infinity
3453 ! Routine called: GAMMA for computing gamma(x)
3454 ! ===================================================
3456 ! IMPLICIT DOUBLE PRECISION (A-H,O-Z)
3459 double precision :: xam,dlog,s,r,ga,t0,a,x
3461 double precision :: gin, gim
3465 IF ( x1 <= 0.0 ) THEN
3466 gamxinf = GAMMA_SP(A1)
3470 IF (XAM.GT.700.0.OR.A.GT.170.0) THEN
3471 WRITE(*,*)'a and/or x too large'
3477 ELSE IF (X.LE.1.0+A) THEN
3483 IF (DABS(R/S).LT.1.0D-15) GO TO 15
3488 ELSE IF (X.GT.1.0+A) THEN
3491 T0=(K-A)/(1.0D0+K/(X+T0))
3493 GIM=DEXP(XAM)/(X+T0)
3500 END function GAMXINF
3502 ! #####################################################################
3504 double precision function GAMXINFDP(A1,X1)
3506 ! ===================================================
3507 ! Purpose: Compute the incomplete gamma function
3508 ! from x to infinity
3509 ! Input : a --- Parameter ( a < 170 )
3511 ! Output: GIM --- Gamma(a,x) t=x,Infinity
3512 ! Routine called: GAMMA for computing gamma_dp(x)
3513 ! ===================================================
3515 ! IMPLICIT DOUBLE PRECISION (A-H,O-Z)
3518 ! dont declare gamma_dp because it is within the module
3519 ! double precision :: gamma_dp
3520 double precision :: xam,dlog,s,r,ga,t0,a,x
3522 double precision :: gin, gim
3526 IF ( x1 <= 0.0 ) THEN
3527 gamxinfdp = GAMMA_DP(A)
3531 IF (XAM.GT.700.0.OR.A.GT.170.0) THEN
3532 WRITE(*,*)'a and/or x too large'
3538 ELSE IF (X.LE.1.0+A) THEN
3544 IF (DABS(R/S).LT.1.0D-15) GO TO 15
3549 ELSE IF (X.GT.1.0+A) THEN
3552 T0=(K-A)/(1.0D0+K/(X+T0))
3554 GIM=DEXP(XAM)/(X+T0)
3561 END function GAMXINFDP
3564 ! #####################################################################
3566 real function gaminterp(ratio, alp, luindex, ilh)
3570 real, intent(in) :: ratio, alp
3571 integer, intent(in) :: ilh ! 1 = graupel, 2 = hail
3572 integer, intent(in) :: luindex ! which argument:
3573 ! gamxinflu(i,j,1,1) = x/y
3574 ! gamxinflu(i,j,2,1) = gamxinf( 2.0+alp, ratio )/y
3575 ! gamxinflu(i,j,3,1) = gamxinf( 2.5+alp+0.5*bxh, ratio )/y
3576 ! gamxinflu(i,j,5,1) = gamxinf( 5.0+alp, ratio )/y
3577 ! gamxinflu(i,j,6,1) = gamxinf( 5.5+alp+0.5*bxh, ratio )/y
3580 real :: delx, dely, tmp1, tmp2, temp3
3581 integer :: i,j,ip1,jp1 !,ilh
3586 i = Min(nqiacrratio,Int(ratio*dqiacrratioinv))
3587 j = Int(Max(0.0,Min(maxalphalu,alp))*dqiacralphainv)
3588 delx = Min(maxratiolu,ratio) - float(i)*dqiacrratio
3589 dely = alp - float(j)*dqiacralpha
3590 ip1 = Min( i+1, nqiacrratio )
3591 jp1 = Min( j+1, nqiacralpha )
3593 ! interpolate along x, i.e., ratio;
3594 tmp1 = gamxinflu(i,j,luindex,ilh) + delx*dqiacrratioinv* &
3595 & (gamxinflu(ip1,j,luindex,ilh) - gamxinflu(i,j,luindex,ilh))
3596 tmp2 = gamxinflu(i,jp1,luindex,ilh) + delx*dqiacrratioinv* &
3597 & (gamxinflu(ip1,jp1,luindex,ilh) - gamxinflu(i,jp1,luindex,ilh))
3599 ! interpolate along alpha;
3601 gaminterp = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))
3604 ! IF ( ilh0 < 0 ) THEN
3605 ! write(0,*) 'gaminterp: ',i,j,ilh,ratio,delx,dely,gamxinflu(i,j,luindex,ilh),tmp1,tmp2
3608 END FUNCTION gaminterp
3609 ! #####################################################################
3611 !**************************** GAML02 ***********************
3612 ! This calculates Gamma(0.2,x)/Gamma[0.2], where is a ratio
3613 ! It is used for qiacr with the gamma of volume to calculate what
3614 ! fraction of drops exceed a certain size (this version is for 40 micron drops)
3615 ! **********************************************************
3616 real FUNCTION GAML02(x)
3618 integer ig, i, ii, n, np
3622 real gamxg(ng), xg(ng)
3623 DATA xg/0.01,0.02,0.025,0.04,0.075,0.1,0.25,0.5,0.75,1.,2.,10./
3625 & 7.391019203578037e-8,0.02212726874591478,0.06959352407989682, &
3626 & 0.2355654024970809,0.46135930387500346,0.545435791452399, &
3627 & 0.7371571313308203, &
3628 & 0.8265676632204345,0.8640182781845841,0.8855756211304151, &
3629 & 0.9245079225301251, &
3630 & 0.9712578342732681/
3631 IF ( x .ge. xg(ng) ) THEN
3635 IF ( x .lt. xg(1) ) THEN
3643 IF ( x .ge. xg(i) ) THEN
3645 gaml02 = gamxg(N)+((X-XG(N))/(XG(NP)-XG(N)))* &
3646 & ( gamxg(NP) - gamxg(N) )
3653 !**************************** GAML02d300 ***********************
3654 ! This calculates Gamma(0.2,x)/Gamma[0.2], where is a ratio
3655 ! It is used for qiacr with the gamma of volume to calculate what
3656 ! fraction of drops exceed a certain size (this version is for 300 micron drops) (see zieglerstuff.nb)
3657 ! **********************************************************
3658 real FUNCTION GAML02d300(x)
3660 integer ig, i, ii, n, np
3664 real gamxg(ng), xg(ng)
3665 DATA xg/0.04,0.075,0.1,0.25,0.5,0.75,1.,2.,10./
3668 & 7.391019203578011e-8,0.0002260640810600053, &
3669 & 0.16567071824457152, &
3670 & 0.4231369044918005,0.5454357914523988, &
3671 & 0.6170290936864555, &
3672 & 0.7471346054110058,0.9037156157718299 /
3673 IF ( x .ge. xg(ng) ) THEN
3677 IF ( x .lt. xg(1) ) THEN
3685 IF ( x .ge. xg(i) ) THEN
3687 GAML02d300 = gamxg(N)+((X-XG(N))/(XG(NP)-XG(N)))* &
3688 & ( gamxg(NP) - gamxg(N) )
3693 END FUNCTION GAML02d300
3696 ! #####################################################################
3697 ! #####################################################################
3699 !**************************** GAML02 ***********************
3700 ! This calculates Gamma(0.2,x)/Gamma[0.2], where is a ratio
3701 ! It is used for qiacr with the gamma of volume to calculate what
3702 ! fraction of drops exceed a certain size (this version is for 500 micron drops) (see zieglerstuff.nb)
3703 ! **********************************************************
3704 real FUNCTION GAML02d500(x)
3706 integer ig, i, ii, n, np
3710 real gamxg(ng), xg(ng)
3711 DATA xg/0.04,0.075,0.1,0.25,0.5,0.75,1.,2.,10./
3714 & 2.2346039e-13, 0.0221272687459, &
3715 & 0.23556540, 0.38710348, &
3716 & 0.48136183,0.6565833, &
3718 IF ( x .ge. xg(ng) ) THEN
3722 IF ( x .lt. xg(1) ) THEN
3730 IF ( x .ge. xg(i) ) THEN
3732 GAML02d500 = gamxg(N)+((X-XG(N))/(XG(NP)-XG(N)))* &
3733 & ( gamxg(NP) - gamxg(N) )
3738 END FUNCTION GAML02d500
3741 ! #####################################################################
3743 ! #####################################################################
3746 real function BETA(P,Q)
3748 ! ==========================================
3749 ! Purpose: Compute the beta function B(p,q)
3750 ! Input : p --- Parameter ( p > 0 )
3751 ! q --- Parameter ( q > 0 )
3752 ! Output: BT --- B(p,q)
3753 ! Routine called: GAMMA for computing gamma(x)
3754 ! ==========================================
3756 ! IMPLICIT real (A-H,O-Z)
3758 double precision p1,gp,q1,gq, ppq,gpq
3766 CALL GAMMADP(PPQ,GPQ)
3771 ! #####################################################################
3772 ! #####################################################################
3774 DOUBLE PRECISION FUNCTION GAMMA_DP(xx)
3780 ! Double precision ser,stp,tmp,x,y,cof(6)
3782 real*8 ser,stp,tmp,x,y,cof(6)
3784 DATA cof,stp/76.18009172947146d+0, &
3785 & -86.50532032941677d0, &
3786 & 24.01409824083091d0, &
3787 & -1.231739572450155d0, &
3788 & 0.1208650973866179d-2,&
3789 & -0.5395239384953d-5, &
3790 & 2.5066282746310005d0/
3795 tmp = (x + 0.5d0)*Log(tmp) - tmp
3796 ser = 1.000000000190015d0
3799 ser = ser + cof(j)/y
3801 gamma_dp = Exp(tmp + log(stp*ser/x))
3804 END function gamma_dp
3805 ! #####################################################################
3807 SUBROUTINE GAMMADP(X,GA)
3809 ! ==================================================
3810 ! Purpose: Compute gamma function Gamma(x)
3811 ! Input : x --- Argument of Gamma(x)
3812 ! ( x is not equal to 0,-1,-2,...)
3813 ! Output: GA --- gamma(x)
3814 ! ==================================================
3816 ! IMPLICIT DOUBLE PRECISION (A-H,O-Z)
3819 double precision, parameter :: PI=3.141592653589793D0
3820 double precision :: x,ga,z,r,gr
3823 double precision :: G(26)
3825 IF (X.EQ.INT(X)) THEN
3826 IF (X.GT.0.0D0) THEN
3836 IF (DABS(X).GT.1.0D0) THEN
3847 DATA G/1.0D0,0.5772156649015329D0, &
3848 & -0.6558780715202538D0, -0.420026350340952D-1, &
3849 & 0.1665386113822915D0,-.421977345555443D-1, &
3850 & -.96219715278770D-2, .72189432466630D-2, &
3851 & -.11651675918591D-2, -.2152416741149D-3, &
3852 & .1280502823882D-3, -.201348547807D-4, &
3853 & -.12504934821D-5, .11330272320D-5, &
3854 & -.2056338417D-6, .61160950D-8, &
3855 & .50020075D-8, -.11812746D-8, &
3856 & .1043427D-9, .77823D-11, &
3857 & -.36968D-11, .51D-12, &
3858 & -.206D-13, -.54D-14, .14D-14, .1D-15/
3864 IF (DABS(X).GT.1.0D0) THEN
3866 IF (X.LT.0.0D0) GA=-PI/(X*GA*DSIN(PI*X))
3870 END SUBROUTINE GAMMADP
3873 ! #####################################################################
3874 ! #####################################################################
3877 ! #####################################################################
3878 Function delbk(bb,nu,mu,k)
3880 ! Purpose: Caluculates collection coefficients following Siefert (2006)
3882 ! delbk is equation (90) (b collecting b -- self-collection)
3883 ! mass-diameter relationship: D = a*x**(b), where x = particle mass
3884 ! general distribution: n(x) = A*x**(nu)*Exp(-lam*x**(mu))
3886 ! A = mu*N/(Gamma((nu+1)/mu)) *lam**((nu+1)/mu)
3888 ! lam = ( Gamma((nu+1)/mu)/Gamma((nu+2)/mu) * xbar )**(-mu)
3890 ! where xbar = L/N (mass content)/(number concentration) = q*rhoa/N
3902 tmp = ((1.0 + nu)/mu)
3903 i = Int(dgami*(tmp))
3905 x1 = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3907 tmp = ((2.0 + nu)/mu)
3908 i = Int(dgami*(tmp))
3910 x2 = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3912 tmp = ((1.0 + 2.0*bb + k + nu)/mu)
3913 i = Int(dgami*(tmp))
3915 x3 = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3918 ! & ((Gamma_sp((1.0 + nu)/mu)/Gamma_sp((2.0 + nu)/mu))**(2.0*bb + k)* &
3919 ! & Gamma_sp((1.0 + 2.0*bb + k + nu)/mu))/Gamma_sp((1.0 + nu)/mu)
3922 & ((x1/x2)**(2.0*bb + k)* &
3928 ! #####################################################################
3931 ! #####################################################################
3932 ! Equation (91) in Seifert and Beheng (2006) ("a" collecting "b")
3933 Function delabk(ba,bb,nua,nub,mua,mub,k)
3944 real g1pnua, g2pnua, g1pbapnua, g1pbbpk, g1pnub, g2pnub
3946 tmp = (1. + nua)/mua
3947 i = Int(dgami*(tmp))
3949 IF ( i+1 > ngm0 ) THEN
3950 write(0,*) 'delabk: i+1 > ngm0!!!!',i,ngm0,nua,mua,tmp
3953 g1pnua = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3954 ! write(91,*) 'delabk: g1pnua,gamma = ',g1pnua,Gamma_sp((1. + nua)/mua)
3956 tmp = ((2. + nua)/mua)
3957 i = Int(dgami*(tmp))
3959 g2pnua = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3961 tmp = ((1. + ba + nua)/mua)
3962 i = Int(dgami*(tmp))
3964 g1pbapnua = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3966 tmp = ((1. + nub)/mub)
3967 i = Int(dgami*(tmp))
3969 g1pnub = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3971 tmp = ((2 + nub)/mub)
3972 i = Int(dgami*(tmp))
3974 g2pnub = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3976 tmp = ((1. + bb + k + nub)/mub)
3977 i = Int(dgami*(tmp))
3979 g1pbbpk = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3982 & (2.*(g1pnua/g2pnua)**ba* &
3984 & (g1pnub/g2pnub)**(bb + k)* &
3993 ! #####################################################################
3995 ! #####################################################################
3996 !--------------------------------------------------------------------------
3997 subroutine cld_cpu(string)
4000 character( LEN = * ) string
4004 end subroutine cld_cpu
4007 !--------------------------------------------------------------------------
4009 !--------------------------------------------------------------------------
4011 ! #######################################################################
4012 ! HAILMAXD - calculated maximum expected hail size
4013 ! #######################################################################
4014 subroutine hailmaxd(dtp,nx,ny,nz,an,na,nor,norz,alpha2d,dn, &
4015 & hailmax1d,hailmaxk1,jslab )
4017 ! Calculate maximum hail size from the tail of of the distribution. The value
4018 ! of thresh_conc sets the minimum concentration in the integral over (Dmax, Inf).
4019 ! This uses the lookup tables for incomplete gamma functions and simply search for
4020 ! the expected value (and linearly interpolate) on D.
4022 ! Written by ERM 7/2023
4028 integer nx,ny,nz,nor,norz,ngt,jgs,na,ia
4029 integer id ! =1 use density, =0 no density
4030 ! integer :: its,ite ! x-range to calculate
4035 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
4036 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4038 ! real gz(-nor+ng1:nz+nor),z1d(-nor+ng1:nz+nor,4)
4040 real alpha2d(-nor+1:nx+nor,1,-norz+1:nz+norz,3) ! array for PSD shape parameters
4041 real :: hailmax1d(nx,ny),hailmaxk1(nx,ny)
4043 integer jslab ! which line of xfall to use
4045 integer ix,jy,kz,ndfall,n,k,il,in
4046 double precision :: tmp, ratio, del, g1palp
4047 real, parameter :: dz = 200.
4049 real :: db1(nx,nz+1),dtz1(nz+1,nx,0:1),dz2dinv(nz+1,nx),db1inv(nx,nz+1)
4051 real :: rhovtzx(nz,nx)
4053 real :: alp, diam, diam1, hwdn
4055 ! real, parameter :: cmin = 0.001 ! threshold number per m^3 for maximum diamter (threshold from diag_nwp)
4056 DOUBLE PRECISION, PARAMETER:: thresh_conc = 0.0005d0 ! number conc. of graupel/hail per cubic meter
4057 real :: cwchtmp,cwchltmp, maxdia
4059 !-----------------------------------------------------------------------------
4061 integer :: ixb, jyb, kzb
4062 integer :: ixe, jye, kze
4064 integer :: ialp, i, j
4066 logical :: debug_mpi = .TRUE.
4068 ! ###################################################################
4072 cwchtmp = ((3. + dnu(lh))*(2. + dnu(lh))*(1.0 + dnu(lh)))**(-1./3.)
4075 cwchltmp = ((3. + dnu(lhl))*(2. + dnu(lhl))*(1.0 + dnu(lhl)))**(-1./3.)
4082 ixb = 1 ! aliased its
4083 ixe = nx ! aliased ite
4090 ! hailmax1d(:,jy) = 0.0
4091 ! hailmaxk1(:,jy) = 0.0
4093 if ( ndebug .gt. 0 ) write(0,*) 'dbg = 3a'
4096 ! first graupel, even if hail is also predicted, since graupel can sometime be large on its own
4097 IF ( lh > 1 .and. lnh > 1 ) THEN
4100 IF ( an(ix,jy,kz,lh) .gt. qxmin(lh) .and. an(ix,jy,kz,lnh) .gt. thresh_conc ) THEN
4101 IF ( lvh .gt. 1 ) THEN
4102 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
4107 tmp = 1. + alpha2d(ix,1,kz,2)
4108 i = Int(dgami*(tmp))
4110 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4112 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lh)/(hwdn*an(ix,jy,kz,lnh))
4113 diam = (6.0*tmp/pi)**(1./3.)
4114 IF ( lzh > 1 ) THEN ! 3moment
4115 cwchtmp = ((3. + alpha2d(ix,1,kz,2))*(2. + alpha2d(ix,1,kz,2))*(1.0 + alpha2d(ix,1,kz,2)))**(-1./3.)
4117 diam1 = diam*cwchtmp ! characteristic diameter, i.e., 1/lambda
4118 ! want cxd1 = thresh_conc
4119 ! tmp = gaminterp(ratio,alpha(mgs,lh),1,1)
4120 ! cxd1 = cx(mgs,lh)*(tmp)/g1palp
4121 ! tmp = thresh_conc*g1palp/cx
4123 tmp = thresh_conc*g1palp/an(ix,jy,kz,lnh)
4124 alp = alpha2d(ix,1,kz,2)
4125 ! gamxinflu(i,j,luindex,ilh)
4126 j = Int(Max(0.0,Min(maxalphalu,alp))*dqiacralphainv)
4129 ! eventually could replace with bisection search, but final value of i is usually small
4130 ! compared to nqiacrratio
4131 DO i = 0,nqiacrratio-1
4132 IF ( gamxinflu(i,j,1,1) >= tmp .and. tmp >= gamxinflu(i+1,j,1,1) ) THEN
4133 ! interpolate here for FWIW
4134 ratio = i*dqiacrratio
4135 del = tmp - gamxinflu(i,j,1,1)
4136 ratio = (float(i) + del/(gamxinflu(i+1,j,1,1) - gamxinflu(i,j,1,1)))*dqiacrratio
4141 IF ( ratio > 0.0 ) THEN
4142 maxdia = ratio*diam1 ! units of m
4145 IF ( kz == kzb ) THEN
4146 hailmaxk1(ix,jy) = Max( maxdia, hailmaxk1(ix,jy) )
4147 ! IF ( maxdia > 0.1 ) THEN
4148 ! IF ( an(ix,jy,kz,lh) > 1.e-4 ) THEN
4149 ! write(0,*) 'maxdia,tmp,alp,ratio,diam,diam1= ',maxdia,tmp,alp,ratio,diam*100.,diam1*100.
4150 ! write(0,*) 'hwdn, cxhl, qx, g1palp = ',hwdn, an(ix,jy,kz,lnhl), an(ix,jy,kz,lhl), g1palp
4151 ! write(0,*) 'j,gamxinflu(0,2,4) = ',j,gamxinflu(0,j,1,1),gamxinflu(2,j,1,1), &
4152 ! gamxinflu(4,j,1,1)
4156 hailmax1d(ix,jy) = Max(maxdia, hailmax1d(ix,jy) )
4167 ! And diam for hail if present
4168 IF ( lhl > 1 .and. lnhl > 1 ) THEN
4171 IF ( an(ix,jy,kz,lhl) .gt. qxmin(lhl) .and. an(ix,jy,kz,lnhl) .gt. thresh_conc ) THEN
4172 IF ( lvhl .gt. 1 ) THEN
4173 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
4178 tmp = 1. + alpha2d(ix,1,kz,3)
4179 i = Int(dgami*(tmp))
4181 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4183 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/(hwdn*an(ix,jy,kz,lnhl))
4184 diam = (6.0*tmp/pi)**(1./3.)
4185 IF ( lzhl > 1 ) THEN ! 3moment
4186 cwchltmp = ((3. + alpha2d(ix,1,kz,3))*(2. + alpha2d(ix,1,kz,3))*(1.0 + alpha2d(ix,1,kz,3)))**(-1./3.)
4188 diam1 = diam*cwchltmp ! characteristic diameter, i.e., 1/lambda
4189 ! want cxd1 = thresh_conc
4190 ! tmp = gaminterp(ratio,alpha(mgs,lh),1,1)
4191 ! cxd1 = cx(mgs,lh)*(tmp)/g1palp
4192 ! tmp = thresh_conc*g1palp/cx
4194 tmp = thresh_conc*g1palp/an(ix,jy,kz,lnhl)
4195 alp = alpha2d(ix,1,kz,3)
4196 ! gamxinflu(i,j,luindex,ilh)
4197 j = Int(Max(0.0,Min(maxalphalu,alp))*dqiacralphainv)
4200 ! eventually could replace with bisection search, but final value of i is usually small
4201 ! compared to nqiacrratio
4202 DO i = 0,nqiacrratio-1
4203 IF ( gamxinflu(i,j,1,1) >= tmp .and. tmp >= gamxinflu(i+1,j,1,1) ) THEN
4204 ! interpolate here for FWIW
4205 ratio = i*dqiacrratio
4206 del = tmp - gamxinflu(i,j,1,1)
4207 ratio = (float(i) + del/(gamxinflu(i+1,j,1,1) - gamxinflu(i,j,1,1)))*dqiacrratio
4212 IF ( ratio > 0.0 ) THEN
4213 maxdia = ratio*diam1 ! units of m
4216 IF ( kz == kzb ) THEN
4217 hailmaxk1(ix,jy) = Max( maxdia, hailmaxk1(ix,jy) )
4218 ! IF ( maxdia > 0.1 ) THEN
4219 ! IF ( an(ix,jy,kz,lhl) > 1.e-4 ) THEN
4220 ! write(0,*) 'maxdia,tmp,alp,ratio,diam,diam1= ',maxdia,tmp,alp,ratio,diam*100.,diam1*100.
4221 ! write(0,*) 'hwdn, cxhl, qx, g1palp = ',hwdn, an(ix,jy,kz,lnhl), an(ix,jy,kz,lhl), g1palp
4222 ! write(0,*) 'j,gamxinflu(0,2,4) = ',j,gamxinflu(0,j,1,1),gamxinflu(2,j,1,1), &
4223 ! gamxinflu(4,j,1,1)
4227 hailmax1d(ix,jy) = Max(maxdia, hailmax1d(ix,jy) )
4239 END SUBROUTINE HAILMAXD
4240 ! #######################################################################
4241 ! #######################################################################
4242 subroutine sediment1d(dtp,nx,ny,nz,an,na,nor,norz,xfall,dn,dz3d,dz3dinv, &
4243 & t0,t7,infdo,jslab,its,jts, &
4244 & timesed1,timesed2,timesed3,zmaxsed,timesetvt) ! used for timing
4246 ! Sedimentation driver -- column by column
4248 ! Written by ERM 10/2011
4254 integer nx,ny,nz,nor,norz,ngt,jgs,na,ia
4255 integer id ! =1 use density, =0 no density
4256 integer :: its,jts ! SW point of local tile
4261 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
4262 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4263 real dz3d(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4264 real dz3dinv(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4265 real t0(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4266 real t7(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4268 ! real gz(-nor+ng1:nz+nor),z1d(-nor+ng1:nz+nor,4)
4270 real xfall(nx,ny,na) ! array for stuff landing on the ground
4271 ! real xfall0(nx,ny) ! dummy array
4273 integer jslab ! which line of xfall to use
4275 integer ix,jy,kz,ndfall,n,k,il,in
4276 real tmp, vtmax, dtptmp, dtfrac
4277 real, parameter :: dz = 200.
4279 ! real :: xvt(nz+1,nx,3,lc:lhab) ! (nx,nz,2,lc:lhab) ! 1=mass-weighted, 2=number-weighted
4280 ! real :: tmpn(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
4281 ! real :: tmpn2(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
4282 ! real :: z(-nor+ng1:nx+nor,-norz+ng1:nz+norz,lr:lhab)
4283 ! real :: db1(nx,nz+1),dtz1(nz+1,nx,0:1),dz2dinv(nz+1,nx),db1inv(nx,nz+1)
4285 ! real :: rhovtzx(nz,nx)
4287 real, allocatable :: db1(:,:), dtz1(:,:,:),dz2dinv(:,:),db1inv(:,:) ! db1(nx,nz+1),dtz1(nz+1,nx,0:1),dz2dinv(nz+1,nx),db1inv(nx,nz+1)
4288 real, allocatable :: rhovtzx(:,:)
4289 real, allocatable :: xfall0(:,:), xvt(:,:,:,:),tmpn(:,:,:),tmpn2(:,:,:),z(:,:,:)
4291 double precision :: timesed1,timesed2,timesed3, zmaxsed,timesetvt,dummy
4292 double precision :: dt1,dt2,dt3,dt4
4294 integer :: ngs ! = 512
4295 integer :: ngscnt,mgs,ipconc0
4297 ! real :: qx(ngs,lv:lhab)
4298 ! real :: qxw(ngs,ls:lhab)
4299 ! real :: cx(ngs,lc:lhab)
4300 ! real :: xv(ngs,lc:lhab)
4301 ! real :: vtxbar(ngs,lc:lhab,3)
4302 ! real :: xmas(ngs,lc:lhab)
4303 ! real :: xdn(ngs,lc:lhab)
4304 ! real :: xdia(ngs,lc:lhab,3)
4305 ! real :: vx(ngs,li:lhab)
4306 ! real :: alpha(ngs,lc:lhab)
4307 ! real :: zx(ngs,lr:lhab)
4308 ! logical :: hasmass(nx,lc+1:lhab)
4310 ! integer igs(ngs),kgs(ngs)
4312 ! real rho0(ngs),temcg(ngs)
4318 ! real cwnc(ngs),cinc(ngs)
4319 ! real fadvisc(ngs),cwdia(ngs),cipmas(ngs)
4321 ! real cimasn,cimasx,cnina(ngs),cimas(ngs)
4325 real, allocatable :: qx(:,:)
4326 real, allocatable :: qxw(:,:)
4327 real, allocatable :: cx(:,:)
4328 real, allocatable :: xv(:,:)
4329 real, allocatable :: vtxbar(:,:,:)
4330 real, allocatable :: xmas(:,:)
4331 real, allocatable :: xdn(:,:)
4332 real, allocatable :: xdia(:,:,:)
4333 real, allocatable :: vx(:,:)
4334 real, allocatable :: alpha(:,:)
4335 real, allocatable :: zx(:,:)
4336 logical, allocatable :: hasmass(:,:)
4338 integer, allocatable :: igs(:),kgs(:)
4340 real, allocatable :: rho0(:),temcg(:)
4342 real, allocatable :: temg(:)
4344 real, allocatable :: rhovt(:)
4346 real, allocatable :: cwnc(:),cinc(:)
4347 real, allocatable :: fadvisc(:),cwdia(:),cipmas(:)
4349 real, allocatable :: cnina(:),cimas(:)
4351 real, allocatable :: cnostmp(:)
4353 real :: cimasn,cimasx
4356 !-----------------------------------------------------------------------------
4358 integer :: ixb, jyb, kzb
4359 integer :: ixe, jye, kze
4362 logical :: debug_mpi = .TRUE.
4364 ! ###################################################################
4367 allocate( db1(nx,nz+1),dtz1(nz+1,nx,0:1),dz2dinv(nz+1,nx),db1inv(nx,nz+1),rhovtzx(nz,nx) )
4368 allocate( xfall0(nx,ny), xvt(nz+1,nx,3,lc:lhab), tmpn(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz) )
4369 allocate( tmpn2(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz), z(-nor+ng1:nx+nor,-norz+ng1:nz+norz,lr:lhab))
4373 allocate( qx(ngs,lv:lhab), &
4377 vtxbar(ngs,lc:lhab,3), &
4378 xmas(ngs,lc:lhab), &
4380 xdia(ngs,lc:lhab,3), &
4382 alpha(ngs,lc:lhab), &
4384 hasmass(nx,lc+1:lhab), &
4385 igs(ngs),kgs(ngs), &
4386 rho0(ngs),temcg(ngs),temg(ngs), rhovt(ngs), &
4387 cwnc(ngs),cinc(ngs), &
4388 fadvisc(ngs),cwdia(ngs),cipmas(ngs), &
4389 cnina(ngs),cimas(ngs), &
4404 ! zero the precip flux arrays (2d)
4409 if ( ndebug .gt. 0 ) write(0,*) 'dbg = 3a'
4414 db1(ix,kz) = dn(ix,jy,kz)
4415 db1inv(ix,kz) = 1./dn(ix,jy,kz)
4416 rhovtzx(kz,ix) = Sqrt(rho00*Min(1.0/0.05, db1inv(ix,kz))) ! prevent excessive rhovt
4422 dtz1(kz,ix,0) = dz3dinv(ix,jy,kz)
4423 dtz1(kz,ix,1) = dz3dinv(ix,jy,kz)*db1inv(ix,kz)
4424 dz2dinv(kz,ix) = dz3dinv(ix,jy,kz)
4428 IF ( lzh .gt. 1 ) THEN
4431 an(ix,jy,kz,lzh) = Max( 0., an(ix,jy,kz,lzh) )
4439 ! hasmass(ix,il) = Any( an(ix,jy,:,il) > qxmin(il) )
4446 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3a2'
4454 call ziegfall1d(nx,ny,nz,nor,norz,na,dtp,jgs,ix, &
4456 & an,dn,ipconc,t0,t7,cwmasn,cwmasx, &
4458 & qxmin,xdnmx,xdnmn,cdx,cno,xdn0,xvmn,xvmx, &
4459 & ngs,qx,qxw,cx,xv,vtxbar,xmas,xdn,xdia,vx,alpha,zx,igs,kgs, &
4460 & rho0,temcg,temg,rhovt,cwnc,cinc,fadvisc,cwdia,cipmas,cnina,cimas, &
4466 ! loop over each species and do sedimentation for all moments
4468 IF ( ido(il) == 0 ) CYCLE
4470 ! IF ( .not. hasmass(ix,il) ) CYCLE
4480 ! apply limit vtmaxsed (08/20/2015)
4481 xvt(kz,ix,1,il) = Min( vtmaxsed, xvt(kz,ix,1,il) )
4482 xvt(kz,ix,2,il) = Min( vtmaxsed, xvt(kz,ix,2,il) )
4483 xvt(kz,ix,3,il) = Min( vtmaxsed, xvt(kz,ix,3,il) )
4485 vtmax = Max(vtmax,xvt(kz,ix,1,il)*dz2dinv(kz,ix))
4486 vtmax = Max(vtmax,xvt(kz,ix,2,il)*dz2dinv(kz,ix))
4487 vtmax = Max(vtmax,xvt(kz,ix,3,il)*dz2dinv(kz,ix))
4489 ! IF ( dtp*xvt(kz,ix,1,il)*dz2dinv(kz,ix) >= 0.7 .or. &
4490 ! & dtp*xvt(kz,ix,2,il)*dz2dinv(kz,ix) >= 0.7 .or. &
4491 ! & dtp*xvt(kz,ix,3,il)*dz2dinv(kz,ix) >= 0.7 ) THEN
4493 ! zmaxsed = Max(zmaxsed, float(kz) )
4494 !! plo = Min(plo,kz)
4495 !! phi = Max(phi,kz)
4501 IF ( vtmax == 0.0 ) CYCLE
4505 IF ( dtp*vtmax .lt. 0.7 ) THEN ! check whether multiple steps are needed.
4508 IF ( dtp > 20.0 ) THEN ! more stringent subdivision for large time steps
4509 ndfall = Max(2, Int(dtp*vtmax/0.7) + 1)
4510 ELSE ! more relaxed for small time steps, but might still be a problem for very thin vertical layers near the ground
4511 ndfall = 1+Int(dtp*vtmax + 0.301)
4515 IF ( ndfall .gt. 1 ) THEN
4516 dtptmp = dtp/Real(ndfall)
4517 ! write(0,*) 'subdivide fallout on its,jts,ix,plo,phi = ',its,jts,ix,plo,phi
4518 ! write(0,*) 'for il,jsblab,c,ndfall = ',il,jslab,dtp*vtmax,ndfall
4528 IF ( do_accurate_sedimentation .and. n .ge. 2 .and. ( n == interval_sedi_vt*(n/interval_sedi_vt) ) ) THEN
4530 ! zero the precip flux arrays (2d)
4535 xvt(kzb:kze,ix,1:3,il) = 0.0 ! reset to zero because routine will only compute points with q > qmin
4537 call ziegfall1d(nx,ny,nz,nor,norz,na,dtp,jgs,ix, &
4539 & an,dn,ipconc,t0,t7,cwmasn,cwmasx, &
4541 & qxmin,xdnmx,xdnmn,cdx,cno,xdn0,xvmn,xvmx, &
4542 & ngs,qx,qxw,cx,xv,vtxbar,xmas,xdn,xdia,vx,alpha,zx,igs,kgs, &
4543 & rho0,temcg,temg,rhovt,cwnc,cinc,fadvisc,cwdia,cipmas,cnina,cimas, &
4549 ! apply limit vtmaxsed (08/20/2015)
4550 xvt(kz,ix,1,il) = Min( vtmaxsed, xvt(kz,ix,1,il) )
4551 xvt(kz,ix,2,il) = Min( vtmaxsed, xvt(kz,ix,2,il) )
4552 xvt(kz,ix,3,il) = Min( vtmaxsed, xvt(kz,ix,3,il) )
4561 IF ( il >= lr .and. ( infall .eq. 3 .or. infall .eq. 4 ) .and. ln(il) > 0 ) THEN
4562 IF ( (il .eq. lr .and. irfall .eq. infall .and. lzr < 1) .or. &
4563 (il .ge. lh .and. lz(il) .lt. 1 ) .or. (il == ls .and. isfall == infall ) ) THEN
4564 call calczgr1d(nx,ny,nz,nor,na,an,ixe,kze, &
4565 & z,db1,jgs,ipconc, dnu(il), il, ln(il), qxmin(il), xvmn(il), xvmx(il), lvol(il), xdn0(il), ix )
4569 if (ndebug .gt. 0 ) write(0,*) 'dbg = 1b'
4573 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
4574 & an,db1,il,1,xfall,dtz1,ix)
4577 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3c'
4581 IF ( ldovol .and. il >= li ) THEN
4582 IF ( lvol(il) .gt. 1 ) THEN
4583 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
4584 & an,db1,lvol(il),0,xfall,dtz1,ix)
4590 IF ( ipconc .ge. 6 ) THEN
4591 IF ( lz(il) .gt. 1 ) THEN
4592 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,3,il), &
4593 & an,db1,lz(il),0,xfall,dtz1,ix)
4597 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3d'
4600 IF ( ipconc .gt. 0 ) THEN !{
4601 IF ( ipconc .ge. ipc(il) ) THEN
4603 IF ( ( infall .ge. 2 .or. (infall .eq. 0 .and. il .lt. lh) ) .and. lz(il) .lt. 1) THEN !{
4605 ! load number conc. into tmpn to do fallout by mass-weighted mean fall speed
4606 ! to put a lower bound on number conc.
4609 IF ( ( infall .eq. 3 .or. infall .eq. 4 ) .and. ( (il == ls .and. isfall .eq. infall ) &
4610 & .or. il .eq. lh .or. il .eq. lhl .or. il == lf .or. &
4611 & ( il .eq. lr .and. irfall .eq. infall) ) ) THEN
4613 ! set up for method I+II
4616 tmpn2(ix,jy,kz) = z(ix,kz,il)
4621 tmpn(ix,jy,kz) = an(ix,jy,kz,ln(il))
4626 ! set up for method II only
4629 tmpn(ix,jy,kz) = an(ix,jy,kz,ln(il))
4638 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3f'
4641 IF ( infall .eq. 1 ) in = 1
4643 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,in,il), &
4644 & an,db1,ln(il),0,xfall,dtz1,ix)
4647 IF ( lz(il) .lt. 1 ) THEN ! if not 3-moment, run one of the correction schemes
4648 IF ( (infall .ge. 2 .or. infall .eq. 3) .and. .not. (infall .eq. 0 .and. il .ge. lh) &
4649 & .and. ( il .eq. lr .or. (il .ge. li .and. il .le. lhab) )) THEN
4650 ! : .or. il .eq. lhl )) THEN
4654 IF ( ( infall .eq. 3 .or. infall .eq. 4 ) .and. &
4655 & ( il .ge. lh .or. (il .eq. lr .and. irfall .eq. infall) &
4656 .or. (il .eq. ls .and. isfall .eq. infall) ) ) THEN
4657 call fallout1d(nx,ny,nz,nor,1,dtptmp,dtfrac,jgs,xvt(1,1,3,il), &
4658 & tmpn2,db1,1,0,xfall0,dtz1,ix)
4659 call fallout1d(nx,ny,nz,nor,1,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
4660 & tmpn,db1,1,0,xfall0,dtz1,ix)
4662 call fallout1d(nx,ny,nz,nor,1,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
4663 & tmpn,db1,1,0,xfall0,dtz1,ix)
4666 IF ( ( infall .eq. 3 .or. infall .eq. 4 ) .and. ( (il .eq. lr .and. irfall .eq. infall) &
4667 & .or. il .ge. lh .or. (il == ls .and. isfall .eq. infall ) ) ) THEN
4668 ! "Method I" - dbz correction
4670 call calcnfromz1d(nx,ny,nz,nor,na,an,tmpn2,ixe,kze, &
4671 & z,db1,jgs,ipconc, dnu(il), il, ln(il), qxmin(il), xvmn(il), xvmx(il),tmpn, &
4672 & lvol(il), xdn0(il), infall, ix)
4674 ELSEIF ( infall .eq. 5 .and. il .ge. lh .or. ( il == lr .and. irfall == 5 ) ) THEN
4678 an(ix,jgs,kz,ln(il)) = Max( an(ix,jgs,kz,ln(il)), 0.5* ( an(ix,jgs,kz,ln(il)) + tmpn(ix,jy,kz) ))
4683 ELSEIF ( .not. (il .eq. lr .and. irfall .eq. 0) .and. .not. (il .eq. ls .and. isfall .eq. 0) ) THEN
4684 ! "Method II" M-wgt N-fallout correction
4689 an(ix,jgs,kz,ln(il)) = Max( an(ix,jgs,kz,ln(il)), tmpn(ix,jy,kz) )
4694 ENDIF ! lz(il) .lt. 1
4710 deallocate( db1,dtz1,dz2dinv,db1inv,rhovtzx )
4711 deallocate( xfall0, xvt, tmpn )
4712 deallocate( tmpn2, z)
4727 rho0,temcg,temg, rhovt, &
4729 fadvisc,cwdia,cipmas, &
4734 END SUBROUTINE SEDIMENT1D
4737 ! #####################################################################
4740 ! #####################################################################
4744 !--------------------------------------------------------------------------
4746 !--------------------------------------------------------------------------
4748 subroutine fallout1d(nx,ny,nz,nor,na,dtp,dtfrac,jgs,vt, &
4749 & a,db1,ia,id,xfall,dtz1,ixcol)
4751 ! First-order, upwind fallout scheme
4753 ! Written by ERM 6/10/2011
4759 integer nx,ny,nz,nor,ngt,jgs,na,ia
4760 integer id ! =1 use density, =0 no density
4765 ! real dz3dinv(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
4766 ! real a(nx,ny,nz,na)
4767 real a(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,na) ! quantity to be 'advected'
4768 real vt(nz+1,nx) ! terminal speed for a
4771 real xfall(nx,ny,na) ! array for stuff landing on the ground
4772 real db1(nx,nz+1),dtz1(nz+1,nx,0:1)
4776 integer ix,jy,kz,n,k
4779 integer imn,imx,kmn,kmx
4782 !-----------------------------------------------------------------------------
4784 integer :: ixb, jyb, kzb
4785 integer :: ixe, jye, kze
4787 logical :: debug_mpi = .TRUE.
4789 ! ###################################################################
4814 ! cmax = Max(cmax, vt(ix,kz)*dz3dinv(ix,jy,kz))
4817 qtmp1(kz) = a(ix,jgs,kz,ia)*vt(kz,ix)*db1(ix,kz)
4819 qtmp1(kz) = a(ix,jgs,kz,ia)*vt(kz,ix)
4822 IF ( a(ix,jgs,kz,ia) .ne. 0.0 ) THEN
4833 ! first check if fallout is worth doing
4834 ! IF ( cmax .eq. 0.0 .or. imn .gt. imx ) THEN
4838 IF ( kmn == 1 ) THEN
4841 ! do ix = imn,imx ! 1,nx-1
4842 xfall(ix,jy,ia) = xfall(ix,jy,ia) + a(ix,jgs,kz,ia)*vt(kz,ix)*dtfrac
4849 a(ix,jgs,kz,ia) = a(ix,jgs,kz,ia) + dtp*dtz1(kz,ix,id)*(qtmp1(kz+1) - qtmp1(kz) )
4855 END SUBROUTINE FALLOUT1D
4857 ! ##############################################################################
4858 ! ##############################################################################
4860 subroutine calczgr1d(nx,ny,nz,nor,na,a,ixe,kze, &
4861 & z,db,jgs,ipconc, alpha, l,ln, qmin, xvmn,xvmx, lvol, rho_qx, ixcol)
4866 integer nx,ny,nz,nor,na,ngt,jgs
4868 integer, parameter :: norz = 3
4869 real a(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,na)
4870 real z(-nor+1:nx+nor,-nor+1:nz+nor,lr:lhab) ! reflectivity
4871 real db(nx,nz+1) ! air density
4872 ! real gt(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,ngt)
4879 integer l ! index for q
4880 integer ln ! index for N
4881 integer lvol ! index for volume
4886 real vr,qr,nrx,rd,xv,g1,zx,chw,xdn,ynu
4892 IF ( l .eq. lh .or. l .eq. lhl .or. ( l .eq. lr .and. imurain == 1 ) &
4893 .or. ( l .eq. ls .and. imusnow == 1 ) ) THEN
4900 IF ( a(ix,jy,kz,l) .gt. qmin .and. a(ix,jy,kz,ln) .gt. 1.e-15 ) THEN
4902 IF ( lvol .gt. 1 ) THEN
4903 IF ( a(ix,jy,kz,lvol) .gt. 0.0 ) THEN
4904 xdn = db(ix,kz)*a(ix,jy,kz,l)/a(ix,jy,kz,lvol)
4905 xdn = Min( 900., Max( hdnmn, xdn ) )
4913 IF ( l == lr ) xdn = 1000.
4916 xv = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
4917 chw = a(ix,jy,kz,ln)
4919 IF ( xv .lt. xvmn .or. xv .gt. xvmx ) THEN
4920 xv = Min( xvmx, Max( xvmn,xv ) )
4921 chw = db(ix,kz)*a(ix,jy,kz,l)/(xv*xdn)
4924 g1 = (6.0 + alpha)*(5.0 + alpha)*(4.0 + alpha)/ &
4925 & ((3.0 + alpha)*(2.0 + alpha)*(1.0 + alpha))
4926 zx = g1*db(ix,kz)**2*(a(ix,jy,kz,l))*a(ix,jy,kz,l)/chw
4927 ! z(ix,kz,l) = 1.e18*zx*(6./(pi*1000.))**2
4928 z(ix,kz,l) = zx*(6./(pi*1000.))**2
4931 ! IF ( ny.eq.2 .and. kz .ge. 25 .and. kz .le. 29 .and. z(ix,kz,l) .gt. 0. ) THEN
4932 ! write(*,*) 'calczgr: z,dbz,xdn = ',ix,kz,z(ix,kz,l),10*log10(z(ix,kz,l)),xdn
4943 ELSEIF ( (l == ls .and. imusnow == 3) .or. ( l .eq. lr .and. imurain == 3 ) ) THEN
4945 xdn = rho_qx ! 1000.
4946 IF ( l == ls ) ynu = snu
4947 IF ( l == lr ) ynu = rnu
4951 IF ( a(ix,jy,kz,l) .gt. qmin .and. a(ix,jy,kz,ln) .gt. 1.e-15 ) THEN
4953 vr = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
4954 ! z(ix,kz,l) = 3.6e18*(ynu+2.0)*a(ix,jy,kz,ln)*vr**2/(ynu+1.0)
4955 z(ix,kz,l) = 3.6*(ynu+2.0)*a(ix,jy,kz,ln)*vr**2/(ynu+1.0)
4956 ! qr = a(ix,jy,kz,lr)
4957 ! nrx = a(ix,jy,kz,lnr)
4972 END subroutine calczgr1d
4974 ! ##############################################################################
4975 ! ##############################################################################
4977 ! Subroutine to correct number concentration to prevent reflectivity growth by
4978 ! sedimentation in 2-moment ZXX scheme.
4979 ! Calculation is in a slab (constant jgs)
4982 subroutine calcnfromz1d(nx,ny,nz,nor,na,a,t0,ixe,kze, &
4983 & z0,db,jgs,ipconc, alpha, l,ln, qmin, xvmn,xvmx,t1, &
4984 & lvol, rho_qx, infall, ixcol)
4989 integer nx,ny,nz,nor,na,ngt,jgs,ixcol
4991 real a(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,na) ! sedimented N and q
4992 real t0(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor) ! sedimented reflectivity
4993 real t1(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor) ! sedimented N (by Vm)
4994 ! real gt(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,ngt)
4995 real z0(-nor+1:nx+nor,-nor+1:nz+nor,lr:lhab) ! initial reflectivity
4997 real db(nx,nz+1) ! air density
5004 integer l ! index for q
5005 integer ln ! index for N
5006 integer lvol ! index for volume
5012 double precision vr,qr,nrx,rd,g1,zx,chw,z,znew,zt,zxt
5014 integer :: ndbz, nmwgt, nnwgt, nwlessthanz
5026 IF ( l .eq. lh .or. l .eq. lhl .or. ( l == lr .and. imurain == 1 ) ) THEN
5028 g1 = (6.0 + alpha)*(5.0 + alpha)*(4.0 + alpha)/ &
5029 & ((3.0 + alpha)*(2.0 + alpha)*(1.0 + alpha))
5034 IF ( t0(ix,jy,kz) .gt. 0. ) THEN ! {
5036 IF ( lvol .gt. 1 ) THEN
5037 IF ( a(ix,jy,kz,lvol) .gt. 0.0 ) THEN
5038 xdn = db(ix,kz)*a(ix,jy,kz,l)/a(ix,jy,kz,lvol)
5039 xdn = Min( 900., Max( hdnmn, xdn ) )
5047 IF ( l == lr ) xdn = 1000.
5050 xv = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
5051 chw = a(ix,jy,kz,ln)
5053 IF ( xv .lt. xvmn .or. xv .gt. xvmx ) THEN
5054 xv = Min( xvmx, Max( xvmn,xv ) )
5055 chw = db(ix,kz)*a(ix,jy,kz,l)/(xv*xdn)
5058 zx = g1*db(ix,kz)**2*( a(ix,jy,kz,l))*a(ix,jy,kz,l)/chw
5059 z = zx*(6./(pi*1000.))**2
5062 IF ( (z .gt. t0(ix,jy,kz) .and. z .gt. 0.0 .and. &
5063 & t0(ix,jy,kz) .gt. z0(ix,kz,l) )) THEN !{
5065 zx = t0(ix,jy,kz)/((6./(pi*1000.))**2)
5067 nrx = g1*db(ix,kz)**2*( a(ix,jy,kz,l))*a(ix,jy,kz,l)/zx
5068 IF ( infall .eq. 3 ) THEN
5069 IF ( nrx .gt. a(ix,jy,kz,ln) ) THEN
5071 IF ( t1(ix,jy,kz) .lt. ndbz ) nwlessthanz = nwlessthanz + 1
5075 a(ix,jy,kz,ln) = Max( real(nrx), a(ix,jy,kz,ln) )
5077 IF ( nrx .gt. a(ix,jy,kz,ln) .and. t1(ix,jy,kz) .gt. a(ix,jy,kz,ln) ) THEN
5078 IF ( nrx .lt. t1(ix,jy,kz) ) THEN
5082 IF ( t1(ix,jy,kz) .lt. ndbz ) nwlessthanz = nwlessthanz + 1
5088 a(ix,jy,kz,ln) = Max(Min( real(nrx), t1(ix,jy,kz) ), a(ix,jy,kz,ln) )
5092 IF ( t1(ix,jy,kz) .gt. 0 .and. a(ix,jy,kz,ln) .gt. 0 ) THEN
5093 IF ( t1(ix,jy,kz) .gt. a(ix,jy,kz,ln) ) THEN
5099 a(ix,jy,kz,ln) = Max(t1(ix,jy,kz), a(ix,jy,kz,ln) )
5100 nrx = a(ix,jy,kz,ln)
5108 IF ( t1(ix,jy,kz) .gt. 0 .and. a(ix,jy,kz,ln) .gt. 0 ) THEN
5109 IF ( t1(ix,jy,kz) .gt. a(ix,jy,kz,ln) ) THEN
5120 ELSEIF ( l .eq. lr .and. imurain == 3) THEN
5125 IF ( t0(ix,jy,kz) .gt. 0. ) THEN
5127 vr = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
5128 z = 3.6*(rnu+2.0)*a(ix,jy,kz,ln)*vr**2/(rnu+1.0)
5130 IF ( z .gt. t0(ix,jy,kz) .and. z .gt. 0.0 .and. &
5131 & t0(ix,jy,kz) .gt. 0.0 &
5132 & .and. t0(ix,jy,kz) .gt. z0(ix,kz,l) ) THEN
5134 vr = db(ix,kz)*a(ix,jy,kz,l)/(xdn)
5135 chw = a(ix,jy,kz,ln)
5136 nrx = 3.6*(rnu+2.0)*vr**2/((rnu+1.0)*t0(ix,jy,kz))
5137 IF ( infall .eq. 3 ) THEN
5138 a(ix,jy,kz,ln) = Max( real(nrx), a(ix,jy,kz,ln) )
5139 ELSEIF ( infall .eq. 4 ) THEN
5140 a(ix,jy,kz,ln) = Max( Min( real(nrx), t1(ix,jy,kz)), a(ix,jy,kz,ln) )
5145 a(ix,jy,kz,ln) = Max(t1(ix,jy,kz), a(ix,jy,kz,ln) )
5151 a(ix,jy,kz,ln) = Max(t1(ix,jy,kz), a(ix,jy,kz,ln) )
5162 END subroutine calcnfromz1d
5165 ! ##############################################################################
5166 ! ##############################################################################
5168 ! Subroutine to calculate number concentrations from initial state that has only mixing ratio.
5169 ! Output N will be in #/m^3 in 'an' array, since sedimentation is done next.
5170 ! Output ccw,cci etc. will be in #/kg
5173 ! 10.27.2015: Added hail calculation
5175 subroutine calcnfromq(nx,ny,nz,an,na,nor,norz,dn, &
5176 & qcw,qci,qsw,qrw,qhw,qhl, &
5177 & ccw,cci,csw,crw,chw,chl, &
5178 & cccn,cccna, vhw,vhl,qv,spechum, invertccn_flag, cwmasin )
5184 integer nx,ny,nz,nor,norz,na,ngt,jgs,ixcol
5186 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na) ! scalars (q, N, Z)
5188 real dn(nx,nz+1) ! air density
5190 real, optional, dimension(nx,nz), intent(inout) :: qcw,qci,qsw,qrw,qhw,qhl, &
5191 ccw,cci,csw,crw,chw,chl, &
5192 cccn,cccna,vhw,vhl,qv, spechum
5193 logical, optional, intent(in) :: invertccn_flag
5194 real, optional :: cwmasin
5201 integer lvol ! index for volume
5206 double precision vr,q,nrx,nrx2,rd,g1h,g1hl,g1r,g1s,zx,z,znew,zt,zxt,n1,laminv1
5207 double precision :: zr, zs, zh, dninv
5208 real, parameter :: xn0s = 3.0e6, xn0r = 8.0e6, xn0h = 2.0e5, xn0hl = 4.0e4
5209 real, parameter :: xdnr = 1000., xdns = 100. ,xdnh = 700.0, xdnhl = 900.0
5210 real, parameter :: zhlfac = 1./(pi*xdnhl*xn0hl)
5211 real, parameter :: zhfac = 1./(pi*xdnh*xn0h)
5212 real, parameter :: zrfac = 1./(pi*xdnr*xn0r)
5213 real, parameter :: zsfac = 1./(pi*xdns*xn0s)
5214 real, parameter :: g0 = (6.0)*(5.0)*(4.0)/((3.0)*(2.0)*(1.0))
5215 real, parameter :: xims=900.*0.523599*(2.*50.e-6)**3 ! mks (100 micron diam solid sphere approx)
5216 real, parameter :: xgms=xdnh*0.523599*(300.e-6)**3 ! mks (300 micron diam sphere approx)
5217 real, parameter :: cwmas09 = 1000.*0.523599*(2.*9.e-6)**3 ! mass of 9-micron radius droplet
5219 real xv,xdn,cwmasinv
5220 integer :: ndbz, nmwgt, nnwgt, nwlessthanz
5221 double precision :: mixconv, mixconvqv, qsmax,qsmax2,qsmax3,qsmax4
5222 logical :: invertccn_local
5224 ! ------------------------------------------------------------------
5226 IF ( present( invertccn_flag ) ) THEN
5227 invertccn_local = invertccn_flag
5229 invertccn_local = .false.
5232 IF ( present( cwmasin ) ) THEN
5233 cwmasinv = 1.0/cwmasin
5235 cwmasinv = 1.0/cwmas09
5241 g1h = (6.0 + alphah)*(5.0 + alphah)*(4.0 + alphah)/ &
5242 & ((3.0 + alphah)*(2.0 + alphah)*(1.0 + alphah))
5244 g1hl = (6.0 + alphahl)*(5.0 + alphahl)*(4.0 + alphahl)/ &
5245 & ((3.0 + alphahl)*(2.0 + alphahl)*(1.0 + alphahl))
5247 IF ( imurain == 3 ) THEN
5248 g1r = (rnu+2.0)/(rnu+1.0)
5250 g1r = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/ &
5251 & ((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
5254 g1s = (snu+2.0)/(snu+1.0)
5259 ! IF ( .not. present( qcw ) ) THEN
5261 DO ix = 1,nx ! ixcol
5263 ! qv_mp = spechum/(1.0_kind_phys-spechum)
5264 ! IF ( convertdry ) THEN
5265 ! qc_mp = qc/(1.0_kind_phys-spechum)
5267 IF ( present( spechum ) ) THEN ! convert to "dry" mixing ratios
5268 an(ix,jy,kz,lv) = spechum(ix,kz)/(1.0d0 - spechum(ix,kz))
5269 mixconv = 1.0d0/(1.0d0 - spechum(ix,kz))
5273 IF ( present( qv ) ) an(ix,jy,kz,lv) = qv(ix,kz) ! assume qv is "dry" mixing ratio if passed in
5274 IF ( present( qcw ) ) an(ix,jy,kz,lc) = qcw(ix,kz)*mixconv
5275 IF ( present( qrw ) ) an(ix,jy,kz,lr) = qrw(ix,kz)*mixconv
5276 IF ( present( qci ) ) an(ix,jy,kz,li) = qci(ix,kz)*mixconv
5277 IF ( present( qsw ) ) THEN
5278 an(ix,jy,kz,ls) = qsw(ix,kz)*mixconv
5279 ! qsmax = Max( qsmax, qsw(ix,kz) )
5280 ! qsmax2 = Max( qsmax2, an(ix,jy,kz,ls) )
5282 IF ( present( qhw ) ) an(ix,jy,kz,lh) = qhw(ix,kz)*mixconv
5283 IF ( lhl > 1 .and. present( qhl ) ) an(ix,jy,kz,lhl) = qhl(ix,kz)*mixconv
5284 IF ( present( ccw ) ) an(ix,jy,kz,lnc) = ccw(ix,kz)*mixconv*dn(ix,kz)
5285 IF ( present( crw ) ) an(ix,jy,kz,lnr) = crw(ix,kz)*mixconv*dn(ix,kz)
5286 IF ( present( cci ) ) an(ix,jy,kz,lni) = cci(ix,kz)*mixconv*dn(ix,kz)
5287 IF ( present( csw ) ) an(ix,jy,kz,lns) = csw(ix,kz)*mixconv*dn(ix,kz)
5288 IF ( present( chw ) ) an(ix,jy,kz,lnh) = chw(ix,kz)*mixconv*dn(ix,kz)
5289 IF ( lhl > 1 .and. present( chl ) ) an(ix,jy,kz,lnhl) = chl(ix,kz)*mixconv*dn(ix,kz)
5290 IF ( lvh > 1 .and. present( vhw ) ) an(ix,jy,kz,lvh) = vhw(ix,kz)*mixconv
5291 IF ( lvhl > 1 .and. present( vhl ) ) an(ix,jy,kz,lvhl) = vhl(ix,kz)*mixconv
5292 IF ( lccn > 1 .and. present( cccn ) ) an(ix,jy,kz,lccn) = cccn(ix,kz)*mixconv*dn(ix,kz)
5293 IF ( lccna > 1 .and. present( cccna ) ) an(ix,jy,kz,lccna) = cccna(ix,kz)*mixconv
5295 dninv = 1./dn(ix,kz)
5297 ! IF ( .not. present( qcw ) ) THEN
5301 IF ( an(ix,jy,kz,lnc) <= cxmin .and. an(ix,jy,kz,lc) > qxmin_init(lc) ) THEN
5303 an(ix,jy,kz,lnc) = Min(qccn, an(ix,jy,kz,lc)*cwmasinv )*dn(ix,kz)
5305 IF ( invertccn_local ) THEN
5306 an(ix,jy,kz,lccn) = an(ix,jy,kz,lccn) + an(ix,jy,kz,lnc)
5309 IF ( lccn > 1 .and. lccna < 1 ) THEN
5310 an(ix,jy,kz,lccn) = an(ix,jy,kz,lccn) - an(ix,jy,kz,lnc)
5312 IF ( lccna > 1 ) THEN
5313 an(ix,jy,kz,lccna) = an(ix,jy,kz,lccna) + an(ix,jy,kz,lnc)
5317 ELSEIF ( an(ix,jy,kz,lc) <= qxmin(lc) .or. &
5318 ( an(ix,jy,kz,lnc) <= cxmin .and. an(ix,jy,kz,lc) <= qxmin_init(lc)) ) THEN
5320 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lc)
5321 an(ix,jy,kz,lnc) = 0.0
5322 an(ix,jy,kz,lc) = 0.0
5330 IF ( an(ix,jy,kz,lni) <= cxmin .and. an(ix,jy,kz,li) > qxmin_init(li) ) THEN
5331 an(ix,jy,kz,lni) = dn(ix,kz)*an(ix,jy,kz,li)/xims
5333 ELSEIF ( an(ix,jy,kz,li) <= qxmin(li) .or. &
5334 ( an(ix,jy,kz,lni) <= cxmin .and. an(ix,jy,kz,li) <= qxmin_init(li)) ) THEN
5335 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,li)
5336 an(ix,jy,kz,lni) = 0.0
5337 an(ix,jy,kz,li) = 0.0
5344 IF ( an(ix,jy,kz,lnr) <= 0.1*cxmin .and. an(ix,jy,kz,lr) > qxmin_init(lr) ) THEN
5348 laminv1 = (dn(ix,kz) * q * zrfac)**(0.25) ! inverse of slope
5350 n1 = laminv1*xn0r ! number concentration for inv. exponential single moment input
5352 nrx = n1*g1r/g0 ! number concentration for different shape parameter
5354 an(ix,jy,kz,lnr) = nrx ! *dninv ! convert to number mixing ratio
5356 ELSEIF ( an(ix,jy,kz,lr) <= qxmin(lr) .or. &
5357 ( an(ix,jy,kz,lnr) <= cxmin .and. an(ix,jy,kz,lr) <= qxmin_init(lr)) ) THEN
5358 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lr)
5359 an(ix,jy,kz,lnr) = 0.0
5360 an(ix,jy,kz,lr) = 0.0
5364 IF ( lzr > 1 ) THEN ! set reflectivity moment
5365 IF ( an(ix,jy,kz,lr) > qxmin_init(lr) .and. an(ix,jy,kz,lzr) < zxmin .and. &
5366 an(ix,jy,kz,lnr) > cxmin ) THEN
5368 nrx = an(ix,jy,kz,lnr)
5369 an(ix,jy,kz,lzr) = 36.*g1r*dn(ix,kz)**2*q**2/(pi**2*xdnr**2*nrx) ! *dninv
5375 IF ( an(ix,jy,kz,lns) <= 0.1*cxmin .and. an(ix,jy,kz,ls) > qxmin_init(ls) ) THEN
5379 laminv1 = (dn(ix,kz) * q * zsfac)**(0.25) ! inverse of slope
5381 n1 = laminv1*xn0s ! number concentration for inv. exponential single moment input
5383 nrx = n1*g1s/g0 ! number concentration for different shape parameter
5385 an(ix,jy,kz,lns) = nrx ! *dninv ! convert to number mixing ratio
5387 ELSEIF ( an(ix,jy,kz,ls) <= qxmin(ls) .or. &
5388 ( an(ix,jy,kz,lns) <= cxmin .and. an(ix,jy,kz,ls) <= qxmin_init(ls)) ) THEN
5389 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,ls)
5390 an(ix,jy,kz,lns) = 0.0
5391 an(ix,jy,kz,ls) = 0.0
5399 IF ( an(ix,jy,kz,lnh) <= 0.1*cxmin .and. an(ix,jy,kz,lh) > qxmin_init(lh) ) THEN
5401 IF ( an(ix,jy,kz,lvh) <= 0.0 ) THEN
5402 an(ix,jy,kz,lvh) = an(ix,jy,kz,lh)/xdnh
5408 laminv1 = (dn(ix,kz) * q * zhfac)**(0.25) ! inverse of slope
5410 n1 = laminv1*xn0h ! number concentration for inv. exponential single moment input
5412 nrx = n1*g1h/g0 ! number concentration for different shape parameter
5414 nrx2 = dn(ix,kz) * q / xgms
5416 nrx = Min( nrx, nrx2 )
5418 IF ( nrx > cxmin ) THEN
5419 an(ix,jy,kz,lnh) = nrx ! *dninv ! convert to number mixing ratio
5421 an(ix,jy,kz,lh) = 0.0
5422 an(ix,jy,kz,lnh) = 0.0
5423 an(ix,jy,kz,lvh) = 0.0
5426 ELSEIF ( an(ix,jy,kz,lh) <= qxmin(lh) .or. &
5427 ( an(ix,jy,kz,lnh) <= cxmin .and. an(ix,jy,kz,lh) <= qxmin_init(lh)) ) THEN
5429 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lh)
5430 an(ix,jy,kz,lh) = 0.0
5435 IF ( lzh > 1 ) THEN ! set reflectivity moment
5436 IF ( an(ix,jy,kz,lh) > qxmin_init(lh) .and. an(ix,jy,kz,lzh) < zxmin .and. &
5437 an(ix,jy,kz,lnh) > cxmin ) THEN
5439 nrx = an(ix,jy,kz,lnh)
5440 an(ix,jy,kz,lzh) = 36.*g1h*dn(ix,kz)**2*q**2/(pi**2*xdnh**2*nrx) ! *dninv
5446 IF ( lnhl > 1 .and. lhl > 1 ) THEN
5447 IF ( an(ix,jy,kz,lnhl) <= 0.1*cxmin .and. an(ix,jy,kz,lhl) > qxmin_init(lhl) ) THEN
5448 IF ( lvhl > 1 ) THEN
5449 IF ( an(ix,jy,kz,lvhl) <= 0.0 ) THEN
5450 an(ix,jy,kz,lvhl) = an(ix,jy,kz,lhl)/xdnhl
5454 q = an(ix,jy,kz,lhl)
5456 laminv1 = (dn(ix,kz) * q * zhlfac)**(0.25) ! inverse of slope
5458 n1 = laminv1*xn0hl ! number concentration for inv. exponential single moment input
5460 nrx = n1*g1hl/g0 ! number concentration for different shape parameter
5462 an(ix,jy,kz,lnhl) = nrx ! *dninv ! convert to number mixing ratio
5464 ELSEIF ( an(ix,jy,kz,lhl) <= qxmin(lhl) .or. &
5465 ( an(ix,jy,kz,lnhl) <= cxmin .and. an(ix,jy,kz,lhl) <= qxmin_init(lhl)) ) THEN
5467 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lhl)
5468 an(ix,jy,kz,lhl) = 0.0
5473 IF ( lzhl > 1 ) THEN ! set reflectivity moment
5474 IF ( an(ix,jy,kz,lhl) > qxmin_init(lhl) .and. an(ix,jy,kz,lzhl) < zxmin .and. &
5475 an(ix,jy,kz,lnhl) > cxmin ) THEN
5476 q = an(ix,jy,kz,lhl)
5477 nrx = an(ix,jy,kz,lnhl)
5478 an(ix,jy,kz,lzhl) = 36.*g1hl*dn(ix,kz)**2*q**2/(pi**2*xdnhl**2*nrx) ! *dninv
5485 ! spechum = qv_mp/(1.0_kind_phys+qv_mp)
5486 ! IF ( convertdry ) THEN
5487 ! qc = qc_mp/(1.0_kind_phys+qv_mp)
5489 IF ( present( spechum ) ) THEN ! convert back to "dry+vapor" mixing ratios
5490 !an(ix,jy,kz,lv) = spechum(ix,kz)/(1.0d0 - spechum(ix,kz))
5491 mixconvqv = 1.0d0/(1.0d0 + an(ix,jy,kz,lv))
5492 spechum(ix,kz) = an(ix,jy,kz,lv)*mixconvqv
5497 IF ( present( qv ) ) qv(ix,kz) = an(ix,jy,kz,lv)
5498 IF ( present( qcw ) ) qcw(ix,kz) = an(ix,jy,kz,lc)*mixconvqv
5499 IF ( present( qrw ) ) qrw(ix,kz) = an(ix,jy,kz,lr)*mixconvqv
5500 IF ( present( qci ) ) qci(ix,kz) = an(ix,jy,kz,li)*mixconvqv
5501 IF ( present( qsw ) ) THEN
5502 qsw(ix,kz) = an(ix,jy,kz,ls)*mixconvqv
5503 ! qsmax3 = Max( qsmax3, qsw(ix,kz) )
5504 ! qsmax4 = Max( qsmax4, an(ix,jy,kz,ls) )
5506 IF ( present( qhw ) ) qhw(ix,kz) = an(ix,jy,kz,lh)*mixconvqv
5507 IF ( lhl > 1 .and. present( qhl ) ) qhl(ix,kz) = an(ix,jy,kz,lhl)*mixconvqv
5508 IF ( present( ccw ) ) ccw(ix,kz) = an(ix,jy,kz,lnc)*mixconvqv*dninv
5509 IF ( present( crw ) ) crw(ix,kz) = an(ix,jy,kz,lnr)*mixconvqv*dninv
5510 IF ( present( cci ) ) cci(ix,kz) = an(ix,jy,kz,lni)*mixconvqv*dninv
5511 IF ( present( csw ) ) csw(ix,kz) = an(ix,jy,kz,lns)*mixconvqv*dninv
5512 IF ( present( chw ) ) chw(ix,kz) = an(ix,jy,kz,lnh)*mixconvqv*dninv
5513 IF ( lhl > 1 .and. present( chl ) ) chl(ix,kz) = an(ix,jy,kz,lnhl)*mixconvqv*dninv
5514 IF ( lvh > 1 .and. present( vhw ) ) vhw(ix,kz) = an(ix,jy,kz,lvh)*mixconvqv
5515 IF ( lvhl > 1 .and. present( vhl ) ) vhl(ix,kz) = an(ix,jy,kz,lvhl)*mixconvqv
5516 IF ( lccn > 1 .and. present( cccn ) ) cccn(ix,kz) = an(ix,jy,kz,lccn)*mixconvqv*dninv
5517 IF ( lccna > 1 .and. present( cccna ) ) cccna(ix,kz) = an(ix,jy,kz,lccna)*mixconvqv
5523 ! write(0,*) 'calcnfromq: lv = ',lv,lc,lr,li,ls,lh,lvh,lhl,lccn,lccna
5524 ! write(0,*) 'calcnfromq: nx,ny,nz,na = ',nx,ny,nz,na
5528 ! IF ( present( qsw ) ) THEN
5529 ! write(0,*) 'calcnfromq: qsmax = ',qsmax,qsmax2,qsmax3,qsmax4
5534 END subroutine calcnfromq
5536 ! ##############################################################################
5537 ! ##############################################################################
5539 ! Subroutine to calculate number concentrations from convection parameterization rates that have only mixing ratio.
5540 ! N will be in #/kg, NOT #/m^3, since sedimentation is done next.
5544 ! 10.27.2015: Added hail calculation
5546 subroutine calcnfromcuten(nx,ny,nz,an,anold,na,nor,norz,dn)
5551 integer nx,ny,nz,nor,norz,na,ngt,jgs,ixcol
5553 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na) ! scalars (q, N, Z) from CUTEN arrays
5554 real anold(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na) ! scalars (q, N, Z)
5556 real dn(nx,nz+1) ! air density
5563 integer lvol ! index for volume
5568 double precision vr,q,nrx,rd,g1h,g1hl,g1r,g1s,zx,chw,z,znew,zt,zxt,n1,laminv1
5569 double precision :: zr, zs, zh, dninv
5570 real, parameter :: xn0s = 3.0e6, xn0r = 8.0e6, xn0h = 4.0e4, xn0hl = 4.0e4
5571 real, parameter :: xdnr = 1000., xdns = 100. ,xdnh = 700.0, xdnhl = 900.0
5572 real, parameter :: zhlfac = 1./(pi*xdnhl*xn0hl)
5573 real, parameter :: zhfac = 1./(pi*xdnh*xn0h)
5574 real, parameter :: zrfac = 1./(pi*xdnr*xn0r)
5575 real, parameter :: zsfac = 1./(pi*xdns*xn0s)
5576 real, parameter :: g0 = (6.0)*(5.0)*(4.0)/((3.0)*(2.0)*(1.0))
5577 real, parameter :: xims=900.*0.523599*(2.*50.e-6)**3 ! mks (100 micron diam solid sphere approx)
5578 real, parameter :: xcms=1000.*0.523599*(2.*7.5e-6)**3 ! mks (100 micron diam solid sphere approx)
5580 real :: xmass,xv,xdn
5581 integer :: ndbz, nmwgt, nnwgt, nwlessthanz
5583 ! ------------------------------------------------------------------
5589 g1h = (6.0 + alphah)*(5.0 + alphah)*(4.0 + alphah)/ &
5590 & ((3.0 + alphah)*(2.0 + alphah)*(1.0 + alphah))
5592 g1hl = (6.0 + alphahl)*(5.0 + alphahl)*(4.0 + alphahl)/ &
5593 & ((3.0 + alphahl)*(2.0 + alphahl)*(1.0 + alphahl))
5595 IF ( imurain == 3 ) THEN
5596 g1r = (rnu+2.0)/(rnu+1.0)
5598 g1r = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/ &
5599 & ((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
5602 g1s = (snu+2.0)/(snu+1.0)
5605 DO ix = 1,nx ! ixcol
5607 dninv = 1./dn(ix,kz)
5612 ! IF ( an(ix,jy,kz,lnc) <= 0.1*cxmin .and. an(ix,jy,kz,lc) > qxmin(lc) ) THEN
5613 IF ( an(ix,jy,kz,lnc) > qxmin(lc) ) THEN
5614 anold(ix,jy,kz,lnc) = anold(ix,jy,kz,lnc) + an(ix,jy,kz,lc)/xcms
5621 IF ( an(ix,jy,kz,lni) > qxmin(li) ) THEN
5622 anold(ix,jy,kz,lni) = anold(ix,jy,kz,lni) + an(ix,jy,kz,li)/xims
5629 IF ( an(ix,jy,kz,lr) > qxmin(lr) ) THEN ! adding rain mass from CU scheme
5631 IF ( .true. .or. (anold(ix,jy,kz,lr) - an(ix,jy,kz,lr)) < qxmin(lr) .or. anold(ix,jy,kz,lnr) < cxmin ) THEN
5635 laminv1 = (dn(ix,kz) * q * zrfac)**(0.25) ! inverse of slope
5637 n1 = laminv1*xn0r ! number concentration for inv. exponential single moment input
5639 nrx = n1*g1r/g0 ! number concentration for different shape parameter
5641 anold(ix,jy,kz,lnr) = anold(ix,jy,kz,lnr) + nrx ! *dninv ! convert to number mixing ratio
5644 ! assume mean particle mass of pre-existing snow
5645 xmass = anold(ix,jy,kz,lr)/anold(ix,jy,kz,lnr)
5646 anold(ix,jy,kz,lnr) = anold(ix,jy,kz,lnr) + an(ix,jy,kz,lr)/xmass
5649 IF ( lzr > 1 ) THEN ! set reflectivity moment
5650 an(ix,jy,kz,lzr) = 36.*g1r*dn(ix,kz)**2*q**2/(pi**2*xdnr**2*nrx) ! *dninv
5657 IF ( an(ix,jy,kz,ls) > qxmin(ls) ) THEN ! adding snow mass from CU scheme
5659 IF ( .true. .or. (anold(ix,jy,kz,ls) - an(ix,jy,kz,ls)) < qxmin(ls) .or. anold(ix,jy,kz,lns) < cxmin ) THEN
5661 ! assume that there was no snow before this
5665 laminv1 = (dn(ix,kz) * q * zsfac)**(0.25) ! inverse of slope
5667 n1 = laminv1*xn0s ! number concentration for inv. exponential single moment input
5669 nrx = n1*g1s/g0 ! number concentration for different shape parameter
5671 anold(ix,jy,kz,lns) = anold(ix,jy,kz,lns) + nrx ! *dninv ! convert to number mixing ratio
5674 ! assume mean particle mass of pre-existing snow
5675 xmass = anold(ix,jy,kz,ls)/anold(ix,jy,kz,lns)
5676 anold(ix,jy,kz,lns) = anold(ix,jy,kz,lns) + an(ix,jy,kz,ls)/xmass
5684 ! IF ( lnh > 1 ) THEN
5685 ! IF ( an(ix,jy,kz,lnh) <= 0.1*cxmin .and. an(ix,jy,kz,lh) > qxmin(lh) ) THEN
5686 ! IF ( lvh > 1 ) THEN
5687 ! IF ( an(ix,jy,kz,lvh) <= 0.0 ) THEN
5688 ! an(ix,jy,kz,lvh) = an(ix,jy,kz,lh)/xdnh
5692 ! q = an(ix,jy,kz,lh)
5694 ! laminv1 = (dn(ix,kz) * q * zhfac)**(0.25) ! inverse of slope
5696 ! n1 = laminv1*xn0h ! number concentration for inv. exponential single moment input
5698 ! nrx = n1*g1h/g0 ! number concentration for different shape parameter
5700 ! an(ix,jy,kz,lnh) = nrx ! *dninv ! convert to number mixing ratio
5702 ! IF ( lzh > 1 ) THEN ! set reflectivity moment
5703 ! an(ix,jy,kz,lzh) = 36.*g1h*dn(ix,kz)**2*q**2/(pi**2*xdnh**2*nrx) ! *dninv
5710 ! IF ( lnhl > 1 .and. lhl > 1 ) THEN
5711 ! IF ( an(ix,jy,kz,lnhl) <= 0.1*cxmin .and. an(ix,jy,kz,lhl) > qxmin(lhl) ) THEN
5712 ! IF ( lvhl > 1 ) THEN
5713 ! IF ( an(ix,jy,kz,lvhl) <= 0.0 ) THEN
5714 ! an(ix,jy,kz,lvhl) = an(ix,jy,kz,lhl)/xdnhl
5718 ! q = an(ix,jy,kz,lhl)
5720 ! laminv1 = (dn(ix,kz) * q * zhlfac)**(0.25) ! inverse of slope
5722 ! n1 = laminv1*xn0hl ! number concentration for inv. exponential single moment input
5724 ! nrx = n1*g1hl/g0 ! number concentration for different shape parameter
5726 ! an(ix,jy,kz,lnhl) = nrx ! *dninv ! convert to number mixing ratio
5728 ! IF ( lzhl > 1 ) THEN ! set reflectivity moment
5729 ! an(ix,jy,kz,lzhl) = 36.*g1hl*dn(ix,kz)**2*q**2/(pi**2*xdnhl**2*nrx) ! *dninv
5739 END subroutine calcnfromcuten
5741 ! #####################################################################
5742 ! #####################################################################
5744 SUBROUTINE calc_eff_radius &
5745 & (nx,ny,nz,na,jyslab &
5747 & ,t1,t2,t3,t4,t5,t6, f_t4, f_t5,f_t6 &
5748 & ,qcw,qci,qsw,qrw &
5749 & ,ccw,cci,csw,crw &
5754 integer, parameter :: ng1 = 1
5755 integer :: nx,ny,nz,na
5757 integer :: nor,norz, jyslab ! ,nht,ngt,igsr
5758 real :: dtp ! time step
5762 ! external temporary arrays
5765 real,optional :: t1(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5766 real,optional :: t2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5767 real,optional :: t3(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5768 real,optional :: t4(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5769 real,optional :: t5(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5770 real,optional :: t6(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5771 logical, optional :: f_t4, f_t5, f_t6 ! flags to fill t4/t5/t6 for rain/graupel/hail
5773 real, optional :: an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
5774 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5775 real, optional, dimension(nx,nz) :: qcw,qci,qsw,qrw,ccw,cci,csw,crw
5780 real pb(-norz+ng1:nz+norz)
5781 real pinit(-norz+ng1:nz+norz)
5784 ! declarations microphysics and for gather/scatter
5786 integer nxmpb,nzmpb,nxz
5787 integer mgs,ngs,numgs,inumgs
5789 integer ngscnt,igs(ngs),kgs(ngs)
5792 integer ix,kz,i,n, kp1
5794 integer ixb,ixe,jyb,jye,kzb,kze
5796 integer itile,jtile,ktile
5797 integer ixend,jyend,kzend,kzbeg
5798 integer nxend,nyend,nzend,nzbeg
5800 real :: qx(ngs,lv:lhab)
5801 real :: cx(ngs,lc:lhab)
5802 real :: xv(ngs,lc:lhab)
5803 real :: xmas(ngs,lc:lhab)
5804 real :: xdn(ngs,lc:lhab)
5805 real :: xdia(ngs,lc:lhab,3)
5806 real :: alpha(ngs,lc:lhab)
5808 real :: gamc1,gamc2,gami1,gami2,gams1,gams2, factor_c, factor_i, factor_s
5809 real :: lam_c, lam_i, lam_s, lam_r, lam_h, lam_hl
5810 real :: gamr1,gamr2,gamh1,gamh2,factor_r,factor_h,factor_hl
5813 double precision :: numh, numhl,denomh,denomhl
5815 logical :: flag_t4, flag_t5, flag_t6
5818 ! -------------------------------------------------------------------------------
5835 IF ( present(f_t4) ) THEN
5836 IF ( present(f_t4) ) THEN
5841 IF ( present(f_t5) ) THEN
5842 IF ( present(f_t5) ) THEN
5847 IF ( present(f_t6) ) THEN
5848 IF ( present(f_t6) ) THEN
5857 gamc1 = Gamma_sp(2. + cnu)
5858 gamc2 = 1. ! Gamma[1 + alphac]
5859 gami1 = Gamma_sp(2. + cinu)
5860 gami2 = 1. ! Gamma[1 + alphac]
5861 gams1 = Gamma_sp(2. + snu)
5862 gams2 = Gamma_sp(1. + snu)
5863 gamr1 = Gamma_sp(2. + rnu)
5864 gamr2 = Gamma_sp(1. + rnu)
5866 factor_c = (1. + cnu)*Gamma_sp(1. + cnu)/Gamma_sp(5./3. + cnu)
5867 factor_i = (1. + cinu)*Gamma_sp(1. + cinu)/Gamma_sp(5./3. + cinu)
5868 factor_s = (1. + snu)*Gamma_sp(1. + snu)/Gamma_sp(5./3. + snu)
5870 IF ( present(t4) ) THEN
5871 IF ( imurain == 3 ) THEN
5872 factor_r = (1. + rnu)*Gamma_sp(1. + rnu)/Gamma_sp(5./3. + rnu)
5874 factor_r = ((Pi*(alphar+3.)*(alphar+1.)*(alphar+1.))/6.)**(1./3.)
5878 factor_h = ((Pi*(alphah+3.)*(alphah+1.)*(alphah+1.))/6.)**(1./3.)
5879 factor_hl = ((Pi*(alphahl+3.)*(alphahl+1.)*(alphahl+1.))/6.)**(1./3.)
5882 ! jy = 1 ! working on a 2d slab
5883 !! VERY IMPORTANT: SET jgs = jy
5889 DO ix = 1,nx ! ixcol
5891 rho0(mgs) = dn(ix,jy,kz)
5892 IF ( present( an ) ) THEN
5894 qx(mgs,il) = max(an(ix,jy,kz,il), 0.0)
5895 cx(mgs,il) = max(an(ix,jy,kz,ln(il)), 0.0)
5900 IF ( present(qcw) ) qx(mgs,lc) = qcw(ix,kz)
5901 IF ( present(qci) ) qx(mgs,li) = qci(ix,kz)
5902 IF ( present(qsw) ) qx(mgs,ls) = qsw(ix,kz)
5903 IF ( present(qrw) ) qx(mgs,lr) = qrw(ix,kz)
5904 IF ( present(ccw) ) cx(mgs,lc) = ccw(ix,kz)*rho0(mgs)
5905 IF ( present(cci) ) cx(mgs,li) = cci(ix,kz)*rho0(mgs)
5906 IF ( present(csw) ) cx(mgs,ls) = csw(ix,kz)*rho0(mgs)
5907 IF ( present(crw) ) cx(mgs,lr) = crw(ix,kz)*rho0(mgs)
5911 IF ( present( t1 ) .and. qx(mgs,lc) > qxmin(lc) .and. cx(mgs,lc) > cxmin ) THEN
5912 ! Lambda for cloud droplets
5913 lam_c = ((cx(mgs,lc)*(Pi/6.)*xdn0(lc)*Gamc1)/(qx(mgs,lc)*rho0(mgs)*Gamc2))**(1./3.)
5914 t1(ix,jy,kz) = 0.5*factor_c/lam_c
5917 IF ( present( t2 ) .and. qx(mgs,li) > qxmin(li) .and. cx(mgs,li) > cxmin ) THEN
5918 ! Lambda for cloud ice
5919 lam_i = ((cx(mgs,li)*(Pi/6.)*xdn0(li)*Gami1)/(qx(mgs,li)*rho0(mgs)*Gami2))**(1./3.)
5920 t2(ix,jy,kz) = 0.5*factor_i/lam_i
5923 IF ( present( t3 ) .and. qx(mgs,ls) > qxmin(ls) .and. cx(mgs,ls) > cxmin ) THEN
5925 lam_s = ((cx(mgs,ls)*(Pi/6.)*xdn0(ls)*Gams1)/(qx(mgs,ls)*rho0(mgs)*Gams2))**(1./3.)
5926 t3(ix,jy,kz) = 0.5*factor_s/lam_s
5929 IF ( present( t4 ) .and.( ( present(qrw) .and. present(crw) ) .or. flag_t4 ) ) THEN
5930 IF ( qx(mgs,lr) > Max(1.e-8,qxmin(lr)) .and. cx(mgs,lr) > cxmin ) THEN
5931 IF ( imurain == 1 ) THEN ! gamma-diameter
5933 lam_r = factor_r *((xdn0(lr)*cx(mgs,lr))/(qx(mgs,lr)*rho0(mgs)))**(1./3.)
5934 t4(ix,jy,kz) = 0.5*(alphar+3.)/lam_r
5937 lam_r = ((cx(mgs,lr)*(Pi/6.)*xdn0(lr)*Gamr1)/(qx(mgs,lr)*rho0(mgs)*Gamr2))**(1./3.)
5938 t4(ix,jy,kz) = 0.5*factor_r/lam_r
5943 IF ( present(t5) .and. flag_t5 ) THEN
5945 ! first: case when hail is off
5947 IF ( lhl < 1 .or. flag_t6 ) THEN
5949 IF ( qx(mgs,lh) > Max(1.e-8,qxmin(lh)) ) THEN
5950 ! Lambda for graupel
5952 IF ( lvh > 1 ) THEN ! variable density
5953 IF ( an(ix,jy,kz,lvh) > 1.e-30 ) THEN
5954 hwdn = rho0(mgs)*qx(mgs,lh)/an(ix,jy,kz,lvh)
5958 lam_h = factor_h *((hwdn*cx(mgs,lh))/(qx(mgs,lh)*rho0(mgs)))**(1./3.)
5959 t5(ix,jy,kz) = 0.5*(alphah+3.)/lam_h
5962 ELSE ! have hail, too, but do not have t6 array
5964 IF ( qx(mgs,lh) > Max(1.e-8,qxmin(lh)) .and. qx(mgs,lhl) < Max(1.e-8,qxmin(lhl)) ) THEN
5965 ! Lambda for graupel
5967 IF ( lvh > 1 ) THEN ! variable density
5968 IF ( an(ix,jy,kz,lvh) > 1.e-30 ) THEN
5969 hwdn = rho0(mgs)*qx(mgs,lh)/an(ix,jy,kz,lvh)
5973 lam_h = factor_h *((hwdn*cx(mgs,lh))/(qx(mgs,lh)*rho0(mgs)))**(1./3.)
5974 t5(ix,jy,kz) = 0.5*(alphah+3.)/lam_h
5976 ELSEIF ( qx(mgs,lh) < Max(1.e-8,qxmin(lh)) .and. qx(mgs,lhl) > Max(1.e-8,qxmin(lhl)) ) THEN
5979 IF ( lvhl > 1 ) THEN ! variable density
5980 IF ( an(ix,jy,kz,lvhl) > 1.e-30 ) THEN
5981 hldn = rho0(mgs)*qx(mgs,lhl)/an(ix,jy,kz,lvhl)
5985 lam_hl = factor_hl *((hldn*cx(mgs,lhl))/(qx(mgs,lhl)*rho0(mgs)))**(1./3.)
5986 t5(ix,jy,kz) = 0.5*(alphahl+3.)/lam_hl
5988 ELSEIF ( qx(mgs,lh) > Max(1.e-8,qxmin(lh)) .and. qx(mgs,lhl) > Max(1.e-8,qxmin(lhl)) ) THEN
5989 ! r_eff graupel and hail combined
5992 IF ( lvhl > 1 ) THEN ! variable density
5993 IF ( an(ix,jy,kz,lvhl) > 1.e-30 ) THEN
5994 hldn = rho0(mgs)*qx(mgs,lhl)/an(ix,jy,kz,lvhl)
5999 IF ( lvh > 1 ) THEN ! variable density
6000 IF ( an(ix,jy,kz,lvh) > 1.e-30 ) THEN
6001 hwdn = rho0(mgs)*qx(mgs,lh)/an(ix,jy,kz,lvh)
6005 lam_h = factor_h *((hwdn*cx(mgs,lh))/(qx(mgs,lh)*rho0(mgs)))**(1./3.)
6006 lam_hl = factor_hl *((hldn*cx(mgs,lhl))/(qx(mgs,lhl)*rho0(mgs)))**(1./3.)
6008 numh = cx(mgs,lh)*(alphah+3.)*(alphah+2.)*(alphah+1.)/lam_h**3
6009 numhl = cx(mgs,lhl)*(alphahl+3.)*(alphahl+2.)*(alphahl+1.)/lam_hl**3
6011 denomh = cx(mgs,lh)*(alphah+2.)*(alphah+1.)/lam_h**2
6012 denomhl = cx(mgs,lhl)*(alphahl+2.)*(alphahl+1.)/lam_hl**2
6014 t5(ix,jy,kz) = 0.5*(numh + numhl)/(denomh + denomhl)
6023 IF ( present(t6) .and. flag_t6 .and. lhl > 1 ) THEN
6025 IF ( qx(mgs,lhl) > Max(1.e-8,qxmin(lhl)) ) THEN
6028 IF ( lvhl > 1 ) THEN ! variable density
6029 IF ( an(ix,jy,kz,lvhl) > 1.e-30 ) THEN
6030 hldn = rho0(mgs)*qx(mgs,lhl)/an(ix,jy,kz,lvhl)
6034 lam_hl = factor_hl *((hldn*cx(mgs,lhl))/(qx(mgs,lhl)*rho0(mgs)))**(1./3.)
6035 t6(ix,jy,kz) = 0.5*(alphahl+3.)/lam_hl
6046 END SUBROUTINE calc_eff_radius
6049 ! #####################################################################
6050 ! #####################################################################
6052 SUBROUTINE QVEXCESS(ngs,mgs,qwvp0,qv0,qcw1,pres,thetap0,theta0, &
6053 & qvex,pi0,tabqvs,nqsat,fqsat,cbw,fcqv1,felvcp,ss1,pk,ngscnt)
6055 !#####################################################################
6056 ! Purpose: find the amount of vapor that can be condensed to liquid
6057 !#####################################################################
6061 integer ngs,mgs,ngscnt
6070 real ss1 ! 'target' supersaturation
6074 real qv0(ngs), qcw1(ngscnt), pres(ngs), qwvp0(mgs)
6075 real thetap0(ngs), theta0(ngs)
6076 real fcqv1(ngs), felvcp(ngs), pi0(ngs)
6087 real theta(ngs), qvap(ngs), pqs(ngs), qcw(ngs), qwv(ngs)
6088 real qcwtmp(ngs), qss(ngs), qvs(ngs), qwvp(ngs)
6089 real dqcw(ngs), dqwv(ngs), dqvcnd(ngs)
6090 real temg(ngs), temcg(ngs), thetap(ngs)
6093 parameter ( tfr = 273.15 )
6096 ! parameter ( cap = rd/cp, poo = 1.0e+05 )
6099 ! Modified Straka adjustment (nearly identical to Tao et al. 1989 MWR)
6103 ! set up temperature and vapor arrays
6105 pqs(mgs) = (380.0)/(pres(mgs))
6106 thetap(mgs) = thetap0(mgs)
6107 theta(mgs) = thetap(mgs) + theta0(mgs)
6108 qwvp(mgs) = qwvp0(mgs)
6109 qvap(mgs) = max( (qwvp0(mgs) + qv0(mgs)), 0.0 )
6110 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
6111 ! temg(mgs) = theta2temp( theta(mgs), pres(mgs) )
6115 ! reset temporaries for cloud particles and vapor
6118 qwv(mgs) = max( 0.0, qvap(mgs) )
6119 qcw(mgs) = max( 0.0, qcw1(mgs) )
6122 qcwtmp(mgs) = qcw(mgs)
6123 temcg(mgs) = temg(mgs) - tfr
6124 ltemq = (temg(mgs)-163.15)/fqsat+1.5
6125 ltemq = Min( nqsat, Max(1,ltemq) )
6127 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
6128 qss(mgs) = (0.01*ss1 + 1.0)*qvs(mgs)
6130 ! iterate adjustment
6135 ! calculate super-saturation
6138 dqwv(mgs) = ( qwv(mgs) - qss(mgs) )
6140 ! evaporation and sublimation adjustment
6142 if( dqwv(mgs) .lt. 0. ) then ! subsaturated
6143 if( qcw(mgs) .gt. -dqwv(mgs) ) then ! check if qc can make up all of the deficit
6144 dqcw(mgs) = dqwv(mgs)
6146 else ! otherwise make all qc available for evap
6147 dqcw(mgs) = -qcw(mgs)
6148 dqwv(mgs) = dqwv(mgs) + qcw(mgs)
6151 qwvp(mgs) = qwvp(mgs) - ( dqcw(mgs) ) ! add to perturbation vapor
6153 qcw(mgs) = qcw(mgs) + dqcw(mgs)
6155 thetap(mgs) = thetap(mgs) + &
6157 & (felvcp(mgs)*dqcw(mgs) )
6159 end if ! dqwv(mgs) .lt. 0. (end of evap/sublim)
6161 ! condensation/deposition
6163 IF ( dqwv(mgs) .ge. 0. ) THEN
6165 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qss(mgs)/ &
6166 & ((temg(mgs)-cbw)**2))
6169 dqcw(mgs) = dqvcnd(mgs)
6171 thetap(mgs) = thetap(mgs) + &
6172 & (felvcp(mgs)*dqcw(mgs) ) &
6174 qwvp(mgs) = qwvp(mgs) - ( dqvcnd(mgs) )
6175 qcw(mgs) = qcw(mgs) + dqcw(mgs)
6177 END IF ! dqwv(mgs) .ge. 0.
6179 theta(mgs) = thetap(mgs) + theta0(mgs)
6180 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
6181 ! temg(mgs) = theta2temp( theta(mgs), pres(mgs) )
6182 qvap(mgs) = Max((qwvp(mgs) + qv0(mgs)), 0.0)
6183 temcg(mgs) = temg(mgs) - tfr
6184 ! tqvcon = temg(mgs)-cbw
6185 ltemq = (temg(mgs)-163.15)/fqsat+1.5
6186 ltemq = Min( nqsat, Max(1,ltemq) )
6187 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
6188 qcw(mgs) = max( 0.0, qcw(mgs) )
6189 qwv(mgs) = max( 0.0, qvap(mgs))
6190 qss(mgs) = (0.01*ss1 + 1.0)*qvs(mgs)
6193 ! end the saturation adjustment iteration loop
6196 qvex = Max(0.0, qcw(mgs) - qcw1(mgs) )
6199 END SUBROUTINE QVEXCESS
6201 ! #####################################################################
6202 ! #####################################################################
6209 ! ##############################################################################
6211 SUBROUTINE setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno,cnostmp, &
6212 & xmas,vtxbar,xdn,xvmn0,xvmx0,xv,cdx,cdxgs, &
6213 & ipconc1,ndebug1,ngs,nz,kgs,fadvisc, &
6214 & cwmasn,cwmasx,cwradn,cnina,cimna,cimxa, &
6215 & itype1a,itype2a,temcg,infdo,alpha,ildo,axx,bxx)
6216 ! & itype1a,itype2a,temcg,infdo,alpha,ildo,axh,bxh,axhl,bxhl)
6221 integer ngscnt,ngs0,ngs,nz
6222 ! integer infall ! whether to calculate number-weighted fall speeds
6224 real xv(ngs,lc:lhab)
6225 real qx(ngs,lv:lhab)
6226 real qxw(ngs,ls:lhab)
6227 real cx(ngs,lc:lhab)
6228 real vtxbar(ngs,lc:lhab,3)
6229 real xmas(ngs,lc:lhab)
6230 real xdn(ngs,lc:lhab)
6231 real cdxgs(ngs,lc:lhab)
6232 real xdia(ngs,lc:lhab,3)
6233 real xvmn0(lc:lhab), xvmx0(lc:lhab)
6236 real alpha(ngs,lc:lhab)
6238 real rho0(ngs),rhovt(ngs),temcg(ngs)
6242 real cwc1, cimna, cimxa
6251 integer, intent (in) :: itype1a,itype2a,infdo
6252 integer, intent (in) :: ildo ! which species to do, or all if ildo=0
6254 real :: axx(ngs,lh:lhab),bxx(ngs,lh:lhab)
6255 !! real :: axh(ngs),bxh(ngs)
6256 ! real :: axhl(ngs),bxhl(ngs)
6265 real :: cwch(ngscnt), cwchl(ngscnt)
6266 real :: cwchtmp,cwchltmp,xnutmp
6269 real cwmasn,cwmasx,cwradn
6278 real arx,frx,vtrain,fw
6279 real fwlo,fwhi,rfwdiff
6281 ! real gf4p5, gf4ds, gf4br, ifirst, gf1ds
6282 ! real gfcinu1, gfcinu1p47, gfcinu2p47
6288 ! save gf4p5, gf4ds, gf4br, ifirst, gf1ds
6289 ! save gfcinu1, gfcinu1p47, gfcinu2p47
6293 parameter ( bta1 = 0.6, cnit = 1.0e-02 )
6298 real, parameter :: rho00 = 1.225
6308 ! cwmasn = 5.23e-13 ! radius of 5.0e-6
6310 ! cwmasx = 5.25e-10 ! radius of 50.0e-6
6312 fwlo = 0.2 ! water fraction to start weighting toward rain fall speed
6313 fwhi = 0.4 ! water fraction at which rain fall speed only is used
6314 rfwdiff = 1./(fwhi - fwlo)
6316 ! pi = 4.0*atan(1.0)
6317 pii = piinv ! 1.0/pi
6320 frx = 516.575 ! raind fit parameters for arx*(1 - Exp(-fx*d)), where d is rain diameter in meters.
6325 ! new values for cs and ds
6329 IF ( ildo == 0 ) THEN
6337 ! IF ( ifirst .eq. 0 ) THEN
6339 ! gf4br = gamma(4.0+br)
6340 ! gf4ds = gamma(4.0+ds)
6341 !! gf1ds = gamma(1.0+ds)
6342 ! gf4p5 = gamma(4.0+0.5)
6343 ! gfcinu1 = gamma(cinu + 1.0)
6344 ! gfcinu1p47 = gamma(cinu + 1.47167)
6345 ! gfcinu2p47 = gamma(cinu + 2.47167)
6347 IF ( lh .gt. 1 ) THEN
6348 IF ( dmuh == 1.0 ) THEN
6349 cwchtmp = ((3. + dnu(lh))*(2. + dnu(lh))*(1.0 + dnu(lh)))**(-1./3.)
6351 cwchtmp = 6.0*pii*gamma_sp( (xnu(lh) + 1.)/xmu(lh) )/gamma_sp( (xnu(lh) + 2.)/xmu(lh) )
6354 IF ( lhl .gt. 1 ) THEN
6355 IF ( dmuhl == 1.0 ) THEN
6356 cwchltmp = ((3. + dnu(lhl))*(2. + dnu(lhl))*(1.0 + dnu(lhl)))**(-1./3.)
6358 cwchltmp = 6.0*pii*gamma_sp( (xnu(lhl) + 1)/xmu(lhl) )/gamma_sp( (xnu(lhl) + 2)/xmu(lhl) )
6362 IF ( ipconc .le. 5 ) THEN
6363 IF ( lh .gt. 1 ) cwch(:) = cwchtmp
6364 IF ( lhl .gt. 1 ) cwchl(:) = cwchltmp
6368 IF ( lh .gt. 1 .and. ( ildo == 0 .or. ildo == lh ) ) THEN
6369 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
6370 IF ( dmuh == 1.0 ) THEN
6371 cwch(mgs) = ((3. + alpha(mgs,lh))*(2. + alpha(mgs,lh))*(1.0 + alpha(mgs,lh)))**(-1./3.)
6373 xnutmp = (alpha(mgs,lh) - 2.0)/3.0
6374 cwch(mgs) = 6.0*pii*gamma_sp( (xnutmp + 1.)/xmu(lh) )/gamma_sp( (xnutmp + 2.)/xmu(lh) )
6380 IF ( lhl .gt. 1 .and. ( ildo == 0 .or. ildo == lhl ) ) THEN
6381 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
6382 IF ( dmuhl == 1.0 ) THEN
6383 cwchl(mgs) = ((3. + alpha(mgs,lhl))*(2. + alpha(mgs,lhl))*(1.0 + alpha(mgs,lhl)))**(-1./3.)
6385 xnutmp = (alpha(mgs,lhl) - 2.0)/3.0
6386 cwchl(mgs) = 6.0*pii*gamma_sp( (xnutmp + 1)/xmu(lhl) )/gamma_sp( (xnutmp + 2)/xmu(lhl) )
6389 cwchl(mgs) = cwchltmp
6398 cimasn = Min( cimas0, 6.88e-13)
6400 ccimx = 5000.0e3 ! max of 5000 per liter
6402 cwc1 = 6.0/(pi*1000.)
6403 cwc0 = pii ! 6.0*pii
6404 mwfac = 6.0**(1./3.)
6407 if (ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set scale diameter'
6412 ! cloud water variables
6413 ! ################################################################
6418 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set cloud water variables'
6420 IF ( ildo == 0 .or. ildo == lc ) THEN
6425 IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN !{
6427 IF ( ipconc .ge. 2 ) THEN
6428 IF ( cx(mgs,lc) .gt. cxmin) THEN !{
6430 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
6431 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6433 cx(mgs,lc) = Max( cxmin, rho0(mgs)*qx(mgs,lc)/cwmasx )
6434 xmas(mgs,lc) = Min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
6435 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6439 IF ( ipconc .lt. 2 ) THEN
6440 cx(mgs,lc) = rho0(mgs)*ccn/rho00 ! scales to local density, relative to standard air density
6442 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. 0.01 ) THEN !{
6444 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),xdn(mgs,lc)*xvmn(lc)), &
6445 & xdn(mgs,lc)*xvmx(lc) )
6447 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6448 cx(mgs,lc) = qx(mgs,lc)*rho0(mgs)/xmas(mgs,lc)
6450 ELSEIF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .le. 1.0e-9 ) THEN
6451 cx(mgs,lc) = Max( cxmin, rho0(mgs)*qx(mgs,lc)/cwmasx )
6453 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
6454 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6456 ELSEIF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .le. 0.01 ) THEN
6457 xmas(mgs,lc) = xdn(mgs,lc)*4.*pi/3.*(5.0e-6)**3
6458 cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc)
6459 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6462 xmas(mgs,lc) = cwmasn
6463 xv(mgs,lc) = xmas(mgs,lc)/1000.
6464 ! do not define ccw here! it can feed back to ccn!!! cx(mgs,lc) = 0.0 ! cwnc(mgs)
6467 ! IF ( ipconc .lt. 2 ) THEN
6469 ! & min( max(qx(mgs,lc)*rho0(mgs)/cwnc(mgs),cwmasn),cwmasx )
6470 ! cx(mgs,lc) = Max(1.0,qx(mgs,lc)*rho0(mgs)/xmas(mgs,lc))
6472 ! cwnc(mgs) = an(igs(mgs),jgs,kgs(mgs),lnc)
6473 ! cx(mgs,lc) = cwnc(mgs)
6475 xdia(mgs,lc,1) = (xmas(mgs,lc)*cwc1)**(1./3.)
6476 xdia(mgs,lc,2) = xdia(mgs,lc,1)**2
6477 xdia(mgs,lc,3) = xdia(mgs,lc,1)
6478 cwrad = 0.5*xdia(mgs,lc,1)
6479 IF ( fadvisc(mgs) > 0.0 ) THEN
6480 vtxbar(mgs,lc,1) = &
6481 & (2.0*gr*xdn(mgs,lc) *(cwrad**2)) &
6482 & /(9.0*fadvisc(mgs))
6484 vtxbar(mgs,lc,1) = 0.0
6489 xmas(mgs,lc) = cwmasn
6490 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6491 IF ( qx(mgs,lc) <= 0.0 ) cx(mgs,lc) = 0.0
6492 IF ( ipconc .le. 1 ) cx(mgs,lc) = 0.01
6493 xdia(mgs,lc,1) = 2.*cwradn
6494 xdia(mgs,lc,2) = 4.*cwradn**2
6495 xdia(mgs,lc,3) = xdia(mgs,lc,1)
6496 vtxbar(mgs,lc,1) = 0.0
6498 ENDIF !} qcw .gt. qxmin(lc)
6507 ! cloud ice variables
6510 ! ################################################################
6514 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set cip'
6516 IF ( li .gt. 1 .and. ( ildo == 0 .or. ildo == li ) ) THEN
6519 IF ( ipconc .eq. 0 ) THEN
6520 ! cx(mgs,li) = min(cnit*exp(-temcg(mgs)*bta1),1.e+09)
6521 cx(mgs,li) = cnina(mgs)
6522 IF ( cimna .gt. 1.0 ) THEN
6523 cx(mgs,li) = Max(cimna,cx(mgs,li))
6525 IF ( cimxa .gt. 1.0 ) THEN
6526 cx(mgs,li) = Min(cimxa,cx(mgs,li))
6529 IF ( itype1a .ge. 1 .or. itype2a .ge. 1 ) THEN
6530 cx(mgs,li) = Max(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasx)
6531 cx(mgs,li) = Min(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasn)
6534 cx(mgs,li) = max(1.0e-20,cx(mgs,li))
6535 ! cx(mgs,li) = Min(ccimx, cx(mgs,li))
6538 ELSEIF ( ipconc .ge. 1 ) THEN
6539 IF ( qx(mgs,li) .gt. qxmin(li) ) THEN
6540 cx(mgs,li) = Max(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasx)
6541 cx(mgs,li) = Min(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasn)
6542 ! cx(mgs,li) = Max(1.0,cx(mgs,li))
6546 IF ( qx(mgs,li) .gt. qxmin(li) ) THEN
6548 & max( qx(mgs,li)*rho0(mgs)/cx(mgs,li), cimasn )
6549 ! & min( max(qx(mgs,li)*rho0(mgs)/cx(mgs,li),cimasn),cimasx )
6551 ! if ( temcg(mgs) .gt. 0.0 ) then
6552 ! xdia(mgs,li,1) = 0.0
6554 if ( xmas(mgs,li) .gt. 0.0 ) THEN ! cimasn ) then
6555 !c xdia(mgs,li,1) = 0.4892*(xmas(mgs,li)**(0.4554))
6556 ! xdia(mgs,li,1) = 0.1871*(xmas(mgs,li)**(0.3429))
6558 ! xdia(mgs,li,1) = (132.694*5.40662/xmas(mgs,li))**(-1./2.9163) ! for inverse exponential distribution
6559 IF ( ixtaltype == 1 ) THEN ! column
6560 xdia(mgs,li,1) = 0.1871*(xmas(mgs,li)**(0.3429))
6561 xdia(mgs,li,3) = 0.1871*(xmas(mgs,li)**(0.3429))
6562 ELSEIF ( ixtaltype == 2 ) THEN ! disk
6563 xdia(mgs,li,1) = 0.277823*xmas(mgs,li)**0.359971
6564 xdia(mgs,li,3) = 0.277823*xmas(mgs,li)**0.359971
6568 ! xdia(mgs,li,1) = max(xdia(mgs,li,1), 5.e-6)
6569 ! xdia(mgs,li,1) = min(xdia(mgs,li,1), 1000.e-6)
6571 IF ( ipconc .ge. 0 ) THEN
6572 ! vtxbar(mgs,li,1) = rhovt(mgs)*49420.*40.0005/5.40662*xdia(mgs,li,1)**(1.415) ! mass-weighted
6573 ! vtxbar(mgs,li,1) = (4.942e4)*(xdia(mgs,li,1)**(1.4150))
6574 xv(mgs,li) = xmas(mgs,li)/xdn(mgs,li)
6575 IF ( icefallopt == 1 ) THEN ! default ice fall
6576 IF ( ixtaltype == 1 ) THEN ! column
6577 tmp = (67056.6300748612*rhovt(mgs))/ &
6578 & (((1.0 + cinu)/xv(mgs,li))**0.4716666666666667*gfcinu1)
6579 vtxbar(mgs,li,2) = tmp*gfcinu1p47
6580 vtxbar(mgs,li,1) = tmp*gfcinu2p47/(1. + cinu)
6581 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
6582 ELSEIF ( ixtaltype == 2 ) THEN ! disk -- but just use Ferrier (1994) snow fall speeds for now
6583 vtxbar(mgs,li,1) = 11.9495*rhovt(mgs)*(xv(mgs,li))**(0.14)
6584 vtxbar(mgs,li,2) = 7.02909*rhovt(mgs)*(xv(mgs,li))**(0.14)
6585 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
6589 ELSEIF ( icefallopt == 2 ) THEN ! ! Ferrier ice fall speed
6590 tmp = (82.3166*rhovt(mgs))/ &
6591 & (((1.0 + cinu)/xv(mgs,li))**0.22117*gfcinu1)
6592 vtxbar(mgs,li,2) = tmp*gfcinu1p22
6593 vtxbar(mgs,li,1) = tmp*gfcinu2p22/(1. + cinu)
6594 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
6596 ELSEIF ( icefallopt == 3 ) THEN ! ! Adjusted Ferrier (smaller exponent of 0.55 instead of 0.6635)
6598 tmp = (47.6273*rhovt(mgs))/ &
6599 & (((1.0 + cinu)/xv(mgs,li))**0.18333*gfcinu1)
6600 vtxbar(mgs,li,2) = tmp*gfcinu1p18
6601 vtxbar(mgs,li,1) = tmp*gfcinu2p18/(1. + cinu)
6602 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
6605 ! vtxbar(mgs,li,1) = vtxbar(mgs,li,2)*(1.+cinu)/(1. + cinu)
6606 ! xdn(mgs,li) = min(max(769.8*xdia(mgs,li,1)**(-0.0140),300.0),900.0)
6607 ! xdn(mgs,li) = 900.0
6608 xdia(mgs,li,2) = xdia(mgs,li,1)**2
6609 ! vtxbar(mgs,li,1) = vtxbar(mgs,li,1)*rhovt(mgs)
6611 xdia(mgs,li,1) = max(xdia(mgs,li,1), 10.e-6)
6612 xdia(mgs,li,1) = min(xdia(mgs,li,1), 1000.e-6)
6613 vtxbar(mgs,li,1) = (4.942e4)*(xdia(mgs,li,1)**(1.4150))
6614 ! xdn(mgs,li) = min(max(769.8*xdia(mgs,li,1)**(-0.0140),300.0),900.0)
6616 xdia(mgs,li,2) = xdia(mgs,li,1)**2
6617 vtxbar(mgs,li,1) = vtxbar(mgs,li,1)*rhovt(mgs)
6618 xv(mgs,li) = xmas(mgs,li)/xdn(mgs,li)
6621 xmas(mgs,li) = 1.e-13
6622 IF ( qx(mgs,li) <= 0.0 ) cx(mgs,li) = 0.0
6624 xdia(mgs,li,1) = 1.e-7
6625 xdia(mgs,li,2) = (1.e-14)
6626 xdia(mgs,li,3) = 1.e-7
6627 vtxbar(mgs,li,1) = 0.0
6632 IF ( icefallfac /= 1.0 ) THEN
6633 vtxbar(mgs,li,1) = icefallfac*vtxbar(mgs,li,1)
6634 vtxbar(mgs,li,2) = icefallfac*vtxbar(mgs,li,2)
6635 vtxbar(mgs,li,3) = icefallfac*vtxbar(mgs,li,3)
6645 ! ################################################################
6651 IF ( ildo == 0 .or. ildo == lr ) THEN
6653 if ( qx(mgs,lr) .gt. qxmin(lr) ) then
6655 ! IF ( qx(mgs,lr) .gt. 10.0e-3 ) &
6656 ! & write(0,*) 'RAIN1: ',igs(mgs),kgs(mgs),qx(mgs,lr)
6658 if ( ipconc .ge. 3 ) then
6659 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*Max(1.0e-11,cx(mgs,lr)))
6661 IF ( imaxdiaopt == 1 ) THEN
6663 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
6664 IF ( imurain == 1 ) THEN
6665 xvbarmax = xvmx(lr)/((3. + alpha(mgs,lr))**3/((3. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(1. + alpha(mgs,lr))))
6666 ELSEIF ( imurain == 3 ) THEN
6669 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
6670 IF ( imurain == 1 ) THEN
6671 xvbarmax = xvmx(lr)/((4. + alpha(mgs,lr))**3/((3. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(1. + alpha(mgs,lr))))
6672 ELSEIF ( imurain == 3 ) THEN
6677 IF ( xv(mgs,lr) .gt. xvbarmax ) THEN
6678 xv(mgs,lr) = xvbarmax
6679 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvbarmax*xdn(mgs,lr))
6680 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
6681 xv(mgs,lr) = xvmn(lr)
6682 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
6686 xmas(mgs,lr) = xv(mgs,lr)*xdn(mgs,lr)
6687 xdia(mgs,lr,3) = (xmas(mgs,lr)*cwc1)**(1./3.) ! xdia(mgs,lr,1)
6688 IF ( imurain == 3 ) THEN
6689 ! xdia(mgs,lr,1) = (6.*pii*xv(mgs,lr)/(alpha(mgs,lr)+1.))**(1./3.)
6690 xdia(mgs,lr,1) = xdia(mgs,lr,3) ! formulae for Ziegler (1985) use mean volume diameter, not lambda**(-1)
6691 ELSE ! imurain == 1, Characteristic diameter (1/lambda)
6692 xdia(mgs,lr,1) = (6.*pii*xv(mgs,lr)/((alpha(mgs,lr)+3.)*(alpha(mgs,lr)+2.)*(alpha(mgs,lr)+1.)))**(1./3.)
6694 ! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
6696 ! Inverse exponential version:
6698 ! & (qx(mgs,lr)*rho0(mgs)
6699 ! & /(pi*xdn(mgs,lr)*cx(mgs,lr)))**(0.333333)
6702 & (qx(mgs,lr)*rho0(mgs)/(pi*xdn(mgs,lr)*cno(lr)))**(0.25)
6703 xmas(mgs,lr) = xdn(mgs,lr)*(pi/6.)*xdia(mgs,lr,1)**3
6704 xdia(mgs,lr,3) = (xmas(mgs,lr)*cwc1)**(1./3.)
6705 cx(mgs,lr) = cno(lr)*xdia(mgs,lr,1)
6706 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr))
6709 xdia(mgs,lr,1) = 1.e-9
6710 xdia(mgs,lr,3) = 1.e-9
6711 xmas(mgs,lr) = xdn(mgs,lr)*(pi/6.)*xdia(mgs,lr,1)**3
6712 ! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
6714 xdia(mgs,lr,2) = xdia(mgs,lr,1)**2
6715 ! xmas(mgs,lr) = xdn(mgs,lr)*(pi/6.)*xdia(mgs,lr,1)**3
6719 ! ################################################################
6724 IF ( ls .gt. 1 .and. ( ildo == 0 .or. ildo == ls ) ) THEN
6727 if ( qx(mgs,ls) .gt. qxmin(ls) ) then
6728 if ( ipconc .ge. 4 ) then !
6730 xmas(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(Max(1.0e-9,cx(mgs,ls)))
6732 ! IF ( xmas(mgs,ls) > swmasmx ) THEN
6733 ! xmas(mgs,ls) = swmasmx
6734 ! cx(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xmas(mgs,ls))
6737 IF ( isnowdens == 2 ) THEN ! Set values according to Cox relationship
6739 xdn(mgs,ls) = 0.0346159*Sqrt(cx(mgs,ls)/(qx(mgs,ls)*rho0(mgs)) )
6740 xdn(mgs,ls) = Max( 100.0, xdn(mgs,ls) ) ! limit snow to 100. to keep other equations in line
6742 IF ( xdn(mgs,ls) <= 900. ) THEN
6743 dtmp = Sqrt( xmas(mgs,ls)/0.069 ) ! diameter (meters) of mean mass particle using Cox 1998 relation (m = p d^2)
6744 xv(mgs,ls) = 28.8887*xmas(mgs,ls)**(3./2.)
6745 ELSE ! at small sizes, assume ice spheres
6747 xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*Max(1.0e-9,cx(mgs,ls)))
6748 dtmp = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6751 ELSE ! leave xdn(ls) at default value
6752 xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*Max(1.0e-9,cx(mgs,ls)))
6753 dtmp = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6756 xdia(mgs,ls,1) = dtmp ! (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6758 IF ( xv(mgs,ls) .lt. xvmn(ls) .and. isnowdens == 1) THEN
6759 xv(mgs,ls) = Max( xvmn(ls),xv(mgs,ls) )
6760 xmas(mgs,ls) = xv(mgs,ls)*xdn(mgs,ls)
6761 cx(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xmas(mgs,ls))
6762 xdia(mgs,ls,1) = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6765 IF ( xv(mgs,ls) .gt. xvmx(ls)*Max(1.,100./Min(100.,xdn(mgs,ls))) ) THEN
6766 xv(mgs,ls) = Min( xvmx(ls), Max( xvmn(ls),xv(mgs,ls) ) )
6767 xmas(mgs,ls) = 0.106214*xv(mgs,ls)**(2./3.)
6768 cx(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xmas(mgs,ls))
6769 xdn(mgs,ls) = 0.0346159*Sqrt(cx(mgs,ls)/(qx(mgs,ls)*rho0(mgs)) )
6770 xdia(mgs,ls,1) = Sqrt( xmas(mgs,ls)/0.069 )
6773 xdia(mgs,ls,3) = xdia(mgs,ls,1)
6777 & (qx(mgs,ls)*rho0(mgs)/(pi*xdn(mgs,ls)*cnostmp(mgs)))**(0.25)
6778 cx(mgs,ls) = cnostmp(mgs)*xdia(mgs,ls,1)
6779 xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*cx(mgs,ls))
6780 xdia(mgs,ls,3) = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6783 xdia(mgs,ls,1) = 1.e-9
6784 xdia(mgs,ls,3) = 1.e-9
6787 IF ( isnowdens == 2 ) THEN ! Set values according to Cox relationship
6792 xdia(mgs,ls,2) = xdia(mgs,ls,1)**2
6793 ! swdia3(mgs) = xdia(mgs,ls,2)*xdia(mgs,ls,1)
6794 ! xmas(mgs,ls) = xdn(mgs,ls)*(pi/6.)*swdia3(mgs)
6800 ! ################################################################
6805 IF ( lh .gt. 1 .and. ( ildo == 0 .or. ildo == lh ) ) THEN
6808 if ( qx(mgs,lh) .gt. qxmin(lh) ) then
6809 if ( ipconc .ge. 5 ) then
6811 xv(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*Max(1.0e-9,cx(mgs,lh)))
6812 xmas(mgs,lh) = xv(mgs,lh)*xdn(mgs,lh)
6814 IF ( xv(mgs,lh) .lt. xvmn(lh) .or. xv(mgs,lh) .gt. xvmx(lh) ) THEN
6815 xv(mgs,lh) = Min( xvmx(lh), Max( xvmn(lh),xv(mgs,lh) ) )
6816 xmas(mgs,lh) = xv(mgs,lh)*xdn(mgs,lh)
6817 cx(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xmas(mgs,lh))
6820 xdia(mgs,lh,3) = (xv(mgs,lh)*6.*pii)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
6821 IF ( dmuh == 1.0 ) THEN
6822 xdia(mgs,lh,1) = cwch(mgs)*xdia(mgs,lh,3)
6824 xdia(mgs,lh,1) = (xv(mgs,lh)*cwch(mgs))**(1./3.)
6829 & (qx(mgs,lh)*rho0(mgs)/(pi*xdn(mgs,lh)*cno(lh)))**(0.25)
6830 cx(mgs,lh) = cno(lh)*xdia(mgs,lh,1)
6831 xv(mgs,lh) = Max(xvmn(lh), rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) )
6832 xdia(mgs,lh,3) = (xv(mgs,lh)*6./pi)**(1./3.)
6835 xdia(mgs,lh,1) = 1.e-9
6836 xdia(mgs,lh,3) = 1.e-9
6838 xdia(mgs,lh,2) = xdia(mgs,lh,1)**2
6839 ! hwdia3(mgs) = xdia(mgs,lh,2)*xdia(mgs,lh,1)
6840 ! xmas(mgs,lh) = xdn(mgs,lh)*(pi/6.)*hwdia3(mgs)
6846 ! ################################################################
6851 IF ( lhl .gt. 1 .and. ( ildo == 0 .or. ildo == lhl ) ) THEN
6854 if ( qx(mgs,lhl) .gt. qxmin(lhl) ) then
6855 if ( ipconc .ge. 5 ) then
6857 xv(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*Max(1.0e-9,cx(mgs,lhl)))
6858 xmas(mgs,lhl) = xv(mgs,lhl)*xdn(mgs,lhl)
6859 ! write(0,*) 'setvt: xv = ',xv(mgs,lhl),xdn(mgs,lhl),cx(mgs,lhl),xmas(mgs,lhl),qx(mgs,lhl)
6861 IF ( xv(mgs,lhl) .lt. xvmn(lhl) .or. xv(mgs,lhl) .gt. xvmx(lhl) ) THEN
6862 xv(mgs,lhl) = Min( xvmx(lhl), Max( xvmn(lhl),xv(mgs,lhl) ) )
6863 xmas(mgs,lhl) = xv(mgs,lhl)*xdn(mgs,lhl)
6864 cx(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xmas(mgs,lhl))
6867 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6./pi)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
6868 IF ( dmuhl == 1.0 ) THEN
6869 xdia(mgs,lhl,1) = cwchl(mgs)*xdia(mgs,lhl,3)
6871 xdia(mgs,lhl,1) = (xv(mgs,lhl)*cwchl(mgs))**(1./3.)
6874 ! write(0,*) 'setvt: xv = ',xv(mgs,lhl),xdn(mgs,lhl),cx(mgs,lhl),xdia(mgs,lhl,3)
6877 & (qx(mgs,lhl)*rho0(mgs)/(pi*xdn(mgs,lhl)*cno(lhl)))**(0.25)
6878 cx(mgs,lhl) = cno(lhl)*xdia(mgs,lhl,1)
6879 xv(mgs,lhl) = Max(xvmn(lhl), rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*cx(mgs,lhl)) )
6880 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6./pi)**(1./3.)
6883 xdia(mgs,lhl,1) = 1.e-9
6884 xdia(mgs,lhl,3) = 1.e-9
6886 xdia(mgs,lhl,2) = xdia(mgs,lhl,1)**2
6887 ! hwdia3(mgs) = xdia(mgs,lh,2)*xdia(mgs,lh,1)
6888 ! xmas(mgs,lh) = xdn(mgs,lh)*(pi/6.)*hwdia3(mgs)
6895 ! Set terminal velocities...
6896 ! also set drag coefficients (moved to start of subroutine)
6907 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set terminal velocities'
6910 ! ################################################################
6914 IF ( ildo == 0 .or. ildo == lr ) THEN
6916 if ( qx(mgs,lr) .gt. qxmin(lr) ) then
6917 IF ( ipconc .lt. 3 ) THEN
6918 vtxbar(mgs,lr,1) = rainfallfac*(ar*gf4br/6.0)*(xdia(mgs,lr,1)**br)*rhovt(mgs)
6919 ! write(91,*) 'vtxbar: ',vtxbar(mgs,lr,1),mgs,gf4br,xdia(mgs,lr,1),rhovt(mgs)
6922 IF ( imurain == 1 ) THEN ! DSD of Diameter
6924 ! using functional form of arx*(1 - Exp(-frx*diameter) ), with arx = arx = 10.
6925 ! and frx = 516.575 ! raind fit parameters for arx*(1 - Exp(-fx*d)), where d is rain diameter in meters.
6926 ! Similar form as in Atlas et al. (1973), who had 9.65 - 10.3*Exp[-600 * d]
6931 vtxbar(mgs,lr,1) = rhovt(mgs)*arx*(1.0 - (1.0 + frx*xdia(mgs,lr,1))**(-alp - 4.0) ) ! mass weighted
6933 IF ( infdo .ge. 1 .and. rssflg == 1 ) THEN
6934 vtxbar(mgs,lr,2) = rhovt(mgs)*arx*(1.0 - (1.0 + frx*xdia(mgs,lr,1))**(-alp - 1.0) ) ! number weighted
6936 vtxbar(mgs,lr,2) = vtxbar(mgs,lr,1)
6939 IF ( infdo .ge. 2 .and. rssflg == 1 ) THEN
6940 vtxbar(mgs,lr,3) = rhovt(mgs)*arx*(1.0 - (1.0 + frx*xdia(mgs,lr,1))**(-alp - 7.0) ) ! z-weighted
6942 vtxbar(mgs,lr,3) = vtxbar(mgs,lr,1)
6945 ! write(91,*) 'setvt: alp,vn,vm,vz = ',alp,vtxbar(mgs,lr,2), vtxbar(mgs,lr,1), vtxbar(mgs,lr,3),alpha(mgs,lr)
6947 ELSEIF ( imurain == 3 ) THEN ! DSD of Volume
6949 IF ( lzr < 1 ) THEN ! not 3-moment rain
6950 rwdia = Min( xdia(mgs,lr,1), 8.0e-3 )
6952 vtxbar(mgs,lr,1) = rhovt(mgs)*6.0*pii*( 0.04771 + 3788.0*rwdia - &
6953 & 1.105e6*rwdia**2 + 1.412e8*rwdia**3 - 6.527e9*rwdia**4)
6955 IF ( infdo .ge. 1 ) THEN
6956 IF ( rssflg >= 1 ) THEN
6957 vtxbar(mgs,lr,2) = (0.09112 + 2714.0*rwdia - 4.872e5*rwdia**2 + &
6958 & 4.495e7*rwdia**3 - 1.626e9*rwdia**4)*rhovt(mgs)
6960 vtxbar(mgs,lr,2) = vtxbar(mgs,lr,1)
6964 IF ( infdo .ge. 2 ) THEN ! Z-weighted fall speed
6965 vtxbar(mgs,lr,3) = rhovt(mgs)*( &
6967 & 9246.494*(rwdia) - &
6968 & 3.2839926e6*(rwdia**2) + &
6969 & 4.944093e8*(rwdia**3) - &
6970 & 2.631718e10*(rwdia**4) )
6973 ELSE ! 3-moment rain, gamma-volume
6976 rnux = alpha(mgs,lr)
6978 IF ( infdo .ge. 1 .and. rssflg == 1) THEN ! number-weighted; DTD: added size-sorting flag
6979 vtxbar(mgs,lr,2) = rhovt(mgs)* &
6980 & (((1. + rnux)/vr)**(-1.333333)* &
6981 & (0.0911229*((1. + rnux)/vr)**1.333333*Gamma_sp(1. + rnux) + &
6982 & (5430.3131*(1. + rnux)*Gamma_sp(4./3. + rnux))/ &
6983 & vr - 1.0732802e6*((1. + rnux)/vr)**0.6666667* &
6984 & Gamma_sp(1.666667 + rnux) + &
6985 & 8.584110982429507e7*((1. + rnux)/vr)**(1./3.)* &
6986 & Gamma_sp(2. + rnux) - &
6987 & 2.3303765697228556e9*Gamma_sp(7./3. + rnux)))/ &
6988 & Gamma_sp(1. + rnux)
6992 vtxbar(mgs,lr,1) = rhovt(mgs)* &
6993 & (0.0911229*(1 + rnux)**1.3333333333333333*Gamma_sp(2. + rnux) + &
6994 & 5430.313059683277*(1 + rnux)*vr**0.3333333333333333* &
6995 & Gamma_sp(2.333333333333333 + rnux) - &
6996 & 1.0732802065650471e6*(1 + rnux)**0.6666666666666666*vr**0.6666666666666666* &
6997 & Gamma_sp(2.6666666666666667 + rnux) + &
6998 & 8.584110982429507e7*(1 + rnux)**0.3333333333333333*vr*Gamma_sp(3 + rnux) - &
6999 & 2.3303765697228556e9*vr**1.3333333333333333* &
7000 & Gamma_sp(3.333333333333333 + rnux))/ &
7001 & ((1 + rnux)**2.333333333333333*Gamma_sp(1 + rnux))
7003 IF(infdo .ge. 1 .and. rssflg == 0) THEN ! No size-sorting, set N-weighted fall speed to mass-weighted
7004 vtxbar(mgs,lr,2) = vtxbar(mgs,lr,1)
7007 IF ( infdo .ge. 2 .and. rssflg == 1) THEN ! Z-weighted fall speed
7008 vtxbar(mgs,lr,3) = rhovt(mgs)* &
7009 & ((1. + rnux)*(0.0911229*(1 + rnux)**1.3333333333333333*Gamma_sp(3. + rnux) + &
7010 & 5430.313059683277*(1 + rnux)*vr**0.3333333333333333* &
7011 & Gamma_sp(3.3333333333333335 + rnux) - &
7012 & 1.0732802065650471e6*(1 + rnux)**0.6666666666666666* &
7013 & vr**0.6666666666666666*Gamma_sp(3.6666666666666665 + rnux) + &
7014 & 8.5841109824295e7*(1 + rnux)**0.3333333333333333*vr*Gamma_sp(4. + rnux) - &
7015 & 2.3303765697228556e9*vr**1.3333333333333333* &
7016 & Gamma_sp(4.333333333333333 + rnux)))/ &
7017 & ((1 + rnux)**3.3333333333333335*(2 + rnux)*Gamma_sp(1 + rnux))
7019 ! write(0,*) 'setvt: mgs,lzr,infdo = ',mgs,lzr,infdo
7020 ! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,lr,1),vtxbar(mgs,lr,2),vtxbar(mgs,lr,3)
7022 ELSEIF (infdo .ge. 2) THEN ! No size-sorting, set Z-weighted fall speed to mass-weighted
7023 vtxbar(mgs,lr,3) = vtxbar(mgs,lr,1)
7030 ! IF ( rwrad*mwfac .gt. 6.0e-4 ) THEN
7031 ! vtxbar(mgs,lr,1) = 20.1*Sqrt(100.*rwrad*mwfac)*rhovt(mgs)
7033 ! vtxbar(mgs,lr,1) = 80.0e2*rwrad*rhovt(mgs)*mwfac
7035 ! IF ( rwrad .gt. 6.0e-4 ) THEN
7036 ! vtxbar(mgs,lr,2) = 20.1*Sqrt(100.*rwrad)*rhovt(mgs)
7038 ! vtxbar(mgs,lr,2) = 80.0e2*rwrad*rhovt(mgs)
7042 vtxbar(mgs,lr,1) = 0.0
7043 vtxbar(mgs,lr,2) = 0.0
7046 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set rain vt'
7050 ! ################################################################
7052 ! SNOW !Zrnic et al. (1993)
7054 IF ( ls .gt. 1 .and. ( ildo == 0 .or. ildo == ls ) ) THEN
7056 if ( qx(mgs,ls) .gt. qxmin(ls) ) then
7057 IF ( ipconc .ge. 4 ) THEN
7058 if ( mixedphase .and. qsvtmod ) then
7060 IF ( isnowfall == 1 ) THEN
7061 ! original (Zrnic et al. 1993)
7062 vtxbar(mgs,ls,1) = 5.72462*rhovt(mgs)*(xv(mgs,ls))**(1./12.)
7063 ELSEIF ( isnowfall == 2 ) THEN
7065 IF ( isnowdens == 1 ) THEN
7066 vtxbar(mgs,ls,1) = 11.9495*rhovt(mgs)*(xv(mgs,ls))**(0.14)
7068 vtxbar(mgs,ls,1) = 11.9495*rhovt(mgs)*(xv(mgs,ls)*xdn(mgs,ls)/100.)**(0.14)
7070 ELSEIF ( isnowfall == 3 ) THEN
7071 ! Cox, mass distrib:
7072 vtxbar(mgs,ls,1) = 50.092*rhovt(mgs)*(xmas(mgs,ls))**(0.2635)
7075 IF(Abs(sssflg) >= 1) THEN
7076 IF ( isnowfall == 1 ) THEN
7077 vtxbar(mgs,ls,2) = 4.04091*rhovt(mgs)*(xv(mgs,ls))**(1./12.)
7078 ELSEIF ( isnowfall == 2 ) THEN
7080 IF ( isnowdens == 1 ) THEN
7081 vtxbar(mgs,ls,2) = 7.02909*rhovt(mgs)*(xv(mgs,ls))**(0.14) ! bug fix 11/15/2015: was rewriting to mass fall speed vtxbar(mgs,ls,1)
7083 vtxbar(mgs,ls,2) = 7.02909*rhovt(mgs)*(xv(mgs,ls)*xdn(mgs,ls)/100.)**(0.14) ! bug fix 11/15/2015: was rewriting to mass fall speed vtxbar(mgs,ls,1)
7085 ELSEIF ( isnowfall == 3 ) THEN
7086 ! Cox, mass distrib:
7087 vtxbar(mgs,ls,2) = 21.6147*rhovt(mgs)*(xmas(mgs,ls))**(0.2635)
7090 vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
7092 IF ( infdo >= 2 ) THEN
7093 IF ( isnowfall == 1 ) THEN
7094 vtxbar(mgs,ls,3) = 6.12217*rhovt(mgs)*(xv(mgs,ls))**(1./12.) ! Zrnic et al 93
7095 ELSEIF ( isnowfall == 2 ) THEN
7096 vtxbar(mgs,ls,3) = 13.3436*rhovt(mgs)*(xv(mgs,ls))**(0.14) ! Ferrier 94
7097 ELSEIF ( isnowfall == 3 ) THEN
7098 ! Cox, mass distrib:
7099 vtxbar(mgs,ls,3) = 61.0914*rhovt(mgs)*(xmas(mgs,ls))**(0.2635)
7103 IF ( sssflg < 0 .and. temcg(mgs) > Abs(sssflg) ) THEN ! above a given temperature, effectively turn off size sorting
7104 vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
7105 vtxbar(mgs,ls,3) = vtxbar(mgs,ls,1)
7109 ELSE ! single-moment:
7110 vtxbar(mgs,ls,1) = (cs*gf4ds/6.0)*(xdia(mgs,ls,1)**ds)*rhovt(mgs)
7111 vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
7114 vtxbar(mgs,ls,1) = 0.0
7117 IF ( snowfallfac /= 1.0 ) THEN
7118 vtxbar(mgs,ls,1) = snowfallfac*vtxbar(mgs,ls,1)
7119 vtxbar(mgs,ls,2) = snowfallfac*vtxbar(mgs,ls,2)
7120 vtxbar(mgs,ls,3) = snowfallfac*vtxbar(mgs,ls,3)
7125 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set snow vt'
7130 ! ################################################################
7132 ! GRAUPEL !Wisner et al. (1972)
7134 IF ( lh .gt. 1 .and. ( ildo == 0 .or. ildo == lh ) ) THEN
7137 vtxbar(mgs,lh,1) = 0.0
7138 if ( qx(mgs,lh) .gt. qxmin(lh) ) then
7140 IF ( icdx .eq. 1 ) THEN
7142 ELSEIF ( icdx .eq. 2 ) THEN
7143 ! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(xdnmx(lh) - xdn(mgs,lh))/(xdnmx(lh)-xdnmn(lh)) ) )
7144 ! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lh))/(900. - 300.) ) )
7145 cd = Max(0.45, Min(1.0, 0.45 + 0.35*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
7146 ! cd = Max(0.55, Min(1.0, 0.55 + 0.25*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
7147 ELSEIF ( icdx .eq. 3 ) THEN
7148 ! cd = Max(0.45, Min(1.0, 0.45 + 0.55*(800.0 - Max( 300., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 300.) ) )
7149 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hdnmn, Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7150 ELSEIF ( icdx .eq. 4 ) THEN
7151 cd = Max(cdhmin, Min(cdhmax, cdhmin + (cdhmax-cdhmin)* &
7152 & (cdhdnmax - Max( cdhdnmin, Min( cdhdnmax, xdn(mgs,lh) ) ) )/(cdhdnmax - cdhdnmin) ) )
7153 ELSEIF ( icdx .eq. 5 ) THEN
7154 cd = cdx(lh)*(xdn(mgs,lh)/rho_qh)**(2./3.)
7155 ELSEIF ( icdx .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
7156 indxr = Int( (xdn(mgs,lh)-50.)/100. ) + 1
7157 indxr = Min( ngdnmm, Max(1,indxr) )
7160 delrho = Max( 0.0, 0.01*(xdn(mgs,lh) - mmgraupvt(indxr,1)) )
7161 IF ( indxr < ngdnmm ) THEN
7163 axx(mgs,lh) = mmgraupvt(indxr,2) + delrho*(mmgraupvt(indxr+1,2) - mmgraupvt(indxr,2) )
7164 bxx(mgs,lh) = mmgraupvt(indxr,3) + delrho*(mmgraupvt(indxr+1,3) - mmgraupvt(indxr,3) )
7168 axx(mgs,lh) = mmgraupvt(indxr,2)
7169 bxx(mgs,lh) = mmgraupvt(indxr,3)
7175 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hdnmn, Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7177 ELSEIF ( icdx <= 0 ) THEN !
7180 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hdnmn, Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7182 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hdnmn, Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7186 IF ( alpha(mgs,lh) .eq. 0.0 .and. icdx > 0 .and. icdx /= 6 ) THEN
7187 ! axx(mgs,lh) = (gf4p5/6.0)* &
7188 ! & Sqrt( (xdn(mgs,lh)*4.0*gr) / &
7189 ! & (3.0*cd*rho0(mgs)) )
7190 axx(mgs,lh) = Sqrt(4.0*xdn(mgs,lh)*gr/(3.0*cd*rho00))
7192 vtxbar(mgs,lh,1) = (gf4p5/6.0)* rhovt(mgs)*axx(mgs,lh) * Sqrt(xdia(mgs,lh,1))
7193 ! vtxbar(mgs,lh,1) = (gf4p5/6.0)* &
7194 ! & Sqrt( (xdn(mgs,lh)*xdia(mgs,lh,1)*4.0*gr) / &
7195 ! & (3.0*cd*rho0(mgs)) )
7197 IF ( icdx /= 6 ) bbx = bx(lh)
7198 tmp = 4. + alpha(mgs,lh) + bbx
7199 i = Int(dgami*(tmp))
7201 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7203 tmp = 4. + alpha(mgs,lh)
7204 i = Int(dgami*(tmp))
7206 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7208 ! aax = Max( 1.0, Min(2.0, (xdn(mgs,lh)/400.) ) )
7209 ! vtxbar(mgs,lh,1) = rhovt(mgs)*aax*ax(lh)*(xdia(mgs,lh,1)**bx(lh)*x)/y
7211 IF ( icdx > 0 .and. icdx /= 6) THEN
7212 aax = Sqrt(4.0*xdn(mgs,lh)*gr/(3.0*cd*rho00))
7213 vtxbar(mgs,lh,1) = rhovt(mgs)*aax* Sqrt(xdia(mgs,lh,1)) * x/y
7216 ELSEIF (icdx == 6 ) THEN
7217 vtxbar(mgs,lh,1) = rhovt(mgs)*aax* xdia(mgs,lh,1)**bbx * x/y
7219 axx(mgs,lh) = ax(lh)
7220 bxx(mgs,lh) = bx(lh)
7221 vtxbar(mgs,lh,1) = rhovt(mgs)*ax(lh)*(xdia(mgs,lh,1)**bx(lh)*x)/y
7224 ! & Gamma_sp(4.0 + dnu(lh) + 0.6))/Gamma_sp(4. + dnu(lh))
7227 IF ( lwsm6 .and. ipconc == 0 ) THEN
7228 ! vtxbar(mgs,lh,1) = (330.*gf4ds/6.0)*(xdia(mgs,ls,1)**ds)*rhovt(mgs)
7229 vtxbar(mgs,lh,1) = (330.*gf4br/6.0)*(xdia(mgs,lh,1)**br)*rhovt(mgs)
7234 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt'
7239 ! ################################################################
7243 IF ( lhl .gt. 1 .and. ( ildo == 0 .or. ildo == lhl ) ) THEN
7246 vtxbar(mgs,lhl,1) = 0.0
7247 if ( qx(mgs,lhl) .gt. qxmin(lhl) ) then
7249 IF ( icdxhl .eq. 1 ) THEN
7251 ELSEIF ( icdxhl .eq. 3 ) THEN
7252 ! cd = Max(0.45, Min(1.0, 0.45 + 0.55*(800.0 - Max( 300., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 300.) ) )
7253 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hldnmn, Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
7254 ELSEIF ( icdxhl .eq. 4 ) THEN
7255 cd = Max(cdhlmin, Min(cdhlmax, cdhlmin + (cdhlmax-cdhlmin)* &
7256 & (cdhldnmax - Max( cdhldnmin, Min( cdhldnmax, xdn(mgs,lhl) ) ) )/(cdhldnmax - cdhldnmin) ) )
7257 ELSEIF ( icdxhl .eq. 5 ) THEN
7258 cd = cdx(lh)*(xdn(mgs,lhl)/rho_qh)**(2./3.)
7259 ELSEIF ( icdxhl .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
7260 indxr = Int( (xdn(mgs,lhl)-50.)/100. ) + 1
7261 indxr = Min( ngdnmm, Max(1,indxr) )
7264 delrho = Max( 0.0, 0.01*(xdn(mgs,lhl) - mmgraupvt(indxr,1)) )
7265 IF ( indxr < ngdnmm ) THEN
7267 axx(mgs,lhl) = mmgraupvt(indxr,2) + delrho*(mmgraupvt(indxr+1,2) - mmgraupvt(indxr,2) )
7268 bxx(mgs,lhl) = mmgraupvt(indxr,3) + delrho*(mmgraupvt(indxr+1,3) - mmgraupvt(indxr,3) )
7272 axx(mgs,lhl) = mmgraupvt(indxr,2)
7273 bxx(mgs,lhl) = mmgraupvt(indxr,3)
7279 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hldnmn, Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
7282 ! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lhl))/(900. - 300.) ) )
7283 ! cd = Max(0.5, Min(0.8, 0.5 + 0.3*(xdnmx(lhl) - xdn(mgs,lhl))/(xdnmx(lhl)-xdnmn(lhl)) ) )
7284 ! cd = Max(0.45, Min(0.6, 0.45 + 0.15*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 500.) ) )
7285 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hldnmn, Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
7290 IF ( alpha(mgs,lhl) .eq. 0.0 .and. icdxhl > 0 .and. icdxhl /= 6) THEN
7291 ! axx(mgs,lhl) = (gf4p5/6.0)* &
7292 ! & Sqrt( (xdn(mgs,lhl)*4.0*gr) / &
7293 ! & (3.0*cd*rho0(mgs)) )
7294 axx(mgs,lhl) = Sqrt(4.0*xdn(mgs,lhl)*gr/(3.0*cd*rho00))
7296 vtxbar(mgs,lhl,1) = (gf4p5/6.0)* rhovt(mgs)*axx(mgs,lhl) * Sqrt(xdia(mgs,lhl,1))
7298 IF ( icdxhl /= 6 ) bbx = bx(lhl)
7299 tmp = 4. + alpha(mgs,lhl) + bbx
7300 i = Int(dgami*(tmp))
7302 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7304 tmp = 4. + alpha(mgs,lhl)
7305 i = Int(dgami*(tmp))
7307 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7309 IF ( icdxhl > 0 .and. icdxhl /= 6) THEN
7310 aax = Sqrt(4.0*xdn(mgs,lhl)*gr/(3.0*cd*rho00))
7311 vtxbar(mgs,lhl,1) = rhovt(mgs)*aax* Sqrt(xdia(mgs,lhl,1)) * x/y
7314 ELSEIF ( icdxhl == 6 ) THEN
7315 vtxbar(mgs,lhl,1) = rhovt(mgs)*aax* (xdia(mgs,lhl,1))**bbx * x/y
7317 axx(mgs,lhl) = ax(lhl)
7318 bxx(mgs,lhl) = bx(lhl)
7319 vtxbar(mgs,lhl,1) = rhovt(mgs)*(ax(lhl)*xdia(mgs,lhl,1)**bx(lhl)*x)/y
7322 ! & Gamma_sp(4.0 + dnu(lh) + 0.6))/Gamma_sp(4. + dnu(lh))
7328 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt'
7333 IF ( infdo .ge. 1 ) THEN
7336 ! IF ( il .ne. lr ) THEN
7338 IF ( ildo == 0 .or. ildo == lc ) THEN
7339 vtxbar(mgs,lc,2) = vtxbar(mgs,lc,1)
7341 IF ( li .gt. 1 ) THEN
7342 ! vtxbar(mgs,li,2) = rhovt(mgs)*49420.*1.25447*xdia(mgs,li,1)**(1.415) ! n-wgt (Ferrier 94)
7343 ! vtxbar(mgs,li,2) = vtxbar(mgs,li,1)
7345 ! test print stuff...
7346 ! IF ( xdia(mgs,li,1) .gt. 200.e-6 ) THEN
7347 ! tmp = (xv(mgs,li)*cwc0)**(1./3.)
7348 ! x = rhovt(mgs)*49420.*40.0005/5.40662*tmp**(1.415)
7349 ! y = rhovt(mgs)*49420.*1.25447*tmp**(1.415)
7350 ! write(6,*) 'Ice fall: ',vtxbar(mgs,li,1),x,y,tmp,xdia(mgs,li,1)
7353 ! vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
7356 IF ( lg .gt. lr ) THEN
7359 IF ( ildo == 0 .or. ildo == il ) THEN
7362 IF ( qx(mgs,il) .gt. qxmin(il) ) THEN
7363 IF ( (il .eq. lh .and. hssflg == 1) .or. ( lhl .gt. 1 .and. il .eq. lhl .and. hlssflg == 1) ) THEN ! DTD: added flag for size-sorting
7365 ! DTD: allow for setting of number-weighted and z-weighted fall speeds to the mass-weighted value,
7366 ! effectively turning off size-sorting
7368 IF ( il .eq. lh ) THEN ! {
7370 IF ( icdx .eq. 1 ) THEN
7372 ELSEIF ( icdx .eq. 2 ) THEN
7373 ! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(xdnmx(lh) - xdn(mgs,lh))/(xdnmx(lh)-xdnmn(lh)) ) )
7374 ! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lh))/(900. - 300.) ) )
7375 cd = Max(0.45, Min(1.0, 0.45 + 0.35*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
7376 ! cd = Max(0.55, Min(1.0, 0.55 + 0.25*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
7377 ELSEIF ( icdx .eq. 3 ) THEN
7378 ! cd = Max(0.45, Min(1.0, 0.45 + 0.55*(800.0 - Max( 170.0, Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7379 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hdnmn, Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7380 ELSEIF ( icdx .eq. 4 ) THEN
7381 cd = Max(cdhmin, Min(cdhmax, cdhmin + (cdhmax-cdhmin)* &
7382 & (cdhdnmax - Max( cdhdnmin, Min( cdhdnmax, xdn(mgs,lh) ) ) )/(cdhdnmax - cdhdnmin) ) )
7383 ELSEIF ( icdx .eq. 5 ) THEN
7384 cd = cdx(lh)*(xdn(mgs,lh)/rho_qh)**(2./3.)
7385 ELSEIF ( icdx .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
7388 ELSEIF ( icdx <= 0 ) THEN !
7393 ELSEIF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
7395 IF ( icdxhl .eq. 1 ) THEN
7397 ELSEIF ( icdxhl .eq. 3 ) THEN
7398 ! cd = Max(0.45, Min(1.0, 0.45 + 0.55*(800.0 - Max( 300., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 300.) ) )
7399 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hldnmn, Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
7400 ELSEIF ( icdxhl .eq. 4 ) THEN
7401 cd = Max(cdhlmin, Min(cdhlmax, cdhlmin + (cdhlmax-cdhlmin)* &
7402 & (cdhldnmax - Max( cdhldnmin, Min( cdhldnmax, xdn(mgs,lhl) ) ) )/(cdhldnmax - cdhldnmin) ) )
7403 ELSEIF ( icdxhl == 5 ) THEN
7404 ! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lhl))/(900. - 300.) ) )
7405 ! cd = Max(0.5, Min(0.8, 0.5 + 0.3*(xdnmx(lhl) - xdn(mgs,lhl))/(xdnmx(lhl)-xdnmn(lhl)) ) )
7406 cd = Max(0.45, Min(0.6, 0.45 + 0.15*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 500.) ) )
7407 ELSEIF ( icdxhl .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
7410 ELSEIF ( icdxhl <= 0 ) THEN !
7417 IF ( alpha(mgs,il) .eq. 0. .and. infdo .lt. 2 .and. &
7418 ( ( il==lh .and. icdx > 0 .and. icdx /= 6) .or. ( il==lhl .and. icdxhl > 0 .and. icdxhl /= 6 ) ) ) THEN ! {
7419 vtxbar(mgs,il,2) = &
7420 & Sqrt( (xdn(mgs,il)*xdia(mgs,il,1)*pi*gr) / &
7421 & (3.0*cd*Max(0.05,rho0(mgs))) )
7424 IF ( il == lh .and. icdx /= 6 ) bbx = bx(il)
7425 IF ( il == lhl .and. icdxhl /= 6 ) bbx = bx(il)
7426 tmp = 1. + alpha(mgs,il) + bbx
7427 i = Int(dgami*(tmp))
7429 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7431 tmp = 1. + alpha(mgs,il)
7432 i = Int(dgami*(tmp))
7434 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7436 IF ( il .eq. lh .or. il .eq. lhl) THEN ! {
7437 IF ( ( il==lh .and. icdx > 0 ) ) THEN
7438 IF ( icdx /= 6 ) THEN
7439 aax = Sqrt(4.0*xdn(mgs,il)*gr/(3.0*cd*rho00))
7440 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bx(il) * x/y
7441 ELSE ! (icdx == 6 ) THEN
7442 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bbx * x/y
7445 ELSEIF ( ( il==lhl .and. icdxhl > 0 ) ) THEN
7446 IF ( icdxhl /= 6 ) THEN
7447 aax = Sqrt(4.0*xdn(mgs,il)*gr/(3.0*cd*rho00))
7448 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bx(il) * x/y
7449 ELSE ! ( icdxhl == 6 )
7450 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bbx * x/y
7452 ELSE ! get here if il==lh and icdx < 0 -- or -- il==lhl and icdxhl < 0
7454 vtxbar(mgs,il,2) = rhovt(mgs)*ax(il)*(xdia(mgs,il,1)**bx(il)*x)/y
7456 ! vtxbar(mgs,il,2) = &
7457 ! & rhovt(mgs)*(xdn(mgs,il)/400.)*(75.715*xdia(mgs,il,1)**0.6* &
7459 ! vtxbar(mgs,il,2) = &
7460 ! & rhovt(mgs)*(xdn(mgs,il)/400.)*(ax(il)*xdia(mgs,il,1)**bx(il)* &
7462 IF ( infdo .ge. 2 ) THEN ! Z-weighted
7464 tmp = 7. + alpha(mgs,il) + bbx
7465 i = Int(dgami*(tmp))
7467 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7469 tmp = 7. + alpha(mgs,il)
7470 i = Int(dgami*(tmp))
7472 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7474 vtxbar(mgs,il,3) = rhovt(mgs)* &
7475 & (aax*(xdia(mgs,il,1) )**bbx * &
7477 ! & Gamma(7.0 + alpha(mgs,il) + bbx)/Gamma(7. + alpha(mgs,il))
7478 IF ( .not. (vtxbar(mgs,il,1) > -1. .and. vtxbar(mgs,il,1) < 200. ) .or. &
7479 .not. (vtxbar(mgs,il,3) > -1. .and. vtxbar(mgs,il,3) < 200. ) ) THEN
7480 write(0,*) 'Setvtz: problem with vtxbar1/3: ',il,vtxbar(mgs,il,1),vtxbar(mgs,il,3),aax,bbx,x,y
7481 write(0,*) 'q, number, diam1,3(mm) = ', qx(mgs,il),cx(mgs,il),1000.*xdia(mgs,il,1),1000.*xdia(mgs,il,3)
7482 ! call commasmpi_abort()
7484 ! & (aax*(1.0/xdia(mgs,il,1) )**(- bx(il))* &
7485 ! & Gamma_sp(7.0 + alpha(mgs,il) + bx(il)))/Gamma_sp(7. + alpha(mgs,il))
7488 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt3'
7491 vtxbar(mgs,il,2) = &
7492 & rhovt(mgs)*(ax(il)*xdia(mgs,il,1)**bx(il)* &
7495 IF ( infdo .ge. 2 ) THEN ! Z-weighted
7496 vtxbar(mgs,il,3) = rhovt(mgs)* &
7497 & (aax*(1.0/xdia(mgs,il,1) )**(- bbx)* &
7498 & Gamma_sp(7.0 + alpha(mgs,il) + bbx))/Gamma_sp(7. + alpha(mgs,il))
7499 ! & (ax(il)*(1.0/xdia(mgs,il,1) )**(- bx(il))* &
7500 ! & Gamma_sp(7.0 + alpha(mgs,il) + bx(il)))/Gamma_sp(7. + alpha(mgs,il))
7503 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt4'
7506 ! & Gamma_sp(1.0 + dnu(il) + 0.6)/Gamma_sp(1. + dnu(il))
7509 ! IF ( infdo .ge. 2 ) THEN ! Z-weighted
7510 ! vtxbar(mgs,il,3) = rhovt(mgs)* &
7511 ! & (ax(il)*(1.0/xdia(mgs,il,1) )**(- bx(il))* &
7512 ! & Gamma_sp(7.0 + alpha(mgs,il) + bx(il)))/Gamma_sp(7. + alpha(mgs,il))
7515 ! IF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
7516 ! write(0,*) 'setvt: ',qx(mgs,il),xdia(mgs,il,1),xdia(mgs,il,3),dnu(il),ax(il),bx(il)
7518 ELSEIF ( (il .eq. lh .and. hssflg == 0) .or. ( lhl .gt. 1 .and. il .eq. lhl .and. hlssflg == 0) ) THEN ! no size-sorting for graupel or hail
7519 vtxbar(mgs,il,2) = vtxbar(mgs,il,1)
7520 vtxbar(mgs,il,3) = vtxbar(mgs,il,1)
7521 ELSE ! not lh or lhl
7522 vtxbar(mgs,il,2) = &
7523 & Sqrt( (xdn(mgs,il)*xdia(mgs,il,1)*pi*gr) / &
7524 & (3.0*cdx(il)*Max(0.05,rho0(mgs))) )
7525 vtxbar(mgs,il,3) = vtxbar(mgs,il,1)
7527 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt5'
7532 vtxbar(mgs,il,2) = 0.0
7534 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt6'
7539 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt7'
7544 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt8'
7551 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt9'
7554 ! IF ( qx(mgs,lr) > qxmin(lr) ) THEN
7555 ! write(0,*) 'setvt2: mgs,lzr,infdo = ',mgs,lzr,infdo
7556 ! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,lr,1),vtxbar(mgs,lr,2),vtxbar(mgs,lr,3)
7560 ENDIF ! infdo .ge. 1
7562 IF ( lh > 0 .and. graupelfallfac /= 1.0 ) THEN
7564 vtxbar(mgs,lh,1) = graupelfallfac*vtxbar(mgs,lh,1)
7565 vtxbar(mgs,lh,2) = graupelfallfac*vtxbar(mgs,lh,2)
7566 vtxbar(mgs,lh,3) = graupelfallfac*vtxbar(mgs,lh,3)
7567 axx(mgs,lh) = graupelfallfac*axx(mgs,lh)
7571 IF ( lhl > 0 .and. hailfallfac /= 1.0 ) THEN
7573 vtxbar(mgs,lhl,1) = hailfallfac*vtxbar(mgs,lhl,1)
7574 vtxbar(mgs,lhl,2) = hailfallfac*vtxbar(mgs,lhl,2)
7575 vtxbar(mgs,lhl,3) = hailfallfac*vtxbar(mgs,lhl,3)
7576 axx(mgs,lhl) = hailfallfac*axx(mgs,lhl)
7580 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: END OF ROUTINE'
7582 !############ SETVTZ ############################
7585 END SUBROUTINE setvtz
7586 !--------------------------------------------------------------------------
7589 ! ##############################################################################
7592 ! subroutine to calculate fall speeds of hydrometeors
7595 subroutine ziegfall1d(nx,ny,nz,nor,norz,na,dtp,jgs,ixcol, &
7597 & an,dn,ipconc0,t0,t7,cwmasn,cwmasx, &
7599 & qxmin,xdnmx,xdnmn,cdx,cno,xdn0,xvmn,xvmx, &
7600 & ngs,qx,qxw,cx,xv,vtxbar,xmas,xdn,xdia,vx,alpha,zx,igs,kgs, &
7601 & rho0,temcg,temg,rhovt,cwnc,cinc,fadvisc,cwdia,cipmas,cnina,cimas, &
7603 & infdo,ildo,timesetvt)
7605 ! 12.16.2005: .F version use in transitional SWM model
7607 ! 10.10.2003: Added cimn and cimx to setting for cci and cip.
7611 ! need to set up values for:
7612 ! : cipdia,cidia,cwdia,cwmas,vtwbar,
7613 ! : rho0,temcg,cip,cci
7615 ! and need to put fallspeed values in cwvt etc.
7622 integer, intent(in) :: ixcol ! which column to return
7623 integer, intent(in) :: ildo
7625 integer nx,ny,nz,nor,norz,ngt,jgs,na
7626 real an(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,na)
7627 real dn(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
7628 real t0(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
7629 real t7(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
7632 real :: rhovtzx(nz,nx)
7635 parameter (ndebugzf = 0)
7637 integer ix,jy,kz,i,j,k,il
7641 real xvt(nz+1,nx,3,lc:lhab) ! 1=mass-weighted, 2=number-weighted
7645 real xvmn(lc:lhab), xvmx(lc:lhab)
7646 double precision,optional :: timesetvt
7649 integer :: ngscnt,mgs,ipconc0
7650 ! parameter ( ngs=200 )
7652 real :: qx(ngs,lv:lhab)
7653 real :: qxw(ngs,ls:lhab)
7654 real :: cx(ngs,lc:lhab)
7655 real :: xv(ngs,lc:lhab)
7656 real :: vtxbar(ngs,lc:lhab,3)
7657 real :: xmas(ngs,lc:lhab)
7658 real :: xdn(ngs,lc:lhab)
7659 real :: cdxgs(ngs,lc:lhab)
7660 real :: xdia(ngs,lc:lhab,3)
7661 real :: vx(ngs,li:lhab)
7662 real :: alpha(ngs,lc:lhab)
7663 real :: zx(ngs,lr:lhab)
7665 real xdnmx(lc:lhab), xdnmn(lc:lhab)
7666 real :: axx(ngs,lh:lhab), bxx(ngs,lh:lhab)
7667 ! real axh(ngs),bxh(ngs),axhl(ngs),bxhl(ngs)
7674 ! Fixed intercept values for single moment scheme
7678 real cwccn0,cwmasn,cwmasx,cwradn
7681 integer nxmpb,nzmpb,nxz,numgs,inumgs
7685 integer igs(ngs),kgs(ngs)
7687 real rho0(ngs),temcg(ngs)
7693 real cwnc(ngs),cinc(ngs)
7694 real fadvisc(ngs),cwdia(ngs),cipmas(ngs)
7696 ! real cimasn,cimasx,
7697 real :: cnina(ngs),cimas(ngs)
7699 real :: cnostmp(ngs)
7704 ! general constants for microphysics
7715 real chw, qr, z, rd, alp, z1, g1, vr, nrx, tmp
7720 real, parameter :: c1r=19.0, c2r=0.6, c3r=1.8, c4r=17.0 ! rain
7721 real, parameter :: c1h=5.5, c2h=0.7, c3h=4.5, c4h=8.5 ! Graupel
7722 real, parameter :: c1hl=3.7, c2hl=0.3, c3hl=9.0, c4hl=6.5, c5hl=1.0, c6hl=6.5 ! Hail
7726 double precision :: dpt1, dpt2
7729 !-----------------------------------------------------------------------------
7730 ! MPI LOCAL VARIABLES
7732 integer :: ixb, jyb, kzb
7733 integer :: ixe, jye, kze
7735 logical :: debug_mpi = .false.
7738 if (ndebugzf .gt. 0 ) write(0,*) "ZIEGFALL: ENTERED SUBROUTINE"
7740 ! #####################################################################
7742 ! #####################################################################
7749 IF ( ls .gt. 1 ) THEN
7751 ldoliq = ldoliq .or. ( lliq(il) .gt. 1 )
7763 ! new values for cs and ds
7766 ! pi = 4.0*atan(1.0)
7767 ! pii = piinv ! 1./pi
7775 ! general constants for microphysics
7779 ! ci constants in mks units
7784 ! Set terminal velocities...
7785 ! also set drag coefficients
7794 IF ( ildo == 0 ) THEN
7813 flag = flag .or. ( an(ix,jy,kz,il) .gt. qxmin(il) )
7817 ! load temp quantities
7822 if ( ngscnt .eq. ngs ) goto 1100
7828 ! if ( jy .eq. (ny-jstag) ) iend = 1
7832 if ( ngscnt .eq. 0 ) go to 9998
7834 ! set temporaries for microphysics variables
7839 ! Reconstruct various quantities
7843 rho0(mgs) = dn(igs(mgs),jy,kgs(mgs))
7844 rhovt(mgs) = rhovtzx(kgs(mgs),ixcol) ! Sqrt(rho00/rho0(mgs))
7845 temg(mgs) = t0(igs(mgs),jy,kgs(mgs))
7846 temcg(mgs) = temg(mgs) - tfr
7852 ! only need fadvisc for
7853 IF ( lc .gt. 1 .and. (ildo == 0 .or. ildo == lc ) ) then
7855 fadvisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))* &
7856 & (temg(mgs)/296.0)**(1.5)
7860 IF ( ipconc .eq. 0 ) THEN
7862 cnina(mgs) = t7(igs(mgs),jgs,kgs(mgs))
7867 IF ( ildo > 0 ) THEN
7868 vtxbar(:,ildo,:) = 0.0
7874 ! qx(mgs,lv) = max(an(igs(mgs),jy,kgs(mgs),lv), 0.0)
7878 qx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),il), 0.0)
7882 cnostmp(:) = cno(ls)
7883 IF ( ipconc < 1 .and. lwsm6 .and. (ildo == 0 .or. ildo == ls )) THEN
7885 tmp = Min( 0.0, temcg(mgs) )
7886 cnostmp(mgs) = Min( 2.e8, 2.e6*exp(0.12*tmp) )
7892 ! set concentrations
7896 if ( ipconc .ge. 1 .and. li .gt. 1 .and. (ildo == 0 .or. ildo == li ) ) then
7898 cx(mgs,li) = Max(an(igs(mgs),jy,kgs(mgs),lni), 0.0)
7901 if ( ipconc .ge. 2 .and. lc .gt. 1 .and. (ildo == 0 .or. ildo == lc ) ) then
7903 cx(mgs,lc) = Max(an(igs(mgs),jy,kgs(mgs),lnc), 0.0)
7904 ! cx(mgs,lc) = Min( ccwmx, cx(mgs,lc) )
7907 if ( ipconc .ge. 3 .and. lr .gt. 1 .and. (ildo == 0 .or. ildo == lr ) ) then
7909 cx(mgs,lr) = Max(an(igs(mgs),jy,kgs(mgs),lnr), 0.0)
7910 ! IF ( qx(mgs,lr) .le. qxmin(lr) ) THEN
7912 ! cx(mgs,lr) = Max( 0.0, cx(mgs,lr) )
7916 if ( ipconc .ge. 4 .and. ls .gt. 1 .and. (ildo == 0 .or. ildo == ls ) ) then
7918 cx(mgs,ls) = Max(an(igs(mgs),jy,kgs(mgs),lns), 0.0)
7919 ! IF ( qx(mgs,ls) .le. qxmin(ls) ) THEN
7921 ! cx(mgs,ls) = Max( 0.0, cx(mgs,ls) )
7926 if ( ipconc .ge. 5 .and. lh .gt. 1 .and. (ildo == 0 .or. ildo == lh ) ) then
7929 cx(mgs,lh) = Max(an(igs(mgs),jy,kgs(mgs),lnh), 0.0)
7930 ! IF ( qx(mgs,lh) .le. qxmin(lh) ) THEN
7932 ! cx(mgs,lh) = Max( 0.0, cx(mgs,lh) )
7938 if ( ipconc .ge. 5 .and. lhl .gt. 1 .and. (ildo == 0 .or. ildo == lhl ) ) then
7941 cx(mgs,lhl) = Max(an(igs(mgs),jy,kgs(mgs),lnhl), 0.0)
7942 ! IF ( qx(mgs,lhl) .le. qxmin(lhl) ) THEN
7944 ! ELSEIF ( cx(mgs,lhl) .eq. 0.0 .and. qx(mgs,lhl) .lt. 3.0*qxmin(lhl) ) THEN
7947 ! cx(mgs,lhl) = Max( 0.0, cx(mgs,lhl) )
7954 xdn(mgs,lc) = xdn0(lc)
7955 xdn(mgs,lr) = xdn0(lr)
7956 ! IF ( ls .gt. 1 .and. lvs .eq. 0 ) xdn(mgs,ls) = xdn0(ls)
7957 ! IF ( lh .gt. 1 .and. lvh .eq. 0 ) xdn(mgs,lh) = xdn0(lh)
7958 IF ( li .gt. 1 ) xdn(mgs,li) = xdn0(li)
7959 IF ( ls .gt. 1 ) xdn(mgs,ls) = xdn0(ls)
7960 IF ( lh .gt. 1 ) xdn(mgs,lh) = xdn0(lh)
7961 IF ( lhl .gt. 1 ) xdn(mgs,lhl) = xdn0(lhl)
7965 ! Set mean particle volume
7967 IF ( ldovol .and. (ildo == 0 .or. ildo >= li ) ) THEN
7973 IF ( lvol(il) .ge. 1 ) THEN
7976 vx(mgs,il) = Max(an(igs(mgs),jy,kgs(mgs),lvol(il)), 0.0)
7977 IF ( vx(mgs,il) .gt. rho0(mgs)*qxmin(il)*1.e-3 .and. qx(mgs,il) .gt. qxmin(il) ) THEN
7978 xdn(mgs,il) = Min( xdnmx(il), Max( xdnmn(il), rho0(mgs)*qx(mgs,il)/vx(mgs,il) ) )
7990 alpha(mgs,il) = dnu(il)
7994 IF ( imurain == 1 ) THEN
7995 alpha(:,lr) = alphar
7996 ELSEIF ( imurain == 3 ) THEN
7997 alpha(:,lr) = xnu(lr)
8001 IF ( ipconc == 5 .and. imydiagalpha > 0 ) THEN
8003 IF ( qx(mgs,lr) .gt. qxmin(lr) .and. cx(mgs,lr) > cxmin ) THEN
8004 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr)) !
8005 xdia(mgs,lr,3) = (xv(mgs,lr)*6.0*cwc1)**(1./3.)
8006 alpha(mgs,lr) = Min(alphamax, c1r*tanh(c2r*(xdia(mgs,lr,3)*1000. - c3r)) + c4r)
8008 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. cx(mgs,lh) > cxmin ) THEN
8009 xv(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) !
8010 xdia(mgs,lh,3) = (xv(mgs,lh)*6.*piinv)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
8011 alpha(mgs,lh) = Min(alphamax, c1h*tanh(c2h*(xdia(mgs,lh,3)*1000. - c3h)) + c4h)
8013 ! alpha(:,lr) = 0. ! 10.
8014 ! alpha(:,lh) = 0. ! 10.
8016 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. cx(mgs,lhl) > cxmin ) THEN
8017 xv(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*cx(mgs,lhl)) !
8018 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6.*piinv)**(1./3.)
8019 IF ( xdia(mgs,lhl,3) < 0.008 ) THEN
8020 alpha(mgs,lhl) = Min(alphamax, c1hl*tanh(c2hl*(xdia(mgs,lhl,3)*1000. - c3hl)) + c4hl)
8022 alpha(mgs,lhl) = Min(alphamax, c5hl*xdia(mgs,lhl,3)*1000. + c6hl)
8033 IF ( ipconc .ge. 6 .or. lzr > 1) THEN
8040 IF ( lz(il) .ge. 1 ) THEN
8043 zx(mgs,il) = Max(an(igs(mgs),jy,kgs(mgs),lz(il)), 0.0)
8057 ! Find shape parameter rain
8060 IF ( lz(lr) > 1 .and. (ildo == 0 .or. ildo == lr ) .and. imurain == 3 ) THEN ! { RAIN SHAPE PARAM
8064 IF ( iresetmoments == 1 .or. iresetmoments == il ) THEN
8065 ! IF ( .false. .and. zx(mgs,lr) <= zxmin ) THEN
8066 IF ( zx(mgs,lr) <= zxmin ) THEN
8069 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
8070 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
8071 an(igs(mgs),jgs,kgs(mgs),ln(lr)) = cx(mgs,lr)
8072 ! ELSEIF ( zx(mgs,lr) <= 0.0 .and. cx(mgs,lr) > 0.0 .and. qx(mgs,il) .gt. qxmin(il)) THEN
8073 ! write(91,*) 'ZF: overdepletion of Zr: z,c,q = ',zx(mgs,il),cx(mgs,il),qx(mgs,il)
8074 ELSEIF ( cx(mgs,lr) <= cxmin ) THEN
8077 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
8078 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
8079 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
8085 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
8087 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*Max(1.0e-11,cx(mgs,lr)))
8088 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
8090 ! xv(mgs,lr) = xvmx(lr)
8091 ! cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
8092 ! an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8093 ! IF ( tmp < cx(mgs,il) ) THEN ! breakup
8094 ! g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8095 !! zx(mgs,lr) = zx(mgs,lr) + g1*(rho0(mgs)/(1000.))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
8096 !! an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
8098 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
8099 xv(mgs,lr) = xvmn(lr)
8100 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
8101 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8104 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
8105 ! have mass and reflectivity but no concentration, so set concentration, using default alpha
8106 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8110 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*1000.*1000)
8111 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8113 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > cxmin ) THEN
8114 ! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
8115 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8119 ! xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(1000.*Max(1.0e-9,cx(mgs,lr)))
8122 ! z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
8124 ! an(igs(mgs),jy,kgs(mgs),lz(il)) = z
8126 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(xdn(mgs,lr)**2*chw)
8127 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8129 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
8130 ! How did this happen?
8131 ! set values according to dBZ of -10, or Z = 0.1
8132 ! write(91,*) 'alpha = ',alpha(mgs,il)
8133 IF ( qx(mgs,il) < 1.e-8 ) THEN
8135 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8136 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8138 ! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
8139 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
8140 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8142 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8145 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*1000.*1000)
8146 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8150 IF ( zx(mgs,lr) > 0.0 ) THEN
8151 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(1000.*Max(1.0e-9,cx(mgs,lr)))
8153 ! z = 36.*(alpha(kz)+2.0)*a(ix,jy,kz,lnr)*vr**2/((alpha(kz)+1.0)*pi**2)
8158 ! xv = (db(1,kz)*a(1,1,kz,lr))**2/(a(1,1,kz,lnr))
8159 ! rd = z*(pi/6.*1000.)**2/xv
8161 ! determine shape parameter alpha by iteration
8162 IF ( z .gt. 0.0 ) THEN
8163 ! alpha(mgs,lr) = 3.
8164 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
8166 ! IF ( 100.*Abs(alp - alpha(mgs,lr))/Abs(alpha(mgs,lr)) .lt. 1. ) EXIT
8167 IF ( Abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
8168 alpha(mgs,lr) = Max( rnumin, Min( rnumax, alp ) )
8169 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
8170 ! write(0,*) 'i,alp = ',i,alp
8171 alp = Max( rnumin, Min( rnumax, alp ) )
8173 ! write(0,*) 'kz, alp, alpha(kz) = ',kz,alp,alpha(mgs,lr),qr*1000,z*1.e18,vr,nrx
8176 ! check for artificial breakup (rain larger than allowed max size)
8177 IF ( xv(mgs,il) .gt. xvmx(il) ) THEN
8179 xv(mgs,il) = Min( xvmx(il), Max( xvmn(il),xv(mgs,il) ) )
8180 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
8181 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
8182 IF ( tmp < cx(mgs,il) ) THEN ! breakup
8184 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8185 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
8186 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8194 ! determine shape parameter alpha by iteration
8195 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
8197 IF ( Abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
8198 alpha(mgs,lr) = Max( rnumin, Min( rnumax, alp ) )
8199 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
8200 alp = Max( rnumin, Min( rnumax, alp ) )
8208 ! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
8209 ! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
8211 ! IF ( alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax ) THEN
8212 IF ( .true. .and. (alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax) ) THEN
8214 IF ( rescale_high_alpha .and. alp >= rnumax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
8215 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8216 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(1./(xdn(mgs,il)))**2
8217 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
8219 ELSEIF ( rescale_low_alphar .and. alp <= rnumin ) THEN
8221 z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
8223 an(igs(mgs),jy,kgs(mgs),lz(il)) = z
8235 an(igs(mgs),jgs,kgs(mgs),ln(lr)) = cx(mgs,lr)
8236 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
8244 IF ( ipconc .ge. 6 ) THEN
8246 ! Find shape parameters for graupel,hail
8250 IF ( lz(il) .gt. 1 .and. (ildo == 0 .or. ildo == il ) .and. ( .not. ( il == lr .and. imurain == 3 )) ) THEN
8254 IF ( iresetmoments == 1 .or. iresetmoments == il .or. iresetmoments == -1 ) THEN
8255 IF ( zx(mgs,il) <= zxmin ) THEN ! .and. qx(mgs,il) > 0.05e-3 ) THEN
8258 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8259 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8260 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8261 ELSEIF ( iresetmoments == -1 .and. qx(mgs,il) < qxmin(il) ) THEN
8264 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8267 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8268 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8269 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8271 ELSEIF ( cx(mgs,il) <= cxmin .and. iresetmoments /= -1 ) THEN ! .and. qx(mgs,il) > 0.05e-3 ) THEN
8272 !! write(91,*) 'cx=0; qx,zx = ',1000.*qx(mgs,il),1.e18*zx(mgs,il)
8275 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8276 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8277 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8281 IF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= cxmin ) THEN
8284 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8286 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8287 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8288 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8291 IF ( qx(mgs,il) .gt. qxmin(il) ) THEN
8293 xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*Max(1.0e-9,cx(mgs,il)))
8294 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
8296 IF ( xv(mgs,il) .lt. xvmn(il) ) THEN
8298 xv(mgs,il) = Min( xvmx(il), Max( xvmn(il),xv(mgs,il) ) )
8299 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
8300 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
8301 ! IF ( tmp < cx(mgs,il) ) THEN ! breakup
8302 ! g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8303 ! & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
8304 ! zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
8305 ! an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8310 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
8311 ! have mass and reflectivity but no concentration, so set concentration, using default alpha
8312 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8313 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
8316 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(z*(pi*xdn(mgs,il))**2)
8317 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8319 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > cxmin ) THEN
8320 ! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
8321 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8322 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
8325 ! zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
8326 zx(mgs,il) = Min(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
8327 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8328 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
8329 ! How did this happen?
8330 ! write(91,*) 'ziegfall: something screwy with moments: il = ',il
8331 ! write(91,*) 'q,n,z = ', 1.e3*qx(mgs,il),cx(mgs,il),zx(mgs,il)
8332 ! write(91,*) 'alpha = ',alpha(mgs,il)
8334 IF ( qx(mgs,il) < 1.e-8 ) THEN
8336 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8337 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8339 ! write(0,*) 'alpha = ',alpha(mgs,il)
8340 ! set values according to dBZ of -10
8341 ! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
8342 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
8343 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8345 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8346 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
8349 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(z*(pi*xdn(mgs,il))**2)
8350 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8355 IF ( qx(mgs,il) .gt. qxmin(il) .and. cx(mgs,il) .gt. cxmin ) THEN
8360 IF ( zx(mgs,il) .gt. 0. ) THEN
8362 ! rd = z*(pi/6.*1000.)**2*chw/(0.224*(dn(igs(mgs),jy,kgs(mgs))*qr)**2)
8363 rd = z*(pi/6.*xdn(mgs,il))**2*chw/((dn(igs(mgs),jy,kgs(mgs))*qr)**2)
8365 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
8366 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd) - 1.0
8368 IF ( Abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
8369 alpha(mgs,il) = Max( alphamin, Min( alphamax, alp ) )
8370 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
8371 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd) - 1.0
8372 ! write(0,*) 'i,alp = ',i,alp
8373 alp = Max( alphamin, Min( alphamax, alp ) )
8378 ! check for artificial breakup (graupel/hail larger than allowed max size)
8380 IF ( imaxdiaopt == 1 ) THEN
8382 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
8383 xvbarmax = xvmx(il) /((3. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
8384 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
8385 xvbarmax = xvmx(il) /((4. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
8388 IF ( xv(mgs,il) .gt. xvbarmax ) THEN
8390 xv(mgs,il) = Min( xvbarmax, Max( xvmn(il),xv(mgs,il) ) )
8391 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
8392 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
8393 IF ( tmp < cx(mgs,il) ) THEN ! breakup
8394 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8395 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
8396 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
8397 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8403 rd = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
8404 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
8405 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd) - 1.0
8407 IF ( Abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
8408 alpha(mgs,il) = Max( alphamin, Min( alphamax, alp ) )
8409 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
8410 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd) - 1.0
8411 alp = Max( alphamin, Min( alphamax, alp ) )
8419 ! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
8420 ! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
8422 IF ( (rescale_low_alpha .or. rescale_high_alpha ) .and. &
8423 & ( alpha(mgs,il) <= alphamin .or. alp == alphamin .or. alp == alphamax ) ) THEN
8425 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8426 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
8428 IF ( rescale_high_alpha .and. alp >= alphamax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
8429 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(6./(pi*xdn(mgs,il)))**2
8430 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
8432 ELSEIF ( rescale_low_alpha .and. alp <= alphamin .and. .not. (il == lh .and. icvhl2h > 0 ) ) THEN
8434 !! z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*( 0.224*qr)*qr/chw
8435 z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
8436 z = z1*(6./(pi*xdn(mgs,il)))**2
8438 an(igs(mgs),jy,kgs(mgs),lz(il)) = z
8446 ENDIF ! lz(il) .gt. 1
8450 ! CALL cld_cpu('Z-MOMENT-ZFAll')
8454 IF ( lzhl > 1 ) THEN
8455 IF ( lhl .gt. 1 ) THEN
8465 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: call setvtz'
8468 call setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno,cnostmp, &
8469 & xmas,vtxbar,xdn,xvmn,xvmx,xv,cdx,cdxgs, &
8470 & ipconc,ndebugzf,ngs,nz,kgs,fadvisc, &
8471 & cwmasn,cwmasx,cwradn,cnina,cimn,cimx, &
8472 & itype1,itype2,temcg,infdo,alpha,ildo,axx,bxx)
8473 ! & itype1,itype2,temcg,infdo,alpha,ildo,axh,bxh,axhl,bxhl)
8478 ! put fall speeds into the x-z arrays
8486 IF ( vtxbar(mgs,il,2) .gt. vtxbar(mgs,il,1) .or. &
8487 & ( vtxbar(mgs,il,1) .gt. vtxbar(mgs,il,3) .and. vtxbar(mgs,il,3) > 0.0) ) THEN
8490 ! IF ( qx(mgs,il) > 1.e-4 .and. &
8491 ! & .not. ( il == lr .and. 1.e3*xdia(mgs,il,3) > 5.0 ) ) THEN
8492 ! write(0,*) 'infdo,mgs = ',infdo,lzr,mgs
8493 ! write(0,*) 'Moment problem with vtxbar for il at i,j,k = ',il,igs(mgs),jy,kgs(mgs)
8494 ! write(0,*) 'nx,ny,nz,ng = ',nx,ny,nz,nor
8495 ! write(0,*) 'cwmasn,cwmasx = ',cwmasn,cwmasx
8496 ! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,il,1),vtxbar(mgs,il,2),vtxbar(mgs,il,3)
8497 ! write(0,*) 'q,n,d = ', 1.e3*qx(mgs,il),cx(mgs,il),1.e3*xdia(mgs,il,3)
8498 ! IF ( il .ge. lr .and. lz(il) > 1 ) write(0,*) 'z = ', zx(mgs,il)
8499 ! IF ( il .ge. lg .or. il == lr ) THEN
8500 ! write(0,*) 'alpha = ',alpha(mgs,il)
8504 vtxbar(mgs,il,1) = Max( vtxbar(mgs,il,1), vtxbar(mgs,il,2) )
8505 vtxbar(mgs,il,3) = Max( vtxbar(mgs,il,3), vtxbar(mgs,il,1) )
8510 IF ( vtxbar(mgs,il,1) .gt. vtmax .or. vtxbar(mgs,il,2) .gt. vtmax .or. &
8511 & vtxbar(mgs,il,3) .gt. vtmax ) THEN
8513 ! IF ( ndebugzf >= 0 .and. 1.e3*qx(mgs,il) > 0.1 ) THEN
8514 ! write(0,*) 'infdo = ',infdo
8515 ! write(0,*) 'Problem with vtxbar for il at i,j,k = ',il,igs(mgs),jy,kgs(mgs)
8516 ! write(0,*) 'nx,ny,nz,ng = ',nx,ny,nz,nor
8517 ! write(0,*) 'cwmasn,cwmasx = ',cwmasn,cwmasx
8518 ! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,il,1),vtxbar(mgs,il,2),vtxbar(mgs,il,3)
8519 ! write(0,*) 'q,n,d = ', 1.e3*qx(mgs,il),cx(mgs,il),1.e3*xdia(mgs,il,3)
8520 ! IF ( il .ge. lr .and. lz(il) > 1 ) write(0,*) 'z = ', zx(mgs,il)
8521 ! IF ( il .ge. lg ) THEN
8522 ! write(0,*) 'alpha = ',alpha(mgs,il)
8525 vtxbar(mgs,il,1) = Min(vtmax,vtxbar(mgs,il,1) )
8526 vtxbar(mgs,il,2) = Min(vtmax,vtxbar(mgs,il,2) )
8527 vtxbar(mgs,il,3) = Min(vtmax,vtxbar(mgs,il,3) )
8529 ! call commasmpi_abort()
8533 xvt(kgs(mgs),igs(mgs),1,il) = vtxbar(mgs,il,1)
8534 xvt(kgs(mgs),igs(mgs),2,il) = vtxbar(mgs,il,2)
8535 IF ( infdo .ge. 2 ) THEN
8536 xvt(kgs(mgs),igs(mgs),3,il) = vtxbar(mgs,il,3)
8538 xvt(kgs(mgs),igs(mgs),3,il) = 0.0
8541 ! xvt(kgs(mgs),igs(mgs),2,il) = xvt(kgs(mgs),igs(mgs),1,il)
8547 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: COPIED FALL SPEEDS'
8553 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: DONE WITH LOOP'
8555 if ( kz .gt. nz-1 ) then
8561 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: SET NZMPB'
8565 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: SET NXMPB'
8574 if (ndebugzf .gt. 0 ) write(0,*) "ZIEGFALL: EXITING SUBROUTINE"
8578 END subroutine ziegfall1d
8580 ! #####################################################################
8581 ! #####################################################################
8584 ! #####################################################################
8585 ! #####################################################################
8587 ! ##############################################################################
8588 subroutine radardd02(nx,ny,nz,nor,na,an,temk, &
8589 & dbz,db,nzdbz,cnoh0t,hwdn1t,ipconc,ke_diag, iunit)
8591 ! 11.13.2005: Changed values of indices for reordering of lip
8593 ! 07.13.2005: Fixed an error where cnoh was being used for graupel and frozen drops
8595 ! 01.24.2005: add ice crystal reflectivity using parameterization of
8596 ! Heymsfield (JAS, 1977). Could also try Ferrier for this, too.
8598 ! 09.28.2002 Test alterations for dry ice following Ferrier (1994)
8599 ! for equivalent melted diameter reflectivity.
8600 ! Converted to Fortran by ERM.
8602 !Date: Tue, 21 Nov 2000 10:13:36 -0600 (CST)
8603 !From: Matthew Gilmore <gilmore@hesston.met.tamu.edu>
8605 !PRO RF_SPEC ; Computes Radar Reflectivity
8606 !COMMON MAINB, data, x1d, y1d, z1d, iconst, rconst, labels, nx, ny, nz, dshft
8608 !;MODIFICATION HISTORY
8609 !; 5/99 -Svelta Veleva introduces variable dielf (const_ki_x) as a (weak)
8610 !; function of density. This leads to slight modification of dielf such
8611 !; that the snow reflectivity is slightly increased - not a big effect.
8612 !; This is believed to be more accurate than assuming the dielectric
8613 !; constant for snow is the same as for hail in previous versions.
8615 !;On 6/13/99 I added the VIL computation (k=0 in vil array)
8616 !;On 6/15/99 I removed the number concentration dependencies as a function
8617 !; of temperature (only use for ferrier!)
8618 !;On 6/15/99 I added the Composite reflectivity (k=1 in VIL array)
8619 !;On 6/15/99 I added the Severe Hail Index computation (k=2 in vil array)
8621 !; 6/99 - Veleva and Seo argue that since graupel is more similar to
8622 !; snow (in number conc and size density) than it is to hail, we
8623 !; should not weight wetted graupel with the .95 exponent correction
8624 !; factor as in the case of hail. An if-statement checks the size
8625 !; density for wet hail/graupel and treats them appropriately.
8627 !; 6/22/99 - Added function to compute height of max rf and 40 dbz echo top
8628 !; Also added vilqr which is the model vertical integrated liquid only
8629 !; using qr. Will need to check...does not seem consistent with vilZ
8635 character(LEN=15), parameter :: microp = 'ZVD'
8636 integer nx,ny,nz,nor,na,ngt
8637 integer nzdbz ! how many levels actually to process
8641 integer, parameter :: printyn = 0
8643 parameter( ng1 = 1 )
8651 integer imapz,mzdist
8654 integer, parameter :: norz = 3
8655 real an(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,na)
8656 real db(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor) ! air density
8657 ! real gt(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,ngt)
8658 real temk(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor) ! air temperature (kelvin)
8659 real dbz(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor) ! reflectivity
8660 real gz(-nor+1:nz+nor) ! ,z1d(-nor+1:nz+nor,4)
8662 ! real g,rgas,eta,inveta
8663 real cr1, cr2 , hwdnsq,swdnsq
8664 real rwdnsq, dhmin, qrmin, qsmin, qhmin, qhlmin, tfr, tfrh, zrc
8665 real reflectmin, kw_sq
8666 real const_ki_sn, const_ki_h, ki_sq_sn
8667 real ki_sq_h, dielf_sn, dielf_h
8676 real*8 dtmps, dtmpr, dtmph, dtmphl, g1, zx, ze, x
8678 integer i,j,k,ix,jy,kz,ihcnt
8680 real*8 xcnoh, xcnos, dadh, dads, zhdryc, zsdryc, zhwetc,zswetc
8683 parameter ( dbzmin = 0 )
8685 real cnow,cnoi,cnoip,cnoir,cnor,cnos
8686 real cnogl,cnogm,cnogh,cnof,cnoh,cnohl
8688 real swdn, rwdn ,hwdn,gldn,gmdn,ghdn,fwdn,hldn
8691 real rwdnmx,cwdnmx,cidnmx,xidnmx,swdnmx,gldnmx,gmdnmx
8692 real ghdnmx,fwdnmx,hwdnmx,hldnmx
8693 real rwdnmn,cwdnmn,cidnmn,xidnmn,swdnmn,gldnmn,gmdnmn
8694 real ghdnmn,fwdnmn,hwdnmn,hldnmn
8696 real gldnsq,gmdnsq,ghdnsq,fwdnsq,hldnsq
8698 real dadgl,dadgm,dadgh,dadhl,dadf
8699 real zgldryc,zglwetc,zgmdryc, zgmwetc,zghdryc,zghwetc
8700 real zhldryc,zhlwetc,zfdryc,zfwetc
8702 real dielf_gl,dielf_gm,dielf_gh,dielf_hl,dielf_fw
8706 real swdia,gldia,gmdia,ghdia,fwdia,hwdia,hldia
8708 real csw,cgl,cgm,cgh,cfw,chw,chl
8709 real xvs,xvgl,xvgm,xvgh,xvf,xvh,xvhl
8715 parameter ( rhos = 0.1 )
8717 real qxw,qxw1 ! temp value for liquid water on ice mixing ratio
8721 real, parameter :: cwmasn = 5.23e-13 ! minimum mass, defined by radius of 5.0e-6
8722 real, parameter :: cwmasx = 5.25e-10 ! maximum mass, defined by radius of 50.0e-6
8723 real, parameter :: cwradn = 5.0e-6 ! minimum radius
8727 real :: vzsnow, vzrain, vzgraupel, vzhail
8732 ! #########################################################################
8738 ! g=9.806 ! g: gravity constant
8739 ! rgas=287.04 ! rgas: gas constant for dry air
8740 ! rcp=rgas/cp ! rcp: gamma constant
8747 cwc0 = piinv ! 1./pi ! 6.0/pi
8760 ! default slope intercepts
8781 IF ( microp(1:4) .eq. 'ZIEG' ) THEN ! na .ge. 14 .and. ipconc .ge. 3 ) THEN
8783 ! write(0,*) 'Set reflectivity for ZIEG'
8786 hwdn = hwdn1t ! 500.
8795 IF ( lhl .gt. 1 ) THEN
8800 ELSEIF ( microp(1:3) .eq. 'ZVD' ) THEN ! na .ge. 14 .and. ipconc .ge. 3 ) THEN
8813 IF ( lhl .gt. 1 ) THEN
8817 ! write(*,*) 'radardbz: ',db(1,1,1),temk(1,1,1),an(1,1,1,lr),an(1,1,1,ls),an(1,1,1,lh)
8825 ! IF ( lh > 1 ) THEN
8826 ! cdx(lh) = 0.8 ! 1.0 ! 0.45
8830 ! IF ( lhl .gt. 1 ) cdx(lhl) = 0.45
8838 ! IF ( lh > 1 ) THEN
8845 ! IF ( lhl .gt. 1 ) THEN
8846 ! xvmn(lhl) = xvhlmn
8847 ! xvmx(lhl) = xvhlmx
8850 ! xdnmx(lr) = 1000.0
8851 ! xdnmx(lc) = 1000.0
8852 ! IF ( lh > 1 ) THEN
8857 ! IF ( lhl .gt. 1 ) xdnmx(lhl) = 900.0
8861 ! xdnmn(lr) = 1000.0
8862 ! xdnmn(lc) = 1000.0
8863 ! IF ( lh > 1 ) THEN
8868 ! IF ( lhl .gt. 1 ) xdnmn(lhl) = 500.0
8874 ! IF ( lh > 1 ) THEN
8876 ! xdn0(ls) = 100.0 ! 100.0
8877 ! xdn0(lh) = hwdn1t ! (0.5)*(xdnmn(lh)+xdnmx(lh))
8879 ! IF ( lhl .gt. 1 ) xdn0(lhl) = 800.0
8898 ! density maximums and minimums
8925 gldn = (0.5)*(gldnmn+gldnmx) ! 300.
8926 gmdn = (0.5)*(gmdnmn+gmdnmx) ! 500.
8927 ghdn = (0.5)*(ghdnmn+ghdnmx) ! 700.
8928 fwdn = (0.5)*(fwdnmn+fwdnmx) ! 800.
8929 hldn = (0.5)*(hldnmn+hldnmx) ! 900.
8955 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8956 ! Dielectric Factor - Formulas implemented by Svetla Veleva
8957 ! following Battan, "Radar Meteorology" - p. 40
8958 ! The result of these calculations is that the dielf numerator (ki_sq) without
8959 ! the density ratio is .2116 for hail if using 917 density and .25 for
8960 ! snow if using 220 density.
8961 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8962 const_ki_sn = 0.5 - (0.5-0.46)/(917.-220.)*(swdn-220.)
8963 const_ki_h = 0.5 - (0.5-0.46)/(917.-220.)*(hwdn-220.)
8964 ki_sq_sn = (swdnsq/rwdnsq) * const_ki_sn**2
8965 ki_sq_h = (hwdnsq/rwdnsq) * const_ki_h**2
8966 dielf_sn = ki_sq_sn / kw_sq
8967 dielf_h = ki_sq_h / kw_sq
8969 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8970 ! Use the next line if you want to hardwire dielf for dry hail for both dry
8971 ! snow and dry hail.
8972 ! This would be equivalent to what Straka had originally. (i.e, .21/.93)
8973 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8974 dielf_sn = (swdnsq/rwdnsq)*.21/ kw_sq
8975 dielf_h = (hwdnsq/rwdnsq)*.21/ kw_sq
8977 dielf_gl = (gldnsq/rwdnsq)*.21/ kw_sq
8978 dielf_gm = (gmdnsq/rwdnsq)*.21/ kw_sq
8979 dielf_gh = (ghdnsq/rwdnsq)*.21/ kw_sq
8980 dielf_hl = (hldnsq/rwdnsq)*.21/ kw_sq
8981 dielf_fw = (fwdnsq/rwdnsq)*.21/ kw_sq
8983 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8984 ! Notes on dielectric factors - from Eun-Kyoung Seo
8985 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8986 ! constants for both snow and hail would be (x=s,h).....
8987 ! xwdnsq/rwdnsq *0.21/kw_sq ! Straka/Smith - the original
8988 ! xwdnsq/rwdnsq *0.224 ! Ferrier - for particle sizes in equiv. drop diam
8989 ! xwdnsq/rwdnsq *0.176/kw_sq ! =0.189 in Smith - for particle sizes in equiv
8991 ! xwdnsq/rwdnsq *0.208/kw_sq ! Smith 1984 - for particle sizes in equiv melted drop diameter
8992 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8995 ! VIL algorithm constants
8996 ! Ztop = 10.**(56./10) !56 dbz is the max rf used by WATADS in cell vil
8999 ! Hail detection algorithm constants
9002 ! Ho = 3400. !WATADS Defaults
9003 ! Hm20 = 6200. !WATADS Defaults
9005 ! DO kz = 1,Min(nzdbz,nz-1)
9009 DO kz = 1,ke_diag ! nz
9023 dadr = (db(ix,jy,kz)/(pi*rwdn*cnor))**(0.25)
9024 !-----------------------------------------------------------------------
9025 ! Compute Rain Radar Reflectivity
9026 !-----------------------------------------------------------------------
9030 IF ( an(ix,jy,kz,lr) .ge. qrmin ) THEN
9031 IF ( ipconc .le. 2 ) THEN
9032 gtmp(ix,kz) = dadr*an(ix,jy,kz,lr)**(0.25)
9033 dtmp(ix,kz) = zrc*gtmp(ix,kz)**7
9034 ELSEIF ( lzr .gt. 1 ) THEN
9035 dtmp(ix,kz) = 1e18*an(ix,jy,kz,lzr)
9036 ELSEIF ( an(ix,jy,kz,lnr) .gt. 1.e-3 ) THEN
9037 IF ( imurain == 3 ) THEN
9038 vr = db(ix,jy,kz)*an(ix,jy,kz,lr)/(1000.*an(ix,jy,kz,lnr))
9039 dtmp(ix,kz) = 3.6e18*(rnu+2.)*an(ix,jy,kz,lnr)*vr**2/(rnu+1.)
9041 g1 = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
9042 zx = g1*(db(ix,jy,kz)*an(ix,jy,kz,lr))**2/an(ix,jy,kz,lnr)
9043 ze =1.e18*zx*(6./(pi*1000.))**2 ! note: using 1000. here for water density
9050 !-----------------------------------------------------------------------
9051 ! Compute snow and graupel reflectivity
9053 ! Lou modified to look at parcel temperature rather than base state
9054 !-----------------------------------------------------------------------
9056 IF( lhab .gt. lr ) THEN
9058 ! qs2d = reform(data[*,*,k,10],[nx*ny])
9059 ! qh2d = reform(data[*,*,k,11],[nx*ny])
9061 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9062 ! Only use the following lines if running Straka GEMS microphysics
9063 ! (Sam 1-d version modified by L Wicker does not use this)
9064 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9065 ! ;xcnoh = cnoh*exp(-0.025*(temp-tfr))
9066 ! ;xcnos = cnos*exp(-0.038*(temp-tfr))
9067 ! ;good = where(temp GT tfr, n_elements)
9068 ! ;IF n_elements NE 0 THEN xcnoh(good) = cnoh*exp(-0.075*(temp(good)-tfr))
9069 ! ;IF n_elements NE 0 THEN xcnos(good) = cnos*exp(-0.088*(temp(good)-tfr))
9071 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9072 ! Only use the following lines if running Ferrier micro with No=No(T)
9073 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9076 ! ; xcnoh = cnoh*(1.>exp(NOGE*(temp-tfr)) )
9077 ! ; xcnos = cnos*(1.>exp(NOSE*(temp-tfr)) )
9079 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9080 ! Use the following lines if Nos and Noh are constant
9081 ! (As in Svetla version of Ferrier, GCE Tao, and SAM 1-d)
9082 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9087 ! Temporary fix for predicted number concentration -- need a
9088 ! more appropriate reflectivity equation!
9090 ! IF ( an(ix,jy,kz,lns) .lt. 0.1 ) THEN
9091 ! swdia = (xvrmn*cwc0)**(1./3.)
9092 ! xcnos = an(ix,jy,kz,ls)*db(ix,jy,kz)/(xvrmn*swdn*swdia)
9094 ! ! changed back to diameter of mean volume!!!
9096 ! > (an(ix,jy,kz,ls)*db(ix,jy,kz)
9097 ! > /(pi*swdn*an(ix,jy,kz,lns)))**(1./3.)
9099 ! xcnos = an(ix,jy,kz,lns)/swdia
9102 IF ( ls .gt. 1 ) THEN ! {
9104 IF ( lvs .gt. 1 ) THEN
9105 IF ( an(ix,jy,kz,lvs) .gt. 0.0 ) THEN
9106 swdn = db(ix,jy,kz)*an(ix,jy,kz,ls)/an(ix,jy,kz,lvs)
9107 swdn = Min( 300., Max( 100., swdn ) )
9114 IF ( ipconc .ge. 5 ) THEN ! {
9116 xvs = db(ix,jy,kz)*an(ix,jy,kz,ls)/ &
9117 & (swdn*Max(1.0e-3,an(ix,jy,kz,lns)))
9118 IF ( xvs .lt. xvsmn .or. xvs .gt. xvsmx ) THEN
9119 xvs = Min( xvsmx, Max( xvsmn,xvs ) )
9120 csw = db(ix,jy,kz)*an(ix,jy,kz,ls)/(xvs*swdn)
9123 swdia = (xvs*cwc0)**(1./3.)
9124 xcnos = an(ix,jy,kz,ls)*db(ix,jy,kz)/(xvs*swdn*swdia)
9129 ! IF ( an(ix,jy,kz,lnh) .lt. 0.1 ) THEN
9130 ! hwdia = (xvrmn*cwc0)**(1./3.)
9131 ! xcnoh = an(ix,jy,kz,lh)*db(ix,jy,kz)/(xvrmn*hwdn*hwdia)
9133 ! ! changed back to diameter of mean volume!!!
9135 ! > (an(ix,jy,kz,lh)*db(ix,jy,kz)
9136 ! > /(pi*hwdn*an(ix,jy,kz,lnh)))**(1./3.)
9138 ! xcnoh = an(ix,jy,kz,lnh)/hwdia
9141 IF ( lh .gt. 1 ) THEN ! {
9143 IF ( lvh .gt. 1 ) THEN
9144 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
9145 hwdn = db(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
9146 hwdn = Min( 900., Max( hdnmn, hwdn ) )
9148 hwdn = 500. ! hwdn1t
9154 IF ( ipconc .ge. 5 ) THEN ! {
9156 xvh = db(ix,jy,kz)*an(ix,jy,kz,lh)/ &
9157 & (hwdn*Max(1.0e-3,an(ix,jy,kz,lnh)))
9158 IF ( xvh .lt. xvhmn .or. xvh .gt. xvhmx ) THEN
9159 xvh = Min( xvhmx, Max( xvhmn,xvh ) )
9160 chw = db(ix,jy,kz)*an(ix,jy,kz,lh)/(xvh*hwdn)
9163 hwdia = (xvh*cwc0)**(1./3.)
9164 xcnoh = an(ix,jy,kz,lh)*db(ix,jy,kz)/(xvh*hwdn*hwdia)
9166 ENDIF ! } ipconc .ge. 5
9173 IF ( xcnoh .gt. 0.0 ) THEN
9174 dadh = ( db(ix,jy,kz) /(pi*hwdn*xcnoh) )**(.25)
9175 zhdryc = 0.224*cr2*(db(ix,jy,kz)/rwdn)**2/xcnoh ! dielf_h*cr1*xcnoh ! SV - equiv formula as before but
9176 ! ratio of densities included in
9177 ! dielf_h rather than here following
9184 IF ( xcnos .gt. 0.0 ) THEN
9185 dads = ( db(ix,jy,kz) /(pi*swdn*xcnos) )**(.25)
9186 zsdryc = 0.224*cr2*(db(ix,jy,kz)/rwdn)**2/xcnos ! dielf_sn*cr1*xcnos ! SV - similar change as above
9191 zhwetc = zhdryc ! cr1*xcnoh !Hail/graupel version with .95 power bug removed
9192 zswetc = zsdryc ! cr1*xcnos
9196 IF ( ls .gt. 1 ) THEN
9202 IF ( an(ix,jy,kz,ls) .ge. qsmin ) THEN !{
9203 IF ( ipconc .ge. 4 ) THEN ! (Ferrier 94) !{
9205 if (lsw .gt. 1) THEN
9206 qxw = an(ix,jy,kz,lsw)
9208 ELSEIF ( ( iusewetsnow == 1 .or. iusewetsnow == 3) .and. temk(ix,jy,kz) .gt. tfr+1. &
9209 & .and. an(ix,jy,kz,ls) > an(ix,jy,kz,lr) .and. an(ix,jy,kz,lr) > qsmin) THEN
9210 qxw = Min(0.5*an(ix,jy,kz,ls), an(ix,jy,kz,lr))
9214 vr = xvs ! db(ix,jy,kz)*an(ix,jy,kz,lr)/(1000.*an(ix,jy,kz,lnr))
9215 ! gtmp(ix,kz) = 3.6e18*(0.243*rhos**2/0.93)*(snu+2.)*an(ix,jy,kz,lns)*vr**2/(snu+1.)
9217 ksq = 0.189 ! Smith (1984, JAMC) for equiv. ice sphere
9218 IF ( an(ix,jy,kz,lns) .gt. 1.e-7 ) THEN
9219 ! IF ( .true. ) THEN
9220 IF ( qxw > qsmin .or. iusewetsnow >= 2 ) THEN ! old version
9221 ! gtmp(ix,kz) = 3.6e18*(snu+2.)*( 0.224*an(ix,jy,kz,ls) + 0.776*qxw)*an(ix,jy,kz,ls)/ &
9222 ! & (an(ix,jy,kz,lns)*(snu+1.)*rwdn**2)*db(ix,jy,kz)**2
9223 gtmp(ix,kz) = 3.6e18*(snu+2.)*( 0.224*(an(ix,jy,kz,ls)+qxw1) + 0.776*qxw)*(an(ix,jy,kz,ls)+qxw1)/ &
9224 & (an(ix,jy,kz,lns)*(snu+1.)*rwdn**2)*db(ix,jy,kz)**2
9226 ELSE ! new form using a mass relationship m = p d^2 (instead of d^3 -- Cox 1988 QJRMS) so that density depends on size
9227 ! p = 0.106214 for m = p v^(2/3)
9228 dnsnow = 0.0346159*sqrt(an(ix,jy,kz,lns)/(an(ix,jy,kz,ls)*db(ix,jy,kz)) )
9229 IF ( .true. .or. dnsnow < 900. ) THEN
9230 gtmp(ix,kz) = 1.e18*323.3226* 0.106214**2*(ksq*an(ix,jy,kz,ls) + &
9231 & (1.-ksq)*qxw)*an(ix,jy,kz,ls)*db(ix,jy,kz)**2*gsnow73/ &
9232 & (an(ix,jy,kz,lns)*(917.)**2* gsnow1*(1.0+snu)**(4./3.))
9233 ELSE ! otherwise small enough to assume ice spheres?
9234 gtmp(ix,kz) = (36./pi**2) * 1.e18*(snu+2.)*( 0.224*(an(ix,jy,kz,ls)+qxw1) + 0.776*qxw)*(an(ix,jy,kz,ls)+qxw1)/ &
9235 & (an(ix,jy,kz,lns)*(snu+1.)*rwdn**2)*db(ix,jy,kz)**2
9242 ! tmp = Min(1.0,1.e3*(an(ix,jy,kz,ls))*db(ix,jy,kz))
9243 ! gtmp(ix,kz) = Max( 1.0*gtmp(ix,kz), 750.0*(tmp)**1.98)
9245 dtmp(ix,kz) = dtmp(ix,kz) + gtmp(ix,kz)
9246 ELSE ! }{ single-moment snow:
9247 gtmp(ix,kz) = dads*an(ix,jy,kz,ls)**(0.25)
9249 IF ( gtmp(ix,kz) .gt. 0.0 ) THEN !{
9250 dtmps = zsdryc*an(ix,jy,kz,ls)**2/gtmp(ix,kz)
9251 IF ( temk(ix,jy,kz) .lt. tfr ) THEN
9252 dtmp(ix,kz) = dtmp(ix,kz) + &
9253 & zsdryc*an(ix,jy,kz,ls)**2/gtmp(ix,kz)
9255 dtmp(ix,kz) = dtmp(ix,kz) + &
9256 & zswetc*an(ix,jy,kz,ls)**2/gtmp(ix,kz)
9267 ! ice crystal contribution (Heymsfield, 1977, JAS)
9269 IF ( li .gt. 1 .and. idbzci .ne. 0 ) THEN
9271 IF ( idbzci == 1 .and. lni > 0 ) THEN
9272 ! assume spherical ice with density of 900 for dbz calc
9273 IF ( an(ix,jy,kz,li) > qxmin(li) .and. an(ix,jy,kz,lni) > 1.0 ) THEN
9274 vr = db(ix,jy,kz)*an(ix,jy,kz,li)/(900.*an(ix,jy,kz,lni))
9275 dtmp(ix,kz) = dtmp(ix,kz) + &
9276 & 0.224*3.6e18*(cinu+2.)*an(ix,jy,kz,lni)*vr**2/(cinu+1.)*(900./1000.)**2
9279 ELSEIF ( idbzci == 2 ) THEN
9281 ! ice crystal contribution (Heymsfield, 1977, JAS)
9284 IF ( an(ix,jy,kz,li) .ge. 0.1e-3 ) THEN
9285 gtmp(ix,kz) = Min(1.0,1.e3*(an(ix,jy,kz,li))*db(ix,jy,kz))
9286 dtmp(ix,kz) = dtmp(ix,kz) + 750.0*(gtmp(ix,kz))**1.98
9294 ! graupel/hail contribution
9296 IF ( lh .gt. 1 ) THEN ! {
9301 IF ( izieg .ge. 1 .and. ipconc .ge. 5 ) THEN
9305 IF ( an(ix,jy,kz,lzh) > 0.0 .and. an(ix,jy,kz,lh) > qhmin .and. &
9306 an(ix,jy,kz,lnh) >= cxmin ) ltest = .true.
9309 IF ( ltest .or. (an(ix,jy,kz,lh) .ge. qhmin .and. an(ix,jy,kz,lnh) .ge. cxmin )) THEN
9311 IF ( lvh .gt. 1 ) THEN
9313 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
9314 hwdn = db(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
9315 hwdn = Min( 900., Max( 100., hwdn ) )
9317 hwdn = 500. ! hwdn1t
9322 chw = an(ix,jy,kz,lnh)
9323 IF ( chw .gt. 0.0 ) THEN ! (Ferrier 94)
9324 xvh = db(ix,jy,kz)*an(ix,jy,kz,lh)/(hwdn*Max(1.0e-3,chw))
9325 IF ( xvh .lt. xvhmn .or. xvh .gt. xvhmx ) THEN
9326 xvh = Min( xvhmx, Max( xvhmn,xvh ) )
9327 chw = db(ix,jy,kz)*an(ix,jy,kz,lh)/(xvh*hwdn)
9330 qh = an(ix,jy,kz,lh)
9332 IF ( lhw .gt. 1 ) THEN
9333 IF ( iusewetgraupel .eq. 1 ) THEN
9334 qxw = an(ix,jy,kz,lhw)
9335 ELSEIF ( iusewetgraupel .eq. 2 ) THEN
9336 IF ( hwdn .lt. 300. ) THEN
9337 qxw = an(ix,jy,kz,lhw)
9340 ELSEIF ( iusewetgraupel .eq. 3 ) THEN
9341 IF ( hwdn .lt. 300. .and. temk(ix,jy,kz) > tfr .and. an(ix,jy,kz,lr) > qhmin ) THEN
9342 qxw = Min( an(ix,jy,kz,lh), an(ix,jy,kz,lr))
9345 ELSEIF ( iusewetgraupel == 4 .and. temk(ix,jy,kz) .gt. tfr+0.25 .and. an(ix,jy,kz,lh) > an(ix,jy,kz,lr) &
9346 & .and. an(ix,jy,kz,lr) > qhmin) THEN
9347 qxw = Min(0.5*an(ix,jy,kz,lh), an(ix,jy,kz,lr))
9352 IF ( lzh .gt. 1 ) THEN
9353 x = (0.224*qh + 0.776*qxw)/an(ix,jy,kz,lh) ! weighted average of dielectric const
9354 dtmph = 1.e18*x*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
9355 dtmp(ix,kz) = dtmp(ix,kz) + dtmph
9357 g1 = (6.0 + alphah)*(5.0 + alphah)*(4.0 + alphah)/((3.0 + alphah)*(2.0 + alphah)*(1.0 + alphah))
9358 ! zx = g1*(db(ix,jy,kz)*an(ix,jy,kz,lh))**2/chw
9359 ! ze = 0.224*1.e18*zx*(6./(pi*1000.))**2
9360 zx = g1*db(ix,jy,kz)**2*( 0.224*qh + 0.776*qxw)*qh/chw
9361 ze =1.e18*zx*(6./(pi*1000.))**2
9362 dtmp(ix,kz) = dtmp(ix,kz) + ze
9368 ! IF ( an(ix,jy,kz,lh) .gt. 1.0e-3 ) write(0,*) 'Graupel Z : ',dtmph,ze
9375 IF ( an(ix,jy,kz,lh) .ge. qhmin ) THEN
9376 gtmp(ix,kz) = dadh*an(ix,jy,kz,lh)**(0.25)
9377 IF ( gtmp(ix,kz) .gt. 0.0 ) THEN
9378 dtmph = zhdryc*an(ix,jy,kz,lh)**2/gtmp(ix,kz)
9379 IF ( temk(ix,jy,kz) .lt. tfr ) THEN
9380 dtmp(ix,kz) = dtmp(ix,kz) + &
9381 & zhdryc*an(ix,jy,kz,lh)**2/gtmp(ix,kz)
9383 ! IF ( hwdn .gt. 700.0 ) THEN
9384 dtmp(ix,kz) = dtmp(ix,kz) + &
9385 & zhdryc*an(ix,jy,kz,lh)**2/gtmp(ix,kz)
9387 ! & (zhwetc*gtmp(ix,kz)**7)**0.95
9389 ! dtmp(ix,kz) = dtmp(ix,kz) + zhwetc*gtmp(ix,kz)**7
9405 IF ( izieg .ge. 1 .and. lhl .gt. 1 ) THEN
9413 IF ( lvhl .gt. 1 ) THEN
9414 IF ( an(ix,jy,kz,lvhl) .gt. 0.0 ) THEN
9415 hldn = db(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
9416 hldn = Min( 900., Max( 300., hldn ) )
9425 IF ( ipconc .ge. 5 ) THEN
9428 IF ( lzhl > 1 ) THEN
9429 IF ( an(ix,jy,kz,lzhl) > 0.0 .and. an(ix,jy,kz,lhl) > qhlmin .and. &
9430 an(ix,jy,kz,lnhl) > 0.0 ) ltest = .true.
9433 IF ( ltest .or. ( an(ix,jy,kz,lhl) .ge. qhlmin .and. an(ix,jy,kz,lnhl) .gt. 0.) ) THEN !{
9434 chl = an(ix,jy,kz,lnhl)
9435 IF ( chl .gt. 0.0 ) THEN !{
9436 xvhl = db(ix,jy,kz)*an(ix,jy,kz,lhl)/ &
9437 & (hldn*Max(1.0e-9,an(ix,jy,kz,lnhl)))
9438 IF ( xvhl .lt. xvhlmn .or. xvhl .gt. xvhlmx ) THEN ! {
9439 xvhl = Min( xvhlmx, Max( xvhlmn,xvhl ) )
9440 chl = db(ix,jy,kz)*an(ix,jy,kz,lhl)/(xvhl*hldn)
9441 ! do not update state in dbz calc. ! an(ix,jy,kz,lnhl) = chl
9444 IF ( lhlw .gt. 1 ) THEN
9445 IF ( iusewethail .eq. 1 ) THEN
9446 qxw = an(ix,jy,kz,lhlw)
9447 ELSEIF ( iusewethail .eq. 2 ) THEN
9448 IF ( hldn .lt. 300. ) THEN
9449 qxw = an(ix,jy,kz,lhlw)
9454 IF ( lzhl .gt. 1 ) THEN !{
9455 x = (0.224*an(ix,jy,kz,lhl) + 0.776*qxw)/an(ix,jy,kz,lhl) ! weighted average of dielectric const
9456 dtmphl = 1.e18*x*an(ix,jy,kz,lzhl)*(hldn/rwdn)**2
9457 dtmp(ix,kz) = dtmp(ix,kz) + dtmphl
9460 g1 = (6.0 + alphahl)*(5.0 + alphahl)*(4.0 + alphahl)/((3.0 + alphahl)*(2.0 + alphahl)*(1.0 + alphahl))
9461 zx = g1*db(ix,jy,kz)**2*( 0.224*an(ix,jy,kz,lhl) + 0.776*qxw)*an(ix,jy,kz,lhl)/chl
9462 ! zx = g1*(db(ix,jy,kz)*an(ix,jy,kz,lhl))**2/chl
9463 ze = 1.e18*zx*(6./(pi*1000.))**2 ! 3/28/2016 removed extra factor of 0.224
9464 dtmp(ix,kz) = dtmp(ix,kz) + ze
9469 ! IF ( an(ix,jy,kz,lh) .gt. 1.0e-3 ) write(0,*) 'Graupel Z : ',dtmph,ze
9476 IF ( an(ix,jy,kz,lhl) .ge. qhlmin ) THEN ! {
9477 dadhl = ( db(ix,jy,kz) /(pi*hldn*cnohl) )**(.25)
9478 gtmp(ix,kz) = dadhl*an(ix,jy,kz,lhl)**(0.25)
9479 IF ( gtmp(ix,kz) .gt. 0.0 ) THEN ! {
9481 zhldryc = 0.224*cr2*( db(ix,jy,kz)/rwdn)**2/cnohl
9483 dtmphl = zhldryc*an(ix,jy,kz,lhl)**2/gtmp(ix,kz)
9485 IF ( temk(ix,jy,kz) .lt. tfr ) THEN
9486 dtmp(ix,kz) = dtmp(ix,kz) + &
9487 & zhldryc*an(ix,jy,kz,lhl)**2/gtmp(ix,kz)
9489 ! IF ( hwdn .gt. 700.0 ) THEN
9490 dtmp(ix,kz) = dtmp(ix,kz) + &
9491 & zhldryc*an(ix,jy,kz,lhl)**2/gtmp(ix,kz)
9493 ! : (zhwetc*gtmp(ix,kz)**7)**0.95
9495 ! dtmp(ix,kz) = dtmp(ix,kz) + zhwetc*gtmp(ix,kz)**7
9502 ENDIF ! ipconc .ge. 5
9505 ENDIF ! izieg .ge. 1 .and. lhl .gt. 1
9509 IF ( dtmp(ix,kz) .gt. 0.0 ) THEN
9510 dbz(ix,jy,kz) = Max(dbzmin, 10.0*Log10(dtmp(ix,kz)) )
9512 IF ( dbz(ix,jy,kz) .gt. dbzmax ) THEN
9513 dbzmax = Max(dbzmax,dbz(ix,jy,kz))
9519 dbz(ix,jy,kz) = dbzmin
9520 IF ( lh > 1 .and. lhl > 1) THEN
9521 IF ( an(ix,jy,kz,lh) > 1.0e-3 ) THEN
9522 write(0,*) 'radardbz: qr,qh,qhl = ',an(ix,jy,kz,lr), an(ix,jy,kz,lh),an(ix,jy,kz,lhl)
9523 write(0,*) 'radardbz: dtmps,dtmph,dadh,dadhl,dtmphl = ',dtmps,dtmph,dadh,dadhl,dtmphl
9525 IF ( lzh>1 .and. lzhl>1 ) write(0,*) 'radardbz: zh, zhl = ',an(ix,jy,kz,lzh),an(ix,jy,kz,lzhl)
9530 ! IF ( an(ix,jy,kz,lh) .gt. 1.e-4 .and.
9531 ! & dbz(ix,jy,kz) .le. 0.0 ) THEN
9532 ! write(0,*) 'dbz = ',dbz(ix,jy,kz)
9533 ! write(0,*) 'Hail intercept: ',xcnoh,ix,kz
9534 ! write(0,*) 'Hail,snow q: ',an(ix,jy,kz,lh),an(ix,jy,kz,ls)
9535 ! write(0,*) 'Hail,snow c: ',an(ix,jy,kz,lnh),an(ix,jy,kz,lns)
9536 ! write(0,*) 'dtmps,dtmph = ',dtmps,dtmph
9538 IF ( .not. dtmp(ix,kz) .lt. 1.e30 .or. dbz(ix,jy,kz) > 190.0 ) THEN
9539 ! IF ( ix == 31 .and. kz == 20 .and. jy == 23 ) THEN
9540 ! write(0,*) 'my_rank = ',my_rank
9541 write(0,*) 'ix,jy,kz = ',ix,jy,kz
9542 write(0,*) 'dbz = ',dbz(ix,jy,kz)
9543 write(0,*) 'db, zhdryc = ',db(ix,jy,kz),zhdryc
9544 write(0,*) 'Hail intercept: ',xcnoh,ix,kz
9545 write(0,*) 'Hail,snow q: ',an(ix,jy,kz,lh),an(ix,jy,kz,ls)
9546 write(0,*) 'graupel density hwdn = ',hwdn
9547 write(0,*) 'rain q: ',an(ix,jy,kz,lr)
9548 write(0,*) 'ice q: ',an(ix,jy,kz,li)
9549 IF ( lhl .gt. 1 ) write(0,*) 'Hail (lhl): ',an(ix,jy,kz,lhl)
9550 IF (ipconc .ge. 3 ) write(0,*) 'rain c: ',an(ix,jy,kz,lnr)
9551 IF ( lzr > 1 ) write(0,*) 'rain Z: ',an(ix,jy,kz,lzr)
9552 IF ( ipconc .ge. 5 ) THEN
9553 write(0,*) 'Hail,snow c: ',an(ix,jy,kz,lnh),an(ix,jy,kz,lns)
9554 IF ( lhl .gt. 1 ) write(0,*) 'Hail (lnhl): ',an(ix,jy,kz,lnhl)
9555 IF ( lzhl .gt. 1 ) THEN
9556 write(0,*) 'Hail (lzhl): ',an(ix,jy,kz,lzhl)
9557 write(0,*) 'chl,xvhl,dhl = ',chl,xvhl,(xvhl*6./3.14159)**(1./3.)
9558 write(0,*) 'xvhlmn,xvhlmx = ',xvhlmn,xvhlmx
9561 write(0,*) 'chw,xvh = ', chw,xvh
9562 write(0,*) 'dtmps,dtmph,dadh,dadhl,dtmphl = ',dtmps,dtmph,dadh,dadhl,dtmphl
9563 write(0,*) 'dtmpr = ',dtmpr
9564 write(0,*) 'gtmp = ',gtmp(ix,kz),dtmp(ix,kz)
9565 IF ( .not. (dbz(ix,jy,kz) .gt. -100 .and. dbz(ix,jy,kz) .lt. 200 ) ) THEN
9566 write(0,*) 'dbz out of bounds!'
9579 ! write(0,*) 'na,lr = ',na,lr
9580 IF ( printyn .eq. 1 ) THEN
9581 ! IF ( dbzmax .gt. dbzmin ) THEN
9582 write(iunit,*) 'maxdbz,ijk = ',dbzmax,imx,jmx,kmx
9583 write(iunit,*) 'qrw = ',an(imx,jmx,kmx,lr)
9585 IF ( lh .gt. 1 ) THEN
9586 write(iunit,*) 'qi = ',an(imx,jmx,kmx,li)
9587 write(iunit,*) 'qsw = ',an(imx,jmx,kmx,ls)
9588 write(iunit,*) 'qhw = ',an(imx,jmx,kmx,lh)
9589 IF ( lhl .gt. 1 ) write(iunit,*) 'qhl = ',an(imx,jmx,kmx,lhl)
9597 END subroutine radardd02
9600 ! ##############################################################################
9601 ! ##############################################################################
9604 ! #####################################################################
9605 ! #####################################################################
9607 ! Subroutine for explicit cloud condensation and droplet nucleation
9609 ! 11/30/2022: Fixed droplet evaporation heating term for CM1 eqtset=2 (was only doing eqtset=1)
9612 & (nx,ny,nz,na,jyslab &
9613 & ,nor,norz,dtp,nxi &
9620 & ,ssfilt,t00,t77,flag_qndrop &
9626 ! real :: cwmasn = 1000.*0.523599*(2.*2.e-6)**3
9627 integer :: nx,ny,nz,na,nxi
9628 integer :: nor,norz, jyslab ! ,nht,ngt,igsr
9629 real :: dtp ! time step
9630 logical :: flag_qndrop
9632 integer, parameter :: ng1 = 1
9636 ! external temporary arrays
9638 real t00(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9639 real t77(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9641 real t0(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9642 ! real t1(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9643 ! real t2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9644 ! real t3(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9645 ! real t4(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9646 ! real t5(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9647 ! real t6(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9648 ! real t7(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9649 ! real t8(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9650 real t9(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9653 real p2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz) ! perturbation Pi
9654 real pn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9655 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
9656 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9658 real w(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9659 ! real qv(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9661 real ssfilt(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9664 real pb(-norz+ng1:nz+norz)
9665 real pinit(-norz+ng1:nz+norz)
9667 real dz3d(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9673 real axtra(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz,nxtra)
9677 real :: ccnefactwo, sstmp, cn1, cnuctmp
9680 ! declarations microphysics and for gather/scatter
9682 real, parameter :: cwmas30 = 1000.*0.523599*(2.*30.e-6)**3 ! mass of 30-micron radius droplet, for sat. adj.
9683 real, parameter :: cwmas20 = 1000.*0.523599*(2.*20.e-6)**3 ! mass of 20-micron radius droplet, for sat. adj.
9684 integer nxmpb,nzmpb,nxz
9685 integer mgs,ngs,numgs,inumgs
9686 integer ngscnt,igs(ngs),kgs(ngs)
9687 integer kgsp(ngs),kgsm(ngs)
9690 integer ix,kz,i,n, kp1, km1
9692 integer ixb,ixe,jyb,jye,kzb,kze
9694 integer itile,jtile,ktile
9695 integer ixend,jyend,kzend,kzbeg
9696 integer nxend,nyend,nzend,nzbeg
9699 ! Variables for Ziegler warm rain microphysics
9703 real ccnc(ngs), ccna(ngs), cnuc(ngs), cwnccn(ngs)
9704 real :: ccnc_nu(ngs), ccnc_ac(ngs), ccnc_co(ngs)
9706 real sscb ! 'cloud base' SS threshold
9707 parameter ( sscb = 2.0 )
9708 integer idecss ! flag to turn on (=1) decay of ssmax when no cloud or ice crystals
9709 parameter ( idecss = 1 )
9710 integer iba ! flag to do condensation/nucleation in 1st or 2nd loop
9711 ! =0 to use ad to calculate SS
9712 ! =1 to use an at end of main jy loop to calculate SS
9714 integer ifilt ! =1 to filter ssat, =0 to set ssfilt=ssat
9715 parameter ( ifilt = 0 )
9716 real temp1,temp2 ! ,ssold
9717 real :: ssmax(ngs) ! maximum SS experienced by a parcel
9720 ! real cnu,rnu,snu,cinu
9721 ! parameter ( cnu = 0.0, rnu = -0.8, snu = -0.8, cinu = 0.0 )
9725 real, parameter :: aa1 = 9.44e15, aa2 = 5.78e3 ! a1 in Ziegler
9727 real ec0, ex1, ft, rhoinv(ngs)
9731 real ac1,bc, taus, c1,d1,e1,f1,p380,tmp,tmp2 ! , sstdy, super
9732 real tmpmx, fw, qctmp
9734 double precision :: vent1,vent2
9738 real d1r, d1i, d1s, e1i
9739 integer nc ! condensation step
9740 real dtcon,dtcon1,dtcon2 ! condensation time step (dtcon*nc = dtp)
9742 integer ltemq1,ltemq1m ! ,ltemq1m2
9743 real dqv,qv1,ss1,ss2,qvs1,dqvs,dtemp,dt1 ! temporaries for condensation
9745 real ssi1, ssi2, dqvi, dqvis, dqvii,qis1
9746 real dqvr, dqc, dqr, dqi, dqs
9747 real qv1m,qvs1m,ss1m,ssi1m,qis1m
9749 real dcloud,dcloud2 ! ,as, bs
9751 real cn(ngs), cnuf(ngs)
9758 real es(ngs) ! ss(ngs),
9760 real ssf(ngs),ssfkp1(ngs),ssfkm1(ngs),ssat0(ngs)
9761 real, parameter :: ssfcut = 4.0
9762 real ssfjp1(ngs),ssfjm1(ngs)
9763 real ssfip1(ngs),ssfim1(ngs)
9766 parameter (supcb=0.5,supmx=238.0)
9767 real r2dxm, r2dym, r2dzm
9768 real dssdz, dssdy, dssdx
9771 parameter (epsi = 0.622, d = 0.266)
9772 real r1,qevap ! ,slv
9774 real vr,nrx,qr,z1,z2,rdi,alp,xnutmp,xnuc
9776 real f5, qvs0 ! Kessler condensation factor
9780 ! real, dimension(ngs) :: temp, tempc, elv, elf, els, pqs, theta, temg, temcg
9781 real dqvcnd(ngs),dqwv(ngs),dqcw(ngs),dqci(ngs)
9782 real temp(ngs),tempc(ngs)
9783 real temg(ngs),temcg(ngs),theta(ngs),qvap(ngs) ! ,tembzg(ngs)
9784 real temgx(ngs),temcgx(ngs)
9785 real qvs(ngs),qis(ngs),qss(ngs),pqs(ngs)
9786 real felv(ngs),felf(ngs),fels(ngs)
9787 real felvcp(ngs),felvpi(ngs)
9788 real gamw(ngs),gams(ngs) ! qciavl(ngs),
9789 real tsqr(ngs),ssi(ngs),ssw(ngs)
9790 real cc3(ngs),cqv1(ngs),cqv2(ngs)
9791 real qcwtmp(ngs),qtmp
9793 real fvent(ngs) !,fraci(ngs),fracl(ngs)
9794 real fwvdf(ngs),ftka(ngs),fthdf(ngs)
9795 real fadvisc(ngs),fakvisc(ngs)
9796 real fci(ngs),fcw(ngs)
9797 real fschm(ngs),fpndl(ngs)
9799 real pres(ngs),pipert(ngs)
9801 real rho0(ngs),pi0(ngs)
9803 real thetap(ngs),theta0(ngs),qwvp(ngs),qv0(ngs)
9807 real wvel(ngs),wvelkm1(ngs)
9809 real wvdf(ngs),tka(ngs)
9815 real :: qx(ngs,lv:lhab)
9816 real :: cx(ngs,lc:lhab)
9817 real :: xv(ngs,lc:lhab)
9818 real :: xmas(ngs,lc:lhab)
9819 real :: xdn(ngs,lc:lhab)
9820 real :: xdia(ngs,lc:lhab,3)
9821 real :: alpha(ngs,lc:lhab)
9822 real :: zx(ngs,lr:lhab)
9825 logical zerocx(lc:lqmx)
9829 integer, parameter :: iunit = 0
9831 real :: frac, hwdn, tmpg
9835 real, parameter :: cpv = 1885.0 ! specific heat of water vapor at constant pressure
9841 ! -------------------------------------------------------------------------------
9854 IF ( ac_opt > 0 ) ccnefactwo = (1.63e-3/(cck * beta(3./2., cck/2.)))**(1.0/(cck + 2.0))
9855 f5 = 237.3 * 17.27 * 2.5e6 / cp ! combined constants for rain condensation (Soong and Ogura 73)
9862 IF ( ipconc <= 1 .or. isedonly == 2 ) GOTO 2200
9865 ! Ziegler nucleation
9868 ! ssfilt(:,:,:) = 0.0
9875 temp1 = an(ix,jy,kz,lt)*t77(ix,jy,kz)
9876 t0(ix,jy,kz) = temp1
9877 ltemq = Int( (temp1-163.15)/fqsat+1.5 )
9878 ltemq = Min( nqsat, Max(1,ltemq) )
9880 c1 = t00(ix,jy,kz)*tabqvs(ltemq)
9883 ssfilt(ix,jy,kz) = 100.*(an(ix,jy,kz,lv)/c1 - 1.0) ! from "new" values
9891 ! jy = 1 ! working on a 2d slab
9892 !! VERY IMPORTANT: SET jgs = jy
9897 !..Gather microphysics
9899 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: Gather stage'
9907 do 2000 inumgs = 1,numgs
9914 ! if (kzbeg .le. nzmpb .and. kzend .gt. nzmpb) kzb = nzmpb
9922 pqs(1) = 380.0/(pn(ix,jy,kz) + pb(kz))
9923 theta(1) = an(ix,jy,kz,lt)
9924 temg(1) = t0(ix,jy,kz)
9926 temcg(1) = temg(1) - tfr
9927 ltemq = (temg(1)-163.15)/fqsat+1.5
9928 ltemq = Min( nqsat, Max(1,ltemq) )
9929 qvs(1) = pqs(1)*tabqvs(ltemq)
9930 qis(1) = pqs(1)*tabqis(ltemq)
9935 if ( temg(1) .lt. tfr ) then
9938 if ( (temg(1) .gt. tfrh .or. an(ix,jy,kz,lv)/qvs(1) > maxlowtempss ) .and. &
9939 & ( an(ix,jy,kz,lv) .gt. qss(1) .or. &
9940 & an(ix,jy,kz,lc) .gt. qxmin(lc) .or. &
9941 & ( an(ix,jy,kz,lr) .gt. qxmin(lr) .and. rcond == 2 ) &
9946 if ( ngscnt .eq. ngs ) goto 2100
9953 ! if ( jy .eq. (ny-jstag) ) iend = 1
9956 if ( ngscnt .eq. 0 ) go to 29998
9958 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: dbg = 8'
9960 ! write(0,*) 'NUCOND: dbg = 8, ngscnt,ssmx = ',ngscnt,ssmx
9970 IF ( imurain == 1 ) THEN
9971 alpha(:,lr) = alphar
9972 ELSEIF ( imurain == 3 ) THEN
9973 alpha(:,lr) = xnu(lr)
9977 ! define temporaries for state variables to be used in calculations
9980 qx(mgs,lv) = an(igs(mgs),jy,kgs(mgs),lv)
9982 qx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),il), 0.0)
9985 qcwtmp(mgs) = qx(mgs,lc)
9988 theta0(mgs) = an(igs(mgs),jy,kgs(mgs),lt) !
9990 theta(mgs) = an(igs(mgs),jy,kgs(mgs),lt)
9991 qv0(mgs) = qx(mgs,lv)
9992 qwvp(mgs) = qx(mgs,lv) - qv0(mgs)
9994 pres(mgs) = pn(igs(mgs),jy,kgs(mgs)) + pb(kgs(mgs))
9995 pipert(mgs) = p2(igs(mgs),jy,kgs(mgs))
9996 rho0(mgs) = dn(igs(mgs),jy,kgs(mgs))
9997 rhoinv(mgs) = 1.0/rho0(mgs)
9998 rhovt(mgs) = Sqrt(rho00/rho0(mgs))
9999 pi0(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs))
10000 temg(mgs) = t0(igs(mgs),jy,kgs(mgs))
10001 ! pk(mgs) = t77(igs(mgs),jy,kgs(mgs)) ! ( pres(mgs) / poo ) ** cap
10002 pk(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs)) ! t77(igs(mgs),jy,kgs(mgs))
10003 temcg(mgs) = temg(mgs) - tfr
10004 qss0(mgs) = (380.0)/(pres(mgs))
10005 pqs(mgs) = (380.0)/(pres(mgs))
10006 ltemq = (temg(mgs)-163.15)/fqsat+1.5
10007 ltemq = Min( nqsat, Max(1,ltemq) )
10008 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
10009 qis(mgs) = pqs(mgs)*tabqis(ltemq)
10011 qvap(mgs) = max( (qwvp(mgs) + qv0(mgs)), 0.0 )
10012 es(mgs) = 6.1078e2*tabqvs(ltemq)
10013 qss(mgs) = qvs(mgs)
10016 temgx(mgs) = min(temg(mgs),313.15)
10017 temgx(mgs) = max(temgx(mgs),233.15)
10018 felv(mgs) = 2500837.367 * (273.15/temgx(mgs))**((0.167)+(3.67e-4)*temgx(mgs))
10020 IF ( eqtset <= 1 ) THEN
10021 felvcp(mgs) = felv(mgs)*cpi
10022 ELSE ! equation set 2 in cm1
10023 tmp = qx(mgs,li)+qx(mgs,ls)+qx(mgs,lh)
10024 IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
10025 IF ( lf > 1 ) tmp = tmp + qx(mgs,lf)
10026 cvm = cv+cvv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
10028 cpm = cp+cpv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
10030 rmm=rd+rw*qx(mgs,lv)
10032 IF ( eqtset == 2 ) THEN
10034 felvcp(mgs) = (felv(mgs)-rw*temg(mgs))/cvm
10037 felvcp(mgs) = (felv(mgs)*cv/(cp) - rw*temg(mgs)*(1.0-rovcp*cpm/rmm))/cvm
10038 felvpi(mgs) = pi0(mgs)*rovcp*(felv(mgs)/(temg(mgs)) - rw*cpm/rmm)/cvm
10043 temcgx(mgs) = min(temg(mgs),273.15)
10044 temcgx(mgs) = max(temcgx(mgs),223.15)
10045 temcgx(mgs) = temcgx(mgs)-273.15
10046 felf(mgs) = 333690.6098 + (2030.61425)*temcgx(mgs) - (10.46708312)*temcgx(mgs)**2
10048 fels(mgs) = felv(mgs) + felf(mgs)
10049 fcqv1(mgs) = 4098.0258*felv(mgs)*cpi
10051 wvdf(mgs) = (2.11e-05)*((temg(mgs)/tfr)**1.94)* &
10052 & (101325.0/(pb(kgs(mgs)) + pn(igs(mgs),jgs,kgs(mgs)))) ! diffusivity of water vapor, Hall and Pruppacher (76)
10053 advisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))* &
10054 & (temg(mgs)/296.0)**(1.5) ! dynamic viscosity (SMT; see Beard & Pruppacher 71)
10055 tka(mgs) = tka0*advisc(mgs)/advisc1 ! thermal conductivity
10063 ! load concentrations
10065 if ( ipconc .ge. 1 ) then
10067 cx(mgs,li) = Max(an(igs(mgs),jy,kgs(mgs),lni), 0.0)
10070 if ( ipconc .ge. 2 ) then
10072 cx(mgs,lc) = Max(an(igs(mgs),jy,kgs(mgs),lnc), 0.0)
10073 cwnccn(mgs) = cwccn*rho0(mgs)/rho00 ! background ccn count
10075 IF ( lss > 1 ) THEN
10076 ssmax(mgs) = an(igs(mgs),jy,kgs(mgs),lss)
10080 IF ( lccn .gt. 1 .and. ac_opt == 0 ) THEN
10081 IF ( lccnuf .gt. 1 .and. i_uf_or_ccn > 0 ) THEN
10082 ccnc(mgs) = an(igs(mgs),jy,kgs(mgs),lccn) + an(igs(mgs),jy,kgs(mgs),lccnuf)
10084 ccnc(mgs) = an(igs(mgs),jy,kgs(mgs),lccn)
10087 ccnc(mgs) = cwnccn(mgs)
10089 IF ( lccnuf .gt. 1 .and. i_uf_or_ccn == 0 ) THEN
10090 ccncuf(mgs) = an(igs(mgs),jy,kgs(mgs),lccnuf)
10095 IF ( lccna > 1 ) THEN
10096 ccna(mgs) = an(igs(mgs),jy,kgs(mgs),lccna) ! predicted count of activated ccn
10098 IF ( lccn > 1 ) THEN
10099 ccna(mgs) = cwnccn(mgs) - ccnc(mgs) ! diagnose activated ccn as background value - remaining unactivated ccn
10101 ccna(mgs) = cx(mgs,lc) ! approximation of number of activated ccn
10106 if ( ipconc .ge. 3 ) then
10108 cx(mgs,lr) = Max(an(igs(mgs),jy,kgs(mgs),lnr), 0.0)
10112 ! cnuc(1:ngscnt) = cwccn*rho0(mgs)/rho00*(1. - renucfrac) + ccnc(1:ngscnt)*renucfrac
10114 ! default value of renucfrac is 0.0
10115 IF ( irenuc /= 6 ) THEN
10116 cnuc(mgs) = Max(ccnc(mgs),cwnccn(mgs))*(1. - renucfrac) + ccnc(mgs)*renucfrac
10118 cnuc(mgs) = Max(ccnc(mgs),cwnccn(mgs))*(1. - renucfrac) + Max(0.0,ccnc(mgs) - ccna(mgs))*renucfrac
10120 IF ( renucfrac >= 0.999 ) THEN
10121 IF ( temg(mgs) < 265. ) THEN
10122 IF ( qx(mgs,lc) > 10.*qxmin(lc) .and. w(igs(mgs),jgs,kgs(mgs)) > 2.0 ) THEN
10123 cnuc(mgs) = 0.0 ! Min(cnuc(mgs), 0.5*cx(mgs,lc) ) ! Hack to reduce nucleation at low temp in updraft when ccn are not predicted
10125 cnuc(mgs) = 0.1*cnuc(mgs)
10133 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: Set density'
10136 xdn(mgs,lc) = xdn0(lc)
10137 xdn(mgs,lr) = xdn0(lr)
10141 ventrxn(:) = ventrn
10144 ! Find shape parameter rain
10146 IF ( lzr > 1 .and. rcond == 2 ) THEN ! { RAIN SHAPE PARAM
10148 zx(mgs,lr) = Max(an(igs(mgs),jy,kgs(mgs),lzr), 0.0)
10151 ! CALL cld_cpu('Z-MOMENT-1r2')
10155 IF ( zx(mgs,il) <= zxmin ) THEN
10156 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
10159 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
10160 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
10161 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
10162 ELSEIF ( cx(mgs,il) <= 0.0 ) THEN
10163 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
10166 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
10167 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
10168 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
10171 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
10173 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*Max(1.0e-11,cx(mgs,lr)))
10174 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
10175 xv(mgs,lr) = xvmx(lr)
10176 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
10177 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
10178 xv(mgs,lr) = xvmn(lr)
10179 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
10182 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
10183 ! have mass and reflectivity but no concentration, so set concentration, using default alpha
10184 IF ( imurain == 3 ) THEN
10185 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10188 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z1*1000.*1000)
10190 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10191 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
10194 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z1*1000.*1000)
10197 ! an(igs(mgs),jgs,kgs(mgs),ln(il)) = zx(mgs,il)
10198 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > 0.0 ) THEN
10199 ! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
10200 IF ( imurain == 3 ) THEN
10201 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10204 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(chw*1000.*1000)
10206 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10207 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
10210 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(chw*1000.*1000)
10214 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
10215 ! How did this happen?
10216 ! set values according to dBZ of -10, or Z = 0.1
10217 ! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
10218 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
10219 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
10221 IF ( imurain == 3 ) THEN
10222 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10225 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z1*1000.*1000)
10226 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
10227 ELSEIF ( imurain == 1 ) THEN
10228 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10229 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
10232 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(z1*(pi*xdn(mgs,il))**2)
10233 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
10238 IF ( zx(mgs,lr) > 0.0 ) THEN
10239 vr = rho0(mgs)*qx(mgs,lr)/(1000.*cx(mgs,lr))
10240 ! z1 = 36.*(alpha(kz)+2.0)*a(ix,jy,kz,lnr)*vr**2/((alpha(kz)+1.0)*pi**2)
10245 ! xv = (db(1,kz)*a(1,1,kz,lr))**2/(a(1,1,kz,lnr))
10246 ! rd = z1*(pi/6.*1000.)**2/xv
10249 ! determine shape parameter alpha by iteration
10250 IF ( z1 .gt. 0.0 ) THEN
10252 IF ( imurain == 3 ) THEN
10253 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z1*pi**2) - 1.
10254 ! write(0,*) 'kz, alp, alpha(kz) = ',kz,alp,alpha(kz),rd,z1,xv
10256 IF ( Abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
10257 alpha(mgs,lr) = Max( rnumin, Min( rnumax, alp ) )
10258 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z1*pi**2) - 1.
10259 ! write(0,*) 'i,alp = ',i,alp
10260 alp = Max( rnumin, Min( rnumax, alp ) )
10263 ELSE ! imurain == 1
10264 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10265 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
10267 rd1 = z1*(pi/6.*xdn(mgs,il))**2*nrx/(rho0(mgs)*qr)**2
10269 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
10270 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd1) - 1.0
10273 IF ( Abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
10274 alpha(mgs,il) = Max( alphamin, Min( alphamax, alp ) )
10276 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
10277 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd1) - 1.0
10279 alp = Max( alphamin, Min( alphamax, alp ) )
10287 ! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
10288 ! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
10290 IF ( imurain == 3 ) THEN
10291 IF ( .true. .and. (alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax) ) THEN
10293 IF ( rescale_high_alpha .and. alp >= rnumax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
10294 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10295 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z1*(1./(xdn(mgs,il)))**2
10296 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
10298 ELSEIF ( rescale_low_alphar .and. alp <= rnumin ) THEN
10300 z1 = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
10305 ELSEIF ( imurain == 1 ) THEN
10307 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10308 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
10310 IF ( (rescale_low_alpha .or. rescale_high_alpha ) .and. &
10311 & ( alpha(mgs,il) <= alphamin .or. alp == alphamin .or. alp == alphamax ) ) THEN
10315 IF ( rescale_high_alpha .and. alp >= alphamax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
10316 cx(mgs,il) = g1*rho0(mgs)**2*(qr)*qr/zx(mgs,lr)*(6./(pi*xdn(mgs,il)))**2
10317 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
10319 ELSEIF ( rescale_low_alpha .and. alp <= alphamin ) THEN ! alpha = alphamin, so reset Z to prevent growth in C
10320 z1 = g1*rho0(mgs)**2*(qr)*qr/nrx
10321 z2 = z1*(6./(pi*xdn(mgs,il)))**2
10323 an(igs(mgs),jy,kgs(mgs),lz(il)) = z2
10329 tmp = alpha(mgs,lr) + 4./3.
10330 i = Int(dgami*(tmp))
10332 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10334 tmp = alpha(mgs,lr) + 1.
10335 i = Int(dgami*(tmp))
10337 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10339 ! ventrx(mgs) = Gamma(alpha(mgs,lr) + 4./3.)/(alpha(mgs,lr) + 1.)**(1./3.)/Gamma(alpha(mgs,lr) + 1.)
10340 ventrx(mgs) = x/(y*(alpha(mgs,lr) + 1.)**(1./3.))
10342 IF ( imurain == 3 .and. izwisventr == 2 ) THEN
10344 tmp = alpha(mgs,lr) + 1.5 + br/6.
10345 i = Int(dgami*(tmp))
10347 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10349 ! ventrx(mgs) = Gamma(alpha(mgs,lr) + 1.5 + br/6.)/Gamma(alpha(mgs,lr) + 1.)
10350 ventrxn(mgs) = x/(y*(alpha(mgs,lr) + 1.)**((1.+br)/6. + 1./3.))
10352 ELSEIF ( imurain == 1 .and. iferwisventr == 2 ) THEN
10354 tmp = alpha(mgs,lr) + 2.5 + br/2.
10355 i = Int(dgami*(tmp))
10357 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10359 ! ventrx(mgs) = Gamma(alpha(mgs,lr) + 1.5 + br/6.)/Gamma(alpha(mgs,lr) + 1.)
10372 ! CALL cld_cpu('Z-MOMENT-1r2')
10376 ! write(0,*) 'NUCOND: Set ssf variables, ssmxinit =',ssmxinit
10380 kp1 = Min(nz, kgs(mgs)+1 )
10381 wvel(mgs) = (0.5)*(w(igs(mgs),jgs,kp1) &
10382 & +w(igs(mgs),jgs,kgs(mgs)))
10383 wvelkm1(mgs) = (0.5)*(w(igs(mgs),jgs,kgs(mgs)) &
10384 & +w(igs(mgs),jgs,Max(1,kgs(mgs)-1)))
10386 ssat0(mgs) = ssfilt(igs(mgs),jgs,kgs(mgs))
10387 ssf(mgs) = ssfilt(igs(mgs),jgs,kgs(mgs))
10388 ! ssmx = Max( ssmx, ssf(mgs) )
10391 ssfkp1(mgs) = ssfilt(igs(mgs),jgs,Min(nz-1,kgs(mgs)+1))
10392 ssfkm1(mgs) = ssfilt(igs(mgs),jgs,Max(1,kgs(mgs)-1))
10394 ! IF ( wvel(mgs) /= 0.0 ) write(0,*) 'mgs,wvel1,ssf = ',mgs,wvel(mgs),ssf(mgs)
10402 ! cloud water variables
10405 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: Set cloud water variables'
10409 IF ( ipconc .ge. 2 .and. cx(mgs,lc) .gt. 1.0e6 ) THEN
10411 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
10412 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
10414 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. cxmin ) THEN
10416 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),xdn(mgs,lc)*xvmn(lc)), &
10417 & xdn(mgs,lc)*xvmx(lc) )
10419 cx(mgs,lc) = qx(mgs,lc)*rho0(mgs)/xmas(mgs,lc)
10421 ELSEIF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .le. cxmin ) THEN
10422 ! xmas(mgs,lc) = xdn(mgs,lc)*4.*pi/3.*(5.0e-6)**3
10423 ! cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc)
10424 cx(mgs,lc) = Max( cxmin, rho0(mgs)*qx(mgs,lc)/cwmasx )
10426 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
10427 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
10430 xmas(mgs,lc) = cwmasn
10433 xdia(mgs,lc,1) = (xmas(mgs,lc)*cwc1)**c1f3
10441 if ( qx(mgs,lr) .gt. qxmin(lr) ) then
10443 if ( ipconc .ge. 3 ) then
10444 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*Max(1.0e-9,cx(mgs,lr)))
10445 ! parameter( xvmn(lr)=2.8866e-13, xvmx(lr)=4.1887e-9 ) ! mks
10446 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
10447 xv(mgs,lr) = xvmx(lr)
10448 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
10449 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
10450 xv(mgs,lr) = xvmn(lr)
10451 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
10454 xmas(mgs,lr) = xv(mgs,lr)*xdn(mgs,lr)
10455 xdia(mgs,lr,3) = (xmas(mgs,lr)*cwc1)**(1./3.) ! xdia(mgs,lr,1)
10456 IF ( imurain == 3 ) THEN
10457 ! xdia(mgs,lr,1) = (6.*pii*xv(mgs,lr)/(alpha(mgs,lr)+1.))**(1./3.)
10458 xdia(mgs,lr,1) = xdia(mgs,lr,3) ! formulae for Ziegler (1985) use mean volume diameter, not lambda**(-1)
10459 ELSE ! imurain == 1, Characteristic diameter (1/lambda)
10460 xdia(mgs,lr,1) = (6.*piinv*xv(mgs,lr)/((alpha(mgs,lr)+3.)*(alpha(mgs,lr)+2.)*(alpha(mgs,lr)+1.)))**(1./3.)
10462 ! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
10464 ! Inverse exponential version:
10466 ! > (qx(mgs,lr)*rho0(mgs)
10467 ! > /(pi*xdn(mgs,lr)*cx(mgs,lr)))**(0.333333)
10470 & (qx(mgs,lr)*rho0(mgs)/(pi*xdn(mgs,lr)*cno(lr)))**(0.25)
10473 xdia(mgs,lr,1) = 1.e-9
10474 ! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
10481 ! Ventilation coefficients
10486 fadvisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))* &
10487 & (temg(mgs)/296.0)**(1.5)
10489 fakvisc(mgs) = fadvisc(mgs)*rhoinv(mgs)
10491 fwvdf(mgs) = (2.11e-05)*((temg(mgs)/tfr)**1.94)* &
10492 & (101325.0/(pres(mgs)))
10494 fschm(mgs) = (fakvisc(mgs)/fwvdf(mgs))
10496 fvent(mgs) = (fschm(mgs)**(1./3.)) * (fakvisc(mgs)**(-0.5))
10501 ! Ziegler nucleation
10504 ! cloud evaporation, condensation, and nucleation
10505 ! sqsat -> qss(mgs)
10509 ! Skip points at low temperature if SS stays less than 1.08,
10510 ! otherwise allow nucleation at low temp (will freeze at next time step)
10511 IF ( temg(mgs) .le. tfrh .and. qx(mgs,lv)/qvs(mgs) < maxlowtempss ) THEN
10515 IF( ssat0(mgs) .GT. 0. .OR. ssf(mgs) .GT. 0. ) GO TO 620
10516 !6/4 IF( qvap(mgs) .EQ. qss(mgs) ) GO TO 631
10518 !.... EVAPORATION. QV IS LESS THAN qss(mgs).
10519 !.... EVAPORATE CLOUD FIRST
10521 IF ( qx(mgs,lc) .LE. 0. ) GO TO 631
10522 !.... CLOUD EVAPORATION.
10523 ! convert input 'cp' to cgs
10524 R1=1./(1. + caw*(273.15 - cbw)*qss(mgs)*felv(mgs)/ &
10525 & (cp*(temg(mgs) - cbw)**2))
10526 QEVAP= Min( qx(mgs,lc), R1*(qss(mgs)-qvap(mgs)) )
10529 IF ( qx(mgs,lc) <= QEVAP ) THEN ! GO TO 63
10530 qwvp(mgs) = qwvp(mgs) + qx(mgs,lc)
10531 thetap(mgs) = thetap(mgs) - felvcp(mgs)*qx(mgs,lc)/(pi0(mgs))
10532 IF ( io_flag .and. nxtra > 1 ) THEN
10533 axtra(igs(mgs),jy,kgs(mgs),1) = -qx(mgs,lc)/dtp
10536 IF ( restoreccn ) THEN
10537 IF ( lccna > 1 ) THEN
10538 ccna(mgs) = ccna(mgs) - restoreccnfrac*cx(mgs,lc)
10539 ELSEIF ( irenuc <= 2 ) THEN
10540 IF ( .not. invertccn ) THEN
10541 ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + restoreccnfrac*cx(mgs,lc) ) )
10543 ccnc(mgs) = ccnc(mgs) + restoreccnfrac*cx(mgs,lc)
10550 qwvp(mgs) = qwvp(mgs) + QEVAP
10551 qx(mgs,lc) = qx(mgs,lc) - QEVAP
10552 IF ( qx(mgs,lc) .le. 0. ) THEN
10553 IF ( restoreccn ) THEN
10554 IF ( lccna > 1 ) THEN
10555 ccna(mgs) = ccna(mgs) - restoreccnfrac*cx(mgs,lc)
10556 ELSEIF ( irenuc <= 2 ) THEN
10557 ! ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + cx(mgs,lc) ) )
10558 ! ccnc(mgs) = ccnc(mgs) + cx(mgs,lc)
10559 IF ( .not. invertccn ) THEN
10560 ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + restoreccnfrac*cx(mgs,lc) ) )
10562 ccnc(mgs) = ccnc(mgs) + restoreccnfrac*cx(mgs,lc)
10568 tmp = 0.9*QEVAP*cx(mgs,lc)/qctmp ! let droplets get smaller but also remove some. A factor of 1.0 would maintain same size
10569 IF ( restoreccn ) THEN
10570 IF ( lccna > 1 ) THEN
10571 ccna(mgs) = ccna(mgs) - restoreccnfrac*tmp
10572 ELSEIF ( irenuc <= 2 ) THEN
10573 ! ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + tmp ) )
10574 ! ccnc(mgs) = ccnc(mgs) + tmp
10575 IF ( .not. invertccn ) THEN
10576 ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + restoreccnfrac*tmp ) )
10578 ccnc(mgs) = ccnc(mgs) + restoreccnfrac*tmp
10582 cx(mgs,lc) = cx(mgs,lc) - tmp
10584 thetap(mgs) = thetap(mgs) - felvcp(mgs)*QEVAP/(pi0(mgs))
10585 IF ( io_flag .and. nxtra > 1 ) THEN
10586 axtra(igs(mgs),jy,kgs(mgs),1) = -QEVAP/dtp
10596 !.... CLOUD CONDENSATION
10598 IF ( qx(mgs,lc) .GT. qxmin(lc) .and. cx(mgs,lc) .ge. 1. ) THEN
10602 ! ac1 = xdn(mgs,lc)*elv(kgs(mgs))**2*epsi/
10603 ! : (tka(kgs(mgs))*rw*temg(mgs)**2)
10604 ! took out xdn factor because it cancels later...
10605 ac1 = felv(mgs)**2/(tka(mgs)*rw*temg(mgs)**2)
10608 ! bc = xdn(mgs,lc)*rw*temg(mgs)/
10609 ! : (epsi*wvdf(kgs(mgs))*es(mgs))
10610 ! took out xdn factor because it cancels later...
10611 bc = rw*temg(mgs)/(wvdf(mgs)*es(mgs))
10613 ! bs = rho0(mgs)*((rd*temg(mgs)/(epsi*es(mgs)))+
10614 ! : (epsi*elv(kgs(mgs))**2/(pres(mgs)*temg(mgs)*cp)))
10616 ! taus = Min(dtp, xdn(mgs,lc)*rho0(mgs)*(ac1+bc)/
10617 ! : (4*pi*0.89298*BS*0.5*xdia(mgs,lc,1)*cx(mgs,lc)*xdn(mgs,lc)))
10620 IF ( ssf(mgs) .gt. 0.0 .or. ssat0(mgs) .gt. 0.0 ) THEN
10621 IF ( ny .le. 2 ) THEN
10622 ! write(0,*) 'undershoot: ',ssf(mgs),
10623 ! : ( (qx(mgs,lv) - dcloud)/c1 - 1.0)*100.
10628 IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN
10630 IF ( xdia(mgs,lc,1) .le. 0.0 ) THEN
10631 xmas(mgs,lc) = cwmasn
10632 xdia(mgs,lc,1) = (xmas(mgs,lc)*cwc1)**c1f3
10634 d1 = (1./(ac1 + bc))*4.0*pi*ventc &
10635 & *0.5*xdia(mgs,lc,1)*cx(mgs,lc)*rhoinv(mgs)
10641 IF ( rcond .eq. 2 .and. qx(mgs,lr) .gt. qxmin(lr) .and. cx(mgs,lr) > 1.e-9 ) THEN
10642 IF ( imurain == 3 ) THEN
10643 IF ( izwisventr == 1 ) THEN
10644 rwvent(mgs) = ventrx(mgs)*(1.6 + 124.9*(1.e-3*rho0(mgs)*qx(mgs,lr))**.2046)
10645 ELSE ! izwisventr = 2
10646 ! Following Wisner et al. (1972) but using gamma of volume. Note that Ferrier rain fall speed does not integrate with gamma of volume, so using Vr = ar*d^br
10648 & (0.78*ventrx(mgs) + 0.308*ventrxn(mgs)*fvent(mgs) &
10649 & *Sqrt((ar*rhovt(mgs))) &
10650 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
10653 ELSE ! imurain == 1
10655 IF ( iferwisventr == 1 ) THEN
10656 alpr = Min(alpharmax,alpha(mgs,lr) )
10657 ! alpr = alpha(mgs,lr)
10661 i = Int(dgami*(tmp))
10663 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10665 tmp = 2.5 + alpr + 0.5*bx(lr)
10666 i = Int(dgami*(tmp))
10668 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp ! ratio of gamma functions
10670 ! vent1 = dble(xdia(mgs,lr,1))**(-2. - alpr) ! Actually OK
10671 ! vent2 = dble(1./xdia(mgs,lr,1) + 0.5*fx(lr))**dble(2.5+alpr+0.5*bx(lr)) ! Actually OK
10672 vent1 = dble(xdia(mgs,lr,1))**(0.5 + 0.5*bx(lr)) ! 2016.2.26 Changed for consistency with derivation (recast formula)
10673 vent2 = dble(1. + 0.5*fx(lr)*xdia(mgs,lr,1))**dble(2.5+alpr+0.5*bx(lr))
10678 & 0.308*fvent(mgs)*y* &
10679 & Sqrt(ax(lr)*rhovt(mgs))*(vent1/vent2)
10681 ELSEIF ( iferwisventr == 2 ) THEN
10683 ! Following Wisner et al. (1972) but using gamma of volume. Note that Ferrier rain fall speed does not integrate with gamma of volume, so using Vr = ar*d^br
10684 x = 1. + alpha(mgs,lr)
10687 & (0.78*x + 0.308*ventrxn(mgs)*fvent(mgs) &
10688 & *Sqrt((ar*rhovt(mgs))) &
10689 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
10692 ENDIF ! iferwisventr
10696 d1r = (1./(ac1 + bc))*4.0*pi*rwvent(mgs) &
10697 & *0.5*xdia(mgs,lr,1)*cx(mgs,lr)*rhoinv(mgs)
10703 e1 = felvcp(mgs)/(pi0(mgs))
10704 f1 = pk(mgs) ! (pres(mgs)/poo)**cap
10707 ! fifth trial to see what happens:
10709 ltemq = (temg(mgs)-163.15)/fqsat+1.5
10710 ltemq = Min( nqsat, Max(1,ltemq) )
10713 p380 = 380.0/pres(mgs)
10715 ! taus = Max( 0.05*dtp, Min(taus, 0.25*dtp ) )
10716 ! nc = NInt(dtp/Min(1.0,0.5*taus))
10717 ! dtcon = dtp/float(nc)
10718 ss1 = qx(mgs,lv)/qvs(mgs)
10727 ! dtcon = Max(dtcon,0.2)
10728 ! nc = Nint(dtp/dtcon)
10731 ! want to start out with a small time step to handle the steep slope
10732 ! and fast changes, then can switch to a larger step (dtcon2) for the
10733 ! rest of the big time step.
10734 ! base the initial time step (dtcon1) on the slope (delta)
10735 IF ( Abs(ss1 - 1.0) .gt. 1.e-5 ) THEN
10736 delta = 0.5*(qv1-qvs1)/(d1*(ss1 - 1.0))
10740 ! delta is the extrapolated time to get halfway from qv1 to qvs1
10741 ! want at least 5 time steps to the halfway point, so multiply by 0.2
10742 ! for the initial time step
10743 dtcon1 = Min(0.05,0.2*delta)
10744 nc = Max(5,2*NInt( (dtp-4.0*dtcon1)/delta))
10745 dtcon2 = (dtp-4.0*dtcon1)/nc
10757 RK2c: DO WHILE ( dt1 .lt. dtp )
10759 IF ( n .le. 4 ) THEN
10764 609 dqv = -(ss1 - 1.)*d1*dtcon
10765 dqvr = -(ss1 - 1.)*d1r*dtcon
10766 dtemp = -0.5*e1*f1*(dqv + dqvr)
10767 ! write(0,*) 'RK2c dqv1 = ',dqv
10768 ! calculate midpoint values:
10769 ! ltemq1m = ltemq1 + Nint(dtemp*fqsat + 0.5)
10771 ! 7.6.2016: Test full calc of ltemq
10772 ltemq1m = (temp1+dtemp-163.15)*fqsati+1.5
10773 ltemq1m = Min( nqsat, Max(1,ltemq1m) )
10775 IF ( ltemq1m .lt. 1 .or. ltemq1m .gt. nqsat ) THEN
10776 write(0,*) 'STOP in nucond line 1192 '
10777 write(0,*) ' ltemq1m,icond = ',ltemq1m,icond
10778 write(0,*) ' dtemp,e1,f1,dqv,dqvr = ', dtemp,e1,f1,dqv,dqvr
10779 write(0,*) ' d1,d1r,dtcon,ss1 = ',d1,d1r,dtcon,ss1
10780 write(0,*) ' dqc, dqr = ',dqc,dqr
10781 write(0,*) ' qv,qc,qr = ',qx(mgs,lv)*1000.,qx(mgs,lc)*1000.,qx(mgs,lr)*1000.
10782 write(0,*) ' i, j, k = ',igs(mgs),jy,kgs(mgs)
10783 write(0,*) ' dtcon1,dtcon2,delta = ',dtcon1,dtcon2,delta
10784 write(0,*) ' nc,dtp = ',nc,dtp
10785 write(0,*) ' rwvent,xdia,crw,ccw = ', rwvent(mgs),xdia(mgs,lr,1),cx(mgs,lr),cx(mgs,lc)
10786 write(0,*) ' fvent,alphar = ',fvent(mgs),alpha(mgs,lr)
10787 write(0,*) ' xvr,xmasr,xdnr,cwc1 = ',xv(mgs,lr),xmas(mgs,lr),xdn(mgs,lr),cwc1
10789 dqvs = dtemp*p380*dtabqvs(ltemq1m)
10790 qv1m = qv1 + dqv + dqvr
10791 ! qv1mr = qv1r + dqvr
10793 qvs1m = qvs1 + dqvs
10796 ! check for undersaturation when no ice is present, if so, then reduce time step
10797 IF ( ss1m .lt. 1. .and. (dqvii + dqvis) .eq. 0.0 ) THEN
10798 dtcon = (0.5*dtcon)
10799 IF ( dtcon .ge. dtcon1 ) THEN
10805 ! calculate full step:
10806 dqv = -(ss1m - 1.)*d1*dtcon
10807 dqvr = -(ss1m - 1.)*d1r*dtcon
10810 ! write(0,*) 'RK2a dqv1m = ',dqv
10811 dtemp = -e1*f1*(dqv + dqvr)
10813 ! ltemq1 = ltemq1 + Nint(dtemp*fqsat + 0.5)
10815 ! 7.6.2016: Test full calc of ltemq
10816 ltemq1 = (temp1+dtemp-163.15)*fqsati+1.5
10817 ltemq1 = Min( nqsat, Max(1,ltemq1) )
10819 IF ( ltemq1 .lt. 1 .or. ltemq1 .gt. nqsat ) THEN
10820 write(0,*) 'STOP in nucond line 1230 '
10821 write(0,*) ' ltemq1m,icond = ',ltemq1m,icond
10822 write(0,*) ' dtemp,e1,dqv,dqvr = ', dtemp,e1,dqv,dqvr
10824 dqvs = dtemp*p380*dtabqvs(ltemq1)
10826 qv1 = qv1 + dqv + dqvr
10833 temp1 = temp1 + dtemp
10834 IF ( temp2 .eq. temp1 .or. ss2 .eq. ss1 .or. &
10835 & ss1 .eq. 1.00 .or. &
10836 & ( n .gt. 10 .and. ss1 .lt. 1.0005 ) ) THEN
10837 ! write(0,*) 'RK2c break'
10848 dcloud = dqc ! qx(mgs,lv) - qv1
10849 thetap(mgs) = thetap(mgs) + e1*(DCLOUD + dqr)
10852 IF ( eqtset > 2 ) THEN
10853 pipert(mgs) = pipert(mgs) + felvpi(mgs)*(DCLOUD + dqr)
10855 IF ( io_flag .and. nxtra > 1 ) THEN
10856 axtra(igs(mgs),jy,kgs(mgs),1) = DCLOUD/dtp
10857 axtra(igs(mgs),jy,kgs(mgs),2) = axtra(igs(mgs),jy,kgs(mgs),2) + dqr/dtp
10859 qwvp(mgs) = qwvp(mgs) - (DCLOUD + dqr)
10860 qx(mgs,lc) = qx(mgs,lc) + DCLOUD
10861 qx(mgs,lr) = qx(mgs,lr) + dqr
10862 ! t9(igs(mgs),jy,kgs(mgs)) = t9(igs(mgs),jy,kgs(mgs)) + (DCLOUD + dqr)/dtp*felv(mgs)/(cp*pi0(mgs)) !* &
10863 !! & dx*dy*dz3d(igs(mgs),jy,kgs(mgs))
10866 IF ( lzr > 1 .and. rcond == 2 .and. qx(mgs,lr) .gt. qxmin(lr) &
10867 & .and. cx(mgs,lr) .gt. 1.e-9 ) THEN
10868 tmp = qx(mgs,lr)/cx(mgs,lr)
10869 IF ( imurain == 3 ) THEN
10870 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10872 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10873 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
10876 zx(mgs,lr) = zx(mgs,lr) + g1*(rho0(mgs)/(xdn(mgs,lr)))**2*( 2.*( tmp ) * dqr )
10879 theta(mgs) = thetap(mgs) + theta0(mgs)
10880 temg(mgs) = theta(mgs)*f1
10881 ltemq = (temg(mgs)-163.15)/fqsat+1.5
10882 ltemq = Min( nqsat, Max(1,ltemq) )
10883 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
10884 ! es(mgs) = 6.1078e2*tabqvs(ltemq)
10888 ENDIF ! dcloud .gt. 0.
10891 ELSE ! qc .le. qxmin(lc)
10893 ! IF ( ssf(mgs) .gt. 0.0 .and. .not. flag_qndrop ) THEN ! flag_qndrop turns off primary nucleation when using wrf-chem with progn=1
10894 IF ( ssf(mgs) .gt. 0.0 ) THEN ! .and. ssmax(mgs) .lt. sscb ) THEN ! except that wrf-chem does not seem to initialize qc for activated aerosols, so keep this, after all
10896 IF ( iqcinit == 1 ) THEN
10898 qvs0 = 380.*exp(17.27*(temg(mgs)-273.)/(temg(mgs)- 36.))/pk(mgs)
10900 dcloud = Max(0.0, (qx(mgs,lv)-qvs0) / (1.+qvs0*f5/(temg(mgs)-36.)**2) )
10902 ELSEIF ( iqcinit == 3 ) THEN
10903 R1=1./(1. + caw*(273.15 - cbw)*qss(mgs)*felvcp(mgs)/ &
10904 & ((temg(mgs) - cbw)**2))
10905 DCLOUD=R1*(qvap(mgs) - qvs(mgs)) ! KW model adjustment;
10906 ! this will put mass into qc if qv > sqsat exists
10908 ELSEIF ( iqcinit == 2 ) THEN
10909 ! R1=1./(1. + caw*(273.15 - cbw)*qss(mgs)*felv(mgs)/
10910 ! : (cp*(temg(mgs) - cbw)**2))
10911 ! DCLOUD=R1*(qvap(mgs) - qvs(mgs)) ! KW model adjustment;
10912 ! this will put mass into qc if qv > sqsat exists
10915 ! IF ( ssf(mgs) > ssmx .and. ssmax(mgs) < 3.0 ) THEN
10916 ! IF ( ssf(mgs) > ssmx .and. ccnc(mgs) > 1.0 ) THEN
10917 ! IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 5.0 .and. ccnc(mgs) > 0.1*cwnccn(mgs) ) THEN ! this one works
10918 ! IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 20.0 ) THEN ! test -- fails
10919 ! IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 20.0 .and. ccnc(mgs) > 0.1*cwnccn(mgs)) THEN ! test -- is OK
10920 IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 20.0 .and. &
10921 ( ccnc(mgs) > 0.05*cwnccn(mgs) .or. ( ac_opt > 0 .and. ccnc_ac(mgs) - cx(mgs,lc) > 0.0 ) ) ) THEN ! test
10922 ! IF ( ssf(mgs) > ssmx ) THEN ! original condition
10923 CALL QVEXCESS(ngs,mgs,qwvp,qv0,qx(1,lc),pres,thetap,theta0,dcloud, &
10924 & pi0,tabqvs,nqsat,fqsat,cbw,fcqv1,felvcp,ssmx,pk,ngscnt)
10933 thetap(mgs) = thetap(mgs) + felvcp(mgs)*DCLOUD/(pi0(mgs))
10934 qwvp(mgs) = qwvp(mgs) - DCLOUD
10935 qx(mgs,lc) = qx(mgs,lc) + DCLOUD
10936 IF ( io_flag .and. nxtra > 1 ) THEN
10937 axtra(igs(mgs),jy,kgs(mgs),1) = DCLOUD/dtp
10939 theta(mgs) = thetap(mgs) + theta0(mgs)
10940 temg(mgs) = theta(mgs)*pk(mgs) !( pres(mgs) / poo ) ** cap
10941 ! temg(mgs) = theta2temp( theta(mgs), pres(mgs) )
10942 ltemq = (temg(mgs)-163.15)/fqsat+1.5
10943 ltemq = Min( nqsat, Max(1,ltemq) )
10944 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
10945 ! es(mgs) = 6.1078e2*tabqvs(ltemq)
10947 !.... S. TWOMEY (1959)
10948 ! Note: get here if there is no previous cloud water and w > 0.
10951 IF ( ncdebug .ge. 1 ) THEN
10952 write(iunit,*) 'at 613: ',qx(mgs,lc),cx(mgs,lc),wvel(mgs),ssmax(mgs),kgs(mgs)
10955 IF ( .not. flag_qndrop ) THEN ! { do not calculate number of droplets if using wrf-chem
10957 IF ( ac_opt == 0 ) THEN
10958 cnuctmp = cnuc(mgs)
10960 cnuctmp = ccnc_ac(mgs)
10963 ! IF ( ssmax(mgs) .lt. sscb .and. qx(mgs,lc) .gt. qxmin(lc)) THEN
10964 IF ( dcloud .gt. qxmin(lc) .and. wvel(mgs) > 0.0) THEN
10965 ! CN(mgs) = CCNE*wvel(mgs)**cnexp ! *Min(1.0,1./dtp) ! 0.3465
10966 CN(mgs) = CCNE0*cnuctmp**(2./(2.+cck))*wvel(mgs)**cnexp ! *Min(1.0,1./dtp) ! 0.3465
10967 IF ( ny .le. 2 .and. cn(mgs) .gt. 0.0 &
10968 & .and. ncdebug .ge. 1 ) THEN
10969 write(iunit,*) 'CN: ',cn(mgs)*1.e-6, cx(mgs,lc)*1.e-6, qx(mgs,lc)*1.e3, &
10970 & wvel(mgs), dcloud*1.e3
10971 IF ( cn(mgs) .gt. 1.0 ) write(iunit,*) 'cwrad = ', &
10972 & 1.e6*(rho0(mgs)*qx(mgs,lc)/cn(mgs)*cwc1)**c1f3, &
10973 & igs(mgs),kgs(mgs),temcg(mgs), &
10974 & 1.e3*an(igs(mgs),jgs,kgs(mgs)-1,lc)
10976 IF ( iccwflg .eq. 1 ) THEN
10977 cn(mgs) = Min(cwccn*rho0(mgs)/rho00, Max(cn(mgs), &
10978 & rho0(mgs)*qx(mgs,lc)/(xdn(mgs,lc)*(4.*pi/3.)*(4.e-6)**3)))
10983 ! cn(mgs) = Min(cwccn, &
10984 ! & rho0(mgs)*dcloud/(xdn(mgs,lc)*(4.*pi/3.)*(4.e-6)**3) )
10987 IF ( cn(mgs) .gt. 0.0 ) THEN
10988 IF ( ac_opt == 0 ) THEN
10989 IF ( cn(mgs) .gt. ccnc(mgs) ) THEN
10990 cn(mgs) = ccnc(mgs)
10994 cn(mgs) = Min( cn(mgs), ccnc_ac(mgs) )
10996 ! cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
10997 IF ( irenuc <= 2 .and. lccna < 1 ) ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
10998 ccna(mgs) = ccna(mgs) + cn(mgs)
11001 ! write(91,*) 'nuc1: cn, ix, kz = ',cn(mgs),igs(mgs),kgs(mgs),wvel(mgs),cnexp,ccnc(mgs)
11003 IF( CN(mgs) .GT. cx(mgs,lc) ) cx(mgs,lc) = CN(mgs)
11004 IF( cx(mgs,lc) .GT. 0. .AND. qx(mgs,lc) .le. qxmin(lc) ) THEN
11007 cx(mgs,lc) = Min(cx(mgs,lc),rho0(mgs)*Max(0.0,qx(mgs,lc))/cwmasn)
11010 ENDIF ! }.not. flag_qndrop
11014 END IF ! qc .gt. 0.
11016 ! ES=EES(PIB(K)*PT)
11017 ! SQSAT=EPSI*ES/(PB(K)*1000.-ES)
11019 !.... CLOUD NUCLEATION
11021 ! ES=1.E3*PB(K)*QV/EPSI
11023 IF ( wvel(mgs) .le. 0. ) GO TO 616
11024 IF ( cx(mgs,lc) .le. 0. ) GO TO 613 !TWOMEY (1959) Nucleation
11025 IF ( kzbeg-1+kgs(mgs) .GT. 1 .and. qx(mgs,lc) .le. qxmin(lc)) GO TO 613 !TWOMEY (1959) Nucleation
11026 IF ( kzbeg-1+kgs(mgs) .eq. 1 .and. wvel(mgs) .gt. 0. ) GO TO 613 !TWOMEY (1959) Nucleation
11027 !.... ATTEMPT ZIEGLER CLOUD NUCLEATION IN CLOUD INTERIOR UNLESS...
11028 616 IF ( ssf(mgs) .LE. SUPCB .AND. wvel(mgs) .GT. 0. ) GO TO 631 !... weakly saturated updraft
11029 IF ( kzbeg-1+kgs(mgs) .GT. 1 .AND. kzbeg-1+kgs(mgs) .LT. nzend-1 .AND. &
11030 & (ssfkp1(mgs) .GE. SUPMX .OR. &
11031 & ssf(mgs) .GE. SUPMX .OR. &
11032 & ssfkm1(mgs) .GE. SUPMX)) GO TO 631 !... too much vapour
11033 IF (ssf(mgs) .LT. 1.E-10 .OR. ssf(mgs) .GE. SUPMX) GO TO 631 !... at the extremes for ss
11036 ! get here if ( qc > 0 and ss > supcb) or (w < 0)
11039 if (ndebug .gt. 0) write(0,*) "ICEZVD_DR: Entered Ziegler Cloud Nucleation" !mpidebug
11042 r2dzm=0.50/dz3d(igs(mgs),jy,kgs(mgs))
11044 IF ( irenuc >= 0 .and. ac_opt == 0 .and. .not. flag_qndrop ) THEN ! turn off nucleation when flag_qndrop (using WRF-CHEM for activation)
11046 IF ( irenuc < 2 ) THEN !{
11048 IF ( kzend == nzend ) THEN
11049 t0p3 = t0(igs(mgs),jgs,Min(kze,kgs(mgs)+3))
11050 t0p1 = t0(igs(mgs),jgs,Min(kze,kgs(mgs)+1))
11052 t0p3 = t0(igs(mgs),jgs,kgs(mgs)+3)
11053 t0p1 = t0(igs(mgs),jgs,kgs(mgs)+1)
11056 IF ( ( ssf(mgs) .gt. ssmax(mgs) .or. irenuc .eq. 1 ) &
11057 & .and. ( ( lccn .lt. 1 .and. &
11058 & cx(mgs,lc) .lt. cwccn*(Min(1.0,rho0(mgs)))) .or. &
11059 & ( lccn .gt. 1 .and. ccnc(mgs) .gt. 0. ) ) &
11061 IF( kzbeg-1+kgs(mgs) .GT. 1 .AND. kzbeg-1+kgs(mgs) .LT. nzend-1 &
11062 & .and. ssf(mgs) .gt. 0.0 &
11063 & .and. ssfkp1(mgs) .LT. SUPMX .and. ssfkp1(mgs) .ge. 0.0 &
11064 & .AND. ssfkm1(mgs) .LT. SUPMX .AND. ssfkm1(mgs) .ge. 0.0 &
11065 & .AND. ssfkp1(mgs) .gt. ssfkm1(mgs) &
11066 & .and. t0p3 .gt. 233.2) THEN
11067 DSSDZ = (ssfkp1(mgs) - ssfkm1(mgs))*R2DZM
11069 ! otherwise check for cloud base condition with updraft:
11071 ELSEIF( kzbeg-1+kgs(mgs) .GT. 1 .AND. kzbeg-1+kgs(mgs) .LT. nzend-1 &
11072 ! IF( kgs(mgs) .GT. 1 .AND. kgs(mgs) .LT. NZ-1 & !)
11073 & .and. ssf(mgs) .gt. 0.0 .and. wvel(mgs) .gt. 0.0 &
11074 & .and. ssfkp1(mgs) .gt. 0.0 &
11075 & .AND. ssfkm1(mgs) .le. 0.0 .and. wvelkm1(mgs) .gt. 0.0 &
11076 & .AND. ssf(mgs) .gt. ssfkm1(mgs) &
11077 & .and. t0p1 .gt. 233.2) THEN
11078 DSSDZ = 2.*(ssf(mgs) - ssfkm1(mgs))*R2DZM ! 1-sided difference
11083 !CLZ IF(wijk.LE.0.) CN=CCN*ssfilt(ix,jy,kz)**CCK
11084 ! note: CCN -> cwccn, DELT -> dtp
11085 c1 = Max(0.0, rho0(mgs)*(qx(mgs,lv) - qss(mgs))/ &
11086 & (xdn(mgs,lc)*(4.*pi/3.)*(4.e-6)**3))
11087 IF ( lccn .lt. 1 ) THEN
11088 CN(mgs) = cwccn*rho0(mgs)/rho00*CCK*ssf(mgs)**CCKM*dtp* &
11090 & (wvel(mgs)*DSSDZ) ) ! probably the vertical gradient dominates
11093 & Min(ccnc(mgs), cnuc(mgs)*CCK*ssf(mgs)**CCKM*dtp* &
11095 & ( wvel(mgs)*DSSDZ) ) )
11096 ! IF ( cn(mgs) .gt. 0 ) ccnc(mgs) = ccnc(mgs) - cn(mgs)
11099 IF ( cn(mgs) .gt. 0.0 ) THEN
11100 IF ( ccnc(mgs) .lt. 5.e7 .and. cn(mgs) .ge. 5.e7 ) THEN
11103 ELSEIF ( cn(mgs) .gt. ccnc(mgs) ) THEN
11104 cn(mgs) = ccnc(mgs)
11107 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11108 ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11111 ELSEIF ( irenuc == 2 ) THEN !} {
11112 ! simple Twomey scheme
11113 ! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11114 CN(mgs) = CCNE0*cnuc(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp ! *Min(1.0,1./dtp) ! 0.3465
11115 ! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
11116 !!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11117 ! Philips, Donner et al. 2007, but results in too much limitation of
11119 CN(mgs) = Min(cn(mgs), ccnc(mgs))
11120 cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11121 CN(mgs) = Min( CN(mgs), Max(0.0, (cnuc(mgs) - ccna(mgs) )) )
11123 IF ( .false. .and. ny <= 2 ) THEN
11124 write(0,*) 'i,k, cwmasn = ',igs(mgs),kgs(mgs),cwmasn
11125 write(0,*) 'wvel, cnuc, cn = ',wvel(mgs),cnuc(mgs),cn(mgs)
11126 write(0,*) 'ccne0,cnexp,cck = ',ccne0,cnexp,cck
11127 write(0,*) 'part1, part2 = ',CCNE0*cnuc(mgs)**(2./(2.+cck)), Max(0.0,wvel(mgs))**cnexp
11128 write(0,*) 'ccnc, dqc, dqc/cwmasn = ',ccnc(mgs), dqc, 0.5*dqc/cwmasn
11131 IF ( icnuclimit > 0 ) THEN
11132 tmp = ccnc(mgs) + cx(mgs,lc)
11133 IF ( tmp < 330.34e6 ) THEN
11134 ccwmax = 1.1173e6 * (1.e-6*tmp)**0.9504
11136 ccwmax = 21.57e6 * (1.e-6*tmp)**0.44
11139 ! IF ( cn(mgs) > 0. ) THEN
11140 ! write(0,*) 'cn,tmp,ccwmax,cx,c-cx = ',cn(mgs),tmp,ccwmax,cx(mgs,lc),ccwmax - cx(mgs,lc)
11143 cn(mgs) = Max( 0.0, Min( cn(mgs), ccwmax - cx(mgs,lc) ) )
11147 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11149 IF ( lccna < 1 ) ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11151 ELSEIF ( irenuc == 3 ) THEN !} {
11152 ! Phillips Donner Garner 2007
11153 ! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11154 ! CN(mgs) = cwccn*Min(ssf(mgs),ssfcut)**cck
11156 ! Need to calculate new ssf since condensation has happened:
11157 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11158 ltemq = Int( (temp1-163.15)/fqsat+1.5 )
11159 ltemq = Min( nqsat, Max(1,ltemq) )
11161 c1= pqs(mgs)*tabqvs(ltemq)
11164 IF ( c1 > 0. ) THEN
11165 ssf(mgs) = 100.*(qx(mgs,lv)/c1 - 1.0) ! from "new" values
11167 CN(mgs) = cnuc(mgs)*Min(1.0, (ssf(mgs))**cck ) !
11169 CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11170 ! Philips, Donner et al. 2007, but results in too much limitation of
11172 CN(mgs) = Min(cn(mgs), ccnc(mgs))
11173 cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11175 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11177 ! 6/13/2016: Phillips et al. appears not to decrement CCN, but only increments CCNa.
11178 ! This would allow an initially non-homogeneous (vertically, e.g.) initial value of CCN/rho_air
11179 ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11181 ELSEIF ( irenuc == 4 ) THEN !} {
11182 ! modification of Phillips Donner Garner 2007
11183 ! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11184 ! CN(mgs) = CCNE0*cnuc(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp
11185 ! cn(mgs) = Min( cn(mgs), cnuc(mgs) )
11186 ! Need to calculate new ssf since condensation has happened:
11187 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11188 ltemq = Int( (temp1-163.15)/fqsat+1.5 )
11189 ltemq = Min( nqsat, Max(1,ltemq) )
11191 c1= pqs(mgs)*tabqvs(ltemq)
11192 IF ( c1 > 0. ) THEN
11193 ssf(mgs) = Max(0.0, 100.*((qv0(mgs) + qwvp(mgs))/c1 - 1.0) ) ! from "new" values
11197 CN(mgs) = cnuc(mgs)*Min(ssf2kmax, ssf(mgs)**cck) ! this allows cn(mgs) > cnuc(mgs)
11199 CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11200 ! Philips, Donner et al. 2007, but results in too much limitation of
11202 ! CN(mgs) = Min(cn(mgs), ccnc(mgs))
11203 cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11205 IF ( cn(mgs) > 0.0 ) THEN
11206 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11207 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11211 dcloud = 1000.*dcrit**3*Pi/6.*cn(mgs)
11212 qx(mgs,lc) = qx(mgs,lc) + DCLOUD
11213 thetap(mgs) = thetap(mgs) + felvcp(mgs)*DCLOUD/(pi0(mgs))
11214 qwvp(mgs) = qwvp(mgs) - DCLOUD
11216 ! 6/13/2016: Phillips et al. appears not to decrement CCN, but only increments CCNa.
11217 ! This would allow an initially non-homogeneous (vertically, e.g.) initial value of CCN/rho_air
11218 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11222 ELSEIF ( irenuc == 6 ) THEN !} {
11224 ! simple Twomey scheme but limit activation to try to do most activation near cloud base, but keep some CCN available for renuclation
11225 ! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11227 ! IF ( ccna(mgs) < 0.7*cnuc(mgs) .and. ccnc(mgs) > 0.69*cnuc(mgs) - ccna(mgs)) THEN ! here, assume we are near cloud base and use Twomey formulation
11228 IF ( ccna(mgs) < 0.7*cnuc(mgs) ) THEN ! here, assume we are near cloud base and use Twomey formulation
11229 CN(mgs) = Min( 0.9*cnuc(mgs), CCNE0*cnuc(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp )! *Min(1.0,1./dtp) ! 0.3465
11230 ! IF ( cn(mgs) + ccna(mgs) > 0.71*cnuc ) THEN
11231 ! prevent this branch from activating more than 70% of CCN
11232 CN(mgs) = Min( CN(mgs), Max(0.0, (0.7*cnuc(mgs) - ccna(mgs) )) )
11233 ! CN(mgs) = Min( CN(mgs), Max(0.0, 0.71*ccnc(mgs) - ccna(mgs) ) )
11236 ! if a large fraction of CCN have been activated, then assume we are in the cloud interior and use local SSw as in Phillips et al. 2007.
11238 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11239 ! t0(ix,jy,kz) = temp1
11240 ltemq = Int( (temp1-163.15)/fqsat+1.5 )
11241 ltemq = Min( nqsat, Max(1,ltemq) )
11243 ! c1 = t00(igs(mgs),jy,kgs(mgs))*tabqvs(ltemq)
11244 c1= pqs(mgs)*tabqvs(ltemq)
11245 IF ( c1 > 0. ) THEN
11246 ssf(mgs) = Max(0.0, 100.*((qv0(mgs) + qwvp(mgs))/c1 - 1.0) ) ! from "new" values
11251 ! CN(mgs) = cnuc(mgs)*Min(0.99, Min(ssf(mgs),ssfcut)**cck ) !
11252 CN(mgs) = cnuc(mgs)*Min(2.0, Max(0.0,ssf(mgs))**cck ) !
11253 ! CN(mgs) = cnuc(mgs)*Min(ssf(mgs),ssfcut)**cck !
11256 CN(mgs) = Min(0.01*cnuc(mgs), Max( 0.0, CN(mgs) - ccna(mgs) ) ) ! this was from
11259 ! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
11260 !!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11261 ! Philips, Donner et al. 2007, but results in too much limitation of
11263 ! CN(mgs) = Min(cn(mgs), ccnc(mgs))
11264 ! cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11266 IF ( cn(mgs) > 0.0 ) THEN
11267 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11269 ! create some small droplets at minimum size (CP 2000), although it adds very little liquid
11273 dcloud = 1000.*dcrit**3*Pi/6.*cn(mgs)
11274 qx(mgs,lc) = qx(mgs,lc) + DCLOUD
11275 thetap(mgs) = thetap(mgs) + felvcp(mgs)*DCLOUD/(pi0(mgs))
11276 qwvp(mgs) = qwvp(mgs) - DCLOUD
11277 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11279 ELSEIF ( irenuc == 5 ) THEN !} {
11281 ! modification of Phillips Donner Garner 2007
11282 ! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11283 ! CN(mgs) = Min( 0.91*cnuc(mgs), CCNE0*cnuc(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp )! *Min(1.0,1./dtp) ! 0.3465
11284 CN(mgs) = Min( cnuc(mgs), CCNE0*cnuc(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp )
11287 IF ( ccna(mgs) >= cnuc(mgs) ) THEN ! apply limit after all "base" CCN have been depleted
11288 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11289 ltemq = Int( (temp1-163.15)/fqsat+1.5 )
11290 ltemq = Min( nqsat, Max(1,ltemq) )
11292 c1= pqs(mgs)*tabqvs(ltemq)
11293 IF ( c1 > 0. ) THEN
11294 ssf(mgs) = Max(0.0, 100.*((qv0(mgs) + qwvp(mgs))/c1 - 1.0) ) ! from "new" values
11300 CN(mgs) = Max( cn(mgs), cnuc(mgs)*Min(ssf2kmax, ssf(mgs)**cck) ) ! this allows cn(mgs) > cnuc(mgs)
11302 ! cn(mgs) = Min( cn(mgs), cnuc(mgs) )
11304 ! IF ( ccna(mgs) >= cnuc(mgs) ) THEN ! apply limit after all "base" CCN have been depleted
11305 CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11308 CN(mgs) = Min( cn(mgs), cnuc(mgs) - ccna(mgs) ) ! no more than remaining "base" CCN
11310 ! Philips, Donner et al. 2007, but results in too much limitation of
11312 ! CN(mgs) = Min(cn(mgs), ccnc(mgs))
11313 ! cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11315 dcloud = 1000.*dcrit**3*Pi/6.
11316 ! cn(mgs) = Min(cn(mgs), 0.5*dqc/dcloud) ! limit the nucleation mass to half of the condensation mass
11317 ! check new droplet size:
11318 ! tmp is number of droplets at diameter dcrit
11319 tmp = Max(0.0, rho0(mgs)*qx(mgs,lc)/dcloud - cx(mgs,lc)) ! (cx(mgs,lc) + cn(mgs))
11320 cn(mgs) = Min(tmp, cn(mgs) )
11323 IF ( cn(mgs) > 0.0 ) THEN
11324 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11328 dcloud = 1000.*dcrit**3*Pi/6.*cn(mgs)
11329 qx(mgs,lc) = qx(mgs,lc) + DCLOUD
11330 thetap(mgs) = thetap(mgs) + felvcp(mgs)*DCLOUD/(pi0(mgs))
11331 qwvp(mgs) = qwvp(mgs) - DCLOUD
11333 ! 6/13/2016: Phillips et al. appears not to decrement CCN, but only increments CCNa.
11334 ! This would allow an initially non-homogeneous (vertically, e.g.) initial value of CCN/rho_air
11335 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11336 ELSEIF ( irenuc == 7 .or. irenuc == 17 ) THEN !} {
11338 ! simple Twomey scheme but limit activation to try to do most activation near cloud base, but keep some CCN available for renuclation
11339 ! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11341 IF ( irenuc == 7 ) THEN
11346 ! IF ( ccna(mgs) < 0.7*cnuc(mgs) .and. ccnc(mgs) > 0.69*cnuc(mgs) - ccna(mgs)) THEN ! here, assume we are near cloud base and use Twomey formulation
11347 IF ( ccna(mgs) < frac*cnuc(mgs) ) THEN ! { here, assume we are near cloud base and use Twomey formulation
11348 CN(mgs) = Min( (frac+0.01)*cnuc(mgs), CCNE0*cnuc(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp )! *Min(1.0,1./dtp) ! 0.3465
11349 ! IF ( cn(mgs) + ccna(mgs) > 0.71*cnuc ) THEN
11350 ! prevent this branch from activating more than 70% of CCN
11351 CN(mgs) = Min( CN(mgs), Max(0.0, (frac*cnuc(mgs) - ccna(mgs) )) )
11352 ! CN(mgs) = Min( CN(mgs), Max(0.0, 0.71*ccnc(mgs) - ccna(mgs) ) )
11353 ! write(0,*) '1: k,cn = ',kgs(mgs),cn(mgs),ssf(mgs)
11354 !! IF ( ccncuf(mgs) > 0.0 .and. cn(mgs) < 1.e-3 .and. ssmax(mgs) > 1.0 ) THEN
11355 ! IF ( ccncuf(mgs) > 0.0 .and. ssf(mgs) > ssmxuf .and. ssmax(mgs) > ssmxuf ) THEN
11356 ! CNuf(mgs) = Min( ccncuf(mgs), CCNE0*ccncuf(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp )! *Min(1.0,1./dtp) ! 0.3465
11357 ! IF ( cnuf(mgs) >= 0.0 ) write(0,*) '1: cnuf, k = ',cnuf(mgs),ccncuf(mgs),kgs(mgs)
11362 ! if a large fraction of CCN have been activated, then assume we are in the cloud interior and use local SSw as in Phillips et al. 2007.
11364 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11365 ! t0(ix,jy,kz) = temp1
11366 ltemq = Int( (temp1-163.15)/fqsat+1.5 )
11367 ltemq = Min( nqsat, Max(1,ltemq) )
11369 ! c1 = t00(igs(mgs),jy,kgs(mgs))*tabqvs(ltemq)
11370 c1= pqs(mgs)*tabqvs(ltemq)
11373 IF ( c1 > 0. ) THEN
11374 ssf(mgs) = 100.*(qx(mgs,lv)/c1 - 1.0) ! from "new" values
11377 ! IF ( ssf(mgs) <= 1.0 .or. cnuc(mgs) > ccna(mgs) ) THEN
11378 IF ( ssf(mgs) <= 1.0 ) THEN
11379 CN(mgs) = cnuc(mgs)*Min(1.0, Max(0.0,ssf(mgs))**cck ) !
11381 CN(mgs) = cnuc(mgs)*Min(2.0, Max(0.0,0.03*(ssf(mgs)-1.0)+1.)**cck ) !
11382 ! write(0,*) 'iren7: ssf,ssmx = ',ssf(mgs),ssmax(mgs),cn(mgs),ccna(mgs),cnuc(mgs)
11383 ! write(0,*) 'c1,qv = ',c1,qx(mgs,lv),temp1,ltemq
11386 ! write(0,*) 'k,cn = ',kgs(mgs),cn(mgs),ssf(mgs)
11387 ! write(0,*) 'ccn-ccna = ',cnuc(mgs) - ccna(mgs),ccnc(mgs) - ccna(mgs)
11388 ! IF ( ccncuf(mgs) > 0.0 .and. cn(mgs) < 1.e-3 .and. ssmax(mgs) > 1.0 ) THEN
11389 IF ( ccncuf(mgs) > 0.0 .and. ssf(mgs) > ssmxuf .and. ( ssmax(mgs) > ssmxuf .or. lss < 1 ) ) THEN
11390 CNuf(mgs) = Min( ccncuf(mgs), CCNE0*ccncuf(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp )! *Min(1.0,1./dtp) ! 0.3465
11391 ! IF ( cnuf(mgs) >= 0.0 ) write(0,*) 'cnuf, k = ',cnuf(mgs),ccncuf(mgs),kgs(mgs)
11395 ! CN(mgs) = Min( Min(0.1,ssf(mgs)-1.)*cnuc(mgs), Max( 0.0, CN(mgs) - ccna(mgs) ) ) ! this was from
11396 ! CN(mgs) = Min( Min(0.5*cx(mgs,lc), Min(0.1,ssf(mgs)/100.)*cnuc(mgs)), Max( 0.0, CN(mgs) - ccna(mgs) ) ) ! this was from
11398 CN(mgs) = Min(0.01*cnuc(mgs), Max( 0.0, CN(mgs) - ccna(mgs) ) ) ! this was from
11401 ! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
11402 !!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11403 ! Philips, Donner et al. 2007, but results in too much limitation of
11405 ! CN(mgs) = Min(cn(mgs), ccnc(mgs))
11406 ! cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11409 IF ( icnuclimit > 0 ) THEN
11410 ! max droplet conc. based on Chandrakar et al. (2016) and Konwar et al. (2012)
11411 tmp = ccnc(mgs) - ccna(mgs) + cx(mgs,lc)
11412 IF ( tmp < 330.34e6 ) THEN
11413 ccwmax = 1.1173e6 * (1.e-6*tmp)**0.9504
11415 ccwmax = 21.57e6 * (1.e-6*tmp)**0.44
11418 cn(mgs) = Max( 0.0, Min( cn(mgs), ccwmax - cx(mgs,lc) ) )
11422 IF ( cn(mgs) + cnuf(mgs) > 0.0 ) THEN
11425 dcloud = 1000.*dcrit**3*Pi/6.
11426 ! cn(mgs) = Min(cn(mgs), 0.5*dqc/dcloud) ! limit the nucleation mass to half of the condensation mass
11427 ! check new droplet size:
11428 ! tmp is number of droplets at diameter dcrit
11429 tmp = Max(0.0, rho0(mgs)*qx(mgs,lc)/dcloud - cx(mgs,lc)) ! (cx(mgs,lc) + cn(mgs))
11430 cn(mgs) = Min(tmp, cn(mgs) )
11432 cx(mgs,lc) = cx(mgs,lc) + cn(mgs) + cnuf(mgs)
11435 ! create some small droplets at minimum size (CP 2000), although it adds very little liquid
11439 dcloud = 1000.*dcrit**3*Pi/6.*(cn(mgs) + cnuf(mgs) )
11440 qx(mgs,lc) = qx(mgs,lc) + DCLOUD
11441 thetap(mgs) = thetap(mgs) + felvcp(mgs)*DCLOUD/(pi0(mgs))
11442 qwvp(mgs) = qwvp(mgs) - DCLOUD
11443 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11444 ccncuf(mgs) = Max(0.0, ccncuf(mgs) - cnuf(mgs))
11447 ELSEIF ( irenuc == 8 ) THEN !} {
11448 ! simple Twomey scheme
11449 ! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11453 IF ( ccnc(mgs) > 0. ) THEN
11454 CN(mgs) = CCNE0*ccnc(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp ! *Min(1.0,1./dtp) ! 0.3465
11455 ! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
11456 !!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11457 ! Philips, Donner et al. 2007, but results in too much limitation of
11459 CN(mgs) = Min(cn(mgs), ccnc(mgs))
11461 ELSEIF ( cx(mgs,lc) < 0.01e9 ) THEN
11463 ! if a large fraction of CCN have been activated, then assume we are in the cloud interior and use local SSw as in Phillips et al. 2007.
11465 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11466 ! t0(ix,jy,kz) = temp1
11467 ltemq = Int( (temp1-163.15)/fqsat+1.5 )
11468 ltemq = Min( nqsat, Max(1,ltemq) )
11470 ! c1 = t00(igs(mgs),jy,kgs(mgs))*tabqvs(ltemq)
11471 c1= pqs(mgs)*tabqvs(ltemq)
11474 IF ( c1 > 0. ) THEN
11475 ssf(mgs) = 100.*(qx(mgs,lv)/c1 - 1.0) ! from "new" values
11478 ! IF ( ssf(mgs) <= 1.0 .or. cnuc(mgs) > ccna(mgs) ) THEN
11479 IF ( ssf(mgs) <= 1.0 ) THEN
11482 ! CN(mgs) = 0.01e9*rho0(mgs)/rho00*Min(2.0, Max(0.0,0.03*(ssf(mgs)-1.0)+1.)**cck ) - cx(mgs,lc) !
11483 CN(mgs) = 0.01e9*Min(2.0, Max(0.0,0.03*(ssf(mgs)-1.0)+1.)**cck ) - cx(mgs,lc) !
11488 IF ( cn(mgs) > 0.0 ) THEN
11489 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11491 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11493 ! create some small droplets at minimum size (CP 2000), although it adds very little liquid
11497 dcloud = 1000.*dcrit**3*Pi/6.*cn(mgs)
11498 qx(mgs,lc) = qx(mgs,lc) + DCLOUD
11499 thetap(mgs) = thetap(mgs) + felvcp(mgs)*DCLOUD/(pi0(mgs))
11500 qwvp(mgs) = qwvp(mgs) - DCLOUD
11501 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11508 ccna(mgs) = ccna(mgs) + cn(mgs)
11510 ENDIF ! irenuc >= 0 .and. .not. flag_qndrop
11512 IF( cx(mgs,lc) .GT. 0. .AND. qx(mgs,lc) .LE. qxmin(lc)) cx(mgs,lc)=0.
11514 !.... NUCLEATION ON CLOUD INFLOW BOUNDARY POINT
11521 ! Check for supersaturation greater than ssmx and adjust down
11524 qv1 = qv0(mgs) + qwvp(mgs)
11527 ! IF ( flag_qndrop .and. do_satadj_for_wrfchem ) ssmx = 1.04 ! set lower threshold for progn=1 when using WRF-CHEM
11529 IF ( qv1 .gt. (ssmx*qvs1) ) THEN
11530 ! use line below to disable saturation adjustment when flag_qndrop is true
11531 ! IF ( qv1 .gt. (ssmx*qvs1) .and. .not. flag_qndrop ) THEN
11535 ssmx = 100.*(ssmx - 1.0)
11539 CALL QVEXCESS(ngs,mgs,qwvp,qv0,qx(1,lc),pres,thetap,theta0,qvex, &
11540 & pi0,tabqvs,nqsat,fqsat,cbw,fcqv1,felvcp,ssmx,pk,ngscnt)
11544 IF ( qvex .gt. 0.0 ) THEN
11545 thetap(mgs) = thetap(mgs) + felvcp(mgs)*qvex/(pi0(mgs))
11546 IF ( io_flag .and. nxtra > 1 ) THEN
11547 axtra(igs(mgs),jy,kgs(mgs),1) = axtra(igs(mgs),jy,kgs(mgs),1) + qvex/dtp
11549 qwvp(mgs) = qwvp(mgs) - qvex
11550 qx(mgs,lc) = qx(mgs,lc) + qvex
11551 IF ( .not. flag_qndrop) THEN
11552 IF ( imaxsupopt == 1 ) THEN
11553 cn(mgs) = Min( Max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/Max( cwmasn5, xmas(mgs,lc) ) )
11554 ELSEIF ( imaxsupopt == 2 ) THEN
11555 cn(mgs) = Min( Max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/Max( cwmasn5, Max(cwmas30,xmas(mgs,lc)) ) )
11556 ELSEIF ( imaxsupopt == 3 ) THEN
11557 cn(mgs) = Min( Max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/Max( cwmasn5, Max(cwmasx,xmas(mgs,lc)) ) )
11558 ! cn(mgs) = 1.5*cxmin
11559 ELSEIF ( imaxsupopt == 4 ) THEN
11560 cn(mgs) = Min( Max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/Max( cwmasn5, Max(cwmas20,xmas(mgs,lc)) ) )
11562 IF ( lccna > 1 ) THEN
11563 ccna(mgs) = ccna(mgs) + cn(mgs)
11565 ccnc(mgs) = Max( 0.0, ccnc(mgs) - cn(mgs) )
11567 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11570 ! write(iunit,*) 'theta = ',theta0(mgs) + thetap(mgs)
11572 ! temg(mgs) = theta(mgs)*( pres(mgs) / poo ) ** cap
11580 ! Calculate droplet volume and check if it is within bounds.
11581 ! Adjust if necessary
11583 ! if (ndebug .gt. 0) write(0,*) "ICEZVD_DR: check droplet volume"
11586 ! cx(mgs,lc) = Min( cwnccn(mgs), cx(mgs,lc) )
11587 IF( cx(mgs,lc) > cxmin .AND. qx(mgs,lc) .GT. qxmin(lc)) THEN
11588 ! SVC(mgs) = rho0(mgs)*qx(mgs,lc)/(cx(mgs,lc)*xdn(mgs,lc))
11589 xmas(mgs,lc) = rho0(mgs)*qx(mgs,lc)/(cx(mgs,lc))
11591 IF ( xmas(mgs,lc) < cwmasn .or. xmas(mgs,lc) > cwmasx ) THEN
11593 xmas(mgs,lc) = Min( xmas(mgs,lc), cwmasx )
11594 xmas(mgs,lc) = Max( xmas(mgs,lc), cwmasn )
11595 cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc)
11596 ! IF ( cx(mgs,lc) > tmp*1.1 ) THEN
11597 ! write(0,*) 'nucond: kgs, ccw1,2 = ',kgs(mgs),tmp,cx(mgs,lc)
11603 ! IF( cx(mgs,lc) .GT. 10.e6 .AND. qx(mgs,lc) .GT. qxmin(lc) ) GO TO 681
11604 ! ccwtmp = cx(mgs,lc)
11605 ! cwmastmp = xmas(mgs,lc)
11606 ! xmas(mgs,lc) = Max(xmas(mgs,lc), cwmasn)
11607 ! IF (qx(mgs,lc) .GT. qxmin(lc) .AND. cx(mgs,lc) .le. 0.) THEN
11608 ! cx(mgs,lc) = Min(0.5*cwccn,rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc))
11609 ! xmas(mgs,lc) = rho0(mgs)*qx(mgs,lc)/cx(mgs,lc)
11611 ! IF (cx(mgs,lc) .GT. 0. .AND. qx(mgs,lc) .GT. qxmin(lc)) &
11612 ! & xmas(mgs,lc) = rho0(mgs)*qx(mgs,lc)/cx(mgs,lc)
11613 ! IF (qx(mgs,lc) .GT. qxmin(lc) .AND. xmas(mgs,lc) .LT. cwmasn) &
11614 ! & xmas(mgs,lc) = cwmasn
11615 ! IF (qx(mgs,lc) .GT. qxmin(lc) .AND. xmas(mgs,lc) .GT. cwmasx) &
11616 ! & xmas(mgs,lc) = cwmasx
11617 ! IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN
11618 ! cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/Max(cwmasn,xmas(mgs,lc))
11625 IF ( ipconc .ge. 3 .and. rcond == 2 ) THEN
11628 IF (cx(mgs,lr) .GT. 0. .AND. qx(mgs,lr) .GT. qxmin(lr)) &
11629 & xv(mgs,lr)=rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr))
11630 IF (xv(mgs,lr) .GT. xvmx(lr)) xv(mgs,lr) = xvmx(lr)
11631 IF (xv(mgs,lr) .LT. xvmn(lr)) xv(mgs,lr) = xvmn(lr)
11640 ! ################################################################
11642 IF ( lss > 1 .and. ssf(mgs) .gt. ssmax(mgs) &
11643 & .and. ( idecss .eq. 0 .or. qx(mgs,lc) .gt. qxmin(lc)) ) THEN
11644 ssmax(mgs) = ssf(mgs)
11650 an(igs(mgs),jy,kgs(mgs),lt) = theta0(mgs) + thetap(mgs)
11651 an(igs(mgs),jy,kgs(mgs),lv) = qv0(mgs) + qwvp(mgs)
11652 ! tmp3d(igs(mgs),jy,kgs(mgs)) = tmp3d(igs(mgs),jy,kgs(mgs)) + t9(igs(mgs),jy,kgs(mgs)) ! pi0(mgs) ! wvdf(mgs) ! ssf(mgs) ! cn(mgs)
11654 IF ( eqtset > 2 ) THEN
11655 p2(igs(mgs),jy,kgs(mgs)) = pipert(mgs)
11658 if ( ido(lc) .eq. 1 ) then
11659 an(igs(mgs),jy,kgs(mgs),lc) = qx(mgs,lc) + &
11660 & min( an(igs(mgs),jy,kgs(mgs),lc), 0.0 )
11661 ! qx(mgs,lc) = an(igs(mgs),jy,kgs(mgs),lc)
11665 if ( ido(lr) .eq. 1 .and. rcond == 2 ) then
11666 an(igs(mgs),jy,kgs(mgs),lr) = qx(mgs,lr) + &
11667 & min( an(igs(mgs),jy,kgs(mgs),lr), 0.0 )
11668 ! qx(mgs,lr) = an(igs(mgs),jy,kgs(mgs),lr)
11671 IF ( lzr > 1 .and. rcond == 2 ) THEN
11672 an(igs(mgs),jy,kgs(mgs),lzr) = zx(mgs,lr) + &
11673 & min( an(igs(mgs),jy,kgs(mgs),lzr), 0.0 )
11677 IF ( ipconc .ge. 2 ) THEN
11678 an(igs(mgs),jy,kgs(mgs),lnc) = Max(cx(mgs,lc) , 0.0)
11679 IF ( lss > 1 ) an(igs(mgs),jy,kgs(mgs),lss) = Max( 0.0, ssmax(mgs) )
11680 IF ( ac_opt == 0 ) THEN
11681 IF ( lccn .gt. 1 .and. lccna .lt. 1 ) THEN
11682 an(igs(mgs),jy,kgs(mgs),lccn) = Max(0.0, ccnc(mgs) )
11685 IF ( lccnuf .gt. 1 .and. .not. ( lccna .gt. 1 .and. i_uf_or_ccn > 0 ) ) THEN
11686 an(igs(mgs),jy,kgs(mgs),lccnuf) = Max(0.0, ccncuf(mgs) )
11688 IF ( lccna .gt. 1 ) THEN
11689 an(igs(mgs),jy,kgs(mgs),lccna) = Max(0.0, ccna(mgs) )
11692 IF ( ipconc .ge. 3 .and. rcond == 2 ) THEN
11693 an(igs(mgs),jy,kgs(mgs),lnr) = Max(cx(mgs,lr) , 0.0)
11701 if ( kz .gt. nz-1 .and. ix .ge. nxi) then
11702 if ( ix .ge. nxi ) then
11703 go to 2200 ! exit gather scatter
11711 if ( ix .ge. nxi ) then
11718 2000 continue ! inumgs
11721 ! end of gather scatter (for this jy slice)
11728 ! Redistribute inappreciable cloud particles and charge
11730 ! Redistribution everywhere in the domain...
11734 frac = 1.0 ! 0.25 ! 1.0 ! 0.2
11736 ! alternate test version for ipconc .ge. 3
11737 ! just vaporize stuff to prevent noise in the number concentrations
11744 t0(ix,jy,kz) = an(ix,jy,kz,lt)*t77(ix,jy,kz)
11746 zerocx(:) = .false.
11748 IF ( iresetmoments == 1 .or. iresetmoments == il ) THEN
11749 IF ( ln(il) > 1 ) zerocx(il) = ( an(ix,jy,kz,ln(il)) < cxmin )
11750 IF ( lz(il) > 1 ) zerocx(il) = ( zerocx(il) .or. an(ix,jy,kz,lz(il)) < zxmin )
11752 IF ( il == lc ) THEN
11753 IF ( ln(il) > 1 ) zerocx(il) = ( an(ix,jy,kz,ln(il)) <= 0 ) .and. .not. flag_qndrop ! do not reset if progn=1 (WRF-CHEM)
11755 IF ( ln(il) > 1 ) zerocx(il) = ( an(ix,jy,kz,ln(il)) <= 0 )
11760 IF ( lhl .gt. 1 ) THEN
11762 IF ( lzhl .gt. 1 ) THEN
11764 an(ix,jy,kz,lzhl) = Max(0.0, an(ix,jy,kz,lzhl) )
11766 IF ( an(ix,jy,kz,lhl) .ge. frac*qxmin(lhl) .and. rescale_low_alpha ) THEN ! check 6th moment
11768 IF ( an(ix,jy,kz,lnhl) .gt. 0.0 ) THEN
11770 IF ( lvhl .gt. 1 ) THEN
11771 IF ( an(ix,jy,kz,lvhl) .gt. 0.0 ) THEN
11772 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
11776 hwdn = Max( xdnmn(lhl), hwdn )
11781 chw = an(ix,jy,kz,lnhl)
11782 g1 = (6.0+alphamin)*(5.0+alphamin)*(4.0+alphamin)/ &
11783 & ((3.0+alphamin)*(2.0+alphamin)*(1.0+alphamin))
11784 z1 = g1*dn(ix,jy,kz)**2*( an(ix,jy,kz,lhl) )*an(ix,jy,kz,lhl)/chw
11785 z1 = z1*(6./(pi*hwdn))**2
11790 an(ix,jy,kz,lzhl) = Min( z1, an(ix,jy,kz,lzhl) )
11792 IF ( an(ix,jy,kz,lnhl) .lt. 1.e-5 ) THEN
11793 ! an(ix,jy,kz,lzhl) = 0.9*an(ix,jy,kz,lzhl)
11799 if ( an(ix,jy,kz,lhl) .lt. frac*qxmin(lhl) .or. zerocx(lhl) ) then
11801 ! IF ( an(ix,jy,kz,lhl) .gt. 0 ) THEN
11802 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lhl)
11803 an(ix,jy,kz,lhl) = 0.0
11806 IF ( ipconc .ge. 5 ) THEN ! .and. an(ix,jy,kz,lnh) .gt. 0.0 ) THEN
11807 an(ix,jy,kz,lnhl) = 0.0
11810 IF ( lvhl .gt. 1 ) THEN
11811 an(ix,jy,kz,lvhl) = 0.0
11814 IF ( lhlw .gt. 1 ) THEN
11815 an(ix,jy,kz,lhlw) = 0.0
11818 IF ( lnhlf .gt. 1 ) THEN
11819 an(ix,jy,kz,lnhlf) = 0.0
11822 IF ( lzhl .gt. 1 ) THEN
11823 an(ix,jy,kz,lzhl) = 0.0
11827 IF ( lvol(lhl) .gt. 1 ) THEN ! check density
11828 IF ( an(ix,jy,kz,lvhl) .gt. 0.0 ) THEN
11829 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
11830 ELSE ! in case volume is zero but mass is above threshold (should not happen, of course)
11832 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
11835 IF ( tmp .lt. xdnmn(lhl) ) THEN
11836 tmp = Max( xdnmn(lhl), tmp )
11837 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
11840 IF ( tmp .gt. xdnmx(lhl) .and. lhlw .le. 0 ) THEN ! no liquid allowed on hail
11841 tmp = Min( xdnmx(lhl), tmp )
11842 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
11843 ELSEIF ( tmp .gt. xdnmx(lhl) .and. lhlw .gt. 1 ) THEN ! allow for liquid on hail
11844 fw = an(ix,jy,kz,lhlw)/an(ix,jy,kz,lhl)
11845 ! tmpmx = xdnmx(lhl) + fw*(xdnmx(lr) - xdnmx(lhl)) ! maximum possible average density
11846 ! it is not exactly linear, but approx. is close enough for this
11847 ! tmpmx = 1./( (1. - fw)/900. + fw/1000. ) is exact max, where 900 is xdnmx
11849 tmpmx = xdnmx(lhl)/( 1. - fw*(1. - xdnmx(lhl)/xdnmx(lr) ))
11851 IF ( tmp .gt. tmpmx ) THEN
11852 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmpmx
11855 ! IF ( tmp .gt. xdnmx(lhl) .and. an(ix,jy,kz,lhlw) .lt. qxmin(lhl) ) THEN
11856 ! tmp = Min( xdnmx(lhl), tmp )
11857 ! an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
11858 ! ELSEIF ( tmp .gt. xdnmx(lr) ) THEN
11860 ! an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
11864 IF ( lhlw .gt. 1 ) THEN ! check if basically pure water
11865 IF ( an(ix,jy,kz,lhlw) .gt. 0.98*an(ix,jy,kz,lhl) ) THEN
11867 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
11875 IF ( ipconc == 5 .and. an(ix,jy,kz,lhl) .gt. qxmin(lhl) .and. alphahl .le. 0.1 .and. lnhl .gt. 1 .and. lzhl == 0 ) THEN
11877 IF ( lvhl .gt. 1 ) THEN
11878 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
11882 tmp = (hwdn*an(ix,jy,kz,lnhl))/(dn(ix,jy,kz)*an(ix,jy,kz,lhl))
11883 tmpg = an(ix,jy,kz,lnhl)*(tmp*(3.14159))**(1./3.)
11884 IF ( tmpg .lt. cnohlmn ) THEN
11885 tmp = ( (hwdn)/(dn(ix,jy,kz)*an(ix,jy,kz,lhl))*(3.14159))**(1./3.)
11886 an(ix,jy,kz,lnhl) = (cnohlmn/tmp)**(3./4.)
11890 ! ELSE ! check mean size here?
11898 IF ( lzh .gt. 1 ) THEN
11900 an(ix,jy,kz,lzh) = Max(0.0, an(ix,jy,kz,lzh) )
11902 IF ( .false. .and. an(ix,jy,kz,lh) .ge. frac*qxmin(lh) .and. rescale_low_alpha ) THEN
11904 IF ( an(ix,jy,kz,lnh) .gt. 0.0 ) THEN
11906 IF ( lvh .gt. 1 ) THEN
11907 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
11908 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
11912 hwdn = Max( xdnmn(lh), hwdn )
11917 chw = an(ix,jy,kz,lnh)
11918 g1 = (6.0+alphamin)*(5.0+alphamin)*(4.0+alphamin)/ &
11919 & ((3.0+alphamin)*(2.0+alphamin)*(1.0+alphamin))
11920 z1 = g1*dn(ix,jy,kz)**2*( an(ix,jy,kz,lh) )*an(ix,jy,kz,lh)/chw
11921 z1 = z1*(6./(pi*hwdn))**2
11926 an(ix,jy,kz,lzh) = Min( z1, an(ix,jy,kz,lzh) )
11928 IF ( an(ix,jy,kz,lnh) .lt. 1.e-5 ) THEN
11929 ! an(ix,jy,kz,lzh) = 0.9*an(ix,jy,kz,lzh)
11935 if ( an(ix,jy,kz,lh) .lt. frac*qxmin(lh) .or. zerocx(lh) ) then
11937 ! IF ( an(ix,jy,kz,lh) .gt. 0 ) THEN
11938 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lh)
11939 an(ix,jy,kz,lh) = 0.0
11942 IF ( ipconc .ge. 5 ) THEN ! .and. an(ix,jy,kz,lnh) .gt. 0.0 ) THEN
11943 an(ix,jy,kz,lnh) = 0.0
11946 IF ( lvh .gt. 1 ) THEN
11947 an(ix,jy,kz,lvh) = 0.0
11950 IF ( lhw .gt. 1 ) THEN
11951 an(ix,jy,kz,lhw) = 0.0
11954 IF ( lnhf .gt. 1 ) THEN
11955 an(ix,jy,kz,lnhf) = 0.0
11958 IF ( lzh .gt. 1 ) THEN
11959 an(ix,jy,kz,lzh) = 0.0
11963 IF ( lvol(lh) .gt. 1 ) THEN ! check density
11964 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
11965 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
11968 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
11971 IF ( tmp .lt. xdnmn(lh) ) THEN
11972 tmp = Max( xdnmn(lh), tmp )
11973 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
11976 IF ( tmp .gt. xdnmx(lh) .and. lhw .le. 0 ) THEN ! no liquid allowed on graupel
11977 tmp = Min( xdnmx(lh), tmp )
11978 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
11979 ELSEIF ( tmp .gt. xdnmx(lh) .and. lhw .gt. 1 ) THEN ! allow for liquid on graupel
11980 fw = an(ix,jy,kz,lhw)/an(ix,jy,kz,lh)
11981 ! tmpmx = xdnmx(lh) + fw*(xdnmx(lr) - xdnmx(lh)) ! maximum possible average density
11982 ! it is not exactly linear, but approx. is close enough for this
11983 ! tmpmx = 1./( (1. - fw)/900. + fw/1000. ) is exact max, where 900 is xdnmx
11984 tmpmx = xdnmx(lh)/( 1. - fw*(1. - xdnmx(lh)/xdnmx(lr) ))
11986 IF ( tmp .gt. tmpmx ) THEN
11987 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmpmx
11990 ! IF ( tmp .gt. xdnmx(lh) .and. an(ix,jy,kz,lhw) .lt. qxmin(lh) ) THEN
11991 ! tmp = Min( xdnmx(lh), tmp )
11992 ! an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
11993 ! ELSEIF ( tmp .gt. xdnmx(lr) ) THEN
11995 ! an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
12000 IF ( lhw .gt. 1 ) THEN ! check if basically pure water
12001 IF ( an(ix,jy,kz,lhw) .gt. 0.98*an(ix,jy,kz,lh) ) THEN
12003 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
12010 IF ( ipconc == 5 .and. an(ix,jy,kz,lh) .gt. qxmin(lh) .and. alphah .le. 0.1 .and. lnh .gt. 1 .and. lzh == 0 ) THEN
12012 IF ( lvh .gt. 1 ) THEN
12013 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
12014 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
12018 hwdn = Max( xdnmn(lh), hwdn )
12022 tmp = (hwdn*an(ix,jy,kz,lnh))/(dn(ix,jy,kz)*an(ix,jy,kz,lh))
12023 tmpg = an(ix,jy,kz,lnh)*(tmp*(3.14159))**(1./3.)
12024 IF ( tmpg .lt. cnohmn ) THEN
12025 ! tmpg = an(ix,jy,kz,lnh)*( (hwdn*an(ix,jy,kz,lnh))/(dn(ix,jy,kz)*an(ix,jy,kz,lh))*(3.14159))**(1./3.)
12026 ! tmpg = an(ix,jy,kz,lnh)**(4./3.)*( (hwdn)/(dn(ix,jy,kz)*an(ix,jy,kz,lh))*(3.14159))**(1./3.)
12027 tmp = ( (hwdn)/(dn(ix,jy,kz)*an(ix,jy,kz,lh))*(3.14159))**(1./3.)
12028 an(ix,jy,kz,lnh) = (cnohmn/tmp)**(3./4.)
12036 if ( an(ix,jy,kz,ls) .lt. frac*qxmin(ls) .or. zerocx(ls) & ! .or. an(ix,jy,kz,lns) .lt. 0.1 ! .and.
12038 IF ( t0(ix,jy,kz) .lt. 273.15 ) THEN
12039 ! IF ( an(ix,jy,kz,ls) .gt. 0 ) THEN
12040 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,ls)
12041 an(ix,jy,kz,ls) = 0.0
12044 IF ( ipconc .ge. 4 ) THEN ! .and. an(ix,jy,kz,lns) .gt. 0.0 ) THEN !
12045 ! an(ix,jy,kz,lni) = an(ix,jy,kz,lni) + an(ix,jy,kz,lns)
12046 an(ix,jy,kz,lns) = 0.0
12049 IF ( lvs .gt. 1 ) THEN
12050 an(ix,jy,kz,lvs) = 0.0
12053 IF ( lsw .gt. 1 ) THEN
12054 an(ix,jy,kz,lsw) = 0.0
12058 ! IF ( an(ix,jy,kz,ls) .gt. 0 ) THEN
12059 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,ls)
12060 an(ix,jy,kz,ls) = 0.0
12063 IF ( lvs .gt. 1 ) THEN
12064 an(ix,jy,kz,lvs) = 0.0
12067 IF ( lsw .gt. 1 ) THEN
12068 an(ix,jy,kz,lsw) = 0.0
12071 IF ( ipconc .ge. 4 ) THEN ! .and. an(ix,jy,kz,lns) .gt. 0.0 ) THEN !
12072 ! an(ix,jy,kz,lnr) = an(ix,jy,kz,lnr) + an(ix,jy,kz,lns)
12073 an(ix,jy,kz,lns) = 0.0
12079 ELSEIF ( lvol(ls) .gt. 1 ) THEN ! check density
12080 IF ( an(ix,jy,kz,lvs) .gt. 0.0 ) THEN
12081 tmp = dn(ix,jy,kz)*an(ix,jy,kz,ls)/an(ix,jy,kz,lvs)
12082 IF ( tmp .gt. xdnmx(ls) .or. tmp .lt. xdnmn(ls) ) THEN
12083 tmp = Min( xdnmx(ls), Max( xdnmn(ls), tmp ) )
12084 an(ix,jy,kz,lvs) = dn(ix,jy,kz)*an(ix,jy,kz,ls)/tmp
12088 an(ix,jy,kz,lvs) = dn(ix,jy,kz)*an(ix,jy,kz,ls)/tmp
12094 IF ( lzr > 1 ) THEN
12095 an(ix,jy,kz,lzr) = Max(0.0, an(ix,jy,kz,lzr) )
12098 if ( an(ix,jy,kz,lr) .lt. frac*qxmin(lr) .or. zerocx(lr) &
12100 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lr)
12101 an(ix,jy,kz,lr) = 0.0
12102 IF ( ipconc .ge. 3 ) THEN
12103 ! an(ix,jy,kz,lnc) = an(ix,jy,kz,lnc) + an(ix,jy,kz,lnr)
12104 an(ix,jy,kz,lnr) = 0.0
12107 IF ( lzr > 1 ) THEN
12108 an(ix,jy,kz,lzr) = 0.0
12116 IF ( an(ix,jy,kz,li) .le. frac*qxmin(li) .or. zerocx(li) & ! .or. an(ix,jy,kz,lni) .lt. 0.1
12118 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,li)
12119 an(ix,jy,kz,li)= 0.0
12120 IF ( ipconc .ge. 1 ) THEN
12121 an(ix,jy,kz,lni) = 0.0
12128 IF ( lis > 1 ) THEN ! {
12129 IF ( an(ix,jy,kz,lis) .le. frac*qxmin(lis) .or. zerocx(lis) & ! .or. an(ix,jy,kz,lni) .lt. 0.1
12131 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lis)
12132 an(ix,jy,kz,lis)= 0.0
12133 IF ( ipconc .ge. 1 ) THEN
12134 an(ix,jy,kz,lnis) = 0.0
12137 ELSEIF ( icespheres >= 2 ) THEN ! } {
12139 IF ( 0.5*( w(ix,jy,kz) + w(ix,jy,kz+1)) < -1.0 .or. &
12140 & (icespheres == 3 .and. ( t0(ix,jy,kz) < 232.15 .or. an(ix,jy,kz,lc) < qxmin(lc) ) ) .or. &
12141 & (icespheres == 5 .and. ( t0(ix,jy,kz) < 232.15 .or. &
12142 & ( an(ix,jy,kz,lc) < qxmin(lc) .and. an(ix,jy,km1,lc) < qxmin(lc) )) ) .or. &
12143 & (icespheres == 4 .and. ( t0(ix,jy,kz) < 235.15 )) ) THEN ! transfer to regular ice crystals in downdraft or at low temp
12144 an(ix,jy,kz,li) = an(ix,jy,kz,li) + an(ix,jy,kz,lis)
12145 an(ix,jy,kz,lni) = an(ix,jy,kz,lni) + an(ix,jy,kz,lnis)
12146 an(ix,jy,kz,lis)= 0.0
12147 an(ix,jy,kz,lnis)= 0.0
12158 IF ( an(ix,jy,kz,lc) .le. frac*qxmin(lc) .or. zerocx(lc) &
12160 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lc)
12161 an(ix,jy,kz,lc)= 0.0
12162 IF ( ipconc .ge. 2 ) THEN
12163 IF ( lccn .gt. 1 .or. ac_opt == 1 ) THEN
12164 IF ( irenuc < 5 .and. lccna <= 1 ) THEN
12165 IF ( ac_opt == 0 ) THEN
12166 an(ix,jy,kz,lccn) = an(ix,jy,kz,lccn) + Max(0.0,an(ix,jy,kz,lnc))
12168 ELSEIF ( lccna > 1 ) THEN
12169 an(ix,jy,kz,lccna) = Max( 0.0, an(ix,jy,kz,lccna) - Max(0.0,an(ix,jy,kz,lnc)) )
12172 an(ix,jy,kz,lnc) = 0.0
12173 IF ( lccn > 1 ) an(ix,jy,kz,lccn) = Max( 0.0, an(ix,jy,kz,lccn) )
12175 IF ( lccna > 0 .and. ac_opt == 0 ) THEN ! apply exponential decay to activated CCN to restore to environmental value
12176 IF ( restoreccn ) THEN
12177 tmp = an(ix,jy,kz,li) + an(ix,jy,kz,ls)
12179 IF ( an(ix,jy,kz,lccna) > 1. .and. tmp < qxmin(li) ) an(ix,jy,kz,lccna) = an(ix,jy,kz,lccna)*Exp(-dtp/ccntimeconst)
12181 ELSEIF ( lccn > 1 .and. restoreccn .and. ac_opt == 0 ) THEN
12182 ! in this case, we are treating the ccn field as ccna
12183 tmp = an(ix,jy,kz,li) + an(ix,jy,kz,ls)
12184 ! IF ( ny == 2 .and. ix == nx/2 ) THEN
12185 ! write(0,*) 'restore: k, qccn,exp = ',kz,qccn,dn(ix,jy,kz)*qccn,Exp(-dtp/ccntimeconst)
12186 ! write(0,*) 'ccn1,ccn2 = ',an(ix,jy,kz,lccn),dn(ix,jy,kz)*qccn - Max(0.0 , dn(ix,jy,kz)*qccn - an(ix,jy,kz,lccn))*Exp(-dtp/ccntimeconst)
12188 IF ( an(ix,jy,kz,lccn) > 1. .and. tmp < qxmin(li) .and. ( an(ix,jy,kz,lccn) < dn(ix,jy,kz)*qccn .or. .not. invertccn ) ) THEN
12189 ! an(ix,jy,kz,lccn) = &
12190 ! an(ix,jy,kz,lccn) + Max(0.0 , dn(ix,jy,kz)*qccn - an(ix,jy,kz,lccn))*(1.0 - Exp(-dtp/ccntimeconst))
12191 ! Equivalent form after expanding last term:
12192 an(ix,jy,kz,lccn) = &
12193 dn(ix,jy,kz)*qccn - Max(0.0 , dn(ix,jy,kz)*qccn - an(ix,jy,kz,lccn))*Exp(-dtp/ccntimeconst)
12208 IF ( ndebug .ge. 1 ) write(6,*) 'END OF ICEZVD_DR'
12215 END SUBROUTINE NUCOND
12218 ! #####################################################################
12219 ! #####################################################################
12224 !c--------------------------------------------------------------------------
12227 !--------------------------------------------------------------------------
12230 subroutine nssl_2mom_gs &
12231 & (nx,ny,nz,na,jyslab &
12234 & ,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9 &
12238 & ventr,ventc,c1sw,jgs,ido, &
12240 ! & ln,ipc,lvol,lz,lliq, &
12242 & xdn0,tmp3d,tkediss &
12243 & ,thproc,numproc,dx1,dy1,ngs &
12244 & ,timevtcalc,axtra,io_flag &
12245 & , has_wetscav,rainprod2d, evapprod2d, alpha2d &
12246 & ,elec,its,ids,ide,jds,jde &
12251 !--------------------------------------------------------------------------
12253 ! Ziegler 1985 parameterized microphysics (also Zrnic et al. 1993)
12260 !--------------------------------------------------------------------------
12264 ! 4/27/2009: allows for liquid water to be advected on snow and graupel particles using flag "mixedphase"
12266 ! 3/14/2007: (APS) added qproc temp to make microphysic process timeseries
12268 ! 10/17/2006: added flag (iehw) to select how to calculate ehw
12270 ! 10/5/2006: switched chacr to integrated version rather than assuming that average rain
12271 ! drop mass does not change. This acts to reduce rain size somewhat via graupel
12273 ! Use Mason data for ehw, with scaling toward ehw=1 as air density decreases.
12275 ! 10/3/2006: Turned off Meyers nucleation for T > -5 (can turn on with imeyers5 flag)
12276 ! Turned off contact nucleation in updrafts
12278 ! 7/24/2006: Turned on Meyers nucleation for -5 < T < 0
12280 ! 5/12/2006: Converted qsacw/csacw and qsaci/csaci to Z93
12282 ! 5/12/2006: Put a threshold on Bigg rain freezing. If the frozen drops
12283 ! have an average volume less than xvhmn, then the drops are put
12284 ! into snow instead of graupel/hail.
12286 ! Fixed bug when vapor deposition was limited.
12288 ! 5/13/2006: Note that qhacr has a large effect, but Z85 did not include it.
12289 ! Turned off qsacr (set to zero).
12291 ! 9/14/2007: erm: recalculate vx(lh) after setting xdn(lh) in case xdn was out of allowed range.
12292 ! added parameter rimc3 for minimum rime density. Default value set at 170. kg/m**3
12293 ! instead of previous use of 100. (Farley, 1987)
12295 !--------------------------------------------------------------------------
12297 ! general declarations
12299 !--------------------------------------------------------------------------
12308 ! parameter ( icond = 2 )
12310 integer, parameter :: ng1 = 1
12312 integer nx,ny,nz,na,nba,nv
12313 integer nor,norz,istag,jstag,kstag ! ,nht,ngt,igsr
12317 logical, intent(in) :: io_flag
12319 integer itile,jtile,ktile
12320 integer ixbeg,jybeg
12321 integer ixend,jyend,kzend,kzbeg
12322 integer nxend,nyend,nzend,nzbeg
12323 integer :: my_rank = 0
12324 integer, parameter :: myprock = 1, nprock = 1
12325 logical, intent(in) :: has_wetscav
12326 integer, intent(in) :: numproc
12327 real, intent(inout) :: thproc(nz,numproc)
12328 real, intent(in) :: dx1,dy1
12329 real rainprod2d(-nor+1:nx+nor,-norz+ng1:nz+norz)
12330 real evapprod2d(-nor+1:nx+nor,-norz+ng1:nz+norz)
12332 real alpha2d(-nor+1:nx+nor,-norz+ng1:nz+norz,3)
12334 real, parameter :: tfrdry = 243.15
12336 logical lrescalelow(lc:lhab)
12337 real tkediss(-nor+1:nx+nor,-norz+ng1:nz+norz)
12338 real axtra(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz,nxtra)
12343 integer jyslab,its,ids,ide,jds,jde ! domain boundaries
12344 integer, intent(in) :: iunit !,iunit0
12346 integer iraincv, icgxconv
12347 parameter ( iraincv = 1, icgxconv = 1)
12349 real :: ffrzh = 1.0
12351 real qcitmp,cirdiatmp ! ,qiptmp,qirtmp
12352 real ccwtmp,ccitmp ! ,ciptmp,cirtmp
12353 real cpqc,cpci ! ,cpip,cpir
12354 real cpqc0,cpci0 ! ,cpip0,cpir0
12355 real scfac ! ,cpip1
12357 double precision dp1
12359 double precision frac, frach, xvfrz, xvbiggsnow
12361 double precision :: timevtcalc
12362 double precision :: dpt1,dpt2
12364 logical, parameter :: gammacheck = .false.
12366 double precision :: tmpgam
12367 logical, parameter :: usegamxinfcnu = .false.
12368 logical, parameter :: usegamxinf = .false.
12369 logical, parameter :: usegamxinf2 = .false.
12370 logical, parameter :: usegamxinf3 = .false.
12371 ! real rar ! rime accretion rate as calculated from qxacw
12373 ! a few vars for time-split fallout
12377 double precision chgneg,chgpos,sctot
12381 real pb(-norz+ng1:nz+norz)
12382 real pinit(-norz+ng1:nz+norz)
12384 real gz(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz) ! dz
12386 real qimax,xni0,roqi0
12392 integer itest,nidx,id1,jd1,kd1
12393 parameter (itest=1)
12394 parameter (nidx=10)
12395 parameter (id1=1,jd1=1,kd1=1)
12399 integer ix,kz, il, ic, ir, icp1, irp1, ip1,jp1,kp1
12403 real slope1, slope2
12406 parameter (eps=1.e-20,eps2=1.e-5)
12413 logical ldovol, ishail, ltest, wtest
12414 logical , parameter :: alp0flag = .false.
12420 parameter (mu=1,mv=2,mw=3)
12422 ! conversion parameters
12424 integer mqcw,mqxw,mtem,mrho,mtim
12425 parameter (mqcw=21,mqxw=21,mtem=21,mrho=5,mtim=6)
12427 real xftim,xftimi,yftim, xftem,yftem, xfqcw,yfqcw, xfqxw,yfqxw
12428 parameter (xftim=0.05,xftimi = 1./xftim,yftim=1.)
12429 parameter (xftem=0.5,yftem=1.)
12430 parameter (xfqcw=2000.,yfqcw=1.)
12431 parameter (xfqxw=2000.,yfqxw=1.)
12433 parameter ( dtfac = 1.0 )
12434 integer ido(lc:lqmx)
12436 ! integer iexy(lc:lqmx,lc:lqmx)
12437 ! integer ieswi, ieswir, ieswip, ieswc, ieswr
12438 ! integer ieglsw, iegli, ieglir, ieglip, ieglc, ieglr
12439 ! integer iegmsw, iegmi, iegmir, iegmip, iegmc, iegmr
12440 ! integer ieghsw, ieghi, ieghir, ieghip, ieghc, ieghr
12441 ! integer iefwsw, iefwi, iefwir, iefwip, iefwc, iefwr
12442 ! integer iehwsw, iehwi, iehwir, iehwip, iehwc, iehwr
12443 ! integer iehlsw, iehli, iehlir, iehlip, iehlc, iehlr
12444 ! real delqnsa, delqxsa, delqnsb, delqxsb, delqnia, delqxia
12445 ! real delqnra, delqxra
12447 real delqnxa(lc:lqmx)
12448 real delqxxa(lc:lqmx)
12450 ! external temporary arrays
12452 real t00(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12453 real t77(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12455 real t0(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12456 real t1(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12457 real t2(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12458 real t3(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12459 real t4(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12460 real t5(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12461 real t6(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12462 real t7(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12463 real t8(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12464 real t9(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12466 real p2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz) ! perturbation Pi
12467 real pn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz)
12468 real an(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz,na)
12469 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz)
12470 real w(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz)
12472 real tmp3d(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12475 ! declarations microphyscs and for gather/scatter
12477 integer nxmpb,nzmpb,nxz
12478 integer jgs,mgs,ngs,numgs
12479 integer, parameter :: ngsz = 500
12481 parameter (ntt=300)
12485 integer ngscnt,igs(ngs),kgs(ngs)
12486 integer kgsp(ngs),kgsm(ngs),kgsm2(ngs)
12488 parameter (ncuse=0)
12489 integer il0(ngs),il5(ngs),il2(ngs),il3(ngs)
12490 ! integer il1m(ngs),il2m(ngs),il3m(ngs),il4m(ngs),il5m(ngs)
12492 real tdtol,temsav,tfrcbw,tfrcbi
12493 real, parameter :: thnuc = 235.15
12495 ! Ice Multiplication Arrays.
12497 real fimt1(ngs),fimta(ngs),fimt2(ngs) !,qmul1(ngs),qmul2(ngs)
12501 ! Variables for Ziegler warm rain microphysics
12505 real ccnc(ngs),ccin(ngs),cina(ngs),ccna(ngs)
12507 real sscb ! 'cloud base' SS threshold
12508 parameter ( sscb = 2.0 )
12509 integer idecss ! flag to turn on (=1) decay of ssmax when no cloud or ice crystals
12510 parameter ( idecss = 1 )
12511 integer iba ! flag to do condensation/nucleation in 1st or 2nd loop
12512 ! =0 to use ad to calculate SS
12513 ! =1 to use an at end of main jy loop to calculate SS
12514 parameter (iba = 1)
12515 integer ifilt ! =1 to filter ssat, =0 to set ssfilt=ssat
12516 parameter ( ifilt = 0 )
12517 real temp1,temp2 ! ,ssold
12518 real :: mwat, mice, dice, mwshed, fwmax, fw, mwcrit, massfactor, tmpdiam
12519 real, parameter :: shedalp = 3. ! set 3 for maximum mass diameter (same as area-weighted diameter), 4 for mass-weighted diameter
12520 real ssmax(ngs) ! maximum SS experienced by a parcel
12523 ! real cnu,rnu,snu,cinu
12524 ! parameter ( cnu = 0.0, rnu = -0.8, snu = -0.8, cinu = 0.0 )
12525 real bfnu, bfnu0, bfnu1
12526 parameter ( bfnu0 = (rnu + 2.0)/(rnu + 1.0) )
12529 double precision t2s, xdp
12530 double precision xl2p(ngs),rb(ngs)
12531 real, parameter :: aa1 = 9.44e15, aa2 = 5.78e3 ! a1 in Ziegler
12533 real, parameter :: cexs = 0.1, cecs = 0.5
12534 real, parameter :: rvt = 0.104 ! ratio of collection kernels (Zrnic et al, 1993)
12535 real, parameter :: kfrag = 1.0e-6 ! rate coefficent for collisional splintering (Schuur & Rutledge 00b)
12536 real, parameter :: mfrag = 1.0e-10 ! assumed ice fragment mass for collisional splintering (Schuur & Rutledge 00b)
12537 double precision cautn(ngs), rh(ngs), nh(ngs)
12538 real ex1, ft, rhoinv(ngs)
12539 double precision ec0(ngs)
12541 real ac1,bc, taus, c1,d1,e1,f1,p380,tmp,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,temp3 ! , sstdy, super
12544 double precision :: tmpz, tmpzmlt
12545 real ratio, delx, dely
12547 real chgtmp,fac,mixedphasefac
12548 real x,y,y2,del,r,rtmp,alpr
12549 double precision :: vent1,vent2
12550 double precision :: g1palp,g4palp
12551 double precision :: g1palpinf,g4palpinf
12552 real fqt !charge separation as fn of temperature from Dong and Hallett 1992
12555 real d1r, d1i, d1s, e1i
12556 real c1sw ! integration factor for snow melting with snu = -0.8
12557 real, parameter :: vr1mm = 5.23599e-10 ! volume of 1mm diameter sphere (m**3)
12558 real, parameter :: vr3mm = 5.23599e-10*(3.0/1.)**3 ! volume of a 3 mm diameter sphere (m**3) (Rasmussen et al. 1984b, JAS)
12559 real, parameter :: vr4p5mm = 5.23599e-10*(4.5/1.)**3 ! volume of 4.5mm diameter sphere (m**3) (Rasmussen et al. 1984b, JAS)
12560 real vmlt,vshd, vshdgs(ngs,lh:lhab), maxmassfac(lc:lhab)
12562 parameter ( rhosm = 500. )
12563 integer nc ! condensation step
12564 real dtcon,dtcon1,dtcon2 ! condensation time step (dtcon*nc = dtp)
12566 integer ltemq1,ltemq1m ! ,ltemq1m2
12567 real dqv,qv1,ss1,ss2,qvs1,dqvs,dtemp,dt1 ! temporaries for condensation
12568 real ssi1, ssi2, dqvi, dqvis, dqvii,qis1
12569 real dqvr, dqc, dqr, dqi, dqs
12570 real qv1m,qvs1m,ss1m,ssi1m,qis1m
12572 real dcloud,dcloud2 ! ,as, bs
12574 double precision xvc, xvr
12576 ! real es(ngs) ! ss(ngs),
12582 parameter ( vgra = 0.523599*(1.0e-3)**3 )
12584 ! real, parameter :: epsi = 0.622
12585 ! real, parameter :: d = 0.266
12586 real :: d, dold, denom,denominv,vth
12587 double precision :: h1, h2, h3, h4,denomdp, denominvdp
12588 real r1,qevap ! ,slv
12590 real vr,nrx,chw,g1,qr,z,z1,rdi,alp,xnutmp,xnuc,g1r,rd1,rdia,rmas
12591 real :: snowmeltmass = 0
12593 ! real, parameter :: rhofrz = 900. ! density of graupel from newly-frozen rain
12594 real, parameter :: rimedens = 500. ! default rime density
12596 ! real svc(ngs) ! droplet volume
12598 ! contact freezing nucleation
12600 real raero,kaero !assumd aerosol radius, thermal conductivity
12601 parameter ( raero = 3.e-7, kaero = 5.39e-3 )
12602 real kb ! Boltzman constant J K-1
12603 parameter (kb = 1.3807e-23)
12605 real knud(ngs),knuda(ngs) !knudsen number and correction factor
12606 real gtp(ngs) !G(T,p) = 1/(a' + b') Cotton 72b
12607 real dfar(ngs) !aerosol diffusivity
12608 real fn1(ngs),fn2(ngs),fnft(ngs)
12611 real ctfzbd(ngs),ctfzth(ngs),ctfzdi(ngs)
12616 real dqvcnd(ngs),dqwv(ngs),dqcw(ngs),dqci(ngs),dqcitmp(ngs),dqwvtmp(ngs)
12618 real temg(ngs),temcg(ngs),theta(ngs),qvap(ngs)
12619 real temgkm1(ngs), temgkm2(ngs)
12620 real temgx(ngs),temcgx(ngs)
12621 real qvs(ngs),qis(ngs),qss(ngs),pqs(ngs)
12622 real elv(ngs),elf(ngs),els(ngs)
12623 real tsqr(ngs),ssi(ngs),ssw(ngs),ssi0(ngs)
12624 real qcwtmp(ngs),qtmp,qtot(ngs)
12627 real cimasn,cimasx,ccimx
12629 real cs,ds,gf7,gf6,gf5,gf4,gf3,gf2,gf1
12631 real gf73rds, gf83rds
12632 real gamice73fac, gamsnow73fac
12633 real gf43rds, gf53rds
12634 real aradcw,bradcw,cradcw,dradcw,cwrad,rwrad,rwradmn
12635 parameter ( rwradmn = 50.e-6 )
12637 real dg0(ngs),df0(ngs)
12638 real dhwet(ngs),dhlwet(ngs),dfwet(ngs)
12640 real clionpmx,clionnmx
12641 parameter (clionpmx=1.e9,clionnmx=1.e9) ! Takahashi 84
12645 real fwet1(ngs),fwet2(ngs)
12646 real fmlt1(ngs),fmlt2(ngs),fmlt1e(ngs)
12647 real fvds(ngs),fvce(ngs),fiinit(ngs)
12648 real fvent(ngs),fraci(ngs),fracl(ngs)
12650 real fai(ngs),fav(ngs),fbi(ngs),fbv(ngs)
12651 real felv(ngs),fels(ngs),felf(ngs)
12652 real felvcp(ngs),felscp(ngs),felfcp(ngs)
12653 real felvpi(ngs),felspi(ngs),felfpi(ngs)
12654 real felvs(ngs),felss(ngs) ! ,felfs(ngs)
12655 real fwvdf(ngs),ftka(ngs),fthdf(ngs)
12656 real fadvisc(ngs),fakvisc(ngs)
12657 real fci(ngs),fcw(ngs) ! heat capacities of ice and liquid
12658 real fschm(ngs),fpndl(ngs)
12659 real fgamw(ngs),fgams(ngs)
12660 real fcqv1(ngs),fcqv2(ngs),fcc3(ngs)
12664 real, parameter :: cpv = 1885.0 ! specific heat of water vapor at constant pressure
12666 real fcci(ngs), fcip(ngs)
12668 real :: sfm1(ngs),sfm2(ngs)
12669 real :: gfm1(ngs),gfm2(ngs)
12670 real :: ffm1(ngs),ffm2(ngs)
12671 real :: hfm1(ngs),hfm2(ngs)
12673 logical :: wetsfc(ngs),wetsfchl(ngs),wetsfcf(ngs)
12674 logical :: wetgrowth(ngs), wetgrowthhl(ngs), wetgrowthf(ngs)
12676 real qitmp(ngs),qistmp(ngs)
12678 real rzxh(ngs), rzxhl(ngs), rzxhlh(ngs), rzxhlf(ngs)
12679 real rzxs(ngs), rzxf(ngs)
12680 ! real axh(ngs),bxh(ngs),axhl(ngs),bxhl(ngs)
12681 real cdh(ngs),cdhl(ngs)
12682 real :: axx(ngs,lh:lhab),bxx(ngs,lh:lhab)
12685 real :: qcwresv(ngs), ccwresv(ngs) ! "reserved" droplet mass and number that are too small for accretion
12687 real :: lfsave(ngs,6)
12688 real :: qx(ngs,lv:lhab)
12689 real :: qxw(ngs,ls:lhab)
12690 real :: qxwlg(ngs,lh:lhab)
12691 real :: chxf(ngs,lh:lhab)
12692 real :: cx(ngs,lc:lhab)
12693 real :: cxmxd(ngs,lc:lhab)
12694 real :: qxmxd(ngs,lv:lhab)
12695 real :: scx(ngs,lc:lhab)
12696 real :: xv(ngs,lc:lhab)
12697 real :: vtxbar(ngs,lc:lhab,3)
12698 real :: xmas(ngs,lc:lhab)
12699 real :: xdn(ngs,lc:lhab)
12700 real :: xdntmp(ngs,lc:lhab)
12701 real :: cdxgs(ngs,lc:lhab)
12702 real :: xdia(ngs,lc:lhab,3)
12703 real :: vtwtdia(ngs,lr:lhab) ! sweep-out volume weighted diameter
12704 real :: rarx(ngs,ls:lhab)
12705 real :: vx(ngs,li:lhab)
12706 real :: rimdn(ngs,li:lhab)
12707 real :: raindn(ngs,li:lhab)
12708 real :: alpha(ngs,lc:lhab)
12709 real :: dab0lh(ngs,lc:lhab,lc:lhab)
12710 real :: dab1lh(ngs,lc:lhab,lc:lhab)
12711 real :: zx(ngs,lr:lhab)
12712 real :: zxmxd(ngs,lr:lhab)
12713 real :: g1x(ngs,lr:lhab)
12716 real :: qsimxdep(ngs) ! max sublimation of qi+qs+qis
12717 real :: qsimxsub(ngs) ! max depositionof qi+qs+qis
12718 logical,parameter :: DoSublimationFix = .true.
12719 real :: qrtmp(ngs),qvtmp(ngs),qctmp(ngs)
12720 real :: felvcptmp,felscptmp,qsstmp
12721 real :: thetatmp, thetaptmp, temcgtmp,qvaptmp
12722 real :: qvstmp, qisstmp, qvptmp, qitmp1, qctmp1
12728 real g1shr, alphashr
12729 real g1mlr, alphamlr
12730 real g1smlr, alphasmlr
12731 real massfacshr, massfacmlr
12733 real :: qhgt8mm ! ice mass greater than 8mm
12734 real :: qhwgt8mm ! ice + max water mass greater than 8mm
12735 real :: qhgt10mm ! mass greater than 10mm
12736 real :: qhgt20mm ! mass greater than 20mm
12738 real, parameter :: fwmhtmptem = -15. ! temperature at which fwmhtmp fully switches to liquid water only being on large particles
12739 real, parameter :: d1t = (6.0 * 0.268e-3/(917.* pi))**(1./3.) ! d1t is the diameter of the ice sphere with the mass (0.268e-3 kg) of an 8mm spherical drop
12740 real, parameter :: srasheym = 0.1389 ! slope fraction from Rasmussen and Heymsfield
12742 real swvent(ngs),hwvent(ngs),rwvent(ngs),hlvent(ngs),hwventy(ngs),hlventy(ngs),rwventz(ngs)
12744 real hlventinc(ngs),hwventinc(ngs)
12745 integer, parameter :: ndiam = 10
12747 real hwvent0(ndiam+4),hlvent0 ! 0 to d1
12748 real hwvent1,hlvent1 ! d1 to infinity
12749 real hwvent2,hlvent2 ! d2 to infinity
12753 ! real, parameter :: mltdiam1 = 9.0e-3, mltdiam1p5 = 16.0e-3, mltdiam2 = 19.0e-3, mltdiam3 = 200.0e-3, mltdiam05 = 4.5e-3
12754 real :: mltdiam(ndiam+4)
12755 real mltmass0inv,mltmass1inv,mltmass2inv, mltmass1cgs, mltmass2cgs,mltmass3inv, mltmass3cgs
12756 real qhmlr0, qhmlr05, qhmlr1, qhmlr2,qhmlr3, qhmlr12, qhmlr23
12757 real qhlmlr0, qhlmlr05, qhlmlr1, qhlmlr2,qhlmlr3, qhlmlr12, qhlmlr23
12758 real qxd1, cxd1, zxd1 ! mass and number up to mltdiam1
12759 real qxd05, cxd05 ! mass and number up to mltdiam1/2
12761 real :: qxd(ndiam+4), cxd(ndiam+4), qhml(ndiam+4), qhml0(ndiam+4)
12762 real :: dqxd(ndiam+4), dcxd(ndiam+4), dqhml(ndiam+4)
12769 real xdnmx(lc:lhab), xdnmn(lc:lhab)
12771 real :: xdiamxmas(ngs,lc:lhab)
12773 real cilen(ngs) ! ,ciplen(ngs)
12776 real rwcap(ngs),swcap(ngs)
12783 real qimxd(ngs),qismxd(ngs),qcmxd(ngs),qrmxd(ngs),qsmxd(ngs),qhmxd(ngs),qhlmxd(ngs)
12784 real cimxd(ngs),ccmxd(ngs),crmxd(ngs),csmxd(ngs),chmxd(ngs)
12785 real cionpmxd(ngs),cionnmxd(ngs)
12786 real clionpmxd(ngs),clionnmxd(ngs)
12789 real elec(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz) ! Ez (elecsave)
12793 ! Hallett-Mossop arrays
12794 real chmul1(ngs),chlmul1(ngs),csmul1(ngs),csmul(ngs)
12795 real qhmul1(ngs),qhlmul1(ngs),qsmul1(ngs),qsmul(ngs)
12797 ! splinters from drop freezing
12798 real csplinter(ngs),qsplinter(ngs)
12799 real csplinter2(ngs),qsplinter2(ngs)
12802 ! concentration arrays...
12804 real :: chlcnh(ngs), vhlcnh(ngs), vhlcnhl(ngs)
12805 real :: chlcnhhl(ngs) ! number of new hail particles (may be different from number of lost graupel)
12806 real cracif(ngs), ciacrf(ngs)
12810 real ciint(ngs), crfrz(ngs), crfrzf(ngs), crfrzs(ngs)
12813 real ciacw(ngs), cwacii(ngs)
12814 real ciacr(ngs), craci(ngs)
12817 real csaci(ngs), csacs(ngs)
12819 real chacw(ngs), chacr(ngs)
12820 real :: chlacw(ngs)
12821 real chaci(ngs), chacs(ngs)
12823 real :: chlacr(ngs)
12824 real :: chlaci(ngs), chlacs(ngs)
12826 real cidpv(ngs),cisbv(ngs)
12827 real cisdpv(ngs),cissbv(ngs)
12828 real cimlr(ngs),cismlr(ngs)
12830 real chlsbv(ngs), chldpv(ngs)
12831 real chlmlr(ngs), chlmlrr(ngs)
12833 ! real chlmlrsave(ngs),chlsave(ngs),qhlsave(ngs)
12834 real chlshr(ngs), chlshrr(ngs)
12837 real chdpv(ngs),chsbv(ngs)
12838 real chmlr(ngs),chcev(ngs)
12840 real chshr(ngs), chshrr(ngs)
12842 real csdpv(ngs),cssbv(ngs)
12843 real csmlr(ngs),csmlrr(ngs),cscev(ngs)
12844 real csshr(ngs), csshrr(ngs)
12848 real cwshw(ngs), qwshw(ngs)
12851 ! arrays for w-ac-x ; x-ac-w
12855 real qrcnw(ngs), qwcnr(ngs)
12856 real zrcnw(ngs),zracr(ngs),zracw(ngs),zrcev(ngs)
12858 real qracw(ngs) ! qwacr(ngs),
12859 real qiacw(ngs) !, qwaci(ngs)
12861 real qsacw(ngs) ! ,qwacs(ngs),
12862 real qhacw(ngs) ! qwach(ngs),
12863 real :: qhlacw(ngs), qxacwtmp, qxacrtmp, qxacitmp, qxacstmp !
12864 real vhacw(ngs), vsacw(ngs), vhlacw(ngs), vhlacr(ngs)
12867 real qfmul1(ngs),cfmul1(ngs)
12872 ! arrays for x-ac-r and r-ac-x;
12874 real qsacr(ngs),qracs(ngs)
12875 real qhacr(ngs),qhacrmlr(ngs),qhacwmlr(ngs) ! ,qrach(ngs)
12876 real vhacr(ngs), zhacr(ngs), zhacrf(ngs), zrach(ngs), zrachl(ngs)
12877 real qiacr(ngs),qraci(ngs)
12881 real qracif(ngs),qiacrf(ngs),qiacrs(ngs),ciacrs(ngs)
12883 real :: qhlacr(ngs),qhlacrmlr(ngs), qhlacwmlr(ngs)
12884 real qsacrs(ngs) !,qracss(ngs)
12886 ! ice - ice interactions
12893 real :: qhacis(ngs)
12894 real :: chacis(ngs)
12895 real :: chacis0(ngs)
12897 real :: csaci0(ngs) ! collision rate only
12898 real :: chaci0(ngs) ! collision rate only
12899 real :: chacs0(ngs) ! collision rate only
12900 real :: chlaci0(ngs)
12901 real :: chlacis(ngs)
12902 real :: chlacis0(ngs)
12903 real :: chlacs0(ngs)
12905 real :: qsaci0(ngs) ! collision rate only
12906 real :: qsacis0(ngs) ! collision rate only
12907 real :: qhaci0(ngs) ! collision rate only
12908 real :: qhacis0(ngs) ! collision rate only
12909 real :: qhacs0(ngs) ! collision rate only
12910 real :: qhlaci0(ngs)
12911 real :: qhlacis0(ngs)
12912 real :: qhlacs0(ngs)
12914 real :: qhlaci(ngs)
12915 real :: qhlacis(ngs)
12916 real :: qhlacs(ngs)
12920 real qrfrz(ngs) ! , qirirhr(ngs)
12921 real zrfrz(ngs), zrfrzf(ngs), zrfrzs(ngs)
12922 real ziacrf(ngs), zhcnsh(ngs), zhcnih(ngs)
12923 real zhacw(ngs), zhacs(ngs), zhaci(ngs)
12924 real zhmlr(ngs), zhdsv(ngs), zhsbv(ngs), zhlcnh(ngs), zhshr(ngs)
12925 real zfacw(ngs), zfacs(ngs), zfaci(ngs)
12926 real zfmlr(ngs), zfdsv(ngs), zfsbv(ngs), zhlcnf(ngs), zfshr(ngs), zfshrr(ngs)
12927 real zhmlrtmp,zhmlr0inf,zhlmlr0inf
12928 real zhmlrr(ngs),zhlmlrr(ngs),zhshrr(ngs),zhlshrr(ngs),zfmlrr(ngs)
12930 real zsmlrr(ngs), zsshr(ngs), zsshrr(ngs)
12931 real zhcns(ngs), zhcni(ngs)
12932 real zhwdn(ngs), zfwdn(ngs) ! change in Z due to density changes
12933 real zhldn(ngs) ! change in Z due to density changes
12935 real zhlacw(ngs), zhlacs(ngs), zhlacr(ngs)
12936 real zhlmlr(ngs), zhldsv(ngs), zhlsbv(ngs), zhlshr(ngs)
12939 real vrfrzf(ngs), viacrf(ngs)
12940 real qrfrzs(ngs), qrfrzf(ngs)
12941 real qwfrz(ngs), qwctfz(ngs)
12942 real cwfrz(ngs), cwctfz(ngs)
12943 real qwfrzis(ngs), qwctfzis(ngs) ! droplet freezing to ice spheres
12944 real cwfrzis(ngs), cwctfzis(ngs)
12945 real qwfrzc(ngs), qwctfzc(ngs) ! droplet freezing to columns
12946 real cwfrzc(ngs), cwctfzc(ngs)
12947 real qwfrzp(ngs), qwctfzp(ngs) ! droplet freezing to plates
12948 real cwfrzp(ngs), cwctfzp(ngs)
12949 real xcolmn(ngs), xplate(ngs)
12950 real ciihr(ngs), qiihr(ngs)
12951 real cicichr(ngs), qicichr(ngs)
12952 real cipiphr(ngs), qipiphr(ngs)
12953 real qscni(ngs), cscni(ngs), cscnis(ngs)
12954 real qscnvi(ngs), cscnvi(ngs), cscnvis(ngs)
12955 real qhcns(ngs), chcns(ngs), chcnsh(ngs), vhcns(ngs)
12956 real qscnh(ngs), cscnh(ngs), vscnh(ngs)
12957 real qhcni(ngs), chcni(ngs), chcnih(ngs), vhcni(ngs)
12958 real qiint(ngs),qipipnt(ngs),qicicnt(ngs)
12959 real cninm(ngs),cnina(ngs),cninp(ngs),wvel(ngs),wvelkm1(ngs)
12961 real uvel(ngs),vvel(ngs)
12963 real qidpv(ngs),qisbv(ngs) ! qicnv(ngs),qievv(ngs),
12964 real qimlr(ngs),qidsv(ngs),qisdsv(ngs),qidsvp(ngs) ! ,qicev(ngs)
12969 real :: qhldpv(ngs), qhlsbv(ngs) ! qhlcnv(ngs),qhlevv(ngs),
12970 real :: qhlmlr(ngs), qhldsv(ngs), qhlmlrsave(ngs)
12971 real :: qhlwet(ngs), qhldry(ngs), qhlshr(ngs), qxwettmp
12973 real :: qrfz(ngs),qsfz(ngs),qhfz(ngs),qhlfz(ngs)
12976 real qhdpv(ngs),qhsbv(ngs) ! qhcnv(ngs),qhevv(ngs),
12977 real qhmlr(ngs),qhdsv(ngs),qhcev(ngs),qhcndv(ngs),qhevv(ngs)
12978 real qhlcev(ngs), chlcev(ngs)
12979 real qhwet(ngs),qhdry(ngs),qhshr(ngs)
12981 real qhshh(ngs) !accreted water that remains on graupel
12982 real qhmlh(ngs) !melt water that remains on graupel
12983 real qhfzh(ngs) !water that freezes on mixed-phase graupel
12984 real qffzf(ngs) !water that freezes on mixed-phase FD
12985 real qhlfzhl(ngs) !water that freezes on mixed-phase hail
12987 real qhmlrlg(ngs),qhlmlrlg(ngs) ! melting from the larger diameters
12988 real qhfzhlg(ngs) !water that freezes on mixed-phase graupel (large sizes)
12989 real qhlfzhllg(ngs) !water that freezes on mixed-phase hail (large sizes)
12990 real qhlcevlg(ngs), chlcevlg(ngs)
12991 real qhcevlg(ngs), chcevlg(ngs)
12993 real vhfzh(ngs), vffzf(ngs) ! change in volume from water that freezes on mixed-phase graupel, frozen drops
12994 real vhlfzhl(ngs) ! change in volume from water that freezes on mixed-phase hail
12996 real vhshdr(ngs) !accreted water that leaves on graupel (mixedphase)
12997 real vhlshdr(ngs) !accreted water that leaves on hail (mixedphase)
12998 real vhmlr(ngs) !melt water that leaves graupel (single phase)
12999 real vhlmlr(ngs) !melt water that leaves hail (single phase)
13000 real vhsoak(ngs) ! aquired water that seeps into graupel.
13001 real vhlsoak(ngs) ! aquired water that seeps into hail.
13004 real qsdpv(ngs),qssbv(ngs) ! qscnv(ngs),qsevv(ngs),
13005 real qsmlr(ngs),qsdsv(ngs),qscev(ngs),qscndv(ngs),qsevv(ngs)
13006 real qswet(ngs),qsdry(ngs),qsshr(ngs)
13011 real qipdpv(ngs),qipsbv(ngs)
13012 real qipmlr(ngs),qipdsv(ngs)
13014 real qirdpv(ngs),qirsbv(ngs)
13015 real qirmlr(ngs),qirdsv(ngs),qirmlw(ngs)
13017 real qgldpv(ngs),qglsbv(ngs)
13018 real qglmlr(ngs),qgldsv(ngs)
13019 real qglwet(ngs),qgldry(ngs),qglshr(ngs)
13022 real qgmdpv(ngs),qgmsbv(ngs)
13023 real qgmmlr(ngs),qgmdsv(ngs)
13024 real qgmwet(ngs),qgmdry(ngs),qgmshr(ngs)
13026 real qghdpv(ngs),qghsbv(ngs)
13027 real qghmlr(ngs),qghdsv(ngs)
13028 real qghwet(ngs),qghdry(ngs),qghshr(ngs)
13031 real qrztot(ngs),qrzmax(ngs),qrzfac(ngs)
13034 real fsw(ngs),fhw(ngs),fhlw(ngs),ffw(ngs) !liquid water fractions
13035 real fswmax(ngs),fhwmax(ngs),fhlwmax(ngs) !liquid water fractions
13038 real :: qhlcnh(ngs)
13039 real qhcngh(ngs),qhcngm(ngs),qhcngl(ngs)
13041 real :: qhcnhl(ngs), chcnhl(ngs), zhcnhl(ngs), vhcnhl(ngs) ! conversion of low-density hail back to graupel
13043 real eiw(ngs),eii(ngs),eiri(ngs),eipir(ngs),eisw(ngs)
13044 real erw(ngs),esw(ngs),eglw(ngs),eghw(ngs),efw(ngs)
13045 real ehxw(ngs),ehlw(ngs),egmw(ngs),ehw(ngs)
13046 real err(ngs),esr(ngs),eglr(ngs),eghr(ngs),efr(ngs)
13047 real ehxr(ngs),ehlr(ngs),egmr(ngs)
13048 real eri(ngs),esi(ngs),egli(ngs),eghi(ngs),efi(ngs),efis(ngs)
13049 real ehxi(ngs),ehli(ngs),egmi(ngs),ehi(ngs),ehis(ngs),ehlis(ngs)
13050 real ers(ngs),ess(ngs),egls(ngs),eghs(ngs),efs(ngs),ehs(ngs),ehsfac(ngs)
13052 real ehxs(ngs),ehls(ngs),egms(ngs),egmip(ngs)
13054 real ehsclsn(ngs),ehiclsn(ngs),ehisclsn(ngs)
13055 real efsclsn(ngs),eficlsn(ngs),efisclsn(ngs)
13056 real ehlsclsn(ngs),ehliclsn(ngs),ehlisclsn(ngs)
13059 real :: ehs_collsn = 0.5, ehi_collsn = 1.0
13060 real :: efs_collsn = 0.5, efi_collsn = 1.0
13061 real :: ehls_collsn = 1.0, ehli_collsn = 1.0
13062 real :: esi_collsn = 1.0
13065 real cwr(8,2) ! radius and inverse of interval
13066 data cwr / 2.0, 3.0, 4.0, 6.0, 8.0, 10.0, 15.0, 20.0 , & ! radius
13067 & 1.0, 1.0, 0.5, 0.5, 0.5, 0.2, 0.2, 1. / ! inverse of interval
13068 integer icwr(ngs), igwr(ngs), irwr(ngs), ihlr(ngs), ifwr(ngs)
13069 real grad(6,2) ! graupel radius and inverse of interval
13070 data grad / 100., 200., 300., 400., 600., 1000., &
13071 & 1.e-2,1.e-2,1.e-2,5.e-3,2.5e-3, 1. /
13072 !droplet radius: 2 3 4 6 8 10 15 20
13073 data ew /0.03, 0.07, 0.17, 0.41, 0.58, 0.69, 0.82, 0.88, & ! 100
13074 ! : 0.07, 0.13, 0.27, 0.48, 0.65, 0.73, 0.84, 0.91, ! 150
13075 & 0.10, 0.20, 0.34, 0.58, 0.70, 0.78, 0.88, 0.92, & ! 200
13076 & 0.15, 0.31, 0.44, 0.65, 0.75, 0.83, 0.96, 0.91, & ! 300
13077 & 0.17, 0.37, 0.50, 0.70, 0.81, 0.87, 0.93, 0.96, & ! 400
13078 & 0.17, 0.40, 0.54, 0.71, 0.83, 0.88, 0.94, 0.98, & ! 600
13079 & 0.15, 0.37, 0.52, 0.74, 0.82, 0.88, 0.94, 0.98 / ! 1000
13080 ! : 0.11, 0.34, 0.49, 0.71, 0.83, 0.88, 0.94, 0.95 / ! 1400
13083 real da0lr(ngs),da1lr(ngs)
13084 real da0lc(ngs),da1lc(ngs)
13088 real :: da0lx(ngs,lr:lhab)
13090 real va0 (lc:lqmx) ! collection coefficients from Seifert 2005
13091 real vab0(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
13092 real vab1(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
13093 real va1 (lc:lqmx) ! collection coefficients from Seifert 2005
13094 real ehip(ngs),ehlip(ngs),ehlir(ngs)
13095 real erir(ngs),esir(ngs),eglir(ngs),egmir(ngs),eghir(ngs)
13096 real efir(ngs),ehir(ngs),eirw(ngs),eirir(ngs),ehr(ngs)
13097 real erip(ngs),esip(ngs),eglip(ngs),eghip(ngs)
13098 real efip(ngs),eipi(ngs),eipw(ngs),eipip(ngs)
13100 ! arrays for production terms
13102 real ptotal(ngs) ! , pqtot(ngs)
13104 real pqcwi(ngs),pqcii(ngs),pqrwi(ngs),pqisi(ngs)
13105 real pqswi(ngs),pqhwi(ngs),pqwvi(ngs)
13106 real pqgli(ngs),pqghi(ngs),pqfwi(ngs)
13107 real pqgmi(ngs),pqhli(ngs) ! ,pqhxi(ngs)
13108 real pqiri(ngs),pqipi(ngs) ! pqwai(ngs),
13109 real pqlwsi(ngs),pqlwhi(ngs),pqlwhli(ngs),pqlwfi(ngs)
13111 real pqlwlghi(ngs),pqlwlghli(ngs)
13112 real pqlwlghd(ngs),pqlwlghld(ngs)
13117 real pvhwi(ngs), pvhwd(ngs)
13118 real pvfwi(ngs), pvfwd(ngs)
13119 real pvhli(ngs), pvhld(ngs)
13120 real pvswi(ngs), pvswd(ngs)
13122 real pqcwd(ngs),pqcid(ngs),pqrwd(ngs),pqisd(ngs), pqcwdacc(ngs)
13123 real pqswd(ngs),pqhwd(ngs),pqwvd(ngs)
13124 real pqgld(ngs),pqghd(ngs),pqfwd(ngs)
13125 real pqgmd(ngs),pqhld(ngs) ! ,pqhxd(ngs)
13126 real pqird(ngs),pqipd(ngs) ! pqwad(ngs),
13127 real pqlwsd(ngs),pqlwhd(ngs),pqlwhld(ngs),pqlwfd(ngs)
13129 ! real pqxii(ngs,nhab),pqxid(ngs,nhab)
13132 real pcipi(ngs), pcipd(ngs)
13133 real pciri(ngs), pcird(ngs)
13134 real pccwi(ngs), pccwd(ngs), pccwdacc(ngs)
13135 real pccii(ngs), pccid(ngs)
13136 real pcisi(ngs), pcisd(ngs)
13138 real pcrwi(ngs), pcrwd(ngs)
13139 real pcswi(ngs), pcswd(ngs)
13140 real pchwi(ngs), pchwd(ngs)
13141 real pchli(ngs), pchld(ngs)
13142 real pcfwi(ngs), pcfwd(ngs)
13143 real pcgli(ngs), pcgld(ngs)
13144 real pcgmi(ngs), pcgmd(ngs)
13145 real pcghi(ngs), pcghd(ngs)
13147 real pzrwi(ngs), pzrwd(ngs)
13148 real pzhwi(ngs), pzhwd(ngs)
13149 real pzfwi(ngs), pzfwd(ngs)
13150 real pzhli(ngs), pzhld(ngs)
13151 real pzswi(ngs), pzswd(ngs)
13156 real dqisdt(ngs) !,advisc(ngs) !dqwsdt(ngs), ,schm(ngs),pndl(ngs)
13161 real pres(ngs),pipert(ngs)
13163 real rho0(ngs),pi0(ngs)
13164 real rhovt(ngs),sqrtrhovt
13165 real thetap(ngs),theta0(ngs),qwvp(ngs),qv0(ngs)
13167 real ptwfzi(ngs),ptimlw(ngs)
13168 real psub(ngs),pvap(ngs),pfrz(ngs),ptem(ngs),pmlt(ngs),pevap(ngs),pdep(ngs),ptem2(ngs)
13170 real cnostmp(ngs) ! for diagnosed snow intercept
13172 ! iholef = 1 to do hole filling technique version 1
13173 ! which uses all hydrometerors to do hole filling of all hydrometeors
13174 ! iholef = 2 to do hole filling technique version 2
13175 ! which uses an individual hydrometeror species to do hole
13176 ! filling of a species of a hydrometeor
13178 ! iholen = interval that hole filling is done
13182 parameter (iholef = 1)
13183 parameter (iholen = 1)
13184 real cqtotn,cqtotn1
13194 real cqtotp,cqtotp1
13219 real ssifac, qvapor
13221 ! Miscellaneous variables
13223 real, parameter :: cwmas30 = 1000.*0.523599*(2.*30.e-6)**3 ! mass of 30-micron radius droplet, for sat. adj.
13224 real, parameter :: cwmas20 = 1000.*0.523599*(2.*20.e-6)**3 ! mass of 20-micron radius droplet, for sat. adj.
13225 integer ireadqf,lrho,lqsw,lqgl,lqgm ,lqgh
13228 real arg ! gamma is a function
13229 real erbnd1, fdgt1, costhe1
13231 real dyi2,dzi2,bta1,cnit,dragh,dnz00,pii ! ,cp608
13232 real qccrit,gf4br,gf4ds,gf4p5, gf3ds, gf1ds
13233 real gf1palp(ngs) ! for storing Gamma[1.0 + alphar]
13237 real xdn_new,drhodt
13239 integer l ,ltemq,inumgs, idelq
13246 real cval,aval,eval,fval,gval ,qsign,ftelwc,qconkq,elecfac,altelecfac
13247 real qconm,qconn,cfce15,gf8,gf4i,gf3p5,gf1a,gf1p5,qdiff,argrcnw
13248 real c4,bradp,bl2,bt2,dthr,hrifac, hdia0,hdia1,civenta,civentb
13249 real civentc,civentd,civente,civentf,civentg,cireyn,xcivent
13250 real cipventa,cipventb,cipventc,cipventd,cipreyn,cirventa
13252 integer igmrwa,igmrwb,igmswa, igmswb,igmfwa,igmfwb,igmhwa,igmhwb
13253 real rwventa ,rwventb,swventa,swventb,fwventa,fwventb,fwventc
13254 real hwventa,hwventb
13255 real hwventc, hlventa, hlventb, hlventc
13256 real glventa, glventb, glventc
13257 real gmventa, gmventb, gmventc, ghventa, ghventb, ghventc
13258 real dzfacp, dzfacm, cmassin, cwdiar
13259 real rimmas, rhobar
13260 real argtim, argqcw, argqxw, argtem
13261 real frcswsw, frcswgl, frcswgm, frcswgh, frcswfw, frcswsw1
13262 real frcglgl, frcglgm, frcglgh, frcglfw, frcglgl1
13263 real frcgmgl, frcgmgm, frcgmgh, frcgmfw, frcgmgm1
13264 real frcghgl, frcghgm, frcghgh, frcghfw, frcghgh1
13265 real frcfwgl, frcfwgm, frcfwgh, frcfwfw, frcfwfw1
13266 real frcswrsw, frcswrgl, frcswrgm, frcswrgh, frcswrfw
13268 real frcrswsw, frcrswgl, frcrswgm, frcrswgh, frcrswfw
13270 real frcglrgl, frcglrgm, frcglrgh, frcglrfw, frcglrgl1
13272 real frcrglgm, frcrglgh, frcrglfw, frcrglgl1
13273 real frcgmrgl, frcgmrgm, frcgmrgh, frcgmrfw, frcgmrgm1
13274 real frcrgmgl, frcrgmgm, frcrgmgh, frcrgmfw, frcrgmgm1
13275 real total, qweps, gf2a, gf4a, dqldt, dqidt, dqdt
13276 real frcghrgl, frcghrgm, frcghrgh, frcghrfw, frcghrgh1, frcrghgl
13277 real frcrghgm, frcrghgh, frcrghfw, frcrghgh1
13278 real a1,a2,a3,a4,a5,a6
13280 real cdw, cdi, denom1, denom2, delqci1, delqip1
13281 real cirtotn, ciptotn, cgmtotn, chltotn, cirtotp
13282 real cgmfac, chlfac, cirfac
13283 integer igmhla, igmhlb, igmgla, igmglb, igmgma, igmgmb
13284 integer igmgha, igmghb
13285 integer idqis, item, itim0
13286 integer iqgl, iqgm, iqgh, iqrw, iqsw
13293 integer cntnic_noliq
13294 real q_noliqmn, q_noliqmx
13295 real scsacimn, scsacimx
13299 ! arrays for temporary bin space
13301 real :: xden,xmlt,cmlt,cmlttot,fventm,fventh,am,ah,felfinv,dmwdt
13303 real :: qhmlrtmp,qhmlrtmp2, chmlrtmp, chmlrtmpd1inf, chlmlrtmp, zhlmlrtmp, zhlmlrrtmp, qvs0,tmpcmlt
13305 real :: term1,term2,term3,term4
13306 real :: qaacw ! combined qsacw-qhacw for WSM6 variation
13309 real, parameter :: c1r=19.0, c2r=0.6, c3r=1.8, c4r=17.0 ! rain
13310 real, parameter :: c1h=5.5, c2h=0.7, c3h=4.5, c4h=8.5 ! Graupel
13311 real, parameter :: c1hl=3.7, c2hl=0.3, c3hl=9.0, c4hl=6.5, c5hl=1.0, c6hl=6.5 ! Hail
13314 ! inline functions for Newton method
13315 real :: galpha, dgalpha
13317 logical, parameter :: newton = .false.
13320 galpha(a_in) = ((4. + a_in)*(5. + a_in)*(6. + a_in))/((1. + a_in)*(2. + a_in)*(3. + a_in))
13321 dgalpha(a_in) = (876. + 1260.*a_in + 621.*a_in**2 + 126.*a_in**3 + 9.*a_in**4)/ &
13322 & (36. + 132.*a_in + 193.*a_in**2 + 144.*a_in**3 + 58.*a_in**4 + 12.*a_in**5 + a_in**6)
13324 ! ####################################################################
13328 ! ####################################################################
13352 lrescalelow(:) = rescale_low_alpha
13353 lrescalelow(lr) = rescale_low_alphar .and. rescale_low_alpha
13354 lrescalelow(lh) = rescale_low_alphah .and. rescale_low_alpha
13355 IF ( lf > 1 ) lrescalelow(lf) = rescale_low_alphah .and. rescale_low_alpha
13356 IF ( lhl > 1 ) lrescalelow(lhl) = rescale_low_alphahl .and. rescale_low_alpha
13363 IF ( ngs .lt. nz ) THEN
13364 ! write(0,*) 'Error in ICEZVD: Must have ngs .ge. nz!'
13377 ldovol = ldovol .or. ( lvol(il) .gt. 1 )
13383 ! write(iunit,*) 'delqnxa(',il,') = ',delqnxa(il)
13387 ! density maximums and minimums
13391 ! Set terminal velocities...
13392 ! also set drag coefficients
13400 ! electricity constants
13402 ! mixing ratio epsilon
13406 ! rebound efficiency (erbnd)
13415 bradcw = 0.26249e+06
13416 cradcw = -1.8896e+10
13417 dradcw = 4.4626e+14
13424 ! new values for cs and ds
13427 pii = piinv ! 1./pi
13430 gf1 = 1.0 ! gamma(1.0)
13431 gf1p5 = 0.8862269255 ! gamma(1.5)
13432 gf2 = 1.0 ! gamma(2.0)
13433 gf3 = 2.0 ! gamma(3.0)
13434 gf3p5 = 3.32335097 ! gamma(3.5)
13435 gf4 = 6.00 ! gamma(4.0)
13436 gf5 = 24.0 ! gamma(5.0)
13437 gf6 = 120.0 ! gamma(6.0)
13438 gf7 = 720.0 ! gamma(7.0)
13439 gf4br = 17.837861981813607 ! gamma(4.0+br)
13440 gf4ds = 10.41688578110938 ! gamma(4.0+ds)
13441 gf4p5 = 11.63172839656745 ! gamma(4.0+0.5)
13442 gf3ds = 3.0458730354120997 ! gamma(3.0+ds)
13443 gf1ds = 0.8863557896089221 ! gamma(1.0+ds)
13445 gf43rds = 0.8929795116 ! gamma(4./3.)
13446 gf53rds = 0.9027452930 ! gamma(5./3.)
13447 gf73rds = 1.190639349 ! gamma(7./3.)
13448 gf83rds = 1.504575488 ! gamma(8./3.)
13450 gamice73fac = (Gamma_sp(7./3. + cinu))**3/ (Gamma_sp(1. + cinu)**3 * (1. + cinu)**4)
13451 gamsnow73fac = (Gamma_sp(7./3. + snu))**3/ (Gamma_sp(1. + snu)**3 * (1. + snu)**4)
13453 ! gcnup1 = Gamma_sp(cnu + 1.)
13454 ! gcnup2 = Gamma_sp(cnu + 2.)
13459 ! general constants for microphysics
13464 bfnu1 = (4. + alphar)*(5. + alphar)*(6. + alphar)/ &
13465 & ((1. + alphar)*(2. + alphar)*(3. + alphar))
13467 galpharaut = (6.+alpharaut)*(5.+alpharaut)*(4.+alpharaut)/ &
13468 & ((3.+alpharaut)*(2.+alpharaut)*(1.+alpharaut))
13470 vfrz = 0.523599*(dfrz)**3
13471 vmlt = Min(xvmx(lr), 0.523599*(dmlt)**3 )
13472 vshd = Min(xvmx(lr), 0.523599*(dshd)**3 )
13474 IF ( snowmeltdia > 0.0 ) THEN
13475 snowmeltmass = pi/6.0 * 1000. * snowmeltdia**3 ! maximum rain particle mass from melting snow (if snowmeltdia > 0)
13482 IF ( mixedphase ) THEN
13489 ! print*,'ventr,ventc = ',ventr,ventc
13492 ! Set up look up tables for supersaturation w.r.t. liq and ice
13496 ! temq = 163.15 + (l-1)*fqsat
13497 ! tabqvs(l) = exp(caw*(temq-273.15)/(temq-cbw))
13498 ! tabqis(l) = exp(cai*(temq-273.15)/(temq-cbi))
13501 mltmass0inv = 1.0/( 1000.0* xvmx(lr) ) ! for drops melting from ice with diameter > 1.9cm
13502 mltmass1inv = 1.0/( 1000.0*(4.0*pi/3.0)*((0.01*0.5*takshedsize1)**3) ) ! for drops melting from ice with diameter > 1.9cm; 0.01 converts cm to m, 0.5 conv. diam to radius
13503 mltmass2inv = 1.0/( 1000.0*(4.0*pi/3.0)*((0.01*0.5*takshedsize2)**3) ) ! for drops melting from ice with 0.9cm < d < 1.9cm (or 1.6cm to 1.9cm)
13504 mltmass3inv = 1.0/( 1000.0*(4.0*pi/3.0)*((0.01*0.5*takshedsize3)**3) ) ! for drops melting from ice with 0.9cm < d < 1.6cm
13505 mltmass1cgs = 1.0*(4.0*pi/3.0)*((0.5*takshedsize1)**3)
13506 mltmass2cgs = 1.0*(4.0*pi/3.0)*((0.5*takshedsize2)**3)
13507 mltmass3cgs = 1.0*(4.0*pi/3.0)*((0.5*takshedsize3)**3)
13509 ! real, parameter :: mltdiam1 = 9.0e-3, mltdiam2 = 19.0e-3, mltdiam05 = 4.5e-3
13511 IF ( ibinnum == 1 ) THEN
13512 numdiam = 1 ! must have numdiam < ndiam because numdiam+1 holds values for the interval of mltdiam(numdiam) to mltdiam(ndiam+1)
13513 mltdiam(1) = 4.5e-3
13514 ELSEIF ( ibinnum == 2 ) THEN
13515 numdiam = 2 ! must have numdiam < ndiam because numdiam+1 holds values for the interval of mltdiam(numdiam) to mltdiam(ndiam+1)
13516 mltdiam(1) = mltdiam1/6. ! 1.5e-3
13517 mltdiam(2) = mltdiam1/2. ! 4.5e-3
13518 ELSEIF ( ibinnum > 2 ) THEN
13519 numdiam = Min(ibinnum, ndiam)
13521 mltdiam(k) = (k - 0.5)*mltdiam1/float(numdiam)
13525 numdiam = 5 ! must have numdiam < ndiam because numdiam+1 holds values for the interval of mltdiam(numdiam) to mltdiam(ndiam+1)
13526 mltdiam(1) = 0.5e-3
13527 mltdiam(2) = 1.0e-3
13528 mltdiam(3) = 2.0e-3
13529 mltdiam(4) = 4.0e-3
13530 mltdiam(5) = 6.0e-3
13534 IF ( numshedregimes == 2 ) THEN
13535 mltdiam(ndiam+1) = mltdiam1 ! 9.0e-3
13536 mltdiam(ndiam+2) = mltdiam3 ! 19.0e-3
13537 mltdiam(ndiam+3) = mltdiam4 !100.0e-3
13538 ELSEIF ( numshedregimes == 3 ) THEN
13539 mltdiam(ndiam+1) = mltdiam1 ! 9.0e-3
13540 mltdiam(ndiam+2) = mltdiam2 ! 16.0e-3
13541 mltdiam(ndiam+3) = mltdiam3 ! 19.0e-3
13542 mltdiam(ndiam+4) = mltdiam4 !200.0e-3
13547 ! if (kzend .eq. nzend) kze = kzend-kzbeg+1-kstag
13550 ! cw constants in mks units
13552 ! cwmasn = 4.25e-15 ! radius of 1.0e-6
13553 mwfac = 6.0**(1./3.)
13554 IF ( ipconc .ge. 2 ) THEN
13555 ! cwmasn = xvmn(lc)*1000.
13557 ! cwmasx = xvmx(lc)*1000.
13559 rwmasn = xvmn(lr)*1000.
13560 rwmasx = xvmx(lr)*1000.
13562 IF ( biggsnowdiam > 0.0 ) THEN
13563 xvbiggsnow = (pi/6.0)*biggsnowdiam**3
13565 xvbiggsnow = xvmn(lh)
13569 ! ci constants in mks units
13571 cimasn = Min(cimas0, cimas1) ! 12 microns for 0.1871*(xmas(mgs,li)**(0.3429))
13572 cimasx = 1.0e-8 ! 338 microns
13573 ccimx = 5000.0e3 ! max of 5000 per liter
13576 ! constants for paramerization
13579 ! set save counter (number of saves): nsvcnt
13585 ! timetd1 = etime(tarray)
13586 ! timetd1 = tarray(1)
13589 !***********************************************************
13591 !***********************************************************
13594 ! do 9999 jy = 1,ny-jstag
13596 ! VERY IMPORTANT: SET jy = jgs
13609 IF ( ipconc < 2 ) THEN ! Make a copy of cloud droplet mixing ratio to use for homogeneous freezing
13612 t9(ix,jy,kz) = an(ix,jy,kz,lc)
13618 !..Gather microphysics
13620 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: ENTER GATHER STAGE'
13627 numgs = nxz/ngs + 1
13628 ! write(0,*) 'ICEZVD_GS: ENTER GATHER STAGE: nx,nz,nxz,numgs,ngs = ',nx,nz,nxz,numgs,ngs
13630 do 1000 inumgs = 1,numgs
13634 do ix = nxmpb,itile
13636 pqs(1) = t00(ix,jy,kz)
13638 theta(1) = an(ix,jy,kz,lt)
13639 temg(1) = t0(ix,jy,kz)
13640 temcg(1) = temg(1) - tfr
13641 tqvcon = temg(1)-cbw
13642 ltemq = (temg(1)-163.15)/fqsat + 1.5
13643 ltemq = Min( nqsat, Max(1,ltemq) )
13644 qvs(1) = pqs(1)*tabqvs(ltemq)
13645 IF ( iqis0 == 1 .or. temg(1) <= tfr+0.5 ) THEN
13646 qis(1) = pqs(1)*tabqis(ltemq)
13648 ltemq = (tfr - 163.15)/fqsat + 1.5
13649 qis(1) = pqs(1)*tabqis(ltemq)
13654 if ( temg(1) .lt. tfr ) then
13659 IF ( lhl > 1 ) THEN
13660 IF ( an(ix,jy,kz,lhl) .gt. qxmin(lhl) ) ishail = .true.
13665 if ( an(ix,jy,kz,lv) .gt. qss(1) .or. &
13666 & an(ix,jy,kz,lc) .gt. qxmin(lc) .or. &
13667 & an(ix,jy,kz,li) .gt. qxmin(li) .or. &
13668 & an(ix,jy,kz,lr) .gt. qxmin(lr) .or. &
13669 & an(ix,jy,kz,ls) .gt. qxmin(ls) .or. &
13670 & an(ix,jy,kz,lh) .gt. qxmin(lh) .or. ishail ) then
13671 ngscnt = ngscnt + 1
13674 if ( ngscnt .eq. ngs ) goto 1100
13681 if ( ngscnt .eq. 0 ) go to 9998
13683 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: dbg = 5, ngscnt = ',ngscnt
13685 ! write(0,*) 'allocating qc'
13690 vtxbar(:,:,:) = 0.0
13694 IF ( lnhf > 1 .or. lnhlf > 1 ) chxf(:,:) = 0.0
13698 rimdn(mgs,il) = rimedens ! xdn0(il)
13702 ! define temporaries for state variables to be used in calculations
13704 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: dbg = def temps'
13706 kgsm(mgs) = max(kgs(mgs)-1,1)
13707 kgsp(mgs) = min(kgs(mgs)+1,nz-1)
13708 kgsm2(mgs) = Max(kgs(mgs)-2,1)
13709 theta0(mgs) = an(igs(mgs),jy,kgs(mgs),lt)
13710 thetap(mgs) = an(igs(mgs),jy,kgs(mgs),lt) - theta0(mgs)
13711 theta(mgs) = an(igs(mgs),jy,kgs(mgs),lt)
13712 qv0(mgs) = an(igs(mgs),jy,kgs(mgs),lv)
13713 qwvp(mgs) = an(igs(mgs),jy,kgs(mgs),lv) - qv0(mgs) ! qv0(mgs) is full qv, so qwvp starts as zero!
13715 pres(mgs) = pn(igs(mgs),jy,kgs(mgs)) + pb(kgs(mgs))
13716 pipert(mgs) = p2(igs(mgs),jy,kgs(mgs))
13717 rho0(mgs) = dn(igs(mgs),jy,kgs(mgs))
13718 rhoinv(mgs) = 1.0/rho0(mgs)
13719 rhovt(mgs) = Sqrt(rho00/Max(0.05,rho0(mgs))) ! prevent excessive rhovt
13720 pi0(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs))
13721 temg(mgs) = t0(igs(mgs),jy,kgs(mgs))
13722 temgkm1(mgs) = t0(igs(mgs),jy,kgsm(mgs))
13723 temgkm2(mgs) = t0(igs(mgs),jy,kgsm2(mgs))
13724 pk(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs)) ! t77(igs(mgs),jy,kgs(mgs))
13725 temcg(mgs) = temg(mgs) - tfr
13726 qss0(mgs) = (380.0)/(pres(mgs))
13727 pqs(mgs) = (380.0)/(pres(mgs))
13728 ltemq = (temg(mgs)-163.15)/fqsat+1.5
13729 ltemq = Min( nqsat, Max(1,ltemq) )
13730 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
13731 IF ( iqis0 == 1 .or. temg(mgs) <= tfr+0.5 ) THEN
13732 qis(mgs) = pqs(mgs)*tabqis(ltemq)
13734 ltemq = (tfr - 163.15)/fqsat + 1.5
13735 qis(mgs) = pqs(mgs)*tabqis(ltemq)
13737 qss(mgs) = qvs(mgs)
13738 ! es(mgs) = 6.1078e2*tabqvs(ltemq)
13739 ! eis(mgs) = 6.1078e2*tabqis(ltemq)
13740 cnostmp(mgs) = cno(ls)
13744 if ( temg(mgs) .lt. tfr ) then
13749 IF ( ipconc < 1 .and. lwsm6 ) THEN
13751 tmp = Min( 0.0, temcg(mgs) )
13752 cnostmp(mgs) = Min( 2.e8, 2.e6*exp(0.12*tmp) )
13758 ! zero arrays that are used but not otherwise set (tm)
13764 ! set temporaries for microphysics variables
13768 qx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),il), 0.0)
13779 ! set concentrations
13784 if ( ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) 'ICEZVD_GS: dbg = 5b'
13786 if ( ipconc .ge. 1 ) then
13788 cx(mgs,li) = Max(an(igs(mgs),jy,kgs(mgs),lni), 0.0)
13789 IF ( qx(mgs,li) .le. qxmin(li) ) THEN
13793 IF ( lcina .gt. 1 ) THEN
13794 cina(mgs) = an(igs(mgs),jy,kgs(mgs),lcina)
13796 cina(mgs) = cx(mgs,li)
13798 IF ( lcin > 1 ) THEN
13799 ccin(mgs) = an(igs(mgs),jy,kgs(mgs),lcin)
13803 if ( ipconc .ge. 2 ) then
13805 cx(mgs,lc) = Max(an(igs(mgs),jy,kgs(mgs),lnc), 0.0)
13806 ! cx(mgs,lc) = Min( ccwmx, cx(mgs,lc) )
13807 IF ( qx(mgs,lc) .le. qxmin(lc) ) THEN
13810 IF ( lss > 1 ) THEN
13811 ssmax(mgs) = an(igs(mgs),jy,kgs(mgs),lss)
13813 IF ( lccn .gt. 1 ) THEN
13814 ccnc(mgs) = an(igs(mgs),jy,kgs(mgs),lccn)
13818 IF ( lccna .gt. 1 ) THEN
13819 ccna(mgs) = an(igs(mgs),jy,kgs(mgs),lccna)
13821 ccna(mgs) = cx(mgs,lc)
13825 ! cx(mgs,lc) = Abs(ccn)
13827 if ( ipconc .ge. 3 ) then
13829 cx(mgs,lr) = Max(an(igs(mgs),jy,kgs(mgs),lnr), 0.0)
13830 IF ( qx(mgs,lr) .le. qxmin(lr) ) THEN
13832 ELSEIF ( cx(mgs,lr) .eq. 0.0 .and. qx(mgs,lr) .lt. 3.0*qxmin(lr) ) THEN
13833 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,lr)
13836 cx(mgs,lr) = Max( 1.e-9, cx(mgs,lr) )
13840 if ( ipconc .ge. 4 ) then
13842 cx(mgs,ls) = Max(an(igs(mgs),jy,kgs(mgs),lns), 0.0)
13843 IF ( qx(mgs,ls) .le. qxmin(ls) ) THEN
13845 ELSEIF ( cx(mgs,ls) .eq. 0.0 .and. qx(mgs,ls) .lt. 3.0*qxmin(ls) ) THEN
13846 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,ls)
13849 cx(mgs,ls) = Max( 1.e-9, cx(mgs,ls) )
13851 IF ( ilimit .ge. ipc(ls) ) THEN
13852 tmp = (xdn0(ls)*cx(mgs,ls))/(rho0(mgs)*qx(mgs,ls))
13853 tmp2 = (tmp*(3.14159))**(1./3.)
13854 cnox = cx(mgs,ls)*(tmp2)
13855 IF ( cnox .gt. 3.0*cno(ls) ) THEN
13856 cx(mgs,ls) = 3.0*cno(ls)/tmp2
13862 if ( ipconc .ge. 5 ) then
13865 cx(mgs,lh) = Max(an(igs(mgs),jy,kgs(mgs),lnh), 0.0)
13866 IF ( qx(mgs,lh) .le. qxmin(lh) ) THEN
13868 ELSEIF ( cx(mgs,lh) .eq. 0.0 .and. qx(mgs,lh) .lt. 3.0*qxmin(lh) ) THEN
13869 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,lh)
13872 cx(mgs,lh) = Max( 1.e-9, cx(mgs,lh) )
13873 IF ( ilimit .ge. ipc(lh) ) THEN
13874 tmp = (xdn0(lh)*cx(mgs,lh))/(rho0(mgs)*qx(mgs,lh))
13875 tmp2 = (tmp*(3.14159))**(1./3.)
13876 cnox = cx(mgs,lh)*(tmp2)
13877 IF ( cnox .gt. 3.0*cno(lh) ) THEN
13878 cx(mgs,lh) = 3.0*cno(lh)/tmp2
13889 if ( lhl .gt. 1 .and. ipconc .ge. 5 ) then
13892 cx(mgs,lhl) = Max(an(igs(mgs),jy,kgs(mgs),lnhl), 0.0)
13893 IF ( qx(mgs,lhl) .le. qxmin(lhl) ) THEN
13895 ELSEIF ( cx(mgs,lhl) .eq. 0.0 .and. qx(mgs,lhl) .lt. 3.0*qxmin(lhl) ) THEN
13896 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,lhl)
13899 cx(mgs,lhl) = Max( 1.e-9, cx(mgs,lhl) )
13900 IF ( ilimit .ge. ipc(lhl) ) THEN
13901 tmp = (xdn0(lhl)*cx(mgs,lhl))/(rho0(mgs)*qx(mgs,lhl))
13902 tmp2 = (tmp*(3.14159))**(1./3.)
13903 cnox = cx(mgs,lhl)*(tmp2)
13904 IF ( cnox .gt. 3.0*cno(lhl) ) THEN
13905 cx(mgs,lhl) = 3.0*cno(lhl)/tmp2
13915 ! Set mean particle volume
13923 IF ( lvol(il) .ge. 1 ) THEN
13926 vx(mgs,il) = Max(an(igs(mgs),jy,kgs(mgs),lvol(il)), 0.0)
13937 ! Set liquid water fraction
13949 IF ( ipconc .ge. 6 ) THEN
13952 IF ( lz(il) .gt. 1 ) THEN
13954 zx(mgs,il) = Max( an(igs(mgs),jy,kgs(mgs),lz(il)), 0.0 )
13961 IF ( ipconc .ge. 6 ) THEN
13963 IF ( lz(lr) .lt. 1 ) THEN
13964 g1x(:,lr) = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/ &
13965 & ((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
13969 IF ( cx(mgs,lr) .gt. 0.0 .and. qx(mgs,lr) .gt. qxmin(lr) ) THEN
13971 vr = rho0(mgs)*qx(mgs,lr)/(1000.*cx(mgs,lr))
13972 IF ( lzr < 1 ) THEN
13973 IF ( imurain == 3 ) THEN
13974 zx(mgs,lr) = 3.6476*(rnu+2.0)*cx(mgs,lr)*vr**2/(rnu+1.0)
13975 ELSE ! imurain == 1
13976 zx(mgs,lr) = 3.6476*g1x(mgs,lr)*cx(mgs,lr)*vr**2
13989 ! set shape parameters
13991 if ( ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'ICEZVD_GS: dbg = set alpha'
13992 IF ( imurain == 1 ) THEN
13993 alpha(:,lr) = alphar
13994 ELSEIF ( imurain == 3 ) THEN
13995 alpha(:,lr) = xnu(lr)
13998 alpha(:,li) = xnu(li)
13999 alpha(:,lc) = xnu(lc)
14001 IF ( imusnow == 1 ) THEN
14002 alpha(:,ls) = alphas
14003 ELSEIF ( imusnow == 3 ) THEN
14004 alpha(:,ls) = xnu(ls)
14007 if ( ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'ICEZVD_GS: dbg = set dab'
14011 IF ( il .ge. lg ) alpha(mgs,il) = dnu(il)
14015 dab0lh(mgs,il,ic) = dab0(il,ic) ! dab0(ic,il)
14016 dab1lh(mgs,il,ic) = dab1(il,ic) ! dab1(ic,il)
14022 ! DO mgs = 1,ngscnt
14024 da0lx(:,il) = da0(il)
14032 if ( ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'ICEZVD_GS: dbg = set rz'
14034 IF ( lzh < 1 .or. lzhl < 1 ) THEN
14035 rzxhlh(:) = rzhl/rz
14036 ELSEIF ( lzh > 1 .and. lzhl > 1 ) THEN
14039 IF ( lzr > 1 ) THEN
14047 IF ( imurain == 1 .and. imusnow == 3 .and. lzr < 1 ) THEN
14049 ELSEIF ( imurain == imusnow .or. lzr > 1 ) THEN
14054 IF ( lhl .gt. 1 ) THEN
14056 da0lhl(mgs) = da0(lhl)
14061 ventrxn(:) = ventrn
14062 gf1palp(:) = gamma_sp(1.0 + alphar)
14069 ssi(mgs) = qx(mgs,lv)/qis(mgs)
14070 ssw(mgs) = qx(mgs,lv)/qvs(mgs)
14072 tsqr(mgs) = temg(mgs)**2
14074 temgx(mgs) = min(temg(mgs),313.15)
14075 temgx(mgs) = max(temgx(mgs),233.15)
14076 felv(mgs) = 2500837.367 * (273.15/temgx(mgs))**((0.167)+(3.67e-4)*temgx(mgs))
14078 temcgx(mgs) = min(temg(mgs),273.15)
14079 temcgx(mgs) = max(temcgx(mgs),223.15)
14080 temcgx(mgs) = temcgx(mgs)-273.15
14082 ! felf = latent heat of fusion, fels = LH of sublimation, felv = LH of vaporization
14083 felf(mgs) = 333690.6098 + (2030.61425)*temcgx(mgs) - (10.46708312)*temcgx(mgs)**2
14085 fels(mgs) = felv(mgs) + felf(mgs)
14087 felvs(mgs) = felv(mgs)*felv(mgs)
14088 felss(mgs) = fels(mgs)*fels(mgs)
14090 IF ( eqtset <= 1 ) THEN
14091 felvcp(mgs) = felv(mgs)*cpi
14092 felscp(mgs) = fels(mgs)*cpi
14093 felfcp(mgs) = felf(mgs)*cpi
14096 ! equations from appendix in Bryan and Morrison (2012, MWR)
14097 ! note that rw is Rv in the paper, and rd is R.
14099 tmp = qx(mgs,li)+qx(mgs,ls)+qx(mgs,lh)
14100 IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
14101 IF ( lf > 1 ) tmp = tmp + qx(mgs,lf)
14102 cvm = cv+cvv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
14105 IF ( eqtset == 2 ) THEN ! compact form from treating dT/dt = theta*d(pi)/dt + pi*d(theta)dt and then applied to theta assuming constant pi
14106 felvcp(mgs) = (felv(mgs)-rw*temg(mgs))/cvm
14107 felscp(mgs) = (fels(mgs)-rw*temg(mgs))/cvm
14108 felfcp(mgs) = felf(mgs)/cvm
14111 ! equivalent version that applies separate updates of latent heating to theta and pi, when both are returned.
14113 cpm = cp+cpv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
14115 rmm=rd+rw*qx(mgs,lv)
14117 felvcp(mgs) = (felv(mgs)*cv/(cp) - rw*temg(mgs)*(1.0-rovcp*cpm/rmm))/cvm
14118 felscp(mgs) = (fels(mgs)*cv/(cp) - rw*temg(mgs)*(1.0-rovcp*cpm/rmm))/cvm
14119 felfcp(mgs) = felf(mgs)*cv/(cp*cvm)
14121 felvpi(mgs) = pi0(mgs)*rovcp*(felv(mgs)/(temg(mgs)) - rw*cpm/rmm)/cvm
14122 felspi(mgs) = pi0(mgs)*rovcp*(fels(mgs)/(temg(mgs)) - rw*cpm/rmm)/cvm
14123 felfpi(mgs) = pi0(mgs)*rovcp*(felf(mgs)/(cvm*temg(mgs)))
14129 fgamw(mgs) = felvcp(mgs)/pi0(mgs)
14130 fgams(mgs) = felscp(mgs)/pi0(mgs)
14132 fcqv1(mgs) = 4098.0258*pi0(mgs)*fgamw(mgs)
14133 fcqv2(mgs) = 5807.6953*pi0(mgs)*fgams(mgs)
14134 fcc3(mgs) = felfcp(mgs)/pi0(mgs)
14136 ! fwvdf = water vapor diffusivity
14137 fwvdf(mgs) = (2.11e-05)*((temg(mgs)/tfr)**1.94)*(101325.0/(pres(mgs)))
14139 ! fadvisc = 'd' for dynamic viscosity
14140 ! fakvisc = 'k' for kinematic viscosity
14141 fadvisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))*(temg(mgs)/296.0)**(1.5) ! dynamic visc.
14143 fakvisc(mgs) = fadvisc(mgs)*rhoinv(mgs) ! divide by rho_air to get kinematic visc. (note the 'k' vs. 'd')
14145 temcgx(mgs) = min(temg(mgs),273.15)
14146 temcgx(mgs) = max(temcgx(mgs),233.15)
14147 temcgx(mgs) = temcgx(mgs)-273.15
14148 fci(mgs) = (2.118636 + 0.007371*(temcgx(mgs)))*(1.0e+03)
14150 if ( temg(mgs) .lt. 273.15 ) then
14151 temcgx(mgs) = min(temg(mgs),273.15)
14152 temcgx(mgs) = max(temcgx(mgs),233.15)
14153 temcgx(mgs) = temcgx(mgs)-273.15
14154 fcw(mgs) = 4203.1548 + (1.30572e-2)*((temcgx(mgs)-35.)**2) &
14155 & + (1.60056e-5)*((temcgx(mgs)-35.)**4)
14157 if ( temg(mgs) .ge. 273.15 ) then
14158 temcgx(mgs) = min(temg(mgs),308.15)
14159 temcgx(mgs) = max(temcgx(mgs),273.15)
14160 temcgx(mgs) = temcgx(mgs)-273.15
14161 fcw(mgs) = 4243.1688 + (3.47104e-1)*(temcgx(mgs)**2)
14164 ftka(mgs) = tka0*fadvisc(mgs)/advisc1 ! thermal conductivity: proportional to dynamic viscosity
14165 fthdf(mgs) = ftka(mgs)*cpi*rhoinv(mgs)
14167 fschm(mgs) = (fakvisc(mgs)/fwvdf(mgs)) ! Schmidt number
14168 fpndl(mgs) = (fakvisc(mgs)/fthdf(mgs)) ! Prandl number (only used for bin melting)
14170 fai(mgs) = (fels(mgs)**2)/(ftka(mgs)*rw*temg(mgs)**2)
14171 fbi(mgs) = (1.0/(rho0(mgs)*fwvdf(mgs)*qis(mgs)))
14172 fav(mgs) = (felv(mgs)**2)/(ftka(mgs)*rw*temg(mgs)**2)
14173 fbv(mgs) = (1.0/(rho0(mgs)*fwvdf(mgs)*qvs(mgs)))
14175 kp1 = Min(nz, kgs(mgs)+1 )
14176 wvel(mgs) = (0.5)*(w(igs(mgs),jgs,kp1) &
14177 & +w(igs(mgs),jgs,kgs(mgs)))
14183 ! ice habit fractions
14189 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: Set density'
14193 xdn(mgs,li) = xdn0(li)
14194 xdn(mgs,lc) = xdn0(lc)
14195 xdn(mgs,lr) = xdn0(lr)
14196 xdn(mgs,ls) = xdn0(ls)
14197 xdn(mgs,lh) = xdn0(lh)
14198 IF ( lvol(ls) .gt. 1 ) THEN
14199 IF ( vx(mgs,ls) .gt. 0.0 .and. qx(mgs,ls) .gt. qxmin(ls) ) THEN
14200 xdn(mgs,ls) = Min( xdnmx(ls), Max( xdnmn(ls), rho0(mgs)*qx(mgs,ls)/vx(mgs,ls) ) )
14204 IF ( lvol(lh) .gt. 1 ) THEN
14205 IF ( vx(mgs,lh) .gt. 0.0 .and. qx(mgs,lh) .gt. qxmin(lh) ) THEN
14206 IF ( mixedphase ) THEN
14210 xdn(mgs,lh) = Min( dnmx, Max( xdnmn(lh), rho0(mgs)*qx(mgs,lh)/vx(mgs,lh) ) )
14211 vx(mgs,lh) = rho0(mgs)*qx(mgs,lh)/xdn(mgs,lh)
14213 ELSEIF ( vx(mgs,lh) == 0.0 .and. qx(mgs,lh) .gt. qxmin(lh) ) THEN ! if volume is zero, need to initialize the default value
14215 vx(mgs,lh) = rho0(mgs)*qx(mgs,lh)/xdn(mgs,lh)
14221 IF ( lhl .gt. 1 ) THEN
14223 xdn(mgs,lhl) = xdn0(lhl)
14224 xdntmp(mgs,lhl) = xdn0(lhl)
14226 IF ( lvol(lhl) .gt. 1 ) THEN
14227 IF ( vx(mgs,lhl) .gt. 0.0 .and. qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
14229 IF ( mixedphase .and. lhlw > 1 ) THEN
14234 xdn(mgs,lhl) = Min( dnmx, Max( xdnmn(lhl), rho0(mgs)*qx(mgs,lhl)/vx(mgs,lhl) ) )
14235 vx(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/xdn(mgs,lhl)
14236 xdntmp(mgs,lhl) = xdn(mgs,lhl)
14238 ELSEIF ( vx(mgs,lhl) == 0.0 .and. qx(mgs,lhl) .gt. qxmin(lhl) ) THEN ! if volume is zero, need to initialize the default value
14240 vx(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/xdn(mgs,lhl)
14250 IF ( ipconc == 5 .and. imydiagalpha == 2 ) THEN
14252 cwchtmp = ((3. + dnu(lh))*(2. + dnu(lh))*(1.0 + dnu(lh)))**(-1./3.)
14255 !IF ( igs(mgs) == 19 ) write(0,*) 'k,qr,qh,cr,ch = ',kgs(mgs),qx(mgs,lr),cx(mgs,lr),qx(mgs,lh),cx(mgs,lh)
14256 IF ( qx(mgs,lr) .gt. qxmin(lr) .and. cx(mgs,lr) > cxmin ) THEN
14257 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr)) !
14258 xdia(mgs,lr,3) = (xv(mgs,lr)*6.0*cwc1)**(1./3.)
14259 ! alpha(mgs,lr) = Min(alphamax, c1r*tanh(c2r*(xdia(mgs,lr,3)*1000. - c3r)) + c4r)
14260 ! IF ( igs(mgs) == 19 ) write(0,*) 'imy: i,k,alpr,xdia = ',igs(mgs),kgs(mgs),alpha(mgs,lr),xdia(mgs,lr,3)*1000.
14264 i = Int(dgami*(tmp))
14266 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14269 i = Int(dgami*(tmp))
14271 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14273 tmp = (x/y)**(1./3.)*xdia(mgs,lr,3)*cwchtmp
14275 alpha(mgs,lr) = Min(15., 11.8*(1000.*tmp - 0.7)**2 + 2.)
14277 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. cx(mgs,lh) > cxmin ) THEN
14279 xv(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) !
14280 xdia(mgs,lh,3) = (xv(mgs,lh)*6.*piinv)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
14281 ! alpha(mgs,lh) = Min(alphamax, c1h*tanh(c2h*(xdia(mgs,lh,3)*1000. - c3h)) + c4h)
14285 i = Int(dgami*(tmp))
14287 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14290 i = Int(dgami*(tmp))
14292 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14294 tmp = (x/y)**(1./3.)*xdia(mgs,lh,3)*cwchtmp
14296 alpha(mgs,lh) = Min(15., 11.8*(1000.*tmp - 0.7)**2 + 2.)
14297 ! alphan(mgs,lh) = alpha(mgs,lh)
14299 ! IF ( igs(mgs) == 19 ) write(0,*) 'imy: i,k,alph,xdia = ',igs(mgs),kgs(mgs),alpha(mgs,lh),xdia(mgs,lh,3)*1000.
14301 DO ic = lc,lh-1 ! lhab
14302 i = Nint( alpha(mgs,il)*dqiacralphainv )
14303 IF ( ic == lc .or. ic == li .or. ic == ls .or. (ic == lr .and. imurain == 3) ) THEN
14304 alp = (3.*alpha(mgs,ic) + 2.)
14305 j = Nint( (3.*alpha(mgs,ic) + 2.)*dqiacralphainv )
14306 ELSE ! IF ( ic == lr .and. imurain == 1 ) ! rain
14307 alp = alpha(mgs,ic)
14308 j = Nint( alpha(mgs,ic)*dqiacralphainv )
14311 dab0lh(mgs,ic,il) = dab0lu(j,i,ic,il)
14312 dab1lh(mgs,ic,il) = dab1lu(j,i,ic,il)
14313 dab0lh(mgs,il,ic) = dab0lu(i,j,il,ic)
14314 dab1lh(mgs,il,ic) = dab1lu(i,j,il,ic)
14317 ! alpha(:,lr) = 0. ! 10.
14318 ! alpha(:,lh) = 0. ! 10.
14319 IF ( lhl > 0 ) THEN
14320 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. cx(mgs,lhl) > cxmin ) THEN
14321 xv(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*cx(mgs,lhl)) !
14322 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6.*piinv)**(1./3.)
14323 IF ( xdia(mgs,lhl,3) < 0.008 ) THEN
14324 alpha(mgs,lhl) = Min(alphamax, c1hl*tanh(c2hl*(xdia(mgs,lhl,3)*1000. - c3hl)) + c4hl)
14326 alpha(mgs,lhl) = Min(alphamax, c5hl*xdia(mgs,lhl,3)*1000. + c6hl)
14330 DO ic = lc,lh-1 ! lhab
14331 i = Nint( alpha(mgs,il)*dqiacralphainv )
14332 IF ( ic == lc .or. ic == li .or. ic == ls .or. (ic == lr .and. imurain == 3) ) THEN
14333 alp = (3.*alpha(mgs,ic) + 2.)
14334 j = Nint( (3.*alpha(mgs,ic) + 2.)*dqiacralphainv )
14335 ELSE ! IF ( ic == lr .and. imurain == 1 ) ! rain
14336 alp = alpha(mgs,ic)
14337 j = Nint( alpha(mgs,ic)*dqiacralphainv )
14340 dab0lh(mgs,ic,il) = dab0lu(j,i,ic,il)
14341 dab1lh(mgs,ic,il) = dab1lu(j,i,ic,il)
14342 dab0lh(mgs,il,ic) = dab0lu(i,j,il,ic)
14343 dab1lh(mgs,il,ic) = dab1lu(i,j,il,ic)
14355 IF ( imurain == 3 ) THEN
14356 IF ( lzr > 1 ) THEN
14358 alphamlr = -2.0/3.0
14359 alphasmlr = -2.0/3.0
14363 alphasmlr = xnu(lr)
14365 ! massfacshr = ( (2. + 3.*(1. +alphashr) )/( 3.*(1. + alphashr) ) )**(1./3.) ! this is the diameter factor
14366 ! massfacmlr = ( (2. + 3.*(1. +alphamlr) )/( 3.*(1. + alphamlr) ) )**(1./3.)
14367 massfacshr = ( (2. + 3.*(1. +alphashr) )**3/( 3.*(1. + alphashr) ) ) ! this is the mass or volume factor
14368 massfacmlr = ( (2. + 3.*(1. +alphamlr) )**3/( 3.*(1. + alphamlr) ) )
14369 ELSEIF ( imurain == 1 ) THEN
14370 IF ( lzr > 1 ) THEN
14373 alphasmlr = alphasmlr0
14379 ! massfacshr = (3.0 + alphashr)*((3.+alphashr)*(2.+alphashr)*(1. + alphashr) )**(-1./3.) ! this is the diameter factor
14380 ! massfacmlr = (3.0 + alphamlr)*((3.+alphamlr)*(2.+alphamlr)*(1. + alphamlr) )**(-1./3.)
14381 massfacshr = (3.0 + alphashr)**3/((3.+alphashr)*(2.+alphashr)*(1. + alphashr) ) ! this is the mass or volume factor
14382 massfacmlr = (3.0 + alphamlr)**3/((3.+alphamlr)*(2.+alphamlr)*(1. + alphamlr) )
14385 ! Find shape parameter rain
14391 ! CALL cld_cpu('Z-MOMENT-1')
14393 IF ( ipconc >= 6 ) THEN
14395 ! set base g1x in case rain is not 3-moment
14396 IF ( ipconc >= 6 .and. imurain == 3 ) THEN
14399 ! g1x(mgs,il) = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14400 g1x(mgs,il) = (alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0))
14405 IF ( imurain == 3 ) THEN
14406 g1shr = (alphashr+2.0)/((alphashr+1.0))
14407 g1mlr = (alphamlr+2.0)/((alphamlr+1.0))
14408 g1smlr = (alphasmlr+2.0)/((alphasmlr+1.0))
14409 ELSEIF ( imurain == 1 ) THEN
14410 ! g1shr = 36.*(6.0 + alphashr)*(5.0 + alphashr)*(4.0 + alphashr)/ &
14411 ! & (pi**2*(3.0 + alphashr)*(2.0 + alphashr)*(1.0 + alphashr))
14412 g1shr = (6.0 + alphashr)*(5.0 + alphashr)*(4.0 + alphashr)/ &
14413 & ((3.0 + alphashr)*(2.0 + alphashr)*(1.0 + alphashr))
14414 ! g1mlr = 36.*(6.0 + alphamlr)*(5.0 + alphamlr)*(4.0 + alphamlr)/ &
14415 ! & (pi**2*(3.0 + alphamlr)*(2.0 + alphamlr)*(1.0 + alphamlr))
14416 g1mlr = (6.0 + alphamlr)*(5.0 + alphamlr)*(4.0 + alphamlr)/ &
14417 & ((3.0 + alphamlr)*(2.0 + alphamlr)*(1.0 + alphamlr))
14418 g1smlr = (6.0 + alphasmlr)*(5.0 + alphasmlr)*(4.0 + alphasmlr)/ &
14419 & ((3.0 + alphasmlr)*(2.0 + alphasmlr)*(1.0 + alphasmlr))
14423 IF ( lzr > 1 .and. imurain == 3 ) THEN ! { RAIN SHAPE PARAM
14426 ! CALL cld_cpu('Z-MOMENT-1r')
14431 IF ( iresetmoments == 1 .or. iresetmoments == il .or. iresetmoments == -1 ) THEN ! .or. qx(mgs,il) <= qxmin(il) THEN
14432 IF ( zx(mgs,il) <= zxmin ) THEN ! .and. qx(mgs,il) > 0.05e-3 THEN
14433 !! write(91,*) 'zx=0; qx,cx = ',1000.*qx(mgs,il),cx(mgs,il)
14436 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14437 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14438 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14439 ELSEIF ( iresetmoments == -1 .and. qx(mgs,il) < qxmin(il) ) THEN
14442 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14445 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14446 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14447 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14449 ELSEIF ( cx(mgs,il) <= cxmin .and. iresetmoments /= -1 ) THEN ! .and. qx(mgs,il) > 0.05e-3 THEN
14451 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
14454 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
14455 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
14456 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
14460 IF ( .false. .and. zx(mgs,il) <= zxmin .and. cx(mgs,il) <= cxmin ) THEN
14463 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14466 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14467 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14468 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14471 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
14473 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*Max(1.0e-11,cx(mgs,lr)))
14474 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
14475 ! xv(mgs,lr) = xvmx(lr)
14476 ! cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
14477 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
14478 xv(mgs,lr) = xvmn(lr)
14479 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
14482 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
14483 ! have mass and reflectivity but no concentration, so set concentration, using default alpha
14484 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14487 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*xdn(mgs,lr)**2)
14488 ! an(igs(mgs),jgs,kgs(mgs),ln(il)) = zx(mgs,il)
14489 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > 0.0 ) THEN
14490 ! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
14491 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14494 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(xdn(mgs,lr)**2*chw)
14495 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
14497 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
14498 ! How did this happen?
14499 ! set values according to dBZ of -10, or Z = 0.1
14500 ! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
14501 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
14502 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14504 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14507 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*1000.*1000)
14508 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14511 IF ( zx(mgs,lr) > 0.0 ) THEN
14512 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(1000.*cx(mgs,lr))
14518 ! xv = (db(1,kz)*a(1,1,kz,lr))**2/(a(1,1,kz,lnr))
14519 ! rd = z*(pi/6.*1000.)**2/xv
14521 ! determine shape parameter alpha by iteration
14522 IF ( z .gt. 0.0 ) THEN
14523 ! alpha(mgs,lr) = 3.
14524 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
14526 IF ( Abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
14527 alpha(mgs,lr) = Max( rnumin, Min( rnumax, alp ) )
14528 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
14529 alp = Max( rnumin, Min( rnumax, alp ) )
14532 ! check for artificial breakup (rain larger than allowed max size)
14533 IF ( (xv(mgs,il) .gt. xvmx(il) .or. (ioldlimiter >= 2 .and. xv(mgs,il) .gt. xvmx(il)/8.) )) THEN
14535 IF ( ioldlimiter >= 2 ) THEN ! MY-style active breakup
14536 x = (6.*rho0(mgs)*qx(mgs,il)/(pi*xdn(mgs,il)*cx(mgs,il)))**(1./3.)
14537 x1 = Max(0.0e-3, x - 3.0e-3)
14538 x2 = Max(0.5, x/6.0e-3)
14540 cx(mgs,il) = cx(mgs,il)*Max((1.+2.222e3*x1**2), x3)
14541 xv(mgs,il) = xv(mgs,il)/Max((1.+2.222e3*x1**2), x3)
14542 ELSE ! simple cutoff
14543 xv(mgs,il) = Min( xvmx(il), Max( xvmn(il),xv(mgs,il) ) )
14544 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
14545 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
14547 !xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
14548 !cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
14550 IF ( tmp < cx(mgs,il) ) THEN ! breakup
14552 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14553 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
14554 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14562 ! determine shape parameter alpha by iteration
14563 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
14565 IF ( Abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
14566 alpha(mgs,lr) = Max( rnumin, Min( rnumax, alp ) )
14567 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
14568 alp = Max( rnumin, Min( rnumax, alp ) )
14576 ! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
14577 ! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
14579 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14580 IF ( .true. .and. (alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax) ) THEN
14582 IF ( rescale_high_alpha .and. alp >= rnumax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
14583 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(1./(xdn(mgs,il)))**2
14584 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
14586 ELSEIF ( rescale_low_alphar .and. alp <= rnumin ) THEN
14587 z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
14589 an(igs(mgs),jy,kgs(mgs),lz(il)) = zx(mgs,il)
14593 ! set g1x to use as G factor later. If alpha is in the range ( rnumin < alpha < rnumax ), then
14594 ! this will be the same as computing G from alpha. If alpha = rnumax, however, it probably means that
14595 ! the moments are not matched correctly, so we compute G from the moments instead so that the dZ/dt rates
14596 ! stay consistent with dN/dt and dq/dt.
14597 IF ( alp >= rnumax - 0.01 ) THEN
14598 ! g1x(mgs,il) = 6**2*zx(mgs,il)/(cx(mgs,il)*(pi*xv(mgs,lr))**2)
14599 ! g1x(mgs,il) = xdn(mgs,il)*zx(mgs,il)*cx(mgs,il)/((rho0(mgs)*qx(mgs,lr))**2)
14600 g1x(mgs,il) = (pi*xdn(mgs,il))**2*zx(mgs,il)*cx(mgs,il)/((6.*rho0(mgs)*qx(mgs,il))**2)
14605 tmp = alpha(mgs,lr) + 4./3.
14606 i = Int(dgami*(tmp))
14608 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14610 tmp = alpha(mgs,lr) + 1.
14611 i = Int(dgami*(tmp))
14613 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14617 ! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 4./3.)/(alpha(mgs,lr) + 1.)**(1./3.)/Gamma_sp(alpha(mgs,lr) + 1.)
14618 ventrx(mgs) = x/(y*(alpha(mgs,lr) + 1.)**(1./3.))
14620 IF ( imurain == 3 .and. izwisventr == 2 ) THEN
14622 tmp = alpha(mgs,lr) + 1.5 + br/6.
14623 i = Int(dgami*(tmp))
14625 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14627 ! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 1.5 + br/6.)/Gamma_sp(alpha(mgs,lr) + 1.)
14628 ventrxn(mgs) = x/(y*(alpha(mgs,lr) + 1.)**((1.+br)/6. + 1./3.))
14630 ! This whole section is imurain == 3, so this branch never runs
14631 ! ELSEIF ( imurain == 1 .and. iferwisventr == 2 ) THEN
14633 ! tmp = alpha(mgs,lr) + 2.5 + br/2.
14634 ! i = Int(dgami*(tmp))
14635 ! del = tmp - dgam*i
14636 ! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14638 !! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 1.5 + br/6.)/Gamma_sp(alpha(mgs,lr) + 1.)
14639 ! ventrxn(mgs) = x/y
14650 ! CALL cld_cpu('Z-MOMENT-1r')
14653 ENDIF ! ipconc >= 6
14655 ! Find shape parameters for graupel and hail
14656 IF ( ipconc .ge. 6 ) THEN
14660 ! set base values of g1x
14661 IF ( (.not. ( il == lr .and. imurain == 3 )) .and. ( il == lr .or. il == lh .or. il == lhl .or. il == lf ) ) THEN
14663 g1x(mgs,il) = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
14664 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
14668 IF ( lz(il) .gt. 1 .and. ( .not. ( il == lr .and. imurain == 3 )) ) THEN
14673 IF ( iresetmoments == 1 .or. iresetmoments == il .or. iresetmoments == -1 ) THEN ! .or. qx(mgs,il) <= qxmin(il) ) THEN
14674 IF ( zx(mgs,il) <= zxmin ) THEN ! .and. qx(mgs,il) > 0.05e-3 ) THEN
14675 !! write(91,*) 'zx=0; qx,cx = ',1000.*qx(mgs,il),cx(mgs,il)
14679 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14680 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14681 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14682 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14683 ELSEIF ( iresetmoments == -1 .and. qx(mgs,il) < qxmin(il) ) THEN
14686 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14689 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14690 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14691 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14693 ELSEIF ( cx(mgs,il) <= cxmin .and. iresetmoments /= -1 ) THEN ! .and. qx(mgs,il) > 0.05e-3 ) THEN
14694 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
14698 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14699 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14700 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14701 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14705 IF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= cxmin ) THEN
14708 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14711 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14712 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14713 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14716 IF ( qx(mgs,il) .gt. qxmin(il) ) THEN
14718 xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*Max(1.0e-9,cx(mgs,il)))
14719 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
14721 IF ( xv(mgs,il) .lt. xvmn(il) ) THEN
14722 xv(mgs,il) = Min( xvmx(il), Max( xvmn(il),xv(mgs,il) ) )
14723 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
14724 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
14727 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
14728 ! have mass and reflectivity but no concentration, so set concentration, using default alpha
14729 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
14730 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
14733 ! cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z
14734 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(z*(pi*xdn(mgs,il))**2)
14736 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > cxmin ) THEN
14737 ! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
14738 ! g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
14739 ! & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
14742 ! zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
14743 ! zx(mgs,il) = Min(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
14744 g1 = (6.0 + alphamax)*(5.0 + alphamax)*(4.0 + alphamax)/ &
14745 & ((3.0 + alphamax)*(2.0 + alphamax)*(1.0 + alphamax))
14746 zx(mgs,il) = Max(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
14747 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14749 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
14750 ! How did this happen?
14751 ! set values according to dBZ of -10, or Z = 0.1
14752 ! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
14753 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
14754 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14756 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
14757 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
14760 ! cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z
14761 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(z*(pi*xdn(mgs,il))**2)
14762 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14769 IF ( zx(mgs,il) .gt. 0. ) THEN
14771 ! rdi = z*(pi/6.*1000.)**2*chw/((rho0(mgs)*qr)**2)
14772 rdi = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
14774 ! alp = 1.e18*(6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/
14775 ! : ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
14776 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
14777 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
14778 ! print*,'kz, alp, alpha(mgs,il) = ',kz,alp,alpha(mgs,il),rdi,z,xv
14779 alp = Max( alphamin, Min( alphamax, alp ) )
14783 IF ( Abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
14784 alpha(mgs,il) = Max( alphamin, Min( alphamax, alp ) )
14785 alp = alp + ( galpha(alp) - rdi )/dgalpha(alp)
14786 alp = Max( alphamin, Min( alphamax, alp ) )
14791 ! IF ( 100.*Abs(alp - alpha(mgs,il))/(Abs(alpha(mgs,il))+1.e-5) .lt. 1. ) EXIT
14792 IF ( Abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
14793 alpha(mgs,il) = Max( alphamin, Min( alphamax, alp ) )
14794 ! alp = 1.e18*(6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/
14795 ! : ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
14796 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
14797 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
14798 ! print*,'i,alp = ',i,alp
14799 alp = Max( alphamin, Min( alphamax, alp ) )
14804 ! check for artificial breakup (graupel/hail larger than allowed max size)
14805 IF ( imaxdiaopt == 1 ) THEN
14806 xvbarmax = xvmx(il)
14807 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
14808 xvbarmax = xvmx(il) /((3. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
14809 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
14810 xvbarmax = xvmx(il) /((4. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
14812 xvbarmax = xvmx(il)
14815 IF ( xv(mgs,il) .gt. xvbarmax .or. (il == lr .and. ioldlimiter >= 2 .and. xv(mgs,il) .gt. xvmx(il)/8.)) THEN
14817 IF( ioldlimiter >= 2 .and. il == lr) THEN ! MY-style drop limiter for rain
14818 x = (6.*rho0(mgs)*qx(mgs,il)/(pi*xdn(mgs,il)*cx(mgs,il)))**(1./3.)
14819 x1 = Max(0.0e-3, x - 3.0e-3)
14820 x2 = Max(0.5, x/6.0e-3)
14822 cx(mgs,il) = cx(mgs,il)*Max((1.+2.222e3*x1**2), x3)
14823 xv(mgs,il) = xv(mgs,il)/Max((1.+2.222e3*x1**2), x3)
14825 xv(mgs,il) = Min( xvbarmax, Max( xvmn(il),xv(mgs,il) ) )
14826 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
14827 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
14829 IF ( tmp < cx(mgs,il) ) THEN ! artificial breakup has happened, so need to adjust reflectivity and find new shape parameter
14830 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
14831 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
14832 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
14833 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14839 rdi = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
14840 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
14841 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
14843 IF ( Abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
14844 alpha(mgs,il) = Max( alphamin, Min( alphamax, alp ) )
14845 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
14846 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
14847 alp = Max( alphamin, Min( alphamax, alp ) )
14855 ! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
14856 ! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
14858 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
14859 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
14861 IF ( ( lrescalelow(il) .or. rescale_high_alpha ) .and. &
14862 & ( alpha(mgs,il) <= alphamin .or. alp == alphamin .or. alp == alphamax ) ) THEN
14866 IF ( rescale_high_alpha .and. alp >= alphamax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
14867 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(6./(pi*xdn(mgs,il)))**2
14868 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
14870 ELSEIF ( lrescalelow(il) .and. alp <= alphamin .and. .not. (il == lh .and. icvhl2h > 0 ) .and. &
14871 .not. ( il == lr .and. .not. rescale_low_alphar ) ) THEN ! alpha = alphamin, so reset Z to prevent growth in C
14873 IF ( irescalerainopt == 0 ) THEN
14875 ELSEIF ( irescalerainopt == 1 ) THEN
14876 wtest = qx(mgs,lc) > qxmin(lc)
14877 ELSEIF ( irescalerainopt == 2 ) THEN
14878 wtest = qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < rescale_wthresh
14879 ELSEIF ( irescalerainopt == 3 ) THEN
14880 wtest = temcg(mgs) > rescale_tempthresh .and. qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < rescale_wthresh
14883 IF ( il == lr .and. ( wtest ) ) THEN
14884 ! IF ( temcg(mgs) > 0.0 .and. il == lr .and. qx(mgs,lc) > qxmin(lc) ) THEN
14885 ! certain situations where rain number is adjusted instead of Z. Helps avoid rain being 'zapped' by autoconverted
14886 ! drops (i.e., favor preserving Z when alpha tries to go negative)
14887 chw = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(6./(pi*xdn(mgs,il)))**2 ! g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z1
14889 an(igs(mgs),jy,kgs(mgs),ln(il)) = chw
14892 ! Usual resetting of reflectivity moment to force consisntency between Q, N, Z, and alpha when alpha = alphamin
14893 z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
14894 z = z1*(6./(pi*xdn(mgs,il)))**2
14896 an(igs(mgs),jy,kgs(mgs),lz(il)) = z
14902 ! set g1x to use as G factor later. If alpha is in the range ( rnumin < alpha < rnumax ), then
14903 ! this will be the same as computing G from alpha. If alpha = rnumax, however, it probably means that
14904 ! the moments are not matched correctly, so we compute G from the moments instead so that the dZ/dt rates
14905 ! stay consistent with dN/dt and dq/dt.
14906 ! g1x(mgs,il) = zx(mgs,il)*chw*(pi*xdn(mgs,il))**2/(6.*qr*dn(igs(mgs),jy,kgs(mgs)))**2
14907 ! g1x(mgs,il) = g1 ! zx(mgs,il)*cx(mgs,il)/(qr)**2
14908 IF ( alp >= alphamax - 0.5 ) THEN
14909 ! g1x(mgs,il) = 6**2*zx(mgs,il)/(cx(mgs,il)*(pi*xv(mgs,lr))**2)
14910 ! g1x(mgs,il) = (xdn(mgs,il))**2*zx(mgs,il)*cx(mgs,il)/((rho0(mgs)*qx(mgs,il))**2)
14911 g1x(mgs,il) = (pi*xdn(mgs,il))**2*zx(mgs,il)*cx(mgs,il)/((6.*rho0(mgs)*qx(mgs,il))**2)
14918 ! IF ( ny .eq. 2 ) THEN
14919 ! IF ( qr .gt. 1.e-3 ) THEN
14920 ! write(0,*) 'alphah at nstep,i,k = ',dtp*(nstep-1),igs(mgs),kgs(mgs),alpha(mgs,il),qr*1000.
14927 IF ( il == lr ) THEN
14929 ! tmp = alpha(mgs,lr) + 4./3.
14930 ! i = Int(dgami*(tmp))
14931 ! del = tmp - dgam*i
14932 ! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14934 ! tmp = alpha(mgs,lr) + 1.
14935 ! i = Int(dgami*(tmp))
14936 ! del = tmp - dgam*i
14937 ! y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14939 !! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 4./3.)/(alpha(mgs,lr) + 1.)**(1./3.)/Gamma_sp(alpha(mgs,lr) + 1.)
14940 ! ventrx(mgs) = x/(y*(alpha(mgs,lr) + 1.)**(1./3.))
14943 tmp = alpha(mgs,lr) + 1.
14944 i = Int(dgami*(tmp))
14946 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14950 IF ( iferwisventr == 2 ) THEN
14951 tmp = alpha(mgs,lr) + 2.5 + br/2.
14952 i = Int(dgami*(tmp))
14954 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14956 ! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 1.5 + br/6.)/Gamma_sp(alpha(mgs,lr) + 1.)
14965 ELSE ! below mass threshold
14966 ! g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/
14967 ! & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
14968 ! z1 = g1*rho0(mgs)**2*(qr)*qr/chw
14969 ! z = 1.e18*z1*(6./(pi*1000.))**2
14970 ! z = z1*(6./(pi*1000.))**2
14972 ! an(igs(mgs),jy,kgs(mgs),lz(il)) = z
14973 ENDIF ! ( qx(mgs,il) .gt. qxmin(il) )
14980 ! CALL cld_cpu('Z-DELABK')
14982 ! IF ( il == lr ) THEN
14983 ! xnutmp = (alpha(mgs,il) - 2.)/3.
14984 ! da0lr(mgs) = delbk(bb(il), xnutmp, xmu(il), 0)
14987 IF ( .not. ( il == lr .and. imurain == 3 ) ) THEN
14988 ! CALL cld_cpu('Z-DELABK')
14990 IF ( qx(mgs,il) > qxmin(il) ) THEN
14991 xnutmp = (alpha(mgs,il) - 2.)/3.
14993 ! IF ( .true. ) THEN
14994 DO ic = lc,lh-1 ! lhab
14995 IF ( il .ne. ic .and. qx(mgs,ic) .gt. qxmin(ic)) THEN
14997 IF ( ic == lc .and. idiagnosecnu > 0 ) xnuc = alpha(mgs,lc) ! alpha for droplets is actually nu
14998 IF ( il /= lr .and. ic == lr .and. lzr > 1 ) THEN
14999 IF ( imurain == 3 ) THEN
15000 xnuc = alpha(mgs,lr) ! alpha is nu already
15002 xnuc = ( alpha(mgs,lr) - 2. )/3. ! convert alpha to nu
15005 ! delabk(ba,bb,nua,nub,mua,mub,k), where a (il) is collector and b (ic) is collected
15006 IF ( .false. ) THEN
15007 dab0lh(mgs,ic,il) = delabk(bb(ic), bb(il), xnuc, xnutmp, xmu(ic), xmu(il), 0) !dab0(il,ic)
15008 dab1lh(mgs,ic,il) = delabk(bb(ic), bb(il), xnuc, xnutmp, xmu(ic), xmu(il), 1) !dab1(il,ic)
15009 dab0lh(mgs,il,ic) = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic), 0) !dab0(il,ic)
15010 dab1lh(mgs,il,ic) = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic), 1) !dab1(il,ic)
15011 ELSE ! use lookup table -- not interpolating yet because table resolution of 0.05 is good enough
15012 i = Nint( alpha(mgs,il)*dqiacralphainv )
15013 IF ( ic == lc .or. ic == li .or. ic == ls .or. (ic == lr .and. imurain == 3) ) THEN
15014 alp = (3.*alpha(mgs,ic) + 2.)
15015 j = Nint( (3.*alpha(mgs,ic) + 2.)*dqiacralphainv )
15016 ELSE ! IF ( ic == lr .and. imurain == 1 ) ! rain
15017 alp = alpha(mgs,ic)
15018 j = Nint( alpha(mgs,ic)*dqiacralphainv )
15021 dab0lh(mgs,ic,il) = dab0lu(j,i,ic,il)
15022 dab1lh(mgs,ic,il) = dab1lu(j,i,ic,il)
15023 dab0lh(mgs,il,ic) = dab0lu(i,j,il,ic)
15024 dab1lh(mgs,il,ic) = dab1lu(i,j,il,ic)
15026 ! tmp1 = dab0lu(j,i,ic,il)
15027 ! tmp2 = dab1lu(j,i,ic,il)
15028 ! tmp3 = dab0lu(i,j,il,ic)
15029 ! tmp4 = dab1lu(i,j,il,ic)
15030 ! tmp5 = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(ic), xmu(il), 0) !dab0(il,ic)
15031 ! tmp6 = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(ic), xmu(il), 1) !dab1(il,ic)
15032 ! tmp5 = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic), 0) !dab0(il,ic)
15033 ! tmp6 = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic), 1) !dab1(il,ic)
15035 IF ( .false. .and. ny <= 2 ) THEN
15037 write(0,*) 'bb: ', bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic)
15038 write(0,*) 'il,ic = ',il,ic,alpha(mgs,il),i,xnuc,alp,j
15039 write(0,*) 'dab0lh,tmp1 = ',dab0lh(mgs,ic,il),tmp1
15040 write(0,*) 'dab1lh,tmp2 = ',dab1lh(mgs,ic,il),tmp2
15041 write(0,*) 'dab0lh,tmp3 = ',dab0lh(mgs,il,ic),tmp3,tmp5
15042 write(0,*) 'dab1lh,tmp4 = ',dab1lh(mgs,il,ic),tmp4,tmp6
15053 da0lx(mgs,il) = delbk(bb(il), xnutmp, xmu(il), 0)
15054 IF ( il .eq. lh ) THEN
15055 da0lh(mgs) = delbk(bb(il), xnutmp, xmu(il), 0)
15056 IF ( lzr > 1 ) THEN
15059 rzxh(mgs) = ((4. + alpha(mgs,il))*(5. + alpha(mgs,il))*(6. + alpha(mgs,il))*(1. + xnu(lr)))/ &
15060 & ((1. + alpha(mgs,il))*(2. + alpha(mgs,il))*(3. + alpha(mgs,il))*(2. + xnu(lr)))
15063 IF ( lzhl < 1 ) THEN
15064 rzxhlh(mgs) = rzxhl(mgs)/(((4. + alpha(mgs,il))*(5. + alpha(mgs,il))*(6. + alpha(mgs,il))*(1. + xnu(lr)))/ &
15065 & ((1. + alpha(mgs,il))*(2. + alpha(mgs,il))*(3. + alpha(mgs,il))*(2. + xnu(lr))))
15067 ELSEIF ( il .eq. lhl ) THEN
15068 da0lhl(mgs) = delbk(bb(il), xnutmp, xmu(il), 0)
15069 IF ( lzr > 1 ) THEN
15072 rzxhl(mgs) = ((4.0 + alpha(mgs,il))*(5. + alpha(mgs,il))*(6. + alpha(mgs,il))*(1. + xnu(lr)))/ &
15073 & ((1. + alpha(mgs,il))*(2. + alpha(mgs,il))*(3. + alpha(mgs,il))*(2. + xnu(lr)))
15075 ELSEIF ( il == lr ) THEN
15076 xnutmp = (alpha(mgs,il) - 2.)/3.
15077 da0lr(mgs) = delbk(bb(il), xnutmp, xmu(il), 0)
15078 da1lr(mgs) = delbk(bb(il), xnutmp, xmu(il), 1)
15081 ENDIF ! ( qx(mgs,il) > qxmin(il) )
15083 ! CALL cld_cpu('Z-DELABK')
15086 ! CALL cld_cpu('Z-DELABK')
15088 ENDIF ! lz(il) .gt. 1
15092 ENDIF ! ipconc .ge. 6
15094 ! CALL cld_cpu('Z-MOMENT-1')
15097 ! set some values for ice nucleation
15100 kp1 = Min(nz, kgs(mgs)+1 )
15101 ! wvel(mgs) = (0.5)*(w(igs(mgs),jgs,kp1) &
15102 ! & +w(igs(mgs),jgs,kgs(mgs)))
15105 wvelkm1(mgs) = (0.5)*(w(igs(mgs),jgs,kgs(mgs)) &
15106 & +w(igs(mgs),jgs,kgsm(mgs)))
15107 cninm(mgs) = t7(igs(mgs),jgs,kgsm(mgs))
15108 cnina(mgs) = t7(igs(mgs),jgs,kgs(mgs))
15109 cninp(mgs) = t7(igs(mgs),jgs,kgsp(mgs))
15113 ! Set a couple of cloud variables...
15116 ! SUBROUTINE setvt(ngscnt,qx,qxmin,cx,rho0,rhovt,xdia,cno,
15117 ! : xmas,xdn,xvmn,xvmx,xv,cdx,
15119 ! SUBROUTINE setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno, &
15120 ! & xmas,vtxbar,xdn,xvmn,xvmx,xv,cdx, &
15121 ! & ipconc1,ndebug1,ngs,nz,kgs,cwnccn,fadvisc, &
15122 ! & cwmasn,cwmasx,cwradn,cnina,cimna,cimxa, &
15123 ! & itype1a,itype2a,temcg,infdo,alpha)
15127 IF ( rimdenvwgt > 0 ) infdo = 1
15129 call setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno,cnostmp, &
15130 & xmas,vtxbar,xdn,xvmn,xvmx,xv,cdx,cdxgs, &
15131 & ipconc,ndebug,ngs,nz,kgs,fadvisc, &
15132 & cwmasn,cwmasx,cwradn,cnina,cimn,cimx, &
15133 & itype1,itype2,temcg,infdo,alpha,0,axx,bxx) ! ,cdh,cdhl)
15134 ! & itype1,itype2,temcg,infdo,alpha,0,axh,bxh,axhl,bxhl) ! ,cdh,cdhl)
15137 IF ( lwsm6 .and. ipconc == 0 ) THEN
15138 tmp = Max(qxmin(lh), qxmin(ls))
15140 total = qx(mgs,lh) + qx(mgs,ls)
15141 IF ( total > tmp ) THEN
15142 vt2ave(mgs) = (qx(mgs,lh)*vtxbar(mgs,lh,1) + qx(mgs,ls)*vtxbar(mgs,ls,1))/total
15151 ! Set number concentrations (need xdia from setvt)
15153 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: Set concentration'
15154 IF ( ipconc .lt. 1 ) THEN
15155 cina(1:ngscnt) = cx(1:ngscnt,li)
15157 if ( ipconc .lt. 5 ) then
15161 IF ( ipconc .lt. 3 ) THEN
15163 if ( qx(mgs,lr) .gt. qxmin(lh) ) then
15164 ! cx(mgs,lr) = cno(lr)*xdia(mgs,lr,1)
15165 ! xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr))
15169 IF ( ipconc .lt. 4 ) THEN
15172 if ( qx(mgs,ls) .gt. qxmin(ls) ) then
15173 ! cx(mgs,ls) = cno(ls)*xdia(mgs,ls,1)
15174 ! xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*cx(mgs,ls))
15176 ENDIF ! ( ipconc .lt. 4 )
15178 IF ( ipconc .lt. 5 ) THEN
15182 if ( qx(mgs,lh) .gt. qxmin(lh) ) then
15183 ! cx(mgs,lh) = cno(lh)*xdia(mgs,lh,1)
15184 ! xv(mgs,lh) = Max(xvmn(lh), rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) )
15185 ! xdia(mgs,lh,3) = (xv(mgs,lh)*6./pi)**(1./3.)
15188 ENDIF ! ( ipconc .lt. 5 )
15193 IF ( ipconc .ge. 2 ) THEN
15196 rb(mgs) = 0.5*xdia(mgs,lc,1)*(1./(1.+alpha(mgs,lc)))**(1./6.)
15197 xl2p(mgs) = Max(0.0d0, 2.7e-2*xdn(mgs,lc)*cx(mgs,lc)*xv(mgs,lc)* &
15198 & ((0.5e20*rb(mgs)**3*xdia(mgs,lc,1))-0.4) )
15199 IF ( rb(mgs) .gt. 3.51e-6 ) THEN
15200 ! rh(mgs) = Max( 0.5d0*xdia(mgs,lc,1), 6.3d-4/(1.d6*(rb(mgs) - 3.5d-6)) )
15201 rh(mgs) = Max( 41.d-6, 6.3d-4/(1.d6*(rb(mgs) - 3.5d-6)) )
15205 IF ( xl2p(mgs) .gt. 0.0 ) THEN
15206 nh(mgs) = 4.2d9*xl2p(mgs)
15217 ! maximum depletion tendency by any one source
15220 if( ndebug .ge. 0 ) THEN
15221 !mpi! write(0,*) 'Set depletion max/min1'
15224 qvimxd(mgs) = 0.70*(qx(mgs,lv)-qis(mgs))*dtpinv ! depletion by all vap. dep to ice.
15226 IF ( qx(mgs,lc) < qxmin(lc) ) qvimxd(mgs) = 0.99*(qx(mgs,lv)-qis(mgs))*dtpinv ! this makes virtually no difference whatsoever, but what the heck
15228 qvimxd(mgs) = max(qvimxd(mgs), 0.0)
15231 qimxd(mgs) = frac*qx(mgs,li)*dtpinv
15232 qcmxd(mgs) = frac*qx(mgs,lc)*dtpinv
15233 qrmxd(mgs) = frac*qx(mgs,lr)*dtpinv
15234 qsmxd(mgs) = frac*qx(mgs,ls)*dtpinv
15235 qhmxd(mgs) = frac*qx(mgs,lh)*dtpinv
15236 IF ( lhl > 1 ) qhlmxd(mgs) = frac*qx(mgs,lhl)*dtpinv
15239 if( ndebug .ge. 0 ) THEN
15240 !mpi! write(0,*) 'Set depletion max/min2'
15245 if ( qx(mgs,lc) .le. qxmin(lc) ) then
15246 ccmxd(mgs) = 0.20*cx(mgs,lc)*dtpinv
15248 IF ( ipconc .ge. 2 ) THEN
15249 ccmxd(mgs) = frac*cx(mgs,lc)*dtpinv
15251 ccmxd(mgs) = frac*qx(mgs,lc)/(xmas(mgs,lc)*rho0(mgs)*dtp)
15255 if ( qx(mgs,li) .le. qxmin(li) ) then
15256 cimxd(mgs) = frac*cx(mgs,li)*dtpinv
15258 IF ( ipconc .ge. 1 ) THEN
15259 cimxd(mgs) = frac*cx(mgs,li)*dtpinv
15261 cimxd(mgs) = frac*qx(mgs,li)/(xmas(mgs,li)*rho0(mgs)*dtp)
15266 crmxd(mgs) = 0.10*cx(mgs,lr)*dtpinv
15267 csmxd(mgs) = frac*cx(mgs,ls)*dtpinv
15268 chmxd(mgs) = frac*cx(mgs,lh)*dtpinv
15270 ccmxd(mgs) = frac*cx(mgs,lc)*dtpinv
15271 cimxd(mgs) = frac*cx(mgs,li)*dtpinv
15272 crmxd(mgs) = frac*cx(mgs,lr)*dtpinv
15273 csmxd(mgs) = frac*cx(mgs,ls)*dtpinv
15274 chmxd(mgs) = frac*cx(mgs,lh)*dtpinv
15276 qxmxd(mgs,lv) = Max(0.0, 0.1*(qx(mgs,lv) - qvs(mgs))*dtpinv)
15279 qxmxd(mgs,il) = frac*qx(mgs,il)*dtpinv
15280 cxmxd(mgs,il) = frac*cx(mgs,il)*dtpinv
15288 IF ( ipconc >= 6 ) THEN
15292 IF ( lz(il) > 0 .or. ( il == lr ) ) THEN
15294 zxmxd(mgs,il) = frac*zx(mgs,il)*dtpinv
15303 ! default factors between mean volume and maximum mass volume
15304 maxmassfac(lc) = ( (2. + 3.*(1. + xnu(lc)) )**3/( 3.*(1. + xnu(lc)) ) )
15305 maxmassfac(li) = ( (2. + 3.*(1. + xnu(li)) )**3/( 3.*(1. + xnu(li)) ) )
15307 IF ( imurain == 3 ) THEN
15308 maxmassfac(lr) = ( (2. + 3.*(1. + xnu(lr)) )**3/( 3.*(1. + xnu(lr)) ) )
15310 maxmassfac(lr) = (3.0 + alphar)**3/ &
15311 & ((3.+alphar)*(2.+alphar)*(1. + alphar) )
15314 IF ( imusnow == 3 ) THEN
15315 maxmassfac(ls) = ( (2. + 3.*(1. + alphas) )**3/( 3.*(1. + alphas) ) )
15317 maxmassfac(ls) = (3.0 + alphas)**3/ &
15318 & ((3.+alphas)*(2.+alphas)*(1. + alphas) )
15321 maxmassfac(lh) = (3.0 + alphah)**3/ &
15322 & ((3.+alphah)*(2.+alphah)*(1. + alphah) )
15324 IF ( lhl > 1 ) THEN
15325 maxmassfac(lhl) = (3.0 + alphahl)**3/ &
15326 & ((3.+alphahl)*(2.+alphahl)*(1. + alphahl) )
15332 DO il = lh,lhab ! graupel and hail only (and frozen drops)
15334 vshdgs(mgs,il) = vshd ! base value
15336 IF ( qx(mgs,il) > qxmin(il) .and. ivshdgs > 0 ) THEN
15338 ! tmpdiam is weighted diameter of d^(shedalp-1), so for shedalp=3, this is the area-weighted diameter or maximum mass diameter.
15339 tmpdiam = (shedalp+alpha(mgs,il))*xdia(mgs,il,1) ! *( xdn(mgs,il)/917. )**(1./3.) ! erm added density factor for equiv. solid ice sphere 10.12.2015
15341 IF ( tmpdiam > sheddiam0 ) THEN
15342 vshdgs(mgs,il) = 0.523599*(1.5e-3)**3/massfacshr ! 1.5mm drops from very large ice
15343 ELSEIF ( tmpdiam > sheddiam ) THEN ! intermediate size
15344 vshdgs(mgs,il) = 0.523599*(3.0e-3)**3/massfacshr ! 3.0mm drops from medium-large ice
15346 ! vshdgs(mgs,il) = Min( xvmx(lr), xv(mgs,il)*xdn(mgs,il)*0.001 ) ! size of drop from melted mean ice particle
15347 vshdgs(mgs,il) = Min( xvmx(lr), 6./pi*xdn(mgs,il)*0.001*tmpdiam**3 )/massfacshr ! size of drop from melted mean ice particle; 0.001 is 1/rhow
15355 ! microphysics source terms (1/s) for mixing ratios
15359 ! Collection efficiencies:
15361 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: Set collection efficiencies'
15387 ehi(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehi*ehiclsn
15388 ehis(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehi*ehiclsn
15389 ehli(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehli*ehliclsn
15390 ehlis(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehli*ehliclsn
15395 ehs(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehs*ehsclsn
15396 ehsfac(mgs) = 1.0 ! factor based on ice saturation
15397 ehls(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehls*ehlsclsn
15405 ehlsclsn(mgs) = 0.0
15406 ehliclsn(mgs) = 0.0
15411 IF ( exwmindiam > 0 .and. qx(mgs,lc) > qxmin(lc) ) THEN
15412 tmp = cx(mgs,lc)*Exp(- (exwmindiam/xdia(mgs,lc,1))**3 )
15413 ccwresv(mgs) = Min( cx(mgs,lc), Max( 2.e6, cx(mgs,lc) - tmp ) )
15415 tmp = cx(mgs,lc) - ccwresv(mgs)
15417 volt = pi/6.*(exwmindiam)**3
15418 qcwresv(mgs) = qx(mgs,lc) - tmp*xdn0(lc)*rhoinv(mgs)*(volt + xv(mgs,lc))
15421 IF ( .false. .and. qx(mgs,lc) > 0.1e-3 ) THEN
15423 write(0,*) 'cx,qx,crsv,qrsv = ',cx(mgs,lc),qx(mgs,lc),ccwresv(mgs),qcwresv(mgs)
15431 IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN
15432 cwrad = 0.5*xdia(mgs,lc,1)
15434 IF ( cwrad .ge. 1.e-6*cwr(il,1) ) icwr(mgs) = il
15440 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
15441 rwrad = 0.5*xdia(mgs,lr,3) ! changed to mean volume diameter (10/6/06)
15443 IF ( rwrad .ge. 1.e-6*grad(il,1) ) irwr(mgs) = il
15449 ! IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
15450 ! rwrad = 0.5*xdia(mgs,lr,1)
15451 ! setting erw = 1 always, so now use igwr for graupel
15452 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
15453 rwrad = 0.5*xdia(mgs,lh,3) ! changed to mean volume diameter (10/6/06)
15455 IF ( rwrad .ge. 1.e-6*grad(il,1) ) igwr(mgs) = il
15460 IF ( lhl .gt. 1 ) THEN ! hail is turned on
15462 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
15463 rwrad = 0.5*xdia(mgs,lhl,3) ! changed to mean volume diameter (10/6/06)
15465 IF ( rwrad .ge. 1.e-6*grad(il,1) ) ihlr(mgs) = il
15472 ! Ice-Ice: Collection (cxc) efficiencies
15475 if ( qx(mgs,li) .gt. qxmin(li) ) then
15476 ! IF ( ipconc .ge. 14 ) THEN
15477 ! eii(mgs)=0.1*exp(0.1*temcg(mgs))
15478 ! if ( temg(mgs) .lt. 243.15 .and. qx(mgs,lc) .gt. 1.e-6 ) then
15483 eii(mgs) = exp(0.025*Min(temcg(mgs),0.0)) ! alpha1 from LFO83 (21)
15485 if ( temg(mgs) .gt. 273.15 ) eii(mgs) = 1.0
15490 ! Ice-cloud water: Collection (cxc) efficiencies
15494 if ( qx(mgs,li).gt.qxmin(li) .and. qx(mgs,lc).gt.qxmin(lc) ) then
15497 if (xdia(mgs,lc,1).gt.ewi_dcmin .and. xdia(mgs,li,1).gt.ewi_dimin) then
15498 ! erm 5/10/2007 test following change:
15499 ! if (xdia(mgs,lc,1).gt.12.0e-06 .and. xdia(mgs,li,1).gt.50.0e-06) then
15502 if ( temg(mgs) .ge. 273.15 ) eiw(mgs) = 0.0
15508 ! Rain: Collection (cxc) efficiencies
15511 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,lc).gt.qxmin(lc) ) then
15513 IF ( lnr .gt. 1 ) THEN
15518 ! cwrad = 0.5*xdia(mgs,lc,1)
15520 ! > min((aradcw + cwrad*(bradcw + cwrad*
15521 ! < (cradcw + cwrad*(dradcw)))), 1.0)
15522 ! IF ( xdia(mgs,lc,1) .lt. 2.4e-06 .or. xdia(mgs,lr,1) .le. 50.0e-6 ) THEN
15525 ! erw(mgs) = ew(icwr(mgs),igwr(mgs))
15526 ! interpolate along droplet radius
15528 icp1 = Min( 8, ic+1 )
15530 irp1 = Min( 6, ir+1 )
15531 cwrad = 0.5*xdia(mgs,lc,3)
15532 rwrad = 0.5*xdia(mgs,lr,3)
15534 slope1 = (ew(icp1, ir ) - ew(ic,ir ))*cwr(ic,2)
15535 slope2 = (ew(icp1, irp1) - ew(ic,irp1))*cwr(ic,2)
15537 ! write(iunit,*) 'slop1: ',slope1,slope2,ew(ic,ir),cwr(ic,2)
15539 x1 = ew(ic, ir) + slope1*Max(0.0, (cwrad - cwr(ic,1)) )
15540 x2 = ew(icp1,ir) + slope2*Max(0.0, (cwrad - cwr(ic,1)) )
15542 slope1 = (x2 - x1)*grad(ir,2)
15544 erw(mgs) = Max(0.0, x1 + slope1*Max(0.0, (rwrad - grad(ir,1)) ))
15546 ! write(iunit,*) 'erw: ',erw(mgs),1.e6*cwrad,1.e6*rwrad,ic,ir,x1,x2
15549 erw(mgs) = Max(0.0, erw(mgs) )
15550 IF ( rwrad .lt. 50.e-6 ) THEN
15552 ELSEIF ( rwrad .lt. 100.e-6 ) THEN ! linear change from zero at 50 to erw at 100 microns
15553 erw(mgs) = erw(mgs)*(rwrad - 50.e-6)/50.e-6
15558 IF ( cx(mgs,lc) .le. 0.0 ) erw(mgs) = 0.0
15560 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,lr).gt.qxmin(lr) ) then
15564 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,ls).gt.qxmin(ls) ) then
15568 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,li).gt.qxmin(li) ) then
15569 ! IF ( vtxbar(mgs,lr,1) .gt. vtxbar(mgs,li,1) .and.
15570 ! : xdia(mgs,lr,3) .gt. 200.e-6 .and. xdia(mgs,li,3) .gt. 100.e-6 ) THEN
15572 ! cwrad = 0.5*xdia(mgs,li,3)
15574 ! > 1.0*min((aradcw + cwrad*(bradcw + cwrad*
15575 ! < (cradcw + cwrad*(dradcw)))), 1.0)
15577 ! if ( xdia(mgs,li,1) .lt. 10.e-6 ) eri(mgs)=0.0
15578 if ( xdia(mgs,li,3) .lt. eri_cimin ) eri(mgs)=0.0
15582 ! Snow aggregates: Collection (cxc) efficiencies
15584 ! Modified by ERM with a linear function for small droplets and large
15585 ! snow agg. based numerical data from Wang and Ji (1992) in P&K 1997 (Fig. 14-13), which
15586 ! allows collection of very small droplets, albeit at low efficiency. But slow
15587 ! fall speeds of snow make up for the efficiency.
15590 if ( qx(mgs,ls).gt.qxmin(ls) .and. qx(mgs,lc).gt.qxmin(lc) ) then
15592 if ( xdia(mgs,lc,1) .gt. 15.e-6 .and. xdia(mgs,ls,1) .gt. 100.e-6) then
15594 ELSEIF ( xdia(mgs,ls,1) .ge. 500.e-6 ) THEN
15595 esw(mgs) = Min(0.5, 0.05 + (0.8-0.05)/(40.e-6)*xdia(mgs,lc,1) )
15599 if ( qx(mgs,ls).gt.qxmin(ls) .and. qx(mgs,lr).gt.qxmin(lr) &
15600 & .and. temg(mgs) .lt. tfr - 1. &
15602 esr(mgs)=Exp(-(40.e-6)**3/xv(mgs,lr))*Exp(-40.e-6/xdia(mgs,ls,1))
15603 IF ( qx(mgs,ls) < 1.e-4 .and. qx(mgs,lr) < 1.e-4 ) il2(mgs) = 1
15606 IF ( ipconc < 3 .and. temg(mgs) < tfr .and. qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,lr) < 1.e-4 ) THEN
15610 ! if ( qx(mgs,ls).gt.qxmin(ls) ) then
15611 if ( temcg(mgs) < 0.0 ) then
15613 IF ( ipconc .lt. 4 .or. temcg(mgs) < esstem1 ) THEN
15615 ! ess(mgs)=0.1*exp(0.1*min(temcg(mgs),0.0))
15616 ! ess(mgs)=min(0.1,ess(mgs))
15621 IF ( iessopt == 2 ) THEN ! experimental code
15622 ! IF ( wvel(mgs) > 2.0 .or. wvel(mgs) < -0.5 .or. ssi(mgs) < 1.0 ) THEN
15623 IF ( wvel(mgs) > 2.0 ) THEN
15624 ! assume convective cell or downdraft
15626 ELSEIF ( wvel(mgs) > 1.0 ) THEN ! transition to stratiform range of values
15627 fac = Max(0.0, 2.0 - wvel(mgs))*fac
15629 ELSEIF ( iessopt == 3 ) THEN ! factor based on ice supersat
15630 IF ( ssi(mgs) <= 1.0 ) THEN
15633 ELSEIF ( ssi(mgs) <= 1.02 ) THEN
15634 fac = fac*(ssi(mgs) - 1.0)/0.02
15635 ehsfac(mgs) = (ssi(mgs) - 1.0)/0.02
15637 ELSEIF ( iessopt == 4 ) THEN ! factor based on ice supersat; very roughly based on Hosler et al. 1957 (J. Met.)
15638 IF ( ssi(mgs) <= 1.0 ) THEN
15641 ELSEIF ( ssi(mgs) <= 1.005 ) THEN
15642 fac = Max(0.1, fac*(ssi(mgs) - 1.0)/0.005)
15643 ehsfac(mgs) = Max(0.1, (ssi(mgs) - 1.0)/0.005)
15647 IF ( temcg(mgs) > esstem1 .and. temcg(mgs) < esstem2 ) THEN ! only nonzero for T > esstem1
15648 ess(mgs) = fac*Exp(ess1*(esstem2) )*(temcg(mgs) - esstem1)/(esstem2 - esstem1) ! linear ramp up from zero at esstem1 to value at esstem2
15649 ELSEIF ( temcg(mgs) >= esstem2 ) THEN
15650 ess(mgs) = fac*Exp(ess1*Min( temcg(mgs), 0.0 ) )
15656 if ( qx(mgs,ls).gt.qxmin(ls) .and. qx(mgs,li).gt.qxmin(li) ) then
15657 esiclsn(mgs) = esi_collsn
15658 ! IF ( ipconc .lt. 4 ) THEN
15659 IF ( ipconc < 1 .and. lwsm6 ) THEN
15660 esi(mgs) = exp(0.7*min(temcg(mgs),0.0))
15662 esi(mgs) = esi0*exp(0.1*min(temcg(mgs),0.0))
15663 esi(mgs) = Min(0.1,esi(mgs))
15665 IF ( ipconc .le. 3 ) THEN
15666 esi(mgs) = exp(0.025*min(temcg(mgs),0.0)) ! LFO
15667 ! esi(mgs) = Min(0.5, exp(0.025*min(temcg(mgs),0.0)) ) ! LFO
15668 ! esi(mgs)=0.5*exp(0.1*min(temcg(mgs),0.0)) ! 10ice
15670 ! ELSE ! zrnic/ziegler 1993
15671 ! esi(mgs)= 0.1 ! 0.5*exp(0.1*min(temcg(mgs),0.0))
15673 if ( temg(mgs) .gt. 273.15 ) esi(mgs) = 0.0
15679 ! Graupel: Collection (cxc) efficiencies
15682 xmascw(mgs) = xmas(mgs,lc)
15683 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lc).gt.qxmin(lc) ) then !{
15685 IF ( iehw .eq. 0 ) THEN
15686 ehw(mgs) = ehw0 ! default value is 1.0
15687 ELSEIF ( iehw .eq. 1 .or. iehw .eq. 10 ) THEN
15688 cwrad = 0.5*xdia(mgs,lc,1)
15689 ehw(mgs) = Min( ehw0, &
15690 & ewfac*min((aradcw + cwrad*(bradcw + cwrad* &
15691 & (cradcw + cwrad*(dradcw)))), 1.0) )
15693 ELSEIF ( iehw .eq. 2 .or. iehw .eq. 10 ) THEN
15695 icp1 = Min( 8, ic+1 )
15697 irp1 = Min( 6, ir+1 )
15698 cwrad = 0.5*xdia(mgs,lc,1)
15699 rwrad = 0.5*xdia(mgs,lh,3) ! changed to mean volume diameter
15701 slope1 = (ew(icp1, ir ) - ew(ic,ir ))*cwr(ic,2)
15702 slope2 = (ew(icp1, irp1) - ew(ic,irp1))*cwr(ic,2)
15704 ! write(iunit,*) 'slop1: ',slope1,slope2,ew(ic,ir),cwr(ic,2)
15706 x1 = ew(ic, ir) + slope1*Max(0.0, (cwrad - cwr(ic,1)) )
15707 x2 = ew(icp1,ir) + slope2*Max(0.0, (cwrad - cwr(ic,1)) )
15709 slope1 = (x2 - x1)*grad(ir,2)
15711 tmp = Max( 0.0, Min( 1.0, x1 + slope1*Max(0.0, (rwrad - grad(ir,1)) ) ) )
15712 ehw(mgs) = Min( ehw(mgs), tmp )
15714 ! write(iunit,*) 'ehw: ',ehw(mgs),1.e6*cwrad,1.e6*rwrad,ic,ir,x1,x2
15717 ! ehw(mgs) = Max( 0.2, ehw(mgs) )
15718 ! assume that ehw = 1 for zero air resistance (rho0 = 0.0) and extrapolate toward that
15719 ! ehw(mgs) = ehw(mgs) + (ehw(mgs) - 1.0)*(rho0(mgs) - rho00)/rho00
15720 ! ehw(mgs) = ehw(mgs) + (1.0 - ehw(mgs))*((Max(0.0,rho00 - rho0(mgs)))/rho00)**2
15722 ELSEIF ( iehw .eq. 3 .or. iehw .eq. 10 ) THEN ! use fraction of droplets greater than dmincw diameter
15723 tmp = Exp(- (dmincw/xdia(mgs,lc,1))**3)
15724 xmascw(mgs) = xmas(mgs,lc) + xdn0(lc)*(pi*dmincw**3/6.0) ! this is the average mass of the droplets with d > dmincw
15725 ehw(mgs) = Min( ehw(mgs), tmp )
15726 ELSEIF ( iehw .eq. 4 .or. iehw .eq. 10 ) THEN ! Cober and List 1993, eq. 19-20
15728 & 2.0*xdn(mgs,lc)*vtxbar(mgs,lh,1)*(0.5*xdia(mgs,lc,1))**2 &
15729 & /(9.0*fadvisc(mgs)*0.5*xdia(mgs,lh,3))
15730 tmp = Max( 1.5, Min(10.0, tmp) )
15731 ehw(mgs) = Min( ehw(mgs), 0.55*Log10(2.51*tmp) )
15733 if ( xdia(mgs,lc,1) .lt. 2.4e-06 ) ehw(mgs)=0.0
15735 ehw(mgs) = Min( ehw0, ehw(mgs) )
15737 IF ( ibfc == -1 .and. temcg(mgs) < -41.0 ) THEN
15743 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lr).gt.qxmin(lr) &
15744 ! & .and. temg(mgs) .lt. tfr &
15746 ! ehr(mgs) = Exp(-(40.e-6)**3/xv(mgs,lr))*Exp(-40.e-6/xdia(mgs,lh,1))
15748 ehr(mgs) = Exp(-(40.e-6)/xdia(mgs,lr,3))*Exp(-40.e-6/xdia(mgs,lh,3))
15749 ehr(mgs) = Min( ehr0, ehr(mgs) )
15752 IF ( qx(mgs,ls).gt.qxmin(ls) ) THEN
15753 IF ( ipconc .ge. 4 ) THEN
15754 ehscnv(mgs) = ehs0*exp(ehs1*min(temcg(mgs),0.0)) ! for 2-moment, used as default for ehs and ehls. Otherwise not used for snow->graupel conversion
15756 ehscnv(mgs) = exp(0.09*min(temcg(mgs),0.0))
15759 IF ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lc) >= qxmin(lc) ) THEN
15760 ! ehsclsn(mgs) = ehs_collsn
15761 ! ehs(mgs) = ehscnv(mgs)*ehsfac(mgs)*Min(1.0, Max(0.0,xdn(mgs,lh) - 300.)/300. )
15762 ! ELSEIF ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lc) >= qxmin(lc) ) then
15763 ehsclsn(mgs) = ehs_collsn
15764 IF ( xdia(mgs,ls,3) < 40.e-6 ) THEN
15766 ELSEIF ( xdia(mgs,ls,3) < 150.e-6 ) THEN
15767 ehsclsn(mgs) = ehs_collsn*(xdia(mgs,ls,3) - 40.e-6)/(150.e-6 - 40.e-6)
15769 ehsclsn(mgs) = ehs_collsn
15771 ! ehs(mgs) = ehscnv(mgs)*Min(1.0, Max(0., xdn(mgs,lh) - xdnmn(lh)*1.2)/xdnmn(lh) ) ! shut off qhacs as graupel goes to lowest density
15772 ehs(mgs) = ehscnv(mgs)*Min(1.0, Max(0.0,xdn(mgs,lh) - 300.)/300. ) ! shut off qhacs as graupel goes to low density; limits scavenging of snow in bright band
15773 ! ehs(mgs) = ehscnv(mgs) ! *Min(1.0, Max(0.0,xdn(mgs,lh) - 300.)/300. ) ! shut off qhacs as graupel goes to low density
15774 ehs(mgs) = Min(ehs(mgs),ehsmax)
15778 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,li).gt.qxmin(li) ) then
15779 ehiclsn(mgs) = ehi_collsn
15780 ehi(mgs)=eii0*exp(eii1*min(temcg(mgs),0.0))
15781 ehi(mgs) = Min( ehimax, Max( ehi(mgs), ehimin ) )
15782 ! if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehi(mgs) = 0.0
15785 IF ( lis > 1 ) THEN
15786 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lis).gt.qxmin(lis) ) then
15787 ehisclsn(mgs) = ehi_collsn
15788 ehis(mgs)=eii0*exp(eii1*min(temcg(mgs),0.0))
15789 ehis(mgs) = Min( ehimax, Max( ehis(mgs), ehimin ) )
15790 ! if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehis(mgs) = 0.0
15797 ! Hail: Collection (cxc) efficiencies
15800 IF ( lhl .gt. 1 ) THEN
15802 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,lc).gt.qxmin(lc) ) then
15803 IF ( iehw == 3 ) iehlw = 3
15804 IF ( iehw == 4 ) iehlw = 4
15806 IF ( iehlw .eq. 0 ) THEN
15807 ehlw(mgs) = ehlw0 ! default value is 1.0
15808 ELSEIF ( iehlw .eq. 1 .or. iehlw .eq. 10 ) THEN
15809 cwrad = 0.5*xdia(mgs,lc,1)
15810 ehlw(mgs) = Min( ehlw0, &
15811 & ewfac*min((aradcw + cwrad*(bradcw + cwrad* &
15812 & (cradcw + cwrad*(dradcw)))), 1.0) )
15814 ELSEIF ( iehlw .eq. 2 .or. iehlw .eq. 10 ) THEN
15816 icp1 = Min( 8, ic+1 )
15818 irp1 = Min( 6, ir+1 )
15819 cwrad = 0.5*xdia(mgs,lc,1)
15820 rwrad = 0.5*xdia(mgs,lhl,3) ! changed to mean volume diameter
15822 slope1 = (ew(icp1, ir ) - ew(ic,ir ))*cwr(ic,2)
15823 slope2 = (ew(icp1, irp1) - ew(ic,irp1))*cwr(ic,2)
15825 x1 = ew(ic, ir) + slope1*(cwrad - cwr(ic,1))
15826 x2 = ew(icp1,ir) + slope2*(cwrad - cwr(ic,1))
15828 slope1 = (x2 - x1)*grad(ir,2)
15830 tmp = Max( 0.0, Min( 1.0, x1 + slope1*(rwrad - grad(ir,1)) ) )
15831 ehlw(mgs) = Min( ehlw(mgs), tmp )
15832 ehlw(mgs) = Min( ehlw0, ehlw(mgs) )
15833 ! ehw(mgs) = Max( 0.2, ehw(mgs) )
15834 ! assume that ehw = 1 for zero air resistance (rho0 = 0.0) and extrapolate toward that
15835 ! ehw(mgs) = ehw(mgs) + (ehw(mgs) - 1.0)*(rho0(mgs) - rho00)/rho00
15836 ! ehlw(mgs) = ehlw(mgs) + (1.0 - ehlw(mgs))*((Max(0.0,rho00 - rho0(mgs)))/rho00)**2
15838 ELSEIF ( iehlw .eq. 3 .or. iehlw .eq. 10 ) THEN ! use fraction of droplets greater than 15 micron diameter
15839 tmp = Exp(- (dmincw/xdia(mgs,lc,1))**3)
15840 ehlw(mgs) = Min( ehlw(mgs), tmp )
15841 ELSEIF ( iehlw .eq. 4 .or. iehlw .eq. 10 ) THEN ! Cober and List 1993
15843 & 2.0*xdn(mgs,lc)*vtxbar(mgs,lhl,1)*(0.5*xdia(mgs,lc,1))**2 &
15844 & /(9.0*fadvisc(mgs)*0.5*xdia(mgs,lhl,3))
15845 tmp = Max( 1.5, Min(10.0, tmp) )
15846 ehlw(mgs) = Min( ehlw(mgs), 0.55*Log10(2.51*tmp) )
15848 if ( xdia(mgs,lc,1) .lt. 2.4e-06 ) ehlw(mgs)=0.0
15849 ehlw(mgs) = Min( ehlw0, ehlw(mgs) )
15851 IF ( ibfc == -1 .and. temcg(mgs) < -41.0 ) THEN
15857 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,lr).gt.qxmin(lr) &
15858 ! & .and. temg(mgs) .lt. tfr &
15861 ehlr(mgs) = Min( ehlr0, ehlr(mgs) )
15864 IF ( qx(mgs,ls).gt.qxmin(ls) ) THEN
15865 if ( qx(mgs,lhl).gt.qxmin(lhl) ) then
15866 ehlsclsn(mgs) = ehls_collsn
15867 ehls(mgs) = ehscnv(mgs)
15868 ehls(mgs) = Min(ehls(mgs),ehsmax)
15872 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,li).gt.qxmin(li) ) then
15873 ehliclsn(mgs) = ehli_collsn
15874 ehli(mgs)=eii0hl*exp(eii1hl*min(temcg(mgs),0.0))
15875 ehli(mgs) = Min( ehimax, Max( ehli(mgs), ehimin ) )
15876 if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehli(mgs) = 0.0
15879 IF ( lis > 1 ) THEN
15880 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,lis).gt.qxmin(lis) ) then
15881 ehlisclsn(mgs) = ehli_collsn
15882 ehlis(mgs)=eii0*exp(eii1*min(temcg(mgs),0.0))
15883 ehlis(mgs) = Min( ehimax, Max( ehlis(mgs), ehimin ) )
15884 if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehlis(mgs) = 0.0
15891 ENDDO ! mgs loop for collection efficiencies
15896 ! Set flags for plates vs. columns
15904 ! if ( temcg(mgs) .lt. 0. .and. temcg(mgs) .ge. -4. ) then
15905 ! xplate(mgs) = 1.0
15906 ! xcolmn(mgs) = 0.0
15909 ! if ( temcg(mgs) .lt. -4. .and. temcg(mgs) .ge. -9. ) then
15910 ! xplate(mgs) = 0.0
15911 ! xcolmn(mgs) = 1.0
15914 ! if ( temcg(mgs) .lt. -9. .and. temcg(mgs) .ge. -22.5 ) then
15915 ! xplate(mgs) = 1.0
15916 ! xcolmn(mgs) = 0.0
15919 ! if ( temcg(mgs) .lt. -22.5 .and. temcg(mgs) .ge. -90. ) then
15920 ! xplate(mgs) = 0.0
15921 ! xcolmn(mgs) = 1.0
15931 ! Collection growth equations....
15934 if (ndebug .gt. 0 ) write(0,*) 'Collection: rain collects xxxxx'
15938 IF ( qx(mgs,lr) .gt. qxmin(lr) .and. erw(mgs) .gt. 0.0 ) THEN
15939 IF ( ipconc .lt. 3 ) THEN
15940 IF ( erw(mgs) .gt. 0.0 .and. qx(mgs,lr) .gt. 1.e-7 ) THEN
15941 vt = (ar*(xdia(mgs,lc,1)**br))*rhovt(mgs)
15943 & (0.25)*pi*erw(mgs)*(qx(mgs,lc)-qcwresv(mgs))*cx(mgs,lr) &
15944 ! > *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,lc,1)) &
15945 & *Max(0.0, vtxbar(mgs,lr,1)-vt) &
15946 & *( gf3*xdia(mgs,lr,2) &
15947 & + 2.0*gf2*xdia(mgs,lr,1)*xdia(mgs,lc,1) &
15948 & + gf1*xdia(mgs,lc,2) )
15950 ! write(iunit,*) 'qracw,cx =',qracw(mgs),1.e6*xdia(mgs,lr,1),erw(mgs)
15951 ! write(iunit,*) 'qracw,cx =',qracw(mgs),cx(mgs,lc),kgs(mgs),cx(mgs,lr),1.e6*xdia(mgs,lr,1),vtxbar(mgs,lr,1),vt
15952 ! write(iunit,*) 'vtr: ',vtxbar(mgs,lr,1), ar*gf4br/6.0*xdia(mgs,lr,1)**br, rhovt(mgs),
15953 ! : ar*gf4br/6.0*xdia(mgs,lr,1)**br * rhovt(mgs)
15957 IF ( dmrauto <= 0 .or. rho0(mgs)*qx(mgs,lr) > 1.2*xl2p(mgs) ) THEN
15958 rwrad = 0.5*xdia(mgs,lr,3)
15959 IF ( rwrad .gt. rh(mgs) ) THEN ! .or. cx(mgs,lr) .gt. nh(mgs) ) THEN
15960 IF ( rwrad .gt. rwradmn ) THEN
15961 ! DM1CCC=A2*XNC*XNR*XVC*(((CNU+2.)/(CNU+1.))*XVC+XVR) ! (A12)
15962 ! NOTE: Result is independent of imurain, assumes mucloud = 3
15963 qracw(mgs) = erw(mgs)*aa2*cx(mgs,lr)*cx(mgs,lc)*xmas(mgs,lc)* &
15964 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)/(alpha(mgs,lc) + 1.) + xv(mgs,lr))/rho0(mgs) !*rhoinv(mgs)
15967 IF ( imurain == 3 ) THEN
15969 ! DM1CCC=A1*XNC*XNR*(((CNU+3.)*(CNU+2.)/(CNU+1.)**2)*XVC**3+ ! (A14)
15970 ! 1 ((RNU+2.)/(RNU+1.))*XVC*XVR**2)
15972 ! qracw(mgs) = aa1*cx(mgs,lr)*cx(mgs,lc)*xdn(mgs,lc)* &
15973 ! & ((cnu + 3.)*(cnu + 2.)*xv(mgs,lc)**3/(cnu + 1.)**2 + &
15974 ! & (alpha(mgs,lr) + 2.)*xv(mgs,lc)*xv(mgs,lr)**2/(alpha(mgs,lr) + 1.))/rho0(mgs) !*rhoinv(mgs)
15975 ! save multiplies by converting cx*xdn*xv/rho0 to qx
15976 qracw(mgs) = aa1*cx(mgs,lr)*(qx(mgs,lc)-qcwresv(mgs))* &
15977 & ((alpha(mgs,lc) + 3.)*(alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.)**2 + &
15978 & (alpha(mgs,lr) + 2.)*xv(mgs,lr)**2/(alpha(mgs,lr) + 1.))
15980 ELSE ! imurain == 1
15982 qracw(mgs) = aa1*cx(mgs,lr)*(qx(mgs,lc)-qcwresv(mgs))* &
15983 & ((alpha(mgs,lc) + 3.)*(alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.)**2 + &
15984 & (alpha(mgs,lr) + 6.)*(alpha(mgs,lr) + 5.)*(alpha(mgs,lr) + 4.)*xv(mgs,lr)**2/ &
15985 & ((alpha(mgs,lr) + 3.)*(alpha(mgs,lr) + 2.)*(alpha(mgs,lr) + 1.)))
15993 ! qracw(mgs) = Min(qracw(mgs), qx(mgs,lc))
15994 qracw(mgs) = Min(qracw(mgs), qcmxd(mgs))
16002 IF ( eri(mgs) .gt. 0.0 .and. iacr .ge. 1 .and. xdia(mgs,lr,3) .gt. 2.*rwradmn ) THEN
16003 IF ( ipconc .ge. 3 ) THEN
16005 tmp = eri(mgs)*aa2*cx(mgs,lr)*cx(mgs,li)* &
16006 & ((cinu + 2.)*xv(mgs,li)/(cinu + 1.) + xv(mgs,lr))
16008 qraci(mgs) = Min( qxmxd(mgs,li), tmp*xmas(mgs,li)*rhoinv(mgs) )
16009 craci(mgs) = Min( cxmxd(mgs,li), tmp )
16011 ! vt = Sqrt((vtxbar(mgs,lr,1)-vtxbar(mgs,li,1))**2 +
16012 ! : 0.04*vtxbar(mgs,lr,1)*vtxbar(mgs,li,1) )
16014 ! qraci(mgs) = 0.25*pi*eri(mgs)*cx(mgs,lr)*qx(mgs,li)*vt*
16015 ! : ( da0(lr)*xdia(mgs,lr,3)**2 +
16016 ! : dab1(lr,li)*xdia(mgs,lr,3)*xdia(mgs,li,3) +
16017 ! : da1(li)*xdia(mgs,li,3)**2 )
16020 ! vt = Sqrt((vtxbar(mgs,lr,1)-vtxbar(mgs,li,1))**2 +
16021 ! : 0.04*vtxbar(mgs,lr,1)*vtxbar(mgs,li,1) )
16023 ! craci(mgs) = 0.25*pi*eri(mgs)*cx(mgs,lr)*cx(mgs,li)*vt*
16024 ! : ( da0(lr)*xdia(mgs,lr,3)**2 +
16025 ! : dab0(lr,li)*xdia(mgs,lr,3)*xdia(mgs,li,3) +
16026 ! : da0(li)*xdia(mgs,li,3)**2 )
16028 ! qraci(mgs) = Min( qraci(mgs), qxmxd(mgs,li) )
16029 ! craci(mgs) = Min( craci(mgs), cxmxd(mgs,li) )
16034 & (0.25)*pi*eri(mgs)*qx(mgs,li)*cx(mgs,lr) &
16035 & *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,li,1)) &
16036 & *( gf3*xdia(mgs,lr,2) &
16037 & + 2.0*gf2*xdia(mgs,lr,1)*xdia(mgs,li,1) &
16038 & + gf1*xdia(mgs,li,2) ) &
16041 if ( temg(mgs) .gt. 268.15 ) then
16047 IF ( ipconc < 3 ) THEN
16050 IF ( ers(mgs) .gt. 0.0 .and. ipconc < 3 ) THEN
16051 IF ( lwsm6 .and. ipconc == 0 ) THEN
16054 vt = vtxbar(mgs,ls,1)
16058 & ((0.25)*pi/gf4)*ers(mgs)*qx(mgs,ls)*cx(mgs,lr) &
16059 & *abs(vtxbar(mgs,lr,1)-vt) &
16060 & *( gf6*gf1*xdia(mgs,ls,2) &
16061 & + 2.0*gf5*gf2*xdia(mgs,ls,1)*xdia(mgs,lr,1) &
16062 & + gf4*gf3*xdia(mgs,lr,2) ) &
16070 if (ndebug .gt. 0 ) write(0,*) 'Collection: snow collects xxxxx'
16076 IF ( esw(mgs) .gt. 0.0 ) THEN
16078 IF ( ipconc .ge. 4 ) THEN
16079 ! QSACC=CECS*RVT*A2*XNC*XNS*XVC*ROS*
16080 ! * (((CNU+2.)/(CNU+1.))*XVC+XVS)/RO
16082 ! tmp = esw(mgs)*rvt*aa2*cx(mgs,ls)*cx(mgs,lc)*
16083 ! : ((cnu + 2.)*xv(mgs,lc)/(cnu + 1.) + xv(mgs,ls))
16084 tmp = 1.0*rvt*aa2*cx(mgs,ls)*cx(mgs,lc)* &
16085 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)/(alpha(mgs,lc) + 1.) + xv(mgs,ls))
16087 qsacw(mgs) = Min( qxmxd(mgs,lc), tmp*xmas(mgs,lc)*rhoinv(mgs) )
16088 csacw(mgs) = Min( cxmxd(mgs,lc), tmp )
16090 IF ( lvol(ls) .gt. 1 ) THEN
16091 IF ( temg(mgs) .lt. 273.15) THEN
16092 rimdn(mgs,ls) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16093 & *((0.60)*vtxbar(mgs,ls,1)) &
16094 & /(temg(mgs)-273.15))**(rimc2)
16095 rimdn(mgs,ls) = Min( Max( rimc3, rimdn(mgs,ls) ), rimc4 )
16097 rimdn(mgs,ls) = 1000.
16100 vsacw(mgs) = rho0(mgs)*qsacw(mgs)/rimdn(mgs,ls)
16105 ! qsacw(mgs) = cecs*aa2*cx(mgs,ls)*cx(mgs,lc)*xmas(mgs,lc)*
16106 ! : ((alpha(mgs,lc) + 2.)*xv(mgs,lc)/(alpha(mgs,lc) + 1.) + xv(mgs,ls))*rhoinv(mgs)
16110 ! > ((0.25)*pi)*esw(mgs)*qx(mgs,lc)*cx(mgs,ls)
16111 ! > *abs(vtxbar(mgs,ls,1)-vtxbar(mgs,lc,1))
16112 ! > *( gf3*xdia(mgs,ls,2)
16113 ! > + 2.0*gf2*xdia(mgs,ls,1)*xdia(mgs,lc,1)
16114 ! > + gf1*xdia(mgs,lc,2) )
16117 vt = abs(vtxbar(mgs,ls,1)-vtxbar(mgs,lc,1))
16119 qsacw(mgs) = 0.25*pi*esw(mgs)*cx(mgs,ls)*qx(mgs,lc)*vt* &
16120 & ( da0(ls)*xdia(mgs,ls,3)**2 + &
16121 & dab1(ls,lc)*xdia(mgs,ls,3)*xdia(mgs,lc,3) + &
16122 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
16123 qsacw(mgs) = Min( qsacw(mgs), qxmxd(mgs,ls) )
16124 csacw(mgs) = rho0(mgs)*qsacw(mgs)/xmas(mgs,lc)
16134 IF ( ipconc .ge. 4 ) THEN
16135 IF ( esi(mgs) .gt. 0.0 .or. ( ipelec > 0 .and. esiclsn(mgs) > 0.0 )) THEN
16136 ! QSCOI=CEXS*RVT*A2*XNCI*XNS*XVCI*ROS*
16137 ! * (((CINU+2.)/(CINU+1.))*VCIP+XVS)/RO
16139 tmp = esiclsn(mgs)*rvt*aa2*cx(mgs,ls)*cx(mgs,li)* &
16140 & ((cinu + 2.)*xv(mgs,li)/(cinu + 1.) + xv(mgs,ls))
16142 qsaci(mgs) = Min( qxmxd(mgs,li), esi(mgs)*tmp*xmas(mgs,li)*rhoinv(mgs) )
16144 csaci(mgs) = Min(cxmxd(mgs,li), esi(mgs)*tmp )
16148 ! > ((0.25)*pi)*esi(mgs)*qx(mgs,li)*cx(mgs,ls)
16149 ! > *abs(vtxbar(mgs,ls,1)-vtxbar(mgs,li,1))
16150 ! > *( gf3*xdia(mgs,ls,2)
16151 ! > + 2.0*gf2*xdia(mgs,ls,1)*xdia(mgs,li,1)
16152 ! > + gf1*xdia(mgs,li,2) )
16156 IF ( esi(mgs) .gt. 0.0 ) THEN
16159 & ((0.25)*pi)*esi(mgs)*qx(mgs,li)*cx(mgs,ls) &
16160 & *abs(vtxbar(mgs,ls,1)-vtxbar(mgs,li,1)) &
16161 & *( gf3*xdia(mgs,ls,2) &
16162 & + 2.0*gf2*xdia(mgs,ls,1)*xdia(mgs,li,1) &
16163 & + gf1*xdia(mgs,li,2) ) &
16175 IF ( esr(mgs) .gt. 0.0 ) THEN
16176 IF ( ipconc .ge. 3 ) THEN
16177 ! vt = Sqrt((vtxbar(mgs,ls,1)-vtxbar(mgs,lr,1))**2 +
16178 ! : 0.04*vtxbar(mgs,ls,1)*vtxbar(mgs,lr,1) )
16179 ! qsacr(mgs) = esr(mgs)*cx(mgs,ls)*vt*
16180 ! : qx(mgs,lr)*0.25*pi*
16181 ! : (3.02787*xdia(mgs,lr,2) +
16182 ! : 3.30669*xdia(mgs,ls,1)*xdia(mgs,lr,1) +
16183 ! : 2.*xdia(mgs,ls,2))
16184 ! qsacr(mgs) = Min( qsacr(mgs), qrmxd(mgs) )
16185 ! csacr(mgs) = qsacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
16186 ! csacr(mgs) = min(csacr(mgs),crmxd(mgs))
16188 IF ( lwsm6 .and. ipconc == 0 ) THEN
16191 vt = vtxbar(mgs,ls,1)
16196 & ((0.25)*pi/gf4)*esr(mgs)*qx(mgs,lr)*cx(mgs,ls) &
16197 & *abs(vtxbar(mgs,lr,1)-vt) &
16198 & *( gf6*gf1*xdia(mgs,lr,2) &
16199 & + 2.0*gf5*gf2*xdia(mgs,lr,1)*xdia(mgs,ls,1) &
16200 & + gf4*gf3*xdia(mgs,ls,2) ) &
16209 if (ndebug .gt. 0 ) write(0,*) 'Collection: graupel collects xxxxx'
16213 qhacwmlr(mgs) = 0.0
16219 IF ( .false. ) THEN
16220 vtmax = (gz(igs(mgs),jgs,kgs(mgs))*dtpinv)
16221 vtxbar(mgs,lh,1) = Min( vtmax, vtxbar(mgs,lh,1))
16222 vtxbar(mgs,lh,2) = Min( vtmax, vtxbar(mgs,lh,2))
16223 vtxbar(mgs,lh,3) = Min( vtmax, vtxbar(mgs,lh,3))
16225 IF ( ehw(mgs) .gt. 0.0 ) THEN
16227 IF ( ipconc .ge. 2 ) THEN
16229 IF ( .false. ) THEN
16230 qhacw(mgs) = (ehw(mgs)*(qx(mgs,lc)-qcwresv(mgs))*cx(mgs,lh)*pi* &
16231 & abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1))* &
16232 & (2.0*xdia(mgs,lh,1)*(xdia(mgs,lh,1) + &
16233 & xdia(mgs,lc,1)*gf73rds) + &
16234 & xdia(mgs,lc,2)*gf83rds))/4.
16236 ELSE ! using Seifert coefficients
16237 vt = abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1))
16239 qhacw(mgs) = 0.25*pi*ehw(mgs)*cx(mgs,lh)*(qx(mgs,lc)-qcwresv(mgs))*vt* &
16240 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16241 & dab1lh(mgs,lh,lc)*xdia(mgs,lh,3)*xdia(mgs,lc,3) + &
16242 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
16245 qhacw(mgs) = Min( qhacw(mgs), 0.5*qx(mgs,lc)*dtpinv )
16247 IF ( lzh .gt. 1 ) THEN
16248 tmp = qx(mgs,lh)/cx(mgs,lh)
16250 !! g1 = (6.0 + alpha(mgs,lh))*(5.0 + alpha(mgs,lh))*(4.0 + alpha(mgs,lh))/
16251 !! : ((3.0 + alpha(mgs,lh))*(2.0 + alpha(mgs,lh))*(1.0 + alpha(mgs,lh)))
16252 ! alp = Max( 1.0, alpha(mgs,lh)+1. )
16253 ! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/
16254 ! : ((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
16255 ! zhacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacw(mgs) )
16261 & ((0.25)*pi)*ehw(mgs)*(qx(mgs,lc)-qcwresv(mgs))*cx(mgs,lh) &
16262 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1)) &
16263 & *( gf3*xdia(mgs,lh,2) &
16264 & + 2.0*gf2*xdia(mgs,lh,1)*xdia(mgs,lc,1) &
16265 & + gf1*xdia(mgs,lc,2) ) &
16266 & , 0.5*(qx(mgs,lc)-qcwresv(mgs))*dtpinv)
16267 ! < , qxmxd(mgs,lc))
16271 IF ( lwsm6 .and. qsacw(mgs) > 0.0 .and. qhacw(mgs) > 0.0) THEN
16272 qaacw = ( qx(mgs,ls)*qsacw(mgs) + qx(mgs,lh)*qhacw(mgs) )/(qx(mgs,ls) + qx(mgs,lh))
16273 ! qaacw = Min( qaacw, 0.5*(qsacw(mgs) + qhacw(mgs) ) )
16280 qhacwmlr(mgs) = qhacw(mgs)
16281 IF ( temg(mgs) > tfr .and. iqhacwshr == 0 ) THEN
16285 IF ( lvol(lh) .gt. 1 .or. lhl .gt. 1 ) THEN ! calculate rime density for graupel volume and/or for graupel conversion to hail
16287 IF ( temg(mgs) .lt. 273.15) THEN
16288 IF ( irimdenopt == 1 ) THEN ! Heymsfield and Pflaum (1985)
16289 vt = ( (1.0-rimdenvwgt)*vtxbar(mgs,lh,1) + rimdenvwgt*vtxbar(mgs,lh,2) )
16291 rimdn(mgs,lh) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16293 & /(temg(mgs)-273.15))**(rimc2)
16294 ! rimdn(mgs,lh) = Min( Max( hdnmn, rimc3, rimdn(mgs,lh) ), rimc4 )
16295 rimdn(mgs,lh) = Min( Max( rimc3, rimdn(mgs,lh) ), rimc4 )
16297 ! IF ( igs(mgs) == 30 ) THEN
16298 ! write(0,*) 'k,vt: ',kgs(mgs),vt, vtxbar(mgs,lh,1),vtxbar(mgs,lh,2), rhovt(mgs)*axx(mgs,lh)*( (alpha(mgs,lh)+3.)*xdia(mgs,lh,1) )**bxx(mgs,lh)
16299 ! write(0,*) 'diam: char, mean, maxmass = ',xdia(mgs,lh,1),xdia(mgs,lh,3),(alpha(mgs,lh)+3.)*xdia(mgs,lh,1)
16300 ! write(0,*) 'ax,bx,cd,xdn = ',axx(mgs,lh),bxx(mgs,lh),cdxgs(mgs,lh),xdn(mgs,lh)
16301 ! write(0,*) 'vt_char,vt_mean = ',rhovt(mgs)*axx(mgs,lh)*( xdia(mgs,lh,1) )**bxx(mgs,lh),rhovt(mgs)*axx(mgs,lh)*( xdia(mgs,lh,3) )**bxx(mgs,lh)
16302 ! write(0,*) 'rimdn,alpha = ',rimdn(mgs,lh),alpha(mgs,lh)
16305 ELSEIF ( irimdenopt == 2 ) THEN ! Cober and List (1993)
16307 tmp = (-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16308 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lh,1) + rimdenvwgt*vtxbar(mgs,lh,2) ) &
16309 & /(temg(mgs)-273.15))
16310 tmp = Min( 5.5/0.6, Max( 0.3/0.6, tmp ) ) ! have to limit range of "R" because quadratic function starts to decrease (unphysically) at higher values
16312 rimdn(mgs,lh) = 1000.*(0.051 + 0.114*tmp - 0.0055*tmp**2)
16314 ELSEIF ( irimdenopt == 3 .or. irimdenopt == 4) THEN ! Macklin (3) or Saunders and Hosseini 2001
16316 tmp = (-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16317 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lh,1) + rimdenvwgt*vtxbar(mgs,lh,2) ) &
16318 & /(temg(mgs)-273.15))
16319 ! tmp = Min( 5.5/0.6, Max( 0.3/0.6, tmp ) )
16321 IF ( irimdenopt == 3 ) THEN
16322 rimdn(mgs,lh) = Min(900., Max( 170., 110.*tmp**0.76 ) )
16323 ELSEIF ( irimdenopt == 4 ) THEN ! Saunders and Hosseini
16324 rimdn(mgs,lh) = Min(917., Max( 10., 900.0*(1.0 - 0.905**tmp ) ) )
16329 rimdn(mgs,lh) = 1000.
16332 IF ( lvol(lh) > 1 ) vhacw(mgs) = rho0(mgs)*qhacw(mgs)/rimdn(mgs,lh)
16336 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. ipelec .ge. 1 ) THEN
16338 & qhacw(mgs)*1.0e3*rho0(mgs)/((pi/2.0)*xdia(mgs,lh,2)*cx(mgs,lh))
16348 IF ( ehi(mgs) .gt. 0.0 ) THEN
16349 IF ( ipconc .ge. 5 ) THEN
16351 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,li,1))**2 + &
16352 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,li,1) )
16354 qhaci0(mgs) = 0.25*pi*ehiclsn(mgs)*cx(mgs,lh)*qx(mgs,li)*vt* &
16355 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16356 & dab1lh(mgs,lh,li)*xdia(mgs,lh,3)*xdia(mgs,li,3) + &
16357 & da1(li)*xdia(mgs,li,3)**2 )
16358 qhaci(mgs) = Min( ehi(mgs)*qhaci0(mgs), qimxd(mgs) )
16362 & ((0.25)*pi)*ehi(mgs)*ehiclsn(mgs)*qx(mgs,li)*cx(mgs,lh) &
16363 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,li,1)) &
16364 & *( gf3*xdia(mgs,lh,2) &
16365 & + 2.0*gf2*xdia(mgs,lh,1)*xdia(mgs,li,1) &
16366 & + gf1*xdia(mgs,li,2) ) &
16373 IF ( lis > 1 .and. ipconc >= 5 ) THEN
16377 IF ( ehis(mgs) .gt. 0.0 ) THEN
16379 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,lis,1))**2 + &
16380 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,lis,1) )
16382 qhacis0(mgs) = 0.25*pi*ehisclsn(mgs)*cx(mgs,lh)*qx(mgs,lis)*vt* &
16383 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16384 & dab1lh(mgs,lh,lis)*xdia(mgs,lh,3)*xdia(mgs,lis,3) + &
16385 & da1(li)*xdia(mgs,lis,3)**2 )
16386 qhacis(mgs) = Min( ehis(mgs)*qhacis0(mgs), qxmxd(mgs,lis) )
16396 IF ( ehs(mgs) .gt. 0.0 ) THEN
16397 IF ( ipconc .ge. 5 ) THEN
16399 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1))**2 + &
16400 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,ls,1) )
16402 qhacs0(mgs) = 0.25*pi*ehsclsn(mgs)*cx(mgs,lh)*qx(mgs,ls)*vt* &
16403 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16404 & dab1lh(mgs,lh,ls)*xdia(mgs,lh,3)*xdia(mgs,ls,3) + &
16405 & da1(ls)*xdia(mgs,ls,3)**2 )
16407 qhacs(mgs) = Min( ehs(mgs)*qhacs0(mgs), qsmxd(mgs) )
16412 & ((0.25)*pi/gf4)*ehs(mgs)*ehsclsn(mgs)*qx(mgs,ls)*cx(mgs,lh) &
16413 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1)) &
16414 & *( gf6*gf1*xdia(mgs,ls,2) &
16415 & + 2.0*gf5*gf2*xdia(mgs,ls,1)*xdia(mgs,lh,1) &
16416 & + gf4*gf3*xdia(mgs,lh,2) ) &
16424 qhacrmlr(mgs) = 0.0
16428 IF ( temg(mgs) .gt. tfr ) raindn(mgs,lh) = 1000.0
16430 IF ( ehr(mgs) .gt. 0.0 ) THEN
16431 IF ( ipconc .ge. 3 ) THEN
16432 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,lr,1))**2 + &
16433 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,lr,1) )
16434 ! qhacr(mgs) = ehr(mgs)*cx(mgs,lh)*vt*
16435 ! : qx(mgs,lr)*0.25*pi*
16436 ! : (3.02787*xdia(mgs,lr,2) +
16437 ! : 3.30669*xdia(mgs,lh,1)*xdia(mgs,lr,1) +
16438 ! : 2.*xdia(mgs,lh,2))
16440 qhacr(mgs) = 0.25*pi*ehr(mgs)*cx(mgs,lh)*qx(mgs,lr)*vt* &
16441 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16442 & dab1lh(mgs,lh,lr)*xdia(mgs,lh,3)*xdia(mgs,lr,3) + &
16443 & da1lr(mgs)*xdia(mgs,lr,3)**2 )
16444 ! & da1(lr)*xdia(mgs,lr,3)**2 )
16445 ! IF ( qhacr(mgs) .gt. 0. .or. tmp .gt. 0.0 ) write(0,*) 'qhacr= ',qhacr(mgs),tmp
16446 !! qhacr(mgs) = Min( qhacr(mgs), qrmxd(mgs) )
16447 !! chacr(mgs) = qhacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
16448 !! chacr(mgs) = min(chacr(mgs),crmxd(mgs))
16450 qhacr(mgs) = Min( qhacr(mgs), qxmxd(mgs,lr) )
16452 qhacrmlr(mgs) = qhacr(mgs)
16454 IF ( temg(mgs) > tfr .and. iehr0c == 0 ) THEN
16457 IF ( iqhacrmlr == 0 ) THEN
16458 qhacrmlr(mgs) = -qhacw(mgs)
16462 ! chacr(mgs) = Min( qhacr(mgs)*rho0(mgs)/xmas(mgs,lr), cxmxd(mgs,lr) )
16464 ! chacr(mgs) = ehr(mgs)*cx(mgs,lh)*vt*
16465 ! : cx(mgs,lr)*0.25*pi*
16466 ! : (0.69874*xdia(mgs,lr,2) +
16467 ! : 1.24001*xdia(mgs,lh,1)*xdia(mgs,lr,1) +
16468 ! : 2.*xdia(mgs,lh,2))
16470 chacr(mgs) = 0.25*pi*ehr(mgs)*cx(mgs,lh)*cx(mgs,lr)*vt* &
16471 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16472 & dab0lh(mgs,lh,lr)*xdia(mgs,lh,3)*xdia(mgs,lr,3) + &
16473 & da0lr(mgs)*xdia(mgs,lr,3)**2 )
16475 ! IF ( qhacr(mgs) .gt. 0. .or. tmp .gt. 0.0 ) write(0,*) 'chacr= ',chacr(mgs),tmp
16477 ! chacr(mgs) = qhacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
16478 chacr(mgs) = min(chacr(mgs),crmxd(mgs))
16480 IF ( lzh .gt. 1 ) THEN
16481 tmp = qx(mgs,lh)/cx(mgs,lh)
16483 ! g1 = (6.0 + alpha(mgs,lh))*(5.0 + alpha(mgs,lh))*(4.0 + alpha(mgs,lh))/
16484 ! : ((3.0 + alpha(mgs,lh))*(2.0 + alpha(mgs,lh))*(1.0 + alpha(mgs,lh)))
16485 ! alp = Max( 1.0, alpha(mgs,lh)+1. )
16486 ! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/
16487 ! : ((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
16488 ! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) - tmp**2 * chacr(mgs) )
16489 ! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qhacr(mgs) )
16494 IF ( lwsm6 .and. ipconc == 0 ) THEN
16497 vt = vtxbar(mgs,lh,1)
16502 & ((0.25)*pi/gf4)*ehr(mgs)*qx(mgs,lr)*cx(mgs,lh) &
16503 & *abs(vt-vtxbar(mgs,lr,1)) &
16504 & *( gf6*gf1*xdia(mgs,lr,2) &
16505 & + 2.0*gf5*gf2*xdia(mgs,lr,1)*xdia(mgs,lh,1) &
16506 & + gf4*gf3*xdia(mgs,lh,2) ) &
16509 IF ( temg(mgs) > tfr ) THEN
16510 IF ( iqhacrmlr >= 1 ) qhacrmlr(mgs) = qhacr(mgs)
16515 IF ( lvol(lh) .gt. 1 .or. lhl .gt. 1 ) THEN ! calculate rime density for graupel volume and/or for graupel conversion to hail
16517 IF ( temg(mgs) .lt. 273.15) THEN
16518 raindn(mgs,lh) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lr,3)) &
16520 & /(temg(mgs)-273.15))**(rimc2)
16522 raindn(mgs,lh) = Min( Max( rimc3, rimdn(mgs,lh) ), rimc4 )
16524 raindn(mgs,lh) = 1000.
16527 IF ( lvol(lh) > 1 ) vhacr(mgs) = rho0(mgs)*qhacr(mgs)/raindn(mgs,lh)
16534 if (ndebug .gt. 0 ) write(0,*) 'Collection: hail collects xxxxx'
16539 qhlacwmlr(mgs) = 0.0
16542 IF ( lhl > 1 .and. .true.) THEN
16543 vtmax = (gz(igs(mgs),jgs,kgs(mgs))*dtpinv)
16544 vtxbar(mgs,lhl,1) = Min( vtmax, vtxbar(mgs,lhl,1))
16545 vtxbar(mgs,lhl,2) = Min( vtmax, vtxbar(mgs,lhl,2))
16546 vtxbar(mgs,lhl,3) = Min( vtmax, vtxbar(mgs,lhl,3))
16549 IF ( lhl > 0 ) THEN
16550 rarx(mgs,lhl) = 0.0
16553 IF ( lhl .gt. 1 .and. ehlw(mgs) .gt. 0.0 ) THEN
16556 ! IF ( ipconc .ge. 2 ) THEN
16558 vt = abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,lc,1))
16560 qhlacw(mgs) = 0.25*pi*ehlw(mgs)*cx(mgs,lhl)*(qx(mgs,lc)-qcwresv(mgs))*vt* &
16561 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
16562 & dab1lh(mgs,lhl,lc)*xdia(mgs,lhl,3)*xdia(mgs,lc,3) + &
16563 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
16566 qhlacw(mgs) = Min( qhlacw(mgs), 0.5*qx(mgs,lc)*dtpinv )
16568 qhlacwmlr(mgs) = qhlacw(mgs)
16569 IF ( temg(mgs) > tfr .and. iqhlacwshr == 0 ) THEN
16573 IF ( lvol(lhl) .gt. 1 ) THEN
16575 IF ( temg(mgs) .lt. 273.15) THEN
16576 IF ( irimdenopt == 1 ) THEN ! Heymsfeld and Pflaum (1985)
16577 rimdn(mgs,lhl) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16578 & *((0.60)*( (1.0-rimdenvwgt)*vtxbar(mgs,lhl,1) + rimdenvwgt*vtxbar(mgs,lhl,2) )) &
16579 & /(temg(mgs)-273.15))**(rimc2)
16580 rimdn(mgs,lhl) = Min( Max( hldnmn, rimc3, rimdn(mgs,lhl) ), rimc4 )
16582 ELSEIF ( irimdenopt == 2 ) THEN ! Cober and List (1993)
16583 tmp = -0.5*(1.e+06)*xdia(mgs,lc,1) &
16584 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lhl,1) + rimdenvwgt*vtxbar(mgs,lhl,2) ) &
16585 & /(temg(mgs)-273.15)
16586 tmp = Min( 5.5/0.6, Max( 0.3/0.6, tmp ) )
16588 rimdn(mgs,lhl) = 1000.*(0.051 + 0.114*tmp - 0.005*tmp**2)
16590 ELSEIF ( irimdenopt == 3 .or. irimdenopt == 4) THEN ! Macklin (3) or Saunders and Hosseini 2001
16591 tmp = -0.5*(1.e+06)*xdia(mgs,lc,1) &
16592 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lhl,1) + rimdenvwgt*vtxbar(mgs,lhl,2) ) &
16593 & /(temg(mgs)-273.15)
16594 ! tmp = Min( 5.5/0.6, Max( 0.3/0.6, tmp ) )
16596 IF ( irimdenopt == 3 ) THEN
16597 rimdn(mgs,lhl) = Min(900., Max( 170., 110.*tmp**0.76 ) )
16598 ELSEIF ( irimdenopt == 4 ) THEN ! Saunders and Hosseini
16599 rimdn(mgs,lhl) = Min(917., Max( 10., 900.0*(1.0 - 0.905**tmp ) ) )
16604 rimdn(mgs,lhl) = 1000.
16607 vhlacw(mgs) = rho0(mgs)*qhlacw(mgs)/rimdn(mgs,lhl)
16612 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. ipelec .ge. 1 ) THEN
16614 & qhlacw(mgs)*1.0e3*rho0(mgs)/((pi/2.0)*xdia(mgs,lhl,2)*cx(mgs,lhl))
16622 IF ( lhl .gt. 1 ) THEN
16624 IF ( ehli(mgs) .gt. 0.0 ) THEN
16625 IF ( ipconc .ge. 5 ) THEN
16627 vt = Sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,li,1))**2 + &
16628 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,li,1) )
16630 qhlaci0(mgs) = 0.25*pi*ehliclsn(mgs)*cx(mgs,lhl)*qx(mgs,li)*vt* &
16631 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
16632 & dab1lh(mgs,lhl,li)*xdia(mgs,lhl,3)*xdia(mgs,li,3) + &
16633 & da1(li)*xdia(mgs,li,3)**2 )
16634 ! qhlaci(mgs) = Min( qhlaci(mgs), qimxd(mgs) )
16635 qhlaci(mgs) = Min( ehli(mgs)*qhlaci0(mgs), qimxd(mgs) )
16643 IF ( lhl .gt. 1 ) THEN
16645 IF ( ehls(mgs) .gt. 0.0) THEN
16646 IF ( ipconc .ge. 5 ) THEN
16648 vt = Sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,ls,1))**2 + &
16649 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,ls,1) )
16651 qhlacs0(mgs) = 0.25*pi*ehlsclsn(mgs)*cx(mgs,lhl)*qx(mgs,ls)*vt* &
16652 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
16653 & dab1lh(mgs,lhl,ls)*xdia(mgs,lhl,3)*xdia(mgs,ls,3) + &
16654 & da1(ls)*xdia(mgs,ls,3)**2 )
16656 qhlacs(mgs) = Min( ehls(mgs)*qhlacs0(mgs), qsmxd(mgs) )
16665 qhlacrmlr(mgs) = 0.0
16668 IF ( lhl .gt. 1 .and. temg(mgs) .gt. tfr ) raindn(mgs,lhl) = 1000.0
16670 IF ( lhl .gt. 1 .and. ehlr(mgs) .gt. 0.0 ) THEN
16671 IF ( ipconc .ge. 3 ) THEN
16672 vt = Sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,lr,1))**2 + &
16673 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,lr,1) )
16675 qhlacr(mgs) = 0.25*pi*ehlr(mgs)*cx(mgs,lhl)*qx(mgs,lr)*vt* &
16676 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
16677 & dab1lh(mgs,lhl,lr)*xdia(mgs,lhl,3)*xdia(mgs,lr,3) + &
16678 & da1lr(mgs)*xdia(mgs,lr,3)**2 )
16679 ! & da1(lr)*xdia(mgs,lr,3)**2 )
16680 ! IF ( qhacr(mgs) .gt. 0. .or. tmp .gt. 0.0 ) write(0,*) 'qhacr= ',qhacr(mgs),tmp
16681 !! qhacr(mgs) = Min( qhacr(mgs), qrmxd(mgs) )
16682 !! chacr(mgs) = qhacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
16683 !! chacr(mgs) = min(chacr(mgs),crmxd(mgs))
16685 qhlacr(mgs) = Min( qhlacr(mgs), qxmxd(mgs,lr) )
16688 IF ( iqhlacrmlr >= 1 ) qhlacrmlr(mgs) = qhlacr(mgs)
16690 IF ( temg(mgs) > tfr .and. iehlr0c == 0) THEN
16692 IF ( iqhlacrmlr == 0 ) THEN
16693 qhlacrmlr(mgs) = -qhlacw(mgs)
16696 chlacr(mgs) = 0.25*pi*ehlr(mgs)*cx(mgs,lhl)*cx(mgs,lr)*vt* &
16697 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
16698 & dab0lh(mgs,lhl,lr)*xdia(mgs,lhl,3)*xdia(mgs,lr,3) + &
16699 & da0lr(mgs)*xdia(mgs,lr,3)**2 )
16701 chlacr(mgs) = min(chlacr(mgs),crmxd(mgs))
16703 IF ( lvol(lhl) .gt. 1 ) THEN
16704 vhlacr(mgs) = rho0(mgs)*qhlacr(mgs)/raindn(mgs,lhl)
16717 ! if (ndebug .gt. 0 ) write(0,*) 'Collection: Cloud collects xxxxx'
16719 if (ndebug .gt. 0 ) write(0,*) 'Collection: cloud ice collects xxxx2'
16723 IF ( eiw(mgs) .gt. 0.0 ) THEN
16725 vt = Sqrt((vtxbar(mgs,li,1)-vtxbar(mgs,lc,1))**2 + &
16726 & 0.04*vtxbar(mgs,li,1)*vtxbar(mgs,lc,1) )
16728 qiacw(mgs) = 0.25*pi*eiw(mgs)*cx(mgs,li)*qx(mgs,lc)*vt* &
16729 & ( da0(li)*xdia(mgs,li,3)**2 + &
16730 & dab1(li,lc)*xdia(mgs,li,3)*xdia(mgs,lc,3) + &
16731 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
16733 qiacw(mgs) = Min( qiacw(mgs), qxmxd(mgs,lc) )
16740 if (ndebug .gt. 0 ) write(0,*) 'Collection: cloud ice collects xxxx8'
16750 csplinter(mgs) = 0.0
16751 qsplinter(mgs) = 0.0
16752 csplinter2(mgs) = 0.0
16753 qsplinter2(mgs) = 0.0
16754 IF ( iacr .ge. 1 .and. eri(mgs) .gt. 0.0 &
16755 & .and. temg(mgs) .le. 270.15 ) THEN
16756 IF ( ipconc .ge. 3 ) THEN
16758 IF ( xdia(mgs,li,1) .ge. 10.e-6 ) THEN
16759 ni = ni + cx(mgs,li)*Exp(- (40.e-6/xdia(mgs,li,1))**3 )
16761 IF ( imurain == 1 ) THEN ! gamma of diameter
16762 IF ( iacrsize /= 4 ) THEN
16763 IF ( iacrsize .eq. 1 ) THEN
16764 ratio = 500.e-6/xdia(mgs,lr,1)
16765 ELSEIF ( iacrsize .eq. 2 ) THEN
16766 ratio = 300.e-6/xdia(mgs,lr,1)
16767 ELSEIF ( iacrsize .eq. 3 ) THEN
16768 ratio = 40.e-6/xdia(mgs,lr,1)
16769 ELSEIF ( iacrsize .eq. 5 ) THEN
16770 ratio = 150.e-6/xdia(mgs,lr,1)
16772 i = Min(nqiacrratio,Int(ratio*dqiacrratioinv))
16773 j = Int(Max(0.0,Min(15.,alpha(mgs,lr)))*dqiacralphainv)
16774 ! j = Int(Max(minalphalu,Min(maxalphalu,alpha(mgs,lr)))*dqiacralphainv)
16775 delx = ratio - float(i)*dqiacrratio
16776 dely = alpha(mgs,lr) - float(j)*dqiacralpha
16777 ip1 = Min( i+1, nqiacrratio )
16778 jp1 = Min( j+1, nqiacralpha )
16780 ! interpolate along x, i.e., ratio
16781 tmp1 = ciacrratio(i,j) + delx*dqiacrratioinv*(ciacrratio(ip1,j) - ciacrratio(i,j))
16782 tmp2 = ciacrratio(i,jp1) + delx*dqiacrratioinv*(ciacrratio(ip1,jp1) - ciacrratio(i,jp1))
16784 ! interpolate along alpha
16786 nr = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*cx(mgs,lr)
16788 ! interpolate along x, i.e., ratio;
16789 tmp1 = qiacrratio(i,j) + delx*dqiacrratioinv*(qiacrratio(ip1,j) - qiacrratio(i,j))
16790 tmp2 = qiacrratio(i,jp1) + delx*dqiacrratioinv*(qiacrratio(ip1,jp1) - qiacrratio(i,jp1))
16792 ! interpolate along alpha;
16794 qr = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*qx(mgs,lr)
16796 ELSE ! iacrsize == 4 : use all
16801 vt = Sqrt((vtxbar(mgs,lr,1)-vtxbar(mgs,li,1))**2 + &
16802 & 0.04*vtxbar(mgs,lr,1)*vtxbar(mgs,li,1) )
16804 qiacr(mgs) = 0.25*pi*eri(mgs)*ni*qr*vt* &
16805 & ( da0(li)*xdia(mgs,li,3)**2 + &
16806 & dab1lh(mgs,li,lr)*xdia(mgs,lh,3)*xdia(mgs,li,3) + &
16807 & da1(lr)*xdia(mgs,lr,3)**2 )
16809 qiacr(mgs) = Min( qrmxd(mgs), qiacr(mgs) )
16812 ciacr(mgs) = 0.25*pi*eri(mgs)*ni*nr*vt* &
16813 & ( da0(li)*xdia(mgs,li,3)**2 + &
16814 & dab0lh(mgs,li,lr)*xdia(mgs,lr,3)*xdia(mgs,li,3) + &
16815 & da0(lr)*xdia(mgs,lr,3)**2 )
16817 ciacr(mgs) = Min( crmxd(mgs), ciacr(mgs) )
16819 ! write(iunit,*) 'qiacr: ',cx(mgs,lr),nr,qx(mgs,lr),qr,qiacr(mgs),ciacr(mgs)
16820 ! write(iunit,*) 'xdia r li = ',xdia(mgs,lr,3),xdia(mgs,li,3),xdia(mgs,lr,1),xdia(mgs,li,1)
16821 ! write(iunit,*) 'i,j,ratio = ',i,j,ciacrratio(i,j),qiacrratio(i,j)
16822 ! write(iunit,*) 'ni,ci = ',ni,cx(mgs,li),qx(mgs,li)
16824 ELSEIF ( imurain == 3 ) THEN ! gamma of volume
16825 ! Set nr to the number of drops greater than 40 microns.
16826 arg = 1000.*xdia(mgs,lr,3)
16827 ! nr = cx(mgs,lr)*gaml02( arg )
16828 ! IF ( iacr .eq. 1 ) THEN
16829 IF ( ipconc .ge. 3 ) THEN
16830 IF ( iacrsize .eq. 1 ) THEN
16831 nr = cx(mgs,lr)*gaml02d500( arg ) ! number greater than 500 microns in diameter
16832 ELSEIF ( iacrsize .eq. 2 .or. iacrsize .eq. 5 ) THEN
16833 nr = cx(mgs,lr)*gaml02d300( arg ) ! number greater than 300 microns in diameter
16834 ELSEIF ( iacrsize .eq. 3 ) THEN
16835 nr = cx(mgs,lr)*gaml02( arg ) ! number greater than 40 microns in diameter
16836 ELSEIF ( iacrsize .eq. 4 ) THEN
16837 nr = cx(mgs,lr) ! all raindrops
16840 nr = cx(mgs,lr)*gaml02( arg )
16842 ! ELSEIF ( iacr .eq. 2 ) THEN
16843 ! nr = cx(mgs,lr)*gaml02d300( arg ) ! number greater than 300 microns in diameter
16845 IF ( ni .gt. 0.0 .and. nr .gt. 0.0 ) THEN
16846 d0 = xdia(mgs,lr,3)
16847 qiacr(mgs) = xdn(mgs,lr)*rhoinv(mgs)* &
16848 & (0.217239*(0.522295*(d0**5) + &
16849 & 49711.81*(d0**6) - &
16850 & 1.673016e7*(d0**7)+ &
16851 & 2.404471e9*(d0**8) - &
16852 & 1.22872e11*(d0**9))*ni*nr)
16853 qiacr(mgs) = Min( qrmxd(mgs), qiacr(mgs) )
16855 & (0.217239*(0.2301947*(d0**2) + &
16856 & 15823.76*(d0**3) - &
16857 & 4.167685e6*(d0**4) + &
16858 & 4.920215e8*(d0**5) - &
16859 & 2.133344e10*(d0**6))*ni*nr)
16860 ciacr(mgs) = Min( crmxd(mgs), ciacr(mgs) )
16861 ! ciacr(mgs) = qiacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
16864 IF ( iacr .eq. 1 .or. iacr .eq. 3 ) THEN
16865 ciacrf(mgs) = Min(ciacr(mgs), qiacr(mgs)/(1.0*vr1mm*1000.0)*rho0(mgs) ) ! *rzxh(mgs)
16866 ELSEIF ( iacr .eq. 2 ) THEN
16867 ciacrf(mgs) = ciacr(mgs) ! *rzxh(mgs)
16868 ELSEIF ( iacr .eq. 4 ) THEN
16869 ciacrf(mgs) = Min(ciacr(mgs), qiacr(mgs)/(1.0*vfrz*1000.0)*rho0(mgs) ) ! *rzxh(mgs)
16870 ELSEIF ( iacr .eq. 5 ) THEN
16871 ciacrf(mgs) = ciacr(mgs)*rzxh(mgs)
16873 ! crfrzf(mgs) = Min(crfrz(mgs), qrfrz(mgs)/(bfnu*27.0*vr1mm*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
16877 ELSE ! single-moment rain
16880 & ((0.25/gf4)*pi)*eri(mgs)*cx(mgs,li)*qx(mgs,lr) &
16881 & *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,li,1)) &
16882 & *( gf6*gf1*xdia(mgs,lr,2) &
16883 & + 2.0*gf5*gf2*xdia(mgs,lr,1)*xdia(mgs,li,1) &
16884 & + gf4*gf3*xdia(mgs,li,2) ) &
16887 ! if ( temg(mgs) .gt. 268.15 ) then
16892 IF ( ipconc .ge. 1 ) THEN
16893 IF ( nsplinter .ge. 1000 ) THEN
16894 ! Lawson et al. 2015 JAS
16895 ! ave. diam of freezing drops in microns
16896 IF ( qiacr(mgs)*dtp > qxmin(lh) .and. ciacr(mgs) > 1.e-3 ) THEN
16897 tmpdiam = 1.e6*( 6.*qiacr(mgs)/(1000.*pi*ciacr(mgs) ) )**(1./3.) ! avg. diameter of newly frozen drops in microns
16898 csplinter(mgs) = lawson_splinter_fac*tmpdiam**4*ciacr(mgs)
16900 ELSEIF ( nsplinter .ge. 0 ) THEN
16901 csplinter(mgs) = nsplinter*ciacr(mgs)
16903 csplinter(mgs) = -nsplinter*ciacrf(mgs)
16905 qsplinter(mgs) = Min(0.1*qiacr(mgs), csplinter(mgs)*splintermass/rho0(mgs) ) ! makes splinters smaller if too much mass is taken from graupel
16909 IF ( ibiggsnow == 2 .or. ibiggsnow == 3 ) THEN
16910 IF ( ciacr(mgs) > qxmin(lh) ) THEN
16911 xvfrz = rho0(mgs)*qiacr(mgs)/(ciacr(mgs)*900.) ! mean volume of frozen drops; 900. for frozen drop density
16912 frach = 0.5 *(1. + Tanh(0.2e12 *( xvfrz - 1.15*xvbiggsnow)))
16914 qiacrs(mgs) = (1.-frach)*qiacr(mgs)
16915 ciacrs(mgs) = (1.-frach)*ciacrf(mgs) ! *rzxh(mgs)
16920 qiacrf(mgs) = frach*qiacr(mgs)
16921 ciacrf(mgs) = frach*ciacrf(mgs)
16923 IF ( lvol(lh) > 1 ) THEN
16924 viacrf(mgs) = rho0(mgs)*qiacrf(mgs)/rhofrz
16933 ! snow aggregation here
16934 if ( ipconc .ge. 4 ) then !
16937 IF ( qx(mgs,ls) > qxmin(ls) .and. ess(mgs) .gt. 0.0 ) THEN ! .and. xv(mgs,ls) < 0.25*xvmx(ls)*Max(1.,100./Min(100.,xdn(mgs,ls))) ) THEN
16939 IF ( iessec0flag == 0 ) THEN
16942 tmp = xv(mgs,ls)/(xvmx(ls)*Max(1.,100./Min(100.,xdn(mgs,ls)))) ! fraction of max snow mass
16943 IF ( tmp .lt. essfrac1 ) THEN
16945 ELSEIF ( tmp .ge. essfrac2 ) THEN
16948 ec0(mgs) = (essfrac2 - tmp)/(essfrac2 - essfrac1)
16952 csacs(mgs) = ec0(mgs)*rvt*aa2*ess(mgs)*cx(mgs,ls)**2*Min( xv(mgs,ls), 4.*pii/3.*essrmax**3 ) ! *Min(1.,xdn(mgs,ls)/100. ) ! Min func tries to recalibrate for low diagnosed density
16953 ! csacs(mgs) = rvt*aa2*ess(mgs)*cx(mgs,ls)**2*Min( xv(mgs,ls), 4.*pii/3.*0.02**3 ) ! *Min(1.,xdn(mgs,ls)/100. ) ! Min func tries to recalibrate for low diagnosed density
16954 csacs(mgs) = Min(csacs(mgs),csmxd(mgs))
16960 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 11'
16961 if ( ipconc .ge. 2 .or. ipelec .ge. 9 ) then
16964 IF ( eiw(mgs) .gt. 0.0 ) THEN
16965 ciacw(mgs) = qiacw(mgs)*rho0(mgs)/xmas(mgs,lc)
16966 ciacw(mgs) = min(ciacw(mgs),ccmxd(mgs))
16972 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 18'
16973 if ( ipconc .ge. 2 .or. ipelec .ge. 1 ) then
16978 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. qx(mgs,lr) .gt. qxmin(lr) &
16979 & .and. qracw(mgs) .gt. 0.0 ) THEN
16981 IF ( ipconc .lt. 3 ) THEN
16982 IF ( erw(mgs) .gt. 0.0 ) THEN
16984 & ((0.25)*pi)*erw(mgs)*(cx(mgs,lc) - ccwresv(mgs))*cx(mgs,lr) &
16985 & *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,lc,1)) &
16986 & *( gf1*xdia(mgs,lc,2) &
16987 & + 2.0*gf2*xdia(mgs,lc,1)*xdia(mgs,lr,1) &
16988 & + gf3*xdia(mgs,lr,2) )
16990 ELSE ! IF ( ipconc .ge. 3 .and.
16991 IF ( dmrauto <= 0 .or. rho0(mgs)*qx(mgs,lr) > 1.2*xl2p(mgs) ) THEN !{
16992 IF ( 0.5*xdia(mgs,lr,3) .gt. rh(mgs) ) THEN ! { .or. cx(mgs,lr) .gt. nh(mgs)
16993 ! IF ( qx(mgs,lc) .gt. qxmin(lc) .and. qx(mgs,lr) .gt. qxmin(lr) ) THEN
16994 IF ( 0.5*xdia(mgs,lr,3) .gt. rwradmn ) THEN ! r > 50.e-6
16995 ! DM0CCC=A2*XNC*XNR*(XVC+XVR) ! (A11)
16996 ! NOTE: murain drops out, so same result for imurain = 1 and 3
16997 cracw(mgs) = aa2*cx(mgs,lr)*(cx(mgs,lc) - ccwresv(mgs))*(xv(mgs,lc) + xv(mgs,lr))
16999 IF ( imurain == 3 ) THEN
17000 ! DM0CCC=A1*XNC*XNR*(((CNU+2.)/(CNU+1.))*XVC**2+((RNU+2.)/(RNU+1.))*XVR**2) ! (A13)
17001 cracw(mgs) = aa1*cx(mgs,lr)*(cx(mgs,lc) - ccwresv(mgs))* &
17002 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.) + &
17003 & (alpha(mgs,lr) + 2.)*xv(mgs,lr)**2/(alpha(mgs,lr) + 1.))
17004 ELSE ! imurain == 1 USE CP00 for rain DSD in diameter
17005 cracw(mgs) = aa1*cx(mgs,lr)*(cx(mgs,lc) - ccwresv(mgs))* &
17006 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.) + &
17007 & (alpha(mgs,lr) + 6.)*(alpha(mgs,lr) + 5.)*(alpha(mgs,lr) + 4.)*xv(mgs,lr)**2/ &
17008 & ((alpha(mgs,lr) + 3.)*(alpha(mgs,lr) + 2.)*(alpha(mgs,lr) + 1.)) )
17014 ENDIF ! qc > qcmin & qr > qrmin
17016 ! Rain self collection (cracr) and break-up (factor of ec0)
17020 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
17021 rwrad = 0.5*xdia(mgs,lr,3)
17024 ! check median volume diameter
17025 IF ( icracrthresh > 1 ) THEN
17026 IF ( imurain == 1 ) THEN
17027 tmp = (3.67+alpha(mgs,lr))*xdia(mgs,lr,1) ! median volume diameter; units of mm (Ulbrich 1983, JCAM)
17028 ELSE ! imurain == 3,
17029 tmp = (1.678+alpha(mgs,lr))**(1./3.)*xdia(mgs,lr,1) ! units of mm (using method of Ulbrich 1983. See ventillation_stuff.nb)
17032 tmp = xdia(mgs,lr,3) - 0.1e-3
17035 ! IF ( xdia(mgs,lr,3) .gt. 2.0e-3 .or. icracr <= 0 ) THEN
17036 IF ( tmp .gt. 1.9e-3 .or. icracr <= 0 ) THEN
17040 IF ( dmrauto <= 0 .or. rho0(mgs)*qx(mgs,lr) > 1.2*xl2p(mgs) ) THEN
17041 IF ( xdia(mgs,lr,3) .lt. 6.1e-4 ) THEN
17044 ec0(mgs) = Exp(-50.0*(50.0*(xdia(mgs,lr,3) - 6.0e-4)))
17048 IF ( rwrad .ge. 50.e-6 ) THEN
17049 cracr(mgs) = ec0(mgs)*aa2*cx(mgs,lr)**2*xv(mgs,lr)
17051 IF ( imurain == 3 ) THEN
17052 cracr(mgs) = ec0(mgs)*aa1*(cx(mgs,lr)*xv(mgs,lr))**2* &
17053 & (alpha(mgs,lr) + 2.)/(alpha(mgs,lr) + 1.)
17054 ELSE ! imurain == 1
17055 cracr(mgs) = ec0(mgs)*aa1*(cx(mgs,lr)*xv(mgs,lr))**2* &
17056 & (alpha(mgs,lr) + 6.)*(alpha(mgs,lr) + 5.)*(alpha(mgs,lr) + 4.)/ &
17057 & ((alpha(mgs,lr) + 3.)*(alpha(mgs,lr) + 2.)*(alpha(mgs,lr) + 1.))
17061 ! cracr(mgs) = Min(cracr(mgs),crmxd(mgs))
17066 ! cracw(mgs) = min(cracw(mgs),cxmxd(mgs,lc))
17075 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22ii'
17077 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17080 IF ( ipconc .ge. 5 ) THEN
17081 IF ( qhacw(mgs) .gt. 0.0 .and. xmas(mgs,lc) .gt. 0.0 ) THEN
17083 ! This is the explict version of chacw, which turns out to be very close to the
17084 ! approximation that the droplet size does not change, to within a few percent.
17085 ! This may _not_ be the case for cnu other than zero!
17086 ! chacw(mgs) = (ehw(mgs)*cx(mgs,lc)*cx(mgs,lh)*(pi/4.)*
17087 ! : abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1))*
17088 ! : (2.0*xdia(mgs,lh,1)*(xdia(mgs,lh,1) +
17089 ! : xdia(mgs,lc,1)*gf43rds) +
17090 ! : xdia(mgs,lc,2)*gf53rds))
17092 ! chacw(mgs) = Min( chacw(mgs), 0.6*cx(mgs,lc)*dtpinv )
17094 ! chacw(mgs) = qhacw(mgs)*rho0(mgs)/xmas(mgs,lc)
17095 chacw(mgs) = qhacw(mgs)*rho0(mgs)/xmascw(mgs)
17096 ! chacw(mgs) = min(chacw(mgs),cxmxd(mgs,lc))
17097 chacw(mgs) = Min( chacw(mgs), 0.5*(cx(mgs,lc) - ccwresv(mgs))*dtpinv )
17104 & ((0.25)*pi)*ehw(mgs)*cx(mgs,lc)*cx(mgs,lh) &
17105 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1)) &
17106 & *( gf1*xdia(mgs,lc,2) &
17107 & + 2.0*gf2*xdia(mgs,lc,1)*xdia(mgs,lh,1) &
17108 & + gf3*xdia(mgs,lh,2) )
17109 chacw(mgs) = min(chacw(mgs),0.5*cx(mgs,lc)*dtpinv)
17110 ! chacw(mgs) = min(chacw(mgs),cxmxd(mgs,lc))
17111 ! chacw(mgs) = min(chacw(mgs),ccmxd(mgs))
17116 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22kk'
17119 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17121 IF ( ehi(mgs) .gt. 0.0 .or. ( ehiclsn(mgs) > 0.0 .and. ipelec > 0 )) THEN
17122 IF ( ipconc .ge. 5 ) THEN
17124 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,li,1))**2 + &
17125 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,li,1) )
17127 chaci0(mgs) = 0.25*pi*ehiclsn(mgs)*cx(mgs,lh)*cx(mgs,li)*vt* &
17128 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
17129 & dab0lh(mgs,lh,li)*xdia(mgs,lh,3)*xdia(mgs,li,3) + &
17130 & da0(li)*xdia(mgs,li,3)**2 )
17134 & ((0.25)*pi)*ehiclsn(mgs)*cx(mgs,li)*cx(mgs,lh) &
17135 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,li,1)) &
17136 & *( gf1*xdia(mgs,li,2) &
17137 & + 2.0*gf2*xdia(mgs,li,1)*xdia(mgs,lh,1) &
17138 & + gf3*xdia(mgs,lh,2) )
17141 chaci(mgs) = min(ehi(mgs)*chaci0(mgs),cimxd(mgs))
17148 if ( lis > 1 .and. ipconc .ge. 5 .or. ipelec .ge. 1 ) then
17150 IF ( ehis(mgs) .gt. 0.0 .or. ( ehisclsn(mgs) > 0.0 .and. ipelec > 0 )) THEN
17152 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,lis,1))**2 + &
17153 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,lis,1) )
17155 chacis0(mgs) = 0.25*pi*ehisclsn(mgs)*cx(mgs,lh)*cx(mgs,lis)*vt* &
17156 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
17157 & dab0lh(mgs,lh,lis)*xdia(mgs,lh,3)*xdia(mgs,lis,3) + &
17158 & da0(lis)*xdia(mgs,lis,3)**2 )
17161 chacis(mgs) = min(ehis(mgs)*chacis0(mgs),cxmxd(mgs,lis))
17167 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22nn'
17170 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17172 IF ( ehs(mgs) .gt. 0 ) THEN
17173 IF ( ipconc .ge. 5 .or. ( ehsclsn(mgs) > 0.0 .and. ipelec > 0 ) ) THEN
17175 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1))**2 + &
17176 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,ls,1) )
17178 chacs0(mgs) = 0.25*pi*ehsclsn(mgs)*cx(mgs,lh)*cx(mgs,ls)*vt* &
17179 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
17180 & dab0lh(mgs,lh,ls)*xdia(mgs,lh,3)*xdia(mgs,ls,3) + &
17181 & da0(ls)*xdia(mgs,ls,3)**2 )
17185 & ((0.25)*pi)*ehsclsn(mgs)*cx(mgs,ls)*cx(mgs,lh) &
17186 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1)) &
17187 & *( gf3*gf1*xdia(mgs,ls,2) &
17188 & + 2.0*gf2*gf2*xdia(mgs,ls,1)*xdia(mgs,lh,1) &
17189 & + gf1*gf3*xdia(mgs,lh,2) )
17191 chacs(mgs) = min(ehs(mgs)*chacs0(mgs),csmxd(mgs))
17201 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22ii'
17203 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17206 IF ( lhl .gt. 1 .and. ipconc .ge. 5 ) THEN
17207 IF ( qhlacw(mgs) .gt. 0.0 .and. xmas(mgs,lc) .gt. 0.0 ) THEN
17209 ! This is the explict version of chacw, which turns out to be very close to the
17210 ! approximation that the droplet size does not change, to within a few percent.
17211 ! This may _not_ be the case for cnu other than zero!
17212 ! chlacw(mgs) = (ehlw(mgs)*cx(mgs,lc)*cx(mgs,lhl)*(pi/4.)*
17213 ! : abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,lc,1))*
17214 ! : (2.0*xdia(mgs,lhl,1)*(xdia(mgs,lhl,1) +
17215 ! : xdia(mgs,lc,1)*gf43rds) +
17216 ! : xdia(mgs,lc,2)*gf53rds))
17218 ! chlacw(mgs) = Min( chlacw(mgs), 0.6*cx(mgs,lc)*dtpinv )
17220 ! chlacw(mgs) = qhlacw(mgs)*rho0(mgs)/xmas(mgs,lc)
17221 chlacw(mgs) = qhlacw(mgs)*rho0(mgs)/xmascw(mgs)
17222 ! chlacw(mgs) = min(chlacw(mgs),cxmxd(mgs,lc))
17223 chlacw(mgs) = Min( chlacw(mgs), 0.5*cx(mgs,lc)*dtpinv )
17229 ! > ((0.25)*pi)*ehlw(mgs)*cx(mgs,lc)*cx(mgs,lhl)
17230 ! > *abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,lc,1))
17231 ! > *( gf1*xdia(mgs,lc,2)
17232 ! > + 2.0*gf2*xdia(mgs,lc,1)*xdia(mgs,lhl,1)
17233 ! > + gf3*xdia(mgs,lhl,2) )
17234 ! chlacw(mgs) = min(chlacw(mgs),0.5*cx(mgs,lc)*dtpinv)
17235 ! chlacw(mgs) = min(chlacw(mgs),cxmxd(mgs,lc))
17236 ! chlacw(mgs) = min(chlacw(mgs),ccmxd(mgs))
17241 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22kk'
17244 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17246 IF ( lhl .gt. 1 .and. ( ehli(mgs) .gt. 0.0 .or. (ipelec > 0 .and. ehliclsn(mgs) > 0.0) ) ) THEN
17247 IF ( ipconc .ge. 5 ) THEN
17249 vt = Sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,li,1))**2 + &
17250 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,li,1) )
17252 chlaci0(mgs) = 0.25*pi*ehliclsn(mgs)*cx(mgs,lhl)*cx(mgs,li)*vt* &
17253 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
17254 & dab0(lhl,li)*xdia(mgs,lhl,3)*xdia(mgs,li,3) + &
17255 & da0(li)*xdia(mgs,li,3)**2 )
17259 ! > ((0.25)*pi)*ehli(mgs)*cx(mgs,li)*cx(mgs,lhl)
17260 ! > *abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,li,1))
17261 ! > *( gf1*xdia(mgs,li,2)
17262 ! > + 2.0*gf2*xdia(mgs,li,1)*xdia(mgs,lhl,1)
17263 ! > + gf3*xdia(mgs,lhl,2) )
17266 chlaci(mgs) = min(ehli(mgs)*chlaci0(mgs),cimxd(mgs))
17272 IF ( lis > 1 .and. ipconc .ge. 5) THEN
17274 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22kk'
17278 IF ( lhl .gt. 1 .and. ( ehlis(mgs) .gt. 0.0 .or. (ipelec > 0 .and. ehlisclsn(mgs) > 0.0) ) ) THEN
17280 vt = Sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,lis,1))**2 + &
17281 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,lis,1) )
17283 chlacis0(mgs) = 0.25*pi*ehlisclsn(mgs)*cx(mgs,lhl)*cx(mgs,lis)*vt* &
17284 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
17285 & dab0(lhl,lis)*xdia(mgs,lhl,3)*xdia(mgs,lis,3) + &
17286 & da0(lis)*xdia(mgs,lis,3)**2 )
17289 chlacis(mgs) = min(ehlis(mgs)*chlacis0(mgs),cxmxd(mgs,lis))
17296 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22jj'
17299 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17301 IF ( lhl .gt. 1 .and. ( ehls(mgs) .gt. 0.0 .or. (ipelec > 0 .and. ehlsclsn(mgs) > 0.0) ) ) THEN
17302 IF ( ipconc .ge. 5 ) THEN
17304 vt = Sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,ls,1))**2 + &
17305 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,ls,1) )
17307 chlacs0(mgs) = 0.25*pi*ehlsclsn(mgs)*cx(mgs,lhl)*cx(mgs,ls)*vt* &
17308 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
17309 & dab0(lhl,ls)*xdia(mgs,lhl,3)*xdia(mgs,ls,3) + &
17310 & da0(ls)*xdia(mgs,ls,3)**2 )
17314 ! > ((0.25)*pi)*ehls(mgs)*cx(mgs,ls)*cx(mgs,lhl)
17315 ! > *abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,ls,1))
17316 ! > *( gf3*gf1*xdia(mgs,ls,2)
17317 ! > + 2.0*gf2*gf2*xdia(mgs,ls,1)*xdia(mgs,lhl,1)
17318 ! > + gf1*gf3*xdia(mgs,lhl,2) )
17320 chlacs(mgs) = min(ehls(mgs)*chlacs0(mgs),csmxd(mgs))
17326 ! Ziegler (1985) autoconversion
17329 IF ( ipconc .ge. 2 ) THEN
17330 if (ndebug .gt. 0 ) write(0,*) 'conc 26a'
17339 IF ( dmrauto >= -1 ) THEN !{
17343 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. 1000. .and. temg(mgs) .gt. tfrh+4.) THEN
17344 !( .and. w(igs(mgs),jgs,kgs(mgs)) > 5.0) THEN ! DTD: added w threshold for testing
17345 volb = xv(mgs,lc)*(1./(1.+alpha(mgs,lc)))**(1./2.)
17346 cautn(mgs) = Min(ccmxd(mgs), &
17347 & ((alpha(mgs,lc)+2.)/(alpha(mgs,lc)+1.))*aa1*cx(mgs,lc)**2*xv(mgs,lc)**2)
17348 cautn(mgs) = Max( 0.0d0, cautn(mgs) )
17349 IF ( rb(mgs) .le. 7.51d-6 .or. dmrauto == -1) THEN
17353 ! XL2P=2.7E-2*XNC*XVC*((1.E12*RB**3*RC)-0.4)
17355 ! T2S=3.72E-3/(((1.E4*RB)-7.5)*XNC*XVC)
17356 ! t2s = 3.72E-3/(((1.e6*rb)-7.5)*cx(mgs,lc)*xv(mgs,lc))
17357 ! t2s = 3.72/(((1.e6*rb(mgs))-7.5)*rho0(mgs)*qx(mgs,lc))
17358 t2s = 3.72/(1.e6*(rb(mgs)-7.500d-6)*rho0(mgs)*qx(mgs,lc))
17360 qrcnw(mgs) = Max( 0.0d0, xl2p(mgs)/(t2s*rho0(mgs)) )
17361 crcnw(mgs) = Max( 0.0d0, Min(3.5e9*xl2p(mgs)/t2s,0.5*cautn(mgs)) )
17363 IF ( dmrauto == 0 ) THEN
17364 IF ( qx(mgs,lr)*rho0(mgs) > 1.2*xl2p(mgs) .and. cx(mgs,lr) > cxmin ) THEN ! Cohard and Pinty (2000a) switch over from (18) to (19)
17365 crcnw(mgs) = cx(mgs,lr)/qx(mgs,lr)*qrcnw(mgs)
17366 ELSEIF ( ( dmropt == 1 .or. dmropt == 3 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17367 tmp = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17368 crcnw(mgs) = Min(tmp,crcnw(mgs) )
17369 ELSEIF ( ( dmropt == 4 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17371 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17372 ! try mass-weighted average of old and new Dmr using converted qc mass
17373 crcnw(mgs) = (tmp*qrcnw(mgs)+tmp2*qx(mgs,lr))/(qrcnw(mgs)+qx(mgs,lr))
17374 ELSEIF ( ( dmropt == 5 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17376 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17377 ! try mass-weighted average of old and new Dmr using full qc mass
17378 crcnw(mgs) = (tmp*qx(mgs,lc)+tmp2*qx(mgs,lr))/(qx(mgs,lc)+qx(mgs,lr))
17379 ELSEIF ( ( dmropt == 6 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17381 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17382 ! try mass*diameter-weighted average of old and new Dmr (using full qc mass)
17383 crcnw(mgs) = (tmp*xdia(mgs,lc,3)*qx(mgs,lc)+tmp2*xdia(mgs,lr,3)*qx(mgs,lr))/(xdia(mgs,lc,3)*qx(mgs,lc)+xdia(mgs,lr,3)*qx(mgs,lr))
17384 ELSEIF ( ( dmropt == 7 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17386 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17387 ! try diameter-weighted average of old and new Dmr
17388 crcnw(mgs) = (tmp*xdia(mgs,lc,3)+tmp2*xdia(mgs,lr,3))/(xdia(mgs,lc,3)+xdia(mgs,lr,3))
17389 ELSEIF ( ( dmropt == 8 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17391 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17392 ! try sqrt(diameter)-weighted average of old and new Dmr
17393 crcnw(mgs) = (tmp*sqrt(xdia(mgs,lc,3))+tmp2*sqrt(xdia(mgs,lr,3)))/(sqrt(xdia(mgs,lc,3))+sqrt(xdia(mgs,lr,3)))
17395 ELSEIF ( dmrauto == 1 .and. cx(mgs,lr) > cxmin) THEN
17396 IF ( qx(mgs,lr) > qxmin(lr) ) THEN
17397 tmp = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17398 crcnw(mgs) = Min(tmp,crcnw(mgs) )
17400 ELSEIF ( dmrauto == 2 .and. cx(mgs,lr) > cxmin) THEN
17402 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17403 ! try mass-weighted average of old and new Dmr
17404 crcnw(mgs) = (tmp*qrcnw(mgs)+tmp2*qx(mgs,lr))/(qrcnw(mgs)+qx(mgs,lr))
17405 ELSEIF ( dmrauto == 3 .and. cx(mgs,lr) > cxmin) THEN ! adapted from MY/CP code
17406 tmp = Max( 2.d0*rh(mgs), dble( xdia(mgs,lr,3) ) )
17407 crcnw(mgs) = rho0(mgs)*qrcnw(mgs)/(pi/6.*1000.*tmp**3)
17410 IF ( crcnw(mgs) < 1.e-30 ) qrcnw(mgs) = 0.0
17412 IF ( ipconc >= 6 ) THEN
17413 IF ( lzr > 1 .and. qrcnw(mgs) > 0.0 ) THEN
17414 ! vr = rho0(mgs)*qrcnw(mgs)/(1000.*crcnw(mgs))
17415 ! zrcnw(mgs) = 36.*(xnu(lr)+2.0)*crcnw(mgs)*vr**2/((xnu(lr)+1.0)*pi**2)
17416 ! DTD: If rain exists at a grid point already either use the alpha-preserving Z-rate eqn. (dmrauto == 1)
17417 ! or a mass-weighted average of the alpha-preserving Z-rate eqn. and the init. rate eqn. (dmrauto == 2)
17418 ! or the original initiation rate equation (dmrauto == 0). Not sure if this is the correct way to go but seems to work ok.
17419 IF (qx(mgs,lr) .gt. qxmin(lr) .and. ( dmrauto == 1 .or. dmrauto ==2 ) ) THEN
17420 tmp3 = qx(mgs,lr)/cx(mgs,lr)
17421 tmp4 = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2* &
17422 & ( 2.*tmp3 * qrcnw(mgs) - tmp3**2 * crcnw(mgs) )
17423 if (imurain == 3) then
17424 vr = rho0(mgs)*qrcnw(mgs)/(1000.)
17425 tmp3 = 36.*(xnu(lc)+2.0)*vr**2/(crcnw(mgs)*(xnu(lc)+1.0)*pi**2)
17427 tmp3 = galpharaut*(6.*rho0(mgs)*qrcnw(mgs)/(pi*xdn0(lr)))**2/crcnw(mgs)
17429 IF ( dmrauto == 1 ) THEN ! Preserve alpha
17431 ELSEIF ( dmrauto == 2 ) THEN ! Mass-weighted average
17432 zrcnw(mgs) = (tmp3*qrcnw(mgs)+tmp4*qx(mgs,lr))/(qrcnw(mgs)+qx(mgs,lr))
17434 else ! original formulation
17435 IF ( imurain == 3 ) THEN
17436 vr = rho0(mgs)*qrcnw(mgs)/(1000.) ! crcnw(mgs) not divided here but is in next line, cancels one factor in the numerator
17437 zrcnw(mgs) = 36.*(xnu(lc)+2.0)*vr**2/(crcnw(mgs)*(xnu(lc)+1.0)*pi**2)
17438 ELSE ! rain in gamma of diameter
17439 IF ( dmropt <= 1 .or. dmropt >= 4 .or. ( qx(mgs,lr) < qxmin(lr) .and. cx(mgs,lr) < cxmin ) ) THEN
17440 zrcnw(mgs) = galpharaut*(6.*rho0(mgs)*qrcnw(mgs)/(pi*xdn0(lr)))**2/crcnw(mgs)
17442 tmp3 = qx(mgs,lr)/cx(mgs,lr)
17443 zrcnw(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2* &
17444 & ( 2.*tmp3 * qrcnw(mgs) - tmp3**2 * crcnw(mgs) )
17446 ! vr = rho0(mgs)*qrcnw(mgs)/(1000.) ! crcnw(mgs) not divided here but is in next line, cancels one factor in the numerator
17447 ! zrcnw(mgs) = 36.*(xnu(lc)+2.0)*vr**2/(crcnw(mgs)*(xnu(lc)+1.0)*pi**2)
17450 ! z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
17452 ENDIF ! ipconc >= 6
17453 ! IF ( crcnw(mgs) .gt. cautn(mgs) .and. crcnw(mgs) .gt. 1.0 )
17455 ! write(0,*) 'crcnw,cautn ',crcnw(mgs)/cautn(mgs),
17456 ! : crcnw(mgs),cautn(mgs),igs(mgs),kgs(mgs),t2s,qx(mgs,lr)
17457 ! write(0,*) ' ',qx(mgs,lc),cx(mgs,lc),0.5e6*xdia(mgs,lc,1)
17458 ! write(0,*) ' ',rho0(mgs)*qrcnw(mgs)/crcnw(mgs),
17459 ! : 1.e6*(( 3/(4.*pi))*rho0(mgs)*qrcnw(mgs)/
17460 ! : (crcnw(mgs)*xdn(mgs,lr)))**(1./3.),rh(mgs)*1.e6,rwrad(mgs)
17461 ! ELSEIF ( crcnw(mgs) .gt. 1.0 .and. cautn(mgs) .gt. 0.) THEN
17462 ! write(0,*) 'crcnw,cautn ',crcnw(mgs)/cautn(mgs),
17463 ! : crcnw(mgs),cautn(mgs),igs(mgs),kgs(mgs),t2s
17464 ! write(0,*) ' ',rho0(mgs)*qrcnw(mgs)/crcnw(mgs),
17465 ! : 1.e6*(( 3*pi/4.)*rho0(mgs)*qrcnw(mgs)/
17466 ! : (crcnw(mgs)*xdn(mgs,lr)))**(1./3.)
17468 ! crcnw(mgs) = Min(cautn(mgs),3.5e9*xl2p(mgs)/t2s)
17470 ! IF ( qrcnw(mgs) .gt. 0.3e-2 ) THEN
17471 ! write(0,*) 'QRCNW'
17472 ! write(0,*) qrcnw(mgs),crcnw(mgs),cautn(mgs)
17473 ! write(0,*) xl2p,t2s,rho0(mgs),xv(mgs,lc),cx(mgs,lc),qx(mgs,lc)
17474 ! write(0,*) rb,0.5*xdia(mgs,lc,1),mgs,igs(mgs),kgs(mgs)
17476 ! qrcnw(mgs) = Min(qrcnw(mgs),qcmxd(mgs))
17483 ENDIF !} dmrauto >= 0
17490 ! Berry 1968 auto conversion for rain (Orville & Kopp 1977)
17493 if ( ircnw .eq. 4 ) then
17495 ! sconvmix(lcw,mgs) = 0.0
17497 qdiff = max((qx(mgs,lc)-qminrncw),0.0)
17498 if ( qdiff .gt. 0.0 .and. xdia(mgs,lc,1) .gt. 20.0e-6 ) then
17500 & ((1.2e-4)+(1.596e-12)*(cx(mgs,lc)*1.0e-6) &
17501 & /(cwdisp*qdiff*1.0e-3*rho0(mgs)))
17502 qrcnw(mgs) = (rho0(mgs)*1e-3)*(qdiff**2)/argrcnw
17503 ! sconvmix(lcw,mgs) = max(sconvmix(lcw,mgs),0.0)
17504 qrcnw(mgs) = (max(qrcnw(mgs),0.0))
17512 ! Berry 1968 auto conversion for rain (Ferrier 1994)
17515 if ( ircnw .eq. 5 ) then
17519 qccrit = (pi/6.)*(cx(mgs,lc)*cwdiap**3)*xdn(mgs,lc)/rho0(mgs)
17520 qdiff = max((qx(mgs,lc)-qccrit),0.)
17521 if ( qdiff .gt. 0.0 .and. cx(mgs,lc) .gt. 1.0 ) then
17523 ! > ((1.2e-4)+(1.596e-12)*cx(mgs,lc)/(cwdisp*rho0(mgs)*qdiff)) &
17524 & ((1.2e-4)+(1.596e-12)*cx(mgs,lc)*1.0e-3/(cwdisp*rho0(mgs)*qdiff))
17526 ! > timflg(mgs)*rho0(mgs)*(qdiff**2)/argrcnw &
17527 & 1.0e-3*rho0(mgs)*(qdiff**2)/argrcnw
17528 qrcnw(mgs) = Min(qxmxd(mgs,lc), (max(qrcnw(mgs),0.0)) )
17530 ! write(iunit,*) 'qrcnw,cx =',qrcnw(mgs),cx(mgs,lc),mgs,1.e3*qx(mgs,lc),cno(lr)
17537 ! kessler auto conversion for rain.
17539 if ( ircnw .eq. 2 ) then
17542 qrcnw(mgs) = (0.001)*max((qx(mgs,lc)-qminrncw),0.0)
17547 ! c1 = 0.12-0.32 for colorado storms...typically 0.3-0.4
17548 ! berry reinhart type conversion (proctor 1988)
17550 if ( ircnw .eq. 1 ) then
17556 & (1.e+06) * ((c1/(0.38))**(1./3.)) * (xdia(mgs,lc,1)*(0.5))
17558 & (0.027) * ((100.0)*(bradp**3)*(xdia(mgs,lc,1)*(0.5)) - (0.4))
17559 bt2 = (bradp -7.5) / (3.72)
17561 if ( bl2 .gt. 0.0 .and. bt2 .gt. 0.0 ) then
17562 qrcnw(mgs) = bl2 * bt2 * rho0(mgs) &
17563 & * qx(mgs,lc) * qx(mgs,lc)
17570 ENDIF ! ( ipconc .ge. 2 )
17575 ! Bigg Freezing of Rain
17577 if (ndebug .gt. 0 ) write(0,*) 'conc 27a'
17590 IF ( .not. ( ipconc == 0 .and. lwsm6 ) ) THEN
17593 if ( qx(mgs,lr) .gt. qxmin(lr) .and. temcg(mgs) .lt. -5. .and. ibiggopt > 0 ) then
17596 IF ( ipconc .lt. 3 ) THEN
17599 & (20.0)*(pi**2)*brz*(xdn(mgs,lr)/rho0(mgs)) &
17600 & *cx(mgs,lr)*(xdia(mgs,lr,1)**6) &
17601 & *(exp(max(-arz*temcg(mgs), 0.0))-1.0) &
17603 qrfrzf(mgs) = qrfrz(mgs)
17605 ! ELSEIF ( ipconc .ge. 3 .and. xv(mgs,lr) .gt. 1.1*xvmn(lr) ) THEN
17606 ELSEIF ( ipconc .ge. 3 ) THEN
17607 ! tmp = brz*cx(mgs,lr)*(Exp(Max( -arz*temcg(mgs), 0.0 )) - 1.0)
17608 ! crfrz(mgs) = xv(mgs,lr)*tmp
17612 ! IF ( ibiggopt == 2 .and. imurain == 1 .and. lzr < 1 ) THEN ! lzr check because results are weird for 3-moment
17613 IF ( ibiggopt == 2 .and. imurain == 1 ) THEN !
17614 ! integrate from Bigg diameter (for given supercooling Ts) to infinity
17616 volt = exp( 16.2 + 1.0*temcg(mgs) )* 1.0e-6 ! Ts == -temcg ; volt comes from the fit in Fig. 1 in Bigg 1953 (Proc. Phys. Soc. London)
17617 ! for mean temperature for freezing: -ln (V) = a*Ts - b, where a = 6.9/6.8, or approx a = 1.0, and b = 16.2
17618 ! volt is given in cm**3, so convert to m**3
17619 dbigg = (6./pi* volt )**(1./3.)
17621 ! perhaps should also test that W > V_t_dbigg, i.e., that drops the size of dbigg are being lifted and cooled.
17622 IF ( dbigg < 8.e-3 ) THEN !{ only bother if freezing diameter is reasonable
17624 ratio = Min(maxratiolu, dbigg/xdia(mgs,lr,1) )
17626 i = Min(nqiacrratio,Int(ratio*dqiacrratioinv))
17627 IF ( alp0flag ) THEN
17628 j = Int(Max(0.0,Min(15.,alpha(mgs,lr)))*dqiacralphainv)
17630 j = Int(Max(minalphalu,Min(maxalphalu,alpha(mgs,lr)))*dqiacralphainv)
17632 delx = ratio - float(i)*dqiacrratio
17633 dely = alpha(mgs,lr) - float(j)*dqiacralpha
17634 ip1 = Min( i+1, nqiacrratio )
17635 jp1 = Min( j+1, nqiacralpha )
17637 ! interpolate along x, i.e., ratio;
17638 tmp1 = ciacrratio(i,j) + delx*dqiacrratioinv*(ciacrratio(ip1,j) - ciacrratio(i,j))
17639 tmp2 = ciacrratio(i,jp1) + delx*dqiacrratioinv*(ciacrratio(ip1,jp1) - ciacrratio(i,jp1))
17641 ! interpolate along alpha;
17643 crfrz(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*cx(mgs,lr)*dtpinv
17644 crfrzf(mgs) = crfrz(mgs)
17645 ! interpolate along x, i.e., ratio;
17646 tmp1 = qiacrratio(i,j) + delx*dqiacrratioinv*(qiacrratio(ip1,j) - qiacrratio(i,j))
17647 tmp2 = qiacrratio(i,jp1) + delx*dqiacrratioinv*(qiacrratio(ip1,jp1) - qiacrratio(i,jp1))
17649 ! interpolate along alpha;
17651 qrfrz(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*qx(mgs,lr)*dtpinv
17652 qrfrzf(mgs) = qrfrz(mgs)
17654 IF ( qrfrz(mgs)*dtp < qxmin(lh) .or. crfrz(mgs)*dtp < cxmin ) THEN
17663 IF ( ipconc >= 6 .and. lzr > 1 ) THEN
17664 ! interpolate along x, i.e., ratio;
17665 tmp1 = ziacrratio(i,j) + delx*dqiacrratioinv*(ziacrratio(ip1,j) - ziacrratio(i,j))
17666 tmp2 = ziacrratio(i,jp1) + delx*dqiacrratioinv*(ziacrratio(ip1,jp1) - ziacrratio(i,jp1))
17668 ! interpolate along alpha;
17670 zrfrz(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*zx(mgs,lr)*dtpinv
17673 IF ( ibiggsmallrain > 0 .and. xv(mgs,lr) < 2.*xvmn(lr) .and. ( ibiggsnow == 1 .or. ibiggsnow == 3 ) ) THEN
17674 ! IF ( ibiggsmallrain > 0 .and. xv(mgs,lr) < xvbiggsnow .and. ( ibiggsnow == 1 .or. ibiggsnow == 3 ) ) THEN
17675 ! rain drops are so small that they cannot be pushed smaller, so put into snow (or cloud ice, depending on ifrzs)
17678 crfrzs(mgs) = crfrz(mgs)
17679 qrfrzs(mgs) = qrfrz(mgs)
17681 IF ( ipconc >= 6 .and. lzr > 1 ) THEN
17682 zrfrzs(mgs) = zrfrz(mgs)
17685 ELSEIF ( dbigg < Max( biggsnowdiam, Max(dfrz,dhmn)) .and. ( ibiggsnow == 1 .or. ibiggsnow == 3 ) ) THEN ! { convert some to snow or ice crystals
17686 ! temporarily store qrfrz and crfrz in snow terms and caclulate new crfrzf, qrfrzf, and zrfrzf. Leave crfrz etc. alone!
17688 crfrzs(mgs) = crfrz(mgs)
17689 qrfrzs(mgs) = qrfrz(mgs)
17691 IF ( ibiggsmallrain > 0 .and. xv(mgs,lr) < 1.2*xvmn(lr) ) THEN
17692 ! rain drops are so small that they cannot be pushed smaller, so put into snow (or cloud ice, depending on ifrzs)
17696 IF (ipconc >= 6 .and. lzr > 1 ) THEN
17697 zrfrzs(mgs) = zrfrz(mgs)
17702 ! recalculate using dhmn for ratio
17703 ratio = Min( maxratiolu, Max(dfrz,dhmn)/xdia(mgs,lr,1) )
17705 i = Min(nqiacrratio,Int(ratio*dqiacrratioinv))
17706 ! j = Int(Max(0.0,Min(15.,alpha(mgs,lr)))*dqiacralphainv)
17707 ! j = Int(Max(alphamin,Min(alphamax,alpha(mgs,lr)))*dqiacralphainv)
17708 IF ( alp0flag ) THEN
17709 j = Int(Max(0.0,Min(15.,alpha(mgs,lr)))*dqiacralphainv)
17711 j = Int(Max(minalphalu,Min(maxalphalu,alpha(mgs,lr)))*dqiacralphainv)
17713 delx = ratio - float(i)*dqiacrratio
17714 dely = alpha(mgs,lr) - float(j)*dqiacralpha
17715 ip1 = Min( i+1, nqiacrratio )
17716 jp1 = Min( j+1, nqiacralpha )
17718 ! interpolate along x, i.e., ratio;
17719 tmp1 = ciacrratio(i,j) + delx*dqiacrratioinv*(ciacrratio(ip1,j) - ciacrratio(i,j))
17720 tmp2 = ciacrratio(i,jp1) + delx*dqiacrratioinv*(ciacrratio(ip1,jp1) - ciacrratio(i,jp1))
17723 ! interpolate along alpha;
17725 crfrzf(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*cx(mgs,lr)*dtpinv
17727 ! interpolate along x, i.e., ratio;
17728 tmp1 = qiacrratio(i,j) + delx*dqiacrratioinv*(qiacrratio(ip1,j) - qiacrratio(i,j))
17729 tmp2 = qiacrratio(i,jp1) + delx*dqiacrratioinv*(qiacrratio(ip1,jp1) - qiacrratio(i,jp1))
17731 ! interpolate along alpha;
17733 qrfrzf(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*qx(mgs,lr)*dtpinv
17735 ! now subtract off the difference
17736 crfrzs(mgs) = crfrzs(mgs) - crfrzf(mgs)
17737 qrfrzs(mgs) = qrfrzs(mgs) - qrfrzf(mgs)
17739 IF ( ipconc >= 6 .and. lzr > 1 ) THEN
17740 zrfrzs(mgs) = zrfrz(mgs)
17741 ! interpolate along x, i.e., ratio;
17742 tmp1 = ziacrratio(i,j) + delx*dqiacrratioinv*(ziacrratio(ip1,j) - ziacrratio(i,j))
17743 tmp2 = ziacrratio(i,jp1) + delx*dqiacrratioinv*(ziacrratio(ip1,jp1) - ziacrratio(i,jp1))
17745 ! interpolate along alpha;
17747 zrfrzf(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*zx(mgs,lr)*dtpinv
17748 zrfrzs(mgs) = zrfrzs(mgs) - zrfrzf(mgs)
17749 zrfrzf(mgs) = (1000./900.)**2*zrfrzf(mgs)
17760 IF ( (qrfrz(mgs))*dtp > qx(mgs,lr) ) THEN
17761 fac = ( qrfrz(mgs) )*dtp/qx(mgs,lr)
17762 qrfrz(mgs) = fac*qrfrz(mgs)
17763 qrfrzs(mgs) = fac*qrfrzs(mgs)
17764 qrfrzf(mgs) = fac*qrfrzf(mgs)
17765 crfrz(mgs) = fac*crfrz(mgs)
17766 crfrzs(mgs) = fac*crfrzs(mgs)
17767 crfrzf(mgs) = fac*crfrzf(mgs)
17768 IF ( ipconc >= 6 .and. lzr > 1 ) THEN
17769 zrfrz(mgs) = fac*zrfrz(mgs)
17770 zrfrzf(mgs) = fac*zrfrzf(mgs)
17776 ! IF ( (crfrzs(mgs) + crfrz(mgs))*dtp > cx(mgs,lr) ) THEN
17777 ! fac = ( crfrzs(mgs) + crfrz(mgs) )*dtp/cx(mgs,lr)
17778 ! crfrz(mgs) = fac*crfrz(mgs)
17779 ! crfrzs(mgs) = fac*crfrzs(mgs)
17782 ! qrfrzf(mgs) = qrfrz(mgs)
17783 ! crfrzf(mgs) = crfrz(mgs)
17785 ! qrfrz(mgs) = qrfrzf(mgs) + qrfrzs(mgs)
17786 ! crfrz(mgs) = crfrzf(mgs) + crfrzs(mgs)
17789 ELSEIF ( ibiggopt == 1 ) THEN
17791 tmp = xv(mgs,lr)*brz*cx(mgs,lr)*(Exp(Max( -arz*temcg(mgs), 0.0 )) - 1.0)
17792 IF ( .false. .and. tmp .gt. cxmxd(mgs,lr) ) THEN ! {
17793 ! write(iunit,*) 'Bigg Freezing problem!',mgs,igs(mgs),kgs(mgs)
17794 ! write(iunit,*) 'tmp, cx(lr), xv = ',tmp, cx(mgs,lr), xv(mgs,lr), (Exp(Max( -arz*temcg(mgs), 0.0 )) - 1.0)
17795 ! write(iunit,*) 'qr,temcg = ',qx(mgs,lr)*1000.,temcg(mgs)
17796 crfrz(mgs) = cxmxd(mgs,lr) ! cx(mgs,lr)*dtpinv
17797 qrfrz(mgs) = qxmxd(mgs,lr) ! qx(mgs,lr)*dtpinv
17801 ! crfrzfmx = cx(mgs,lr)*Exp(-4./3.*pi*(40.e-6)**3/xv(mgs,lr))
17802 ! IF ( crfrz(mgs) .gt. crfrzmx ) THEN
17803 ! crfrz(mgs) = crfrzmx
17804 ! qrfrz(mgs) = bfnu*xmas(mgs,lr)*rhoinv(mgs)*crfrzmx
17805 ! qwcnr(mgs) = cx(mgs,lr) - crfrzmx
17807 IF ( lzr < 1 ) THEN
17808 IF ( imurain == 3 ) THEN
17814 ! bfnu = 1.0 ! (alpha(mgs,lr)+2.0)/(alpha(mgs,lr)+1.)
17815 IF ( imurain == 3 ) THEN
17816 bfnu = (alpha(mgs,lr)+2.0)/(alpha(mgs,lr)+1.)
17819 bfnu = (4. + alpha(mgs,lr))*(5. + alpha(mgs,lr))*(6. + alpha(mgs,lr))/ &
17820 & ((1. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(3. + alpha(mgs,lr)))
17824 qrfrz(mgs) = bfnu*xmas(mgs,lr)*rhoinv(mgs)*crfrz(mgs)
17826 qrfrz(mgs) = Min( qrfrz(mgs), 1.*qx(mgs,lr)*dtpinv ) ! qxmxd(mgs,lr)
17827 crfrz(mgs) = Min( crfrz(mgs), 1.*cx(mgs,lr)*dtpinv ) !cxmxd(mgs,lr)
17828 qrfrz(mgs) = Min( qrfrz(mgs), qx(mgs,lr) )
17829 qrfrzf(mgs) = qrfrz(mgs)
17835 IF ( crfrz(mgs) .gt. qxmin(lh) ) THEN !{ Yes, it compares cx and qxmin, but this is just to be sure that
17836 ! crfrz is greater than zero in the division
17837 ! IF ( xdia(mgs,lr,1) .lt. 200.e-6 ) THEN
17838 ! IF ( xv(mgs,lr) .lt. xvmn(lh) ) THEN
17840 IF ( (ibiggsnow == 1 .or. ibiggsnow == 3 ) .and. ibiggopt /= 2 ) THEN
17841 xvfrz = rho0(mgs)*qrfrz(mgs)/(crfrz(mgs)*900.) ! mean volume of frozen drops; 900. for frozen drop density
17842 frach = 0.5 *(1. + Tanh(0.2e12 *( xvfrz - 1.15*xvmn(lh))))
17844 qrfrzs(mgs) = (1.-frach)*qrfrz(mgs)
17845 crfrzs(mgs) = (1.-frach)*crfrz(mgs) ! *rzxh(mgs)
17846 ! qrfrzf(mgs) = frach*qrfrz(mgs)
17850 IF ( ipconc .ge. 14 .and. 1.e-3*rho0(mgs)*qrfrz(mgs)/crfrz(mgs) .lt. xvmn(lh) ) THEN
17851 qrfrzs(mgs) = qrfrz(mgs)
17852 crfrzs(mgs) = crfrz(mgs) ! *rzxh(mgs)
17854 ! crfrz(mgs) = Min( crfrz(mgs), 0.1*cx(mgs,lr)*dtpinv ) ! cxmxd(mgs,lr)
17855 ! qrfrz(mgs) = Min( qrfrz(mgs), 0.1*qx(mgs,lr)*dtpinv ) ! qxmxd(mgs,lr)
17856 qrfrzf(mgs) = frach*qrfrz(mgs)
17857 ! crfrzf(mgs) = Min( qrfrz(mgs)*rho0(mgs)/(xdn(mgs,lh)*vgra), crfrz(mgs) )
17858 IF ( ibfr .le. 1 ) THEN
17859 crfrzf(mgs) = frach*Min(crfrz(mgs), qrfrz(mgs)/(bfnu*1.0*vr1mm*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
17860 ELSEIF ( ibfr .eq. 5 ) THEN
17861 crfrzf(mgs) = frach*Min(crfrz(mgs), qrfrz(mgs)/(bfnu*vfrz*1000.0)*rho0(mgs) )*rzxh(mgs) !*crfrz(mgs)
17862 ELSEIF ( ibfr .eq. 2 ) THEN
17863 crfrzf(mgs) = frach*Min(crfrz(mgs), qrfrz(mgs)/(bfnu*vfrz*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
17864 ELSEIF ( ibfr .eq. 6 ) THEN
17865 crfrzf(mgs) = frach*Max(crfrz(mgs), qrfrz(mgs)/(bfnu*9.*xv(mgs,lr)*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
17867 crfrzf(mgs) = frach*crfrz(mgs)
17869 ! crfrzf(mgs) = Min(crfrz(mgs), qrfrz(mgs)/(bfnu*xvmn(lh)*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
17870 ! IF ( lz(lr) > 1 .and. lz(lh) > 1 ) THEN
17871 ! crfrzf(mgs) = crfrz(mgs)
17875 ! crfrz(mgs) = Min( cxmxd(mgs,lr), rho0(mgs)*qrfrz(mgs)/xmas(mgs,lr) )
17883 IF ( lvol(lh) .gt. 1 ) THEN
17884 vrfrzf(mgs) = rho0(mgs)*qrfrzf(mgs)/rhofrz
17888 IF ( nsplinter .ne. 0 ) THEN
17889 IF ( nsplinter .ge. 1000 ) THEN
17890 ! Lawson et al. 2015 JAS
17891 ! ave. diam of freezing drops in microns
17893 IF ( qrfrz(mgs)*dtp > qxmin(lh) .and. crfrz(mgs) > 1.e-3 ) THEN
17894 tmpdiam = 1.e6*( 6.*qrfrz(mgs)/(1000.*pi*crfrz(mgs) ))**(1./3.) ! avg. diameter of newly frozen drops in microns
17895 tmp = lawson_splinter_fac*tmpdiam**4*crfrz(mgs)
17897 ELSEIF ( nsplinter .gt. 0 ) THEN
17898 tmp = nsplinter*crfrz(mgs)
17900 tmp = -nsplinter*crfrzf(mgs)
17902 csplinter2(mgs) = tmp
17903 qsplinter2(mgs) = Min(0.1*qrfrz(mgs), tmp*splintermass/rho0(mgs) ) ! makes splinters smaller if too much mass is taken from graupel
17905 ! csplinter(mgs) = csplinter(mgs) + tmp
17906 ! qsplinter(mgs) = qsplinter(mgs) + Min(0.1*qrfrz(mgs), tmp*splintermass/rho0(mgs) ) ! makes splinters smaller if too much mass is taken from graupel
17908 ! IF ( temcg(mgs) .lt. -31.0 ) THEN
17909 ! qrfrz(mgs) = qx(mgs,lr)*dtpinv + qrcnw(mgs)
17910 ! qrfrzf(mgs) = qrfrz(mgs)
17911 ! crfrz(mgs) = cx(mgs,lr)*dtpinv + crcnw(mgs)
17912 ! crfrzf(mgs) = Min(crfrz(mgs), qrfrz(mgs)/(bfnu*1.0*vr1mm*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
17914 ! qrfrz(mgs) = 6.0*xdn(mgs,lr)*xv(mgs,lr)**2*tmp*rhoinv(mgs)
17915 ! qrfrz(mgs) = Min( qrfrz(mgs), ffrz*qrmxd(mgs) )
17916 ! crfrz(mgs) = Min( crmxd(mgs), ffrz*crfrz(mgs))
17917 ! crfrz(mgs) = Min(crmxd(mgs),qrfrz(mgs)*rho0(mgs)/xmas(mgs,lr))
17919 ! if ( temg(mgs) .gt. 268.15 ) then
17927 ! Homogeneous freezing of cloud drops to ice crystals
17928 ! following Bigg (1953) and Ferrier (1994).
17930 if (ndebug .gt. 0 ) write(0,*) 'conc 25b'
17938 IF ( ibfc .ge. 1 .and. ibfc /= 3 .and. temg(mgs) < 268.15 ) THEN
17939 ! if ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. 1. .and. &
17940 ! & .not. (ipconc .ge. 2 .and. xdia(mgs,lc,1) .lt. 10.e-6) ) then
17941 if ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. cxmin ) THEN
17942 IF ( ipconc < 2 ) THEN
17943 qwfrz(mgs) = ((2.0)*(brz)/(xdn(mgs,lc)*cx(mgs,lc))) &
17944 & *(exp(max(-arz*temcg(mgs), 0.0))-1.0) &
17945 & *rho0(mgs)*(qx(mgs,lc)**2)
17946 qwfrz(mgs) = max(qwfrz(mgs), 0.0)
17947 qwfrz(mgs) = min(qwfrz(mgs),qcmxd(mgs))
17948 cwfrz(mgs) = qwfrz(mgs)*rho0(mgs)/xmas(mgs,li)
17949 ELSEIF ( ipconc .ge. 2 ) THEN
17950 IF ( xdia(mgs,lc,3) > 0.e-6 ) THEN
17951 volt = exp( 16.2 + 1.0*temcg(mgs) )* 1.0e-6 ! Ts == -temcg ; volt comes from the fit in Fig. 1 in Bigg 1953
17952 ! for mean temperature for freezing: -ln (V) = a*Ts - b
17953 ! volt is given in cm**3, so factor of 1.e-6 to convert to m**3
17954 ! dbigg = (6./pi* volt )**(1./3.)
17956 IF ( alpha(mgs,lc) == 0.0 ) THEN
17957 cwfrz(mgs) = cx(mgs,lc)*Exp(-volt/xv(mgs,lc))*dtpinv ! number of droplets with volume greater than volt
17958 !turn off limit so that all can freeze at low temp
17959 !!! cwfrz(mgs) = Min(cwfrz(mgs),ccmxd(mgs))
17961 qwfrz(mgs) = cwfrz(mgs)*xdn0(lc)*rhoinv(mgs)*(volt + xv(mgs,lc))
17963 ratio = (1. + alpha(mgs,lc))*volt/xv(mgs,lc)
17965 IF ( .false. .and. usegamxinfcnu ) THEN
17966 i = Nint(dgami*(1. + alpha(mgs,lc)))
17968 i = Nint(dgami*(2. + alpha(mgs,lc)))
17971 cwfrz(mgs) = cx(mgs,lc)*Gamxinf(1.+alpha(mgs,lc), ratio)/(dtp*gcnup1) ! gamxinflu(i,j,1,1)
17973 qwfrz(mgs) = cx(mgs,lc)*xdn0(lc)*xv(mgs,lc)*rhoinv(mgs)*Gamxinf(2.+alpha(mgs,lc), ratio)/(dtp*gcnup2) ! gamxinflu(i,j,12,1)
17977 ratio = Min( maxratiolu, ratio )
17978 ! write(0,*) 'cwfrz: temp,ratio = ',temcg(mgs),ratio
17979 ! write(0,*) 'cwfrz: xv,volt,qx = ',xv(mgs,lc),volt,qx(mgs,lc)
17980 ! write(0,*) 'cwfrz: i,j,k = ',igs(mgs),jgs,kgs(mgs)
17981 tmp = gaminterp(ratio,alpha(mgs,lc),1,1)
17982 ! write(0,*) 'cwfrz: tmp1 = ',tmp
17983 cwfrz(mgs) = cx(mgs,lc)*tmp*dtpinv ! Gamxinf(1.+alpha(mgs,lc), ratio)/(dtp*gcnup1) ! gamxinflu(i,j,1,1)
17985 tmp = gaminterp(ratio,alpha(mgs,lc),12,1)
17986 ! write(0,*) 'cwfrz: tmp2 = ',tmp
17987 qwfrz(mgs) = cx(mgs,lc)*xdn0(lc)*xv(mgs,lc)*rhoinv(mgs)*dtpinv*tmp ! Gamxinf(2.+alpha(mgs,lc), ratio)/(dtp*gcnup2) ! gamxinflu(i,j,12,1)
17995 if ( temg(mgs) .gt. 268.15 ) then
18002 if ( xplate(mgs) .eq. 1 ) then
18003 qwfrzp(mgs) = qwfrz(mgs)
18004 cwfrzp(mgs) = cwfrz(mgs)
18007 if ( xcolmn(mgs) .eq. 1 ) then
18008 qwfrzc(mgs) = qwfrz(mgs)
18009 cwfrzc(mgs) = cwfrz(mgs)
18013 ! qwfrzp(mgs) = 0.0
18014 ! qwfrzc(mgs) = qwfrz(mgs)
18019 ! Contact freezing nucleation: factor is to convert from L-1
18020 ! T < -2C: via Meyers et al. JAM July, 1992 (31, 708-721)
18022 if (ndebug .gt. 0 ) write(0,*) 'conc 25a'
18037 IF ( icfn .ge. 1 ) THEN
18039 IF ( temg(mgs) .lt. 271.15 .and. qx(mgs,lc) .gt. qxmin(lc)) THEN
18041 ! find available # of ice nuclei & limit value to max depletion of cloud water
18043 IF ( icfn .ge. 2 ) THEN
18044 ccia(mgs) = exp( 4.11 - (0.262)*temcg(mgs) ) ! in m-3, see Walko et al. 1995; 1000*exp(-2.8 -b*t) = exp(6.91)*exp(-2.8 - b*t) = exp(4.11 -b*t)
18045 !ccia(mgs) = Min(cwctfz(mgs), ccmxd(mgs) )
18047 ! now find how many of these collect cloud water to form IN
18048 ! Cotton et al 1986
18050 knud(mgs) = 2.28e-5 * temg(mgs) / ( pres(mgs)*raero ) !Walko et al. 1995
18051 knuda(mgs) = 1.257 + 0.4*exp(-1.1/knud(mgs)) !Pruppacher & Klett 1997 eqn 11-16
18052 gtp(mgs) = 1. / ( fai(mgs) + fbi(mgs) ) !Byers 65 / Cotton 72b
18053 dfar(mgs) = kb*temg(mgs)*(1.+knuda(mgs)*knud(mgs))/(6.*pi*fadvisc(mgs)*raero) !P&K 1997 eqn 11-15
18054 fn1(mgs) = 2.*pi*xdia(mgs,lc,1)*cx(mgs,lc)*ccia(mgs)
18055 fn2(mgs) = -gtp(mgs)*(ssw(mgs)-1.)*felv(mgs)/pres(mgs)
18056 fnft(mgs) = 0.4*(1.+1.45*knud(mgs)+0.4*knud(mgs)*exp(-1./knud(mgs)))*(ftka(mgs)+2.5*knud(mgs)*kaero) &
18057 & / ( (1.+3.*knud(mgs))*(2*ftka(mgs)+5.*knud(mgs)*kaero+kaero) )
18060 ! Brownian diffusion
18061 ctfzbd(mgs) = fn1(mgs)*dfar(mgs)
18063 ! Thermophoretic contact nucleation
18064 ctfzth(mgs) = fn1(mgs)*fn2(mgs)*fnft(mgs)/rho0(mgs)
18066 ! Diffusiophoretic contact nucleation
18067 ctfzdi(mgs) = fn1(mgs)*fn2(mgs)*rw*temg(mgs)/(felv(mgs)*rho0(mgs))
18069 cwctfz(mgs) = max( ctfzbd(mgs) + ctfzth(mgs) + ctfzdi(mgs) , 0.)
18071 ! Sum of the contact nucleation processes
18072 ! IF ( cx(mgs,lc) .gt. 1.e6) write(0,*) 'ctfzbd,etc = ',cwctfz(mgs),ctfzbd(mgs),ctfzth(mgs),ctfzdi(mgs)
18073 ! IF ( wvel(mgs) .lt. -0.05 ) write(6,*) 'ctfzbd,etc = ',ctfzbd(mgs),ctfzth(mgs),ctfzdi(mgs),cx(mgs,lc)*1e-6,wvel(mgs)
18074 ! IF ( ssw(mgs) .lt. 1.0 .and. cx(mgs,lc) .gt. 1.e6 .and. cwctfz(mgs) .gt. 1. ) THEN
18075 ! write(6,*) 'ctfzbd,etc = ',ctfzbd(mgs),ctfzth(mgs),ctfzdi(mgs),cx(mgs,lc)*1e-6,wvel(mgs),fn1(mgs),fn2(mgs)
18076 ! write(6,*) 'more = ',nstep,ssw(mgs),dfar(mgs),gtp(mgs),felv(mgs),pres(mgs)
18079 ELSEIF ( icfn .eq. 1 ) THEN
18080 IF ( wvel(mgs) .lt. -0.05 ) THEN ! older kludgy version
18081 cwctfz(mgs) = cfnfac*exp( (-2.80) - (0.262)*temcg(mgs) )
18082 cwctfz(mgs) = Min((1.0e3)*cwctfz(mgs), ccmxd(mgs) ) !convert to m-3
18086 IF ( ipconc .ge. 2 ) THEN
18087 cwctfz(mgs) = Min( cwctfz(mgs)*dtpinv, ccmxd(mgs) )
18088 qwctfz(mgs) = xmas(mgs,lc)*cwctfz(mgs)/rho0(mgs)
18090 qwctfz(mgs) = (cimasn)*cwctfz(mgs)/(dtp*rho0(mgs))
18091 qwctfz(mgs) = max(qwctfz(mgs), 0.0)
18092 qwctfz(mgs) = min(qwctfz(mgs),qcmxd(mgs))
18096 if ( xplate(mgs) .eq. 1 ) then
18097 qwctfzp(mgs) = qwctfz(mgs)
18098 cwctfzp(mgs) = cwctfz(mgs)
18101 if ( xcolmn(mgs) .eq. 1 ) then
18102 qwctfzc(mgs) = qwctfz(mgs)
18103 cwctfzc(mgs) = cwctfz(mgs)
18106 ! IF ( cwctfz(mgs)*dtp > 0.5 .and. dtp*qwctfz(mgs) > qxmin(li) ) THEN
18107 ! write(91,*) 'cwctfz: ',cwctfz(mgs),qwctfz(mgs) ! ,cwctfzc(mgs),qwctfzc(mgs)
18111 ! qwctfzc(mgs) = qwctfz(mgs)
18112 ! qwctfzp(mgs) = 0.0
18122 ! Hobbs-Rangno ice enhancement (Ferrier, 1994)
18124 if (ndebug .gt. 0 ) write(0,*) 'conc 23a'
18126 hrifac = (1.e-3)*((0.044)*(0.01**3))
18134 IF ( ihrn .ge. 1 ) THEN
18135 if ( qx(mgs,lc) .gt. qxmin(lc) ) then
18136 if ( temg(mgs) .lt. 273.15 ) then
18137 ! write(iunit,'(3(1x,i3),3(1x,1pe12.5))')
18138 ! : igs(mgs),jgs,kgs(mgs),cx(mgs,lc),rho0(mgs),qx(mgs,lc)
18139 ! write(iunit,'(1pe15.6)')
18140 ! : log(cx(mgs,lc)*(1.e-6)/(3.0)),
18141 ! : ((1.e-3)*rho0(mgs)*qx(mgs,lc)),
18142 ! : (cx(mgs,lc)*(1.e-6)),
18143 ! : ((1.e-3)*rho0(mgs)*qx(mgs,lc))/(cx(mgs,lc)*(1.e-6)),
18144 ! : (alog(cx(mgs,lc)*(1.e-6)/(3.0)) *
18145 ! > ((1.e-3)*rho0(mgs)*qx(mgs,lc))/(cx(mgs,lc)*(1.e-6)))
18147 IF ( Log(cx(mgs,lc)*(1.e-6)/(3.0)) .gt. 0.0 ) THEN
18148 ciihr(mgs) = ((1.69e17)/dthr) &
18149 & *(log(cx(mgs,lc)*(1.e-6)/(3.0)) * &
18150 & ((1.e-3)*rho0(mgs)*qx(mgs,lc))/(cx(mgs,lc)*(1.e-6)))**(7./3.)
18151 ciihr(mgs) = ciihr(mgs)*(1.0e6)
18152 qiihr(mgs) = hrifac*ciihr(mgs)/rho0(mgs)
18153 qiihr(mgs) = max(qiihr(mgs), 0.0)
18154 qiihr(mgs) = min(qiihr(mgs),qcmxd(mgs))
18157 if ( xplate(mgs) .eq. 1 ) then
18158 qipiphr(mgs) = qiihr(mgs)
18159 cipiphr(mgs) = ciihr(mgs)
18162 if ( xcolmn(mgs) .eq. 1 ) then
18163 qicichr(mgs) = qiihr(mgs)
18164 cicichr(mgs) = ciihr(mgs)
18167 ! qipiphr(mgs) = 0.0
18168 ! qicichr(mgs) = qiihr(mgs)
18177 ! simple frozen rain to hail conversion. All of the
18178 ! frozen rain larger than 5.0e-3 m in diameter are converted
18179 ! to hail. This is done by considering the equation for
18180 ! frozen rain mixing ratio:
18183 ! qfw = [ cno(lf) * pi * fwdn / (6 rhoair) ]
18186 ! * | fwdia*3 exp(-dia/fwdia) d(dia)
18189 ! The amount to be reclassified as hail is the integral above from
18190 ! Do to inf where Do is 5.0e-3 m.
18193 ! qfauh = [ cno(lf) * pi * fwdn / (6 rhoair) ]
18203 ! IF ( .false. ) THEN
18204 ! IF ( temg(mgs) .lt. tfr .and. ssi(mgs) .gt. 1.01 .and. qx(mgs,li) .gt. qxmin(li) ) THEN
18205 IF ( temg(mgs) .lt. tfr .and. qx(mgs,li) .gt. qxmin(li) ) THEN
18206 IF ( ipconc .ge. 4 .and. .false. ) THEN
18207 if ( cx(mgs,li) .gt. 10. .and. xdia(mgs,li,1) .gt. 50.e-6 ) then !{
18209 & (qx(mgs,li)*rho0(mgs) &
18210 & /(pi*xdn(mgs,li)*cx(mgs,li)))**(1./3.)
18211 IF ( cirdiatmp .gt. 100.e-6 ) THEN !{
18213 & ((pi*xdn(mgs,li)*cx(mgs,li)) / (6.0*rho0(mgs)*dtp)) &
18214 & *exp(-hdia0/cirdiatmp) &
18215 & *( (hdia0**3) + 3.0*(hdia0**2)*cirdiatmp &
18216 & + 6.0*(hdia0)*(cirdiatmp**2) + 6.0*(cirdiatmp**3) )
18218 & min(qscnvi(mgs),qimxd(mgs))
18219 IF ( ipconc .ge. 4 ) THEN
18220 cscnvi(mgs) = Min( cimxd(mgs), cx(mgs,li)*Exp(-hdia0/cirdiatmp))
18225 ELSEIF ( ipconc .lt. 4 ) THEN
18227 qscnvi(mgs) = 0.001*eii(mgs)*max((qx(mgs,li)-1.e-3),0.0)
18228 qscnvi(mgs) = min(qscnvi(mgs),qxmxd(mgs,li))
18229 cscnvi(mgs) = qscnvi(mgs)*rho0(mgs)/xmas(mgs,li)
18230 cscnvis(mgs) = 0.5*cscnvi(mgs)
18240 ! Ventilation coeficients
18243 fvent(mgs) = (fschm(mgs)**(1./3.)) * (fakvisc(mgs)**(-0.5))
18247 if ( ndebug .gt. 0 ) write(0,*) 'civent'
18258 IF ( icond .eq. 1 .or. temg(mgs) .le. tfrh &
18259 & .or. (qx(mgs,lr) .le. qxmin(lr) .and. qx(mgs,lc) .le. qxmin(lc)) ) THEN
18260 IF ( qx(mgs,li) .gt. qxmin(li) ) THEN
18262 & (civenta*xdia(mgs,li,1)**civentb &
18263 & +civentc*xdia(mgs,li,1)**civentd) &
18265 & (civente*xdia(mgs,li,1)**civentf+civentg)
18266 xcivent = (fschm(mgs)**(1./3.))*((cireyn/fakvisc(mgs))**0.5)
18267 if ( xcivent .lt. 1.0 ) then
18268 civent(mgs) = 1.0 + 0.14*xcivent**2
18270 if ( xcivent .ge. 1.0 ) then
18271 civent(mgs) = 0.86 + 0.28*xcivent
18278 ENDIF ! icond .eq. 1
18284 igmrwb = 100.*((5.0+br)/2.0)
18285 rwventa = (0.78)*gmoi(igmrwa) ! 0.78
18286 rwventb = (0.308)*gmoi(igmrwb) ! 0.562825
18288 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
18289 IF ( ipconc .ge. 3 ) THEN
18290 IF ( imurain == 3 ) THEN
18291 IF ( izwisventr == 1 ) THEN
18292 rwvent(mgs) = ventrx(mgs)*(1.6 + 124.9*(1.e-3*rho0(mgs)*qx(mgs,lr))**.2046)
18293 ELSE ! izwisventr = 2
18294 ! Following Wisner et al. (1972) but using gamma of volume. Note that Ferrier rain fall speed does not integrate with gamma of volume, so using Vr = ar*d^br
18296 & (0.78*ventrx(mgs) + 0.308*ventrxn(mgs)*fvent(mgs) &
18297 & *Sqrt((ar*rhovt(mgs))) &
18298 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
18301 ELSE ! imurain == 1
18302 ! linear interpolation of complete gamma function
18303 ! tmp = 2. + alpha(mgs,lr)
18304 ! i = Int(dgami*(tmp))
18305 ! del = tmp - dgam*i
18306 ! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18308 IF ( iferwisventr == 1 ) THEN
18310 ! Ferrier fall speed in the ventillation term [uses fx(lr) ]
18312 alpr = Min(alpharmax,alpha(mgs,lr) )
18314 x = 1. + alpha(mgs,lr)
18316 IF ( ipconc >= 6 .and. lzr > 1 ) THEN ! 3 moment
18317 tmp = 1. + alpr ! alpha(mgs,lr)
18318 i = Int(dgami*(tmp))
18320 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18322 tmp = 2.5 + alpha(mgs,lr) + 0.5*bx(lr)
18323 i = Int(dgami*(tmp))
18325 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp ! ratio of gamma functions
18330 ! vent1 = dble(xdia(mgs,lr,1))**(-2. - alpr) ! Actually OK
18331 ! vent2 = dble(1./xdia(mgs,lr,1) + 0.5*fx(lr))**dble(2.5+alpr+0.5*bx(lr)) ! Actually OK
18332 vent1 = dble(xdia(mgs,lr,1))**(0.5 + 0.5*bx(lr)) ! 2016.2.26 Changed for consistency with derivation (recast formula -- should be equivalent)
18333 vent2 = dble(1. + 0.5*fx(lr)*xdia(mgs,lr,1))**dble(2.5+alpr+0.5*bx(lr))
18338 & 0.308*fvent(mgs)*y* &
18339 & Sqrt(ax(lr)*rhovt(mgs))*(vent1/vent2)
18345 ! & 0.308*fvent(mgs)*y* &
18346 ! & Sqrt(ax(lr)*rhovt(mgs))*(vent1/vent2)
18349 ELSEIF ( iferwisventr == 2 ) THEN
18351 ! Following Wisner et al. (1972) but using gamma of volume. Note that Ferrier rain fall speed does not integrate with gamma of volume, so using Vr = ar*d^br
18352 x = 1. + alpha(mgs,lr)
18355 & (0.78*x + 0.308*ventrxn(mgs)*fvent(mgs) &
18356 & *Sqrt((ar*rhovt(mgs))) &
18357 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
18360 IF ( ipconc >= 7 ) THEN
18361 alpr = Min(alpharmax,alpha(mgs,lr) )
18363 tmp = alpr + 5.5 + br/2.
18364 i = Int(dgami*(tmp))
18366 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18369 ! & 0.78*(4. + alpha(mgs,lr))*(3. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(1. + alpha(mgs,lr)) + &
18371 & 0.78*(4. + alpr)*(3. + alpr)*(2. + alpr)*(1. + alpr) + &
18372 & 0.308*fvent(mgs)* &
18373 & Sqrt(ax(lr)*rhovt(mgs))*(y/gf1palp(mgs))*(xdia(mgs,lr,1)**((1.0+br)/2.0))
18378 ENDIF ! iferwisventr
18383 & (rwventa + rwventb*fvent(mgs) &
18384 & *Sqrt((ar*rhovt(mgs))) &
18385 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
18393 igmswb = 100.*((5.0+ds)/2.0)
18394 swventa = (0.78)*gmoi(igmswa)
18395 swventb = (0.308)*gmoi(igmswb)
18397 IF ( qx(mgs,ls) .gt. qxmin(ls) ) THEN
18398 IF ( ipconc .ge. 4 ) THEN
18399 swvent(mgs) = 0.65 + 0.44*fvent(mgs)*Sqrt(vtxbar(mgs,ls,1)*xdia(mgs,ls,1))
18403 & (swventa + swventb*fvent(mgs) &
18404 & *Sqrt((cs*rhovt(mgs))) &
18405 & *(xdia(mgs,ls,1)**((1.0+ds)/2.0)) )
18415 igmhwb = 100.0*2.75
18416 hwventa = (0.78)*gmoi(igmhwa)
18417 hwventb = (0.308)*gmoi(igmhwb)
18418 ! hwventc = (4.0*gr/(3.0*cdx(lh)))**(0.25)
18423 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
18424 hwventc = (4.0*gr/(3.0*cdxgs(mgs,lh)))**(0.25)
18425 IF ( .false. .or. alpha(mgs,lh) .eq. 0.0 ) THEN
18427 & ( hwventa + hwventb*hwventc*fvent(mgs) &
18428 & *((xdn(mgs,lh)/rho0(mgs))**(0.25)) &
18429 & *(xdia(mgs,lh,1)**(0.75)))
18430 ELSE ! Ferrier 1994, eq. B.36
18431 ! linear interpolation of complete gamma function
18432 ! tmp = 2. + alpha(mgs,lh)
18433 ! i = Int(dgami*(tmp))
18434 ! del = tmp - dgam*i
18435 ! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18437 ! note that hwvent includes a division by Gamma(1+alpha), so Gamma(2+alpha)/Gamma(1+alpha) = 1 + alpha
18438 ! and g1palp = Gamma(1+alpha) divides into y
18439 x = 1. + alpha(mgs,lh)
18441 tmp = 1 + alpha(mgs,lh)
18442 i = Int(dgami*(tmp))
18444 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18446 tmp = 2.5 + alpha(mgs,lh) + 0.5*bxx(mgs,lh)
18447 i = Int(dgami*(tmp))
18449 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp
18452 hwventy(mgs) = 0.308*fvent(mgs)*(xdia(mgs,lh,1)**(0.5 + 0.5*bxx(mgs,lh)))*Sqrt(axx(mgs,lh)*rhovt(mgs))
18454 & ( 0.78*x + y*hwventy(mgs) ) ! &
18455 ! & 0.308*fvent(mgs)*y*(xdia(mgs,lh,1)**(0.5 + 0.5*bxx(mgs,lh)))* &
18456 ! & Sqrt(axx(mgs,lh)*rhovt(mgs)) )
18469 IF ( lhl .gt. 1 ) THEN
18471 igmhwb = 100.0*2.75
18472 hwventa = (0.78)*gmoi(igmhwa)
18473 hwventb = (0.308)*gmoi(igmhwb)
18474 ! hwventc = (4.0*gr/(3.0*cdx(lhl)))**(0.25)
18476 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
18477 hwventc = (4.0*gr/(3.0*cdxgs(mgs,lhl)))**(0.25)
18479 IF ( .false. .or. alpha(mgs,lhl) .eq. 0.0 ) THEN
18481 & ( hwventa + hwventb*hwventc*fvent(mgs) &
18482 & *((xdn(mgs,lhl)/rho0(mgs))**(0.25)) &
18483 & *(xdia(mgs,lhl,1)**(0.75)))
18484 ELSE ! Ferrier 1994, eq. B.36
18485 ! linear interpolation of complete gamma function
18486 ! tmp = 2. + alpha(mgs,lhl)
18487 ! i = Int(dgami*(tmp))
18488 ! del = tmp - dgam*i
18489 ! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18491 ! note that hlvent includes a division by Gamma(1+alpha), so x = Gamma(2+alpha)/Gamma(1+alpha) = 1 + alpha
18492 ! and g1palp = Gamma(1+alpha) divides into y
18494 x = 1. + alpha(mgs,lhl)
18496 tmp = 1 + alpha(mgs,lhl)
18497 i = Int(dgami*(tmp))
18499 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18501 tmp = 2.5 + alpha(mgs,lhl) + 0.5*bxx(mgs,lhl)
18502 i = Int(dgami*(tmp))
18504 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp ! ratio of gamma functions
18506 hlventy(mgs) = 0.308*fvent(mgs)*(xdia(mgs,lhl,1)**(0.5 + 0.5*bxx(mgs,lhl)))*Sqrt(axx(mgs,lhl)*rhovt(mgs))
18508 hlvent(mgs) = 0.78*x + y*hlventy(mgs) ! &
18509 ! & 0.308*fvent(mgs)*y*(xdia(mgs,lhl,1)**(0.5 + 0.5*bxx(mgs,lhl)))* &
18510 ! & Sqrt(axx(mgs,lhl)*rhovt(mgs)))
18511 ! : Sqrt(xdn(mgs,lhl)*ax(lhl)*rhovt(mgs)/rg0))/tmp
18521 ! Wet growth constants
18526 & ( felv(mgs)*fwvdf(mgs)*rho0(mgs)*(qss0(mgs)-qx(mgs,lv)) &
18527 & -ftka(mgs)*temcg(mgs) ) &
18528 & / ( rho0(mgs)*(felf(mgs)+fcw(mgs)*temcg(mgs)) )
18530 & (1.0)-fci(mgs)*temcg(mgs) &
18531 & / ( felf(mgs)+fcw(mgs)*temcg(mgs) )
18534 ! Melting constants
18537 fmlt1(mgs) = (2.0*pi)* &
18538 & ( felv(mgs)*fwvdf(mgs)*(qss0(mgs)-qx(mgs,lv)) &
18539 & -ftka(mgs)*temcg(mgs)/rho0(mgs) ) &
18541 fmlt2(mgs) = -fcw(mgs)*temcg(mgs)/felf(mgs)
18542 fmlt1e(mgs) = (2.0*pi)* &
18543 & ( felv(mgs)*fwvdf(mgs)*(qss0(mgs)-qx(mgs,lv)) ) / (felf(mgs))
18546 ! Vapor Deposition constants
18550 & (4.0*pi/rho0(mgs))*(ssi(mgs)-1.0)* &
18551 & (1.0/(fai(mgs)+fbi(mgs)))
18555 & (4.0*pi/rho0(mgs))*(ssw(mgs)-1.0)* &
18556 & (1.0/(fav(mgs)+fbv(mgs)))
18560 ! deposition, sublimation, and melting of snow, graupel and hail
18563 qimlr(:) = 0.0 ! this is not used. qi melts to qc way down in the code.
18566 IF ( lhwlg > 1 ) THEN
18597 ! chlmlrsave(:) = 0.0
18598 ! qhlmlrsave(:) = 0.0
18604 if ( .not. mixedphase ) then !{
18607 IF ( temg(mgs) .gt. tfr ) THEN
18609 IF ( qx(mgs,ls) .gt. qxmin(ls) ) THEN
18612 & (c1sw*fmlt1(mgs)*cx(mgs,ls)*swvent(mgs)*xdia(mgs,ls,1) ) & ! /rhosm &
18617 ! IF ( qx(mgs,ls) .gt. 0.1e-4 ) write(0,*) 'qsmlr: ',qsmlr(mgs),qx(mgs,ls),cx(mgs,ls),fmlt1(mgs),
18618 ! : temcg(mgs),swvent(mgs),xdia(mgs,ls,1),qss0(mgs)-qx(mgs,lv)
18624 ! > (fmlt1(mgs)*cx(mgs,ls)*swvent(mgs)*xdia(mgs,ls,1) +
18625 ! > fmlt2(mgs)*(qsacr(mgs)+qsacw(mgs)) )
18628 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
18630 IF ( ibinhmlr == 0 .or. lzh < 1 ) THEN
18633 & fmlt1(mgs)*cx(mgs,lh)*hwvent(mgs)*xdia(mgs,lh,1) &
18634 & + fmlt2(mgs)*(qhacrmlr(mgs)+qhacwmlr(mgs)) &
18636 ELSEIF ( ibinhmlr == 1 ) THEN ! use incomplete gamma functions to approximate the bin results
18638 write(0,*) 'ibinhmlr = 1 not available for 2-moment'
18641 ELSEIF ( ibinhmlr == 2 .or. ibinhmlr == 3 ) THEN
18646 IF ( ivhmltsoak > 0 .and. qhmlr(mgs) < 0.0 .and. lvol(lh) > 1 .and. xdn(mgs,lh) .lt. xdnmx(lh) ) THEN
18647 ! act as if 100% of the meltwater were soaked into the graupel
18648 v1 = (1. - xdn(mgs,lh)/xdnmx(lh))*(vx(mgs,lh) + rho0(mgs)*qhmlr(mgs)/xdn(mgs,lh) )/(dtp) ! volume available for filling
18649 v2 = -1.0*rho0(mgs)*qhmlr(mgs)/xdnmx(lh) ! volume of melted ice if it were refrozen in the matrix
18651 vhsoak(mgs) = Min(v1,v2)
18655 ENDIF ! qx(mgs,lh) .gt. qxmin(lh)
18658 IF ( lhl .gt. 1 .and. lhlw < 1 ) THEN
18660 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
18661 IF ( ibinhlmlr == 0 .or. lzhl < 1) THEN
18664 & fmlt1(mgs)*cx(mgs,lhl)*hlvent(mgs)*xdia(mgs,lhl,1) &
18665 & + fmlt2(mgs)*(qhlacrmlr(mgs)+qhlacwmlr(mgs)) &
18668 ELSEIF ( ibinhlmlr == 1 ) THEN ! use incomplete gamma functions to approximate the bin results
18671 ! #if (defined 1) && defined( COMMAS ) || defined( COMMASTMP )
18673 ELSEIF ( ibinhlmlr == -1 ) THEN ! OLD VERSION use incomplete gamma functions to approximate the bin results
18678 IF ( ivhmltsoak > 0 .and. qhlmlr(mgs) < 0.0 .and. lvol(lhl) > 1 .and. xdn(mgs,lhl) .lt. xdnmx(lhl) ) THEN
18679 ! act as if 50% of the meltwater were soaked into the graupel
18680 v1 = (1. - xdn(mgs,lhl)/xdnmx(lhl))*(vx(mgs,lhl) + rho0(mgs)*qhlmlr(mgs)/xdn(mgs,lhl) )/(dtp) ! volume available for filling
18681 v2 = -1.0*rho0(mgs)*qhlmlr(mgs)/xdnmx(lhl) ! volume of melted ice if it were refrozen in the matrix
18683 vhlsoak(mgs) = Min(v1,v2)
18693 ! qimlr(mgs) = max( qimlr(mgs), -qimxd(mgs) )
18694 ! qsmlr(mgs) = max( qsmlr(mgs), -qsmxd(mgs) )
18695 ! erm 5/10/2007 changed to next line:
18696 if ( .not. mixedphase ) qsmlr(mgs) = max( qsmlr(mgs), Min( -qsmxd(mgs), -0.7*qx(mgs,ls)*dtpinv ) )
18697 IF ( .not. mixedphase ) THEN
18698 qhmlr(mgs) = max( qhmlr(mgs), Min( -qhmxd(mgs), -0.95*qx(mgs,lh)*dtpinv ) )
18699 chmlr(mgs) = max( chmlr(mgs), Min( -chmxd(mgs), -0.95*cx(mgs,lh)*dtpinv ) )
18701 ! qhmlr(mgs) = max( max( qhmlr(mgs), -qhmxd(mgs) ) , -0.5*qx(mgs,lh)*dtpinv ) !limits to 1/2 qh or max depletion
18702 qhmlh(mgs) = 0. ! not used
18705 ! Rasmussen and Heymsfield say melt water remains on graupel up to 9 mm before shedding
18708 IF ( lhl .gt. 1 .and. lhlw < 1 ) THEN
18709 qhlmlr(mgs) = max( qhlmlr(mgs), Min( -qxmxd(mgs,lhl), -0.95*qx(mgs,lhl)*dtpinv ) )
18710 chlmlr(mgs) = max( chlmlr(mgs), Min( -cxmxd(mgs,lhl), -0.95*cx(mgs,lhl)*dtpinv ) )
18716 endif ! } not mixedphase
18718 if ( ipconc .ge. 1 ) then
18720 cimlr(mgs) = (cx(mgs,li)/(qx(mgs,li)+1.e-20))*qimlr(mgs)
18721 IF ( .not. mixedphase ) THEN !{
18722 IF ( xdia(mgs,ls,1) .gt. 1.e-6 .and. -qsmlr(mgs) .ge. 0.5*qxmin(ls) .and. ipconc .ge. 4 ) THEN
18723 ! csmlr(mgs) = rho0(mgs)*qsmlr(mgs)/(xv(mgs,ls)*rhosm)
18724 csmlr(mgs) = (cx(mgs,ls)/(qx(mgs,ls)))*qsmlr(mgs)
18725 ELSEIF ( qx(mgs,ls) > qxmin(ls) ) THEN
18726 csmlr(mgs) = (cx(mgs,ls)/(qx(mgs,ls)))*qsmlr(mgs)
18729 csmlrr(mgs) = csmlr(mgs)/rzxs(mgs)
18730 IF ( -csmlrr(mgs)*dtp > cxmin .and. -qsmlr(mgs)*dtp > qxmin(lr) .and. snowmeltdia > 0.0 ) THEN
18731 rmas = rho0(mgs)*qsmlr(mgs)/csmlrr(mgs)
18732 IF ( rmas > snowmeltmass ) THEN
18733 csmlrr(mgs) = rho0(mgs)*qsmlr(mgs)/snowmeltmass
18739 ! IF ( xdia(mgs,lh,1) .gt. 1.e-6 .and. Abs(qhmlr(mgs)) .ge. qxmin(lh) ) THEN
18740 ! chmlr(mgs) = rho0(mgs)*qhmlr(mgs)/(pi*xdn(mgs,lh)*xdia(mgs,lh,1)**3) ! out of hail
18741 ! chmlr(mgs) = Max( chmlr(mgs), -chmxd(mgs) )
18743 IF ( ibinhmlr == 0 .or. lzh < 1 ) THEN
18744 chmlr(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhmlr(mgs)
18745 IF ( imltshddmr == 3 .and. qhmlr(mgs) < -qxmin(lh) ) THEN
18746 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
18748 ! IF ( tmpdiam > sheddiam ) THEN ! let size get smaller until it reaches sheddiam
18752 ! test to remove the part of the melting associated with large ice particles so they get smaller
18754 tmp = 1. + alpha(mgs,lh)
18755 i = Int(dgami*(tmp))
18757 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18759 ratio = Min( maxratiolu, mltdiam1/xdia(mgs,lh,1) )
18761 x = gamxinfdp(2. + alpha(mgs,lh), ratio)/g1palp
18762 y = gamxinfdp(2.5 + alpha(mgs,lh) + 0.5*bxx(mgs,lh), ratio)/g1palp
18764 hwvent1 = 0.78*x + y*hwventy(mgs)
18766 qhlmlr1 = min( fmlt1(mgs)*cx(mgs,lh)*hwvent1*xdia(mgs,lh,1), 0.0 )
18768 chmlr(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*(qhmlr(mgs) - qhlmlr1)
18772 ! IF ( igs(mgs) == 40 ) THEN
18773 ! write(0,*) 'is this running? chmlr = ',kgs(mgs), chmlr(mgs)
18779 IF ( chmlr(mgs) < 0.0 .and. (ibinhmlr < 1 .or. lzh < 1) ) THEN ! { already done if ibinhmlr > 0
18780 IF ( ipconc >= 6 .and. lzr .gt. 1 .and. lzh < 1 .and. qx(mgs,lh) > qxmin(lh) ) THEN ! Only compute if rain is 3-moment but graupel is not, otherwise is computed later
18781 tmp = qx(mgs,lh)/cx(mgs,lh)
18782 alp = alpha(mgs,lh)
18783 g1 = g1x(mgs,lh) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
18785 zhmlr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*tmp * qhmlr(mgs) - tmp**2 * chmlr(mgs) )
18789 IF ( ibinhmlr == 0 .or. lzh < 1 ) THEN
18790 IF ( ihmlt .eq. 1 ) THEN
18791 chmlrr(mgs) = Min( chmlr(mgs), rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*vmlt) ) ! into rain
18792 ELSEIF ( ihmlt .eq. 2 ) THEN
18793 IF ( xv(mgs,lh) .gt. 0.0 .and. chmlr(mgs) .lt. 0.0 ) THEN
18794 ! chmlrr(mgs) = Min( chmlr(mgs), rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lh)*xv(mgs,lh)) ) ! into rain
18795 ! guess what, this is the same as chmlr: rho0*qhmlr/xmas(lh) --> cx/qx = rho0/xmas
18796 IF(imltshddmr == 1) THEN
18797 ! DTD: If Dmg < sheddiam, then assume complete melting into
18798 ! maximal raindrop. Between sheddiam and sheddiam0 mm, linearly ramp down to a 3 mm shed drop
18799 tmp = -rho0(mgs)*qhmlr(mgs)/(Min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lh)*xv(mgs,lh))) ! Min of Maximum raindrop size/mean hail size
18800 tmp2 = -rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*vr3mm) ! conc. change for a 3 mm mean drop diameter
18802 chmlrr(mgs) = tmp*(sheddiam0-xdia(mgs,lh,3))/(sheddiam0-sheddiam)+tmp2*(xdia(mgs,lh,3)-sheddiam)/(sheddiam0-sheddiam) ! old version
18803 chmlrr(mgs) = -Max(tmp,Min(tmp2,chmlrr(mgs)))
18804 ELSEIF ( imltshddmr == 2 .or. imltshddmr == 3 ) THEN
18805 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
18806 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
18807 chmlrr(mgs) = rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lh)) ! into rain
18809 chmlrr(mgs) = rho0(mgs)*qhmlr(mgs)/(Min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lh)*xv(mgs,lh))) ! into rain
18812 chmlrr(mgs) = chmlr(mgs)
18814 ELSEIF ( ihmlt .eq. 0 ) THEN
18815 chmlrr(mgs) = chmlr(mgs)
18818 ELSE ! ibinhmlr < 0? Already have an outer IF test for ibinhmlr < 1
18819 chmlrr(mgs) = Min( chmlrr(mgs), rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*xvmx(lr)) ) ! into rain
18822 ENDIF ! } ( chmlr(mgs) < 0.0 .and. ibinhmlr < 1)
18824 IF ( lhl .gt. 1 .and. lhlw < 1 .and. .not. mixedphase .and. qhlmlr(mgs) < 0.0 ) THEN ! {
18826 IF ( ibinhlmlr == 0 .or. lzhl < 1 ) THEN
18827 ! IF ( xdia(mgs,lhl,1) .gt. 1.e-6 .and. Abs(qhlmlr(mgs)) .ge. qxmin(lhl) ) THEN
18828 ! chlmlr(mgs) = rho0(mgs)*qhlmlr(mgs)/(pi*xdn(mgs,lhl)*xdia(mgs,lhl,1)**3) ! out of hail
18829 ! chlmlr(mgs) = Max( chlmlr(mgs), -cxmxd(mgs,lhl) )
18831 chlmlr(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlmlr(mgs)
18832 IF ( imltshddmr == 3 .and. qhlmlr(mgs) < -qxmin(lhl) ) THEN
18833 ! IF ( .false. .and. imltshddmr == 3 ) THEN
18834 ! tmpdiam = (shedalp+alpha(mgs,lhl))*xdia(mgs,lhl,1)
18836 ! IF ( tmpdiam > sheddiam ) THEN ! let size get smaller until it reaches sheddiam
18837 ! chlmlr(mgs) = 0.0
18840 ! test to remove the part of the melting associated with large ice particles so they get smaller
18842 tmp = 1. + alpha(mgs,lhl)
18843 i = Int(dgami*(tmp))
18845 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18847 ratio = Min( maxratiolu, mltdiam1/xdia(mgs,lhl,1) )
18849 x = gamxinfdp(2. + alpha(mgs,lhl), ratio)/g1palp
18850 y = gamxinfdp(2.5 + alpha(mgs,lhl) + 0.5*bxx(mgs,lhl), ratio)/g1palp
18852 hwvent1 = 0.78*x + y*hlventy(mgs)
18854 qhlmlr1 = min( fmlt1(mgs)*cx(mgs,lhl)*hwvent1*xdia(mgs,lhl,1), 0.0 )
18856 chlmlr(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*Min(0.0, qhlmlr(mgs) - qhlmlr1)
18862 IF ( ibinhlmlr == 0 .or. lzhl < 1 ) THEN !{
18863 IF ( ihmlt .eq. 1 ) THEN
18864 chlmlrr(mgs) = Min( chlmlr(mgs), rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*vmlt) ) ! into rain
18865 ELSEIF ( ihmlt .eq. 2 ) THEN
18866 IF ( xv(mgs,lhl) .gt. 0.0 .and. chlmlr(mgs) .lt. 0.0 ) THEN
18867 ! chlmlrr(mgs) = rho0(mgs)*qhlmlr(mgs)/(Min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lhl)*xv(mgs,lhl))) ! into rain
18868 ! chlmlrr(mgs) = Min( chlmlr(mgs), rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lhl)*xv(mgs,lhl)) ) ! into rain
18869 IF(imltshddmr == 1 ) THEN
18870 tmp = -rho0(mgs)*qhlmlr(mgs)/(Min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lhl)*xv(mgs,lhl))) ! Min of Maximum raindrop size/mean hail size
18871 tmp2 = -rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*vr3mm) ! conc. change for a 3 mm mean drop diameter
18872 chlmlrr(mgs) = tmp*(20.e-3-xdia(mgs,lhl,3))/(20.e-3-sheddiam)+tmp2*(xdia(mgs,lhl,3)-sheddiam)/(20.e-3-sheddiam)
18873 chlmlrr(mgs) = -Max(tmp,Min(tmp2,chlmlrr(mgs)))
18874 ELSEIF ( imltshddmr == 2 .or. imltshddmr == 3 ) THEN
18875 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
18876 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
18877 chlmlrr(mgs) = rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lhl)) ! into rain
18879 chlmlrr(mgs) = rho0(mgs)*qhlmlr(mgs)/(Min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lhl)*xv(mgs,lhl))) ! into rain
18882 chlmlrr(mgs) = chlmlr(mgs)
18884 ELSEIF ( ihmlt .eq. 0 ) THEN
18885 chlmlrr(mgs) = chlmlr(mgs)
18888 ELSE ! } { ibinhlmlr > 0
18889 chlmlrr(mgs) = Min( chlmlrr(mgs), rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*xvmx(lr)) ) ! into rain
18893 IF ( ipconc >= 8 .and. lzhl .gt. 1 .and. ibinhlmlr <= 0 ) THEN
18894 IF ( cx(mgs,lhl) > 0.0 ) THEN
18896 tmp = qx(mgs,lhl)/cx(mgs,lhl)
18897 alp = alpha(mgs,lhl)
18898 ! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
18899 g1 = g1x(mgs,lhl) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
18901 zhlmlr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( tmp * qhlmlr(mgs) )
18906 ENDIF ! }.not. mixedphase
18909 ! chmlr(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhmlr(mgs)
18910 ! chmlrr(mgs) = chmlr(mgs)
18915 ! deposition/sublimation of ice
18919 rwcap(mgs) = (0.5)*xdia(mgs,lr,1)
18920 swcap(mgs) = (0.5)*xdia(mgs,ls,1)
18921 hwcap(mgs) = (0.5)*xdia(mgs,lh,1)
18922 IF ( lhl .gt. 1 ) hlcap(mgs) = (0.5)*xdia(mgs,lhl,1)
18924 if ( qx(mgs,li).gt.qxmin(li) .and. xdia(mgs,li,1) .gt. 0.0 ) then
18926 ! from Cotton, 1972 (Part II)
18928 cilen(mgs) = 0.4764*(xdia(mgs,li,1))**(0.958)
18929 cval = xdia(mgs,li,1)
18931 eval = Sqrt(1.0-(aval**2)/(cval**2))
18932 fval = min(0.99,eval)
18933 gval = alog( abs( (1.+fval)/(1.-fval) ) )
18934 cicap(mgs) = cval*fval / gval
18945 IF ( icond .eq. 1 .or. temg(mgs) .le. tfrh &
18946 & .or. (qx(mgs,lr) .le. qxmin(lr) .and. qx(mgs,lc) .le. qxmin(lc)) ) THEN
18948 & fvds(mgs)*cx(mgs,li)*civent(mgs)*cicap(mgs)*depfac
18950 & fvds(mgs)*cx(mgs,ls)*swvent(mgs)*swcap(mgs)*depfac
18952 ! IF ( ny .eq. 2 .and. igs(mgs) .eq. 302 .and. temg(mgs) .le. tfrh+10 .and. qx(mgs,lv) .gt. qis(mgs)
18953 ! : .and. qx(mgs,li) .gt. qxmin(li) ) THEN
18954 ! write(0,*) 'qidsv = ',nstep,kgs(mgs),qidsv(mgs),temg(mgs)-tfrh,100.*(qx(mgs,lv)/qis(mgs) - 1.),1.e6*xdia(mgs,li,1),
18955 ! : fvds(mgs),civent(mgs),cicap(mgs)
18962 & fvds(mgs)*cx(mgs,lh)*hwvent(mgs)*hwcap(mgs)*depfac
18964 IF ( lhl .gt. 1 ) qhldsv(mgs) = fvds(mgs)*cx(mgs,lhl)*hlvent(mgs)*hlcap(mgs)*depfac
18971 ! #include "nssl.qlimit.F"
18974 ! Use a test saturation adjustment to set limits on ice deposition/sublimation
18975 ! and rain evaporation
18978 IF ( DoSublimationFix ) THEN
18982 qitmp(mgs) = qx(mgs,li) + qx(mgs,ls) + qx(mgs,lh)
18983 IF ( lis > 1 ) qitmp(mgs) = qitmp(mgs) + qx(mgs,lis)
18984 IF ( lhl > 1 ) qitmp(mgs) = qitmp(mgs) + qx(mgs,lhl)
18985 qrtmp(mgs) = qx(mgs,lr)
18986 qctmp(mgs) = qx(mgs,lc)
18987 qsimxdep(mgs) = 0.0
18988 qsimxsub(mgs) = 0.0
18992 ! IF ( ( qitmp(mgs) > qxmin(li) .or. qrtmp(mgs) > qxmin(lr) ) ) THEN
18993 IF ( qitmp(mgs) > qxmin(li) ) THEN
18995 qitmp1 = qitmp(mgs)
18996 qctmp1 = qctmp(mgs)
18997 felvcptmp = felvcp(mgs)
18998 felscptmp = felscp(mgs)
18999 qvtmp(mgs) = qx(mgs,lv)
19000 qss(mgs) = qvs(mgs)
19004 thetatmp = theta(mgs)
19005 thetaptmp = thetap(mgs)
19006 temgtmp = temg(mgs)
19007 temcgtmp = temcg(mgs)
19008 qvaptmp = qx(mgs,lv) ! qwvp(mgs) + qv0(mgs)
19009 qvptmp = 0.0 ! qwvp(mgs) ! qv pertubation
19014 dqwvtmp(mgs) = ( qvtmp(mgs) - qsstmp )
19019 ! calculate super-saturation
19021 IF ( itertd == 1 ) THEN
19024 dqcitmp(mgs) = dqci(mgs)
19025 ! dqwvtmp(mgs) = dqwv(mgs)
19030 dqwv(mgs) = ( qvtmp(mgs) - qsstmp )
19032 ! evaporation and sublimation adjustment
19034 if( dqwv(mgs) .lt. 0. ) then ! { subsaturated
19035 if( qitmp(mgs) .gt. -dqwv(mgs) ) then ! check if qi can make up all the deficit
19036 dqci(mgs) = dqwv(mgs)
19038 else ! otherwise make all ice available for sublimation
19039 dqci(mgs) = -qitmp(mgs)
19040 dqwv(mgs) = dqwv(mgs) + qitmp(mgs)
19043 qvptmp = qvptmp - ( dqcw(mgs) + dqci(mgs) ) ! add to perturbation vapor
19045 IF ( itertd == 2 .and. eqtset > 1 ) THEN
19046 ! if eqtset == 2, then need to update the latent heats for change in hydrometeor content
19047 tmp = qitmp(mgs) !+ qx(mgs,lh)
19048 ! IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
19049 cvm = cv+cvv*qvtmp(mgs)+cpl*(qx(mgs,lc)+qrtmp(mgs)) &
19052 felvcptmp = (felv(mgs)-rw*temg(mgs))/cvm
19053 felscptmp = (fels(mgs)-rw*temg(mgs))/cvm
19057 ! qitmp(mgs) = qx(mgs,li)
19058 qctmp(mgs) = qctmp(mgs) + dqcw(mgs) ! dqcw is zero
19059 qitmp(mgs) = qitmp(mgs) + dqci(mgs)
19060 thetaptmp = thetaptmp + &
19062 & (felvcp(mgs)*dqcw(mgs) +felscp(mgs)*dqci(mgs))
19065 end if ! } dqwv(mgs) .lt. 0. (end of evap/sublim)
19067 ! condensation/deposition
19069 IF ( dqwv(mgs) .ge. 0. ) THEN ! {
19071 ! write(iunit,*) 'satadj: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qx(mgs,lv),qx(mgs,lc)
19073 ! qitmp(mgs) = qx(mgs,li)
19076 if ( temg(mgs) .lt. tfr .and. temg(mgs) .gt. thnuc ) then
19077 ! fracl(mgs) = max(min(1.,(temg(mgs)-233.15)/(20.)),0.0)
19078 ! fraci(mgs) = 1.0-fracl(mgs)
19080 if ( temg(mgs) .le. thnuc ) then
19084 ! fraci(mgs) = 1.0-fracl(mgs)
19086 gamss = (felvcp(mgs)*fracl(mgs) + felscp(mgs)*fraci(mgs)) &
19089 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv2(mgs)*qsstmp/ &
19090 & ((temg(mgs)-cbi)**2))
19092 if ( temg(mgs) .ge. tfr ) then
19093 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qsstmp/ &
19094 & ((temg(mgs)-cbw)**2))
19100 dqcw(mgs) = dqvcnd(mgs)*fracl(mgs) ! is zero
19101 dqci(mgs) = dqvcnd(mgs)*fraci(mgs)
19103 thetaptmp = thetaptmp + &
19104 & (felvcp(mgs)*dqcw(mgs) + felscp(mgs)*dqci(mgs)) &
19107 qvptmp = qvptmp - ( dqvcnd(mgs) )
19108 qctmp(mgs) = qctmp(mgs) + dqcw(mgs)
19109 qitmp(mgs) = qitmp(mgs) + dqci(mgs)
19111 IF ( itertd == 2 .and. eqtset > 1 ) THEN
19112 ! if eqtset == 2, then need to update the latent heats for change in hydrometeor content
19113 tmp = qitmp(mgs) ! + qx(mgs,lh)
19114 ! IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
19115 cvm = cv+cvv*qvtmp(mgs)+cpl*(qctmp(mgs) +qrtmp(mgs)) &
19118 felvcptmp = (felv(mgs)-rw*temg(mgs))/cvm
19119 felscptmp = (fels(mgs)-rw*temg(mgs))/cvm
19122 IF ( eqtset > 2 ) THEN
19123 pipert(mgs) = pipert(mgs) + (0 &
19124 & +felspi(mgs)*dqci(mgs) &
19125 & +felvpi(mgs)*dqcw(mgs))*dtp
19130 END IF ! } dqwv(mgs) .ge. 0.
19134 IF ( itertd == 1 ) THEN
19135 ! update temporary saturation values
19137 thetatmp = thetaptmp + theta0(mgs)
19138 temgtmp = thetatmp*pk(mgs) ! ( pres(mgs) / poo ) ** cap
19139 qvaptmp = Max((qvptmp + qv0(mgs)), 0.0)
19140 temcgtmp = temgtmp - tfr
19141 tqvcon = temgtmp-cbw
19142 ltemq = (temgtmp-163.15)/fqsat+1.5
19143 ltemq = Min( nqsat, Max(1,ltemq) )
19144 qvstmp = pqs(mgs)*tabqvs(ltemq)
19145 qisstmp = pqs(mgs)*tabqis(ltemq)
19146 qctmp(mgs) = max( 0.0, qctmp(mgs) )
19147 qitmp(mgs) = max( 0.0, qitmp(mgs) )
19148 qvtmp(mgs) = max( 0.0, qvaptmp )
19154 ! set max depletion
19155 qctmp(mgs) = max( 0.0, qctmp(mgs) )
19156 qitmp(mgs) = max( 0.0, qitmp(mgs) )
19158 IF ( qitmp(mgs) < qitmp1 ) THEN
19159 qsimxsub(mgs) = (qitmp1 - qitmp(mgs))*dtpinv
19160 ELSEIF ( qitmp(mgs) > qitmp1 ) THEN
19161 qsimxdep(mgs) = (qitmp(mgs) - qitmp1)*dtpinv
19166 ! pceds(mgs) = (thetap(mgs) - thsave(mgs))*dtpinv
19167 ! write(iunit,*) 'satadj2: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qxtmp,qctmp(mgs)
19169 ! end the saturation adjustment iteration loop
19180 qsimxdep(mgs) = qvimxd(mgs)
19181 qsimxsub(mgs) = 1.e20
19202 IF ( icond .eq. 1 .or. temg(mgs) .le. tfrh &
19203 & .or. (qx(mgs,lr) .le. qxmin(lr) .and. qx(mgs,lc) .le. qxmin(lc)) ) THEN ! last condition (qr<qmin & qc<qmin) for case icond=0
19204 ! qisbv(mgs) = max( min(qidsv(mgs), 0.0), -qimxd(mgs) )
19205 ! qssbv(mgs) = max( min(qsdsv(mgs), 0.0), -qsmxd(mgs) )
19207 qisbv(mgs) = max( min(qidsv(mgs), 0.0), Min( -qimxd(mgs), -0.5*qx(mgs,li)*dtpinv ) )
19208 IF ( temg(mgs) < tfr .or. .not. qsmlr(mgs) < 0.0 ) THEN
19209 qssbv(mgs) = max( min(qsdsv(mgs), 0.0), Min( -qsmxd(mgs), -0.5*qx(mgs,ls)*dtpinv ) )
19211 qidpv(mgs) = Max(qidsv(mgs), 0.0)
19212 qsdpv(mgs) = Max(qsdsv(mgs), 0.0)
19214 IF ( qsmlr(mgs) < 0.0 .and. .not. mixedphase ) THEN ! switch snow sublimation to evaporation if there is melting
19216 qscev(mgs) = evapfac* &
19217 & 4.0*pi*(qx(mgs,lv)-qss0(mgs))*cx(mgs,ls)*swcap(mgs)*swvent(mgs)/(qss0(mgs)*(fav(mgs)+fbv(mgs)))
19218 qscev(mgs) = Max( Min(0.0,qscev(mgs)), Min( -qsmxd(mgs), -0.5*qx(mgs,ls)*dtpinv ) )
19234 IF ( qx(mgs,lh) > qxmin(lh) ) THEN
19235 IF ( temg(mgs) < tfr .or. .not. qhmlr(mgs) < 0.0 ) THEN
19236 ! no liquid from melting, so evaporation is greater. Thus can calculate sublimation rate
19237 qhsbv(mgs) = max( min(qhdsv(mgs), 0.0), -qhmxd(mgs) )
19238 qhdpv(mgs) = Max(qhdsv(mgs), 0.0)
19241 IF ( .true. .and. qhmlr(mgs) < 0.0 .and. .not. mixedphase ) THEN
19242 ! Liquid is forming, so find the evaporation that was subtracted from melting (if it is not condensing)
19245 ! & fmlt1e(mgs)*cx(mgs,lh)*hwvent(mgs)*xdia(mgs,lh,1), 0.0 )
19247 qhcev(mgs) = evapfac*2.0*pi*(qx(mgs,lv)-qss0(mgs))* &
19248 & cx(mgs,lh)*xdia(mgs,lh,1)*hwvent(mgs)/(qss0(mgs)*(fav(mgs)+fbv(mgs)))
19250 qhcev(mgs) = max(qhcev(mgs), -qhmxd(mgs))
19251 IF ( temg(mgs) > tfr ) qhcev(mgs) = Min(0.0, qhcev(mgs) )
19259 IF ( lhl .gt. 1 ) THEN
19260 IF ( qx(mgs,lhl) > qxmin(lhl) ) THEN
19261 IF ( temg(mgs) < tfr .or. .not. qhlmlr(mgs) < 0.0 ) THEN
19262 qhlsbv(mgs) = max( min(qhldsv(mgs), 0.0), -qxmxd(mgs,lhl) )
19263 qhldpv(mgs) = Max(qhldsv(mgs), 0.0)
19265 IF ( qhlmlr(mgs) < 0.0 .and. .not. mixedphase ) THEN
19266 ! Liquid is forming, so find the evaporation that was subtracted from melting (if it is not condensing)
19267 qhlcev(mgs) = evapfac*2.0*pi*(qx(mgs,lv)-qss0(mgs))* &
19268 & cx(mgs,lhl)*xdia(mgs,lhl,1)*hlvent(mgs)/(qss0(mgs)*(fav(mgs)+fbv(mgs)))
19270 qhlcev(mgs) = max(qhlcev(mgs), -qhlmxd(mgs))
19271 IF ( temg(mgs) > tfr ) qhlcev(mgs) = Min(0.0, qhlcev(mgs) )
19277 temp1 = qidpv(mgs) + qsdpv(mgs) + qhdpv(mgs) + qhldpv(mgs)
19279 ! IF ( temp1 .gt. qvimxd(mgs) ) THEN
19281 ! frac = qvimxd(mgs)/temp1
19283 IF ( temp1 .gt. qsimxdep(mgs) ) THEN
19284 frac = qsimxdep(mgs)/temp1
19286 qidpv(mgs) = frac*qidpv(mgs)
19287 qsdpv(mgs) = frac*qsdpv(mgs)
19288 qhdpv(mgs) = frac*qhdpv(mgs)
19289 qhldpv(mgs) = frac*qhldpv(mgs)
19291 ! IF ( ny .eq. 2 .and. igs(mgs) .eq. 302 .and. temg(mgs) .le. tfrh+10 .and. qx(mgs,lv) .gt. qis(mgs)
19292 ! : .and. qx(mgs,li) .gt. qxmin(li) ) THEN
19293 ! write(0,*) 'qidpv,frac = ',kgs(mgs),qidpv(mgs),frac
19298 temp1 = qisbv(mgs) + qssbv(mgs) + qhsbv(mgs) + qhlsbv(mgs)
19301 IF ( temp1 < -qsimxsub(mgs) ) THEN
19302 frac = -qsimxsub(mgs)/temp1
19304 qisbv(mgs) = frac*qisbv(mgs)
19305 qssbv(mgs) = frac*qssbv(mgs)
19306 qhsbv(mgs) = frac*qhsbv(mgs)
19307 qhlsbv(mgs) = frac*qhlsbv(mgs)
19309 ! IF ( ny .eq. 2 .and. igs(mgs) .eq. 302 .and. temg(mgs) .le. tfrh+10 .and. qx(mgs,lv) .gt. qis(mgs)
19310 ! : .and. qx(mgs,li) .gt. qxmin(li) ) THEN
19311 ! write(0,*) 'qidpv,frac = ',kgs(mgs),qidpv(mgs),frac
19320 if ( ipconc .ge. 1 ) then
19322 cssbv(mgs) = (cx(mgs,ls)/(qx(mgs,ls)+1.e-20))*qssbv(mgs)
19323 cisbv(mgs) = (cx(mgs,li)/(qx(mgs,li)+1.e-20))*qisbv(mgs)
19324 chsbv(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhsbv(mgs)
19325 IF ( lhl .gt. 1 ) chlsbv(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlsbv(mgs)
19326 csdpv(mgs) = 0.0 ! (cx(mgs,ls)/(qx(mgs,ls)+1.e-20))*qsdpv(mgs)
19327 cidpv(mgs) = 0.0 ! (cx(mgs,li)/(qx(mgs,li)+1.e-20))*qidpv(mgs)
19329 chdpv(mgs) = 0.0 ! (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhdpv(mgs)
19335 ! Aggregation or size conversion of small crystals to snow
19337 if (ndebug .gt. 0 ) write(0,*) 'conc 29a'
19342 if ( ipconc .ge. 4 .and. iscni .ge. 1 .and. qx(mgs,li) .gt. qxmin(li) ) then
19343 IF ( iscni .eq. 1 ) THEN
19345 & pi*rho0(mgs)*((0.25)/(6.0)) &
19346 & *eii(mgs)*(qx(mgs,li)**2)*(xdia(mgs,li,2)) &
19347 & *vtxbar(mgs,li,1)/xmas(mgs,li)
19348 cscni(mgs) = Min(cimxd(mgs),qscni(mgs)*rho0(mgs)/xmas(mgs,li))
19349 cscnis(mgs) = 0.5*cscni(mgs)
19350 ELSEIF ( iscni .eq. 2 .or. iscni .eq. 4 .or. iscni .eq. 5 ) THEN ! Zeigler 1985/Zrnic 1993, sort of
19351 IF ( iscni .ne. 5 .and. qidpv(mgs) .gt. 0.0 .and. xdia(mgs,li,3) .ge. 100.e-6 ) THEN
19352 ! convert larger crystals to snow
19353 ! IF ( xdia(mgs,ls,3) .gt. xdia(mgs,li,3) ) THEN
19354 ! qscni(mgs) = Max(0.1,xdia(mgs,li,3)/xdia(mgs,ls,3))*qidpv(mgs)
19355 ! erm 9/5/08 changed max to min
19356 qscni(mgs) = Min(0.5, xdia(mgs,li,3)/200.e-6)*qidpv(mgs)
19358 ! qscni(mgs) = 0.1*qidpv(mgs)
19360 cscni(mgs) = fscni*qscni(mgs)*rho0(mgs)/Max(rho_qs*xvmn(ls),xmas(mgs,li))
19361 ! cscni(mgs) = fscni*Min(cimxd(mgs),qscni(mgs)*rho0(mgs)/Max(xdn(mgs,ls)*xvmn(ls),xmas(mgs,li)))
19362 ! cscni(mgs) = Min(cimxd(mgs),qscni(mgs)*rho0(mgs)/xmas(mgs,li) )
19363 ! IF ( xdia(mgs,ls,3) .le. 200.e-6 ) THEN
19364 cscnis(mgs) = cscni(mgs)
19366 ! cscnis(mgs) = 0.0
19370 IF ( iscni .ne. 4 ) THEN
19371 ! crystal aggregation to become snow
19372 ! erm 9/5/08 commented second line and added xv to 1st line (zrnic et al 1993)
19373 tmp = ess(mgs)*rvt*aa2*cx(mgs,li)*cx(mgs,li)*xv(mgs,li)
19374 ! : ((cinu + 2.)*xv(mgs,li)/(cinu + 1.) + xv(mgs,li))
19376 ! csacs(mgs) = rvt*aa2*ess(mgs)*cx(mgs,ls)**2*xv(mgs,ls)
19378 qscni(mgs) = qscni(mgs) + Min( qxmxd(mgs,li), 2.0*tmp*xmas(mgs,li)*rhoinv(mgs) )
19379 cscni(mgs) = cscni(mgs) + Min( cxmxd(mgs,li), 2.0*tmp )
19380 cscnis(mgs) = cscnis(mgs) + Min( cxmxd(mgs,li), tmp )
19382 ELSEIF ( iscni .eq. 3 ) THEN ! LFO
19383 qscni(mgs) = 0.001*eii(mgs)*max((qx(mgs,li)-1.e-3),0.0)
19384 qscni(mgs) = min(qscni(mgs),qxmxd(mgs,li))
19385 cscni(mgs) = qscni(mgs)*rho0(mgs)/xmas(mgs,li)
19386 cscnis(mgs) = 0.5*cscni(mgs)
19387 ! write(iunit,*) 'qscni, qi = ',qscni(mgs),qx(mgs,li),igs(mgs),kgs(mgs)
19390 ELSEIF ( ipconc < 4 ) THEN ! LFO
19392 qimax = rhoinv(mgs)*roqimax
19393 qscni(mgs) = Min(0.90*qx(mgs,li), Max( 0.0, (qx(mgs,li) - qimax)*dtpinv ) )
19395 qscni(mgs) = 0.001*eii(mgs)*max((qx(mgs,li)-1.e-3),0.0)
19396 qscni(mgs) = min(qscni(mgs),qxmxd(mgs,li))
19398 else ! 10-ice version
19399 if ( iscni > 0 .and. qx(mgs,li) .gt. qxmin(li) ) then
19401 & pi*rho0(mgs)*((0.25)/(6.0)) &
19402 & *eii(mgs)*(qx(mgs,li)**2)*(xdia(mgs,li,2)) &
19403 & *vtxbar(mgs,li,1)/xmas(mgs,li)
19404 cscni(mgs) = Min(cimxd(mgs),qscni(mgs)*rho0(mgs)/xmas(mgs,li))
19416 ! compute dry growth rate of snow, graupel, and hail
19420 qsdry(mgs) = qsacr(mgs) + qsacw(mgs) &
19423 qhdry(mgs) = qhaci(mgs) + qhacs(mgs) &
19429 IF ( lhl .gt. 1 ) THEN
19430 qhldry(mgs) = qhlaci(mgs) + qhlacs(mgs) &
19436 ! set wet growth and shedding
19440 IF ( tfrdry < temg(mgs) .and. temg(mgs) < tfr ) THEN
19443 ! > ( xdia(mgs,ls,1)*swvent(mgs)*cx(mgs,ls)*fwet1(mgs)
19444 ! > + fwet2(mgs)*(qsaci(mgs)+qsacir(mgs)
19445 ! > +qsacip(mgs)) )
19446 ! qswet(mgs) = max( 0.0, qswet(mgs))
19448 ! IF ( dnu(lh) .ne. 0. ) THEN
19449 ! qhwet(mgs) = qhdry(mgs)
19451 IF ( incwet == 0 ) THEN
19453 & ( xdia(mgs,lh,1)*hwvent(mgs)*cx(mgs,lh)*fwet1(mgs) &
19454 & + fwet2(mgs)*(qhaci(mgs) + qhacs(mgs)) )
19455 qhwet(mgs) = max( 0.0, qhwet(mgs))
19463 IF ( lhl .gt. 1 ) THEN
19464 IF ( incwet == 0 ) THEN
19466 & ( xdia(mgs,lhl,1)*hlvent(mgs)*cx(mgs,lhl)*fwet1(mgs) &
19467 & + fwet2(mgs)*(qhlaci(mgs) + qhlacs(mgs)) )
19468 qhlwet(mgs) = max( 0.0, qhlwet(mgs))
19476 qhwet(mgs) = qhdry(mgs)
19477 qhlwet(mgs) = qhldry(mgs)
19480 ! qhlwet(mgs) = qhldry(mgs)
19499 wetsfc(:) = .false.
19500 wetgrowth(:) = .false.
19501 wetsfchl(:) = .false.
19502 wetgrowthhl(:) = .false.
19508 qhshr(mgs) = Min( 0.0, qhwet(mgs) - qhdry(mgs) ) ! water that freezes should never be more than what sheds
19512 qhlshr(mgs) = Min( 0.0, qhlwet(mgs) - qhldry(mgs) )
19515 ! limit wet growth to only higher density particles
19520 ! no shedding for temperatures < 243.15
19522 if ( temg(mgs) .lt. 243.15 ) then
19528 wetsfc(mgs) = .false.
19529 wetgrowth(mgs) = .false.
19530 wetsfchl(mgs) = .false.
19531 wetgrowthhl(mgs) = .false.
19534 ! shed all at temperatures > 273.15
19536 if ( temg(mgs) .gt. tfr ) then
19538 IF ( .false. ) THEN ! old and incorrect -- Thanks to Shaofeng Hua for noticing this error (9/17/2017)
19539 qsshr(mgs) = -qsdry(mgs)
19540 qhshr(mgs) = -qhdry(mgs)
19541 qhlshr(mgs) = -qhldry(mgs)
19542 ELSE ! new and correct
19543 ! note that the qxacr terms should be zero here, so shedding at T > 0 is all from the droplets
19544 qsshr(mgs) = - qsacr(mgs) - qsacw(mgs) ! -qsdry(mgs)
19545 qhlshr(mgs) = - qhlacw(mgs) - qhlacr(mgs) ! -qhldry(mgs)
19546 qhshr(mgs) = - qhacw(mgs) - qhacr(mgs) ! -qhdry(mgs)
19550 vhshdr(mgs) = -vhacw(mgs) - vhacr(mgs)
19551 vhlshdr(mgs) = -vhlacw(mgs) - vhlacr(mgs)
19556 ! if (qhshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) THEN
19557 wetsfc(mgs) = (qhshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) .or. ( qhmlr(mgs) < -qxmin(lh) .and. temg(mgs) > tfr )
19558 wetgrowth(mgs) = (qhshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr )
19560 if (qhlshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) THEN
19561 wetsfchl(mgs) = (qhlshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) .or. ( qhlmlr(mgs) < -qxmin(lhl) .and. temg(mgs) > tfr )
19562 wetgrowthhl(mgs) = (qhlshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr )
19567 if ( ipconc .ge. 1 ) then
19569 csshr(mgs) = 0.0 ! (cx(mgs,ls)/(qx(mgs,ls)+1.e-20))*Min(0.0,qsshr(mgs))
19571 chshr(mgs) = 0.0 ! no change to graupel number concentration for wet-growth shedding
19573 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
19574 ! Base the drop size on the shedding regime
19575 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
19576 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
19577 chshrr(mgs) = rho0(mgs)*qhshr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lh)) ! into rain
19583 IF ( lhl .gt. 1 ) THEN
19584 ! chlshr(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlshr(mgs)
19587 chlshr(mgs) = 0.0 ! no change to hail number concentration for wet-growth shedding
19589 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
19590 ! Base the drop size on the shedding regime
19591 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
19592 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
19593 chlshrr(mgs) = rho0(mgs)*qhlshr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lhl)) ! into rain
19595 ENDIF ! ( lhl > 1 )
19610 if ( qsshr(mgs) .lt. 0.0 ) then
19617 ! if ( qsdry(mgs) .lt. qswet(mgs) ) then
19627 if ( wetgrowth(mgs) .or. (mixedphase .and. fhw(mgs) .gt. 0.05 .and. temg(mgs) .gt. 243.15) ) then
19630 ! soaking (when not advected liquid water film with graupel)
19632 IF ( lvol(lh) .gt. 1 .and. .not. mixedphase) THEN
19633 ! rescale volumes to maximum density
19634 IF ( iwetsoak ) THEN
19636 rimdn(mgs,lh) = xdnmx(lh)
19637 raindn(mgs,lh) = xdnmx(lh)
19638 vhacw(mgs) = qhacw(mgs)*rho0(mgs)/rimdn(mgs,lh)
19639 vhacr(mgs) = qhacr(mgs)*rho0(mgs)/raindn(mgs,lh)
19640 ! IF ( lvol(lh) .gt. 1 .and. wetgrowth(mgs) ) THEN
19641 IF ( xdn(mgs,lh) .lt. xdnmx(lh) ) THEN
19642 ! soak some liquid into the graupel
19643 ! v1 = xdnmx(lh)*vx(mgs,lh)/(xdn(mgs,lh)*dtp) ! volume available for filling
19644 v1 = (1. - xdn(mgs,lh)/xdnmx(lh))*vx(mgs,lh)/(dtp) ! volume available for filling
19645 ! tmp = (vx(mgs,lh)/rho0(mgs))*(xdnmx(lh) - xdn(mgs,lh)) ! max mixing ratio of liquid water that can be added
19646 v2 = rho0(mgs)*qhwet(mgs)/xdnmx(lh) ! volume of frozen accretion
19648 vhsoak(mgs) = Min(v1,v2)
19655 vhshdr(mgs) = Min(0.0, rho0(mgs)*qhwet(mgs)/xdnmx(lh) - vhacw(mgs) - vhacr(mgs) )
19657 ELSEIF ( lvol(lh) .gt. 1 .and. mixedphase ) THEN
19658 ! vhacw(mgs) = rho0(mgs)*qhacw(mgs)/xdn0(lr)
19659 ! vhacr(mgs) = rho0(mgs)*qhacr(mgs)/xdn0(lr)
19668 ! collection efficiency modification
19670 IF ( ehi(mgs) .gt. 0.0 ) THEN
19671 qhaci(mgs) = Min(qimxd(mgs),qhaci0(mgs)) ! effectively sets collection eff to 1
19672 chaci(mgs) = Min(cimxd(mgs),chaci0(mgs)) ! effectively sets collection eff to 1
19674 IF ( ehs(mgs) .gt. 0.0 ) THEN
19675 ! qhacs(mgs) = Min(qsmxd(mgs),qhacs(mgs)/ehs(mgs)) ! effectively sets collection eff to 1
19676 qhacs(mgs) = Min(qsmxd(mgs),qhacs0(mgs)) !/ehs(mgs) ! divide out the collection efficiency
19677 chacs(mgs) = Min(csmxd(mgs),chacs0(mgs)) !/ehs(mgs) ! divide out the collection efficiency
19678 ehs(mgs) = ehsmax ! 1.0 ! min(ehsfrac*ehs(mgs),ehsmax) ! modify it
19679 qhacs(mgs) = Min(qsmxd(mgs),qhacs(mgs)) ! plug it back in
19682 ! be sure to catch particles with wet surfaces but not in wet growth to turn off Hallett-Mossop
19683 wetsfc(mgs) = .true.
19692 ! if ( lhl .gt. 1 .and. qhlshr(mgs) .lt. 0.0 ) then
19693 if ( lhl > 1 .and. ( wetgrowthhl(mgs) .or. (mixedphase .and. fhlw(mgs) .gt. 0.05 .and. temg(mgs) .gt. 243.15) ) ) then
19694 ! if ( wetgrowthhl(mgs) ) then
19698 ! qhlsbv(mgs) = 0.0
19700 ! chlsbv(mgs) = 0.0
19705 IF ( lvol(lhl) .gt. 1 .and. .not. mixedphase ) THEN
19706 ! IF ( lvol(lhl) .gt. 1 .and. wetgrowthhl(mgs) ) THEN
19708 IF ( iwetsoak ) THEN
19710 rimdn(mgs,lhl) = xdnmx(lhl)
19711 raindn(mgs,lhl) = xdnmx(lhl)
19712 vhlacw(mgs) = qhlacw(mgs)*rho0(mgs)/rimdn(mgs,lhl)
19713 vhlacr(mgs) = qhlacr(mgs)*rho0(mgs)/raindn(mgs,lhl)
19715 IF ( xdn(mgs,lhl) .lt. xdnmx(lhl) ) THEN
19716 ! soak some liquid into the hail
19717 ! v1 = xdnmx(lhl)*vx(mgs,lhl)/(xdn(mgs,lhl)*dtp) ! volume available for filling
19718 v1 = (1. - xdn(mgs,lhl)/xdnmx(lhl))*vx(mgs,lhl)/(dtp) ! volume available for filling
19719 ! tmp = (vx(mgs,lhl)/rho0(mgs))*(xdnmx(lhl) - xdn(mgs,lhl)) ! max mixing ratio of liquid water that can be added
19720 v2 = rho0(mgs)*qhlwet(mgs)/xdnmx(lhl) ! volume of frozen accretion
19721 IF ( v1 > v2 ) THEN ! all the frozen stuff fits in
19723 ELSE ! fill up the available space
19726 ! vhlacw(mgs) = 0.0
19727 ! vhlacr(mgs) = Max( 0.0, v2 - v1 )
19730 ! vhlacw(mgs) = 0.0
19731 ! vhlacr(mgs) = rho0(mgs)*qhlwet(mgs)/raindn(mgs,lhl)
19737 vhlshdr(mgs) = Min(0.0, rho0(mgs)*qhlwet(mgs)/xdnmx(lhl) - vhlacw(mgs) - vhlacr(mgs) )
19740 ELSEIF ( lvol(lhl) .gt. 1 .and. mixedphase ) THEN
19741 ! vhlacw(mgs) = rho0(mgs)*qhlacw(mgs)/xdn0(lr)
19742 ! vhlacr(mgs) = rho0(mgs)*qhlacr(mgs)/xdn0(lr)
19745 IF ( ehli(mgs) .gt. 0.0 ) THEN
19746 qhlaci(mgs) = Min(qimxd(mgs),qhlaci0(mgs)) ! effectively sets collection eff to 1
19747 chlaci(mgs) = Min(cimxd(mgs),chlaci0(mgs)) ! effectively sets collection eff to 1
19750 ! IF ( ehls(mgs) .gt. 0.0 ) THEN
19751 ! qhlacs(mgs) = Min(qsmxd(mgs),qhlacs(mgs)/ehls(mgs))
19753 IF ( ehls(mgs) .gt. 0.0 ) THEN
19754 qhlacs(mgs) = Min(qsmxd(mgs),qhlacs0(mgs)) !/ehls(mgs) ! divide out the collection efficiency
19755 chlacs(mgs) = Min(csmxd(mgs),chlacs0(mgs)) !/ehls(mgs) ! divide out the collection efficiency
19756 ehls(mgs) = ehsmax ! 1.0 ! min(ehsfrac*ehs(mgs),ehsmax) ! modify it
19757 ! qhlacs(mgs) = Min(qsmxd(mgs),qhlacs(mgs)) ! plug it back in
19761 ! qhlwet(mgs) = 1.0
19763 ! be sure to catch particles with wet surfaces but not in wet growth to turn off Hallett-Mossop
19764 wetsfchl(mgs) = .true.
19768 ! qhlshr(mgs) = 0.0
19769 ! qhlwet(mgs) = 0.0
19774 ! Ice -> graupel conversion
19783 IF ( iglcnvi .ge. 1 ) THEN
19784 IF ( temg(mgs) .lt. 273.0 .and. qiacw(mgs) - qidpv(mgs) .gt. 0.0 ) THEN
19787 tmp = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
19788 & *((0.60)*vtxbar(mgs,li,1)) &
19789 & /(temg(mgs)-273.15))**(rimc2)
19790 tmp = Min( Max( rimc3, tmp ), 900.0 )
19792 ! Assume that half the volume of the embryo is rime with density 'tmp'
19793 ! m = rhoi*(V/2) + rhorime*(V/2) = (rhoi + rhorime)*V/2
19794 ! V = 2*m/(rhoi + rhorime)
19796 ! write(0,*) 'rime dens = ',tmp
19798 IF ( tmp .ge. 200.0 .or. iglcnvi >= 2 ) THEN
19799 r = Max( 0.5*(xdn(mgs,li) + tmp), xdnmn(lh) )
19800 ! r = Max( r, 400. )
19801 qhcni(mgs) = (qiacw(mgs) - qidpv(mgs)) ! *float(iglcnvi)
19802 chcni(mgs) = cx(mgs,li)*qhcni(mgs)/qx(mgs,li)
19803 ! chcnih(mgs) = rho0(mgs)*qhcni(mgs)/(1.6e-10)
19804 chcnih(mgs) = Min(chcni(mgs), rho0(mgs)*qhcni(mgs)/(r*xvmn(lh)) )
19805 ! vhcni(mgs) = rho0(mgs)*2.0*qhcni(mgs)/(xdn(mgs,li) + tmp)
19806 vhcni(mgs) = rho0(mgs)*qhcni(mgs)/r
19809 ELSEIF ( iglcnvi == 3 ) THEN
19811 IF ( temg(mgs) .lt. 273.0 .and. qiacw(mgs)*dtp > 2.*qxmin(lh) .and. gamice73fac*xmas(mgs,li) > xdnmn(lh)*xvmn(lh) ) THEN
19814 tmp = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
19815 & *((0.60)*vtxbar(mgs,li,1)) &
19816 & /(temg(mgs)-273.15))**(rimc2)
19817 tmp = Min( Max( rimc3, tmp ), 900.0 )
19819 ! Assume that half the volume of the embryo is rime with density 'tmp'
19820 ! m = rhoi*(V/2) + rhorime*(V/2) = (rhoi + rhorime)*V/2
19821 ! V = 2*m/(rhoi + rhorime)
19823 ! write(0,*) 'rime dens = ',tmp
19824 ! convert to particles with the mass of the mass-weighted diameter
19825 ! massofmwr = gamice73fac*xmas(mgs,li)
19827 IF ( tmp .ge. xdnmn(lh) ) THEN
19828 r = Max( 0.5*(xdn(mgs,li) + tmp), xdnmn(lh) )
19829 ! r = Max( r, 400. )
19830 qhcni(mgs) = 0.5*qiacw(mgs)
19831 chcni(mgs) = qhcni(mgs)/(gamice73fac*xmas(mgs,li))
19832 chcnih(mgs) = Min(chcni(mgs), rho0(mgs)*qhcni(mgs)/(r*xvmn(lh)) )
19833 ! vhcni(mgs) = rho0(mgs)*2.0*qhcni(mgs)/(xdn(mgs,li) + tmp)
19834 vhcni(mgs) = rho0(mgs)*qhcni(mgs)/r
19860 IF ( lhl .gt. 1 ) THEN
19862 IF ( ihlcnh == 1 .or. ihlcnh == 3 ) THEN
19865 ! Graupel (h) conversion to hail (hl) based on Milbrandt and Yau 2005b
19869 ! IF ( lhl .gt. 1 .and. ipconc .ge. 5 .and. qx(mgs,lh) .gt. 1.0e-3 .and.
19870 ! : xdn(mgs,lh) .gt. 750. .and. qhshr(mgs) .lt. 0.0 .and.
19871 ! : xdia(mgs,lh,3) .gt. 1.e-3 ) THEN
19872 IF ( hlcnhdia > 0 ) THEN
19873 ltest = xdia(mgs,lh,3) .gt. hlcnhdia ! test on mean volume diameter
19875 ! ltest = xdia(mgs,lh,1)*(3. + alpha(mgs,lh)) > Abs( hlcnhdia ) ! test on maximum mass diameter
19876 ltest = xdia(mgs,lh,1)*(4. + alpha(mgs,lh)) > Abs( hlcnhdia ) ! test on mass-weighted diameter
19879 IF ( iusedw == 0 .and. ihlcnh == 1 ) THEN
19882 IF (((qhacw(mgs) + qhacr(mgs))*dtp > qxmin(lh) .and. qx(mgs,lh) > hlcnhqmin .and. temg(mgs) .le. tfr-2.0 &
19883 .and. temg(mgs) .gt. dwtempmin ) .or. ( wetgrowth(mgs) .and. qx(mgs,lh) > hlcnhqmin ) ) THEN
19884 ! dw = 0.01*( Exp( -temcg(mgs)/( 1.1e4 * rho0(mgs)*ehw(mgs)*qx(mgs,lc) - 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0 ) ) - 1.0 )
19885 ! dwr = 0.01*( Exp( -temcg(mgs)/( 1.1e4 * rho0(mgs)*(ehw(mgs)*qx(mgs,lc)+ehr(mgs)*qx(mgs,lr)) - &
19886 ! 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0 ) ) - 1.0 )
19887 x = 1.1e4 * rho0(mgs)*(ehw(mgs)*qx(mgs,lc)+ehr(mgs)*qx(mgs,lr)) - &
19888 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0
19889 IF ( x > 1.e-20 ) THEN
19890 arg = Min(70.0, (-temcg(mgs)/x )) ! prevent overflow of the exp function in 32 bit
19891 dwr = 0.01*(exp(arg) - 1.0)
19896 IF ( dwr < 0.2 .and. dwr > 0.0 .and. rho0(mgs)*(qx(mgs,lc)+qx(mgs,lr)) > 1.e-4 ) THEN
19897 sqrtrhovt = Sqrt( rhovt(mgs) )
19898 fventh = sqrtrhovt*(fpndl(mgs)**(1./3.)) * (fakvisc(mgs))**(-0.5)
19899 fventm = sqrtrhovt*(fschm(mgs)**(1./3.)) * (fakvisc(mgs))**(-0.5)
19900 ltemq = (tfr-163.15)/fqsat+1.5
19901 qvs0 = pqs(mgs)*tabqvs(ltemq)
19902 denomdp = felf(mgs) + fcw(mgs)*temcg(mgs)
19903 denominvdp = 1.d0/(felf(mgs) + fcw(mgs)*temcg(mgs))
19905 ! write(91,*) 'dw,dwr,temcg = ',100.*dw,100.*dwr,temcg(mgs)
19906 h1 = ( -ftka(mgs)*temcg(mgs) - felv(mgs)*fwvdf(mgs)*rho0(mgs)*(qx(mgs,lv) - qvs0) )
19907 h2 = ehi(mgs)*qx(mgs,li)*rho0(mgs)*fci(mgs)*temcg(mgs)
19908 h3 = Max(dwehwmin, ehw(mgs))*qx(mgs,lc)
19909 h4 = ehr(mgs)* qx(mgs,lr)
19910 ! iterate to find minimum diameter for wet growth. Start with value of dwr
19914 vth = axx(mgs,lh)*d**bxx(mgs,lh)
19915 x2 = fventh*sqrtrhovt*Sqrt(d*vth)
19916 IF ( x2 > 1.4 ) THEN
19917 ah = 0.78 + 0.308*x2 ! heat ventillation
19919 ah = 1.0 + 0.108*x2**2 ! mass ventillation (Beard and Pruppacher 1971, eq. 9)
19922 IF ( .false. ) THEN ! this option includes 'am' separate from ah, which makes only small differences. Otherwise equivalent to second option
19923 x1 = fventm*sqrtrhovt*Sqrt(d*vth)
19924 IF ( x1 > 1.4 ) THEN
19925 am = 0.78 + 0.308*x1 ! mass ventillation (Beard and Pruppacher 1971, eq. 8)
19927 am = 1.0 + 0.108*x1**2 ! mass ventillation (Beard and Pruppacher 1971, eq. 9)
19930 d = 8.*denominvdp*( am*felv(mgs)*fwvdf(mgs)*rho0(mgs)*(qvs0 - qx(mgs,lv)) - ah*ftka(mgs)*temcg(mgs) )/ &
19931 (dtp* ( ( Max(0.001,vth - vtxbar(mgs,lc,1))*h3 + &
19932 Max(0.001,vth - vtxbar(mgs,lr,1))*h4) *rho0(mgs) + &
19933 Max(0.001,vth - vtxbar(mgs,li,1))*h2*denominvdp))
19937 ! Based on Farley and Orville (1986), eq. 5-9 but neglecting the Ci*(T0-Ts) term in (8) since we want Ts=T0
19938 ! Simplified mass rates as dm_w/dt = pi/4*d**2*(Vh - Vc)*rhoair*qc*ehw, etc.
19940 ( ( Max(0.001,vth - vtxbar(mgs,lc,1))*h3 + &
19941 Max(0.001,vth - vtxbar(mgs,lr,1))*h4) *rho0(mgs)*denomdp + &
19942 Max(0.001,vth - vtxbar(mgs,li,1))*h2)
19945 IF ( Abs(dold - d)/dold < 0.05 .or. ( n > 3 .and. d > dg0thresh ) ) EXIT
19950 dg0(mgs) = Min( dwmax, Max( d, dwmin ) )
19952 IF ( qx(mgs,lh) > qxmin(lh) .and. qx(mgs,lh) > hlcnhqmin .and. temg(mgs) .le. tfr-2.0 ) THEN
19955 dg0(mgs) = dg0thresh + 0.0001
19959 IF ( ihlcnh == 3 .and. (qhacw(mgs) + qhacr(mgs))*dtp > qxmin(lh) .and. qx(mgs,lh) > hlcnhqmin &
19960 .and. temg(mgs) .le. tfr-2.0 ) THEN
19961 ! set a secondary condition on to capture large graupel that is riming but not in wet growth
19962 dg0(mgs) = Min( dg0(mgs), dg0thresh - 0.0001 )
19967 wtest = (dg0(mgs) > 0.0 .and. dg0(mgs) < dg0thresh )
19969 IF ( ihlcnh == 1 ) THEN ! .or. iusedw == 0 THEN
19971 IF ( ( wetgrowth(mgs) .and. (xdn(mgs,lh) .gt. hldnmn .or. lvh < 1 ) .and. & ! correct this when hail gets turned on
19972 & rimdn(mgs,lh) .gt. 800. .and. &
19973 & ltest .and. qx(mgs,lh) .gt. hlcnhqmin ) .or. wtest ) THEN ! {
19974 ! : xdia(mgs,lh,3) .gt. 2.e-3 .and. qx(mgs,lh) .gt. 1.0e-3 THEN ! 0823.2008 erm test
19975 ! IF ( xdia(mgs,lh,3) .gt. 1.e-3 ) THEN
19976 IF ( qhacw(mgs) .gt. 0.0 .and. qhacw(mgs) .gt. qhaci(mgs) .and. temg(mgs) .le. tfr-2.0 ) THEN ! {
19977 ! dh0 is the diameter dividing wet growth from dry growth (Ziegler 1985), modified by MY05
19978 ! dh0 = 0.01*(exp(temcg(mgs)/(1.1e4*(qx(mgs,lc)+qx(mgs,lr)) -
19979 ! : 1.3e3*qx(mgs,li) + 1.0e-3 ) ) - 1.0)
19983 x = (1.1e4*(rho0(mgs)*qx(mgs,lc)) - 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0e-3 )
19984 IF ( x > 1.e-20 ) THEN
19985 arg = Min(70.0, (-temcg(mgs)/x )) ! prevent overflow of the exp function in 32 bit
19986 dh0 = 0.01*(exp(arg) - 1.0)
19991 ! dh0 = Max( dh0, 5.e-3 )
19993 ! IF ( dh0 .gt. 0.0 ) write(0,*) 'dh0 = ',dh0
19994 ! IF ( dh0 .gt. 1.0e-4 ) THEN
19995 IF ( xdia(mgs,lh,3)/dh0 .gt. 0.1 ) THEN !{
19996 ! IF ( xdia(mgs,lh,3) .lt. 20.*dh0 .and. dh0 .lt. 2.0*xdia(mgs,lh,3) ) THEN
19997 tmp = qhacw(mgs) + qhacr(mgs) + qhaci(mgs) + qhacs(mgs)
19998 ! qtmp = Min( 1.0, xdia(mgs,lh,3)/(2.0*dh0) )*(tmp)
19999 qtmp = Min( 100.0, xdia(mgs,lh,3)/(2.0*dh0) )*(tmp)
20000 qhlcnh(mgs) = Min( qxmxd(mgs,lh), qtmp )
20002 IF ( ipconc .ge. 5 ) THEN !{
20003 ! dh0 = Max( xdia(mgs,lh,3), Min( dh0, 5.e-3 ) ) ! do not create hail greater than 5mm diam. unless the graupel is larger
20004 IF ( .not. wtest ) dh0 = Min( dh0, 10.e-3 ) ! do not create hail greater than 10mm diam., which is the max graupel size
20005 IF ( qx(mgs,lhl) > 0.1e-3 ) dh0 = Max( dh0, xdia(mgs,lhl,3) ) ! when enough hail is established, do not dilute the size
20006 chlcnhhl(mgs) = Min( cxmxd(mgs,lh), rho0(mgs)*qhlcnh(mgs)/(pi*xdn(mgs,lh)*dh0**3/6.0) )
20008 r = rho0(mgs)*qhlcnh(mgs)/(xdn(mgs,lh)*xv(mgs,lh)) ! number of graupel particles at mean volume diameter
20009 chlcnh(mgs) = Max( chlcnhhl(mgs), r )
20012 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
20013 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/Max(xdnmn(lhl), xdn(mgs,lh))
20020 ELSEIF ( ihlcnh == 3 ) THEN !{
20024 ( qhacw(mgs)*dtp > qxmin(lh) .and. temg(mgs) .lt. tfr-2. .and. qx(mgs,lh) > hlcnhqmin ) ) THEN
20025 ! convert number, mass, and reflectivity for d > dw
20026 IF ( ipconc == 5 ) THEN
20027 ! dg0(mgs) = Min( dg0(mgs), hldia1 )
20031 ratio = Min( maxratiolu, dg0(mgs)/xdia(mgs,lh,1) )
20035 tmp2 = gaminterp(ratio,alpha(mgs,lh),4,1)
20036 IF ( ipconc == 5 ) THEN
20037 ! tmp2 = Min( 0.25, tmp2 )
20039 qxd1 = qx(mgs,lh)*(tmp2)
20040 qhlcnh(mgs) = dtpinv*qxd1
20042 tmp3 = qxmxd(mgs,lh)
20043 IF (qxd1 > tmp3 ) THEN
20044 ! flim = tmp3/(qxd1)
20045 ! qhlcnh(mgs) = flim*qhlcnh(mgs)
20050 IF ( ( qxd1 > qxmin(lhl) .and. ipconc > 5 ) .or. ( qxd1 > 10.*qxmin(lhl) .and. ipconc == 5) ) THEN
20053 tmp = gaminterp(ratio,alpha(mgs,lh),1,1)
20054 IF ( ipconc == 5 ) THEN
20055 ! tmp = Min( 0.2, tmp )
20057 cxd1 = flim*cx(mgs,lh)*( tmp)
20058 chlcnh(mgs) = dtpinv*cxd1
20059 chlcnhhl(mgs) = chlcnh(mgs)
20061 IF ( qx(mgs,lhl) > qxmin(lhl) .and. dmhlopt > 0 ) THEN
20062 tmp = rho0(mgs)*qhlcnh(mgs)/chlcnhhl(mgs)
20063 IF ( tmp < xmas(mgs,lhl) ) THEN
20064 ! dh0 = ( qxd1*dh0 + qx(mgs,lhl)*xmas(mgs,lhl))/( qxd1 + qx(mgs,lhl)) ! weighted average
20065 dh0 = (( qxd1*tmp**(1./3.) + qx(mgs,lhl)*xmas(mgs,lhl)**(1./3.))/( qxd1 + qx(mgs,lhl)))**3 ! weighted average
20066 chlcnhhl(mgs) = Min( chlcnhhl(mgs), rho0(mgs)*qhlcnh(mgs)/dh0 )
20068 ! dh0 = Max( dh0, xmas(mgs,lhl) ) ! when enough hail is established, do not dilute the size
20074 IF ( ipconc >= 6 .and. lzh > 1 .and. lzhl > 1 ) THEN
20075 tmp3 = gaminterp(ratio,alpha(mgs,lh),11,1)
20076 zxd1 = flim*zx(mgs,lh)*(tmp3)
20077 zhlcnh(mgs) = dtpinv*zxd1
20086 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
20087 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/Max(xdnmn(lhl), xdn(mgs,lh))
20096 ELSEIF ( ihlcnh == 2 ) THEN ! 10-ice type conversion
20099 ! Staka and Mansell (2005) type conversion
20101 ! hldia1 is set in micro_module and namelist
20102 ! IF ( .true. ) THEN
20104 ! convert number, mass, and reflectivity for d > hldia1,
20105 ! regardless of wet growth status, but as long as riming > 0
20107 IF ( qhacw(mgs)*dtp > qxmin(lh) .and. temg(mgs) .lt. tfr-2. .and. qx(mgs,lh) > qxmin(lh) ) THEN
20108 ratio = Min( maxratiolu, hldia1/xdia(mgs,lh,1) )
20111 tmp = gaminterp(ratio,alpha(mgs,lh),1,1)
20112 cxd1 = cx(mgs,lh)*( tmp)
20113 chlcnh(mgs) = dtpinv*cxd1
20114 chlcnhhl(mgs) = chlcnh(mgs)
20117 tmp2 = gaminterp(ratio,alpha(mgs,lh),4,1)
20118 qxd1 = qx(mgs,lh)*(tmp2)
20119 qhlcnh(mgs) = dtpinv*qxd1
20122 IF ( lzh > 1 .and. lzhl > 1 ) THEN
20123 tmp3 = gaminterp(ratio,alpha(mgs,lh),11,1)
20124 zxd1 = zx(mgs,lh)*(tmp3)
20125 zhlcnh(mgs) = dtpinv*zxd1
20129 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
20130 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/Max(xdnmn(lhl), xdn(mgs,lh))
20136 ELSEIF ( ihlcnh == 0 ) THEN
20139 ! qhlcnh(mgs) = 0.0
20140 ! chlcnh(mgs) = 0.0
20141 if ( wetgrowth(mgs) .and. temg(mgs) .lt. tfr-5. .and. qx(mgs,lh) > qxmin(lh) ) then
20142 if ( qhacw(mgs).gt.1.e-6 .and. xdn(mgs,lh) > 700. ) then
20144 ((pi*xdn(mgs,lh)*cx(mgs,lh)) / (6.0*rho0(mgs)*dtp)) &
20145 *exp(-hldia1/xdia(mgs,lh,1)) &
20146 *( (hldia1**3) + 3.0*(hldia1**2)*xdia(mgs,lh,1) &
20147 + 6.0*(hldia1)*(xdia(mgs,lh,1)**2) + 6.0*(xdia(mgs,lh,1)**3) )
20148 qhlcnh(mgs) = min(qhlcnh(mgs),qhmxd(mgs))
20149 IF ( ipconc .ge. 5 ) THEN
20150 chlcnh(mgs) = Min( cxmxd(mgs,lh), cx(mgs,lh)*Exp(-hldia1/xdia(mgs,lh,1)))
20151 chlcnhhl(mgs) = chlcnh(mgs)
20152 ! chlcnh(mgs) = Min( cxmxd(mgs,lh), rho0(mgs)*qhlcnh(mgs)/(2.0*xmas(mgs,lh) ))
20154 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
20155 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/Max(xdnmn(lhl), xdn(mgs,lh))
20162 ENDIF ! ihlcnh options
20164 ! convert low-density hail to graupel
20165 IF ( icvhl2h >= 1 ) THEN
20167 IF ( qx(mgs,lhl) > qxmin(lhl) .and. xdn(mgs,lhl) < 0.5*(xdnmn(lhl) + xdnmx(lhl)) ) THEN
20168 tmp = Min(0.95, 1. - 0.5*(1. + tanh(0.125*(xdn(mgs,lhl) - 1.01*xdnmn(lhl) )) ))
20169 qhcnhl(mgs) = tmp*qx(mgs,lhl)*dtpinv
20170 chcnhl(mgs) = cx(mgs,lhl)*qhcnhl(mgs)/qx(mgs,lhl)
20171 vhcnhl(mgs) = vx(mgs,lhl)*qhcnhl(mgs)/qx(mgs,lhl)
20184 ! Ziegler snow conversion to graupel
20197 IF ( ipconc .ge. 5 ) THEN
20199 ! test attempt at converting graupel to snow when not riming but growing by deposition
20200 IF ( temg(mgs) < tfr .and. qx(mgs,lh) .gt. qxmin(lh) .and. qhdpv(mgs) > qxmin(lh)*dtpinv &
20201 & .and. qhacw(mgs) < qxmin(lh)*dtpinv ) THEN
20202 IF ( xdn(mgs,lh) < 290. ) THEN
20203 ! qscnh(mgs) = 2.*qhdpv(mgs)
20204 ! cscnh(mgs) = cx(mgs,lh)*qscnh(mgs)/qx(mgs,lh)
20205 ! vscnh(mgs) = rho0(mgs)*qscnh(mgs)/xdn(mgs,lh)
20210 IF ( qx(mgs,ls) .gt. qxmin(ls) .and. qsacw(mgs) .gt. 0.0 ) THEN
20212 ! DATA VGRA/1.413E-2/ ! this is the volume (cm**3) of a 3mm diam. sphere
20213 ! vgra = 1.4137e-8 m**3
20215 ! DNNET=DNCNV-DNAGG
20216 ! DQNET=QXCON+QSACC+SDEP
20218 ! DNSCNV=EXP(-(ROS*XNS*VGRA/(RO*QI)))*((1.-(XNS*VGRA*ROS/
20219 ! / (RO*QI)))*DNNET + (XNS**2*VGRA*ROS/(RO*QI**2))*DQNET)
20220 ! IF(DNSCNV.LT.0.) DNSCNV=0.
20222 ! QIHC=(ROS*VGRA/RO)*DNSCNV
20226 ! XNH=XNH+DT*DNSCNV
20227 ! XNS=XNS-DT*DNSCNV
20229 IF ( iglcnvs .eq. 1 ) THEN ! Zrnic, Ziegler et al (1993)
20231 dnnet = cscnvis(mgs) + cscnis(mgs) - csacs(mgs)
20232 dqnet = qscnvi(mgs) + qscni(mgs) + qsacw(mgs) + qsdpv(mgs) + qssbv(mgs)
20234 a3 = 1./(rho0(mgs)*qx(mgs,ls))
20235 a1 = Exp( - xdn(mgs,ls)*cx(mgs,ls)*vgra*a3 ) !! EXP(-(ROS*XNS*VGRA/(RO*QI)))
20236 ! (1.-(XNS*VGRA*ROS/(RO*QI)))*DNNET
20237 a2 = (1.-(cx(mgs,ls)*vgra*xdn(mgs,ls)*a3))*dnnet
20238 ! (XNS**2*VGRA*ROS/(RO*QI**2))*DQNET
20239 a4 = cx(mgs,ls)**2*vgra*xdn(mgs,ls)*a3/qx(mgs,ls)*dqnet
20241 chcns(mgs) = Max( 0.0, a1*(a2 + a4) )
20242 chcns(mgs) = Min( chcns(mgs), cxmxd(mgs,ls) )
20243 chcnsh(mgs) = chcns(mgs)
20245 qhcns(mgs) = Min( xdn(mgs,ls)*vgra*rhoinv(mgs)*chcns(mgs), qxmxd(mgs,ls) )
20246 vhcns(mgs) = rho0(mgs)*qhcns(mgs)/Max(xdn(mgs,ls),xdnmn(lh))
20247 ! vhcns(mgs) = rho0(mgs)*qhcns(mgs)/Max(xdn(mgs,ls),400.)
20249 ELSEIF ( iglcnvs .ge. 2 ) THEN ! treat like ice crystals, i.e., check for rime density (ERM)
20251 IF ( temg(mgs) .lt. 273.0 .and. ( qsacw(mgs) - qsdpv(mgs) .gt. 0.0 .or. &
20252 ( iglcnvs >= 3 .and. qsacw(mgs)*dtp > 2.*qxmin(lh) .and. gamsnow73fac*xmas(mgs,ls) > xdnmn(lh)*xvmn(lh) ) ) ) THEN !{
20255 tmp = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
20256 & *((0.60)*vtxbar(mgs,ls,1)) &
20257 & /(temg(mgs)-273.15))**(rimc2)
20258 ! tmp = Min( Max( rimc3, tmp ), 900.0 )
20259 tmp = Min( tmp , 900.0 )
20261 ! Assume that half the volume of the embryo is rime with density 'tmp'
20262 ! m = rhoi*(V/2) + rhorime*(V/2) = (rhoi + rhorime)*V/2
20263 ! V = 2*m/(rhoi + rhorime)
20265 ! write(0,*) 'rime dens = ',tmp
20267 IF ( iglcnvs == 2 ) THEN !{
20268 IF ( tmp .ge. 200.0 ) THEN
20269 r = Max( 0.5*(xdn(mgs,ls) + tmp), xdnmn(lh) )
20270 ! r = Max( r, 400. )
20271 qhcns(mgs) = (qsacw(mgs) - qsdpv(mgs))
20272 chcns(mgs) = cx(mgs,ls)*qhcns(mgs)/qx(mgs,ls)
20273 ! chcnih(mgs) = rho0(mgs)*qhcni(mgs)/(1.6e-10)
20274 chcnsh(mgs) = Min(chcns(mgs), rho0(mgs)*qhcns(mgs)/(r*xvmn(lh)) )
20275 ! vhcni(mgs) = rho0(mgs)*2.0*qhcni(mgs)/(xdn(mgs,li) + tmp)
20276 vhcns(mgs) = rho0(mgs)*qhcns(mgs)/r
20279 ELSEIF ( iglcnvs == 3 ) THEN
20281 ! convert to particles with the mass of the mass-weighted diameter
20282 ! massofmwr = gamice73fac*xmas(mgs,li)
20284 IF ( tmp > xdnmn(lh) ) THEN
20285 r = Max( 0.5*(xdn(mgs,ls) + tmp), xdnmn(lh) )
20286 ! r = Max( r, 400. )
20287 qhcns(mgs) = 0.5*qsacw(mgs)
20288 chcns(mgs) = qhcns(mgs)/(gamsnow73fac*xmas(mgs,ls))
20289 chcns(mgs) = Min( chcns(mgs), cx(mgs,ls)*qhcns(mgs)/qx(mgs,ls))
20290 chcnsh(mgs) = Min(chcns(mgs), rho0(mgs)*qhcns(mgs)/(r*xvmn(lh)) )
20291 vhcns(mgs) = rho0(mgs)*qhcns(mgs)/r
20303 ELSE ! single moment lfo
20305 qhcns(mgs) = 0.001*ehscnv(mgs)*max((qx(mgs,ls)-6.e-4),0.0)
20306 qhcns(mgs) = min(qhcns(mgs),qxmxd(mgs,ls))
20307 IF ( lvol(lh) .ge. 1 ) vhcns(mgs) = rho0(mgs)*qhcns(mgs)/Max(xdn(mgs,ls),400.)
20313 ! heat budget for rain---not all rain that collects ice can freeze
20317 if ( irwfrz .gt. 0 .and. .not. mixedphase) then
20321 ! compute total rain that freeze when it interacts with cloud ice
20323 qrztot(mgs) = qrfrz(mgs) + qiacr(mgs) + qsacr(mgs)
20325 ! compute the maximum amount of rain that can freeze
20326 ! Used to limit freezing to 4*qrmxd, but now allow all rain to freeze if possible
20329 & ( xdia(mgs,lr,1)*rwvent(mgs)*cx(mgs,lr)*fwet1(mgs) )
20330 qrzmax(mgs) = max(qrzmax(mgs), 0.0)
20331 qrzmax(mgs) = min(qrztot(mgs), qrzmax(mgs))
20332 qrzmax(mgs) = min(qx(mgs,lr)*dtpinv, qrzmax(mgs))
20334 IF ( temcg(mgs) < -30. ) THEN ! allow all to freeze if T < -30 because fwet becomes invalid (negative)
20335 qrzmax(mgs) = qx(mgs,lr)*dtpinv
20337 ! qrzmax(mgs) = min(4.*qrmxd(mgs), qrzmax(mgs))
20339 ! compute the correction factor
20341 ! IF ( qrztot(mgs) .gt. qxmin(lr) ) THEN
20342 IF ( qrztot(mgs) .gt. qrzmax(mgs) .and. qrztot(mgs) .gt. qxmin(lr) ) THEN
20343 qrzfac(mgs) = qrzmax(mgs)/(qrztot(mgs))
20347 qrzfac(mgs) = min(1.0, qrzfac(mgs))
20352 ! now correct the above sources
20356 if ( temg(mgs) .le. 273.15 .and. qrzfac(mgs) .lt. 1.0 ) then
20357 qrfrz(mgs) = qrzfac(mgs)*qrfrz(mgs)
20358 qrfrzs(mgs) = qrzfac(mgs)*qrfrzs(mgs)
20359 qrfrzf(mgs) = qrzfac(mgs)*qrfrzf(mgs)
20360 qiacr(mgs) = qrzfac(mgs)*qiacr(mgs)
20361 qsacr(mgs) = qrzfac(mgs)*qsacr(mgs)
20362 qiacrf(mgs) = qrzfac(mgs)*qiacrf(mgs)
20363 qiacrs(mgs) = qrzfac(mgs)*qiacrs(mgs)
20364 crfrz(mgs) = qrzfac(mgs)*crfrz(mgs)
20365 crfrzf(mgs) = qrzfac(mgs)*crfrzf(mgs)
20366 crfrzs(mgs) = qrzfac(mgs)*crfrzs(mgs)
20367 ciacr(mgs) = qrzfac(mgs)*ciacr(mgs)
20368 ciacrf(mgs) = qrzfac(mgs)*ciacrf(mgs)
20369 ciacrs(mgs) = qrzfac(mgs)*ciacrs(mgs)
20371 ! IF ( lzh .gt. 1 ) THEN
20372 ! zrfrzf(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,lr)+2.)/(xdn0(lr)**2*(alpha(mgs,lr)+1.)) * &
20373 ! ( 2.*tmp * qrfrzf(mgs) - tmp**2 * crfrzf(mgs) )
20376 vrfrzf(mgs) = qrzfac(mgs)*vrfrzf(mgs)
20377 viacrf(mgs) = qrzfac(mgs)*viacrf(mgs)
20387 ! evaporation of rain
20397 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
20400 & fvce(mgs)*cx(mgs,lr)*rwvent(mgs)*rwcap(mgs)*evapfac
20401 ! this line to allow condensation on rain:
20402 IF ( rcond .eq. 1 ) THEN
20403 qrcev(mgs) = min(qrcev(mgs), qxmxd(mgs,lv))
20404 ! this line to have evaporation only:
20406 qrcev(mgs) = min(qrcev(mgs), 0.0)
20409 qrcev(mgs) = max(qrcev(mgs), -qrmxd(mgs))
20410 ! if ( temg(mgs) .lt. 273.15 ) qrcev(mgs) = 0.0
20411 IF ( qrcev(mgs) .lt. 0. .and. lnr > 1 ) THEN
20412 ! qrcev(mgs) = -qrmxd(mgs)
20413 ! crcev(mgs) = (rho0(mgs)/(xmas(mgs,lr)+1.e-20))*qrcev(mgs)
20414 IF ( icrcev == 1 ) THEN
20415 crcev(mgs) = (cx(mgs,lr)/(qx(mgs,lr)))*qrcev(mgs)
20416 ELSEIF ( icrcev == 2 ) THEN
20417 crcev(mgs) = (cx(mgs,lr)/(qx(mgs,lr)))*qrcev(mgs)*vtxbar(mgs,lr,2)/vtxbar(mgs,lr,1)
20424 ! if ( temg(mgs) .lt. 273.15 ) crcev(mgs) = 0.0
20430 ! evaporation/condensation of wet graupel and snow
20432 IF ( lhwlg > 1 ) THEN
20436 IF ( lhlwlg > 1 ) THEN
20445 ! ICE MULTIPLICATION: Two modes (rimpa, and rimpb)
20446 ! (following Cotton et al. 1986)
20458 ltest = qx(mgs,lh) .gt. qxmin(lh)
20459 IF ( lhl > 1 ) ltest = ltest .or. qx(mgs,lhl) .gt. qxmin(lhl)
20461 IF ( (itype1 .ge. 1 .or. itype2 .ge. 1 ) &
20462 & .and. qx(mgs,lc) .gt. qxmin(lc)) THEN
20463 if ( temg(mgs) .ge. 265.15 .and. temg(mgs) .le. 271.15 ) then
20464 IF ( ipconc .ge. 2 ) THEN
20465 IF ( xv(mgs,lc) .gt. 0.0 &
20467 ! .and. itype2 .ge. 2 &
20470 ! Ziegler et al. 1986 Hallett-Mossop process. VSTAR = 7.23e-15 (vol of 12micron radius)
20472 IF ( alpha(mgs,lc) == 0.0 ) THEN
20473 ex1 = (1./250.)*Exp(-7.23e-15/xv(mgs,lc))
20476 ratio = (1. + alpha(mgs,lc))*(7.23e-15)/xv(mgs,lc)
20478 IF ( usegamxinfcnu ) THEN
20479 i = Nint(dgami*(1. + alpha(mgs,lc)))
20481 ex1 = (1./250.)*Gamxinf(1.+alpha(mgs,lc), ratio)/(gcnup1)
20483 ratio = Min( maxratiolu, ratio )
20484 tmp = gaminterp(ratio,alpha(mgs,lc),1,1)
20485 ex1 = (1./250.)*tmp
20488 IF ( itype2 .le. 2 ) THEN
20489 ft = Max(0.0,Min(1.0,-0.11*temcg(mgs)**2 - 1.1*temcg(mgs)-1.7))
20491 IF ( temg(mgs) .ge. 265.15 .and. temg(mgs) .le. 267.15 ) THEN
20493 ELSEIF (temg(mgs) .ge. 267.15 .and. temg(mgs) .le. 269.15 ) THEN
20495 ELSEIF (temg(mgs) .ge. 269.15 .and. temg(mgs) .le. 271.15 ) THEN
20501 ! rhoinv = 1./rho0(mgs)
20502 ! DNSTAR = ex1*cglacw(mgs)
20504 IF ( ft > 0.0 ) THEN
20506 IF ( itype2 > 0 ) THEN
20507 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. (.not. wetsfc(mgs)) ) THEN
20508 chmul1(mgs) = ft*ex1*chacw(mgs)
20509 ! chmul1(mgs) = Min( ft*ex1*chacw(mgs), ft*(30.*1.e+06)*rho0(mgs)*qhacw(mgs) ) ! 1.e+6 converts kg to mg; Saunders & Hosseini (2001) average of about 30 crystals per mg
20510 qhmul1(mgs) = cimas0*chmul1(mgs)*rhoinv(mgs)
20512 IF ( lhl .gt. 1 ) THEN
20513 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. (.not. wetsfchl(mgs)) ) THEN
20514 chlmul1(mgs) = (ft*ex1*chlacw(mgs))
20515 qhlmul1(mgs) = cimas0*chlmul1(mgs)*rhoinv(mgs)
20520 IF ( itype1 > 0 ) THEN
20521 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. (.not. wetsfc(mgs)) ) THEN
20522 tmp = ft*(3.5e+08)*rho0(mgs)*qhacw(mgs)
20523 chmul1(mgs) = chmul1(mgs) + tmp
20524 qhmul1(mgs) = qhmul1(mgs) + cimas0*tmp*rhoinv(mgs)
20526 IF ( lhl .gt. 1 ) THEN
20527 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. (.not. wetsfchl(mgs)) ) THEN
20528 tmp = ft*(3.5e+08)*rho0(mgs)*qhlacw(mgs)
20529 chlmul1(mgs) = chlmul1(mgs) + tmp
20530 qhlmul1(mgs) = qhlmul1(mgs) + cimas0*tmp*rhoinv(mgs)
20538 ENDIF ! xv(mgs,lc) .gt. 0.0 .and.
20540 ELSE ! ipconc .lt. 2
20542 ! define the temperature function
20546 ! Cotton et al. (1986) version
20548 if ( temg(mgs) .ge. 268.15 .and. temg(mgs) .le. 270.15 ) then
20549 fimt1(mgs) = 1.0 -(temg(mgs)-268.15)/2.0
20550 elseif (temg(mgs) .le. 268.15 .and. temg(mgs) .ge. 265.15 ) then
20551 fimt1(mgs) = 1.0 +(temg(mgs)-268.15)/3.0
20556 ! Ferrier (1994) version
20558 if ( temg(mgs) .ge. 265.15 .and. temg(mgs) .le. 267.15 ) then
20560 elseif (temg(mgs) .ge. 267.15 .and. temg(mgs) .le. 269.15 ) then
20562 elseif (temg(mgs) .ge. 269.15 .and. temg(mgs) .le. 271.15 ) then
20569 ! type I: 350 splinters are formed for every 1e-3 grams of cloud
20570 ! water accreted by graupel/hail (note converted to MKS units)
20571 ! 3.5e+8 has units of 1/kg
20573 IF ( itype1 .ge. 1 ) THEN
20574 fimta(mgs) = (3.5e+08)*rho0(mgs)
20581 ! type II: 1 splinter formed for every 250 cloud droplets larger than
20582 ! 24 micons in diameter (12 microns in radius) accreted by
20587 xcwmas = xmas(mgs,lc) * 1000.
20589 IF ( itype2 .ge. 1 ) THEN
20590 if ( xcwmas.lt.1.26e-9 ) then
20593 if ( xcwmas .le. 3.55e-9 .and. xcwmas .ge. 1.26e-9 ) then
20594 fimt2(mgs) = (2.27)*alog(xcwmas) + 13.39
20596 if ( xcwmas .gt. 3.55e-9 ) then
20600 fimt2(mgs) = min(fimt2(mgs),1.0)
20601 fimt2(mgs) = max(fimt2(mgs),0.0)
20609 ! > (4.0e-03)*fimt1(mgs)*fimt2(mgs)*qhacw(mgs)
20611 ! > (4.0e-03)*fimt1(mgs)*fimt2(mgs)*qsacw(mgs)
20613 ! cimas0 = (1.0e-12)
20615 IF ( .not. wetsfc(mgs) ) THEN
20616 chmul1(mgs) = fimt1(mgs)*(fimta(mgs) + &
20617 & (4.0e-03)*fimt2(mgs))*qhacw(mgs)
20620 qhmul1(mgs) = chmul1(mgs)*(cimas0/rho0(mgs))
20622 IF ( lhl .gt. 1 ) THEN
20623 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. (.not. wetsfchl(mgs)) ) THEN
20624 tmp = fimt1(mgs)*(fimta(mgs) + &
20625 & (4.0e-03)*fimt2(mgs))*qhlacw(mgs)
20627 qhlmul1(mgs) = cimas0*tmp*rhoinv(mgs)
20631 ! qsmul1(mgs) = csmul1(mgs)*(cimas0/rho0(mgs))
20633 ENDIF ! ( ipconc .ge. 2 )
20635 end if ! (in temperature range)
20637 ENDIF ! ( itype1 .eq. 1 .or. itype2 .eq. 1)
20648 ! ICE MULTIPLICATION FROM SNOW
20649 ! Lo and Passarelli 82 / Willis and Heymsfield 89 / Schuur and Rutledge 00b
20650 ! using kfrag as fragmentation rate (s-1) / 500 microns as char mean diam for max snow mix ratio
20655 IF ( isnwfrac /= 0 ) THEN
20657 IF (temg(mgs) .gt. 265.0) THEN !{
20658 if (xdia(mgs,ls,1) .gt. 100.e-6 .and. xdia(mgs,ls,1) .lt. 2.0e-3) then ! equiv diameter 100microns to 2mm
20660 tmp = rhoinv(mgs)*pi*xdn(mgs,ls)*cx(mgs,ls)*(500.e-6)**3
20661 qsmul(mgs) = Max( kfrag*( qx(mgs,ls) - tmp ) , 0.0 )
20663 qsmul(mgs) = Min( qxmxd(mgs,li), qsmul(mgs) )
20664 csmul(mgs) = Min( cxmxd(mgs,li), rho0(mgs)*qsmul(mgs)/mfrag )
20672 ! frozen rain-rain interaction....
20677 ! rain-ice interaction
20681 qracif(mgs) = qraci(mgs)
20682 cracif(mgs) = craci(mgs)
20683 ! ciacrf(mgs) = ciacr(mgs)
20687 ! vapor to pristine ice crystals UP
20691 ! compute the nucleation rate
20693 ! do mgs = 1,ngscnt
20695 ! if ( ssi(mgs) .gt. 1.0 ) idqis = 1
20696 ! fiinit(mgs) = (felv(mgs)**2)/(cp*rw)
20697 ! dqisdt(mgs) = (qx(mgs,lv)-qis(mgs))/
20698 ! > (1.0 + fiinit(mgs)*qis(mgs)/tsqr(mgs))
20699 ! qidsvp(mgs) = dqisdt(mgs)
20700 ! cnnt = min(cnit*exp(-temcg(mgs)*bta1),1.0e+09)
20702 ! > il5(mgs)*idqis*(1.0*dtpinv)
20703 ! < *min((6.88e-13)*cnnt/rho0(mgs), 0.25*dqisdt(mgs))
20706 ! Meyers et al. (1992; JAS) and Ferrier (1994) primary ice nucleation
20708 cmassin = cimasn ! 6.88e-13
20717 IF ( icenucopt == 1 .or. icenucopt == -10 .or. icenucopt == -11 ) THEN
20718 if ( ( temg(mgs) .lt. 268.15 .or. &
20719 ! : ( imeyers5 .and. temg(mgs) .lt. 273.0) ) .and. &
20720 & ( imeyers5 .and. temg(mgs) .lt. 272.0 .and. temgkm2(mgs) .lt. tfr) ) .and. &
20721 & ciintmx .gt. (cx(mgs,li)+ccitmp) &
20722 ! : .and. cninm(mgs) .gt. 0. &
20724 fiinit(mgs) = (felv(mgs)**2)/(cp*rw)
20725 dqisdt(mgs) = (qx(mgs,lv)-qis(mgs))/ &
20726 & (1.0 + fiinit(mgs)*qis(mgs)/tsqr(mgs))
20727 ! qidsvp(mgs) = dqisdt(mgs)
20729 if ( ssi(mgs) .gt. 1.0 ) THEN
20731 dzfacp = max( float(kgsp(mgs)-kgs(mgs)), 0.0 )
20732 dzfacm = max( float(kgs(mgs)-kgsm(mgs)), 0.0 )
20735 & *(cmassin/rho0(mgs)) &
20736 & *max(0.0,wvel(mgs)) &
20737 & *max((cninp(mgs)-cninm(mgs)),0.0)/gz(igs(mgs),jgs,kgs(mgs)) &
20738 & /((dzfacp+dzfacm))
20740 qiint(mgs) = min(qiint(mgs), max(0.25*dqisdt(mgs),0.0))
20741 ciint(mgs) = qiint(mgs)*rho0(mgs)/cmassin
20744 ! limit new crystals so it does not increase the current concentration
20745 ! above ciintmx 20,000 per liter (2.e7 per m**3)
20749 IF ( icenucopt /= -10 ) THEN
20751 IF ( lcin > 1 ) THEN
20752 ciint(mgs) = Min(ciint(mgs), ccin(mgs)*dtpinv) ! because ciint is a *rate*
20753 ccin(mgs) = ccin(mgs) - ciint(mgs)*dtp
20754 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
20755 ELSEIF ( lcina > 1 ) THEN
20756 ciint(mgs) = Max(0.0, Min( ciint(mgs), Min( cnina(mgs), ciintmx ) - cina(mgs) ))
20757 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
20759 ELSEIF ( icenucopt == 1 .and. ciint(mgs) .gt. Max(0.0, ciintmx - cx(mgs,li) - ccitmp )*dtpinv ) THEN
20760 ciint(mgs) = Max(0.0, ciintmx - (cx(mgs,li)) )*dtpinv
20761 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
20763 ELSEIF ( icenucopt == -11 .and. dtp*ciint(mgs) .gt. ( cnina(mgs) - (cx(mgs,li) - ccitmp))) THEN
20764 ciint(mgs) = Max(0.0, cnina(mgs) - (cx(mgs,li)+ccitmp)*dtpinv )
20765 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
20773 ELSEIF ( icenucopt == 2 .or. icenucopt == -1 .or. icenucopt == -2 ) THEN
20775 IF ( ( temg(mgs) .lt. 268.15 .and. ssw(mgs) > 1.0 ) .or. ssi(mgs) > 1.25 ) THEN
20776 IF ( lcin > 1 ) THEN
20777 ciint(mgs) = Min(cnina(mgs), ccin(mgs))
20778 ciint(mgs) = Min( ciint(mgs), Max(0.0, ciintmx - (cx(mgs,li) - ccitmp) ) ) ! do not initiate ice beyond concentration of ciintmx
20779 ccin(mgs) = ccin(mgs) - ciint(mgs)
20780 ciint(mgs) = ciint(mgs)*dtpinv ! convert total initiation to a rate
20782 ciint(mgs) = Max( 0.0, cnina(mgs) - cina(mgs) )*dtpinv
20784 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
20786 fiinit(mgs) = (felv(mgs)**2)/(cp*rw)
20787 dqisdt(mgs) = (qx(mgs,lv)-qis(mgs))/(1.0 + fiinit(mgs)*qis(mgs)/tsqr(mgs))
20788 qiint(mgs) = min(qiint(mgs), max(0.25*dqisdt(mgs),0.0))
20789 ciint(mgs) = qiint(mgs)*rho0(mgs)/cmassin
20794 ELSEIF ( icenucopt == 3 .or. icenucopt == 4 .or. icenucopt == 10 ) THEN
20795 IF ( temg(mgs) .lt. 268.15 ) THEN
20796 IF ( lcin > 1 ) THEN
20797 ciint(mgs) = Min(cnina(mgs), ccin(mgs))
20798 ciint(mgs) = Min( ciint(mgs), Max(0.0, ciintmx - (cx(mgs,li) + ccitmp) ) ) ! do not initiate ice beyond concentration of ciintmx
20799 ccin(mgs) = ccin(mgs) - ciint(mgs)
20800 ciint(mgs) = ciint(mgs)*dtpinv ! convert total initiation to a rate
20802 ciint(mgs) = Max( 0.0, cnina(mgs) - cina(mgs) )*dtpinv
20804 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
20809 if ( xplate(mgs) .eq. 1 ) then
20810 qipipnt(mgs) = qiint(mgs)
20811 cipint(mgs) = ciint(mgs)
20814 if ( xcolmn(mgs) .eq. 1 ) then
20815 qicicnt(mgs) = qiint(mgs)
20816 cicint(mgs) = ciint(mgs)
20819 ! qipipnt(mgs) = 0.0
20820 ! qicicnt(mgs) = qiint(mgs)
20827 ! vapor to cloud droplets UP
20829 if (ndebug .gt. 0 ) write(0,*) 'dbg = 8'
20832 if (ndebug .gt. 0 ) write(0,*) 'Collection: set 3-component'
20834 ! time for riming....
20842 ! coefficients for riming
20860 ! first sum all of the shed rain
20864 qrshr(mgs) = qsshr(mgs) + qhshr(mgs) + qhlshr(mgs)
20865 crshr(mgs) = chshrr(mgs)/rzxh(mgs) + chlshrr(mgs)/rzxhl(mgs)
20868 IF ( ipconc .ge. 3 ) THEN
20869 ! crshr(mgs) = Max(crshr(mgs), rho0(mgs)*qrshr(mgs)/(xdn(mgs,lr)*vr1mm) )
20880 IF ( ipconc .ge. 1 ) THEN
20883 ! concentration production terms
20888 ! DO mgs = 1,ngscnt
20909 ! IF ( ipconc .ge. 1 ) THEN
20911 IF ( warmonly < 0.5 ) THEN
20912 IF ( ffrzs < 1.0 ) THEN
20915 & il5(mgs)*cicint(mgs) &
20916 & +il5(mgs)*((1.0-cwfrz2snowfrac)*cwfrzc(mgs)+cwctfzc(mgs) &
20920 & + csplinter(mgs) + csplinter2(mgs) &
20923 pccii(mgs) = pccii(mgs)*(1.0 - ffrzs)
20925 ! > + nsplinter*(crfrzf(mgs) + crfrz(mgs))
20927 & il5(mgs)*(-cscni(mgs) - cscnvi(mgs) & ! - cwaci(mgs) &
20930 & -chaci(mgs) - chlaci(mgs) &
20932 & +il5(mgs)*cisbv(mgs) &
20933 & -(1.-il5(mgs))*cimlr(mgs)
20935 pccin(mgs) = ciint(mgs)
20940 ELSEIF ( warmonly < 0.8 ) THEN
20944 ! cicint(mgs) = 0.0
20945 ! qicicnt(mgs) = 0.0
20948 & il5(mgs)*cicint(mgs) &
20949 & +il5(mgs)*((1.0-cwfrz2snowfrac)*cwfrzc(mgs)+cwctfzc(mgs) &
20953 & + csplinter(mgs) + csplinter2(mgs) &
20956 pccii(mgs) = pccii(mgs)*(1. - ffrzs)
20958 ! & il5(mgs)*(-cscni(mgs) - cscnvi(mgs) & ! - cwaci(mgs) &
20961 ! & -chaci(mgs) - chlaci(mgs) &
20963 & +il5(mgs)*cisbv(mgs) &
20964 & -(1.-il5(mgs))*cimlr(mgs)
20966 pccin(mgs) = ciint(mgs)
20972 ! ENDIF ! ( ipconc .ge. 1 )
20976 IF ( ipconc .ge. 2 ) THEN
20979 pccwi(mgs) = (0.0) - cwshw(mgs) ! + (1-il5(mgs))*(-cirmlw(mgs))
20981 IF ( warmonly < 0.5 ) THEN
20984 & il5(mgs)*(-ciacw(mgs)-cwfrz(mgs)-cwctfzp(mgs) &
20987 & -cracw(mgs) -csacw(mgs) -chacw(mgs) - chlacw(mgs)
20990 ELSEIF ( warmonly < 0.8 ) THEN
20994 & -ciacw(mgs)-cwfrz(mgs)-cwctfzp(mgs) &
20997 & -cracw(mgs) -chacw(mgs) -chlacw(mgs)
21000 ! tmp3d(igs(mgs),jy,kgs(mgs)) = crcnw(mgs)
21002 ! cracw(mgs) = 0.0 ! turn off accretion
21004 ! crcev(mgs) = 0.0 ! turn off evap
21005 ! qrcev(mgs) = 0.0 ! turn off evap
21006 ! cracr(mgs) = 0.0 ! turn off self collection
21014 & - cautn(mgs) -cracw(mgs)
21018 IF ( .false. .and. exwmindiam > 0.0 .and. ccwresv(mgs) > 0.0 ) THEN
21020 & il5(mgs)*(-ciacw(mgs) &
21022 & -cracw(mgs) -csacw(mgs) -chacw(mgs) - chlacw(mgs)
21024 IF ( -pccwdacc(mgs)*dtp .gt. cx(mgs,lc) - ccwresv(mgs) ) THEN
21026 frac = -(cx(mgs,lc) - ccwresv(mgs) )/(pccwdacc(mgs)*dtp)
21027 pccwdacc(mgs) = -(cx(mgs,lc) - ccwresv(mgs) )*dtpinv
21029 ciacw(mgs) = frac*ciacw(mgs)
21030 cracw(mgs) = frac*cracw(mgs)
21031 csacw(mgs) = frac*csacw(mgs)
21032 chacw(mgs) = frac*chacw(mgs)
21033 cautn(mgs) = frac*cautn(mgs)
21035 IF ( lhl .gt. 1 ) chlacw(mgs) = frac*chlacw(mgs)
21040 & il5(mgs)*(-ciacw(mgs)-cwfrzp(mgs)-cwctfzp(mgs) &
21041 & -cwfrzc(mgs)-cwctfzc(mgs) &
21042 & -il5(mgs)*(ciihr(mgs)) &
21044 & -cracw(mgs) -csacw(mgs) -chacw(mgs) - chlacw(mgs)
21051 IF ( -pccwd(mgs)*dtp .gt. cx(mgs,lc) ) THEN
21052 ! write(0,*) 'OUCH! pccwd(mgs)*dtp .gt. ccw(mgs) ',pccwd(mgs),cx(mgs,lc)
21053 ! write(0,*) 'qc = ',qx(mgs,lc)
21054 ! write(0,*) -ciacw(mgs)-cwfrzp(mgs)-cwctfzp(mgs)-cwfrzc(mgs)-cwctfzc(mgs)
21055 ! write(0,*) -cracw(mgs) -csacw(mgs) -chacw(mgs)
21056 ! write(0,*) - cautn(mgs)
21058 frac = -cx(mgs,lc)/(pccwd(mgs)*dtp)
21059 pccwd(mgs) = -cx(mgs,lc)*dtpinv
21061 ciacw(mgs) = frac*ciacw(mgs)
21062 cwfrz(mgs) = frac*cwfrz(mgs)
21063 cwfrzp(mgs) = frac*cwfrzp(mgs)
21064 cwctfzp(mgs) = frac*cwctfzp(mgs)
21065 cwfrzc(mgs) = frac*cwfrzc(mgs)
21066 cwctfzc(mgs) = frac*cwctfzc(mgs)
21067 cwctfz(mgs) = frac*cwctfz(mgs)
21068 cracw(mgs) = frac*cracw(mgs)
21069 csacw(mgs) = frac*csacw(mgs)
21070 chacw(mgs) = frac*chacw(mgs)
21071 cautn(mgs) = frac*cautn(mgs)
21073 pccii(mgs) = pccii(mgs) - (1.-frac)*il5(mgs)*(cwfrzc(mgs)+cwctfzc(mgs))*(1. - ffrzs)
21074 IF ( lhl .gt. 1 ) chlacw(mgs) = frac*chlacw(mgs)
21086 IF ( ipconc .ge. 3 ) THEN
21090 IF ( warmonly < 0.5 ) THEN
21094 & +(1-il5(mgs))*( &
21095 & -chmlrr(mgs)/rzxh(mgs) &
21096 & -chlmlrr(mgs)/rzxhl(mgs) &
21097 ! & -csmlr(mgs)/rzxs(mgs) &
21100 & -crshr(mgs) !null at this point when wet snow/graupel included
21102 & il5(mgs)*(-ciacr(mgs) - crfrz(mgs) ) & ! - cipacr(mgs))
21104 & - chacr(mgs) - chlacr(mgs) &
21107 ! > -il5(mgs)*ciracr(mgs)
21110 ELSEIF ( warmonly < 0.8 ) THEN
21113 & +(1-il5(mgs))*( &
21114 & -chmlrr(mgs)/rzxh(mgs) &
21115 & -chlmlrr(mgs)/rzxhl(mgs) &
21119 & -crshr(mgs) !null at this point when wet snow/graupel included
21121 & il5(mgs)*( - crfrz(mgs) ) & ! - cipacr(mgs))
21133 ! tmp3d(igs(mgs),jy,kgs(mgs)) = vtxbar(mgs,lr,1) ! crcnw(mgs) ! (pcrwi(mgs) + pcrwd(mgs))
21142 IF ( -pcrwd(mgs)*dtp .gt. cx(mgs,lr) ) THEN
21143 ! write(0,*) 'OUCH! pcrwd(mgs)*dtp .gt. crw(mgs) ',pcrwd(mgs)*dtp,cx(mgs,lr),mgs,igs(mgs),kgs(mgs)
21144 ! write(0,*) -ciacr(mgs)
21145 ! write(0,*) -crfrz(mgs)
21146 ! write(0,*) -chacr(mgs)
21147 ! write(0,*) crcev(mgs)
21148 ! write(0,*) -cracr(mgs)
21150 frac = -cx(mgs,lr)/(pcrwd(mgs)*dtp)
21151 pcrwd(mgs) = -cx(mgs,lr)*dtpinv
21153 ciacr(mgs) = frac*ciacr(mgs)
21154 ciacrf(mgs) = frac*ciacrf(mgs)
21155 ciacrs(mgs) = frac*ciacrs(mgs)
21156 crfrz(mgs) = frac*crfrz(mgs)
21157 crfrzf(mgs) = frac*crfrzf(mgs)
21158 crfrzs(mgs) = frac*crfrzs(mgs)
21159 chacr(mgs) = frac*chacr(mgs)
21160 chlacr(mgs) = frac*chlacr(mgs)
21161 crcev(mgs) = frac*crcev(mgs)
21162 cracr(mgs) = frac*cracr(mgs)
21172 IF ( warmonly < 0.5 ) THEN
21177 IF ( ipconc .ge. 4 ) THEN !
21181 & il5(mgs)*(cscnis(mgs) + cscnvis(mgs) ) &
21182 & + cwfrz2snowfrac*cwfrz(mgs)/cwfrz2snowratio &
21185 IF ( ffrzs > 0.0 ) THEN
21186 pcswi(mgs) = pcswi(mgs) + ffrzs* ( &
21187 & il5(mgs)*cicint(mgs) &
21188 & +il5(mgs)*(cwfrzc(mgs)+cwctfzc(mgs) &
21192 & + csplinter(mgs) + csplinter2(mgs) &
21197 IF ( ess0 < 0.0 ) THEN
21198 csacs(mgs) = Max(0.0, csacs(mgs) - (ifrzs)*(crfrzs(mgs) + ciacrs(mgs)))
21203 & -chacs(mgs) - chlacs(mgs) &
21205 & +(1-il5(mgs))*csmlr(mgs) + csshr(mgs) & ! + csshrp(mgs)
21206 ! > +il5(mgs)*(cssbv(mgs)) &
21211 IF ( imixedphase == 0 ) THEN
21212 IF ( cx(mgs,ls) + dtp*(pcswi(mgs) + pcswd(mgs)) < 0.0 ) THEN
21213 frac = (-cx(mgs,ls) + pcswi(mgs)*dtp)/(pcswd(mgs)*dtp)
21215 pcswd(mgs) = frac*pcswd(mgs)
21217 chacs(mgs) = frac*chacs(mgs)
21218 chlacs(mgs) = frac*chlacs(mgs)
21219 chcns(mgs) = frac*chcns(mgs)
21220 csmlr(mgs) = frac*csmlr(mgs)
21221 csshr(mgs) = frac*csshr(mgs)
21222 cssbv(mgs) = frac*cssbv(mgs)
21223 csacs(mgs) = frac*csacs(mgs)
21230 pccii(mgs) = pccii(mgs) &
21231 & + (1. - ifrzs)*crfrzs(mgs) &
21232 & + (1. - ifrzs)*ciacrs(mgs)
21234 pcswi(mgs) = pcswi(mgs) &
21235 & + (ifrzs)*crfrzs(mgs) &
21236 & + (ifrzs)*ciacrs(mgs)
21245 IF ( ipconc .ge. 5 ) THEN !
21248 & +(ffrzh*ifrzg*crfrzf(mgs) &
21249 & +il5(mgs)*ffrzh*ifiacrg*(ciacrf(mgs) )) &
21250 & + f2h*chcnsh(mgs) + f2h*chcnih(mgs) + chcnhl(mgs)
21253 & (1-il5(mgs))*chmlr(mgs) &
21254 ! > + il5(mgs)*chsbv(mgs) &
21256 & - il5(mgs)*chlcnh(mgs) &
21268 IF ( lhl .gt. 1 .and. lnhl > 1 ) THEN !
21270 pchli(mgs) = (ffrzh*(1.0-ifrzg)*crfrzf(mgs) +il5(mgs)*ffrzh*(1.0-ifiacrg)*(ciacrf(mgs) )) &
21271 & + chlcnhhl(mgs) *rzxhlh(mgs)
21274 & (1-il5(mgs))*chlmlr(mgs) &
21275 ! > + il5(mgs)*chlsbv(mgs) &
21276 & + chlsbv(mgs) - chcnhl(mgs)
21278 IF ( imixedphase == 0 ) THEN
21280 IF ( cx(mgs,lhl) + dtp*(pchli(mgs) + pchld(mgs)) < 0.0 ) THEN
21281 ! rescale depletion
21283 frac = (-cx(mgs,lhl) + pchli(mgs)*dtp)/(pchld(mgs)*dtp)
21285 chlmlr(mgs) = frac*chlmlr(mgs)
21286 chlsbv(mgs) = frac*chlsbv(mgs)
21287 chcnhl(mgs) = frac*chcnhl(mgs)
21289 pchld(mgs) = frac*pchld(mgs)
21299 ENDIF ! (ipconc .ge. 5 )
21301 ELSEIF ( warmonly < 0.8 ) THEN
21306 IF ( ipconc .ge. 5 ) THEN !
21309 & +ifrzg*(crfrzf(mgs) ) ! +il5(mgs)*(ciacrf(mgs) ))
21312 & (1-il5(mgs))*chmlr(mgs) &
21313 & - il5(mgs)*chlcnh(mgs)
21318 IF ( lhl .gt. 1 ) THEN !
21320 pchli(mgs) = (1.0-ifrzg)*(crfrzf(mgs)) & ! +il5(mgs)*(ciacrf(mgs) )) &
21321 & + chlcnhhl(mgs) *rzxhl(mgs)/rzxh(mgs)
21324 & (1-il5(mgs))*chlmlr(mgs) ! &
21325 ! > + il5(mgs)*chlsbv(mgs) &
21328 ! IF ( pchli(mgs) .ne. 0. .or. pchld(mgs) .ne. 0 ) THEN
21329 ! write(0,*) 'dr: pchli,pchld = ', pchli(mgs),pchld(mgs), igs(mgs),kgs(mgs)
21335 ENDIF ! ipconc >= 5
21342 ! Balance and checks for continuity.....within machine precision...
21345 pctot(mgs) = pccwi(mgs) +pccwd(mgs) + &
21346 & pccii(mgs) +pccid(mgs) + &
21347 & pcrwi(mgs) +pcrwd(mgs) + &
21348 & pcswi(mgs) +pcswd(mgs) + &
21349 & pchwi(mgs) +pchwd(mgs) + &
21350 & pchli(mgs) +pchld(mgs)
21354 ENDIF ! ( ipconc .ge. 1 )
21361 ! production terms for mass
21389 IF ( ipconc > 5 ) THEN
21402 IF ( warmonly < 0.5 ) THEN
21405 ! NOTE: ANY CHANGES HERE ALSO NEED TO GO INTO THE RESUM FARTHER DOWN!
21407 & -Min(0.0, qrcev(mgs)) &
21408 & -Min(0.0, qhcev(mgs)) &
21409 & -Min(0.0, qhlcev(mgs)) &
21410 & -Min(0.0, qscev(mgs)) &
21411 ! > +il5(mgs)*(-qhsbv(mgs) - qhlsbv(mgs) ) &
21412 & -qhsbv(mgs) - qhlsbv(mgs) &
21414 & -il5(mgs)*qisbv(mgs)
21417 & -Max(0.0, qrcev(mgs)) &
21418 & -Max(0.0, qhcev(mgs)) &
21419 & -Max(0.0, qhlcev(mgs)) &
21420 & -Max(0.0, qscev(mgs)) &
21421 & +il5(mgs)*(-qiint(mgs) &
21422 & -qhdpv(mgs) -qsdpv(mgs) - qhldpv(mgs)) &
21423 & -il5(mgs)*qidpv(mgs)
21427 ELSEIF ( warmonly < 0.8 ) THEN
21430 & -Min(0.0, qrcev(mgs)) &
21431 & -il5(mgs)*qisbv(mgs)
21433 & +il5(mgs)*(-qiint(mgs) &
21434 ! & -qhdpv(mgs) ) & !- qhldpv(mgs)) &
21435 & -qhdpv(mgs) - qhldpv(mgs)) &
21436 ! & -qhdpv(mgs) -qsdpv(mgs) - qhldpv(mgs)) &
21437 & -Max(0.0, qrcev(mgs)) &
21438 & -il5(mgs)*qidpv(mgs)
21444 & -Min(0.0, qrcev(mgs))
21446 & -Max(0.0, qrcev(mgs))
21455 pqcwi(mgs) = (0.0) + qwcnr(mgs) - qwshw(mgs)
21457 IF ( warmonly < 0.5 ) THEN
21459 & il5(mgs)*(-qiacw(mgs)-qwfrz(mgs)-qwctfz(mgs)) &
21460 & -il5(mgs)*(qiihr(mgs)) &
21461 & -qracw(mgs) -qsacw(mgs) -qrcnw(mgs) -qhacw(mgs) - qhlacw(mgs) !&
21462 ! & -il5(mgs)*(qwfrzp(mgs))
21463 ELSEIF ( warmonly < 0.8 ) THEN
21465 & il5(mgs)*(-qiacw(mgs)-qwfrz(mgs)-qwctfz(mgs)) &
21466 & -il5(mgs)*(qiihr(mgs)) &
21467 & -qracw(mgs) -qrcnw(mgs) -qhacw(mgs) -qhlacw(mgs)
21470 & -qracw(mgs) - qrcnw(mgs)
21474 IF ( pqcwd(mgs) .lt. 0.0 .and. -pqcwd(mgs)*dtp .gt. qx(mgs,lc) ) THEN
21476 frac = -Max(0.0,qx(mgs,lc))/(pqcwd(mgs)*dtp)
21477 pqcwd(mgs) = -qx(mgs,lc)*dtpinv
21479 qiacw(mgs) = frac*qiacw(mgs)
21480 ! qwfrzp(mgs) = frac*qwfrzp(mgs)
21481 ! qwctfzp(mgs) = frac*qwctfzp(mgs)
21482 qwfrzc(mgs) = frac*qwfrzc(mgs)
21483 qwfrz(mgs) = frac*qwfrz(mgs)
21484 qwctfzc(mgs) = frac*qwctfzc(mgs)
21485 qwctfz(mgs) = frac*qwctfz(mgs)
21486 qracw(mgs) = frac*qracw(mgs)
21487 qsacw(mgs) = frac*qsacw(mgs)
21488 qhacw(mgs) = frac*qhacw(mgs)
21489 vhacw(mgs) = frac*vhacw(mgs)
21490 qrcnw(mgs) = frac*qrcnw(mgs)
21491 qwfrzp(mgs) = frac*qwfrzp(mgs)
21492 IF ( lhl .gt. 1 ) THEN
21493 qhlacw(mgs) = frac*qhlacw(mgs)
21494 vhlacw(mgs) = frac*vhlacw(mgs)
21496 ! IF ( lzh .gt. 1 ) zhacw(mgs) = frac*zhacw(mgs)
21506 IF ( warmonly < 0.5 ) THEN
21509 IF ( ffrzs < 1.0 ) THEN
21511 & il5(mgs)*qicicnt(mgs) &
21512 & +il5(mgs)*((1.0-cwfrz2snowfrac)*qwfrzc(mgs)+qwctfzc(mgs)) &
21513 & +il5(mgs)*(qicichr(mgs)) &
21515 & +qhmul1(mgs) + qhlmul1(mgs) &
21516 & + qsplinter(mgs) + qsplinter2(mgs)
21517 ! > + cimas0*nsplinter*(crfrzf(mgs) + crfrz(mgs))/rho0(mgs)
21520 pqcii(mgs) = pqcii(mgs)*(1.0 - ffrzs) &
21521 & +il5(mgs)*qidpv(mgs) &
21522 & +il5(mgs)*qiacw(mgs)
21525 & il5(mgs)*(-qscni(mgs) - qscnvi(mgs) & ! -qwaci(mgs) &
21530 & +il5(mgs)*qisbv(mgs) &
21531 & +(1.-il5(mgs))*qimlr(mgs) &
21536 ELSEIF ( warmonly < 0.8 ) THEN
21540 & il5(mgs)*qicicnt(mgs)*(1. - ffrzs) &
21541 & +il5(mgs)*((1.0-cwfrz2snowfrac)*qwfrzc(mgs)+qwctfzc(mgs))*(1. - ffrzs) &
21542 & +il5(mgs)*(qicichr(mgs))*(1. - ffrzs) &
21543 ! & +il5(mgs)*(qicichr(mgs)) &
21545 & +qhmul1(mgs) + qhlmul1(mgs) &
21546 & + qsplinter(mgs) + qsplinter2(mgs) &
21547 & +il5(mgs)*qidpv(mgs) &
21548 & +il5(mgs)*qiacw(mgs) ! & ! (qiacwi(mgs)+qwacii(mgs)) &
21549 ! & +il5(mgs)*(qwfrzc(mgs)+qwctfzc(mgs)) &
21550 ! & +il5(mgs)*(qicichr(mgs)) &
21552 ! & +qhmul1(mgs) + qhlmul1(mgs) &
21553 ! & + qsplinter(mgs) + qsplinter2(mgs)
21556 ! & il5(mgs)*(-qscni(mgs) - qscnvi(mgs) & ! -qwaci(mgs) &
21558 ! & -qsaci(mgs) ) &
21561 & +il5(mgs)*qisbv(mgs) &
21562 & +(1.-il5(mgs))*qimlr(mgs) ! &
21572 IF ( warmonly < 0.5 ) THEN
21574 & qracw(mgs) + qrcnw(mgs) + Max(0.0, qrcev(mgs)) &
21575 & +(1-il5(mgs))*( &
21576 & -qhmlr(mgs) & !null at this point when wet snow/graupel included
21577 & -qsmlr(mgs) - qhlmlr(mgs) &
21579 ! & -qsshr(mgs) & !null at this point when wet snow/graupel included
21580 ! & -qhshr(mgs) & !null at this point when wet snow/graupel included
21585 & il5(mgs)*(-qiacr(mgs)-qrfrz(mgs)) &
21586 & - qsacr(mgs) - qhacr(mgs) - qhlacr(mgs) - qwcnr(mgs) &
21587 & + Min(0.0,qrcev(mgs))
21588 ELSEIF ( warmonly < 0.8 ) THEN
21590 & qracw(mgs) + qrcnw(mgs) + Max(0.0, qrcev(mgs)) &
21591 & +(1-il5(mgs))*( &
21592 & -qhlmlr(mgs) & !null at this point when wet snow/graupel included
21593 & -qhmlr(mgs) ) & !null at this point when wet snow/graupel included
21594 & -qhshr(mgs) & !null at this point when wet snow/graupel included
21595 & -qhlshr(mgs) !null at this point when wet snow/graupel included
21597 & il5(mgs)*(-qrfrz(mgs)) &
21600 & + Min(0.0,qrcev(mgs))
21603 & qracw(mgs) + qrcnw(mgs) + Max(0.0, qrcev(mgs))
21604 pqrwd(mgs) = Min(0.0,qrcev(mgs))
21608 ! IF ( pqrwd(mgs) .lt. 0.0 .and. -(pqrwd(mgs) + pqrwi(mgs))*dtp .gt. qx(mgs,lr) ) THEN
21609 IF ( pqrwd(mgs) .lt. 0.0 .and. -(pqrwd(mgs) + pqrwi(mgs))*dtp .gt. qx(mgs,lr) ) THEN
21611 frac = (-qx(mgs,lr) + pqrwi(mgs)*dtp)/(pqrwd(mgs)*dtp)
21612 ! pqrwd(mgs) = -qx(mgs,lr)*dtpinv + pqrwi(mgs)
21614 pqwvi(mgs) = pqwvi(mgs) &
21615 & + Min(0.0, qrcev(mgs)) &
21616 & - frac*Min(0.0, qrcev(mgs))
21617 pqwvd(mgs) = pqwvd(mgs) &
21618 & + Max(0.0, qrcev(mgs)) &
21619 & - frac*Max(0.0, qrcev(mgs))
21621 qiacr(mgs) = frac*qiacr(mgs)
21622 qiacrf(mgs) = frac*qiacrf(mgs)
21623 qiacrs(mgs) = frac*qiacrs(mgs)
21624 viacrf(mgs) = frac*viacrf(mgs)
21625 qrfrz(mgs) = frac*qrfrz(mgs)
21626 qrfrzs(mgs) = frac*qrfrzs(mgs)
21627 qrfrzf(mgs) = frac*qrfrzf(mgs)
21628 vrfrzf(mgs) = frac*vrfrzf(mgs)
21629 qsacr(mgs) = frac*qsacr(mgs)
21630 qhacr(mgs) = frac*qhacr(mgs)
21631 vhacr(mgs) = frac*vhacr(mgs)
21632 qrcev(mgs) = frac*qrcev(mgs)
21633 qhlacr(mgs) = frac*qhlacr(mgs)
21634 vhlacr(mgs) = frac*vhlacr(mgs)
21635 qhcev(mgs) = frac*qhcev(mgs)
21636 qhlcev(mgs) = frac*qhlcev(mgs)
21639 IF ( warmonly < 0.5 ) THEN
21641 & il5(mgs)*(-qiacr(mgs)-qrfrz(mgs) - qsacr(mgs)) &
21642 & - qhacr(mgs) - qhlacr(mgs) - qwcnr(mgs) &
21643 & + Min(0.0,qrcev(mgs))
21644 ELSEIF ( warmonly < 0.8 ) THEN
21646 & il5(mgs)*(-qrfrz(mgs)) &
21649 & + Min(0.0,qrcev(mgs))
21651 pqrwd(mgs) = Min(0.0,qrcev(mgs))
21655 ! Resum for vapor since qrcev has changed
21657 IF ( qrcev(mgs) .ne. 0.0 ) THEN
21659 & -Min(0.0, qrcev(mgs)) &
21660 & -Min(0.0, qhcev(mgs)) &
21661 & -Min(0.0, qhlcev(mgs)) &
21662 & -Min(0.0, qscev(mgs)) &
21663 ! > +il5(mgs)*(-qhsbv(mgs) - qhlsbv(mgs) ) &
21664 & -qhsbv(mgs) - qhlsbv(mgs) &
21666 & -il5(mgs)*qisbv(mgs)
21669 & -Max(0.0, qrcev(mgs)) &
21670 & -Max(0.0, qhcev(mgs)) &
21671 & -Max(0.0, qhlcev(mgs)) &
21672 & -Max(0.0, qscev(mgs)) &
21673 & +il5(mgs)*(-qiint(mgs) &
21674 & -qhdpv(mgs) -qsdpv(mgs) - qhldpv(mgs)) &
21675 & -il5(mgs)*qidpv(mgs)
21686 IF ( warmonly < 0.5 ) THEN
21693 & il5(mgs)*(qscni(mgs)+qsaci(mgs)+qsdpv(mgs) &
21695 & + ifrzs*(qiacrs(mgs) + qrfrzs(mgs)) &
21696 & + il5(mgs)*(( qwfrzc(mgs) + qwctfzc(mgs) + qicichr(mgs) )*ffrzs &
21697 & + (1.0 - ffrzs)*cwfrz2snowfrac*qwfrz(mgs) ) &
21698 & + il2(mgs)*qsacr(mgs)) &
21699 & + il5(mgs)*qicicnt(mgs)*ffrzs &
21700 & + il3(mgs)*(qiacrf(mgs)+qracif(mgs)) & ! only applies for ipconc <= 3
21701 & + Max(0.0, qscev(mgs)) &
21702 & + qsacw(mgs) + qscnh(mgs) &
21703 & + ffrzs*(qsmul(mgs) &
21704 & +qhmul1(mgs) + qhlmul1(mgs) &
21705 & + qsplinter(mgs) + qsplinter2(mgs))
21707 ! > -qfacs(mgs) ! -qwacs(mgs) &
21708 & -qracs(mgs)*(1-il2(mgs)) -qhacs(mgs) - qhlacs(mgs) &
21710 & +(1-il5(mgs))*qsmlr(mgs) + qsshr(mgs) & !null at this point when wet snow included
21711 ! > +il5(mgs)*(qssbv(mgs)) &
21713 & + Min(0.0, qscev(mgs)) &
21717 IF ( imixedphase == 0 .and. pqswd(mgs) .lt. 0.0 ) THEN
21718 IF ( qx(mgs,ls) + dtp*(pqswi(mgs) + pqswd(mgs)) < 0.0 ) THEN
21719 frac = (-qx(mgs,ls) + pqswi(mgs)*dtp)/(pqswd(mgs)*dtp)
21721 pqswd(mgs) = frac*pqswd(mgs)
21723 qracs(mgs) = frac*qracs(mgs) ! only used for single moment at this time
21724 qhacs(mgs) = frac*qhacs(mgs)
21725 qhlacs(mgs) = frac*qhlacs(mgs)
21726 qhcns(mgs) = frac*qhcns(mgs)
21727 qsmlr(mgs) = frac*qsmlr(mgs)
21728 qsshr(mgs) = frac*qsshr(mgs)
21729 qssbv(mgs) = frac*qssbv(mgs)
21730 qsmul(mgs) = frac*qsmul(mgs)
21731 IF ( qscev(mgs) < 0.0 ) qscev(mgs) = frac*qscev(mgs)
21736 pqcii(mgs) = pqcii(mgs) &
21737 & + (1. - ifrzs)*qrfrzs(mgs) &
21738 & + (1. - ifrzs)*qiacrs(mgs)
21747 & +il5(mgs)*(ffrzh*ifrzg*qrfrzf(mgs) + (1-il3(mgs))*ffrzh*ifiacrg*(qiacrf(mgs)+qracif(mgs))) &
21748 & + (1-il2(mgs))*(qracs(mgs) + qsacr(mgs)) & ! only used for ipconc < 3
21749 & +il5(mgs)*(qhdpv(mgs)) &
21750 & +Max(0.0, qhcev(mgs)) &
21751 & +qhacr(mgs)+qhacw(mgs) &
21752 & +qhacs(mgs)+qhaci(mgs) &
21753 & + f2h*qhcns(mgs) + f2h*qhcni(mgs) + qhcnhl(mgs)
21755 & qhshr(mgs) & !null at this point when wet graupel included
21756 & +(1-il5(mgs))*qhmlr(mgs) & !null at this point when wet graupel included
21757 ! > +il5(mgs)*qhsbv(mgs) &
21759 & + Min(0.0, qhcev(mgs)) &
21760 & -qhmul1(mgs) - qhlcnh(mgs) - qscnh(mgs) &
21761 & - ffrzh*(qsplinter(mgs) + qsplinter2(mgs))
21762 ! > - cimas0*nsplinter*(crfrzf(mgs) + crfrz(mgs))/rho0(mgs)
21770 IF ( lhl .gt. 1 ) THEN
21774 & +il5(mgs)*(qhldpv(mgs) + ((1.0-ifrzg)*qrfrzf(mgs) + (1.0-ifiacrg)*(qiacrf(mgs)+ qracif(mgs)))) &
21775 & +Max(0.0, qhlcev(mgs)) &
21776 & +qhlacr(mgs)+qhlacw(mgs) &
21777 & +qhlacs(mgs)+qhlaci(mgs) &
21781 & +(1-il5(mgs))*qhlmlr(mgs) &
21782 ! > +il5(mgs)*qhlsbv(mgs) &
21784 & + Min(0.0, qhlcev(mgs)) &
21785 & -qhlmul1(mgs) - qhcnhl(mgs)
21787 IF ( imixedphase == 0 ) THEN
21789 IF ( qx(mgs,lhl) + dtp*(pqhli(mgs) + pqhld(mgs)) < 0.0 ) THEN
21790 ! rescale depletion
21792 frac = (-qx(mgs,lhl) + pqhli(mgs)*dtp)/(pqhld(mgs)*dtp)
21794 qhlmlr(mgs) = frac*qhlmlr(mgs)
21795 qhlsbv(mgs) = frac*qhlsbv(mgs)
21796 qhcnhl(mgs) = frac*qhcnhl(mgs)
21797 qhlmul1(mgs) = frac*qhlmul1(mgs)
21798 IF ( qhlcev(mgs) < 0.0 ) qhlcev(mgs) = frac*qhlcev(mgs)
21800 pqhld(mgs) = frac*pqhld(mgs)
21810 ELSEIF ( warmonly < 0.8 ) THEN
21816 & +il5(mgs)*ifrzg*(qrfrzf(mgs) ) &
21817 & +il5(mgs)*(qhdpv(mgs)) &
21818 & +qhacr(mgs)+qhacw(mgs)
21820 & qhshr(mgs) & !null at this point when wet graupel included
21823 & - qsplinter(mgs) - qsplinter2(mgs) &
21824 & +(1-il5(mgs))*qhmlr(mgs) !null at this point when wet graupel included
21830 IF ( lhl .gt. 1 ) THEN
21834 & +il5(mgs)*(qhldpv(mgs) ) & ! + (1.0-ifrzg)*(qiacrf(mgs)+qrfrzf(mgs) + qracif(mgs))) &
21835 & +il5(mgs)*(1.0-ifrzg)*(qrfrzf(mgs) ) &
21836 & +qhlacr(mgs)+qhlacw(mgs) &
21837 ! & +qhlacs(mgs)+qhlaci(mgs) &
21841 & +(1-il5(mgs))*qhlmlr(mgs) &
21842 ! > +il5(mgs)*qhlsbv(mgs) &
21844 & -qhlmul1(mgs) - qhcnhl(mgs)
21853 ! Liquid water on snow and graupel
21861 IF ( mixedphase ) THEN
21862 ELSE ! set arrays for non-mixedphase graupel
21865 vhmlr(:) = qhmlr(:) ! not actually volume, but treated as q in rate equation
21869 vhlmlr(:) = qhlmlr(:) ! not actually volume, but treated as q in rate equation
21870 ! vhlmlr(:) = rho0(:)*qhlmlr(:)/xdn(:,lhl)
21878 ! Graupel reflectivity
21880 if (ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'graupel reflectivity'
21886 ! zhmlrr(mgs) = 0.0
21887 ! zhshrr(mgs) = 0.0
21889 ! IF ( lf < 1 ) THEN
21890 IF ( ffrzh > 0.0 ) THEN
21902 IF ( lzh .gt. 1 ) THEN !
21906 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. cx(mgs,lh) .gt. 0.0 ) THEN
21907 tmp = qx(mgs,lh)/cx(mgs,lh)
21908 alp = Max( alphamin, alpha(mgs,lh) )
21909 ! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
21910 g1 = g1x(mgs,lh) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
21911 ! g1r = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
21913 zhaci(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qhaci(mgs) )
21914 zhacs(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qhacs(mgs) )
21916 IF ( .not. mixedphase .and. ibinhmlr < 1 ) THEN
21917 zhmlr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*tmp * qhmlr(mgs) - tmp**2 * chmlr(mgs) )
21920 zhshr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshr(mgs) )
21922 ! IF ( lzr > 0 .and. qhshr(mgs) /= 0.0 .and. chshrr(mgs) /= 0.0 .and. ibinhmlr < 1 ) THEN
21923 IF ( lzr > 0 .and. qhshr(mgs) /= 0.0 .and. chshrr(mgs) /= 0.0 ) THEN
21924 ! IF ( temg(mgs) > tfr + 2.0 ) THEN
21925 ! zhshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshrr(mgs) )
21926 ! IF ( zhshrr(mgs) > 0. ) THEN
21927 ! zhshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshr(mgs) )
21929 ! z1 = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) ) ! should this be g1shr?
21930 ! zhshrr(mgs) = Max( z1, zhshrr(mgs))
21932 ! zhshrr(mgs) = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) )
21935 IF ( temg(mgs) >= tfr ) THEN
21936 ! zhshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn0(lr)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshrr(mgs) )
21937 ! IF ( zhshrr(mgs) > 0.0 ) THEN
21938 ! zhshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn0(lr)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshr(mgs) )
21940 IF ( (shedalp + alpha(mgs,lh))*xdia(mgs,lh,1) < sheddiam ) THEN ! if not shedding small drops, then use alpha of hail
21941 z1 = g1*(6.0*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) )
21943 z1 = g1shr*(6.0*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) ) ! should this be g1shr?
21946 ! z1 = g1mlr*(rho0(mgs)/(xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) ) ! should this be g1shr?
21947 ! zhshrr(mgs) = Max( z1, zhshrr(mgs))
21949 zhshrr(mgs) = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) )
21952 zhshrr(mgs) = Min( 0.0, zhshrr(mgs) )
21955 IF ( zhshr(mgs) > 0.0 ) THEN
21956 write(0,*) 'Problem with zhshr! zhshr,qhshr,chshr = ',zhshr(mgs),qhshr(mgs),chshr(mgs)
21957 write(0,*) 'g1,tmp, qx,cx,zx = ',g1,tmp,qx(mgs,lh),cx(mgs,lh),zx(mgs,lh)
21958 write(0,*) ( 2.*tmp * qhshr(mgs) - tmp**2 * chshr(mgs) ), 2.*tmp * qhshr(mgs), - tmp**2 * chshr(mgs)
21959 write(0,*) 'temcg = ',temcg(mgs),'chshr recalc = ',(cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhshr(mgs)
21965 ! zhshr(mgs) = (xdn0(lr)/(xdn(mgs,lh)))**2*( zx(mgs,lh) * qhshr(mgs) )
21967 qtmp = qhdpv(mgs) + qhcev(mgs) + qhsbv(mgs)
21968 ctmp = chdpv(mgs) + chcev(mgs) + chsbv(mgs)
21970 zhdsv(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qtmp - tmp**2 * ctmp )
21972 alp = Max( alphahacx, alpha(mgs,lh) )
21973 ! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
21974 g1 = g1x(mgs,lh) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
21976 IF ( .true. ) THEN ! {
21977 IF ( qhacr(mgs) .gt. 0.0 ) THEN
21978 ! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacr(mgs) )
21980 ! g1r = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
21981 ! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacr(mgs) )
21982 zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacr(mgs) )
21983 ! zhacrf(mgs) = g1*zhacr
21986 ! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lh)+dtp*qhacr(mgs))**2)/(cx(mgs,lh))
21988 IF ( z > zx(mgs,lh) ) THEN
21989 ! zhacr(mgs) = (z - zx(mgs,lh))*dtpinv
21995 ! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) )
21996 ! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) - tmp**2 * chacr(mgs) )
21998 ! alp = Max( 1.0, alpha(mgs,lh)+1. )
21999 ! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/
22000 ! : ((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22001 IF ( qhacw(mgs) .gt. 0.0 ) THEN
22002 ! zhacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacw(mgs) )
22003 zhacw(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacw(mgs) )
22005 ! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lh)+dtp*(qhacw(mgs)-qhmul1(mgs)))**2)/(cx(mgs,lh))
22006 IF ( z > zx(mgs,lh) ) THEN
22007 ! zhacw(mgs) = (z - zx(mgs,lh))*dtpinv
22011 ELSE ! } { ! this is not used because of the 'true' above
22013 IF ( qhacw(mgs) .gt. 0.0 .or. qhacr(mgs) .gt. 0.0 ) THEN
22014 z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lh)+dtp*(qhacr(mgs) + qhacw(mgs)-qhmul1(mgs)))**2)/(cx(mgs,lh))
22015 ! zhacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacw(mgs) )
22016 IF ( z > zx(mgs,lh) ) THEN
22017 zhacw(mgs) = (z - zx(mgs,lh))*dtpinv
22023 IF ( qhlcnh(mgs) .gt. 0.0 .and. ihlcnh < 2 ) THEN
22024 zhlcnh(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qhlcnh(mgs) - tmp**2 * chlcnh(mgs) )
22028 IF ( ffrzh*qiacrf(mgs) .gt. 0.0 .and. cx(mgs,lr) .gt. 0.0 .and. qx(mgs,lr) .gt. qxmin(lr) ) THEN
22029 tmp = qx(mgs,lr)/cx(mgs,lr)
22031 ! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22032 IF ( imurain == 3 ) THEN
22033 ! note that 3.6476 = (6/pi)**2
22034 ziacr(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,lr)+2.)/(xdn0(lr)**2*(alpha(mgs,lr)+1.))* &
22035 & ( 2.*tmp * qiacrf(mgs) - tmp**2 * ciacrf(mgs) )
22036 ELSE ! imurain == 1
22037 ziacr(mgs) = 3.6476*rho0(mgs)**2*g1x(mgs,lr)/(xdn0(lr)**2)* &
22038 & ( 2.*tmp * qiacrf(mgs) - tmp**2 * ciacrf(mgs) )
22040 ziacr(mgs) = Min( ziacr(mgs), zxmxd(mgs,lr) )
22041 ! ziacrf(mgs) = (xdn(mgs,lr)/xdn(mgs,lh))**2 * ziacr(mgs)
22042 ziacrf(mgs) = (xdn(mgs,lr)/xdnmx(lh))**2 * ziacr(mgs)
22043 ! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*tmp * (qiacrf(mgs) - qsplinter(mgs)) - tmp**2 * ciacrf(mgs) )
22044 ! ziacrf(mgs) = Min( ziacrf(mgs), z )
22049 IF ( ffrzh*qrfrzf(mgs) .gt. 0.0 .and. cx(mgs,lr) .gt. 0.0 ) THEN
22050 tmp = qx(mgs,lr)/cx(mgs,lr)
22052 ! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22053 IF ( imurain == 3 ) THEN
22054 zrfrz(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,lr)+2.)/(xdn0(lr)**2*(alpha(mgs,lr)+1.)) * &
22055 & ( 2.*tmp * qrfrzf(mgs) - tmp**2 * crfrzf(mgs) )
22056 zrfrzf(mgs) = (xdn(mgs,lr)/xdn(mgs,lh))**2 * zrfrz(mgs)
22057 ELSEIF ( imurain == 1 .and. ibiggopt /= 2 ) THEN
22058 ! zrfrz(mgs) = 3.6476*rho0(mgs)**2*g1x(mgs,lr)/(xdn0(lr)**2) * &
22059 ! & ( 2.*tmp * qrfrzf(mgs) - tmp**2 * crfrz(mgs) )
22060 zrfrz(mgs) = 3.6476*rho0(mgs)**2*g1x(mgs,lr)/(xdn0(lr)**2) * &
22061 & ( 2.*tmp * qrfrz(mgs) - tmp**2 * crfrz(mgs) )
22062 zrfrzf(mgs) = 3.6476*rho0(mgs)**2*g1x(mgs,lr)/(rhofrz**2) * &
22063 & ( 2.*tmp * qrfrzf(mgs) - tmp**2 * crfrzf(mgs) )
22065 zrfrz(mgs) = Min( zrfrz(mgs), Max(0.4,qrfrz(mgs)/qx(mgs,lr))*zx(mgs,lr)*dtpinv )
22066 ! zrfrzf(mgs) = (xdn(mgs,lr)/xdn(mgs,lh))**2 * zrfrz(mgs)
22067 ! zrfrzf(mgs) = (xdn(mgs,lr)/xdnmx(lh))**2 * zrfrz(mgs)
22068 ! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*tmp * (qrfrzf(mgs)-qsplinter2(mgs)) - tmp**2 * crfrzf(mgs) )
22069 ! zrfrzf(mgs) = Min( zrfrzf(mgs), z )
22070 ! change this to be alpha=0?
22073 IF ( lhl > 1 .and. qhcnhl(mgs) .gt. 0.0 ) THEN
22074 tmp = qx(mgs,lhl)/cx(mgs,lhl)
22075 zhcnhl(mgs) = g1x(mgs,lhl)*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*( tmp ) * qhcnhl(mgs) - tmp**2 * chcnhl(mgs) )
22079 IF ( qhcns(mgs) > 0.0 .and. chcns(mgs) > 0.0 .and. cx(mgs,ls) > cxmin .and. vhcns(mgs) > 0 ) THEN
22080 tmp = qx(mgs,ls)/cx(mgs,ls)
22081 r = rho0(mgs)*qhcns(mgs)/vhcns(mgs) ! density of new graupel particles
22082 IF ( imusnow == 3 ) THEN
22083 zhcns(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,ls)+2.)/(r**2*(alpha(mgs,ls)+1.)) * &
22084 & ( 2.*tmp * qhcns(mgs) - tmp**2 * chcns(mgs) )
22086 write(0,*) 'Value of imusnow not valid. Must be 3 (fix me for =1). imusnow = ',imusnow
22091 IF ( qhcni(mgs) > 0.0 .and. chcni(mgs) > 0.0 .and. cx(mgs,li) > cxmin .and. vhcni(mgs) > 0 ) THEN
22092 tmp = qx(mgs,li)/cx(mgs,li)
22093 r = rho0(mgs)*qhcni(mgs)/vhcni(mgs) ! density of new graupel particles
22094 zhcni(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,li)+2.)/(r**2*(alpha(mgs,li)+1.)) * &
22095 & ( 2.*tmp * qhcni(mgs) - tmp**2 * chcni(mgs) )
22100 & +ifrzg*ffrzh*(zrfrzf(mgs) &
22101 & +il5(mgs)*ifiacrg*(ziacrf(mgs) ) ) &
22102 ! : + zhcnsh(mgs) + zhcnih(mgs) &
22108 & + f2h*zhcni(mgs) + f2h*zhcns(mgs) &
22109 & + Max( 0.0, zhdsv(mgs) )
22112 & + (1-il5(mgs))*zhmlr(mgs) &
22114 & + Min( 0.0, zhdsv(mgs) ) &
22115 & - il5(mgs)*zhlcnh(mgs)
22118 IF ( igs(mgs) == 44 .and. kgs(mgs) == 23 .or. dtp*( pqhwi(mgs) + pqhwd(mgs) ) > qxmin(lh) ) THEN
22119 ! write(0,*) 'i,k,time = ',igs(mgs),kgs(mgs),time_real
22120 ! write(0,*) 'pzhwi,d = ',pzhwi(mgs),pzhwd(mgs),dtp*( pzhwi(mgs) + pzhwd(mgs) ),zx(mgs,lh)
22121 ! write(0,*) 'pqhwi,d = ',pqhwi(mgs),pqhwd(mgs),dtp*( pqhwi(mgs) + pqhwd(mgs) ),qx(mgs,lh)
22122 ! write(0,*) 'pchwi,d = ',pchwi(mgs),pchwd(mgs),dtp*( pchwi(mgs) + pchwd(mgs) ),cx(mgs,lh)
22126 ! IF ( zhcnhl(mgs) < 0.0 ) THEN
22127 ! write(0,*) 'Problem with zhcnhl! zhcnhl,qhcnhl,chcnhl = ',zhcnhl(mgs),qhcnhl(mgs),chcnhl(mgs)
22128 ! write(0,*) 'g1,tmp = ',g1x(mgs,lhl),tmp
22129 ! write(0,*) ( 2.*( tmp ) * qhcnhl(mgs) - tmp**2 * chcnhl(mgs) )
22135 if (ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'end graupel reflectivity'
22140 ! Hail reflectivity
22151 IF ( lzhl .gt. 1 .or. ( lzr > 1 .and. lnhl > 1 ) ) THEN ! also run for 2-moment hail for 3-moment rain sources
22153 if (ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'hail reflectivity'
22157 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. cx(mgs,lhl) .gt. 0.0 ) THEN
22158 tmp = qx(mgs,lhl)/cx(mgs,lhl)
22159 alp = Max( alphamin, alpha(mgs,lhl) )
22160 ! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22161 g1 = g1x(mgs,lhl) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22163 IF ( .not. mixedphase .and. qhlmlr(mgs) /= 0.0 .and. chlmlr(mgs) /= 0.0 .and. ibinhlmlr < 1 ) THEN
22164 zhlmlr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*tmp * qhlmlr(mgs) - tmp**2 * chlmlr(mgs) )
22167 zhlshr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*tmp * qhlshr(mgs) - tmp**2 * chlshr(mgs) )
22168 IF ( lzr > 1 .and. qhlshr(mgs) /= 0.0 .and. chlshrr(mgs) /= 0.0 ) THEN
22169 IF ( temg(mgs) >= tfr ) THEN
22170 ! zhlshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn0(lr)))**2*( 2.*tmp * qhlshr(mgs) - tmp**2 * chlshrr(mgs) )
22171 ! IF ( zhlshrr(mgs) > 0.0 ) THEN
22172 ! zhlshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn0(lr)))**2*( 2.*tmp * qhlshr(mgs) - tmp**2 * chlshr(mgs) )
22174 IF ( (shedalp + alpha(mgs,lhl))*xdia(mgs,lhl,1) < sheddiam ) THEN ! if not shedding small drops, then use alpha of hail
22175 z1 = g1*(6.0*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlshr(mgs)**2/ chlshrr(mgs) )
22177 z1 = g1shr*(6.0*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlshr(mgs)**2/ chlshrr(mgs) ) ! should this be g1shr?
22180 ! z1 = g1mlr*(rho0(mgs)/(xdn(mgs,lr)))**2*( qhlshr(mgs)**2/ chlshrr(mgs) ) ! should this be g1shr?
22181 ! zhlshrr(mgs) = Max( z1, zhlshrr(mgs))
22183 zhlshrr(mgs) = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlshr(mgs)**2/ chlshrr(mgs) )
22186 zhlshrr(mgs) = Min( 0.0, zhlshrr(mgs) )
22189 IF ( zhlshr(mgs) > 0.0 ) THEN
22190 write(0,*) 'Problem with zhlshr! zhlshr,qhlshr,chlshr = ',zhlshr(mgs),qhlshr(mgs),chlshr(mgs)
22191 write(0,*) 'g1,tmp, qx,cx,zx = ',g1,tmp,qx(mgs,lhl),cx(mgs,lhl),zx(mgs,lhl)
22192 write(0,*) ( 2.*tmp * qhlshr(mgs) - tmp**2 * chlshr(mgs) ), 2.*tmp * qhlshr(mgs), - tmp**2 * chlshr(mgs)
22193 write(0,*) 'temcg = ',temcg(mgs),'chlshr recalc = ',(cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlshr(mgs)
22197 ! zhlshr(mgs) = Min( 0.0, zhlshr(mgs) )
22199 ! zhlshr(mgs) = (xdn0(lr)/(xdn(mgs,lhl)))**2*( zx(mgs,lhl) * qhlshr(mgs) )
22201 qtmp = qhldpv(mgs) + qhlcev(mgs)
22202 ctmp = chldpv(mgs) + chlcev(mgs)
22204 zhldsv(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*( tmp ) * qtmp - tmp**2 * ctmp )
22206 alp = Max( alphahacx, alpha(mgs,lhl) )
22207 ! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22208 g1 = g1x(mgs,lhl) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22210 IF ( .true. ) THEN ! {
22211 IF ( qhlacr(mgs) .gt. 0.0 ) THEN
22212 ! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lhl)+dtp*qhlacr(mgs))**2)/(cx(mgs,lhl))
22213 zhlacr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*( tmp ) * qhlacr(mgs) )
22214 ! zhlacr(mgs) = Min( zxmxd(mgs,lr), zhlacr(mgs) )
22216 ! IF ( z > zx(mgs,lhl) ) THEN
22217 ! zhlacr(mgs) = (z - zx(mgs,lhl))*dtpinv
22219 ! zhlacr(mgs) = 0.0
22223 ! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) )
22224 ! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) - tmp**2 * chacr(mgs) )
22226 IF ( qhlacw(mgs) .gt. 0.0 ) THEN
22227 alp = Max( 3.0, alpha(mgs,lhl)+1. )
22228 g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22230 ! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lhl)+dtp*(qhlacw(mgs)-qhlmul1(mgs)))**2)/(cx(mgs,lhl))
22231 ! zhlacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lhl)/cx(mgs,lhl)) * qhlacw(mgs) )
22232 zhlacw(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*tmp * qhlacw(mgs) )
22234 ! IF ( z > zx(mgs,lhl) ) THEN
22235 ! zhlacw(mgs) = (z - zx(mgs,lhl))*dtpinv
22237 g1 = g1x(mgs,lhl) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22242 IF ( qhlacw(mgs) .gt. 0.0 .or. qhlacr(mgs) .gt. 0.0 ) THEN
22243 z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lhl)+dtp*(qhlacr(mgs) + qhlacw(mgs)-qhlmul1(mgs)))**2)/(cx(mgs,lhl))
22244 ! zhlacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lhl)/cx(mgs,lhl)) * qhlacw(mgs) )
22245 IF ( z > zx(mgs,lhl) ) THEN
22246 zhlacw(mgs) = (z - zx(mgs,lhl))*dtpinv
22255 IF ( lzhl > 1 ) THEN
22256 pzhli(mgs) = ffrzh*(((1.0-ifrzg)*zrfrzf(mgs) &
22257 & +il5(mgs)*(1.0-ifiacrg)*ziacrf(mgs) )) &
22258 & + il5(mgs)*zhlcnh(mgs) &
22261 ! : + zhlacs(mgs) &
22262 & + Max( 0.0, zhldsv(mgs) )
22265 & + (1-il5(mgs))*zhlmlr(mgs) &
22268 & + Min( 0.0, zhldsv(mgs) )
22271 IF ( .not. ( -1.0 < pzhli(mgs) .and. pzhli(mgs) < 1.e20 ) ) THEN
22272 write(iunit,*) 'Problem with pzhli!'
22273 write(iunit,*) 'zhlcnh,zhlacw,zhlacr,zhldsv = ',zhlcnh(mgs),zhlacw(mgs),zhlacr(mgs),zhldsv(mgs)
22276 IF ( .not. ( -1.0e20 < pzhld(mgs) .and. pzhld(mgs) < 1. ) ) THEN
22277 write(iunit,*) 'Problem with pzhld!'
22278 write(iunit,*) 'zhlmlr,zhlshr,zhldsv = ',zhlmlr(mgs),zhlshr(mgs),zhldsv(mgs)
22288 ! rain reflectivity
22290 if (ndebug .gt. 0 ) write(0,*) 'WARMZIEG: dbg = 11'
22292 IF ( lzr .gt. 1 ) THEN !
22306 IF ( qx(mgs,ls) .gt. qxmin(ls) .and. ( csmlr(mgs) /= 0.0 .or. csshr(mgs) /= 0.0 .or. &
22307 csmlrr(mgs) /= 0.0 .or. csshrr(mgs) /= 0.0) ) THEN !{
22308 tmp = qx(mgs,ls)/cx(mgs,ls)
22309 g1 = 36.*(xnu(ls)+2.0)/((xnu(ls)+1.0)*pi**2)
22310 IF ( .not. mixedphase ) THEN
22311 ! zsmlr(mgs) = (xdn(mgs,ls)/xdn(mgs,lr))**2*g1*(rho0(mgs)/(xdn(mgs,ls)))**2* &
22312 ! & ( 2.*tmp * qsmlr(mgs) - tmp**2 * csmlr(mgs) )
22314 IF ( csmlrr(mgs) /= 0.0 ) THEN
22315 z1 = g1smlr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qsmlr(mgs)**2/ csmlrr(mgs) )
22320 ! zsshr(mgs) = (xdn(mgs,ls)/xdn(mgs,lr))**2*g1*(rho0(mgs)/(xdn(mgs,ls)))**2* &
22321 ! & ( 2.*tmp * qsshr(mgs) - tmp**2 * csshr(mgs) )
22323 IF ( csshrr(mgs) /= 0.0 ) THEN
22324 z1 = g1smlr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qsshr(mgs)**2/ csshrr(mgs) )
22330 IF ( .not. mixedphase ) THEN !{
22331 IF ( zhmlr(mgs) < 0.0 .and. chmlrr(mgs) /= 0.0 .and. ibinhmlr == 0 ) THEN !{
22332 tmp = qx(mgs,lh)/cx(mgs,lh)
22333 ! zhmlrr(mgs) = Min(0.0, (xdn(mgs,lh)/xdn(mgs,lr))**2 * &
22334 ! & g1x(mgs,lh)*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*tmp * qhmlr(mgs) - tmp**2 * chmlrr(mgs) ) )
22336 ! IF ( zhmlrr(mgs) >= 0. ) THEN
22337 ! zhmlrr(mgs) = (xdn(mgs,lh)/xdn(mgs,lr))**2 * zhmlr(mgs)
22339 IF ( (shedalp + alpha(mgs,lh))*xdia(mgs,lh,1) < sheddiam ) THEN ! if not shedding small drops, then use alpha of graupel
22340 z1 = g1x(mgs,lh)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhmlr(mgs)**2/ chmlrr(mgs) )
22341 ELSE ! assume drops are shed off, so use either alpha for shedding or graupel alpha, whichever gives the lower g-factor (i.e., larger alpha)
22342 z1 = Min(g1x(mgs,lh),g1shr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhmlr(mgs)**2/ chmlrr(mgs) )
22345 ! z1 = g1mlr*(rho0(mgs)/(xdn(mgs,lr)))**2*( qhmlr(mgs)**2/ chmlrr(mgs) )
22346 ! zhmlrr(mgs) = Max( z1, zhmlrr(mgs))
22350 ! zhshrr(mgs) = (xdn(mgs,lh)/xdn(mgs,lr))**2 * zhshr(mgs)
22352 IF ( lhl > 1 .and. qhlmlr(mgs) /= 0 .and. ibinhlmlr == 0) THEN
22353 tmp = qx(mgs,lhl)/cx(mgs,lhl)
22354 ! zhlmlrr(mgs) = Min(0.0, (xdn(mgs,lhl)/xdn(mgs,lr))**2 * &
22355 ! & g1x(mgs,lhl)*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*tmp * qhlmlr(mgs) - tmp**2 * chlmlrr(mgs) ) )
22357 ! IF ( zhlmlrr(mgs) >= 0. ) THEN ! should be negative, if not, then use alternate calculation
22358 ! zhlmlrr(mgs) = (xdn(mgs,lhl)/xdn(mgs,lr))**2 * zhlmlr(mgs)
22361 IF ( (shedalp + alpha(mgs,lhl))*xdia(mgs,lhl,1) < sheddiam ) THEN ! if not shedding small drops, then use alpha of hail
22362 z1 = g1x(mgs,lhl)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlmlr(mgs)**2/ chlmlrr(mgs) )
22363 ELSE ! assume drops are shed off, so use either alpha for shedding or graupel alpha, whichever gives the lower g-factor (i.e., larger alpha)
22364 z1 = Min(g1x(mgs,lhl),g1shr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlmlr(mgs)**2/ chlmlrr(mgs) )
22365 ! z1 = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlmlr(mgs)**2/ chlmlrr(mgs) )
22369 ! z1 = g1mlr*(rho0(mgs)/(xdn(mgs,lr)))**2*( qhlmlr(mgs)**2/ chlmlrr(mgs) )
22370 ! zhlmlrr(mgs) = Max( z1, zhlmlrr(mgs))
22372 ! zhlshrr(mgs) = (xdn(mgs,lhl)/xdn(mgs,lr))**2 * zhlshr(mgs)
22377 IF ( qx(mgs,lr) .gt. qxmin(lr) .and. cx(mgs,lr) .gt. 0.0 ) THEN
22379 tmp = qx(mgs,lr)/cx(mgs,lr)
22380 g1 = g1x(mgs,lr) ! 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
22383 IF ( qracw(mgs) > 0.0 .and. cx(mgs,lr) > 0.0 ) THEN
22384 zracw(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*tmp * qracw(mgs) )
22387 IF ( cracr(mgs) > 0.0 .and. cx(mgs,lr) > 0.0 ) THEN
22388 zracr(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*1000.))**2*( tmp**2 * cracr(mgs) )
22394 ! IF ( .false. .or. iferwisventr == 2 ) THEN
22395 ! zrcev(mgs) = Min(0.0, (12./(pii*xdn(mgs,lr)))*xdia(mgs,lr,1)**3*fvce(mgs)*rwcap(mgs)*rwventz(mgs) )
22397 zrcev(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( 2.*( tmp ) * qtmp - tmp**2 * ctmp )
22400 IF ( iferwisventr == 2 ) THEN
22401 vent1 = Min(0.0, (12./(pii*xdn(mgs,lr)))*xdia(mgs,lr,1)**3*fvce(mgs)*rwcap(mgs)*rwventz(mgs))
22402 zrcev(mgs) = Max( zrcev(mgs), vent1 )
22404 ! IF ( ny == 2 .and. igs(mgs) == 20 ) THEN
22405 ! write(0,*) 'k,zrcevold,new,maxdep : ',kgs(mgs),zrcev(mgs),vent1,-zxmxd(mgs,lr),alpha(mgs,lr),cx(mgs,lr)
22410 zrcev(mgs) = Max( zrcev(mgs), -zxmxd(mgs,lr) )
22412 IF ( qhacr(mgs) > 0.0 ) THEN
22413 zrach(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2* &
22414 & ( 2.*( qx(mgs,lr)/cx(mgs,lr)) * qhacr(mgs) - tmp**2 * chacr(mgs) )
22415 zrach(mgs) = Min( zrach(mgs), zxmxd(mgs,lr) )
22419 IF ( lhl > 1 .and. qhlacr(mgs) > 0.0 ) THEN
22420 zrachl(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2* &
22421 & ( 2.*( qx(mgs,lr)/cx(mgs,lr)) * qhlacr(mgs) - tmp**2 * chlacr(mgs) )
22422 zrachl(mgs) = Min( zrachl(mgs), zxmxd(mgs,lr) )
22429 pzrwi(mgs) = zrcnw(mgs) + zracw(mgs) + zracr(mgs) &
22430 & + Max( 0.,zrcev(mgs) ) &
22431 & - (1-il5(mgs))*zsmlrr(mgs) &
22433 & - (1-il5(mgs))*zhmlrr(mgs) &
22435 & - (1-il5(mgs))*zhlmlrr(mgs) &
22440 & + Min(0.,zrcev(mgs) ) &
22444 & - il5(mgs)*(ziacr(mgs) )
22447 IF ( zx(mgs,lr) + dtp*(pzrwi(mgs)+pzrwd(mgs)) <= 0.0 &
22448 .and. qx(mgs,lr) > qxmin(lr) ) THEN
22449 pzrwd(mgs) = -zx(mgs,lr)*dtpinv - pzrwi(mgs)
22461 IF ( lvol(ls) .gt. 1 ) THEN
22463 ! pvswi(mgs) = rho0(mgs)*( pqswi(mgs) )/xdn0(ls)
22465 pvswi(mgs) = rho0(mgs)*( &
22466 !aps > il5*qsfzs(mgs)/xdn(mgs,ls) &
22467 !aps > -il5*qsfzs(mgs)/xdn(mgs,lr) &
22468 & +il5(mgs)*(qscni(mgs)+qsaci(mgs)+qsdpv(mgs) &
22469 & + qscnvi(mgs) + (1. - ifrzs)*qiacrs(mgs) &
22470 & + (1. - ifrzs)*qrfrzs(mgs) &
22472 & + (qsacr(mgs))/rimdn(mgs,ls) ) + vsacw(mgs)
22473 ! > + (qsacw(mgs) + qsacr(mgs))/rimdn(mgs,ls) )
22474 pvswd(mgs) = rho0(mgs)*( pqswd(mgs) )/xdn0(ls) &
22477 ! > +(1-il5(mgs))*qsmlr(mgs) + qsshr(mgs)
22478 ! > +il5(mgs)*(qssbv(mgs))
22479 & -rho0(mgs)*qsmul(mgs)/xdn0(ls)
22480 !aps > +rho0(mgs)*(1-il5(mgs))*(
22481 !aps > qsmlr(mgs)/xdn(mgs,ls)
22482 !aps > +(qscev-qsmlr(mgs))/xdn(mgs,lr) )
22485 !aps IF (mixedphase) THEN
22486 !aps pvswd(mgs) = pvswd(mgs)
22487 !aps > + rho0(mgs)*qsshr(mgs)/xdn(mgs,lr)
22494 IF ( lvol(lh) .gt. 1 ) THEN
22496 ! pvhwi(mgs) = rho0(mgs)*( (pqhwi(mgs) )/xdn0(lh) )
22498 ! pvhwi(mgs) = rho0(mgs)*( (pqhwi(mgs) - il5(mgs)*qrfrzf(mgs) )/xdn0(lh) !
22499 ! : + il5(mgs)*qrfrzf(mgs)/rhofrz )
22501 pvhwi(mgs) = rho0(mgs)*( &
22502 & +il5(mgs)*( ifiacrg*ffrzh*qracif(mgs))/rhofrz &
22503 !erm > + il5(mgs)*qhfzh(mgs)/rhofrz !aps: or use xdnmx(lh)? &
22504 & + ( il5(mgs)*qhdpv(mgs)/qhdpvdn &
22505 & + (qhacs(mgs) + qhaci(mgs))/qhacidn ) ) &
22506 & + rho0(mgs)*Max(0.0, qhcev(mgs))/1000. & ! only used in mixed phase: evaporation/condensation of liquid water coating
22507 ! > + qhacs(mgs) + qhaci(mgs) )/xdn0(ls) ) &
22508 & + f2h*vhcns(mgs) &
22509 & + vhacr(mgs) + vhacw(mgs) + vhfzh(mgs) & ! qhacw(mgs)/rimdn(mgs,lh)
22511 & + f2h*vhcni(mgs) + (ifiacrg*viacrf(mgs) + ifrzg*vrfrzf(mgs))*ffrzh
22512 ! > +qhacr(mgs)/raindn(mgs,lh) + qhacw(mgs)/rimdn(mgs,lh)
22514 ! pvhwd(mgs) = rho0(mgs)*(pqhwd(mgs) )/xdn0(lh)
22516 pvhwd(mgs) = rho0(mgs)*( &
22517 ! > qhshr(mgs)/xdn0(lr) &
22518 ! > - il5(mgs)*qhfzh(mgs)/xdn(mgs,lr) &
22519 & +( (1-il5(mgs))*vhmlr(mgs) &
22520 ! > +il5(mgs)*qhsbv(mgs) &
22522 & + Min(0.0, qhcev(mgs)) &
22523 & -qhmul1(mgs) )/xdn(mgs,lh) ) &
22524 & - vhlcnh(mgs) + vhshdr(mgs) - vhsoak(mgs) - vscnh(mgs)
22526 ! IF (mixedphase) THEN
22527 ! pvhwd(mgs) = pvhwd(mgs)
22528 ! > + rho0(mgs)*qhshr(mgs)/xdn(mgs,lh) !xdn(mgs,lr)
22531 IF ( lzh > 1 .and. qx(mgs,lh) > qxmin(lh) ) THEN
22532 ! Calculate change in reflectivity due to density changes
22534 xdn_new = rho0(mgs)*(qx(mgs,lh) + dtp*(pqhwi(mgs) + pqhwd(mgs) ))/ &
22535 & (vx(mgs,lh) + dtp*(pvhwi(mgs) + pvhwd(mgs)) )
22537 IF ( mixedphase ) THEN
22538 IF ( qxw(mgs,lh) .gt. 0.0 ) THEN
22547 xdn_new = Max( Min( xdn_new, dnmx ), xdnmn(lh) )
22549 drhodt = (xdn_new - xdn(mgs,lh))*dtpinv
22551 zhwdn(mgs) = -2.*g1x(mgs,lh)*(rho0(mgs)*qx(mgs,lh)*6.*pii )**2/(cx(mgs,lh)*xdn(mgs,lh)**3)*drhodt
22553 pzhwi(mgs) = pzhwi(mgs) + Max(0.0, zhwdn(mgs))
22554 pzhwd(mgs) = pzhwd(mgs) + Min(0.0, zhwdn(mgs))
22558 IF ( .false. .and. ny .eq. 2 .and. kgs(mgs) .eq. 9 .and. igs(mgs) .eq. 19 ) THEN
22561 write(iunit,*) 'Graupel at ',igs(mgs),kgs(mgs)
22563 write(iunit,*) il5(mgs)*qrfrzf(mgs), qrfrzf(mgs) - qrfrz(mgs)
22564 write(iunit,*) il5(mgs)*qiacrf(mgs)
22565 write(iunit,*) il5(mgs)*qracif(mgs)
22566 write(iunit,*) 'qhcns',qhcns(mgs)
22567 write(iunit,*) 'qhcni',qhcni(mgs)
22568 write(iunit,*) il5(mgs)*(qhdpv(mgs))
22569 write(iunit,*) 'qhacr ',qhacr(mgs)
22570 write(iunit,*) 'qhacw', qhacw(mgs)
22571 write(iunit,*) 'qhacs', qhacs(mgs)
22572 write(iunit,*) 'qhaci', qhaci(mgs)
22573 write(iunit,*) 'pqhwi = ',pqhwi(mgs)
22575 write(iunit,*) 'qhcev',qhcev(mgs)
22577 write(iunit,*) 'qhshr',qhshr(mgs)
22578 write(iunit,*) 'qhmlr', (1-il5(mgs))*qhmlr(mgs)
22579 write(iunit,*) 'qhsbv', qhsbv(mgs)
22580 write(iunit,*) 'qhlcnh',-qhlcnh(mgs)
22581 write(iunit,*) 'qhmul1',-qhmul1(mgs)
22582 write(iunit,*) 'pqhwd = ', pqhwd(mgs)
22584 write(iunit,*) 'Volume'
22586 write(iunit,*) 'pvhwi',pvhwi(mgs)
22587 write(iunit,*) 'vhcns', vhcns(mgs)
22588 write(iunit,*) 'vhacr,vhacw',vhacr(mgs), vhacw(mgs) ! qhacw(mgs)/rimdn(mgs,lh)
22589 write(iunit,*) 'vhcni',vhcni(mgs)
22591 write(iunit,*) 'pvhwd',pvhwd(mgs)
22592 write(iunit,*) 'vhlcnh,vhshdr,vhsoak ', vhlcnh(mgs), vhshdr(mgs), vhsoak(mgs)
22593 write(iunit,*) 'vhmlr', vhmlr(mgs)
22598 write(iunit,*) 'Concentration'
22599 write(iunit,*) pchwi(mgs),pchwd(mgs)
22600 write(iunit,*) crfrzf(mgs)
22601 write(iunit,*) chcns(mgs)
22602 write(iunit,*) ciacrf(mgs)
22618 IF ( lhl .gt. 1 ) THEN
22619 IF ( lvol(lhl) .gt. 1 ) THEN
22622 pvhli(mgs) = rho0(mgs)*( &
22623 & + ( il5(mgs)*(((1.0-ifiacrg)*ffrzh*qracif(mgs))/rhofrz + qhldpv(mgs) ) &
22624 ! & + Max(0.0, qhlcev(mgs)) &
22625 ! & + qhlacs(mgs) + qhlaci(mgs) )/xdnmn(lhl) ) & ! xdn0(ls) ) &
22626 ! & + qhlacs(mgs) + qhlaci(mgs) )/xdnmn(lh) ) & ! yes, this is 'lh' on purpose
22627 & + qhlacs(mgs) + qhlaci(mgs) )/500. ) & ! changed to 500 instead of min graupel density to keep hail density from dropping too much
22628 & + rho0(mgs)*Max(0.0, qhlcev(mgs))/1000. &
22629 & + vhlcnhl(mgs) + ((1.0-ifiacrg)*ffrzh*viacrf(mgs) + (1.0-ifrzg)*ffrzh*vrfrzf(mgs)) &
22630 & + vhlacr(mgs) + vhlacw(mgs) + vhlfzhl(mgs) ! qhlacw(mgs)/rimdn(mgs,lhl)
22632 pvhld(mgs) = rho0(mgs)*( &
22634 & + Min(0.0, qhlcev(mgs)) &
22635 & -qhlmul1(mgs) )/xdn(mgs,lhl) ) &
22636 ! & + vhlmlr(mgs) &
22637 & + rho0(mgs)*(1-il5(mgs))*vhlmlr(mgs)/xdn(mgs,lhl) &
22638 & + vhlshdr(mgs) - vhlsoak(mgs)
22640 IF ( lzhl > 1 .and. qx(mgs,lhl) > qxmin(lhl) ) THEN
22641 ! Calculate change in reflectivity due to density changes
22643 xdn_new = rho0(mgs)*(qx(mgs,lhl) + dtp*(pqhli(mgs) + pqhld(mgs) ))/ &
22644 & (vx(mgs,lhl) + dtp*(pvhli(mgs) + pvhld(mgs)) )
22646 IF ( mixedphase ) THEN
22647 IF ( qxw(mgs,lhl) .gt. 0.0 ) THEN
22655 xdn_new = Max( Min( xdn_new, dnmx ), xdnmn(lhl) )
22657 drhodt = (xdn_new - xdn(mgs,lhl))*dtpinv
22659 zhldn(mgs) = -2.*g1x(mgs,lhl)*(rho0(mgs)*qx(mgs,lhl)*6.*pii )**2/(cx(mgs,lhl)*xdn(mgs,lhl)**3)*drhodt
22661 pzhli(mgs) = pzhli(mgs) + Max(0.0, zhldn(mgs))
22662 pzhld(mgs) = pzhld(mgs) + Min(0.0, zhldn(mgs))
22673 if ( ndebug .ge. 1 ) then
22677 ptotal(mgs) = ptotal(mgs) &
22678 & + pqwvi(mgs) + pqwvd(mgs) &
22679 & + pqcwi(mgs) + pqcwd(mgs) &
22680 & + pqcii(mgs) + pqcid(mgs) &
22681 & + pqrwi(mgs) + pqrwd(mgs) &
22682 & + pqswi(mgs) + pqswd(mgs) &
22683 & + pqhwi(mgs) + pqhwd(mgs) &
22684 & + pqhli(mgs) + pqhld(mgs)
22693 if ( ( (ndebug .ge. 0 ) .and. abs(ptotal(mgs)) .gt. eqtot ) &
22694 ! if ( ( abs(ptotal(mgs)) .gt. eqtot )
22695 ! : .or. pqswi(mgs)*dtp .gt. 1.e-3
22696 ! : .or. pqhwi(mgs)*dtp .gt. 1.e-3
22697 ! : .or. dtp*(pqrwi(mgs)+pqrwd(mgs)) .gt. 10.0e-3
22698 ! : .or. dtp*(pccii(mgs)+pccid(mgs)) .gt. 1.e7
22699 ! : .or. dtp*(pcipi(mgs)+pcipd(mgs)) .gt. 1.e7 &
22700 & .or. .not. (ptotal(mgs) .lt. 1.0 .and. ptotal(mgs) .gt. -1.0) & ! this line is basically checking for NaNs
22702 write(iunit,*) 'YIKES! ','ptotal1',mgs,igs(mgs),jgs, &
22703 & kgs(mgs),ptotal(mgs)
22705 write(iunit,*) 't7: ', t7(igs(mgs),jgs,kgs(mgs))
22706 write(iunit,*) 'cci,ccw,crw,rdia: ',cx(mgs,li),cx(mgs,lc),cx(mgs,lr),0.5*xdia(mgs,lr,1)
22707 write(iunit,*) 'qc,qi,qr : ',qx(mgs,lc),qx(mgs,li),qx(mgs,lr)
22708 write(iunit,*) 'rmas, qrcalc : ',xmas(mgs,lr),xmas(mgs,lr)*cx(mgs,lr)/rho0(mgs)
22709 write(iunit,*) 'vti,vtc,eiw,vtr: ',vtxbar(mgs,li,1),vtxbar(mgs,lc,1),eiw(mgs),vtxbar(mgs,lr,1)
22710 write(iunit,*) 'cidia,cwdia,qcmxd: ', xdia(mgs,li,1),xdia(mgs,lc,1),qcmxd(mgs)
22711 write(iunit,*) 'snow: ',qx(mgs,ls),cx(mgs,ls),swvent(mgs),vtxbar(mgs,ls,1),xdia(mgs,ls,1)
22712 write(iunit,*) 'graupel: ',qx(mgs,lh),cx(mgs,lh),hwvent(mgs),vtxbar(mgs,lh,1),xdia(mgs,lh,1)
22713 IF ( lhl .gt. 1 ) write(iunit,*) 'hail: ',qx(mgs,lhl),cx(mgs,lhl),hlvent(mgs),vtxbar(mgs,lhl,1),xdia(mgs,lhl,1)
22716 write(iunit,*) 'li: ',xdia(mgs,li,1),xdia(mgs,li,2),xmas(mgs,li),qx(mgs,li), &
22720 write(iunit,*) 'rain cx,xv : ',cx(mgs,lr),xv(mgs,lr)
22721 write(iunit,*) 'temcg = ', temcg(mgs)
22723 write(iunit,*) 'v ', pqwvi(mgs) ,pqwvd(mgs)
22724 write(iunit,*) 'c ', pqcwi(mgs) ,pqcwd(mgs)
22725 write(iunit,*) 'ci', pqcii(mgs) ,pqcid(mgs)
22726 write(iunit,*) 'r ', pqrwi(mgs) ,pqrwd(mgs)
22727 write(iunit,*) 's ', pqswi(mgs) ,pqswd(mgs)
22728 write(iunit,*) 'h ', pqhwi(mgs) ,pqhwd(mgs)
22729 write(iunit,*) 'hl', pqhli(mgs) ,pqhld(mgs)
22730 tmp = pqwvi(mgs) + pqwvd(mgs) &
22731 & + pqcwi(mgs) + pqcwd(mgs) &
22732 & + pqcii(mgs) + pqcid(mgs) &
22733 & + pqrwi(mgs) + pqrwd(mgs) &
22734 & + pqswi(mgs) + pqswd(mgs) &
22735 & + pqhwi(mgs) + pqhwd(mgs) &
22736 & + pqhli(mgs) + pqhld(mgs)
22738 write(iunit,*) 'total = ',tmp
22739 write(iunit,*) 'END OF OUTPUT OF SOURCE AND SINK'
22742 ! print production terms
22745 write(iunit,*) 'Vapor'
22747 write(iunit,*) -Min(0.0,qrcev(mgs))
22748 write(iunit,*) -il5(mgs)*qhsbv(mgs)
22749 write(iunit,*) -il5(mgs)*qhlsbv(mgs)
22750 write(iunit,*) -il5(mgs)*qssbv(mgs)
22751 write(iunit,*) -il5(mgs)*qisbv(mgs)
22752 write(iunit,*) 'pqwvi= ', pqwvi(mgs)
22753 write(iunit,*) -Max(0.0,qrcev(mgs))
22754 write(iunit,*) -Max(0.0,qhcev(mgs))
22755 write(iunit,*) -Max(0.0,qhlcev(mgs))
22756 write(iunit,*) -Max(0.0,qscev(mgs))
22757 write(iunit,*) -il5(mgs)*qiint(mgs)
22758 write(iunit,*) -il5(mgs)*qhdpv(mgs)
22759 write(iunit,*) -il5(mgs)*qhldpv(mgs)
22760 write(iunit,*) -il5(mgs)*qsdpv(mgs)
22761 write(iunit,*) -il5(mgs)*qidpv(mgs)
22762 write(iunit,*) 'pqwvd = ', pqwvd(mgs)
22765 write(iunit,*) 'Cloud ice'
22767 write(iunit,*) il5(mgs)*qicicnt(mgs)
22768 write(iunit,*) il5(mgs)*qidpv(mgs)
22769 write(iunit,*) il5(mgs)*qiacw(mgs)
22770 write(iunit,*) il5(mgs)*qwfrzc(mgs)
22771 write(iunit,*) il5(mgs)*qwctfzc(mgs)
22772 write(iunit,*) il5(mgs)*qicichr(mgs)
22773 write(iunit,*) qhmul1(mgs)
22774 write(iunit,*) qhlmul1(mgs)
22775 write(iunit,*) 'pqcii = ', pqcii(mgs)
22776 write(iunit,*) -il5(mgs)*qscni(mgs)
22777 write(iunit,*) -il5(mgs)*qscnvi(mgs)
22778 write(iunit,*) -il5(mgs)*qraci(mgs)
22779 write(iunit,*) -il5(mgs)*qsaci(mgs)
22780 write(iunit,*) -il5(mgs)*qhaci(mgs)
22781 write(iunit,*) -il5(mgs)*qhlaci(mgs)
22782 write(iunit,*) il5(mgs)*qisbv(mgs)
22783 write(iunit,*) (1.-il5(mgs))*qimlr(mgs)
22784 write(iunit,*) -il5(mgs)*qhcni(mgs)
22785 write(iunit,*) 'pqcid = ', pqcid(mgs)
22786 write(iunit,*) ' Conc:'
22787 write(iunit,*) pccii(mgs),pccid(mgs)
22788 write(iunit,*) il5(mgs),cicint(mgs)
22789 write(iunit,*) cwfrzc(mgs),cwctfzc(mgs)
22790 write(iunit,*) cicichr(mgs)
22791 write(iunit,*) chmul1(mgs)
22792 write(iunit,*) chlmul1(mgs)
22793 write(iunit,*) csmul(mgs)
22799 write(iunit,*) 'Cloud water'
22801 write(iunit,*) 'pqcwi =', pqcwi(mgs)
22802 write(iunit,*) -il5(mgs)*qiacw(mgs)
22803 write(iunit,*) -il5(mgs)*qwfrzc(mgs)
22804 write(iunit,*) -il5(mgs)*qwctfzc(mgs)
22805 ! write(iunit,*) -il5(mgs)*qwfrzp(mgs)
22806 ! write(iunit,*) -il5(mgs)*qwctfzp(mgs)
22807 write(iunit,*) -il5(mgs)*qiihr(mgs)
22808 write(iunit,*) -il5(mgs)*qicichr(mgs)
22809 write(iunit,*) -il5(mgs)*qipiphr(mgs)
22810 write(iunit,*) -qracw(mgs)
22811 write(iunit,*) -qsacw(mgs)
22812 write(iunit,*) -qrcnw(mgs)
22813 write(iunit,*) -qhacw(mgs)
22814 write(iunit,*) -qhlacw(mgs)
22815 write(iunit,*) 'pqcwd = ', pqcwd(mgs)
22819 write(iunit,*) 'Concentration:'
22820 write(iunit,*) -cautn(mgs)
22821 write(iunit,*) -cracw(mgs)
22822 write(iunit,*) -csacw(mgs)
22823 write(iunit,*) -chacw(mgs)
22824 write(iunit,*) -ciacw(mgs)
22825 write(iunit,*) -cwfrzp(mgs)
22826 write(iunit,*) -cwctfzp(mgs)
22827 write(iunit,*) -cwfrzc(mgs)
22828 write(iunit,*) -cwctfzc(mgs)
22829 write(iunit,*) pccwd(mgs)
22832 write(iunit,*) 'Rain '
22834 write(iunit,*) qracw(mgs)
22835 write(iunit,*) qrcnw(mgs)
22836 write(iunit,*) Max(0.0, qrcev(mgs))
22837 write(iunit,*) -(1-il5(mgs))*qhmlr(mgs)
22838 write(iunit,*) -(1-il5(mgs))*qhlmlr(mgs)
22839 write(iunit,*) -(1-il5(mgs))*qsmlr(mgs)
22840 write(iunit,*) -(1-il5(mgs))*qimlr(mgs)
22841 write(iunit,*) -qrshr(mgs)
22842 write(iunit,*) 'pqrwi = ', pqrwi(mgs)
22843 write(iunit,*) -qsshr(mgs)
22844 write(iunit,*) -qhshr(mgs)
22845 write(iunit,*) -qhlshr(mgs)
22846 write(iunit,*) -il5(mgs)*qiacr(mgs),qiacr(mgs), qiacrf(mgs)
22847 write(iunit,*) -il5(mgs)*qrfrz(mgs)
22848 write(iunit,*) -qsacr(mgs)
22849 write(iunit,*) -qhacr(mgs)
22850 write(iunit,*) -qhlacr(mgs)
22851 write(iunit,*) qrcev(mgs)
22852 write(iunit,*) 'pqrwd = ', pqrwd(mgs)
22853 write(iunit,*) 'qrzfac = ', qrzfac(mgs)
22857 write(iunit,*) 'Rain concentration'
22858 write(iunit,*) pcrwi(mgs)
22859 write(iunit,*) crcnw(mgs)
22860 write(iunit,*) 1-il5(mgs)
22861 write(iunit,*) -chmlr(mgs),-csmlr(mgs)
22862 write(iunit,*) -crshr(mgs)
22863 write(iunit,*) pcrwd(mgs)
22864 write(iunit,*) il5(mgs)
22865 write(iunit,*) -ciacr(mgs),-crfrz(mgs)
22866 write(iunit,*) -csacr(mgs),-chacr(mgs)
22867 write(iunit,*) +crcev(mgs)
22868 write(iunit,*) cracr(mgs)
22869 ! write(iunit,*) -il5(mgs)*ciracr(mgs)
22873 write(iunit,*) 'Snow'
22875 write(iunit,*) il5(mgs)*qscni(mgs), qscnvi(mgs)
22876 write(iunit,*) il5(mgs)*qsaci(mgs)
22877 write(iunit,*) il5(mgs)*qrfrzs(mgs)
22878 write(iunit,*) il5(mgs)*qiacrs(mgs),il3(mgs)*(qiacrf(mgs)+qracif(mgs)),il3(mgs),qiacrf(mgs),qracif(mgs)
22879 write(iunit,*) il5(mgs)*qsdpv(mgs), qscev(mgs)
22880 write(iunit,*) qsacw(mgs)
22881 write(iunit,*) qsacr(mgs), qscnh(mgs)
22882 write(iunit,*) 'pqswi = ',pqswi(mgs)
22883 write(iunit,*) -qhcns(mgs)
22884 write(iunit,*) -qracs(mgs)
22885 write(iunit,*) -qhacs(mgs)
22886 write(iunit,*) -qhlacs(mgs)
22887 write(iunit,*) (1-il5(mgs))*qsmlr(mgs)
22888 write(iunit,*) qsshr(mgs)
22889 ! write(iunit,*) qsshrp(mgs)
22890 write(iunit,*) il5(mgs)*(qssbv(mgs))
22891 write(iunit,*) 'pqswd = ', pqswd(mgs)
22892 write(iunit,*) -qracs(mgs)*(1-il2(mgs)) , qhacs(mgs) , qhlacs(mgs)
22893 write(iunit,*) -qhcns(mgs)
22894 write(iunit,*) +(1-il5(mgs))*qsmlr(mgs) , qsshr(mgs)
22895 write(iunit,*) qssbv(mgs)
22896 write(iunit,*) Min(0.0, qscev(mgs))
22897 write(iunit,*) -qsmul(mgs)
22901 write(iunit,*) 'Graupel'
22903 write(iunit,*) il5(mgs)*qrfrzf(mgs), qrfrzf(mgs) - qrfrz(mgs)
22904 write(iunit,*) il5(mgs)*qiacrf(mgs)
22905 write(iunit,*) il5(mgs)*qracif(mgs)
22906 write(iunit,*) qhcns(mgs)
22907 write(iunit,*) qhcni(mgs)
22908 write(iunit,*) il5(mgs)*(qhdpv(mgs))
22909 write(iunit,*) qhacr(mgs)
22910 write(iunit,*) qhacw(mgs)
22911 write(iunit,*) qhacs(mgs)
22912 write(iunit,*) qhaci(mgs)
22913 write(iunit,*) 'pqhwi = ',pqhwi(mgs)
22915 write(iunit,*) qhshr(mgs)
22916 write(iunit,*) (1-il5(mgs))*qhmlr(mgs)
22917 write(iunit,*) il5(mgs),qhsbv(mgs)
22918 write(iunit,*) -qhlcnh(mgs)
22919 write(iunit,*) -qhmul1(mgs)
22920 write(iunit,*) 'pqhwd = ', pqhwd(mgs)
22921 write(iunit,*) 'Concentration'
22922 write(iunit,*) pchwi(mgs),pchwd(mgs)
22923 write(iunit,*) crfrzf(mgs)
22924 write(iunit,*) chcns(mgs)
22925 write(iunit,*) ciacrf(mgs)
22929 write(iunit,*) 'Hail'
22931 write(iunit,*) qhlcnh(mgs)
22932 write(iunit,*) il5(mgs)*(qhldpv(mgs))
22933 write(iunit,*) qhlacr(mgs)
22934 write(iunit,*) qhlacw(mgs)
22935 write(iunit,*) qhlacs(mgs)
22936 write(iunit,*) qhlaci(mgs)
22937 write(iunit,*) pqhli(mgs)
22939 write(iunit,*) qhlshr(mgs)
22940 write(iunit,*) (1-il5(mgs))*qhlmlr(mgs)
22941 write(iunit,*) il5(mgs)*qhlsbv(mgs)
22942 write(iunit,*) pqhld(mgs)
22943 write(iunit,*) 'Concentration'
22944 write(iunit,*) pchli(mgs),pchld(mgs)
22945 write(iunit,*) chlcnh(mgs)
22947 ! Balance and checks for continuity.....within machine precision...
22950 write(iunit,*) 'END OF OUTPUT OF SOURCE AND SINK'
22951 write(iunit,*) 'PTOTAL',ptotal(mgs)
22953 end if ! ptotal out of bounds or NaN
22958 end if ! ( nstep/12*12 .eq. nstep )
22961 ! latent heating from phase changes (except qcw, qci cond, and evap)
22964 IF ( warmonly < 0.5 ) THEN
22968 & qsmlr(mgs)+qhlmlr(mgs)) & !+qhmlh(mgs)) &
22969 & +il5(mgs)*(1-imixedphase)*( &
22970 & qsacw(mgs)+qhacw(mgs) + qhlacw(mgs) &
22971 & +qsacr(mgs)+qhacr(mgs) + qhlacr(mgs) &
22975 & +qrfrz(mgs)+qiacr(mgs) &
22977 & +il5(mgs)*(qwfrz(mgs) &
22978 & +qwctfz(mgs)+qiihr(mgs) &
22982 & (qhmlr(mgs)+qsmlr(mgs)+ &
22983 & qhlmlr(mgs)) !+qhmlh(mgs))
22984 ! NOTE: psub is sum of sublimation and deposition
22987 & + qsdpv(mgs) + qhdpv(mgs) &
22989 & + qidpv(mgs) + qisbv(mgs) ) &
22990 & + qssbv(mgs) + qhsbv(mgs) &
22992 & +il5(mgs)*(qiint(mgs))
22994 & qrcev(mgs) + qhcev(mgs) + qscev(mgs) + qhlcev(mgs) + qfcev(mgs)
22996 & Min(0.0,qrcev(mgs)) + Min(0.0,qhcev(mgs)) + Min(0.0,qscev(mgs)) + Min(0.0,qhlcev(mgs)) &
22997 + Min(0.0,qfcev(mgs))
22998 ! NOTE: pdep is the deposition part only
23001 & + qsdpv(mgs) + qhdpv(mgs) &
23004 & +il5(mgs)*(qiint(mgs))
23005 ELSEIF ( warmonly < 0.8 ) THEN
23008 & (qhmlr(mgs)+qhlmlr(mgs)) & !+qhmlh(mgs)) &
23009 & +il5(mgs)*(qhfzh(mgs)+qhlfzhl(mgs)) &
23013 & +qrfrz(mgs)+qwfrz(mgs) &
23014 & +qwctfz(mgs)+qiihr(mgs) &
23016 & +qhacw(mgs) + qhlacw(mgs) &
23017 & +qhacr(mgs) + qhlacr(mgs) )
23018 psub(mgs) = 0.0 + &
23022 & + qidpv(mgs) + qisbv(mgs) ) &
23023 & +il5(mgs)*(qiint(mgs))
23025 & qrcev(mgs) + qhcev(mgs) + qhlcev(mgs) + qfcev(mgs)
23029 pvap(mgs) = qrcev(mgs)
23033 & (felfcp(mgs)*pfrz(mgs) &
23034 & +felscp(mgs)*psub(mgs) &
23035 & +felvcp(mgs)*pvap(mgs))
23036 thetap(mgs) = thetap(mgs) + dtp*ptem(mgs)
23037 ptem2(mgs) = ptem(mgs)
23038 IF ( eqtset > 2 ) THEN
23039 pipert(mgs) = pipert(mgs) + (felfpi(mgs)*pfrz(mgs) &
23040 & +felspi(mgs)*psub(mgs) &
23041 & +felvpi(mgs)*pvap(mgs))*dtp
23049 ! sum the sources and sinks for qwvp, qcw, qci, qrw, qsw
23055 qwvp(mgs) = qwvp(mgs) + &
23056 & dtp*(pqwvi(mgs)+pqwvd(mgs))
23057 qx(mgs,lc) = qx(mgs,lc) + &
23058 & dtp*(pqcwi(mgs)+pqcwd(mgs))
23059 qx(mgs,lr) = qx(mgs,lr) + &
23060 & dtp*(pqrwi(mgs)+pqrwd(mgs))
23061 qx(mgs,li) = qx(mgs,li) + &
23062 & dtp*(pqcii(mgs)+pqcid(mgs))
23063 qx(mgs,ls) = qx(mgs,ls) + &
23064 & dtp*(pqswi(mgs)+pqswd(mgs))
23065 qx(mgs,lh) = qx(mgs,lh) + &
23066 & dtp*(pqhwi(mgs)+pqhwd(mgs))
23068 IF ( lhl .gt. 1 ) THEN
23069 qx(mgs,lhl) = qx(mgs,lhl) + &
23070 & dtp*(pqhli(mgs)+pqhld(mgs))
23076 ! sum sources for particle volume
23082 IF ( lvol(ls) .gt. 1 ) THEN
23083 vx(mgs,ls) = vx(mgs,ls) + &
23084 & dtp*(pvswi(mgs)+pvswd(mgs))
23087 IF ( lvol(lh) .gt. 1 ) THEN
23088 vx(mgs,lh) = vx(mgs,lh) + &
23089 & dtp*(pvhwi(mgs)+pvhwd(mgs))
23090 ! > rho0(mgs)*dtp*(pqhwi(mgs)+pqhwd(mgs))/xdn0(lh)
23093 IF ( lhl .gt. 1 ) THEN
23094 IF ( lvol(lhl) .gt. 1 ) THEN
23095 vx(mgs,lhl) = vx(mgs,lhl) + &
23096 & dtp*(pvhli(mgs)+pvhld(mgs))
23097 ! > rho0(mgs)*dtp*(pqhwi(mgs)+pqhwd(mgs))/xdn0(lh)
23110 if ( ipconc .ge. 1 ) then
23112 cx(mgs,li) = cx(mgs,li) + &
23113 & dtp*(pccii(mgs)+pccid(mgs))
23114 cina(mgs) = cina(mgs) + pccin(mgs)*dtp
23115 IF ( ipconc .ge. 2 ) THEN
23116 cx(mgs,lc) = cx(mgs,lc) + &
23117 & dtp*(pccwi(mgs)+pccwd(mgs))
23119 IF ( ipconc .ge. 3 ) THEN
23120 cx(mgs,lr) = cx(mgs,lr) + &
23121 & dtp*(pcrwi(mgs)+pcrwd(mgs))
23123 IF ( ipconc .ge. 4 ) THEN
23124 cx(mgs,ls) = cx(mgs,ls) + &
23125 & dtp*(pcswi(mgs)+pcswd(mgs))
23127 IF ( ipconc .ge. 5 ) THEN
23128 cx(mgs,lh) = cx(mgs,lh) + &
23129 & dtp*(pchwi(mgs)+pchwd(mgs))
23130 IF ( lhl .gt. 1 ) THEN
23131 cx(mgs,lhl) = cx(mgs,lhl) + &
23132 & dtp*(pchli(mgs)+pchld(mgs))
23139 IF ( ipconc .ge. 6 ) THEN
23140 IF ( lzr .gt. 1 ) THEN
23141 zx(mgs,lr) = zx(mgs,lr) + &
23142 & dtp*(pzrwi(mgs)+pzrwd(mgs))
23144 IF ( lzs .gt. 1 ) THEN
23145 zx(mgs,ls) = zx(mgs,ls) + &
23146 & dtp*(pzswi(mgs)+pzswd(mgs))
23148 IF ( lzh .gt. 1 ) THEN
23149 zx(mgs,lh) = zx(mgs,lh) + &
23150 & dtp*(pzhwi(mgs)+pzhwd(mgs))
23152 IF ( lzhl .gt. 1 ) THEN
23153 zx(mgs,lhl) = zx(mgs,lhl) + &
23154 & dtp*(pzhli(mgs)+pzhld(mgs))
23155 ! IF ( pchli(mgs) .ne. 0. .or. pchld(mgs) .ne. 0 ) THEN
23156 ! write(0,*) 'dr: cx,pchli,pchld = ', cx(mgs,lhl),pchli(mgs),pchld(mgs), igs(mgs),kgs(mgs)
23163 IF ( has_wetscav ) THEN
23165 evapprod2d(igs(mgs),kgs(mgs)) = -(qrcev(mgs) + qssbv(mgs) + qhsbv(mgs) + qhlsbv(mgs))
23166 rainprod2d(igs(mgs),kgs(mgs)) = qrcnw(mgs) + qracw(mgs) + qsacw(mgs) + qhacw(mgs) + qhlacw(mgs) + &
23167 qraci(mgs) + qsaci(mgs) + qhaci(mgs) + qhlaci(mgs) + qscni(mgs)
23173 ! start saturation adjustment
23175 if (ndebug .gt. 0 ) write(0,*) 'conc 30a'
23176 ! include 'sam.jms.satadj.sgi'
23180 ! Modified Straka adjustment (nearly identical to Tao et al. 1989 MWR)
23184 ! set up temperature and vapor arrays
23187 pqs(mgs) = (380.0)/(pres(mgs))
23188 theta(mgs) = thetap(mgs) + theta0(mgs)
23189 qvap(mgs) = max( (qwvp(mgs) + qv0(mgs)), 0.0 )
23190 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
23193 ! melting of cloud ice
23196 qcwtmp(mgs) = qx(mgs,lc)
23201 qitmp(mgs) = qx(mgs,li)
23202 if( temg(mgs) .gt. tfr .and. &
23203 & qitmp(mgs) .gt. 0.0 ) then
23204 qx(mgs,lc) = qx(mgs,lc) + qitmp(mgs)
23205 ! pfrz(mgs) = pfrz(mgs) - qitmp(mgs)*dtpinv
23206 ptem(mgs) = ptem(mgs) + &
23208 & felfcp(mgs)*(- qitmp(mgs)*dtpinv)
23209 IF ( eqtset > 2 ) THEN
23210 pipert(mgs) = pipert(mgs) - (felfpi(mgs)*qitmp(mgs))
23212 pmlt(mgs) = pmlt(mgs) - qitmp(mgs)*dtpinv
23213 scx(mgs,lc) = scx(mgs,lc) + scx(mgs,li)
23214 thetap(mgs) = thetap(mgs) - &
23215 & fcc3(mgs)*qitmp(mgs)
23216 ptimlw(mgs) = -fcc3(mgs)*qitmp(mgs)*dtpinv
23217 cx(mgs,lc) = cx(mgs,lc) + cx(mgs,li)
23230 ! do mgs = 1,ngscnt
23231 ! qimlw(mgs) = (qcwtmp(mgs)-qx(mgs,lc))*dtpinv
23234 ! homogeneous freezing of cloud water
23236 IF ( warmonly < 0.8 ) THEN
23239 qcwtmp(mgs) = qx(mgs,lc)
23245 ! if( temg(mgs) .lt. tfrh ) THEN
23246 ! write(0,*) 'GS: mgs,temp,qc,qi = ',mgs,temg(mgs),temcg(mgs),qx(mgs,lc),qx(mgs,li)
23253 ! if( ( temg(mgs) .lt. thnuc + 2. .or. (ibfc == 2 .and. temg(mgs) < thnuc + 10. ) ) .and. &
23254 ! & qx(mgs,lc) .gt. qxmin(lc) .and. (ipconc < 2 .or. ibfc == 0 .or. ibfc == 2 )) then
23255 ! commented for test (12/01/2015):
23256 ! if( temg(mgs) .lt. thnuc + 0. .and. &
23257 ! & qx(mgs,lc) .gt. 0.0 .and. (ipconc < 2 .or. ibfc == 0 )) then
23258 if( ( ( temg(mgs) .lt. thnuc + 0.) .or. (temg(mgs) .lt. thnuc + 2. .and. ibfc >= 3) ) .and. &
23259 & qx(mgs,lc) .gt. 0.0 .and. (ipconc < 2 .or. ibfc == 0 .or. ibfc == 2)) then
23261 IF ( ibfc >= 3 ) THEN
23262 frac = Max( 0.25, Min( 1., ((thnuc + 2.) - temg(mgs) )/4.0 ) )
23263 ELSEIF ( ibfc /= 2 .or. ipconc < 2 ) THEN
23264 frac = Max( 0.25, Min( 1., ((thnuc + 1.) - temg(mgs) )/4.0 ) )
23266 volt = exp( 16.2 + 1.0*temcg(mgs) )* 1.0e-6 ! Ts == -temcg ; volt comes from the fit in Fig. 1 in Bigg 1953
23267 ! for mean temperature for freezing: -ln (V) = a*Ts - b
23268 ! volt is given in cm**3, so factor of 1.e-6 to convert to m**3
23270 cwfrz(mgs) = cx(mgs,lc)*Exp(-volt/xv(mgs,lc)) ! number of droplets with volume greater than volt
23272 qtmp = cwfrz(mgs)*xdn0(lc)*rhoinv(mgs)*(volt + xv(mgs,lc))
23273 frac = qtmp/qx(mgs,lc) ! reset number frozen to same fraction as mass. This makes
23274 ! sure that cwfrz and qwfrz are consistent and prevents
23275 ! spurious creation of ice crystals.
23278 qtmp = frac*qx(mgs,lc)
23280 IF ( ibfc == 4 .and. lis >= 1 ) THEN
23281 qx(mgs,lis) = qx(mgs,lis) + qtmp
23283 qx(mgs,li) = qx(mgs,li) + qtmp ! qx(mgs,lc)
23285 pfrz(mgs) = pfrz(mgs) + qtmp*dtpinv
23286 ptem(mgs) = ptem(mgs) + &
23288 & felfcp(mgs)*(qtmp*dtpinv)
23290 IF ( eqtset > 2 ) THEN
23291 pipert(mgs) = pipert(mgs) + felfpi(mgs)*qtmp
23294 ! IF ( lvol(li) .gt. 1 ) vx(mgs,li) = vx(mgs,li) + rho0(mgs)*qx(mgs,lc)/xdn0(li)
23295 IF ( lvol(li) .gt. 1 ) vx(mgs,li) = vx(mgs,li) + rho0(mgs)*qtmp/xdn0(li)
23297 IF ( ipconc .ge. 2 ) THEN
23298 ctmp = frac*cx(mgs,lc)
23299 ! cx(mgs,li) = cx(mgs,li) + cx(mgs,lc)
23300 IF ( ibfc == 4 .and. lis >= 1 ) THEN
23301 cx(mgs,lis) = cx(mgs,lis) + ctmp
23303 cx(mgs,li) = cx(mgs,li) + ctmp
23305 ELSE ! (ipconc .lt. 2 )
23307 IF ( t9(igs(mgs),jgs,kgs(mgs)-1) .gt. qx(mgs,lc) ) THEN
23308 qtmp = frac*t9(igs(mgs),jgs,kgs(mgs)-1)
23310 ! cx(mgs,lc) = cx(mgs,lc)*qx(mgs,lc)*rho0(mgs)/qtmp
23311 ctmp = cx(mgs,lc)*qx(mgs,lc)*rho0(mgs)/qtmp
23313 cx(mgs,lc) = Max(0.0,wvel(mgs))*dtp*cwccn &
23314 & /gz(igs(mgs),jgs,kgs(mgs))
23318 IF ( ipconc .ge. 1 ) cx(mgs,li) = Min(ccimx, cx(mgs,li) + cx(mgs,lc))
23321 sctmp = frac*scx(mgs,lc)
23322 ! scx(mgs,li) = scx(mgs,li) + scx(mgs,lc)
23323 scx(mgs,li) = scx(mgs,li) + sctmp
23324 ! thetap(mgs) = thetap(mgs) + fcc3(mgs)*qx(mgs,lc)
23325 ! ptwfzi(mgs) = fcc3(mgs)*qx(mgs,lc)*dtpinv
23328 ! scx(mgs,lc) = 0.0
23329 thetap(mgs) = thetap(mgs) + fcc3(mgs)*qtmp
23330 ptwfzi(mgs) = fcc3(mgs)*qtmp*dtpinv
23331 qx(mgs,lc) = qx(mgs,lc) - qtmp
23332 cx(mgs,lc) = cx(mgs,lc) - ctmp
23333 scx(mgs,lc) = scx(mgs,lc) - sctmp
23339 ! do mgs = 1,ngscnt
23340 ! qwfzi(mgs) = (qcwtmp(mgs)-qx(mgs,lc))*dtpinv ! Not used?? (ERM)
23343 ! reset temporaries for cloud particles and vapor
23347 IF ( ipconc .le. 1 .and. lwsm6 ) THEN ! Explicit cloud condensation/evaporation (Rutledge and Hobbs 1983)
23350 qcwtmp(mgs) = qx(mgs,lc)
23351 theta(mgs) = thetap(mgs) + theta0(mgs)
23352 temgtmp = temg(mgs)
23353 ! temg(mgs) = theta(mgs)*(p2(igs(mgs),jgs,kgs(mgs)) ) ! *pk(mgs) ! ( pres(mgs) / poo ) ** cap
23354 ! temsav = temg(mgs)
23355 ! thsave(mgs) = thetap(mgs)
23356 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
23357 temcg(mgs) = temg(mgs) - tfr
23358 ltemq = (temg(mgs)-163.15)/fqsat+1.5
23359 ltemq = Min( nqsat, Max(1,ltemq) )
23361 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
23363 IF ( ( qvap(mgs) > qvs(mgs) .or. qx(mgs,lc) > qxmin(lc) ) .and. temg(mgs) > tfrh ) THEN
23364 tmp = (qvap(mgs) - qvs(mgs))/(1. + qvs(mgs)*felv(mgs)**2/(cp*rw*temg(mgs)**2) )
23365 qcond(mgs) = Min( Max( 0.0, tmp ), (qvap(mgs)-qvs(mgs)) )
23366 IF ( qx(mgs,lc) > qxmin(lc) .and. tmp < 0.0 ) THEN ! evaporation
23367 qcond(mgs) = Max( tmp, -qx(mgs,lc) )
23369 qwvp(mgs) = qwvp(mgs) - qcond(mgs)
23370 qvap(mgs) = qvap(mgs) - qcond(mgs)
23371 qx(mgs,lc) = Max( 0.0, qx(mgs,lc) + qcond(mgs) )
23372 thetap(mgs) = thetap(mgs) + felvcp(mgs)*qcond(mgs)/(pi0(mgs))
23381 IF ( ipconc .le. 1 .and. .not. lwsm6 ) THEN
23382 ! IF ( ipconc .le. 1 ) THEN
23385 qx(mgs,lv) = max( 0.0, qvap(mgs) )
23386 qx(mgs,lc) = max( 0.0, qx(mgs,lc) )
23387 qx(mgs,li) = max( 0.0, qx(mgs,li) )
23388 qitmp(mgs) = qx(mgs,li)
23393 qcwtmp(mgs) = qx(mgs,lc)
23394 qitmp(mgs) = qx(mgs,li)
23395 theta(mgs) = thetap(mgs) + theta0(mgs)
23396 temgtmp = temg(mgs)
23397 temg(mgs) = theta(mgs)*(pinit(kgs(mgs)) + p2(igs(mgs),jgs,kgs(mgs)) ) ! *pk(mgs) ! ( pres(mgs) / poo ) ** cap
23399 thsave(mgs) = thetap(mgs)
23400 temcg(mgs) = temg(mgs) - tfr
23401 tqvcon = temg(mgs)-cbw
23402 ltemq = (temg(mgs)-163.15)/fqsat+1.5
23403 ltemq = Min( nqsat, Max(1,ltemq) )
23405 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
23406 qis(mgs) = pqs(mgs)*tabqis(ltemq)
23407 qss(mgs) = qvs(mgs)
23408 if ( temg(mgs) .lt. tfr ) then
23409 if( qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) ) &
23410 & qss(mgs) = qvs(mgs)
23411 if( qx(mgs,lc) .le. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
23412 & qss(mgs) = qis(mgs)
23413 if( qx(mgs,lc) .gt. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
23414 & qss(mgs) = (qx(mgs,lc)*qvs(mgs) + qitmp(mgs)*qis(mgs)) / &
23415 & (qx(mgs,lc) + qitmp(mgs))
23419 ! iterate adjustment
23425 ! calculate super-saturation
23427 qitmp(mgs) = qx(mgs,li)
23432 dqwv(mgs) = ( qx(mgs,lv) - qss(mgs) )
23434 ! evaporation and sublimation adjustment
23436 if( dqwv(mgs) .lt. 0. ) then ! subsaturated
23437 if( qx(mgs,lc) .gt. -dqwv(mgs) ) then ! check if qc can make up all of the deficit
23438 dqcw(mgs) = dqwv(mgs)
23440 else ! otherwise make all qc available for evap
23441 dqcw(mgs) = -qx(mgs,lc)
23442 dqwv(mgs) = dqwv(mgs) + qx(mgs,lc)
23445 if( qitmp(mgs) .gt. -dqwv(mgs) ) then ! check if qi can make up all the deficit
23446 dqci(mgs) = dqwv(mgs)
23448 else ! otherwise make all ice available for sublimation
23449 dqci(mgs) = -qitmp(mgs)
23450 dqwv(mgs) = dqwv(mgs) + qitmp(mgs)
23453 qwvp(mgs) = qwvp(mgs) - ( dqcw(mgs) + dqci(mgs) ) ! add to perturbation vapor
23455 ! This next line removed 3/19/2003 thanks to Adam Houston,
23456 ! who found the bug in the 3-ICE code
23457 ! qwvp(mgs) = max(qwvp(mgs), 0.0)
23458 qitmp(mgs) = qx(mgs,li)
23459 IF ( qitmp(mgs) .ge. qxmin(li) ) THEN
23460 fcci(mgs) = qx(mgs,li)/(qitmp(mgs))
23464 qx(mgs,lc) = qx(mgs,lc) + dqcw(mgs)
23465 qx(mgs,li) = qx(mgs,li) + dqci(mgs) * fcci(mgs)
23466 thetap(mgs) = thetap(mgs) + &
23468 & (felvcp(mgs)*dqcw(mgs) +felscp(mgs)*dqci(mgs))
23470 IF ( eqtset > 2 ) THEN
23471 pipert(mgs) = pipert(mgs) &
23472 & +(felspi(mgs)*dqci(mgs) &
23473 & +felvpi(mgs)*dqcw(mgs))*dtp
23476 end if ! dqwv(mgs) .lt. 0. (end of evap/sublim)
23478 ! condensation/deposition
23480 IF ( dqwv(mgs) .ge. 0. ) THEN
23482 ! write(iunit,*) 'satadj: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qx(mgs,lv),qx(mgs,lc)
23484 qitmp(mgs) = qx(mgs,li)
23487 if ( temg(mgs) .lt. tfr .and. temg(mgs) .gt. thnuc ) then
23488 fracl(mgs) = max(min(1.,(temg(mgs)-233.15)/(20.)),0.0)
23489 fraci(mgs) = 1.0-fracl(mgs)
23491 if ( temg(mgs) .le. thnuc ) then
23495 fraci(mgs) = 1.0-fracl(mgs)
23497 gamss = (felvcp(mgs)*fracl(mgs) + felscp(mgs)*fraci(mgs)) &
23500 IF ( temg(mgs) .lt. tfr ) then
23501 IF (qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) ) then
23502 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qss(mgs)/ &
23503 & ((temg(mgs)-cbw)**2))
23505 IF ( qx(mgs,lc) .eq. 0.0 .and. qitmp(mgs) .gt. qxmin(li) ) then
23506 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv2(mgs)*qss(mgs)/ &
23507 & ((temg(mgs)-cbi)**2))
23509 IF ( qx(mgs,lc) .gt. 0.0 .and. qitmp(mgs) .gt. qxmin(li) ) then
23510 cdw = caw*pi0(mgs)*tfrcbw/((temg(mgs)-cbw)**2)
23511 cdi = cai*pi0(mgs)*tfrcbi/((temg(mgs)-cbi)**2)
23512 denom1 = qx(mgs,lc) + qitmp(mgs)
23513 denom2 = 1.0 + gamss* &
23514 & (qx(mgs,lc)*qvs(mgs)*cdw + qitmp(mgs)*qis(mgs)*cdi) / denom1
23515 dqvcnd(mgs) = dqwv(mgs) / denom2
23518 ENDIF ! temg(mgs) .lt. tfr
23520 if ( temg(mgs) .ge. tfr ) then
23521 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qss(mgs)/ &
23522 & ((temg(mgs)-cbw)**2))
23527 IF ( qitmp(mgs) .gt. qxmin(li) ) THEN
23528 fcci(mgs) = qx(mgs,li)/(qitmp(mgs))
23533 dqcw(mgs) = dqvcnd(mgs)*fracl(mgs)
23534 dqci(mgs) = dqvcnd(mgs)*fraci(mgs)
23536 thetap(mgs) = thetap(mgs) + &
23537 & (felvcp(mgs)*dqcw(mgs) + felscp(mgs)*dqci(mgs)) &
23540 IF ( eqtset > 2 ) THEN
23541 pipert(mgs) = pipert(mgs) + (0 &
23542 & +felspi(mgs)*dqci(mgs) &
23543 & +felvpi(mgs)*dqcw(mgs))*dtp
23546 qwvp(mgs) = qwvp(mgs) - ( dqvcnd(mgs) )
23547 qx(mgs,lc) = qx(mgs,lc) + dqcw(mgs)
23548 ! IF ( qitmp(mgs) .gt. qxmin(li) ) THEN
23549 qx(mgs,li) = qx(mgs,li) + dqci(mgs)*fcci(mgs)
23550 qitmp(mgs) = qx(mgs,li)
23553 ! delqci(mgs) = dqci(mgs)*fcci(mgs)
23555 END IF ! dqwv(mgs) .ge. 0.
23559 qitmp(mgs) = qx(mgs,li)
23560 theta(mgs) = thetap(mgs) + theta0(mgs)
23561 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
23562 qvap(mgs) = Max((qwvp(mgs) + qv0(mgs)), 0.0)
23563 temcg(mgs) = temg(mgs) - tfr
23564 tqvcon = temg(mgs)-cbw
23565 ltemq = (temg(mgs)-163.15)/fqsat+1.5
23566 ltemq = Min( nqsat, Max(1,ltemq) )
23567 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
23568 qis(mgs) = pqs(mgs)*tabqis(ltemq)
23569 qx(mgs,lc) = max( 0.0, qx(mgs,lc) )
23570 qitmp(mgs) = max( 0.0, qitmp(mgs) )
23571 qx(mgs,lv) = max( 0.0, qvap(mgs))
23572 ! if ( temg(mgs) .lt. tfr ) then
23573 ! if( qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) )
23574 ! > qss(mgs) = qvs(mgs)
23575 !c if( qx(mgs,lc) .le. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li))
23576 ! if( qx(mgs,lc) .eq. 0.0 .and. qitmp(mgs) .gt. qxmin(li))
23577 ! > qss(mgs) = qis(mgs)
23578 !c if( qx(mgs,lc) .gt. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li))
23579 ! if( qx(mgs,lc) .gt. 0.0 .and. qitmp(mgs) .gt. qxmin(li))
23580 ! > qss(mgs) = (qx(mgs,lc)*qvs(mgs) + qitmp(mgs)*qis(mgs)) /
23581 ! > (qx(mgs,lc) + qitmp(mgs))
23583 ! qss(mgs) = qvs(mgs)
23585 qss(mgs) = qvs(mgs)
23586 if ( temg(mgs) .lt. tfr ) then
23587 if( qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) ) &
23588 & qss(mgs) = qvs(mgs)
23589 if( qx(mgs,lc) .le. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
23590 & qss(mgs) = qis(mgs)
23591 if( qx(mgs,lc) .gt. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
23592 & qss(mgs) = (qx(mgs,lc)*qvs(mgs) + qitmp(mgs)*qis(mgs)) / &
23593 & (qx(mgs,lc) + qitmp(mgs))
23595 ! pceds(mgs) = (thetap(mgs) - thsave(mgs))*dtpinv
23596 ! write(iunit,*) 'satadj2: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qx(mgs,lv),qx(mgs,lc)
23599 ! end the saturation adjustment iteration loop
23603 ENDIF ! ( ipconc .le. 1 )
23606 ! spread the growth owing to vapor diffusion onto the
23607 ! ice crystal categories using the
23609 ! END OF SATURATION ADJUSTMENT
23612 if (ndebug .gt. 0 ) write(0,*) 'conc 30b'
23615 ! end of saturation adjustment
23621 t0(igs(mgs),jy,kgs(mgs)) = temg(mgs)
23624 ! Load the save arrays
23628 ! Sample code for using the axtra array to load microphysical rates or quantities for output
23630 ! Note that indices 1 and 2 are used in the nucond subroutine for condensation/evap of droplets (1) and
23631 ! condensation of rain (2)
23633 ! IF ( io_flag .and. nxtra > 1 ) THEN
23634 ! DO mgs = 1,ngscnt
23635 ! axtra(igs(mgs),jy,kgs(mgs),3) = pfrz(mgs) !
23636 ! axtra(igs(mgs),jy,kgs(mgs),4) = qrcev(mgs) ! pre2
23637 ! axtra(igs(mgs),jy,kgs(mgs),5) = psub(mgs) ! depsubr
23638 ! axtra(igs(mgs),jy,kgs(mgs),6) = qrfrz(mgs) ! rain freezing (Bigg)
23639 ! axtra(igs(mgs),jy,kgs(mgs),7) = pmlt(mgs) ! melr2
23645 if (ndebug .gt. 0 ) write(0,*) 'gs 11'
23649 an(igs(mgs),jy,kgs(mgs),lt) = &
23650 & theta0(mgs) + thetap(mgs)
23651 an(igs(mgs),jy,kgs(mgs),lv) = qwvp(mgs) + qv0(mgs) !
23653 IF ( eqtset > 2 ) THEN
23654 p2(igs(mgs),jy,kgs(mgs)) = pipert(mgs)
23659 IF ( ido(il) .eq. 1 ) THEN
23660 IF ( lf > 1 .and. il == lf ) THEN
23661 lfsave(mgs,1) = an(igs(mgs),jy,kgs(mgs),il)
23662 lfsave(mgs,2) = qx(mgs,il)
23664 an(igs(mgs),jy,kgs(mgs),il) = qx(mgs,il) + &
23665 & min( an(igs(mgs),jy,kgs(mgs),il), 0.0 )
23666 qx(mgs,il) = an(igs(mgs),jy,kgs(mgs),il)
23670 IF ( lcina > 1 ) THEN
23671 an(igs(mgs),jy,kgs(mgs),lcina) = cina(mgs)
23682 IF ( ipconc .ge. 6 ) THEN
23684 IF ( lz(il) .gt. 1 ) THEN
23685 IF ( lf > 1 .and. il == lf ) THEN
23686 lfsave(mgs,3) = an(igs(mgs),jy,kgs(mgs),lz(il))
23687 lfsave(mgs,4) = zx(mgs,il)
23690 an(igs(mgs),jy,kgs(mgs),lz(il)) = zx(mgs,il) + &
23691 & min( an(igs(mgs),jy,kgs(mgs),lz(il)), 0.0 )
23692 zx(mgs,il) = an(igs(mgs),jy,kgs(mgs),lz(il))
23702 if ( ipconc .ge. 1 ) then
23705 ! write(0,*) 'limiter loop: il,ipc,lz: ',il,ipc(il),lz(il),ipconc
23707 IF ( ipconc .ge. ipc(il) .and. ido(il) > 0 ) THEN ! {
23709 IF ( ipconc .ge. 4 .and. ipc(il) .ge. 1 ) THEN ! {
23711 ! write(0,*) 'MY limiter: il,ipc,lz: ',il,ipc(il),lz(il),lr,lzr
23714 IF ( lz(il) <= 1 .or. ioldlimiter == 1 ) THEN ! { { is a two-moment category so dont worry about reflectivity
23718 IF ( qx(mgs,il) .le. 0.0 ) THEN
23721 IF ( cx(mgs,il) .gt. cxmin ) THEN !{
23722 ! xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*Max(1.0e-9,cx(mgs,il)))
23723 ! xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*Max(cxmin,cx(mgs,il)))
23724 xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*cx(mgs,il))
23726 ! IF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
23727 ! write(0,*) 'dr: xv,cx,qx,xdn,ln = ',xv(mgs,il),cx(mgs,il),qx(mgs,il),xdn(mgs,il),ln(il)
23730 ! 8/26/2015 erm: apply imaxdiaopt for 2-moment also
23731 IF ( imaxdiaopt == 1 .or. il == lc .or. il == li .or. (il == lr .and. imurain == 3) .or. &
23732 & (il == ls .and. imusnow == 3 ) ) THEN
23733 xvbarmax = xvmx(il)
23734 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
23735 xvbarmax = xvmx(il) /((3. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
23736 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
23737 xvbarmax = xvmx(il) /((4. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
23739 xvbarmax = xvmx(il)
23743 IF ( il == ls ) THEN
23744 xvbarmax = xvbarmax*Max(1.,100./Min(100.,xdn(mgs,ls)))
23747 IF ( xv(mgs,il) .lt. xvmn(il) .or. xv(mgs,il) .gt. xvbarmax ) THEN
23748 xv(mgs,il) = Min( xvbarmax, xv(mgs,il) )
23749 xv(mgs,il) = Max( xvmn(il), xv(mgs,il) )
23750 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xv(mgs,il)*xdn(mgs,il))
23755 ! IF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
23756 ! write(0,*) 'dr: xv,cx,= ',xv(mgs,il),cx(mgs,il)
23762 ELSE ! } { is three-moment, so have to adjust Z if size is too large
23763 IF ( il == lr .and. imurain == 3 ) THEN ! { { RAIN
23771 IF ( iresetmoments == 1 .or. iresetmoments == il ) THEN
23772 IF ( zx(mgs,lr) <= zxmin ) THEN
23773 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
23776 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
23777 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
23778 an(igs(mgs),jgs,kgs(mgs),ln(lr)) = cx(mgs,lr)
23779 ELSEIF ( cx(mgs,lr) <= cxmin ) THEN
23780 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
23783 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
23784 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
23785 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
23789 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
23791 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*Max(1.0e-11,cx(mgs,lr)))
23792 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
23793 ! xv(mgs,lr) = xvmx(lr)
23794 ! cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
23795 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
23796 xv(mgs,lr) = xvmn(lr)
23797 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
23800 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
23801 ! have mass and reflectivity but no concentration, so set concentration, using default alpha
23802 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
23805 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*xdn(mgs,lr)**2)
23806 ! an(igs(mgs),jgs,kgs(mgs),ln(il)) = zx(mgs,il)
23807 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > 0.0 ) THEN
23808 ! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
23809 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
23812 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(xdn(mgs,lr)**2*chw)
23813 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
23815 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
23816 ! How did this happen?
23817 ! set values according to dBZ of -10, or Z = 0.1
23818 ! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
23819 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
23820 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
23822 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
23825 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*1000.*1000)
23826 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
23829 IF ( zx(mgs,lr) > 0.0 ) THEN
23830 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(1000.*cx(mgs,lr))
23836 ! xv = (db(1,kz)*a(1,1,kz,lr))**2/(a(1,1,kz,lnr))
23837 ! rd = z*(pi/6.*1000.)**2/xv
23839 ! determine shape parameter alpha by iteration
23840 IF ( z .gt. 0.0 ) THEN
23841 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
23843 IF ( Abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
23844 alpha(mgs,lr) = Max( rnumin, Min( rnumax, alp ) )
23845 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
23846 alp = Max( rnumin, Min( rnumax, alp ) )
23849 ! check for artificial breakup (rain larger than allowed max size)
23850 IF ( xv(mgs,il) .gt. xvmx(il) .or. (ioldlimiter == 2 .and. xv(mgs,il) .gt. xvmx(il)/8.) ) THEN
23852 ! write(0,*) 'MY limiter: xv: ',xv(mgs,il), xv(mgs,il)/(xvmx(il)/8.)
23854 IF ( ioldlimiter == 2 ) THEN ! MY-style active breakup
23855 x = (6.*rho0(mgs)*qx(mgs,il)/(pi*xdn(mgs,il)*cx(mgs,il)))**(1./3.)
23856 x1 = Max(0.0e-3, x - 3.0e-3)
23857 x2 = Max(0.5, x/6.0e-3)
23859 cx(mgs,il) = cx(mgs,il)*Max((1.+2.222e3*x1**2), x3)
23860 xv(mgs,il) = xv(mgs,il)/Max((1.+2.222e3*x1**2), x3)
23861 ELSE ! simple cutoff
23862 xv(mgs,il) = Min( xvmx(il), Max( xvmn(il),xv(mgs,il) ) )
23863 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
23864 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
23866 !xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
23867 !cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
23870 IF ( tmp < cx(mgs,il) ) THEN ! breakup
23872 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
23873 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
23874 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
23882 ! determine shape parameter alpha by iteration
23883 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
23885 IF ( Abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
23886 alpha(mgs,lr) = Max( rnumin, Min( rnumax, alp ) )
23887 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
23888 alp = Max( rnumin, Min( rnumax, alp ) )
23896 ! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
23897 ! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
23899 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
23900 IF ( .true. .and. (alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax) ) THEN
23902 IF ( rescale_high_alpha .and. alp >= rnumax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
23903 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(1./(xdn(mgs,il)))**2
23904 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
23906 ELSEIF ( rescale_low_alphar .and. alp <= rnumin ) THEN
23907 z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
23909 an(igs(mgs),jy,kgs(mgs),lz(il)) = zx(mgs,il)
23921 ! CALL cld_cpu('Z-MOMENT-1r')
23924 ELSEIF ( il == lh .or. il == lhl .or. il == lf .or. (il == lr .and. imurain == 1 )) THEN ! } { Rain, GRAUPEL OR HAIL
23930 IF ( lf > 1 .and. il == lf ) THEN
23931 lfsave(mgs,5) = an(igs(mgs),jy,kgs(mgs),ln(il))
23932 lfsave(mgs,6) = cx(mgs,il)
23935 IF ( il == lhl .and. lnhlf > 1 ) THEN
23936 IF ( cx(mgs,lhl) > cxmin ) THEN
23937 frac = chxf(mgs,lhl)/cx(mgs,lhl)
23943 IF ( il == lh .and. lnhf > 1 ) THEN
23944 IF ( cx(mgs,lh) > cxmin ) THEN
23945 frach = chxf(mgs,lh)/cx(mgs,lh)
23953 IF ( iresetmoments == 1 .or. iresetmoments == il .or. iresetmoments == -1 ) THEN ! { .or. qx(mgs,il) <= qxmin(il)
23954 IF ( zx(mgs,il) <= zxmin ) THEN ! .and. qx(mgs,il) > 0.05e-3
23955 !! write(91,*) 'zx=0; qx,cx = ',1000.*qx(mgs,il),cx(mgs,il)
23958 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
23959 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
23960 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
23961 ELSEIF ( iresetmoments == -1 .and. qx(mgs,il) < qxmin(il) ) THEN
23964 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
23967 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
23968 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
23969 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
23971 ELSEIF ( cx(mgs,il) <= cxmin .and. iresetmoments /= -1 ) THEN ! .and. qx(mgs,il) > 0.05e-3
23972 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
23975 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
23976 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
23977 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
23980 IF ( zx(mgs,il) < 0.0 ) THEN ! .and. qx(mgs,il) > 0.05e-3
23986 IF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= cxmin ) THEN
23989 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
23991 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
23992 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
23993 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
23996 IF ( qx(mgs,il) .gt. qxmin(il) ) THEN !{
23998 xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*Max(1.0e-9,cx(mgs,il)))
23999 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
24001 IF ( xv(mgs,il) .lt. xvmn(il) ) THEN
24002 xv(mgs,il) = Min( xvmx(il), Max( xvmn(il),xv(mgs,il) ) )
24003 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
24004 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
24007 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN !{
24008 ! have mass and reflectivity but no concentration, so set concentration, using default alpha
24009 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
24010 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
24013 ! cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z
24014 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(z*(pi*xdn(mgs,il))**2)
24017 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > 0.0 ) THEN
24018 ! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
24019 ! g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
24020 ! & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
24023 ! zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
24024 ! zx(mgs,il) = Min(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
24025 g1 = (6.0 + alphamax)*(5.0 + alphamax)*(4.0 + alphamax)/ &
24026 & ((3.0 + alphamax)*(2.0 + alphamax)*(1.0 + alphamax))
24027 zx(mgs,il) = Max(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
24028 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
24030 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
24031 ! How did this happen?
24032 ! set values according to dBZ of -10, or Z = 0.1
24033 ! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
24035 ! write(0,*) 'GS: moment problem! il,c,z,q = ',il,cx(mgs,il),zx(mgs,il),qx(mgs,il)
24037 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
24038 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
24040 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
24041 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
24044 ! cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z
24045 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(z*(pi*xdn(mgs,il))**2)
24046 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
24048 ! write(0,*) 'GS: moment problem! reset il,c,z,q = ',il,cx(mgs,il),zx(mgs,il),qx(mgs,il)
24051 ! have all valid moments, so find shape parameter
24056 IF ( zx(mgs,il) .gt. 0. ) THEN !{
24058 ! rdi = z*(pi/6.*1000.)**2*chw/((rho0(mgs)*qr)**2)
24059 rdi = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
24061 ! alp = 1.e18*(6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/
24062 ! : ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24063 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
24064 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24065 ! print*,'kz, alp, alpha(mgs,il) = ',kz,alp,alpha(mgs,il),rdi,z,xv
24067 ! IF ( 100.*Abs(alp - alpha(mgs,il))/(Abs(alpha(mgs,il))+1.e-5) .lt. 1. ) EXIT
24068 IF ( Abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
24069 alpha(mgs,il) = Max( alphamin, Min( alphamax, alp ) )
24070 ! alp = 1.e18*(6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/
24071 ! : ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24072 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
24073 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24074 ! print*,'i,alp = ',i,alp
24075 alp = Max( alphamin, Min( alphamax, alp ) )
24079 ! check for artificial breakup (graupel/hail larger than allowed max size)
24080 IF ( xv(mgs,il) .gt. xvmx(il) ) THEN !{
24084 xv(mgs,il) = Min( xvmx(il), Max( xvmn(il),xv(mgs,il) ) )
24085 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
24086 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
24087 IF ( tmp < cx(mgs,il) ) THEN ! breakup
24088 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
24089 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
24090 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
24091 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
24097 rdi = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
24098 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
24099 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24101 IF ( Abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
24102 alpha(mgs,il) = Max( alphamin, Min( alphamax, alp ) )
24103 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
24104 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24105 alp = Max( alphamin, Min( alphamax, alp ) )
24113 ! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
24114 ! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
24116 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
24117 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
24119 IF ( ( lrescalelow(il) .or. rescale_high_alpha ) .and. &
24120 & ( alpha(mgs,il) <= alphamin .or. alp == alphamin .or. alp == alphamax ) ) THEN !{
24122 IF ( rescale_high_alpha .and. alp >= alphamax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
24123 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(6./(pi*xdn(mgs,il)))**2
24124 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
24126 ELSEIF ( lrescalelow(il) .and. alp <= alphamin .and. .not. (il == lh .and. icvhl2h > 0 ) .and. &
24127 .not. ( il == lr .and. .not. rescale_low_alphar ) ) THEN ! alpha = alphamin, so reset Z to prevent growth in C
24130 IF ( irescalerainopt == 0 ) THEN
24132 ELSEIF ( irescalerainopt == 1 ) THEN
24133 wtest = qx(mgs,lc) > qxmin(lc)
24134 ELSEIF ( irescalerainopt == 2 ) THEN
24135 wtest = qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < rescale_wthresh
24136 ELSEIF ( irescalerainopt == 3 ) THEN
24137 wtest = temcg(mgs) > rescale_tempthresh .and. qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < rescale_wthresh
24140 IF ( il == lr .and. ( wtest .or. .not. rescale_low_alphar ) ) THEN
24141 ! certain situations where rain number is adjusted instead of Z. Helps avoid rain being 'zapped' by autoconverted
24142 ! drops (i.e., favor preserving Z when alpha tries to go negative)
24143 chw = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(6./(pi*xdn(mgs,il)))**2 ! g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z1
24145 an(igs(mgs),jy,kgs(mgs),ln(il)) = chw
24147 ! Usual resetting of reflectivity moment to force consisntency between Q, N, Z, and alpha when alpha = alphamin
24148 z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
24149 z = z1*(6./(pi*xdn(mgs,il)))**2
24151 an(igs(mgs),jy,kgs(mgs),lz(il)) = z
24154 ! z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
24155 ! z = z1*(6./(pi*xdn(mgs,il)))**2
24157 ! an(igs(mgs),jy,kgs(mgs),lz(il)) = z
24172 IF ( lzr > 1 ) THEN
24173 alpha2d(igs(mgs),kgs(mgs),1) = Max(alphamin, Min(alphamax, alpha(mgs,lr) ))
24175 IF ( lzh > 1 ) THEN
24176 alpha2d(igs(mgs),kgs(mgs),2) = Max(alphamin, Min(alphamax, alpha(mgs,lh) ))
24178 IF ( lzhl > 1 ) THEN
24179 alpha2d(igs(mgs),kgs(mgs),3) = Max(alphamin, Min(alphamax, alpha(mgs,lhl) ))
24182 IF ( il == lhl .and. lnhlf > 1 ) THEN
24183 ! update chxf in case cx has changed
24184 chxf(mgs,lhl) = frac*cx(mgs,lhl)
24186 IF ( il == lh .and. lnhf > 1 ) THEN
24187 ! update chxf in case cx has changed
24188 chxf(mgs,lh) = frach*cx(mgs,lh)
24192 ! IF ( lf > 0 .and. il == lf .and. kgs(mgs) <= 20 .and. ( cx(mgs,lf) + dtp*( pcfwi(mgs) + pcfwd(mgs) ) > 200. .or. cx(mgs,lf) > 400. )) THEN
24193 ! write(0,*) 'ix,jy, kz, cf = ',igs(mgs)+ixbeg,jy+jybeg,kgs(mgs), an(igs(mgs),jy,kgs(mgs),ln(lf)),lfsave(mgs,5),lfsave(mgs,6)
24194 ! write(0,*) 'qold,qxold,zold,zxold = ',lfsave(mgs,1),lfsave(mgs,2),lfsave(mgs,3),lfsave(mgs,4)
24195 ! write(0,*) 'cf_new,pcfwi,pcfwd = ',cx(mgs,lf),cx(mgs,lf) + dtp*( pcfwi(mgs) + pcfwd(mgs) ),pcfwi(mgs) + pcfwd(mgs)
24201 ! CALL cld_cpu('Z-DELABK')
24204 ! CALL cld_cpu('Z-DELABK')
24216 IF ( il == lh ) THEN
24217 IF ( lnhf > 1 ) THEN ! number of graupel from frozen drops
24218 an(igs(mgs),jy,kgs(mgs),lnhf) = Max( chxf(mgs,lh), 0.0)
24222 IF ( il == lhl ) THEN
24224 IF ( lnhlf > 1 ) THEN ! number of hail from frozen drops
24225 ! an(igs(mgs),jy,kgs(mgs),lnhlf) = Min( cx(mgs,lhl), Max( chxf(mgs,lhl), 0.0) )
24226 an(igs(mgs),jy,kgs(mgs),lnhlf) = Max( chxf(mgs,lhl), 0.0)
24229 an(igs(mgs),jy,kgs(mgs),ln(il)) = Max(cx(mgs,il), 0.0)
24234 IF ( lcin > 1 ) THEN
24236 an(igs(mgs),jy,kgs(mgs),lcin) = Max(0.0, ccin(mgs))
24240 IF ( ipconc .ge. 2 ) THEN
24242 IF ( lss > 1 ) THEN
24243 an(igs(mgs),jy,kgs(mgs),lss) = Max(0.0, ssmax(mgs) )
24246 IF ( lccn > 1 ) THEN
24247 an(igs(mgs),jy,kgs(mgs),lccn) = Max(0.0, ccnc(mgs) )
24252 ELSEIF ( ipconc .eq. 0 .and. lni .gt. 1 ) THEN
24255 an(igs(mgs),jy,kgs(mgs),lni) = Max(cx(mgs,li), 0.0)
24265 IF ( lvol(il) .ge. 1 ) THEN
24269 an(igs(mgs),jy,kgs(mgs),lvol(il)) = Max( 0.0, vx(mgs,il) )
24282 if (ndebug .gt. 0 ) write(0,*) 'gs 12'
24286 if (ndebug .gt. 0 ) write(0,*) 'gs 13'
24290 if ( kz .gt. nz-1 .and. ix .ge. itile) then
24291 if ( ix .ge. itile ) then
24292 go to 1200 ! exit gather scatter
24300 if ( ix .ge. itile ) then
24310 ! end of gather scatter (for this jy slice)
24315 end subroutine nssl_2mom_gs
24317 !--------------------------------------------------------------------------
24323 !--------------------------------------------------------------------------
24327 END MODULE module_mp_nssl_2mom