1 !WRF:MODEL_LAYER:PHYSICS
4 ! prepocessed on "Sep 7 2021" at "19:37:43"
13 !---------------------------------------------------------------------
14 ! IMPORTANT: Best results are attained using the 5th-order WENO (Weighted Essentially Non-Oscillatory) advection option (4) for scalars:
16 ! scalar_adv_opt = 4, (can also use option 3, which is WENO without the positive definite filter)
17 ! The WENO-5 scheme provides a 5th-order (horizontal and vertical) adaptive weighting of components that
18 ! better preserve monotinicity in strong gradients. The standard 5th-order formulation is prone to undershoots
19 ! (negative values) of mass and number concentrations at cloud edges. The WENO scheme helps
20 ! to prevent undershoots and results in less noise at cloud and reflectivity boundaries. This is particularly
21 ! useful for multi-moment schemes to preserve relationships between mass and number concentration. An option is also available
22 ! for WENO-5 advection of momentum, but this can result in excessive damping of poorly-resolved features. For both scalar and momentum
23 ! 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)
24 ! RK step. Option 3 applies the WENO-5, and option 4 adds the positive definite filter (as also used in option 1).
26 ! WENO references: Jiang and Shu, 1996, J. Comp. Phys. v. 126, 202-223; Shu 2003, Int. J. Comp. Fluid Dyn. v. 17 107-118;
28 ! This module provides a 2-moment bulk microphysics scheme originally
29 ! developed by Conrad Ziegler (Zeigler, 1985, JAS) and modified/upgraded in
30 ! in Mansell, Zeigler, and Bruning (2010, JAS). Two-moment adaptive sedimentation
31 ! follows Mansell (2010, JAS), using parameter infall = 4.
33 ! Added info on graupel density and soaking is in Mansell and Ziegler (2013, JAS)
35 ! Average graupel particle density is predicted, which affects fall speed as well.
36 ! Hail density prediction is by default disabled in this version, but may be enabled
37 ! at some point if there is interest.
39 ! Maintainer: Ted Mansell, National Severe Storms Laboratory <ted.mansell@noaa.gov>
41 ! Microphysics References:
43 ! Mansell, E. R., C. L. Ziegler, and E. C. Bruning, 2010: Simulated electrification of a small
44 ! thunderstorm with two-moment bulk microphysics. J. Atmos. Sci., 67, 171-194, doi:10. 1175/2009JAS2965.1.
46 ! Mansell, E. R. and C. L. Ziegler, 2013: Aerosol effects on simulated storm electrification and
47 ! precipitation in a two-moment bulk microphysics model. J. Atmos. Sci., 70 (7), 2032-2050,
48 ! doi:10.1175/JAS-D-12-0264.1.
50 ! Ziegler, C. L., 1985: Retrieval of thermal and microphysical variables in observed convective storms.
51 ! Part I: Model development and preliminary testing. J. Atmos. Sci., 42, 1487-1509.
53 ! Sedimentation reference:
55 ! Mansell, E. R., 2010: On sedimentation and advection in multimoment bulk microphysics.
56 ! J. Atmos. Sci., 67, 3084-3094, doi:10.1175/2010JAS3341.1.
58 ! Possible parameters to adjust:
60 ! ccn : base cloud condensation nuclei concentration (use namelist.input value "nssl_cccn")
61 ! alphah, alphahl : Size distribution shape parameters for graupel (h) and hail (hl)
62 ! infall : changes sedimentation options to see effects (see below)
64 ! lightning model references:
66 ! Fierro, A. O., E.R. Mansell, C. Ziegler and D. R. MacGorman 2013: The
67 ! implementation of an explicit charging and discharge lightning scheme
68 ! within the WRF-ARW model: Benchmark simulations of a continental squall line, a
69 ! tropical cyclone and a winter storm. Monthly Weather Review, Volume 141, 2390-2415
71 ! Mansell et al. 2005: Charge structure and lightning sensitivity in a simulated
72 ! multicell thunderstorm. J. Geophys. Res., 110, D12101, doi:10.1029/2004JD005287
74 ! Note: Some parameters below apply to unreleased features.
77 !---------------------------------------------------------------------
80 ! Restored previous formulation of snow reflectivity, as it was realized that the last change incorrectly assumed a fixed density independent of size. Generally lower snow reflectivity values as a result (no effect on microphysics)
82 ! Generic fall speed coeffecients (axx,bxx) to accomodate future frozen drops category (no effect)
83 ! Reordered collection coefficients (dab1lh) to be consistent (no effect)
84 ! Switched to full calculation of rain number loss via collection by graupel (chacr; to be consisted with collection by hail) (minor effects)
85 !---------------------------------------------------------------------
88 ! Fall speed air density factor limited to air density of 0.05 (for very high model top) to mitigate excessive fall speeds
89 ! Fixed issue of spurious creation of large concentrations of very small droplets and transient large condensation (also increased minimum droplet size)
90 ! Fixed issue of negligible "seed" values of graupel from Bigg freezing at relatively high temperatures (thanks to S. Lasher-Trapp)
91 ! Minor bug fix in effective radius calculation of snow. (thanks to T. Iguchi)
93 ! Enabled regeneration of CCN by droplet evaporation and background restore (default time constant of 3600s)
94 ! 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).
95 ! Enabled radar reflectivity from cloud ice (new formulation) ( idbzci = 1 )
96 ! Added internal option for ice crystal nucleation by DeMott et al. (2010, PNAS) (inucopt=4)
97 ! Allow greater fraction of hail to melt in one time step
98 ! Reduced minimum number concentration from 1e-4 to 1e-8 (based on CAPS input)
99 ! Added internal namelist for easier access to internal variables for development/testing and easier setup for ensemble microphysics diversity
100 ! (namelist read is disabled by default)
101 ! Increased resolution of lookup table for incomplete gamma functions
103 !---------------------------------------------------------------------
106 ! - Effective radius calculation was only done at history times. Now every time step (though should be just before radiation is called)
107 ! - Snow reflectivity: Previous "fix" was incorrect and yields snow dBZ that is too low. Reverted to old version which was correct
108 ! - Incorrectly updated a state value in the reflectivity code. (Could cause small differences if reflectivity is not calculated)
110 ! - 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.
111 ! - Graupel and hail drag coefficients are returned from fall speed subroutine to use in ventilation coeffs. for consistency (minor change)
112 ! - Added (compile) option flag to turn on diagnosis of cloud droplet shape parameter based on number concentration
113 ! - Added (compile) option flag icracr to turn off rain self-collection
114 ! - 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
115 ! - Put limit on snow volume (2 cm) in aggregation rate
116 !---------------------------------------------------------------------
119 ! Fixed excessive sublimation that could occur in very strong downdrafts (3.9.1.1 update)
122 ! icefallopt=3 : New ice crystal fall speed that has faster speeds for small ice particles. Main effect
123 ! is on anvil clouds to help them decay a bit faster. Old behavior can be recovered with icefallopt=1
124 ! Cosmetic: removed stray single quotes because some preprocessors complain about unclosed quotes even in comments
126 !---------------------------------------------------------------------
127 ! WRF 3.9.1.1 update:
129 ! Added a check on overdepletion of ice by sublimation, which could sometimes result in water supersaturation
130 ! Bug fix: setting of t7 used 'dn' instead of 'dn1' (Thanks to Chunxi Zhang)
132 !---------------------------------------------------------------------
135 ! 2-moment scheme now creates number concentration tendencies from cumulus scheme mass mixing ratio rates
136 ! Renamed internal gamma function routine from 'gamma' to 'gamma_sp' to avoid name conflicts
137 ! Restored older settings that allow snow aggregation starting at T > -25C
138 ! Adjusted Meyers number of activated nuclei by the local air density to compensate for using data at surface
139 ! Minor updates to rain-ice crystal and hail-rain collection efficiencies
142 ! Reduced minimum mean snow diameter from 100 microns to 10 microns
144 !---------------------------------------------------------------------
146 ! Fixed issue with reflectivity conservation for graupel melting into rain. Rain number concentrations were too low,
147 ! resulting in excessive reflectivity of a couple dBZ
148 ! Changed default value of iusewetgraupel to 1 (turns off diagnostic meltwater on graupel for reflectivity)
149 ! Apply a 70 m/s fall speed limit for sedimentation
150 ! Changed vapor ice nucleation to Meyers-Ferrier method (original scheme)
151 ! New method for Bigg freezing (ibiggopt=2)
152 ! Reduced snow aggregration efficiency and restricted aggregation to higher temperatures (assuming dendrites and mechanical aggregation)
153 ! Increased maximum graupel-droplet collection efficiency when hail is turned off (nssl_2momg)
154 ! Updates for compatibility with WRF-NMM
155 ! Added calculation of hail number concentration in calcnfromq (creates number concentration from mixing ratio
156 ! when starting from an analysis). And fixed error in graupel intercept
157 ! Bug fix in snow fall speeds
158 ! Further fix in snow reflectivity
159 ! Use diameter of maximum mass rather than mean diamter when checking maximum size
160 ! Helped performance in sedimentation with flag "do_accurate_sedimentation" to control recalculation of fall speeds when
161 ! more than one sub-time step is needed (often happens with large time steps and small dz near the ground):
162 ! = .true. : recalculates fall speed after each substep (more accurate)
163 ! = .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
164 ! Increased maximum mean droplet radius from 40 to 60 microns, which alleviates spurious number concentration increases at low CCN concentration.
165 ! Removed a duplicate factor from hail reflectivity that was causing a loss of about 6 dBZ (since WRF 3.5).
167 !---------------------------------------------------------------------
171 MODULE module_mp_nssl_2mom
175 public nssl_2mom_driver
176 public nssl_2mom_init
177 private gamma_sp,gamxinf,GAML02, GAML02d300, GAML02d500, fqvs, fqis
178 private gamma_dp, gamxinfdp, gamma_dpr
179 private delbk, delabk
182 logical, private :: cleardiag = .false.
185 #if ( WRF_CHEM == 1 )
186 integer, parameter :: wrfchem_flag = 1
188 integer, parameter :: wrfchem_flag = 0
191 LOGICAL, PRIVATE:: is_aerosol_aware = .false.
193 logical, private :: turn_on_cin = .false.
195 integer, private :: eqtset = 1 ! Flag for use with cm1 to use alternate equation set (changes latent heating rates)
196 ! value of > 2 invokes the equivalent version of eqtset=2 that applies updates to both theta and Pi.
197 double precision, parameter, public :: zscale = 1.0d0 ! 1.000e-10
198 double precision, parameter, public :: zscaleinv = 1.0d0/zscale ! 1.000e-10
201 real, parameter :: warmonly = 0.0 ! testing parameter, set to 1.0 to reduce to warm-rain physics (ice variables stay zero)
203 logical, parameter :: lwsm6 = .false. ! act like wsm6 for some single moment interactions
205 ! some constants from WSM6
206 real, parameter :: dimax = 500.e-6 ! limited maximum value for the cloud-ice diamter
207 real, parameter :: roqimax = 2.08e22*dimax**8
210 integer :: iuseferrier = 1 ! =1: use dry graupel only from Ferrier 1994; = 0: Use Smith (wet graupel)
211 integer :: idbzci = 1
212 integer :: iusewetgraupel = 1 ! =1 to turn on use of QHW for graupel reflectivity (only for ZVDM -- mixedphase)
213 ! =2 turn on for graupel density less than 300. only
214 integer :: iusewethail = 0 ! =1 to turn on use of QHW for graupel reflectivity (only for ZVDM -- mixedphase)
215 integer :: iusewetsnow = 1 ! =1 to turn on diagnosed bright band; =2 'old' snow reflectivity (dry), =3 'old' snow dbz + brightband
219 real, private :: rho_qr = 1000., cnor = 8.0e5 ! cnor is set in namelist!! rain params
220 real, private :: rho_qs = 100., cnos = 3.0e6 ! set in namelist!! snow params
221 real, private :: rho_qh = 500., cnoh = 4.0e5 ! set in namelist!! graupel params
222 real, private :: rho_qhl= 900., cnohl = 4.0e4 ! set in namelist!! hail params
224 real, private :: hdnmn = 170.0 ! minimum graupel density (for variable density graupel)
225 real, private :: hldnmn = 500.0 ! minimum hail density (for variable density hail)
227 real :: cnohmn = 1.e-2 ! minimum intercept for 2-moment graupel (alphah < 0.5)
228 real :: cnohlmn = 1.e-2 ! minimum intercept for 2-moment hail (alphahl < 0.5)
230 ! Autoconversion parameters
232 real , private :: qcmincwrn = 2.0e-3 ! qc threshold for autonconversion (LFO; for 10ICE use qminrncw for ircnw != 5)
233 real , private :: cwdiap = 20.0e-6 ! threshold diameter of cloud drops (Ferrier 1994 autoconversion)
234 real , private :: cwdisp = 0.15 ! assume droplet dispersion parameter (can be 0.3 for maritime)
235 real , private :: ccn = 0.6e+09 ! set in namelist!! Central plains CCN value
236 real , public :: qccn ! ccn "mixing ratio"
237 integer, private :: iauttim = 1 ! 10-ice rain delay flag
238 real , private :: auttim = 300. ! 10-ice rain delay time
239 real , private :: qcwmntim = 1.0e-5 ! 10-ice rain delay min qc for time accrual
242 ! NMM WRF core does not have special boundary conditions for CCN, therefore set invertccn to true
243 logical, parameter :: invertccn = .true. ! =true for base state of ccn=0, =false for ccn initialized in the base state
245 logical, parameter :: invertccn = .false. ! =true for base state of ccn=0, =false for ccn initialized in the base state
247 logical :: restoreccn = .true. ! whether or not to nudge CCN back to base state (qccn) (only applies if CCNA is NOT predicted)
248 real :: ccntimeconst = 3600. ! time constant for CCN restore (either for CCNA or when restoreccn = true)
250 ! sedimentation flags
251 ! itfall -> 0 = 1st order fallout (other options removed)
252 ! iscfall, infall -> fallout options for charge and number concentration, respectively
253 ! 1 = mass-weighted fall speed; 2 = number-weighted fallspeed.
254 integer, private :: itfall = 0
255 integer, private :: iscfall = 1
256 integer, private :: irfall = -1
257 logical, private :: do_accurate_sedimentation = .false. ! if true, recalculate fall speeds on sub time steps; (more expensive)
258 ! if false, reuse fall speeds on multiple steps (can have a noticeable speedup)
259 ! Mainly is an issue for small dz near the surface.
260 integer, private :: interval_sedi_vt = 1 ! interval for recalculating Vt in sedimentation subloop (only when do_accurate_sedimentation = .true.)
261 integer, private :: infall = 4 ! 0 -> uses number-wgt for N; NO correction applied (results in excessive size sorting)
262 ! 1 -> uses mass-weighted fallspeed for N ALWAYS
263 ! 2 -> uses number-wgt for N and mass-weighted correction for N (Method II in Mansell, 2010 JAS)
264 ! 3 -> uses number-wgt for N and Z-weighted correction for N (Method I in Mansell, 2010 JAS)
265 ! 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)
266 ! 5 -> uses number-wgt for N and uses average of N-wgt and q-wgt instead of Max.
267 real, private :: rainfallfac = 1.0 ! factor to adjust rain fall speed (single moment only)
268 real, private :: icefallfac = 1.0 ! factor to adjust ice fall speed
269 real, private :: snowfallfac = 1.0 ! factor to adjust snow fall speed
270 real, private :: graupelfallfac = 1.0 ! factor to adjust graupel fall speed
271 real, private :: hailfallfac = 1.0 ! factor to adjust hail fall speed
272 integer, private :: icefallopt = 3 ! 1= default, 2 = Ferrier ice fall speed; 3 = adjusted Ferrier (slightly high Vt)
273 integer, private :: icdx = 3 ! (graupel) 0=Ferrier; 1=leave drag coef. cd fixed; 2=vary by density, 4=set by user with cdxmin,cdxmax,etc.
274 integer, private :: icdxhl = 3 ! (hail) 0=Ferrier; 1=leave drag coef. cd fixed; 2=vary by density, 4=set by user with cdxmin,cdxmax,etc.
275 real , private :: cdhmin = 0.45, cdhmax = 0.8 ! defaults for graupel (icdx=4)
276 real , private :: cdhdnmin = 500., cdhdnmax = 800.0 ! defaults for graupel (icdx=4)
277 real , private :: cdhlmin = 0.45, cdhlmax = 0.6 ! defaults for hail (icdx=4)
278 real , private :: cdhldnmin = 500., cdhldnmax = 800.0 ! defaults for hail (icdx=4)
279 real , private :: vtmaxsed = 70. ! Limit on fall speed (m/s, all moments) for sedimentation calculations. Not applied to fall speeds for microphysical rates
281 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
282 integer :: sssflg = 1 ! As above but for snow
283 integer :: hssflg = 1 ! As above but for graupel
284 integer :: hlssflg = 1 ! As above but for hail
288 integer, private :: ndebug = -1, ncdebug = 0
289 integer, private :: ipconc = 5
290 integer, private :: inucopt = 0
291 integer, private :: ichaff = 0
292 integer, parameter :: ilimit = 0
294 real, private :: constccw = -1.
296 real, private :: cimn = 1.0e3, cimx = 1.0e6
298 real , private :: rhofrz = 900 ! density of freezing drops
299 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
300 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
301 real , private :: ifrzs = 1.0 ! fraction of small frozen drops going to snow. 1=freeze rain to snow, 0=freeze to cloud ice
302 real , private :: ffrzs = 0.0 ! fraction of other initiated cloud ice going to snow. 1=freeze rain to snow, 0=freeze to cloud ice
303 real , private :: f2h = 1.0 ! fraction of cloud ice conversion going to graupel (vs. frozen drops). For testing
304 integer, private :: irwfrz = 1 ! compute total rain that can freeze (checks heat budget)
305 integer, private :: irimtim = 0 ! future use
306 ! integer, private :: infdo = 1 ! 1 = calculate number-weighted fall speeds
308 integer, private :: irimdenopt = 1 ! = 1 for default Macklin; = 2 for experimental Cober and List (1993)
309 real , private :: rimc1 = 300.0, rimc2 = 0.44 ! rime density coeff. and power (Default Heymsfield and Pflaum, 1985)
310 real , private :: rimc3 = 170.0 ! minimum rime density
311 real :: rimc4 = 900.0 ! maximum rime density
312 real , private :: rimtim = 120.0 ! cut-off rime time (10ICE)
313 real , private :: eqtot = 1.0e-9 ! threshold for mass budget reporting
314 real, private :: rimdenvwgt = 0.0 ! weight (0-1) given to number-weighted fall speed when calculating rime density
316 integer, private :: ireadmic = 0
318 integer, private :: idiagnosecnu = 0 ! =1 to diagnose cnu based on Chandrakar et al. 2016 data; =2 for Geoffroy et al. (2010, ACP)
319 integer, private :: iccwflg = 1 ! sets max size of first droplets in parcel to 4 micron radius (in two-moment liquid)
320 ! (first nucleation is done with a KW sat. adj. step)
321 integer, private :: issfilt = 0 ! flag to turn on filtering of supersaturation field
322 integer, private :: icnuclimit = 0 ! limit droplet nucleation based on Konwar et al. (2012) and Chandrakar et al. (2016)
323 integer, private :: irenuc = 2 ! =1 to always allow renucleation of droplets within the cloud
324 ! =2 renucleation following Twomey/Cohard&Pinty
325 ! =7 New renucleation that requires prediction of the number of activated nuclei
326 ! i.e., not only at cloud base
327 integer, private :: irenuc3d = 0 ! =1 to include horizontal gradient in renucleation of droplets within the cloud
328 real :: renucfrac = 0.0 ! = 0 : cnuc = cwccn
329 ! = 1 : cnuc = actual available CCN
330 ! otherwise cnuc = cwccn*(1. - renufrac) + ccnc(1:ngscnt)*renucfrac
331 real :: ssf2kmax = 10. ! max value for ssf**cck in irenuc=4 or 5
332 real , private :: cck = 0.6 ! exponent in Twomey expression
333 real , private :: ciintmx = 1.0e6 ! limit on ice concentration from primary nucleation
335 real , private :: cwccn ! , cwmasn,cwmasx
336 real , private :: ccwmx
338 integer, private :: idocw = 1, idorw = 1, idoci = 1, idoir = 1, idoip = 1, idosw = 1
339 integer, private :: idogl = 1, idogm = 1, idogh = 1, idofw = 1, idohw = 1, idohl = 1
340 ! integer, private :: ido(3:14) = / 12*1 /
343 ! 0,2, 5.00e-10, 1, 0, 0, 0 : itype1,itype2,cimas0,icfn,ihrn,ibfc,iacr
344 integer, private :: itype1 = 0, itype2 = 2 ! controls Hallett-Mossop process
345 integer, private :: icenucopt = 1 ! =1 Meyers/Ferrier primary ice nucleation; =2 Thompson/Cooper, =3 Phillips (Meyers/Demott), =4 DeMott (2010)
346 real, private :: naer = 1.0e6 ! background large aerosol conc. for DeMott
347 integer, private :: icfn = 2 ! contact freezing: 0 = off; 1 = hack (ok for single moment); 2 = full Cotton/Meyers version
348 integer, private :: ihrn = 0 ! Hobbs-Rangno ice multiplication (Ferrier, 1994; use in 10-ice only)
349 integer, private :: ibfc = 1 ! Flag to use Bigg freezing on droplets (0 = off (uses alternate freezing), 1 = on)
350 real, private :: cwfrz2snowfrac = 0.0 ! fraction of freezing droplet mass to send to snow
351 real, private :: cwfrz2snowratio = 5. ! Assumed number of frozen droplets in a cluster
352 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
353 integer, private :: iacr = 2 ! Flag for drop contact freezing with crytals
354 ! (0=off; 1=drops > 500micron diameter; 2 = > 300micron)
355 integer, private :: icracr = 1 ! Flag to turn rain self-collection on/off (=0 to turn off)
356 integer, private :: ibfr = 2 ! Flag for Bigg freezing conversion of freezing drops to graupel
357 ! (1=min graupel size is vr1mm; 2=use min size of dfrz, 5= as for 2 and apply dbz conservation)
358 integer, private :: ibiggopt = 2 ! 1 = old Bigg; 2 = experimental Bigg (only for imurain = 1, however)
359 integer :: ibiggsmallrain = 0 ! 1 = When rain is too small, freeze none to graupel and send all to snow (experimental)
360 integer, private :: iacrsize = 5 ! assumed min size of drops freezing by capture
361 ! 1: > 500 micron diam
365 ! 5: > 150 micron (only for imurain = 1)
366 real , private :: cimas0 = 6.62e-11 ! default mass of Hallett-Mossop crystals
367 ! 6.62e-11kg results in half the diam. (60 microns) of old default value of 5.0e-10
368 real , private :: cimas1 = 6.88e-13 ! default mass of new ice crystals
369 real , private :: splintermass = 6.88e-13
370 real , private :: cfnfac = 0.1 ! Hack factor that goes with icfn=1
371 integer, private :: iscni = 4 ! default option for ice crystal aggregation/conversion to snow
372 real , private :: fscni = 1.0 ! factor for calculating cscni
373 logical, private :: imeyers5 = .false. ! .false.=off, true=on for Meyers ice nucleation for temp > -5 C
374 real , private :: dmincw = 15.0e-6 ! minimum droplet diameter for collection for iehw=3
375 integer, private :: iehw = 1 ! 0 -> ehw=ehw0; 1 -> old ehw; 2 -> test ehw with Mason table data
376 integer, private :: iefw = 1 ! 0 -> ehw=ehw0; 1 -> old ehw; 2 -> test ehw with Mason table data
377 integer, private :: iehlw = 1 ! 0 -> ehlw=ehlw0; 1 -> old ehlw; 2 -> test ehlw with Mason table data
378 ! For ehw/ehlw = 1, ehw0/ehlw0 act as maximum limit on collection efficiency (defaults are 1.0)
379 integer, private :: ierw = 1 ! for single-moment rain (LFO/Z)
380 integer, private :: iehr0c = 0 ! 0 -> no collection for T > 0C; 1 -> turn on collection/shedding for T > 0C
381 integer, private :: iehlr0c = 0 ! 0 -> no collection for T > 0C; 1 -> turn on collection/shedding for T > 0C
382 real , private :: ehw0 = 0.5 ! constant or max assumed graupel-droplet collection efficiency
383 real , private :: erw0 = 1.0 ! constant assumed rain-droplet collection efficiency
384 real , private :: ehlw0 = 0.75 ! constant or max assumed hail-droplet collection efficiency
385 real , private :: efw0 = 0.5 ! constant or max assumed graupel-droplet collection efficiency
386 real :: ehr0 = 1.0 ! constant or max assumed graupel-rain collection efficiency
387 real :: efr0 = 1.0 ! constant or max assumed graupel-rain collection efficiency
388 real :: ehlr0 = 1.0 ! constant or max assumed hail-rain collection efficiency
389 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)
392 real , private :: esilfo0 = 1.0 ! factor for LFO collection efficiency of snow for cloud ice.
393 real , private :: ehslfo0 = 1.0 ! factor for LFO collection efficiency of hail/graupel for snow.
395 integer, private :: ircnw = 5 ! single-moment warm-rain autoconversion option. 5= Ferrier 1994.
396 real , private :: qminrncw = 2.0e-3 ! qc threshold for rain autoconversion (NA for ircnw=5)
398 integer, private :: iqcinit = 2 ! For ZVDxx schemes, flag to choose which way to initialize droplets
399 ! 1 = Soong-Ogura adjustment
400 ! 2 = Saturation adjustment to value of ssmxinit
403 real , private :: ssmxinit = 0.4 ! saturation percentage to adjust down to for initial cloud
404 ! formation (ZVDxx scheme only)
406 real , private :: ewfac = 1.0 ! hack factor applied to graupel and hail collection eff. for droplets
407 real , private :: eii0 = 0.1 ,eii1 = 0.1 ! graupel-crystal coll. eff. parameters: eii0*exp(eii1*min(temcg(mgs),0.0))
408 ! set eii1 = 0 to get a constant value of eii0
409 real , private :: eii0hl = 0.2 ,eii1hl = 0.0 ! hail-crystal coll. eff. parameters: eii0hl*exp(eii1hl*min(temcg(mgs),0.0))
410 ! set eii1hl = 0 to get a constant value of eii0hl
411 real , private :: eri0 = 0.1 ! rain efficiency to collect ice crystals
412 real , private :: eri_cimin = 10.e-6 ! minimum ice crystal diameter for collection by rain
413 real , private :: esi0 = 0.1 ! linear factor in snow-ice collection efficiency
414 real , private :: ehs0 = 0.1, ehs1 = 0.1 ! graupel-snow coll. eff. parameters: ehs0*exp(ehs1*min(temcg(mgs),0.0))
415 ! set ehs1 = 0 to get a constant value of ehs0
416 real , private :: ess0 = 1.0, ess1 = 0.05 ! snow aggregation coefficients: ess0*exp(ess1*min(temcg(mgs),0.0))
417 ! set ess1 = 0 to get a constant value of ess0
418 real , private :: esstem1 = -25. ! lower temperature where snow aggregation turns on
419 real , private :: esstem2 = -20. ! higher temperature for linear ramp of ess from zero at esstem1 to formula value at esstem2
420 real , private :: essrmax = 0.02 ! maximum snow radius (meters) for csacs
421 real , private :: essfrac1 = 0.5 ! snow mass fraction 1 for aggregation roll-off
422 real , private :: essfrac2 = 0.75 ! snow mass fraction 2 for aggregation roll-off
423 integer, private :: iessec0flag = 0 ! flag to activate aggregation roll-off
424 real , private :: ehsfrac = 1.0 ! multiplier for graupel collection efficiency in wet growth
425 real , private :: ehimin = 0.0 ! Minimum collection efficiency (graupel - ice crystal)
426 real , private :: ehimax = 1.0 ! Maximum collection efficiency (graupel - ice crystal)
427 real , private :: ehsmax = 0.5 ! Maximum collection efficiency (graupel - snow)
428 real , private :: ecollmx = 0.5 ! Maximum collision efficiency for graup/hail with ice; used only for charging rates
429 integer, private :: iglcnvi = 1 ! flag for riming conversion from cloud ice to rimed ice/graupel
430 integer, private :: iglcnvs = 2 ! flag for conversion from snow to rimed ice/graupel
432 real , private :: rz ! reflectivity conservation factor for graupel/rain
433 ! now calculated in icezvd_dr.F from alphah and rnu
434 ! currently only used for graupel melting to rain
435 real , private :: rzhl ! reflectivity conservation factor for hail/rain
436 ! now calculated in icezvd_dr.F from alphahl and rnu
438 real , private :: rzs ! reflectivity conservation factor for snow(imusnow=3) with rain (imurain=1)
440 real , private :: alphahacx = 0.0 ! assumed minimum shape parameter for zhacw and zhacr
442 real , private :: fconv = 1.0 ! factor to boost max graupel depletion by riming conversions in 10ICE
444 real , private :: rg0 = 400.0 ! reference graupel density for graupel fall speed
446 integer, private :: rcond = 2 ! (Z only) rcond = 2 includes rain condensation in loop with droplet condensation
447 ! 0 = no condensation on rain; 1 = bulk condensation on rain
448 integer, parameter, private :: icond = 1 ! (Z only) icond = 1 calculates ice deposition (crystals and snow) BEFORE droplet condensation
449 ! icond = 2 does not work (intended to calc. dep in loop with droplet cond.)
451 real , private :: dfrz = 0.15e-3 ! 0.25e-3 ! minimum diameter of frozen drops from Bigg freezing (used for vfrz) for iacr > 1
452 ! and for ciacrf for iacr=4
453 real , private :: dmlt = 3.0e-3 ! maximum diameter for rain melting from graupel and hail
454 real , private :: dshd = 1.0e-3 ! nominal diameter for rain drops shed from graupel/hail
455 integer, private :: ished2cld = 0 ! 1: Send shed liquid (from wet growth) to cloud droplets
457 integer, private :: ihmlt = 2 ! 1=old melting with vmlt; 2=new melting using mean volume diam of graupel/hail
458 integer, private :: imltshddmr = 2 ! 0 (default)=mean diameter of drops produced during melting+shedding as before (using mean diameter of graupel/hail
459 ! and max mean diameter of rain)
460 ! 1=new method where mean diameter of rain during melting is adjusted linearly downward
461 ! toward 3 mm for large (> sheddiam) graupel and hail, to take into account shedding of
462 ! smaller drops. sheddiam0 controls the size of graupel/hail above which the assumed
463 ! mean diameter of rain is set to 3 mm
464 ! Only valid for ihmlt = 2 for ZVD(H) but also applies to ZVD(H)M
465 ! 2 = method that sets the resulting rain size ( vshdgs ) according to the mass-weighted diameter of the ice
467 real :: mltdiam1 = 9.0e-3, mltdiam2 = 16.0e-3, mltdiam3 = 19.0e-3, mltdiam4 = 200.0e-3, mltdiam05 = 4.5e-3
469 integer, private :: nsplinter = 0 ! number of ice splinters per freezing drop, if negative, then per resulting graupel particle
470 real, private :: lawson_splinter_fac = 2.5e-11 ! constant in Lawson et al. (2015, JAS) for ice particle production from freezing drops
471 integer, private :: isnwfrac = 0 ! 0= no snow fragmentation; 1 = turn on snow fragmentation (Schuur, 2000)
473 ! integer, private :: denscale = 1 ! 1=scale num. conc. and charge by air density for advection, 0=turn off for comparison
475 real, private :: qhdpvdn = -1.
476 real, private :: qhacidn = -1.
478 logical, private :: mixedphase = .false. ! .false.=off, true=on to include mixed phase graupel
479 integer, private :: imixedphase = 0
480 logical, private :: qsdenmod = .false. ! true = modify snow density by linear interpolation of snow and rain density
481 logical, private :: qhdenmod = .false. ! true = modify graupel density by linear interpolation of graupel and rain density
482 logical, private :: qsvtmod = .false. ! true = modify snow fall speed by linear interpolation of snow and rain vt
483 real , private :: sheddiam = 8.0e-03 ! minimum diameter of graupel before shedding occurs
484 real :: sheddiamlg = 10.0e-03 ! diameter of hail to use fwmlarge
485 real :: sheddiam0 = 20.0e-03 ! diameter of hail at which all water is shed
487 integer :: ifwmhopt = 2 ! option for calculating maximum liquid fraction when fwmh and/or fwmhl is set to -1
488 ! 1 = maximum based on size of maximum mass diameter
489 ! 2 = integrate over spectrum for maximum liquid (experimental)
491 integer :: ihxw2rain = 0 ! = 0 no transfer
492 ! = 1 transfer completely melted (99.5%) graupel/hail to rain when fwmh/fwmhl is set to -1.
494 real , private :: fwms = 0.5 ! maximum liquid water fraction on snow
495 real , private :: fwmh = 0.5 ! maximum liquid water fraction on graupel
496 real , private :: fwmhl = 0.5 ! maximum liquid water fraction on hail
497 real :: fwmlarge = 0.2 ! maximum liquid water fraction on hail larger than sheddiam
498 integer :: ifwmfall = 0 ! whether to interpolate toward rain fall speed for graupel and hail
499 ! when diam < sheddiam and liquid fraction is predicted (0=no, 1=yes)
501 logical :: rescale_high_alpha = .false. ! whether to rescale number. conc. when alpha = alphamax (3-moment only)
502 logical :: rescale_low_alpha = .true. ! whether to rescale Z (graupel/hail) when alpha = alphamin (3-moment only)
503 logical :: rescale_low_alphar = .true. ! whether to rescale Z for rain when alpha = alphamin (3-moment only)
504 logical :: rescale_low_alphah = .true. ! whether to rescale Z for rain when alpha = alphamin (3-moment only)
505 logical :: rescale_low_alphahl = .true. ! whether to rescale Z for rain when alpha = alphamin (3-moment only)
507 real, parameter :: alpharmax = 8. ! limited for rwvent calculation
509 integer, private :: ihlcnh = 1 ! which graupel -> hail conversion to use
510 ! 1 = Milbrandt and Yau (2005) using Ziegler 1985 wet growth diameter
511 ! 2 = Straka and Mansell (2005) conversion using size threshold
512 real, private :: hlcnhdia = 1.e-3 ! threshold diameter for graupel -> hail conversion for ihlcnh = 1 option.
513 real, private :: hlcnhqmin = 0.1e-3 ! minimum graupel mass content for graupel -> hail conversion (ihlcnh = 1)
514 real , private :: hldia1 = 20.0e-3 ! threshold diameter for graupel -> hail conversion for ihlcnh = 2 option.
515 integer, private :: iusedw = 0 ! flag to use experimental wet growth ice diameter for gr -> hl conversion (=1 turns on)
516 real , private :: dwmin = 0.0 ! Minimum diameter with iusedw (can stay at 0 or be set to something larger)
517 real , private :: dwtempmin = 242. ! lowest temperature to allow wet growth conversion to hail
518 real , private :: dwehwmin = 0. ! Minimum ehw to use to find wet growth diameter (if > ehw0, then wet growth diam becomes smaller)
519 real , private :: dg0thresh = 0.15 ! graupel wet growth diameter above which we say do not bother
520 integer :: icvhl2h = 0 ! allow conversion of hail back to graupel when hail density gets close to minimum allowed
522 integer, private :: imurain = 1 ! 3 for gamma-volume, 1 for gamma-diameter DSD for rain.
523 integer, private :: imusnow = 3 ! 3 for gamma-volume, 1 for gamma-diameter DSD for snow (=1 NOT IMPLEMENTED!!).
524 integer, private :: iturbenhance = 0 ! warm-rain collision enhancement
525 ! 1 = enhance autoconversion only
526 ! 2 = add rain collection of cloud
527 ! 3 = add rain self-collection
528 integer, private :: isedonly = 0 ! 1= only do sedimentation and skip other microphysics
529 integer, private :: iferwisventr = 2 ! =1 for Ferrier rwvent, =2 for Wisner rwvent (imurain=1)
530 integer, private :: izwisventr = 2 ! =1 for old Ziegler rwvent, =2 for Wisner-style rwvent (imurain=3)
531 integer :: iresetmoments = 0 ! if >0, then set all moments to zero when one of them is zero (3-moment only)
532 integer, private :: imaxdiaopt = 3
533 ! = 1 use mean diameter for breakup
534 ! = 2 use maximum mass diameter for breakup
535 ! = 3 use mass-weighted diameter for breakup
536 integer, private :: dmrauto = 0
537 ! = -1 no limiter on crcnw
538 ! = 0 limit crcnw when qr > 1.2*L (Cohard-Pinty 2002)
539 ! = 1 DTD version based on MY code
540 ! = 2 DTD mass-weighted version based on MY code
541 ! = 3 Milbrandt version (from Cohard and Pinty code
542 integer :: dmropt = 0 ! extra option for crcnw
543 integer :: dmhlopt = 1 ! options for graupel -> conversion
544 integer :: irescalerainopt = 3 ! 0 = default option
545 ! 1 = qx(mgs,lc) > qxmin(lc)
546 ! 2 = qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < 3.0
547 ! 3 = temcg(mgs) > 0.0.and. qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < 3.0
548 real :: rescale_wthresh = 3.0
549 real :: rescale_tempthresh = 0.0
550 real, parameter :: alpharaut = 0.0 ! MY2005 for autoconversion
551 real :: cxmin = 1.e-8 ! threshold cutoff for number concentration
552 real :: zxmin = 1.e-28 ! threshold cutoff for reflectivity moment
554 integer :: ithompsoncnoh = 0 ! For single moment graupel only
555 ! 0 = fixed intercept
556 ! 1 = intercept based on graupel mass
558 integer :: ivhmltsoak = 1 ! 0=off, 1=on : flag to simulate soaking (graupel/hail) during melting
559 ! when liquid fraction is not predicted
560 integer, private :: ioldlimiter = 0 ! test switch for new(=0) or old(=1) size limiter at the end of GS for 3-moment categories
561 integer, private :: isnowfall = 2 ! Option for choosing between snow fall speed parameters
562 ! 1 = original Zrnic et al. (Mansell et al. 2010)
563 ! 2 = Ferrier 1994 (results in slower fall speeds)
565 integer, private :: isnowdens = 1 ! Option for choosing between snow density options
566 ! 1 = constant of 100 kg m^-3
567 ! 2 = Option based on Cox
569 integer, private :: ibiggsnow = 3 ! 1 = switch conversion over to snow for small frozen drops from Bigg freezing
570 ! 2 = switch conversion over to snow for small frozen drops from rain-ice interaction
571 ! 3 = switch conversion over to snow for small frozen drops from both
572 real :: biggsnowdiam = -1.0 ! If >0, use for ibiggsnow threshold
574 integer, private :: ixtaltype = 1 ! =1 column, =2 disk (similar to Takahashi)
576 real, private :: takshedsize1 = 0.15 ! diameter (cm) of drop shed from ice with D > 1.9 cm
577 real, private :: takshedsize2 = 0.3 ! diameter (cm) of drop shed from ice with D < 1.9 cm and D > 0.8 cm
578 real, private :: takshedsize3 = 0.45 ! diameter (cm) of drop shed from ice with D < 1.6 cm and D > 0.8 cm
579 integer, private :: numshedregimes = 3
581 real, private :: evapfac = 1.0 ! Multiplier on rain evaporation rate
582 real, private :: depfac = 1.0 ! Multiplier on graupel/hail deposition/sublimation rate
583 real,private,parameter :: meltfac = 1.0 ! Multiplier on graupel/hail melting rate
585 integer, private :: ibinhmlr = 0 ! =1 use incomplete gammas to determine melting from larger and smaller sizes of graupel, and appropriate shed drop sizes
586 ! =2 to test melting by temporary bins
587 integer, private :: ibinhlmlr = 0 ! =1 use incomplete gammas to determine melting from larger and smaller sizes of hail, and appropriate shed drop sizes
588 ! =2 to test melting by temporary bins
589 integer, private :: ibinnum = 2 ! number of bins for melting of smaller ice (for ibinhmlr = 1)
590 integer, private :: iqhacrmlr = 1 ! turn on/off qhacrmlr
591 integer, private :: iqhlacrmlr = 1 ! turn on/off qhlacrmlr
592 real, private :: binmlrmxdia = 40.e-3 ! threshold diameter (graupel/hail) to switch bin-bulk melting to use standard chmlr
593 real, private :: binmlrzrrfac = 1.0 ! factor for reflectivity change ice that sheds while melting
594 real, private :: snowmeltdia = 0 ! If nonzero, sets the size of rain drops from melting snow.
595 real, private :: delta_alphamlr = 0.5 ! offset from alphamax at which melting does not further collapse the shape parameter
597 integer :: iqvsopt = 0 ! =0 use old default for tabqvs; =1 use Bolton formulation (Rogers and Yau)
599 integer :: imaxsupopt = 4 ! how to treat saturation adjustment in two-moment droplets
600 ! 1 = add droplets with same mean mass as current droplets
601 ! 2 = add droplets with minimum radius of 30 microns
602 ! 3 = only add 1.5*cxmin to number concentration (allow max size to apply)
603 ! 4 = add droplets with minimum radius of 20 microns
604 real :: maxsupersat = 1.9 ! maximum supersaturation ratio, above which a saturation adustment is done
605 real :: ssmxuf = 4.0 ! supersaturation at which to start using "ultrafine" CCN (if ccnuf > 0.)
608 integer, parameter :: icespheres = 0 ! turn ice spheres (frozen droplets) on (1) or off (0). NOT COMPLETE IN WRF/ARPS/CM1 CODE!
609 integer, parameter :: lqmx = 30
610 integer, parameter :: lt = 1
611 integer, parameter :: lv = 2
612 integer, parameter :: lc = 3
613 integer, parameter :: lr = 4
614 integer, parameter :: li = 5
615 integer, private :: lis = 0
616 integer, private :: ls = 6
617 integer, private :: lh = 7
618 integer, private :: lf = 0
619 integer, private :: lhl = 0
621 integer, private :: lccn = 9 ! 0 or 9, other indices adjusted accordingly
622 integer, private :: lccnuf = 0
623 integer, private :: lccna = 0
624 integer, private :: lcina = 0
625 integer, private :: lcin = 0
626 integer, private :: lnc = 9
627 integer, private :: lnr = 10
628 integer, private :: lni = 11
629 integer, private :: lnis = 0
630 integer, private :: lns = 12
631 integer, private :: lnh = 13
632 integer, private :: lnf = 0
633 integer, private :: lnhl = 0
634 integer, private :: lnhf = 0
635 integer, private :: lnhlf = 0
636 integer, private :: lss = 0
639 integer, private :: lhab = 8
640 integer, private :: lg = 7
650 ! integer :: lvh = 16
653 ! liquid water fraction (not predicted here but tested for)
659 integer :: lhlwlg = 0
661 ! reflectivity (6th moment) ! not predicted here but may be tested against
686 integer :: lscpli = 0
687 integer :: lscnli = 0
688 integer :: lschab = 0
694 ! integer, parameter :: lscmx = 100
696 integer :: lne = 0 ! last varible for transforming
698 real :: cnoh0 = 4.0e+5
699 real :: hwdn1 = 700.0
701 real :: alphai = 0.0 ! shape parameter for ZIEG ice crystals ! not currently used
702 real :: alphas = 0.0 ! shape parameter for ZIEG snow ! used only for single moment
703 real :: alphar = 0.0 ! shape parameter for rain (imurain=1 only)
704 real, private :: alphah = 0.0 ! set in namelist!! shape parameter for ZIEG graupel
705 real, private :: alphahl = 1.0 ! set in namelist!! shape parameter for ZIEG hail
707 real :: dmuh = 1.0 ! power in exponential part (graupel)
708 real :: dmuhl = 1.0 ! power in exponential part (hail)
710 real, private :: alphamax = 15.
711 real, private :: alphamin = 0.
712 real, parameter :: rnumin = -0.8
713 real, parameter :: rnumax = 15.0
716 real :: cnu = 0.0 ! default value of droplet shape parameter. Can be diagnosed by setting idiagnosecnu=1
717 real, parameter :: rnu = -0.8, snu = -0.8, cinu = 0.0
718 ! parameter ( cnu = 0.0, rnu = -0.8, snu = -0.8, cinu = 0.0 )
720 real xnu(lc:lqmx) ! 1st shape parameter (mass)
721 real xmu(lc:lqmx) ! 2nd shape parameter (mass)
722 real dnu(lc:lqmx) ! 1st shape parameter (diameter)
723 real dmu(lc:lqmx) ! 2nd shape parameter (diameter)
729 real da0 (lc:lqmx) ! collection coefficients from Seifert 2005
730 real dab0(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
731 real dab1(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
732 real da1 (lc:lqmx) ! collection coefficients from Seifert 2005
735 ! put ipelec here for now....
736 integer :: ipelec = 0
737 integer :: isaund = 0
738 logical :: idoniconly = .false.
739 integer, private :: elec_on_time = -1 ! time (seconds) to turn on charge separation.
740 integer, private :: elec_ramp_time = 0 ! time (interval) for linear ramp after elec_on_time
741 ! (i.e., linear factor on chg sep to smoothly turn on elec)
742 ! full charging rate is achieved at time = elec_on_time + elec_ramp_time
743 integer :: jchgs = 3 ! number of points near boundary where charging is turned off (to keep lightning from getting wonky)
747 real :: charging_border = 4000. ! width of no-charging zone from boundary
748 real, private :: delqnw = -1.0e-10!-1.0e-12 !
749 real, private :: delqxw = 1.0e-10! 1.0e-12 !
750 real :: tindmn = 233, tindmx = 298.0 ! min and max temperatures where inductive charging is allowed
753 ! gamma function lookup table
755 integer ngm0,ngm1,ngm2
756 parameter (ngm0=3001,ngm1=500,ngm2=500)
757 double precision, parameter :: dgam = 0.01, dgami = 100.
758 double precision gmoi(0:ngm0) ! ,gmod(0:ngm1,0:ngm2),gmdi(0:ngm1,0:ngm2)
760 integer, parameter :: nqiacralpha = 240 !480 ! 240 ! 120 ! 15
761 integer, parameter :: nqiacrratio = 100 ! 500 !50 ! 25
762 ! real, parameter :: maxratiolu = 25.
763 real, parameter :: maxratiolu = 100. ! 25.
764 real, parameter :: maxalphalu = 15.
765 real, parameter :: minalphalu = -0.95
766 real, parameter :: dqiacralpha = maxalphalu/Float(nqiacralpha), dqiacrratio = maxratiolu/Float(nqiacrratio)
767 real, parameter :: dqiacrratioinv = 1./dqiacrratio, dqiacralphainv = 1./dqiacralpha
768 integer, parameter :: ialpstart = minalphalu*dqiacralphainv
769 real :: ciacrratio(0:nqiacrratio,ialpstart:nqiacralpha)
770 real :: qiacrratio(0:nqiacrratio,ialpstart:nqiacralpha)
771 real :: ziacrratio(0:nqiacrratio,ialpstart:nqiacralpha)
772 double precision :: gamxinflu(0:nqiacrratio,ialpstart:nqiacralpha,12,2) ! last index for graupel (1) or hail (2)
773 ! real :: ciacrratio(0:nqiacrratio,0:nqiacralpha)
774 ! real :: qiacrratio(0:nqiacrratio,0:nqiacralpha)
775 ! real :: ziacrratio(0:nqiacrratio,0:nqiacralpha)
776 ! double precision :: gamxinflu(0:nqiacrratio,0:nqiacralpha,12,2) ! last index for graupel (1) or hail (2)
778 integer, parameter :: ngdnmm = 9
779 real :: mmgraupvt(ngdnmm,3) ! Milbrandt and Morrison (2013) fall speed coefficients for graupel/hail
781 DATA mmgraupvt(:,1) / 50., 150., 250., 350., 450., 550., 650., 750., 850./
782 DATA mmgraupvt(:,2) / 62.923, 94.122, 114.74, 131.21, 145.26, 157.71, 168.98, 179.36, 189.02 /
783 DATA mmgraupvt(:,3) / 0.67819, 0.63789, 0.62197, 0.61240, 0.60572, 0.60066, 0.59663, 0.59330, 0.59048 /
788 integer lvol(lc:lqmx)
790 integer lliq(li:lqmx)
791 integer denscale(lc:lqmx) ! flag for density scaling (mixing ratio conversion)
797 real xdnmx(lc:lqmx), xdnmn(lc:lqmx)
800 real xvmn(lc:lqmx), xvmx(lc:lqmx)
802 real qxmin_init(lc:lqmx)
805 parameter (nqsat=1000001) ! (nqsat=20001)
807 parameter (fqsat=0.002,fqsati=1./fqsat)
808 real tabqvs(nqsat),tabqis(nqsat),dtabqvs(nqsat),dtabqis(nqsat)
813 real, parameter :: cp608 = 0.608 ! constant used in conversion of T to Tv
814 real, parameter :: ar = 841.99666 ! rain terminal velocity power law coefficient (LFO)
815 real, parameter :: br = 0.8 ! rain terminal velocity power law coefficient (LFO)
816 real, parameter :: aradcw = -0.27544 !
817 real, parameter :: bradcw = 0.26249e+06 !
818 real, parameter :: cradcw = -1.8896e+10 !
819 real, parameter :: dradcw = 4.4626e+14 !
820 real, parameter :: bta1 = 0.6 ! beta-1 constant used for ice nucleation by deposition (Ferrier 94, among others)
821 real, parameter :: cnit = 1.0e-02 ! No for ice nucleation by deposition (Cotton et al. 86)
822 real, parameter :: dragh = 0.60 ! coefficient used to adjust fall speed for hail versus graupel (Pruppacher and Klett 78)
823 real, parameter :: dnz00 = 1.225 ! reference/MSL air density
824 real, parameter :: rho00 = 1.225 ! reference/MSL air density
825 ! cs = 4.83607122 ! snow terminal velocity power law coefficient (LFO)
826 ! ds = 0.25 ! snow terminal velocity power law coefficient (LFO)
827 ! new values for cs and ds
828 real, parameter :: cs = 12.42 ! snow terminal velocity power law coefficient
829 real, parameter :: ds = 0.42 ! snow terminal velocity power law coefficient
830 real, parameter :: pi = 3.141592653589793
831 real, parameter :: piinv = 1./pi
832 real, parameter :: pid4 = pi/4.0
834 real, parameter :: gr = 9.8
837 ! max and min mean volumes
839 real xvrmn, xvrmx0 ! min, max rain volumes
840 real xvsmn, xvsmx ! min, max snow volumes
841 real xvfmn, xvfmx ! min, max frozen drop volumes
842 real xvgmn, xvgmx ! min, max graupel volumes
843 real xvhmn, xvhmn0, xvhmx, xvhmx0 ! min, max hail volumes
844 real xvhlmn, xvhlmx ! min, max lg hail volumes
846 real, parameter :: dhlmn = 0.3e-3, dhlmx = 40.e-3
847 real, parameter :: dhmn0 = 0.3e-3
848 real, private :: dhmn = dhmn0, dhmx = -1.
850 real, parameter :: cwradn = 2.0e-6, xcradmn = cwradn ! minimum radius
851 real, parameter :: cwradx = 60.e-6, xcradmx = cwradx ! maximum radius
852 real, parameter :: cwc1 = 6.0/(pi*1000.)
854 ! parameter( xvcmn=4.188e-18 ) ! mks min volume = 3 micron radius
855 real, parameter :: xvcmn=0.523599*(2.*cwradn)**3 ! mks min volume = 2.5 micron radius
856 real, parameter :: xvcmx=0.523599*(2.*xcradmx)**3 ! mks min volume = 2.5 micron radius
857 real, parameter :: cwmasn = 1000.*xvcmn ! minimum mass, defined by radius of 5.0e-6
858 real, parameter :: cwmasx = 1000.*xvcmx ! maximum mass, defined by radius of 50.0e-6
859 real, parameter :: cwmasn5 = 1000.*0.523599*(2.*5.0e-6)**3 ! 5.23e-13
861 real, parameter :: xvimn=0.523599*(2.*5.e-6)**3 ! mks min volume = 5 micron radius
862 real, parameter :: xvimx=0.523599*(2.*1.e-3)**3 ! mks max volume = 1 mm radius (solid sphere approx)
864 real, private :: xvdmx = -1.0 ! 3.0e-3
866 parameter( xvrmn=0.523599*(80.e-6)**3, xvrmx0=0.523599*(6.e-3)**3 ) !( was 4.1887e-9 ) ! mks
867 parameter( xvsmn=0.523599*(0.01e-3)**3, xvsmx=0.523599*(10.e-3)**3 ) !( was 4.1887e-9 ) ! mks
868 parameter( xvfmn=0.523599*(0.1e-3)**3, xvfmx=0.523599*(10.e-3)**3 ) ! mks xvfmx = (pi/6)*(10mm)**3
869 parameter( xvgmn=0.523599*(0.1e-3)**3, xvgmx=0.523599*(10.e-3)**3 ) ! mks xvfmx = (pi/6)*(10mm)**3
870 parameter( xvhmn0=0.523599*(0.3e-3)**3, xvhmx0=0.523599*(20.e-3)**3 ) ! mks xvfmx = (pi/6)*(20mm)**3
871 parameter( xvhlmn=0.523599*(dhlmn)**3, xvhlmx=0.523599*(dhlmx)**3 ) ! mks xvfmx = (pi/6)*(40mm)**3
874 ! electrical permitivity of air C / (N m**2) - check the units
877 parameter (eperao = 8.8592e-12 )
879 real ec,eci ! fundamental unit of charge
880 parameter (ec = 1.602e-19)
881 parameter (eci = 1.0/ec)
883 real :: scwppmx = 20.0e-12
884 real :: scippmx = 20.0e-12
888 real, parameter :: c1f3 = 1.0/3.0
890 real, parameter :: cai = 21.87455
891 real, parameter :: caw = 17.2693882
892 real, parameter :: cbi = 7.66
893 real, parameter :: cbw = 35.86
895 real, parameter :: cbwbolton = 29.65 ! constants for Bolton formulation
896 real, parameter :: cawbolton = 17.67
898 real, parameter :: tfr = 273.15, tfrh = 233.15
900 real, parameter :: cp = 1004.0, rd = 287.04
901 real, parameter :: cpi = 1./cp
902 real, parameter :: cap = rd/cp, poo = 1.0e+05
904 real, parameter :: rw = 461.5 ! gas const. for water vapor
905 real, parameter :: advisc0 = 1.832e-05 ! reference dynamic viscosity (SMT; see Beard & Pruppacher 71)
906 real, parameter :: advisc1 = 1.718e-05 ! dynamic viscosity constant used in thermal conductivity calc
907 real, parameter :: tka0 = 2.43e-02 ! reference thermal conductivity
908 real, parameter :: tfrcbw = tfr - cbw
909 real, parameter :: tfrcbi = tfr - cbi
911 ! GHB: Needed for eqtset=2 in cm1
912 ! REAL, PRIVATE :: cv = cp - rd
913 real, private, parameter :: cv = 717.0 ! specific heat at constant volume - air
914 REAL, PRIVATE, parameter :: cvv = 1408.5
915 REAL, PRIVATE, parameter :: cpl = 4190.0
916 REAL, PRIVATE, parameter :: cpigb = 2106.0
919 real, parameter :: bfnu0 = (rnu + 2.0)/(rnu + 1.0)
920 real :: ventr, ventrn, ventc, c1sw
923 real :: cckm,ccne,ccnefac,cnexp,CCNE0
927 real gf4p5, gf4ds, gf4br
928 real gsnow1, gsnow53, gsnow73
929 real gfcinu1, gfcinu1p47, gfcinu2p47
930 real gfcinu1p22,gfcinu2p22
931 real gfcinu1p18,gfcinu2p18
933 real :: cwchtmp0 = 1.0
934 real :: cwchltmp0 = 1.0
936 real :: esctot = 1.0e-13
938 integer iexy(lc:lqmx,lc:lqmx)
939 integer :: ieswi = 1, ieswc = 1, ieswr = 0
940 integer :: iehlsw = 1, iehli = 1, iehlc = 1, iehlr = 0
941 integer :: iehwsw = 1, iehwi = 1, iehwc = 1, iehwr = 0
943 logical, parameter :: do_satadj_for_wrfchem = .true.
946 ! Note to users: Many of these options are for development and not guaranteed to perform well.
947 ! Some may not be functional depending on the version of the code.
948 ! Some may be useful for ensemble physics diversity. Feel free to contact me if you have questions
950 NAMELIST /nssl_mp_params/ &
963 irimdenopt,rimdenvwgt, &
964 rimc1, rimc2, rimc3, rimc4, &
968 restoreccn, ccntimeconst, cck, &
974 ibfc, iacr, icracr, &
975 cwfrz2snowfrac, cwfrz2snowratio, &
982 cimas0, cimas1, cfnfac, &
992 ircnw, qminrncw,& ! single-moment only
1004 alphas, & ! note that alphah and alphahl come through physics namelist
1017 cdhdnmin, cdhdnmax, &
1019 cdhldnmin, cdhldnmax, &
1030 lawson_splinter_fac, &
1041 qsdenmod,qhdenmod, &
1043 alphamin,alphamax, &
1045 rescale_low_alpha, &
1046 rescale_low_alphar, &
1047 rescale_low_alphah, &
1048 rescale_low_alphahl, &
1049 rescale_high_alpha, &
1050 ihlcnh, hldia1,iusedw, dwehwmin, dwmin, dwtempmin, &
1051 icvhl2h, hldnmn,hdnmn, &
1052 hlcnhdia, hlcnhqmin, &
1061 sheddiam,sheddiamlg, &
1063 mltdiam1,mltdiam2,mltdiam3,mltdiam4,mltdiam05, &
1075 dmrauto,irescalerainopt, dmropt,dmhlopt, &
1076 rescale_tempthresh, rescale_wthresh, &
1077 ibinhmlr,ibinhlmlr,imltshddmr, binmlrmxdia, binmlrzrrfac,ibinnum, &
1078 iqhacrmlr, iqhlacrmlr, &
1084 do_accurate_sedimentation, interval_sedi_vt
1085 ! #####################################################################
1086 ! #####################################################################
1090 ! #####################################################################
1091 ! #####################################################################
1094 REAL FUNCTION fqvs(t)
1097 fqvs = exp(caw*(t-273.15)/(t-cbw))
1100 REAL FUNCTION fqis(t)
1103 fqis = exp(cai*(t-273.15)/(t-cbi))
1109 ! #####################################################################
1110 ! #####################################################################
1113 SUBROUTINE nssl_2mom_init( &
1114 & ims,ime, jms,jme, kms,kme, nssl_params, ipctmp, mixphase,ihvol,idoniconlytmp, &
1115 & nssl_graupelfallfac, &
1116 & nssl_hailfallfac, &
1121 & nssl_icefallfac, &
1122 & nssl_snowfallfac &
1127 real, intent(in), optional :: &
1128 & nssl_graupelfallfac, &
1129 & nssl_hailfallfac, &
1132 & nssl_icefallfac, &
1134 integer, intent(in), optional :: &
1138 integer, intent(in) :: ims,ime, jms,jme, kms,kme
1139 real, intent(in), dimension(20) :: nssl_params
1143 integer, intent(in) :: ipctmp,mixphase,ihvol
1144 logical, optional, intent(in) :: idoniconlytmp
1146 logical :: wrote_namelist = .false.
1147 logical :: wrf_dm_on_monitor
1149 double precision :: arg
1158 double precision :: x,y,y2,y7
1159 logical :: turn_on_ccna, turn_on_cina
1163 turn_on_ccna = .false.
1164 turn_on_cina = .false.
1166 ! set some global values from namelist input
1169 ccn = Abs( nssl_params(1) )
1170 alphah = nssl_params(2)
1171 alphahl = nssl_params(3)
1172 cnoh = nssl_params(4)
1173 cnohl = nssl_params(5)
1174 cnor = nssl_params(6)
1175 cnos = nssl_params(7)
1176 rho_qh = nssl_params(8)
1177 rho_qhl = nssl_params(9)
1178 rho_qs = nssl_params(10)
1180 ! ipelec = Nint(nssl_params(11))
1181 ! isaund = Nint(nssl_params(12))
1182 IF ( present(nssl_graupelfallfac) ) graupelfallfac = nssl_graupelfallfac
1183 IF ( present(nssl_hailfallfac) ) hailfallfac = nssl_hailfallfac
1184 IF ( present(nssl_ehw0) ) ehw0 = nssl_ehw0
1185 IF ( present(nssl_ehlw0) ) ehlw0 = nssl_ehlw0
1186 IF ( present(nssl_icdx) ) icdx = nssl_icdx
1187 IF ( present(nssl_icdxhl) ) icdxhl = nssl_icdxhl
1188 IF ( present(nssl_icefallfac) ) icefallfac = nssl_icefallfac
1189 IF ( present(nssl_snowfallfac) ) snowfallfac = nssl_snowfallfac
1192 IF ( Nint(nssl_params(13)) == 1 ) THEN
1193 ! hack to switch CCN field to CCNA (activated ccn)
1194 ! invertccn = .true.
1195 turn_on_ccna = .true.
1202 IF ( .false. ) THEN ! set to true to enable internal namelist read
1203 open(15,file='namelist.input',status='old',form='formatted',action='read')
1205 read(15,NML=nssl_mp_params,iostat=istat)
1207 IF ( istat /= 0 ) THEN
1208 write(0,*) 'READ_NAMELIST: PROBLEM WITH NSSL_MP_PARAMS namelist: not found or bad token'
1210 IF ( wrf_dm_on_monitor() .and. .not. wrote_namelist ) THEN
1211 open(15,file='namelist.output',status='old',action='readwrite', position='append',form='formatted')
1212 write(15,NML=nssl_mp_params)
1214 wrote_namelist = .true.
1220 IF ( irenuc >= 5 ) THEN
1221 turn_on_ccna = .true.
1228 IF ( icespheres >= 1 ) THEN
1235 IF ( ihvol <= -1 .or. ihvol == 2 ) THEN
1236 IF ( ihvol == -1 .or. ihvol == -2 ) THEN
1237 lhab = lhab - 1 ! turns off hail
1239 ! past me thought it would be a good idea to change graupel factors when hail is off....
1242 ! dfrz = Max( dfrz, 0.5e-3 )
1244 IF ( ihvol == -2 .or. ihvol == 2 ) THEN ! ice crystals are turned off
1245 ! a value of -3 means to turn off ice crystals but turn on hail
1248 ! idoci = 0 ! try this later
1252 ! write(0,*) 'wrf_init: lhab,lhl = ',lhab,lhl
1254 ! IF ( ipelec > 0 ) idonic = .true.
1257 ! Build lookup table for saturation mixing ratio (Soong and Ogura 73)
1261 temq = 163.15 + (l-1)*fqsat
1262 IF ( iqvsopt == 0 ) THEN
1263 tabqvs(l) = exp(caw*(temq-273.15)/(temq-cbw))
1264 dtabqvs(l) = ((-caw*(-273.15 + temq))/(temq - cbw)**2 + &
1265 & caw/(temq - cbw))*tabqvs(l)
1267 tabqvs(l) = exp(caw*(temq-273.15)/(temq-cbw))
1268 dtabqvs(l) = ((-cawbolton*(-273.15 + temq))/(temq - cbwbolton)**2 + &
1269 & cawbolton/(temq - cbwbolton))*tabqvs(l)
1271 tabqis(l) = exp(cai*(temq-273.15)/(temq-cbi))
1272 dtabqis(l) = ((-cai*(-273.15 + temq))/(temq - cbi)**2 + &
1273 & cai/(temq - cbi))*tabqis(l)
1280 IF ( icdx == 6 ) THEN
1281 bx(lh) = 0.6 ! Milbrandt and Morrison (2013) for density of 550.
1283 ELSEIF ( icdx > 0 ) THEN
1287 bx(lh) = 0.37 ! 0.6 ! Ferrier 1994
1292 IF ( lhl .gt. 1 ) THEN
1293 IF ( icdxhl == 6 ) THEN
1294 bx(lhl) = 0.593 ! Milbrandt and Morrison (2013) for density of 750.
1296 ELSEIF (icdxhl > 0 ) THEN
1300 ax(lhl) = 206.984 ! Ferrier 1994
1305 ! fill in the complete gamma function lookup table
1309 gmoi(igam) = gamma_dp(arg)
1312 ! build lookup table to compute the number and mass fractions of rain drops
1313 ! (imurain=1) greater than a given diameter. Used for qiacr and ciacr
1314 ! Uses incomplete gamma functions
1315 ! The terms with bxh or bxhl will be off if the actual bxh or bxhl is different from the base value (icdx=6 option)
1318 bxhl = bx(Max(lh,lhl))
1320 ! DO j = 0,nqiacralpha
1321 DO j = ialpstart,nqiacralpha
1322 alp = float(j)*dqiacralpha
1323 y = gamma_dpr(1.+alp)
1324 y2 = gamma_dpr(2.+alp)
1325 DO i = 0,nqiacrratio
1326 ratio = float(i)*dqiacrratio
1327 x = gamxinfdp( 1.+alp, ratio )
1328 ! write(0,*) 'i, x/y = ',i, x/y
1329 ciacrratio(i,j) = x/y
1332 gamxinflu(i,j,1,1) = x/y
1333 gamxinflu(i,j,2,1) = gamxinfdp( 2.0+alp, ratio )/y
1334 gamxinflu(i,j,3,1) = gamxinfdp( 2.5+alp+0.5*bxh, ratio )/y
1335 gamxinflu(i,j,5,1) = (gamma_dpr(5.0+alp) - gamxinfdp( 5.0+alp, ratio ))/y
1336 gamxinflu(i,j,6,1) = (gamma_dpr(5.5+alp+0.5*bxh) - gamxinfdp( 5.5+alp+0.5*bxh, ratio ))/y
1337 gamxinflu(i,j,9,1) = gamxinfdp( 1.0+alp, ratio )/y
1338 gamxinflu(i,j,10,1)= gamxinfdp( 4.0+alp, ratio )/y
1340 gamxinflu(i,j,12,1) = gamxinfdp( 2.0+alp, ratio )/y2
1343 gamxinflu(i,j,1,2) = gamxinflu(i,j,1,1)
1344 gamxinflu(i,j,2,2) = gamxinflu(i,j,2,1)
1345 gamxinflu(i,j,3,2) = gamxinfdp( 2.5+alp+0.5*bxhl, ratio )/y
1346 gamxinflu(i,j,5,2) = gamxinflu(i,j,5,1)
1347 gamxinflu(i,j,6,2) = (gamma_dpr(5.5+alp+0.5*bxhl) - gamxinfdp( 5.5+alp+0.5*bxhl, ratio ))/y
1348 gamxinflu(i,j,9,2) = gamxinflu(i,j,9,1)
1349 gamxinflu(i,j,10,2)= gamxinflu(i,j,10,1)
1351 IF ( alp > 1.1 ) THEN
1352 ! gamxinflu(i,j,7,1) = gamxinfdp( alp - 1., ratio )/y
1353 gamxinflu(i,j,7,1) = (gamma_dpr(alp - 1.) - gamxinfdp( alp - 1., ratio ))/y
1354 ! gamxinflu(i,j,8,1) = gamxinfdp( alp - 0.5 + 0.5*bxh, ratio )/y
1355 gamxinflu(i,j,8,1) = (gamma_dpr(alp - 0.5 + 0.5*bxh) - gamxinfdp( alp - 0.5 + 0.5*bxh, ratio ))/y
1356 ! gamxinflu(i,j,8,2) = gamxinfdp( alp - 0.5 + 0.5*bxhl, ratio )/y
1357 gamxinflu(i,j,8,2) = (gamma_dpr(alp - 0.5 + 0.5*bxhl) - gamxinfdp( alp - 0.5 + 0.5*bxhl, ratio ))/y
1359 ! gamxinflu(i,j,7,1) = gamxinfdp( .1, ratio )/y
1360 gamxinflu(i,j,7,1) = (gamma_dpr(0.1) - gamxinfdp( 0.1, ratio ) )/y
1361 ! gamxinflu(i,j,8,1) = gamxinfdp( 1.1 - 0.5 + 0.5*bxh, ratio )/y
1362 ! gamxinflu(i,j,8,2) = gamxinfdp( 1.1 - 0.5 + 0.5*bxhl, ratio )/y
1363 gamxinflu(i,j,8,1) = (gamma_dpr(1.1 - 0.5 + 0.5*bxh) - gamxinfdp( 1.1 - 0.5 + 0.5*bxh, ratio ) )/y
1364 gamxinflu(i,j,8,2) = (gamma_dpr(1.1 - 0.5 + 0.5*bxhl) - gamxinfdp( 1.1 - 0.5 + 0.5*bxhl, ratio ) )/y
1367 gamxinflu(i,j,7,2) = gamxinflu(i,j,7,1)
1371 ciacrratio(0,:) = 1.0
1373 DO j = ialpstart,nqiacralpha
1374 alp = float(j)*dqiacralpha
1375 y = gamma_sp(4.+alp)
1376 y7 = gamma_sp(7.+alp)
1377 DO i = 0,nqiacrratio
1378 ratio = float(i)*dqiacrratio
1381 x = gamxinfdp( 4.+alp, ratio )
1382 ! write(0,*) 'i, x/y = ',i, x/y
1383 qiacrratio(i,j) = x/y
1384 gamxinflu(i,j,4,1) = x/y
1385 gamxinflu(i,j,4,2) = x/y
1387 ! reflectivity fraction
1388 x = gamxinfdp( 7.+alp, ratio )
1389 ziacrratio(i,j) = x/y7
1390 gamxinflu(i,j,11,1) = x/y7
1391 gamxinflu(i,j,11,2) = x/y7
1395 qiacrratio(0,:) = 1.0
1398 isub = Min( 0, Max(-1,ihvol) ) ! is -1 or 0
1424 IF ( ipconc == 0 ) THEN
1425 IF ( ihvol >= 0 ) THEN
1433 ELSEIF ( ipconc == 5 ) THEN
1441 IF ( ihvol >= 0 ) THEN
1443 lnhl = ltmp ! lhab+7 ! 15
1446 lvh = ltmp ! lhab+8 + isub ! 16 + isub ! isub adjusts to 15 if hail is off
1448 denscale(lccn:lvh) = 1
1449 IF ( ihvol >= 1 ) THEN
1455 IF ( mixedphase ) THEN
1466 ELSEIF ( ipconc >= 6 ) THEN
1467 write(0,*) 'NSSL microphysics has not been compiled for 3-moment. Sorry.'
1478 lnhl = ltmp ! lhab+7 ! 15
1481 lvh = ltmp ! lhab+8 + isub ! 16 + isub ! isub adjusts to 15 if hail is off
1483 denscale(lccn:lvh) = 1
1484 IF ( ihvol >= 1 ) THEN
1491 IF ( ipconc == 6 ) THEN
1494 ELSEIF ( ipconc == 7 ) THEN
1499 ELSEIF ( ipconc == 8 ) THEN
1511 ! denscale(lccn:lvh) = 1
1512 IF ( ihvol >= 1 ) THEN
1517 IF ( mixedphase ) THEN
1529 CALL wrf_error_fatal( 'nssl_2mom_init: Invalid value of ipctmp' )
1535 ! write(0,*) 'wrf_init: irenuc, turn_on_ccna = ',irenuc, turn_on_ccna
1536 IF ( turn_on_ccna ) THEN
1542 IF ( turn_on_cina ) THEN
1548 IF ( turn_on_cin .or. is_aerosol_aware ) THEN
1552 !debug write(0,*) 'Setting lcin to ',lcin
1561 IF ( lhl .gt. 1 ) ln(lhl) = lnhl
1568 IF ( lhl .gt. 1 ) ipc(lhl) = 5
1575 IF ( lhl .gt. 1 .and. lvhl .gt. 1 ) lvol(lhl) = lvhl
1588 IF ( lhl .gt. 1 ) lsc(lhl) = lschl
1592 ldovol = ldovol .or. ( lvol(il) .gt. 1 )
1595 ! write(0,*) 'nssl_2mom_init: ldovol = ',ldovol
1602 IF ( lhl .gt. 1 .and. lzhl > 1 ) lz(lhl) = lzhl
1607 IF ( lhl .gt. 1 ) lliq(lhl) = lhlw
1608 IF ( mixedphase ) THEN
1609 ! write(0,*) 'lsw,lhw,lhlw = ',lsw,lhw,lhlw
1617 IF ( imurain == 3 ) THEN
1620 ELSEIF ( imurain == 1 ) THEN
1621 xnu(lr) = (alphar - 2.0)/3.0
1628 IF ( lis >= 1 ) THEN
1633 dnu(lc) = 3.*xnu(lc) + 2. ! alphac
1634 dmu(lc) = 3.*xmu(lc)
1636 dnu(lr) = 3.*xnu(lr) + 2. ! alphar
1637 dmu(lr) = 3.*xmu(lr)
1642 dnu(ls) = 3.*xnu(ls) + 2. ! -0.4 ! alphas
1643 dmu(ls) = 3.*xmu(ls)
1649 xnu(lh) = (dnu(lh) - 2.)/3.
1653 IF ( imurain == 3 ) THEN ! rain is gamma of volume
1654 rz = ((4. + alphah)*(5. + alphah)*(6. + alphah)*(1. + xnu(lr)))/ &
1655 & ((1 + alphah)*(2 + alphah)*(3 + alphah)*(2. + xnu(lr)))
1657 ! IF ( ipconc .lt. 5 ) alphahl = alphah
1659 rzhl = ((4. + alphahl)*(5. + alphahl)*(6. + alphahl)*(1. + xnu(lr)))/ &
1660 & ((1. + alphahl)*(2. + alphahl)*(3. + alphahl)*(2. + xnu(lr)))
1662 rzs = 1. ! assume rain and snow are both gamma volume
1664 ELSE ! rain is gamma of diameter
1666 rz = ((4. + alphah)*(5. + alphah)*(6. + alphah)*(1. + alphar)*(2. + alphar)*(3. + alphar))/ &
1667 & ((1 + alphah)*(2 + alphah)*(3 + alphah)*(4. + alphar)*(5. + alphar)*(6. + alphar))
1669 rzhl = ((4. + alphahl)*(5. + alphahl)*(6. + alphahl)*(1. + alphar)*(2. + alphar)*(3. + alphar))/ &
1670 & ((1 + alphahl)*(2 + alphahl)*(3 + alphahl)*(4. + alphar)*(5. + alphar)*(6. + alphar))
1674 & ((1. + alphar)*(2. + alphar)*(3. + alphar)*(2. + xnu(ls)))/ &
1675 & ((4. + alphar)*(5. + alphar)*(6. + alphar)*(1. + xnu(ls)))
1680 IF ( ipconc <= 5 ) THEN
1681 imltshddmr = Min(1, imltshddmr)
1686 IF ( ipconc > 5 .and. (ibinhmlr == 0 .and. ibinhlmlr == 0 ) ) THEN
1687 imltshddmr = Min(1, imltshddmr)
1690 ! write(0,*) 'rz,rzhl = ', rz,rzhl
1692 IF ( ipconc .lt. 4 ) THEN
1697 xnu(ls) = (dnu(ls) - 2.)/3.
1703 IF ( lhl .gt. 1 ) THEN
1708 xnu(lhl) = (dnu(lhl) - 2.)/3.
1714 IF ( li .gt. 1 ) cno(li) = 1.0e+08
1716 IF ( ls .gt. 1 ) cno(ls) = cnos ! 8.0e+06
1717 IF ( lh .gt. 1 ) cno(lh) = cnoh ! 4.0e+05
1718 IF ( lhl .gt. 1 ) cno(lhl) = cnohl ! 4.0e+05
1720 ! density maximums and minimums
1729 IF ( lhl .gt. 1 ) xdnmx(lhl) = 900.0
1738 IF ( lhl .gt. 1 ) xdnmn(lhl) = hldnmn
1745 xdn0(ls) = rho_qs ! 100.0
1746 xdn0(lh) = rho_qh ! (0.5)*(xdnmn(lh)+xdnmx(lh))
1747 IF ( lhl .gt. 1 ) xdn0(lhl) = rho_qhl ! 800.0
1750 ! Set terminal velocities...
1751 ! also set drag coefficients
1754 cdx(lh) = 0.8 ! 1.0 ! 0.45
1756 IF ( lhl .gt. 1 ) cdx(lhl) = 0.45
1763 IF ( lhl .gt. 1 ) ido(lhl) = idohl
1765 IF ( irfall .lt. 0 ) irfall = infall
1766 IF ( lzr > 0 ) irfall = 0
1769 ! xvcmx = (4./3.)*pi*xcradmx**3
1771 ! set max rain diameter
1772 IF ( xvdmx .gt. 0.0 ) THEN
1773 xvrmx = 0.523599*(xvdmx)**3
1778 IF ( dhmn <= 0.0 ) THEN
1780 ! xvhmn = Min(xvhmn0, 0.523599*(dfrz)**3 )
1782 xvhmn = 0.523599*(dhmn)**3
1783 ! xvhmn = 0.523599*(Min(dhmn,dfrz))**3
1786 IF ( dhmx <= 0.0 ) THEN
1789 xvhmx = 0.523599*(dhmx)**3
1792 IF ( qhdpvdn < 0. ) qhdpvdn = xdnmn(lh)
1793 IF ( qhacidn < 0. ) qhacidn = xdnmn(lh)
1795 ! load max/min diameters
1808 IF ( lhl .gt. 1 ) THEN
1814 ! cloud water constants in mks units
1816 ! cwmasn = 4.25e-15 ! radius of 1.0e-6
1817 ! cwmasn = 5.23e-13 ! minimum mass, defined by radius of 5.0e-6
1818 ! cwmasn5 = 5.23e-13
1819 ! cwradn = 5.0e-6 ! minimum radius
1820 ! cwmasx = 5.25e-10 ! maximum mass, defined by radius of 50.0e-6
1821 ! mwfac = 6.0**(1./3.)
1822 IF ( ipconc .ge. 2 ) THEN
1823 ! cwmasn = xvmn(lc)*1000. ! minimum mass, defined by minimum droplet volume
1824 ! cwradn = 1.0e-6 ! minimum radius
1825 ! cwmasx = xvmx(lc)*1000. ! maximum mass, defined by maximum droplet volume
1828 ! rwmasn = xvmn(lr)*1000. ! minimum mass, defined by minimum rain volume
1829 ! rwmasx = xvmx(lr)*1000. ! maximum mass, defined by maximum rain volume
1831 IF ( lhl < 1 ) ifrzg = 1
1834 IF ( imurain == 3 ) THEN
1835 ! IF ( izwisventr == 1 ) THEN
1836 ventr = Gamma_sp(rnu + 4./3.)/((rnu + 1.)**(1./3.)*Gamma_sp(rnu + 1.)) ! Ziegler 1985
1838 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
1839 ! ventr = Gamma_sp(rnu + 4./3.)/((rnu + 1.)**(1./3.)*Gamma_sp(rnu + 1.)) ! Ziegler 1985, still use for first term in rwvent
1840 ! ventr = Gamma_sp(rnu + 4./3.)/Gamma_sp(rnu + 1.)
1843 ! IF ( iferwisventr == 1 ) THEN
1844 ventr = Gamma_sp(2. + alphar) ! Ferrier 1994
1845 ! ELSEIF ( iferwisventr == 2 ) THEN
1846 ventrn = Gamma_sp(alphar + 2.5 + br/2.)/Gamma_sp(alphar + 1.) ! adapted from Wisner et al. 1972
1849 ventc = Gamma_sp(cnu + 4./3.)/(cnu + 1.)**(1./3.)/Gamma_sp(cnu + 1.)
1850 c1sw = Gamma_sp(snu + 4./3.)*(snu + 1.0)**(-1./3.)/gamma_sp(snu + 1.0)
1852 ! set threshold mixing ratios
1858 IF ( li > 1 ) qxmin(li) = 1.e-12
1859 IF ( ls > 1 ) qxmin(ls) = 1.e-7
1860 IF ( lh > 1 ) qxmin(lh) = 1.e-7
1861 IF ( lhl .gt. 1 ) qxmin(lhl) = 1.e-7
1863 IF ( lc .gt. 1 .and. lnc .gt. 1 ) qxmin(lc) = 1.0e-13
1864 IF ( lr .gt. 1 .and. lnr .gt. 1 ) qxmin(lr) = 1.0e-12
1866 IF ( li .gt. 1 .and. lni .gt. 1 ) qxmin(li ) = 1.0e-13
1867 IF ( ls .gt. 1 .and. lns .gt. 1 ) qxmin(ls ) = 1.0e-13
1868 IF ( lh .gt. 1 .and. lnh .gt. 1 ) qxmin(lh ) = 1.0e-12
1869 IF ( lhl.gt. 1 .and. lnhl.gt. 1 ) qxmin(lhl) = 1.0e-12
1871 qxmin_init(:) = 1.0e-8 ! threshold for considering single-moment initial condition mixing ratios
1872 ! constants for droplet nucleation
1875 ccnefac = (1.63/(cck * beta(3./2., cck/2.)))**(cck/(cck + 2.0))
1876 cnexp = (3./2.)*cck/(cck+2.0)
1877 ! ccne is all the factors with w in eq. A7 in Mansell et al. 2010 (JAS). The constant changes
1878 ! if k (cck) is changed!
1879 ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
1880 ccne0 = ccnefac*1.e6*(1.e-6)**(2./(2.+cck))
1881 ! write(0,*) 'cwccn, cck, ccne = ',cwccn,cck,ccne,ccnefac,cnexp
1882 IF ( cwccn .lt. 0.0 ) THEN
1884 ccwmx = 50.e9 ! cwccn
1886 ccwmx = 50.e9 ! cwccn ! *1.4
1891 ! Set collection coefficients (Seifert and Beheng 05)
1896 da0(il) = delbk(bb(il), xnu(il), xmu(il), 0)
1897 da1(il) = delbk(bb(il), xnu(il), xmu(il), 1)
1899 ! write(0,*) 'il, da0, da1, xnu, xmu = ', il, da0(il), da1(il), xnu(il), xmu(il)
1907 IF ( il .ne. j ) THEN
1909 dab0(il,j) = delabk(bb(il), bb(j), xnu(il), xnu(j), xmu(il), xmu(j), 0)
1910 dab1(il,j) = delabk(bb(il), bb(j), xnu(il), xnu(j), xmu(il), xmu(j), 1)
1912 ! write(0,*) 'il, j, dab0, dab1 = ',il, j, dab0(il,j), dab1(il,j)
1917 gf4br = gamma_sp(4.0+br)
1918 gf4ds = gamma_sp(4.0+ds)
1919 gf4p5 = gamma_sp(4.0+0.5)
1920 gfcinu1 = gamma_sp(cinu + 1.0)
1921 gfcinu1p47 = gamma_sp(cinu + 1.47167)
1922 gfcinu2p47 = gamma_sp(cinu + 2.47167)
1923 gfcinu1p22 = gamma_sp(cinu + 1.22117)
1924 gfcinu2p22 = gamma_sp(cinu + 2.22117)
1925 gfcinu1p18 = gamma_sp(cinu + 1.18333)
1926 gfcinu2p18 = gamma_sp(cinu + 2.18333)
1928 gsnow1 = gamma_sp(snu + 1.0)
1929 gsnow53 = gamma_sp(snu + 5./3.)
1930 gsnow73 = gamma_sp(snu + 7./3.)
1932 IF ( lh .gt. 1 ) cwchtmp0 = 6.0/pi*gamma_sp( (xnu(lh) + 1.)/xmu(lh) )/gamma_sp( (xnu(lh) + 2.)/xmu(lh) )
1933 IF ( lhl .gt. 1 ) cwchltmp0 = 6.0/pi*gamma_sp( (xnu(lhl) + 1)/xmu(lhl) )/gamma_sp( (xnu(lhl) + 2)/xmu(lhl) )
1936 iexy(:,:)=0; ! sets to zero the ones Imight have forgotten
1940 iexy(ls,lc) = ieswc ; iexy(ls,lr) = ieswr ;
1943 iexy(lh,ls) = iehwsw ; iexy(lh,li) = iehwi ;
1944 iexy(lh,lc) = iehwc ; iexy(lh,lr) = iehwr ;
1947 IF (lhl .gt. 1 ) THEN
1948 iexy(lhl,ls) = iehlsw ; iexy(lhl,li) = iehli ;
1949 iexy(lhl,lc) = iehlc ; iexy(lhl,lr) = iehlr ;
1952 ! IF ( icefallfac /= 1.0 ) write(0,*) 'icefallfac = ',icefallfac
1953 ! IF ( snowfallfac /= 1.0 ) write(0,*) 'snowfallfac = ',snowfallfac
1957 END SUBROUTINE nssl_2mom_init
1959 ! #####################################################################
1960 ! #####################################################################
1962 SUBROUTINE nssl_2mom_driver(qv, qc, qr, qi, qs, qh, qhl, ccw, crw, cci, csw, chw, chl, &
1963 cn, vhw, vhl, cna, cni, f_cn, f_cna, f_cina, &
1966 tt, th, pii, p, w, dn, dz, dtp, itimestep, &
1970 SNOWNC, SNOWNCV, GRPLNC, GRPLNCV, &
1971 SR,HAILNC, HAILNCV, &
1973 re_cloud, re_ice, re_snow, &
1974 has_reqc, has_reqi, has_reqs, &
1975 rainncw2, rainnci2, &
1977 rscghis_2d,rscghis_2dp,rscghis_2dn, &
1978 scr,scw,sci,scs,sch,schl,sctot, &
1980 induc,elec,scion,sciona, &
1981 noninduc,noninducp,noninducn, &
1982 pcc2, pre2, depsubr, &
1983 mnucf2, melr2, ctr2, &
1984 rim1_2, rim2_2,rim3_2, &
1985 nctr2, nnuccd2, nnucf2, &
1986 effc2,effr2,effi2, &
1988 fc2, fr2,fi2,fs2,fg2, &
1989 fnc2, fnr2,fni2,fns2,fng2, &
1990 ! qcond,qdep,qfrz,qrauto,qhcnvi,qhcollw,qscollw, &
1991 ! ncauto, niinit,nifrz, &
1992 ! re_liquid, re_graupel, re_hail, re_icesnow, &
1993 ! vtcloud, vtrain, vtsnow, vtgraupel, vthail, &
1996 nssl_progn, & ! wrf-chem
1997 ! 20130903 acd_mb_washout start
1998 wetscav_on, rainprod, evapprod, & ! wrf-chem
1999 ! 20130903 acd_mb_washout end
2000 cu_used, qrcuten, qscuten, qicuten, qccuten, & ! hm added
2001 ids,ide, jds,jde, kds,kde, & ! domain dims
2002 ims,ime, jms,jme, kms,kme, & ! memory dims
2003 its,ite, jts,jte, kts,kte) ! tile dims
2010 !Subroutine arguments:
2012 integer, intent(in):: &
2013 ids,ide, jds,jde, kds,kde, &
2014 ims,ime, jms,jme, kms,kme, &
2015 its,ite, jts,jte, kts,kte
2016 real, dimension(ims:ime, kms:kme, jms:jme), intent(inout):: &
2018 ! tt is air temperature -- used by CCPP instead of th (theta)
2019 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2023 qi,qhl,ccw,crw,cci,csw,chw,chl,vhw,vhl
2024 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: dbz, vzf, cn, cna, cni
2025 real, dimension(ims:ime, jms:jme), optional, intent(inout):: compdbz
2026 real, dimension(ims:ime, jms:jme), optional, intent(inout):: rscghis_2d, & ! 2D accumulation arrays for vertically-integrated charging rate
2027 rscghis_2dp, & ! 2D accumulation arrays for vertically-integrated charging rate (positive only)
2028 rscghis_2dn ! 2D accumulation arrays for vertically-integrated charging rate (negative only)
2029 ! real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout)::rscghis_3d
2030 integer, optional, intent(in) :: elec_physics
2031 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2032 scr,scw,sci,scs,sch,schl,sciona,sctot ! space charge
2033 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2034 induc,noninduc,noninducp,noninducn ! charging rates: inductive, noninductive (all, positive, negative to graupel)
2035 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(in) :: elec ! elecsave = Ez
2036 real, dimension(ims:ime, kms:kme, jms:jme,2),optional, intent(inout) :: scion
2037 real, dimension(ims:ime, kms:kme, jms:jme), intent(in):: p,w,dz,dn
2039 real, dimension(ims:ime, kms:kme, jms:jme), intent(in):: pii
2040 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2041 pcc2, pre2, depsubr, &
2042 mnucf2, melr2, ctr2, &
2043 rim1_2, rim2_2,rim3_2, &
2044 nctr2, nnuccd2, nnucf2, &
2045 effc2,effr2,effi2, &
2047 fc2, fr2,fi2,fs2,fg2, &
2048 fnc2, fnr2,fni2,fns2,fng2
2049 ! qcond,qdep,qfrz,qrauto,qhcnvi,qhcollw,qscollw, &
2050 ! ncauto, niinit,nifrz, &
2051 ! re_liquid, re_graupel, re_hail, re_icesnow, &
2052 ! vtcloud, vtrain, vtsnow, vtgraupel, vthail
2054 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout) :: axtra
2057 real, dimension(ims:ime, jms:jme), intent(inout):: &
2058 RAINNC,RAINNCV ! accumulated precip (NC) and rate (NCV)
2059 real, dimension(ims:ime, jms:jme), optional, intent(inout):: &
2060 SNOWNC,SNOWNCV,GRPLNC,GRPLNCV,SR ! accumulated precip (NC) and rate (NCV)
2061 real, dimension(ims:ime, jms:jme), optional, intent(inout):: &
2062 HAILNC,HAILNCV ! accumulated precip (NC) and rate (NCV)
2063 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional, INTENT(INOUT):: re_cloud, re_ice, re_snow
2064 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional, INTENT(IN):: tkediss
2065 INTEGER, INTENT(IN), optional :: has_reqc, has_reqi, has_reqs
2066 real, dimension(ims:ime, jms:jme), intent(out), optional :: &
2067 rainncw2, rainnci2 ! liquid rain, ice, accumulation rates
2068 real, optional, intent(in) :: dx,dy
2069 real, intent(in):: dtp
2070 integer, intent(in):: itimestep !, ccntype
2071 logical, optional, intent(in) :: diagflag, f_cna, f_cn, f_cina
2072 integer, optional, intent(in) :: ipelectmp, ke_diag
2074 LOGICAL, INTENT(IN), OPTIONAL :: nssl_progn ! flags for wrf-chem
2076 ! REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional,INTENT(INOUT):: qndrop
2077 LOGICAL :: flag_qndrop ! wrf-chem
2078 LOGICAL :: flag_qnifa , flag_qnwfa
2080 real :: cinchange, t7max,testmax,wmax
2082 ! 20130903 acd_ck_washout start
2083 ! rainprod - total tendency of conversion of cloud water/ice and graupel to rain (kg kg-1 s-1)
2084 ! evapprod - tendency of evaporation of rain (kg kg-1 s-1)
2085 ! 20130903 acd_ck_washout end
2086 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional,INTENT(INOUT):: rainprod, evapprod
2088 ! qrcuten, rain tendency from parameterized cumulus convection
2089 ! qscuten, snow tendency from parameterized cumulus convection
2090 ! qicuten, cloud ice tendency from parameterized cumulus convection
2091 ! mu : air mass in column
2092 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional, INTENT(IN):: qrcuten, qscuten, qicuten, qccuten
2093 INTEGER, optional, intent(in) :: cu_used
2094 LOGICAL, optional, intent(in) :: wetscav_on
2099 real, dimension(its:ite, 1, kts:kte) :: elec2 ! ez = elecsave slab
2100 ! real, dimension(its:ite, 1, kts:kte,2) :: scion2 ! 1=- , 2=+
2101 real, dimension(its:ite, kts:kte) :: rainprod2d, evapprod2d,tke2d
2102 real, dimension(its:ite, 1, kts:kte, na) :: an, ancuten
2103 real, dimension(its:ite, 1, kts:kte, nxtra) :: axtra2d
2104 real, dimension(its:ite, 1, kts:kte) :: t0,t1,t2,t3,t4,t5,t6,t7,t8,t9
2105 real, dimension(its:ite, 1, kts:kte) :: dn1,t00,t77,ssat,pn,wn,dz2d,dz2dinv,dbz2d,vzf2d
2106 real, dimension(its:ite, 1, na) :: xfall
2107 integer, parameter :: nor = 0, ng = 0
2109 integer ix,jy,kz,i,j,k,il,n
2111 real :: ssival, ssifac, t8s, t9s, qvapor
2113 double precision :: dp1
2117 integer :: vzflag0 = 0
2119 real, parameter :: cnin20 = 1.0e3
2120 real, parameter :: cnin10 = 5.0e1
2121 real, parameter :: cnin1a = 4.5
2122 real, parameter :: cnin2a = 12.96
2123 real, parameter :: cnin2b = 0.639
2125 double precision :: cwmass1,cwmass2
2126 double precision :: rwmass1,rwmass2
2127 double precision :: icemass1,icemass2
2128 double precision :: swmass1,swmass2
2129 double precision :: grmass1,grmass2
2130 double precision :: hlmass1,hlmass2
2131 double precision :: wvol5,wvol10
2135 double precision :: dt1,dt2
2136 double precision :: timesed,timesed1,timesed2,timesed3, timegs, timenucond, timedbz,zmaxsed
2137 double precision :: timevtcalc,timesetvt
2139 logical :: f_cnatmp, f_cinatmp
2140 logical :: has_wetscav
2142 integer :: kediagloc
2145 real :: ycent, y, emissrate, emissrate0, emissrate1, z, fac, factot
2146 real :: fach(kts:kte)
2151 integer, parameter :: ntot = 50
2152 double precision mpitotindp(ntot), mpitotoutdp(ntot)
2153 INTEGER :: mpi_error_code = 1
2158 ! -------------------------------------------------------------------
2163 ! write(0,*) 'N2M: entering routine'
2165 flag_qndrop = .false.
2166 flag_qnifa = .false.
2167 flag_qnwfa = .false.
2169 IF ( PRESENT ( nssl_progn ) ) flag_qndrop = nssl_progn
2176 IF ( present( f_cna ) ) THEN
2182 IF ( present( f_cina ) ) THEN
2188 IF ( present( vzf ) ) vzflag0 = 1
2190 IF ( present( ipelectmp ) ) THEN
2195 ! IF ( present( dbz ) ) THEN
2199 ! dbz(ix,kz,jy) = 0.0
2207 IF ( present( diagflag ) ) THEN
2208 makediag = diagflag .or. itimestep == 1
2211 ! write(0,*) 'N2M: makediag = ',makediag
2215 ny = 1 ! set up as 2D slabs
2218 IF ( .not. present( cn ) ) THEN
2222 ! set up CCN array and some other static local values
2223 IF ( itimestep == 1 .and. .not. invertccn .and. present( cn ) ) THEN
2224 ! this is not needed for WRF 3.8 and later because it is done in physics_init,
2225 ! but kept for backwards compatibility with earlier versions
2226 IF ( lccna > 1 .and. .not. ( present( cna ) .and. f_cnatmp ) ) THEN
2227 ! using cn array for cna and use background qccn for local cn array
2236 ELSEIF ( cn((ite+its)/2,(kte+kts)/2,(jte+jts)/2) < 10.0 ) THEN ! initialize ccn if not already done
2247 IF ( itimestep == 1 .and. invertccn .and. present( cn ) ) THEN
2248 ! this is not needed for WRF 3.8 and later because it is done in physics_init,
2249 ! but kept for backwards compatibility with earlier versions
2259 IF ( invertccn .and. present( cn ) ) THEN ! hack for WRF to convert activated ccn to unactivated, then do not have to
2260 ! worry about initial and boundary conditions - they are zero
2264 cn(ix,kz,jy) = Max( 0.0, qccn - cn(ix,kz,jy) )
2270 ! ENDIF ! itimestep == 1
2273 ! sedimentation settings
2277 IF ( infall .ne. 1 .or. iscfall .ge. 2 ) THEN
2283 IF ( infall .ge. 3 .or. ipconc .ge. 6 ) THEN
2288 IF ( present( HAILNCV ) .and. lhl < 1 ) THEN ! for WRF 3.1 compatibility
2289 HAILNCV(its:ite,jts:jte) = 0.
2292 tke2d(:,:) = 0.0 ! initialize if not used
2294 lnb = Max(lh,lhl)+1 ! lnc
2295 ! IF ( lccn > 1 ) lnb = lccn
2299 IF ( present( compdbz ) .and. makediag ) THEN
2302 compdbz(ix,jy) = -3.0
2319 ! write(0,*) 'N2M: jy loop 1, lhl,na = ',lhl,na,present(qhl)
2321 ancuten(its:ite,1,kts:kte,:) = 0.0
2327 ! write(0,*) 'N2M: load an, jy,lccn = ',jy,lccn,qccn
2329 IF ( present( pcc2 ) .and. makediag ) THEN
2330 axtra2d(its:ite,1,kts:kte,:) = 0.0
2333 ! copy from 3D array to 2D slab
2338 an(ix,1,kz,lt) = th(ix,kz,jy)
2341 an(ix,1,kz,lv) = qv(ix,kz,jy)
2342 an(ix,1,kz,lc) = qc(ix,kz,jy)
2343 an(ix,1,kz,lr) = qr(ix,kz,jy)
2344 IF ( present( qi ) ) THEN
2345 an(ix,1,kz,li) = qi(ix,kz,jy)
2347 an(ix,1,kz,li) = 0.0
2349 an(ix,1,kz,ls) = qs(ix,kz,jy)
2350 an(ix,1,kz,lh) = qh(ix,kz,jy)
2351 IF ( lhl > 1 ) an(ix,1,kz,lhl) = qhl(ix,kz,jy)
2352 IF ( lccn > 1 ) THEN
2353 IF ( is_aerosol_aware .and. flag_qnwfa ) THEN
2355 ELSEIF ( present( cn ) ) THEN
2356 IF ( lccna > 1 .and. .not. ( present( cna ) .and. f_cnatmp ) ) THEN
2357 an(ix,1,kz,lccna) = cn(ix,kz,jy)
2358 an(ix,1,kz,lccn) = qccn ! cn(ix,kz,jy)
2360 an(ix,1,kz,lccn) = cn(ix,kz,jy)
2363 IF ( lccna == 0 .and. ( .not. f_cnatmp ) ) THEN
2364 an(ix,1,kz,lccn) = qccn - ccw(ix,kz,jy)
2366 an(ix,1,kz,lccn) = qccn
2372 IF ( lccna > 1 ) THEN
2373 IF ( present( cna ) .and. f_cnatmp ) THEN
2374 an(ix,1,kz,lccna) = cna(ix,kz,jy)
2378 IF ( lcina > 1 ) THEN
2379 IF ( present( cni ) .and. f_cinatmp ) THEN
2380 an(ix,1,kz,lcina) = cni(ix,kz,jy)
2384 IF ( ipconc >= 5 ) THEN
2385 an(ix,1,kz,lnc) = ccw(ix,kz,jy)
2386 IF ( constccw > 0.0 ) THEN
2387 an(ix,1,kz,lnc) = constccw
2389 an(ix,1,kz,lnr) = crw(ix,kz,jy)
2390 IF ( present( cci ) ) THEN
2391 an(ix,1,kz,lni) = cci(ix,kz,jy)
2393 an(ix,1,kz,lni) = 0.0
2395 an(ix,1,kz,lns) = csw(ix,kz,jy)
2396 an(ix,1,kz,lnh) = chw(ix,kz,jy)
2397 IF ( lhl > 1 ) an(ix,1,kz,lnhl) = chl(ix,kz,jy)
2399 IF ( lvh > 0 ) an(ix,1,kz,lvh) = vhw(ix,kz,jy)
2400 IF ( lvhl > 0 .and. present( vhl ) ) an(ix,1,kz,lvhl) = vhl(ix,kz,jy)
2407 t0(ix,1,kz) = th(ix,kz,jy)*pii(ix,kz,jy) ! temperature (Kelvin)
2417 t00(ix,1,kz) = 380.0/p(ix,kz,jy)
2418 t77(ix,1,kz) = pii(ix,kz,jy)
2419 dbz2d(ix,1,kz) = 0.0
2420 vzf2d(ix,1,kz) = 0.0
2422 dn1(ix,1,kz) = dn(ix,kz,jy)
2423 pn(ix,1,kz) = p(ix,kz,jy)
2424 wn(ix,1,kz) = w(ix,kz,jy)
2425 ! wmax = Max(wmax,wn(ix,1,kz))
2426 dz2d(ix,1,kz) = dz(ix,kz,jy)
2427 dz2dinv(ix,1,kz) = 1./dz(ix,kz,jy)
2429 ltemq = Int( (t0(ix,1,kz)-163.15)/fqsat+1.5 )
2430 ltemq = Min( nqsat, Max(1,ltemq) )
2432 ! saturation mixing ratio
2434 t8s = t00(ix,1,kz)*tabqvs(ltemq) !saturation mixing ratio wrt water
2435 t9s = t00(ix,1,kz)*tabqis(ltemq) !saturation mixing ratio wrt ice
2438 ! calculate rate of nucleation
2440 ssival = Min(t8s,max(an(ix,1,kz,lv),0.0))/t9s ! qv/qvi
2442 if ( ssival .gt. 1.0 ) then
2444 IF ( icenucopt == 1 ) THEN
2446 if ( t0(ix,1,kz).le.268.15 ) then
2448 dp1 = dn1(ix,1,kz)/rho00*cnin20*exp( Min( 57.0 ,(cnin2a*(ssival-1.0)-cnin2b) ) )
2449 t7(ix,1,kz) = Min(dp1, 1.0d30)
2453 ! Default value of imeyers5 turns off nucleation by Meyer at higher temperatures
2454 ! This is really from Ferrier (1994), eq. 4.31 - 4.34
2455 IF ( imeyers5 ) THEN
2456 if ( t0(ix,1,kz).lt.tfr .and. t0(ix,1,kz).gt.268.15 ) then
2457 qvapor = max(an(ix,1,kz,lv),0.0)
2459 if ( (qvapor-t9s) .gt. 1.0e-5 ) then
2460 if ( (t8s-t9s) .gt. 1.0e-5 ) then
2461 ssifac = (qvapor-t9s) /(t8s-t9s)
2462 ssifac = ssifac**cnin1a
2465 t7(ix,1,kz) = dn1(ix,1,kz)/rho00*cnin10*ssifac*exp(-(t0(ix,1,kz)-tfr)*bta1)
2469 ! t7max = Max(t7max, t7(ix,1,kz) )
2471 ELSEIF ( icenucopt == 2 ) THEN ! Thompson/Cooper; Note Thompson 2004 has constants of
2472 ! 0.005 and 0.304 because the line function was estimated from Cooper plot
2473 ! Here, the fit line values from Cooper 1986 are converted. Very little difference
2476 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
2478 ! write(0,*) 'Cooper t7,ssival = ',ix,kz,t7(ix,1,kz),ssival
2480 ELSEIF ( icenucopt == 3 ) THEN ! Phillips (Meyers/DeMott)
2482 if ( t0(ix,1,kz).le.268.15 .and. t0(ix,1,kz) > 243.15 ) then ! Meyers with factor of Psi=0.06
2484 dp1 = 0.06*cnin20*exp( Min( 57.0 ,(cnin2a*(ssival-1.0)-cnin2b) ) )
2485 t7(ix,1,kz) = Min(dp1, 1.0d30)
2486 elseif ( t0(ix,1,kz) <= 243.15 ) then ! Phillips estimate of DeMott et al (2003) data
2487 dp1 = 1000.*( exp( Min( 57.0 ,cnin2a*(ssival-1.1) ) ) )**0.3
2488 t7(ix,1,kz) = Min(dp1, 1.0d30)
2492 ELSEIF ( icenucopt == 4 ) THEN ! DeMott 2010
2494 IF ( t0(ix,jy,kz) < 268.16 .and. t0(ix,jy,kz) > 223.15 .and. ssival > 1.001 ) THEN !
2496 ! a = 0.0000594, b = 3.33, c = 0.0264, d = 0.0033,
2497 ! nint = a*(-Tc)**b * naer**(c*(-Tc) + d)
2498 ! nint has units of per (standard) liter, so mult by 1.e3 and scale by dn/rho00
2499 ! naer needs units of cm**-3, so mult by 1.e-6
2501 ! dp1 = 1.e3*0.0000594*(273.16 - t0(ix,jy,kz))**3.33 * (1.e-6*cin*dn(ix,jy,kz))**(0.0264*(273.16 - t0(ix,jy,kz)) + 0.0033)
2502 dp1 = 1.e3*dn(ix,jy,kz)/rho00*0.0000594*(273.16 - t0(ix,jy,kz))**3.33 * (1.e-6*naer)**(0.0264*(273.16 - t0(ix,jy,kz)) + 0.0033)
2503 t7(ix,jy,kz) = Min(dp1, 1.0d30)
2513 end if ! ( ssival .gt. 1.0 )
2519 has_wetscav = .false.
2520 IF ( wrfchem_flag > 0 ) THEN
2521 IF ( PRESENT( wetscav_on ) ) THEN
2522 has_wetscav = wetscav_on
2523 IF ( has_wetscav ) THEN
2524 IF ( PRESENT( rainprod ) ) rainprod2d(its:ite,kts:kte) = 0
2525 IF ( PRESENT( evapprod ) ) evapprod2d(its:ite,kts:kte) = 0
2531 ! transform from number mixing ratios to number conc.
2534 IF ( denscale(il) == 1 ) THEN
2537 an(ix,1,kz,il) = an(ix,1,kz,il)*dn(ix,kz,jy)
2550 ! for real cases when hydrometeor mixing ratios have been initialized without concentrations
2551 IF ( itimestep == 1 .and. ipconc > 0 ) THEN
2552 call calcnfromq(nx,ny,nz,an,na,nor,nor,dn1)
2556 IF ( present(cu_used) .and. &
2557 ( present( qrcuten ) .or. present( qscuten ) .or. &
2558 present( qicuten ) .or. present( qccuten ) ) ) THEN
2560 IF ( cu_used == 1 ) THEN
2564 IF ( present( qrcuten ) ) ancuten(ix,1,kz,lr) = dtp*qrcuten(ix,kz,jy)
2565 IF ( present( qscuten ) ) ancuten(ix,1,kz,ls) = dtp*qscuten(ix,kz,jy)
2566 IF ( present( qicuten ) ) ancuten(ix,1,kz,li) = dtp*qicuten(ix,kz,jy)
2567 IF ( present( qccuten ) ) ancuten(ix,1,kz,lc) = dtp*qccuten(ix,kz,jy)
2572 call calcnfromcuten(nx,ny,nz,ancuten,an,na,nor,nor,dn1)
2580 call sediment1d(dtp,nx,ny,nz,an,na,nor,nor,xfall,dn1,dz2d,dz2dinv, &
2581 & t0,t7,infdo,jy,its,jts &
2582 & ,timesed1,timesed2,timesed3,zmaxsed,timesetvt)
2585 ! copy xfall to appropriate places...
2587 ! write(0,*) 'N2M: end sediment, jy = ',jy
2591 RAINNCV(ix,jy) = dtp*dn1(ix,1,1)*(xfall(ix,1,lr) + xfall(ix,1,ls)*1000./xdn0(lr) + &
2592 & xfall(ix,1,lh)*1000./xdn0(lr) + xfall(ix,1,lhl)*1000./xdn0(lr) )
2594 RAINNCV(ix,jy) = dtp*dn1(ix,1,1)*(xfall(ix,1,lr) + xfall(ix,1,ls)*1000./xdn0(lr) + &
2595 & xfall(ix,1,lh)*1000./xdn0(lr) )
2597 IF ( present ( rainncw2 ) ) THEN ! rain only
2598 rainncw2(ix,jy) = rainncw2(ix,jy) + dtp*dn1(ix,1,1)*xfall(ix,1,lr)
2600 IF ( present ( rainnci2 ) ) THEN ! ice only
2602 rainnci2(ix,jy) =rainnci2(ix,jy) + dtp*dn1(ix,1,1)*(xfall(ix,1,ls)*1000./xdn0(lr) + &
2603 & xfall(ix,1,lh)*1000./xdn0(lr) + xfall(ix,1,lhl)*1000./xdn0(lr) )
2605 rainnci2(ix,jy) = rainnci2(ix,jy) + dtp*dn1(ix,1,1)*(xfall(ix,1,ls)*1000./xdn0(lr) + &
2606 & xfall(ix,1,lh)*1000./xdn0(lr) )
2609 IF ( present( SNOWNCV ) ) SNOWNCV(ix,jy) = dtp*dn1(ix,1,1)*xfall(ix,1,ls)*1000./xdn0(lr)
2610 IF ( present( GRPLNCV ) ) GRPLNCV(ix,jy) = dtp*dn1(ix,1,1)*xfall(ix,1,lh)*1000./xdn0(lr)
2611 RAINNC(ix,jy) = RAINNC(ix,jy) + RAINNCV(ix,jy)
2613 IF ( present (SNOWNC) .and. present (SNOWNCV) ) SNOWNC(ix,jy) = SNOWNC(ix,jy) + SNOWNCV(ix,jy)
2616 ! IF ( .true. ) THEN
2618 IF ( present( HAILNC ) ) THEN
2620 HAILNCV(ix,jy) = dtp*dn1(ix,1,1)*xfall(ix,1,lhl)*1000./xdn0(lr)
2621 HAILNC(ix,jy) = HAILNC(ix,jy) + HAILNCV(ix,jy)
2622 ELSEIF ( present( GRPLNCV ) ) THEN
2623 GRPLNCV(ix,jy) = dtp*dn1(ix,1,1)*xfall(ix,1,lhl)*1000./xdn0(lr)
2626 IF ( present( GRPLNCV ) ) GRPLNC(ix,jy) = GRPLNC(ix,jy) + GRPLNCV(ix,jy)
2627 IF ( present( SR ) .and. present (SNOWNCV) .and. present(GRPLNCV) ) THEN
2628 IF ( present( HAILNC ) ) THEN
2629 SR(ix,jy) = (SNOWNCV(ix,jy)+HAILNCV(ix,jy)+GRPLNCV(ix,jy))/(RAINNCV(ix,jy)+1.e-12)
2631 SR(ix,jy) = (SNOWNCV(ix,jy)+GRPLNCV(ix,jy))/(RAINNCV(ix,jy)+1.e-12)
2638 IF ( isedonly /= 1 ) THEN
2639 ! call nssl_2mom_gs: main gather-scatter routine to calculate microphysics
2641 ! write(0,*) 'N2M: gs, jy = ',jy
2642 ! IF ( isedonly /= 2 ) THEN
2649 & ,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9 &
2653 & ventr,ventc,c1sw,1,ido, &
2655 ! & ln,ipc,lvol,lz,lliq, &
2657 & xdn0,dbz2d,tke2d, &
2658 & timevtcalc,axtra2d, makediag &
2659 & ,has_wetscav, rainprod2d, evapprod2d &
2660 & ,elec2,its,ids,ide,jds,jde &
2667 ENDIF ! isedonly /= 1
2669 ! droplet nucleation/condensation/evaporation
2678 & ,axtra2d, makediag &
2679 & ,ssat,t00,t77,flag_qndrop)
2685 IF ( present( pcc2 ) .and. makediag ) THEN
2688 ! example of using the 'axtra2d' array to get rates out of the microphysics routine for output.
2689 ! Search for 'axtra' to find example code below
2690 ! pcc2(ix,kz,jy) = axtra2d(ix,1,kz,1)
2697 ! compute diagnostic S-band reflectivity if needed
2698 IF ( present( dbz ) .and. makediag ) THEN
2702 IF ( present(ke_diag) ) THEN
2707 call radardd02(nx,ny,nz,nor,na,an,t0, &
2708 & dbz2d,dn1,nz,cnoh,rho_qh,ipconc,kediagloc, 0)
2712 DO kz = kts,kediagloc ! kte
2714 dbz(ix,kz,jy) = dbz2d(ix,1,kz)
2715 IF ( present( vzf ) ) THEN
2716 vzf(ix,kz,jy) = vzf2d(ix,1,kz)
2717 IF ( dbz2d(ix,1,kz) <= 0.0 ) THEN
2719 ELSEIF ( dbz2d(ix,1,kz) <= 15.0 ) THEN
2720 refl = 10**(0.1*dbz2d(ix,1,kz))
2721 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 )
2724 IF ( present( compdbz ) ) THEN
2725 compdbz(ix,jy) = Max( compdbz(ix,jy), dbz2d(ix,1,kz) )
2734 ! Following Greg Thompson, calculation for effective radii. Used by RRTMG LW/SW schemes if enabled in module_physics_init.F
2735 IF ( present( has_reqc ).and. present( has_reqi ) .and. present( has_reqs ) .and. &
2736 present( re_cloud ).and. present( re_ice ) .and. present( re_snow ) ) THEN
2737 IF ( has_reqc.ne.0 .or. has_reqi.ne.0 .or. has_reqs.ne.0) THEN
2740 re_cloud(ix,kz,jy) = 2.51E-6
2741 re_ice(ix,kz,jy) = 10.01E-6
2742 re_snow(ix,kz,jy) = 25.E-6
2743 t1(ix,1,kz) = 2.51E-6
2744 t2(ix,1,kz) = 10.01E-6
2745 t3(ix,1,kz) = 25.E-6
2749 call calc_eff_radius &
2757 re_cloud(ix,kz,jy) = MAX(2.51E-6, MIN(t1(ix,1,kz), 50.E-6))
2758 re_ice(ix,kz,jy) = MAX(10.01E-6, MIN(t2(ix,1,kz), 125.E-6))
2759 re_snow(ix,kz,jy) = MAX(25.E-6, MIN(t3(ix,1,kz), 999.E-6))
2760 ! check for case where snow needs to be treated as cloud ice (for rrtmg radiation)
2761 IF ( .not. present(qi) ) re_ice(ix,kz,jy) = MAX(10.E-6, MIN(t3(ix,1,kz), 125.E-6))
2771 ! transform concentrations back to mixing ratios
2773 IF ( denscale(il) == 1 ) THEN
2776 an(ix,1,kz,il) = an(ix,1,kz,il)/dn(ix,kz,jy)
2782 ! copy 2D slabs back to 3D
2788 th(ix,kz,jy) = an(ix,1,kz,lt)
2790 qv(ix,kz,jy) = an(ix,1,kz,lv)
2791 qc(ix,kz,jy) = an(ix,1,kz,lc)
2792 qr(ix,kz,jy) = an(ix,1,kz,lr)
2793 IF ( present(qi) ) qi(ix,kz,jy) = an(ix,1,kz,li)
2794 qs(ix,kz,jy) = an(ix,1,kz,ls)
2795 qh(ix,kz,jy) = an(ix,1,kz,lh)
2796 IF ( lhl > 1 ) qhl(ix,kz,jy) = an(ix,1,kz,lhl)
2798 IF ( lccn > 1 .and. is_aerosol_aware .and. flag_qnwfa ) THEN
2800 ELSEIF ( present( cn ) .and. lccn > 1 .and. .not. flag_qndrop) THEN
2801 IF ( lccna > 1 .and. .not. present( cna ) ) THEN
2802 cn(ix,kz,jy) = Max(0.0, an(ix,1,kz,lccna) )
2804 cn(ix,kz,jy) = an(ix,1,kz,lccn)
2807 IF ( lccna > 1 ) THEN
2808 IF ( present( cna ) .and. f_cnatmp ) THEN
2809 cna(ix,kz,jy) = Max(0.0, an(ix,1,kz,lccna) )
2813 IF ( lcina > 1 ) THEN
2814 IF ( present( cni ) .and. f_cinatmp ) THEN
2815 cni(ix,kz,jy) = Max(0.0, an(ix,1,kz,lcina) )
2819 IF ( ipconc >= 5 ) THEN
2821 ccw(ix,kz,jy) = an(ix,1,kz,lnc)
2822 crw(ix,kz,jy) = an(ix,1,kz,lnr)
2823 IF ( present( cci ) ) cci(ix,kz,jy) = an(ix,1,kz,lni)
2824 csw(ix,kz,jy) = an(ix,1,kz,lns)
2825 chw(ix,kz,jy) = an(ix,1,kz,lnh)
2826 IF ( lhl > 1 ) chl(ix,kz,jy) = an(ix,1,kz,lnhl)
2832 IF ( lvh > 0 ) vhw(ix,kz,jy) = an(ix,1,kz,lvh)
2833 IF ( lvhl > 0 .and. present( vhl ) ) vhl(ix,kz,jy) = an(ix,1,kz,lvhl)
2835 #if ( WRF_CHEM == 1 )
2836 IF ( has_wetscav ) THEN
2837 IF ( PRESENT( rainprod ) ) rainprod(ix,kz,jy) = rainprod2d(ix,kz)
2838 IF ( PRESENT( evapprod ) ) evapprod(ix,kz,jy) = evapprod2d(ix,kz)
2847 IF ( invertccn .and. present( cn ) ) THEN ! hack to convert unactivated ccn back to activated
2851 cn(ix,kz,jy) = Max( 0.0, qccn - cn(ix,kz,jy) )
2862 END SUBROUTINE nssl_2mom_driver
2864 ! #####################################################################
2865 ! #####################################################################
2867 REAL FUNCTION GAMMA_SP(xx)
2873 ! Double precision ser,stp,tmp,x,y,cof(6)
2875 real*8 ser,stp,tmp,x,y,cof(6)
2877 DATA cof,stp/76.18009172947146d+0, &
2878 & -86.50532032941677d0, &
2879 & 24.01409824083091d0, &
2880 & -1.231739572450155d0, &
2881 & 0.1208650973866179d-2,&
2882 & -0.5395239384953d-5, &
2883 & 2.5066282746310005d0/
2885 IF ( xx <= 0.0 ) THEN
2886 write(0,*) 'Argument to gamma must be > 0!! xx = ',xx
2893 tmp = (x + 0.5d0)*Log(tmp) - tmp
2894 ser = 1.000000000190015d0
2897 ser = ser + cof(j)/y
2899 gamma_sp = Exp(tmp + log(stp*ser/x))
2902 END FUNCTION GAMMA_SP
2904 ! #####################################################################
2906 DOUBLE PRECISION FUNCTION GAMMA_DPR(x)
2907 ! dp gamma with real input
2910 double precision :: xx
2914 gamma_dpr = gamma_dp(xx)
2917 end FUNCTION GAMMA_DPR
2922 ! #####################################################################
2924 real function GAMXINF(A1,X1)
2926 ! ===================================================
2927 ! Purpose: Compute the incomplete gamma function
2928 ! from x to infinity
2929 ! Input : a --- Parameter ( a 170 )
2931 ! Output: GIM --- gamma(a,x) t=x,Infinity
2932 ! Routine called: GAMMA for computing gamma(x)
2933 ! ===================================================
2935 ! IMPLICIT DOUBLE PRECISION (A-H,O-Z)
2938 double precision :: xam,dlog,s,r,ga,t0,a,x
2940 double precision :: gin, gim
2944 IF ( x1 <= 0.0 ) THEN
2945 gamxinf = GAMMA_SP(A1)
2949 IF (XAM.GT.700.0.OR.A.GT.170.0) THEN
2950 WRITE(*,*)'a and/or x too large'
2956 ELSE IF (X.LE.1.0+A) THEN
2962 IF (DABS(R/S).LT.1.0D-15) GO TO 15
2967 ELSE IF (X.GT.1.0+A) THEN
2970 T0=(K-A)/(1.0D0+K/(X+T0))
2972 GIM=DEXP(XAM)/(X+T0)
2979 END function GAMXINF
2981 ! #####################################################################
2983 double precision function GAMXINFDP(A1,X1)
2985 ! ===================================================
2986 ! Purpose: Compute the incomplete gamma function
2987 ! from x to infinity
2988 ! Input : a --- Parameter ( a < 170 )
2990 ! Output: GIM --- Gamma(a,x) t=x,Infinity
2991 ! Routine called: GAMMA for computing gamma_dp(x)
2992 ! ===================================================
2994 ! IMPLICIT DOUBLE PRECISION (A-H,O-Z)
2997 ! dont declare gamma_dp because it is within the module
2998 ! double precision :: gamma_dp
2999 double precision :: xam,dlog,s,r,ga,t0,a,x
3001 double precision :: gin, gim
3005 IF ( x1 <= 0.0 ) THEN
3006 gamxinfdp = GAMMA_DP(A)
3010 IF (XAM.GT.700.0.OR.A.GT.170.0) THEN
3011 WRITE(*,*)'a and/or x too large'
3017 ELSE IF (X.LE.1.0+A) THEN
3023 IF (DABS(R/S).LT.1.0D-15) GO TO 15
3028 ELSE IF (X.GT.1.0+A) THEN
3031 T0=(K-A)/(1.0D0+K/(X+T0))
3033 GIM=DEXP(XAM)/(X+T0)
3040 END function GAMXINFDP
3043 ! #####################################################################
3046 real function gaminterp(ratio, alp, luindex, ilh)
3050 real, intent(in) :: ratio, alp
3051 integer, intent(in) :: ilh ! 1 = graupel, 2 = hail
3052 integer, intent(in) :: luindex ! which argument:
3053 ! gamxinflu(i,j,1,1) = x/y
3054 ! gamxinflu(i,j,2,1) = gamxinf( 2.0+alp, ratio )/y
3055 ! gamxinflu(i,j,3,1) = gamxinf( 2.5+alp+0.5*bxh, ratio )/y
3056 ! gamxinflu(i,j,5,1) = gamxinf( 5.0+alp, ratio )/y
3057 ! gamxinflu(i,j,6,1) = gamxinf( 5.5+alp+0.5*bxh, ratio )/y
3060 real :: delx, dely, tmp1, tmp2, temp3
3061 integer :: i,j,ip1,jp1 !,ilh
3066 i = Min(nqiacrratio,Int(ratio*dqiacrratioinv))
3067 j = Int(Max(0.0,Min(maxalphalu,alp))*dqiacralphainv)
3068 delx = Min(maxratiolu,ratio) - float(i)*dqiacrratio
3069 dely = alp - float(j)*dqiacralpha
3070 ip1 = Min( i+1, nqiacrratio )
3071 jp1 = Min( j+1, nqiacralpha )
3073 ! interpolate along x, i.e., ratio;
3074 tmp1 = gamxinflu(i,j,luindex,ilh) + delx*dqiacrratioinv* &
3075 & (gamxinflu(ip1,j,luindex,ilh) - gamxinflu(i,j,luindex,ilh))
3076 tmp2 = gamxinflu(i,jp1,luindex,ilh) + delx*dqiacrratioinv* &
3077 & (gamxinflu(ip1,jp1,luindex,ilh) - gamxinflu(i,jp1,luindex,ilh))
3079 ! interpolate along alpha;
3081 gaminterp = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))
3084 ! IF ( ilh0 < 0 ) THEN
3085 ! write(0,*) 'gaminterp: ',i,j,ilh,ratio,delx,dely,gamxinflu(i,j,luindex,ilh),tmp1,tmp2
3088 END FUNCTION gaminterp
3089 ! #endif /* Z3MOM */
3090 ! #####################################################################
3092 !**************************** GAML02 ***********************
3093 ! This calculates Gamma(0.2,x)/Gamma[0.2], where is a ratio
3094 ! It is used for qiacr with the gamma of volume to calculate what
3095 ! fraction of drops exceed a certain size (this version is for 40 micron drops)
3096 ! **********************************************************
3097 real FUNCTION GAML02(x)
3099 integer ig, i, ii, n, np
3103 real gamxg(ng), xg(ng)
3104 DATA xg/0.01,0.02,0.025,0.04,0.075,0.1,0.25,0.5,0.75,1.,2.,10./
3106 & 7.391019203578037e-8,0.02212726874591478,0.06959352407989682, &
3107 & 0.2355654024970809,0.46135930387500346,0.545435791452399, &
3108 & 0.7371571313308203, &
3109 & 0.8265676632204345,0.8640182781845841,0.8855756211304151, &
3110 & 0.9245079225301251, &
3111 & 0.9712578342732681/
3112 IF ( x .ge. xg(ng) ) THEN
3116 IF ( x .lt. xg(1) ) THEN
3124 IF ( x .ge. xg(i) ) THEN
3126 gaml02 = gamxg(N)+((X-XG(N))/(XG(NP)-XG(N)))* &
3127 & ( gamxg(NP) - gamxg(N) )
3134 !**************************** GAML02d300 ***********************
3135 ! This calculates Gamma(0.2,x)/Gamma[0.2], where is a ratio
3136 ! It is used for qiacr with the gamma of volume to calculate what
3137 ! fraction of drops exceed a certain size (this version is for 300 micron drops) (see zieglerstuff.nb)
3138 ! **********************************************************
3139 real FUNCTION GAML02d300(x)
3141 integer ig, i, ii, n, np
3145 real gamxg(ng), xg(ng)
3146 DATA xg/0.04,0.075,0.1,0.25,0.5,0.75,1.,2.,10./
3149 & 7.391019203578011e-8,0.0002260640810600053, &
3150 & 0.16567071824457152, &
3151 & 0.4231369044918005,0.5454357914523988, &
3152 & 0.6170290936864555, &
3153 & 0.7471346054110058,0.9037156157718299 /
3154 IF ( x .ge. xg(ng) ) THEN
3158 IF ( x .lt. xg(1) ) THEN
3166 IF ( x .ge. xg(i) ) THEN
3168 GAML02d300 = gamxg(N)+((X-XG(N))/(XG(NP)-XG(N)))* &
3169 & ( gamxg(NP) - gamxg(N) )
3174 END FUNCTION GAML02d300
3177 ! #####################################################################
3178 ! #####################################################################
3180 !**************************** GAML02 ***********************
3181 ! This calculates Gamma(0.2,x)/Gamma[0.2], where is a ratio
3182 ! It is used for qiacr with the gamma of volume to calculate what
3183 ! fraction of drops exceed a certain size (this version is for 500 micron drops) (see zieglerstuff.nb)
3184 ! **********************************************************
3185 real FUNCTION GAML02d500(x)
3187 integer ig, i, ii, n, np
3191 real gamxg(ng), xg(ng)
3192 DATA xg/0.04,0.075,0.1,0.25,0.5,0.75,1.,2.,10./
3195 & 2.2346039e-13, 0.0221272687459, &
3196 & 0.23556540, 0.38710348, &
3197 & 0.48136183,0.6565833, &
3199 IF ( x .ge. xg(ng) ) THEN
3203 IF ( x .lt. xg(1) ) THEN
3211 IF ( x .ge. xg(i) ) THEN
3213 GAML02d500 = gamxg(N)+((X-XG(N))/(XG(NP)-XG(N)))* &
3214 & ( gamxg(NP) - gamxg(N) )
3219 END FUNCTION GAML02d500
3222 ! #####################################################################
3224 ! #####################################################################
3227 real function BETA(P,Q)
3229 ! ==========================================
3230 ! Purpose: Compute the beta function B(p,q)
3231 ! Input : p --- Parameter ( p > 0 )
3232 ! q --- Parameter ( q > 0 )
3233 ! Output: BT --- B(p,q)
3234 ! Routine called: GAMMA for computing gamma(x)
3235 ! ==========================================
3237 ! IMPLICIT real (A-H,O-Z)
3239 double precision p1,gp,q1,gq, ppq,gpq
3247 CALL GAMMADP(PPQ,GPQ)
3252 ! #####################################################################
3253 ! #####################################################################
3255 DOUBLE PRECISION FUNCTION GAMMA_DP(xx)
3261 ! Double precision ser,stp,tmp,x,y,cof(6)
3263 real*8 ser,stp,tmp,x,y,cof(6)
3265 DATA cof,stp/76.18009172947146d+0, &
3266 & -86.50532032941677d0, &
3267 & 24.01409824083091d0, &
3268 & -1.231739572450155d0, &
3269 & 0.1208650973866179d-2,&
3270 & -0.5395239384953d-5, &
3271 & 2.5066282746310005d0/
3276 tmp = (x + 0.5d0)*Log(tmp) - tmp
3277 ser = 1.000000000190015d0
3280 ser = ser + cof(j)/y
3282 gamma_dp = Exp(tmp + log(stp*ser/x))
3285 END function gamma_dp
3286 ! #####################################################################
3288 SUBROUTINE GAMMADP(X,GA)
3290 ! ==================================================
3291 ! Purpose: Compute gamma function Gamma(x)
3292 ! Input : x --- Argument of Gamma(x)
3293 ! ( x is not equal to 0,-1,-2,...)
3294 ! Output: GA --- gamma(x)
3295 ! ==================================================
3297 ! IMPLICIT DOUBLE PRECISION (A-H,O-Z)
3300 double precision, parameter :: PI=3.141592653589793D0
3301 double precision :: x,ga,z,r,gr
3304 double precision :: G(26)
3306 IF (X.EQ.INT(X)) THEN
3307 IF (X.GT.0.0D0) THEN
3317 IF (DABS(X).GT.1.0D0) THEN
3328 DATA G/1.0D0,0.5772156649015329D0, &
3329 & -0.6558780715202538D0, -0.420026350340952D-1, &
3330 & 0.1665386113822915D0,-.421977345555443D-1, &
3331 & -.96219715278770D-2, .72189432466630D-2, &
3332 & -.11651675918591D-2, -.2152416741149D-3, &
3333 & .1280502823882D-3, -.201348547807D-4, &
3334 & -.12504934821D-5, .11330272320D-5, &
3335 & -.2056338417D-6, .61160950D-8, &
3336 & .50020075D-8, -.11812746D-8, &
3337 & .1043427D-9, .77823D-11, &
3338 & -.36968D-11, .51D-12, &
3339 & -.206D-13, -.54D-14, .14D-14, .1D-15/
3345 IF (DABS(X).GT.1.0D0) THEN
3347 IF (X.LT.0.0D0) GA=-PI/(X*GA*DSIN(PI*X))
3351 END SUBROUTINE GAMMADP
3354 ! #####################################################################
3355 ! #####################################################################
3358 ! #####################################################################
3359 Function delbk(bb,nu,mu,k)
3361 ! Purpose: Caluculates collection coefficients following Siefert (2006)
3363 ! delbk is equation (90) (b collecting b -- self-collection)
3364 ! mass-diameter relationship: D = a*x**(b), where x = particle mass
3365 ! general distribution: n(x) = A*x**(nu)*Exp(-lam*x**(mu))
3367 ! A = mu*N/(Gamma((nu+1)/mu)) *lam**((nu+1)/mu)
3369 ! lam = ( Gamma((nu+1)/mu)/Gamma((nu+2)/mu) * xbar )**(-mu)
3371 ! where xbar = L/N (mass content)/(number concentration) = q*rhoa/N
3383 tmp = ((1.0 + nu)/mu)
3384 i = Int(dgami*(tmp))
3386 x1 = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3388 tmp = ((2.0 + nu)/mu)
3389 i = Int(dgami*(tmp))
3391 x2 = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3393 tmp = ((1.0 + 2.0*bb + k + nu)/mu)
3394 i = Int(dgami*(tmp))
3396 x3 = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3399 ! & ((Gamma_sp((1.0 + nu)/mu)/Gamma_sp((2.0 + nu)/mu))**(2.0*bb + k)* &
3400 ! & Gamma_sp((1.0 + 2.0*bb + k + nu)/mu))/Gamma_sp((1.0 + nu)/mu)
3403 & ((x1/x2)**(2.0*bb + k)* &
3409 ! #####################################################################
3412 ! #####################################################################
3413 ! Equation (91) in Seifert and Beheng (2006) ("a" collecting "b")
3414 Function delabk(ba,bb,nua,nub,mua,mub,k)
3425 real g1pnua, g2pnua, g1pbapnua, g1pbbpk, g1pnub, g2pnub
3427 tmp = (1. + nua)/mua
3428 i = Int(dgami*(tmp))
3430 IF ( i+1 > ngm0 ) THEN
3431 write(0,*) 'delabk: i+1 > ngm0!!!!',i,ngm0,nua,mua,tmp
3434 g1pnua = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3435 ! write(91,*) 'delabk: g1pnua,gamma = ',g1pnua,Gamma_sp((1. + nua)/mua)
3437 tmp = ((2. + nua)/mua)
3438 i = Int(dgami*(tmp))
3440 g2pnua = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3442 tmp = ((1. + ba + nua)/mua)
3443 i = Int(dgami*(tmp))
3445 g1pbapnua = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3447 tmp = ((1. + nub)/mub)
3448 i = Int(dgami*(tmp))
3450 g1pnub = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3452 tmp = ((2 + nub)/mub)
3453 i = Int(dgami*(tmp))
3455 g2pnub = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3457 tmp = ((1. + bb + k + nub)/mub)
3458 i = Int(dgami*(tmp))
3460 g1pbbpk = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3463 & (2.*(g1pnua/g2pnua)**ba* &
3465 & (g1pnub/g2pnub)**(bb + k)* &
3473 ! #####################################################################
3475 ! #####################################################################
3476 !--------------------------------------------------------------------------
3477 subroutine cld_cpu(string)
3480 character( LEN = * ) string
3484 end subroutine cld_cpu
3487 !--------------------------------------------------------------------------
3489 !--------------------------------------------------------------------------
3491 subroutine sediment1d(dtp,nx,ny,nz,an,na,nor,norz,xfall,dn,dz3d,dz3dinv, &
3492 & t0,t7,infdo,jslab,its,jts, &
3493 & timesed1,timesed2,timesed3,zmaxsed,timesetvt) ! used for timing
3495 ! Sedimentation driver -- column by column
3497 ! Written by ERM 10/2011
3503 integer nx,ny,nz,nor,norz,ngt,jgs,na,ia
3504 integer id ! =1 use density, =0 no density
3505 integer :: its,jts ! SW point of local tile
3510 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
3511 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
3512 real dz3d(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
3513 real dz3dinv(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
3514 real t0(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
3515 real t7(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
3517 ! real gz(-nor+ng1:nz+nor),z1d(-nor+ng1:nz+nor,4)
3519 real xfall(nx,ny,na) ! array for stuff landing on the ground
3520 real xfall0(nx,ny) ! dummy array
3522 integer jslab ! which line of xfall to use
3524 integer ix,jy,kz,ndfall,n,k,il,in
3525 real tmp, vtmax, dtptmp, dtfrac
3526 real, parameter :: dz = 200.
3528 real :: xvt(nz+1,nx,3,lc:lhab) ! (nx,nz,2,lc:lhab) ! 1=mass-weighted, 2=number-weighted
3529 real :: tmpn(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
3530 real :: tmpn2(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
3531 real :: z(-nor+ng1:nx+nor,-norz+ng1:nz+norz,lr:lhab)
3532 real :: db1(nx,nz+1),dtz1(nz+1,nx,0:1),dz2dinv(nz+1,nx),db1inv(nx,nz+1)
3534 real :: rhovtzx(nz,nx)
3536 double precision :: timesed1,timesed2,timesed3, zmaxsed,timesetvt,dummy
3537 double precision :: dt1,dt2,dt3,dt4
3539 integer,parameter :: ngs = 128
3540 integer :: ngscnt,mgs,ipconc0
3542 real :: qx(ngs,lv:lhab)
3543 real :: qxw(ngs,ls:lhab)
3544 real :: cx(ngs,lc:lhab)
3545 real :: xv(ngs,lc:lhab)
3546 real :: vtxbar(ngs,lc:lhab,3)
3547 real :: xmas(ngs,lc:lhab)
3548 real :: xdn(ngs,lc:lhab)
3549 real :: xdia(ngs,lc:lhab,3)
3550 real :: vx(ngs,li:lhab)
3551 real :: alpha(ngs,lc:lhab)
3552 real :: zx(ngs,lr:lhab)
3553 logical :: hasmass(nx,lc+1:lhab)
3555 integer igs(ngs),kgs(ngs)
3557 real rho0(ngs),temcg(ngs)
3563 real cwnc(ngs),cinc(ngs)
3564 real fadvisc(ngs),cwdia(ngs),cipmas(ngs)
3566 real cimasn,cimasx,cnina(ngs),cimas(ngs)
3571 !-----------------------------------------------------------------------------
3573 integer :: ixb, jyb, kzb
3574 integer :: ixe, jye, kze
3577 logical :: debug_mpi = .TRUE.
3579 ! ###################################################################
3596 ! zero the precip flux arrays (2d)
3601 if ( ndebug .gt. 0 ) write(0,*) 'dbg = 3a'
3606 db1(ix,kz) = dn(ix,jy,kz)
3607 db1inv(ix,kz) = 1./dn(ix,jy,kz)
3608 rhovtzx(kz,ix) = Sqrt(rho00*Min(1.0/0.05, db1inv(ix,kz))) ! prevent excessive rhovt
3614 dtz1(kz,ix,0) = dz3dinv(ix,jy,kz)
3615 dtz1(kz,ix,1) = dz3dinv(ix,jy,kz)*db1inv(ix,kz)
3616 dz2dinv(kz,ix) = dz3dinv(ix,jy,kz)
3620 IF ( lzh .gt. 1 ) THEN
3623 an(ix,jy,kz,lzh) = Max( 0., an(ix,jy,kz,lzh) )
3631 ! hasmass(ix,il) = Any( an(ix,jy,:,il) > qxmin(il) )
3638 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3a2'
3646 call ziegfall1d(nx,ny,nz,nor,norz,na,dtp,jgs,ix, &
3648 & an,dn,ipconc,t0,t7,cwmasn,cwmasx, &
3650 & qxmin,xdnmx,xdnmn,cdx,cno,xdn0,xvmn,xvmx, &
3651 & ngs,qx,qxw,cx,xv,vtxbar,xmas,xdn,xdia,vx,alpha,zx,igs,kgs, &
3652 & rho0,temcg,temg,rhovt,cwnc,cinc,fadvisc,cwdia,cipmas,cnina,cimas, &
3658 ! loop over each species and do sedimentation for all moments
3660 IF ( ido(il) == 0 ) CYCLE
3662 ! IF ( .not. hasmass(ix,il) ) CYCLE
3672 ! apply limit vtmaxsed (08/20/2015)
3673 xvt(kz,ix,1,il) = Min( vtmaxsed, xvt(kz,ix,1,il) )
3674 xvt(kz,ix,2,il) = Min( vtmaxsed, xvt(kz,ix,2,il) )
3675 xvt(kz,ix,3,il) = Min( vtmaxsed, xvt(kz,ix,3,il) )
3677 vtmax = Max(vtmax,xvt(kz,ix,1,il)*dz2dinv(kz,ix))
3678 vtmax = Max(vtmax,xvt(kz,ix,2,il)*dz2dinv(kz,ix))
3679 vtmax = Max(vtmax,xvt(kz,ix,3,il)*dz2dinv(kz,ix))
3681 ! IF ( dtp*xvt(kz,ix,1,il)*dz2dinv(kz,ix) >= 0.7 .or. &
3682 ! & dtp*xvt(kz,ix,2,il)*dz2dinv(kz,ix) >= 0.7 .or. &
3683 ! & dtp*xvt(kz,ix,3,il)*dz2dinv(kz,ix) >= 0.7 ) THEN
3685 ! zmaxsed = Max(zmaxsed, float(kz) )
3686 !! plo = Min(plo,kz)
3687 !! phi = Max(phi,kz)
3693 IF ( vtmax == 0.0 ) CYCLE
3697 IF ( dtp*vtmax .lt. 0.7 ) THEN ! check whether multiple steps are needed.
3700 IF ( dtp > 20.0 ) THEN ! more stringent subdivision for large time steps
3701 ndfall = Max(2, Int(dtp*vtmax/0.7) + 1)
3702 ELSE ! more relaxed for small time steps, but might still be a problem for very thin vertical layers near the ground
3703 ndfall = 1+Int(dtp*vtmax + 0.301)
3707 IF ( ndfall .gt. 1 ) THEN
3708 dtptmp = dtp/Real(ndfall)
3709 ! write(0,*) 'subdivide fallout on its,jts,ix,plo,phi = ',its,jts,ix,plo,phi
3710 ! write(0,*) 'for il,jsblab,c,ndfall = ',il,jslab,dtp*vtmax,ndfall
3720 IF ( do_accurate_sedimentation .and. n .ge. 2 .and. ( n == n*(n/interval_sedi_vt) ) ) THEN
3722 ! zero the precip flux arrays (2d)
3725 ! xvt(:,:,:,il) = 0.0
3727 call ziegfall1d(nx,ny,nz,nor,norz,na,dtp,jgs,ix, &
3729 & an,dn,ipconc,t0,t7,cwmasn,cwmasx, &
3731 & qxmin,xdnmx,xdnmn,cdx,cno,xdn0,xvmn,xvmx, &
3732 & ngs,qx,qxw,cx,xv,vtxbar,xmas,xdn,xdia,vx,alpha,zx,igs,kgs, &
3733 & rho0,temcg,temg,rhovt,cwnc,cinc,fadvisc,cwdia,cipmas,cnina,cimas, &
3739 ! apply limit vtmaxsed (08/20/2015)
3740 xvt(kz,ix,1,il) = Min( vtmaxsed, xvt(kz,ix,1,il) )
3741 xvt(kz,ix,2,il) = Min( vtmaxsed, xvt(kz,ix,2,il) )
3742 xvt(kz,ix,3,il) = Min( vtmaxsed, xvt(kz,ix,3,il) )
3751 IF ( il >= lr .and. ( infall .eq. 3 .or. infall .eq. 4 ) .and. ln(il) > 0 ) THEN
3752 IF ( (il .eq. lr .and. irfall .eq. infall .and. lzr < 1) .or. (il .ge. lh .and. lz(il) .lt. 1 ) ) THEN
3753 call calczgr1d(nx,ny,nz,nor,na,an,ixe,kze, &
3754 & z,db1,jgs,ipconc, dnu(il), il, ln(il), qxmin(il), xvmn(il), xvmx(il), lvol(il), xdn0(il), ix )
3758 if (ndebug .gt. 0 ) write(0,*) 'dbg = 1b'
3762 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
3763 & an,db1,il,1,xfall,dtz1,ix)
3766 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3c'
3770 IF ( ldovol .and. il >= li ) THEN
3771 IF ( lvol(il) .gt. 1 ) THEN
3772 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
3773 & an,db1,lvol(il),0,xfall,dtz1,ix)
3778 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3d'
3781 IF ( ipconc .gt. 0 ) THEN !{
3782 IF ( ipconc .ge. ipc(il) ) THEN
3784 IF ( ( infall .ge. 2 .or. (infall .eq. 0 .and. il .lt. lh) ) .and. lz(il) .lt. 1) THEN !{
3786 ! load number conc. into tmpn to do fallout by mass-weighted mean fall speed
3787 ! to put a lower bound on number conc.
3790 IF ( ( infall .eq. 3 .or. infall .eq. 4 ) .and. ( il .eq. lh .or. il .eq. lhl .or. &
3791 & ( il .eq. lr .and. irfall .eq. infall) ) ) THEN
3795 tmpn2(ix,jy,kz) = z(ix,kz,il)
3800 tmpn(ix,jy,kz) = an(ix,jy,kz,ln(il))
3808 tmpn(ix,jy,kz) = an(ix,jy,kz,ln(il))
3817 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3f'
3820 IF ( infall .eq. 1 ) in = 1
3822 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,in,il), &
3823 & an,db1,ln(il),0,xfall,dtz1,ix)
3826 IF ( lz(il) .lt. 1 ) THEN ! if not 3-moment, run one of the correction schemes
3827 IF ( (infall .ge. 2 .or. infall .eq. 3) .and. .not. (infall .eq. 0 .and. il .ge. lh) &
3828 & .and. ( il .eq. lr .or. (il .ge. li .and. il .le. lhab) )) THEN
3829 ! : .or. il .eq. lhl )) THEN
3833 IF ( ( infall .eq. 3 .or. infall .eq. 4 ) .and. &
3834 & ( il .ge. lh .or. (il .eq. lr .and. irfall .eq. infall) ) ) THEN
3835 call fallout1d(nx,ny,nz,nor,1,dtptmp,dtfrac,jgs,xvt(1,1,3,il), &
3836 & tmpn2,db1,1,0,xfall0,dtz1,ix)
3837 call fallout1d(nx,ny,nz,nor,1,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
3838 & tmpn,db1,1,0,xfall0,dtz1,ix)
3840 call fallout1d(nx,ny,nz,nor,1,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
3841 & tmpn,db1,1,0,xfall0,dtz1,ix)
3844 IF ( ( infall .eq. 3 .or. infall .eq. 4 ) .and. ( (il .eq. lr .and. irfall .eq. infall) &
3845 & .or. il .ge. lh ) ) THEN
3846 ! "Method I" - dbz correction
3848 call calcnfromz1d(nx,ny,nz,nor,na,an,tmpn2,ixe,kze, &
3849 & z,db1,jgs,ipconc, dnu(il), il, ln(il), qxmin(il), xvmn(il), xvmx(il),tmpn, &
3850 & lvol(il), rho_qh, infall, ix)
3852 ELSEIF ( infall .eq. 5 .and. il .ge. lh .or. ( il == lr .and. irfall == 5 ) ) THEN
3856 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) ))
3861 ELSEIF ( .not. (il .eq. lr .and. irfall .eq. 0) ) THEN
3862 ! "Method II" M-wgt N-fallout correction
3867 an(ix,jgs,kz,ln(il)) = Max( an(ix,jgs,kz,ln(il)), tmpn(ix,jy,kz) )
3872 ENDIF ! lz(il) .lt. 1
3891 END SUBROUTINE SEDIMENT1D
3894 ! #####################################################################
3897 ! #####################################################################
3901 !--------------------------------------------------------------------------
3903 !--------------------------------------------------------------------------
3905 subroutine fallout1d(nx,ny,nz,nor,na,dtp,dtfrac,jgs,vt, &
3906 & a,db1,ia,id,xfall,dtz1,ixcol)
3908 ! First-order, upwind fallout scheme
3910 ! Written by ERM 6/10/2011
3916 integer nx,ny,nz,nor,ngt,jgs,na,ia
3917 integer id ! =1 use density, =0 no density
3922 ! real dz3dinv(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
3923 ! real a(nx,ny,nz,na)
3924 real a(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,na) ! quantity to be 'advected'
3925 real vt(nz+1,nx) ! terminal speed for a
3928 real xfall(nx,ny,na) ! array for stuff landing on the ground
3929 real db1(nx,nz+1),dtz1(nz+1,nx,0:1)
3933 integer ix,jy,kz,n,k
3936 integer imn,imx,kmn,kmx
3939 !-----------------------------------------------------------------------------
3941 integer :: ixb, jyb, kzb
3942 integer :: ixe, jye, kze
3944 logical :: debug_mpi = .TRUE.
3946 ! ###################################################################
3971 ! cmax = Max(cmax, vt(ix,kz)*dz3dinv(ix,jy,kz))
3974 qtmp1(kz) = a(ix,jgs,kz,ia)*vt(kz,ix)*db1(ix,kz)
3976 qtmp1(kz) = a(ix,jgs,kz,ia)*vt(kz,ix)
3979 IF ( a(ix,jgs,kz,ia) .ne. 0.0 ) THEN
3990 ! first check if fallout is worth doing
3991 ! IF ( cmax .eq. 0.0 .or. imn .gt. imx ) THEN
3995 IF ( kmn == 1 ) THEN
3998 ! do ix = imn,imx ! 1,nx-1
3999 xfall(ix,jy,ia) = xfall(ix,jy,ia) + a(ix,jgs,kz,ia)*vt(kz,ix)*dtfrac
4006 a(ix,jgs,kz,ia) = a(ix,jgs,kz,ia) + dtp*dtz1(kz,ix,id)*(qtmp1(kz+1) - qtmp1(kz) )
4012 END SUBROUTINE FALLOUT1D
4014 ! ##############################################################################
4015 ! ##############################################################################
4017 subroutine calczgr1d(nx,ny,nz,nor,na,a,ixe,kze, &
4018 & z,db,jgs,ipconc, alpha, l,ln, qmin, xvmn,xvmx, lvol, rho_qx, ixcol)
4023 integer nx,ny,nz,nor,na,ngt,jgs
4025 integer, parameter :: norz = 3
4026 real a(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,na)
4027 real z(-nor+1:nx+nor,-nor+1:nz+nor,lr:lhab) ! reflectivity
4028 real db(nx,nz+1) ! air density
4029 ! real gt(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,ngt)
4036 integer l ! index for q
4037 integer ln ! index for N
4038 integer lvol ! index for volume
4043 real vr,qr,nrx,rd,xv,g1,zx,chw,xdn
4049 IF ( l .eq. lh .or. l .eq. lhl .or. ( l .eq. lr .and. imurain == 1 ) ) THEN
4056 IF ( a(ix,jy,kz,l) .gt. qmin .and. a(ix,jy,kz,ln) .gt. 1.e-15 ) THEN
4058 IF ( lvol .gt. 1 ) THEN
4059 IF ( a(ix,jy,kz,lvol) .gt. 0.0 ) THEN
4060 xdn = db(ix,kz)*a(ix,jy,kz,l)/a(ix,jy,kz,lvol)
4061 xdn = Min( 900., Max( hdnmn, xdn ) )
4069 IF ( l == lr ) xdn = 1000.
4072 xv = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
4073 chw = a(ix,jy,kz,ln)
4075 IF ( xv .lt. xvmn .or. xv .gt. xvmx ) THEN
4076 xv = Min( xvmx, Max( xvmn,xv ) )
4077 chw = db(ix,kz)*a(ix,jy,kz,l)/(xv*xdn)
4080 g1 = (6.0 + alpha)*(5.0 + alpha)*(4.0 + alpha)/ &
4081 & ((3.0 + alpha)*(2.0 + alpha)*(1.0 + alpha))
4082 zx = g1*db(ix,kz)**2*(a(ix,jy,kz,l))*a(ix,jy,kz,l)/chw
4083 ! z(ix,kz,l) = 1.e18*zx*(6./(pi*1000.))**2
4084 z(ix,kz,l) = zx*(6./(pi*1000.))**2
4087 ! IF ( ny.eq.2 .and. kz .ge. 25 .and. kz .le. 29 .and. z(ix,kz,l) .gt. 0. ) THEN
4088 ! write(*,*) 'calczgr: z,dbz,xdn = ',ix,kz,z(ix,kz,l),10*log10(z(ix,kz,l)),xdn
4099 ELSEIF ( l .eq. lr .and. imurain == 3) THEN
4104 IF ( a(ix,jy,kz,l) .gt. qmin .and. a(ix,jy,kz,ln) .gt. 1.e-15 ) THEN
4106 vr = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
4107 ! z(ix,kz,l) = 3.6e18*(rnu+2.0)*a(ix,jy,kz,ln)*vr**2/(rnu+1.0)
4108 z(ix,kz,l) = 3.6*(rnu+2.0)*a(ix,jy,kz,ln)*vr**2/(rnu+1.0)
4109 ! qr = a(ix,jy,kz,lr)
4110 ! nrx = a(ix,jy,kz,lnr)
4125 END subroutine calczgr1d
4127 ! ##############################################################################
4128 ! ##############################################################################
4130 ! Subroutine to correct number concentration to prevent reflectivity growth by
4131 ! sedimentation in 2-moment ZXX scheme.
4132 ! Calculation is in a slab (constant jgs)
4135 subroutine calcnfromz1d(nx,ny,nz,nor,na,a,t0,ixe,kze, &
4136 & z0,db,jgs,ipconc, alpha, l,ln, qmin, xvmn,xvmx,t1, &
4137 & lvol, rho_qx, infall, ixcol)
4142 integer nx,ny,nz,nor,na,ngt,jgs,ixcol
4144 real a(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,na) ! sedimented N and q
4145 real t0(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor) ! sedimented reflectivity
4146 real t1(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor) ! sedimented N (by Vm)
4147 ! real gt(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,ngt)
4148 real z0(-nor+1:nx+nor,-nor+1:nz+nor,lr:lhab) ! initial reflectivity
4150 real db(nx,nz+1) ! air density
4157 integer l ! index for q
4158 integer ln ! index for N
4159 integer lvol ! index for volume
4165 double precision vr,qr,nrx,rd,g1,zx,chw,z,znew,zt,zxt
4167 integer :: ndbz, nmwgt, nnwgt, nwlessthanz
4179 IF ( l .eq. lh .or. l .eq. lhl .or. ( l == lr .and. imurain == 1 ) ) THEN
4181 g1 = (6.0 + alpha)*(5.0 + alpha)*(4.0 + alpha)/ &
4182 & ((3.0 + alpha)*(2.0 + alpha)*(1.0 + alpha))
4187 IF ( t0(ix,jy,kz) .gt. 0. ) THEN ! {
4189 IF ( lvol .gt. 1 ) THEN
4190 IF ( a(ix,jy,kz,lvol) .gt. 0.0 ) THEN
4191 xdn = db(ix,kz)*a(ix,jy,kz,l)/a(ix,jy,kz,lvol)
4192 xdn = Min( 900., Max( hdnmn, xdn ) )
4200 IF ( l == lr ) xdn = 1000.
4203 xv = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
4204 chw = a(ix,jy,kz,ln)
4206 IF ( xv .lt. xvmn .or. xv .gt. xvmx ) THEN
4207 xv = Min( xvmx, Max( xvmn,xv ) )
4208 chw = db(ix,kz)*a(ix,jy,kz,l)/(xv*xdn)
4211 zx = g1*db(ix,kz)**2*( a(ix,jy,kz,l))*a(ix,jy,kz,l)/chw
4212 z = zx*(6./(pi*1000.))**2
4215 IF ( (z .gt. t0(ix,jy,kz) .and. z .gt. 0.0 .and. &
4216 & t0(ix,jy,kz) .gt. z0(ix,kz,l) )) THEN !{
4218 zx = t0(ix,jy,kz)/((6./(pi*1000.))**2)
4220 nrx = g1*db(ix,kz)**2*( a(ix,jy,kz,l))*a(ix,jy,kz,l)/zx
4221 IF ( infall .eq. 3 ) THEN
4222 IF ( nrx .gt. a(ix,jy,kz,ln) ) THEN
4224 IF ( t1(ix,jy,kz) .lt. ndbz ) nwlessthanz = nwlessthanz + 1
4228 a(ix,jy,kz,ln) = Max( real(nrx), a(ix,jy,kz,ln) )
4230 IF ( nrx .gt. a(ix,jy,kz,ln) .and. t1(ix,jy,kz) .gt. a(ix,jy,kz,ln) ) THEN
4231 IF ( nrx .lt. t1(ix,jy,kz) ) THEN
4235 IF ( t1(ix,jy,kz) .lt. ndbz ) nwlessthanz = nwlessthanz + 1
4241 a(ix,jy,kz,ln) = Max(Min( real(nrx), t1(ix,jy,kz) ), a(ix,jy,kz,ln) )
4245 IF ( t1(ix,jy,kz) .gt. 0 .and. a(ix,jy,kz,ln) .gt. 0 ) THEN
4246 IF ( t1(ix,jy,kz) .gt. a(ix,jy,kz,ln) ) THEN
4252 a(ix,jy,kz,ln) = Max(t1(ix,jy,kz), a(ix,jy,kz,ln) )
4253 nrx = a(ix,jy,kz,ln)
4261 IF ( t1(ix,jy,kz) .gt. 0 .and. a(ix,jy,kz,ln) .gt. 0 ) THEN
4262 IF ( t1(ix,jy,kz) .gt. a(ix,jy,kz,ln) ) THEN
4273 ELSEIF ( l .eq. lr .and. imurain == 3) THEN
4278 IF ( t0(ix,jy,kz) .gt. 0. ) THEN
4280 vr = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
4281 z = 3.6*(rnu+2.0)*a(ix,jy,kz,ln)*vr**2/(rnu+1.0)
4283 IF ( z .gt. t0(ix,jy,kz) .and. z .gt. 0.0 .and. &
4284 & t0(ix,jy,kz) .gt. 0.0 &
4285 & .and. t0(ix,jy,kz) .gt. z0(ix,kz,l) ) THEN
4287 vr = db(ix,kz)*a(ix,jy,kz,l)/(xdn)
4288 chw = a(ix,jy,kz,ln)
4289 nrx = 3.6*(rnu+2.0)*vr**2/((rnu+1.0)*t0(ix,jy,kz))
4290 IF ( infall .eq. 3 ) THEN
4291 a(ix,jy,kz,ln) = Max( real(nrx), a(ix,jy,kz,ln) )
4292 ELSEIF ( infall .eq. 4 ) THEN
4293 a(ix,jy,kz,ln) = Max( Min( real(nrx), t1(ix,jy,kz)), a(ix,jy,kz,ln) )
4298 a(ix,jy,kz,ln) = Max(t1(ix,jy,kz), a(ix,jy,kz,ln) )
4304 a(ix,jy,kz,ln) = Max(t1(ix,jy,kz), a(ix,jy,kz,ln) )
4315 END subroutine calcnfromz1d
4318 ! ##############################################################################
4319 ! ##############################################################################
4321 ! Subroutine to calculate number concentrations from initial state that has only mixing ratio.
4322 ! N will be in #/kg, NOT #/m^3, since sedimentation is done next.
4326 ! 10.27.2015: Added hail calculation
4328 subroutine calcnfromq(nx,ny,nz,an,na,nor,norz,dn)
4333 integer nx,ny,nz,nor,norz,na,ngt,jgs,ixcol
4335 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na) ! scalars (q, N, Z)
4337 real dn(nx,nz+1) ! air density
4344 integer lvol ! index for volume
4349 double precision vr,q,nrx,nrx2,rd,g1h,g1hl,g1r,g1s,zx,chw,z,znew,zt,zxt,n1,laminv1
4350 double precision :: zr, zs, zh, dninv
4351 real, parameter :: xn0s = 3.0e6, xn0r = 8.0e6, xn0h = 2.0e5, xn0hl = 4.0e4
4352 real, parameter :: xdnr = 1000., xdns = 100. ,xdnh = 700.0, xdnhl = 900.0
4353 real, parameter :: zhlfac = 1./(pi*xdnhl*xn0hl)
4354 real, parameter :: zhfac = 1./(pi*xdnh*xn0h)
4355 real, parameter :: zrfac = 1./(pi*xdnr*xn0r)
4356 real, parameter :: zsfac = 1./(pi*xdns*xn0s)
4357 real, parameter :: g0 = (6.0)*(5.0)*(4.0)/((3.0)*(2.0)*(1.0))
4358 real, parameter :: xims=900.*0.523599*(2.*50.e-6)**3 ! mks (100 micron diam solid sphere approx)
4359 real, parameter :: xgms=xdnh*0.523599*(300.e-6)**3 ! mks (300 micron diam sphere approx)
4360 real, parameter :: cwmas09 = 1000.*0.523599*(2.*9.e-6)**3 ! mass of 9-micron radius droplet
4363 integer :: ndbz, nmwgt, nnwgt, nwlessthanz
4365 ! ------------------------------------------------------------------
4371 g1h = (6.0 + alphah)*(5.0 + alphah)*(4.0 + alphah)/ &
4372 & ((3.0 + alphah)*(2.0 + alphah)*(1.0 + alphah))
4374 g1hl = (6.0 + alphahl)*(5.0 + alphahl)*(4.0 + alphahl)/ &
4375 & ((3.0 + alphahl)*(2.0 + alphahl)*(1.0 + alphahl))
4377 IF ( imurain == 3 ) THEN
4378 g1r = (rnu+2.0)/(rnu+1.0)
4380 g1r = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/ &
4381 & ((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
4384 g1s = (snu+2.0)/(snu+1.0)
4387 DO ix = 1,nx ! ixcol
4389 dninv = 1./dn(ix,kz)
4394 IF ( an(ix,jy,kz,lnc) <= cxmin .and. an(ix,jy,kz,lc) > qxmin_init(lc) ) THEN
4396 an(ix,jy,kz,lnc) = Min(qccn, an(ix,jy,kz,lc)/cwmas09 )*dn(ix,kz)
4398 IF ( lccn > 1 .and. lccna < 1 ) THEN
4399 an(ix,jy,kz,lccn) = an(ix,jy,kz,lccn) - an(ix,jy,kz,lnc)
4401 IF ( lccna > 1 ) THEN
4402 an(ix,jy,kz,lccna) = an(ix,jy,kz,lccna) + an(ix,jy,kz,lnc)
4405 ELSEIF ( an(ix,jy,kz,lc) <= qxmin(lc) .or. &
4406 ( an(ix,jy,kz,lnc) <= cxmin .and. an(ix,jy,kz,lc) <= qxmin_init(lc)) ) THEN
4408 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lc)
4409 an(ix,jy,kz,lnc) = 0.0
4410 an(ix,jy,kz,lc) = 0.0
4418 IF ( an(ix,jy,kz,lni) <= cxmin .and. an(ix,jy,kz,li) > qxmin_init(li) ) THEN
4419 an(ix,jy,kz,lni) = dn(ix,kz)*an(ix,jy,kz,li)/xims
4421 ELSEIF ( an(ix,jy,kz,li) <= qxmin(li) .or. &
4422 ( an(ix,jy,kz,lni) <= cxmin .and. an(ix,jy,kz,li) <= qxmin_init(li)) ) THEN
4423 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,li)
4424 an(ix,jy,kz,lni) = 0.0
4425 an(ix,jy,kz,li) = 0.0
4432 IF ( an(ix,jy,kz,lnr) <= 0.1*cxmin .and. an(ix,jy,kz,lr) > qxmin_init(lr) ) THEN
4436 laminv1 = (dn(ix,kz) * q * zrfac)**(0.25) ! inverse of slope
4438 n1 = laminv1*xn0r ! number concentration for inv. exponential single moment input
4440 nrx = n1*g1r/g0 ! number concentration for different shape parameter
4442 an(ix,jy,kz,lnr) = nrx ! *dninv ! convert to number mixing ratio
4444 ELSEIF ( an(ix,jy,kz,lr) <= qxmin(lr) .or. &
4445 ( an(ix,jy,kz,lnr) <= cxmin .and. an(ix,jy,kz,lr) <= qxmin_init(lr)) ) THEN
4446 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lr)
4447 an(ix,jy,kz,lnr) = 0.0
4448 an(ix,jy,kz,lr) = 0.0
4454 IF ( an(ix,jy,kz,lns) <= 0.1*cxmin .and. an(ix,jy,kz,ls) > qxmin_init(ls) ) THEN
4458 laminv1 = (dn(ix,kz) * q * zsfac)**(0.25) ! inverse of slope
4460 n1 = laminv1*xn0s ! number concentration for inv. exponential single moment input
4462 nrx = n1*g1s/g0 ! number concentration for different shape parameter
4464 an(ix,jy,kz,lns) = nrx ! *dninv ! convert to number mixing ratio
4466 ELSEIF ( an(ix,jy,kz,ls) <= qxmin(ls) .or. &
4467 ( an(ix,jy,kz,lns) <= cxmin .and. an(ix,jy,kz,ls) <= qxmin_init(ls)) ) THEN
4468 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,ls)
4469 an(ix,jy,kz,lns) = 0.0
4470 an(ix,jy,kz,ls) = 0.0
4478 IF ( an(ix,jy,kz,lnh) <= 0.1*cxmin .and. an(ix,jy,kz,lh) > qxmin_init(lh) ) THEN
4480 IF ( an(ix,jy,kz,lvh) <= 0.0 ) THEN
4481 an(ix,jy,kz,lvh) = an(ix,jy,kz,lh)/xdnh
4487 laminv1 = (dn(ix,kz) * q * zhfac)**(0.25) ! inverse of slope
4489 n1 = laminv1*xn0h ! number concentration for inv. exponential single moment input
4491 nrx = n1*g1h/g0 ! number concentration for different shape parameter
4493 nrx2 = dn(ix,kz) * q / xgms
4495 nrx = Min( nrx, nrx2 )
4497 IF ( nrx > cxmin ) THEN
4498 an(ix,jy,kz,lnh) = nrx ! *dninv ! convert to number mixing ratio
4500 an(ix,jy,kz,lh) = 0.0
4501 an(ix,jy,kz,lnh) = 0.0
4502 an(ix,jy,kz,lvh) = 0.0
4505 ELSEIF ( an(ix,jy,kz,lh) <= qxmin(lh) .or. &
4506 ( an(ix,jy,kz,lnh) <= cxmin .and. an(ix,jy,kz,lh) <= qxmin_init(lh)) ) THEN
4508 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lh)
4509 an(ix,jy,kz,lh) = 0.0
4516 IF ( lnhl > 1 .and. lhl > 1 ) THEN
4517 IF ( an(ix,jy,kz,lnhl) <= 0.1*cxmin .and. an(ix,jy,kz,lhl) > qxmin_init(lhl) ) THEN
4518 IF ( lvhl > 1 ) THEN
4519 IF ( an(ix,jy,kz,lvhl) <= 0.0 ) THEN
4520 an(ix,jy,kz,lvhl) = an(ix,jy,kz,lhl)/xdnhl
4524 q = an(ix,jy,kz,lhl)
4526 laminv1 = (dn(ix,kz) * q * zhlfac)**(0.25) ! inverse of slope
4528 n1 = laminv1*xn0hl ! number concentration for inv. exponential single moment input
4530 nrx = n1*g1hl/g0 ! number concentration for different shape parameter
4532 an(ix,jy,kz,lnhl) = nrx ! *dninv ! convert to number mixing ratio
4535 ELSEIF ( an(ix,jy,kz,lhl) <= qxmin(lhl) .or. &
4536 ( an(ix,jy,kz,lnhl) <= cxmin .and. an(ix,jy,kz,lhl) <= qxmin_init(lhl)) ) THEN
4538 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lhl)
4539 an(ix,jy,kz,lhl) = 0.0
4549 END subroutine calcnfromq
4551 ! ##############################################################################
4552 ! ##############################################################################
4554 ! Subroutine to calculate number concentrations from convection parameterization rates that have only mixing ratio.
4555 ! N will be in #/kg, NOT #/m^3, since sedimentation is done next.
4559 ! 10.27.2015: Added hail calculation
4561 subroutine calcnfromcuten(nx,ny,nz,an,anold,na,nor,norz,dn)
4566 integer nx,ny,nz,nor,norz,na,ngt,jgs,ixcol
4568 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na) ! scalars (q, N, Z) from CUTEN arrays
4569 real anold(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na) ! scalars (q, N, Z)
4571 real dn(nx,nz+1) ! air density
4578 integer lvol ! index for volume
4583 double precision vr,q,nrx,rd,g1h,g1hl,g1r,g1s,zx,chw,z,znew,zt,zxt,n1,laminv1
4584 double precision :: zr, zs, zh, dninv
4585 real, parameter :: xn0s = 3.0e6, xn0r = 8.0e6, xn0h = 4.0e4, xn0hl = 4.0e4
4586 real, parameter :: xdnr = 1000., xdns = 100. ,xdnh = 700.0, xdnhl = 900.0
4587 real, parameter :: zhlfac = 1./(pi*xdnhl*xn0hl)
4588 real, parameter :: zhfac = 1./(pi*xdnh*xn0h)
4589 real, parameter :: zrfac = 1./(pi*xdnr*xn0r)
4590 real, parameter :: zsfac = 1./(pi*xdns*xn0s)
4591 real, parameter :: g0 = (6.0)*(5.0)*(4.0)/((3.0)*(2.0)*(1.0))
4592 real, parameter :: xims=900.*0.523599*(2.*50.e-6)**3 ! mks (100 micron diam solid sphere approx)
4593 real, parameter :: xcms=1000.*0.523599*(2.*7.5e-6)**3 ! mks (100 micron diam solid sphere approx)
4595 real :: xmass,xv,xdn
4596 integer :: ndbz, nmwgt, nnwgt, nwlessthanz
4598 ! ------------------------------------------------------------------
4604 g1h = (6.0 + alphah)*(5.0 + alphah)*(4.0 + alphah)/ &
4605 & ((3.0 + alphah)*(2.0 + alphah)*(1.0 + alphah))
4607 g1hl = (6.0 + alphahl)*(5.0 + alphahl)*(4.0 + alphahl)/ &
4608 & ((3.0 + alphahl)*(2.0 + alphahl)*(1.0 + alphahl))
4610 IF ( imurain == 3 ) THEN
4611 g1r = (rnu+2.0)/(rnu+1.0)
4613 g1r = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/ &
4614 & ((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
4617 g1s = (snu+2.0)/(snu+1.0)
4620 DO ix = 1,nx ! ixcol
4622 dninv = 1./dn(ix,kz)
4627 ! IF ( an(ix,jy,kz,lnc) <= 0.1*cxmin .and. an(ix,jy,kz,lc) > qxmin(lc) ) THEN
4628 IF ( an(ix,jy,kz,lnc) > qxmin(lc) ) THEN
4629 anold(ix,jy,kz,lnc) = anold(ix,jy,kz,lnc) + an(ix,jy,kz,lc)/xcms
4636 IF ( an(ix,jy,kz,lni) > qxmin(li) ) THEN
4637 anold(ix,jy,kz,lni) = anold(ix,jy,kz,lni) + an(ix,jy,kz,li)/xims
4644 IF ( an(ix,jy,kz,lr) > qxmin(lr) ) THEN ! adding rain mass from CU scheme
4646 IF ( .true. .or. (anold(ix,jy,kz,lr) - an(ix,jy,kz,lr)) < qxmin(lr) .or. anold(ix,jy,kz,lnr) < cxmin ) THEN
4650 laminv1 = (dn(ix,kz) * q * zrfac)**(0.25) ! inverse of slope
4652 n1 = laminv1*xn0r ! number concentration for inv. exponential single moment input
4654 nrx = n1*g1r/g0 ! number concentration for different shape parameter
4656 anold(ix,jy,kz,lnr) = anold(ix,jy,kz,lnr) + nrx ! *dninv ! convert to number mixing ratio
4659 ! assume mean particle mass of pre-existing snow
4660 xmass = anold(ix,jy,kz,lr)/anold(ix,jy,kz,lnr)
4661 anold(ix,jy,kz,lnr) = anold(ix,jy,kz,lnr) + an(ix,jy,kz,lr)/xmass
4669 IF ( an(ix,jy,kz,ls) > qxmin(ls) ) THEN ! adding snow mass from CU scheme
4671 IF ( .true. .or. (anold(ix,jy,kz,ls) - an(ix,jy,kz,ls)) < qxmin(ls) .or. anold(ix,jy,kz,lns) < cxmin ) THEN
4673 ! assume that there was no snow before this
4677 laminv1 = (dn(ix,kz) * q * zsfac)**(0.25) ! inverse of slope
4679 n1 = laminv1*xn0s ! number concentration for inv. exponential single moment input
4681 nrx = n1*g1s/g0 ! number concentration for different shape parameter
4683 anold(ix,jy,kz,lns) = anold(ix,jy,kz,lns) + nrx ! *dninv ! convert to number mixing ratio
4686 ! assume mean particle mass of pre-existing snow
4687 xmass = anold(ix,jy,kz,ls)/anold(ix,jy,kz,lns)
4688 anold(ix,jy,kz,lns) = anold(ix,jy,kz,lns) + an(ix,jy,kz,ls)/xmass
4696 ! IF ( lnh > 1 ) THEN
4697 ! IF ( an(ix,jy,kz,lnh) <= 0.1*cxmin .and. an(ix,jy,kz,lh) > qxmin(lh) ) THEN
4698 ! IF ( lvh > 1 ) THEN
4699 ! IF ( an(ix,jy,kz,lvh) <= 0.0 ) THEN
4700 ! an(ix,jy,kz,lvh) = an(ix,jy,kz,lh)/xdnh
4704 ! q = an(ix,jy,kz,lh)
4706 ! laminv1 = (dn(ix,kz) * q * zhfac)**(0.25) ! inverse of slope
4708 ! n1 = laminv1*xn0h ! number concentration for inv. exponential single moment input
4710 ! nrx = n1*g1h/g0 ! number concentration for different shape parameter
4712 ! an(ix,jy,kz,lnh) = nrx ! *dninv ! convert to number mixing ratio
4719 ! IF ( lnhl > 1 .and. lhl > 1 ) THEN
4720 ! IF ( an(ix,jy,kz,lnhl) <= 0.1*cxmin .and. an(ix,jy,kz,lhl) > qxmin(lhl) ) THEN
4721 ! IF ( lvhl > 1 ) THEN
4722 ! IF ( an(ix,jy,kz,lvhl) <= 0.0 ) THEN
4723 ! an(ix,jy,kz,lvhl) = an(ix,jy,kz,lhl)/xdnhl
4727 ! q = an(ix,jy,kz,lhl)
4729 ! laminv1 = (dn(ix,kz) * q * zhlfac)**(0.25) ! inverse of slope
4731 ! n1 = laminv1*xn0hl ! number concentration for inv. exponential single moment input
4733 ! nrx = n1*g1hl/g0 ! number concentration for different shape parameter
4735 ! an(ix,jy,kz,lnhl) = nrx ! *dninv ! convert to number mixing ratio
4745 END subroutine calcnfromcuten
4747 ! #####################################################################
4748 ! #####################################################################
4750 SUBROUTINE calc_eff_radius &
4751 & (nx,ny,nz,na,jyslab &
4758 integer, parameter :: ng1 = 1
4759 integer :: nx,ny,nz,na
4761 integer :: nor,norz, jyslab ! ,nht,ngt,igsr
4762 real :: dtp ! time step
4766 ! external temporary arrays
4769 real t1(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4770 real t2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4771 real t3(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4774 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
4775 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4783 real pb(-norz+ng1:nz+norz)
4784 real pinit(-norz+ng1:nz+norz)
4787 ! declarations microphysics and for gather/scatter
4789 integer nxmpb,nzmpb,nxz
4790 integer mgs,ngs,numgs,inumgs
4792 integer ngscnt,igs(ngs),kgs(ngs)
4795 integer ix,kz,i,n, kp1
4797 integer ixb,ixe,jyb,jye,kzb,kze
4799 integer itile,jtile,ktile
4800 integer ixend,jyend,kzend,kzbeg
4801 integer nxend,nyend,nzend,nzbeg
4803 real :: qx(ngs,lv:lhab)
4804 real :: cx(ngs,lc:lhab)
4805 real :: xv(ngs,lc:lhab)
4806 real :: xmas(ngs,lc:lhab)
4807 real :: xdn(ngs,lc:lhab)
4808 real :: xdia(ngs,lc:lhab,3)
4809 real :: alpha(ngs,lc:lhab)
4811 real :: gamc1,gamc2,gami1,gami2,gams1,gams2, factor_c, factor_i, factor_s
4812 real :: lam_c, lam_i, lam_s
4816 ! -------------------------------------------------------------------------------
4833 gamc1 = Gamma_sp(2. + cnu)
4834 gamc2 = 1. ! Gamma[1 + alphac]
4835 gami1 = Gamma_sp(2. + cinu)
4836 gami2 = 1. ! Gamma[1 + alphac]
4837 gams1 = Gamma_sp(2. + snu)
4838 gams2 = Gamma_sp(1. + snu)
4840 factor_c = (1. + cnu)*Gamma_sp(1. + cnu)/Gamma_sp(5./3. + cnu)
4841 factor_i = (1. + cinu)*Gamma_sp(1. + cinu)/Gamma_sp(5./3. + cinu)
4842 factor_s = (1. + snu)*Gamma_sp(1. + snu)/Gamma_sp(5./3. + snu)
4845 ! jy = 1 ! working on a 2d slab
4846 !! VERY IMPORTANT: SET jgs = jy
4852 DO ix = 1,nx ! ixcol
4854 rho0(mgs) = dn(ix,jy,kz)
4856 qx(mgs,il) = max(an(ix,jy,kz,il), 0.0)
4857 cx(mgs,il) = max(an(ix,jy,kz,ln(il)), 0.0)
4860 IF ( qx(mgs,lc) > qxmin(lc) ) THEN
4861 ! Lambda for cloud droplets
4862 lam_c = ((cx(mgs,lc)*(Pi/6.)*xdn0(lc)*Gamc1)/(qx(mgs,lc)*rho0(mgs)*Gamc2))**(1./3.)
4863 t1(ix,jy,kz) = 0.5*factor_c/lam_c
4866 IF ( qx(mgs,li) > qxmin(li) ) THEN
4867 ! Lambda for cloud ice
4868 lam_i = ((cx(mgs,li)*(Pi/6.)*xdn0(li)*Gami1)/(qx(mgs,li)*rho0(mgs)*Gami2))**(1./3.)
4869 t2(ix,jy,kz) = 0.5*factor_i/lam_i
4872 IF ( qx(mgs,ls) > qxmin(ls) ) THEN
4874 lam_s = ((cx(mgs,ls)*(Pi/6.)*xdn0(ls)*Gams1)/(qx(mgs,ls)*rho0(mgs)*Gams2))**(1./3.)
4875 t3(ix,jy,kz) = 0.5*factor_s/lam_s
4883 END SUBROUTINE calc_eff_radius
4886 ! #####################################################################
4887 ! #####################################################################
4889 SUBROUTINE QVEXCESS(ngs,mgs,qwvp0,qv0,qcw1,pres,thetap0,theta0, &
4890 & qvex,pi0,tabqvs,nqsat,fqsat,cbw,fcqv1,felvcp,ss1,pk,ngscnt)
4892 !#####################################################################
4893 ! Purpose: find the amount of vapor that can be condensed to liquid
4894 !#####################################################################
4898 integer ngs,mgs,ngscnt
4907 real ss1 ! 'target' supersaturation
4911 real qv0(ngs), qcw1(ngscnt), pres(ngs), qwvp0(mgs)
4912 real thetap0(ngs), theta0(ngs)
4913 real fcqv1(ngs), felvcp(ngs), pi0(ngs)
4924 real theta(ngs), qvap(ngs), pqs(ngs), qcw(ngs), qwv(ngs)
4925 real qcwtmp(ngs), qss(ngs), qvs(ngs), qwvp(ngs)
4926 real dqcw(ngs), dqwv(ngs), dqvcnd(ngs)
4927 real temg(ngs), temcg(ngs), thetap(ngs)
4930 parameter ( tfr = 273.15 )
4933 ! parameter ( cap = rd/cp, poo = 1.0e+05 )
4936 ! Modified Straka adjustment (nearly identical to Tao et al. 1989 MWR)
4940 ! set up temperature and vapor arrays
4942 pqs(mgs) = (380.0)/(pres(mgs))
4943 thetap(mgs) = thetap0(mgs)
4944 theta(mgs) = thetap(mgs) + theta0(mgs)
4945 qwvp(mgs) = qwvp0(mgs)
4946 qvap(mgs) = max( (qwvp0(mgs) + qv0(mgs)), 0.0 )
4947 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
4948 ! temg(mgs) = theta2temp( theta(mgs), pres(mgs) )
4952 ! reset temporaries for cloud particles and vapor
4955 qwv(mgs) = max( 0.0, qvap(mgs) )
4956 qcw(mgs) = max( 0.0, qcw1(mgs) )
4959 qcwtmp(mgs) = qcw(mgs)
4960 temcg(mgs) = temg(mgs) - tfr
4961 ltemq = (temg(mgs)-163.15)/fqsat+1.5
4962 ltemq = Min( nqsat, Max(1,ltemq) )
4964 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
4965 qss(mgs) = (0.01*ss1 + 1.0)*qvs(mgs)
4967 ! iterate adjustment
4972 ! calculate super-saturation
4975 dqwv(mgs) = ( qwv(mgs) - qss(mgs) )
4977 ! evaporation and sublimation adjustment
4979 if( dqwv(mgs) .lt. 0. ) then ! subsaturated
4980 if( qcw(mgs) .gt. -dqwv(mgs) ) then ! check if qc can make up all of the deficit
4981 dqcw(mgs) = dqwv(mgs)
4983 else ! otherwise make all qc available for evap
4984 dqcw(mgs) = -qcw(mgs)
4985 dqwv(mgs) = dqwv(mgs) + qcw(mgs)
4988 qwvp(mgs) = qwvp(mgs) - ( dqcw(mgs) ) ! add to perturbation vapor
4990 qcw(mgs) = qcw(mgs) + dqcw(mgs)
4992 thetap(mgs) = thetap(mgs) + &
4994 & (felvcp(mgs)*dqcw(mgs) )
4996 end if ! dqwv(mgs) .lt. 0. (end of evap/sublim)
4998 ! condensation/deposition
5000 IF ( dqwv(mgs) .ge. 0. ) THEN
5002 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qss(mgs)/ &
5003 & ((temg(mgs)-cbw)**2))
5006 dqcw(mgs) = dqvcnd(mgs)
5008 thetap(mgs) = thetap(mgs) + &
5009 & (felvcp(mgs)*dqcw(mgs) ) &
5011 qwvp(mgs) = qwvp(mgs) - ( dqvcnd(mgs) )
5012 qcw(mgs) = qcw(mgs) + dqcw(mgs)
5014 END IF ! dqwv(mgs) .ge. 0.
5016 theta(mgs) = thetap(mgs) + theta0(mgs)
5017 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
5018 ! temg(mgs) = theta2temp( theta(mgs), pres(mgs) )
5019 qvap(mgs) = Max((qwvp(mgs) + qv0(mgs)), 0.0)
5020 temcg(mgs) = temg(mgs) - tfr
5021 ! tqvcon = temg(mgs)-cbw
5022 ltemq = (temg(mgs)-163.15)/fqsat+1.5
5023 ltemq = Min( nqsat, Max(1,ltemq) )
5024 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
5025 qcw(mgs) = max( 0.0, qcw(mgs) )
5026 qwv(mgs) = max( 0.0, qvap(mgs))
5027 qss(mgs) = (0.01*ss1 + 1.0)*qvs(mgs)
5030 ! end the saturation adjustment iteration loop
5033 qvex = Max(0.0, qcw(mgs) - qcw1(mgs) )
5036 END SUBROUTINE QVEXCESS
5038 ! #####################################################################
5039 ! #####################################################################
5046 ! ##############################################################################
5048 SUBROUTINE setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno,cnostmp, &
5049 & xmas,vtxbar,xdn,xvmn0,xvmx0,xv,cdx,cdxgs, &
5050 & ipconc1,ndebug1,ngs,nz,kgs,fadvisc, &
5051 & cwmasn,cwmasx,cwradn,cnina,cimna,cimxa, &
5052 & itype1a,itype2a,temcg,infdo,alpha,ildo,axx,bxx)
5053 ! & itype1a,itype2a,temcg,infdo,alpha,ildo,axh,bxh,axhl,bxhl)
5058 integer ngscnt,ngs0,ngs,nz
5059 ! integer infall ! whether to calculate number-weighted fall speeds
5061 real xv(ngs,lc:lhab)
5062 real qx(ngs,lv:lhab)
5063 real qxw(ngs,ls:lhab)
5064 real cx(ngs,lc:lhab)
5065 real vtxbar(ngs,lc:lhab,3)
5066 real xmas(ngs,lc:lhab)
5067 real xdn(ngs,lc:lhab)
5068 real cdxgs(ngs,lc:lhab)
5069 real xdia(ngs,lc:lhab,3)
5070 real xvmn0(lc:lhab), xvmx0(lc:lhab)
5073 real alpha(ngs,lc:lhab)
5075 real rho0(ngs),rhovt(ngs),temcg(ngs)
5079 real cwc1, cimna, cimxa
5088 integer, intent (in) :: itype1a,itype2a,infdo
5089 integer, intent (in) :: ildo ! which species to do, or all if ildo=0
5091 real :: axx(ngs,lh:lhab),bxx(ngs,lh:lhab)
5092 !! real :: axh(ngs),bxh(ngs)
5093 ! real :: axhl(ngs),bxhl(ngs)
5102 real :: cwch(ngscnt), cwchl(ngscnt)
5103 real :: cwchtmp,cwchltmp,xnutmp
5106 real cwmasn,cwmasx,cwradn
5115 real arx,frx,vtrain,fw
5116 real fwlo,fwhi,rfwdiff
5118 ! real gf4p5, gf4ds, gf4br, ifirst, gf1ds
5119 ! real gfcinu1, gfcinu1p47, gfcinu2p47
5125 ! save gf4p5, gf4ds, gf4br, ifirst, gf1ds
5126 ! save gfcinu1, gfcinu1p47, gfcinu2p47
5130 parameter ( bta1 = 0.6, cnit = 1.0e-02 )
5135 real, parameter :: rho00 = 1.225
5145 ! cwmasn = 5.23e-13 ! radius of 5.0e-6
5147 ! cwmasx = 5.25e-10 ! radius of 50.0e-6
5149 fwlo = 0.2 ! water fraction to start weighting toward rain fall speed
5150 fwhi = 0.4 ! water fraction at which rain fall speed only is used
5151 rfwdiff = 1./(fwhi - fwlo)
5153 ! pi = 4.0*atan(1.0)
5154 pii = piinv ! 1.0/pi
5157 frx = 516.575 ! raind fit parameters for arx*(1 - Exp(-fx*d)), where d is rain diameter in meters.
5162 ! new values for cs and ds
5166 IF ( ildo == 0 ) THEN
5174 ! IF ( ifirst .eq. 0 ) THEN
5176 ! gf4br = gamma(4.0+br)
5177 ! gf4ds = gamma(4.0+ds)
5178 !! gf1ds = gamma(1.0+ds)
5179 ! gf4p5 = gamma(4.0+0.5)
5180 ! gfcinu1 = gamma(cinu + 1.0)
5181 ! gfcinu1p47 = gamma(cinu + 1.47167)
5182 ! gfcinu2p47 = gamma(cinu + 2.47167)
5184 IF ( lh .gt. 1 ) THEN
5185 IF ( dmuh == 1.0 ) THEN
5186 cwchtmp = ((3. + dnu(lh))*(2. + dnu(lh))*(1.0 + dnu(lh)))**(-1./3.)
5188 cwchtmp = 6.0*pii*gamma_sp( (xnu(lh) + 1.)/xmu(lh) )/gamma_sp( (xnu(lh) + 2.)/xmu(lh) )
5191 IF ( lhl .gt. 1 ) THEN
5192 IF ( dmuhl == 1.0 ) THEN
5193 cwchltmp = ((3. + dnu(lhl))*(2. + dnu(lhl))*(1.0 + dnu(lhl)))**(-1./3.)
5195 cwchltmp = 6.0*pii*gamma_sp( (xnu(lhl) + 1)/xmu(lhl) )/gamma_sp( (xnu(lhl) + 2)/xmu(lhl) )
5199 IF ( ipconc .le. 5 ) THEN
5200 IF ( lh .gt. 1 ) cwch(:) = cwchtmp
5201 IF ( lhl .gt. 1 ) cwchl(:) = cwchltmp
5205 IF ( lh .gt. 1 .and. ( ildo == 0 .or. ildo == lh ) ) THEN
5206 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
5207 IF ( dmuh == 1.0 ) THEN
5208 cwch(mgs) = ((3. + alpha(mgs,lh))*(2. + alpha(mgs,lh))*(1.0 + alpha(mgs,lh)))**(-1./3.)
5210 xnutmp = (alpha(mgs,lh) - 2.0)/3.0
5211 cwch(mgs) = 6.0*pii*gamma_sp( (xnutmp + 1.)/xmu(lh) )/gamma_sp( (xnutmp + 2.)/xmu(lh) )
5217 IF ( lhl .gt. 1 .and. ( ildo == 0 .or. ildo == lhl ) ) THEN
5218 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
5219 IF ( dmuhl == 1.0 ) THEN
5220 cwchl(mgs) = ((3. + alpha(mgs,lhl))*(2. + alpha(mgs,lhl))*(1.0 + alpha(mgs,lhl)))**(-1./3.)
5222 xnutmp = (alpha(mgs,lhl) - 2.0)/3.0
5223 cwchl(mgs) = 6.0*pii*gamma_sp( (xnutmp + 1)/xmu(lhl) )/gamma_sp( (xnutmp + 2)/xmu(lhl) )
5226 cwchl(mgs) = cwchltmp
5235 cimasn = Min( cimas0, 6.88e-13)
5237 ccimx = 5000.0e3 ! max of 5000 per liter
5239 cwc1 = 6.0/(pi*1000.)
5240 cwc0 = pii ! 6.0*pii
5241 mwfac = 6.0**(1./3.)
5244 if (ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set scale diameter'
5249 ! cloud water variables
5250 ! ################################################################
5255 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set cloud water variables'
5257 IF ( ildo == 0 .or. ildo == lc ) THEN
5262 IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN !{
5264 IF ( ipconc .ge. 2 ) THEN
5265 IF ( cx(mgs,lc) .gt. cxmin) THEN !{
5267 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
5268 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
5270 cx(mgs,lc) = Max( cxmin, rho0(mgs)*qx(mgs,lc)/cwmasx )
5271 xmas(mgs,lc) = Min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
5272 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
5276 IF ( ipconc .lt. 2 ) THEN
5277 cx(mgs,lc) = rho0(mgs)*ccn/rho00 ! scales to local density, relative to standard air density
5279 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. 0.01 ) THEN !{
5281 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),xdn(mgs,lc)*xvmn(lc)), &
5282 & xdn(mgs,lc)*xvmx(lc) )
5284 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
5285 cx(mgs,lc) = qx(mgs,lc)*rho0(mgs)/xmas(mgs,lc)
5287 ELSEIF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .le. 1.0e-9 ) THEN
5288 cx(mgs,lc) = Max( cxmin, rho0(mgs)*qx(mgs,lc)/cwmasx )
5290 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
5291 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
5293 ELSEIF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .le. 0.01 ) THEN
5294 xmas(mgs,lc) = xdn(mgs,lc)*4.*pi/3.*(5.0e-6)**3
5295 cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc)
5296 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
5299 xmas(mgs,lc) = cwmasn
5300 xv(mgs,lc) = xmas(mgs,lc)/1000.
5301 ! do not define ccw here! it can feed back to ccn!!! cx(mgs,lc) = 0.0 ! cwnc(mgs)
5304 ! IF ( ipconc .lt. 2 ) THEN
5306 ! & min( max(qx(mgs,lc)*rho0(mgs)/cwnc(mgs),cwmasn),cwmasx )
5307 ! cx(mgs,lc) = Max(1.0,qx(mgs,lc)*rho0(mgs)/xmas(mgs,lc))
5309 ! cwnc(mgs) = an(igs(mgs),jgs,kgs(mgs),lnc)
5310 ! cx(mgs,lc) = cwnc(mgs)
5312 xdia(mgs,lc,1) = (xmas(mgs,lc)*cwc1)**(1./3.)
5313 xdia(mgs,lc,2) = xdia(mgs,lc,1)**2
5314 xdia(mgs,lc,3) = xdia(mgs,lc,1)
5315 cwrad = 0.5*xdia(mgs,lc,1)
5316 IF ( fadvisc(mgs) > 0.0 ) THEN
5317 vtxbar(mgs,lc,1) = &
5318 & (2.0*gr*xdn(mgs,lc) *(cwrad**2)) &
5319 & /(9.0*fadvisc(mgs))
5321 vtxbar(mgs,lc,1) = 0.0
5326 xmas(mgs,lc) = cwmasn
5327 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
5328 IF ( qx(mgs,lc) <= 0.0 ) cx(mgs,lc) = 0.0
5329 IF ( ipconc .le. 1 ) cx(mgs,lc) = 0.01
5330 xdia(mgs,lc,1) = 2.*cwradn
5331 xdia(mgs,lc,2) = 4.*cwradn**2
5332 xdia(mgs,lc,3) = xdia(mgs,lc,1)
5333 vtxbar(mgs,lc,1) = 0.0
5335 ENDIF !} qcw .gt. qxmin(lc)
5344 ! cloud ice variables
5347 ! ################################################################
5351 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set cip'
5353 IF ( li .gt. 1 .and. ( ildo == 0 .or. ildo == li ) ) THEN
5356 IF ( ipconc .eq. 0 ) THEN
5357 ! cx(mgs,li) = min(cnit*exp(-temcg(mgs)*bta1),1.e+09)
5358 cx(mgs,li) = cnina(mgs)
5359 IF ( cimna .gt. 1.0 ) THEN
5360 cx(mgs,li) = Max(cimna,cx(mgs,li))
5362 IF ( cimxa .gt. 1.0 ) THEN
5363 cx(mgs,li) = Min(cimxa,cx(mgs,li))
5366 IF ( itype1a .ge. 1 .or. itype2a .ge. 1 ) THEN
5367 cx(mgs,li) = Max(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasx)
5368 cx(mgs,li) = Min(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasn)
5371 cx(mgs,li) = max(1.0e-20,cx(mgs,li))
5372 ! cx(mgs,li) = Min(ccimx, cx(mgs,li))
5375 ELSEIF ( ipconc .ge. 1 ) THEN
5376 IF ( qx(mgs,li) .gt. qxmin(li) ) THEN
5377 cx(mgs,li) = Max(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasx)
5378 cx(mgs,li) = Min(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasn)
5379 ! cx(mgs,li) = Max(1.0,cx(mgs,li))
5383 IF ( qx(mgs,li) .gt. qxmin(li) ) THEN
5385 & max( qx(mgs,li)*rho0(mgs)/cx(mgs,li), cimasn )
5386 ! & min( max(qx(mgs,li)*rho0(mgs)/cx(mgs,li),cimasn),cimasx )
5388 ! if ( temcg(mgs) .gt. 0.0 ) then
5389 ! xdia(mgs,li,1) = 0.0
5391 if ( xmas(mgs,li) .gt. 0.0 ) THEN ! cimasn ) then
5392 !c xdia(mgs,li,1) = 0.4892*(xmas(mgs,li)**(0.4554))
5393 ! xdia(mgs,li,1) = 0.1871*(xmas(mgs,li)**(0.3429))
5395 ! xdia(mgs,li,1) = (132.694*5.40662/xmas(mgs,li))**(-1./2.9163) ! for inverse exponential distribution
5396 IF ( ixtaltype == 1 ) THEN ! column
5397 xdia(mgs,li,1) = 0.1871*(xmas(mgs,li)**(0.3429))
5398 xdia(mgs,li,3) = 0.1871*(xmas(mgs,li)**(0.3429))
5399 ELSEIF ( ixtaltype == 2 ) THEN ! disk
5400 xdia(mgs,li,1) = 0.277823*xmas(mgs,li)**0.359971
5401 xdia(mgs,li,3) = 0.277823*xmas(mgs,li)**0.359971
5405 ! xdia(mgs,li,1) = max(xdia(mgs,li,1), 5.e-6)
5406 ! xdia(mgs,li,1) = min(xdia(mgs,li,1), 1000.e-6)
5408 IF ( ipconc .ge. 0 ) THEN
5409 ! vtxbar(mgs,li,1) = rhovt(mgs)*49420.*40.0005/5.40662*xdia(mgs,li,1)**(1.415) ! mass-weighted
5410 ! vtxbar(mgs,li,1) = (4.942e4)*(xdia(mgs,li,1)**(1.4150))
5411 xv(mgs,li) = xmas(mgs,li)/xdn(mgs,li)
5412 IF ( icefallopt == 1 ) THEN ! default ice fall
5413 IF ( ixtaltype == 1 ) THEN ! column
5414 tmp = (67056.6300748612*rhovt(mgs))/ &
5415 & (((1.0 + cinu)/xv(mgs,li))**0.4716666666666667*gfcinu1)
5416 vtxbar(mgs,li,2) = tmp*gfcinu1p47
5417 vtxbar(mgs,li,1) = tmp*gfcinu2p47/(1. + cinu)
5418 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
5419 ELSEIF ( ixtaltype == 2 ) THEN ! disk -- but just use Ferrier (1994) snow fall speeds for now
5420 vtxbar(mgs,li,1) = 11.9495*rhovt(mgs)*(xv(mgs,li))**(0.14)
5421 vtxbar(mgs,li,2) = 7.02909*rhovt(mgs)*(xv(mgs,li))**(0.14)
5422 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
5426 ELSEIF ( icefallopt == 2 ) THEN ! ! Ferrier ice fall speed
5427 tmp = (82.3166*rhovt(mgs))/ &
5428 & (((1.0 + cinu)/xv(mgs,li))**0.22117*gfcinu1)
5429 vtxbar(mgs,li,2) = tmp*gfcinu1p22
5430 vtxbar(mgs,li,1) = tmp*gfcinu2p22/(1. + cinu)
5431 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
5433 ELSEIF ( icefallopt == 3 ) THEN ! ! Adjusted Ferrier (smaller exponent of 0.55 instead of 0.6635)
5435 tmp = (47.6273*rhovt(mgs))/ &
5436 & (((1.0 + cinu)/xv(mgs,li))**0.18333*gfcinu1)
5437 vtxbar(mgs,li,2) = tmp*gfcinu1p18
5438 vtxbar(mgs,li,1) = tmp*gfcinu2p18/(1. + cinu)
5439 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
5442 ! vtxbar(mgs,li,1) = vtxbar(mgs,li,2)*(1.+cinu)/(1. + cinu)
5443 ! xdn(mgs,li) = min(max(769.8*xdia(mgs,li,1)**(-0.0140),300.0),900.0)
5444 ! xdn(mgs,li) = 900.0
5445 xdia(mgs,li,2) = xdia(mgs,li,1)**2
5446 ! vtxbar(mgs,li,1) = vtxbar(mgs,li,1)*rhovt(mgs)
5448 xdia(mgs,li,1) = max(xdia(mgs,li,1), 10.e-6)
5449 xdia(mgs,li,1) = min(xdia(mgs,li,1), 1000.e-6)
5450 vtxbar(mgs,li,1) = (4.942e4)*(xdia(mgs,li,1)**(1.4150))
5451 ! xdn(mgs,li) = min(max(769.8*xdia(mgs,li,1)**(-0.0140),300.0),900.0)
5453 xdia(mgs,li,2) = xdia(mgs,li,1)**2
5454 vtxbar(mgs,li,1) = vtxbar(mgs,li,1)*rhovt(mgs)
5455 xv(mgs,li) = xmas(mgs,li)/xdn(mgs,li)
5458 xmas(mgs,li) = 1.e-13
5459 IF ( qx(mgs,li) <= 0.0 ) cx(mgs,li) = 0.0
5461 xdia(mgs,li,1) = 1.e-7
5462 xdia(mgs,li,2) = (1.e-14)
5463 xdia(mgs,li,3) = 1.e-7
5464 vtxbar(mgs,li,1) = 0.0
5469 IF ( icefallfac /= 1.0 ) THEN
5470 vtxbar(mgs,li,1) = icefallfac*vtxbar(mgs,li,1)
5471 vtxbar(mgs,li,2) = icefallfac*vtxbar(mgs,li,2)
5472 vtxbar(mgs,li,3) = icefallfac*vtxbar(mgs,li,3)
5482 ! ################################################################
5488 IF ( ildo == 0 .or. ildo == lr ) THEN
5490 if ( qx(mgs,lr) .gt. qxmin(lr) ) then
5492 ! IF ( qx(mgs,lr) .gt. 10.0e-3 ) &
5493 ! & write(0,*) 'RAIN1: ',igs(mgs),kgs(mgs),qx(mgs,lr)
5495 if ( ipconc .ge. 3 ) then
5496 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*Max(1.0e-11,cx(mgs,lr)))
5498 IF ( imaxdiaopt == 1 ) THEN
5500 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
5501 IF ( imurain == 1 ) THEN
5502 xvbarmax = xvmx(lr)/((3. + alpha(mgs,lr))**3/((3. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(1. + alpha(mgs,lr))))
5503 ELSEIF ( imurain == 3 ) THEN
5506 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
5507 IF ( imurain == 1 ) THEN
5508 xvbarmax = xvmx(lr)/((4. + alpha(mgs,lr))**3/((3. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(1. + alpha(mgs,lr))))
5509 ELSEIF ( imurain == 3 ) THEN
5514 IF ( xv(mgs,lr) .gt. xvbarmax ) THEN
5515 xv(mgs,lr) = xvbarmax
5516 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvbarmax*xdn(mgs,lr))
5517 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
5518 xv(mgs,lr) = xvmn(lr)
5519 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
5523 xmas(mgs,lr) = xv(mgs,lr)*xdn(mgs,lr)
5524 xdia(mgs,lr,3) = (xmas(mgs,lr)*cwc1)**(1./3.) ! xdia(mgs,lr,1)
5525 IF ( imurain == 3 ) THEN
5526 ! xdia(mgs,lr,1) = (6.*pii*xv(mgs,lr)/(alpha(mgs,lr)+1.))**(1./3.)
5527 xdia(mgs,lr,1) = xdia(mgs,lr,3) ! formulae for Ziegler (1985) use mean volume diameter, not lambda**(-1)
5528 ELSE ! imurain == 1, Characteristic diameter (1/lambda)
5529 xdia(mgs,lr,1) = (6.*pii*xv(mgs,lr)/((alpha(mgs,lr)+3.)*(alpha(mgs,lr)+2.)*(alpha(mgs,lr)+1.)))**(1./3.)
5531 ! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
5533 ! Inverse exponential version:
5535 ! & (qx(mgs,lr)*rho0(mgs)
5536 ! & /(pi*xdn(mgs,lr)*cx(mgs,lr)))**(0.333333)
5539 & (qx(mgs,lr)*rho0(mgs)/(pi*xdn(mgs,lr)*cno(lr)))**(0.25)
5540 xmas(mgs,lr) = xdn(mgs,lr)*(pi/6.)*xdia(mgs,lr,1)**3
5541 xdia(mgs,lr,3) = (xmas(mgs,lr)*cwc1)**(1./3.)
5542 cx(mgs,lr) = cno(lr)*xdia(mgs,lr,1)
5543 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr))
5546 xdia(mgs,lr,1) = 1.e-9
5547 xdia(mgs,lr,3) = 1.e-9
5548 xmas(mgs,lr) = xdn(mgs,lr)*(pi/6.)*xdia(mgs,lr,1)**3
5549 ! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
5551 xdia(mgs,lr,2) = xdia(mgs,lr,1)**2
5552 ! xmas(mgs,lr) = xdn(mgs,lr)*(pi/6.)*xdia(mgs,lr,1)**3
5556 ! ################################################################
5561 IF ( ls .gt. 1 .and. ( ildo == 0 .or. ildo == ls ) ) THEN
5564 if ( qx(mgs,ls) .gt. qxmin(ls) ) then
5565 if ( ipconc .ge. 4 ) then !
5567 xmas(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(Max(1.0e-9,cx(mgs,ls)))
5569 ! IF ( xmas(mgs,ls) > swmasmx ) THEN
5570 ! xmas(mgs,ls) = swmasmx
5571 ! cx(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xmas(mgs,ls))
5574 IF ( isnowdens == 2 ) THEN ! Set values according to Cox relationship
5576 xdn(mgs,ls) = 0.0346159*Sqrt(cx(mgs,ls)/(qx(mgs,ls)*rho0(mgs)) )
5577 xdn(mgs,ls) = Max( 100.0, xdn(mgs,ls) ) ! limit snow to 100. to keep other equations in line
5579 IF ( xdn(mgs,ls) <= 900. ) THEN
5580 dtmp = Sqrt( xmas(mgs,ls)/0.069 ) ! diameter (meters) of mean mass particle using Cox 1998 relation (m = p d^2)
5581 xv(mgs,ls) = 28.8887*xmas(mgs,ls)**(3./2.)
5582 ELSE ! at small sizes, assume ice spheres
5584 xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*Max(1.0e-9,cx(mgs,ls)))
5585 dtmp = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
5588 ELSE ! leave xdn(ls) at default value
5589 xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*Max(1.0e-9,cx(mgs,ls)))
5590 dtmp = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
5593 xdia(mgs,ls,1) = dtmp ! (xv(mgs,ls)*cwc0*6.0)**(1./3.)
5595 IF ( xv(mgs,ls) .lt. xvmn(ls) .and. isnowdens == 1) THEN
5596 xv(mgs,ls) = Max( xvmn(ls),xv(mgs,ls) )
5597 xmas(mgs,ls) = xv(mgs,ls)*xdn(mgs,ls)
5598 cx(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xmas(mgs,ls))
5599 xdia(mgs,ls,1) = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
5602 IF ( xv(mgs,ls) .gt. xvmx(ls)*Max(1.,100./Min(100.,xdn(mgs,ls))) ) THEN
5603 xv(mgs,ls) = Min( xvmx(ls), Max( xvmn(ls),xv(mgs,ls) ) )
5604 xmas(mgs,ls) = 0.106214*xv(mgs,ls)**(2./3.)
5605 cx(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xmas(mgs,ls))
5606 xdn(mgs,ls) = 0.0346159*Sqrt(cx(mgs,ls)/(qx(mgs,ls)*rho0(mgs)) )
5607 xdia(mgs,ls,1) = Sqrt( xmas(mgs,ls)/0.069 )
5610 xdia(mgs,ls,3) = xdia(mgs,ls,1)
5614 & (qx(mgs,ls)*rho0(mgs)/(pi*xdn(mgs,ls)*cnostmp(mgs)))**(0.25)
5615 cx(mgs,ls) = cnostmp(mgs)*xdia(mgs,ls,1)
5616 xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*cx(mgs,ls))
5617 xdia(mgs,ls,3) = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
5620 xdia(mgs,ls,1) = 1.e-9
5621 xdia(mgs,ls,3) = 1.e-9
5624 IF ( isnowdens == 2 ) THEN ! Set values according to Cox relationship
5629 xdia(mgs,ls,2) = xdia(mgs,ls,1)**2
5630 ! swdia3(mgs) = xdia(mgs,ls,2)*xdia(mgs,ls,1)
5631 ! xmas(mgs,ls) = xdn(mgs,ls)*(pi/6.)*swdia3(mgs)
5637 ! ################################################################
5642 IF ( lh .gt. 1 .and. ( ildo == 0 .or. ildo == lh ) ) THEN
5645 if ( qx(mgs,lh) .gt. qxmin(lh) ) then
5646 if ( ipconc .ge. 5 ) then
5648 xv(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*Max(1.0e-9,cx(mgs,lh)))
5649 xmas(mgs,lh) = xv(mgs,lh)*xdn(mgs,lh)
5651 IF ( xv(mgs,lh) .lt. xvmn(lh) .or. xv(mgs,lh) .gt. xvmx(lh) ) THEN
5652 xv(mgs,lh) = Min( xvmx(lh), Max( xvmn(lh),xv(mgs,lh) ) )
5653 xmas(mgs,lh) = xv(mgs,lh)*xdn(mgs,lh)
5654 cx(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xmas(mgs,lh))
5657 xdia(mgs,lh,3) = (xv(mgs,lh)*6.*pii)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
5658 IF ( dmuh == 1.0 ) THEN
5659 xdia(mgs,lh,1) = cwch(mgs)*xdia(mgs,lh,3)
5661 xdia(mgs,lh,1) = (xv(mgs,lh)*cwch(mgs))**(1./3.)
5666 & (qx(mgs,lh)*rho0(mgs)/(pi*xdn(mgs,lh)*cno(lh)))**(0.25)
5667 cx(mgs,lh) = cno(lh)*xdia(mgs,lh,1)
5668 xv(mgs,lh) = Max(xvmn(lh), rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) )
5669 xdia(mgs,lh,3) = (xv(mgs,lh)*6./pi)**(1./3.)
5672 xdia(mgs,lh,1) = 1.e-9
5673 xdia(mgs,lh,3) = 1.e-9
5675 xdia(mgs,lh,2) = xdia(mgs,lh,1)**2
5676 ! hwdia3(mgs) = xdia(mgs,lh,2)*xdia(mgs,lh,1)
5677 ! xmas(mgs,lh) = xdn(mgs,lh)*(pi/6.)*hwdia3(mgs)
5683 ! ################################################################
5688 IF ( lhl .gt. 1 .and. ( ildo == 0 .or. ildo == lhl ) ) THEN
5691 if ( qx(mgs,lhl) .gt. qxmin(lhl) ) then
5692 if ( ipconc .ge. 5 ) then
5694 xv(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*Max(1.0e-9,cx(mgs,lhl)))
5695 xmas(mgs,lhl) = xv(mgs,lhl)*xdn(mgs,lhl)
5696 ! write(0,*) 'setvt: xv = ',xv(mgs,lhl),xdn(mgs,lhl),cx(mgs,lhl),xmas(mgs,lhl),qx(mgs,lhl)
5698 IF ( xv(mgs,lhl) .lt. xvmn(lhl) .or. xv(mgs,lhl) .gt. xvmx(lhl) ) THEN
5699 xv(mgs,lhl) = Min( xvmx(lhl), Max( xvmn(lhl),xv(mgs,lhl) ) )
5700 xmas(mgs,lhl) = xv(mgs,lhl)*xdn(mgs,lhl)
5701 cx(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xmas(mgs,lhl))
5704 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6./pi)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
5705 IF ( dmuhl == 1.0 ) THEN
5706 xdia(mgs,lhl,1) = cwchl(mgs)*xdia(mgs,lhl,3)
5708 xdia(mgs,lhl,1) = (xv(mgs,lhl)*cwchl(mgs))**(1./3.)
5711 ! write(0,*) 'setvt: xv = ',xv(mgs,lhl),xdn(mgs,lhl),cx(mgs,lhl),xdia(mgs,lhl,3)
5714 & (qx(mgs,lhl)*rho0(mgs)/(pi*xdn(mgs,lhl)*cno(lhl)))**(0.25)
5715 cx(mgs,lhl) = cno(lhl)*xdia(mgs,lhl,1)
5716 xv(mgs,lhl) = Max(xvmn(lhl), rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*cx(mgs,lhl)) )
5717 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6./pi)**(1./3.)
5720 xdia(mgs,lhl,1) = 1.e-9
5721 xdia(mgs,lhl,3) = 1.e-9
5723 xdia(mgs,lhl,2) = xdia(mgs,lhl,1)**2
5724 ! hwdia3(mgs) = xdia(mgs,lh,2)*xdia(mgs,lh,1)
5725 ! xmas(mgs,lh) = xdn(mgs,lh)*(pi/6.)*hwdia3(mgs)
5732 ! Set terminal velocities...
5733 ! also set drag coefficients (moved to start of subroutine)
5744 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set terminal velocities'
5747 ! ################################################################
5751 IF ( ildo == 0 .or. ildo == lr ) THEN
5753 if ( qx(mgs,lr) .gt. qxmin(lr) ) then
5754 IF ( ipconc .lt. 3 ) THEN
5755 vtxbar(mgs,lr,1) = rainfallfac*(ar*gf4br/6.0)*(xdia(mgs,lr,1)**br)*rhovt(mgs)
5756 ! write(91,*) 'vtxbar: ',vtxbar(mgs,lr,1),mgs,gf4br,xdia(mgs,lr,1),rhovt(mgs)
5759 IF ( imurain == 1 ) THEN ! DSD of Diameter
5761 ! using functional form of arx*(1 - Exp(-frx*diameter) ), with arx = arx = 10.
5762 ! and frx = 516.575 ! raind fit parameters for arx*(1 - Exp(-fx*d)), where d is rain diameter in meters.
5763 ! Similar form as in Atlas et al. (1973), who had 9.65 - 10.3*Exp[-600 * d]
5768 vtxbar(mgs,lr,1) = rhovt(mgs)*arx*(1.0 - (1.0 + frx*xdia(mgs,lr,1))**(-alp - 4.0) ) ! mass weighted
5770 IF ( infdo .ge. 1 .and. rssflg == 1 ) THEN
5771 vtxbar(mgs,lr,2) = rhovt(mgs)*arx*(1.0 - (1.0 + frx*xdia(mgs,lr,1))**(-alp - 1.0) ) ! number weighted
5773 vtxbar(mgs,lr,2) = vtxbar(mgs,lr,1)
5776 IF ( infdo .ge. 2 .and. rssflg == 1 ) THEN
5777 vtxbar(mgs,lr,3) = rhovt(mgs)*arx*(1.0 - (1.0 + frx*xdia(mgs,lr,1))**(-alp - 7.0) ) ! z-weighted
5779 vtxbar(mgs,lr,3) = vtxbar(mgs,lr,1)
5782 ! write(91,*) 'setvt: alp,vn,vm,vz = ',alp,vtxbar(mgs,lr,2), vtxbar(mgs,lr,1), vtxbar(mgs,lr,3),alpha(mgs,lr)
5784 ELSEIF ( imurain == 3 ) THEN ! DSD of Volume
5786 IF ( lzr < 1 ) THEN ! not 3-moment rain
5787 rwdia = Min( xdia(mgs,lr,1), 8.0e-3 )
5789 vtxbar(mgs,lr,1) = rhovt(mgs)*6.0*pii*( 0.04771 + 3788.0*rwdia - &
5790 & 1.105e6*rwdia**2 + 1.412e8*rwdia**3 - 6.527e9*rwdia**4)
5792 IF ( infdo .ge. 1 ) THEN
5793 IF ( rssflg >= 1 ) THEN
5794 vtxbar(mgs,lr,2) = (0.09112 + 2714.0*rwdia - 4.872e5*rwdia**2 + &
5795 & 4.495e7*rwdia**3 - 1.626e9*rwdia**4)*rhovt(mgs)
5797 vtxbar(mgs,lr,2) = vtxbar(mgs,lr,1)
5801 IF ( infdo .ge. 2 ) THEN ! Z-weighted fall speed
5802 vtxbar(mgs,lr,3) = rhovt(mgs)*( &
5804 & 9246.494*(rwdia) - &
5805 & 3.2839926e6*(rwdia**2) + &
5806 & 4.944093e8*(rwdia**3) - &
5807 & 2.631718e10*(rwdia**4) )
5810 ELSE ! 3-moment rain, gamma-volume
5813 rnux = alpha(mgs,lr)
5815 IF ( infdo .ge. 1 .and. rssflg == 1) THEN ! number-weighted; DTD: added size-sorting flag
5816 vtxbar(mgs,lr,2) = rhovt(mgs)* &
5817 & (((1. + rnux)/vr)**(-1.333333)* &
5818 & (0.0911229*((1. + rnux)/vr)**1.333333*Gamma_sp(1. + rnux) + &
5819 & (5430.3131*(1. + rnux)*Gamma_sp(4./3. + rnux))/ &
5820 & vr - 1.0732802e6*((1. + rnux)/vr)**0.6666667* &
5821 & Gamma_sp(1.666667 + rnux) + &
5822 & 8.584110982429507e7*((1. + rnux)/vr)**(1./3.)* &
5823 & Gamma_sp(2. + rnux) - &
5824 & 2.3303765697228556e9*Gamma_sp(7./3. + rnux)))/ &
5825 & Gamma_sp(1. + rnux)
5829 vtxbar(mgs,lr,1) = rhovt(mgs)* &
5830 & (0.0911229*(1 + rnux)**1.3333333333333333*Gamma_sp(2. + rnux) + &
5831 & 5430.313059683277*(1 + rnux)*vr**0.3333333333333333* &
5832 & Gamma_sp(2.333333333333333 + rnux) - &
5833 & 1.0732802065650471e6*(1 + rnux)**0.6666666666666666*vr**0.6666666666666666* &
5834 & Gamma_sp(2.6666666666666667 + rnux) + &
5835 & 8.584110982429507e7*(1 + rnux)**0.3333333333333333*vr*Gamma_sp(3 + rnux) - &
5836 & 2.3303765697228556e9*vr**1.3333333333333333* &
5837 & Gamma_sp(3.333333333333333 + rnux))/ &
5838 & ((1 + rnux)**2.333333333333333*Gamma_sp(1 + rnux))
5840 IF(infdo .ge. 1 .and. rssflg == 0) THEN ! No size-sorting, set N-weighted fall speed to mass-weighted
5841 vtxbar(mgs,lr,2) = vtxbar(mgs,lr,1)
5844 IF ( infdo .ge. 2 .and. rssflg == 1) THEN ! Z-weighted fall speed
5845 vtxbar(mgs,lr,3) = rhovt(mgs)* &
5846 & ((1. + rnux)*(0.0911229*(1 + rnux)**1.3333333333333333*Gamma_sp(3. + rnux) + &
5847 & 5430.313059683277*(1 + rnux)*vr**0.3333333333333333* &
5848 & Gamma_sp(3.3333333333333335 + rnux) - &
5849 & 1.0732802065650471e6*(1 + rnux)**0.6666666666666666* &
5850 & vr**0.6666666666666666*Gamma_sp(3.6666666666666665 + rnux) + &
5851 & 8.5841109824295e7*(1 + rnux)**0.3333333333333333*vr*Gamma_sp(4. + rnux) - &
5852 & 2.3303765697228556e9*vr**1.3333333333333333* &
5853 & Gamma_sp(4.333333333333333 + rnux)))/ &
5854 & ((1 + rnux)**3.3333333333333335*(2 + rnux)*Gamma_sp(1 + rnux))
5856 ! write(0,*) 'setvt: mgs,lzr,infdo = ',mgs,lzr,infdo
5857 ! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,lr,1),vtxbar(mgs,lr,2),vtxbar(mgs,lr,3)
5859 ELSEIF (infdo .ge. 2) THEN ! No size-sorting, set Z-weighted fall speed to mass-weighted
5860 vtxbar(mgs,lr,3) = vtxbar(mgs,lr,1)
5867 ! IF ( rwrad*mwfac .gt. 6.0e-4 ) THEN
5868 ! vtxbar(mgs,lr,1) = 20.1*Sqrt(100.*rwrad*mwfac)*rhovt(mgs)
5870 ! vtxbar(mgs,lr,1) = 80.0e2*rwrad*rhovt(mgs)*mwfac
5872 ! IF ( rwrad .gt. 6.0e-4 ) THEN
5873 ! vtxbar(mgs,lr,2) = 20.1*Sqrt(100.*rwrad)*rhovt(mgs)
5875 ! vtxbar(mgs,lr,2) = 80.0e2*rwrad*rhovt(mgs)
5879 vtxbar(mgs,lr,1) = 0.0
5880 vtxbar(mgs,lr,2) = 0.0
5883 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set rain vt'
5887 ! ################################################################
5889 ! SNOW !Zrnic et al. (1993)
5891 IF ( ls .gt. 1 .and. ( ildo == 0 .or. ildo == ls ) ) THEN
5893 if ( qx(mgs,ls) .gt. qxmin(ls) ) then
5894 IF ( ipconc .ge. 4 ) THEN
5895 if ( mixedphase .and. qsvtmod ) then
5897 IF ( isnowfall == 1 ) THEN
5898 ! original (Zrnic et al. 1993)
5899 vtxbar(mgs,ls,1) = 5.72462*rhovt(mgs)*(xv(mgs,ls))**(1./12.)
5900 ELSEIF ( isnowfall == 2 ) THEN
5902 IF ( isnowdens == 1 ) THEN
5903 vtxbar(mgs,ls,1) = 11.9495*rhovt(mgs)*(xv(mgs,ls))**(0.14)
5905 vtxbar(mgs,ls,1) = 11.9495*rhovt(mgs)*(xv(mgs,ls)*xdn(mgs,ls)/100.)**(0.14)
5907 ELSEIF ( isnowfall == 3 ) THEN
5908 ! Cox, mass distrib:
5909 vtxbar(mgs,ls,1) = 50.092*rhovt(mgs)*(xmas(mgs,ls))**(0.2635)
5912 IF(Abs(sssflg) >= 1) THEN
5913 IF ( isnowfall == 1 ) THEN
5914 vtxbar(mgs,ls,2) = 4.04091*rhovt(mgs)*(xv(mgs,ls))**(1./12.)
5915 ELSEIF ( isnowfall == 2 ) THEN
5917 IF ( isnowdens == 1 ) THEN
5918 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)
5920 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)
5922 ELSEIF ( isnowfall == 3 ) THEN
5923 ! Cox, mass distrib:
5924 vtxbar(mgs,ls,2) = 21.6147*rhovt(mgs)*(xmas(mgs,ls))**(0.2635)
5927 vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
5929 IF ( infdo >= 2 ) THEN
5930 IF ( isnowfall == 1 ) THEN
5931 vtxbar(mgs,ls,3) = 6.12217*rhovt(mgs)*(xv(mgs,ls))**(1./12.) ! Zrnic et al 93
5932 ELSEIF ( isnowfall == 2 ) THEN
5933 vtxbar(mgs,ls,3) = 13.3436*rhovt(mgs)*(xv(mgs,ls))**(0.14) ! Ferrier 94
5934 ELSEIF ( isnowfall == 3 ) THEN
5935 ! Cox, mass distrib:
5936 vtxbar(mgs,ls,3) = 61.0914*rhovt(mgs)*(xmas(mgs,ls))**(0.2635)
5940 IF ( sssflg < 0 .and. temcg(mgs) > Abs(sssflg) ) THEN ! above a given temperature, effectively turn off size sorting
5941 vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
5942 vtxbar(mgs,ls,3) = vtxbar(mgs,ls,1)
5946 ELSE ! single-moment:
5947 vtxbar(mgs,ls,1) = (cs*gf4ds/6.0)*(xdia(mgs,ls,1)**ds)*rhovt(mgs)
5948 vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
5951 vtxbar(mgs,ls,1) = 0.0
5954 IF ( snowfallfac /= 1.0 ) THEN
5955 vtxbar(mgs,ls,1) = snowfallfac*vtxbar(mgs,ls,1)
5956 vtxbar(mgs,ls,2) = snowfallfac*vtxbar(mgs,ls,2)
5957 vtxbar(mgs,ls,3) = snowfallfac*vtxbar(mgs,ls,3)
5962 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set snow vt'
5967 ! ################################################################
5969 ! GRAUPEL !Wisner et al. (1972)
5971 IF ( lh .gt. 1 .and. ( ildo == 0 .or. ildo == lh ) ) THEN
5974 vtxbar(mgs,lh,1) = 0.0
5975 if ( qx(mgs,lh) .gt. qxmin(lh) ) then
5977 IF ( icdx .eq. 1 ) THEN
5979 ELSEIF ( icdx .eq. 2 ) THEN
5980 ! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(xdnmx(lh) - xdn(mgs,lh))/(xdnmx(lh)-xdnmn(lh)) ) )
5981 ! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lh))/(900. - 300.) ) )
5982 cd = Max(0.45, Min(1.0, 0.45 + 0.35*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
5983 ! cd = Max(0.55, Min(1.0, 0.55 + 0.25*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
5984 ELSEIF ( icdx .eq. 3 ) THEN
5985 ! cd = Max(0.45, Min(1.0, 0.45 + 0.55*(800.0 - Max( 300., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 300.) ) )
5986 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hdnmn, Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
5987 ELSEIF ( icdx .eq. 4 ) THEN
5988 cd = Max(cdhmin, Min(cdhmax, cdhmin + (cdhmax-cdhmin)* &
5989 & (cdhdnmax - Max( cdhdnmin, Min( cdhdnmax, xdn(mgs,lh) ) ) )/(cdhdnmax - cdhdnmin) ) )
5990 ELSEIF ( icdx .eq. 5 ) THEN
5991 cd = cdx(lh)*(xdn(mgs,lh)/rho_qh)**(2./3.)
5992 ELSEIF ( icdx .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
5993 indxr = Int( (xdn(mgs,lh)-50.)/100. ) + 1
5994 indxr = Min( ngdnmm, Max(1,indxr) )
5997 delrho = Max( 0.0, 0.01*(xdn(mgs,lh) - mmgraupvt(indxr,1)) )
5998 IF ( indxr < ngdnmm ) THEN
6000 axx(mgs,lh) = mmgraupvt(indxr,2) + delrho*(mmgraupvt(indxr+1,2) - mmgraupvt(indxr,2) )
6001 bxx(mgs,lh) = mmgraupvt(indxr,3) + delrho*(mmgraupvt(indxr+1,3) - mmgraupvt(indxr,3) )
6005 axx(mgs,lh) = mmgraupvt(indxr,2)
6006 bxx(mgs,lh) = mmgraupvt(indxr,3)
6012 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hdnmn, Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
6014 ELSEIF ( icdx <= 0 ) THEN !
6017 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hdnmn, Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
6019 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hdnmn, Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
6023 IF ( alpha(mgs,lh) .eq. 0.0 .and. icdx > 0 .and. icdx /= 6 ) THEN
6024 ! axx(mgs,lh) = (gf4p5/6.0)* &
6025 ! & Sqrt( (xdn(mgs,lh)*4.0*gr) / &
6026 ! & (3.0*cd*rho0(mgs)) )
6027 axx(mgs,lh) = Sqrt(4.0*xdn(mgs,lh)*gr/(3.0*cd*rho00))
6029 vtxbar(mgs,lh,1) = (gf4p5/6.0)* rhovt(mgs)*axx(mgs,lh) * Sqrt(xdia(mgs,lh,1))
6030 ! vtxbar(mgs,lh,1) = (gf4p5/6.0)* &
6031 ! & Sqrt( (xdn(mgs,lh)*xdia(mgs,lh,1)*4.0*gr) / &
6032 ! & (3.0*cd*rho0(mgs)) )
6034 IF ( icdx /= 6 ) bbx = bx(lh)
6035 tmp = 4. + alpha(mgs,lh) + bbx
6036 i = Int(dgami*(tmp))
6038 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
6040 tmp = 4. + alpha(mgs,lh)
6041 i = Int(dgami*(tmp))
6043 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
6045 ! aax = Max( 1.0, Min(2.0, (xdn(mgs,lh)/400.) ) )
6046 ! vtxbar(mgs,lh,1) = rhovt(mgs)*aax*ax(lh)*(xdia(mgs,lh,1)**bx(lh)*x)/y
6048 IF ( icdx > 0 .and. icdx /= 6) THEN
6049 aax = Sqrt(4.0*xdn(mgs,lh)*gr/(3.0*cd*rho00))
6050 vtxbar(mgs,lh,1) = rhovt(mgs)*aax* Sqrt(xdia(mgs,lh,1)) * x/y
6053 ELSEIF (icdx == 6 ) THEN
6054 vtxbar(mgs,lh,1) = rhovt(mgs)*aax* xdia(mgs,lh,1)**bbx * x/y
6056 axx(mgs,lh) = ax(lh)
6057 bxx(mgs,lh) = bx(lh)
6058 vtxbar(mgs,lh,1) = rhovt(mgs)*ax(lh)*(xdia(mgs,lh,1)**bx(lh)*x)/y
6061 ! & Gamma_sp(4.0 + dnu(lh) + 0.6))/Gamma_sp(4. + dnu(lh))
6064 IF ( lwsm6 .and. ipconc == 0 ) THEN
6065 ! vtxbar(mgs,lh,1) = (330.*gf4ds/6.0)*(xdia(mgs,ls,1)**ds)*rhovt(mgs)
6066 vtxbar(mgs,lh,1) = (330.*gf4br/6.0)*(xdia(mgs,lh,1)**br)*rhovt(mgs)
6071 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt'
6076 ! ################################################################
6080 IF ( lhl .gt. 1 .and. ( ildo == 0 .or. ildo == lhl ) ) THEN
6083 vtxbar(mgs,lhl,1) = 0.0
6084 if ( qx(mgs,lhl) .gt. qxmin(lhl) ) then
6086 IF ( icdxhl .eq. 1 ) THEN
6088 ELSEIF ( icdxhl .eq. 3 ) THEN
6089 ! cd = Max(0.45, Min(1.0, 0.45 + 0.55*(800.0 - Max( 300., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 300.) ) )
6090 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hldnmn, Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
6091 ELSEIF ( icdxhl .eq. 4 ) THEN
6092 cd = Max(cdhlmin, Min(cdhlmax, cdhlmin + (cdhlmax-cdhlmin)* &
6093 & (cdhldnmax - Max( cdhldnmin, Min( cdhldnmax, xdn(mgs,lhl) ) ) )/(cdhldnmax - cdhldnmin) ) )
6094 ELSEIF ( icdxhl .eq. 5 ) THEN
6095 cd = cdx(lh)*(xdn(mgs,lhl)/rho_qh)**(2./3.)
6096 ELSEIF ( icdxhl .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
6097 indxr = Int( (xdn(mgs,lhl)-50.)/100. ) + 1
6098 indxr = Min( ngdnmm, Max(1,indxr) )
6101 delrho = Max( 0.0, 0.01*(xdn(mgs,lhl) - mmgraupvt(indxr,1)) )
6102 IF ( indxr < ngdnmm ) THEN
6104 axx(mgs,lhl) = mmgraupvt(indxr,2) + delrho*(mmgraupvt(indxr+1,2) - mmgraupvt(indxr,2) )
6105 bxx(mgs,lhl) = mmgraupvt(indxr,3) + delrho*(mmgraupvt(indxr+1,3) - mmgraupvt(indxr,3) )
6109 axx(mgs,lhl) = mmgraupvt(indxr,2)
6110 bxx(mgs,lhl) = mmgraupvt(indxr,3)
6116 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hldnmn, Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
6119 ! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lhl))/(900. - 300.) ) )
6120 ! cd = Max(0.5, Min(0.8, 0.5 + 0.3*(xdnmx(lhl) - xdn(mgs,lhl))/(xdnmx(lhl)-xdnmn(lhl)) ) )
6121 ! cd = Max(0.45, Min(0.6, 0.45 + 0.15*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 500.) ) )
6122 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hldnmn, Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
6127 IF ( alpha(mgs,lhl) .eq. 0.0 .and. icdxhl > 0 .and. icdxhl /= 6) THEN
6128 ! axx(mgs,lhl) = (gf4p5/6.0)* &
6129 ! & Sqrt( (xdn(mgs,lhl)*4.0*gr) / &
6130 ! & (3.0*cd*rho0(mgs)) )
6131 axx(mgs,lhl) = Sqrt(4.0*xdn(mgs,lhl)*gr/(3.0*cd*rho00))
6133 vtxbar(mgs,lhl,1) = (gf4p5/6.0)* rhovt(mgs)*axx(mgs,lhl) * Sqrt(xdia(mgs,lhl,1))
6135 IF ( icdxhl /= 6 ) bbx = bx(lhl)
6136 tmp = 4. + alpha(mgs,lhl) + bbx
6137 i = Int(dgami*(tmp))
6139 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
6141 tmp = 4. + alpha(mgs,lhl)
6142 i = Int(dgami*(tmp))
6144 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
6146 IF ( icdxhl > 0 .and. icdxhl /= 6) THEN
6147 aax = Sqrt(4.0*xdn(mgs,lhl)*gr/(3.0*cd*rho00))
6148 vtxbar(mgs,lhl,1) = rhovt(mgs)*aax* Sqrt(xdia(mgs,lhl,1)) * x/y
6151 ELSEIF ( icdxhl == 6 ) THEN
6152 vtxbar(mgs,lhl,1) = rhovt(mgs)*aax* (xdia(mgs,lhl,1))**bbx * x/y
6154 axx(mgs,lhl) = ax(lhl)
6155 bxx(mgs,lhl) = bx(lhl)
6156 vtxbar(mgs,lhl,1) = rhovt(mgs)*(ax(lhl)*xdia(mgs,lhl,1)**bx(lhl)*x)/y
6159 ! & Gamma_sp(4.0 + dnu(lh) + 0.6))/Gamma_sp(4. + dnu(lh))
6165 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt'
6170 IF ( infdo .ge. 1 ) THEN
6173 ! IF ( il .ne. lr ) THEN
6175 vtxbar(mgs,lc,2) = vtxbar(mgs,lc,1)
6176 IF ( li .gt. 1 ) THEN
6177 ! vtxbar(mgs,li,2) = rhovt(mgs)*49420.*1.25447*xdia(mgs,li,1)**(1.415) ! n-wgt (Ferrier 94)
6178 ! vtxbar(mgs,li,2) = vtxbar(mgs,li,1)
6180 ! test print stuff...
6181 ! IF ( xdia(mgs,li,1) .gt. 200.e-6 ) THEN
6182 ! tmp = (xv(mgs,li)*cwc0)**(1./3.)
6183 ! x = rhovt(mgs)*49420.*40.0005/5.40662*tmp**(1.415)
6184 ! y = rhovt(mgs)*49420.*1.25447*tmp**(1.415)
6185 ! write(6,*) 'Ice fall: ',vtxbar(mgs,li,1),x,y,tmp,xdia(mgs,li,1)
6188 ! vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
6191 IF ( lg .gt. lr ) THEN
6194 IF ( ildo == 0 .or. ildo == il ) THEN
6197 IF ( qx(mgs,il) .gt. qxmin(il) ) THEN
6198 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
6200 ! DTD: allow for setting of number-weighted and z-weighted fall speeds to the mass-weighted value,
6201 ! effectively turning off size-sorting
6203 IF ( il .eq. lh ) THEN ! {
6205 IF ( icdx .eq. 1 ) THEN
6207 ELSEIF ( icdx .eq. 2 ) THEN
6208 ! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(xdnmx(lh) - xdn(mgs,lh))/(xdnmx(lh)-xdnmn(lh)) ) )
6209 ! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lh))/(900. - 300.) ) )
6210 cd = Max(0.45, Min(1.0, 0.45 + 0.35*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
6211 ! cd = Max(0.55, Min(1.0, 0.55 + 0.25*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
6212 ELSEIF ( icdx .eq. 3 ) THEN
6213 ! 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) ) )
6214 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hdnmn, Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
6215 ELSEIF ( icdx .eq. 4 ) THEN
6216 cd = Max(cdhmin, Min(cdhmax, cdhmin + (cdhmax-cdhmin)* &
6217 & (cdhdnmax - Max( cdhdnmin, Min( cdhdnmax, xdn(mgs,lh) ) ) )/(cdhdnmax - cdhdnmin) ) )
6218 ELSEIF ( icdx .eq. 5 ) THEN
6219 cd = cdx(lh)*(xdn(mgs,lh)/rho_qh)**(2./3.)
6220 ELSEIF ( icdx .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
6223 ELSEIF ( icdx <= 0 ) THEN !
6228 ELSEIF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
6230 IF ( icdxhl .eq. 1 ) THEN
6232 ELSEIF ( icdxhl .eq. 3 ) THEN
6233 ! cd = Max(0.45, Min(1.0, 0.45 + 0.55*(800.0 - Max( 300., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 300.) ) )
6234 cd = Max(0.45, Min(1.2, 0.45 + 0.55*(800.0 - Max( hldnmn, Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
6235 ELSEIF ( icdxhl .eq. 4 ) THEN
6236 cd = Max(cdhlmin, Min(cdhlmax, cdhlmin + (cdhlmax-cdhlmin)* &
6237 & (cdhldnmax - Max( cdhldnmin, Min( cdhldnmax, xdn(mgs,lhl) ) ) )/(cdhldnmax - cdhldnmin) ) )
6238 ELSEIF ( icdxhl == 5 ) THEN
6239 ! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lhl))/(900. - 300.) ) )
6240 ! cd = Max(0.5, Min(0.8, 0.5 + 0.3*(xdnmx(lhl) - xdn(mgs,lhl))/(xdnmx(lhl)-xdnmn(lhl)) ) )
6241 cd = Max(0.45, Min(0.6, 0.45 + 0.15*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 500.) ) )
6242 ELSEIF ( icdxhl .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
6249 IF ( alpha(mgs,il) .eq. 0. .and. infdo .lt. 2 .and. &
6250 ( ( il==lh .and. icdx > 0 .and. icdx /= 6) .or. ( il==lhl .and. icdxhl > 0 .and. icdxhl /= 6 ) ) ) THEN ! {
6251 vtxbar(mgs,il,2) = &
6252 & Sqrt( (xdn(mgs,il)*xdia(mgs,il,1)*pi*gr) / &
6253 & (3.0*cd*Max(0.05,rho0(mgs))) )
6256 IF ( il == lh .and. icdx /= 6 ) bbx = bx(il)
6257 IF ( il == lhl .and. icdxhl /= 6 ) bbx = bx(il)
6258 tmp = 1. + alpha(mgs,il) + bbx
6259 i = Int(dgami*(tmp))
6261 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
6263 tmp = 1. + alpha(mgs,il)
6264 i = Int(dgami*(tmp))
6266 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
6268 IF ( il .eq. lh .or. il .eq. lhl) THEN ! {
6269 IF ( ( il==lh .and. icdx > 0 ) ) THEN
6270 IF ( icdx /= 6 ) THEN
6271 aax = Sqrt(4.0*xdn(mgs,il)*gr/(3.0*cd*rho00))
6272 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bx(il) * x/y
6273 ELSE ! (icdx == 6 ) THEN
6274 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bbx * x/y
6277 ELSEIF ( ( il==lhl .and. icdxhl > 0 ) ) THEN
6278 IF ( icdxhl /= 6 ) THEN
6279 aax = Sqrt(4.0*xdn(mgs,il)*gr/(3.0*cd*rho00))
6280 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bx(il) * x/y
6281 ELSE ! ( icdxhl == 6 )
6282 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bbx * x/y
6284 ELSE ! get here if il==lh and icdx < 0 -- or -- il==lhl and icdxhl < 0
6286 vtxbar(mgs,il,2) = rhovt(mgs)*ax(il)*(xdia(mgs,il,1)**bx(il)*x)/y
6289 ! vtxbar(mgs,il,2) = &
6290 ! & rhovt(mgs)*(xdn(mgs,il)/400.)*(75.715*xdia(mgs,il,1)**0.6* &
6292 ! vtxbar(mgs,il,2) = &
6293 ! & rhovt(mgs)*(xdn(mgs,il)/400.)*(ax(il)*xdia(mgs,il,1)**bx(il)* &
6295 IF ( infdo .ge. 2 ) THEN ! Z-weighted
6297 tmp = 7. + alpha(mgs,il) + bbx
6298 i = Int(dgami*(tmp))
6300 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
6302 tmp = 7. + alpha(mgs,il)
6303 i = Int(dgami*(tmp))
6305 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
6307 vtxbar(mgs,il,3) = rhovt(mgs)* &
6308 & (aax*(xdia(mgs,il,1) )**bbx * &
6310 ! & Gamma(7.0 + alpha(mgs,il) + bbx))/Gamma(7. + alpha(mgs,il))
6311 IF ( .not. (vtxbar(mgs,il,1) > -1. .and. vtxbar(mgs,il,1) < 200. ) .or. &
6312 .not. (vtxbar(mgs,il,3) > -1. .and. vtxbar(mgs,il,3) < 200. ) ) THEN
6313 write(0,*) 'Setvtz: problem with vtxbar1/3: ',il,vtxbar(mgs,il,1),vtxbar(mgs,il,3),aax,bbx,x,y
6314 write(0,*) 'q, number, diam1,3(mm) = ', qx(mgs,il),cx(mgs,il),1000.*xdia(mgs,il,1),1000.*xdia(mgs,il,3)
6315 ! call commasmpi_abort()
6317 ! & (aax*(1.0/xdia(mgs,il,1) )**(- bx(il))* &
6318 ! & Gamma_sp(7.0 + alpha(mgs,il) + bx(il)))/Gamma_sp(7. + alpha(mgs,il))
6321 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt3'
6324 vtxbar(mgs,il,2) = &
6325 & rhovt(mgs)*(ax(il)*xdia(mgs,il,1)**bx(il)* &
6328 IF ( infdo .ge. 2 ) THEN ! Z-weighted
6329 vtxbar(mgs,il,3) = rhovt(mgs)* &
6330 & (aax*(1.0/xdia(mgs,il,1) )**(- bbx)* &
6331 & Gamma_sp(7.0 + alpha(mgs,il) + bbx))/Gamma_sp(7. + alpha(mgs,il))
6332 ! & (ax(il)*(1.0/xdia(mgs,il,1) )**(- bx(il))* &
6333 ! & Gamma_sp(7.0 + alpha(mgs,il) + bx(il)))/Gamma_sp(7. + alpha(mgs,il))
6336 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt4'
6339 ! & Gamma_sp(1.0 + dnu(il) + 0.6)/Gamma_sp(1. + dnu(il))
6342 ! IF ( infdo .ge. 2 ) THEN ! Z-weighted
6343 ! vtxbar(mgs,il,3) = rhovt(mgs)* &
6344 ! & (ax(il)*(1.0/xdia(mgs,il,1) )**(- bx(il))* &
6345 ! & Gamma_sp(7.0 + alpha(mgs,il) + bx(il)))/Gamma_sp(7. + alpha(mgs,il))
6348 ! IF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
6349 ! write(0,*) 'setvt: ',qx(mgs,il),xdia(mgs,il,1),xdia(mgs,il,3),dnu(il),ax(il),bx(il)
6351 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
6352 vtxbar(mgs,il,2) = vtxbar(mgs,il,1)
6353 vtxbar(mgs,il,3) = vtxbar(mgs,il,1)
6354 ELSE ! not lh or lhl
6355 vtxbar(mgs,il,2) = &
6356 & Sqrt( (xdn(mgs,il)*xdia(mgs,il,1)*pi*gr) / &
6357 & (3.0*cdx(il)*Max(0.05,rho0(mgs))) )
6358 vtxbar(mgs,il,3) = vtxbar(mgs,il,1)
6360 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt5'
6365 vtxbar(mgs,il,2) = 0.0
6367 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt6'
6372 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt7'
6377 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt8'
6384 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt9'
6387 ! IF ( qx(mgs,lr) > qxmin(lr) ) THEN
6388 ! write(0,*) 'setvt2: mgs,lzr,infdo = ',mgs,lzr,infdo
6389 ! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,lr,1),vtxbar(mgs,lr,2),vtxbar(mgs,lr,3)
6393 ENDIF ! infdo .ge. 1
6395 IF ( lh > 0 .and. graupelfallfac /= 1.0 ) THEN
6397 vtxbar(mgs,lh,1) = graupelfallfac*vtxbar(mgs,lh,1)
6398 vtxbar(mgs,lh,2) = graupelfallfac*vtxbar(mgs,lh,2)
6399 vtxbar(mgs,lh,3) = graupelfallfac*vtxbar(mgs,lh,3)
6400 axx(mgs,lh) = graupelfallfac*axx(mgs,lh)
6404 IF ( lhl > 0 .and. hailfallfac /= 1.0 ) THEN
6406 vtxbar(mgs,lhl,1) = hailfallfac*vtxbar(mgs,lhl,1)
6407 vtxbar(mgs,lhl,2) = hailfallfac*vtxbar(mgs,lhl,2)
6408 vtxbar(mgs,lhl,3) = hailfallfac*vtxbar(mgs,lhl,3)
6409 axx(mgs,lhl) = hailfallfac*axx(mgs,lhl)
6413 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: END OF ROUTINE'
6415 !############ SETVTZ ############################
6418 END SUBROUTINE setvtz
6419 !--------------------------------------------------------------------------
6422 ! ##############################################################################
6425 ! subroutine to calculate fall speeds of hydrometeors
6428 subroutine ziegfall1d(nx,ny,nz,nor,norz,na,dtp,jgs,ixcol, &
6430 & an,dn,ipconc0,t0,t7,cwmasn,cwmasx, &
6432 & qxmin,xdnmx,xdnmn,cdx,cno,xdn0,xvmn,xvmx, &
6433 & ngs,qx,qxw,cx,xv,vtxbar,xmas,xdn,xdia,vx,alpha,zx,igs,kgs, &
6434 & rho0,temcg,temg,rhovt,cwnc,cinc,fadvisc,cwdia,cipmas,cnina,cimas, &
6436 & infdo,ildo,timesetvt)
6438 ! 12.16.2005: .F version use in transitional SWM model
6440 ! 10.10.2003: Added cimn and cimx to setting for cci and cip.
6444 ! need to set up values for:
6445 ! : cipdia,cidia,cwdia,cwmas,vtwbar,
6446 ! : rho0,temcg,cip,cci
6448 ! and need to put fallspeed values in cwvt etc.
6455 integer, intent(in) :: ixcol ! which column to return
6456 integer, intent(in) :: ildo
6458 integer nx,ny,nz,nor,norz,ngt,jgs,na
6459 real an(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,na)
6460 real dn(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
6461 real t0(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
6462 real t7(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
6465 real :: rhovtzx(nz,nx)
6468 parameter (ndebugzf = 0)
6470 integer ix,jy,kz,i,j,k,il
6474 real xvt(nz+1,nx,3,lc:lhab) ! 1=mass-weighted, 2=number-weighted
6478 real xvmn(lc:lhab), xvmx(lc:lhab)
6479 double precision,optional :: timesetvt
6482 integer :: ngscnt,mgs,ipconc0
6483 ! parameter ( ngs=200 )
6485 real :: qx(ngs,lv:lhab)
6486 real :: qxw(ngs,ls:lhab)
6487 real :: cx(ngs,lc:lhab)
6488 real :: xv(ngs,lc:lhab)
6489 real :: vtxbar(ngs,lc:lhab,3)
6490 real :: xmas(ngs,lc:lhab)
6491 real :: xdn(ngs,lc:lhab)
6492 real :: cdxgs(ngs,lc:lhab)
6493 real :: xdia(ngs,lc:lhab,3)
6494 real :: vx(ngs,li:lhab)
6495 real :: alpha(ngs,lc:lhab)
6496 real :: zx(ngs,lr:lhab)
6498 real xdnmx(lc:lhab), xdnmn(lc:lhab)
6499 real :: axx(ngs,lh:lhab), bxx(ngs,lh:lhab)
6500 ! real axh(ngs),bxh(ngs),axhl(ngs),bxhl(ngs)
6507 ! Fixed intercept values for single moment scheme
6511 real cwccn0,cwmasn,cwmasx,cwradn
6514 integer nxmpb,nzmpb,nxz,numgs,inumgs
6518 integer igs(ngs),kgs(ngs)
6520 real rho0(ngs),temcg(ngs)
6526 real cwnc(ngs),cinc(ngs)
6527 real fadvisc(ngs),cwdia(ngs),cipmas(ngs)
6529 ! real cimasn,cimasx,
6530 real :: cnina(ngs),cimas(ngs)
6532 real :: cnostmp(ngs)
6537 ! general constants for microphysics
6548 real chw, qr, z, rd, alp, z1, g1, vr, nrx, tmp
6555 double precision :: dpt1, dpt2
6558 !-----------------------------------------------------------------------------
6559 ! MPI LOCAL VARIABLES
6561 integer :: ixb, jyb, kzb
6562 integer :: ixe, jye, kze
6564 logical :: debug_mpi = .false.
6567 if (ndebugzf .gt. 0 ) write(0,*) "ZIEGFALL: ENTERED SUBROUTINE"
6569 ! #####################################################################
6571 ! #####################################################################
6578 IF ( ls .gt. 1 ) THEN
6580 ldoliq = ldoliq .or. ( lliq(il) .gt. 1 )
6592 ! new values for cs and ds
6595 ! pi = 4.0*atan(1.0)
6596 ! pii = piinv ! 1./pi
6604 ! general constants for microphysics
6608 ! ci constants in mks units
6613 ! Set terminal velocities...
6614 ! also set drag coefficients
6623 IF ( ildo == 0 ) THEN
6642 flag = flag .or. ( an(ix,jy,kz,il) .gt. qxmin(il) )
6646 ! load temp quantities
6651 if ( ngscnt .eq. ngs ) goto 1100
6657 ! if ( jy .eq. (ny-jstag) ) iend = 1
6661 if ( ngscnt .eq. 0 ) go to 9998
6663 ! set temporaries for microphysics variables
6668 ! Reconstruct various quantities
6672 rho0(mgs) = dn(igs(mgs),jy,kgs(mgs))
6673 rhovt(mgs) = rhovtzx(kgs(mgs),ixcol) ! Sqrt(rho00/rho0(mgs))
6674 temg(mgs) = t0(igs(mgs),jy,kgs(mgs))
6675 temcg(mgs) = temg(mgs) - tfr
6681 ! only need fadvisc for
6682 IF ( lc .gt. 1 .and. (ildo == 0 .or. ildo == lc ) ) then
6684 fadvisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))* &
6685 & (temg(mgs)/296.0)**(1.5)
6689 IF ( ipconc .eq. 0 ) THEN
6691 cnina(mgs) = t7(igs(mgs),jgs,kgs(mgs))
6696 IF ( ildo > 0 ) THEN
6697 vtxbar(:,ildo,:) = 0.0
6703 ! qx(mgs,lv) = max(an(igs(mgs),jy,kgs(mgs),lv), 0.0)
6707 qx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),il), 0.0)
6711 cnostmp(:) = cno(ls)
6712 IF ( ipconc < 1 .and. lwsm6 .and. (ildo == 0 .or. ildo == ls )) THEN
6714 tmp = Min( 0.0, temcg(mgs) )
6715 cnostmp(mgs) = Min( 2.e8, 2.e6*exp(0.12*tmp) )
6721 ! set concentrations
6725 if ( ipconc .ge. 1 .and. li .gt. 1 .and. (ildo == 0 .or. ildo == li ) ) then
6727 cx(mgs,li) = Max(an(igs(mgs),jy,kgs(mgs),lni), 0.0)
6730 if ( ipconc .ge. 2 .and. lc .gt. 1 .and. (ildo == 0 .or. ildo == lc ) ) then
6732 cx(mgs,lc) = Max(an(igs(mgs),jy,kgs(mgs),lnc), 0.0)
6733 ! cx(mgs,lc) = Min( ccwmx, cx(mgs,lc) )
6736 if ( ipconc .ge. 3 .and. lr .gt. 1 .and. (ildo == 0 .or. ildo == lr ) ) then
6738 cx(mgs,lr) = Max(an(igs(mgs),jy,kgs(mgs),lnr), 0.0)
6739 ! IF ( qx(mgs,lr) .le. qxmin(lr) ) THEN
6741 ! cx(mgs,lr) = Max( 0.0, cx(mgs,lr) )
6745 if ( ipconc .ge. 4 .and. ls .gt. 1 .and. (ildo == 0 .or. ildo == ls ) ) then
6747 cx(mgs,ls) = Max(an(igs(mgs),jy,kgs(mgs),lns), 0.0)
6748 ! IF ( qx(mgs,ls) .le. qxmin(ls) ) THEN
6750 ! cx(mgs,ls) = Max( 0.0, cx(mgs,ls) )
6755 if ( ipconc .ge. 5 .and. lh .gt. 1 .and. (ildo == 0 .or. ildo == lh ) ) then
6758 cx(mgs,lh) = Max(an(igs(mgs),jy,kgs(mgs),lnh), 0.0)
6759 ! IF ( qx(mgs,lh) .le. qxmin(lh) ) THEN
6761 ! cx(mgs,lh) = Max( 0.0, cx(mgs,lh) )
6767 if ( ipconc .ge. 5 .and. lhl .gt. 1 .and. (ildo == 0 .or. ildo == lhl ) ) then
6770 cx(mgs,lhl) = Max(an(igs(mgs),jy,kgs(mgs),lnhl), 0.0)
6771 ! IF ( qx(mgs,lhl) .le. qxmin(lhl) ) THEN
6773 ! ELSEIF ( cx(mgs,lhl) .eq. 0.0 .and. qx(mgs,lhl) .lt. 3.0*qxmin(lhl) ) THEN
6776 ! cx(mgs,lhl) = Max( 0.0, cx(mgs,lhl) )
6783 xdn(mgs,lc) = xdn0(lc)
6784 xdn(mgs,lr) = xdn0(lr)
6785 ! IF ( ls .gt. 1 .and. lvs .eq. 0 ) xdn(mgs,ls) = xdn0(ls)
6786 ! IF ( lh .gt. 1 .and. lvh .eq. 0 ) xdn(mgs,lh) = xdn0(lh)
6787 IF ( li .gt. 1 ) xdn(mgs,li) = xdn0(li)
6788 IF ( ls .gt. 1 ) xdn(mgs,ls) = xdn0(ls)
6789 IF ( lh .gt. 1 ) xdn(mgs,lh) = xdn0(lh)
6790 IF ( lhl .gt. 1 ) xdn(mgs,lhl) = xdn0(lhl)
6794 ! Set mean particle volume
6796 IF ( ldovol .and. (ildo == 0 .or. ildo >= li ) ) THEN
6802 IF ( lvol(il) .ge. 1 ) THEN
6805 vx(mgs,il) = Max(an(igs(mgs),jy,kgs(mgs),lvol(il)), 0.0)
6806 IF ( vx(mgs,il) .gt. rho0(mgs)*qxmin(il)*1.e-3 .and. qx(mgs,il) .gt. qxmin(il) ) THEN
6807 xdn(mgs,il) = Min( xdnmx(il), Max( xdnmn(il), rho0(mgs)*qx(mgs,il)/vx(mgs,il) ) )
6819 alpha(mgs,il) = dnu(il)
6823 IF ( imurain == 1 ) THEN
6824 alpha(:,lr) = alphar
6825 ELSEIF ( imurain == 3 ) THEN
6826 alpha(:,lr) = xnu(lr)
6838 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: call setvtz'
6841 call setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno,cnostmp, &
6842 & xmas,vtxbar,xdn,xvmn,xvmx,xv,cdx,cdxgs, &
6843 & ipconc,ndebugzf,ngs,nz,kgs,fadvisc, &
6844 & cwmasn,cwmasx,cwradn,cnina,cimn,cimx, &
6845 & itype1,itype2,temcg,infdo,alpha,ildo,axx,bxx)
6846 ! & itype1,itype2,temcg,infdo,alpha,ildo,axh,bxh,axhl,bxhl)
6851 ! put fall speeds into the x-z arrays
6859 IF ( vtxbar(mgs,il,2) .gt. vtxbar(mgs,il,1) .or. &
6860 & ( vtxbar(mgs,il,1) .gt. vtxbar(mgs,il,3) .and. vtxbar(mgs,il,3) > 0.0) ) THEN
6864 vtxbar(mgs,il,1) = Max( vtxbar(mgs,il,1), vtxbar(mgs,il,2) )
6865 vtxbar(mgs,il,3) = Max( vtxbar(mgs,il,3), vtxbar(mgs,il,1) )
6870 IF ( vtxbar(mgs,il,1) .gt. vtmax .or. vtxbar(mgs,il,2) .gt. vtmax .or. &
6871 & vtxbar(mgs,il,3) .gt. vtmax ) THEN
6873 vtxbar(mgs,il,1) = Min(vtmax,vtxbar(mgs,il,1) )
6874 vtxbar(mgs,il,2) = Min(vtmax,vtxbar(mgs,il,2) )
6875 vtxbar(mgs,il,3) = Min(vtmax,vtxbar(mgs,il,3) )
6877 ! call commasmpi_abort()
6881 xvt(kgs(mgs),igs(mgs),1,il) = vtxbar(mgs,il,1)
6882 xvt(kgs(mgs),igs(mgs),2,il) = vtxbar(mgs,il,2)
6883 IF ( infdo .ge. 2 ) THEN
6884 xvt(kgs(mgs),igs(mgs),3,il) = vtxbar(mgs,il,3)
6886 xvt(kgs(mgs),igs(mgs),3,il) = 0.0
6889 ! xvt(kgs(mgs),igs(mgs),2,il) = xvt(kgs(mgs),igs(mgs),1,il)
6895 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: COPIED FALL SPEEDS'
6901 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: DONE WITH LOOP'
6903 if ( kz .gt. nz-1 ) then
6909 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: SET NZMPB'
6913 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: SET NXMPB'
6922 if (ndebugzf .gt. 0 ) write(0,*) "ZIEGFALL: EXITING SUBROUTINE"
6926 END subroutine ziegfall1d
6928 ! #####################################################################
6929 ! #####################################################################
6932 ! #####################################################################
6933 ! #####################################################################
6935 ! ##############################################################################
6936 subroutine radardd02(nx,ny,nz,nor,na,an,temk, &
6937 & dbz,db,nzdbz,cnoh0t,hwdn1t,ipconc,ke_diag, iunit)
6939 ! 11.13.2005: Changed values of indices for reordering of lip
6941 ! 07.13.2005: Fixed an error where cnoh was being used for graupel and frozen drops
6943 ! 01.24.2005: add ice crystal reflectivity using parameterization of
6944 ! Heymsfield (JAS, 1977). Could also try Ferrier for this, too.
6946 ! 09.28.2002 Test alterations for dry ice following Ferrier (1994)
6947 ! for equivalent melted diameter reflectivity.
6948 ! Converted to Fortran by ERM.
6950 !Date: Tue, 21 Nov 2000 10:13:36 -0600 (CST)
6951 !From: Matthew Gilmore <gilmore@hesston.met.tamu.edu>
6953 !PRO RF_SPEC ; Computes Radar Reflectivity
6954 !COMMON MAINB, data, x1d, y1d, z1d, iconst, rconst, labels, nx, ny, nz, dshft
6956 !;MODIFICATION HISTORY
6957 !; 5/99 -Svelta Veleva introduces variable dielf (const_ki_x) as a (weak)
6958 !; function of density. This leads to slight modification of dielf such
6959 !; that the snow reflectivity is slightly increased - not a big effect.
6960 !; This is believed to be more accurate than assuming the dielectric
6961 !; constant for snow is the same as for hail in previous versions.
6963 !;On 6/13/99 I added the VIL computation (k=0 in vil array)
6964 !;On 6/15/99 I removed the number concentration dependencies as a function
6965 !; of temperature (only use for ferrier!)
6966 !;On 6/15/99 I added the Composite reflectivity (k=1 in VIL array)
6967 !;On 6/15/99 I added the Severe Hail Index computation (k=2 in vil array)
6969 !; 6/99 - Veleva and Seo argue that since graupel is more similar to
6970 !; snow (in number conc and size density) than it is to hail, we
6971 !; should not weight wetted graupel with the .95 exponent correction
6972 !; factor as in the case of hail. An if-statement checks the size
6973 !; density for wet hail/graupel and treats them appropriately.
6975 !; 6/22/99 - Added function to compute height of max rf and 40 dbz echo top
6976 !; Also added vilqr which is the model vertical integrated liquid only
6977 !; using qr. Will need to check...does not seem consistent with vilZ
6983 character(LEN=15), parameter :: microp = 'ZVD'
6984 integer nx,ny,nz,nor,na,ngt
6985 integer nzdbz ! how many levels actually to process
6989 integer, parameter :: printyn = 0
6991 parameter( ng1 = 1 )
6999 integer imapz,mzdist
7002 integer, parameter :: norz = 3
7003 real an(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,na)
7004 real db(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor) ! air density
7005 ! real gt(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,ngt)
7006 real temk(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor) ! air temperature (kelvin)
7007 real dbz(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor) ! reflectivity
7008 real gz(-nor+1:nz+nor) ! ,z1d(-nor+1:nz+nor,4)
7010 ! real g,rgas,eta,inveta
7011 real cr1, cr2 , hwdnsq,swdnsq
7012 real rwdnsq, dhmin, qrmin, qsmin, qhmin, qhlmin, tfr, tfrh, zrc
7013 real reflectmin, kw_sq
7014 real const_ki_sn, const_ki_h, ki_sq_sn
7015 real ki_sq_h, dielf_sn, dielf_h
7024 real*8 dtmps, dtmpr, dtmph, dtmphl, g1, zx, ze, x
7026 integer i,j,k,ix,jy,kz,ihcnt
7028 real*8 xcnoh, xcnos, dadh, dads, zhdryc, zsdryc, zhwetc,zswetc
7031 parameter ( dbzmin = 0 )
7033 real cnow,cnoi,cnoip,cnoir,cnor,cnos
7034 real cnogl,cnogm,cnogh,cnof,cnoh,cnohl
7036 real swdn, rwdn ,hwdn,gldn,gmdn,ghdn,fwdn,hldn
7039 real rwdnmx,cwdnmx,cidnmx,xidnmx,swdnmx,gldnmx,gmdnmx
7040 real ghdnmx,fwdnmx,hwdnmx,hldnmx
7041 real rwdnmn,cwdnmn,cidnmn,xidnmn,swdnmn,gldnmn,gmdnmn
7042 real ghdnmn,fwdnmn,hwdnmn,hldnmn
7044 real gldnsq,gmdnsq,ghdnsq,fwdnsq,hldnsq
7046 real dadgl,dadgm,dadgh,dadhl,dadf
7047 real zgldryc,zglwetc,zgmdryc, zgmwetc,zghdryc,zghwetc
7048 real zhldryc,zhlwetc,zfdryc,zfwetc
7050 real dielf_gl,dielf_gm,dielf_gh,dielf_hl,dielf_fw
7054 real swdia,gldia,gmdia,ghdia,fwdia,hwdia,hldia
7056 real csw,cgl,cgm,cgh,cfw,chw,chl
7057 real xvs,xvgl,xvgm,xvgh,xvf,xvh,xvhl
7063 parameter ( rhos = 0.1 )
7065 real qxw,qxw1 ! temp value for liquid water on ice mixing ratio
7069 real, parameter :: cwmasn = 5.23e-13 ! minimum mass, defined by radius of 5.0e-6
7070 real, parameter :: cwmasx = 5.25e-10 ! maximum mass, defined by radius of 50.0e-6
7071 real, parameter :: cwradn = 5.0e-6 ! minimum radius
7075 real :: vzsnow, vzrain, vzgraupel, vzhail
7080 ! #########################################################################
7086 ! g=9.806 ! g: gravity constant
7087 ! rgas=287.04 ! rgas: gas constant for dry air
7088 ! rcp=rgas/cp ! rcp: gamma constant
7095 cwc0 = piinv ! 1./pi ! 6.0/pi
7108 ! default slope intercepts
7129 IF ( microp(1:4) .eq. 'ZIEG' ) THEN ! na .ge. 14 .and. ipconc .ge. 3 ) THEN
7131 ! write(0,*) 'Set reflectivity for ZIEG'
7134 hwdn = hwdn1t ! 500.
7143 IF ( lhl .gt. 1 ) THEN
7148 ELSEIF ( microp(1:3) .eq. 'ZVD' ) THEN ! na .ge. 14 .and. ipconc .ge. 3 ) THEN
7161 IF ( lhl .gt. 1 ) THEN
7165 ! 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)
7173 ! IF ( lh > 1 ) THEN
7174 ! cdx(lh) = 0.8 ! 1.0 ! 0.45
7178 ! IF ( lhl .gt. 1 ) cdx(lhl) = 0.45
7186 ! IF ( lh > 1 ) THEN
7193 ! IF ( lhl .gt. 1 ) THEN
7194 ! xvmn(lhl) = xvhlmn
7195 ! xvmx(lhl) = xvhlmx
7198 ! xdnmx(lr) = 1000.0
7199 ! xdnmx(lc) = 1000.0
7200 ! IF ( lh > 1 ) THEN
7205 ! IF ( lhl .gt. 1 ) xdnmx(lhl) = 900.0
7209 ! xdnmn(lr) = 1000.0
7210 ! xdnmn(lc) = 1000.0
7211 ! IF ( lh > 1 ) THEN
7216 ! IF ( lhl .gt. 1 ) xdnmn(lhl) = 500.0
7222 ! IF ( lh > 1 ) THEN
7224 ! xdn0(ls) = 100.0 ! 100.0
7225 ! xdn0(lh) = hwdn1t ! (0.5)*(xdnmn(lh)+xdnmx(lh))
7227 ! IF ( lhl .gt. 1 ) xdn0(lhl) = 800.0
7246 ! density maximums and minimums
7273 gldn = (0.5)*(gldnmn+gldnmx) ! 300.
7274 gmdn = (0.5)*(gmdnmn+gmdnmx) ! 500.
7275 ghdn = (0.5)*(ghdnmn+ghdnmx) ! 700.
7276 fwdn = (0.5)*(fwdnmn+fwdnmx) ! 800.
7277 hldn = (0.5)*(hldnmn+hldnmx) ! 900.
7303 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7304 ! Dielectric Factor - Formulas implemented by Svetla Veleva
7305 ! following Battan, "Radar Meteorology" - p. 40
7306 ! The result of these calculations is that the dielf numerator (ki_sq) without
7307 ! the density ratio is .2116 for hail if using 917 density and .25 for
7308 ! snow if using 220 density.
7309 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7310 const_ki_sn = 0.5 - (0.5-0.46)/(917.-220.)*(swdn-220.)
7311 const_ki_h = 0.5 - (0.5-0.46)/(917.-220.)*(hwdn-220.)
7312 ki_sq_sn = (swdnsq/rwdnsq) * const_ki_sn**2
7313 ki_sq_h = (hwdnsq/rwdnsq) * const_ki_h**2
7314 dielf_sn = ki_sq_sn / kw_sq
7315 dielf_h = ki_sq_h / kw_sq
7317 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7318 ! Use the next line if you want to hardwire dielf for dry hail for both dry
7319 ! snow and dry hail.
7320 ! This would be equivalent to what Straka had originally. (i.e, .21/.93)
7321 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7322 dielf_sn = (swdnsq/rwdnsq)*.21/ kw_sq
7323 dielf_h = (hwdnsq/rwdnsq)*.21/ kw_sq
7325 dielf_gl = (gldnsq/rwdnsq)*.21/ kw_sq
7326 dielf_gm = (gmdnsq/rwdnsq)*.21/ kw_sq
7327 dielf_gh = (ghdnsq/rwdnsq)*.21/ kw_sq
7328 dielf_hl = (hldnsq/rwdnsq)*.21/ kw_sq
7329 dielf_fw = (fwdnsq/rwdnsq)*.21/ kw_sq
7331 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7332 ! Notes on dielectric factors - from Eun-Kyoung Seo
7333 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7334 ! constants for both snow and hail would be (x=s,h).....
7335 ! xwdnsq/rwdnsq *0.21/kw_sq ! Straka/Smith - the original
7336 ! xwdnsq/rwdnsq *0.224 ! Ferrier - for particle sizes in equiv. drop diam
7337 ! xwdnsq/rwdnsq *0.176/kw_sq ! =0.189 in Smith - for particle sizes in equiv
7339 ! xwdnsq/rwdnsq *0.208/kw_sq ! Smith 1984 - for particle sizes in equiv melted drop diameter
7340 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7343 ! VIL algorithm constants
7344 ! Ztop = 10.**(56./10) !56 dbz is the max rf used by WATADS in cell vil
7347 ! Hail detection algorithm constants
7350 ! Ho = 3400. !WATADS Defaults
7351 ! Hm20 = 6200. !WATADS Defaults
7353 ! DO kz = 1,Min(nzdbz,nz-1)
7357 DO kz = 1,ke_diag ! nz
7371 dadr = (db(ix,jy,kz)/(pi*rwdn*cnor))**(0.25)
7372 !-----------------------------------------------------------------------
7373 ! Compute Rain Radar Reflectivity
7374 !-----------------------------------------------------------------------
7378 IF ( an(ix,jy,kz,lr) .ge. qrmin ) THEN
7379 IF ( ipconc .le. 2 ) THEN
7380 gtmp(ix,kz) = dadr*an(ix,jy,kz,lr)**(0.25)
7381 dtmp(ix,kz) = zrc*gtmp(ix,kz)**7
7382 ELSEIF ( an(ix,jy,kz,lnr) .gt. 1.e-3 ) THEN
7383 IF ( imurain == 3 ) THEN
7384 vr = db(ix,jy,kz)*an(ix,jy,kz,lr)/(1000.*an(ix,jy,kz,lnr))
7385 dtmp(ix,kz) = 3.6e18*(rnu+2.)*an(ix,jy,kz,lnr)*vr**2/(rnu+1.)
7387 g1 = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
7388 zx = g1*(db(ix,jy,kz)*an(ix,jy,kz,lr))**2/an(ix,jy,kz,lnr)
7389 ze =1.e18*zx*(6./(pi*1000.))**2 ! note: using 1000. here for water density
7396 !-----------------------------------------------------------------------
7397 ! Compute snow and graupel reflectivity
7399 ! Lou modified to look at parcel temperature rather than base state
7400 !-----------------------------------------------------------------------
7402 IF( lhab .gt. lr ) THEN
7404 ! qs2d = reform(data[*,*,k,10],[nx*ny])
7405 ! qh2d = reform(data[*,*,k,11],[nx*ny])
7407 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7408 ! Only use the following lines if running Straka GEMS microphysics
7409 ! (Sam 1-d version modified by L Wicker does not use this)
7410 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7411 ! ;xcnoh = cnoh*exp(-0.025*(temp-tfr))
7412 ! ;xcnos = cnos*exp(-0.038*(temp-tfr))
7413 ! ;good = where(temp GT tfr, n_elements)
7414 ! ;IF n_elements NE 0 THEN xcnoh(good) = cnoh*exp(-0.075*(temp(good)-tfr))
7415 ! ;IF n_elements NE 0 THEN xcnos(good) = cnos*exp(-0.088*(temp(good)-tfr))
7417 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7418 ! Only use the following lines if running Ferrier micro with No=No(T)
7419 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7422 ! ; xcnoh = cnoh*(1.>exp(NOGE*(temp-tfr)) )
7423 ! ; xcnos = cnos*(1.>exp(NOSE*(temp-tfr)) )
7425 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7426 ! Use the following lines if Nos and Noh are constant
7427 ! (As in Svetla version of Ferrier, GCE Tao, and SAM 1-d)
7428 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7433 ! Temporary fix for predicted number concentration -- need a
7434 ! more appropriate reflectivity equation!
7436 ! IF ( an(ix,jy,kz,lns) .lt. 0.1 ) THEN
7437 ! swdia = (xvrmn*cwc0)**(1./3.)
7438 ! xcnos = an(ix,jy,kz,ls)*db(ix,jy,kz)/(xvrmn*swdn*swdia)
7440 ! ! changed back to diameter of mean volume!!!
7442 ! > (an(ix,jy,kz,ls)*db(ix,jy,kz)
7443 ! > /(pi*swdn*an(ix,jy,kz,lns)))**(1./3.)
7445 ! xcnos = an(ix,jy,kz,lns)/swdia
7448 IF ( ls .gt. 1 ) THEN ! {
7450 IF ( lvs .gt. 1 ) THEN
7451 IF ( an(ix,jy,kz,lvs) .gt. 0.0 ) THEN
7452 swdn = db(ix,jy,kz)*an(ix,jy,kz,ls)/an(ix,jy,kz,lvs)
7453 swdn = Min( 300., Max( 100., swdn ) )
7460 IF ( ipconc .ge. 5 ) THEN ! {
7462 xvs = db(ix,jy,kz)*an(ix,jy,kz,ls)/ &
7463 & (swdn*Max(1.0e-3,an(ix,jy,kz,lns)))
7464 IF ( xvs .lt. xvsmn .or. xvs .gt. xvsmx ) THEN
7465 xvs = Min( xvsmx, Max( xvsmn,xvs ) )
7466 csw = db(ix,jy,kz)*an(ix,jy,kz,ls)/(xvs*swdn)
7469 swdia = (xvs*cwc0)**(1./3.)
7470 xcnos = an(ix,jy,kz,ls)*db(ix,jy,kz)/(xvs*swdn*swdia)
7475 ! IF ( an(ix,jy,kz,lnh) .lt. 0.1 ) THEN
7476 ! hwdia = (xvrmn*cwc0)**(1./3.)
7477 ! xcnoh = an(ix,jy,kz,lh)*db(ix,jy,kz)/(xvrmn*hwdn*hwdia)
7479 ! ! changed back to diameter of mean volume!!!
7481 ! > (an(ix,jy,kz,lh)*db(ix,jy,kz)
7482 ! > /(pi*hwdn*an(ix,jy,kz,lnh)))**(1./3.)
7484 ! xcnoh = an(ix,jy,kz,lnh)/hwdia
7487 IF ( lh .gt. 1 ) THEN ! {
7489 IF ( lvh .gt. 1 ) THEN
7490 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
7491 hwdn = db(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
7492 hwdn = Min( 900., Max( hdnmn, hwdn ) )
7494 hwdn = 500. ! hwdn1t
7500 IF ( ipconc .ge. 5 ) THEN ! {
7502 xvh = db(ix,jy,kz)*an(ix,jy,kz,lh)/ &
7503 & (hwdn*Max(1.0e-3,an(ix,jy,kz,lnh)))
7504 IF ( xvh .lt. xvhmn .or. xvh .gt. xvhmx ) THEN
7505 xvh = Min( xvhmx, Max( xvhmn,xvh ) )
7506 chw = db(ix,jy,kz)*an(ix,jy,kz,lh)/(xvh*hwdn)
7509 hwdia = (xvh*cwc0)**(1./3.)
7510 xcnoh = an(ix,jy,kz,lh)*db(ix,jy,kz)/(xvh*hwdn*hwdia)
7512 ENDIF ! } ipconc .ge. 5
7519 IF ( xcnoh .gt. 0.0 ) THEN
7520 dadh = ( db(ix,jy,kz) /(pi*hwdn*xcnoh) )**(.25)
7521 zhdryc = 0.224*cr2*(db(ix,jy,kz)/rwdn)**2/xcnoh ! dielf_h*cr1*xcnoh ! SV - equiv formula as before but
7522 ! ratio of densities included in
7523 ! dielf_h rather than here following
7530 IF ( xcnos .gt. 0.0 ) THEN
7531 dads = ( db(ix,jy,kz) /(pi*swdn*xcnos) )**(.25)
7532 zsdryc = 0.224*cr2*(db(ix,jy,kz)/rwdn)**2/xcnos ! dielf_sn*cr1*xcnos ! SV - similar change as above
7537 zhwetc = zhdryc ! cr1*xcnoh !Hail/graupel version with .95 power bug removed
7538 zswetc = zsdryc ! cr1*xcnos
7542 IF ( ls .gt. 1 ) THEN
7548 IF ( an(ix,jy,kz,ls) .ge. qsmin ) THEN !{
7549 IF ( ipconc .ge. 4 ) THEN ! (Ferrier 94) !{
7551 if (lsw .gt. 1) THEN
7552 qxw = an(ix,jy,kz,lsw)
7554 ELSEIF ( ( iusewetsnow == 1 .or. iusewetsnow == 3) .and. temk(ix,jy,kz) .gt. tfr+1. &
7555 & .and. an(ix,jy,kz,ls) > an(ix,jy,kz,lr) .and. an(ix,jy,kz,lr) > qsmin) THEN
7556 qxw = Min(0.5*an(ix,jy,kz,ls), an(ix,jy,kz,lr))
7560 vr = xvs ! db(ix,jy,kz)*an(ix,jy,kz,lr)/(1000.*an(ix,jy,kz,lnr))
7561 ! gtmp(ix,kz) = 3.6e18*(0.243*rhos**2/0.93)*(snu+2.)*an(ix,jy,kz,lns)*vr**2/(snu+1.)
7563 ksq = 0.189 ! Smith (1984, JAMC) for equiv. ice sphere
7564 IF ( an(ix,jy,kz,lns) .gt. 1.e-7 ) THEN
7565 ! IF ( .true. ) THEN
7566 IF ( qxw > qsmin .or. iusewetsnow >= 2 ) THEN ! old version
7567 ! gtmp(ix,kz) = 3.6e18*(snu+2.)*( 0.224*an(ix,jy,kz,ls) + 0.776*qxw)*an(ix,jy,kz,ls)/ &
7568 ! & (an(ix,jy,kz,lns)*(snu+1.)*rwdn**2)*db(ix,jy,kz)**2
7569 gtmp(ix,kz) = 3.6e18*(snu+2.)*( 0.224*(an(ix,jy,kz,ls)+qxw1) + 0.776*qxw)*(an(ix,jy,kz,ls)+qxw1)/ &
7570 & (an(ix,jy,kz,lns)*(snu+1.)*rwdn**2)*db(ix,jy,kz)**2
7572 ELSE ! new form using a mass relationship m = p d^2 (instead of d^3 -- Cox 1988 QJRMS) so that density depends on size
7573 ! p = 0.106214 for m = p v^(2/3)
7574 dnsnow = 0.346159*sqrt(an(ix,jy,kz,lns)/(an(ix,jy,kz,ls)*db(ix,jy,kz)) )
7575 IF ( .true. .or. dnsnow < 900. ) THEN
7576 gtmp(ix,kz) = 1.e18*323.3226* 0.106214**2*(ksq*an(ix,jy,kz,ls) + &
7577 & (1.-ksq)*qxw)*an(ix,jy,kz,ls)*db(ix,jy,kz)**2*gsnow73/ &
7578 & (an(ix,jy,kz,lns)*(917.)**2* gsnow1*(1.0+snu)**(4./3.))
7579 ELSE ! otherwise small enough to assume ice spheres?
7580 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)/ &
7581 & (an(ix,jy,kz,lns)*(snu+1.)*rwdn**2)*db(ix,jy,kz)**2
7588 ! tmp = Min(1.0,1.e3*(an(ix,jy,kz,ls))*db(ix,jy,kz))
7589 ! gtmp(ix,kz) = Max( 1.0*gtmp(ix,kz), 750.0*(tmp)**1.98)
7591 dtmp(ix,kz) = dtmp(ix,kz) + gtmp(ix,kz)
7592 ELSE ! }{ single-moment snow:
7593 gtmp(ix,kz) = dads*an(ix,jy,kz,ls)**(0.25)
7595 IF ( gtmp(ix,kz) .gt. 0.0 ) THEN !{
7596 dtmps = zsdryc*an(ix,jy,kz,ls)**2/gtmp(ix,kz)
7597 IF ( temk(ix,jy,kz) .lt. tfr ) THEN
7598 dtmp(ix,kz) = dtmp(ix,kz) + &
7599 & zsdryc*an(ix,jy,kz,ls)**2/gtmp(ix,kz)
7601 dtmp(ix,kz) = dtmp(ix,kz) + &
7602 & zswetc*an(ix,jy,kz,ls)**2/gtmp(ix,kz)
7613 ! ice crystal contribution (Heymsfield, 1977, JAS)
7615 IF ( li .gt. 1 .and. idbzci .ne. 0 ) THEN
7617 IF ( idbzci == 1 .and. lni > 0 ) THEN
7618 ! assume spherical ice with density of 900 for dbz calc
7619 IF ( an(ix,jy,kz,li) > qxmin(li) .and. an(ix,jy,kz,lni) > 1.0 ) THEN
7620 vr = db(ix,jy,kz)*an(ix,jy,kz,li)/(900.*an(ix,jy,kz,lni))
7621 dtmp(ix,kz) = dtmp(ix,kz) + &
7622 & 0.224*3.6e18*(cinu+2.)*an(ix,jy,kz,lni)*vr**2/(cinu+1.)*(900./1000.)**2
7625 ELSEIF ( idbzci == 2 ) THEN
7627 ! ice crystal contribution (Heymsfield, 1977, JAS)
7630 IF ( an(ix,jy,kz,li) .ge. 0.1e-3 ) THEN
7631 gtmp(ix,kz) = Min(1.0,1.e3*(an(ix,jy,kz,li))*db(ix,jy,kz))
7632 dtmp(ix,kz) = dtmp(ix,kz) + 750.0*(gtmp(ix,kz))**1.98
7640 ! graupel/hail contribution
7642 IF ( lh .gt. 1 ) THEN ! {
7647 IF ( izieg .ge. 1 .and. ipconc .ge. 5 ) THEN
7651 IF ( ltest .or. (an(ix,jy,kz,lh) .ge. qhmin .and. an(ix,jy,kz,lnh) .ge. cxmin )) THEN
7653 IF ( lvh .gt. 1 ) THEN
7655 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
7656 hwdn = db(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
7657 hwdn = Min( 900., Max( 100., hwdn ) )
7659 hwdn = 500. ! hwdn1t
7664 chw = an(ix,jy,kz,lnh)
7665 IF ( chw .gt. 0.0 ) THEN ! (Ferrier 94)
7666 xvh = db(ix,jy,kz)*an(ix,jy,kz,lh)/(hwdn*Max(1.0e-3,chw))
7667 IF ( xvh .lt. xvhmn .or. xvh .gt. xvhmx ) THEN
7668 xvh = Min( xvhmx, Max( xvhmn,xvh ) )
7669 chw = db(ix,jy,kz)*an(ix,jy,kz,lh)/(xvh*hwdn)
7672 qh = an(ix,jy,kz,lh)
7674 IF ( lhw .gt. 1 ) THEN
7675 IF ( iusewetgraupel .eq. 1 ) THEN
7676 qxw = an(ix,jy,kz,lhw)
7677 ELSEIF ( iusewetgraupel .eq. 2 ) THEN
7678 IF ( hwdn .lt. 300. ) THEN
7679 qxw = an(ix,jy,kz,lhw)
7682 ELSEIF ( iusewetgraupel .eq. 3 ) THEN
7683 IF ( hwdn .lt. 300. .and. temk(ix,jy,kz) > tfr .and. an(ix,jy,kz,lr) > qhmin ) THEN
7684 qxw = Min( an(ix,jy,kz,lh), an(ix,jy,kz,lr))
7687 ELSEIF ( iusewetgraupel == 4 .and. temk(ix,jy,kz) .gt. tfr+0.25 .and. an(ix,jy,kz,lh) > an(ix,jy,kz,lr) &
7688 & .and. an(ix,jy,kz,lr) > qhmin) THEN
7689 qxw = Min(0.5*an(ix,jy,kz,lh), an(ix,jy,kz,lr))
7694 IF ( lzh .gt. 1 ) THEN
7696 g1 = (6.0 + alphah)*(5.0 + alphah)*(4.0 + alphah)/((3.0 + alphah)*(2.0 + alphah)*(1.0 + alphah))
7697 ! zx = g1*(db(ix,jy,kz)*an(ix,jy,kz,lh))**2/chw
7698 ! ze = 0.224*1.e18*zx*(6./(pi*1000.))**2
7699 zx = g1*db(ix,jy,kz)**2*( 0.224*qh + 0.776*qxw)*qh/chw
7700 ze =1.e18*zx*(6./(pi*1000.))**2
7701 dtmp(ix,kz) = dtmp(ix,kz) + ze
7707 ! IF ( an(ix,jy,kz,lh) .gt. 1.0e-3 ) write(0,*) 'Graupel Z : ',dtmph,ze
7714 IF ( an(ix,jy,kz,lh) .ge. qhmin ) THEN
7715 gtmp(ix,kz) = dadh*an(ix,jy,kz,lh)**(0.25)
7716 IF ( gtmp(ix,kz) .gt. 0.0 ) THEN
7717 dtmph = zhdryc*an(ix,jy,kz,lh)**2/gtmp(ix,kz)
7718 IF ( temk(ix,jy,kz) .lt. tfr ) THEN
7719 dtmp(ix,kz) = dtmp(ix,kz) + &
7720 & zhdryc*an(ix,jy,kz,lh)**2/gtmp(ix,kz)
7722 ! IF ( hwdn .gt. 700.0 ) THEN
7723 dtmp(ix,kz) = dtmp(ix,kz) + &
7724 & zhdryc*an(ix,jy,kz,lh)**2/gtmp(ix,kz)
7726 ! & (zhwetc*gtmp(ix,kz)**7)**0.95
7728 ! dtmp(ix,kz) = dtmp(ix,kz) + zhwetc*gtmp(ix,kz)**7
7744 IF ( izieg .ge. 1 .and. lhl .gt. 1 ) THEN
7752 IF ( lvhl .gt. 1 ) THEN
7753 IF ( an(ix,jy,kz,lvhl) .gt. 0.0 ) THEN
7754 hldn = db(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
7755 hldn = Min( 900., Max( 300., hldn ) )
7764 IF ( ipconc .ge. 5 ) THEN
7768 IF ( ltest .or. ( an(ix,jy,kz,lhl) .ge. qhlmin .and. an(ix,jy,kz,lnhl) .gt. 0.) ) THEN !{
7769 chl = an(ix,jy,kz,lnhl)
7770 IF ( chl .gt. 0.0 ) THEN !{
7771 xvhl = db(ix,jy,kz)*an(ix,jy,kz,lhl)/ &
7772 & (hldn*Max(1.0e-9,an(ix,jy,kz,lnhl)))
7773 IF ( xvhl .lt. xvhlmn .or. xvhl .gt. xvhlmx ) THEN ! {
7774 xvhl = Min( xvhlmx, Max( xvhlmn,xvhl ) )
7775 chl = db(ix,jy,kz)*an(ix,jy,kz,lhl)/(xvhl*hldn)
7776 ! do not update state in dbz calc. ! an(ix,jy,kz,lnhl) = chl
7779 IF ( lhlw .gt. 1 ) THEN
7780 IF ( iusewethail .eq. 1 ) THEN
7781 qxw = an(ix,jy,kz,lhlw)
7782 ELSEIF ( iusewethail .eq. 2 ) THEN
7783 IF ( hldn .lt. 300. ) THEN
7784 qxw = an(ix,jy,kz,lhlw)
7789 IF ( lzhl .gt. 1 ) THEN !{
7792 g1 = (6.0 + alphahl)*(5.0 + alphahl)*(4.0 + alphahl)/((3.0 + alphahl)*(2.0 + alphahl)*(1.0 + alphahl))
7793 zx = g1*db(ix,jy,kz)**2*( 0.224*an(ix,jy,kz,lhl) + 0.776*qxw)*an(ix,jy,kz,lhl)/chl
7794 ! zx = g1*(db(ix,jy,kz)*an(ix,jy,kz,lhl))**2/chl
7795 ze = 1.e18*zx*(6./(pi*1000.))**2 ! 3/28/2016 removed extra factor of 0.224
7796 dtmp(ix,kz) = dtmp(ix,kz) + ze
7801 ! IF ( an(ix,jy,kz,lh) .gt. 1.0e-3 ) write(0,*) 'Graupel Z : ',dtmph,ze
7808 IF ( an(ix,jy,kz,lhl) .ge. qhlmin ) THEN ! {
7809 dadhl = ( db(ix,jy,kz) /(pi*hldn*cnohl) )**(.25)
7810 gtmp(ix,kz) = dadhl*an(ix,jy,kz,lhl)**(0.25)
7811 IF ( gtmp(ix,kz) .gt. 0.0 ) THEN ! {
7813 zhldryc = 0.224*cr2*( db(ix,jy,kz)/rwdn)**2/cnohl
7815 dtmphl = zhldryc*an(ix,jy,kz,lhl)**2/gtmp(ix,kz)
7817 IF ( temk(ix,jy,kz) .lt. tfr ) THEN
7818 dtmp(ix,kz) = dtmp(ix,kz) + &
7819 & zhldryc*an(ix,jy,kz,lhl)**2/gtmp(ix,kz)
7821 ! IF ( hwdn .gt. 700.0 ) THEN
7822 dtmp(ix,kz) = dtmp(ix,kz) + &
7823 & zhldryc*an(ix,jy,kz,lhl)**2/gtmp(ix,kz)
7825 ! : (zhwetc*gtmp(ix,kz)**7)**0.95
7827 ! dtmp(ix,kz) = dtmp(ix,kz) + zhwetc*gtmp(ix,kz)**7
7834 ENDIF ! ipconc .ge. 5
7837 ENDIF ! izieg .ge. 1 .and. lhl .gt. 1
7841 IF ( dtmp(ix,kz) .gt. 0.0 ) THEN
7842 dbz(ix,jy,kz) = Max(dbzmin, 10.0*Log10(dtmp(ix,kz)) )
7844 IF ( dbz(ix,jy,kz) .gt. dbzmax ) THEN
7845 dbzmax = Max(dbzmax,dbz(ix,jy,kz))
7851 dbz(ix,jy,kz) = dbzmin
7852 IF ( lh > 1 .and. lhl > 1) THEN
7853 IF ( an(ix,jy,kz,lh) > 1.0e-3 ) THEN
7854 write(0,*) 'radardbz: qr,qh,qhl = ',an(ix,jy,kz,lr), an(ix,jy,kz,lh),an(ix,jy,kz,lhl)
7855 write(0,*) 'radardbz: dtmps,dtmph,dadh,dadhl,dtmphl = ',dtmps,dtmph,dadh,dadhl,dtmphl
7857 IF ( lzh>1 .and. lzhl>1 ) write(0,*) 'radardbz: zh, zhl = ',an(ix,jy,kz,lzh),an(ix,jy,kz,lzhl)
7862 ! IF ( an(ix,jy,kz,lh) .gt. 1.e-4 .and.
7863 ! & dbz(ix,jy,kz) .le. 0.0 ) THEN
7864 ! write(0,*) 'dbz = ',dbz(ix,jy,kz)
7865 ! write(0,*) 'Hail intercept: ',xcnoh,ix,kz
7866 ! write(0,*) 'Hail,snow q: ',an(ix,jy,kz,lh),an(ix,jy,kz,ls)
7867 ! write(0,*) 'Hail,snow c: ',an(ix,jy,kz,lnh),an(ix,jy,kz,lns)
7868 ! write(0,*) 'dtmps,dtmph = ',dtmps,dtmph
7870 IF ( .not. dtmp(ix,kz) .lt. 1.e30 .or. dbz(ix,jy,kz) > 190.0 ) THEN
7871 ! IF ( ix == 31 .and. kz == 20 .and. jy == 23 ) THEN
7872 ! write(0,*) 'my_rank = ',my_rank
7873 write(0,*) 'ix,jy,kz = ',ix,jy,kz
7874 write(0,*) 'dbz = ',dbz(ix,jy,kz)
7875 write(0,*) 'db, zhdryc = ',db(ix,jy,kz),zhdryc
7876 write(0,*) 'Hail intercept: ',xcnoh,ix,kz
7877 write(0,*) 'Hail,snow q: ',an(ix,jy,kz,lh),an(ix,jy,kz,ls)
7878 write(0,*) 'graupel density hwdn = ',hwdn
7879 write(0,*) 'rain q: ',an(ix,jy,kz,lr)
7880 write(0,*) 'ice q: ',an(ix,jy,kz,li)
7881 IF ( lhl .gt. 1 ) write(0,*) 'Hail (lhl): ',an(ix,jy,kz,lhl)
7882 IF (ipconc .ge. 3 ) write(0,*) 'rain c: ',an(ix,jy,kz,lnr)
7883 IF ( lzr > 1 ) write(0,*) 'rain Z: ',an(ix,jy,kz,lzr)
7884 IF ( ipconc .ge. 5 ) THEN
7885 write(0,*) 'Hail,snow c: ',an(ix,jy,kz,lnh),an(ix,jy,kz,lns)
7886 IF ( lhl .gt. 1 ) write(0,*) 'Hail (lnhl): ',an(ix,jy,kz,lnhl)
7887 IF ( lzhl .gt. 1 ) THEN
7888 write(0,*) 'Hail (lzhl): ',an(ix,jy,kz,lzhl)
7889 write(0,*) 'chl,xvhl,dhl = ',chl,xvhl,(xvhl*6./3.14159)**(1./3.)
7890 write(0,*) 'xvhlmn,xvhlmx = ',xvhlmn,xvhlmx
7893 write(0,*) 'chw,xvh = ', chw,xvh
7894 write(0,*) 'dtmps,dtmph,dadh,dadhl,dtmphl = ',dtmps,dtmph,dadh,dadhl,dtmphl
7895 write(0,*) 'dtmpr = ',dtmpr
7896 write(0,*) 'gtmp = ',gtmp(ix,kz),dtmp(ix,kz)
7897 IF ( .not. (dbz(ix,jy,kz) .gt. -100 .and. dbz(ix,jy,kz) .lt. 200 ) ) THEN
7898 write(0,*) 'dbz out of bounds! STOP!'
7911 ! write(0,*) 'na,lr = ',na,lr
7912 IF ( printyn .eq. 1 ) THEN
7913 ! IF ( dbzmax .gt. dbzmin ) THEN
7914 write(iunit,*) 'maxdbz,ijk = ',dbzmax,imx,jmx,kmx
7915 write(iunit,*) 'qrw = ',an(imx,jmx,kmx,lr)
7917 IF ( lh .gt. 1 ) THEN
7918 write(iunit,*) 'qi = ',an(imx,jmx,kmx,li)
7919 write(iunit,*) 'qsw = ',an(imx,jmx,kmx,ls)
7920 write(iunit,*) 'qhw = ',an(imx,jmx,kmx,lh)
7921 IF ( lhl .gt. 1 ) write(iunit,*) 'qhl = ',an(imx,jmx,kmx,lhl)
7929 END subroutine radardd02
7932 ! ##############################################################################
7933 ! ##############################################################################
7936 ! #####################################################################
7937 ! #####################################################################
7939 ! Subroutine for explicit cloud condensation and droplet nucleation
7942 & (nx,ny,nz,na,jyslab &
7943 & ,nor,norz,dtp,nxi &
7949 & ,ssfilt,t00,t77,flag_qndrop &
7955 ! real :: cwmasn = 1000.*0.523599*(2.*2.e-6)**3
7956 integer :: nx,ny,nz,na,nxi
7957 integer :: nor,norz, jyslab ! ,nht,ngt,igsr
7958 real :: dtp ! time step
7959 logical :: flag_qndrop
7961 integer, parameter :: ng1 = 1
7965 ! external temporary arrays
7967 real t00(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7968 real t77(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7970 real t0(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7971 ! real t1(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7972 ! real t2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7973 ! real t3(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7974 ! real t4(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7975 ! real t5(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7976 ! real t6(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7977 ! real t7(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7978 ! real t8(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7979 real t9(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7982 real p2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz) ! perturbation Pi
7983 real pn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7984 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
7985 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7987 real w(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7988 ! real qv(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7990 real ssfilt(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
7993 real pb(-norz+ng1:nz+norz)
7994 real pinit(-norz+ng1:nz+norz)
7996 real dz3d(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
8002 real axtra(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz,nxtra)
8008 ! declarations microphysics and for gather/scatter
8010 real, parameter :: cwmas30 = 1000.*0.523599*(2.*30.e-6)**3 ! mass of 30-micron radius droplet, for sat. adj.
8011 real, parameter :: cwmas20 = 1000.*0.523599*(2.*20.e-6)**3 ! mass of 20-micron radius droplet, for sat. adj.
8012 integer nxmpb,nzmpb,nxz
8013 integer mgs,ngs,numgs,inumgs
8015 integer ngscnt,igs(ngs),kgs(ngs)
8016 integer kgsp(ngs),kgsm(ngs)
8019 integer ix,kz,i,n, kp1, km1
8021 integer ixb,ixe,jyb,jye,kzb,kze
8023 integer itile,jtile,ktile
8024 integer ixend,jyend,kzend,kzbeg
8025 integer nxend,nyend,nzend,nzbeg
8028 ! Variables for Ziegler warm rain microphysics
8032 real ccnc(ngs), ccna(ngs), cnuc(ngs), cwnccn(ngs)
8034 real sscb ! 'cloud base' SS threshold
8035 parameter ( sscb = 2.0 )
8036 integer idecss ! flag to turn on (=1) decay of ssmax when no cloud or ice crystals
8037 parameter ( idecss = 1 )
8038 integer iba ! flag to do condensation/nucleation in 1st or 2nd loop
8039 ! =0 to use ad to calculate SS
8040 ! =1 to use an at end of main jy loop to calculate SS
8042 integer ifilt ! =1 to filter ssat, =0 to set ssfilt=ssat
8043 parameter ( ifilt = 0 )
8044 real temp1,temp2 ! ,ssold
8045 real :: ssmax(ngs) = 0.0 ! maximum SS experienced by a parcel
8048 ! real cnu,rnu,snu,cinu
8049 ! parameter ( cnu = 0.0, rnu = -0.8, snu = -0.8, cinu = 0.0 )
8053 real, parameter :: aa1 = 9.44e15, aa2 = 5.78e3 ! a1 in Ziegler
8055 real ec0, ex1, ft, rhoinv(ngs)
8059 real ac1,bc, taus, c1,d1,e1,f1,p380,tmp,tmp2 ! , sstdy, super
8060 real tmpmx, fw, qctmp
8062 double precision :: vent1,vent2
8066 real d1r, d1i, d1s, e1i
8067 integer nc ! condensation step
8068 real dtcon,dtcon1,dtcon2 ! condensation time step (dtcon*nc = dtp)
8070 integer ltemq1,ltemq1m ! ,ltemq1m2
8071 real dqv,qv1,ss1,ss2,qvs1,dqvs,dtemp,dt1 ! temporaries for condensation
8073 real ssi1, ssi2, dqvi, dqvis, dqvii,qis1
8074 real dqvr, dqc, dqr, dqi, dqs
8075 real qv1m,qvs1m,ss1m,ssi1m,qis1m
8077 real dcloud,dcloud2 ! ,as, bs
8079 real cn(ngs), cnuf(ngs)
8086 real es(ngs) ! ss(ngs),
8088 real ssf(ngs),ssfkp1(ngs),ssfkm1(ngs),ssat0(ngs)
8089 real, parameter :: ssfcut = 4.0
8090 real ssfjp1(ngs),ssfjm1(ngs)
8091 real ssfip1(ngs),ssfim1(ngs)
8094 parameter (supcb=0.5,supmx=238.0)
8095 real r2dxm, r2dym, r2dzm
8096 real dssdz, dssdy, dssdx
8099 parameter (epsi = 0.622, d = 0.266)
8100 real r1,qevap ! ,slv
8102 real vr,nrx,qr,z1,z2,rdi,alp,xnutmp,xnuc
8104 real f5, qvs0 ! Kessler condensation factor
8108 ! real, dimension(ngs) :: temp, tempc, elv, elf, els, pqs, theta, temg, temcg
8109 real dqvcnd(ngs),dqwv(ngs),dqcw(ngs),dqci(ngs)
8110 real temp(ngs),tempc(ngs)
8111 real temg(ngs),temcg(ngs),theta(ngs),qvap(ngs) ! ,tembzg(ngs)
8112 real temgx(ngs),temcgx(ngs)
8113 real qvs(ngs),qis(ngs),qss(ngs),pqs(ngs)
8114 real felv(ngs),felf(ngs),fels(ngs)
8115 real felvcp(ngs),felvpi(ngs)
8116 real gamw(ngs),gams(ngs) ! qciavl(ngs),
8117 real tsqr(ngs),ssi(ngs),ssw(ngs)
8118 real cc3(ngs),cqv1(ngs),cqv2(ngs)
8119 real qcwtmp(ngs),qtmp
8121 real fvent(ngs) !,fraci(ngs),fracl(ngs)
8122 real fwvdf(ngs),ftka(ngs),fthdf(ngs)
8123 real fadvisc(ngs),fakvisc(ngs)
8124 real fci(ngs),fcw(ngs)
8125 real fschm(ngs),fpndl(ngs)
8127 real pres(ngs),pipert(ngs)
8129 real rho0(ngs),pi0(ngs)
8131 real thetap(ngs),theta0(ngs),qwvp(ngs),qv0(ngs)
8135 real wvel(ngs),wvelkm1(ngs)
8137 real wvdf(ngs),tka(ngs)
8143 real :: qx(ngs,lv:lhab)
8144 real :: cx(ngs,lc:lhab)
8145 real :: xv(ngs,lc:lhab)
8146 real :: xmas(ngs,lc:lhab)
8147 real :: xdn(ngs,lc:lhab)
8148 real :: xdia(ngs,lc:lhab,3)
8149 real :: alpha(ngs,lc:lhab)
8150 real :: zx(ngs,lr:lhab)
8153 logical zerocx(lc:lqmx)
8157 integer, parameter :: iunit = 0
8159 real :: frac, hwdn, tmpg
8163 real, parameter :: rovcp = rd/cp
8164 real, parameter :: cpv = 1885.0 ! specific heat of water vapor at constant pressure
8171 ! -------------------------------------------------------------------------------
8184 f5 = 237.3 * 17.27 * 2.5e6 / cp ! combined constants for rain condensation (Soong and Ogura 73)
8191 IF ( ipconc <= 1 .or. isedonly == 2 ) GOTO 2200
8194 ! Ziegler nucleation
8197 ! ssfilt(:,:,:) = 0.0
8204 temp1 = an(ix,jy,kz,lt)*t77(ix,jy,kz)
8205 t0(ix,jy,kz) = temp1
8206 ltemq = Int( (temp1-163.15)/fqsat+1.5 )
8207 ltemq = Min( nqsat, Max(1,ltemq) )
8209 c1 = t00(ix,jy,kz)*tabqvs(ltemq)
8212 ssfilt(ix,jy,kz) = 100.*(an(ix,jy,kz,lv)/c1 - 1.0) ! from "new" values
8220 ! jy = 1 ! working on a 2d slab
8221 !! VERY IMPORTANT: SET jgs = jy
8226 !..Gather microphysics
8228 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: Gather stage'
8236 do 2000 inumgs = 1,numgs
8243 ! if (kzbeg .le. nzmpb .and. kzend .gt. nzmpb) kzb = nzmpb
8251 pqs(1) = 380.0/(pn(ix,jy,kz) + pb(kz))
8252 theta(1) = an(ix,jy,kz,lt)
8253 temg(1) = t0(ix,jy,kz)
8255 temcg(1) = temg(1) - tfr
8256 ltemq = (temg(1)-163.15)/fqsat+1.5
8257 ltemq = Min( nqsat, Max(1,ltemq) )
8258 qvs(1) = pqs(1)*tabqvs(ltemq)
8259 qis(1) = pqs(1)*tabqis(ltemq)
8264 if ( temg(1) .lt. tfr ) then
8267 if ( (temg(1) .gt. tfrh .or. an(ix,jy,kz,lv)/qvs(1) > maxsupersat ) .and. &
8268 & ( an(ix,jy,kz,lv) .gt. qss(1) .or. &
8269 & an(ix,jy,kz,lc) .gt. qxmin(lc) .or. &
8270 & ( an(ix,jy,kz,lr) .gt. qxmin(lr) .and. rcond == 2 ) &
8275 if ( ngscnt .eq. ngs ) goto 2100
8282 ! if ( jy .eq. (ny-jstag) ) iend = 1
8285 if ( ngscnt .eq. 0 ) go to 29998
8287 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: dbg = 8'
8289 ! write(0,*) 'NUCOND: dbg = 8, ngscnt,ssmx = ',ngscnt,ssmx
8298 IF ( imurain == 1 ) THEN
8299 alpha(:,lr) = alphar
8300 ELSEIF ( imurain == 3 ) THEN
8301 alpha(:,lr) = xnu(lr)
8305 ! define temporaries for state variables to be used in calculations
8308 qx(mgs,lv) = an(igs(mgs),jy,kgs(mgs),lv)
8310 qx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),il), 0.0)
8313 qcwtmp(mgs) = qx(mgs,lc)
8316 theta0(mgs) = an(igs(mgs),jy,kgs(mgs),lt) !
8318 theta(mgs) = an(igs(mgs),jy,kgs(mgs),lt)
8319 qv0(mgs) = qx(mgs,lv)
8320 qwvp(mgs) = qx(mgs,lv) - qv0(mgs)
8322 pres(mgs) = pn(igs(mgs),jy,kgs(mgs)) + pb(kgs(mgs))
8323 pipert(mgs) = p2(igs(mgs),jy,kgs(mgs))
8324 rho0(mgs) = dn(igs(mgs),jy,kgs(mgs))
8325 rhoinv(mgs) = 1.0/rho0(mgs)
8326 rhovt(mgs) = Sqrt(rho00/rho0(mgs))
8327 pi0(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs))
8328 temg(mgs) = t0(igs(mgs),jy,kgs(mgs))
8329 ! pk(mgs) = t77(igs(mgs),jy,kgs(mgs)) ! ( pres(mgs) / poo ) ** cap
8330 pk(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs)) ! t77(igs(mgs),jy,kgs(mgs))
8331 temcg(mgs) = temg(mgs) - tfr
8332 qss0(mgs) = (380.0)/(pres(mgs))
8333 pqs(mgs) = (380.0)/(pres(mgs))
8334 ltemq = (temg(mgs)-163.15)/fqsat+1.5
8335 ltemq = Min( nqsat, Max(1,ltemq) )
8336 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
8337 qis(mgs) = pqs(mgs)*tabqis(ltemq)
8339 qvap(mgs) = max( (qwvp(mgs) + qv0(mgs)), 0.0 )
8340 es(mgs) = 6.1078e2*tabqvs(ltemq)
8344 temgx(mgs) = min(temg(mgs),313.15)
8345 temgx(mgs) = max(temgx(mgs),233.15)
8346 felv(mgs) = 2500837.367 * (273.15/temgx(mgs))**((0.167)+(3.67e-4)*temgx(mgs))
8348 IF ( eqtset <= 1 ) THEN
8349 felvcp(mgs) = felv(mgs)*cpi
8350 ELSE ! equation set 2 in cm1
8351 tmp = qx(mgs,li)+qx(mgs,ls)+qx(mgs,lh)
8352 IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
8353 cvm = cv+cvv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
8355 cpm = cp+cpv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
8357 rmm=rd+rw*qx(mgs,lv)
8359 IF ( eqtset == 2 ) THEN
8361 felvcp(mgs) = (felv(mgs)-rw*temg(mgs))/cvm
8364 felvcp(mgs) = (felv(mgs)*cv/(cp) - rw*temg(mgs)*(1.0-rovcp*cpm/rmm))/cvm
8365 felvpi(mgs) = pi0(mgs)*rovcp*(felv(mgs)/(temg(mgs)) - rw*cpm/rmm)/cvm
8370 temcgx(mgs) = min(temg(mgs),273.15)
8371 temcgx(mgs) = max(temcgx(mgs),223.15)
8372 temcgx(mgs) = temcgx(mgs)-273.15
8373 felf(mgs) = 333690.6098 + (2030.61425)*temcgx(mgs) - (10.46708312)*temcgx(mgs)**2
8375 fels(mgs) = felv(mgs) + felf(mgs)
8376 fcqv1(mgs) = 4098.0258*felv(mgs)*cpi
8378 wvdf(mgs) = (2.11e-05)*((temg(mgs)/tfr)**1.94)* &
8379 & (101325.0/(pb(kgs(mgs)) + pn(igs(mgs),jgs,kgs(mgs)))) ! diffusivity of water vapor, Hall and Pruppacher (76)
8380 advisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))* &
8381 & (temg(mgs)/296.0)**(1.5) ! dynamic viscosity (SMT; see Beard & Pruppacher 71)
8382 tka(mgs) = tka0*advisc(mgs)/advisc1 ! thermal conductivity
8390 ! load concentrations
8392 if ( ipconc .ge. 1 ) then
8394 cx(mgs,li) = Max(an(igs(mgs),jy,kgs(mgs),lni), 0.0)
8397 if ( ipconc .ge. 2 ) then
8399 cx(mgs,lc) = Max(an(igs(mgs),jy,kgs(mgs),lnc), 0.0)
8400 cwnccn(mgs) = cwccn*rho0(mgs)/rho00 ! background ccn count
8403 ssmax(mgs) = an(igs(mgs),jy,kgs(mgs),lss)
8407 IF ( lccn .gt. 1 ) THEN
8408 ccnc(mgs) = an(igs(mgs),jy,kgs(mgs),lccn)
8410 ccnc(mgs) = cwnccn(mgs)
8412 IF ( lccnuf .gt. 1 ) THEN
8413 ccncuf(mgs) = an(igs(mgs),jy,kgs(mgs),lccnuf)
8418 IF ( lccna > 1 ) THEN
8419 ccna(mgs) = an(igs(mgs),jy,kgs(mgs),lccna) ! predicted count of activated ccn
8421 IF ( lccn > 1 ) THEN
8422 ccna(mgs) = cwnccn(mgs) - ccnc(mgs) ! diagnose activated ccn as background value - remaining unactivated ccn
8424 ccna(mgs) = cx(mgs,lc) ! approximation of number of activated ccn
8429 if ( ipconc .ge. 3 ) then
8431 cx(mgs,lr) = Max(an(igs(mgs),jy,kgs(mgs),lnr), 0.0)
8435 ! cnuc(1:ngscnt) = cwccn*rho0(mgs)/rho00*(1. - renucfrac) + ccnc(1:ngscnt)*renucfrac
8437 ! default value of renucfrac is 0.0
8438 IF ( irenuc /= 6 ) THEN
8439 cnuc(mgs) = Max(ccnc(mgs),cwnccn(mgs))*(1. - renucfrac) + ccnc(mgs)*renucfrac
8441 cnuc(mgs) = Max(ccnc(mgs),cwnccn(mgs))*(1. - renucfrac) + Max(0.0,ccnc(mgs) - ccna(mgs))*renucfrac
8443 IF ( renucfrac >= 0.999 ) THEN
8444 IF ( temg(mgs) < 265. ) THEN
8445 IF ( qx(mgs,lc) > 10.*qxmin(lc) .and. w(igs(mgs),jgs,kgs(mgs)) > 2.0 ) THEN
8446 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
8448 cnuc(mgs) = 0.1*cnuc(mgs)
8456 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: Set density'
8459 xdn(mgs,lc) = xdn0(lc)
8460 xdn(mgs,lr) = xdn0(lr)
8468 ! write(0,*) 'NUCOND: Set ssf variables, ssmxinit =',ssmxinit
8472 kp1 = Min(nz, kgs(mgs)+1 )
8473 wvel(mgs) = (0.5)*(w(igs(mgs),jgs,kp1) &
8474 & +w(igs(mgs),jgs,kgs(mgs)))
8475 wvelkm1(mgs) = (0.5)*(w(igs(mgs),jgs,kgs(mgs)) &
8476 & +w(igs(mgs),jgs,Max(1,kgs(mgs)-1)))
8478 ssat0(mgs) = ssfilt(igs(mgs),jgs,kgs(mgs))
8479 ssf(mgs) = ssfilt(igs(mgs),jgs,kgs(mgs))
8480 ! ssmx = Max( ssmx, ssf(mgs) )
8483 ssfkp1(mgs) = ssfilt(igs(mgs),jgs,Min(nz-1,kgs(mgs)+1))
8484 ssfkm1(mgs) = ssfilt(igs(mgs),jgs,Max(1,kgs(mgs)-1))
8492 ! cloud water variables
8495 if ( ndebug .gt. 0 )write(0,*) 'ICEZVD_DR: Set cloud water variables'
8499 IF ( ipconc .ge. 2 .and. cx(mgs,lc) .gt. 1.0e6 ) THEN
8501 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
8502 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
8504 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. cxmin ) THEN
8506 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),xdn(mgs,lc)*xvmn(lc)), &
8507 & xdn(mgs,lc)*xvmx(lc) )
8509 cx(mgs,lc) = qx(mgs,lc)*rho0(mgs)/xmas(mgs,lc)
8511 ELSEIF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .le. cxmin ) THEN
8512 ! xmas(mgs,lc) = xdn(mgs,lc)*4.*pi/3.*(5.0e-6)**3
8513 ! cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc)
8514 cx(mgs,lc) = Max( cxmin, rho0(mgs)*qx(mgs,lc)/cwmasx )
8516 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
8517 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
8520 xmas(mgs,lc) = cwmasn
8523 xdia(mgs,lc,1) = (xmas(mgs,lc)*cwc1)**c1f3
8531 if ( qx(mgs,lr) .gt. qxmin(lr) ) then
8533 if ( ipconc .ge. 3 ) then
8534 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*Max(1.0e-9,cx(mgs,lr)))
8535 ! parameter( xvmn(lr)=2.8866e-13, xvmx(lr)=4.1887e-9 ) ! mks
8536 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
8537 xv(mgs,lr) = xvmx(lr)
8538 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
8539 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
8540 xv(mgs,lr) = xvmn(lr)
8541 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
8544 xmas(mgs,lr) = xv(mgs,lr)*xdn(mgs,lr)
8545 xdia(mgs,lr,3) = (xmas(mgs,lr)*cwc1)**(1./3.) ! xdia(mgs,lr,1)
8546 IF ( imurain == 3 ) THEN
8547 ! xdia(mgs,lr,1) = (6.*pii*xv(mgs,lr)/(alpha(mgs,lr)+1.))**(1./3.)
8548 xdia(mgs,lr,1) = xdia(mgs,lr,3) ! formulae for Ziegler (1985) use mean volume diameter, not lambda**(-1)
8549 ELSE ! imurain == 1, Characteristic diameter (1/lambda)
8550 xdia(mgs,lr,1) = (6.*piinv*xv(mgs,lr)/((alpha(mgs,lr)+3.)*(alpha(mgs,lr)+2.)*(alpha(mgs,lr)+1.)))**(1./3.)
8552 ! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
8554 ! Inverse exponential version:
8556 ! > (qx(mgs,lr)*rho0(mgs)
8557 ! > /(pi*xdn(mgs,lr)*cx(mgs,lr)))**(0.333333)
8560 & (qx(mgs,lr)*rho0(mgs)/(pi*xdn(mgs,lr)*cno(lr)))**(0.25)
8563 xdia(mgs,lr,1) = 1.e-9
8564 ! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
8571 ! Ventilation coefficients
8576 fadvisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))* &
8577 & (temg(mgs)/296.0)**(1.5)
8579 fakvisc(mgs) = fadvisc(mgs)*rhoinv(mgs)
8581 fwvdf(mgs) = (2.11e-05)*((temg(mgs)/tfr)**1.94)* &
8582 & (101325.0/(pres(mgs)))
8584 fschm(mgs) = (fakvisc(mgs)/fwvdf(mgs))
8586 fvent(mgs) = (fschm(mgs)**(1./3.)) * (fakvisc(mgs)**(-0.5))
8591 ! Ziegler nucleation
8594 ! cloud evaporation, condensation, and nucleation
8599 IF ( temg(mgs) .le. tfrh .and. qx(mgs,lv)/qvs(mgs) < maxsupersat ) THEN
8603 IF( ssat0(mgs) .GT. 0. .OR. ssf(mgs) .GT. 0. ) GO TO 620
8604 !6/4 IF( qvap(mgs) .EQ. qss(mgs) ) GO TO 631
8606 !.... EVAPORATION. QV IS LESS THAN qss(mgs).
8607 !.... EVAPORATE CLOUD FIRST
8609 IF ( qx(mgs,lc) .LE. 0. ) GO TO 631
8610 !.... CLOUD EVAPORATION.
8611 ! convert input 'cp' to cgs
8612 R1=1./(1. + caw*(273.15 - cbw)*qss(mgs)*felv(mgs)/ &
8613 & (cp*(temg(mgs) - cbw)**2))
8614 QEVAP= Min( qx(mgs,lc), R1*(qss(mgs)-qvap(mgs)) )
8617 IF ( qx(mgs,lc) .LT. QEVAP ) THEN ! GO TO 63
8618 qwvp(mgs) = qwvp(mgs) + qx(mgs,lc)
8619 thetap(mgs) = thetap(mgs) - felv(mgs)*qx(mgs,lc)/(cp*pi0(mgs))
8620 IF ( io_flag .and. nxtra > 1 ) THEN
8621 axtra(igs(mgs),jy,kgs(mgs),1) = -qx(mgs,lc)/dtp
8624 IF ( restoreccn ) THEN
8625 IF ( irenuc <= 2 ) THEN
8626 IF ( .not. invertccn ) THEN
8627 ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + cx(mgs,lc) ) )
8629 ccnc(mgs) = ccnc(mgs) + cx(mgs,lc)
8632 IF ( lccna > 1 ) THEN
8633 ccna(mgs) = ccna(mgs) - cx(mgs,lc)
8639 qwvp(mgs) = qwvp(mgs) + QEVAP
8640 qx(mgs,lc) = qx(mgs,lc) - QEVAP
8641 IF ( qx(mgs,lc) .le. 0. ) THEN
8642 IF ( restoreccn ) THEN
8643 IF ( irenuc <= 2 ) THEN
8644 ! ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + cx(mgs,lc) ) )
8645 ! ccnc(mgs) = ccnc(mgs) + cx(mgs,lc)
8646 IF ( .not. invertccn ) THEN
8647 ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + cx(mgs,lc) ) )
8649 ccnc(mgs) = ccnc(mgs) + cx(mgs,lc)
8652 IF ( lccna > 1 ) THEN
8653 ccna(mgs) = ccna(mgs) - cx(mgs,lc)
8658 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
8659 IF ( restoreccn ) THEN
8660 IF ( irenuc <= 2 ) THEN
8661 ! ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + tmp ) )
8662 ! ccnc(mgs) = ccnc(mgs) + tmp
8663 IF ( .not. invertccn ) THEN
8664 ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + tmp ) )
8666 ccnc(mgs) = ccnc(mgs) + tmp
8669 IF ( lccna > 1 ) THEN
8670 ccna(mgs) = ccna(mgs) - tmp
8673 cx(mgs,lc) = cx(mgs,lc) - tmp
8675 thetap(mgs) = thetap(mgs) - felv(mgs)*QEVAP/(CP*pi0(mgs))
8676 IF ( io_flag .and. nxtra > 1 ) THEN
8677 axtra(igs(mgs),jy,kgs(mgs),1) = -QEVAP/dtp
8687 !.... CLOUD CONDENSATION
8689 IF ( qx(mgs,lc) .GT. qxmin(lc) .and. cx(mgs,lc) .ge. 1. ) THEN
8693 ! ac1 = xdn(mgs,lc)*elv(kgs(mgs))**2*epsi/
8694 ! : (tka(kgs(mgs))*rw*temg(mgs)**2)
8695 ! took out xdn factor because it cancels later...
8696 ac1 = felv(mgs)**2/(tka(mgs)*rw*temg(mgs)**2)
8699 ! bc = xdn(mgs,lc)*rw*temg(mgs)/
8700 ! : (epsi*wvdf(kgs(mgs))*es(mgs))
8701 ! took out xdn factor because it cancels later...
8702 bc = rw*temg(mgs)/(wvdf(mgs)*es(mgs))
8704 ! bs = rho0(mgs)*((rd*temg(mgs)/(epsi*es(mgs)))+
8705 ! : (epsi*elv(kgs(mgs))**2/(pres(mgs)*temg(mgs)*cp)))
8707 ! taus = Min(dtp, xdn(mgs,lc)*rho0(mgs)*(ac1+bc)/
8708 ! : (4*pi*0.89298*BS*0.5*xdia(mgs,lc,1)*cx(mgs,lc)*xdn(mgs,lc)))
8711 IF ( ssf(mgs) .gt. 0.0 .or. ssat0(mgs) .gt. 0.0 ) THEN
8712 IF ( ny .le. 2 ) THEN
8713 ! write(0,*) 'undershoot: ',ssf(mgs),
8714 ! : ( (qx(mgs,lv) - dcloud)/c1 - 1.0)*100.
8719 IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN
8721 IF ( xdia(mgs,lc,1) .le. 0.0 ) THEN
8722 xmas(mgs,lc) = cwmasn
8723 xdia(mgs,lc,1) = (xmas(mgs,lc)*cwc1)**c1f3
8725 d1 = (1./(ac1 + bc))*4.0*pi*ventc &
8726 & *0.5*xdia(mgs,lc,1)*cx(mgs,lc)*rhoinv(mgs)
8732 IF ( rcond .eq. 2 .and. qx(mgs,lr) .gt. qxmin(lr) .and. cx(mgs,lr) > 1.e-9 ) THEN
8733 IF ( imurain == 3 ) THEN
8734 IF ( izwisventr == 1 ) THEN
8735 rwvent(mgs) = ventrx(mgs)*(1.6 + 124.9*(1.e-3*rho0(mgs)*qx(mgs,lr))**.2046)
8736 ELSE ! izwisventr = 2
8737 ! 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
8739 & (0.78*ventrx(mgs) + 0.308*ventrxn(mgs)*fvent(mgs) &
8740 & *Sqrt((ar*rhovt(mgs))) &
8741 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
8746 IF ( iferwisventr == 1 ) THEN
8747 alpr = Min(alpharmax,alpha(mgs,lr) )
8748 ! alpr = alpha(mgs,lr)
8752 i = Int(dgami*(tmp))
8754 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
8756 tmp = 2.5 + alpr + 0.5*bx(lr)
8757 i = Int(dgami*(tmp))
8759 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp ! ratio of gamma functions
8761 ! vent1 = dble(xdia(mgs,lr,1))**(-2. - alpr) ! Actually OK
8762 ! vent2 = dble(1./xdia(mgs,lr,1) + 0.5*fx(lr))**dble(2.5+alpr+0.5*bx(lr)) ! Actually OK
8763 vent1 = dble(xdia(mgs,lr,1))**(0.5 + 0.5*bx(lr)) ! 2016.2.26 Changed for consistency with derivation (recast formula)
8764 vent2 = dble(1. + 0.5*fx(lr)*xdia(mgs,lr,1))**dble(2.5+alpr+0.5*bx(lr))
8769 & 0.308*fvent(mgs)*y* &
8770 & Sqrt(ax(lr)*rhovt(mgs))*(vent1/vent2)
8772 ELSEIF ( iferwisventr == 2 ) THEN
8774 ! 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
8775 x = 1. + alpha(mgs,lr)
8778 & (0.78*x + 0.308*ventrxn(mgs)*fvent(mgs) &
8779 & *Sqrt((ar*rhovt(mgs))) &
8780 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
8783 ENDIF ! iferwisventr
8787 d1r = (1./(ac1 + bc))*4.0*pi*rwvent(mgs) &
8788 & *0.5*xdia(mgs,lr,1)*cx(mgs,lr)*rhoinv(mgs)
8794 e1 = felvcp(mgs)/(pi0(mgs))
8795 f1 = pk(mgs) ! (pres(mgs)/poo)**cap
8798 ! fifth trial to see what happens:
8800 ltemq = (temg(mgs)-163.15)/fqsat+1.5
8801 ltemq = Min( nqsat, Max(1,ltemq) )
8804 p380 = 380.0/pres(mgs)
8806 ! taus = Max( 0.05*dtp, Min(taus, 0.25*dtp ) )
8807 ! nc = NInt(dtp/Min(1.0,0.5*taus))
8808 ! dtcon = dtp/float(nc)
8809 ss1 = qx(mgs,lv)/qvs(mgs)
8818 ! dtcon = Max(dtcon,0.2)
8819 ! nc = Nint(dtp/dtcon)
8822 ! want to start out with a small time step to handle the steep slope
8823 ! and fast changes, then can switch to a larger step (dtcon2) for the
8824 ! rest of the big time step.
8825 ! base the initial time step (dtcon1) on the slope (delta)
8826 IF ( Abs(ss1 - 1.0) .gt. 1.e-5 ) THEN
8827 delta = 0.5*(qv1-qvs1)/(d1*(ss1 - 1.0))
8831 ! delta is the extrapolated time to get halfway from qv1 to qvs1
8832 ! want at least 5 time steps to the halfway point, so multiply by 0.2
8833 ! for the initial time step
8834 dtcon1 = Min(0.05,0.2*delta)
8835 nc = Max(5,2*NInt( (dtp-4.0*dtcon1)/delta))
8836 dtcon2 = (dtp-4.0*dtcon1)/nc
8848 RK2c: DO WHILE ( dt1 .lt. dtp )
8850 IF ( n .le. 4 ) THEN
8855 609 dqv = -(ss1 - 1.)*d1*dtcon
8856 dqvr = -(ss1 - 1.)*d1r*dtcon
8857 dtemp = -0.5*e1*f1*(dqv + dqvr)
8858 ! write(0,*) 'RK2c dqv1 = ',dqv
8859 ! calculate midpoint values:
8860 ! ltemq1m = ltemq1 + Nint(dtemp*fqsat + 0.5)
8862 ! 7.6.2016: Test full calc of ltemq
8863 ltemq1m = (temp1+dtemp-163.15)*fqsati+1.5
8864 ltemq1m = Min( nqsat, Max(1,ltemq1m) )
8866 IF ( ltemq1m .lt. 1 .or. ltemq1m .gt. nqsat ) THEN
8867 write(0,*) 'STOP in nucond line 1192 '
8868 write(0,*) ' ltemq1m,icond = ',ltemq1m,icond
8869 write(0,*) ' dtemp,e1,f1,dqv,dqvr = ', dtemp,e1,f1,dqv,dqvr
8870 write(0,*) ' d1,d1r,dtcon,ss1 = ',d1,d1r,dtcon,ss1
8871 write(0,*) ' dqc, dqr = ',dqc,dqr
8872 write(0,*) ' qv,qc,qr = ',qx(mgs,lv)*1000.,qx(mgs,lc)*1000.,qx(mgs,lr)*1000.
8873 write(0,*) ' i, j, k = ',igs(mgs),jy,kgs(mgs)
8874 write(0,*) ' dtcon1,dtcon2,delta = ',dtcon1,dtcon2,delta
8875 write(0,*) ' nc,dtp = ',nc,dtp
8876 write(0,*) ' rwvent,xdia,crw,ccw = ', rwvent(mgs),xdia(mgs,lr,1),cx(mgs,lr),cx(mgs,lc)
8877 write(0,*) ' fvent,alphar = ',fvent(mgs),alpha(mgs,lr)
8878 write(0,*) ' xvr,xmasr,xdnr,cwc1 = ',xv(mgs,lr),xmas(mgs,lr),xdn(mgs,lr),cwc1
8880 dqvs = dtemp*p380*dtabqvs(ltemq1m)
8881 qv1m = qv1 + dqv + dqvr
8882 ! qv1mr = qv1r + dqvr
8887 ! check for undersaturation when no ice is present, if so, then reduce time step
8888 IF ( ss1m .lt. 1. .and. (dqvii + dqvis) .eq. 0.0 ) THEN
8890 IF ( dtcon .ge. dtcon1 ) THEN
8896 ! calculate full step:
8897 dqv = -(ss1m - 1.)*d1*dtcon
8898 dqvr = -(ss1m - 1.)*d1r*dtcon
8901 ! write(0,*) 'RK2a dqv1m = ',dqv
8902 dtemp = -e1*f1*(dqv + dqvr)
8904 ! ltemq1 = ltemq1 + Nint(dtemp*fqsat + 0.5)
8906 ! 7.6.2016: Test full calc of ltemq
8907 ltemq1 = (temp1+dtemp-163.15)*fqsati+1.5
8908 ltemq1 = Min( nqsat, Max(1,ltemq1) )
8910 IF ( ltemq1 .lt. 1 .or. ltemq1 .gt. nqsat ) THEN
8911 write(0,*) 'STOP in nucond line 1230 '
8912 write(0,*) ' ltemq1m,icond = ',ltemq1m,icond
8913 write(0,*) ' dtemp,e1,dqv,dqvr = ', dtemp,e1,dqv,dqvr
8915 dqvs = dtemp*p380*dtabqvs(ltemq1)
8917 qv1 = qv1 + dqv + dqvr
8924 temp1 = temp1 + dtemp
8925 IF ( temp2 .eq. temp1 .or. ss2 .eq. ss1 .or. &
8926 & ss1 .eq. 1.00 .or. &
8927 & ( n .gt. 10 .and. ss1 .lt. 1.0005 ) ) THEN
8928 ! write(0,*) 'RK2c break'
8939 dcloud = dqc ! qx(mgs,lv) - qv1
8940 thetap(mgs) = thetap(mgs) + e1*(DCLOUD + dqr)
8943 IF ( eqtset > 2 ) THEN
8944 pipert(mgs) = pipert(mgs) + felvpi(mgs)*(DCLOUD + dqr)
8946 IF ( io_flag .and. nxtra > 1 ) THEN
8947 axtra(igs(mgs),jy,kgs(mgs),1) = DCLOUD/dtp
8948 axtra(igs(mgs),jy,kgs(mgs),2) = axtra(igs(mgs),jy,kgs(mgs),2) + dqr/dtp
8950 qwvp(mgs) = qwvp(mgs) - (DCLOUD + dqr)
8951 qx(mgs,lc) = qx(mgs,lc) + DCLOUD
8952 qx(mgs,lr) = qx(mgs,lr) + dqr
8953 ! t9(igs(mgs),jy,kgs(mgs)) = t9(igs(mgs),jy,kgs(mgs)) + (DCLOUD + dqr)/dtp*felv(mgs)/(cp*pi0(mgs)) !* &
8954 !! & dx*dy*dz3d(igs(mgs),jy,kgs(mgs))
8957 theta(mgs) = thetap(mgs) + theta0(mgs)
8958 temg(mgs) = theta(mgs)*f1
8959 ltemq = (temg(mgs)-163.15)/fqsat+1.5
8960 ltemq = Min( nqsat, Max(1,ltemq) )
8961 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
8962 ! es(mgs) = 6.1078e2*tabqvs(ltemq)
8966 ENDIF ! dcloud .gt. 0.
8969 ELSE ! qc .le. qxmin(lc)
8971 ! IF ( ssf(mgs) .gt. 0.0 .and. .not. flag_qndrop ) THEN ! flag_qndrop turns off primary nucleation when using wrf-chem with progn=1
8972 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
8974 IF ( iqcinit == 1 ) THEN
8976 qvs0 = 380.*exp(17.27*(temg(mgs)-273.)/(temg(mgs)- 36.))/pk(mgs)
8978 dcloud = Max(0.0, (qx(mgs,lv)-qvs0) / (1.+qvs0*f5/(temg(mgs)-36.)**2) )
8980 ELSEIF ( iqcinit == 3 ) THEN
8981 R1=1./(1. + caw*(273.15 - cbw)*qss(mgs)*felvcp(mgs)/ &
8982 & ((temg(mgs) - cbw)**2))
8983 DCLOUD=R1*(qvap(mgs) - qvs(mgs)) ! KW model adjustment;
8984 ! this will put mass into qc if qv > sqsat exists
8986 ELSEIF ( iqcinit == 2 ) THEN
8987 ! R1=1./(1. + caw*(273.15 - cbw)*qss(mgs)*felv(mgs)/
8988 ! : (cp*(temg(mgs) - cbw)**2))
8989 ! DCLOUD=R1*(qvap(mgs) - qvs(mgs)) ! KW model adjustment;
8990 ! this will put mass into qc if qv > sqsat exists
8993 ! IF ( ssf(mgs) > ssmx .and. ssmax(mgs) < 3.0 ) THEN
8994 ! IF ( ssf(mgs) > ssmx .and. ccnc(mgs) > 1.0 ) THEN
8995 ! IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 5.0 .and. ccnc(mgs) > 0.1*cwnccn(mgs) ) THEN ! this one works
8996 ! IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 20.0 ) THEN ! test -- fails
8997 ! IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 20.0 .and. ccnc(mgs) > 0.1*cwnccn(mgs)) THEN ! test -- is OK
8998 IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 20.0 .and. ccnc(mgs) > 0.05*cwnccn(mgs)) THEN ! test
8999 ! IF ( ssf(mgs) > ssmx ) THEN ! original condition
9000 CALL QVEXCESS(ngs,mgs,qwvp,qv0,qx(1,lc),pres,thetap,theta0,dcloud, &
9001 & pi0,tabqvs,nqsat,fqsat,cbw,fcqv1,felvcp,ssmx,pk,ngscnt)
9010 thetap(mgs) = thetap(mgs) + felvcp(mgs)*DCLOUD/(pi0(mgs))
9011 qwvp(mgs) = qwvp(mgs) - DCLOUD
9012 qx(mgs,lc) = qx(mgs,lc) + DCLOUD
9013 IF ( io_flag .and. nxtra > 1 ) THEN
9014 axtra(igs(mgs),jy,kgs(mgs),1) = DCLOUD/dtp
9016 theta(mgs) = thetap(mgs) + theta0(mgs)
9017 temg(mgs) = theta(mgs)*pk(mgs) !( pres(mgs) / poo ) ** cap
9018 ! temg(mgs) = theta2temp( theta(mgs), pres(mgs) )
9019 ltemq = (temg(mgs)-163.15)/fqsat+1.5
9020 ltemq = Min( nqsat, Max(1,ltemq) )
9021 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
9022 ! es(mgs) = 6.1078e2*tabqvs(ltemq)
9024 !.... S. TWOMEY (1959)
9025 ! Note: get here if there is no previous cloud water and w > 0.
9028 IF ( ncdebug .ge. 1 ) THEN
9029 write(iunit,*) 'at 613: ',qx(mgs,lc),cx(mgs,lc),wvel(mgs),ssmax(mgs),kgs(mgs)
9032 IF ( .not. flag_qndrop ) THEN ! { do not calculate number of droplets if using wrf-chem
9035 ! IF ( ssmax(mgs) .lt. sscb .and. qx(mgs,lc) .gt. qxmin(lc)) THEN
9036 IF ( dcloud .gt. qxmin(lc) .and. wvel(mgs) > 0.0) THEN
9037 ! CN(mgs) = CCNE*wvel(mgs)**cnexp ! *Min(1.0,1./dtp) ! 0.3465
9038 CN(mgs) = CCNE0*cnuc(mgs)**(2./(2.+cck))*wvel(mgs)**cnexp ! *Min(1.0,1./dtp) ! 0.3465
9039 IF ( ny .le. 2 .and. cn(mgs) .gt. 0.0 &
9040 & .and. ncdebug .ge. 1 ) THEN
9041 write(iunit,*) 'CN: ',cn(mgs)*1.e-6, cx(mgs,lc)*1.e-6, qx(mgs,lc)*1.e3, &
9042 & wvel(mgs), dcloud*1.e3
9043 IF ( cn(mgs) .gt. 1.0 ) write(iunit,*) 'cwrad = ', &
9044 & 1.e6*(rho0(mgs)*qx(mgs,lc)/cn(mgs)*cwc1)**c1f3, &
9045 & igs(mgs),kgs(mgs),temcg(mgs), &
9046 & 1.e3*an(igs(mgs),jgs,kgs(mgs)-1,lc)
9048 IF ( iccwflg .eq. 1 ) THEN
9049 cn(mgs) = Min(cwccn*rho0(mgs)/rho00, Max(cn(mgs), &
9050 & rho0(mgs)*qx(mgs,lc)/(xdn(mgs,lc)*(4.*pi/3.)*(4.e-6)**3)))
9055 ! cn(mgs) = Min(cwccn, &
9056 ! & rho0(mgs)*dcloud/(xdn(mgs,lc)*(4.*pi/3.)*(4.e-6)**3) )
9059 IF ( cn(mgs) .gt. 0.0 ) THEN
9060 IF ( cn(mgs) .gt. ccnc(mgs) ) THEN
9064 ! cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
9065 IF ( irenuc <= 2 ) ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
9066 ccna(mgs) = ccna(mgs) + cn(mgs)
9069 ! write(91,*) 'nuc1: cn, ix, kz = ',cn(mgs),igs(mgs),kgs(mgs),wvel(mgs),cnexp,ccnc(mgs)
9071 IF( CN(mgs) .GT. cx(mgs,lc) ) cx(mgs,lc) = CN(mgs)
9072 IF( cx(mgs,lc) .GT. 0. .AND. qx(mgs,lc) .le. qxmin(lc) ) THEN
9075 cx(mgs,lc) = Min(cx(mgs,lc),rho0(mgs)*Max(0.0,qx(mgs,lc))/cwmasn)
9078 ENDIF ! }.not. flag_qndrop
9085 ! SQSAT=EPSI*ES/(PB(K)*1000.-ES)
9087 !.... CLOUD NUCLEATION
9089 ! ES=1.E3*PB(K)*QV/EPSI
9091 IF ( wvel(mgs) .le. 0. ) GO TO 616
9092 IF ( cx(mgs,lc) .le. 0. ) GO TO 613 !TWOMEY (1959) Nucleation
9093 IF ( kzbeg-1+kgs(mgs) .GT. 1 .and. qx(mgs,lc) .le. qxmin(lc)) GO TO 613 !TWOMEY (1959) Nucleation
9094 IF ( kzbeg-1+kgs(mgs) .eq. 1 .and. wvel(mgs) .gt. 0. ) GO TO 613 !TWOMEY (1959) Nucleation
9095 !.... ATTEMPT ZIEGLER CLOUD NUCLEATION IN CLOUD INTERIOR UNLESS...
9096 616 IF ( ssf(mgs) .LE. SUPCB .AND. wvel(mgs) .GT. 0. ) GO TO 631 !... weakly saturated updraft
9097 IF ( kzbeg-1+kgs(mgs) .GT. 1 .AND. kzbeg-1+kgs(mgs) .LT. nzend-1 .AND. &
9098 & (ssfkp1(mgs) .GE. SUPMX .OR. &
9099 & ssf(mgs) .GE. SUPMX .OR. &
9100 & ssfkm1(mgs) .GE. SUPMX)) GO TO 631 !... too much vapour
9101 IF (ssf(mgs) .LT. 1.E-10 .OR. ssf(mgs) .GE. SUPMX) GO TO 631 !... at the extremes for ss
9104 ! get here if ( qc > 0 and ss > supcb) or (w < 0)
9107 if (ndebug .gt. 0) write(0,*) "ICEZVD_DR: Entered Ziegler Cloud Nucleation" !mpidebug
9110 r2dzm=0.50/dz3d(igs(mgs),jy,kgs(mgs))
9111 IF ( irenuc >= 0 .and. .not. flag_qndrop) THEN ! turn off nucleation when flag_qndrop (using WRF-CHEM for activation)
9113 IF ( irenuc < 2 ) THEN !{
9115 IF ( kzend == nzend ) THEN
9116 t0p3 = t0(igs(mgs),jgs,Min(kze,kgs(mgs)+3))
9117 t0p1 = t0(igs(mgs),jgs,Min(kze,kgs(mgs)+1))
9119 t0p3 = t0(igs(mgs),jgs,kgs(mgs)+3)
9120 t0p1 = t0(igs(mgs),jgs,kgs(mgs)+1)
9123 IF ( ( ssf(mgs) .gt. ssmax(mgs) .or. irenuc .eq. 1 ) &
9124 & .and. ( ( lccn .lt. 1 .and. &
9125 & cx(mgs,lc) .lt. cwccn*(Min(1.0,rho0(mgs)))) .or. &
9126 & ( lccn .gt. 1 .and. ccnc(mgs) .gt. 0. ) ) &
9128 IF( kzbeg-1+kgs(mgs) .GT. 1 .AND. kzbeg-1+kgs(mgs) .LT. nzend-1 &
9129 & .and. ssf(mgs) .gt. 0.0 &
9130 & .and. ssfkp1(mgs) .LT. SUPMX .and. ssfkp1(mgs) .ge. 0.0 &
9131 & .AND. ssfkm1(mgs) .LT. SUPMX .AND. ssfkm1(mgs) .ge. 0.0 &
9132 & .AND. ssfkp1(mgs) .gt. ssfkm1(mgs) &
9133 & .and. t0p3 .gt. 233.2) THEN
9134 DSSDZ = (ssfkp1(mgs) - ssfkm1(mgs))*R2DZM
9136 ! otherwise check for cloud base condition with updraft:
9138 ELSEIF( kzbeg-1+kgs(mgs) .GT. 1 .AND. kzbeg-1+kgs(mgs) .LT. nzend-1 &
9139 ! IF( kgs(mgs) .GT. 1 .AND. kgs(mgs) .LT. NZ-1 & !)
9140 & .and. ssf(mgs) .gt. 0.0 .and. wvel(mgs) .gt. 0.0 &
9141 & .and. ssfkp1(mgs) .gt. 0.0 &
9142 & .AND. ssfkm1(mgs) .le. 0.0 .and. wvelkm1(mgs) .gt. 0.0 &
9143 & .AND. ssf(mgs) .gt. ssfkm1(mgs) &
9144 & .and. t0p1 .gt. 233.2) THEN
9145 DSSDZ = 2.*(ssf(mgs) - ssfkm1(mgs))*R2DZM ! 1-sided difference
9150 !CLZ IF(wijk.LE.0.) CN=CCN*ssfilt(ix,jy,kz)**CCK
9151 ! note: CCN -> cwccn, DELT -> dtp
9152 c1 = Max(0.0, rho0(mgs)*(qx(mgs,lv) - qss(mgs))/ &
9153 & (xdn(mgs,lc)*(4.*pi/3.)*(4.e-6)**3))
9154 IF ( lccn .lt. 1 ) THEN
9155 CN(mgs) = cwccn*rho0(mgs)/rho00*CCK*ssf(mgs)**CCKM*dtp* &
9157 & (wvel(mgs)*DSSDZ) ) ! probably the vertical gradient dominates
9160 & Min(ccnc(mgs), cnuc(mgs)*CCK*ssf(mgs)**CCKM*dtp* &
9162 & ( wvel(mgs)*DSSDZ) ) )
9163 ! IF ( cn(mgs) .gt. 0 ) ccnc(mgs) = ccnc(mgs) - cn(mgs)
9166 IF ( cn(mgs) .gt. 0.0 ) THEN
9167 IF ( ccnc(mgs) .lt. 5.e7 .and. cn(mgs) .ge. 5.e7 ) THEN
9170 ELSEIF ( cn(mgs) .gt. ccnc(mgs) ) THEN
9174 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
9175 ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
9178 ELSEIF ( irenuc == 2 ) THEN !} {
9179 ! simple Twomey scheme
9180 ! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
9181 CN(mgs) = CCNE0*cnuc(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp ! *Min(1.0,1./dtp) ! 0.3465
9182 ! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
9183 !!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
9184 ! Philips, Donner et al. 2007, but results in too much limitation of
9186 CN(mgs) = Min(cn(mgs), ccnc(mgs))
9187 cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
9189 IF ( .false. .and. ny <= 2 ) THEN
9190 write(0,*) 'i,k, cwmasn = ',igs(mgs),kgs(mgs),cwmasn
9191 write(0,*) 'wvel, cnuc, cn = ',wvel(mgs),cnuc(mgs),cn(mgs)
9192 write(0,*) 'ccne0,cnexp,cck = ',ccne0,cnexp,cck
9193 write(0,*) 'part1, part2 = ',CCNE0*cnuc(mgs)**(2./(2.+cck)), Max(0.0,wvel(mgs))**cnexp
9194 write(0,*) 'ccnc, dqc, dqc/cwmasn = ',ccnc(mgs), dqc, 0.5*dqc/cwmasn
9197 IF ( icnuclimit > 0 ) THEN
9198 tmp = ccnc(mgs) + cx(mgs,lc)
9199 IF ( tmp < 330.34e6 ) THEN
9200 ccwmax = 1.1173e6 * (1.e-6*tmp)**0.9504
9202 ccwmax = 21.57e6 * (1.e-6*tmp)**0.44
9205 ! IF ( cn(mgs) > 0. ) THEN
9206 ! write(0,*) 'cn,tmp,ccwmax,cx,c-cx = ',cn(mgs),tmp,ccwmax,cx(mgs,lc),ccwmax - cx(mgs,lc)
9209 cn(mgs) = Max( 0.0, Min( cn(mgs), ccwmax - cx(mgs,lc) ) )
9213 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
9215 ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
9217 ELSEIF ( irenuc == 5 ) THEN !} {
9219 ! modification of Phillips Donner Garner 2007
9220 ! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
9221 ! 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
9222 CN(mgs) = Min( cnuc(mgs), CCNE0*cnuc(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp )
9225 IF ( ccna(mgs) >= cnuc(mgs) ) THEN ! apply limit after all "base" CCN have been depleted
9226 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
9227 ltemq = Int( (temp1-163.15)/fqsat+1.5 )
9228 ltemq = Min( nqsat, Max(1,ltemq) )
9230 c1= pqs(mgs)*tabqvs(ltemq)
9232 ssf(mgs) = Max(0.0, 100.*((qv0(mgs) + qwvp(mgs))/c1 - 1.0) ) ! from "new" values
9238 CN(mgs) = Max( cn(mgs), cnuc(mgs)*Min(ssf2kmax, ssf(mgs)**cck) ) ! this allows cn(mgs) > cnuc(mgs)
9240 ! cn(mgs) = Min( cn(mgs), cnuc(mgs) )
9242 ! IF ( ccna(mgs) >= cnuc(mgs) ) THEN ! apply limit after all "base" CCN have been depleted
9243 CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
9246 CN(mgs) = Min( cn(mgs), cnuc(mgs) - ccna(mgs) ) ! no more than remaining "base" CCN
9248 ! Philips, Donner et al. 2007, but results in too much limitation of
9250 ! CN(mgs) = Min(cn(mgs), ccnc(mgs))
9251 ! cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
9253 dcloud = 1000.*dcrit**3*Pi/6.
9254 ! cn(mgs) = Min(cn(mgs), 0.5*dqc/dcloud) ! limit the nucleation mass to half of the condensation mass
9255 ! check new droplet size:
9256 ! tmp is number of droplets at diameter dcrit
9257 tmp = Max(0.0, rho0(mgs)*qx(mgs,lc)/dcloud - cx(mgs,lc)) ! (cx(mgs,lc) + cn(mgs))
9258 cn(mgs) = Min(tmp, cn(mgs) )
9261 IF ( cn(mgs) > 0.0 ) THEN
9262 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
9266 dcloud = 1000.*dcrit**3*Pi/6.*cn(mgs)
9267 qx(mgs,lc) = qx(mgs,lc) + DCLOUD
9268 thetap(mgs) = thetap(mgs) + felvcp(mgs)*DCLOUD/(pi0(mgs))
9269 qwvp(mgs) = qwvp(mgs) - DCLOUD
9271 ! 6/13/2016: Phillips et al. appears not to decrement CCN, but only increments CCNa.
9272 ! This would allow an initially non-homogeneous (vertically, e.g.) initial value of CCN/rho_air
9273 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
9274 ELSEIF ( irenuc == 7 ) THEN !} {
9276 ! simple Twomey scheme but limit activation to try to do most activation near cloud base, but keep some CCN available for renuclation
9277 ! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
9279 ! 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
9280 IF ( ccna(mgs) < 0.9*cnuc(mgs) ) THEN ! { here, assume we are near cloud base and use Twomey formulation
9281 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
9282 ! IF ( cn(mgs) + ccna(mgs) > 0.71*cnuc ) THEN
9283 ! prevent this branch from activating more than 70% of CCN
9284 CN(mgs) = Min( CN(mgs), Max(0.0, (0.9*cnuc(mgs) - ccna(mgs) )) )
9285 ! CN(mgs) = Min( CN(mgs), Max(0.0, 0.71*ccnc(mgs) - ccna(mgs) ) )
9286 ! write(0,*) '1: k,cn = ',kgs(mgs),cn(mgs),ssf(mgs)
9287 !! IF ( ccncuf(mgs) > 0.0 .and. cn(mgs) < 1.e-3 .and. ssmax(mgs) > 1.0 ) THEN
9288 ! IF ( ccncuf(mgs) > 0.0 .and. ssf(mgs) > ssmxuf .and. ssmax(mgs) > ssmxuf ) THEN
9289 ! CNuf(mgs) = Min( ccncuf(mgs), CCNE0*ccncuf(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp )! *Min(1.0,1./dtp) ! 0.3465
9290 ! IF ( cnuf(mgs) >= 0.0 ) write(0,*) '1: cnuf, k = ',cnuf(mgs),ccncuf(mgs),kgs(mgs)
9295 ! 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.
9297 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
9298 ! t0(ix,jy,kz) = temp1
9299 ltemq = Int( (temp1-163.15)/fqsat+1.5 )
9300 ltemq = Min( nqsat, Max(1,ltemq) )
9302 ! c1 = t00(igs(mgs),jy,kgs(mgs))*tabqvs(ltemq)
9303 c1= pqs(mgs)*tabqvs(ltemq)
9307 ssf(mgs) = 100.*(qx(mgs,lv)/c1 - 1.0) ! from "new" values
9310 ! IF ( ssf(mgs) <= 1.0 .or. cnuc(mgs) > ccna(mgs) ) THEN
9311 IF ( ssf(mgs) <= 1.0 ) THEN
9312 CN(mgs) = cnuc(mgs)*Min(1.0, Max(0.0,ssf(mgs))**cck ) !
9314 CN(mgs) = cnuc(mgs)*Min(2.0, Max(0.0,0.03*(ssf(mgs)-1.0)+1.)**cck ) !
9315 ! write(0,*) 'iren7: ssf,ssmx = ',ssf(mgs),ssmax(mgs),cn(mgs),ccna(mgs),cnuc(mgs)
9316 ! write(0,*) 'c1,qv = ',c1,qx(mgs,lv),temp1,ltemq
9319 ! write(0,*) 'k,cn = ',kgs(mgs),cn(mgs),ssf(mgs)
9320 ! write(0,*) 'ccn-ccna = ',cnuc(mgs) - ccna(mgs),ccnc(mgs) - ccna(mgs)
9321 ! IF ( ccncuf(mgs) > 0.0 .and. cn(mgs) < 1.e-3 .and. ssmax(mgs) > 1.0 ) THEN
9322 IF ( ccncuf(mgs) > 0.0 .and. ssf(mgs) > ssmxuf .and. ssmax(mgs) > ssmxuf ) THEN
9323 CNuf(mgs) = Min( ccncuf(mgs), CCNE0*ccncuf(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp )! *Min(1.0,1./dtp) ! 0.3465
9324 ! IF ( cnuf(mgs) >= 0.0 ) write(0,*) 'cnuf, k = ',cnuf(mgs),ccncuf(mgs),kgs(mgs)
9328 ! CN(mgs) = Min( Min(0.1,ssf(mgs)-1.)*cnuc(mgs), Max( 0.0, CN(mgs) - ccna(mgs) ) ) ! this was from
9329 ! 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
9331 CN(mgs) = Min(0.01*cnuc(mgs), Max( 0.0, CN(mgs) - ccna(mgs) ) ) ! this was from
9334 ! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
9335 !!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
9336 ! Philips, Donner et al. 2007, but results in too much limitation of
9338 ! CN(mgs) = Min(cn(mgs), ccnc(mgs))
9339 ! cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
9342 IF ( icnuclimit > 0 ) THEN
9343 ! max droplet conc. based on Chandrakar et al. (2016) and Konwar et al. (2012)
9344 tmp = ccnc(mgs) - ccna(mgs) + cx(mgs,lc)
9345 IF ( tmp < 330.34e6 ) THEN
9346 ccwmax = 1.1173e6 * (1.e-6*tmp)**0.9504
9348 ccwmax = 21.57e6 * (1.e-6*tmp)**0.44
9351 cn(mgs) = Max( 0.0, Min( cn(mgs), ccwmax - cx(mgs,lc) ) )
9355 IF ( cn(mgs) + cnuf(mgs) > 0.0 ) THEN
9358 dcloud = 1000.*dcrit**3*Pi/6.
9359 ! cn(mgs) = Min(cn(mgs), 0.5*dqc/dcloud) ! limit the nucleation mass to half of the condensation mass
9360 ! check new droplet size:
9361 ! tmp is number of droplets at diameter dcrit
9362 tmp = Max(0.0, rho0(mgs)*qx(mgs,lc)/dcloud - cx(mgs,lc)) ! (cx(mgs,lc) + cn(mgs))
9363 cn(mgs) = Min(tmp, cn(mgs) )
9365 cx(mgs,lc) = cx(mgs,lc) + cn(mgs) + cnuf(mgs)
9368 ! create some small droplets at minimum size (CP 2000), although it adds very little liquid
9372 dcloud = 1000.*dcrit**3*Pi/6.*(cn(mgs) + cnuf(mgs) )
9373 qx(mgs,lc) = qx(mgs,lc) + DCLOUD
9374 thetap(mgs) = thetap(mgs) + felvcp(mgs)*DCLOUD/(pi0(mgs))
9375 qwvp(mgs) = qwvp(mgs) - DCLOUD
9376 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
9377 ccncuf(mgs) = Max(0.0, ccncuf(mgs) - cnuf(mgs))
9380 ELSEIF ( irenuc == 8 ) THEN !} {
9381 ! simple Twomey scheme
9382 ! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
9386 IF ( ccnc(mgs) > 0. ) THEN
9387 CN(mgs) = CCNE0*ccnc(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp ! *Min(1.0,1./dtp) ! 0.3465
9388 ! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
9389 !!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
9390 ! Philips, Donner et al. 2007, but results in too much limitation of
9392 CN(mgs) = Min(cn(mgs), ccnc(mgs))
9394 ELSEIF ( cx(mgs,lc) < 0.01e9 ) THEN
9396 ! 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.
9398 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
9399 ! t0(ix,jy,kz) = temp1
9400 ltemq = Int( (temp1-163.15)/fqsat+1.5 )
9401 ltemq = Min( nqsat, Max(1,ltemq) )
9403 ! c1 = t00(igs(mgs),jy,kgs(mgs))*tabqvs(ltemq)
9404 c1= pqs(mgs)*tabqvs(ltemq)
9408 ssf(mgs) = 100.*(qx(mgs,lv)/c1 - 1.0) ! from "new" values
9411 ! IF ( ssf(mgs) <= 1.0 .or. cnuc(mgs) > ccna(mgs) ) THEN
9412 IF ( ssf(mgs) <= 1.0 ) THEN
9415 ! CN(mgs) = 0.01e9*rho0(mgs)/rho00*Min(2.0, Max(0.0,0.03*(ssf(mgs)-1.0)+1.)**cck ) - cx(mgs,lc) !
9416 CN(mgs) = 0.01e9*Min(2.0, Max(0.0,0.03*(ssf(mgs)-1.0)+1.)**cck ) - cx(mgs,lc) !
9421 IF ( cn(mgs) > 0.0 ) THEN
9422 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
9424 ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
9426 ! create some small droplets at minimum size (CP 2000), although it adds very little liquid
9430 dcloud = 1000.*dcrit**3*Pi/6.*cn(mgs)
9431 qx(mgs,lc) = qx(mgs,lc) + DCLOUD
9432 thetap(mgs) = thetap(mgs) + felvcp(mgs)*DCLOUD/(pi0(mgs))
9433 qwvp(mgs) = qwvp(mgs) - DCLOUD
9434 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
9441 ccna(mgs) = ccna(mgs) + cn(mgs)
9445 ENDIF ! irenuc >= 0 .and. .not. flag_qndrop
9447 IF( cx(mgs,lc) .GT. 0. .AND. qx(mgs,lc) .LE. qxmin(lc)) cx(mgs,lc)=0.
9449 !.... NUCLEATION ON CLOUD INFLOW BOUNDARY POINT
9456 ! Check for supersaturation greater than ssmx and adjust down
9459 qv1 = qv0(mgs) + qwvp(mgs)
9462 ! IF ( flag_qndrop .and. do_satadj_for_wrfchem ) ssmx = 1.04 ! set lower threshold for progn=1 when using WRF-CHEM
9464 IF ( qv1 .gt. (ssmx*qvs1) ) THEN
9465 ! use line below to disable saturation adjustment when flag_qndrop is true
9466 ! IF ( qv1 .gt. (ssmx*qvs1) .and. .not. flag_qndrop ) THEN
9470 ssmx = 100.*(ssmx - 1.0)
9474 CALL QVEXCESS(ngs,mgs,qwvp,qv0,qx(1,lc),pres,thetap,theta0,qvex, &
9475 & pi0,tabqvs,nqsat,fqsat,cbw,fcqv1,felvcp,ssmx,pk,ngscnt)
9479 IF ( qvex .gt. 0.0 ) THEN
9480 thetap(mgs) = thetap(mgs) + felvcp(mgs)*qvex/(pi0(mgs))
9481 IF ( io_flag .and. nxtra > 1 ) THEN
9482 axtra(igs(mgs),jy,kgs(mgs),1) = axtra(igs(mgs),jy,kgs(mgs),1) + qvex/dtp
9484 qwvp(mgs) = qwvp(mgs) - qvex
9485 qx(mgs,lc) = qx(mgs,lc) + qvex
9486 IF ( .not. flag_qndrop) THEN
9487 IF ( imaxsupopt == 1 ) THEN
9488 cn(mgs) = Min( Max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/Max( cwmasn5, xmas(mgs,lc) ) )
9489 ELSEIF ( imaxsupopt == 2 ) THEN
9490 cn(mgs) = Min( Max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/Max( cwmasn5, Max(cwmas30,xmas(mgs,lc)) ) )
9491 ELSEIF ( imaxsupopt == 3 ) THEN
9492 cn(mgs) = Min( Max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/Max( cwmasn5, Max(cwmasx,xmas(mgs,lc)) ) )
9493 ! cn(mgs) = 1.5*cxmin
9494 ELSEIF ( imaxsupopt == 4 ) THEN
9495 cn(mgs) = Min( Max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/Max( cwmasn5, Max(cwmas20,xmas(mgs,lc)) ) )
9497 ccnc(mgs) = Max( 0.0, ccnc(mgs) - cn(mgs) )
9498 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
9501 ! write(iunit,*) 'theta = ',theta0(mgs) + thetap(mgs)
9503 ! temg(mgs) = theta(mgs)*( pres(mgs) / poo ) ** cap
9511 ! Calculate droplet volume and check if it is within bounds.
9512 ! Adjust if necessary
9514 ! if (ndebug .gt. 0) write(0,*) "ICEZVD_DR: check droplet volume"
9517 ! cx(mgs,lc) = Min( cwnccn(mgs), cx(mgs,lc) )
9518 IF( cx(mgs,lc) > cxmin .AND. qx(mgs,lc) .GT. qxmin(lc)) THEN
9519 ! SVC(mgs) = rho0(mgs)*qx(mgs,lc)/(cx(mgs,lc)*xdn(mgs,lc))
9520 xmas(mgs,lc) = rho0(mgs)*qx(mgs,lc)/(cx(mgs,lc))
9522 IF ( xmas(mgs,lc) < cwmasn .or. xmas(mgs,lc) > cwmasx ) THEN
9524 xmas(mgs,lc) = Min( xmas(mgs,lc), cwmasx )
9525 xmas(mgs,lc) = Max( xmas(mgs,lc), cwmasn )
9526 cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc)
9527 ! IF ( cx(mgs,lc) > tmp*1.1 ) THEN
9528 ! write(0,*) 'nucond: kgs, ccw1,2 = ',kgs(mgs),tmp,cx(mgs,lc)
9534 ! IF( cx(mgs,lc) .GT. 10.e6 .AND. qx(mgs,lc) .GT. qxmin(lc) ) GO TO 681
9535 ! ccwtmp = cx(mgs,lc)
9536 ! cwmastmp = xmas(mgs,lc)
9537 ! xmas(mgs,lc) = Max(xmas(mgs,lc), cwmasn)
9538 ! IF (qx(mgs,lc) .GT. qxmin(lc) .AND. cx(mgs,lc) .le. 0.) THEN
9539 ! cx(mgs,lc) = Min(0.5*cwccn,rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc))
9540 ! xmas(mgs,lc) = rho0(mgs)*qx(mgs,lc)/cx(mgs,lc)
9542 ! IF (cx(mgs,lc) .GT. 0. .AND. qx(mgs,lc) .GT. qxmin(lc)) &
9543 ! & xmas(mgs,lc) = rho0(mgs)*qx(mgs,lc)/cx(mgs,lc)
9544 ! IF (qx(mgs,lc) .GT. qxmin(lc) .AND. xmas(mgs,lc) .LT. cwmasn) &
9545 ! & xmas(mgs,lc) = cwmasn
9546 ! IF (qx(mgs,lc) .GT. qxmin(lc) .AND. xmas(mgs,lc) .GT. cwmasx) &
9547 ! & xmas(mgs,lc) = cwmasx
9548 ! IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN
9549 ! cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/Max(cwmasn,xmas(mgs,lc))
9556 IF ( ipconc .ge. 3 .and. rcond == 2 ) THEN
9559 IF (cx(mgs,lr) .GT. 0. .AND. qx(mgs,lr) .GT. qxmin(lr)) &
9560 & xv(mgs,lr)=rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr))
9561 IF (xv(mgs,lr) .GT. xvmx(lr)) xv(mgs,lr) = xvmx(lr)
9562 IF (xv(mgs,lr) .LT. xvmn(lr)) xv(mgs,lr) = xvmn(lr)
9571 ! ################################################################
9573 IF ( lss > 1 .and. ssf(mgs) .gt. ssmax(mgs) &
9574 & .and. ( idecss .eq. 0 .or. qx(mgs,lc) .gt. qxmin(lc)) ) THEN
9575 ssmax(mgs) = ssf(mgs)
9581 an(igs(mgs),jy,kgs(mgs),lt) = theta0(mgs) + thetap(mgs)
9582 an(igs(mgs),jy,kgs(mgs),lv) = qv0(mgs) + qwvp(mgs)
9583 ! 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)
9585 IF ( eqtset > 2 ) THEN
9586 p2(igs(mgs),jy,kgs(mgs)) = pipert(mgs)
9589 if ( ido(lc) .eq. 1 ) then
9590 an(igs(mgs),jy,kgs(mgs),lc) = qx(mgs,lc) + &
9591 & min( an(igs(mgs),jy,kgs(mgs),lc), 0.0 )
9592 ! qx(mgs,lc) = an(igs(mgs),jy,kgs(mgs),lc)
9596 if ( ido(lr) .eq. 1 .and. rcond == 2 ) then
9597 an(igs(mgs),jy,kgs(mgs),lr) = qx(mgs,lr) + &
9598 & min( an(igs(mgs),jy,kgs(mgs),lr), 0.0 )
9599 ! qx(mgs,lr) = an(igs(mgs),jy,kgs(mgs),lr)
9604 IF ( ipconc .ge. 2 ) THEN
9605 an(igs(mgs),jy,kgs(mgs),lnc) = Max(cx(mgs,lc) , 0.0)
9606 IF ( lss > 1 ) an(igs(mgs),jy,kgs(mgs),lss) = Max( 0.0, ssmax(mgs) )
9607 IF ( lccn .gt. 1 ) THEN
9608 an(igs(mgs),jy,kgs(mgs),lccn) = Max(0.0, ccnc(mgs) )
9610 IF ( lccnuf .gt. 1 ) THEN
9611 an(igs(mgs),jy,kgs(mgs),lccnuf) = Max(0.0, ccncuf(mgs) )
9613 IF ( lccna .gt. 1 ) THEN
9614 an(igs(mgs),jy,kgs(mgs),lccna) = Max(0.0, ccna(mgs) )
9617 IF ( ipconc .ge. 3 .and. rcond == 2 ) THEN
9618 an(igs(mgs),jy,kgs(mgs),lnr) = Max(cx(mgs,lr) , 0.0)
9626 if ( kz .gt. nz-1 .and. ix .ge. nxi) then
9627 if ( ix .ge. nxi ) then
9628 go to 2200 ! exit gather scatter
9636 if ( ix .ge. nxi ) then
9643 2000 continue ! inumgs
9646 ! end of gather scatter (for this jy slice)
9653 ! Redistribute inappreciable cloud particles and charge
9655 ! Redistribution everywhere in the domain...
9659 frac = 1.0 ! 0.25 ! 1.0 ! 0.2
9661 ! alternate test version for ipconc .ge. 3
9662 ! just vaporize stuff to prevent noise in the number concentrations
9669 t0(ix,jy,kz) = an(ix,jy,kz,lt)*t77(ix,jy,kz)
9673 IF ( iresetmoments == 1 .or. iresetmoments == il ) THEN
9674 IF ( ln(il) > 1 ) zerocx(il) = ( an(ix,jy,kz,ln(il)) < cxmin )
9675 IF ( lz(il) > 1 ) zerocx(il) = ( zerocx(il) .or. an(ix,jy,kz,lz(il)) < zxmin )
9677 IF ( il == lc ) THEN
9678 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)
9680 IF ( ln(il) > 1 ) zerocx(il) = ( an(ix,jy,kz,ln(il)) <= 0 )
9685 IF ( lhl .gt. 1 ) THEN
9688 if ( an(ix,jy,kz,lhl) .lt. frac*qxmin(lhl) .or. zerocx(lhl) ) then
9690 ! IF ( an(ix,jy,kz,lhl) .gt. 0 ) THEN
9691 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lhl)
9692 an(ix,jy,kz,lhl) = 0.0
9695 IF ( ipconc .ge. 5 ) THEN ! .and. an(ix,jy,kz,lnh) .gt. 0.0 ) THEN
9696 an(ix,jy,kz,lnhl) = 0.0
9699 IF ( lvhl .gt. 1 ) THEN
9700 an(ix,jy,kz,lvhl) = 0.0
9703 IF ( lhlw .gt. 1 ) THEN
9704 an(ix,jy,kz,lhlw) = 0.0
9707 IF ( lzhl .gt. 1 ) THEN
9708 an(ix,jy,kz,lzhl) = 0.0
9712 IF ( lvol(lhl) .gt. 1 ) THEN ! check density
9713 IF ( an(ix,jy,kz,lvhl) .gt. 0.0 ) THEN
9714 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
9715 ELSE ! in case volume is zero but mass is above threshold (should not happen, of course)
9717 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
9720 IF ( tmp .lt. xdnmn(lhl) ) THEN
9721 tmp = Max( xdnmn(lhl), tmp )
9722 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
9725 IF ( tmp .gt. xdnmx(lhl) .and. lhlw .le. 0 ) THEN ! no liquid allowed on hail
9726 tmp = Min( xdnmx(lhl), tmp )
9727 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
9728 ELSEIF ( tmp .gt. xdnmx(lhl) .and. lhlw .gt. 1 ) THEN ! allow for liquid on hail
9729 fw = an(ix,jy,kz,lhlw)/an(ix,jy,kz,lhl)
9730 ! tmpmx = xdnmx(lhl) + fw*(xdnmx(lr) - xdnmx(lhl)) ! maximum possible average density
9731 ! it is not exactly linear, but approx. is close enough for this
9732 ! tmpmx = 1./( (1. - fw)/900. + fw/1000. ) is exact max, where 900 is xdnmx
9734 tmpmx = xdnmx(lhl)/( 1. - fw*(1. - xdnmx(lhl)/xdnmx(lr) ))
9736 IF ( tmp .gt. tmpmx ) THEN
9737 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmpmx
9740 ! IF ( tmp .gt. xdnmx(lhl) .and. an(ix,jy,kz,lhlw) .lt. qxmin(lhl) ) THEN
9741 ! tmp = Min( xdnmx(lhl), tmp )
9742 ! an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
9743 ! ELSEIF ( tmp .gt. xdnmx(lr) ) THEN
9745 ! an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
9749 IF ( lhlw .gt. 1 ) THEN ! check if basically pure water
9750 IF ( an(ix,jy,kz,lhlw) .gt. 0.98*an(ix,jy,kz,lhl) ) THEN
9752 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
9760 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
9762 IF ( lvhl .gt. 1 ) THEN
9763 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
9767 tmp = (hwdn*an(ix,jy,kz,lnhl))/(dn(ix,jy,kz)*an(ix,jy,kz,lhl))
9768 tmpg = an(ix,jy,kz,lnhl)*(tmp*(3.14159))**(1./3.)
9769 IF ( tmpg .lt. cnohlmn ) THEN
9770 tmp = ( (hwdn)/(dn(ix,jy,kz)*an(ix,jy,kz,lhl))*(3.14159))**(1./3.)
9771 an(ix,jy,kz,lnhl) = (cnohlmn/tmp)**(3./4.)
9775 ! ELSE ! check mean size here?
9784 if ( an(ix,jy,kz,lh) .lt. frac*qxmin(lh) .or. zerocx(lh) ) then
9786 ! IF ( an(ix,jy,kz,lh) .gt. 0 ) THEN
9787 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lh)
9788 an(ix,jy,kz,lh) = 0.0
9791 IF ( ipconc .ge. 5 ) THEN ! .and. an(ix,jy,kz,lnh) .gt. 0.0 ) THEN
9792 an(ix,jy,kz,lnh) = 0.0
9795 IF ( lvh .gt. 1 ) THEN
9796 an(ix,jy,kz,lvh) = 0.0
9799 IF ( lhw .gt. 1 ) THEN
9800 an(ix,jy,kz,lhw) = 0.0
9803 IF ( lzh .gt. 1 ) THEN
9804 an(ix,jy,kz,lzh) = 0.0
9808 IF ( lvol(lh) .gt. 1 ) THEN ! check density
9809 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
9810 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
9813 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
9816 IF ( tmp .lt. xdnmn(lh) ) THEN
9817 tmp = Max( xdnmn(lh), tmp )
9818 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
9821 IF ( tmp .gt. xdnmx(lh) .and. lhw .le. 0 ) THEN ! no liquid allowed on graupel
9822 tmp = Min( xdnmx(lh), tmp )
9823 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
9824 ELSEIF ( tmp .gt. xdnmx(lh) .and. lhw .gt. 1 ) THEN ! allow for liquid on graupel
9825 fw = an(ix,jy,kz,lhw)/an(ix,jy,kz,lh)
9826 ! tmpmx = xdnmx(lh) + fw*(xdnmx(lr) - xdnmx(lh)) ! maximum possible average density
9827 ! it is not exactly linear, but approx. is close enough for this
9828 ! tmpmx = 1./( (1. - fw)/900. + fw/1000. ) is exact max, where 900 is xdnmx
9829 tmpmx = xdnmx(lh)/( 1. - fw*(1. - xdnmx(lh)/xdnmx(lr) ))
9831 IF ( tmp .gt. tmpmx ) THEN
9832 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmpmx
9835 ! IF ( tmp .gt. xdnmx(lh) .and. an(ix,jy,kz,lhw) .lt. qxmin(lh) ) THEN
9836 ! tmp = Min( xdnmx(lh), tmp )
9837 ! an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
9838 ! ELSEIF ( tmp .gt. xdnmx(lr) ) THEN
9840 ! an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
9845 IF ( lhw .gt. 1 ) THEN ! check if basically pure water
9846 IF ( an(ix,jy,kz,lhw) .gt. 0.98*an(ix,jy,kz,lh) ) THEN
9848 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
9855 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
9857 IF ( lvh .gt. 1 ) THEN
9858 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
9859 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
9863 hwdn = Max( xdnmn(lh), hwdn )
9867 tmp = (hwdn*an(ix,jy,kz,lnh))/(dn(ix,jy,kz)*an(ix,jy,kz,lh))
9868 tmpg = an(ix,jy,kz,lnh)*(tmp*(3.14159))**(1./3.)
9869 IF ( tmpg .lt. cnohmn ) THEN
9870 ! 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.)
9871 ! tmpg = an(ix,jy,kz,lnh)**(4./3.)*( (hwdn)/(dn(ix,jy,kz)*an(ix,jy,kz,lh))*(3.14159))**(1./3.)
9872 tmp = ( (hwdn)/(dn(ix,jy,kz)*an(ix,jy,kz,lh))*(3.14159))**(1./3.)
9873 an(ix,jy,kz,lnh) = (cnohmn/tmp)**(3./4.)
9881 if ( an(ix,jy,kz,ls) .lt. frac*qxmin(ls) .or. zerocx(ls) & ! .or. an(ix,jy,kz,lns) .lt. 0.1 ! .and.
9883 IF ( t0(ix,jy,kz) .lt. 273.15 ) THEN
9884 ! IF ( an(ix,jy,kz,ls) .gt. 0 ) THEN
9885 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,ls)
9886 an(ix,jy,kz,ls) = 0.0
9889 IF ( ipconc .ge. 4 ) THEN ! .and. an(ix,jy,kz,lns) .gt. 0.0 ) THEN !
9890 ! an(ix,jy,kz,lni) = an(ix,jy,kz,lni) + an(ix,jy,kz,lns)
9891 an(ix,jy,kz,lns) = 0.0
9894 IF ( lvs .gt. 1 ) THEN
9895 an(ix,jy,kz,lvs) = 0.0
9898 IF ( lsw .gt. 1 ) THEN
9899 an(ix,jy,kz,lsw) = 0.0
9903 ! IF ( an(ix,jy,kz,ls) .gt. 0 ) THEN
9904 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,ls)
9905 an(ix,jy,kz,ls) = 0.0
9908 IF ( lvs .gt. 1 ) THEN
9909 an(ix,jy,kz,lvs) = 0.0
9912 IF ( lsw .gt. 1 ) THEN
9913 an(ix,jy,kz,lsw) = 0.0
9916 IF ( ipconc .ge. 4 ) THEN ! .and. an(ix,jy,kz,lns) .gt. 0.0 ) THEN !
9917 ! an(ix,jy,kz,lnr) = an(ix,jy,kz,lnr) + an(ix,jy,kz,lns)
9918 an(ix,jy,kz,lns) = 0.0
9924 ELSEIF ( lvol(ls) .gt. 1 ) THEN ! check density
9925 IF ( an(ix,jy,kz,lvs) .gt. 0.0 ) THEN
9926 tmp = dn(ix,jy,kz)*an(ix,jy,kz,ls)/an(ix,jy,kz,lvs)
9927 IF ( tmp .gt. xdnmx(ls) .or. tmp .lt. xdnmn(ls) ) THEN
9928 tmp = Min( xdnmx(ls), Max( xdnmn(ls), tmp ) )
9929 an(ix,jy,kz,lvs) = dn(ix,jy,kz)*an(ix,jy,kz,ls)/tmp
9933 an(ix,jy,kz,lvs) = dn(ix,jy,kz)*an(ix,jy,kz,ls)/tmp
9940 if ( an(ix,jy,kz,lr) .lt. frac*qxmin(lr) .or. zerocx(lr) &
9942 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lr)
9943 an(ix,jy,kz,lr) = 0.0
9944 IF ( ipconc .ge. 3 ) THEN
9945 ! an(ix,jy,kz,lnc) = an(ix,jy,kz,lnc) + an(ix,jy,kz,lnr)
9946 an(ix,jy,kz,lnr) = 0.0
9954 IF ( an(ix,jy,kz,li) .le. frac*qxmin(li) .or. zerocx(li) & ! .or. an(ix,jy,kz,lni) .lt. 0.1
9956 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,li)
9957 an(ix,jy,kz,li)= 0.0
9958 IF ( ipconc .ge. 1 ) THEN
9959 an(ix,jy,kz,lni) = 0.0
9966 IF ( lis > 1 ) THEN ! {
9967 IF ( an(ix,jy,kz,lis) .le. frac*qxmin(lis) .or. zerocx(lis) & ! .or. an(ix,jy,kz,lni) .lt. 0.1
9969 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lis)
9970 an(ix,jy,kz,lis)= 0.0
9971 IF ( ipconc .ge. 1 ) THEN
9972 an(ix,jy,kz,lnis) = 0.0
9975 ELSEIF ( icespheres >= 2 ) THEN ! } {
9977 IF ( 0.5*( w(ix,jy,kz) + w(ix,jy,kz+1)) < -1.0 .or. &
9978 & (icespheres == 3 .and. ( t0(ix,jy,kz) < 232.15 .or. an(ix,jy,kz,lc) < qxmin(lc) ) ) .or. &
9979 & (icespheres == 5 .and. ( t0(ix,jy,kz) < 232.15 .or. &
9980 & ( an(ix,jy,kz,lc) < qxmin(lc) .and. an(ix,jy,km1,lc) < qxmin(lc) )) ) .or. &
9981 & (icespheres == 4 .and. ( t0(ix,jy,kz) < 235.15 )) ) THEN ! transfer to regular ice crystals in downdraft or at low temp
9982 an(ix,jy,kz,li) = an(ix,jy,kz,li) + an(ix,jy,kz,lis)
9983 an(ix,jy,kz,lni) = an(ix,jy,kz,lni) + an(ix,jy,kz,lnis)
9984 an(ix,jy,kz,lis)= 0.0
9985 an(ix,jy,kz,lnis)= 0.0
9996 IF ( an(ix,jy,kz,lc) .le. frac*qxmin(lc) .or. zerocx(lc) &
9998 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lc)
9999 an(ix,jy,kz,lc)= 0.0
10000 IF ( ipconc .ge. 2 ) THEN
10001 IF ( lccn .gt. 1 ) THEN
10002 an(ix,jy,kz,lccn) = &
10003 & an(ix,jy,kz,lccn) + Max(0.0,an(ix,jy,kz,lnc))
10005 an(ix,jy,kz,lnc) = 0.0
10007 IF ( lccna > 0 ) THEN ! apply exponential decay to activated CCN to restore to environmental value
10008 tmp = an(ix,jy,kz,li) + an(ix,jy,kz,ls)
10010 IF ( an(ix,jy,kz,lccna) > 1. .and. tmp < qxmin(li) ) an(ix,jy,kz,lccna) = an(ix,jy,kz,lccna)*Exp(-dtp/ccntimeconst)
10012 ELSEIF ( lccn > 1 .and. restoreccn ) THEN
10013 ! in this case, we are treating the ccn field as ccna
10014 tmp = an(ix,jy,kz,li) + an(ix,jy,kz,ls)
10015 ! IF ( ny == 2 .and. ix == nx/2 ) THEN
10016 ! write(0,*) 'restore: k, qccn,exp = ',kz,qccn,dn(ix,jy,kz)*qccn,Exp(-dtp/ccntimeconst)
10017 ! 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)
10019 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
10020 ! an(ix,jy,kz,lccn) = &
10021 ! an(ix,jy,kz,lccn) + Max(0.0 , dn(ix,jy,kz)*qccn - an(ix,jy,kz,lccn))*(1.0 - Exp(-dtp/ccntimeconst))
10022 ! Equivalent form after expanding last term:
10023 an(ix,jy,kz,lccn) = &
10024 dn(ix,jy,kz)*qccn - Max(0.0 , dn(ix,jy,kz)*qccn - an(ix,jy,kz,lccn))*Exp(-dtp/ccntimeconst)
10039 IF ( ndebug .ge. 1 ) write(6,*) 'END OF ICEZVD_DR'
10046 END SUBROUTINE NUCOND
10049 ! #####################################################################
10050 ! #####################################################################
10055 !c--------------------------------------------------------------------------
10058 !--------------------------------------------------------------------------
10061 subroutine nssl_2mom_gs &
10062 & (nx,ny,nz,na,jyslab &
10065 & ,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9 &
10069 & ventr,ventc,c1sw,jgs,ido, &
10071 ! & ln,ipc,lvol,lz,lliq, &
10073 & xdn0,tmp3d,tkediss &
10074 & ,timevtcalc,axtra,io_flag &
10075 & , has_wetscav,rainprod2d, evapprod2d &
10076 & ,elec,its,ids,ide,jds,jde &
10081 !--------------------------------------------------------------------------
10083 ! Ziegler 1985 parameterized microphysics (also Zrnic et al. 1993)
10090 !--------------------------------------------------------------------------
10094 ! 4/27/2009: allows for liquid water to be advected on snow and graupel particles using flag "mixedphase"
10096 ! 3/14/2007: (APS) added qproc temp to make microphysic process timeseries
10098 ! 10/17/2006: added flag (iehw) to select how to calculate ehw
10100 ! 10/5/2006: switched chacr to integrated version rather than assuming that average rain
10101 ! drop mass does not change. This acts to reduce rain size somewhat via graupel
10103 ! Use Mason data for ehw, with scaling toward ehw=1 as air density decreases.
10105 ! 10/3/2006: Turned off Meyers nucleation for T > -5 (can turn on with imeyers5 flag)
10106 ! Turned off contact nucleation in updrafts
10108 ! 7/24/2006: Turned on Meyers nucleation for -5 < T < 0
10110 ! 5/12/2006: Converted qsacw/csacw and qsaci/csaci to Z93
10112 ! 5/12/2006: Put a threshold on Bigg rain freezing. If the frozen drops
10113 ! have an average volume less than xvhmn, then the drops are put
10114 ! into snow instead of graupel/hail.
10116 ! Fixed bug when vapor deposition was limited.
10118 ! 5/13/2006: Note that qhacr has a large effect, but Z85 did not include it.
10119 ! Turned off qsacr (set to zero).
10121 ! 9/14/2007: erm: recalculate vx(lh) after setting xdn(lh) in case xdn was out of allowed range.
10122 ! added parameter rimc3 for minimum rime density. Default value set at 170. kg/m**3
10123 ! instead of previous use of 100. (Farley, 1987)
10125 !--------------------------------------------------------------------------
10127 ! general declarations
10129 !--------------------------------------------------------------------------
10138 ! parameter ( icond = 2 )
10140 integer, parameter :: ng1 = 1
10142 integer nx,ny,nz,na,nba,nv
10143 integer nor,norz,istag,jstag,kstag ! ,nht,ngt,igsr
10147 logical, intent(in) :: io_flag
10149 integer itile,jtile,ktile
10150 integer ixbeg,jybeg
10151 integer ixend,jyend,kzend,kzbeg
10152 integer nxend,nyend,nzend,nzbeg
10153 integer :: my_rank = 0
10154 integer, parameter :: myprock = 1, nprock = 1
10155 logical, intent(in) :: has_wetscav
10156 real rainprod2d(-nor+1:nx+nor,-norz+ng1:nz+norz)
10157 real evapprod2d(-nor+1:nx+nor,-norz+ng1:nz+norz)
10159 real tkediss(-nor+1:nx+nor,-norz+ng1:nz+norz)
10160 real axtra(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz,nxtra)
10165 integer jyslab,its,ids,ide,jds,jde ! domain boundaries
10166 integer, intent(in) :: iunit !,iunit0
10168 integer iraincv, icgxconv
10169 parameter ( iraincv = 1, icgxconv = 1)
10171 real :: ffrzh = 1.0
10173 real qcitmp,cirdiatmp ! ,qiptmp,qirtmp
10174 real ccwtmp,ccitmp ! ,ciptmp,cirtmp
10175 real cpqc,cpci ! ,cpip,cpir
10176 real cpqc0,cpci0 ! ,cpip0,cpir0
10177 real scfac ! ,cpip1
10179 double precision dp1
10181 double precision frac, frach, xvfrz, xvbiggsnow
10183 double precision :: timevtcalc
10184 double precision :: dpt1,dpt2
10186 logical, parameter :: gammacheck = .false.
10188 double precision :: tmpgam
10189 logical, parameter :: usegamxinfcnu = .false.
10190 logical, parameter :: usegamxinf = .false.
10191 logical, parameter :: usegamxinf2 = .false.
10192 logical, parameter :: usegamxinf3 = .false.
10193 ! real rar ! rime accretion rate as calculated from qxacw
10196 ! a few vars for time-split fallout
10200 double precision chgneg,chgpos,sctot
10204 real pb(-norz+ng1:nz+norz)
10205 real pinit(-norz+ng1:nz+norz)
10207 real gz(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz) ! dz
10209 real qimax,xni0,roqi0
10215 integer itest,nidx,id1,jd1,kd1
10216 parameter (itest=1)
10217 parameter (nidx=10)
10218 parameter (id1=1,jd1=1,kd1=1)
10222 integer ix,kz, il, ic, ir, icp1, irp1, ip1,jp1,kp1
10226 real slope1, slope2
10229 parameter (eps=1.e-20,eps2=1.e-5)
10236 logical ldovol, ishail, ltest, wtest
10237 logical , parameter :: alp0flag = .false.
10243 parameter (mu=1,mv=2,mw=3)
10245 ! conversion parameters
10247 integer mqcw,mqxw,mtem,mrho,mtim
10248 parameter (mqcw=21,mqxw=21,mtem=21,mrho=5,mtim=6)
10250 real xftim,xftimi,yftim, xftem,yftem, xfqcw,yfqcw, xfqxw,yfqxw
10251 parameter (xftim=0.05,xftimi = 1./xftim,yftim=1.)
10252 parameter (xftem=0.5,yftem=1.)
10253 parameter (xfqcw=2000.,yfqcw=1.)
10254 parameter (xfqxw=2000.,yfqxw=1.)
10256 parameter ( dtfac = 1.0 )
10257 integer ido(lc:lqmx)
10259 ! integer iexy(lc:lqmx,lc:lqmx)
10260 ! integer ieswi, ieswir, ieswip, ieswc, ieswr
10261 ! integer ieglsw, iegli, ieglir, ieglip, ieglc, ieglr
10262 ! integer iegmsw, iegmi, iegmir, iegmip, iegmc, iegmr
10263 ! integer ieghsw, ieghi, ieghir, ieghip, ieghc, ieghr
10264 ! integer iefwsw, iefwi, iefwir, iefwip, iefwc, iefwr
10265 ! integer iehwsw, iehwi, iehwir, iehwip, iehwc, iehwr
10266 ! integer iehlsw, iehli, iehlir, iehlip, iehlc, iehlr
10267 ! real delqnsa, delqxsa, delqnsb, delqxsb, delqnia, delqxia
10268 ! real delqnra, delqxra
10270 real delqnxa(lc:lqmx)
10271 real delqxxa(lc:lqmx)
10273 ! external temporary arrays
10275 real t00(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
10276 real t77(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
10278 real t0(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
10279 real t1(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
10280 real t2(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
10281 real t3(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
10282 real t4(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
10283 real t5(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
10284 real t6(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
10285 real t7(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
10286 real t8(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
10287 real t9(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
10289 real p2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz) ! perturbation Pi
10290 real pn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz)
10291 real an(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz,na)
10292 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz)
10293 real w(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz)
10295 real tmp3d(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
10298 ! declarations microphyscs and for gather/scatter
10300 integer nxmpb,nzmpb,nxz
10301 integer jgs,mgs,ngs,numgs
10302 parameter (ngs=500) !500)
10303 integer, parameter :: ngsz = 500
10305 parameter (ntt=300)
10309 integer ngscnt,igs(ngs),kgs(ngs)
10310 integer kgsp(ngs),kgsm(ngs),kgsm2(ngs)
10312 parameter (ncuse=0)
10313 integer il0(ngs),il5(ngs),il2(ngs),il3(ngs)
10314 ! integer il1m(ngs),il2m(ngs),il3m(ngs),il4m(ngs),il5m(ngs)
10316 real tdtol,temsav,tfrcbw,tfrcbi
10317 real, parameter :: thnuc = 235.15
10319 ! Ice Multiplication Arrays.
10321 real fimt1(ngs),fimta(ngs),fimt2(ngs) !,qmul1(ngs),qmul2(ngs)
10325 ! Variables for Ziegler warm rain microphysics
10329 real ccnc(ngs),ccin(ngs),cina(ngs),ccna(ngs)
10331 real sscb ! 'cloud base' SS threshold
10332 parameter ( sscb = 2.0 )
10333 integer idecss ! flag to turn on (=1) decay of ssmax when no cloud or ice crystals
10334 parameter ( idecss = 1 )
10335 integer iba ! flag to do condensation/nucleation in 1st or 2nd loop
10336 ! =0 to use ad to calculate SS
10337 ! =1 to use an at end of main jy loop to calculate SS
10338 parameter (iba = 1)
10339 integer ifilt ! =1 to filter ssat, =0 to set ssfilt=ssat
10340 parameter ( ifilt = 0 )
10341 real temp1,temp2 ! ,ssold
10342 real :: mwat, mice, dice, mwshed, fwmax, fw, mwcrit, massfactor, tmpdiam
10343 real, parameter :: shedalp = 3. ! set 3 for maximum mass diameter (same as area-weighted diameter), 4 for mass-weighted diameter
10344 real ssmax(ngs) ! maximum SS experienced by a parcel
10347 ! real cnu,rnu,snu,cinu
10348 ! parameter ( cnu = 0.0, rnu = -0.8, snu = -0.8, cinu = 0.0 )
10349 real bfnu, bfnu0, bfnu1
10350 parameter ( bfnu0 = (rnu + 2.0)/(rnu + 1.0) )
10353 double precision t2s, xdp
10354 double precision xl2p(ngs),rb(ngs)
10355 real, parameter :: aa1 = 9.44e15, aa2 = 5.78e3 ! a1 in Ziegler
10357 real, parameter :: cexs = 0.1, cecs = 0.5
10358 real, parameter :: rvt = 0.104 ! ratio of collection kernels (Zrnic et al, 1993)
10359 real, parameter :: kfrag = 1.0e-6 ! rate coefficent for collisional splintering (Schuur & Rutledge 00b)
10360 real, parameter :: mfrag = 1.0e-10 ! assumed ice fragment mass for collisional splintering (Schuur & Rutledge 00b)
10361 double precision cautn(ngs), rh(ngs), nh(ngs)
10362 real ex1, ft, rhoinv(ngs)
10363 double precision ec0(ngs)
10365 real ac1,bc, taus, c1,d1,e1,f1,p380,tmp,tmp1,tmp2,tmp3,tmp4,tmp5,temp3 ! , sstdy, super
10367 double precision :: tmpz, tmpzmlt
10368 real ratio, delx, dely
10370 real chgtmp,fac,mixedphasefac
10371 real x,y,y2,del,r,rtmp,alpr
10372 double precision :: vent1,vent2
10373 double precision :: g1palp,g4palp
10374 double precision :: g1palpinf,g4palpinf
10375 real fqt !charge separation as fn of temperature from Dong and Hallett 1992
10378 real d1r, d1i, d1s, e1i
10379 real c1sw ! integration factor for snow melting with snu = -0.8
10380 real, parameter :: vr1mm = 5.23599e-10 ! volume of 1mm diameter sphere (m**3)
10381 real, parameter :: vr3mm = 5.23599e-10*(3.0/1.)**3 ! volume of a 3 mm diameter sphere (m**3) (Rasmussen et al. 1984b, JAS)
10382 real, parameter :: vr4p5mm = 5.23599e-10*(4.5/1.)**3 ! volume of 4.5mm diameter sphere (m**3) (Rasmussen et al. 1984b, JAS)
10383 real vmlt,vshd, vshdgs(ngs,lh:lhab), maxmassfac(lc:lhab)
10385 parameter ( rhosm = 500. )
10386 integer nc ! condensation step
10387 real dtcon,dtcon1,dtcon2 ! condensation time step (dtcon*nc = dtp)
10389 integer ltemq1,ltemq1m ! ,ltemq1m2
10390 real dqv,qv1,ss1,ss2,qvs1,dqvs,dtemp,dt1 ! temporaries for condensation
10391 real ssi1, ssi2, dqvi, dqvis, dqvii,qis1
10392 real dqvr, dqc, dqr, dqi, dqs
10393 real qv1m,qvs1m,ss1m,ssi1m,qis1m
10395 real dcloud,dcloud2 ! ,as, bs
10397 double precision xvc, xvr
10399 ! real es(ngs) ! ss(ngs),
10405 parameter ( vgra = 0.523599*(1.0e-3)**3 )
10407 ! real, parameter :: epsi = 0.622
10408 ! real, parameter :: d = 0.266
10409 real :: d, dold, denom,denominv,vth
10410 double precision :: h1, h2, h3, h4,denomdp, denominvdp
10411 real r1,qevap ! ,slv
10413 real vr,nrx,chw,g1,qr,z,z1,rdi,alp,xnutmp,xnuc,g1r,rd1,rdia,rmas
10414 real :: snowmeltmass = 0
10416 ! real, parameter :: rhofrz = 900. ! density of graupel from newly-frozen rain
10417 real, parameter :: rimedens = 500. ! default rime density
10419 ! real svc(ngs) ! droplet volume
10421 ! contact freezing nucleation
10423 real raero,kaero !assumd aerosol radius, thermal conductivity
10424 parameter ( raero = 3.e-7, kaero = 5.39e-3 )
10425 real kb ! Boltzman constant J K-1
10426 parameter (kb = 1.3807e-23)
10428 real knud(ngs),knuda(ngs) !knudsen number and correction factor
10429 real gtp(ngs) !G(T,p) = 1/(a' + b') Cotton 72b
10430 real dfar(ngs) !aerosol diffusivity
10431 real fn1(ngs),fn2(ngs),fnft(ngs)
10434 real ctfzbd(ngs),ctfzth(ngs),ctfzdi(ngs)
10439 real dqvcnd(ngs),dqwv(ngs),dqcw(ngs),dqci(ngs),dqcitmp(ngs),dqwvtmp(ngs)
10441 real temg(ngs),temcg(ngs),theta(ngs),qvap(ngs)
10442 real temgkm1(ngs), temgkm2(ngs)
10443 real temgx(ngs),temcgx(ngs)
10444 real qvs(ngs),qis(ngs),qss(ngs),pqs(ngs)
10445 real elv(ngs),elf(ngs),els(ngs)
10446 real tsqr(ngs),ssi(ngs),ssw(ngs)
10447 real qcwtmp(ngs),qtmp,qtot(ngs)
10450 real cimasn,cimasx,ccimx
10452 real cs,ds,gf7,gf6,gf5,gf4,gf3,gf2,gf1
10454 real gf73rds, gf83rds
10455 real gamice73fac, gamsnow73fac
10456 real gf43rds, gf53rds
10457 real aradcw,bradcw,cradcw,dradcw,cwrad,rwrad,rwradmn
10458 parameter ( rwradmn = 50.e-6 )
10460 real dg0(ngs),df0(ngs)
10462 real clionpmx,clionnmx
10463 parameter (clionpmx=1.e9,clionnmx=1.e9) ! Takahashi 84
10467 real fwet1(ngs),fwet2(ngs)
10468 real fmlt1(ngs),fmlt2(ngs)
10469 real fvds(ngs),fvce(ngs),fiinit(ngs)
10470 real fvent(ngs),fraci(ngs),fracl(ngs)
10472 real fai(ngs),fav(ngs),fbi(ngs),fbv(ngs)
10473 real felv(ngs),fels(ngs),felf(ngs)
10474 real felvcp(ngs),felscp(ngs),felfcp(ngs)
10475 real felvpi(ngs),felspi(ngs),felfpi(ngs)
10476 real felvs(ngs),felss(ngs) ! ,felfs(ngs)
10477 real fwvdf(ngs),ftka(ngs),fthdf(ngs)
10478 real fadvisc(ngs),fakvisc(ngs)
10479 real fci(ngs),fcw(ngs) ! heat capacities of ice and liquid
10480 real fschm(ngs),fpndl(ngs)
10481 real fgamw(ngs),fgams(ngs)
10482 real fcqv1(ngs),fcqv2(ngs),fcc3(ngs)
10486 real, parameter :: rovcp = rd/cp
10487 real, parameter :: cpv = 1885.0 ! specific heat of water vapor at constant pressure
10489 real fcci(ngs), fcip(ngs)
10491 real :: sfm1(ngs),sfm2(ngs)
10492 real :: gfm1(ngs),gfm2(ngs)
10493 real :: hfm1(ngs),hfm2(ngs)
10495 logical :: wetsfc(ngs),wetsfchl(ngs),wetsfcf(ngs)
10496 logical :: wetgrowth(ngs), wetgrowthhl(ngs), wetgrowthf(ngs)
10498 real qitmp(ngs),qistmp(ngs)
10500 real rzxh(ngs), rzxhl(ngs), rzxhlh(ngs), rzxhlf(ngs)
10501 real rzxs(ngs), rzxf(ngs)
10502 ! real axh(ngs),bxh(ngs),axhl(ngs),bxhl(ngs)
10503 real cdh(ngs),cdhl(ngs)
10504 real :: axx(ngs,lh:lhab),bxx(ngs,lh:lhab)
10507 real :: qcwresv(ngs), ccwresv(ngs) ! "reserved" droplet mass and number that are too small for accretion
10509 real :: lfsave(ngs,6)
10510 real :: qx(ngs,lv:lhab)
10511 real :: qxw(ngs,ls:lhab)
10512 real :: qxwlg(ngs,lh:lhab)
10513 real :: chxf(ngs,lh:lhab)
10514 real :: cx(ngs,lc:lhab)
10515 real :: cxmxd(ngs,lc:lhab)
10516 real :: qxmxd(ngs,lv:lhab)
10517 real :: scx(ngs,lc:lhab)
10518 real :: xv(ngs,lc:lhab)
10519 real :: vtxbar(ngs,lc:lhab,3)
10520 real :: xmas(ngs,lc:lhab)
10521 real :: xdn(ngs,lc:lhab)
10522 real :: cdxgs(ngs,lc:lhab)
10523 real :: xdia(ngs,lc:lhab,3)
10524 real :: vtwtdia(ngs,lr:lhab) ! sweep-out volume weighted diameter
10525 real :: rarx(ngs,ls:lhab)
10526 real :: vx(ngs,li:lhab)
10527 real :: rimdn(ngs,li:lhab)
10528 real :: raindn(ngs,li:lhab)
10529 real :: alpha(ngs,lc:lhab)
10530 real :: dab0lh(ngs,lc:lhab,lc:lhab)
10531 real :: dab1lh(ngs,lc:lhab,lc:lhab)
10533 real :: qsimxdep(ngs) ! max sublimation of qi+qs+qis
10534 real :: qsimxsub(ngs) ! max depositionof qi+qs+qis
10535 logical,parameter :: DoSublimationFix = .true.
10536 real :: qrtmp(ngs),qvtmp(ngs),qctmp(ngs)
10537 real :: felvcptmp,felscptmp,qsstmp
10538 real :: thetatmp, thetaptmp, temcgtmp,qvaptmp
10539 real :: qvstmp, qisstmp, qvptmp, qitmp1, qctmp1
10545 real g1shr, alphashr
10546 real g1mlr, alphamlr
10547 real massfacshr, massfacmlr
10549 real :: qhgt8mm ! ice mass greater than 8mm
10550 real :: qhwgt8mm ! ice + max water mass greater than 8mm
10551 real :: qhgt10mm ! mass greater than 10mm
10552 real :: qhgt20mm ! mass greater than 20mm
10554 real, parameter :: fwmhtmptem = -15. ! temperature at which fwmhtmp fully switches to liquid water only being on large particles
10555 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
10556 real, parameter :: srasheym = 0.1389 ! slope fraction from Rasmussen and Heymsfield
10558 real swvent(ngs),hwvent(ngs),rwvent(ngs),hlvent(ngs),hwventy(ngs),hlventy(ngs),rwventz(ngs)
10559 integer, parameter :: ndiam = 10
10561 real hwvent0(ndiam+4),hlvent0 ! 0 to d1
10562 real hwvent1,hlvent1 ! d1 to infinity
10563 real hwvent2,hlvent2 ! d2 to infinity
10567 ! real, parameter :: mltdiam1 = 9.0e-3, mltdiam1p5 = 16.0e-3, mltdiam2 = 19.0e-3, mltdiam3 = 200.0e-3, mltdiam05 = 4.5e-3
10568 real :: mltdiam(ndiam+4)
10569 real mltmass0inv,mltmass1inv,mltmass2inv, mltmass1cgs, mltmass2cgs,mltmass3inv, mltmass3cgs
10570 real qhmlr0, qhmlr05, qhmlr1, qhmlr2,qhmlr3, qhmlr12, qhmlr23
10571 real qhlmlr0, qhlmlr05, qhlmlr1, qhlmlr2,qhlmlr3, qhlmlr12, qhlmlr23
10572 real qxd1, cxd1, zxd1 ! mass and number up to mltdiam1
10573 real qxd05, cxd05 ! mass and number up to mltdiam1/2
10575 real :: qxd(ndiam+4), cxd(ndiam+4), qhml(ndiam+4), qhml0(ndiam+4)
10576 real :: dqxd(ndiam+4), dcxd(ndiam+4), dqhml(ndiam+4)
10583 real xdnmx(lc:lhab), xdnmn(lc:lhab)
10585 real :: xdiamxmas(ngs,lc:lhab)
10587 real cilen(ngs) ! ,ciplen(ngs)
10590 real rwcap(ngs),swcap(ngs)
10597 real qimxd(ngs),qismxd(ngs),qcmxd(ngs),qrmxd(ngs),qsmxd(ngs),qhmxd(ngs),qhlmxd(ngs)
10598 real cimxd(ngs),ccmxd(ngs),crmxd(ngs),csmxd(ngs),chmxd(ngs)
10599 real cionpmxd(ngs),cionnmxd(ngs)
10600 real clionpmxd(ngs),clionnmxd(ngs)
10603 real elec(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz) ! Ez (elecsave)
10607 ! Hallett-Mossop arrays
10608 real chmul1(ngs),chlmul1(ngs),csmul1(ngs),csmul(ngs)
10609 real qhmul1(ngs),qhlmul1(ngs),qsmul1(ngs),qsmul(ngs)
10611 ! splinters from drop freezing
10612 real csplinter(ngs),qsplinter(ngs)
10613 real csplinter2(ngs),qsplinter2(ngs)
10616 ! concentration arrays...
10618 real :: chlcnh(ngs), vhlcnh(ngs), vhlcnhl(ngs)
10619 real :: chlcnhhl(ngs) ! number of new hail particles (may be different from number of lost graupel)
10620 real cracif(ngs), ciacrf(ngs)
10624 real ciint(ngs), crfrz(ngs), crfrzf(ngs), crfrzs(ngs)
10627 real ciacw(ngs), cwacii(ngs)
10628 real ciacr(ngs), craci(ngs)
10631 real csaci(ngs), csacs(ngs)
10633 real chacw(ngs), chacr(ngs)
10634 real :: chlacw(ngs)
10635 real chaci(ngs), chacs(ngs)
10637 real :: chlacr(ngs)
10638 real :: chlaci(ngs), chlacs(ngs)
10640 real cidpv(ngs),cisbv(ngs)
10641 real cisdpv(ngs),cissbv(ngs)
10642 real cimlr(ngs),cismlr(ngs)
10644 real chlsbv(ngs), chldpv(ngs)
10645 real chlmlr(ngs), chlmlrr(ngs)
10646 ! real chlmlrsave(ngs),chlsave(ngs),qhlsave(ngs)
10647 real chlshr(ngs), chlshrr(ngs)
10650 real chdpv(ngs),chsbv(ngs)
10651 real chmlr(ngs),chcev(ngs)
10653 real chshr(ngs), chshrr(ngs)
10655 real csdpv(ngs),cssbv(ngs)
10656 real csmlr(ngs),csmlrr(ngs),cscev(ngs)
10657 real csshr(ngs), csshrr(ngs)
10661 real cwshw(ngs), qwshw(ngs)
10664 ! arrays for w-ac-x ; x-ac-w
10668 real qrcnw(ngs), qwcnr(ngs)
10669 real zrcnw(ngs),zracr(ngs),zracw(ngs),zrcev(ngs)
10672 real qracw(ngs) ! qwacr(ngs),
10673 real qiacw(ngs) !, qwaci(ngs)
10675 real qsacw(ngs) ! ,qwacs(ngs),
10676 real qhacw(ngs) ! qwach(ngs),
10677 real :: qhlacw(ngs) !
10678 real vhacw(ngs), vsacw(ngs), vhlacw(ngs), vhlacr(ngs)
10680 real qfmul1(ngs),cfmul1(ngs)
10685 ! arrays for x-ac-r and r-ac-x;
10687 real qsacr(ngs),qracs(ngs)
10688 real qhacr(ngs),qhacrmlr(ngs) ! ,qrach(ngs)
10689 real vhacr(ngs), zhacr(ngs), zhacrf(ngs), zrach(ngs), zrachl(ngs)
10690 real qiacr(ngs),qraci(ngs)
10694 real qracif(ngs),qiacrf(ngs),qiacrs(ngs),ciacrs(ngs)
10696 real :: qhlacr(ngs),qhlacrmlr(ngs)
10697 real qsacrs(ngs) !,qracss(ngs)
10699 ! ice - ice interactions
10706 real :: qhacis(ngs)
10707 real :: chacis(ngs)
10708 real :: chacis0(ngs)
10710 real :: csaci0(ngs) ! collision rate only
10711 real :: chaci0(ngs) ! collision rate only
10712 real :: chacs0(ngs) ! collision rate only
10713 real :: chlaci0(ngs)
10714 real :: chlacis(ngs)
10715 real :: chlacis0(ngs)
10716 real :: chlacs0(ngs)
10718 real :: qsaci0(ngs) ! collision rate only
10719 real :: qsacis0(ngs) ! collision rate only
10720 real :: qhaci0(ngs) ! collision rate only
10721 real :: qhacis0(ngs) ! collision rate only
10722 real :: qhacs0(ngs) ! collision rate only
10723 real :: qhlaci0(ngs)
10724 real :: qhlacis0(ngs)
10725 real :: qhlacs0(ngs)
10727 real :: qhlaci(ngs)
10728 real :: qhlacis(ngs)
10729 real :: qhlacs(ngs)
10733 real qrfrz(ngs) ! , qirirhr(ngs)
10734 real zrfrz(ngs), zrfrzf(ngs), zrfrzs(ngs)
10735 real ziacrf(ngs), zhcnsh(ngs), zhcnih(ngs)
10736 real zhacw(ngs), zhacs(ngs), zhaci(ngs)
10737 real zhmlr(ngs), zhdsv(ngs), zhsbv(ngs), zhlcnh(ngs), zhshr(ngs)
10738 real zfacw(ngs), zfacs(ngs), zfaci(ngs)
10739 real zfmlr(ngs), zfdsv(ngs), zfsbv(ngs), zhlcnf(ngs), zfshr(ngs), zfshrr(ngs)
10740 real zhmlrtmp,zhmlr0inf,zhlmlr0inf
10741 real zhmlrr(ngs),zhlmlrr(ngs),zhshrr(ngs),zhlshrr(ngs),zfmlrr(ngs)
10742 real zsmlr(ngs), zsmlrr(ngs), zsshr(ngs)
10743 real zhcns(ngs), zhcni(ngs)
10744 real zhwdn(ngs), zfwdn(ngs) ! change in Z due to density changes
10745 real zhldn(ngs) ! change in Z due to density changes
10747 real zhlacw(ngs), zhlacs(ngs), zhlacr(ngs)
10748 real zhlmlr(ngs), zhldsv(ngs), zhlsbv(ngs), zhlshr(ngs)
10751 real vrfrzf(ngs), viacrf(ngs)
10752 real qrfrzs(ngs), qrfrzf(ngs)
10753 real qwfrz(ngs), qwctfz(ngs)
10754 real cwfrz(ngs), cwctfz(ngs)
10755 real qwfrzis(ngs), qwctfzis(ngs) ! droplet freezing to ice spheres
10756 real cwfrzis(ngs), cwctfzis(ngs)
10757 real qwfrzc(ngs), qwctfzc(ngs) ! droplet freezing to columns
10758 real cwfrzc(ngs), cwctfzc(ngs)
10759 real qwfrzp(ngs), qwctfzp(ngs) ! droplet freezing to plates
10760 real cwfrzp(ngs), cwctfzp(ngs)
10761 real xcolmn(ngs), xplate(ngs)
10762 real ciihr(ngs), qiihr(ngs)
10763 real cicichr(ngs), qicichr(ngs)
10764 real cipiphr(ngs), qipiphr(ngs)
10765 real qscni(ngs), cscni(ngs), cscnis(ngs)
10766 real qscnvi(ngs), cscnvi(ngs), cscnvis(ngs)
10767 real qhcns(ngs), chcns(ngs), chcnsh(ngs), vhcns(ngs)
10768 real qscnh(ngs), cscnh(ngs), vscnh(ngs)
10769 real qhcni(ngs), chcni(ngs), chcnih(ngs), vhcni(ngs)
10770 real qiint(ngs),qipipnt(ngs),qicicnt(ngs)
10771 real cninm(ngs),cnina(ngs),cninp(ngs),wvel(ngs),wvelkm1(ngs)
10773 real uvel(ngs),vvel(ngs)
10775 real qidpv(ngs),qisbv(ngs) ! qicnv(ngs),qievv(ngs),
10776 real qimlr(ngs),qidsv(ngs),qisdsv(ngs),qidsvp(ngs) ! ,qicev(ngs)
10781 real :: qhldpv(ngs), qhlsbv(ngs) ! qhlcnv(ngs),qhlevv(ngs),
10782 real :: qhlmlr(ngs), qhldsv(ngs), qhlmlrsave(ngs)
10783 real :: qhlwet(ngs), qhldry(ngs), qhlshr(ngs)
10785 real :: qrfz(ngs),qsfz(ngs),qhfz(ngs),qhlfz(ngs)
10787 real qhdpv(ngs),qhsbv(ngs) ! qhcnv(ngs),qhevv(ngs),
10788 real qhmlr(ngs),qhdsv(ngs),qhcev(ngs),qhcndv(ngs),qhevv(ngs)
10789 real qhlcev(ngs), chlcev(ngs)
10790 real qhwet(ngs),qhdry(ngs),qhshr(ngs)
10792 real qhshh(ngs) !accreted water that remains on graupel
10793 real qhmlh(ngs) !melt water that remains on graupel
10794 real qhfzh(ngs) !water that freezes on mixed-phase graupel
10795 real qhlfzhl(ngs) !water that freezes on mixed-phase hail
10797 real qhmlrlg(ngs),qhlmlrlg(ngs) ! melting from the larger diameters
10798 real qhfzhlg(ngs) !water that freezes on mixed-phase graupel (large sizes)
10799 real qhlfzhllg(ngs) !water that freezes on mixed-phase hail (large sizes)
10800 real qhlcevlg(ngs), chlcevlg(ngs)
10801 real qhcevlg(ngs), chcevlg(ngs)
10803 real vhfzh(ngs), vffzf(ngs) ! change in volume from water that freezes on mixed-phase graupel, frozen drops
10804 real vhlfzhl(ngs) ! change in volume from water that freezes on mixed-phase hail
10806 real vhshdr(ngs) !accreted water that leaves on graupel (mixedphase)
10807 real vhlshdr(ngs) !accreted water that leaves on hail (mixedphase)
10808 real vhmlr(ngs) !melt water that leaves graupel (single phase)
10809 real vhlmlr(ngs) !melt water that leaves hail (single phase)
10810 real vhsoak(ngs) ! aquired water that seeps into graupel.
10811 real vhlsoak(ngs) ! aquired water that seeps into hail.
10814 real qsdpv(ngs),qssbv(ngs) ! qscnv(ngs),qsevv(ngs),
10815 real qsmlr(ngs),qsdsv(ngs),qscev(ngs),qscndv(ngs),qsevv(ngs)
10816 real qswet(ngs),qsdry(ngs),qsshr(ngs)
10821 real qipdpv(ngs),qipsbv(ngs)
10822 real qipmlr(ngs),qipdsv(ngs)
10824 real qirdpv(ngs),qirsbv(ngs)
10825 real qirmlr(ngs),qirdsv(ngs),qirmlw(ngs)
10827 real qgldpv(ngs),qglsbv(ngs)
10828 real qglmlr(ngs),qgldsv(ngs)
10829 real qglwet(ngs),qgldry(ngs),qglshr(ngs)
10832 real qgmdpv(ngs),qgmsbv(ngs)
10833 real qgmmlr(ngs),qgmdsv(ngs)
10834 real qgmwet(ngs),qgmdry(ngs),qgmshr(ngs)
10836 real qghdpv(ngs),qghsbv(ngs)
10837 real qghmlr(ngs),qghdsv(ngs)
10838 real qghwet(ngs),qghdry(ngs),qghshr(ngs)
10841 real qrztot(ngs),qrzmax(ngs),qrzfac(ngs)
10844 real fsw(ngs),fhw(ngs),fhlw(ngs),ffw(ngs) !liquid water fractions
10845 real fswmax(ngs),fhwmax(ngs),fhlwmax(ngs) !liquid water fractions
10847 real :: qhlcnh(ngs)
10848 real qhcngh(ngs),qhcngm(ngs),qhcngl(ngs)
10850 real :: qhcnhl(ngs), chcnhl(ngs), zhcnhl(ngs), vhcnhl(ngs) ! conversion of low-density hail back to graupel
10852 real eiw(ngs),eii(ngs),eiri(ngs),eipir(ngs),eisw(ngs)
10853 real erw(ngs),esw(ngs),eglw(ngs),eghw(ngs),efw(ngs)
10854 real ehxw(ngs),ehlw(ngs),egmw(ngs),ehw(ngs)
10855 real err(ngs),esr(ngs),eglr(ngs),eghr(ngs),efr(ngs)
10856 real ehxr(ngs),ehlr(ngs),egmr(ngs)
10857 real eri(ngs),esi(ngs),egli(ngs),eghi(ngs),efi(ngs),efis(ngs)
10858 real ehxi(ngs),ehli(ngs),egmi(ngs),ehi(ngs),ehis(ngs),ehlis(ngs)
10859 real ers(ngs),ess(ngs),egls(ngs),eghs(ngs),efs(ngs),ehs(ngs)
10861 real ehxs(ngs),ehls(ngs),egms(ngs),egmip(ngs)
10863 real ehsclsn(ngs),ehiclsn(ngs),ehisclsn(ngs)
10864 real efsclsn(ngs),eficlsn(ngs),efisclsn(ngs)
10865 real ehlsclsn(ngs),ehliclsn(ngs),ehlisclsn(ngs)
10868 real :: ehs_collsn = 0.5, ehi_collsn = 1.0
10869 real :: efs_collsn = 0.5, efi_collsn = 1.0
10870 real :: ehls_collsn = 1.0, ehli_collsn = 1.0
10871 real :: esi_collsn = 1.0
10874 real cwr(8,2) ! radius and inverse of interval
10875 data cwr / 2.0, 3.0, 4.0, 6.0, 8.0, 10.0, 15.0, 20.0 , & ! radius
10876 & 1.0, 1.0, 0.5, 0.5, 0.5, 0.2, 0.2, 1. / ! inverse of interval
10877 integer icwr(ngs), igwr(ngs), irwr(ngs), ihlr(ngs), ifwr(ngs)
10878 real grad(6,2) ! graupel radius and inverse of interval
10879 data grad / 100., 200., 300., 400., 600., 1000., &
10880 & 1.e-2,1.e-2,1.e-2,5.e-3,2.5e-3, 1. /
10881 !droplet radius: 2 3 4 6 8 10 15 20
10882 data ew /0.03, 0.07, 0.17, 0.41, 0.58, 0.69, 0.82, 0.88, & ! 100
10883 ! : 0.07, 0.13, 0.27, 0.48, 0.65, 0.73, 0.84, 0.91, ! 150
10884 & 0.10, 0.20, 0.34, 0.58, 0.70, 0.78, 0.88, 0.92, & ! 200
10885 & 0.15, 0.31, 0.44, 0.65, 0.75, 0.83, 0.96, 0.91, & ! 300
10886 & 0.17, 0.37, 0.50, 0.70, 0.81, 0.87, 0.93, 0.96, & ! 400
10887 & 0.17, 0.40, 0.54, 0.71, 0.83, 0.88, 0.94, 0.98, & ! 600
10888 & 0.15, 0.37, 0.52, 0.74, 0.82, 0.88, 0.94, 0.98 / ! 1000
10889 ! : 0.11, 0.34, 0.49, 0.71, 0.83, 0.88, 0.94, 0.95 / ! 1400
10892 real da0lr(ngs),da1lr(ngs)
10893 real da0lc(ngs),da1lc(ngs)
10897 real :: da0lx(ngs,lr:lhab)
10899 real va0 (lc:lqmx) ! collection coefficients from Seifert 2005
10900 real vab0(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
10901 real vab1(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
10902 real va1 (lc:lqmx) ! collection coefficients from Seifert 2005
10903 real ehip(ngs),ehlip(ngs),ehlir(ngs)
10904 real erir(ngs),esir(ngs),eglir(ngs),egmir(ngs),eghir(ngs)
10905 real efir(ngs),ehir(ngs),eirw(ngs),eirir(ngs),ehr(ngs)
10906 real erip(ngs),esip(ngs),eglip(ngs),eghip(ngs)
10907 real efip(ngs),eipi(ngs),eipw(ngs),eipip(ngs)
10909 ! arrays for production terms
10911 real ptotal(ngs) ! , pqtot(ngs)
10913 real pqcwi(ngs),pqcii(ngs),pqrwi(ngs),pqisi(ngs)
10914 real pqswi(ngs),pqhwi(ngs),pqwvi(ngs)
10915 real pqgli(ngs),pqghi(ngs),pqfwi(ngs)
10916 real pqgmi(ngs),pqhli(ngs) ! ,pqhxi(ngs)
10917 real pqiri(ngs),pqipi(ngs) ! pqwai(ngs),
10918 real pqlwsi(ngs),pqlwhi(ngs),pqlwhli(ngs)
10920 real pqlwlghi(ngs),pqlwlghli(ngs)
10921 real pqlwlghd(ngs),pqlwlghld(ngs)
10925 real pvhwi(ngs), pvhwd(ngs)
10926 real pvfwi(ngs), pvfwd(ngs)
10927 real pvhli(ngs), pvhld(ngs)
10928 real pvswi(ngs), pvswd(ngs)
10930 real pqcwd(ngs),pqcid(ngs),pqrwd(ngs),pqisd(ngs), pqcwdacc(ngs)
10931 real pqswd(ngs),pqhwd(ngs),pqwvd(ngs)
10932 real pqgld(ngs),pqghd(ngs),pqfwd(ngs)
10933 real pqgmd(ngs),pqhld(ngs) ! ,pqhxd(ngs)
10934 real pqird(ngs),pqipd(ngs) ! pqwad(ngs),
10935 real pqlwsd(ngs),pqlwhd(ngs),pqlwhld(ngs)
10937 ! real pqxii(ngs,nhab),pqxid(ngs,nhab)
10940 real pcipi(ngs), pcipd(ngs)
10941 real pciri(ngs), pcird(ngs)
10942 real pccwi(ngs), pccwd(ngs), pccwdacc(ngs)
10943 real pccii(ngs), pccid(ngs)
10944 real pcisi(ngs), pcisd(ngs)
10946 real pcrwi(ngs), pcrwd(ngs)
10947 real pcswi(ngs), pcswd(ngs)
10948 real pchwi(ngs), pchwd(ngs)
10949 real pchli(ngs), pchld(ngs)
10950 real pcfwi(ngs), pcfwd(ngs)
10951 real pcgli(ngs), pcgld(ngs)
10952 real pcgmi(ngs), pcgmd(ngs)
10953 real pcghi(ngs), pcghd(ngs)
10955 real pzrwi(ngs), pzrwd(ngs)
10956 real pzhwi(ngs), pzhwd(ngs)
10957 real pzfwi(ngs), pzfwd(ngs)
10958 real pzhli(ngs), pzhld(ngs)
10959 real pzswi(ngs), pzswd(ngs)
10964 real dqisdt(ngs) !,advisc(ngs) !dqwsdt(ngs), ,schm(ngs),pndl(ngs)
10969 real pres(ngs),pipert(ngs)
10971 real rho0(ngs),pi0(ngs)
10972 real rhovt(ngs),sqrtrhovt
10973 real thetap(ngs),theta0(ngs),qwvp(ngs),qv0(ngs)
10975 real ptwfzi(ngs),ptimlw(ngs)
10976 real psub(ngs),pvap(ngs),pfrz(ngs),ptem(ngs),pmlt(ngs),pevap(ngs),pdep(ngs),ptem2(ngs)
10978 real cnostmp(ngs) ! for diagnosed snow intercept
10980 ! iholef = 1 to do hole filling technique version 1
10981 ! which uses all hydrometerors to do hole filling of all hydrometeors
10982 ! iholef = 2 to do hole filling technique version 2
10983 ! which uses an individual hydrometeror species to do hole
10984 ! filling of a species of a hydrometeor
10986 ! iholen = interval that hole filling is done
10990 parameter (iholef = 1)
10991 parameter (iholen = 1)
10992 real cqtotn,cqtotn1
11002 real cqtotp,cqtotp1
11027 real ssifac, qvapor
11029 ! Miscellaneous variables
11031 real, parameter :: cwmas30 = 1000.*0.523599*(2.*30.e-6)**3 ! mass of 30-micron radius droplet, for sat. adj.
11032 real, parameter :: cwmas20 = 1000.*0.523599*(2.*20.e-6)**3 ! mass of 20-micron radius droplet, for sat. adj.
11033 integer ireadqf,lrho,lqsw,lqgl,lqgm ,lqgh
11036 real arg ! gamma is a function
11037 real erbnd1, fdgt1, costhe1
11039 real dyi2,dzi2,cp608,bta1,cnit,dragh,dnz00,pii
11040 real qccrit,gf4br,gf4ds,gf4p5, gf3ds, gf1ds,gr
11041 real gf1palp(ngs) ! for storing Gamma[1.0 + alphar]
11045 real xdn_new,drhodt
11047 integer l ,ltemq,inumgs, idelq
11054 real cval,aval,eval,fval,gval ,qsign,ftelwc,qconkq,elecfac,altelecfac
11055 real qconm,qconn,cfce15,gf8,gf4i,gf3p5,gf1a,gf1p5,qdiff,argrcnw
11056 real c4,bradp,bl2,bt2,dthr,hrifac, hdia0,hdia1,civenta,civentb
11057 real civentc,civentd,civente,civentf,civentg,cireyn,xcivent
11058 real cipventa,cipventb,cipventc,cipventd,cipreyn,cirventa
11060 integer igmrwa,igmrwb,igmswa, igmswb,igmfwa,igmfwb,igmhwa,igmhwb
11061 real rwventa ,rwventb,swventa,swventb,fwventa,fwventb,fwventc
11062 real hwventa,hwventb
11063 real hwventc, hlventa, hlventb, hlventc
11064 real glventa, glventb, glventc
11065 real gmventa, gmventb, gmventc, ghventa, ghventb, ghventc
11066 real dzfacp, dzfacm, cmassin, cwdiar
11067 real rimmas, rhobar
11068 real argtim, argqcw, argqxw, argtem
11069 real frcswsw, frcswgl, frcswgm, frcswgh, frcswfw, frcswsw1
11070 real frcglgl, frcglgm, frcglgh, frcglfw, frcglgl1
11071 real frcgmgl, frcgmgm, frcgmgh, frcgmfw, frcgmgm1
11072 real frcghgl, frcghgm, frcghgh, frcghfw, frcghgh1
11073 real frcfwgl, frcfwgm, frcfwgh, frcfwfw, frcfwfw1
11074 real frcswrsw, frcswrgl, frcswrgm, frcswrgh, frcswrfw
11076 real frcrswsw, frcrswgl, frcrswgm, frcrswgh, frcrswfw
11078 real frcglrgl, frcglrgm, frcglrgh, frcglrfw, frcglrgl1
11080 real frcrglgm, frcrglgh, frcrglfw, frcrglgl1
11081 real frcgmrgl, frcgmrgm, frcgmrgh, frcgmrfw, frcgmrgm1
11082 real frcrgmgl, frcrgmgm, frcrgmgh, frcrgmfw, frcrgmgm1
11083 real sum, qweps, gf2a, gf4a, dqldt, dqidt, dqdt
11084 real frcghrgl, frcghrgm, frcghrgh, frcghrfw, frcghrgh1, frcrghgl
11085 real frcrghgm, frcrghgh, frcrghfw, frcrghgh1
11086 real a1,a2,a3,a4,a5,a6
11088 real cdw, cdi, denom1, denom2, delqci1, delqip1
11089 real cirtotn, ciptotn, cgmtotn, chltotn, cirtotp
11090 real cgmfac, chlfac, cirfac
11091 integer igmhla, igmhlb, igmgla, igmglb, igmgma, igmgmb
11092 integer igmgha, igmghb
11093 integer idqis, item, itim0
11094 integer iqgl, iqgm, iqgh, iqrw, iqsw
11101 integer cntnic_noliq
11102 real q_noliqmn, q_noliqmx
11103 real scsacimn, scsacimx
11107 ! arrays for temporary bin space
11109 real :: xden,xmlt,cmlt,cmlttot,fventm,fventh,am,ah,felfinv,dmwdt
11111 real :: qhmlrtmp,qhmlrtmp2, chmlrtmp, chmlrtmpd1inf, chlmlrtmp, zhlmlrtmp, zhlmlrrtmp, qvs0,tmpcmlt
11113 real :: term1,term2,term3,term4
11114 real :: qaacw ! combined qsacw-qhacw for WSM6 variation
11119 ! ####################################################################
11123 ! ####################################################################
11153 IF ( ngs .lt. nz ) THEN
11154 ! write(0,*) 'Error in ICEZVD: Must have ngs .ge. nz!'
11167 ldovol = ldovol .or. ( lvol(il) .gt. 1 )
11173 ! write(iunit,*) 'delqnxa(',il,') = ',delqnxa(il)
11177 ! density maximums and minimums
11181 ! Set terminal velocities...
11182 ! also set drag coefficients
11190 ! electricity constants
11192 ! mixing ratio epsilon
11196 ! rebound efficiency (erbnd)
11205 bradcw = 0.26249e+06
11206 cradcw = -1.8896e+10
11207 dradcw = 4.4626e+14
11214 ! new values for cs and ds
11217 pii = piinv ! 1./pi
11220 gf1 = 1.0 ! gamma(1.0)
11221 gf1p5 = 0.8862269255 ! gamma(1.5)
11222 gf2 = 1.0 ! gamma(2.0)
11223 gf3 = 2.0 ! gamma(3.0)
11224 gf3p5 = 3.32335097 ! gamma(3.5)
11225 gf4 = 6.00 ! gamma(4.0)
11226 gf5 = 24.0 ! gamma(5.0)
11227 gf6 = 120.0 ! gamma(6.0)
11228 gf7 = 720.0 ! gamma(7.0)
11229 gf4br = 17.837861981813607 ! gamma(4.0+br)
11230 gf4ds = 10.41688578110938 ! gamma(4.0+ds)
11231 gf4p5 = 11.63172839656745 ! gamma(4.0+0.5)
11232 gf3ds = 3.0458730354120997 ! gamma(3.0+ds)
11233 gf1ds = 0.8863557896089221 ! gamma(1.0+ds)
11235 gf43rds = 0.8929795116 ! gamma(4./3.)
11236 gf53rds = 0.9027452930 ! gamma(5./3.)
11237 gf73rds = 1.190639349 ! gamma(7./3.)
11238 gf83rds = 1.504575488 ! gamma(8./3.)
11240 gamice73fac = (Gamma_sp(7./3. + cinu))**3/ (Gamma_sp(1. + cinu)**3 * (1. + cinu)**4)
11241 gamsnow73fac = (Gamma_sp(7./3. + snu))**3/ (Gamma_sp(1. + snu)**3 * (1. + snu)**4)
11243 ! gcnup1 = Gamma_sp(cnu + 1.)
11244 ! gcnup2 = Gamma_sp(cnu + 2.)
11249 ! general constants for microphysics
11254 bfnu1 = (4. + alphar)*(5. + alphar)*(6. + alphar)/ &
11255 & ((1. + alphar)*(2. + alphar)*(3. + alphar))
11257 galpharaut = (6.+alpharaut)*(5.+alpharaut)*(4.+alpharaut)/ &
11258 & ((3.+alpharaut)*(2.+alpharaut)*(1.+alpharaut))
11260 vfrz = 0.523599*(dfrz)**3
11261 vmlt = Min(xvmx(lr), 0.523599*(dmlt)**3 )
11262 vshd = Min(xvmx(lr), 0.523599*(dshd)**3 )
11264 snowmeltmass = pi/6.0 * 1000. * snowmeltdia**3 ! maximum rain particle mass from melting snow (if snowmeltdia > 0)
11272 ! print*,'ventr,ventc = ',ventr,ventc
11275 ! Set up look up tables for supersaturation w.r.t. liq and ice
11279 ! temq = 163.15 + (l-1)*fqsat
11280 ! tabqvs(l) = exp(caw*(temq-273.15)/(temq-cbw))
11281 ! tabqis(l) = exp(cai*(temq-273.15)/(temq-cbi))
11284 mltmass0inv = 1.0/( 1000.0* xvmx(lr) ) ! for drops melting from ice with diameter > 1.9cm
11285 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
11286 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)
11287 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
11288 mltmass1cgs = 1.0*(4.0*pi/3.0)*((0.5*takshedsize1)**3)
11289 mltmass2cgs = 1.0*(4.0*pi/3.0)*((0.5*takshedsize2)**3)
11290 mltmass3cgs = 1.0*(4.0*pi/3.0)*((0.5*takshedsize3)**3)
11292 ! real, parameter :: mltdiam1 = 9.0e-3, mltdiam2 = 19.0e-3, mltdiam05 = 4.5e-3
11294 IF ( ibinnum == 1 ) THEN
11295 numdiam = 1 ! must have numdiam < ndiam because numdiam+1 holds values for the interval of mltdiam(numdiam) to mltdiam(ndiam+1)
11296 mltdiam(1) = 4.5e-3
11297 ELSEIF ( ibinnum == 2 ) THEN
11298 numdiam = 2 ! must have numdiam < ndiam because numdiam+1 holds values for the interval of mltdiam(numdiam) to mltdiam(ndiam+1)
11299 mltdiam(1) = mltdiam1/6. ! 1.5e-3
11300 mltdiam(2) = mltdiam1/2. ! 4.5e-3
11301 ELSEIF ( ibinnum > 2 ) THEN
11302 numdiam = Min(ibinnum, ndiam)
11304 mltdiam(k) = (k - 0.5)*mltdiam1/float(numdiam)
11308 numdiam = 5 ! must have numdiam < ndiam because numdiam+1 holds values for the interval of mltdiam(numdiam) to mltdiam(ndiam+1)
11309 mltdiam(1) = 0.5e-3
11310 mltdiam(2) = 1.0e-3
11311 mltdiam(3) = 2.0e-3
11312 mltdiam(4) = 4.0e-3
11313 mltdiam(5) = 6.0e-3
11317 IF ( numshedregimes == 2 ) THEN
11318 mltdiam(ndiam+1) = mltdiam1 ! 9.0e-3
11319 mltdiam(ndiam+2) = mltdiam3 ! 19.0e-3
11320 mltdiam(ndiam+3) = mltdiam4 !100.0e-3
11321 ELSEIF ( numshedregimes == 3 ) THEN
11322 mltdiam(ndiam+1) = mltdiam1 ! 9.0e-3
11323 mltdiam(ndiam+2) = mltdiam2 ! 16.0e-3
11324 mltdiam(ndiam+3) = mltdiam3 ! 19.0e-3
11325 mltdiam(ndiam+4) = mltdiam4 !200.0e-3
11330 ! if (kzend .eq. nzend) kze = kzend-kzbeg+1-kstag
11333 ! cw constants in mks units
11335 ! cwmasn = 4.25e-15 ! radius of 1.0e-6
11336 mwfac = 6.0**(1./3.)
11337 IF ( ipconc .ge. 2 ) THEN
11338 ! cwmasn = xvmn(lc)*1000.
11340 ! cwmasx = xvmx(lc)*1000.
11342 rwmasn = xvmn(lr)*1000.
11343 rwmasx = xvmx(lr)*1000.
11345 IF ( biggsnowdiam > 0.0 ) THEN
11346 xvbiggsnow = (pi/6.0)*biggsnowdiam**3
11348 xvbiggsnow = xvmn(lh)
11352 ! ci constants in mks units
11354 cimasn = Min(cimas0, cimas1) ! 12 microns for 0.1871*(xmas(mgs,li)**(0.3429))
11355 cimasx = 1.0e-8 ! 338 microns
11356 ccimx = 5000.0e3 ! max of 5000 per liter
11359 ! constants for paramerization
11362 ! set save counter (number of saves): nsvcnt
11368 ! timetd1 = etime(tarray)
11369 ! timetd1 = tarray(1)
11372 !***********************************************************
11374 !***********************************************************
11377 ! do 9999 jy = 1,ny-jstag
11379 ! VERY IMPORTANT: SET jy = jgs
11392 IF ( ipconc < 2 ) THEN ! Make a copy of cloud droplet mixing ratio to use for homogeneous freezing
11395 t9(ix,jy,kz) = an(ix,jy,kz,lc)
11401 !..Gather microphysics
11403 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: ENTER GATHER STAGE'
11410 numgs = nxz/ngs + 1
11411 ! write(0,*) 'ICEZVD_GS: ENTER GATHER STAGE: nx,nz,nxz,numgs,ngs = ',nx,nz,nxz,numgs,ngs
11413 do 1000 inumgs = 1,numgs
11417 do ix = nxmpb,itile
11419 pqs(1) = t00(ix,jy,kz)
11420 ! pqs(kz) = t00(ix,jy,kz)
11422 theta(1) = an(ix,jy,kz,lt)
11423 temg(1) = t0(ix,jy,kz)
11424 temcg(1) = temg(1) - tfr
11425 tqvcon = temg(1)-cbw
11426 ltemq = (temg(1)-163.15)/fqsat+1.5
11427 ltemq = Min( nqsat, Max(1,ltemq) )
11428 qvs(1) = pqs(1)*tabqvs(ltemq)
11429 qis(1) = pqs(1)*tabqis(ltemq)
11433 ! IF ( jy .eq. 1 .and. ix .eq. 24 ) THEN
11434 ! write(91,*) 'kz,qv,th: ',kz,an(ix,jy,kz,lv),an(ix,jy,kz,lt),pqs(kz),tabqvs(ltemq),qvs(kz)
11437 if ( temg(1) .lt. tfr ) then
11438 ! if( qcw(kz) .le. qxmin(lc) .and. qci(kz) .gt. qxmin(li))
11439 ! > qss(kz) = qis(kz)
11440 ! if( qcw(kz) .gt. qxmin(lc) .and. qci(kz) .gt. qxmin(li))
11441 ! > qss(kz) = (qcw(kz)*qvs(kz) + qci(kz)*qis(kz)) /
11442 ! > (qcw(kz) + qci(kz))
11445 ! IF ( an(ix,jy,kz,lv) .gt. qss(kz) ) THEN
11446 ! write(iunit,*) 'qss exceeded at ',ix,jy,kz,qss(kz),an(ix,jy,kz,lv),temg(kz)
11447 ! write(iunit,*) 'other temg = ',theta(kz)*(pinit(kz)+p2(ix,jy,kz))
11452 IF ( lhl > 1 ) THEN
11453 IF ( an(ix,jy,kz,lhl) .gt. qxmin(lhl) ) ishail = .true.
11458 if ( an(ix,jy,kz,lv) .gt. qss(1) .or. &
11459 & an(ix,jy,kz,lc) .gt. qxmin(lc) .or. &
11460 & an(ix,jy,kz,li) .gt. qxmin(li) .or. &
11461 & an(ix,jy,kz,lr) .gt. qxmin(lr) .or. &
11462 & an(ix,jy,kz,ls) .gt. qxmin(ls) .or. &
11463 & an(ix,jy,kz,lh) .gt. qxmin(lh) .or. ishail ) then
11464 ngscnt = ngscnt + 1
11467 if ( ngscnt .eq. ngs ) goto 1100
11474 if ( ngscnt .eq. 0 ) go to 9998
11476 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: dbg = 5, ngscnt = ',ngscnt
11478 ! write(0,*) 'allocating qc'
11483 vtxbar(:,:,:) = 0.0
11487 IF ( lnhf > 1 .or. lnhlf > 1 ) chxf(:,:) = 0.0
11491 rimdn(mgs,il) = rimedens ! xdn0(il)
11495 ! define temporaries for state variables to be used in calculations
11497 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: dbg = def temps'
11499 kgsm(mgs) = max(kgs(mgs)-1,1)
11500 kgsp(mgs) = min(kgs(mgs)+1,nz-1)
11501 kgsm2(mgs) = Max(kgs(mgs)-2,1)
11502 theta0(mgs) = an(igs(mgs),jy,kgs(mgs),lt)
11503 thetap(mgs) = an(igs(mgs),jy,kgs(mgs),lt) - theta0(mgs)
11504 theta(mgs) = an(igs(mgs),jy,kgs(mgs),lt)
11505 qv0(mgs) = an(igs(mgs),jy,kgs(mgs),lv)
11506 qwvp(mgs) = an(igs(mgs),jy,kgs(mgs),lv) - qv0(mgs) ! qv0(mgs) is full qv, so qwvp starts as zero!
11508 pres(mgs) = pn(igs(mgs),jy,kgs(mgs)) + pb(kgs(mgs))
11509 pipert(mgs) = p2(igs(mgs),jy,kgs(mgs))
11510 rho0(mgs) = dn(igs(mgs),jy,kgs(mgs))
11511 rhoinv(mgs) = 1.0/rho0(mgs)
11512 rhovt(mgs) = Sqrt(rho00/Max(0.05,rho0(mgs))) ! prevent excessive rhovt
11513 pi0(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs))
11514 temg(mgs) = t0(igs(mgs),jy,kgs(mgs))
11515 temgkm1(mgs) = t0(igs(mgs),jy,kgsm(mgs))
11516 temgkm2(mgs) = t0(igs(mgs),jy,kgsm2(mgs))
11517 pk(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs)) ! t77(igs(mgs),jy,kgs(mgs))
11518 temcg(mgs) = temg(mgs) - tfr
11519 qss0(mgs) = (380.0)/(pres(mgs))
11520 pqs(mgs) = (380.0)/(pres(mgs))
11521 ltemq = (temg(mgs)-163.15)/fqsat+1.5
11522 ltemq = Min( nqsat, Max(1,ltemq) )
11523 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
11524 qis(mgs) = pqs(mgs)*tabqis(ltemq)
11525 qss(mgs) = qvs(mgs)
11526 ! es(mgs) = 6.1078e2*tabqvs(ltemq)
11527 ! eis(mgs) = 6.1078e2*tabqis(ltemq)
11528 cnostmp(mgs) = cno(ls)
11532 if ( temg(mgs) .lt. tfr ) then
11537 IF ( ipconc < 1 .and. lwsm6 ) THEN
11539 tmp = Min( 0.0, temcg(mgs) )
11540 cnostmp(mgs) = Min( 2.e8, 2.e6*exp(0.12*tmp) )
11546 ! zero arrays that are used but not otherwise set (tm)
11552 ! set temporaries for microphysics variables
11556 qx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),il), 0.0)
11567 ! set shape parameters
11569 IF ( imurain == 1 ) THEN
11570 alpha(:,lr) = alphar
11571 ELSEIF ( imurain == 3 ) THEN
11572 alpha(:,lr) = xnu(lr)
11575 alpha(:,li) = xnu(li)
11576 alpha(:,lc) = xnu(lc)
11578 IF ( imusnow == 1 ) THEN
11579 alpha(:,ls) = alphas
11580 ELSEIF ( imusnow == 3 ) THEN
11581 alpha(:,ls) = xnu(ls)
11586 IF ( il .ge. lg ) alpha(mgs,il) = dnu(il)
11590 dab0lh(mgs,il,ic) = dab0(il,ic) ! dab0(ic,il)
11591 dab1lh(mgs,il,ic) = dab1(il,ic) ! dab1(ic,il)
11597 ! DO mgs = 1,ngscnt
11599 da0lx(:,il) = da0(il)
11608 IF ( lzh < 1 .or. lzhl < 1 ) THEN
11609 rzxhlh(:) = rzhl/rz
11610 ELSEIF ( lzh > 1 .and. lzhl > 1 ) THEN
11613 IF ( lzr > 1 ) THEN
11621 IF ( imurain == 1 .and. imusnow == 3 .and. lzr < 1 ) THEN
11623 ELSEIF ( imurain == imusnow .or. lzr > 1 ) THEN
11628 IF ( lhl .gt. 1 ) THEN
11630 da0lhl(mgs) = da0(lhl)
11635 ventrxn(:) = ventrn
11636 gf1palp(:) = gamma_sp(1.0 + alphar)
11639 ! set concentrations
11644 if ( ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) 'ICEZVD_GS: dbg = 5b'
11646 if ( ipconc .ge. 1 ) then
11648 cx(mgs,li) = Max(an(igs(mgs),jy,kgs(mgs),lni), 0.0)
11649 IF ( qx(mgs,li) .le. qxmin(li) ) THEN
11653 IF ( lcina .gt. 1 ) THEN
11654 cina(mgs) = an(igs(mgs),jy,kgs(mgs),lcina)
11656 cina(mgs) = cx(mgs,li)
11658 IF ( lcin > 1 ) THEN
11659 ccin(mgs) = an(igs(mgs),jy,kgs(mgs),lcin)
11663 if ( ipconc .ge. 2 ) then
11665 cx(mgs,lc) = Max(an(igs(mgs),jy,kgs(mgs),lnc), 0.0)
11666 ! cx(mgs,lc) = Min( ccwmx, cx(mgs,lc) )
11667 IF ( qx(mgs,lc) .le. qxmin(lc) ) THEN
11670 IF ( lss > 1 ) THEN
11671 ssmax(mgs) = an(igs(mgs),jy,kgs(mgs),lss)
11673 IF ( lccn .gt. 1 ) THEN
11674 ccnc(mgs) = an(igs(mgs),jy,kgs(mgs),lccn)
11678 IF ( lccna .gt. 1 ) THEN
11679 ccna(mgs) = an(igs(mgs),jy,kgs(mgs),lccna)
11681 ccna(mgs) = cx(mgs,lc)
11685 ! cx(mgs,lc) = Abs(ccn)
11687 if ( ipconc .ge. 3 ) then
11689 cx(mgs,lr) = Max(an(igs(mgs),jy,kgs(mgs),lnr), 0.0)
11690 IF ( qx(mgs,lr) .le. qxmin(lr) ) THEN
11692 ELSEIF ( cx(mgs,lr) .eq. 0.0 .and. qx(mgs,lr) .lt. 3.0*qxmin(lr) ) THEN
11693 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,lr)
11696 cx(mgs,lr) = Max( 1.e-9, cx(mgs,lr) )
11700 if ( ipconc .ge. 4 ) then
11702 cx(mgs,ls) = Max(an(igs(mgs),jy,kgs(mgs),lns), 0.0)
11703 IF ( qx(mgs,ls) .le. qxmin(ls) ) THEN
11705 ELSEIF ( cx(mgs,ls) .eq. 0.0 .and. qx(mgs,ls) .lt. 3.0*qxmin(ls) ) THEN
11706 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,ls)
11709 cx(mgs,ls) = Max( 1.e-9, cx(mgs,ls) )
11711 IF ( ilimit .ge. ipc(ls) ) THEN
11712 tmp = (xdn0(ls)*cx(mgs,ls))/(rho0(mgs)*qx(mgs,ls))
11713 tmp2 = (tmp*(3.14159))**(1./3.)
11714 cnox = cx(mgs,ls)*(tmp2)
11715 IF ( cnox .gt. 3.0*cno(ls) ) THEN
11716 cx(mgs,ls) = 3.0*cno(ls)/tmp2
11722 if ( ipconc .ge. 5 ) then
11725 cx(mgs,lh) = Max(an(igs(mgs),jy,kgs(mgs),lnh), 0.0)
11726 IF ( qx(mgs,lh) .le. qxmin(lh) ) THEN
11728 ELSEIF ( cx(mgs,lh) .eq. 0.0 .and. qx(mgs,lh) .lt. 3.0*qxmin(lh) ) THEN
11729 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,lh)
11732 cx(mgs,lh) = Max( 1.e-9, cx(mgs,lh) )
11733 IF ( ilimit .ge. ipc(lh) ) THEN
11734 tmp = (xdn0(lh)*cx(mgs,lh))/(rho0(mgs)*qx(mgs,lh))
11735 tmp2 = (tmp*(3.14159))**(1./3.)
11736 cnox = cx(mgs,lh)*(tmp2)
11737 IF ( cnox .gt. 3.0*cno(lh) ) THEN
11738 cx(mgs,lh) = 3.0*cno(lh)/tmp2
11749 if ( lhl .gt. 1 .and. ipconc .ge. 5 ) then
11752 cx(mgs,lhl) = Max(an(igs(mgs),jy,kgs(mgs),lnhl), 0.0)
11753 IF ( qx(mgs,lhl) .le. qxmin(lhl) ) THEN
11755 ELSEIF ( cx(mgs,lhl) .eq. 0.0 .and. qx(mgs,lhl) .lt. 3.0*qxmin(lhl) ) THEN
11756 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,lhl)
11759 cx(mgs,lhl) = Max( 1.e-9, cx(mgs,lhl) )
11760 IF ( ilimit .ge. ipc(lhl) ) THEN
11761 tmp = (xdn0(lhl)*cx(mgs,lhl))/(rho0(mgs)*qx(mgs,lhl))
11762 tmp2 = (tmp*(3.14159))**(1./3.)
11763 cnox = cx(mgs,lhl)*(tmp2)
11764 IF ( cnox .gt. 3.0*cno(lhl) ) THEN
11765 cx(mgs,lhl) = 3.0*cno(lhl)/tmp2
11775 ! Set mean particle volume
11783 IF ( lvol(il) .ge. 1 ) THEN
11786 vx(mgs,il) = Max(an(igs(mgs),jy,kgs(mgs),lvol(il)), 0.0)
11797 ! Set liquid water fraction
11811 ssi(mgs) = qx(mgs,lv)/qis(mgs)
11812 ssw(mgs) = qx(mgs,lv)/qvs(mgs)
11814 tsqr(mgs) = temg(mgs)**2
11816 temgx(mgs) = min(temg(mgs),313.15)
11817 temgx(mgs) = max(temgx(mgs),233.15)
11818 felv(mgs) = 2500837.367 * (273.15/temgx(mgs))**((0.167)+(3.67e-4)*temgx(mgs))
11820 temcgx(mgs) = min(temg(mgs),273.15)
11821 temcgx(mgs) = max(temcgx(mgs),223.15)
11822 temcgx(mgs) = temcgx(mgs)-273.15
11824 ! felf = latent heat of fusion, fels = LH of sublimation, felv = LH of vaporization
11825 felf(mgs) = 333690.6098 + (2030.61425)*temcgx(mgs) - (10.46708312)*temcgx(mgs)**2
11827 fels(mgs) = felv(mgs) + felf(mgs)
11829 felvs(mgs) = felv(mgs)*felv(mgs)
11830 felss(mgs) = fels(mgs)*fels(mgs)
11832 IF ( eqtset <= 1 ) THEN
11833 felvcp(mgs) = felv(mgs)*cpi
11834 felscp(mgs) = fels(mgs)*cpi
11835 felfcp(mgs) = felf(mgs)*cpi
11838 ! equations from appendix in Bryan and Morrison (2012, MWR)
11839 ! note that rw is Rv in the paper, and rd is R.
11841 tmp = qx(mgs,li)+qx(mgs,ls)+qx(mgs,lh)
11842 IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
11843 cvm = cv+cvv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
11846 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
11847 felvcp(mgs) = (felv(mgs)-rw*temg(mgs))/cvm
11848 felscp(mgs) = (fels(mgs)-rw*temg(mgs))/cvm
11849 felfcp(mgs) = felf(mgs)/cvm
11852 ! equivalent version that applies separate updates of latent heating to theta and pi, when both are returned.
11854 cpm = cp+cpv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
11856 rmm=rd+rw*qx(mgs,lv)
11858 felvcp(mgs) = (felv(mgs)*cv/(cp) - rw*temg(mgs)*(1.0-rovcp*cpm/rmm))/cvm
11859 felscp(mgs) = (fels(mgs)*cv/(cp) - rw*temg(mgs)*(1.0-rovcp*cpm/rmm))/cvm
11860 felfcp(mgs) = felf(mgs)*cv/(cp*cvm)
11862 felvpi(mgs) = pi0(mgs)*rovcp*(felv(mgs)/(temg(mgs)) - rw*cpm/rmm)/cvm
11863 felspi(mgs) = pi0(mgs)*rovcp*(fels(mgs)/(temg(mgs)) - rw*cpm/rmm)/cvm
11864 felfpi(mgs) = pi0(mgs)*rovcp*(felf(mgs)/(cvm*temg(mgs)))
11870 fgamw(mgs) = felvcp(mgs)/pi0(mgs)
11871 fgams(mgs) = felscp(mgs)/pi0(mgs)
11873 fcqv1(mgs) = 4098.0258*pi0(mgs)*fgamw(mgs)
11874 fcqv2(mgs) = 5807.6953*pi0(mgs)*fgams(mgs)
11875 fcc3(mgs) = felfcp(mgs)/pi0(mgs)
11877 ! fwvdf = water vapor diffusivity
11878 fwvdf(mgs) = (2.11e-05)*((temg(mgs)/tfr)**1.94)*(101325.0/(pres(mgs)))
11880 ! fadvisc = 'd' for dynamic viscosity
11881 ! fakvisc = 'k' for kinematic viscosity
11882 fadvisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))*(temg(mgs)/296.0)**(1.5) ! dynamic visc.
11884 fakvisc(mgs) = fadvisc(mgs)*rhoinv(mgs) ! divide by rho_air to get kinematic visc. (note the 'k' vs. 'd')
11886 temcgx(mgs) = min(temg(mgs),273.15)
11887 temcgx(mgs) = max(temcgx(mgs),233.15)
11888 temcgx(mgs) = temcgx(mgs)-273.15
11889 fci(mgs) = (2.118636 + 0.007371*(temcgx(mgs)))*(1.0e+03)
11891 if ( temg(mgs) .lt. 273.15 ) then
11892 temcgx(mgs) = min(temg(mgs),273.15)
11893 temcgx(mgs) = max(temcgx(mgs),233.15)
11894 temcgx(mgs) = temcgx(mgs)-273.15
11895 fcw(mgs) = 4203.1548 + (1.30572e-2)*((temcgx(mgs)-35.)**2) &
11896 & + (1.60056e-5)*((temcgx(mgs)-35.)**4)
11898 if ( temg(mgs) .ge. 273.15 ) then
11899 temcgx(mgs) = min(temg(mgs),308.15)
11900 temcgx(mgs) = max(temcgx(mgs),273.15)
11901 temcgx(mgs) = temcgx(mgs)-273.15
11902 fcw(mgs) = 4243.1688 + (3.47104e-1)*(temcgx(mgs)**2)
11905 ftka(mgs) = tka0*fadvisc(mgs)/advisc1 ! thermal conductivity: proportional to dynamic viscosity
11906 fthdf(mgs) = ftka(mgs)*cpi*rhoinv(mgs)
11908 fschm(mgs) = (fakvisc(mgs)/fwvdf(mgs)) ! Schmidt number
11909 fpndl(mgs) = (fakvisc(mgs)/fthdf(mgs)) ! Prandl number (only used for bin melting)
11911 fai(mgs) = (fels(mgs)**2)/(ftka(mgs)*rw*temg(mgs)**2)
11912 fbi(mgs) = (1.0/(rho0(mgs)*fwvdf(mgs)*qis(mgs)))
11913 fav(mgs) = (felv(mgs)**2)/(ftka(mgs)*rw*temg(mgs)**2)
11914 fbv(mgs) = (1.0/(rho0(mgs)*fwvdf(mgs)*qvs(mgs)))
11916 kp1 = Min(nz, kgs(mgs)+1 )
11917 wvel(mgs) = (0.5)*(w(igs(mgs),jgs,kp1) &
11918 & +w(igs(mgs),jgs,kgs(mgs)))
11924 ! ice habit fractions
11930 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: Set density'
11934 xdn(mgs,li) = xdn0(li)
11935 xdn(mgs,lc) = xdn0(lc)
11936 xdn(mgs,lr) = xdn0(lr)
11937 xdn(mgs,ls) = xdn0(ls)
11938 xdn(mgs,lh) = xdn0(lh)
11939 IF ( lvol(ls) .gt. 1 ) THEN
11940 IF ( vx(mgs,ls) .gt. 0.0 .and. qx(mgs,ls) .gt. qxmin(ls) ) THEN
11941 xdn(mgs,ls) = Min( xdnmx(ls), Max( xdnmn(ls), rho0(mgs)*qx(mgs,ls)/vx(mgs,ls) ) )
11945 IF ( lvol(lh) .gt. 1 ) THEN
11946 IF ( vx(mgs,lh) .gt. 0.0 .and. qx(mgs,lh) .gt. qxmin(lh) ) THEN
11947 IF ( mixedphase ) THEN
11951 xdn(mgs,lh) = Min( dnmx, Max( xdnmn(lh), rho0(mgs)*qx(mgs,lh)/vx(mgs,lh) ) )
11952 vx(mgs,lh) = rho0(mgs)*qx(mgs,lh)/xdn(mgs,lh)
11954 ELSEIF ( vx(mgs,lh) == 0.0 .and. qx(mgs,lh) .gt. qxmin(lh) ) THEN ! if volume is zero, need to initialize the default value
11956 vx(mgs,lh) = rho0(mgs)*qx(mgs,lh)/xdn(mgs,lh)
11962 IF ( lhl .gt. 1 ) THEN
11964 xdn(mgs,lhl) = xdn0(lhl)
11966 IF ( lvol(lhl) .gt. 1 ) THEN
11967 IF ( vx(mgs,lhl) .gt. 0.0 .and. qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
11969 IF ( mixedphase .and. lhlw > 1 ) THEN
11974 xdn(mgs,lhl) = Min( dnmx, Max( xdnmn(lhl), rho0(mgs)*qx(mgs,lhl)/vx(mgs,lhl) ) )
11975 vx(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/xdn(mgs,lhl)
11977 ELSEIF ( vx(mgs,lhl) == 0.0 .and. qx(mgs,lhl) .gt. qxmin(lhl) ) THEN ! if volume is zero, need to initialize the default value
11979 vx(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/xdn(mgs,lhl)
11990 IF ( imurain == 3 ) THEN
11991 IF ( lzr > 1 ) THEN
11993 alphamlr = -2.0/3.0
11998 ! massfacshr = ( (2. + 3.*(1. +alphashr) )/( 3.*(1. + alphashr) ) )**(1./3.) ! this is the diameter factor
11999 ! massfacmlr = ( (2. + 3.*(1. +alphamlr) )/( 3.*(1. + alphamlr) ) )**(1./3.)
12000 massfacshr = ( (2. + 3.*(1. +alphashr) )**3/( 3.*(1. + alphashr) ) ) ! this is the mass or volume factor
12001 massfacmlr = ( (2. + 3.*(1. +alphamlr) )**3/( 3.*(1. + alphamlr) ) )
12002 ELSEIF ( imurain == 1 ) THEN
12003 IF ( lzr > 1 ) THEN
12010 ! massfacshr = (3.0 + alphashr)*((3.+alphashr)*(2.+alphashr)*(1. + alphashr) )**(-1./3.) ! this is the diameter factor
12011 ! massfacmlr = (3.0 + alphamlr)*((3.+alphamlr)*(2.+alphamlr)*(1. + alphamlr) )**(-1./3.)
12012 massfacshr = (3.0 + alphashr)**3/((3.+alphashr)*(2.+alphashr)*(1. + alphashr) ) ! this is the mass or volume factor
12013 massfacmlr = (3.0 + alphamlr)**3/((3.+alphamlr)*(2.+alphamlr)*(1. + alphamlr) )
12018 ! set some values for ice nucleation
12021 kp1 = Min(nz, kgs(mgs)+1 )
12022 ! wvel(mgs) = (0.5)*(w(igs(mgs),jgs,kp1) &
12023 ! & +w(igs(mgs),jgs,kgs(mgs)))
12026 wvelkm1(mgs) = (0.5)*(w(igs(mgs),jgs,kgs(mgs)) &
12027 & +w(igs(mgs),jgs,kgsm(mgs)))
12028 cninm(mgs) = t7(igs(mgs),jgs,kgsm(mgs))
12029 cnina(mgs) = t7(igs(mgs),jgs,kgs(mgs))
12030 cninp(mgs) = t7(igs(mgs),jgs,kgsp(mgs))
12034 ! Set a couple of cloud variables...
12037 ! SUBROUTINE setvt(ngscnt,qx,qxmin,cx,rho0,rhovt,xdia,cno,
12038 ! : xmas,xdn,xvmn,xvmx,xv,cdx,
12040 ! SUBROUTINE setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno, &
12041 ! & xmas,vtxbar,xdn,xvmn,xvmx,xv,cdx, &
12042 ! & ipconc1,ndebug1,ngs,nz,kgs,cwnccn,fadvisc, &
12043 ! & cwmasn,cwmasx,cwradn,cnina,cimna,cimxa, &
12044 ! & itype1a,itype2a,temcg,infdo,alpha)
12048 IF ( rimdenvwgt > 0 ) infdo = 1
12050 call setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno,cnostmp, &
12051 & xmas,vtxbar,xdn,xvmn,xvmx,xv,cdx,cdxgs, &
12052 & ipconc,ndebug,ngs,nz,kgs,fadvisc, &
12053 & cwmasn,cwmasx,cwradn,cnina,cimn,cimx, &
12054 & itype1,itype2,temcg,infdo,alpha,0,axx,bxx) ! ,cdh,cdhl)
12055 ! & itype1,itype2,temcg,infdo,alpha,0,axh,bxh,axhl,bxhl) ! ,cdh,cdhl)
12058 IF ( lwsm6 .and. ipconc == 0 ) THEN
12059 tmp = Max(qxmin(lh), qxmin(ls))
12061 sum = qx(mgs,lh) + qx(mgs,ls)
12062 IF ( sum > tmp ) THEN
12063 vt2ave(mgs) = (qx(mgs,lh)*vtxbar(mgs,lh,1) + qx(mgs,ls)*vtxbar(mgs,ls,1))/sum
12072 ! Set number concentrations (need xdia from setvt)
12074 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: Set concentration'
12075 IF ( ipconc .lt. 1 ) THEN
12076 cina(1:ngscnt) = cx(1:ngscnt,li)
12078 if ( ipconc .lt. 5 ) then
12082 IF ( ipconc .lt. 3 ) THEN
12084 if ( qx(mgs,lr) .gt. qxmin(lh) ) then
12085 ! cx(mgs,lr) = cno(lr)*xdia(mgs,lr,1)
12086 ! xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr))
12090 IF ( ipconc .lt. 4 ) THEN
12093 if ( qx(mgs,ls) .gt. qxmin(ls) ) then
12094 ! cx(mgs,ls) = cno(ls)*xdia(mgs,ls,1)
12095 ! xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*cx(mgs,ls))
12097 ENDIF ! ( ipconc .lt. 4 )
12099 IF ( ipconc .lt. 5 ) THEN
12103 if ( qx(mgs,lh) .gt. qxmin(lh) ) then
12104 ! cx(mgs,lh) = cno(lh)*xdia(mgs,lh,1)
12105 ! xv(mgs,lh) = Max(xvmn(lh), rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) )
12106 ! xdia(mgs,lh,3) = (xv(mgs,lh)*6./pi)**(1./3.)
12109 ENDIF ! ( ipconc .lt. 5 )
12114 IF ( ipconc .ge. 2 ) THEN
12117 rb(mgs) = 0.5*xdia(mgs,lc,1)*(1./(1.+alpha(mgs,lc)))**(1./6.)
12118 xl2p(mgs) = Max(0.0d0, 2.7e-2*xdn(mgs,lc)*cx(mgs,lc)*xv(mgs,lc)* &
12119 & ((0.5e20*rb(mgs)**3*xdia(mgs,lc,1))-0.4) )
12120 IF ( rb(mgs) .gt. 3.51e-6 ) THEN
12121 ! rh(mgs) = Max( 0.5d0*xdia(mgs,lc,1), 6.3d-4/(1.d6*(rb(mgs) - 3.5d-6)) )
12122 rh(mgs) = Max( 41.d-6, 6.3d-4/(1.d6*(rb(mgs) - 3.5d-6)) )
12126 IF ( xl2p(mgs) .gt. 0.0 ) THEN
12127 nh(mgs) = 4.2d9*xl2p(mgs)
12138 ! maximum depletion tendency by any one source
12141 if( ndebug .ge. 0 ) THEN
12142 !mpi! write(0,*) 'Set depletion max/min1'
12145 qvimxd(mgs) = 0.70*(qx(mgs,lv)-qis(mgs))*dtpinv ! depletion by all vap. dep to ice.
12147 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
12149 qvimxd(mgs) = max(qvimxd(mgs), 0.0)
12152 qimxd(mgs) = frac*qx(mgs,li)*dtpinv
12153 qcmxd(mgs) = frac*qx(mgs,lc)*dtpinv
12154 qrmxd(mgs) = frac*qx(mgs,lr)*dtpinv
12155 qsmxd(mgs) = frac*qx(mgs,ls)*dtpinv
12156 qhmxd(mgs) = frac*qx(mgs,lh)*dtpinv
12157 IF ( lhl > 1 ) qhlmxd(mgs) = frac*qx(mgs,lhl)*dtpinv
12160 if( ndebug .ge. 0 ) THEN
12161 !mpi! write(0,*) 'Set depletion max/min2'
12166 if ( qx(mgs,lc) .le. qxmin(lc) ) then
12167 ccmxd(mgs) = 0.20*cx(mgs,lc)*dtpinv
12169 IF ( ipconc .ge. 2 ) THEN
12170 ccmxd(mgs) = frac*cx(mgs,lc)*dtpinv
12172 ccmxd(mgs) = frac*qx(mgs,lc)/(xmas(mgs,lc)*rho0(mgs)*dtp)
12176 if ( qx(mgs,li) .le. qxmin(li) ) then
12177 cimxd(mgs) = frac*cx(mgs,li)*dtpinv
12179 IF ( ipconc .ge. 1 ) THEN
12180 cimxd(mgs) = frac*cx(mgs,li)*dtpinv
12182 cimxd(mgs) = frac*qx(mgs,li)/(xmas(mgs,li)*rho0(mgs)*dtp)
12187 crmxd(mgs) = 0.10*cx(mgs,lr)*dtpinv
12188 csmxd(mgs) = frac*cx(mgs,ls)*dtpinv
12189 chmxd(mgs) = frac*cx(mgs,lh)*dtpinv
12191 ccmxd(mgs) = frac*cx(mgs,lc)*dtpinv
12192 cimxd(mgs) = frac*cx(mgs,li)*dtpinv
12193 crmxd(mgs) = frac*cx(mgs,lr)*dtpinv
12194 csmxd(mgs) = frac*cx(mgs,ls)*dtpinv
12195 chmxd(mgs) = frac*cx(mgs,lh)*dtpinv
12197 qxmxd(mgs,lv) = Max(0.0, 0.1*(qx(mgs,lv) - qvs(mgs))*dtpinv)
12200 qxmxd(mgs,il) = frac*qx(mgs,il)*dtpinv
12201 cxmxd(mgs,il) = frac*cx(mgs,il)*dtpinv
12213 ! default factors between mean volume and maximum mass volume
12214 maxmassfac(lc) = ( (2. + 3.*(1. + xnu(lc)) )**3/( 3.*(1. + xnu(lc)) ) )
12215 maxmassfac(li) = ( (2. + 3.*(1. + xnu(li)) )**3/( 3.*(1. + xnu(li)) ) )
12217 IF ( imurain == 3 ) THEN
12218 maxmassfac(lr) = ( (2. + 3.*(1. + xnu(lr)) )**3/( 3.*(1. + xnu(lr)) ) )
12220 maxmassfac(lr) = (3.0 + alphar)**3/ &
12221 & ((3.+alphar)*(2.+alphar)*(1. + alphar) )
12224 IF ( imusnow == 3 ) THEN
12225 maxmassfac(ls) = ( (2. + 3.*(1. + alphas) )**3/( 3.*(1. + alphas) ) )
12227 maxmassfac(ls) = (3.0 + alphas)**3/ &
12228 & ((3.+alphas)*(2.+alphas)*(1. + alphas) )
12231 maxmassfac(lh) = (3.0 + alphah)**3/ &
12232 & ((3.+alphah)*(2.+alphah)*(1. + alphah) )
12234 IF ( lhl > 1 ) THEN
12235 maxmassfac(lhl) = (3.0 + alphahl)**3/ &
12236 & ((3.+alphahl)*(2.+alphahl)*(1. + alphahl) )
12242 DO il = lh,lhab ! graupel and hail only (and frozen drops)
12244 vshdgs(mgs,il) = vshd ! base value
12246 IF ( qx(mgs,il) > qxmin(il) ) THEN
12248 ! tmpdiam is weighted diameter of d^(shedalp-1), so for shedalp=3, this is the area-weighted diameter or maximum mass diameter.
12249 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
12251 IF ( tmpdiam > sheddiam0 ) THEN
12252 vshdgs(mgs,il) = 0.523599*(1.5e-3)**3/massfacshr ! 1.5mm drops from very large ice
12253 ELSEIF ( tmpdiam > sheddiam ) THEN ! intermediate size
12254 vshdgs(mgs,il) = 0.523599*(3.0e-3)**3/massfacshr ! 3.0mm drops from medium-large ice
12256 ! vshdgs(mgs,il) = Min( xvmx(lr), xv(mgs,il)*xdn(mgs,il)*0.001 ) ! size of drop from melted mean ice particle
12257 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
12265 ! microphysics source terms (1/s) for mixing ratios
12269 ! Collection efficiencies:
12271 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: Set collection efficiencies'
12297 ehi(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehi*ehiclsn
12298 ehis(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehi*ehiclsn
12299 ehli(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehli*ehliclsn
12300 ehlis(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehli*ehliclsn
12305 ehs(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehs*ehsclsn
12306 ehls(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehls*ehlsclsn
12315 ehlsclsn(mgs) = 0.0
12316 ehliclsn(mgs) = 0.0
12321 IF ( exwmindiam > 0 .and. qx(mgs,lc) > qxmin(lc) ) THEN
12322 tmp = cx(mgs,lc)*Exp(- (exwmindiam/xdia(mgs,lc,1))**3 )
12323 ccwresv(mgs) = Min( cx(mgs,lc), Max( 2.e6, cx(mgs,lc) - tmp ) )
12325 tmp = cx(mgs,lc) - ccwresv(mgs)
12327 volt = pi/6.*(exwmindiam)**3
12328 qcwresv(mgs) = qx(mgs,lc) - tmp*xdn0(lc)*rhoinv(mgs)*(volt + xv(mgs,lc))
12331 IF ( .false. .and. qx(mgs,lc) > 0.1e-3 ) THEN
12333 write(0,*) 'cx,qx,crsv,qrsv = ',cx(mgs,lc),qx(mgs,lc),ccwresv(mgs),qcwresv(mgs)
12341 IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN
12342 cwrad = 0.5*xdia(mgs,lc,1)
12344 IF ( cwrad .ge. 1.e-6*cwr(il,1) ) icwr(mgs) = il
12350 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
12351 rwrad = 0.5*xdia(mgs,lr,3) ! changed to mean volume diameter (10/6/06)
12353 IF ( rwrad .ge. 1.e-6*grad(il,1) ) irwr(mgs) = il
12359 ! IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
12360 ! rwrad = 0.5*xdia(mgs,lr,1)
12361 ! setting erw = 1 always, so now use igwr for graupel
12362 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
12363 rwrad = 0.5*xdia(mgs,lh,3) ! changed to mean volume diameter (10/6/06)
12365 IF ( rwrad .ge. 1.e-6*grad(il,1) ) igwr(mgs) = il
12370 IF ( lhl .gt. 1 ) THEN ! hail is turned on
12372 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
12373 rwrad = 0.5*xdia(mgs,lhl,3) ! changed to mean volume diameter (10/6/06)
12375 IF ( rwrad .ge. 1.e-6*grad(il,1) ) ihlr(mgs) = il
12382 ! Ice-Ice: Collection (cxc) efficiencies
12385 if ( qx(mgs,li) .gt. qxmin(li) ) then
12386 ! IF ( ipconc .ge. 14 ) THEN
12387 ! eii(mgs)=0.1*exp(0.1*temcg(mgs))
12388 ! if ( temg(mgs) .lt. 243.15 .and. qx(mgs,lc) .gt. 1.e-6 ) then
12393 eii(mgs) = exp(0.025*Min(temcg(mgs),0.0)) ! alpha1 from LFO83 (21)
12395 if ( temg(mgs) .gt. 273.15 ) eii(mgs) = 1.0
12400 ! Ice-cloud water: Collection (cxc) efficiencies
12404 if ( qx(mgs,li).gt.qxmin(li) .and. qx(mgs,lc).gt.qxmin(lc) ) then
12407 if (xdia(mgs,lc,1).gt.15.0e-06 .and. xdia(mgs,li,1).gt.30.0e-06) then
12408 ! erm 5/10/2007 test following change:
12409 ! if (xdia(mgs,lc,1).gt.12.0e-06 .and. xdia(mgs,li,1).gt.50.0e-06) then
12412 if ( temg(mgs) .ge. 273.15 ) eiw(mgs) = 0.0
12418 ! Rain: Collection (cxc) efficiencies
12421 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,lc).gt.qxmin(lc) ) then
12423 IF ( lnr .gt. 1 ) THEN
12428 ! cwrad = 0.5*xdia(mgs,lc,1)
12430 ! > min((aradcw + cwrad*(bradcw + cwrad*
12431 ! < (cradcw + cwrad*(dradcw)))), 1.0)
12432 ! IF ( xdia(mgs,lc,1) .lt. 2.4e-06 .or. xdia(mgs,lr,1) .le. 50.0e-6 ) THEN
12435 ! erw(mgs) = ew(icwr(mgs),igwr(mgs))
12436 ! interpolate along droplet radius
12438 icp1 = Min( 8, ic+1 )
12440 irp1 = Min( 6, ir+1 )
12441 cwrad = 0.5*xdia(mgs,lc,3)
12442 rwrad = 0.5*xdia(mgs,lr,3)
12444 slope1 = (ew(icp1, ir ) - ew(ic,ir ))*cwr(ic,2)
12445 slope2 = (ew(icp1, irp1) - ew(ic,irp1))*cwr(ic,2)
12447 ! write(iunit,*) 'slop1: ',slope1,slope2,ew(ic,ir),cwr(ic,2)
12449 x1 = ew(ic, ir) + slope1*Max(0.0, (cwrad - cwr(ic,1)) )
12450 x2 = ew(icp1,ir) + slope2*Max(0.0, (cwrad - cwr(ic,1)) )
12452 slope1 = (x2 - x1)*grad(ir,2)
12454 erw(mgs) = Max(0.0, x1 + slope1*Max(0.0, (rwrad - grad(ir,1)) ))
12456 ! write(iunit,*) 'erw: ',erw(mgs),1.e6*cwrad,1.e6*rwrad,ic,ir,x1,x2
12459 erw(mgs) = Max(0.0, erw(mgs) )
12460 IF ( rwrad .lt. 50.e-6 ) THEN
12462 ELSEIF ( rwrad .lt. 100.e-6 ) THEN ! linear change from zero at 50 to erw at 100 microns
12463 erw(mgs) = erw(mgs)*(rwrad - 50.e-6)/50.e-6
12468 IF ( cx(mgs,lc) .le. 0.0 ) erw(mgs) = 0.0
12470 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,lr).gt.qxmin(lr) ) then
12474 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,ls).gt.qxmin(ls) ) then
12478 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,li).gt.qxmin(li) ) then
12479 ! IF ( vtxbar(mgs,lr,1) .gt. vtxbar(mgs,li,1) .and.
12480 ! : xdia(mgs,lr,3) .gt. 200.e-6 .and. xdia(mgs,li,3) .gt. 100.e-6 ) THEN
12482 ! cwrad = 0.5*xdia(mgs,li,3)
12484 ! > 1.0*min((aradcw + cwrad*(bradcw + cwrad*
12485 ! < (cradcw + cwrad*(dradcw)))), 1.0)
12487 ! if ( xdia(mgs,li,1) .lt. 10.e-6 ) eri(mgs)=0.0
12488 if ( xdia(mgs,li,3) .lt. eri_cimin ) eri(mgs)=0.0
12492 ! Snow aggregates: Collection (cxc) efficiencies
12494 ! Modified by ERM with a linear function for small droplets and large
12495 ! snow agg. based numerical data from Wang and Ji (1992) in P&K 1997 (Fig. 14-13), which
12496 ! allows collection of very small droplets, albeit at low efficiency. But slow
12497 ! fall speeds of snow make up for the efficiency.
12500 if ( qx(mgs,ls).gt.qxmin(ls) .and. qx(mgs,lc).gt.qxmin(lc) ) then
12502 if ( xdia(mgs,lc,1) .gt. 15.e-6 .and. xdia(mgs,ls,1) .gt. 100.e-6) then
12504 ELSEIF ( xdia(mgs,ls,1) .ge. 500.e-6 ) THEN
12505 esw(mgs) = Min(0.5, 0.05 + (0.8-0.05)/(40.e-6)*xdia(mgs,lc,1) )
12509 if ( qx(mgs,ls).gt.qxmin(ls) .and. qx(mgs,lr).gt.qxmin(lr) &
12510 & .and. temg(mgs) .lt. tfr - 1. &
12512 esr(mgs)=Exp(-(40.e-6)**3/xv(mgs,lr))*Exp(-40.e-6/xdia(mgs,ls,1))
12513 IF ( qx(mgs,ls) < 1.e-4 .and. qx(mgs,lr) < 1.e-4 ) il2(mgs) = 1
12516 IF ( ipconc < 3 .and. temg(mgs) < tfr .and. qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,lr) < 1.e-4 ) THEN
12520 ! if ( qx(mgs,ls).gt.qxmin(ls) ) then
12521 if ( temcg(mgs) < 0.0 ) then
12523 IF ( ipconc .lt. 4 .or. temcg(mgs) < esstem1 ) THEN
12525 ! ess(mgs)=0.1*exp(0.1*min(temcg(mgs),0.0))
12526 ! ess(mgs)=min(0.1,ess(mgs))
12531 IF ( .true. .and. ess0 < 0.0 ) THEN
12532 ! IF ( wvel(mgs) > 2.0 .or. wvel(mgs) < -0.5 .or. ssi(mgs) < 1.0 ) THEN
12533 IF ( wvel(mgs) > 2.0 ) THEN
12534 ! assume convective cell or downdraft
12536 ELSEIF ( wvel(mgs) > 1.0 ) THEN ! transition to stratiform range of values
12537 fac = Max(0.0, 2.0 - wvel(mgs))*fac
12541 IF ( temcg(mgs) > esstem1 .and. temcg(mgs) < esstem2 ) THEN ! only nonzero for T > -25
12542 ess(mgs) = fac*Exp(ess1*(esstem2) )*(temcg(mgs) - esstem1)/(esstem2 - esstem1) ! linear ramp up from zero at esstem1 to value at esstem2
12543 ELSEIF ( temcg(mgs) >= esstem2 ) THEN
12544 ess(mgs) = fac*Exp(ess1*Min( temcg(mgs), 0.0 ) )
12550 if ( qx(mgs,ls).gt.qxmin(ls) .and. qx(mgs,li).gt.qxmin(li) ) then
12551 esiclsn(mgs) = esi_collsn
12552 ! IF ( ipconc .lt. 4 ) THEN
12553 IF ( ipconc < 1 .and. lwsm6 ) THEN
12554 esi(mgs) = exp(0.7*min(temcg(mgs),0.0))
12556 esi(mgs) = esi0*exp(0.1*min(temcg(mgs),0.0))
12557 esi(mgs) = Min(0.1,esi(mgs))
12559 IF ( ipconc .le. 3 ) THEN
12560 esi(mgs) = exp(0.025*min(temcg(mgs),0.0)) ! LFO
12561 ! esi(mgs) = Min(0.5, exp(0.025*min(temcg(mgs),0.0)) ) ! LFO
12562 ! esi(mgs)=0.5*exp(0.1*min(temcg(mgs),0.0)) ! 10ice
12564 ! ELSE ! zrnic/ziegler 1993
12565 ! esi(mgs)= 0.1 ! 0.5*exp(0.1*min(temcg(mgs),0.0))
12567 if ( temg(mgs) .gt. 273.15 ) esi(mgs) = 0.0
12573 ! Graupel: Collection (cxc) efficiencies
12576 xmascw(mgs) = xmas(mgs,lc)
12577 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lc).gt.qxmin(lc) ) then !{
12579 IF ( iehw .eq. 0 ) THEN
12580 ehw(mgs) = ehw0 ! default value is 1.0
12581 ELSEIF ( iehw .eq. 1 .or. iehw .eq. 10 ) THEN
12582 cwrad = 0.5*xdia(mgs,lc,1)
12583 ehw(mgs) = Min( ehw0, &
12584 & ewfac*min((aradcw + cwrad*(bradcw + cwrad* &
12585 & (cradcw + cwrad*(dradcw)))), 1.0) )
12587 ELSEIF ( iehw .eq. 2 .or. iehw .eq. 10 ) THEN
12589 icp1 = Min( 8, ic+1 )
12591 irp1 = Min( 6, ir+1 )
12592 cwrad = 0.5*xdia(mgs,lc,1)
12593 rwrad = 0.5*xdia(mgs,lh,3) ! changed to mean volume diameter
12595 slope1 = (ew(icp1, ir ) - ew(ic,ir ))*cwr(ic,2)
12596 slope2 = (ew(icp1, irp1) - ew(ic,irp1))*cwr(ic,2)
12598 ! write(iunit,*) 'slop1: ',slope1,slope2,ew(ic,ir),cwr(ic,2)
12600 x1 = ew(ic, ir) + slope1*Max(0.0, (cwrad - cwr(ic,1)) )
12601 x2 = ew(icp1,ir) + slope2*Max(0.0, (cwrad - cwr(ic,1)) )
12603 slope1 = (x2 - x1)*grad(ir,2)
12605 tmp = Max( 0.0, Min( 1.0, x1 + slope1*Max(0.0, (rwrad - grad(ir,1)) ) ) )
12606 ehw(mgs) = Min( ehw(mgs), tmp )
12608 ! write(iunit,*) 'ehw: ',ehw(mgs),1.e6*cwrad,1.e6*rwrad,ic,ir,x1,x2
12611 ! ehw(mgs) = Max( 0.2, ehw(mgs) )
12612 ! assume that ehw = 1 for zero air resistance (rho0 = 0.0) and extrapolate toward that
12613 ! ehw(mgs) = ehw(mgs) + (ehw(mgs) - 1.0)*(rho0(mgs) - rho00)/rho00
12614 ! ehw(mgs) = ehw(mgs) + (1.0 - ehw(mgs))*((Max(0.0,rho00 - rho0(mgs)))/rho00)**2
12616 ELSEIF ( iehw .eq. 3 .or. iehw .eq. 10 ) THEN ! use fraction of droplets greater than dmincw diameter
12617 tmp = Exp(- (dmincw/xdia(mgs,lc,1))**3)
12618 xmascw(mgs) = xmas(mgs,lc) + xdn0(lc)*(pi*dmincw**3/6.0) ! this is the average mass of the droplets with d > dmincw
12619 ehw(mgs) = Min( ehw(mgs), tmp )
12620 ELSEIF ( iehw .eq. 4 .or. iehw .eq. 10 ) THEN ! Cober and List 1993, eq. 19-20
12622 & 2.0*xdn(mgs,lc)*vtxbar(mgs,lh,1)*(0.5*xdia(mgs,lc,1))**2 &
12623 & /(9.0*fadvisc(mgs)*0.5*xdia(mgs,lh,3))
12624 tmp = Max( 1.5, Min(10.0, tmp) )
12625 ehw(mgs) = Min( ehw(mgs), 0.55*Log10(2.51*tmp) )
12627 if ( xdia(mgs,lc,1) .lt. 2.4e-06 ) ehw(mgs)=0.0
12629 ehw(mgs) = Min( ehw0, ehw(mgs) )
12631 IF ( ibfc == -1 .and. temcg(mgs) < -41.0 ) THEN
12637 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lr).gt.qxmin(lr) &
12638 ! & .and. temg(mgs) .lt. tfr &
12640 ! ehr(mgs) = Exp(-(40.e-6)**3/xv(mgs,lr))*Exp(-40.e-6/xdia(mgs,lh,1))
12642 ehr(mgs) = Exp(-(40.e-6)/xdia(mgs,lr,3))*Exp(-40.e-6/xdia(mgs,lh,3))
12643 ehr(mgs) = Min( ehr0, ehr(mgs) )
12646 IF ( qx(mgs,ls).gt.qxmin(ls) ) THEN
12647 IF ( ipconc .ge. 4 ) THEN
12648 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
12650 ehscnv(mgs) = exp(0.09*min(temcg(mgs),0.0))
12652 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lc) > qxmin(lc) ) then
12653 ehsclsn(mgs) = ehs_collsn
12654 IF ( xdia(mgs,ls,3) < 40.e-6 ) THEN
12656 ELSEIF ( xdia(mgs,ls,3) < 150.e-6 ) THEN
12657 ehsclsn(mgs) = ehs_collsn*(xdia(mgs,ls,3) - 40.e-6)/(150.e-6 - 40.e-6)
12659 ehsclsn(mgs) = ehs_collsn
12661 ! 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
12662 ehs(mgs) = ehscnv(mgs)*Min(1.0, Max(0.0,xdn(mgs,lh) - 300.)/300. ) ! shut off qhacs as graupel goes to low density
12663 ehs(mgs) = Min(ehs(mgs),ehsmax)
12664 IF ( qx(mgs,lc) < qxmin(lc) ) ehs(mgs) = 0.0
12668 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,li).gt.qxmin(li) ) then
12669 ehiclsn(mgs) = ehi_collsn
12670 ehi(mgs)=eii0*exp(eii1*min(temcg(mgs),0.0))
12671 ehi(mgs) = Min( ehimax, Max( ehi(mgs), ehimin ) )
12672 if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehi(mgs) = 0.0
12675 IF ( lis > 1 ) THEN
12676 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lis).gt.qxmin(lis) ) then
12677 ehisclsn(mgs) = ehi_collsn
12678 ehis(mgs)=eii0*exp(eii1*min(temcg(mgs),0.0))
12679 ehis(mgs) = Min( ehimax, Max( ehis(mgs), ehimin ) )
12680 if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehis(mgs) = 0.0
12687 ! Hail: Collection (cxc) efficiencies
12690 IF ( lhl .gt. 1 ) THEN
12692 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,lc).gt.qxmin(lc) ) then
12693 IF ( iehw == 3 ) iehlw = 3
12694 IF ( iehw == 4 ) iehlw = 4
12696 IF ( iehlw .eq. 0 ) THEN
12697 ehlw(mgs) = ehlw0 ! default value is 1.0
12698 ELSEIF ( iehlw .eq. 1 .or. iehlw .eq. 10 ) THEN
12699 cwrad = 0.5*xdia(mgs,lc,1)
12700 ehlw(mgs) = Min( ehlw0, &
12701 & ewfac*min((aradcw + cwrad*(bradcw + cwrad* &
12702 & (cradcw + cwrad*(dradcw)))), 1.0) )
12704 ELSEIF ( iehlw .eq. 2 .or. iehlw .eq. 10 ) THEN
12706 icp1 = Min( 8, ic+1 )
12708 irp1 = Min( 6, ir+1 )
12709 cwrad = 0.5*xdia(mgs,lc,1)
12710 rwrad = 0.5*xdia(mgs,lhl,3) ! changed to mean volume diameter
12712 slope1 = (ew(icp1, ir ) - ew(ic,ir ))*cwr(ic,2)
12713 slope2 = (ew(icp1, irp1) - ew(ic,irp1))*cwr(ic,2)
12715 x1 = ew(ic, ir) + slope1*(cwrad - cwr(ic,1))
12716 x2 = ew(icp1,ir) + slope2*(cwrad - cwr(ic,1))
12718 slope1 = (x2 - x1)*grad(ir,2)
12720 tmp = Max( 0.0, Min( 1.0, x1 + slope1*(rwrad - grad(ir,1)) ) )
12721 ehlw(mgs) = Min( ehlw(mgs), tmp )
12722 ehlw(mgs) = Min( ehlw0, ehlw(mgs) )
12723 ! ehw(mgs) = Max( 0.2, ehw(mgs) )
12724 ! assume that ehw = 1 for zero air resistance (rho0 = 0.0) and extrapolate toward that
12725 ! ehw(mgs) = ehw(mgs) + (ehw(mgs) - 1.0)*(rho0(mgs) - rho00)/rho00
12726 ! ehlw(mgs) = ehlw(mgs) + (1.0 - ehlw(mgs))*((Max(0.0,rho00 - rho0(mgs)))/rho00)**2
12728 ELSEIF ( iehlw .eq. 3 .or. iehlw .eq. 10 ) THEN ! use fraction of droplets greater than 15 micron diameter
12729 tmp = Exp(- (dmincw/xdia(mgs,lc,1))**3)
12730 ehlw(mgs) = Min( ehlw(mgs), tmp )
12731 ELSEIF ( iehlw .eq. 4 .or. iehlw .eq. 10 ) THEN ! Cober and List 1993
12733 & 2.0*xdn(mgs,lc)*vtxbar(mgs,lhl,1)*(0.5*xdia(mgs,lc,1))**2 &
12734 & /(9.0*fadvisc(mgs)*0.5*xdia(mgs,lhl,3))
12735 tmp = Max( 1.5, Min(10.0, tmp) )
12736 ehlw(mgs) = Min( ehlw(mgs), 0.55*Log10(2.51*tmp) )
12738 if ( xdia(mgs,lc,1) .lt. 2.4e-06 ) ehlw(mgs)=0.0
12739 ehlw(mgs) = Min( ehlw0, ehlw(mgs) )
12741 IF ( ibfc == -1 .and. temcg(mgs) < -41.0 ) THEN
12747 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,lr).gt.qxmin(lr) &
12748 ! & .and. temg(mgs) .lt. tfr &
12751 ehlr(mgs) = Min( ehlr0, ehlr(mgs) )
12754 IF ( qx(mgs,ls).gt.qxmin(ls) ) THEN
12755 if ( qx(mgs,lhl).gt.qxmin(lhl) ) then
12756 ehlsclsn(mgs) = ehls_collsn
12757 ehls(mgs) = ehscnv(mgs)
12758 ehls(mgs) = Min(ehls(mgs),ehsmax)
12762 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,li).gt.qxmin(li) ) then
12763 ehliclsn(mgs) = ehli_collsn
12764 ehli(mgs)=eii0hl*exp(eii1hl*min(temcg(mgs),0.0))
12765 ehli(mgs) = Min( ehimax, Max( ehli(mgs), ehimin ) )
12766 if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehli(mgs) = 0.0
12769 IF ( lis > 1 ) THEN
12770 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,lis).gt.qxmin(lis) ) then
12771 ehlisclsn(mgs) = ehli_collsn
12772 ehlis(mgs)=eii0*exp(eii1*min(temcg(mgs),0.0))
12773 ehlis(mgs) = Min( ehimax, Max( ehlis(mgs), ehimin ) )
12774 if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehlis(mgs) = 0.0
12781 ENDDO ! mgs loop for collection efficiencies
12786 ! Set flags for plates vs. columns
12794 ! if ( temcg(mgs) .lt. 0. .and. temcg(mgs) .ge. -4. ) then
12795 ! xplate(mgs) = 1.0
12796 ! xcolmn(mgs) = 0.0
12799 ! if ( temcg(mgs) .lt. -4. .and. temcg(mgs) .ge. -9. ) then
12800 ! xplate(mgs) = 0.0
12801 ! xcolmn(mgs) = 1.0
12804 ! if ( temcg(mgs) .lt. -9. .and. temcg(mgs) .ge. -22.5 ) then
12805 ! xplate(mgs) = 1.0
12806 ! xcolmn(mgs) = 0.0
12809 ! if ( temcg(mgs) .lt. -22.5 .and. temcg(mgs) .ge. -90. ) then
12810 ! xplate(mgs) = 0.0
12811 ! xcolmn(mgs) = 1.0
12820 ! Collection growth equations....
12823 if (ndebug .gt. 0 ) write(0,*) 'Collection: rain collects xxxxx'
12827 IF ( qx(mgs,lr) .gt. qxmin(lr) .and. erw(mgs) .gt. 0.0 ) THEN
12828 IF ( ipconc .lt. 3 ) THEN
12829 IF ( erw(mgs) .gt. 0.0 .and. qx(mgs,lr) .gt. 1.e-7 ) THEN
12830 vt = (ar*(xdia(mgs,lc,1)**br))*rhovt(mgs)
12832 & (0.25)*pi*erw(mgs)*(qx(mgs,lc)-qcwresv(mgs))*cx(mgs,lr) &
12833 ! > *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,lc,1)) &
12834 & *Max(0.0, vtxbar(mgs,lr,1)-vt) &
12835 & *( gf3*xdia(mgs,lr,2) &
12836 & + 2.0*gf2*xdia(mgs,lr,1)*xdia(mgs,lc,1) &
12837 & + gf1*xdia(mgs,lc,2) )
12839 ! write(iunit,*) 'qracw,cx =',qracw(mgs),1.e6*xdia(mgs,lr,1),erw(mgs)
12840 ! 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
12841 ! write(iunit,*) 'vtr: ',vtxbar(mgs,lr,1), ar*gf4br/6.0*xdia(mgs,lr,1)**br, rhovt(mgs),
12842 ! : ar*gf4br/6.0*xdia(mgs,lr,1)**br * rhovt(mgs)
12846 IF ( dmrauto <= 0 .or. rho0(mgs)*qx(mgs,lr) > 1.2*xl2p(mgs) ) THEN
12847 rwrad = 0.5*xdia(mgs,lr,3)
12848 IF ( rwrad .gt. rh(mgs) ) THEN ! .or. cx(mgs,lr) .gt. nh(mgs) ) THEN
12849 IF ( rwrad .gt. rwradmn ) THEN
12850 ! DM1CCC=A2*XNC*XNR*XVC*(((CNU+2.)/(CNU+1.))*XVC+XVR) ! (A12)
12851 ! NOTE: Result is independent of imurain, assumes mucloud = 3
12852 qracw(mgs) = erw(mgs)*aa2*cx(mgs,lr)*cx(mgs,lc)*xmas(mgs,lc)* &
12853 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)/(alpha(mgs,lc) + 1.) + xv(mgs,lr))/rho0(mgs) !*rhoinv(mgs)
12856 IF ( imurain == 3 ) THEN
12858 ! DM1CCC=A1*XNC*XNR*(((CNU+3.)*(CNU+2.)/(CNU+1.)**2)*XVC**3+ ! (A14)
12859 ! 1 ((RNU+2.)/(RNU+1.))*XVC*XVR**2)
12861 ! qracw(mgs) = aa1*cx(mgs,lr)*cx(mgs,lc)*xdn(mgs,lc)* &
12862 ! & ((cnu + 3.)*(cnu + 2.)*xv(mgs,lc)**3/(cnu + 1.)**2 + &
12863 ! & (alpha(mgs,lr) + 2.)*xv(mgs,lc)*xv(mgs,lr)**2/(alpha(mgs,lr) + 1.))/rho0(mgs) !*rhoinv(mgs)
12864 ! save multiplies by converting cx*xdn*xv/rho0 to qx
12865 qracw(mgs) = aa1*cx(mgs,lr)*(qx(mgs,lc)-qcwresv(mgs))* &
12866 & ((alpha(mgs,lc) + 3.)*(alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.)**2 + &
12867 & (alpha(mgs,lr) + 2.)*xv(mgs,lr)**2/(alpha(mgs,lr) + 1.))
12869 ELSE ! imurain == 1
12871 qracw(mgs) = aa1*cx(mgs,lr)*(qx(mgs,lc)-qcwresv(mgs))* &
12872 & ((alpha(mgs,lc) + 3.)*(alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.)**2 + &
12873 & (alpha(mgs,lr) + 6.)*(alpha(mgs,lr) + 5.)*(alpha(mgs,lr) + 4.)*xv(mgs,lr)**2/ &
12874 & ((alpha(mgs,lr) + 3.)*(alpha(mgs,lr) + 2.)*(alpha(mgs,lr) + 1.)))
12882 ! qracw(mgs) = Min(qracw(mgs), qx(mgs,lc))
12883 qracw(mgs) = Min(qracw(mgs), qcmxd(mgs))
12890 IF ( eri(mgs) .gt. 0.0 .and. iacr .ge. 1 .and. xdia(mgs,lr,3) .gt. 2.*rwradmn ) THEN
12891 IF ( ipconc .ge. 3 ) THEN
12893 tmp = eri(mgs)*aa2*cx(mgs,lr)*cx(mgs,li)* &
12894 & ((cinu + 2.)*xv(mgs,li)/(cinu + 1.) + xv(mgs,lr))
12896 qraci(mgs) = Min( qxmxd(mgs,li), tmp*xmas(mgs,li)*rhoinv(mgs) )
12897 craci(mgs) = Min( cxmxd(mgs,li), tmp )
12899 ! vt = Sqrt((vtxbar(mgs,lr,1)-vtxbar(mgs,li,1))**2 +
12900 ! : 0.04*vtxbar(mgs,lr,1)*vtxbar(mgs,li,1) )
12902 ! qraci(mgs) = 0.25*pi*eri(mgs)*cx(mgs,lr)*qx(mgs,li)*vt*
12903 ! : ( da0(lr)*xdia(mgs,lr,3)**2 +
12904 ! : dab1(lr,li)*xdia(mgs,lr,3)*xdia(mgs,li,3) +
12905 ! : da1(li)*xdia(mgs,li,3)**2 )
12908 ! vt = Sqrt((vtxbar(mgs,lr,1)-vtxbar(mgs,li,1))**2 +
12909 ! : 0.04*vtxbar(mgs,lr,1)*vtxbar(mgs,li,1) )
12911 ! craci(mgs) = 0.25*pi*eri(mgs)*cx(mgs,lr)*cx(mgs,li)*vt*
12912 ! : ( da0(lr)*xdia(mgs,lr,3)**2 +
12913 ! : dab0(lr,li)*xdia(mgs,lr,3)*xdia(mgs,li,3) +
12914 ! : da0(li)*xdia(mgs,li,3)**2 )
12916 ! qraci(mgs) = Min( qraci(mgs), qxmxd(mgs,li) )
12917 ! craci(mgs) = Min( craci(mgs), cxmxd(mgs,li) )
12922 & (0.25)*pi*eri(mgs)*qx(mgs,li)*cx(mgs,lr) &
12923 & *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,li,1)) &
12924 & *( gf3*xdia(mgs,lr,2) &
12925 & + 2.0*gf2*xdia(mgs,lr,1)*xdia(mgs,li,1) &
12926 & + gf1*xdia(mgs,li,2) ) &
12929 if ( temg(mgs) .gt. 268.15 ) then
12937 IF ( ers(mgs) .gt. 0.0 .and. ipconc < 3 ) THEN
12938 IF ( lwsm6 .and. ipconc == 0 ) THEN
12941 vt = vtxbar(mgs,ls,1)
12945 & ((0.25)*pi/gf4)*ers(mgs)*qx(mgs,ls)*cx(mgs,lr) &
12946 & *abs(vtxbar(mgs,lr,1)-vt) &
12947 & *( gf6*gf1*xdia(mgs,ls,2) &
12948 & + 2.0*gf5*gf2*xdia(mgs,ls,1)*xdia(mgs,lr,1) &
12949 & + gf4*gf3*xdia(mgs,lr,2) ) &
12956 if (ndebug .gt. 0 ) write(0,*) 'Collection: snow collects xxxxx'
12962 IF ( esw(mgs) .gt. 0.0 ) THEN
12964 IF ( ipconc .ge. 4 ) THEN
12965 ! QSACC=CECS*RVT*A2*XNC*XNS*XVC*ROS*
12966 ! * (((CNU+2.)/(CNU+1.))*XVC+XVS)/RO
12968 ! tmp = esw(mgs)*rvt*aa2*cx(mgs,ls)*cx(mgs,lc)*
12969 ! : ((cnu + 2.)*xv(mgs,lc)/(cnu + 1.) + xv(mgs,ls))
12970 tmp = 1.0*rvt*aa2*cx(mgs,ls)*cx(mgs,lc)* &
12971 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)/(alpha(mgs,lc) + 1.) + xv(mgs,ls))
12973 qsacw(mgs) = Min( qxmxd(mgs,lc), tmp*xmas(mgs,lc)*rhoinv(mgs) )
12974 csacw(mgs) = Min( cxmxd(mgs,lc), tmp )
12976 IF ( lvol(ls) .gt. 1 ) THEN
12977 IF ( temg(mgs) .lt. 273.15) THEN
12978 rimdn(mgs,ls) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
12979 & *((0.60)*vtxbar(mgs,ls,1)) &
12980 & /(temg(mgs)-273.15))**(rimc2)
12981 rimdn(mgs,ls) = Min( Max( rimc3, rimdn(mgs,ls) ), rimc4 )
12983 rimdn(mgs,ls) = 1000.
12986 vsacw(mgs) = rho0(mgs)*qsacw(mgs)/rimdn(mgs,ls)
12991 ! qsacw(mgs) = cecs*aa2*cx(mgs,ls)*cx(mgs,lc)*xmas(mgs,lc)*
12992 ! : ((alpha(mgs,lc) + 2.)*xv(mgs,lc)/(alpha(mgs,lc) + 1.) + xv(mgs,ls))*rhoinv(mgs)
12996 ! > ((0.25)*pi)*esw(mgs)*qx(mgs,lc)*cx(mgs,ls)
12997 ! > *abs(vtxbar(mgs,ls,1)-vtxbar(mgs,lc,1))
12998 ! > *( gf3*xdia(mgs,ls,2)
12999 ! > + 2.0*gf2*xdia(mgs,ls,1)*xdia(mgs,lc,1)
13000 ! > + gf1*xdia(mgs,lc,2) )
13003 vt = abs(vtxbar(mgs,ls,1)-vtxbar(mgs,lc,1))
13005 qsacw(mgs) = 0.25*pi*esw(mgs)*cx(mgs,ls)*qx(mgs,lc)*vt* &
13006 & ( da0(ls)*xdia(mgs,ls,3)**2 + &
13007 & dab1(ls,lc)*xdia(mgs,ls,3)*xdia(mgs,lc,3) + &
13008 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
13009 qsacw(mgs) = Min( qsacw(mgs), qxmxd(mgs,ls) )
13010 csacw(mgs) = rho0(mgs)*qsacw(mgs)/xmas(mgs,lc)
13020 IF ( ipconc .ge. 4 ) THEN
13021 IF ( esi(mgs) .gt. 0.0 .or. ( ipelec > 0 .and. esiclsn(mgs) > 0.0 )) THEN
13022 ! QSCOI=CEXS*RVT*A2*XNCI*XNS*XVCI*ROS*
13023 ! * (((CINU+2.)/(CINU+1.))*VCIP+XVS)/RO
13025 tmp = esiclsn(mgs)*rvt*aa2*cx(mgs,ls)*cx(mgs,li)* &
13026 & ((cinu + 2.)*xv(mgs,li)/(cinu + 1.) + xv(mgs,ls))
13028 qsaci(mgs) = Min( qxmxd(mgs,li), esi(mgs)*tmp*xmas(mgs,li)*rhoinv(mgs) )
13030 csaci(mgs) = Min(cxmxd(mgs,li), esi(mgs)*tmp )
13034 ! > ((0.25)*pi)*esi(mgs)*qx(mgs,li)*cx(mgs,ls)
13035 ! > *abs(vtxbar(mgs,ls,1)-vtxbar(mgs,li,1))
13036 ! > *( gf3*xdia(mgs,ls,2)
13037 ! > + 2.0*gf2*xdia(mgs,ls,1)*xdia(mgs,li,1)
13038 ! > + gf1*xdia(mgs,li,2) )
13042 IF ( esi(mgs) .gt. 0.0 ) THEN
13045 & ((0.25)*pi)*esi(mgs)*qx(mgs,li)*cx(mgs,ls) &
13046 & *abs(vtxbar(mgs,ls,1)-vtxbar(mgs,li,1)) &
13047 & *( gf3*xdia(mgs,ls,2) &
13048 & + 2.0*gf2*xdia(mgs,ls,1)*xdia(mgs,li,1) &
13049 & + gf1*xdia(mgs,li,2) ) &
13061 IF ( esr(mgs) .gt. 0.0 ) THEN
13062 IF ( ipconc .ge. 3 ) THEN
13063 ! vt = Sqrt((vtxbar(mgs,ls,1)-vtxbar(mgs,lr,1))**2 +
13064 ! : 0.04*vtxbar(mgs,ls,1)*vtxbar(mgs,lr,1) )
13065 ! qsacr(mgs) = esr(mgs)*cx(mgs,ls)*vt*
13066 ! : qx(mgs,lr)*0.25*pi*
13067 ! : (3.02787*xdia(mgs,lr,2) +
13068 ! : 3.30669*xdia(mgs,ls,1)*xdia(mgs,lr,1) +
13069 ! : 2.*xdia(mgs,ls,2))
13070 ! qsacr(mgs) = Min( qsacr(mgs), qrmxd(mgs) )
13071 ! csacr(mgs) = qsacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
13072 ! csacr(mgs) = min(csacr(mgs),crmxd(mgs))
13074 IF ( lwsm6 .and. ipconc == 0 ) THEN
13077 vt = vtxbar(mgs,ls,1)
13082 & ((0.25)*pi/gf4)*esr(mgs)*qx(mgs,lr)*cx(mgs,ls) &
13083 & *abs(vtxbar(mgs,lr,1)-vt) &
13084 & *( gf6*gf1*xdia(mgs,lr,2) &
13085 & + 2.0*gf5*gf2*xdia(mgs,lr,1)*xdia(mgs,ls,1) &
13086 & + gf4*gf3*xdia(mgs,ls,2) ) &
13095 if (ndebug .gt. 0 ) write(0,*) 'Collection: graupel collects xxxxx'
13104 IF ( .false. ) THEN
13105 vtmax = (gz(igs(mgs),jgs,kgs(mgs))*dtpinv)
13106 vtxbar(mgs,lh,1) = Min( vtmax, vtxbar(mgs,lh,1))
13107 vtxbar(mgs,lh,2) = Min( vtmax, vtxbar(mgs,lh,2))
13108 vtxbar(mgs,lh,3) = Min( vtmax, vtxbar(mgs,lh,3))
13110 IF ( ehw(mgs) .gt. 0.0 ) THEN
13112 IF ( ipconc .ge. 2 ) THEN
13114 IF ( .false. ) THEN
13115 qhacw(mgs) = (ehw(mgs)*(qx(mgs,lc)-qcwresv(mgs))*cx(mgs,lh)*pi* &
13116 & abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1))* &
13117 & (2.0*xdia(mgs,lh,1)*(xdia(mgs,lh,1) + &
13118 & xdia(mgs,lc,1)*gf73rds) + &
13119 & xdia(mgs,lc,2)*gf83rds))/4.
13121 ELSE ! using Seifert coefficients
13122 vt = abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1))
13124 qhacw(mgs) = 0.25*pi*ehw(mgs)*cx(mgs,lh)*(qx(mgs,lc)-qcwresv(mgs))*vt* &
13125 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
13126 & dab1lh(mgs,lh,lc)*xdia(mgs,lh,3)*xdia(mgs,lc,3) + &
13127 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
13130 qhacw(mgs) = Min( qhacw(mgs), 0.5*qx(mgs,lc)*dtpinv )
13132 IF ( lzh .gt. 1 ) THEN
13133 tmp = qx(mgs,lh)/cx(mgs,lh)
13135 !! g1 = (6.0 + alpha(mgs,lh))*(5.0 + alpha(mgs,lh))*(4.0 + alpha(mgs,lh))/
13136 !! : ((3.0 + alpha(mgs,lh))*(2.0 + alpha(mgs,lh))*(1.0 + alpha(mgs,lh)))
13137 ! alp = Max( 1.0, alpha(mgs,lh)+1. )
13138 ! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/
13139 ! : ((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
13140 ! zhacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacw(mgs) )
13146 & ((0.25)*pi)*ehw(mgs)*(qx(mgs,lc)-qcwresv(mgs))*cx(mgs,lh) &
13147 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1)) &
13148 & *( gf3*xdia(mgs,lh,2) &
13149 & + 2.0*gf2*xdia(mgs,lh,1)*xdia(mgs,lc,1) &
13150 & + gf1*xdia(mgs,lc,2) ) &
13151 & , 0.5*(qx(mgs,lc)-qcwresv(mgs))*dtpinv)
13152 ! < , qxmxd(mgs,lc))
13156 IF ( lwsm6 .and. qsacw(mgs) > 0.0 .and. qhacw(mgs) > 0.0) THEN
13157 qaacw = ( qx(mgs,ls)*qsacw(mgs) + qx(mgs,lh)*qhacw(mgs) )/(qx(mgs,ls) + qx(mgs,lh))
13158 ! qaacw = Min( qaacw, 0.5*(qsacw(mgs) + qhacw(mgs) ) )
13165 IF ( lvol(lh) .gt. 1 .or. lhl .gt. 1 ) THEN ! calculate rime density for graupel volume and/or for graupel conversion to hail
13167 IF ( temg(mgs) .lt. 273.15) THEN
13168 IF ( irimdenopt == 1 ) THEN ! Heymsfield and Pflaum (1985)
13169 vt = ( (1.0-rimdenvwgt)*vtxbar(mgs,lh,1) + rimdenvwgt*vtxbar(mgs,lh,2) )
13171 rimdn(mgs,lh) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
13173 & /(temg(mgs)-273.15))**(rimc2)
13174 ! rimdn(mgs,lh) = Min( Max( hdnmn, rimc3, rimdn(mgs,lh) ), rimc4 )
13175 rimdn(mgs,lh) = Min( Max( rimc3, rimdn(mgs,lh) ), rimc4 )
13177 ! IF ( igs(mgs) == 30 ) THEN
13178 ! 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)
13179 ! write(0,*) 'diam: char, mean, maxmass = ',xdia(mgs,lh,1),xdia(mgs,lh,3),(alpha(mgs,lh)+3.)*xdia(mgs,lh,1)
13180 ! write(0,*) 'ax,bx,cd,xdn = ',axx(mgs,lh),bxx(mgs,lh),cdxgs(mgs,lh),xdn(mgs,lh)
13181 ! 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)
13182 ! write(0,*) 'rimdn,alpha = ',rimdn(mgs,lh),alpha(mgs,lh)
13185 ELSEIF ( irimdenopt == 2 ) THEN ! Cober and List (1993)
13187 tmp = (-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
13188 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lh,1) + rimdenvwgt*vtxbar(mgs,lh,2) ) &
13189 & /(temg(mgs)-273.15))
13190 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
13192 rimdn(mgs,lh) = 1000.*(0.051 + 0.114*tmp - 0.0055*tmp**2)
13194 ELSEIF ( irimdenopt == 3 ) THEN ! Macklin
13196 tmp = (-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
13197 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lh,1) + rimdenvwgt*vtxbar(mgs,lh,2) ) &
13198 & /(temg(mgs)-273.15))
13199 ! tmp = Min( 5.5/0.6, Max( 0.3/0.6, tmp ) )
13201 rimdn(mgs,lh) = Min(900., Max( 170., 110.*tmp**0.76 ) )
13205 rimdn(mgs,lh) = 1000.
13208 IF ( lvol(lh) > 1 ) vhacw(mgs) = rho0(mgs)*qhacw(mgs)/rimdn(mgs,lh)
13212 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. ipelec .ge. 1 ) THEN
13214 & qhacw(mgs)*1.0e3*rho0(mgs)/((pi/2.0)*xdia(mgs,lh,2)*cx(mgs,lh))
13224 IF ( ehi(mgs) .gt. 0.0 ) THEN
13225 IF ( ipconc .ge. 5 ) THEN
13227 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,li,1))**2 + &
13228 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,li,1) )
13230 qhaci0(mgs) = 0.25*pi*ehiclsn(mgs)*cx(mgs,lh)*qx(mgs,li)*vt* &
13231 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
13232 & dab1lh(mgs,lh,li)*xdia(mgs,lh,3)*xdia(mgs,li,3) + &
13233 & da1(li)*xdia(mgs,li,3)**2 )
13234 qhaci(mgs) = Min( ehi(mgs)*qhaci0(mgs), qimxd(mgs) )
13238 & ((0.25)*pi)*ehi(mgs)*ehiclsn(mgs)*qx(mgs,li)*cx(mgs,lh) &
13239 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,li,1)) &
13240 & *( gf3*xdia(mgs,lh,2) &
13241 & + 2.0*gf2*xdia(mgs,lh,1)*xdia(mgs,li,1) &
13242 & + gf1*xdia(mgs,li,2) ) &
13249 IF ( lis > 1 .and. ipconc >= 5 ) THEN
13253 IF ( ehis(mgs) .gt. 0.0 ) THEN
13255 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,lis,1))**2 + &
13256 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,lis,1) )
13258 qhacis0(mgs) = 0.25*pi*ehisclsn(mgs)*cx(mgs,lh)*qx(mgs,lis)*vt* &
13259 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
13260 & dab1lh(mgs,lh,lis)*xdia(mgs,lh,3)*xdia(mgs,lis,3) + &
13261 & da1(li)*xdia(mgs,lis,3)**2 )
13262 qhacis(mgs) = Min( ehis(mgs)*qhacis0(mgs), qxmxd(mgs,lis) )
13272 IF ( ehs(mgs) .gt. 0.0 ) THEN
13273 IF ( ipconc .ge. 5 ) THEN
13275 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1))**2 + &
13276 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,ls,1) )
13278 qhacs0(mgs) = 0.25*pi*ehsclsn(mgs)*cx(mgs,lh)*qx(mgs,ls)*vt* &
13279 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
13280 & dab1lh(mgs,lh,ls)*xdia(mgs,lh,3)*xdia(mgs,ls,3) + &
13281 & da1(ls)*xdia(mgs,ls,3)**2 )
13283 qhacs(mgs) = Min( ehs(mgs)*qhacs0(mgs), qsmxd(mgs) )
13288 & ((0.25)*pi/gf4)*ehs(mgs)*ehsclsn(mgs)*qx(mgs,ls)*cx(mgs,lh) &
13289 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1)) &
13290 & *( gf6*gf1*xdia(mgs,ls,2) &
13291 & + 2.0*gf5*gf2*xdia(mgs,ls,1)*xdia(mgs,lh,1) &
13292 & + gf4*gf3*xdia(mgs,lh,2) ) &
13300 qhacrmlr(mgs) = 0.0
13304 IF ( temg(mgs) .gt. tfr ) raindn(mgs,lh) = 1000.0
13306 IF ( ehr(mgs) .gt. 0.0 ) THEN
13307 IF ( ipconc .ge. 3 ) THEN
13308 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,lr,1))**2 + &
13309 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,lr,1) )
13310 ! qhacr(mgs) = ehr(mgs)*cx(mgs,lh)*vt*
13311 ! : qx(mgs,lr)*0.25*pi*
13312 ! : (3.02787*xdia(mgs,lr,2) +
13313 ! : 3.30669*xdia(mgs,lh,1)*xdia(mgs,lr,1) +
13314 ! : 2.*xdia(mgs,lh,2))
13316 qhacr(mgs) = 0.25*pi*ehr(mgs)*cx(mgs,lh)*qx(mgs,lr)*vt* &
13317 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
13318 & dab1lh(mgs,lh,lr)*xdia(mgs,lh,3)*xdia(mgs,lr,3) + &
13319 & da1lr(mgs)*xdia(mgs,lr,3)**2 )
13320 ! & da1(lr)*xdia(mgs,lr,3)**2 )
13321 ! IF ( qhacr(mgs) .gt. 0. .or. tmp .gt. 0.0 ) write(0,*) 'qhacr= ',qhacr(mgs),tmp
13322 !! qhacr(mgs) = Min( qhacr(mgs), qrmxd(mgs) )
13323 !! chacr(mgs) = qhacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
13324 !! chacr(mgs) = min(chacr(mgs),crmxd(mgs))
13326 qhacr(mgs) = Min( qhacr(mgs), qxmxd(mgs,lr) )
13328 qhacrmlr(mgs) = qhacr(mgs)
13330 IF ( temg(mgs) > tfr .and. iehr0c == 0 ) THEN
13333 IF ( iqhacrmlr == 0 ) THEN
13334 qhacrmlr(mgs) = -qhacw(mgs)
13338 ! chacr(mgs) = Min( qhacr(mgs)*rho0(mgs)/xmas(mgs,lr), cxmxd(mgs,lr) )
13340 ! chacr(mgs) = ehr(mgs)*cx(mgs,lh)*vt*
13341 ! : cx(mgs,lr)*0.25*pi*
13342 ! : (0.69874*xdia(mgs,lr,2) +
13343 ! : 1.24001*xdia(mgs,lh,1)*xdia(mgs,lr,1) +
13344 ! : 2.*xdia(mgs,lh,2))
13346 chacr(mgs) = 0.25*pi*ehr(mgs)*cx(mgs,lh)*cx(mgs,lr)*vt* &
13347 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
13348 & dab0lh(mgs,lh,lr)*xdia(mgs,lh,3)*xdia(mgs,lr,3) + &
13349 & da0lr(mgs)*xdia(mgs,lr,3)**2 )
13351 ! IF ( qhacr(mgs) .gt. 0. .or. tmp .gt. 0.0 ) write(0,*) 'chacr= ',chacr(mgs),tmp
13353 ! chacr(mgs) = qhacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
13354 chacr(mgs) = min(chacr(mgs),crmxd(mgs))
13356 IF ( lzh .gt. 1 ) THEN
13357 tmp = qx(mgs,lh)/cx(mgs,lh)
13359 ! g1 = (6.0 + alpha(mgs,lh))*(5.0 + alpha(mgs,lh))*(4.0 + alpha(mgs,lh))/
13360 ! : ((3.0 + alpha(mgs,lh))*(2.0 + alpha(mgs,lh))*(1.0 + alpha(mgs,lh)))
13361 ! alp = Max( 1.0, alpha(mgs,lh)+1. )
13362 ! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/
13363 ! : ((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
13364 ! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) - tmp**2 * chacr(mgs) )
13365 ! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qhacr(mgs) )
13370 IF ( lwsm6 .and. ipconc == 0 ) THEN
13373 vt = vtxbar(mgs,lh,1)
13378 & ((0.25)*pi/gf4)*ehr(mgs)*qx(mgs,lr)*cx(mgs,lh) &
13379 & *abs(vt-vtxbar(mgs,lr,1)) &
13380 & *( gf6*gf1*xdia(mgs,lr,2) &
13381 & + 2.0*gf5*gf2*xdia(mgs,lr,1)*xdia(mgs,lh,1) &
13382 & + gf4*gf3*xdia(mgs,lh,2) ) &
13385 IF ( temg(mgs) > tfr ) THEN
13386 IF ( iqhacrmlr >= 1 ) qhacrmlr(mgs) = qhacr(mgs)
13391 IF ( lvol(lh) .gt. 1 .or. lhl .gt. 1 ) THEN ! calculate rime density for graupel volume and/or for graupel conversion to hail
13393 IF ( temg(mgs) .lt. 273.15) THEN
13394 raindn(mgs,lh) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lr,3)) &
13396 & /(temg(mgs)-273.15))**(rimc2)
13398 raindn(mgs,lh) = Min( Max( rimc3, rimdn(mgs,lh) ), rimc4 )
13400 raindn(mgs,lh) = 1000.
13403 IF ( lvol(lh) > 1 ) vhacr(mgs) = rho0(mgs)*qhacr(mgs)/raindn(mgs,lh)
13410 if (ndebug .gt. 0 ) write(0,*) 'Collection: hail collects xxxxx'
13417 IF ( lhl > 1 .and. .true.) THEN
13418 vtmax = (gz(igs(mgs),jgs,kgs(mgs))*dtpinv)
13419 vtxbar(mgs,lhl,1) = Min( vtmax, vtxbar(mgs,lhl,1))
13420 vtxbar(mgs,lhl,2) = Min( vtmax, vtxbar(mgs,lhl,2))
13421 vtxbar(mgs,lhl,3) = Min( vtmax, vtxbar(mgs,lhl,3))
13424 IF ( lhl > 0 ) THEN
13425 rarx(mgs,lhl) = 0.0
13428 IF ( lhl .gt. 1 .and. ehlw(mgs) .gt. 0.0 ) THEN
13431 ! IF ( ipconc .ge. 2 ) THEN
13433 vt = abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,lc,1))
13435 qhlacw(mgs) = 0.25*pi*ehlw(mgs)*cx(mgs,lhl)*(qx(mgs,lc)-qcwresv(mgs))*vt* &
13436 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
13437 & dab1lh(mgs,lhl,lc)*xdia(mgs,lhl,3)*xdia(mgs,lc,3) + &
13438 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
13441 qhlacw(mgs) = Min( qhlacw(mgs), 0.5*qx(mgs,lc)*dtpinv )
13443 IF ( lvol(lhl) .gt. 1 ) THEN
13445 IF ( temg(mgs) .lt. 273.15) THEN
13446 IF ( irimdenopt == 1 ) THEN ! Rasmussen and Heymsfeld (1985)
13447 rimdn(mgs,lhl) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
13448 & *((0.60)*( (1.0-rimdenvwgt)*vtxbar(mgs,lhl,1) + rimdenvwgt*vtxbar(mgs,lhl,2) )) &
13449 & /(temg(mgs)-273.15))**(rimc2)
13450 rimdn(mgs,lhl) = Min( Max( hldnmn, rimc3, rimdn(mgs,lhl) ), rimc4 )
13452 ELSEIF ( irimdenopt == 2 ) THEN ! Cober and List (1993)
13453 tmp = -0.5*(1.e+06)*xdia(mgs,lc,1) &
13454 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lhl,1) + rimdenvwgt*vtxbar(mgs,lhl,2) ) &
13455 & /(temg(mgs)-273.15)
13456 tmp = Min( 5.5/0.6, Max( 0.3/0.6, tmp ) )
13458 rimdn(mgs,lhl) = 1000.*(0.051 + 0.114*tmp - 0.005*tmp**2)
13460 ELSEIF ( irimdenopt == 3 ) THEN ! Macklin
13461 tmp = -0.5*(1.e+06)*xdia(mgs,lc,1) &
13462 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lhl,1) + rimdenvwgt*vtxbar(mgs,lhl,2) ) &
13463 & /(temg(mgs)-273.15)
13464 ! tmp = Min( 5.5/0.6, Max( 0.3/0.6, tmp ) )
13466 rimdn(mgs,lhl) = Min(900., Max( 170., 110.*tmp**0.76 ) )
13470 rimdn(mgs,lhl) = 1000.
13473 vhlacw(mgs) = rho0(mgs)*qhlacw(mgs)/rimdn(mgs,lhl)
13478 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. ipelec .ge. 1 ) THEN
13480 & qhlacw(mgs)*1.0e3*rho0(mgs)/((pi/2.0)*xdia(mgs,lhl,2)*cx(mgs,lhl))
13488 IF ( lhl .gt. 1 ) THEN
13490 IF ( ehli(mgs) .gt. 0.0 ) THEN
13491 IF ( ipconc .ge. 5 ) THEN
13493 vt = Sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,li,1))**2 + &
13494 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,li,1) )
13496 qhlaci0(mgs) = 0.25*pi*ehliclsn(mgs)*cx(mgs,lhl)*qx(mgs,li)*vt* &
13497 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
13498 & dab1lh(mgs,lhl,li)*xdia(mgs,lhl,3)*xdia(mgs,li,3) + &
13499 & da1(li)*xdia(mgs,li,3)**2 )
13500 ! qhlaci(mgs) = Min( qhlaci(mgs), qimxd(mgs) )
13501 qhlaci(mgs) = Min( ehli(mgs)*qhlaci0(mgs), qimxd(mgs) )
13509 IF ( lhl .gt. 1 ) THEN
13511 IF ( ehls(mgs) .gt. 0.0) THEN
13512 IF ( ipconc .ge. 5 ) THEN
13514 vt = Sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,ls,1))**2 + &
13515 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,ls,1) )
13517 qhlacs0(mgs) = 0.25*pi*ehlsclsn(mgs)*cx(mgs,lhl)*qx(mgs,ls)*vt* &
13518 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
13519 & dab1lh(mgs,lhl,ls)*xdia(mgs,lhl,3)*xdia(mgs,ls,3) + &
13520 & da1(ls)*xdia(mgs,ls,3)**2 )
13522 qhlacs(mgs) = Min( ehls(mgs)*qhlacs0(mgs), qsmxd(mgs) )
13531 qhlacrmlr(mgs) = 0.0
13534 IF ( lhl .gt. 1 .and. temg(mgs) .gt. tfr ) raindn(mgs,lhl) = 1000.0
13536 IF ( lhl .gt. 1 .and. ehlr(mgs) .gt. 0.0 ) THEN
13537 IF ( ipconc .ge. 3 ) THEN
13538 vt = Sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,lr,1))**2 + &
13539 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,lr,1) )
13541 qhlacr(mgs) = 0.25*pi*ehlr(mgs)*cx(mgs,lhl)*qx(mgs,lr)*vt* &
13542 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
13543 & dab1lh(mgs,lhl,lr)*xdia(mgs,lhl,3)*xdia(mgs,lr,3) + &
13544 & da1lr(mgs)*xdia(mgs,lr,3)**2 )
13545 ! & da1(lr)*xdia(mgs,lr,3)**2 )
13546 ! IF ( qhacr(mgs) .gt. 0. .or. tmp .gt. 0.0 ) write(0,*) 'qhacr= ',qhacr(mgs),tmp
13547 !! qhacr(mgs) = Min( qhacr(mgs), qrmxd(mgs) )
13548 !! chacr(mgs) = qhacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
13549 !! chacr(mgs) = min(chacr(mgs),crmxd(mgs))
13551 qhlacr(mgs) = Min( qhlacr(mgs), qxmxd(mgs,lr) )
13554 IF ( iqhlacrmlr >= 1 ) qhlacrmlr(mgs) = qhlacr(mgs)
13556 IF ( temg(mgs) > tfr .and. iehlr0c == 0) THEN
13558 IF ( iqhlacrmlr == 0 ) THEN
13559 qhlacrmlr(mgs) = -qhlacw(mgs)
13562 chlacr(mgs) = 0.25*pi*ehlr(mgs)*cx(mgs,lhl)*cx(mgs,lr)*vt* &
13563 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
13564 & dab0lh(mgs,lhl,lr)*xdia(mgs,lhl,3)*xdia(mgs,lr,3) + &
13565 & da0lr(mgs)*xdia(mgs,lr,3)**2 )
13567 chlacr(mgs) = min(chlacr(mgs),crmxd(mgs))
13569 IF ( lvol(lhl) .gt. 1 ) THEN
13570 vhlacr(mgs) = rho0(mgs)*qhlacr(mgs)/raindn(mgs,lhl)
13583 ! if (ndebug .gt. 0 ) write(0,*) 'Collection: Cloud collects xxxxx'
13585 if (ndebug .gt. 0 ) write(0,*) 'Collection: cloud ice collects xxxx2'
13589 IF ( eiw(mgs) .gt. 0.0 ) THEN
13591 vt = Sqrt((vtxbar(mgs,li,1)-vtxbar(mgs,lc,1))**2 + &
13592 & 0.04*vtxbar(mgs,li,1)*vtxbar(mgs,lc,1) )
13594 qiacw(mgs) = 0.25*pi*eiw(mgs)*cx(mgs,li)*qx(mgs,lc)*vt* &
13595 & ( da0(li)*xdia(mgs,li,3)**2 + &
13596 & dab1(li,lc)*xdia(mgs,li,3)*xdia(mgs,lc,3) + &
13597 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
13599 qiacw(mgs) = Min( qiacw(mgs), qxmxd(mgs,lc) )
13606 if (ndebug .gt. 0 ) write(0,*) 'Collection: cloud ice collects xxxx8'
13616 csplinter(mgs) = 0.0
13617 qsplinter(mgs) = 0.0
13618 csplinter2(mgs) = 0.0
13619 qsplinter2(mgs) = 0.0
13620 IF ( iacr .ge. 1 .and. eri(mgs) .gt. 0.0 &
13621 & .and. temg(mgs) .le. 270.15 ) THEN
13622 IF ( ipconc .ge. 3 ) THEN
13624 IF ( xdia(mgs,li,1) .ge. 10.e-6 ) THEN
13625 ni = ni + cx(mgs,li)*Exp(- (40.e-6/xdia(mgs,li,1))**3 )
13627 IF ( imurain == 1 ) THEN ! gamma of diameter
13628 IF ( iacrsize /= 4 ) THEN
13629 IF ( iacrsize .eq. 1 ) THEN
13630 ratio = 500.e-6/xdia(mgs,lr,1)
13631 ELSEIF ( iacrsize .eq. 2 ) THEN
13632 ratio = 300.e-6/xdia(mgs,lr,1)
13633 ELSEIF ( iacrsize .eq. 3 ) THEN
13634 ratio = 40.e-6/xdia(mgs,lr,1)
13635 ELSEIF ( iacrsize .eq. 5 ) THEN
13636 ratio = 150.e-6/xdia(mgs,lr,1)
13638 i = Min(nqiacrratio,Int(ratio*dqiacrratioinv))
13639 j = Int(Max(0.0,Min(15.,alpha(mgs,lr)))*dqiacralphainv)
13640 ! j = Int(Max(minalphalu,Min(maxalphalu,alpha(mgs,lr)))*dqiacralphainv)
13641 delx = ratio - float(i)*dqiacrratio
13642 dely = alpha(mgs,lr) - float(j)*dqiacralpha
13643 ip1 = Min( i+1, nqiacrratio )
13644 jp1 = Min( j+1, nqiacralpha )
13646 ! interpolate along x, i.e., ratio
13647 tmp1 = ciacrratio(i,j) + delx*dqiacrratioinv*(ciacrratio(ip1,j) - ciacrratio(i,j))
13648 tmp2 = ciacrratio(i,jp1) + delx*dqiacrratioinv*(ciacrratio(ip1,jp1) - ciacrratio(i,jp1))
13650 ! interpolate along alpha
13652 nr = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*cx(mgs,lr)
13654 ! interpolate along x, i.e., ratio;
13655 tmp1 = qiacrratio(i,j) + delx*dqiacrratioinv*(qiacrratio(ip1,j) - qiacrratio(i,j))
13656 tmp2 = qiacrratio(i,jp1) + delx*dqiacrratioinv*(qiacrratio(ip1,jp1) - qiacrratio(i,jp1))
13658 ! interpolate along alpha;
13660 qr = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*qx(mgs,lr)
13662 ELSE ! iacrsize == 4 : use all
13667 vt = Sqrt((vtxbar(mgs,lr,1)-vtxbar(mgs,li,1))**2 + &
13668 & 0.04*vtxbar(mgs,lr,1)*vtxbar(mgs,li,1) )
13670 qiacr(mgs) = 0.25*pi*eri(mgs)*ni*qr*vt* &
13671 & ( da0(li)*xdia(mgs,li,3)**2 + &
13672 & dab1lh(mgs,li,lr)*xdia(mgs,lh,3)*xdia(mgs,li,3) + &
13673 & da1(lr)*xdia(mgs,lr,3)**2 )
13675 qiacr(mgs) = Min( qrmxd(mgs), qiacr(mgs) )
13678 ciacr(mgs) = 0.25*pi*eri(mgs)*ni*nr*vt* &
13679 & ( da0(li)*xdia(mgs,li,3)**2 + &
13680 & dab0lh(mgs,li,lr)*xdia(mgs,lr,3)*xdia(mgs,li,3) + &
13681 & da0(lr)*xdia(mgs,lr,3)**2 )
13683 ciacr(mgs) = Min( crmxd(mgs), ciacr(mgs) )
13685 ! write(iunit,*) 'qiacr: ',cx(mgs,lr),nr,qx(mgs,lr),qr,qiacr(mgs),ciacr(mgs)
13686 ! write(iunit,*) 'xdia r li = ',xdia(mgs,lr,3),xdia(mgs,li,3),xdia(mgs,lr,1),xdia(mgs,li,1)
13687 ! write(iunit,*) 'i,j,ratio = ',i,j,ciacrratio(i,j),qiacrratio(i,j)
13688 ! write(iunit,*) 'ni,ci = ',ni,cx(mgs,li),qx(mgs,li)
13690 ELSEIF ( imurain == 3 ) THEN ! gamma of volume
13691 ! Set nr to the number of drops greater than 40 microns.
13692 arg = 1000.*xdia(mgs,lr,3)
13693 ! nr = cx(mgs,lr)*gaml02( arg )
13694 ! IF ( iacr .eq. 1 ) THEN
13695 IF ( ipconc .ge. 3 ) THEN
13696 IF ( iacrsize .eq. 1 ) THEN
13697 nr = cx(mgs,lr)*gaml02d500( arg ) ! number greater than 500 microns in diameter
13698 ELSEIF ( iacrsize .eq. 2 .or. iacrsize .eq. 5 ) THEN
13699 nr = cx(mgs,lr)*gaml02d300( arg ) ! number greater than 300 microns in diameter
13700 ELSEIF ( iacrsize .eq. 3 ) THEN
13701 nr = cx(mgs,lr)*gaml02( arg ) ! number greater than 40 microns in diameter
13702 ELSEIF ( iacrsize .eq. 4 ) THEN
13703 nr = cx(mgs,lr) ! all raindrops
13706 nr = cx(mgs,lr)*gaml02( arg )
13708 ! ELSEIF ( iacr .eq. 2 ) THEN
13709 ! nr = cx(mgs,lr)*gaml02d300( arg ) ! number greater than 300 microns in diameter
13711 IF ( ni .gt. 0.0 .and. nr .gt. 0.0 ) THEN
13712 d0 = xdia(mgs,lr,3)
13713 qiacr(mgs) = xdn(mgs,lr)*rhoinv(mgs)* &
13714 & (0.217239*(0.522295*(d0**5) + &
13715 & 49711.81*(d0**6) - &
13716 & 1.673016e7*(d0**7)+ &
13717 & 2.404471e9*(d0**8) - &
13718 & 1.22872e11*(d0**9))*ni*nr)
13719 qiacr(mgs) = Min( qrmxd(mgs), qiacr(mgs) )
13721 & (0.217239*(0.2301947*(d0**2) + &
13722 & 15823.76*(d0**3) - &
13723 & 4.167685e6*(d0**4) + &
13724 & 4.920215e8*(d0**5) - &
13725 & 2.133344e10*(d0**6))*ni*nr)
13726 ciacr(mgs) = Min( crmxd(mgs), ciacr(mgs) )
13727 ! ciacr(mgs) = qiacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
13730 IF ( iacr .eq. 1 .or. iacr .eq. 3 ) THEN
13731 ciacrf(mgs) = Min(ciacr(mgs), qiacr(mgs)/(1.0*vr1mm*1000.0)*rho0(mgs) ) ! *rzxh(mgs)
13732 ELSEIF ( iacr .eq. 2 ) THEN
13733 ciacrf(mgs) = ciacr(mgs) ! *rzxh(mgs)
13734 ELSEIF ( iacr .eq. 4 ) THEN
13735 ciacrf(mgs) = Min(ciacr(mgs), qiacr(mgs)/(1.0*vfrz*1000.0)*rho0(mgs) ) ! *rzxh(mgs)
13736 ELSEIF ( iacr .eq. 5 ) THEN
13737 ciacrf(mgs) = ciacr(mgs)*rzxh(mgs)
13739 ! crfrzf(mgs) = Min(crfrz(mgs), qrfrz(mgs)/(bfnu*27.0*vr1mm*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
13743 ELSE ! single-moment rain
13746 & ((0.25/gf4)*pi)*eri(mgs)*cx(mgs,li)*qx(mgs,lr) &
13747 & *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,li,1)) &
13748 & *( gf6*gf1*xdia(mgs,lr,2) &
13749 & + 2.0*gf5*gf2*xdia(mgs,lr,1)*xdia(mgs,li,1) &
13750 & + gf4*gf3*xdia(mgs,li,2) ) &
13753 ! if ( temg(mgs) .gt. 268.15 ) then
13758 IF ( ipconc .ge. 1 ) THEN
13759 IF ( nsplinter .ge. 1000 ) THEN
13760 ! Lawson et al. 2015 JAS
13761 ! ave. diam of freezing drops in microns
13762 IF ( qiacr(mgs)*dtp > qxmin(lh) .and. ciacr(mgs) > 1.e-3 ) THEN
13763 tmpdiam = 1.e6*( 6.*qiacr(mgs)/(1000.*pi*ciacr(mgs) ) )**(1./3.) ! avg. diameter of newly frozen drops in microns
13764 csplinter(mgs) = lawson_splinter_fac*tmpdiam**4*ciacr(mgs)
13766 ELSEIF ( nsplinter .ge. 0 ) THEN
13767 csplinter(mgs) = nsplinter*ciacr(mgs)
13769 csplinter(mgs) = -nsplinter*ciacrf(mgs)
13771 qsplinter(mgs) = Min(0.1*qiacr(mgs), csplinter(mgs)*splintermass/rho0(mgs) ) ! makes splinters smaller if too much mass is taken from graupel
13775 IF ( ibiggsnow == 2 .or. ibiggsnow == 3 ) THEN
13776 IF ( ciacr(mgs) > qxmin(lh) ) THEN
13777 xvfrz = rho0(mgs)*qiacr(mgs)/(ciacr(mgs)*900.) ! mean volume of frozen drops; 900. for frozen drop density
13778 frach = 0.5 *(1. + Tanh(0.2e12 *( xvfrz - 1.15*xvbiggsnow)))
13780 qiacrs(mgs) = (1.-frach)*qiacr(mgs)
13781 ciacrs(mgs) = (1.-frach)*ciacr(mgs) ! *rzxh(mgs)
13786 qiacrf(mgs) = frach*qiacr(mgs)
13787 ciacrf(mgs) = frach*ciacrf(mgs)
13789 IF ( lvol(lh) > 1 ) THEN
13790 viacrf(mgs) = rho0(mgs)*qiacrf(mgs)/rhofrz
13799 ! snow aggregation here
13800 if ( ipconc .ge. 4 ) then !
13803 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
13805 IF ( iessec0flag == 0 ) THEN
13808 tmp = xv(mgs,ls)/(xvmx(ls)*Max(1.,100./Min(100.,xdn(mgs,ls)))) ! fraction of max snow mass
13809 IF ( tmp .lt. essfrac1 ) THEN
13811 ELSEIF ( tmp .gt. essfrac2 ) THEN
13814 ec0(mgs) = (essfrac2 - tmp)/(essfrac2 - essfrac1)
13818 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
13819 ! 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
13820 csacs(mgs) = Min(csacs(mgs),csmxd(mgs))
13826 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 11'
13827 if ( ipconc .ge. 2 .or. ipelec .ge. 9 ) then
13830 IF ( eiw(mgs) .gt. 0.0 ) THEN
13831 ciacw(mgs) = qiacw(mgs)*rho0(mgs)/xmas(mgs,lc)
13832 ciacw(mgs) = min(ciacw(mgs),ccmxd(mgs))
13838 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 18'
13839 if ( ipconc .ge. 2 .or. ipelec .ge. 1 ) then
13844 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. qx(mgs,lr) .gt. qxmin(lr) &
13845 & .and. qracw(mgs) .gt. 0.0 ) THEN
13847 IF ( ipconc .lt. 3 ) THEN
13848 IF ( erw(mgs) .gt. 0.0 ) THEN
13850 & ((0.25)*pi)*erw(mgs)*(cx(mgs,lc) - ccwresv(mgs))*cx(mgs,lr) &
13851 & *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,lc,1)) &
13852 & *( gf1*xdia(mgs,lc,2) &
13853 & + 2.0*gf2*xdia(mgs,lc,1)*xdia(mgs,lr,1) &
13854 & + gf3*xdia(mgs,lr,2) )
13856 ELSE ! IF ( ipconc .ge. 3 .and.
13857 IF ( dmrauto <= 0 .or. rho0(mgs)*qx(mgs,lr) > 1.2*xl2p(mgs) ) THEN !{
13858 IF ( 0.5*xdia(mgs,lr,3) .gt. rh(mgs) ) THEN ! { .or. cx(mgs,lr) .gt. nh(mgs)
13859 ! IF ( qx(mgs,lc) .gt. qxmin(lc) .and. qx(mgs,lr) .gt. qxmin(lr) ) THEN
13860 IF ( 0.5*xdia(mgs,lr,3) .gt. rwradmn ) THEN ! r > 50.e-6
13861 ! DM0CCC=A2*XNC*XNR*(XVC+XVR) ! (A11)
13862 ! NOTE: murain drops out, so same result for imurain = 1 and 3
13863 cracw(mgs) = aa2*cx(mgs,lr)*(cx(mgs,lc) - ccwresv(mgs))*(xv(mgs,lc) + xv(mgs,lr))
13865 IF ( imurain == 3 ) THEN
13866 ! DM0CCC=A1*XNC*XNR*(((CNU+2.)/(CNU+1.))*XVC**2+((RNU+2.)/(RNU+1.))*XVR**2) ! (A13)
13867 cracw(mgs) = aa1*cx(mgs,lr)*(cx(mgs,lc) - ccwresv(mgs))* &
13868 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.) + &
13869 & (alpha(mgs,lr) + 2.)*xv(mgs,lr)**2/(alpha(mgs,lr) + 1.))
13870 ELSE ! imurain == 1 USE CP00 for rain DSD in diameter
13871 cracw(mgs) = aa1*cx(mgs,lr)*(cx(mgs,lc) - ccwresv(mgs))* &
13872 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.) + &
13873 & (alpha(mgs,lr) + 6.)*(alpha(mgs,lr) + 5.)*(alpha(mgs,lr) + 4.)*xv(mgs,lr)**2/ &
13874 & ((alpha(mgs,lr) + 3.)*(alpha(mgs,lr) + 2.)*(alpha(mgs,lr) + 1.)) )
13880 ENDIF ! qc > qcmin & qr > qrmin
13882 ! Rain self collection (cracr) and break-up (factor of ec0)
13886 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
13887 rwrad = 0.5*xdia(mgs,lr,3)
13888 IF ( xdia(mgs,lr,3) .gt. 2.0e-3 .or. icracr <= 0 ) THEN
13892 IF ( dmrauto <= 0 .or. rho0(mgs)*qx(mgs,lr) > 1.2*xl2p(mgs) ) THEN
13893 IF ( xdia(mgs,lr,3) .lt. 6.1e-4 ) THEN
13896 ec0(mgs) = Exp(-50.0*(50.0*(xdia(mgs,lr,3) - 6.0e-4)))
13900 IF ( rwrad .ge. 50.e-6 ) THEN
13901 cracr(mgs) = ec0(mgs)*aa2*cx(mgs,lr)**2*xv(mgs,lr)
13903 IF ( imurain == 3 ) THEN
13904 cracr(mgs) = ec0(mgs)*aa1*(cx(mgs,lr)*xv(mgs,lr))**2* &
13905 & (alpha(mgs,lr) + 2.)/(alpha(mgs,lr) + 1.)
13906 ELSE ! imurain == 1
13907 cracr(mgs) = ec0(mgs)*aa1*(cx(mgs,lr)*xv(mgs,lr))**2* &
13908 & (alpha(mgs,lr) + 6.)*(alpha(mgs,lr) + 5.)*(alpha(mgs,lr) + 4.)/ &
13909 & ((alpha(mgs,lr) + 3.)*(alpha(mgs,lr) + 2.)*(alpha(mgs,lr) + 1.))
13913 ! cracr(mgs) = Min(cracr(mgs),crmxd(mgs))
13918 ! cracw(mgs) = min(cracw(mgs),cxmxd(mgs,lc))
13927 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22ii'
13929 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
13932 IF ( ipconc .ge. 5 ) THEN
13933 IF ( qhacw(mgs) .gt. 0.0 .and. xmas(mgs,lc) .gt. 0.0 ) THEN
13935 ! This is the explict version of chacw, which turns out to be very close to the
13936 ! approximation that the droplet size does not change, to within a few percent.
13937 ! This may _not_ be the case for cnu other than zero!
13938 ! chacw(mgs) = (ehw(mgs)*cx(mgs,lc)*cx(mgs,lh)*(pi/4.)*
13939 ! : abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1))*
13940 ! : (2.0*xdia(mgs,lh,1)*(xdia(mgs,lh,1) +
13941 ! : xdia(mgs,lc,1)*gf43rds) +
13942 ! : xdia(mgs,lc,2)*gf53rds))
13944 ! chacw(mgs) = Min( chacw(mgs), 0.6*cx(mgs,lc)*dtpinv )
13946 ! chacw(mgs) = qhacw(mgs)*rho0(mgs)/xmas(mgs,lc)
13947 chacw(mgs) = qhacw(mgs)*rho0(mgs)/xmascw(mgs)
13948 ! chacw(mgs) = min(chacw(mgs),cxmxd(mgs,lc))
13949 chacw(mgs) = Min( chacw(mgs), 0.5*(cx(mgs,lc) - ccwresv(mgs))*dtpinv )
13956 & ((0.25)*pi)*ehw(mgs)*cx(mgs,lc)*cx(mgs,lh) &
13957 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1)) &
13958 & *( gf1*xdia(mgs,lc,2) &
13959 & + 2.0*gf2*xdia(mgs,lc,1)*xdia(mgs,lh,1) &
13960 & + gf3*xdia(mgs,lh,2) )
13961 chacw(mgs) = min(chacw(mgs),0.5*cx(mgs,lc)*dtpinv)
13962 ! chacw(mgs) = min(chacw(mgs),cxmxd(mgs,lc))
13963 ! chacw(mgs) = min(chacw(mgs),ccmxd(mgs))
13968 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22kk'
13970 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
13972 IF ( ehi(mgs) .gt. 0.0 .or. ( ehiclsn(mgs) > 0.0 .and. ipelec > 0 )) THEN
13973 IF ( ipconc .ge. 5 ) THEN
13975 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,li,1))**2 + &
13976 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,li,1) )
13978 chaci0(mgs) = 0.25*pi*ehiclsn(mgs)*cx(mgs,lh)*cx(mgs,li)*vt* &
13979 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
13980 & dab0lh(mgs,lh,li)*xdia(mgs,lh,3)*xdia(mgs,li,3) + &
13981 & da0(li)*xdia(mgs,li,3)**2 )
13985 & ((0.25)*pi)*ehiclsn(mgs)*cx(mgs,li)*cx(mgs,lh) &
13986 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,li,1)) &
13987 & *( gf1*xdia(mgs,li,2) &
13988 & + 2.0*gf2*xdia(mgs,li,1)*xdia(mgs,lh,1) &
13989 & + gf3*xdia(mgs,lh,2) )
13992 chaci(mgs) = min(ehi(mgs)*chaci0(mgs),cimxd(mgs))
13999 if ( lis > 1 .and. ipconc .ge. 5 .or. ipelec .ge. 1 ) then
14001 IF ( ehis(mgs) .gt. 0.0 .or. ( ehisclsn(mgs) > 0.0 .and. ipelec > 0 )) THEN
14003 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,lis,1))**2 + &
14004 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,lis,1) )
14006 chacis0(mgs) = 0.25*pi*ehisclsn(mgs)*cx(mgs,lh)*cx(mgs,lis)*vt* &
14007 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
14008 & dab0lh(mgs,lh,lis)*xdia(mgs,lh,3)*xdia(mgs,lis,3) + &
14009 & da0(lis)*xdia(mgs,lis,3)**2 )
14012 chacis(mgs) = min(ehis(mgs)*chacis0(mgs),cxmxd(mgs,lis))
14018 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22nn'
14020 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
14022 IF ( ehs(mgs) .gt. 0 ) THEN
14023 IF ( ipconc .ge. 5 .or. ( ehsclsn(mgs) > 0.0 .and. ipelec > 0 ) ) THEN
14025 vt = Sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1))**2 + &
14026 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,ls,1) )
14028 chacs0(mgs) = 0.25*pi*ehsclsn(mgs)*cx(mgs,lh)*cx(mgs,ls)*vt* &
14029 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
14030 & dab0lh(mgs,lh,ls)*xdia(mgs,lh,3)*xdia(mgs,ls,3) + &
14031 & da0(ls)*xdia(mgs,ls,3)**2 )
14035 & ((0.25)*pi)*ehsclsn(mgs)*cx(mgs,ls)*cx(mgs,lh) &
14036 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1)) &
14037 & *( gf3*gf1*xdia(mgs,ls,2) &
14038 & + 2.0*gf2*gf2*xdia(mgs,ls,1)*xdia(mgs,lh,1) &
14039 & + gf1*gf3*xdia(mgs,lh,2) )
14041 chacs(mgs) = min(ehs(mgs)*chacs0(mgs),csmxd(mgs))
14051 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22ii'
14053 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
14056 IF ( lhl .gt. 1 .and. ipconc .ge. 5 ) THEN
14057 IF ( qhlacw(mgs) .gt. 0.0 .and. xmas(mgs,lc) .gt. 0.0 ) THEN
14059 ! This is the explict version of chacw, which turns out to be very close to the
14060 ! approximation that the droplet size does not change, to within a few percent.
14061 ! This may _not_ be the case for cnu other than zero!
14062 ! chlacw(mgs) = (ehlw(mgs)*cx(mgs,lc)*cx(mgs,lhl)*(pi/4.)*
14063 ! : abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,lc,1))*
14064 ! : (2.0*xdia(mgs,lhl,1)*(xdia(mgs,lhl,1) +
14065 ! : xdia(mgs,lc,1)*gf43rds) +
14066 ! : xdia(mgs,lc,2)*gf53rds))
14068 ! chlacw(mgs) = Min( chlacw(mgs), 0.6*cx(mgs,lc)*dtpinv )
14070 ! chlacw(mgs) = qhlacw(mgs)*rho0(mgs)/xmas(mgs,lc)
14071 chlacw(mgs) = qhlacw(mgs)*rho0(mgs)/xmascw(mgs)
14072 ! chlacw(mgs) = min(chlacw(mgs),cxmxd(mgs,lc))
14073 chlacw(mgs) = Min( chlacw(mgs), 0.5*cx(mgs,lc)*dtpinv )
14079 ! > ((0.25)*pi)*ehlw(mgs)*cx(mgs,lc)*cx(mgs,lhl)
14080 ! > *abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,lc,1))
14081 ! > *( gf1*xdia(mgs,lc,2)
14082 ! > + 2.0*gf2*xdia(mgs,lc,1)*xdia(mgs,lhl,1)
14083 ! > + gf3*xdia(mgs,lhl,2) )
14084 ! chlacw(mgs) = min(chlacw(mgs),0.5*cx(mgs,lc)*dtpinv)
14085 ! chlacw(mgs) = min(chlacw(mgs),cxmxd(mgs,lc))
14086 ! chlacw(mgs) = min(chlacw(mgs),ccmxd(mgs))
14091 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22kk'
14094 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
14096 IF ( lhl .gt. 1 .and. ( ehli(mgs) .gt. 0.0 .or. (ipelec > 0 .and. ehliclsn(mgs) > 0.0) ) ) THEN
14097 IF ( ipconc .ge. 5 ) THEN
14099 vt = Sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,li,1))**2 + &
14100 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,li,1) )
14102 chlaci0(mgs) = 0.25*pi*ehliclsn(mgs)*cx(mgs,lhl)*cx(mgs,li)*vt* &
14103 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
14104 & dab0(lhl,li)*xdia(mgs,lhl,3)*xdia(mgs,li,3) + &
14105 & da0(li)*xdia(mgs,li,3)**2 )
14109 ! > ((0.25)*pi)*ehli(mgs)*cx(mgs,li)*cx(mgs,lhl)
14110 ! > *abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,li,1))
14111 ! > *( gf1*xdia(mgs,li,2)
14112 ! > + 2.0*gf2*xdia(mgs,li,1)*xdia(mgs,lhl,1)
14113 ! > + gf3*xdia(mgs,lhl,2) )
14116 chlaci(mgs) = min(ehli(mgs)*chlaci0(mgs),cimxd(mgs))
14122 IF ( lis > 1 .and. ipconc .ge. 5) THEN
14124 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22kk'
14128 IF ( lhl .gt. 1 .and. ( ehlis(mgs) .gt. 0.0 .or. (ipelec > 0 .and. ehlisclsn(mgs) > 0.0) ) ) THEN
14130 vt = Sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,lis,1))**2 + &
14131 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,lis,1) )
14133 chlacis0(mgs) = 0.25*pi*ehlisclsn(mgs)*cx(mgs,lhl)*cx(mgs,lis)*vt* &
14134 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
14135 & dab0(lhl,lis)*xdia(mgs,lhl,3)*xdia(mgs,lis,3) + &
14136 & da0(lis)*xdia(mgs,lis,3)**2 )
14139 chlacis(mgs) = min(ehlis(mgs)*chlacis0(mgs),cxmxd(mgs,lis))
14146 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22jj'
14149 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
14151 IF ( lhl .gt. 1 .and. ( ehls(mgs) .gt. 0.0 .or. (ipelec > 0 .and. ehlsclsn(mgs) > 0.0) ) ) THEN
14152 IF ( ipconc .ge. 5 ) THEN
14154 vt = Sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,ls,1))**2 + &
14155 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,ls,1) )
14157 chlacs0(mgs) = 0.25*pi*ehlsclsn(mgs)*cx(mgs,lhl)*cx(mgs,ls)*vt* &
14158 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
14159 & dab0(lhl,ls)*xdia(mgs,lhl,3)*xdia(mgs,ls,3) + &
14160 & da0(ls)*xdia(mgs,ls,3)**2 )
14164 ! > ((0.25)*pi)*ehls(mgs)*cx(mgs,ls)*cx(mgs,lhl)
14165 ! > *abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,ls,1))
14166 ! > *( gf3*gf1*xdia(mgs,ls,2)
14167 ! > + 2.0*gf2*gf2*xdia(mgs,ls,1)*xdia(mgs,lhl,1)
14168 ! > + gf1*gf3*xdia(mgs,lhl,2) )
14170 chlacs(mgs) = min(ehls(mgs)*chlacs0(mgs),csmxd(mgs))
14176 ! Ziegler (1985) autoconversion
14179 IF ( ipconc .ge. 2 .and. ircnw /= -1) THEN ! DTD: added flag for autoconversion. If -1, turns off autoconversion
14180 if (ndebug .gt. 0 ) write(0,*) 'conc 26a'
14189 IF ( dmrauto >= -1 ) THEN !{
14193 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. 1000. .and. temg(mgs) .gt. tfrh+4.) THEN
14194 !( .and. w(igs(mgs),jgs,kgs(mgs)) > 5.0) THEN ! DTD: added w threshold for testing
14195 volb = xv(mgs,lc)*(1./(1.+alpha(mgs,lc)))**(1./2.)
14196 cautn(mgs) = Min(ccmxd(mgs), &
14197 & ((alpha(mgs,lc)+2.)/(alpha(mgs,lc)+1.))*aa1*cx(mgs,lc)**2*xv(mgs,lc)**2)
14198 cautn(mgs) = Max( 0.0d0, cautn(mgs) )
14199 IF ( rb(mgs) .le. 7.51d-6 ) THEN
14203 ! XL2P=2.7E-2*XNC*XVC*((1.E12*RB**3*RC)-0.4)
14205 ! T2S=3.72E-3/(((1.E4*RB)-7.5)*XNC*XVC)
14206 ! t2s = 3.72E-3/(((1.e6*rb)-7.5)*cx(mgs,lc)*xv(mgs,lc))
14207 ! t2s = 3.72/(((1.e6*rb(mgs))-7.5)*rho0(mgs)*qx(mgs,lc))
14208 t2s = 3.72/(1.e6*(rb(mgs)-7.500d-6)*rho0(mgs)*qx(mgs,lc))
14210 qrcnw(mgs) = Max( 0.0d0, xl2p(mgs)/(t2s*rho0(mgs)) )
14211 crcnw(mgs) = Max( 0.0d0, Min(3.5e9*xl2p(mgs)/t2s,0.5*cautn(mgs)) )
14213 IF ( dmrauto == 0 ) THEN
14214 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)
14215 crcnw(mgs) = cx(mgs,lr)/qx(mgs,lr)*qrcnw(mgs)
14216 ELSEIF ( ( dmropt == 1 .or. dmropt == 3 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
14217 tmp = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
14218 crcnw(mgs) = Min(tmp,crcnw(mgs) )
14219 ELSEIF ( ( dmropt == 4 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
14221 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
14222 ! try mass-weighted average of old and new Dmr using converted qc mass
14223 crcnw(mgs) = (tmp*qrcnw(mgs)+tmp2*qx(mgs,lr))/(qrcnw(mgs)+qx(mgs,lr))
14224 ELSEIF ( ( dmropt == 5 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
14226 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
14227 ! try mass-weighted average of old and new Dmr using full qc mass
14228 crcnw(mgs) = (tmp*qx(mgs,lc)+tmp2*qx(mgs,lr))/(qx(mgs,lc)+qx(mgs,lr))
14229 ELSEIF ( ( dmropt == 6 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
14231 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
14232 ! try mass*diameter-weighted average of old and new Dmr (using full qc mass)
14233 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))
14234 ELSEIF ( ( dmropt == 7 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
14236 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
14237 ! try diameter-weighted average of old and new Dmr
14238 crcnw(mgs) = (tmp*xdia(mgs,lc,3)+tmp2*xdia(mgs,lr,3))/(xdia(mgs,lc,3)+xdia(mgs,lr,3))
14239 ELSEIF ( ( dmropt == 8 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
14241 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
14242 ! try sqrt(diameter)-weighted average of old and new Dmr
14243 crcnw(mgs) = (tmp*sqrt(xdia(mgs,lc,3))+tmp2*sqrt(xdia(mgs,lr,3)))/(sqrt(xdia(mgs,lc,3))+sqrt(xdia(mgs,lr,3)))
14245 ELSEIF ( dmrauto == 1 .and. cx(mgs,lr) > cxmin) THEN
14246 IF ( qx(mgs,lr) > qxmin(lr) ) THEN
14247 tmp = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
14248 crcnw(mgs) = Min(tmp,crcnw(mgs) )
14250 ELSEIF ( dmrauto == 2 .and. cx(mgs,lr) > cxmin) THEN
14252 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
14253 ! try mass-weighted average of old and new Dmr
14254 crcnw(mgs) = (tmp*qrcnw(mgs)+tmp2*qx(mgs,lr))/(qrcnw(mgs)+qx(mgs,lr))
14255 ELSEIF ( dmrauto == 3 .and. cx(mgs,lr) > cxmin) THEN ! adapted from MY/CP code
14256 tmp = Max( 2.d0*rh(mgs), dble( xdia(mgs,lr,3) ) )
14257 crcnw(mgs) = rho0(mgs)*qrcnw(mgs)/(pi/6.*1000.*tmp**3)
14260 IF ( crcnw(mgs) < 1.e-30 ) qrcnw(mgs) = 0.0
14262 ! IF ( crcnw(mgs) .gt. cautn(mgs) .and. crcnw(mgs) .gt. 1.0 )
14264 ! write(0,*) 'crcnw,cautn ',crcnw(mgs)/cautn(mgs),
14265 ! : crcnw(mgs),cautn(mgs),igs(mgs),kgs(mgs),t2s,qx(mgs,lr)
14266 ! write(0,*) ' ',qx(mgs,lc),cx(mgs,lc),0.5e6*xdia(mgs,lc,1)
14267 ! write(0,*) ' ',rho0(mgs)*qrcnw(mgs)/crcnw(mgs),
14268 ! : 1.e6*(( 3/(4.*pi))*rho0(mgs)*qrcnw(mgs)/
14269 ! : (crcnw(mgs)*xdn(mgs,lr)))**(1./3.),rh(mgs)*1.e6,rwrad(mgs)
14270 ! ELSEIF ( crcnw(mgs) .gt. 1.0 .and. cautn(mgs) .gt. 0.) THEN
14271 ! write(0,*) 'crcnw,cautn ',crcnw(mgs)/cautn(mgs),
14272 ! : crcnw(mgs),cautn(mgs),igs(mgs),kgs(mgs),t2s
14273 ! write(0,*) ' ',rho0(mgs)*qrcnw(mgs)/crcnw(mgs),
14274 ! : 1.e6*(( 3*pi/4.)*rho0(mgs)*qrcnw(mgs)/
14275 ! : (crcnw(mgs)*xdn(mgs,lr)))**(1./3.)
14277 ! crcnw(mgs) = Min(cautn(mgs),3.5e9*xl2p(mgs)/t2s)
14279 ! IF ( qrcnw(mgs) .gt. 0.3e-2 ) THEN
14280 ! write(0,*) 'QRCNW'
14281 ! write(0,*) qrcnw(mgs),crcnw(mgs),cautn(mgs)
14282 ! write(0,*) xl2p,t2s,rho0(mgs),xv(mgs,lc),cx(mgs,lc),qx(mgs,lc)
14283 ! write(0,*) rb,0.5*xdia(mgs,lc,1),mgs,igs(mgs),kgs(mgs)
14285 ! qrcnw(mgs) = Min(qrcnw(mgs),qcmxd(mgs))
14292 ENDIF !} dmrauto >= 0
14299 ! Berry 1968 auto conversion for rain (Orville & Kopp 1977)
14302 if ( ircnw .eq. 4 ) then
14304 ! sconvmix(lcw,mgs) = 0.0
14306 qdiff = max((qx(mgs,lc)-qminrncw),0.0)
14307 if ( qdiff .gt. 0.0 .and. xdia(mgs,lc,1) .gt. 20.0e-6 ) then
14309 & ((1.2e-4)+(1.596e-12)*(cx(mgs,lc)*1.0e-6) &
14310 & /(cwdisp*qdiff*1.0e-3*rho0(mgs)))
14311 qrcnw(mgs) = (rho0(mgs)*1e-3)*(qdiff**2)/argrcnw
14312 ! sconvmix(lcw,mgs) = max(sconvmix(lcw,mgs),0.0)
14313 qrcnw(mgs) = (max(qrcnw(mgs),0.0))
14321 ! Berry 1968 auto conversion for rain (Ferrier 1994)
14324 if ( ircnw .eq. 5 ) then
14328 qccrit = (pi/6.)*(cx(mgs,lc)*cwdiap**3)*xdn(mgs,lc)/rho0(mgs)
14329 qdiff = max((qx(mgs,lc)-qccrit),0.)
14330 if ( qdiff .gt. 0.0 .and. cx(mgs,lc) .gt. 1.0 ) then
14332 ! > ((1.2e-4)+(1.596e-12)*cx(mgs,lc)/(cwdisp*rho0(mgs)*qdiff)) &
14333 & ((1.2e-4)+(1.596e-12)*cx(mgs,lc)*1.0e-3/(cwdisp*rho0(mgs)*qdiff))
14335 ! > timflg(mgs)*rho0(mgs)*(qdiff**2)/argrcnw &
14336 & 1.0e-3*rho0(mgs)*(qdiff**2)/argrcnw
14337 qrcnw(mgs) = Min(qxmxd(mgs,lc), (max(qrcnw(mgs),0.0)) )
14339 ! write(iunit,*) 'qrcnw,cx =',qrcnw(mgs),cx(mgs,lc),mgs,1.e3*qx(mgs,lc),cno(lr)
14346 ! kessler auto conversion for rain.
14348 if ( ircnw .eq. 2 ) then
14351 qrcnw(mgs) = (0.001)*max((qx(mgs,lc)-qminrncw),0.0)
14356 ! c1 = 0.12-0.32 for colorado storms...typically 0.3-0.4
14357 ! berry reinhart type conversion (proctor 1988)
14359 if ( ircnw .eq. 1 ) then
14365 & (1.e+06) * ((c1/(0.38))**(1./3.)) * (xdia(mgs,lc,1)*(0.5))
14367 & (0.027) * ((100.0)*(bradp**3)*(xdia(mgs,lc,1)*(0.5)) - (0.4))
14368 bt2 = (bradp -7.5) / (3.72)
14370 if ( bl2 .gt. 0.0 .and. bt2 .gt. 0.0 ) then
14371 qrcnw(mgs) = bl2 * bt2 * rho0(mgs) &
14372 & * qx(mgs,lc) * qx(mgs,lc)
14379 ENDIF ! ( ipconc .ge. 2 )
14384 ! Bigg Freezing of Rain
14386 if (ndebug .gt. 0 ) write(0,*) 'conc 27a'
14399 IF ( .not. ( ipconc == 0 .and. lwsm6 ) ) THEN
14402 if ( qx(mgs,lr) .gt. qxmin(lr) .and. temcg(mgs) .lt. -5. .and. ibiggopt > 0 ) then
14405 IF ( ipconc .lt. 3 ) THEN
14408 & (20.0)*(pi**2)*brz*(xdn(mgs,lr)/rho0(mgs)) &
14409 & *cx(mgs,lr)*(xdia(mgs,lr,1)**6) &
14410 & *(exp(max(-arz*temcg(mgs), 0.0))-1.0) &
14412 qrfrzf(mgs) = qrfrz(mgs)
14414 ! ELSEIF ( ipconc .ge. 3 .and. xv(mgs,lr) .gt. 1.1*xvmn(lr) ) THEN
14415 ELSEIF ( ipconc .ge. 3 ) THEN
14416 ! tmp = brz*cx(mgs,lr)*(Exp(Max( -arz*temcg(mgs), 0.0 )) - 1.0)
14417 ! crfrz(mgs) = xv(mgs,lr)*tmp
14421 ! IF ( ibiggopt == 2 .and. imurain == 1 .and. lzr < 1 ) THEN ! lzr check because results are weird for 3-moment
14422 IF ( ibiggopt == 2 .and. imurain == 1 ) THEN !
14423 ! integrate from Bigg diameter (for given supercooling Ts) to infinity
14425 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)
14426 ! 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
14427 ! volt is given in cm**3, so convert to m**3
14428 dbigg = (6./pi* volt )**(1./3.)
14430 ! perhaps should also test that W > V_t_dbigg, i.e., that drops the size of dbigg are being lifted and cooled.
14431 IF ( dbigg < 8.e-3 ) THEN !{ only bother if freezing diameter is reasonable
14433 ratio = Min(maxratiolu, dbigg/xdia(mgs,lr,1) )
14435 i = Min(nqiacrratio,Int(ratio*dqiacrratioinv))
14436 IF ( alp0flag ) THEN
14437 j = Int(Max(0.0,Min(15.,alpha(mgs,lr)))*dqiacralphainv)
14439 j = Int(Max(minalphalu,Min(maxalphalu,alpha(mgs,lr)))*dqiacralphainv)
14441 delx = ratio - float(i)*dqiacrratio
14442 dely = alpha(mgs,lr) - float(j)*dqiacralpha
14443 ip1 = Min( i+1, nqiacrratio )
14444 jp1 = Min( j+1, nqiacralpha )
14446 ! interpolate along x, i.e., ratio;
14447 tmp1 = ciacrratio(i,j) + delx*dqiacrratioinv*(ciacrratio(ip1,j) - ciacrratio(i,j))
14448 tmp2 = ciacrratio(i,jp1) + delx*dqiacrratioinv*(ciacrratio(ip1,jp1) - ciacrratio(i,jp1))
14450 ! interpolate along alpha;
14452 crfrz(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*cx(mgs,lr)*dtpinv
14453 crfrzf(mgs) = crfrz(mgs)
14454 ! interpolate along x, i.e., ratio;
14455 tmp1 = qiacrratio(i,j) + delx*dqiacrratioinv*(qiacrratio(ip1,j) - qiacrratio(i,j))
14456 tmp2 = qiacrratio(i,jp1) + delx*dqiacrratioinv*(qiacrratio(ip1,jp1) - qiacrratio(i,jp1))
14458 ! interpolate along alpha;
14460 qrfrz(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*qx(mgs,lr)*dtpinv
14461 qrfrzf(mgs) = qrfrz(mgs)
14463 IF ( qrfrz(mgs)*dtp < qxmin(lh) .or. crfrz(mgs)*dtp < cxmin ) THEN
14473 IF ( ibiggsmallrain > 0 .and. xv(mgs,lr) < 2.*xvmn(lr) .and. ( ibiggsnow == 1 .or. ibiggsnow == 3 ) ) THEN
14474 ! IF ( ibiggsmallrain > 0 .and. xv(mgs,lr) < xvbiggsnow .and. ( ibiggsnow == 1 .or. ibiggsnow == 3 ) ) THEN
14475 ! rain drops are so small that they cannot be pushed smaller, so put into snow (or cloud ice, depending on ifrzs)
14478 crfrzs(mgs) = crfrz(mgs)
14479 qrfrzs(mgs) = qrfrz(mgs)
14481 ELSEIF ( dbigg < Max( biggsnowdiam, Max(dfrz,dhmn)) .and. ( ibiggsnow == 1 .or. ibiggsnow == 3 ) ) THEN ! { convert some to snow or ice crystals
14482 ! temporarily store qrfrz and crfrz in snow terms and caclulate new crfrzf, qrfrzf, and zrfrzf. Leave crfrz etc. alone!
14484 crfrzs(mgs) = crfrz(mgs)
14485 qrfrzs(mgs) = qrfrz(mgs)
14487 IF ( ibiggsmallrain > 0 .and. xv(mgs,lr) < 1.2*xvmn(lr) ) THEN
14488 ! rain drops are so small that they cannot be pushed smaller, so put into snow (or cloud ice, depending on ifrzs)
14494 ! recalculate using dhmn for ratio
14495 ratio = Min( maxratiolu, Max(dfrz,dhmn)/xdia(mgs,lr,1) )
14497 i = Min(nqiacrratio,Int(ratio*dqiacrratioinv))
14498 ! j = Int(Max(0.0,Min(15.,alpha(mgs,lr)))*dqiacralphainv)
14499 ! j = Int(Max(alphamin,Min(alphamax,alpha(mgs,lr)))*dqiacralphainv)
14500 IF ( alp0flag ) THEN
14501 j = Int(Max(0.0,Min(15.,alpha(mgs,lr)))*dqiacralphainv)
14503 j = Int(Max(minalphalu,Min(maxalphalu,alpha(mgs,lr)))*dqiacralphainv)
14505 delx = ratio - float(i)*dqiacrratio
14506 dely = alpha(mgs,lr) - float(j)*dqiacralpha
14507 ip1 = Min( i+1, nqiacrratio )
14508 jp1 = Min( j+1, nqiacralpha )
14510 ! interpolate along x, i.e., ratio;
14511 tmp1 = ciacrratio(i,j) + delx*dqiacrratioinv*(ciacrratio(ip1,j) - ciacrratio(i,j))
14512 tmp2 = ciacrratio(i,jp1) + delx*dqiacrratioinv*(ciacrratio(ip1,jp1) - ciacrratio(i,jp1))
14515 ! interpolate along alpha;
14517 crfrzf(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*cx(mgs,lr)*dtpinv
14519 ! interpolate along x, i.e., ratio;
14520 tmp1 = qiacrratio(i,j) + delx*dqiacrratioinv*(qiacrratio(ip1,j) - qiacrratio(i,j))
14521 tmp2 = qiacrratio(i,jp1) + delx*dqiacrratioinv*(qiacrratio(ip1,jp1) - qiacrratio(i,jp1))
14523 ! interpolate along alpha;
14525 qrfrzf(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*qx(mgs,lr)*dtpinv
14527 ! now subtract off the difference
14528 crfrzs(mgs) = crfrzs(mgs) - crfrzf(mgs)
14529 qrfrzs(mgs) = qrfrzs(mgs) - qrfrzf(mgs)
14539 IF ( (qrfrz(mgs))*dtp > qx(mgs,lr) ) THEN
14540 fac = ( qrfrz(mgs) )*dtp/qx(mgs,lr)
14541 qrfrz(mgs) = fac*qrfrz(mgs)
14542 qrfrzs(mgs) = fac*qrfrzs(mgs)
14543 qrfrzf(mgs) = fac*qrfrzf(mgs)
14544 crfrz(mgs) = fac*crfrz(mgs)
14545 crfrzs(mgs) = fac*crfrzs(mgs)
14546 crfrzf(mgs) = fac*crfrzf(mgs)
14551 ! IF ( (crfrzs(mgs) + crfrz(mgs))*dtp > cx(mgs,lr) ) THEN
14552 ! fac = ( crfrzs(mgs) + crfrz(mgs) )*dtp/cx(mgs,lr)
14553 ! crfrz(mgs) = fac*crfrz(mgs)
14554 ! crfrzs(mgs) = fac*crfrzs(mgs)
14557 ! qrfrzf(mgs) = qrfrz(mgs)
14558 ! crfrzf(mgs) = crfrz(mgs)
14560 ! qrfrz(mgs) = qrfrzf(mgs) + qrfrzs(mgs)
14561 ! crfrz(mgs) = crfrzf(mgs) + crfrzs(mgs)
14564 ELSEIF ( ibiggopt == 1 ) THEN
14566 tmp = xv(mgs,lr)*brz*cx(mgs,lr)*(Exp(Max( -arz*temcg(mgs), 0.0 )) - 1.0)
14567 IF ( .false. .and. tmp .gt. cxmxd(mgs,lr) ) THEN ! {
14568 ! write(iunit,*) 'Bigg Freezing problem!',mgs,igs(mgs),kgs(mgs)
14569 ! write(iunit,*) 'tmp, cx(lr), xv = ',tmp, cx(mgs,lr), xv(mgs,lr), (Exp(Max( -arz*temcg(mgs), 0.0 )) - 1.0)
14570 ! write(iunit,*) 'qr,temcg = ',qx(mgs,lr)*1000.,temcg(mgs)
14571 crfrz(mgs) = cxmxd(mgs,lr) ! cx(mgs,lr)*dtpinv
14572 qrfrz(mgs) = qxmxd(mgs,lr) ! qx(mgs,lr)*dtpinv
14576 ! crfrzfmx = cx(mgs,lr)*Exp(-4./3.*pi*(40.e-6)**3/xv(mgs,lr))
14577 ! IF ( crfrz(mgs) .gt. crfrzmx ) THEN
14578 ! crfrz(mgs) = crfrzmx
14579 ! qrfrz(mgs) = bfnu*xmas(mgs,lr)*rhoinv(mgs)*crfrzmx
14580 ! qwcnr(mgs) = cx(mgs,lr) - crfrzmx
14582 IF ( lzr < 1 ) THEN
14583 IF ( imurain == 3 ) THEN
14589 ! bfnu = 1.0 ! (alpha(mgs,lr)+2.0)/(alpha(mgs,lr)+1.)
14590 IF ( imurain == 3 ) THEN
14591 bfnu = (alpha(mgs,lr)+2.0)/(alpha(mgs,lr)+1.)
14594 bfnu = (4. + alpha(mgs,lr))*(5. + alpha(mgs,lr))*(6. + alpha(mgs,lr))/ &
14595 & ((1. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(3. + alpha(mgs,lr)))
14599 qrfrz(mgs) = bfnu*xmas(mgs,lr)*rhoinv(mgs)*crfrz(mgs)
14601 qrfrz(mgs) = Min( qrfrz(mgs), 1.*qx(mgs,lr)*dtpinv ) ! qxmxd(mgs,lr)
14602 crfrz(mgs) = Min( crfrz(mgs), 1.*cx(mgs,lr)*dtpinv ) !cxmxd(mgs,lr)
14603 qrfrz(mgs) = Min( qrfrz(mgs), qx(mgs,lr) )
14604 qrfrzf(mgs) = qrfrz(mgs)
14610 IF ( crfrz(mgs) .gt. qxmin(lh) ) THEN !{ Yes, it compares cx and qxmin, but this is just to be sure that
14611 ! crfrz is greater than zero in the division
14612 ! IF ( xdia(mgs,lr,1) .lt. 200.e-6 ) THEN
14613 ! IF ( xv(mgs,lr) .lt. xvmn(lh) ) THEN
14615 IF ( (ibiggsnow == 1 .or. ibiggsnow == 3 ) .and. ibiggopt /= 2 ) THEN
14616 xvfrz = rho0(mgs)*qrfrz(mgs)/(crfrz(mgs)*900.) ! mean volume of frozen drops; 900. for frozen drop density
14617 frach = 0.5 *(1. + Tanh(0.2e12 *( xvfrz - 1.15*xvmn(lh))))
14619 qrfrzs(mgs) = (1.-frach)*qrfrz(mgs)
14620 crfrzs(mgs) = (1.-frach)*crfrz(mgs) ! *rzxh(mgs)
14621 ! qrfrzf(mgs) = frach*qrfrz(mgs)
14625 IF ( ipconc .ge. 14 .and. 1.e-3*rho0(mgs)*qrfrz(mgs)/crfrz(mgs) .lt. xvmn(lh) ) THEN
14626 qrfrzs(mgs) = qrfrz(mgs)
14627 crfrzs(mgs) = crfrz(mgs) ! *rzxh(mgs)
14629 ! crfrz(mgs) = Min( crfrz(mgs), 0.1*cx(mgs,lr)*dtpinv ) ! cxmxd(mgs,lr)
14630 ! qrfrz(mgs) = Min( qrfrz(mgs), 0.1*qx(mgs,lr)*dtpinv ) ! qxmxd(mgs,lr)
14631 qrfrzf(mgs) = frach*qrfrz(mgs)
14632 ! crfrzf(mgs) = Min( qrfrz(mgs)*rho0(mgs)/(xdn(mgs,lh)*vgra), crfrz(mgs) )
14633 IF ( ibfr .le. 1 ) THEN
14634 crfrzf(mgs) = frach*Min(crfrz(mgs), qrfrz(mgs)/(bfnu*1.0*vr1mm*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
14635 ELSEIF ( ibfr .eq. 5 ) THEN
14636 crfrzf(mgs) = frach*Min(crfrz(mgs), qrfrz(mgs)/(bfnu*vfrz*1000.0)*rho0(mgs) )*rzxh(mgs) !*crfrz(mgs)
14637 ELSEIF ( ibfr .eq. 2 ) THEN
14638 crfrzf(mgs) = frach*Min(crfrz(mgs), qrfrz(mgs)/(bfnu*vfrz*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
14639 ELSEIF ( ibfr .eq. 6 ) THEN
14640 crfrzf(mgs) = frach*Max(crfrz(mgs), qrfrz(mgs)/(bfnu*9.*xv(mgs,lr)*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
14642 crfrzf(mgs) = frach*crfrz(mgs)
14644 ! crfrzf(mgs) = Min(crfrz(mgs), qrfrz(mgs)/(bfnu*xvmn(lh)*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
14645 ! IF ( lz(lr) > 1 .and. lz(lh) > 1 ) THEN
14646 ! crfrzf(mgs) = crfrz(mgs)
14650 ! crfrz(mgs) = Min( cxmxd(mgs,lr), rho0(mgs)*qrfrz(mgs)/xmas(mgs,lr) )
14658 IF ( lvol(lh) .gt. 1 ) THEN
14659 vrfrzf(mgs) = rho0(mgs)*qrfrzf(mgs)/rhofrz
14663 IF ( nsplinter .ne. 0 ) THEN
14664 IF ( nsplinter .ge. 1000 ) THEN
14665 ! Lawson et al. 2015 JAS
14666 ! ave. diam of freezing drops in microns
14668 IF ( qrfrz(mgs)*dtp > qxmin(lh) .and. crfrz(mgs) > 1.e-3 ) THEN
14669 tmpdiam = 1.e6*( 6.*qrfrz(mgs)/(1000.*pi*crfrz(mgs) ))**(1./3.) ! avg. diameter of newly frozen drops in microns
14670 tmp = lawson_splinter_fac*tmpdiam**4*crfrz(mgs)
14672 ELSEIF ( nsplinter .gt. 0 ) THEN
14673 tmp = nsplinter*crfrz(mgs)
14675 tmp = -nsplinter*crfrzf(mgs)
14677 csplinter2(mgs) = tmp
14678 qsplinter2(mgs) = Min(0.1*qrfrz(mgs), tmp*splintermass/rho0(mgs) ) ! makes splinters smaller if too much mass is taken from graupel
14680 ! csplinter(mgs) = csplinter(mgs) + tmp
14681 ! qsplinter(mgs) = qsplinter(mgs) + Min(0.1*qrfrz(mgs), tmp*splintermass/rho0(mgs) ) ! makes splinters smaller if too much mass is taken from graupel
14683 ! IF ( temcg(mgs) .lt. -31.0 ) THEN
14684 ! qrfrz(mgs) = qx(mgs,lr)*dtpinv + qrcnw(mgs)
14685 ! qrfrzf(mgs) = qrfrz(mgs)
14686 ! crfrz(mgs) = cx(mgs,lr)*dtpinv + crcnw(mgs)
14687 ! crfrzf(mgs) = Min(crfrz(mgs), qrfrz(mgs)/(bfnu*1.0*vr1mm*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
14689 ! qrfrz(mgs) = 6.0*xdn(mgs,lr)*xv(mgs,lr)**2*tmp*rhoinv(mgs)
14690 ! qrfrz(mgs) = Min( qrfrz(mgs), ffrz*qrmxd(mgs) )
14691 ! crfrz(mgs) = Min( crmxd(mgs), ffrz*crfrz(mgs))
14692 ! crfrz(mgs) = Min(crmxd(mgs),qrfrz(mgs)*rho0(mgs)/xmas(mgs,lr))
14694 ! if ( temg(mgs) .gt. 268.15 ) then
14702 ! Homogeneous freezing of cloud drops to ice crystals
14703 ! following Bigg (1953) and Ferrier (1994).
14705 if (ndebug .gt. 0 ) write(0,*) 'conc 25b'
14713 IF ( ibfc .ge. 1 .and. ibfc /= 3 .and. temg(mgs) < 268.15 ) THEN
14714 ! if ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. 1. .and. &
14715 ! & .not. (ipconc .ge. 2 .and. xdia(mgs,lc,1) .lt. 10.e-6) ) then
14716 if ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. cxmin ) THEN
14717 IF ( ipconc < 2 ) THEN
14718 qwfrz(mgs) = ((2.0)*(brz)/(xdn(mgs,lc)*cx(mgs,lc))) &
14719 & *(exp(max(-arz*temcg(mgs), 0.0))-1.0) &
14720 & *rho0(mgs)*(qx(mgs,lc)**2)
14721 qwfrz(mgs) = max(qwfrz(mgs), 0.0)
14722 qwfrz(mgs) = min(qwfrz(mgs),qcmxd(mgs))
14723 cwfrz(mgs) = qwfrz(mgs)*rho0(mgs)/xmas(mgs,li)
14724 ELSEIF ( ipconc .ge. 2 ) THEN
14725 IF ( xdia(mgs,lc,3) > 0.e-6 ) THEN
14726 volt = exp( 16.2 + 1.0*temcg(mgs) )* 1.0e-6 ! Ts == -temcg ; volt comes from the fit in Fig. 1 in Bigg 1953
14727 ! for mean temperature for freezing: -ln (V) = a*Ts - b
14728 ! volt is given in cm**3, so factor of 1.e-6 to convert to m**3
14729 ! dbigg = (6./pi* volt )**(1./3.)
14731 IF ( alpha(mgs,lc) == 0.0 ) THEN
14732 cwfrz(mgs) = cx(mgs,lc)*Exp(-volt/xv(mgs,lc))*dtpinv ! number of droplets with volume greater than volt
14733 !turn off limit so that all can freeze at low temp
14734 !!! cwfrz(mgs) = Min(cwfrz(mgs),ccmxd(mgs))
14736 qwfrz(mgs) = cwfrz(mgs)*xdn0(lc)*rhoinv(mgs)*(volt + xv(mgs,lc))
14738 ratio = (1. + alpha(mgs,lc))*volt/xv(mgs,lc)
14740 IF ( .false. .and. usegamxinfcnu ) THEN
14741 i = Nint(dgami*(1. + alpha(mgs,lc)))
14743 i = Nint(dgami*(2. + alpha(mgs,lc)))
14746 cwfrz(mgs) = cx(mgs,lc)*Gamxinf(1.+alpha(mgs,lc), ratio)/(dtp*gcnup1) ! gamxinflu(i,j,1,1)
14748 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)
14752 ratio = Min( maxratiolu, ratio )
14753 ! write(0,*) 'cwfrz: temp,ratio = ',temcg(mgs),ratio
14754 ! write(0,*) 'cwfrz: xv,volt,qx = ',xv(mgs,lc),volt,qx(mgs,lc)
14755 ! write(0,*) 'cwfrz: i,j,k = ',igs(mgs),jgs,kgs(mgs)
14756 tmp = gaminterp(ratio,alpha(mgs,lc),1,1)
14757 ! write(0,*) 'cwfrz: tmp1 = ',tmp
14758 cwfrz(mgs) = cx(mgs,lc)*tmp*dtpinv ! Gamxinf(1.+alpha(mgs,lc), ratio)/(dtp*gcnup1) ! gamxinflu(i,j,1,1)
14760 tmp = gaminterp(ratio,alpha(mgs,lc),12,1)
14761 ! write(0,*) 'cwfrz: tmp2 = ',tmp
14762 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)
14770 if ( temg(mgs) .gt. 268.15 ) then
14777 if ( xplate(mgs) .eq. 1 ) then
14778 qwfrzp(mgs) = qwfrz(mgs)
14779 cwfrzp(mgs) = cwfrz(mgs)
14782 if ( xcolmn(mgs) .eq. 1 ) then
14783 qwfrzc(mgs) = qwfrz(mgs)
14784 cwfrzc(mgs) = cwfrz(mgs)
14788 ! qwfrzp(mgs) = 0.0
14789 ! qwfrzc(mgs) = qwfrz(mgs)
14794 ! Contact freezing nucleation: factor is to convert from L-1
14795 ! T < -2C: via Meyers et al. JAM July, 1992 (31, 708-721)
14797 if (ndebug .gt. 0 ) write(0,*) 'conc 25a'
14812 IF ( icfn .ge. 1 ) THEN
14814 IF ( temg(mgs) .lt. 271.15 .and. qx(mgs,lc) .gt. qxmin(lc)) THEN
14816 ! find available # of ice nuclei & limit value to max depletion of cloud water
14818 IF ( icfn .ge. 2 ) THEN
14819 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)
14820 !ccia(mgs) = Min(cwctfz(mgs), ccmxd(mgs) )
14822 ! now find how many of these collect cloud water to form IN
14823 ! Cotton et al 1986
14825 knud(mgs) = 2.28e-5 * temg(mgs) / ( pres(mgs)*raero ) !Walko et al. 1995
14826 knuda(mgs) = 1.257 + 0.4*exp(-1.1/knud(mgs)) !Pruppacher & Klett 1997 eqn 11-16
14827 gtp(mgs) = 1. / ( fai(mgs) + fbi(mgs) ) !Byers 65 / Cotton 72b
14828 dfar(mgs) = kb*temg(mgs)*(1.+knuda(mgs)*knud(mgs))/(6.*pi*fadvisc(mgs)*raero) !P&K 1997 eqn 11-15
14829 fn1(mgs) = 2.*pi*xdia(mgs,lc,1)*cx(mgs,lc)*ccia(mgs)
14830 fn2(mgs) = -gtp(mgs)*(ssw(mgs)-1.)*felv(mgs)/pres(mgs)
14831 fnft(mgs) = 0.4*(1.+1.45*knud(mgs)+0.4*knud(mgs)*exp(-1./knud(mgs)))*(ftka(mgs)+2.5*knud(mgs)*kaero) &
14832 & / ( (1.+3.*knud(mgs))*(2*ftka(mgs)+5.*knud(mgs)*kaero+kaero) )
14835 ! Brownian diffusion
14836 ctfzbd(mgs) = fn1(mgs)*dfar(mgs)
14838 ! Thermophoretic contact nucleation
14839 ctfzth(mgs) = fn1(mgs)*fn2(mgs)*fnft(mgs)/rho0(mgs)
14841 ! Diffusiophoretic contact nucleation
14842 ctfzdi(mgs) = fn1(mgs)*fn2(mgs)*rw*temg(mgs)/(felv(mgs)*rho0(mgs))
14844 cwctfz(mgs) = max( ctfzbd(mgs) + ctfzth(mgs) + ctfzdi(mgs) , 0.)
14846 ! Sum of the contact nucleation processes
14847 ! IF ( cx(mgs,lc) .gt. 1.e6) write(0,*) 'ctfzbd,etc = ',cwctfz(mgs),ctfzbd(mgs),ctfzth(mgs),ctfzdi(mgs)
14848 ! IF ( wvel(mgs) .lt. -0.05 ) write(6,*) 'ctfzbd,etc = ',ctfzbd(mgs),ctfzth(mgs),ctfzdi(mgs),cx(mgs,lc)*1e-6,wvel(mgs)
14849 ! IF ( ssw(mgs) .lt. 1.0 .and. cx(mgs,lc) .gt. 1.e6 .and. cwctfz(mgs) .gt. 1. ) THEN
14850 ! write(6,*) 'ctfzbd,etc = ',ctfzbd(mgs),ctfzth(mgs),ctfzdi(mgs),cx(mgs,lc)*1e-6,wvel(mgs),fn1(mgs),fn2(mgs)
14851 ! write(6,*) 'more = ',nstep,ssw(mgs),dfar(mgs),gtp(mgs),felv(mgs),pres(mgs)
14854 ELSEIF ( icfn .eq. 1 ) THEN
14855 IF ( wvel(mgs) .lt. -0.05 ) THEN ! older kludgy version
14856 cwctfz(mgs) = cfnfac*exp( (-2.80) - (0.262)*temcg(mgs) )
14857 cwctfz(mgs) = Min((1.0e3)*cwctfz(mgs), ccmxd(mgs) ) !convert to m-3
14861 IF ( ipconc .ge. 2 ) THEN
14862 cwctfz(mgs) = Min( cwctfz(mgs)*dtpinv, ccmxd(mgs) )
14863 qwctfz(mgs) = xmas(mgs,lc)*cwctfz(mgs)/rho0(mgs)
14865 qwctfz(mgs) = (cimasn)*cwctfz(mgs)/(dtp*rho0(mgs))
14866 qwctfz(mgs) = max(qwctfz(mgs), 0.0)
14867 qwctfz(mgs) = min(qwctfz(mgs),qcmxd(mgs))
14871 if ( xplate(mgs) .eq. 1 ) then
14872 qwctfzp(mgs) = qwctfz(mgs)
14873 cwctfzp(mgs) = cwctfz(mgs)
14876 if ( xcolmn(mgs) .eq. 1 ) then
14877 qwctfzc(mgs) = qwctfz(mgs)
14878 cwctfzc(mgs) = cwctfz(mgs)
14881 ! IF ( cwctfz(mgs)*dtp > 0.5 .and. dtp*qwctfz(mgs) > qxmin(li) ) THEN
14882 ! write(91,*) 'cwctfz: ',cwctfz(mgs),qwctfz(mgs) ! ,cwctfzc(mgs),qwctfzc(mgs)
14886 ! qwctfzc(mgs) = qwctfz(mgs)
14887 ! qwctfzp(mgs) = 0.0
14897 ! Hobbs-Rangno ice enhancement (Ferrier, 1994)
14899 if (ndebug .gt. 0 ) write(0,*) 'conc 23a'
14901 hrifac = (1.e-3)*((0.044)*(0.01**3))
14909 IF ( ihrn .ge. 1 ) THEN
14910 if ( qx(mgs,lc) .gt. qxmin(lc) ) then
14911 if ( temg(mgs) .lt. 273.15 ) then
14912 ! write(iunit,'(3(1x,i3),3(1x,1pe12.5))')
14913 ! : igs(mgs),jgs,kgs(mgs),cx(mgs,lc),rho0(mgs),qx(mgs,lc)
14914 ! write(iunit,'(1pe15.6)')
14915 ! : log(cx(mgs,lc)*(1.e-6)/(3.0)),
14916 ! : ((1.e-3)*rho0(mgs)*qx(mgs,lc)),
14917 ! : (cx(mgs,lc)*(1.e-6)),
14918 ! : ((1.e-3)*rho0(mgs)*qx(mgs,lc))/(cx(mgs,lc)*(1.e-6)),
14919 ! : (alog(cx(mgs,lc)*(1.e-6)/(3.0)) *
14920 ! > ((1.e-3)*rho0(mgs)*qx(mgs,lc))/(cx(mgs,lc)*(1.e-6)))
14922 IF ( Log(cx(mgs,lc)*(1.e-6)/(3.0)) .gt. 0.0 ) THEN
14923 ciihr(mgs) = ((1.69e17)/dthr) &
14924 & *(log(cx(mgs,lc)*(1.e-6)/(3.0)) * &
14925 & ((1.e-3)*rho0(mgs)*qx(mgs,lc))/(cx(mgs,lc)*(1.e-6)))**(7./3.)
14926 ciihr(mgs) = ciihr(mgs)*(1.0e6)
14927 qiihr(mgs) = hrifac*ciihr(mgs)/rho0(mgs)
14928 qiihr(mgs) = max(qiihr(mgs), 0.0)
14929 qiihr(mgs) = min(qiihr(mgs),qcmxd(mgs))
14932 if ( xplate(mgs) .eq. 1 ) then
14933 qipiphr(mgs) = qiihr(mgs)
14934 cipiphr(mgs) = ciihr(mgs)
14937 if ( xcolmn(mgs) .eq. 1 ) then
14938 qicichr(mgs) = qiihr(mgs)
14939 cicichr(mgs) = ciihr(mgs)
14942 ! qipiphr(mgs) = 0.0
14943 ! qicichr(mgs) = qiihr(mgs)
14952 ! simple frozen rain to hail conversion. All of the
14953 ! frozen rain larger than 5.0e-3 m in diameter are converted
14954 ! to hail. This is done by considering the equation for
14955 ! frozen rain mixing ratio:
14958 ! qfw = [ cno(lf) * pi * fwdn / (6 rhoair) ]
14961 ! * | fwdia*3 exp(-dia/fwdia) d(dia)
14964 ! The amount to be reclassified as hail is the integral above from
14965 ! Do to inf where Do is 5.0e-3 m.
14968 ! qfauh = [ cno(lf) * pi * fwdn / (6 rhoair) ]
14978 ! IF ( .false. ) THEN
14979 ! IF ( temg(mgs) .lt. tfr .and. ssi(mgs) .gt. 1.01 .and. qx(mgs,li) .gt. qxmin(li) ) THEN
14980 IF ( temg(mgs) .lt. tfr .and. qx(mgs,li) .gt. qxmin(li) ) THEN
14981 IF ( ipconc .ge. 4 .and. .false. ) THEN
14982 if ( cx(mgs,li) .gt. 10. .and. xdia(mgs,li,1) .gt. 50.e-6 ) then !{
14984 & (qx(mgs,li)*rho0(mgs) &
14985 & /(pi*xdn(mgs,li)*cx(mgs,li)))**(1./3.)
14986 IF ( cirdiatmp .gt. 100.e-6 ) THEN !{
14988 & ((pi*xdn(mgs,li)*cx(mgs,li)) / (6.0*rho0(mgs)*dtp)) &
14989 & *exp(-hdia0/cirdiatmp) &
14990 & *( (hdia0**3) + 3.0*(hdia0**2)*cirdiatmp &
14991 & + 6.0*(hdia0)*(cirdiatmp**2) + 6.0*(cirdiatmp**3) )
14993 & min(qscnvi(mgs),qimxd(mgs))
14994 IF ( ipconc .ge. 4 ) THEN
14995 cscnvi(mgs) = Min( cimxd(mgs), cx(mgs,li)*Exp(-hdia0/cirdiatmp))
15000 ELSEIF ( ipconc .lt. 4 ) THEN
15002 qscnvi(mgs) = 0.001*eii(mgs)*max((qx(mgs,li)-1.e-3),0.0)
15003 qscnvi(mgs) = min(qscnvi(mgs),qxmxd(mgs,li))
15004 cscnvi(mgs) = qscnvi(mgs)*rho0(mgs)/xmas(mgs,li)
15005 cscnvis(mgs) = 0.5*cscnvi(mgs)
15015 ! Ventilation coeficients
15018 fvent(mgs) = (fschm(mgs)**(1./3.)) * (fakvisc(mgs)**(-0.5))
15022 if ( ndebug .gt. 0 ) write(0,*) 'civent'
15033 IF ( icond .eq. 1 .or. temg(mgs) .le. tfrh &
15034 & .or. (qx(mgs,lr) .le. qxmin(lr) .and. qx(mgs,lc) .le. qxmin(lc)) ) THEN
15035 IF ( qx(mgs,li) .gt. qxmin(li) ) THEN
15037 & (civenta*xdia(mgs,li,1)**civentb &
15038 & +civentc*xdia(mgs,li,1)**civentd) &
15040 & (civente*xdia(mgs,li,1)**civentf+civentg)
15041 xcivent = (fschm(mgs)**(1./3.))*((cireyn/fakvisc(mgs))**0.5)
15042 if ( xcivent .lt. 1.0 ) then
15043 civent(mgs) = 1.0 + 0.14*xcivent**2
15045 if ( xcivent .ge. 1.0 ) then
15046 civent(mgs) = 0.86 + 0.28*xcivent
15053 ENDIF ! icond .eq. 1
15059 igmrwb = 100.*((5.0+br)/2.0)
15060 rwventa = (0.78)*gmoi(igmrwa) ! 0.78
15061 rwventb = (0.308)*gmoi(igmrwb) ! 0.562825
15063 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
15064 IF ( ipconc .ge. 3 ) THEN
15065 IF ( imurain == 3 ) THEN
15066 IF ( izwisventr == 1 ) THEN
15067 rwvent(mgs) = ventrx(mgs)*(1.6 + 124.9*(1.e-3*rho0(mgs)*qx(mgs,lr))**.2046)
15068 ELSE ! izwisventr = 2
15069 ! 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
15071 & (0.78*ventrx(mgs) + 0.308*ventrxn(mgs)*fvent(mgs) &
15072 & *Sqrt((ar*rhovt(mgs))) &
15073 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
15076 ELSE ! imurain == 1
15077 ! linear interpolation of complete gamma function
15078 ! tmp = 2. + alpha(mgs,lr)
15079 ! i = Int(dgami*(tmp))
15080 ! del = tmp - dgam*i
15081 ! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15083 IF ( iferwisventr == 1 ) THEN
15085 ! Ferrier fall speed in the ventillation term [uses fx(lr) ]
15087 alpr = Min(alpharmax,alpha(mgs,lr) )
15089 x = 1. + alpha(mgs,lr)
15091 IF ( lzr > 1 ) THEN ! 3 moment
15097 ! vent1 = dble(xdia(mgs,lr,1))**(-2. - alpr) ! Actually OK
15098 ! vent2 = dble(1./xdia(mgs,lr,1) + 0.5*fx(lr))**dble(2.5+alpr+0.5*bx(lr)) ! Actually OK
15099 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)
15100 vent2 = dble(1. + 0.5*fx(lr)*xdia(mgs,lr,1))**dble(2.5+alpr+0.5*bx(lr))
15105 & 0.308*fvent(mgs)*y* &
15106 & Sqrt(ax(lr)*rhovt(mgs))*(vent1/vent2)
15109 ELSEIF ( iferwisventr == 2 ) THEN
15111 ! 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
15112 x = 1. + alpha(mgs,lr)
15115 & (0.78*x + 0.308*ventrxn(mgs)*fvent(mgs) &
15116 & *Sqrt((ar*rhovt(mgs))) &
15117 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
15121 ENDIF ! iferwisventr
15126 & (rwventa + rwventb*fvent(mgs) &
15127 & *Sqrt((ar*rhovt(mgs))) &
15128 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
15136 igmswb = 100.*((5.0+ds)/2.0)
15137 swventa = (0.78)*gmoi(igmswa)
15138 swventb = (0.308)*gmoi(igmswb)
15140 IF ( qx(mgs,ls) .gt. qxmin(ls) ) THEN
15141 IF ( ipconc .ge. 4 ) THEN
15142 swvent(mgs) = 0.65 + 0.44*fvent(mgs)*Sqrt(vtxbar(mgs,ls,1)*xdia(mgs,ls,1))
15146 & (swventa + swventb*fvent(mgs) &
15147 & *Sqrt((cs*rhovt(mgs))) &
15148 & *(xdia(mgs,ls,1)**((1.0+ds)/2.0)) )
15158 igmhwb = 100.0*2.75
15159 hwventa = (0.78)*gmoi(igmhwa)
15160 hwventb = (0.308)*gmoi(igmhwb)
15161 ! hwventc = (4.0*gr/(3.0*cdx(lh)))**(0.25)
15163 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
15164 hwventc = (4.0*gr/(3.0*cdxgs(mgs,lh)))**(0.25)
15165 IF ( .false. .or. alpha(mgs,lh) .eq. 0.0 ) THEN
15167 & ( hwventa + hwventb*hwventc*fvent(mgs) &
15168 & *((xdn(mgs,lh)/rho0(mgs))**(0.25)) &
15169 & *(xdia(mgs,lh,1)**(0.75)))
15170 ELSE ! Ferrier 1994, eq. B.36
15171 ! linear interpolation of complete gamma function
15172 ! tmp = 2. + alpha(mgs,lh)
15173 ! i = Int(dgami*(tmp))
15174 ! del = tmp - dgam*i
15175 ! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15177 ! note that hwvent includes a division by Gamma(1+alpha), so Gamma(2+alpha)/Gamma(1+alpha) = 1 + alpha
15178 ! and g1palp = Gamma(1+alpha) divides into y
15179 x = 1. + alpha(mgs,lh)
15181 tmp = 1 + alpha(mgs,lh)
15182 i = Int(dgami*(tmp))
15184 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15186 tmp = 2.5 + alpha(mgs,lh) + 0.5*bxx(mgs,lh)
15187 i = Int(dgami*(tmp))
15189 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp
15192 hwventy(mgs) = 0.308*fvent(mgs)*(xdia(mgs,lh,1)**(0.5 + 0.5*bxx(mgs,lh)))*Sqrt(axx(mgs,lh)*rhovt(mgs))
15194 & ( 0.78*x + y*hwventy(mgs) ) ! &
15195 ! & 0.308*fvent(mgs)*y*(xdia(mgs,lh,1)**(0.5 + 0.5*bxx(mgs,lh)))* &
15196 ! & Sqrt(axx(mgs,lh)*rhovt(mgs)) )
15209 IF ( lhl .gt. 1 ) THEN
15211 igmhwb = 100.0*2.75
15212 hwventa = (0.78)*gmoi(igmhwa)
15213 hwventb = (0.308)*gmoi(igmhwb)
15214 ! hwventc = (4.0*gr/(3.0*cdx(lhl)))**(0.25)
15216 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
15217 hwventc = (4.0*gr/(3.0*cdxgs(mgs,lhl)))**(0.25)
15219 IF ( .false. .or. alpha(mgs,lhl) .eq. 0.0 ) THEN
15221 & ( hwventa + hwventb*hwventc*fvent(mgs) &
15222 & *((xdn(mgs,lhl)/rho0(mgs))**(0.25)) &
15223 & *(xdia(mgs,lhl,1)**(0.75)))
15224 ELSE ! Ferrier 1994, eq. B.36
15225 ! linear interpolation of complete gamma function
15226 ! tmp = 2. + alpha(mgs,lhl)
15227 ! i = Int(dgami*(tmp))
15228 ! del = tmp - dgam*i
15229 ! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15231 ! note that hlvent includes a division by Gamma(1+alpha), so x = Gamma(2+alpha)/Gamma(1+alpha) = 1 + alpha
15232 ! and g1palp = Gamma(1+alpha) divides into y
15234 x = 1. + alpha(mgs,lhl)
15236 tmp = 1 + alpha(mgs,lhl)
15237 i = Int(dgami*(tmp))
15239 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15241 tmp = 2.5 + alpha(mgs,lhl) + 0.5*bxx(mgs,lhl)
15242 i = Int(dgami*(tmp))
15244 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp ! ratio of gamma functions
15246 hlventy(mgs) = 0.308*fvent(mgs)*(xdia(mgs,lhl,1)**(0.5 + 0.5*bxx(mgs,lhl)))*Sqrt(axx(mgs,lhl)*rhovt(mgs))
15248 hlvent(mgs) = 0.78*x + y*hlventy(mgs) ! &
15249 ! & 0.308*fvent(mgs)*y*(xdia(mgs,lhl,1)**(0.5 + 0.5*bxx(mgs,lhl)))* &
15250 ! & Sqrt(axx(mgs,lhl)*rhovt(mgs)))
15251 ! : Sqrt(xdn(mgs,lhl)*ax(lhl)*rhovt(mgs)/rg0))/tmp
15261 ! Wet growth constants
15266 & ( felv(mgs)*fwvdf(mgs)*rho0(mgs)*(qss0(mgs)-qx(mgs,lv)) &
15267 & -ftka(mgs)*temcg(mgs) ) &
15268 & / ( rho0(mgs)*(felf(mgs)+fcw(mgs)*temcg(mgs)) )
15270 & (1.0)-fci(mgs)*temcg(mgs) &
15271 & / ( felf(mgs)+fcw(mgs)*temcg(mgs) )
15274 ! Melting constants
15277 fmlt1(mgs) = (2.0*pi)* &
15278 & ( felv(mgs)*fwvdf(mgs)*(qss0(mgs)-qx(mgs,lv)) &
15279 & -ftka(mgs)*temcg(mgs)/rho0(mgs) ) &
15281 fmlt2(mgs) = -fcw(mgs)*temcg(mgs)/felf(mgs)
15284 ! Vapor Deposition constants
15288 & (4.0*pi/rho0(mgs))*(ssi(mgs)-1.0)* &
15289 & (1.0/(fai(mgs)+fbi(mgs)))
15293 & (4.0*pi/rho0(mgs))*(ssw(mgs)-1.0)* &
15294 & (1.0/(fav(mgs)+fbv(mgs)))
15298 ! deposition, sublimation, and melting of snow, graupel and hail
15301 qimlr(:) = 0.0 ! this is not used. qi melts to qc way down in the code.
15304 IF ( lhwlg > 1 ) THEN
15332 ! chlmlrsave(:) = 0.0
15333 ! qhlmlrsave(:) = 0.0
15339 if ( .not. mixedphase ) then !{
15342 IF ( temg(mgs) .gt. tfr ) THEN
15344 IF ( qx(mgs,ls) .gt. qxmin(ls) ) THEN
15347 & (c1sw*fmlt1(mgs)*cx(mgs,ls)*swvent(mgs)*xdia(mgs,ls,1) ) & ! /rhosm &
15352 ! IF ( qx(mgs,ls) .gt. 0.1e-4 ) write(0,*) 'qsmlr: ',qsmlr(mgs),qx(mgs,ls),cx(mgs,ls),fmlt1(mgs),
15353 ! : temcg(mgs),swvent(mgs),xdia(mgs,ls,1),qss0(mgs)-qx(mgs,lv)
15359 ! > (fmlt1(mgs)*cx(mgs,ls)*swvent(mgs)*xdia(mgs,ls,1) +
15360 ! > fmlt2(mgs)*(qsacr(mgs)+qsacw(mgs)) )
15363 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
15365 IF ( ibinhmlr == 0 .or. lzh < 1 ) THEN
15368 & fmlt1(mgs)*cx(mgs,lh)*hwvent(mgs)*xdia(mgs,lh,1) &
15369 & + fmlt2(mgs)*(qhacrmlr(mgs)+qhacw(mgs)) &
15371 ELSEIF ( ibinhmlr == 1 ) THEN ! use incomplete gamma functions to approximate the bin results
15373 write(0,*) 'ibinhmlr = 1 not available for 2-moment'
15376 ELSEIF ( ibinhmlr == 2 .or. ibinhmlr == 3 ) THEN
15381 IF ( ivhmltsoak > 0 .and. qhmlr(mgs) < 0.0 .and. lvol(lh) > 1 .and. xdn(mgs,lh) .lt. xdnmx(lh) ) THEN
15382 ! act as if 100% of the meltwater were soaked into the graupel
15383 v1 = (1. - xdn(mgs,lh)/xdnmx(lh))*(vx(mgs,lh) + rho0(mgs)*qhmlr(mgs)/xdn(mgs,lh) )/(dtp) ! volume available for filling
15384 v2 = -1.0*rho0(mgs)*qhmlr(mgs)/xdnmx(lh) ! volume of melted ice if it were refrozen in the matrix
15386 vhsoak(mgs) = Min(v1,v2)
15390 ENDIF ! qx(mgs,lh) .gt. qxmin(lh)
15393 IF ( lhl .gt. 1 .and. lhlw < 1 ) THEN
15395 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
15396 IF ( ibinhlmlr == 0 .or. lzhl < 1) THEN
15399 & fmlt1(mgs)*cx(mgs,lhl)*hlvent(mgs)*xdia(mgs,lhl,1) &
15400 & + fmlt2(mgs)*(qhlacrmlr(mgs)+qhlacw(mgs)) &
15403 ELSEIF ( ibinhlmlr == 1 ) THEN ! use incomplete gamma functions to approximate the bin results
15406 ! #if (defined Z3MOM) && defined( COMMAS ) || defined( COMMASTMP )
15408 ELSEIF ( ibinhlmlr == -1 ) THEN ! OLD VERSION use incomplete gamma functions to approximate the bin results
15413 IF ( ivhmltsoak > 0 .and. qhlmlr(mgs) < 0.0 .and. lvol(lhl) > 1 .and. xdn(mgs,lhl) .lt. xdnmx(lhl) ) THEN
15414 ! act as if 50% of the meltwater were soaked into the graupel
15415 v1 = (1. - xdn(mgs,lhl)/xdnmx(lhl))*(vx(mgs,lhl) + rho0(mgs)*qhlmlr(mgs)/xdn(mgs,lhl) )/(dtp) ! volume available for filling
15416 v2 = -1.0*rho0(mgs)*qhlmlr(mgs)/xdnmx(lhl) ! volume of melted ice if it were refrozen in the matrix
15418 vhlsoak(mgs) = Min(v1,v2)
15428 ! qimlr(mgs) = max( qimlr(mgs), -qimxd(mgs) )
15429 ! qsmlr(mgs) = max( qsmlr(mgs), -qsmxd(mgs) )
15430 ! erm 5/10/2007 changed to next line:
15431 if ( .not. mixedphase ) qsmlr(mgs) = max( qsmlr(mgs), Min( -qsmxd(mgs), -0.7*qx(mgs,ls)*dtpinv ) )
15432 IF ( .not. mixedphase ) THEN
15433 qhmlr(mgs) = max( qhmlr(mgs), Min( -qhmxd(mgs), -0.95*qx(mgs,lh)*dtpinv ) )
15434 chmlr(mgs) = max( chmlr(mgs), Min( -chmxd(mgs), -0.95*cx(mgs,lh)*dtpinv ) )
15436 ! qhmlr(mgs) = max( max( qhmlr(mgs), -qhmxd(mgs) ) , -0.5*qx(mgs,lh)*dtpinv ) !limits to 1/2 qh or max depletion
15440 ! Rasmussen and Heymsfield say melt water remains on graupel up to 9 mm before shedding
15443 IF ( lhl .gt. 1 .and. lhlw < 1 ) THEN
15444 qhlmlr(mgs) = max( qhlmlr(mgs), Min( -qxmxd(mgs,lhl), -0.95*qx(mgs,lhl)*dtpinv ) )
15445 chlmlr(mgs) = max( chlmlr(mgs), Min( -cxmxd(mgs,lhl), -0.95*cx(mgs,lhl)*dtpinv ) )
15451 endif ! } not mixedphase
15453 if ( ipconc .ge. 1 ) then
15455 cimlr(mgs) = (cx(mgs,li)/(qx(mgs,li)+1.e-20))*qimlr(mgs)
15456 IF ( .not. mixedphase ) THEN !{
15457 IF ( xdia(mgs,ls,1) .gt. 1.e-6 .and. -qsmlr(mgs) .ge. 0.5*qxmin(ls) .and. ipconc .ge. 4 ) THEN
15458 ! csmlr(mgs) = rho0(mgs)*qsmlr(mgs)/(xv(mgs,ls)*rhosm)
15459 csmlr(mgs) = (cx(mgs,ls)/(qx(mgs,ls)))*qsmlr(mgs)
15460 ELSEIF ( qx(mgs,ls) > qxmin(ls) ) THEN
15461 csmlr(mgs) = (cx(mgs,ls)/(qx(mgs,ls)))*qsmlr(mgs)
15464 csmlrr(mgs) = csmlr(mgs)/rzxs(mgs)
15465 IF ( -csmlrr(mgs)*dtp > cxmin .and. -qsmlr(mgs)*dtp > qxmin(lr) .and. snowmeltdia > 0.0 ) THEN
15466 rmas = rho0(mgs)*qsmlr(mgs)/csmlrr(mgs)
15467 IF ( rmas > snowmeltmass ) THEN
15468 csmlrr(mgs) = rho0(mgs)*qsmlr(mgs)/snowmeltmass
15474 ! IF ( xdia(mgs,lh,1) .gt. 1.e-6 .and. Abs(qhmlr(mgs)) .ge. qxmin(lh) ) THEN
15475 ! chmlr(mgs) = rho0(mgs)*qhmlr(mgs)/(pi*xdn(mgs,lh)*xdia(mgs,lh,1)**3) ! out of hail
15476 ! chmlr(mgs) = Max( chmlr(mgs), -chmxd(mgs) )
15478 IF ( ibinhmlr == 0 .or. lzh < 1 ) THEN
15479 chmlr(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhmlr(mgs)
15480 IF ( imltshddmr == 3 .and. qhmlr(mgs) < -qxmin(lh) ) THEN
15481 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
15483 ! IF ( tmpdiam > sheddiam ) THEN ! let size get smaller until it reaches sheddiam
15487 ! test to remove the part of the melting associated with large ice particles so they get smaller
15489 tmp = 1. + alpha(mgs,lh)
15490 i = Int(dgami*(tmp))
15492 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15494 ratio = Min( maxratiolu, mltdiam1/xdia(mgs,lh,1) )
15496 x = gamxinfdp(2. + alpha(mgs,lh), ratio)/g1palp
15497 y = gamxinfdp(2.5 + alpha(mgs,lh) + 0.5*bxx(mgs,lh), ratio)/g1palp
15499 hwvent1 = 0.78*x + y*hwventy(mgs)
15501 qhlmlr1 = min( fmlt1(mgs)*cx(mgs,lh)*hwvent1*xdia(mgs,lh,1), 0.0 )
15503 chmlr(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*(qhmlr(mgs) - qhlmlr1)
15507 ! IF ( igs(mgs) == 40 ) THEN
15508 ! write(0,*) 'is this running? chmlr = ',kgs(mgs), chmlr(mgs)
15515 IF ( chmlr(mgs) < 0.0 .and. (ibinhmlr < 1 .or. lzh < 1) ) THEN ! { already done if ibinhmlr > 0
15517 IF ( ibinhmlr == 0 .or. lzh < 1 ) THEN
15518 IF ( ihmlt .eq. 1 ) THEN
15519 chmlrr(mgs) = Min( chmlr(mgs), rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*vmlt) ) ! into rain
15520 ELSEIF ( ihmlt .eq. 2 ) THEN
15521 IF ( xv(mgs,lh) .gt. 0.0 .and. chmlr(mgs) .lt. 0.0 ) THEN
15522 ! chmlrr(mgs) = Min( chmlr(mgs), rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lh)*xv(mgs,lh)) ) ! into rain
15523 ! guess what, this is the same as chmlr: rho0*qhmlr/xmas(lh) --> cx/qx = rho0/xmas
15524 IF(imltshddmr == 1) THEN
15525 ! DTD: If Dmg < sheddiam, then assume complete melting into
15526 ! maximal raindrop. Between sheddiam and sheddiam0 mm, linearly ramp down to a 3 mm shed drop
15527 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
15528 tmp2 = -rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*vr3mm) ! conc. change for a 3 mm mean drop diameter
15530 chmlrr(mgs) = tmp*(sheddiam0-xdia(mgs,lh,3))/(sheddiam0-sheddiam)+tmp2*(xdia(mgs,lh,3)-sheddiam)/(sheddiam0-sheddiam) ! old version
15531 chmlrr(mgs) = -Max(tmp,Min(tmp2,chmlrr(mgs)))
15532 ELSEIF ( imltshddmr == 2 .or. imltshddmr == 3 ) THEN
15533 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
15534 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
15535 chmlrr(mgs) = rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lh)) ! into rain
15537 chmlrr(mgs) = rho0(mgs)*qhmlr(mgs)/(Min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lh)*xv(mgs,lh))) ! into rain
15540 chmlrr(mgs) = chmlr(mgs)
15542 ELSEIF ( ihmlt .eq. 0 ) THEN
15543 chmlrr(mgs) = chmlr(mgs)
15546 ELSE ! ibinhmlr < 0? Already have an outer IF test for ibinhmlr < 1
15547 chmlrr(mgs) = Min( chmlrr(mgs), rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*xvmx(lr)) ) ! into rain
15550 ENDIF ! } ( chmlr(mgs) < 0.0 .and. ibinhmlr < 1)
15552 IF ( lhl .gt. 1 .and. lhlw < 1 .and. .not. mixedphase .and. qhlmlr(mgs) < 0.0 ) THEN ! {
15554 IF ( ibinhlmlr == 0 .or. lzhl < 1 ) THEN
15555 ! IF ( xdia(mgs,lhl,1) .gt. 1.e-6 .and. Abs(qhlmlr(mgs)) .ge. qxmin(lhl) ) THEN
15556 ! chlmlr(mgs) = rho0(mgs)*qhlmlr(mgs)/(pi*xdn(mgs,lhl)*xdia(mgs,lhl,1)**3) ! out of hail
15557 ! chlmlr(mgs) = Max( chlmlr(mgs), -cxmxd(mgs,lhl) )
15559 chlmlr(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlmlr(mgs)
15560 IF ( imltshddmr == 3 .and. qhlmlr(mgs) < -qxmin(lhl) ) THEN
15561 ! IF ( .false. .and. imltshddmr == 3 ) THEN
15562 ! tmpdiam = (shedalp+alpha(mgs,lhl))*xdia(mgs,lhl,1)
15564 ! IF ( tmpdiam > sheddiam ) THEN ! let size get smaller until it reaches sheddiam
15565 ! chlmlr(mgs) = 0.0
15568 ! test to remove the part of the melting associated with large ice particles so they get smaller
15570 tmp = 1. + alpha(mgs,lhl)
15571 i = Int(dgami*(tmp))
15573 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15575 ratio = Min( maxratiolu, mltdiam1/xdia(mgs,lhl,1) )
15577 x = gamxinfdp(2. + alpha(mgs,lhl), ratio)/g1palp
15578 y = gamxinfdp(2.5 + alpha(mgs,lhl) + 0.5*bxx(mgs,lhl), ratio)/g1palp
15580 hwvent1 = 0.78*x + y*hlventy(mgs)
15582 qhlmlr1 = min( fmlt1(mgs)*cx(mgs,lhl)*hwvent1*xdia(mgs,lhl,1), 0.0 )
15584 chlmlr(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*Min(0.0, qhlmlr(mgs) - qhlmlr1)
15590 IF ( ibinhlmlr == 0 .or. lzhl < 1 ) THEN !{
15591 IF ( ihmlt .eq. 1 ) THEN
15592 chlmlrr(mgs) = Min( chlmlr(mgs), rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*vmlt) ) ! into rain
15593 ELSEIF ( ihmlt .eq. 2 ) THEN
15594 IF ( xv(mgs,lhl) .gt. 0.0 .and. chlmlr(mgs) .lt. 0.0 ) THEN
15595 ! chlmlrr(mgs) = rho0(mgs)*qhlmlr(mgs)/(Min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lhl)*xv(mgs,lhl))) ! into rain
15596 ! chlmlrr(mgs) = Min( chlmlr(mgs), rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lhl)*xv(mgs,lhl)) ) ! into rain
15597 IF(imltshddmr == 1 ) THEN
15598 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
15599 tmp2 = -rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*vr3mm) ! conc. change for a 3 mm mean drop diameter
15600 chlmlrr(mgs) = tmp*(20.e-3-xdia(mgs,lhl,3))/(20.e-3-sheddiam)+tmp2*(xdia(mgs,lhl,3)-sheddiam)/(20.e-3-sheddiam)
15601 chlmlrr(mgs) = -Max(tmp,Min(tmp2,chlmlrr(mgs)))
15602 ELSEIF ( imltshddmr == 2 .or. imltshddmr == 3 ) THEN
15603 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
15604 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
15605 chlmlrr(mgs) = rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lhl)) ! into rain
15607 chlmlrr(mgs) = rho0(mgs)*qhlmlr(mgs)/(Min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lhl)*xv(mgs,lhl))) ! into rain
15610 chlmlrr(mgs) = chlmlr(mgs)
15612 ELSEIF ( ihmlt .eq. 0 ) THEN
15613 chlmlrr(mgs) = chlmlr(mgs)
15616 ELSE ! } { ibinhlmlr > 0
15617 chlmlrr(mgs) = Min( chlmlrr(mgs), rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*xvmx(lr)) ) ! into rain
15623 ENDIF ! }.not. mixedphase
15626 ! chmlr(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhmlr(mgs)
15627 ! chmlrr(mgs) = chmlr(mgs)
15632 ! deposition/sublimation of ice
15636 rwcap(mgs) = (0.5)*xdia(mgs,lr,1)
15637 swcap(mgs) = (0.5)*xdia(mgs,ls,1)
15638 hwcap(mgs) = (0.5)*xdia(mgs,lh,1)
15639 IF ( lhl .gt. 1 ) hlcap(mgs) = (0.5)*xdia(mgs,lhl,1)
15641 if ( qx(mgs,li).gt.qxmin(li) .and. xdia(mgs,li,1) .gt. 0.0 ) then
15643 ! from Cotton, 1972 (Part II)
15645 cilen(mgs) = 0.4764*(xdia(mgs,li,1))**(0.958)
15646 cval = xdia(mgs,li,1)
15648 eval = Sqrt(1.0-(aval**2)/(cval**2))
15649 fval = min(0.99,eval)
15650 gval = alog( abs( (1.+fval)/(1.-fval) ) )
15651 cicap(mgs) = cval*fval / gval
15661 IF ( icond .eq. 1 .or. temg(mgs) .le. tfrh &
15662 & .or. (qx(mgs,lr) .le. qxmin(lr) .and. qx(mgs,lc) .le. qxmin(lc)) ) THEN
15664 & fvds(mgs)*cx(mgs,li)*civent(mgs)*cicap(mgs)*depfac
15666 & fvds(mgs)*cx(mgs,ls)*swvent(mgs)*swcap(mgs)*depfac
15667 ! IF ( ny .eq. 2 .and. igs(mgs) .eq. 302 .and. temg(mgs) .le. tfrh+10 .and. qx(mgs,lv) .gt. qis(mgs)
15668 ! : .and. qx(mgs,li) .gt. qxmin(li) ) THEN
15669 ! write(0,*) 'qidsv = ',nstep,kgs(mgs),qidsv(mgs),temg(mgs)-tfrh,100.*(qx(mgs,lv)/qis(mgs) - 1.),1.e6*xdia(mgs,li,1),
15670 ! : fvds(mgs),civent(mgs),cicap(mgs)
15677 & fvds(mgs)*cx(mgs,lh)*hwvent(mgs)*hwcap(mgs)*depfac
15679 IF ( lhl .gt. 1 ) qhldsv(mgs) = fvds(mgs)*cx(mgs,lhl)*hlvent(mgs)*hlcap(mgs)*depfac
15686 ! #include "nssl.qlimit.F"
15689 ! Use a test saturation adjustment to set limits on ice deposition/sublimation
15690 ! and rain evaporation
15693 IF ( DoSublimationFix ) THEN
15697 qitmp(mgs) = qx(mgs,li) + qx(mgs,ls) + qx(mgs,lh)
15698 IF ( lis > 1 ) qitmp(mgs) = qitmp(mgs) + qx(mgs,lis)
15699 IF ( lhl > 1 ) qitmp(mgs) = qitmp(mgs) + qx(mgs,lhl)
15700 qrtmp(mgs) = qx(mgs,lr)
15701 qctmp(mgs) = qx(mgs,lc)
15702 qsimxdep(mgs) = 0.0
15703 qsimxsub(mgs) = 0.0
15707 ! IF ( ( qitmp(mgs) > qxmin(li) .or. qrtmp(mgs) > qxmin(lr) ) ) THEN
15708 IF ( qitmp(mgs) > qxmin(li) ) THEN
15710 qitmp1 = qitmp(mgs)
15711 qctmp1 = qctmp(mgs)
15712 felvcptmp = felvcp(mgs)
15713 felscptmp = felscp(mgs)
15714 qvtmp(mgs) = qx(mgs,lv)
15715 qss(mgs) = qvs(mgs)
15719 thetatmp = theta(mgs)
15720 thetaptmp = thetap(mgs)
15721 temgtmp = temg(mgs)
15722 temcgtmp = temcg(mgs)
15723 qvaptmp = qx(mgs,lv) ! qwvp(mgs) + qv0(mgs)
15724 qvptmp = 0.0 ! qwvp(mgs) ! qv pertubation
15729 dqwvtmp(mgs) = ( qvtmp(mgs) - qsstmp )
15734 ! calculate super-saturation
15736 IF ( itertd == 1 ) THEN
15739 dqcitmp(mgs) = dqci(mgs)
15740 ! dqwvtmp(mgs) = dqwv(mgs)
15745 dqwv(mgs) = ( qvtmp(mgs) - qsstmp )
15747 ! evaporation and sublimation adjustment
15749 if( dqwv(mgs) .lt. 0. ) then ! { subsaturated
15750 if( qitmp(mgs) .gt. -dqwv(mgs) ) then ! check if qi can make up all the deficit
15751 dqci(mgs) = dqwv(mgs)
15753 else ! otherwise make all ice available for sublimation
15754 dqci(mgs) = -qitmp(mgs)
15755 dqwv(mgs) = dqwv(mgs) + qitmp(mgs)
15758 qvptmp = qvptmp - ( dqcw(mgs) + dqci(mgs) ) ! add to perturbation vapor
15760 IF ( itertd == 2 .and. eqtset > 1 ) THEN
15761 ! if eqtset == 2, then need to update the latent heats for change in hydrometeor content
15762 tmp = qitmp(mgs) !+ qx(mgs,lh)
15763 ! IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
15764 cvm = cv+cvv*qvtmp(mgs)+cpl*(qx(mgs,lc)+qrtmp(mgs)) &
15767 felvcptmp = (felv(mgs)-rw*temg(mgs))/cvm
15768 felscptmp = (fels(mgs)-rw*temg(mgs))/cvm
15772 ! qitmp(mgs) = qx(mgs,li)
15773 qctmp(mgs) = qctmp(mgs) + dqcw(mgs) ! dqcw is zero
15774 qitmp(mgs) = qitmp(mgs) + dqci(mgs)
15775 thetaptmp = thetaptmp + &
15777 & (felvcp(mgs)*dqcw(mgs) +felscp(mgs)*dqci(mgs))
15780 end if ! } dqwv(mgs) .lt. 0. (end of evap/sublim)
15782 ! condensation/deposition
15784 IF ( dqwv(mgs) .ge. 0. ) THEN ! {
15786 ! write(iunit,*) 'satadj: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qx(mgs,lv),qx(mgs,lc)
15788 ! qitmp(mgs) = qx(mgs,li)
15791 if ( temg(mgs) .lt. tfr .and. temg(mgs) .gt. thnuc ) then
15792 ! fracl(mgs) = max(min(1.,(temg(mgs)-233.15)/(20.)),0.0)
15793 ! fraci(mgs) = 1.0-fracl(mgs)
15795 if ( temg(mgs) .le. thnuc ) then
15799 ! fraci(mgs) = 1.0-fracl(mgs)
15801 gamss = (felvcp(mgs)*fracl(mgs) + felscp(mgs)*fraci(mgs)) &
15804 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv2(mgs)*qsstmp/ &
15805 & ((temg(mgs)-cbi)**2))
15807 if ( temg(mgs) .ge. tfr ) then
15808 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qsstmp/ &
15809 & ((temg(mgs)-cbw)**2))
15815 dqcw(mgs) = dqvcnd(mgs)*fracl(mgs) ! is zero
15816 dqci(mgs) = dqvcnd(mgs)*fraci(mgs)
15818 thetaptmp = thetaptmp + &
15819 & (felvcp(mgs)*dqcw(mgs) + felscp(mgs)*dqci(mgs)) &
15822 qvptmp = qvptmp - ( dqvcnd(mgs) )
15823 qctmp(mgs) = qctmp(mgs) + dqcw(mgs)
15824 qitmp(mgs) = qitmp(mgs) + dqci(mgs)
15826 IF ( itertd == 2 .and. eqtset > 1 ) THEN
15827 ! if eqtset == 2, then need to update the latent heats for change in hydrometeor content
15828 tmp = qitmp(mgs) ! + qx(mgs,lh)
15829 ! IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
15830 cvm = cv+cvv*qvtmp(mgs)+cpl*(qctmp(mgs) +qrtmp(mgs)) &
15833 felvcptmp = (felv(mgs)-rw*temg(mgs))/cvm
15834 felscptmp = (fels(mgs)-rw*temg(mgs))/cvm
15837 IF ( eqtset > 2 ) THEN
15838 pipert(mgs) = pipert(mgs) + (0 &
15839 & +felspi(mgs)*dqci(mgs) &
15840 & +felvpi(mgs)*dqcw(mgs))*dtp
15845 END IF ! } dqwv(mgs) .ge. 0.
15849 IF ( itertd == 1 ) THEN
15850 ! update temporary saturation values
15852 thetatmp = thetaptmp + theta0(mgs)
15853 temgtmp = thetatmp*pk(mgs) ! ( pres(mgs) / poo ) ** cap
15854 qvaptmp = Max((qvptmp + qv0(mgs)), 0.0)
15855 temcgtmp = temgtmp - tfr
15856 tqvcon = temgtmp-cbw
15857 ltemq = (temgtmp-163.15)/fqsat+1.5
15858 ltemq = Min( nqsat, Max(1,ltemq) )
15859 qvstmp = pqs(mgs)*tabqvs(ltemq)
15860 qisstmp = pqs(mgs)*tabqis(ltemq)
15861 qctmp(mgs) = max( 0.0, qctmp(mgs) )
15862 qitmp(mgs) = max( 0.0, qitmp(mgs) )
15863 qvtmp(mgs) = max( 0.0, qvaptmp )
15869 ! set max depletion
15870 qctmp(mgs) = max( 0.0, qctmp(mgs) )
15871 qitmp(mgs) = max( 0.0, qitmp(mgs) )
15873 IF ( qitmp(mgs) < qitmp1 ) THEN
15874 qsimxsub(mgs) = (qitmp1 - qitmp(mgs))*dtpinv
15875 ELSEIF ( qitmp(mgs) > qitmp1 ) THEN
15876 qsimxdep(mgs) = (qitmp(mgs) - qitmp1)*dtpinv
15881 ! pceds(mgs) = (thetap(mgs) - thsave(mgs))*dtpinv
15882 ! write(iunit,*) 'satadj2: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qxtmp,qctmp(mgs)
15884 ! end the saturation adjustment iteration loop
15895 qsimxdep(mgs) = qvimxd(mgs)
15896 qsimxsub(mgs) = 1.e20
15908 IF ( icond .eq. 1 .or. temg(mgs) .le. tfrh &
15909 & .or. (qx(mgs,lr) .le. qxmin(lr) .and. qx(mgs,lc) .le. qxmin(lc)) ) THEN
15910 ! qisbv(mgs) = max( min(qidsv(mgs), 0.0), -qimxd(mgs) )
15911 ! qssbv(mgs) = max( min(qsdsv(mgs), 0.0), -qsmxd(mgs) )
15913 qisbv(mgs) = max( min(qidsv(mgs), 0.0), Min( -qimxd(mgs), -0.5*qx(mgs,li)*dtpinv ) )
15914 qssbv(mgs) = max( min(qsdsv(mgs), 0.0), Min( -qsmxd(mgs), -0.5*qx(mgs,ls)*dtpinv ) )
15915 qidpv(mgs) = Max(qidsv(mgs), 0.0)
15916 qsdpv(mgs) = Max(qsdsv(mgs), 0.0)
15926 qhsbv(mgs) = max( min(qhdsv(mgs), 0.0), -qhmxd(mgs) )
15928 qhdpv(mgs) = Max(qhdsv(mgs), 0.0)
15933 IF ( lhl .gt. 1 ) THEN
15934 qhlsbv(mgs) = max( min(qhldsv(mgs), 0.0), -qxmxd(mgs,lhl) )
15935 qhldpv(mgs) = Max(qhldsv(mgs), 0.0)
15938 temp1 = qidpv(mgs) + qsdpv(mgs) + qhdpv(mgs) + qhldpv(mgs)
15940 ! IF ( temp1 .gt. qvimxd(mgs) ) THEN
15942 ! frac = qvimxd(mgs)/temp1
15944 IF ( temp1 .gt. qsimxdep(mgs) ) THEN
15945 frac = qsimxdep(mgs)/temp1
15947 qidpv(mgs) = frac*qidpv(mgs)
15948 qsdpv(mgs) = frac*qsdpv(mgs)
15949 qhdpv(mgs) = frac*qhdpv(mgs)
15950 qhldpv(mgs) = frac*qhldpv(mgs)
15952 ! IF ( ny .eq. 2 .and. igs(mgs) .eq. 302 .and. temg(mgs) .le. tfrh+10 .and. qx(mgs,lv) .gt. qis(mgs)
15953 ! : .and. qx(mgs,li) .gt. qxmin(li) ) THEN
15954 ! write(0,*) 'qidpv,frac = ',kgs(mgs),qidpv(mgs),frac
15959 temp1 = qisbv(mgs) + qssbv(mgs) + qhsbv(mgs) + qhlsbv(mgs)
15962 IF ( temp1 < -qsimxsub(mgs) ) THEN
15963 frac = -qsimxsub(mgs)/temp1
15965 qisbv(mgs) = frac*qisbv(mgs)
15966 qssbv(mgs) = frac*qssbv(mgs)
15967 qhsbv(mgs) = frac*qhsbv(mgs)
15968 qhlsbv(mgs) = frac*qhlsbv(mgs)
15970 ! IF ( ny .eq. 2 .and. igs(mgs) .eq. 302 .and. temg(mgs) .le. tfrh+10 .and. qx(mgs,lv) .gt. qis(mgs)
15971 ! : .and. qx(mgs,li) .gt. qxmin(li) ) THEN
15972 ! write(0,*) 'qidpv,frac = ',kgs(mgs),qidpv(mgs),frac
15981 if ( ipconc .ge. 1 ) then
15983 cssbv(mgs) = (cx(mgs,ls)/(qx(mgs,ls)+1.e-20))*qssbv(mgs)
15984 cisbv(mgs) = (cx(mgs,li)/(qx(mgs,li)+1.e-20))*qisbv(mgs)
15985 chsbv(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhsbv(mgs)
15986 IF ( lhl .gt. 1 ) chlsbv(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlsbv(mgs)
15987 csdpv(mgs) = 0.0 ! (cx(mgs,ls)/(qx(mgs,ls)+1.e-20))*qsdpv(mgs)
15988 cidpv(mgs) = 0.0 ! (cx(mgs,li)/(qx(mgs,li)+1.e-20))*qidpv(mgs)
15990 chdpv(mgs) = 0.0 ! (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhdpv(mgs)
15996 ! Aggregation or size conversion of small crystals to snow
15998 if (ndebug .gt. 0 ) write(0,*) 'conc 29a'
16003 if ( ipconc .ge. 4 .and. iscni .ge. 1 .and. qx(mgs,li) .gt. qxmin(li) ) then
16004 IF ( iscni .eq. 1 ) THEN
16006 & pi*rho0(mgs)*((0.25)/(6.0)) &
16007 & *eii(mgs)*(qx(mgs,li)**2)*(xdia(mgs,li,2)) &
16008 & *vtxbar(mgs,li,1)/xmas(mgs,li)
16009 cscni(mgs) = Min(cimxd(mgs),qscni(mgs)*rho0(mgs)/xmas(mgs,li))
16010 cscnis(mgs) = 0.5*cscni(mgs)
16011 ELSEIF ( iscni .eq. 2 .or. iscni .eq. 4 .or. iscni .eq. 5 ) THEN ! Zeigler 1985/Zrnic 1993, sort of
16012 IF ( iscni .ne. 5 .and. qidpv(mgs) .gt. 0.0 .and. xdia(mgs,li,3) .ge. 100.e-6 ) THEN
16013 ! convert larger crystals to snow
16014 ! IF ( xdia(mgs,ls,3) .gt. xdia(mgs,li,3) ) THEN
16015 ! qscni(mgs) = Max(0.1,xdia(mgs,li,3)/xdia(mgs,ls,3))*qidpv(mgs)
16016 ! erm 9/5/08 changed max to min
16017 qscni(mgs) = Min(0.5, xdia(mgs,li,3)/200.e-6)*qidpv(mgs)
16019 ! qscni(mgs) = 0.1*qidpv(mgs)
16021 cscni(mgs) = fscni*qscni(mgs)*rho0(mgs)/Max(rho_qs*xvmn(ls),xmas(mgs,li))
16022 ! cscni(mgs) = fscni*Min(cimxd(mgs),qscni(mgs)*rho0(mgs)/Max(xdn(mgs,ls)*xvmn(ls),xmas(mgs,li)))
16023 ! cscni(mgs) = Min(cimxd(mgs),qscni(mgs)*rho0(mgs)/xmas(mgs,li) )
16024 ! IF ( xdia(mgs,ls,3) .le. 200.e-6 ) THEN
16025 cscnis(mgs) = cscni(mgs)
16027 ! cscnis(mgs) = 0.0
16031 IF ( iscni .ne. 4 ) THEN
16032 ! crystal aggregation to become snow
16033 ! erm 9/5/08 commented second line and added xv to 1st line (zrnic et al 1993)
16034 tmp = ess(mgs)*rvt*aa2*cx(mgs,li)*cx(mgs,li)*xv(mgs,li)
16035 ! : ((cinu + 2.)*xv(mgs,li)/(cinu + 1.) + xv(mgs,li))
16037 ! csacs(mgs) = rvt*aa2*ess(mgs)*cx(mgs,ls)**2*xv(mgs,ls)
16039 qscni(mgs) = qscni(mgs) + Min( qxmxd(mgs,li), 2.0*tmp*xmas(mgs,li)*rhoinv(mgs) )
16040 cscni(mgs) = cscni(mgs) + Min( cxmxd(mgs,li), 2.0*tmp )
16041 cscnis(mgs) = cscnis(mgs) + Min( cxmxd(mgs,li), tmp )
16043 ELSEIF ( iscni .eq. 3 ) THEN ! LFO
16044 qscni(mgs) = 0.001*eii(mgs)*max((qx(mgs,li)-1.e-3),0.0)
16045 qscni(mgs) = min(qscni(mgs),qxmxd(mgs,li))
16046 cscni(mgs) = qscni(mgs)*rho0(mgs)/xmas(mgs,li)
16047 cscnis(mgs) = 0.5*cscni(mgs)
16048 ! write(iunit,*) 'qscni, qi = ',qscni(mgs),qx(mgs,li),igs(mgs),kgs(mgs)
16051 ELSEIF ( ipconc < 4 ) THEN ! LFO
16053 qimax = rhoinv(mgs)*roqimax
16054 qscni(mgs) = Min(0.90*qx(mgs,li), Max( 0.0, (qx(mgs,li) - qimax)*dtpinv ) )
16056 qscni(mgs) = 0.001*eii(mgs)*max((qx(mgs,li)-1.e-3),0.0)
16057 qscni(mgs) = min(qscni(mgs),qxmxd(mgs,li))
16059 else ! 10-ice version
16060 if ( iscni > 0 .and. qx(mgs,li) .gt. qxmin(li) ) then
16062 & pi*rho0(mgs)*((0.25)/(6.0)) &
16063 & *eii(mgs)*(qx(mgs,li)**2)*(xdia(mgs,li,2)) &
16064 & *vtxbar(mgs,li,1)/xmas(mgs,li)
16065 cscni(mgs) = Min(cimxd(mgs),qscni(mgs)*rho0(mgs)/xmas(mgs,li))
16073 ! compute dry growth rate of snow, graupel, and hail
16077 qsdry(mgs) = qsacr(mgs) + qsacw(mgs) &
16080 qhdry(mgs) = qhaci(mgs) + qhacs(mgs) &
16086 IF ( lhl .gt. 1 ) THEN
16087 qhldry(mgs) = qhlaci(mgs) + qhlacs(mgs) &
16093 ! set wet growth and shedding
16097 IF ( temg(mgs) < tfr ) THEN
16100 ! > ( xdia(mgs,ls,1)*swvent(mgs)*cx(mgs,ls)*fwet1(mgs)
16101 ! > + fwet2(mgs)*(qsaci(mgs)+qsacir(mgs)
16102 ! > +qsacip(mgs)) )
16103 ! qswet(mgs) = max( 0.0, qswet(mgs))
16105 ! IF ( dnu(lh) .ne. 0. ) THEN
16106 ! qhwet(mgs) = qhdry(mgs)
16109 & ( xdia(mgs,lh,1)*hwvent(mgs)*cx(mgs,lh)*fwet1(mgs) &
16110 & + fwet2(mgs)*(qhaci(mgs) + qhacs(mgs)) )
16111 qhwet(mgs) = max( 0.0, qhwet(mgs))
16116 IF ( lhl .gt. 1 ) THEN
16118 & ( xdia(mgs,lhl,1)*hlvent(mgs)*cx(mgs,lhl)*fwet1(mgs) &
16119 & + fwet2(mgs)*(qhlaci(mgs) + qhlacs(mgs)) )
16120 qhlwet(mgs) = max( 0.0, qhlwet(mgs))
16125 qhwet(mgs) = qhdry(mgs)
16126 qhlwet(mgs) = qhldry(mgs)
16130 ! qhlwet(mgs) = qhldry(mgs)
16148 wetsfc(:) = .false.
16149 wetgrowth(:) = .false.
16150 wetsfchl(:) = .false.
16151 wetgrowthhl(:) = .false.
16157 qhshr(mgs) = Min( 0.0, qhwet(mgs) - qhdry(mgs) ) ! water that freezes should never be more than what sheds
16161 qhlshr(mgs) = Min( 0.0, qhlwet(mgs) - qhldry(mgs) )
16164 ! limit wet growth to only higher density particles
16169 ! no shedding for temperatures < 243.15
16171 if ( temg(mgs) .lt. 243.15 ) then
16177 wetsfc(mgs) = .false.
16178 wetgrowth(mgs) = .false.
16179 wetsfchl(mgs) = .false.
16180 wetgrowthhl(mgs) = .false.
16183 ! shed all at temperatures > 273.15
16185 if ( temg(mgs) .gt. tfr ) then
16187 IF ( .false. ) THEN ! old and incorrect -- Thanks to Shaofeng Hua for noticing this error (9/17/2017)
16188 qsshr(mgs) = -qsdry(mgs)
16189 qhshr(mgs) = -qhdry(mgs)
16190 qhlshr(mgs) = -qhldry(mgs)
16191 ELSE ! new and correct
16193 qsshr(mgs) = - qsacr(mgs) - qsacw(mgs) ! -qsdry(mgs)
16194 qhlshr(mgs) = - qhlacw(mgs) - qhlacr(mgs) ! -qhldry(mgs)
16195 qhshr(mgs) = - qhacw(mgs) - qhacr(mgs) ! -qhdry(mgs)
16199 vhshdr(mgs) = -vhacw(mgs) - vhacr(mgs)
16200 vhlshdr(mgs) = -vhlacw(mgs) - vhlacr(mgs)
16205 ! if (qhshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) THEN
16206 wetsfc(mgs) = (qhshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) .or. ( qhmlr(mgs) < -qxmin(lh) .and. temg(mgs) > tfr )
16207 wetgrowth(mgs) = (qhshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr )
16209 if (qhlshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) THEN
16210 wetsfchl(mgs) = (qhlshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) .or. ( qhlmlr(mgs) < -qxmin(lhl) .and. temg(mgs) > tfr )
16211 wetgrowthhl(mgs) = (qhlshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr )
16216 if ( ipconc .ge. 1 ) then
16218 csshr(mgs) = 0.0 ! (cx(mgs,ls)/(qx(mgs,ls)+1.e-20))*Min(0.0,qsshr(mgs))
16220 chshr(mgs) = 0.0 ! no change to graupel number concentration for wet-growth shedding
16222 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
16223 ! Base the drop size on the shedding regime
16224 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
16225 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
16226 chshrr(mgs) = rho0(mgs)*qhshr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lh)) ! into rain
16232 IF ( lhl .gt. 1 ) THEN
16233 ! chlshr(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlshr(mgs)
16236 chlshr(mgs) = 0.0 ! no change to hail number concentration for wet-growth shedding
16238 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
16239 ! Base the drop size on the shedding regime
16240 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
16241 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
16242 chlshrr(mgs) = rho0(mgs)*qhlshr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lhl)) ! into rain
16244 ENDIF ! ( lhl > 1 )
16259 if ( qsshr(mgs) .lt. 0.0 ) then
16266 ! if ( qsdry(mgs) .lt. qswet(mgs) ) then
16276 if ( wetgrowth(mgs) .or. (mixedphase .and. fhw(mgs) .gt. 0.05 .and. temg(mgs) .gt. 243.15) ) then
16279 ! soaking (when not advected liquid water film with graupel)
16281 IF ( lvol(lh) .gt. 1 .and. .not. mixedphase) THEN
16282 ! rescale volumes to maximum density
16283 rimdn(mgs,lh) = xdnmx(lh)
16284 raindn(mgs,lh) = xdnmx(lh)
16285 vhacw(mgs) = qhacw(mgs)*rho0(mgs)/rimdn(mgs,lh)
16286 vhacr(mgs) = qhacr(mgs)*rho0(mgs)/raindn(mgs,lh)
16287 ! IF ( lvol(lh) .gt. 1 .and. wetgrowth(mgs) ) THEN
16288 IF ( xdn(mgs,lh) .lt. xdnmx(lh) ) THEN
16289 ! soak some liquid into the graupel
16290 ! v1 = xdnmx(lh)*vx(mgs,lh)/(xdn(mgs,lh)*dtp) ! volume available for filling
16291 v1 = (1. - xdn(mgs,lh)/xdnmx(lh))*vx(mgs,lh)/(dtp) ! volume available for filling
16292 ! tmp = (vx(mgs,lh)/rho0(mgs))*(xdnmx(lh) - xdn(mgs,lh)) ! max mixing ratio of liquid water that can be added
16293 v2 = rho0(mgs)*qhwet(mgs)/xdnmx(lh) ! volume of frozen accretion
16295 vhsoak(mgs) = Min(v1,v2)
16299 vhshdr(mgs) = Min(0.0, rho0(mgs)*qhwet(mgs)/xdnmx(lh) - vhacw(mgs) - vhacr(mgs) )
16301 ELSEIF ( lvol(lh) .gt. 1 .and. mixedphase ) THEN
16302 ! vhacw(mgs) = rho0(mgs)*qhacw(mgs)/xdn0(lr)
16303 ! vhacr(mgs) = rho0(mgs)*qhacr(mgs)/xdn0(lr)
16312 ! collection efficiency modification
16314 IF ( ehi(mgs) .gt. 0.0 ) THEN
16315 qhaci(mgs) = Min(qimxd(mgs),qhaci0(mgs)) ! effectively sets collection eff to 1
16316 chaci(mgs) = Min(cimxd(mgs),chaci0(mgs)) ! effectively sets collection eff to 1
16318 IF ( ehs(mgs) .gt. 0.0 ) THEN
16319 ! qhacs(mgs) = Min(qsmxd(mgs),qhacs(mgs)/ehs(mgs)) ! effectively sets collection eff to 1
16320 qhacs(mgs) = Min(qsmxd(mgs),qhacs0(mgs)) !/ehs(mgs) ! divide out the collection efficiency
16321 chacs(mgs) = Min(csmxd(mgs),chacs0(mgs)) !/ehs(mgs) ! divide out the collection efficiency
16322 ehs(mgs) = ehsmax ! 1.0 ! min(ehsfrac*ehs(mgs),ehsmax) ! modify it
16323 qhacs(mgs) = Min(qsmxd(mgs),qhacs(mgs)) ! plug it back in
16326 ! be sure to catch particles with wet surfaces but not in wet growth to turn off Hallett-Mossop
16327 wetsfc(mgs) = .true.
16336 ! if ( lhl .gt. 1 .and. qhlshr(mgs) .lt. 0.0 ) then
16337 if ( lhl > 1 .and. ( wetgrowthhl(mgs) .or. (mixedphase .and. fhlw(mgs) .gt. 0.05 .and. temg(mgs) .gt. 243.15) ) ) then
16338 ! if ( wetgrowthhl(mgs) ) then
16342 ! qhlsbv(mgs) = 0.0
16344 ! chlsbv(mgs) = 0.0
16349 IF ( lvol(lhl) .gt. 1 .and. .not. mixedphase ) THEN
16350 ! IF ( lvol(lhl) .gt. 1 .and. wetgrowthhl(mgs) ) THEN
16352 rimdn(mgs,lhl) = xdnmx(lhl)
16353 raindn(mgs,lhl) = xdnmx(lhl)
16354 vhlacw(mgs) = qhlacw(mgs)*rho0(mgs)/rimdn(mgs,lhl)
16355 vhlacr(mgs) = qhlacr(mgs)*rho0(mgs)/raindn(mgs,lhl)
16357 IF ( xdn(mgs,lhl) .lt. xdnmx(lhl) ) THEN
16358 ! soak some liquid into the hail
16359 ! v1 = xdnmx(lhl)*vx(mgs,lhl)/(xdn(mgs,lhl)*dtp) ! volume available for filling
16360 v1 = (1. - xdn(mgs,lhl)/xdnmx(lhl))*vx(mgs,lhl)/(dtp) ! volume available for filling
16361 ! tmp = (vx(mgs,lhl)/rho0(mgs))*(xdnmx(lhl) - xdn(mgs,lhl)) ! max mixing ratio of liquid water that can be added
16362 v2 = rho0(mgs)*qhlwet(mgs)/xdnmx(lhl) ! volume of frozen accretion
16363 IF ( v1 > v2 ) THEN ! all the frozen stuff fits in
16365 ELSE ! fill up the available space
16368 ! vhlacw(mgs) = 0.0
16369 ! vhlacr(mgs) = Max( 0.0, v2 - v1 )
16372 ! vhlacw(mgs) = 0.0
16373 ! vhlacr(mgs) = rho0(mgs)*qhlwet(mgs)/raindn(mgs,lhl)
16377 vhlshdr(mgs) = Min(0.0, rho0(mgs)*qhlwet(mgs)/xdnmx(lhl) - vhlacw(mgs) - vhlacr(mgs) )
16380 ELSEIF ( lvol(lhl) .gt. 1 .and. mixedphase ) THEN
16381 ! vhlacw(mgs) = rho0(mgs)*qhlacw(mgs)/xdn0(lr)
16382 ! vhlacr(mgs) = rho0(mgs)*qhlacr(mgs)/xdn0(lr)
16385 IF ( ehli(mgs) .gt. 0.0 ) THEN
16386 qhlaci(mgs) = Min(qimxd(mgs),qhlaci0(mgs)) ! effectively sets collection eff to 1
16387 chlaci(mgs) = Min(cimxd(mgs),chlaci0(mgs)) ! effectively sets collection eff to 1
16390 ! IF ( ehls(mgs) .gt. 0.0 ) THEN
16391 ! qhlacs(mgs) = Min(qsmxd(mgs),qhlacs(mgs)/ehls(mgs))
16393 IF ( ehls(mgs) .gt. 0.0 ) THEN
16394 qhlacs(mgs) = Min(qsmxd(mgs),qhlacs0(mgs)) !/ehls(mgs) ! divide out the collection efficiency
16395 chlacs(mgs) = Min(csmxd(mgs),chlacs0(mgs)) !/ehls(mgs) ! divide out the collection efficiency
16396 ehls(mgs) = ehsmax ! 1.0 ! min(ehsfrac*ehs(mgs),ehsmax) ! modify it
16397 ! qhlacs(mgs) = Min(qsmxd(mgs),qhlacs(mgs)) ! plug it back in
16401 ! qhlwet(mgs) = 1.0
16403 ! be sure to catch particles with wet surfaces but not in wet growth to turn off Hallett-Mossop
16404 wetsfchl(mgs) = .true.
16408 ! qhlshr(mgs) = 0.0
16409 ! qhlwet(mgs) = 0.0
16414 ! Ice -> graupel conversion
16423 IF ( iglcnvi .ge. 1 ) THEN
16424 IF ( temg(mgs) .lt. 273.0 .and. qiacw(mgs) - qidpv(mgs) .gt. 0.0 ) THEN
16427 tmp = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16428 & *((0.60)*vtxbar(mgs,li,1)) &
16429 & /(temg(mgs)-273.15))**(rimc2)
16430 tmp = Min( Max( rimc3, tmp ), 900.0 )
16432 ! Assume that half the volume of the embryo is rime with density 'tmp'
16433 ! m = rhoi*(V/2) + rhorime*(V/2) = (rhoi + rhorime)*V/2
16434 ! V = 2*m/(rhoi + rhorime)
16436 ! write(0,*) 'rime dens = ',tmp
16438 IF ( tmp .ge. 200.0 .or. iglcnvi >= 2 ) THEN
16439 r = Max( 0.5*(xdn(mgs,li) + tmp), xdnmn(lh) )
16440 ! r = Max( r, 400. )
16441 qhcni(mgs) = (qiacw(mgs) - qidpv(mgs)) ! *float(iglcnvi)
16442 chcni(mgs) = cx(mgs,li)*qhcni(mgs)/qx(mgs,li)
16443 ! chcnih(mgs) = rho0(mgs)*qhcni(mgs)/(1.6e-10)
16444 chcnih(mgs) = Min(chcni(mgs), rho0(mgs)*qhcni(mgs)/(r*xvmn(lh)) )
16445 ! vhcni(mgs) = rho0(mgs)*2.0*qhcni(mgs)/(xdn(mgs,li) + tmp)
16446 vhcni(mgs) = rho0(mgs)*qhcni(mgs)/r
16449 ELSEIF ( iglcnvi == 3 ) THEN
16451 IF ( temg(mgs) .lt. 273.0 .and. qiacw(mgs)*dtp > 2.*qxmin(lh) .and. gamice73fac*xmas(mgs,li) > xdnmn(lh)*xvmn(lh) ) THEN
16454 tmp = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16455 & *((0.60)*vtxbar(mgs,li,1)) &
16456 & /(temg(mgs)-273.15))**(rimc2)
16457 tmp = Min( Max( rimc3, tmp ), 900.0 )
16459 ! Assume that half the volume of the embryo is rime with density 'tmp'
16460 ! m = rhoi*(V/2) + rhorime*(V/2) = (rhoi + rhorime)*V/2
16461 ! V = 2*m/(rhoi + rhorime)
16463 ! write(0,*) 'rime dens = ',tmp
16464 ! convert to particles with the mass of the mass-weighted diameter
16465 ! massofmwr = gamice73fac*xmas(mgs,li)
16467 IF ( tmp .ge. xdnmn(lh) ) THEN
16468 r = Max( 0.5*(xdn(mgs,li) + tmp), xdnmn(lh) )
16469 ! r = Max( r, 400. )
16470 qhcni(mgs) = 0.5*qiacw(mgs)
16471 chcni(mgs) = qhcni(mgs)/(gamice73fac*xmas(mgs,li))
16472 chcnih(mgs) = Min(chcni(mgs), rho0(mgs)*qhcni(mgs)/(r*xvmn(lh)) )
16473 ! vhcni(mgs) = rho0(mgs)*2.0*qhcni(mgs)/(xdn(mgs,li) + tmp)
16474 vhcni(mgs) = rho0(mgs)*qhcni(mgs)/r
16500 IF ( lhl .gt. 1 ) THEN
16502 IF ( ihlcnh == 1 .or. ihlcnh == 3 ) THEN
16505 ! Graupel (h) conversion to hail (hl) based on Milbrandt and Yau 2005b
16509 ! IF ( lhl .gt. 1 .and. ipconc .ge. 5 .and. qx(mgs,lh) .gt. 1.0e-3 .and.
16510 ! : xdn(mgs,lh) .gt. 750. .and. qhshr(mgs) .lt. 0.0 .and.
16511 ! : xdia(mgs,lh,3) .gt. 1.e-3 ) THEN
16512 IF ( hlcnhdia > 0 ) THEN
16513 ltest = xdia(mgs,lh,3) .gt. hlcnhdia ! test on mean volume diameter
16515 ! ltest = xdia(mgs,lh,1)*(3. + alpha(mgs,lh)) > Abs( hlcnhdia ) ! test on maximum mass diameter
16516 ltest = xdia(mgs,lh,1)*(4. + alpha(mgs,lh)) > Abs( hlcnhdia ) ! test on mass-weighted diameter
16521 wtest = (dg0(mgs) > 0.0 .and. dg0(mgs) < dg0thresh )
16523 IF ( ihlcnh == 1 ) THEN ! .or. iusedw == 0 THEN
16525 IF ( ( wetgrowth(mgs) .and. (xdn(mgs,lh) .gt. hldnmn .or. lvh < 1 ) .and. & ! correct this when hail gets turned on
16526 & rimdn(mgs,lh) .gt. 800. .and. &
16527 & ltest .and. qx(mgs,lh) .gt. hlcnhqmin ) .or. wtest ) THEN ! {
16528 ! : xdia(mgs,lh,3) .gt. 2.e-3 .and. qx(mgs,lh) .gt. 1.0e-3 THEN ! 0823.2008 erm test
16529 ! IF ( xdia(mgs,lh,3) .gt. 1.e-3 ) THEN
16530 IF ( qhacw(mgs) .gt. 0.0 .and. qhacw(mgs) .gt. qhaci(mgs) .and. temg(mgs) .le. tfr-2.0 ) THEN ! {
16531 ! dh0 is the diameter dividing wet growth from dry growth (Ziegler 1985), modified by MY05
16532 ! dh0 = 0.01*(exp(temcg(mgs)/(1.1e4*(qx(mgs,lc)+qx(mgs,lr)) -
16533 ! : 1.3e3*qx(mgs,li) + 1.0e-3 ) ) - 1.0)
16537 x = (1.1e4*(rho0(mgs)*qx(mgs,lc)) - 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0e-3 )
16538 IF ( x > 1.e-20 ) THEN
16539 arg = Min(70.0, (-temcg(mgs)/x )) ! prevent overflow of the exp function in 32 bit
16540 dh0 = 0.01*(exp(arg) - 1.0)
16545 ! dh0 = Max( dh0, 5.e-3 )
16547 ! IF ( dh0 .gt. 0.0 ) write(0,*) 'dh0 = ',dh0
16548 ! IF ( dh0 .gt. 1.0e-4 ) THEN
16549 IF ( xdia(mgs,lh,3)/dh0 .gt. 0.1 ) THEN !{
16550 ! IF ( xdia(mgs,lh,3) .lt. 20.*dh0 .and. dh0 .lt. 2.0*xdia(mgs,lh,3) ) THEN
16551 tmp = qhacw(mgs) + qhacr(mgs) + qhaci(mgs) + qhacs(mgs)
16552 ! qtmp = Min( 1.0, xdia(mgs,lh,3)/(2.0*dh0) )*(tmp)
16553 qtmp = Min( 100.0, xdia(mgs,lh,3)/(2.0*dh0) )*(tmp)
16554 ! IF ( .false. .and. qx(mgs,lhl) + qtmp*dtp .lt. 0.5e-3 ) THEN
16555 ! hdia1 = Max(dh0, xdia(mgs,lh,3) )
16556 ! qtmp = qtmp + Min(qxmxd(mgs,lh), Max( 0.0, &
16557 ! & ((pi*xdn(mgs,lh)*cx(mgs,lh)) / (6.0*rho0(mgs)*dtp)) &
16558 ! & *exp(-hdia1/xdia(mgs,lh,1)) &
16559 ! & *( (hdia1**3) + 3.0*(hdia1**2)*xdia(mgs,lh,1) &
16560 ! & + 6.0*(hdia1)*(xdia(mgs,lh,1)**2) + 6.0*(xdia(mgs,lh,1)**3) ) ) )
16564 ! qhlcnh(mgs) = Min( 0.5*(qx(mgs,lh))+tmp, xdia(mgs,lh,3)/(2.0*dh0)*(tmp) )
16565 ! qhlcnh(mgs) = Min( qxmxd(mgs,lh), xdia(mgs,lh,3)/(2.0*dh0)*(tmp) )
16566 qhlcnh(mgs) = Min( qxmxd(mgs,lh), qtmp )
16568 IF ( ipconc .ge. 5 ) THEN !{
16569 ! dh0 = Max( xdia(mgs,lh,3), Min( dh0, 5.e-3 ) ) ! do not create hail greater than 5mm diam. unless the graupel is larger
16570 IF ( .not. wtest ) dh0 = Min( dh0, 10.e-3 ) ! do not create hail greater than 10mm diam., which is the max graupel size
16571 IF ( qx(mgs,lhl) > 0.1e-3 ) dh0 = Max( dh0, xdia(mgs,lhl,3) ) ! when enough hail is established, do not dilute the size
16572 chlcnhhl(mgs) = Min( cxmxd(mgs,lh), rho0(mgs)*qhlcnh(mgs)/(pi*xdn(mgs,lh)*dh0**3/6.0) )
16574 r = rho0(mgs)*qhlcnh(mgs)/(xdn(mgs,lh)*xv(mgs,lh)) ! number of graupel particles at mean volume diameter
16575 ! chlcnh(mgs) = Min( Max( 1./8.*r , chlcnh(mgs)), r )
16576 ! chlcnh(mgs) = Min( chlcnh(mgs), r )
16577 chlcnh(mgs) = Max( chlcnhhl(mgs), r )
16580 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
16581 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/Max(xdnmn(lhl), xdn(mgs,lh))
16588 ELSEIF ( ihlcnh == 3 ) THEN !{
16595 ELSEIF ( ihlcnh == 2 ) THEN ! 10-ice type conversion
16597 ELSEIF ( ihlcnh == 0 ) THEN
16600 ! qhlcnh(mgs) = 0.0
16601 ! chlcnh(mgs) = 0.0
16602 if ( wetgrowth(mgs) .and. temg(mgs) .lt. tfr-5. .and. qx(mgs,lh) > qxmin(lh) ) then
16603 if ( qhacw(mgs).gt.1.e-6 .and. xdn(mgs,lh) > 700. ) then
16605 ((pi*xdn(mgs,lh)*cx(mgs,lh)) / (6.0*rho0(mgs)*dtp)) &
16606 *exp(-hldia1/xdia(mgs,lh,1)) &
16607 *( (hldia1**3) + 3.0*(hldia1**2)*xdia(mgs,lh,1) &
16608 + 6.0*(hldia1)*(xdia(mgs,lh,1)**2) + 6.0*(xdia(mgs,lh,1)**3) )
16609 qhlcnh(mgs) = min(qhlcnh(mgs),qhmxd(mgs))
16610 IF ( ipconc .ge. 5 ) THEN
16611 chlcnh(mgs) = Min( cxmxd(mgs,lh), cx(mgs,lh)*Exp(-hldia1/xdia(mgs,lh,1)))
16612 chlcnhhl(mgs) = chlcnh(mgs)
16613 ! chlcnh(mgs) = Min( cxmxd(mgs,lh), rho0(mgs)*qhlcnh(mgs)/(2.0*xmas(mgs,lh) ))
16615 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
16616 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/Max(xdnmn(lhl), xdn(mgs,lh))
16623 ENDIF ! ihlcnh options
16625 ! convert low-density hail to graupel
16626 IF ( icvhl2h >= 1 ) THEN
16628 IF ( qx(mgs,lhl) > qxmin(lhl) .and. xdn(mgs,lhl) < 0.5*(xdnmn(lhl) + xdnmx(lhl)) ) THEN
16629 tmp = Min(0.95, 1. - 0.5*(1. + tanh(0.125*(xdn(mgs,lhl) - 1.01*xdnmn(lhl) )) ))
16630 qhcnhl(mgs) = tmp*qx(mgs,lhl)*dtpinv
16631 chcnhl(mgs) = cx(mgs,lhl)*qhcnhl(mgs)/qx(mgs,lhl)
16632 vhcnhl(mgs) = vx(mgs,lhl)*qhcnhl(mgs)/qx(mgs,lhl)
16645 ! Ziegler snow conversion to graupel
16658 IF ( ipconc .ge. 5 ) THEN
16660 ! test attempt at converting graupel to snow when not riming but growing by deposition
16661 IF ( temg(mgs) < tfr .and. qx(mgs,lh) .gt. qxmin(lh) .and. qhdpv(mgs) > qxmin(lh)*dtpinv &
16662 & .and. qhacw(mgs) < qxmin(lh)*dtpinv ) THEN
16663 IF ( xdn(mgs,lh) < 290. ) THEN
16664 ! qscnh(mgs) = 2.*qhdpv(mgs)
16665 ! cscnh(mgs) = cx(mgs,lh)*qscnh(mgs)/qx(mgs,lh)
16666 ! vscnh(mgs) = rho0(mgs)*qscnh(mgs)/xdn(mgs,lh)
16671 IF ( qx(mgs,ls) .gt. qxmin(ls) .and. qsacw(mgs) .gt. 0.0 ) THEN
16673 ! DATA VGRA/1.413E-2/ ! this is the volume (cm**3) of a 3mm diam. sphere
16674 ! vgra = 1.4137e-8 m**3
16676 ! DNNET=DNCNV-DNAGG
16677 ! DQNET=QXCON+QSACC+SDEP
16679 ! DNSCNV=EXP(-(ROS*XNS*VGRA/(RO*QI)))*((1.-(XNS*VGRA*ROS/
16680 ! / (RO*QI)))*DNNET + (XNS**2*VGRA*ROS/(RO*QI**2))*DQNET)
16681 ! IF(DNSCNV.LT.0.) DNSCNV=0.
16683 ! QIHC=(ROS*VGRA/RO)*DNSCNV
16687 ! XNH=XNH+DT*DNSCNV
16688 ! XNS=XNS-DT*DNSCNV
16690 IF ( iglcnvs .eq. 1 ) THEN ! Zrnic, Ziegler et al (1993)
16692 dnnet = cscnvis(mgs) + cscnis(mgs) - csacs(mgs)
16693 dqnet = qscnvi(mgs) + qscni(mgs) + qsacw(mgs) + qsdpv(mgs) + qssbv(mgs)
16695 a3 = 1./(rho0(mgs)*qx(mgs,ls))
16696 a1 = Exp( - xdn(mgs,ls)*cx(mgs,ls)*vgra*a3 ) !! EXP(-(ROS*XNS*VGRA/(RO*QI)))
16697 ! (1.-(XNS*VGRA*ROS/(RO*QI)))*DNNET
16698 a2 = (1.-(cx(mgs,ls)*vgra*xdn(mgs,ls)*a3))*dnnet
16699 ! (XNS**2*VGRA*ROS/(RO*QI**2))*DQNET
16700 a4 = cx(mgs,ls)**2*vgra*xdn(mgs,ls)*a3/qx(mgs,ls)*dqnet
16702 chcns(mgs) = Max( 0.0, a1*(a2 + a4) )
16703 chcns(mgs) = Min( chcns(mgs), cxmxd(mgs,ls) )
16704 chcnsh(mgs) = chcns(mgs)
16706 qhcns(mgs) = Min( xdn(mgs,ls)*vgra*rhoinv(mgs)*chcns(mgs), qxmxd(mgs,ls) )
16707 vhcns(mgs) = rho0(mgs)*qhcns(mgs)/Max(xdn(mgs,ls),xdnmn(lh))
16708 ! vhcns(mgs) = rho0(mgs)*qhcns(mgs)/Max(xdn(mgs,ls),400.)
16710 ELSEIF ( iglcnvs .ge. 2 ) THEN ! treat like ice crystals, i.e., check for rime density (ERM)
16712 IF ( temg(mgs) .lt. 273.0 .and. ( qsacw(mgs) - qsdpv(mgs) .gt. 0.0 .or. &
16713 ( iglcnvs >= 3 .and. qsacw(mgs)*dtp > 2.*qxmin(lh) .and. gamsnow73fac*xmas(mgs,ls) > xdnmn(lh)*xvmn(lh) ) ) ) THEN !{
16716 tmp = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16717 & *((0.60)*vtxbar(mgs,ls,1)) &
16718 & /(temg(mgs)-273.15))**(rimc2)
16719 ! tmp = Min( Max( rimc3, tmp ), 900.0 )
16720 tmp = Min( tmp , 900.0 )
16722 ! Assume that half the volume of the embryo is rime with density 'tmp'
16723 ! m = rhoi*(V/2) + rhorime*(V/2) = (rhoi + rhorime)*V/2
16724 ! V = 2*m/(rhoi + rhorime)
16726 ! write(0,*) 'rime dens = ',tmp
16728 IF ( iglcnvs == 2 ) THEN !{
16729 IF ( tmp .ge. 200.0 ) THEN
16730 r = Max( 0.5*(xdn(mgs,ls) + tmp), xdnmn(lh) )
16731 ! r = Max( r, 400. )
16732 qhcns(mgs) = (qsacw(mgs) - qsdpv(mgs))
16733 chcns(mgs) = cx(mgs,ls)*qhcns(mgs)/qx(mgs,ls)
16734 ! chcnih(mgs) = rho0(mgs)*qhcni(mgs)/(1.6e-10)
16735 chcnsh(mgs) = Min(chcns(mgs), rho0(mgs)*qhcns(mgs)/(r*xvmn(lh)) )
16736 ! vhcni(mgs) = rho0(mgs)*2.0*qhcni(mgs)/(xdn(mgs,li) + tmp)
16737 vhcns(mgs) = rho0(mgs)*qhcns(mgs)/r
16740 ELSEIF ( iglcnvs == 3 ) THEN
16742 ! convert to particles with the mass of the mass-weighted diameter
16743 ! massofmwr = gamice73fac*xmas(mgs,li)
16745 IF ( tmp > xdnmn(lh) ) THEN
16746 r = Max( 0.5*(xdn(mgs,ls) + tmp), xdnmn(lh) )
16747 ! r = Max( r, 400. )
16748 qhcns(mgs) = 0.5*qsacw(mgs)
16749 chcns(mgs) = qhcns(mgs)/(gamsnow73fac*xmas(mgs,ls))
16750 chcns(mgs) = Min( chcns(mgs), cx(mgs,ls)*qhcns(mgs)/qx(mgs,ls))
16751 chcnsh(mgs) = Min(chcns(mgs), rho0(mgs)*qhcns(mgs)/(r*xvmn(lh)) )
16752 vhcns(mgs) = rho0(mgs)*qhcns(mgs)/r
16764 ELSE ! single moment lfo
16766 qhcns(mgs) = 0.001*ehscnv(mgs)*max((qx(mgs,ls)-6.e-4),0.0)
16767 qhcns(mgs) = min(qhcns(mgs),qxmxd(mgs,ls))
16768 IF ( lvol(lh) .ge. 1 ) vhcns(mgs) = rho0(mgs)*qhcns(mgs)/Max(xdn(mgs,ls),400.)
16774 ! heat budget for rain---not all rain that collects ice can freeze
16778 if ( irwfrz .gt. 0 .and. .not. mixedphase) then
16782 ! compute total rain that freeze when it interacts with cloud ice
16784 qrztot(mgs) = qrfrz(mgs) + qiacr(mgs) + qsacr(mgs)
16786 ! compute the maximum amount of rain that can freeze
16787 ! Used to limit freezing to 4*qrmxd, but now allow all rain to freeze if possible
16790 & ( xdia(mgs,lr,1)*rwvent(mgs)*cx(mgs,lr)*fwet1(mgs) )
16791 qrzmax(mgs) = max(qrzmax(mgs), 0.0)
16792 qrzmax(mgs) = min(qrztot(mgs), qrzmax(mgs))
16793 qrzmax(mgs) = min(qx(mgs,lr)*dtpinv, qrzmax(mgs))
16795 IF ( temcg(mgs) < -30. ) THEN ! allow all to freeze if T < -30 because fwet becomes invalid (negative)
16796 qrzmax(mgs) = qx(mgs,lr)*dtpinv
16798 ! qrzmax(mgs) = min(4.*qrmxd(mgs), qrzmax(mgs))
16800 ! compute the correction factor
16802 ! IF ( qrztot(mgs) .gt. qxmin(lr) ) THEN
16803 IF ( qrztot(mgs) .gt. qrzmax(mgs) .and. qrztot(mgs) .gt. qxmin(lr) ) THEN
16804 qrzfac(mgs) = qrzmax(mgs)/(qrztot(mgs))
16808 qrzfac(mgs) = min(1.0, qrzfac(mgs))
16813 ! now correct the above sources
16817 if ( temg(mgs) .le. 273.15 .and. qrzfac(mgs) .lt. 1.0 ) then
16818 qrfrz(mgs) = qrzfac(mgs)*qrfrz(mgs)
16819 qrfrzs(mgs) = qrzfac(mgs)*qrfrzs(mgs)
16820 qrfrzf(mgs) = qrzfac(mgs)*qrfrzf(mgs)
16821 qiacr(mgs) = qrzfac(mgs)*qiacr(mgs)
16822 qsacr(mgs) = qrzfac(mgs)*qsacr(mgs)
16823 qiacrf(mgs) = qrzfac(mgs)*qiacrf(mgs)
16824 qiacrs(mgs) = qrzfac(mgs)*qiacrs(mgs)
16825 crfrz(mgs) = qrzfac(mgs)*crfrz(mgs)
16826 crfrzf(mgs) = qrzfac(mgs)*crfrzf(mgs)
16827 crfrzs(mgs) = qrzfac(mgs)*crfrzs(mgs)
16828 ciacr(mgs) = qrzfac(mgs)*ciacr(mgs)
16829 ciacrf(mgs) = qrzfac(mgs)*ciacrf(mgs)
16830 ciacrs(mgs) = qrzfac(mgs)*ciacrs(mgs)
16833 vrfrzf(mgs) = qrzfac(mgs)*vrfrzf(mgs)
16834 viacrf(mgs) = qrzfac(mgs)*viacrf(mgs)
16844 ! evaporation of rain
16854 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
16857 & fvce(mgs)*cx(mgs,lr)*rwvent(mgs)*rwcap(mgs)*evapfac
16858 ! this line to allow condensation on rain:
16859 IF ( rcond .eq. 1 ) THEN
16860 qrcev(mgs) = min(qrcev(mgs), qxmxd(mgs,lv))
16861 ! this line to have evaporation only:
16863 qrcev(mgs) = min(qrcev(mgs), 0.0)
16866 qrcev(mgs) = max(qrcev(mgs), -qrmxd(mgs))
16867 ! if ( temg(mgs) .lt. 273.15 ) qrcev(mgs) = 0.0
16868 IF ( qrcev(mgs) .lt. 0. .and. lnr > 1 ) THEN
16869 ! qrcev(mgs) = -qrmxd(mgs)
16870 ! crcev(mgs) = (rho0(mgs)/(xmas(mgs,lr)+1.e-20))*qrcev(mgs)
16871 crcev(mgs) = (cx(mgs,lr)/(qx(mgs,lr)))*qrcev(mgs)
16875 ! if ( temg(mgs) .lt. 273.15 ) crcev(mgs) = 0.0
16881 ! evaporation/condensation of wet graupel and snow
16889 IF ( lhwlg > 1 ) THEN
16893 IF ( lhlwlg > 1 ) THEN
16901 ! ICE MULTIPLICATION: Two modes (rimpa, and rimpb)
16902 ! (following Cotton et al. 1986)
16914 ltest = qx(mgs,lh) .gt. qxmin(lh)
16915 IF ( lhl > 1 ) ltest = ltest .or. qx(mgs,lhl) .gt. qxmin(lhl)
16917 IF ( (itype1 .ge. 1 .or. itype2 .ge. 1 ) &
16918 & .and. qx(mgs,lc) .gt. qxmin(lc)) THEN
16919 if ( temg(mgs) .ge. 265.15 .and. temg(mgs) .le. 271.15 ) then
16920 IF ( ipconc .ge. 2 ) THEN
16921 IF ( xv(mgs,lc) .gt. 0.0 &
16923 ! .and. itype2 .ge. 2 &
16926 ! Ziegler et al. 1986 Hallett-Mossop process. VSTAR = 7.23e-15 (vol of 12micron radius)
16928 IF ( alpha(mgs,lc) == 0.0 ) THEN
16929 ex1 = (1./250.)*Exp(-7.23e-15/xv(mgs,lc))
16932 ratio = (1. + alpha(mgs,lc))*(7.23e-15)/xv(mgs,lc)
16934 IF ( usegamxinfcnu ) THEN
16935 i = Nint(dgami*(1. + alpha(mgs,lc)))
16937 ex1 = (1./250.)*Gamxinf(1.+alpha(mgs,lc), ratio)/(gcnup1)
16939 ratio = Min( maxratiolu, ratio )
16940 tmp = gaminterp(ratio,alpha(mgs,lc),1,1)
16941 ex1 = (1./250.)*tmp
16944 IF ( itype2 .le. 2 ) THEN
16945 ft = Max(0.0,Min(1.0,-0.11*temcg(mgs)**2 - 1.1*temcg(mgs)-1.7))
16947 IF ( temg(mgs) .ge. 265.15 .and. temg(mgs) .le. 267.15 ) THEN
16949 ELSEIF (temg(mgs) .ge. 267.15 .and. temg(mgs) .le. 269.15 ) THEN
16951 ELSEIF (temg(mgs) .ge. 269.15 .and. temg(mgs) .le. 271.15 ) THEN
16957 ! rhoinv = 1./rho0(mgs)
16958 ! DNSTAR = ex1*cglacw(mgs)
16960 IF ( ft > 0.0 ) THEN
16962 IF ( itype2 > 0 ) THEN
16963 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. (.not. wetsfc(mgs)) ) THEN
16964 chmul1(mgs) = ft*ex1*chacw(mgs)
16965 ! 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
16966 qhmul1(mgs) = cimas0*chmul1(mgs)*rhoinv(mgs)
16968 IF ( lhl .gt. 1 ) THEN
16969 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. (.not. wetsfchl(mgs)) ) THEN
16970 chlmul1(mgs) = (ft*ex1*chlacw(mgs))
16971 qhlmul1(mgs) = cimas0*chlmul1(mgs)*rhoinv(mgs)
16976 IF ( itype1 > 0 ) THEN
16977 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. (.not. wetsfc(mgs)) ) THEN
16978 tmp = ft*(3.5e+08)*rho0(mgs)*qhacw(mgs)
16979 chmul1(mgs) = chmul1(mgs) + tmp
16980 qhmul1(mgs) = qhmul1(mgs) + cimas0*tmp*rhoinv(mgs)
16982 IF ( lhl .gt. 1 ) THEN
16983 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. (.not. wetsfchl(mgs)) ) THEN
16984 tmp = ft*(3.5e+08)*rho0(mgs)*qhlacw(mgs)
16985 chlmul1(mgs) = chlmul1(mgs) + tmp
16986 qhlmul1(mgs) = qhlmul1(mgs) + cimas0*tmp*rhoinv(mgs)
16994 ENDIF ! xv(mgs,lc) .gt. 0.0 .and.
16996 ELSE ! ipconc .lt. 2
16998 ! define the temperature function
17002 ! Cotton et al. (1986) version
17004 if ( temg(mgs) .ge. 268.15 .and. temg(mgs) .le. 270.15 ) then
17005 fimt1(mgs) = 1.0 -(temg(mgs)-268.15)/2.0
17006 elseif (temg(mgs) .le. 268.15 .and. temg(mgs) .ge. 265.15 ) then
17007 fimt1(mgs) = 1.0 +(temg(mgs)-268.15)/3.0
17012 ! Ferrier (1994) version
17014 if ( temg(mgs) .ge. 265.15 .and. temg(mgs) .le. 267.15 ) then
17016 elseif (temg(mgs) .ge. 267.15 .and. temg(mgs) .le. 269.15 ) then
17018 elseif (temg(mgs) .ge. 269.15 .and. temg(mgs) .le. 271.15 ) then
17025 ! type I: 350 splinters are formed for every 1e-3 grams of cloud
17026 ! water accreted by graupel/hail (note converted to MKS units)
17027 ! 3.5e+8 has units of 1/kg
17029 IF ( itype1 .ge. 1 ) THEN
17030 fimta(mgs) = (3.5e+08)*rho0(mgs)
17037 ! type II: 1 splinter formed for every 250 cloud droplets larger than
17038 ! 24 micons in diameter (12 microns in radius) accreted by
17043 xcwmas = xmas(mgs,lc) * 1000.
17045 IF ( itype2 .ge. 1 ) THEN
17046 if ( xcwmas.lt.1.26e-9 ) then
17049 if ( xcwmas .le. 3.55e-9 .and. xcwmas .ge. 1.26e-9 ) then
17050 fimt2(mgs) = (2.27)*alog(xcwmas) + 13.39
17052 if ( xcwmas .gt. 3.55e-9 ) then
17056 fimt2(mgs) = min(fimt2(mgs),1.0)
17057 fimt2(mgs) = max(fimt2(mgs),0.0)
17065 ! > (4.0e-03)*fimt1(mgs)*fimt2(mgs)*qhacw(mgs)
17067 ! > (4.0e-03)*fimt1(mgs)*fimt2(mgs)*qsacw(mgs)
17069 ! cimas0 = (1.0e-12)
17071 IF ( .not. wetsfc(mgs) ) THEN
17072 chmul1(mgs) = fimt1(mgs)*(fimta(mgs) + &
17073 & (4.0e-03)*fimt2(mgs))*qhacw(mgs)
17076 qhmul1(mgs) = chmul1(mgs)*(cimas0/rho0(mgs))
17078 IF ( lhl .gt. 1 ) THEN
17079 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. (.not. wetsfchl(mgs)) ) THEN
17080 tmp = fimt1(mgs)*(fimta(mgs) + &
17081 & (4.0e-03)*fimt2(mgs))*qhlacw(mgs)
17083 qhlmul1(mgs) = cimas0*tmp*rhoinv(mgs)
17087 ! qsmul1(mgs) = csmul1(mgs)*(cimas0/rho0(mgs))
17089 ENDIF ! ( ipconc .ge. 2 )
17091 end if ! (in temperature range)
17093 ENDIF ! ( itype1 .eq. 1 .or. itype2 .eq. 1)
17104 ! ICE MULTIPLICATION FROM SNOW
17105 ! Lo and Passarelli 82 / Willis and Heymsfield 89 / Schuur and Rutledge 00b
17106 ! using kfrag as fragmentation rate (s-1) / 500 microns as char mean diam for max snow mix ratio
17111 IF ( isnwfrac /= 0 ) THEN
17113 IF (temg(mgs) .gt. 265.0) THEN !{
17114 if (xdia(mgs,ls,1) .gt. 100.e-6 .and. xdia(mgs,ls,1) .lt. 2.0e-3) then ! equiv diameter 100microns to 2mm
17116 tmp = rhoinv(mgs)*pi*xdn(mgs,ls)*cx(mgs,ls)*(500.e-6)**3
17117 qsmul(mgs) = Max( kfrag*( qx(mgs,ls) - tmp ) , 0.0 )
17119 qsmul(mgs) = Min( qxmxd(mgs,li), qsmul(mgs) )
17120 csmul(mgs) = Min( cxmxd(mgs,li), rho0(mgs)*qsmul(mgs)/mfrag )
17128 ! frozen rain-rain interaction....
17133 ! rain-ice interaction
17137 qracif(mgs) = qraci(mgs)
17138 cracif(mgs) = craci(mgs)
17139 ! ciacrf(mgs) = ciacr(mgs)
17143 ! vapor to pristine ice crystals UP
17147 ! compute the nucleation rate
17149 ! do mgs = 1,ngscnt
17151 ! if ( ssi(mgs) .gt. 1.0 ) idqis = 1
17152 ! fiinit(mgs) = (felv(mgs)**2)/(cp*rw)
17153 ! dqisdt(mgs) = (qx(mgs,lv)-qis(mgs))/
17154 ! > (1.0 + fiinit(mgs)*qis(mgs)/tsqr(mgs))
17155 ! qidsvp(mgs) = dqisdt(mgs)
17156 ! cnnt = min(cnit*exp(-temcg(mgs)*bta1),1.0e+09)
17158 ! > il5(mgs)*idqis*(1.0*dtpinv)
17159 ! < *min((6.88e-13)*cnnt/rho0(mgs), 0.25*dqisdt(mgs))
17162 ! Meyers et al. (1992; JAS) and Ferrier (1994) primary ice nucleation
17164 cmassin = cimasn ! 6.88e-13
17173 IF ( icenucopt == 1 .or. icenucopt == -10 .or. icenucopt == -11 ) THEN
17174 if ( ( temg(mgs) .lt. 268.15 .or. &
17175 ! : ( imeyers5 .and. temg(mgs) .lt. 273.0) ) .and. &
17176 & ( imeyers5 .and. temg(mgs) .lt. 272.0 .and. temgkm2(mgs) .lt. tfr) ) .and. &
17177 & ciintmx .gt. (cx(mgs,li)+ccitmp) &
17178 ! : .and. cninm(mgs) .gt. 0. &
17180 fiinit(mgs) = (felv(mgs)**2)/(cp*rw)
17181 dqisdt(mgs) = (qx(mgs,lv)-qis(mgs))/ &
17182 & (1.0 + fiinit(mgs)*qis(mgs)/tsqr(mgs))
17183 ! qidsvp(mgs) = dqisdt(mgs)
17185 if ( ssi(mgs) .gt. 1.0 ) THEN
17187 dzfacp = max( float(kgsp(mgs)-kgs(mgs)), 0.0 )
17188 dzfacm = max( float(kgs(mgs)-kgsm(mgs)), 0.0 )
17191 & *(cmassin/rho0(mgs)) &
17192 & *max(0.0,wvel(mgs)) &
17193 & *max((cninp(mgs)-cninm(mgs)),0.0)/gz(igs(mgs),jgs,kgs(mgs)) &
17194 & /((dzfacp+dzfacm))
17196 qiint(mgs) = min(qiint(mgs), max(0.25*dqisdt(mgs),0.0))
17197 ciint(mgs) = qiint(mgs)*rho0(mgs)/cmassin
17200 ! limit new crystals so it does not increase the current concentration
17201 ! above ciintmx 20,000 per liter (2.e7 per m**3)
17205 IF ( icenucopt /= -10 ) THEN
17207 IF ( lcin > 1 ) THEN
17208 ciint(mgs) = Min(ciint(mgs), ccin(mgs)*dtpinv) ! because ciint is a *rate*
17209 ccin(mgs) = ccin(mgs) - ciint(mgs)*dtp
17210 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
17211 ELSEIF ( lcina > 1 ) THEN
17212 ciint(mgs) = Max(0.0, Min( ciint(mgs), Min( cnina(mgs), ciintmx ) - cina(mgs) ))
17213 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
17215 ELSEIF ( icenucopt == 1 .and. ciint(mgs) .gt. Max(0.0, ciintmx - cx(mgs,li) - ccitmp )*dtpinv ) THEN
17216 ciint(mgs) = Max(0.0, ciintmx - (cx(mgs,li)) )*dtpinv
17217 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
17219 ELSEIF ( icenucopt == -11 .and. dtp*ciint(mgs) .gt. ( cnina(mgs) - (cx(mgs,li) - ccitmp))) THEN
17220 ciint(mgs) = Max(0.0, cnina(mgs) - (cx(mgs,li)+ccitmp)*dtpinv )
17221 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
17229 ELSEIF ( icenucopt == 2 .or. icenucopt == -1 .or. icenucopt == -2 ) THEN
17231 IF ( ( temg(mgs) .lt. 268.15 .and. ssw(mgs) > 1.0 ) .or. ssi(mgs) > 1.25 ) THEN
17232 IF ( lcin > 1 ) THEN
17233 ciint(mgs) = Min(cnina(mgs), ccin(mgs))
17234 ciint(mgs) = Min( ciint(mgs), Max(0.0, ciintmx - (cx(mgs,li) - ccitmp) ) ) ! do not initiate ice beyond concentration of ciintmx
17235 ccin(mgs) = ccin(mgs) - ciint(mgs)
17236 ciint(mgs) = ciint(mgs)*dtpinv ! convert total initiation to a rate
17238 ciint(mgs) = Max( 0.0, cnina(mgs) - cina(mgs) )*dtpinv
17240 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
17242 fiinit(mgs) = (felv(mgs)**2)/(cp*rw)
17243 dqisdt(mgs) = (qx(mgs,lv)-qis(mgs))/(1.0 + fiinit(mgs)*qis(mgs)/tsqr(mgs))
17244 qiint(mgs) = min(qiint(mgs), max(0.25*dqisdt(mgs),0.0))
17245 ciint(mgs) = qiint(mgs)*rho0(mgs)/cmassin
17250 ELSEIF ( icenucopt == 3 .or. icenucopt == 4 .or. icenucopt == 10 ) THEN
17251 IF ( temg(mgs) .lt. 268.15 ) THEN
17252 IF ( lcin > 1 ) THEN
17253 ciint(mgs) = Min(cnina(mgs), ccin(mgs))
17254 ciint(mgs) = Min( ciint(mgs), Max(0.0, ciintmx - (cx(mgs,li) + ccitmp) ) ) ! do not initiate ice beyond concentration of ciintmx
17255 ccin(mgs) = ccin(mgs) - ciint(mgs)
17256 ciint(mgs) = ciint(mgs)*dtpinv ! convert total initiation to a rate
17258 ciint(mgs) = Max( 0.0, cnina(mgs) - cina(mgs) )*dtpinv
17260 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
17265 if ( xplate(mgs) .eq. 1 ) then
17266 qipipnt(mgs) = qiint(mgs)
17267 cipint(mgs) = ciint(mgs)
17270 if ( xcolmn(mgs) .eq. 1 ) then
17271 qicicnt(mgs) = qiint(mgs)
17272 cicint(mgs) = ciint(mgs)
17275 ! qipipnt(mgs) = 0.0
17276 ! qicicnt(mgs) = qiint(mgs)
17283 ! vapor to cloud droplets UP
17285 if (ndebug .gt. 0 ) write(0,*) 'dbg = 8'
17288 if (ndebug .gt. 0 ) write(0,*) 'Collection: set 3-component'
17290 ! time for riming....
17298 ! coefficients for riming
17316 ! first sum all of the shed rain
17320 qrshr(mgs) = qsshr(mgs) + qhshr(mgs) + qhlshr(mgs)
17321 crshr(mgs) = chshrr(mgs)/rzxh(mgs) + chlshrr(mgs)/rzxhl(mgs)
17324 IF ( ipconc .ge. 3 ) THEN
17325 ! crshr(mgs) = Max(crshr(mgs), rho0(mgs)*qrshr(mgs)/(xdn(mgs,lr)*vr1mm) )
17336 IF ( ipconc .ge. 1 ) THEN
17339 ! concentration production terms
17344 ! DO mgs = 1,ngscnt
17365 ! IF ( ipconc .ge. 1 ) THEN
17367 IF ( warmonly < 0.5 ) THEN
17368 IF ( ffrzs < 1.0 ) THEN
17371 & il5(mgs)*cicint(mgs) &
17372 & +il5(mgs)*((1.0-cwfrz2snowfrac)*cwfrzc(mgs)+cwctfzc(mgs) &
17376 & + csplinter(mgs) + csplinter2(mgs) &
17379 pccii(mgs) = pccii(mgs)*(1.0 - ffrzs)
17381 ! > + nsplinter*(crfrzf(mgs) + crfrz(mgs))
17383 & il5(mgs)*(-cscni(mgs) - cscnvi(mgs) & ! - cwaci(mgs) &
17386 & -chaci(mgs) - chlaci(mgs) &
17388 & +il5(mgs)*cisbv(mgs) &
17389 & -(1.-il5(mgs))*cimlr(mgs)
17391 pccin(mgs) = ciint(mgs)
17396 ELSEIF ( warmonly < 0.8 ) THEN
17400 ! cicint(mgs) = 0.0
17401 ! qicicnt(mgs) = 0.0
17404 & il5(mgs)*cicint(mgs) &
17405 & +il5(mgs)*((1.0-cwfrz2snowfrac)*cwfrzc(mgs)+cwctfzc(mgs) &
17409 & + csplinter(mgs) + csplinter2(mgs) &
17412 pccii(mgs) = pccii(mgs)*(1. - ffrzs)
17414 ! & il5(mgs)*(-cscni(mgs) - cscnvi(mgs) & ! - cwaci(mgs) &
17417 ! & -chaci(mgs) - chlaci(mgs) &
17419 & +il5(mgs)*cisbv(mgs) &
17420 & -(1.-il5(mgs))*cimlr(mgs)
17422 pccin(mgs) = ciint(mgs)
17428 ! ENDIF ! ( ipconc .ge. 1 )
17432 IF ( ipconc .ge. 2 ) THEN
17435 pccwi(mgs) = (0.0) - cwshw(mgs) ! + (1-il5(mgs))*(-cirmlw(mgs))
17437 IF ( warmonly < 0.5 ) THEN
17440 & il5(mgs)*(-ciacw(mgs)-cwfrz(mgs)-cwctfzp(mgs) &
17443 & -cracw(mgs) -csacw(mgs) -chacw(mgs) - chlacw(mgs)
17446 ELSEIF ( warmonly < 0.8 ) THEN
17450 & -ciacw(mgs)-cwfrz(mgs)-cwctfzp(mgs) &
17453 & -cracw(mgs) -chacw(mgs) -chlacw(mgs)
17456 ! tmp3d(igs(mgs),jy,kgs(mgs)) = crcnw(mgs)
17458 ! cracw(mgs) = 0.0 ! turn off accretion
17460 ! crcev(mgs) = 0.0 ! turn off evap
17461 ! qrcev(mgs) = 0.0 ! turn off evap
17462 ! cracr(mgs) = 0.0 ! turn off self collection
17470 & - cautn(mgs) -cracw(mgs)
17474 IF ( .false. .and. exwmindiam > 0.0 .and. ccwresv(mgs) > 0.0 ) THEN
17476 & il5(mgs)*(-ciacw(mgs) &
17478 & -cracw(mgs) -csacw(mgs) -chacw(mgs) - chlacw(mgs)
17480 IF ( -pccwdacc(mgs)*dtp .gt. cx(mgs,lc) - ccwresv(mgs) ) THEN
17482 frac = -(cx(mgs,lc) - ccwresv(mgs) )/(pccwdacc(mgs)*dtp)
17483 pccwdacc(mgs) = -(cx(mgs,lc) - ccwresv(mgs) )*dtpinv
17485 ciacw(mgs) = frac*ciacw(mgs)
17486 cracw(mgs) = frac*cracw(mgs)
17487 csacw(mgs) = frac*csacw(mgs)
17488 chacw(mgs) = frac*chacw(mgs)
17489 cautn(mgs) = frac*cautn(mgs)
17491 IF ( lhl .gt. 1 ) chlacw(mgs) = frac*chlacw(mgs)
17496 & il5(mgs)*(-ciacw(mgs)-cwfrzp(mgs)-cwctfzp(mgs) &
17497 & -cwfrzc(mgs)-cwctfzc(mgs) &
17498 & -il5(mgs)*(ciihr(mgs)) &
17500 & -cracw(mgs) -csacw(mgs) -chacw(mgs) - chlacw(mgs)
17507 IF ( -pccwd(mgs)*dtp .gt. cx(mgs,lc) ) THEN
17508 ! write(0,*) 'OUCH! pccwd(mgs)*dtp .gt. ccw(mgs) ',pccwd(mgs),cx(mgs,lc)
17509 ! write(0,*) 'qc = ',qx(mgs,lc)
17510 ! write(0,*) -ciacw(mgs)-cwfrzp(mgs)-cwctfzp(mgs)-cwfrzc(mgs)-cwctfzc(mgs)
17511 ! write(0,*) -cracw(mgs) -csacw(mgs) -chacw(mgs)
17512 ! write(0,*) - cautn(mgs)
17514 frac = -cx(mgs,lc)/(pccwd(mgs)*dtp)
17515 pccwd(mgs) = -cx(mgs,lc)*dtpinv
17517 ciacw(mgs) = frac*ciacw(mgs)
17518 cwfrz(mgs) = frac*cwfrz(mgs)
17519 cwfrzp(mgs) = frac*cwfrzp(mgs)
17520 cwctfzp(mgs) = frac*cwctfzp(mgs)
17521 cwfrzc(mgs) = frac*cwfrzc(mgs)
17522 cwctfzc(mgs) = frac*cwctfzc(mgs)
17523 cwctfz(mgs) = frac*cwctfz(mgs)
17524 cracw(mgs) = frac*cracw(mgs)
17525 csacw(mgs) = frac*csacw(mgs)
17526 chacw(mgs) = frac*chacw(mgs)
17527 cautn(mgs) = frac*cautn(mgs)
17529 pccii(mgs) = pccii(mgs) - (1.-frac)*il5(mgs)*(cwfrzc(mgs)+cwctfzc(mgs))*(1. - ffrzs)
17530 IF ( lhl .gt. 1 ) chlacw(mgs) = frac*chlacw(mgs)
17542 IF ( ipconc .ge. 3 ) THEN
17546 IF ( warmonly < 0.5 ) THEN
17550 & +(1-il5(mgs))*( &
17551 & -chmlrr(mgs)/rzxh(mgs) &
17552 & -chlmlrr(mgs)/rzxhl(mgs) &
17553 ! & -csmlr(mgs)/rzxs(mgs) &
17556 & -crshr(mgs) !null at this point when wet snow/graupel included
17558 & il5(mgs)*(-ciacr(mgs) - crfrz(mgs) ) & ! - cipacr(mgs))
17560 & - chacr(mgs) - chlacr(mgs) &
17563 ! > -il5(mgs)*ciracr(mgs)
17566 ELSEIF ( warmonly < 0.8 ) THEN
17569 & +(1-il5(mgs))*( &
17570 & -chmlrr(mgs)/rzxh(mgs) &
17571 & -chlmlrr(mgs)/rzxhl(mgs) &
17575 & -crshr(mgs) !null at this point when wet snow/graupel included
17577 & il5(mgs)*( - crfrz(mgs) ) & ! - cipacr(mgs))
17589 ! tmp3d(igs(mgs),jy,kgs(mgs)) = vtxbar(mgs,lr,1) ! crcnw(mgs) ! (pcrwi(mgs) + pcrwd(mgs))
17598 IF ( -pcrwd(mgs)*dtp .gt. cx(mgs,lr) ) THEN
17599 ! write(0,*) 'OUCH! pcrwd(mgs)*dtp .gt. crw(mgs) ',pcrwd(mgs)*dtp,cx(mgs,lr),mgs,igs(mgs),kgs(mgs)
17600 ! write(0,*) -ciacr(mgs)
17601 ! write(0,*) -crfrz(mgs)
17602 ! write(0,*) -chacr(mgs)
17603 ! write(0,*) crcev(mgs)
17604 ! write(0,*) -cracr(mgs)
17606 frac = -cx(mgs,lr)/(pcrwd(mgs)*dtp)
17607 pcrwd(mgs) = -cx(mgs,lr)*dtpinv
17609 ciacr(mgs) = frac*ciacr(mgs)
17610 ciacrf(mgs) = frac*ciacrf(mgs)
17611 ciacrs(mgs) = frac*ciacrs(mgs)
17612 crfrz(mgs) = frac*crfrz(mgs)
17613 crfrzf(mgs) = frac*crfrzf(mgs)
17614 crfrzs(mgs) = frac*crfrzs(mgs)
17615 chacr(mgs) = frac*chacr(mgs)
17616 chlacr(mgs) = frac*chlacr(mgs)
17617 crcev(mgs) = frac*crcev(mgs)
17618 cracr(mgs) = frac*cracr(mgs)
17628 IF ( warmonly < 0.5 ) THEN
17633 IF ( ipconc .ge. 4 ) THEN !
17637 & il5(mgs)*(cscnis(mgs) + cscnvis(mgs) ) &
17638 & + cwfrz2snowfrac*cwfrz(mgs)/cwfrz2snowratio &
17641 IF ( ffrzs > 0.0 ) THEN
17642 pcswi(mgs) = pcswi(mgs) + ffrzs* ( &
17643 & il5(mgs)*cicint(mgs) &
17644 & +il5(mgs)*(cwfrzc(mgs)+cwctfzc(mgs) &
17648 & + csplinter(mgs) + csplinter2(mgs) &
17653 IF ( ess0 < 0.0 ) THEN
17654 csacs(mgs) = Max(0.0, csacs(mgs) - (ifrzs)*(crfrzs(mgs) + ciacrs(mgs)))
17659 & -chacs(mgs) - chlacs(mgs) &
17661 & +(1-il5(mgs))*csmlr(mgs) + csshr(mgs) & ! + csshrp(mgs)
17662 ! > +il5(mgs)*(cssbv(mgs)) &
17667 IF ( imixedphase == 0 ) THEN
17668 IF ( cx(mgs,ls) + dtp*(pcswi(mgs) + pcswd(mgs)) < 0.0 ) THEN
17669 frac = (-cx(mgs,ls) + pcswi(mgs)*dtp)/(pcswd(mgs)*dtp)
17671 pcswd(mgs) = frac*pcswd(mgs)
17673 chacs(mgs) = frac*chacs(mgs)
17674 chlacs(mgs) = frac*chlacs(mgs)
17675 chcns(mgs) = frac*chcns(mgs)
17676 csmlr(mgs) = frac*csmlr(mgs)
17677 csshr(mgs) = frac*csshr(mgs)
17678 cssbv(mgs) = frac*cssbv(mgs)
17679 csacs(mgs) = frac*csacs(mgs)
17686 pccii(mgs) = pccii(mgs) &
17687 & + (1. - ifrzs)*crfrzs(mgs) &
17688 & + (1. - ifrzs)*ciacrs(mgs)
17690 pcswi(mgs) = pcswi(mgs) &
17691 & + (ifrzs)*crfrzs(mgs) &
17692 & + (ifrzs)*ciacrs(mgs)
17701 IF ( ipconc .ge. 5 ) THEN !
17704 & +(ffrzh*ifrzg*crfrzf(mgs) &
17705 & +il5(mgs)*ffrzh*ifiacrg*(ciacrf(mgs) )) &
17706 & + f2h*chcnsh(mgs) + f2h*chcnih(mgs) + chcnhl(mgs)
17709 & (1-il5(mgs))*chmlr(mgs) &
17710 ! > + il5(mgs)*chsbv(mgs) &
17712 & - il5(mgs)*chlcnh(mgs) &
17722 IF ( lhl .gt. 1 .and. lnhl > 1 ) THEN !
17724 pchli(mgs) = (ffrzh*(1.0-ifrzg)*crfrzf(mgs) +il5(mgs)*ffrzh*(1.0-ifiacrg)*(ciacrf(mgs) )) &
17725 & + chlcnhhl(mgs) *rzxhlh(mgs)
17728 & (1-il5(mgs))*chlmlr(mgs) &
17729 ! > + il5(mgs)*chlsbv(mgs) &
17730 & + chlsbv(mgs) - chcnhl(mgs)
17732 IF ( imixedphase == 0 ) THEN
17734 IF ( cx(mgs,lhl) + dtp*(pchli(mgs) + pchld(mgs)) < 0.0 ) THEN
17735 ! rescale depletion
17737 frac = (-cx(mgs,lhl) + pchli(mgs)*dtp)/(pchld(mgs)*dtp)
17739 chlmlr(mgs) = frac*chlmlr(mgs)
17740 chlsbv(mgs) = frac*chlsbv(mgs)
17741 chcnhl(mgs) = frac*chcnhl(mgs)
17743 pchld(mgs) = frac*pchld(mgs)
17753 ENDIF ! (ipconc .ge. 5 )
17755 ELSEIF ( warmonly < 0.8 ) THEN
17760 IF ( ipconc .ge. 5 ) THEN !
17763 & +ifrzg*(crfrzf(mgs) ) ! +il5(mgs)*(ciacrf(mgs) ))
17766 & (1-il5(mgs))*chmlr(mgs) &
17767 & - il5(mgs)*chlcnh(mgs)
17772 IF ( lhl .gt. 1 ) THEN !
17774 pchli(mgs) = (1.0-ifrzg)*(crfrzf(mgs)) & ! +il5(mgs)*(ciacrf(mgs) )) &
17775 & + chlcnhhl(mgs) *rzxhl(mgs)/rzxh(mgs)
17778 & (1-il5(mgs))*chlmlr(mgs) ! &
17779 ! > + il5(mgs)*chlsbv(mgs) &
17782 ! IF ( pchli(mgs) .ne. 0. .or. pchld(mgs) .ne. 0 ) THEN
17783 ! write(0,*) 'dr: pchli,pchld = ', pchli(mgs),pchld(mgs), igs(mgs),kgs(mgs)
17789 ENDIF ! ipconc >= 5
17796 ! Balance and checks for continuity.....within machine precision...
17799 pctot(mgs) = pccwi(mgs) +pccwd(mgs) + &
17800 & pccii(mgs) +pccid(mgs) + &
17801 & pcrwi(mgs) +pcrwd(mgs) + &
17802 & pcswi(mgs) +pcswd(mgs) + &
17803 & pchwi(mgs) +pchwd(mgs) + &
17804 & pchli(mgs) +pchld(mgs)
17808 ENDIF ! ( ipconc .ge. 1 )
17815 ! production terms for mass
17848 IF ( warmonly < 0.5 ) THEN
17851 ! NOTE: ANY CHANGES HERE ALSO NEED TO GO INTO THE RESUM FARTHER DOWN!
17853 & -Min(0.0, qrcev(mgs)) &
17854 & -Min(0.0, qhcev(mgs)) &
17855 & -Min(0.0, qhlcev(mgs)) &
17856 & -Min(0.0, qscev(mgs)) &
17857 ! > +il5(mgs)*(-qhsbv(mgs) - qhlsbv(mgs) ) &
17858 & -qhsbv(mgs) - qhlsbv(mgs) &
17860 & -il5(mgs)*qisbv(mgs)
17863 & -Max(0.0, qrcev(mgs)) &
17864 & -Max(0.0, qhcev(mgs)) &
17865 & -Max(0.0, qhlcev(mgs)) &
17866 & -Max(0.0, qscev(mgs)) &
17867 & +il5(mgs)*(-qiint(mgs) &
17868 & -qhdpv(mgs) -qsdpv(mgs) - qhldpv(mgs)) &
17869 & -il5(mgs)*qidpv(mgs)
17873 ELSEIF ( warmonly < 0.8 ) THEN
17876 & -Min(0.0, qrcev(mgs)) &
17877 & -il5(mgs)*qisbv(mgs)
17879 & +il5(mgs)*(-qiint(mgs) &
17880 ! & -qhdpv(mgs) ) & !- qhldpv(mgs)) &
17881 & -qhdpv(mgs) - qhldpv(mgs)) &
17882 ! & -qhdpv(mgs) -qsdpv(mgs) - qhldpv(mgs)) &
17883 & -Max(0.0, qrcev(mgs)) &
17884 & -il5(mgs)*qidpv(mgs)
17890 & -Min(0.0, qrcev(mgs))
17892 & -Max(0.0, qrcev(mgs))
17901 pqcwi(mgs) = (0.0) + qwcnr(mgs) - qwshw(mgs)
17903 IF ( warmonly < 0.5 ) THEN
17905 & il5(mgs)*(-qiacw(mgs)-qwfrz(mgs)-qwctfz(mgs)) &
17906 & -il5(mgs)*(qiihr(mgs)) &
17907 & -qracw(mgs) -qsacw(mgs) -qrcnw(mgs) -qhacw(mgs) - qhlacw(mgs) !&
17908 ! & -il5(mgs)*(qwfrzp(mgs))
17909 ELSEIF ( warmonly < 0.8 ) THEN
17911 & il5(mgs)*(-qiacw(mgs)-qwfrz(mgs)-qwctfz(mgs)) &
17912 & -il5(mgs)*(qiihr(mgs)) &
17913 & -qracw(mgs) -qrcnw(mgs) -qhacw(mgs) -qhlacw(mgs)
17916 & -qracw(mgs) - qrcnw(mgs)
17920 IF ( pqcwd(mgs) .lt. 0.0 .and. -pqcwd(mgs)*dtp .gt. qx(mgs,lc) ) THEN
17922 frac = -Max(0.0,qx(mgs,lc))/(pqcwd(mgs)*dtp)
17923 pqcwd(mgs) = -qx(mgs,lc)*dtpinv
17925 qiacw(mgs) = frac*qiacw(mgs)
17926 ! qwfrzp(mgs) = frac*qwfrzp(mgs)
17927 ! qwctfzp(mgs) = frac*qwctfzp(mgs)
17928 qwfrzc(mgs) = frac*qwfrzc(mgs)
17929 qwfrz(mgs) = frac*qwfrz(mgs)
17930 qwctfzc(mgs) = frac*qwctfzc(mgs)
17931 qwctfz(mgs) = frac*qwctfz(mgs)
17932 qracw(mgs) = frac*qracw(mgs)
17933 qsacw(mgs) = frac*qsacw(mgs)
17934 qhacw(mgs) = frac*qhacw(mgs)
17935 vhacw(mgs) = frac*vhacw(mgs)
17936 qrcnw(mgs) = frac*qrcnw(mgs)
17937 qwfrzp(mgs) = frac*qwfrzp(mgs)
17938 IF ( lhl .gt. 1 ) THEN
17939 qhlacw(mgs) = frac*qhlacw(mgs)
17940 vhlacw(mgs) = frac*vhlacw(mgs)
17942 ! IF ( lzh .gt. 1 ) zhacw(mgs) = frac*zhacw(mgs)
17952 IF ( warmonly < 0.5 ) THEN
17955 IF ( ffrzs < 1.0 ) THEN
17957 & il5(mgs)*qicicnt(mgs) &
17958 & +il5(mgs)*((1.0-cwfrz2snowfrac)*qwfrzc(mgs)+qwctfzc(mgs)) &
17959 & +il5(mgs)*(qicichr(mgs)) &
17961 & +qhmul1(mgs) + qhlmul1(mgs) &
17962 & + qsplinter(mgs) + qsplinter2(mgs)
17963 ! > + cimas0*nsplinter*(crfrzf(mgs) + crfrz(mgs))/rho0(mgs)
17966 pqcii(mgs) = pqcii(mgs)*(1.0 - ffrzs) &
17967 & +il5(mgs)*qidpv(mgs) &
17968 & +il5(mgs)*qiacw(mgs)
17971 & il5(mgs)*(-qscni(mgs) - qscnvi(mgs) & ! -qwaci(mgs) &
17976 & +il5(mgs)*qisbv(mgs) &
17977 & +(1.-il5(mgs))*qimlr(mgs) &
17982 ELSEIF ( warmonly < 0.8 ) THEN
17986 & il5(mgs)*qicicnt(mgs)*(1. - ffrzs) &
17987 & +il5(mgs)*((1.0-cwfrz2snowfrac)*qwfrzc(mgs)+qwctfzc(mgs))*(1. - ffrzs) &
17988 & +il5(mgs)*(qicichr(mgs))*(1. - ffrzs) &
17989 ! & +il5(mgs)*(qicichr(mgs)) &
17991 & +qhmul1(mgs) + qhlmul1(mgs) &
17992 & + qsplinter(mgs) + qsplinter2(mgs) &
17993 & +il5(mgs)*qidpv(mgs) &
17994 & +il5(mgs)*qiacw(mgs) ! & ! (qiacwi(mgs)+qwacii(mgs)) &
17995 ! & +il5(mgs)*(qwfrzc(mgs)+qwctfzc(mgs)) &
17996 ! & +il5(mgs)*(qicichr(mgs)) &
17998 ! & +qhmul1(mgs) + qhlmul1(mgs) &
17999 ! & + qsplinter(mgs) + qsplinter2(mgs)
18002 ! & il5(mgs)*(-qscni(mgs) - qscnvi(mgs) & ! -qwaci(mgs) &
18004 ! & -qsaci(mgs) ) &
18007 & +il5(mgs)*qisbv(mgs) &
18008 & +(1.-il5(mgs))*qimlr(mgs) ! &
18018 IF ( warmonly < 0.5 ) THEN
18020 & qracw(mgs) + qrcnw(mgs) + Max(0.0, qrcev(mgs)) &
18021 & +(1-il5(mgs))*( &
18022 & -qhmlr(mgs) & !null at this point when wet snow/graupel included
18023 & -qsmlr(mgs) - qhlmlr(mgs) &
18025 ! & -qsshr(mgs) & !null at this point when wet snow/graupel included
18026 ! & -qhshr(mgs) & !null at this point when wet snow/graupel included
18031 & il5(mgs)*(-qiacr(mgs)-qrfrz(mgs)) &
18032 & - qsacr(mgs) - qhacr(mgs) - qhlacr(mgs) - qwcnr(mgs) &
18033 & + Min(0.0,qrcev(mgs))
18034 ELSEIF ( warmonly < 0.8 ) THEN
18036 & qracw(mgs) + qrcnw(mgs) + Max(0.0, qrcev(mgs)) &
18037 & +(1-il5(mgs))*( &
18038 & -qhlmlr(mgs) & !null at this point when wet snow/graupel included
18039 & -qhmlr(mgs) ) & !null at this point when wet snow/graupel included
18040 & -qhshr(mgs) & !null at this point when wet snow/graupel included
18041 & -qhlshr(mgs) !null at this point when wet snow/graupel included
18043 & il5(mgs)*(-qrfrz(mgs)) &
18046 & + Min(0.0,qrcev(mgs))
18049 & qracw(mgs) + qrcnw(mgs) + Max(0.0, qrcev(mgs))
18050 pqrwd(mgs) = Min(0.0,qrcev(mgs))
18054 ! IF ( pqrwd(mgs) .lt. 0.0 .and. -(pqrwd(mgs) + pqrwi(mgs))*dtp .gt. qx(mgs,lr) ) THEN
18055 IF ( pqrwd(mgs) .lt. 0.0 .and. -(pqrwd(mgs) + pqrwi(mgs))*dtp .gt. qx(mgs,lr) ) THEN
18057 frac = (-qx(mgs,lr) + pqrwi(mgs)*dtp)/(pqrwd(mgs)*dtp)
18058 ! pqrwd(mgs) = -qx(mgs,lr)*dtpinv + pqrwi(mgs)
18060 pqwvi(mgs) = pqwvi(mgs) &
18061 & + Min(0.0, qrcev(mgs)) &
18062 & - frac*Min(0.0, qrcev(mgs))
18063 pqwvd(mgs) = pqwvd(mgs) &
18064 & + Max(0.0, qrcev(mgs)) &
18065 & - frac*Max(0.0, qrcev(mgs))
18067 qiacr(mgs) = frac*qiacr(mgs)
18068 qiacrf(mgs) = frac*qiacrf(mgs)
18069 qiacrs(mgs) = frac*qiacrs(mgs)
18070 viacrf(mgs) = frac*viacrf(mgs)
18071 qrfrz(mgs) = frac*qrfrz(mgs)
18072 qrfrzs(mgs) = frac*qrfrzs(mgs)
18073 qrfrzf(mgs) = frac*qrfrzf(mgs)
18074 vrfrzf(mgs) = frac*vrfrzf(mgs)
18075 qsacr(mgs) = frac*qsacr(mgs)
18076 qhacr(mgs) = frac*qhacr(mgs)
18077 vhacr(mgs) = frac*vhacr(mgs)
18078 qrcev(mgs) = frac*qrcev(mgs)
18079 qhlacr(mgs) = frac*qhlacr(mgs)
18080 vhlacr(mgs) = frac*vhlacr(mgs)
18081 ! qhcev(mgs) = frac*qhcev(mgs)
18084 IF ( warmonly < 0.5 ) THEN
18086 & il5(mgs)*(-qiacr(mgs)-qrfrz(mgs) - qsacr(mgs)) &
18087 & - qhacr(mgs) - qhlacr(mgs) - qwcnr(mgs) &
18088 & + Min(0.0,qrcev(mgs))
18089 ELSEIF ( warmonly < 0.8 ) THEN
18091 & il5(mgs)*(-qrfrz(mgs)) &
18094 & + Min(0.0,qrcev(mgs))
18096 pqrwd(mgs) = Min(0.0,qrcev(mgs))
18100 ! Resum for vapor since qrcev has changed
18102 IF ( qrcev(mgs) .ne. 0.0 ) THEN
18104 & -Min(0.0, qrcev(mgs)) &
18105 & -Min(0.0, qhcev(mgs)) &
18106 & -Min(0.0, qhlcev(mgs)) &
18107 & -Min(0.0, qscev(mgs)) &
18108 ! > +il5(mgs)*(-qhsbv(mgs) - qhlsbv(mgs) ) &
18109 & -qhsbv(mgs) - qhlsbv(mgs) &
18111 & -il5(mgs)*qisbv(mgs)
18114 & -Max(0.0, qrcev(mgs)) &
18115 & -Max(0.0, qhcev(mgs)) &
18116 & -Max(0.0, qhlcev(mgs)) &
18117 & -Max(0.0, qscev(mgs)) &
18118 & +il5(mgs)*(-qiint(mgs) &
18119 & -qhdpv(mgs) -qsdpv(mgs) - qhldpv(mgs)) &
18120 & -il5(mgs)*qidpv(mgs)
18129 IF ( warmonly < 0.5 ) THEN
18136 & il5(mgs)*(qscni(mgs)+qsaci(mgs)+qsdpv(mgs) &
18138 & + ifrzs*(qiacrs(mgs) + qrfrzs(mgs)) &
18139 & + il5(mgs)*(( qwfrzc(mgs) + qwctfzc(mgs) + qicichr(mgs) )*ffrzs &
18140 & + (1.0 - ffrzs)*cwfrz2snowfrac*qwfrz(mgs) ) &
18141 & + il2(mgs)*qsacr(mgs)) &
18142 & + il5(mgs)*qicicnt(mgs)*ffrzs &
18143 & + il3(mgs)*(qiacrf(mgs)+qracif(mgs)) & ! only applies for ipconc <= 3
18144 & + Max(0.0, qscev(mgs)) &
18145 & + qsacw(mgs) + qscnh(mgs) &
18146 & + ffrzs*(qsmul(mgs) &
18147 & +qhmul1(mgs) + qhlmul1(mgs) &
18148 & + qsplinter(mgs) + qsplinter2(mgs))
18150 ! > -qfacs(mgs) ! -qwacs(mgs) &
18151 & -qracs(mgs)*(1-il2(mgs)) -qhacs(mgs) - qhlacs(mgs) &
18153 & +(1-il5(mgs))*qsmlr(mgs) + qsshr(mgs) & !null at this point when wet snow included
18154 ! > +il5(mgs)*(qssbv(mgs)) &
18156 & + Min(0.0, qscev(mgs)) &
18160 IF ( imixedphase == 0 .and. pqswd(mgs) .lt. 0.0 ) THEN
18161 IF ( qx(mgs,ls) + dtp*(pqswi(mgs) + pqswd(mgs)) < 0.0 ) THEN
18162 frac = (-qx(mgs,ls) + pqswi(mgs)*dtp)/(pqswd(mgs)*dtp)
18164 pqswd(mgs) = frac*pqswd(mgs)
18166 qracs(mgs) = frac*qracs(mgs) ! only used for single moment at this time
18167 qhacs(mgs) = frac*qhacs(mgs)
18168 qhlacs(mgs) = frac*qhlacs(mgs)
18169 qhcns(mgs) = frac*qhcns(mgs)
18170 qsmlr(mgs) = frac*qsmlr(mgs)
18171 qsshr(mgs) = frac*qsshr(mgs)
18172 qssbv(mgs) = frac*qssbv(mgs)
18173 qsmul(mgs) = frac*qsmul(mgs)
18174 IF ( qscev(mgs) < 0.0 ) qscev(mgs) = frac*qscev(mgs)
18179 pqcii(mgs) = pqcii(mgs) &
18180 & + (1. - ifrzs)*qrfrzs(mgs) &
18181 & + (1. - ifrzs)*qiacrs(mgs)
18190 & +il5(mgs)*(ffrzh*ifrzg*qrfrzf(mgs) + (1-il3(mgs))*ffrzh*ifiacrg*(qiacrf(mgs)+qracif(mgs))) &
18191 & + (1-il2(mgs))*(qracs(mgs) + qsacr(mgs)) & ! only used for ipconc < 3
18192 & +il5(mgs)*(qhdpv(mgs)) &
18193 & +Max(0.0, qhcev(mgs)) &
18194 & +qhacr(mgs)+qhacw(mgs) &
18195 & +qhacs(mgs)+qhaci(mgs) &
18196 & + f2h*qhcns(mgs) + f2h*qhcni(mgs) + qhcnhl(mgs)
18198 & qhshr(mgs) & !null at this point when wet graupel included
18199 & +(1-il5(mgs))*qhmlr(mgs) & !null at this point when wet graupel included
18200 ! > +il5(mgs)*qhsbv(mgs) &
18202 & + Min(0.0, qhcev(mgs)) &
18203 & -qhmul1(mgs) - qhlcnh(mgs) - qscnh(mgs) &
18204 & - ffrzh*(qsplinter(mgs) + qsplinter2(mgs))
18205 ! > - cimas0*nsplinter*(crfrzf(mgs) + crfrz(mgs))/rho0(mgs)
18213 IF ( lhl .gt. 1 ) THEN
18217 & +il5(mgs)*(qhldpv(mgs) + ((1.0-ifrzg)*qrfrzf(mgs) + (1.0-ifiacrg)*(qiacrf(mgs)+ qracif(mgs)))) &
18218 & +Max(0.0, qhlcev(mgs)) &
18219 & +qhlacr(mgs)+qhlacw(mgs) &
18220 & +qhlacs(mgs)+qhlaci(mgs) &
18224 & +(1-il5(mgs))*qhlmlr(mgs) &
18225 ! > +il5(mgs)*qhlsbv(mgs) &
18227 & + Min(0.0, qhlcev(mgs)) &
18228 & -qhlmul1(mgs) - qhcnhl(mgs)
18230 IF ( imixedphase == 0 ) THEN
18232 IF ( qx(mgs,lhl) + dtp*(pqhli(mgs) + pqhld(mgs)) < 0.0 ) THEN
18233 ! rescale depletion
18235 frac = (-qx(mgs,lhl) + pqhli(mgs)*dtp)/(pqhld(mgs)*dtp)
18237 qhlmlr(mgs) = frac*qhlmlr(mgs)
18238 qhlsbv(mgs) = frac*qhlsbv(mgs)
18239 qhcnhl(mgs) = frac*qhcnhl(mgs)
18240 qhlmul1(mgs) = frac*qhlmul1(mgs)
18241 IF ( qhlcev(mgs) < 0.0 ) qhlcev(mgs) = frac*qhlcev(mgs)
18243 pqhld(mgs) = frac*pqhld(mgs)
18253 ELSEIF ( warmonly < 0.8 ) THEN
18259 & +il5(mgs)*ifrzg*(qrfrzf(mgs) ) &
18260 & +il5(mgs)*(qhdpv(mgs)) &
18261 & +qhacr(mgs)+qhacw(mgs)
18263 & qhshr(mgs) & !null at this point when wet graupel included
18266 & - qsplinter(mgs) - qsplinter2(mgs) &
18267 & +(1-il5(mgs))*qhmlr(mgs) !null at this point when wet graupel included
18273 IF ( lhl .gt. 1 ) THEN
18277 & +il5(mgs)*(qhldpv(mgs) ) & ! + (1.0-ifrzg)*(qiacrf(mgs)+qrfrzf(mgs) + qracif(mgs))) &
18278 & +il5(mgs)*(1.0-ifrzg)*(qrfrzf(mgs) ) &
18279 & +qhlacr(mgs)+qhlacw(mgs) &
18280 ! & +qhlacs(mgs)+qhlaci(mgs) &
18284 & +(1-il5(mgs))*qhlmlr(mgs) &
18285 ! > +il5(mgs)*qhlsbv(mgs) &
18287 & -qhlmul1(mgs) - qhcnhl(mgs)
18296 ! Liquid water on snow and graupel
18304 IF ( mixedphase ) THEN
18305 ELSE ! set arrays for non-mixedphase graupel
18308 vhmlr(:) = qhmlr(:) ! not actually volume, but treated as q in rate equation
18312 vhlmlr(:) = qhlmlr(:) ! not actually volume, but treated as q in rate equation
18313 ! vhlmlr(:) = rho0(:)*qhlmlr(:)/xdn(:,lhl)
18323 IF ( lvol(ls) .gt. 1 ) THEN
18325 ! pvswi(mgs) = rho0(mgs)*( pqswi(mgs) )/xdn0(ls)
18327 pvswi(mgs) = rho0(mgs)*( &
18328 !aps > il5*qsfzs(mgs)/xdn(mgs,ls) &
18329 !aps > -il5*qsfzs(mgs)/xdn(mgs,lr) &
18330 & +il5(mgs)*(qscni(mgs)+qsaci(mgs)+qsdpv(mgs) &
18331 & + qscnvi(mgs) + (1. - ifrzs)*qiacrs(mgs) &
18332 & + (1. - ifrzs)*qrfrzs(mgs) &
18334 & + (qsacr(mgs))/rimdn(mgs,ls) ) + vsacw(mgs)
18335 ! > + (qsacw(mgs) + qsacr(mgs))/rimdn(mgs,ls) )
18336 pvswd(mgs) = rho0(mgs)*( pqswd(mgs) )/xdn0(ls) &
18339 ! > +(1-il5(mgs))*qsmlr(mgs) + qsshr(mgs)
18340 ! > +il5(mgs)*(qssbv(mgs))
18341 & -rho0(mgs)*qsmul(mgs)/xdn0(ls)
18342 !aps > +rho0(mgs)*(1-il5(mgs))*(
18343 !aps > qsmlr(mgs)/xdn(mgs,ls)
18344 !aps > +(qscev-qsmlr(mgs))/xdn(mgs,lr) )
18347 !aps IF (mixedphase) THEN
18348 !aps pvswd(mgs) = pvswd(mgs)
18349 !aps > + rho0(mgs)*qsshr(mgs)/xdn(mgs,lr)
18356 IF ( lvol(lh) .gt. 1 ) THEN
18358 ! pvhwi(mgs) = rho0(mgs)*( (pqhwi(mgs) )/xdn0(lh) )
18360 ! pvhwi(mgs) = rho0(mgs)*( (pqhwi(mgs) - il5(mgs)*qrfrzf(mgs) )/xdn0(lh) !
18361 ! : + il5(mgs)*qrfrzf(mgs)/rhofrz )
18363 pvhwi(mgs) = rho0(mgs)*( &
18364 & +il5(mgs)*( ifiacrg*ffrzh*qracif(mgs))/rhofrz &
18365 !erm > + il5(mgs)*qhfzh(mgs)/rhofrz !aps: or use xdnmx(lh)? &
18366 & + ( il5(mgs)*qhdpv(mgs)/qhdpvdn &
18367 & + (qhacs(mgs) + qhaci(mgs))/qhacidn ) ) &
18368 & + rho0(mgs)*Max(0.0, qhcev(mgs))/1000. & ! only used in mixed phase: evaporation/condensation of liquid water coating
18369 ! > + qhacs(mgs) + qhaci(mgs) )/xdn0(ls) ) &
18370 & + f2h*vhcns(mgs) &
18371 & + vhacr(mgs) + vhacw(mgs) + vhfzh(mgs) & ! qhacw(mgs)/rimdn(mgs,lh)
18373 & + f2h*vhcni(mgs) + (ifiacrg*viacrf(mgs) + ifrzg*vrfrzf(mgs))*ffrzh
18374 ! > +qhacr(mgs)/raindn(mgs,lh) + qhacw(mgs)/rimdn(mgs,lh)
18376 ! pvhwd(mgs) = rho0(mgs)*(pqhwd(mgs) )/xdn0(lh)
18378 pvhwd(mgs) = rho0(mgs)*( &
18379 ! > qhshr(mgs)/xdn0(lr) &
18380 ! > - il5(mgs)*qhfzh(mgs)/xdn(mgs,lr) &
18381 & +( (1-il5(mgs))*vhmlr(mgs) &
18382 ! > +il5(mgs)*qhsbv(mgs) &
18384 & + Min(0.0, qhcev(mgs)) &
18385 & -qhmul1(mgs) )/xdn(mgs,lh) ) &
18386 & - vhlcnh(mgs) + vhshdr(mgs) - vhsoak(mgs) - vscnh(mgs)
18388 ! IF (mixedphase) THEN
18389 ! pvhwd(mgs) = pvhwd(mgs)
18390 ! > + rho0(mgs)*qhshr(mgs)/xdn(mgs,lh) !xdn(mgs,lr)
18393 IF ( .false. .and. ny .eq. 2 .and. kgs(mgs) .eq. 9 .and. igs(mgs) .eq. 19 ) THEN
18396 write(iunit,*) 'Graupel at ',igs(mgs),kgs(mgs)
18398 write(iunit,*) il5(mgs)*qrfrzf(mgs), qrfrzf(mgs) - qrfrz(mgs)
18399 write(iunit,*) il5(mgs)*qiacrf(mgs)
18400 write(iunit,*) il5(mgs)*qracif(mgs)
18401 write(iunit,*) 'qhcns',qhcns(mgs)
18402 write(iunit,*) 'qhcni',qhcni(mgs)
18403 write(iunit,*) il5(mgs)*(qhdpv(mgs))
18404 write(iunit,*) 'qhacr ',qhacr(mgs)
18405 write(iunit,*) 'qhacw', qhacw(mgs)
18406 write(iunit,*) 'qhacs', qhacs(mgs)
18407 write(iunit,*) 'qhaci', qhaci(mgs)
18408 write(iunit,*) 'pqhwi = ',pqhwi(mgs)
18410 write(iunit,*) 'qhcev',qhcev(mgs)
18412 write(iunit,*) 'qhshr',qhshr(mgs)
18413 write(iunit,*) 'qhmlr', (1-il5(mgs))*qhmlr(mgs)
18414 write(iunit,*) 'qhsbv', qhsbv(mgs)
18415 write(iunit,*) 'qhlcnh',-qhlcnh(mgs)
18416 write(iunit,*) 'qhmul1',-qhmul1(mgs)
18417 write(iunit,*) 'pqhwd = ', pqhwd(mgs)
18419 write(iunit,*) 'Volume'
18421 write(iunit,*) 'pvhwi',pvhwi(mgs)
18422 write(iunit,*) 'vhcns', vhcns(mgs)
18423 write(iunit,*) 'vhacr,vhacw',vhacr(mgs), vhacw(mgs) ! qhacw(mgs)/rimdn(mgs,lh)
18424 write(iunit,*) 'vhcni',vhcni(mgs)
18426 write(iunit,*) 'pvhwd',pvhwd(mgs)
18427 write(iunit,*) 'vhlcnh,vhshdr,vhsoak ', vhlcnh(mgs), vhshdr(mgs), vhsoak(mgs)
18428 write(iunit,*) 'vhmlr', vhmlr(mgs)
18433 write(iunit,*) 'Concentration'
18434 write(iunit,*) pchwi(mgs),pchwd(mgs)
18435 write(iunit,*) crfrzf(mgs)
18436 write(iunit,*) chcns(mgs)
18437 write(iunit,*) ciacrf(mgs)
18453 IF ( lhl .gt. 1 ) THEN
18454 IF ( lvol(lhl) .gt. 1 ) THEN
18457 pvhli(mgs) = rho0(mgs)*( &
18458 & + ( il5(mgs)*(((1.0-ifiacrg)*ffrzh*qracif(mgs))/rhofrz + qhldpv(mgs) ) &
18459 ! & + Max(0.0, qhlcev(mgs)) &
18460 ! & + qhlacs(mgs) + qhlaci(mgs) )/xdnmn(lhl) ) & ! xdn0(ls) ) &
18461 ! & + qhlacs(mgs) + qhlaci(mgs) )/xdnmn(lh) ) & ! yes, this is 'lh' on purpose
18462 & + qhlacs(mgs) + qhlaci(mgs) )/500. ) & ! changed to 500 instead of min graupel density to keep hail density from dropping too much
18463 & + rho0(mgs)*Max(0.0, qhlcev(mgs))/1000. &
18464 & + vhlcnhl(mgs) + ((1.0-ifiacrg)*ffrzh*viacrf(mgs) + (1.0-ifrzg)*ffrzh*vrfrzf(mgs)) &
18465 & + vhlacr(mgs) + vhlacw(mgs) + vhlfzhl(mgs) ! qhlacw(mgs)/rimdn(mgs,lhl)
18467 pvhld(mgs) = rho0(mgs)*( &
18469 & + Min(0.0, qhlcev(mgs)) &
18470 & -qhlmul1(mgs) )/xdn(mgs,lhl) ) &
18471 ! & + vhlmlr(mgs) &
18472 & + rho0(mgs)*(1-il5(mgs))*vhlmlr(mgs)/xdn(mgs,lhl) &
18473 & + vhlshdr(mgs) - vhlsoak(mgs)
18482 if ( ndebug .ge. 1 ) then
18486 ptotal(mgs) = ptotal(mgs) &
18487 & + pqwvi(mgs) + pqwvd(mgs) &
18488 & + pqcwi(mgs) + pqcwd(mgs) &
18489 & + pqcii(mgs) + pqcid(mgs) &
18490 & + pqrwi(mgs) + pqrwd(mgs) &
18491 & + pqswi(mgs) + pqswd(mgs) &
18492 & + pqhwi(mgs) + pqhwd(mgs) &
18493 & + pqhli(mgs) + pqhld(mgs)
18502 if ( ( (ndebug .ge. 0 ) .and. abs(ptotal(mgs)) .gt. eqtot ) &
18503 ! if ( ( abs(ptotal(mgs)) .gt. eqtot )
18504 ! : .or. pqswi(mgs)*dtp .gt. 1.e-3
18505 ! : .or. pqhwi(mgs)*dtp .gt. 1.e-3
18506 ! : .or. dtp*(pqrwi(mgs)+pqrwd(mgs)) .gt. 10.0e-3
18507 ! : .or. dtp*(pccii(mgs)+pccid(mgs)) .gt. 1.e7
18508 ! : .or. dtp*(pcipi(mgs)+pcipd(mgs)) .gt. 1.e7 &
18509 & .or. .not. (ptotal(mgs) .lt. 1.0 .and. ptotal(mgs) .gt. -1.0) & ! this line is basically checking for NaNs
18511 write(iunit,*) 'YIKES! ','ptotal1',mgs,igs(mgs),jgs, &
18512 & kgs(mgs),ptotal(mgs)
18514 write(iunit,*) 't7: ', t7(igs(mgs),jgs,kgs(mgs))
18515 write(iunit,*) 'cci,ccw,crw,rdia: ',cx(mgs,li),cx(mgs,lc),cx(mgs,lr),0.5*xdia(mgs,lr,1)
18516 write(iunit,*) 'qc,qi,qr : ',qx(mgs,lc),qx(mgs,li),qx(mgs,lr)
18517 write(iunit,*) 'rmas, qrcalc : ',xmas(mgs,lr),xmas(mgs,lr)*cx(mgs,lr)/rho0(mgs)
18518 write(iunit,*) 'vti,vtc,eiw,vtr: ',vtxbar(mgs,li,1),vtxbar(mgs,lc,1),eiw(mgs),vtxbar(mgs,lr,1)
18519 write(iunit,*) 'cidia,cwdia,qcmxd: ', xdia(mgs,li,1),xdia(mgs,lc,1),qcmxd(mgs)
18520 write(iunit,*) 'snow: ',qx(mgs,ls),cx(mgs,ls),swvent(mgs),vtxbar(mgs,ls,1),xdia(mgs,ls,1)
18521 write(iunit,*) 'graupel: ',qx(mgs,lh),cx(mgs,lh),hwvent(mgs),vtxbar(mgs,lh,1),xdia(mgs,lh,1)
18522 IF ( lhl .gt. 1 ) write(iunit,*) 'hail: ',qx(mgs,lhl),cx(mgs,lhl),hlvent(mgs),vtxbar(mgs,lhl,1),xdia(mgs,lhl,1)
18525 write(iunit,*) 'li: ',xdia(mgs,li,1),xdia(mgs,li,2),xmas(mgs,li),qx(mgs,li), &
18529 write(iunit,*) 'rain cx,xv : ',cx(mgs,lr),xv(mgs,lr)
18530 write(iunit,*) 'temcg = ', temcg(mgs)
18532 write(iunit,*) 'v ', pqwvi(mgs) ,pqwvd(mgs)
18533 write(iunit,*) 'c ', pqcwi(mgs) ,pqcwd(mgs)
18534 write(iunit,*) 'ci', pqcii(mgs) ,pqcid(mgs)
18535 write(iunit,*) 'r ', pqrwi(mgs) ,pqrwd(mgs)
18536 write(iunit,*) 's ', pqswi(mgs) ,pqswd(mgs)
18537 write(iunit,*) 'h ', pqhwi(mgs) ,pqhwd(mgs)
18538 write(iunit,*) 'hl', pqhli(mgs) ,pqhld(mgs)
18539 tmp = pqwvi(mgs) + pqwvd(mgs) &
18540 & + pqcwi(mgs) + pqcwd(mgs) &
18541 & + pqcii(mgs) + pqcid(mgs) &
18542 & + pqrwi(mgs) + pqrwd(mgs) &
18543 & + pqswi(mgs) + pqswd(mgs) &
18544 & + pqhwi(mgs) + pqhwd(mgs) &
18545 & + pqhli(mgs) + pqhld(mgs)
18547 write(iunit,*) 'total = ',tmp
18548 write(iunit,*) 'END OF OUTPUT OF SOURCE AND SINK'
18551 ! print production terms
18554 write(iunit,*) 'Vapor'
18556 write(iunit,*) -Min(0.0,qrcev(mgs))
18557 write(iunit,*) -il5(mgs)*qhsbv(mgs)
18558 write(iunit,*) -il5(mgs)*qhlsbv(mgs)
18559 write(iunit,*) -il5(mgs)*qssbv(mgs)
18560 write(iunit,*) -il5(mgs)*qisbv(mgs)
18561 write(iunit,*) 'pqwvi= ', pqwvi(mgs)
18562 write(iunit,*) -Max(0.0,qrcev(mgs))
18563 write(iunit,*) -Max(0.0,qhcev(mgs))
18564 write(iunit,*) -Max(0.0,qhlcev(mgs))
18565 write(iunit,*) -Max(0.0,qscev(mgs))
18566 write(iunit,*) -il5(mgs)*qiint(mgs)
18567 write(iunit,*) -il5(mgs)*qhdpv(mgs)
18568 write(iunit,*) -il5(mgs)*qhldpv(mgs)
18569 write(iunit,*) -il5(mgs)*qsdpv(mgs)
18570 write(iunit,*) -il5(mgs)*qidpv(mgs)
18571 write(iunit,*) 'pqwvd = ', pqwvd(mgs)
18574 write(iunit,*) 'Cloud ice'
18576 write(iunit,*) il5(mgs)*qicicnt(mgs)
18577 write(iunit,*) il5(mgs)*qidpv(mgs)
18578 write(iunit,*) il5(mgs)*qiacw(mgs)
18579 write(iunit,*) il5(mgs)*qwfrzc(mgs)
18580 write(iunit,*) il5(mgs)*qwctfzc(mgs)
18581 write(iunit,*) il5(mgs)*qicichr(mgs)
18582 write(iunit,*) qhmul1(mgs)
18583 write(iunit,*) qhlmul1(mgs)
18584 write(iunit,*) 'pqcii = ', pqcii(mgs)
18585 write(iunit,*) -il5(mgs)*qscni(mgs)
18586 write(iunit,*) -il5(mgs)*qscnvi(mgs)
18587 write(iunit,*) -il5(mgs)*qraci(mgs)
18588 write(iunit,*) -il5(mgs)*qsaci(mgs)
18589 write(iunit,*) -il5(mgs)*qhaci(mgs)
18590 write(iunit,*) -il5(mgs)*qhlaci(mgs)
18591 write(iunit,*) il5(mgs)*qisbv(mgs)
18592 write(iunit,*) (1.-il5(mgs))*qimlr(mgs)
18593 write(iunit,*) -il5(mgs)*qhcni(mgs)
18594 write(iunit,*) 'pqcid = ', pqcid(mgs)
18595 write(iunit,*) ' Conc:'
18596 write(iunit,*) pccii(mgs),pccid(mgs)
18597 write(iunit,*) il5(mgs),cicint(mgs)
18598 write(iunit,*) cwfrzc(mgs),cwctfzc(mgs)
18599 write(iunit,*) cicichr(mgs)
18600 write(iunit,*) chmul1(mgs)
18601 write(iunit,*) chlmul1(mgs)
18602 write(iunit,*) csmul(mgs)
18608 write(iunit,*) 'Cloud water'
18610 write(iunit,*) 'pqcwi =', pqcwi(mgs)
18611 write(iunit,*) -il5(mgs)*qiacw(mgs)
18612 write(iunit,*) -il5(mgs)*qwfrzc(mgs)
18613 write(iunit,*) -il5(mgs)*qwctfzc(mgs)
18614 ! write(iunit,*) -il5(mgs)*qwfrzp(mgs)
18615 ! write(iunit,*) -il5(mgs)*qwctfzp(mgs)
18616 write(iunit,*) -il5(mgs)*qiihr(mgs)
18617 write(iunit,*) -il5(mgs)*qicichr(mgs)
18618 write(iunit,*) -il5(mgs)*qipiphr(mgs)
18619 write(iunit,*) -qracw(mgs)
18620 write(iunit,*) -qsacw(mgs)
18621 write(iunit,*) -qrcnw(mgs)
18622 write(iunit,*) -qhacw(mgs)
18623 write(iunit,*) -qhlacw(mgs)
18624 write(iunit,*) 'pqcwd = ', pqcwd(mgs)
18628 write(iunit,*) 'Concentration:'
18629 write(iunit,*) -cautn(mgs)
18630 write(iunit,*) -cracw(mgs)
18631 write(iunit,*) -csacw(mgs)
18632 write(iunit,*) -chacw(mgs)
18633 write(iunit,*) -ciacw(mgs)
18634 write(iunit,*) -cwfrzp(mgs)
18635 write(iunit,*) -cwctfzp(mgs)
18636 write(iunit,*) -cwfrzc(mgs)
18637 write(iunit,*) -cwctfzc(mgs)
18638 write(iunit,*) pccwd(mgs)
18641 write(iunit,*) 'Rain '
18643 write(iunit,*) qracw(mgs)
18644 write(iunit,*) qrcnw(mgs)
18645 write(iunit,*) Max(0.0, qrcev(mgs))
18646 write(iunit,*) -(1-il5(mgs))*qhmlr(mgs)
18647 write(iunit,*) -(1-il5(mgs))*qhlmlr(mgs)
18648 write(iunit,*) -(1-il5(mgs))*qsmlr(mgs)
18649 write(iunit,*) -(1-il5(mgs))*qimlr(mgs)
18650 write(iunit,*) -qrshr(mgs)
18651 write(iunit,*) 'pqrwi = ', pqrwi(mgs)
18652 write(iunit,*) -qsshr(mgs)
18653 write(iunit,*) -qhshr(mgs)
18654 write(iunit,*) -qhlshr(mgs)
18655 write(iunit,*) -il5(mgs)*qiacr(mgs),qiacr(mgs), qiacrf(mgs)
18656 write(iunit,*) -il5(mgs)*qrfrz(mgs)
18657 write(iunit,*) -qsacr(mgs)
18658 write(iunit,*) -qhacr(mgs)
18659 write(iunit,*) -qhlacr(mgs)
18660 write(iunit,*) qrcev(mgs)
18661 write(iunit,*) 'pqrwd = ', pqrwd(mgs)
18662 write(iunit,*) 'qrzfac = ', qrzfac(mgs)
18666 write(iunit,*) 'Rain concentration'
18667 write(iunit,*) pcrwi(mgs)
18668 write(iunit,*) crcnw(mgs)
18669 write(iunit,*) 1-il5(mgs)
18670 write(iunit,*) -chmlr(mgs),-csmlr(mgs)
18671 write(iunit,*) -crshr(mgs)
18672 write(iunit,*) pcrwd(mgs)
18673 write(iunit,*) il5(mgs)
18674 write(iunit,*) -ciacr(mgs),-crfrz(mgs)
18675 write(iunit,*) -csacr(mgs),-chacr(mgs)
18676 write(iunit,*) +crcev(mgs)
18677 write(iunit,*) cracr(mgs)
18678 ! write(iunit,*) -il5(mgs)*ciracr(mgs)
18682 write(iunit,*) 'Snow'
18684 write(iunit,*) il5(mgs)*qscni(mgs), qscnvi(mgs)
18685 write(iunit,*) il5(mgs)*qsaci(mgs)
18686 write(iunit,*) il5(mgs)*qrfrzs(mgs)
18687 write(iunit,*) il5(mgs)*qiacrs(mgs),il3(mgs)*(qiacrf(mgs)+qracif(mgs)),il3(mgs),qiacrf(mgs),qracif(mgs)
18688 write(iunit,*) il5(mgs)*qsdpv(mgs), qscev(mgs)
18689 write(iunit,*) qsacw(mgs)
18690 write(iunit,*) qsacr(mgs), qscnh(mgs)
18691 write(iunit,*) 'pqswi = ',pqswi(mgs)
18692 write(iunit,*) -qhcns(mgs)
18693 write(iunit,*) -qracs(mgs)
18694 write(iunit,*) -qhacs(mgs)
18695 write(iunit,*) -qhlacs(mgs)
18696 write(iunit,*) (1-il5(mgs))*qsmlr(mgs)
18697 write(iunit,*) qsshr(mgs)
18698 ! write(iunit,*) qsshrp(mgs)
18699 write(iunit,*) il5(mgs)*(qssbv(mgs))
18700 write(iunit,*) 'pqswd = ', pqswd(mgs)
18701 write(iunit,*) -qracs(mgs)*(1-il2(mgs)) , qhacs(mgs) , qhlacs(mgs)
18702 write(iunit,*) -qhcns(mgs)
18703 write(iunit,*) +(1-il5(mgs))*qsmlr(mgs) , qsshr(mgs)
18704 write(iunit,*) (qssbv(mgs))
18705 write(iunit,*) Min(0.0, qscev(mgs))
18706 write(iunit,*) -qsmul(mgs)
18710 write(iunit,*) 'Graupel'
18712 write(iunit,*) il5(mgs)*qrfrzf(mgs), qrfrzf(mgs) - qrfrz(mgs)
18713 write(iunit,*) il5(mgs)*qiacrf(mgs)
18714 write(iunit,*) il5(mgs)*qracif(mgs)
18715 write(iunit,*) qhcns(mgs)
18716 write(iunit,*) qhcni(mgs)
18717 write(iunit,*) il5(mgs)*(qhdpv(mgs))
18718 write(iunit,*) qhacr(mgs)
18719 write(iunit,*) qhacw(mgs)
18720 write(iunit,*) qhacs(mgs)
18721 write(iunit,*) qhaci(mgs)
18722 write(iunit,*) 'pqhwi = ',pqhwi(mgs)
18724 write(iunit,*) qhshr(mgs)
18725 write(iunit,*) (1-il5(mgs))*qhmlr(mgs)
18726 write(iunit,*) il5(mgs),qhsbv(mgs)
18727 write(iunit,*) -qhlcnh(mgs)
18728 write(iunit,*) -qhmul1(mgs)
18729 write(iunit,*) 'pqhwd = ', pqhwd(mgs)
18730 write(iunit,*) 'Concentration'
18731 write(iunit,*) pchwi(mgs),pchwd(mgs)
18732 write(iunit,*) crfrzf(mgs)
18733 write(iunit,*) chcns(mgs)
18734 write(iunit,*) ciacrf(mgs)
18738 write(iunit,*) 'Hail'
18740 write(iunit,*) qhlcnh(mgs)
18741 write(iunit,*) il5(mgs)*(qhldpv(mgs))
18742 write(iunit,*) qhlacr(mgs)
18743 write(iunit,*) qhlacw(mgs)
18744 write(iunit,*) qhlacs(mgs)
18745 write(iunit,*) qhlaci(mgs)
18746 write(iunit,*) pqhli(mgs)
18748 write(iunit,*) qhlshr(mgs)
18749 write(iunit,*) (1-il5(mgs))*qhlmlr(mgs)
18750 write(iunit,*) il5(mgs)*qhlsbv(mgs)
18751 write(iunit,*) pqhld(mgs)
18752 write(iunit,*) 'Concentration'
18753 write(iunit,*) pchli(mgs),pchld(mgs)
18754 write(iunit,*) chlcnh(mgs)
18756 ! Balance and checks for continuity.....within machine precision...
18759 write(iunit,*) 'END OF OUTPUT OF SOURCE AND SINK'
18760 write(iunit,*) 'PTOTAL',ptotal(mgs)
18762 end if ! ptotal out of bounds or NaN
18767 end if ! ( nstep/12*12 .eq. nstep )
18770 ! latent heating from phase changes (except qcw, qci cond, and evap)
18773 IF ( warmonly < 0.5 ) THEN
18776 & (qhmlr(mgs)+qsmlr(mgs)+qhlmlr(mgs)) & !+qhmlh(mgs)) &
18777 & +il5(mgs)*(qhfzh(mgs)+qsfzs(mgs)+qhlfzhl(mgs)) &
18778 & +il5(mgs)*(1-imixedphase)*( &
18779 & qsacw(mgs)+qhacw(mgs) + qhlacw(mgs) &
18780 & +qsacr(mgs)+qhacr(mgs) + qhlacr(mgs) &
18783 & +qhlshr(mgs) +qrfrz(mgs)+qiacr(mgs) &
18785 & +il5(mgs)*(qwfrz(mgs) &
18786 & +qwctfz(mgs)+qiihr(mgs) &
18790 & (qhmlr(mgs)+qsmlr(mgs)+qhlmlr(mgs)) !+qhmlh(mgs))
18791 ! NOTE: psub is sum of sublimation and deposition
18794 & + qsdpv(mgs) + qhdpv(mgs) &
18796 & + qidpv(mgs) + qisbv(mgs) ) &
18797 & + qssbv(mgs) + qhsbv(mgs) + qhlsbv(mgs) &
18798 & +il5(mgs)*(qiint(mgs))
18800 & qrcev(mgs) + qhcev(mgs) + qscev(mgs) + qhlcev(mgs)
18802 & Min(0.0,qrcev(mgs)) + Min(0.0,qhcev(mgs)) + Min(0.0,qscev(mgs)) + Min(0.0,qhlcev(mgs))
18803 ! NOTE: pdep is the deposition part only
18806 & + qsdpv(mgs) + qhdpv(mgs) &
18809 & +il5(mgs)*(qiint(mgs))
18810 ELSEIF ( warmonly < 0.8 ) THEN
18813 & (qhmlr(mgs)+qhlmlr(mgs)) & !+qhmlh(mgs)) &
18814 & +il5(mgs)*(qhfzh(mgs)+qhlfzhl(mgs)) &
18818 & +qrfrz(mgs)+qwfrz(mgs) &
18819 & +qwctfz(mgs)+qiihr(mgs) &
18821 & +qhacw(mgs) + qhlacw(mgs) &
18822 & +qhacr(mgs) + qhlacr(mgs) )
18823 psub(mgs) = 0.0 + &
18827 & + qidpv(mgs) + qisbv(mgs) ) &
18828 & +il5(mgs)*(qiint(mgs))
18830 & qrcev(mgs) + qhcev(mgs) + qhlcev(mgs) ! + qscev(mgs)
18834 pvap(mgs) = qrcev(mgs)
18838 & (felfcp(mgs)*pfrz(mgs) &
18839 & +felscp(mgs)*psub(mgs) &
18840 & +felvcp(mgs)*pvap(mgs))
18841 thetap(mgs) = thetap(mgs) + dtp*ptem(mgs)
18842 ptem2(mgs) = ptem(mgs)
18843 IF ( eqtset > 2 ) THEN
18844 pipert(mgs) = pipert(mgs) + (felfpi(mgs)*pfrz(mgs) &
18845 & +felspi(mgs)*psub(mgs) &
18846 & +felvpi(mgs)*pvap(mgs))*dtp
18854 ! sum the sources and sinks for qwvp, qcw, qci, qrw, qsw
18858 qwvp(mgs) = qwvp(mgs) + &
18859 & dtp*(pqwvi(mgs)+pqwvd(mgs))
18860 qx(mgs,lc) = qx(mgs,lc) + &
18861 & dtp*(pqcwi(mgs)+pqcwd(mgs))
18862 qx(mgs,lr) = qx(mgs,lr) + &
18863 & dtp*(pqrwi(mgs)+pqrwd(mgs))
18864 qx(mgs,li) = qx(mgs,li) + &
18865 & dtp*(pqcii(mgs)+pqcid(mgs))
18866 qx(mgs,ls) = qx(mgs,ls) + &
18867 & dtp*(pqswi(mgs)+pqswd(mgs))
18868 qx(mgs,lh) = qx(mgs,lh) + &
18869 & dtp*(pqhwi(mgs)+pqhwd(mgs))
18870 IF ( lhl .gt. 1 ) THEN
18871 qx(mgs,lhl) = qx(mgs,lhl) + &
18872 & dtp*(pqhli(mgs)+pqhld(mgs))
18878 ! sum sources for particle volume
18884 IF ( lvol(ls) .gt. 1 ) THEN
18885 vx(mgs,ls) = vx(mgs,ls) + &
18886 & dtp*(pvswi(mgs)+pvswd(mgs))
18889 IF ( lvol(lh) .gt. 1 ) THEN
18890 vx(mgs,lh) = vx(mgs,lh) + &
18891 & dtp*(pvhwi(mgs)+pvhwd(mgs))
18892 ! > rho0(mgs)*dtp*(pqhwi(mgs)+pqhwd(mgs))/xdn0(lh)
18895 IF ( lhl .gt. 1 ) THEN
18896 IF ( lvol(lhl) .gt. 1 ) THEN
18897 vx(mgs,lhl) = vx(mgs,lhl) + &
18898 & dtp*(pvhli(mgs)+pvhld(mgs))
18899 ! > rho0(mgs)*dtp*(pqhwi(mgs)+pqhwd(mgs))/xdn0(lh)
18912 if ( ipconc .ge. 1 ) then
18914 cx(mgs,li) = cx(mgs,li) + &
18915 & dtp*(pccii(mgs)+pccid(mgs))
18916 cina(mgs) = cina(mgs) + pccin(mgs)*dtp
18917 IF ( ipconc .ge. 2 ) THEN
18918 cx(mgs,lc) = cx(mgs,lc) + &
18919 & dtp*(pccwi(mgs)+pccwd(mgs))
18921 IF ( ipconc .ge. 3 ) THEN
18922 cx(mgs,lr) = cx(mgs,lr) + &
18923 & dtp*(pcrwi(mgs)+pcrwd(mgs))
18925 IF ( ipconc .ge. 4 ) THEN
18926 cx(mgs,ls) = cx(mgs,ls) + &
18927 & dtp*(pcswi(mgs)+pcswd(mgs))
18929 IF ( ipconc .ge. 5 ) THEN
18930 cx(mgs,lh) = cx(mgs,lh) + &
18931 & dtp*(pchwi(mgs)+pchwd(mgs))
18932 IF ( lhl .gt. 1 ) THEN
18933 cx(mgs,lhl) = cx(mgs,lhl) + &
18934 & dtp*(pchli(mgs)+pchld(mgs))
18945 IF ( has_wetscav ) THEN
18947 evapprod2d(igs(mgs),kgs(mgs)) = -(qrcev(mgs) + qssbv(mgs) + qhsbv(mgs) + qhlsbv(mgs))
18948 rainprod2d(igs(mgs),kgs(mgs)) = qrcnw(mgs) + qracw(mgs) + qsacw(mgs) + qhacw(mgs) + qhlacw(mgs) + &
18949 qraci(mgs) + qsaci(mgs) + qhaci(mgs) + qhlaci(mgs) + qscni(mgs)
18955 ! start saturation adjustment
18957 if (ndebug .gt. 0 ) write(0,*) 'conc 30a'
18958 ! include 'sam.jms.satadj.sgi'
18962 ! Modified Straka adjustment (nearly identical to Tao et al. 1989 MWR)
18966 ! set up temperature and vapor arrays
18969 pqs(mgs) = (380.0)/(pres(mgs))
18970 theta(mgs) = thetap(mgs) + theta0(mgs)
18971 qvap(mgs) = max( (qwvp(mgs) + qv0(mgs)), 0.0 )
18972 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
18975 ! melting of cloud ice
18978 qcwtmp(mgs) = qx(mgs,lc)
18983 qitmp(mgs) = qx(mgs,li)
18984 if( temg(mgs) .gt. tfr .and. &
18985 & qitmp(mgs) .gt. 0.0 ) then
18986 qx(mgs,lc) = qx(mgs,lc) + qitmp(mgs)
18987 ! pfrz(mgs) = pfrz(mgs) - qitmp(mgs)*dtpinv
18988 ptem(mgs) = ptem(mgs) + &
18990 & felfcp(mgs)*(- qitmp(mgs)*dtpinv)
18991 IF ( eqtset > 2 ) THEN
18992 pipert(mgs) = pipert(mgs) - (felfpi(mgs)*qitmp(mgs))
18994 pmlt(mgs) = pmlt(mgs) - qitmp(mgs)*dtpinv
18995 scx(mgs,lc) = scx(mgs,lc) + scx(mgs,li)
18996 thetap(mgs) = thetap(mgs) - &
18997 & fcc3(mgs)*qitmp(mgs)
18998 ptimlw(mgs) = -fcc3(mgs)*qitmp(mgs)*dtpinv
18999 cx(mgs,lc) = cx(mgs,lc) + cx(mgs,li)
19012 ! do mgs = 1,ngscnt
19013 ! qimlw(mgs) = (qcwtmp(mgs)-qx(mgs,lc))*dtpinv
19016 ! homogeneous freezing of cloud water
19018 IF ( warmonly < 0.8 ) THEN
19021 qcwtmp(mgs) = qx(mgs,lc)
19027 ! if( temg(mgs) .lt. tfrh ) THEN
19028 ! write(0,*) 'GS: mgs,temp,qc,qi = ',mgs,temg(mgs),temcg(mgs),qx(mgs,lc),qx(mgs,li)
19035 ! if( ( temg(mgs) .lt. thnuc + 2. .or. (ibfc == 2 .and. temg(mgs) < thnuc + 10. ) ) .and. &
19036 ! & qx(mgs,lc) .gt. qxmin(lc) .and. (ipconc < 2 .or. ibfc == 0 .or. ibfc == 2 )) then
19037 ! commented for test (12/01/2015):
19038 ! if( temg(mgs) .lt. thnuc + 0. .and. &
19039 ! & qx(mgs,lc) .gt. 0.0 .and. (ipconc < 2 .or. ibfc == 0 )) then
19040 if( ( ( temg(mgs) .lt. thnuc + 0.) .or. (temg(mgs) .lt. thnuc + 2. .and. ibfc >= 3) ) .and. &
19041 & qx(mgs,lc) .gt. 0.0 .and. (ipconc < 2 .or. ibfc == 0 .or. ibfc == 2)) then
19043 IF ( ibfc >= 3 ) THEN
19044 frac = Max( 0.25, Min( 1., ((thnuc + 2.) - temg(mgs) )/4.0 ) )
19045 ELSEIF ( ibfc /= 2 .or. ipconc < 2 ) THEN
19046 frac = Max( 0.25, Min( 1., ((thnuc + 1.) - temg(mgs) )/4.0 ) )
19048 volt = exp( 16.2 + 1.0*temcg(mgs) )* 1.0e-6 ! Ts == -temcg ; volt comes from the fit in Fig. 1 in Bigg 1953
19049 ! for mean temperature for freezing: -ln (V) = a*Ts - b
19050 ! volt is given in cm**3, so factor of 1.e-6 to convert to m**3
19052 cwfrz(mgs) = cx(mgs,lc)*Exp(-volt/xv(mgs,lc)) ! number of droplets with volume greater than volt
19054 qtmp = cwfrz(mgs)*xdn0(lc)*rhoinv(mgs)*(volt + xv(mgs,lc))
19055 frac = qtmp/qx(mgs,lc) ! reset number frozen to same fraction as mass. This makes
19056 ! sure that cwfrz and qwfrz are consistent and prevents
19057 ! spurious creation of ice crystals.
19060 qtmp = frac*qx(mgs,lc)
19062 IF ( ibfc == 4 .and. lis >= 1 ) THEN
19063 qx(mgs,lis) = qx(mgs,lis) + qtmp
19065 qx(mgs,li) = qx(mgs,li) + qtmp ! qx(mgs,lc)
19067 pfrz(mgs) = pfrz(mgs) + qtmp*dtpinv
19068 ptem(mgs) = ptem(mgs) + &
19070 & felfcp(mgs)*(qtmp*dtpinv)
19072 IF ( eqtset > 2 ) THEN
19073 pipert(mgs) = pipert(mgs) + felfpi(mgs)*qtmp
19076 ! IF ( lvol(li) .gt. 1 ) vx(mgs,li) = vx(mgs,li) + rho0(mgs)*qx(mgs,lc)/xdn0(li)
19077 IF ( lvol(li) .gt. 1 ) vx(mgs,li) = vx(mgs,li) + rho0(mgs)*qtmp/xdn0(li)
19079 IF ( ipconc .ge. 2 ) THEN
19080 ctmp = frac*cx(mgs,lc)
19081 ! cx(mgs,li) = cx(mgs,li) + cx(mgs,lc)
19082 IF ( ibfc == 4 .and. lis >= 1 ) THEN
19083 cx(mgs,lis) = cx(mgs,lis) + ctmp
19085 cx(mgs,li) = cx(mgs,li) + ctmp
19087 ELSE ! (ipconc .lt. 2 )
19089 IF ( t9(igs(mgs),jgs,kgs(mgs)-1) .gt. qx(mgs,lc) ) THEN
19090 qtmp = frac*t9(igs(mgs),jgs,kgs(mgs)-1)
19092 ! cx(mgs,lc) = cx(mgs,lc)*qx(mgs,lc)*rho0(mgs)/qtmp
19093 ctmp = cx(mgs,lc)*qx(mgs,lc)*rho0(mgs)/qtmp
19095 cx(mgs,lc) = Max(0.0,wvel(mgs))*dtp*cwccn &
19096 & /gz(igs(mgs),jgs,kgs(mgs))
19100 IF ( ipconc .ge. 1 ) cx(mgs,li) = Min(ccimx, cx(mgs,li) + cx(mgs,lc))
19103 sctmp = frac*scx(mgs,lc)
19104 ! scx(mgs,li) = scx(mgs,li) + scx(mgs,lc)
19105 scx(mgs,li) = scx(mgs,li) + sctmp
19106 ! thetap(mgs) = thetap(mgs) + fcc3(mgs)*qx(mgs,lc)
19107 ! ptwfzi(mgs) = fcc3(mgs)*qx(mgs,lc)*dtpinv
19110 ! scx(mgs,lc) = 0.0
19111 thetap(mgs) = thetap(mgs) + fcc3(mgs)*qtmp
19112 ptwfzi(mgs) = fcc3(mgs)*qtmp*dtpinv
19113 qx(mgs,lc) = qx(mgs,lc) - qtmp
19114 cx(mgs,lc) = cx(mgs,lc) - ctmp
19115 scx(mgs,lc) = scx(mgs,lc) - sctmp
19121 ! do mgs = 1,ngscnt
19122 ! qwfzi(mgs) = (qcwtmp(mgs)-qx(mgs,lc))*dtpinv ! Not used?? (ERM)
19125 ! reset temporaries for cloud particles and vapor
19129 IF ( ipconc .le. 1 .and. lwsm6 ) THEN ! Explicit cloud condensation/evaporation (Rutledge and Hobbs 1983)
19132 qcwtmp(mgs) = qx(mgs,lc)
19133 theta(mgs) = thetap(mgs) + theta0(mgs)
19134 temgtmp = temg(mgs)
19135 ! temg(mgs) = theta(mgs)*(p2(igs(mgs),jgs,kgs(mgs)) ) ! *pk(mgs) ! ( pres(mgs) / poo ) ** cap
19136 ! temsav = temg(mgs)
19137 ! thsave(mgs) = thetap(mgs)
19138 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
19139 temcg(mgs) = temg(mgs) - tfr
19140 ltemq = (temg(mgs)-163.15)/fqsat+1.5
19141 ltemq = Min( nqsat, Max(1,ltemq) )
19143 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
19145 IF ( ( qvap(mgs) > qvs(mgs) .or. qx(mgs,lc) > qxmin(lc) ) .and. temg(mgs) > tfrh ) THEN
19146 tmp = (qvap(mgs) - qvs(mgs))/(1. + qvs(mgs)*felv(mgs)**2/(cp*rw*temg(mgs)**2) )
19147 qcond(mgs) = Min( Max( 0.0, tmp ), (qvap(mgs)-qvs(mgs)) )
19148 IF ( qx(mgs,lc) > qxmin(lc) .and. tmp < 0.0 ) THEN ! evaporation
19149 qcond(mgs) = Max( tmp, -qx(mgs,lc) )
19151 qwvp(mgs) = qwvp(mgs) - qcond(mgs)
19152 qvap(mgs) = qvap(mgs) - qcond(mgs)
19153 qx(mgs,lc) = Max( 0.0, qx(mgs,lc) + qcond(mgs) )
19154 thetap(mgs) = thetap(mgs) + felvcp(mgs)*qcond(mgs)/(pi0(mgs))
19163 IF ( ipconc .le. 1 .and. .not. lwsm6 ) THEN
19164 ! IF ( ipconc .le. 1 ) THEN
19167 qx(mgs,lv) = max( 0.0, qvap(mgs) )
19168 qx(mgs,lc) = max( 0.0, qx(mgs,lc) )
19169 qx(mgs,li) = max( 0.0, qx(mgs,li) )
19170 qitmp(mgs) = qx(mgs,li)
19175 qcwtmp(mgs) = qx(mgs,lc)
19176 qitmp(mgs) = qx(mgs,li)
19177 theta(mgs) = thetap(mgs) + theta0(mgs)
19178 temgtmp = temg(mgs)
19179 temg(mgs) = theta(mgs)*(pinit(kgs(mgs)) + p2(igs(mgs),jgs,kgs(mgs)) ) ! *pk(mgs) ! ( pres(mgs) / poo ) ** cap
19181 thsave(mgs) = thetap(mgs)
19182 temcg(mgs) = temg(mgs) - tfr
19183 tqvcon = temg(mgs)-cbw
19184 ltemq = (temg(mgs)-163.15)/fqsat+1.5
19185 ltemq = Min( nqsat, Max(1,ltemq) )
19186 ! IF ( ltemq .lt. 1 .or. ltemq .gt. nqsat ) THEN
19187 ! C$PAR CRITICAL SECTION
19188 ! write(iunit,*) 'out of range ltemq!',temgtmp,temg(mgs),
19189 ! : thetap(mgs),theta0(mgs),pres(mgs),theta(mgs),
19190 ! : ltemq,igs(mgs),jy,kgs(mgs)
19191 ! write(iunit,*) an(igs(mgs),jy,kgs(mgs),lt),
19192 ! : ab(igs(mgs),jy,kgs(mgs),lt),
19193 ! : t0(igs(mgs),jy,kgs(mgs))
19194 ! write(iunit,*) fcc3(mgs),qx(mgs,lc),qitmp(mgs),dtp,ptem(mgs)
19196 ! C$PAR END CRITICAL SECTION
19198 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
19199 qis(mgs) = pqs(mgs)*tabqis(ltemq)
19200 ! qss(kz) = qvs(kz)
19201 ! if ( temg(kz) .lt. tfr ) then
19202 ! if( qcw(kz) .le. qxmin(lc) .and. qci(kz) .gt. qxmin(li))
19203 ! > qss(kz) = qis(kz)
19204 ! if( qcw(kz) .gt. qxmin(lc) .and. qci(kz) .gt. qxmin(li))
19205 ! > qss(kz) = (qcw(kz)*qvs(kz) + qci(kz)*qis(kz)) /
19206 ! > (qcw(kz) + qci(kz))
19207 ! qss(kz) = qis(kz)
19209 ! dont get enough condensation with qcw .le./.gt. qxmin(lc)
19210 ! if ( temg(mgs) .lt. tfr ) then
19211 ! if( qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) )
19212 ! > qss(mgs) = qvs(mgs)
19213 ! if( qx(mgs,lc) .eq. 0.0 .and. qitmp(mgs) .gt. qxmin(li))
19214 ! > qss(mgs) = qis(mgs)
19215 ! if( qx(mgs,lc) .gt. 0.0 .and. qitmp(mgs) .gt. qxmin(li))
19216 ! > qss(mgs) = (qx(mgs,lc)*qvs(mgs) + qitmp(mgs)*qis(mgs)) /
19217 ! > (qx(mgs,lc) + qitmp(mgs))
19219 ! qss(mgs) = qvs(mgs)
19221 qss(mgs) = qvs(mgs)
19222 if ( temg(mgs) .lt. tfr ) then
19223 if( qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) ) &
19224 & qss(mgs) = qvs(mgs)
19225 if( qx(mgs,lc) .le. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
19226 & qss(mgs) = qis(mgs)
19227 if( qx(mgs,lc) .gt. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
19228 & qss(mgs) = (qx(mgs,lc)*qvs(mgs) + qitmp(mgs)*qis(mgs)) / &
19229 & (qx(mgs,lc) + qitmp(mgs))
19233 ! iterate adjustment
19239 ! calculate super-saturation
19241 qitmp(mgs) = qx(mgs,li)
19246 dqwv(mgs) = ( qx(mgs,lv) - qss(mgs) )
19248 ! evaporation and sublimation adjustment
19250 if( dqwv(mgs) .lt. 0. ) then ! subsaturated
19251 if( qx(mgs,lc) .gt. -dqwv(mgs) ) then ! check if qc can make up all of the deficit
19252 dqcw(mgs) = dqwv(mgs)
19254 else ! otherwise make all qc available for evap
19255 dqcw(mgs) = -qx(mgs,lc)
19256 dqwv(mgs) = dqwv(mgs) + qx(mgs,lc)
19259 if( qitmp(mgs) .gt. -dqwv(mgs) ) then ! check if qi can make up all the deficit
19260 dqci(mgs) = dqwv(mgs)
19262 else ! otherwise make all ice available for sublimation
19263 dqci(mgs) = -qitmp(mgs)
19264 dqwv(mgs) = dqwv(mgs) + qitmp(mgs)
19267 qwvp(mgs) = qwvp(mgs) - ( dqcw(mgs) + dqci(mgs) ) ! add to perturbation vapor
19269 ! This next line removed 3/19/2003 thanks to Adam Houston,
19270 ! who found the bug in the 3-ICE code
19271 ! qwvp(mgs) = max(qwvp(mgs), 0.0)
19272 qitmp(mgs) = qx(mgs,li)
19273 IF ( qitmp(mgs) .ge. qxmin(li) ) THEN
19274 fcci(mgs) = qx(mgs,li)/(qitmp(mgs))
19278 qx(mgs,lc) = qx(mgs,lc) + dqcw(mgs)
19279 qx(mgs,li) = qx(mgs,li) + dqci(mgs) * fcci(mgs)
19280 thetap(mgs) = thetap(mgs) + &
19282 & (felvcp(mgs)*dqcw(mgs) +felscp(mgs)*dqci(mgs))
19284 IF ( eqtset > 2 ) THEN
19285 pipert(mgs) = pipert(mgs) &
19286 & +(felspi(mgs)*dqci(mgs) &
19287 & +felvpi(mgs)*dqcw(mgs))*dtp
19290 end if ! dqwv(mgs) .lt. 0. (end of evap/sublim)
19292 ! condensation/deposition
19294 IF ( dqwv(mgs) .ge. 0. ) THEN
19296 ! write(iunit,*) 'satadj: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qx(mgs,lv),qx(mgs,lc)
19298 qitmp(mgs) = qx(mgs,li)
19301 if ( temg(mgs) .lt. tfr .and. temg(mgs) .gt. thnuc ) then
19302 fracl(mgs) = max(min(1.,(temg(mgs)-233.15)/(20.)),0.0)
19303 fraci(mgs) = 1.0-fracl(mgs)
19305 if ( temg(mgs) .le. thnuc ) then
19309 fraci(mgs) = 1.0-fracl(mgs)
19311 gamss = (felvcp(mgs)*fracl(mgs) + felscp(mgs)*fraci(mgs)) &
19314 IF ( temg(mgs) .lt. tfr ) then
19315 IF (qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) ) then
19316 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qss(mgs)/ &
19317 & ((temg(mgs)-cbw)**2))
19319 IF ( qx(mgs,lc) .eq. 0.0 .and. qitmp(mgs) .gt. qxmin(li) ) then
19320 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv2(mgs)*qss(mgs)/ &
19321 & ((temg(mgs)-cbi)**2))
19323 IF ( qx(mgs,lc) .gt. 0.0 .and. qitmp(mgs) .gt. qxmin(li) ) then
19324 cdw = caw*pi0(mgs)*tfrcbw/((temg(mgs)-cbw)**2)
19325 cdi = cai*pi0(mgs)*tfrcbi/((temg(mgs)-cbi)**2)
19326 denom1 = qx(mgs,lc) + qitmp(mgs)
19327 denom2 = 1.0 + gamss* &
19328 & (qx(mgs,lc)*qvs(mgs)*cdw + qitmp(mgs)*qis(mgs)*cdi) / denom1
19329 dqvcnd(mgs) = dqwv(mgs) / denom2
19332 ENDIF ! temg(mgs) .lt. tfr
19334 if ( temg(mgs) .ge. tfr ) then
19335 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qss(mgs)/ &
19336 & ((temg(mgs)-cbw)**2))
19341 IF ( qitmp(mgs) .gt. qxmin(li) ) THEN
19342 fcci(mgs) = qx(mgs,li)/(qitmp(mgs))
19347 dqcw(mgs) = dqvcnd(mgs)*fracl(mgs)
19348 dqci(mgs) = dqvcnd(mgs)*fraci(mgs)
19350 thetap(mgs) = thetap(mgs) + &
19351 & (felvcp(mgs)*dqcw(mgs) + felscp(mgs)*dqci(mgs)) &
19354 IF ( eqtset > 2 ) THEN
19355 pipert(mgs) = pipert(mgs) + (0 &
19356 & +felspi(mgs)*dqci(mgs) &
19357 & +felvpi(mgs)*dqcw(mgs))*dtp
19360 qwvp(mgs) = qwvp(mgs) - ( dqvcnd(mgs) )
19361 qx(mgs,lc) = qx(mgs,lc) + dqcw(mgs)
19362 ! IF ( qitmp(mgs) .gt. qxmin(li) ) THEN
19363 qx(mgs,li) = qx(mgs,li) + dqci(mgs)*fcci(mgs)
19364 qitmp(mgs) = qx(mgs,li)
19367 ! delqci(mgs) = dqci(mgs)*fcci(mgs)
19369 END IF ! dqwv(mgs) .ge. 0.
19373 qitmp(mgs) = qx(mgs,li)
19374 theta(mgs) = thetap(mgs) + theta0(mgs)
19375 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
19376 qvap(mgs) = Max((qwvp(mgs) + qv0(mgs)), 0.0)
19377 temcg(mgs) = temg(mgs) - tfr
19378 tqvcon = temg(mgs)-cbw
19379 ltemq = (temg(mgs)-163.15)/fqsat+1.5
19380 ltemq = Min( nqsat, Max(1,ltemq) )
19381 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
19382 qis(mgs) = pqs(mgs)*tabqis(ltemq)
19383 qx(mgs,lc) = max( 0.0, qx(mgs,lc) )
19384 qitmp(mgs) = max( 0.0, qitmp(mgs) )
19385 qx(mgs,lv) = max( 0.0, qvap(mgs))
19386 ! if ( temg(mgs) .lt. tfr ) then
19387 ! if( qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) )
19388 ! > qss(mgs) = qvs(mgs)
19389 !c if( qx(mgs,lc) .le. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li))
19390 ! if( qx(mgs,lc) .eq. 0.0 .and. qitmp(mgs) .gt. qxmin(li))
19391 ! > qss(mgs) = qis(mgs)
19392 !c if( qx(mgs,lc) .gt. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li))
19393 ! if( qx(mgs,lc) .gt. 0.0 .and. qitmp(mgs) .gt. qxmin(li))
19394 ! > qss(mgs) = (qx(mgs,lc)*qvs(mgs) + qitmp(mgs)*qis(mgs)) /
19395 ! > (qx(mgs,lc) + qitmp(mgs))
19397 ! qss(mgs) = qvs(mgs)
19399 qss(mgs) = qvs(mgs)
19400 if ( temg(mgs) .lt. tfr ) then
19401 if( qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) ) &
19402 & qss(mgs) = qvs(mgs)
19403 if( qx(mgs,lc) .le. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
19404 & qss(mgs) = qis(mgs)
19405 if( qx(mgs,lc) .gt. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
19406 & qss(mgs) = (qx(mgs,lc)*qvs(mgs) + qitmp(mgs)*qis(mgs)) / &
19407 & (qx(mgs,lc) + qitmp(mgs))
19409 ! pceds(mgs) = (thetap(mgs) - thsave(mgs))*dtpinv
19410 ! write(iunit,*) 'satadj2: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qx(mgs,lv),qx(mgs,lc)
19413 ! end the saturation adjustment iteration loop
19417 ENDIF ! ( ipconc .le. 1 )
19420 ! spread the growth owing to vapor diffusion onto the
19421 ! ice crystal categories using the
19423 ! END OF SATURATION ADJUSTMENT
19426 if (ndebug .gt. 0 ) write(0,*) 'conc 30b'
19429 ! end of saturation adjustment
19435 t0(igs(mgs),jy,kgs(mgs)) = temg(mgs)
19438 ! Load the save arrays
19442 ! Sample code for using the axtra array to load microphysical rates or quantities for output
19444 ! Note that indices 1 and 2 are used in the nucond subroutine for condensation/evap of droplets (1) and
19445 ! condensation of rain (2)
19447 ! IF ( io_flag .and. nxtra > 1 ) THEN
19448 ! DO mgs = 1,ngscnt
19449 ! axtra(igs(mgs),jy,kgs(mgs),3) = pfrz(mgs) !
19450 ! axtra(igs(mgs),jy,kgs(mgs),4) = qrcev(mgs) ! pre2
19451 ! axtra(igs(mgs),jy,kgs(mgs),5) = psub(mgs) ! depsubr
19452 ! axtra(igs(mgs),jy,kgs(mgs),6) = qrfrz(mgs) ! rain freezing (Bigg)
19453 ! axtra(igs(mgs),jy,kgs(mgs),7) = pmlt(mgs) ! melr2
19460 if (ndebug .gt. 0 ) write(0,*) 'gs 11'
19464 an(igs(mgs),jy,kgs(mgs),lt) = &
19465 & theta0(mgs) + thetap(mgs)
19466 an(igs(mgs),jy,kgs(mgs),lv) = qwvp(mgs) + qv0(mgs) !
19468 IF ( eqtset > 2 ) THEN
19469 p2(igs(mgs),jy,kgs(mgs)) = pipert(mgs)
19474 IF ( ido(il) .eq. 1 ) THEN
19475 IF ( lf > 1 .and. il == lf ) THEN
19476 lfsave(mgs,1) = an(igs(mgs),jy,kgs(mgs),il)
19477 lfsave(mgs,2) = qx(mgs,il)
19479 an(igs(mgs),jy,kgs(mgs),il) = qx(mgs,il) + &
19480 & min( an(igs(mgs),jy,kgs(mgs),il), 0.0 )
19481 qx(mgs,il) = an(igs(mgs),jy,kgs(mgs),il)
19485 IF ( lcina > 1 ) THEN
19486 an(igs(mgs),jy,kgs(mgs),lcina) = cina(mgs)
19494 if ( ipconc .ge. 1 ) then
19497 ! write(0,*) 'limiter loop: il,ipc,lz: ',il,ipc(il),lz(il),ipconc
19499 IF ( ipconc .ge. ipc(il) .and. ido(il) > 0 ) THEN ! {
19501 IF ( ipconc .ge. 4 .and. ipc(il) .ge. 1 ) THEN ! {
19503 ! write(0,*) 'MY limiter: il,ipc,lz: ',il,ipc(il),lz(il),lr,lzr
19506 IF ( lz(il) <= 1 .or. ioldlimiter == 1 ) THEN ! { { is a two-moment category so dont worry about reflectivity
19510 IF ( qx(mgs,il) .le. 0.0 ) THEN
19513 IF ( cx(mgs,il) .gt. cxmin ) THEN !{
19514 ! xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*Max(1.0e-9,cx(mgs,il)))
19515 ! xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*Max(cxmin,cx(mgs,il)))
19516 xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*cx(mgs,il))
19518 ! IF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
19519 ! write(0,*) 'dr: xv,cx,qx,xdn,ln = ',xv(mgs,il),cx(mgs,il),qx(mgs,il),xdn(mgs,il),ln(il)
19522 ! 8/26/2015 erm: apply imaxdiaopt for 2-moment also
19523 IF ( imaxdiaopt == 1 .or. il == lc .or. il == li .or. (il == lr .and. imurain == 3) .or. &
19524 & (il == ls .and. imusnow == 3 ) ) THEN
19525 xvbarmax = xvmx(il)
19526 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
19527 xvbarmax = xvmx(il) /((3. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
19528 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
19529 xvbarmax = xvmx(il) /((4. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
19531 xvbarmax = xvmx(il)
19535 IF ( il == ls ) THEN
19536 xvbarmax = xvbarmax*Max(1.,100./Min(100.,xdn(mgs,ls)))
19539 IF ( xv(mgs,il) .lt. xvmn(il) .or. xv(mgs,il) .gt. xvbarmax ) THEN
19540 xv(mgs,il) = Min( xvbarmax, xv(mgs,il) )
19541 xv(mgs,il) = Max( xvmn(il), xv(mgs,il) )
19542 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xv(mgs,il)*xdn(mgs,il))
19547 ! IF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
19548 ! write(0,*) 'dr: xv,cx,= ',xv(mgs,il),cx(mgs,il)
19559 IF ( il == lhl ) THEN
19561 IF ( lnhlf > 1 ) THEN ! number of hail from frozen drops
19562 ! an(igs(mgs),jy,kgs(mgs),lnhlf) = Min( cx(mgs,lhl), Max( chxf(mgs,lhl), 0.0) )
19563 an(igs(mgs),jy,kgs(mgs),lnhlf) = Max( chxf(mgs,lhl), 0.0)
19566 an(igs(mgs),jy,kgs(mgs),ln(il)) = Max(cx(mgs,il), 0.0)
19571 IF ( lcin > 1 ) THEN
19573 an(igs(mgs),jy,kgs(mgs),lcin) = Max(0.0, ccin(mgs))
19577 IF ( ipconc .ge. 2 ) THEN
19579 IF ( lss > 1 ) THEN
19580 an(igs(mgs),jy,kgs(mgs),lss) = Max(0.0, ssmax(mgs) )
19583 IF ( lccn > 1 ) THEN
19584 an(igs(mgs),jy,kgs(mgs),lccn) = Max(0.0, ccnc(mgs) )
19589 ELSEIF ( ipconc .eq. 0 .and. lni .gt. 1 ) THEN
19592 an(igs(mgs),jy,kgs(mgs),lni) = Max(cx(mgs,li), 0.0)
19602 IF ( lvol(il) .ge. 1 ) THEN
19606 an(igs(mgs),jy,kgs(mgs),lvol(il)) = Max( 0.0, vx(mgs,il) )
19619 if (ndebug .gt. 0 ) write(0,*) 'gs 12'
19623 if (ndebug .gt. 0 ) write(0,*) 'gs 13'
19627 if ( kz .gt. nz-1 .and. ix .ge. itile) then
19628 if ( ix .ge. itile ) then
19629 go to 1200 ! exit gather scatter
19637 if ( ix .ge. itile ) then
19647 ! end of gather scatter (for this jy slice)
19652 end subroutine nssl_2mom_gs
19654 !--------------------------------------------------------------------------
19660 !--------------------------------------------------------------------------
19664 END MODULE module_mp_nssl_2mom