CCPP SciDoc v7.0.0  v7.0.0
Common Community Physics Package Developed at DTC
 
Loading...
Searching...
No Matches
module_mp_nssl_2mom.F90
1
3
4!---------------------------------------------------------------------
5! code snapshot: "Sep 22 2023" at "22:01:53"
6!---------------------------------------------------------------------
7!---------------------------------------------------------------------
8! IMPORTANT: Best results are attained using the 5th-order WENO (Weighted Essentially Non-Oscillatory) advection option (4) for scalars:
9! moist_adv_opt = 4,
10! scalar_adv_opt = 4, (can also use option 3, which is WENO without the positive definite filter)
11! The WENO-5 scheme provides a 5th-order (horizontal and vertical) adaptive weighting of components that
12! better preserve monotinicity in strong gradients. The standard 5th-order formulation is prone to undershoots
13! (negative values) of mass and number concentrations at cloud edges. The WENO scheme helps
14! to prevent undershoots and results in less noise at cloud and reflectivity boundaries. This is particularly
15! useful for multi-moment schemes to preserve relationships between mass and number concentration. An option is also available
16! for WENO-5 advection of momentum, but this can result in excessive damping of poorly-resolved features. For both scalar and momentum
17! 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)
18! RK step. Option 3 applies the WENO-5, and option 4 adds the positive definite filter (as also used in option 1).
19!
20! WENO references: Jiang and Shu, 1996, J. Comp. Phys. v. 126, 202-223; Shu 2003, Int. J. Comp. Fluid Dyn. v. 17 107-118;
21!
50!
51! Possible parameters to adjust:
52!
53! ccn : base cloud condensation nuclei concentration (use namelist.input value "nssl_cccn")
54! alphah, alphahl : Size distribution shape parameters for graupel (h) and hail (hl)
55! infall : changes sedimentation options to see effects (see below)
56!
57! lightning model references:
58!
59! Fierro, A. O., E.R. Mansell, C. Ziegler and D. R. MacGorman 2013: The
60! implementation of an explicit charging and discharge lightning scheme
61! within the WRF-ARW model: Benchmark simulations of a continental squall line, a
62! tropical cyclone and a winter storm. Monthly Weather Review, Volume 141, 2390-2415
63!
64! Mansell et al. 2005: Charge structure and lightning sensitivity in a simulated
65! multicell thunderstorm. J. Geophys. Res., 110, D12101, doi:10.1029/2004JD005287
66!
67! Note: Some parameters below apply to unreleased features.
68!
69!
70!---------------------------------------------------------------------
71! Apr. 2023
72! - Update to 3-moment for rain, graupel, and hail
73! - Change default graupel/hail fall speeds to icdx/icdxhl=6 (Milbrandt & Morrison 2013)
74! and also set default ehw0=0.9 and ehlw0=0.9 to compensate for lower fall speeds.
75! - Change default hail conversion to ihlcnh=-1, and then =1 for 2-mom or =3 for 3-mom,
76! using wet growth diameter to convert large graupel
77!---------------------------------------------------------------------
78! Sept. 2021:
79! Fixes:
80! Restored previous formulation of snow reflectivity, as it was realized that the last change incorrectly assumed a fixed
81! density independent of size. Generally lower snow reflectivity values as a result (no effect on microphysics)
82! Other:
83! Generic fall speed coeffecients (axx,bxx) to accomodate future frozen drops category (no effect)
84! Reordered collection coefficients (dab1lh) to be consistent (no effect)
85! Switched to full calculation of rain number loss via collection by graupel (chacr; to be consisted with collection by hail) (minor effects)
86!---------------------------------------------------------------------
87! April 2021:
88! Fixes:
89! Fall speed air density factor limited to air density of 0.05 (for very high model top) to mitigate excessive fall speeds
90! Fixed issue of spurious creation of large concentrations of very small droplets and transient large condensation (also increased minimum droplet size)
91! Fixed issue of negligible "seed" values of graupel from Bigg freezing at relatively high temperatures (thanks to S. Lasher-Trapp)
92! Minor bug fix in effective radius calculation of snow. (thanks to T. Iguchi)
93! Updates:
94! Enabled regeneration of CCN by droplet evaporation and background restore (default time constant of 3600s)
95! 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).
96! Enabled radar reflectivity from cloud ice (new formulation) ( idbzci = 1 )
97! Added internal option for ice crystal nucleation by DeMott et al. (2010, PNAS) (inucopt=4)
98! Allow greater fraction of hail to melt in one time step
99! Reduced minimum number concentration from 1e-4 to 1e-8 (based on CAPS input)
100! Added internal namelist for easier access to internal variables for development/testing and easier setup for ensemble microphysics diversity
101! (namelist read is disabled by default)
102! Increased resolution of lookup table for incomplete gamma functions
103!
104!---------------------------------------------------------------------
105! Sept. 2019:
106! Bug fixes:
107! - Effective radius calculation was only done at history times. Now every time step (though should be just before radiation is called)
108! - Snow reflectivity: Previous "fix" was incorrect and yields snow dBZ that is too low. Reverted to old version which was correct
109! - Incorrectly updated a state value in the reflectivity code. (Could cause small differences if reflectivity is not calculated)
110! Updates:
111! - 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.
112! - Graupel and hail drag coefficients are returned from fall speed subroutine to use in ventilation coeffs. for consistency (minor change)
113! - Added (compile) option flag to turn on diagnosis of cloud droplet shape parameter based on number concentration
114! - Added (compile) option flag icracr to turn off rain self-collection
115! - 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
116! - Put limit on snow volume (2 cm) in aggregation rate
117!---------------------------------------------------------------------
118! WRF 4.0 update:
119! Major:
120! Fixed excessive sublimation that could occur in very strong downdrafts (3.9.1.1 update)
121!
122! Minor:
123! icefallopt=3 : New ice crystal fall speed that has faster speeds for small ice particles. Main effect
124! is on anvil clouds to help them decay a bit faster. Old behavior can be recovered with icefallopt=1
125! Cosmetic: removed stray single quotes because some preprocessors complain about unclosed quotes even in comments
126!
127!---------------------------------------------------------------------
128! WRF 3.9.1.1 update:
129!
130! Added a check on overdepletion of ice by sublimation, which could sometimes result in water supersaturation
131! Bug fix: setting of t7 used 'dn' instead of 'dn1' (Thanks to Chunxi Zhang)
132!
133!---------------------------------------------------------------------
134! WRF 3.9 updates:
135!
136! 2-moment scheme now creates number concentration tendencies from cumulus scheme mass mixing ratio rates
137! Renamed internal gamma function routine from 'gamma' to 'gamma_sp' to avoid name conflicts
138! Restored older settings that allow snow aggregation starting at T > -25C
139! Adjusted Meyers number of activated nuclei by the local air density to compensate for using data at surface
140! Minor updates to rain-ice crystal and hail-rain collection efficiencies
141!
142!
143! Reduced minimum mean snow diameter from 100 microns to 10 microns
144!
145!---------------------------------------------------------------------
146! WRF 3.8 updates:
147! Fixed issue with reflectivity conservation for graupel melting into rain. Rain number concentrations were too low,
148! resulting in excessive reflectivity of a couple dBZ
149! Changed default value of iusewetgraupel to 1 (turns off diagnostic meltwater on graupel for reflectivity)
150! Apply a 70 m/s fall speed limit for sedimentation
151! Changed vapor ice nucleation to Meyers-Ferrier method (original scheme)
152! New method for Bigg freezing (ibiggopt=2)
153! Reduced snow aggregration efficiency and restricted aggregation to higher temperatures (assuming dendrites and mechanical aggregation)
154! Increased maximum graupel-droplet collection efficiency when hail is turned off (nssl_2momg)
155! Updates for compatibility with WRF-NMM
156! Added calculation of hail number concentration in calcnfromq (creates number concentration from mixing ratio
157! when starting from an analysis). And fixed error in graupel intercept
158! Bug fix in snow fall speeds
159! Further fix in snow reflectivity
160! Use diameter of maximum mass rather than mean diamter when checking maximum size
161! Helped performance in sedimentation with flag "do_accurate_sedimentation" to control recalculation of fall speeds when
162! more than one sub-time step is needed (often happens with large time steps and small dz near the ground):
163! = .true. : recalculates fall speed after each substep (more accurate)
164! = .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
165! Increased maximum mean droplet radius from 40 to 60 microns, which alleviates spurious number concentration increases at low CCN concentration.
166! Removed a duplicate factor from hail reflectivity that was causing a loss of about 6 dBZ (since WRF 3.5).
167!
168!---------------------------------------------------------------------
169
170
171
174
179 IMPLICIT NONE
180
181 public nssl_2mom_driver
182 public nssl_2mom_init
184 public calc_eff_radius
185 public calcnfromq
188 private delbk, delabk
189 private gammadp
190
191 logical, private :: cleardiag = .false.
192 PRIVATE
193
194#if ( WRF_CHEM == 1 )
195 integer, parameter :: wrfchem_flag = 1
196#else
197 integer, parameter :: wrfchem_flag = 0
198#endif
199
200 LOGICAL, PRIVATE:: is_aerosol_aware = .false.
201
202 logical, private :: turn_on_cin = .false.
203
204 integer, private :: eqtset = 1 ! Flag for use with cm1 to use alternate equation set (changes latent heating rates)
205 ! value of > 2 invokes the equivalent version of eqtset=2 that applies updates to both theta and Pi.
206 double precision, parameter, public :: zscale = 1.0d0 ! 1.000e-10
207 double precision, parameter, public :: zscaleinv = 1.0d0/zscale ! 1.000e-10
208
209
210 real, parameter :: warmonly = 0.0 ! testing parameter, set to 1.0 to reduce to warm-rain physics (ice variables stay zero)
211
212 logical, parameter :: lwsm6 = .false. ! act like wsm6 for some single moment interactions
213
214! some constants from WSM6
215 real, parameter :: dimax = 500.e-6 ! limited maximum value for the cloud-ice diamter
216 real, parameter :: roqimax = 2.08e22*dimax**8
217
218! Params for dbz:
219 integer :: iuseferrier = 1 ! =1: use dry graupel only from Ferrier 1994; = 0: Use Smith (wet graupel)
220 integer :: idbzci = 1
221 integer :: iusewetgraupel = 1 ! =1 to turn on use of QHW for graupel reflectivity (only for ZVDM -- mixedphase)
222 ! =2 turn on for graupel density less than 300. only
223 integer :: iusewethail = 0 ! =1 to turn on use of QHW for graupel reflectivity (only for ZVDM -- mixedphase)
224 integer :: iusewetsnow = 0 ! =1 to turn on diagnosed bright band; =2 'old' snow reflectivity (dry), =3 'old' snow dbz + brightband
225! microphysics
226
227 real, private :: rho_qr = 1000., cnor = 8.0e5 ! cnor is set in namelist!! rain params
228 real, private :: rho_qs = 100., cnos = 3.0e6 ! set in namelist!! snow params
229 real, private :: rho_qh = 500., cnoh = 4.0e5 ! set in namelist!! graupel params
230 real, private :: rho_qhl= 800., cnohl = 4.0e4 ! set in namelist!! hail params
231
232 real, private :: hdnmn = 170.0 ! minimum graupel density (for variable density graupel)
233 real, private :: hldnmn = 500.0 ! minimum hail density (for variable density hail)
234
235 real :: cnohmn = 1.e-2 ! minimum intercept for 2-moment graupel (alphah < 0.5)
236 real :: cnohlmn = 1.e-2 ! minimum intercept for 2-moment hail (alphahl < 0.5)
237
238! Autoconversion parameters
239
240 real , private :: qcmincwrn = 2.0e-3 ! qc threshold for autonconversion (LFO; for 10ICE use qminrncw for ircnw != 5)
241 real , private :: cwdiap = 20.0e-6 ! threshold diameter of cloud drops (Ferrier 1994 autoconversion)
242 real , private :: cwdisp = 0.15 ! assume droplet dispersion parameter (can be 0.3 for maritime)
243 real , private :: ccn = 0.6e+09 ! set in namelist!! Central plains CCN value
244 real , private :: ccnuf = 0 ! set in namelist!! Central plains CCN value
245 real , public :: qccn, qccnuf ! ccn "mixing ratio"
246 real , private :: old_qccn = -1.0
247 integer, private :: iauttim = 1 ! 10-ice rain delay flag
248 real , private :: auttim = 300. ! 10-ice rain delay time
249 real , private :: qcwmntim = 1.0e-5 ! 10-ice rain delay min qc for time accrual
250
251#if (NMM_CORE == 1)
252! NMM WRF core does not have special boundary conditions for CCN, therefore set invertccn to true
253 logical, parameter :: invertccn = .true. ! =true for base state of ccn=0, =false for ccn initialized in the base state
254#else
255 logical, private :: invertccn = .false. ! =true for base state of ccn=0, =false for ccn initialized in the base state
256#endif
257 logical :: switchccn = .false.
258 real :: old_cccn = -1.0
259 logical :: restoreccn = .true. ! whether or not to nudge CCN back to base state (qccn) (only applies if CCNA is NOT predicted)
260 real :: ccntimeconst = 3600. ! time constant for CCN restore (either for CCNA or when restoreccn = true)
261 real, private :: restoreccnfrac = 1.0 ! fraction of evaporated droplets that restore CCN
262 real :: ufccntimeconst = 6.*3600. ! time constant for UFCCN decay (Blossey et al. 2018)
263 real :: ufbackground = 0.1e9 ! background ccnuf value (Blossey et al.)
264 logical :: decayufccn = .false.
265 integer :: i_uf_or_ccn = 0 ! 0 = ship adds UF; 1 = treat UF as regular ccn (add to qccn)
266
267! sedimentation flags
268! itfall -> 0 = 1st order fallout (other options removed)
269! iscfall, infall -> fallout options for charge and number concentration, respectively
270! 1 = mass-weighted fall speed; 2 = number-weighted fallspeed.
271 integer, private :: itfall = 0
272 integer, private :: iscfall = 1
273 integer, private :: irfall = -1
274 integer, private :: isfall = 2 ! default limit with method II (more restrictive)
275 logical, private :: do_accurate_sedimentation = .true. ! if true, recalculate fall speeds on sub time steps; (more expensive)
276 ! if false, reuse fall speeds on multiple steps (can have a noticeable speedup)
277 ! Mainly is an issue for small dz near the surface.
278 integer, private :: interval_sedi_vt = 2 ! interval for recalculating Vt in sedimentation subloop (only when do_accurate_sedimentation = .true.)
279 integer, private :: infall = 4 ! 0 -> uses number-wgt for N; NO correction applied (results in excessive size sorting)
280 ! 1 -> uses mass-weighted fallspeed for N ALWAYS
281 ! 2 -> uses number-wgt for N and mass-weighted correction for N (Method II in Mansell, 2010 JAS)
282 ! 3 -> uses number-wgt for N and Z-weighted correction for N (Method I in Mansell, 2010 JAS)
283 ! 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)
284 ! 5 -> uses number-wgt for N and uses average of N-wgt and q-wgt instead of Max.
285 integer :: imydiagalpha = 0 ! apply MY diagnostic shape parameter for fall speeds (1=for fall speed only; 2=also for microphysics rates)
286 real, private :: rainfallfac = 1.0 ! factor to adjust rain fall speed (single moment only)
287 real, private :: icefallfac = 1.5 ! factor to adjust ice fall speed
288 real, private :: snowfallfac = 1.25 ! factor to adjust snow fall speed
289 real, private :: graupelfallfac = 1.0 ! factor to adjust graupel fall speed
290 real, private :: hailfallfac = 1.0 ! factor to adjust hail fall speed
291 integer, private :: icefallopt = 3 ! 1= default, 2 = Ferrier ice fall speed; 3 = adjusted Ferrier (slightly high Vt)
292 integer, private :: icdx = 6 ! (graupel) 0=Ferrier; 1=leave drag coef. cd fixed; 2=vary by density, 4=set by user with cdxmin,cdxmax,etc.
293 ! 6= Milbrandt and Morrison (2013) density-based fall speed
294 integer, private :: icdxhl = 6 ! (hail) 0=Ferrier; 1=leave drag coef. cd fixed; 2=vary by density, 4=set by user with cdxmin,cdxmax,etc.
295 ! 6= Milbrandt and Morrison (2013) density-based fall speed
296 real :: axh = 75.7149, bxh = 0.5
297 real :: axf = 75.7149, bxf = 0.5
298 real :: axhl = 206.984, bxhl = 0.6384
299 real , private :: cdhmin = 0.45, cdhmax = 0.8 ! defaults for graupel (icdx=4)
300 real , private :: cdhdnmin = 500., cdhdnmax = 800.0 ! defaults for graupel (icdx=4)
301 real , private :: cdhlmin = 0.45, cdhlmax = 0.6 ! defaults for hail (icdx=4)
302 real , private :: cdhldnmin = 500., cdhldnmax = 800.0 ! defaults for hail (icdx=4)
303 real , private :: vtmaxsed = 70. ! Limit on fall speed (m/s, all moments) for sedimentation calculations. Not applied to fall speeds for microphysical rates
304
305 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
306 integer :: sssflg = 1 ! As above but for snow
307 integer :: hssflg = 1 ! As above but for graupel
308 integer :: hlssflg = 1 ! As above but for hail
309
310! input flags
311
312 integer, private :: ndebug = -1, ncdebug = 0
313 integer, private :: ipconc = 5
314 integer, private :: inucopt = 0
315 integer, private :: ichaff = 0
316 integer, parameter :: ilimit = 0
317
318 real, private :: constccw = -1.
319
320 real, private :: cimn = 1.0e3, cimx = 1.0e6
321
322 real , private :: rhofrz = 900 ! density of freezing drops
323 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
324 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
325 real , private :: ifrzs = 1.0 ! fraction of small frozen drops going to snow. 1=freeze rain to snow, 0=freeze to cloud ice
326 real , private :: ffrzs = 0.0 ! fraction of other initiated cloud ice going to snow. 1=freeze rain to snow, 0=freeze to cloud ice
327 real , private :: f2h = 1.0 ! fraction of cloud ice conversion going to graupel (vs. frozen drops). For testing
328 integer, private :: irwfrz = 1 ! compute total rain that can freeze (checks heat budget)
329 integer, private :: irimtim = 0 ! future use
330! integer, private :: infdo = 1 ! 1 = calculate number-weighted fall speeds
331
332 integer, private :: irimdenopt = 1 ! = 1 for default Heymsfield and Pflaum (1985); = 2 for experimental Cober and List (1993); = 3 Macklin
333 real , private :: rimc1 = 300.0, rimc2 = 0.44 ! rime density coeff. and power (Default Heymsfield and Pflaum, 1985)
334 real , private :: rimc3 = 170.0 ! minimum rime density
335 real :: rimc4 = 900.0 ! maximum rime density
336 real , private :: rimtim = 120.0 ! cut-off rime time (10ICE)
337 real , private :: eqtot = 1.0e-9 ! threshold for mass budget reporting
338 real, private :: rimdenvwgt = 0.0 ! weight (0-1) given to number-weighted fall speed when calculating rime density
339
340 integer, private :: ireadmic = 0
341
342 integer, private :: idiagnosecnu = 0 ! =1 to diagnose cnu based on Chandrakar et al. 2016 data; =2 for Geoffroy et al. (2010, ACP)
343 integer, private :: iccwflg = 1 ! sets max size of first droplets in parcel to 4 micron radius (in two-moment liquid)
344 ! (first nucleation is done with a KW sat. adj. step)
345 integer, private :: issfilt = 0 ! flag to turn on filtering of supersaturation field
346 integer, private :: icnuclimit = 0 ! limit droplet nucleation based on Konwar et al. (2012) and Chandrakar et al. (2016)
347 integer, private :: irenuc = 2 ! =1 to always allow renucleation of droplets within the cloud (do no use, obsolete)
348 ! =2 renucleation following Twomey/Cohard&Pinty
349 ! =7 New renucleation that requires prediction of the number of activated nuclei
350 ! i.e., not only at cloud base
351 integer, private :: irenuc3d = 0 ! =1 to include horizontal gradient in renucleation of droplets within the cloud
352 real :: renucfrac = 0.0 ! = 0 : cnuc = cwccn
353 ! = 1 : cnuc = actual available CCN
354 ! otherwise cnuc = cwccn*(1. - renufrac) + ccnc(1:ngscnt)*renucfrac
355 real :: ssf2kmax = 10. ! max value for ssf**cck in irenuc=4 or 5
356 real , private :: cck = 0.6 ! exponent in Twomey expression
357 real , private :: ciintmx = 1.0e6 ! limit on ice concentration from primary nucleation
358
359 real , private :: cwccn ! , cwmasn,cwmasx
360 real , private :: ccwmx
361
362 integer, private :: idocw = 1, idorw = 1, idoci = 1, idoir = 1, idoip = 1, idosw = 1
363 integer, private :: idogl = 1, idogm = 1, idogh = 1, idofw = 1, idohw = 1, idohl = 1
364! integer, private :: ido(3:14) = / 12*1 /
365
366
367! 0,2, 5.00e-10, 1, 0, 0, 0 : itype1,itype2,cimas0,icfn,ihrn,ibfc,iacr
368 integer, private :: itype1 = 0, itype2 = 2 ! controls Hallett-Mossop process
369 integer, private :: in_freeze_rain_first = 0 ! =1 use IN to freezed rain drops (if none, then freeze droplets)
370 integer, private :: icenucopt = 1 ! =1 Meyers/Ferrier primary ice nucleation; =2 Thompson/Cooper, =3 Phillips (Meyers/Demott), =4 DeMott (2010)
371 real, private :: naer = 1.0e6 ! background large aerosol conc. for DeMott
372 integer, private :: icfn = 2 ! contact freezing: 0 = off; 1 = hack (ok for single moment); 2 = full Cotton/Meyers version
373 integer, private :: ihrn = 0 ! Hobbs-Rangno ice multiplication (Ferrier, 1994; use in 10-ice only)
374 integer, private :: ibfc = 1 ! Flag to use Bigg freezing on droplets (0 = off (uses alternate freezing), 1 = on)
375 real, private :: cwfrz2snowfrac = 0.0 ! fraction of freezing droplet mass to send to snow
376 real, private :: cwfrz2snowratio = 5. ! Assumed number of frozen droplets in a cluster
377 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
378 integer, private :: iacr = 2 ! Flag for drop contact freezing with crytals
379 ! (0=off; 1=drops > 500micron diameter; 2 = > 300micron)
380 integer, private :: icrcev = 1 ! 1 = old crcev; 2 = crcev scaled by vtrain ratio (num/mass); 3 = set to zero
381 integer, private :: icracr = 1 ! Flag to turn rain self-collection on/off (=0 to turn off)
382 integer, private :: icracrthresh = 1 ! For rain self-coll. thresh. use: 1 = mean diam of 2mm; 2 = rain median volume diam of 1.9mm
383 integer, private :: ibfr = 2 ! Flag for Bigg freezing conversion of freezing drops to graupel
384 ! (1=min graupel size is vr1mm; 2=use min size of dfrz, 5= as for 2 and apply dbz conservation)
385 integer, private :: ibiggopt = 2 ! 1 = old Bigg; 2 = experimental Bigg (only for imurain = 1, however)
386 integer :: ibiggsmallrain = 0 ! 1 = When rain is too small, freeze none to graupel and send all to snow (experimental)
387 integer, private :: iacrsize = 5 ! assumed min size of drops freezing by capture
388 ! 1: > 500 micron diam
389 ! 2: > 300 micron
390 ! 3: > 40 micron
391 ! 4: all sizes
392 ! 5: > 150 micron (only for imurain = 1)
393 real , private :: cimas0 = 6.62e-11 ! default mass of Hallett-Mossop crystals
394 ! 6.62e-11kg results in half the diam. (60 microns) of old default value of 5.0e-10
395 real , private :: cimas1 = 6.88e-13 ! default mass of new ice crystals
396 real , private :: splintermass = 6.88e-13
397 real , private :: cfnfac = 0.1 ! Hack factor that goes with icfn=1
398 integer, private :: iscni = 4 ! default option for ice crystal aggregation/conversion to snow
399 real , private :: fscni = 1.0 ! factor for calculating cscni
400 logical, private :: imeyers5 = .false. ! .false.=off, true=on for Meyers ice nucleation for temp > -5 C
401 real , private :: dmincw = 15.0e-6 ! minimum droplet diameter for collection for iehw=3
402 integer, private :: iehw = 1 ! 0 -> ehw=ehw0; 1 -> old ehw; 2 -> test ehw with Mason table data
403 integer, private :: iefw = 1 ! 0 -> ehw=ehw0; 1 -> old ehw; 2 -> test ehw with Mason table data
404 integer, private :: iehlw = 1 ! 0 -> ehlw=ehlw0; 1 -> old ehlw; 2 -> test ehlw with Mason table data
405 ! For ehw/ehlw = 1, ehw0/ehlw0 act as maximum limit on collection efficiency (defaults are 1.0)
406 integer, private :: ierw = 1 ! for single-moment rain (LFO/Z)
407 integer, private :: iehr0c = 0 ! 0 -> no collection for T > 0C; 1 -> turn on collection/shedding for T > 0C
408 integer, private :: iehlr0c = 0 ! 0 -> no collection for T > 0C; 1 -> turn on collection/shedding for T > 0C
409 real , private :: ehw0 = 0.9 ! constant or max assumed graupel-droplet collection efficiency
410 real , private :: erw0 = 1.0 ! constant assumed rain-droplet collection efficiency
411 real , private :: ehlw0 = 0.9 ! constant or max assumed hail-droplet collection efficiency
412 real , private :: efw0 = 0.5 ! constant or max assumed graupel-droplet collection efficiency
413 real :: ehr0 = 1.0 ! constant or max assumed graupel-rain collection efficiency
414 real :: efr0 = 1.0 ! constant or max assumed graupel-rain collection efficiency
415 real :: ehlr0 = 1.0 ! constant or max assumed hail-rain collection efficiency
416 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)
417
418
419 real , private :: esilfo0 = 1.0 ! factor for LFO collection efficiency of snow for cloud ice.
420 real , private :: ehslfo0 = 1.0 ! factor for LFO collection efficiency of hail/graupel for snow.
421
422 integer, private :: ircnw = 5 ! single-moment warm-rain autoconversion option. 5= Ferrier 1994.
423 real , private :: qminrncw = 2.0e-3 ! qc threshold for rain autoconversion (NA for ircnw=5)
424
425 integer, private :: iqcinit = 2 ! For ZVDxx schemes, flag to choose which way to initialize droplets
426 ! 1 = Soong-Ogura adjustment
427 ! 2 = Saturation adjustment to value of ssmxinit
428 ! 3 = KW adjustment
429
430 real , private :: ssmxinit = 0.4 ! saturation percentage to adjust down to for initial cloud
431 ! formation (ZVDxx scheme only)
432
433 real , private :: ewfac = 1.0 ! hack factor applied to graupel and hail collection eff. for droplets
434 real , private :: eii0 = 0.1 ,eii1 = 0.1 ! graupel-crystal coll. eff. parameters: eii0*exp(eii1*min(temcg(mgs),0.0))
435 ! set eii1 = 0 to get a constant value of eii0
436 real , private :: eii0hl = 0.2 ,eii1hl = 0.0 ! hail-crystal coll. eff. parameters: eii0hl*exp(eii1hl*min(temcg(mgs),0.0))
437 ! set eii1hl = 0 to get a constant value of eii0hl
438 real, private :: ewi_dcmin = 15.0e-06 ! minimum droplet diameter for nonzero ewi
439 real, private :: ewi_dimin = 30.0e-06 ! minimum ice crystal diameter for nonzero ewi
440 real , private :: eri0 = 0.1 ! rain efficiency to collect ice crystals
441 real , private :: eri_cimin = 10.e-6 ! minimum ice crystal diameter for collection by rain
442 real , private :: esi0 = 0.1 ! linear factor in snow-ice collection efficiency
443 real , private :: ehs0 = 0.1, ehs1 = 0.1 ! graupel-snow coll. eff. parameters: ehs0*exp(ehs1*min(temcg(mgs),0.0))
444 ! set ehs1 = 0 to get a constant value of ehs0
445 integer :: iessopt = 1 ! 1 = Original (no factor); 2 = factor based on wvel; 3 = factor based on SSI
446 ! 4 = as 3 but sets min factor of 0.1 and goes to full value at 0.5% SSI
447 real , private :: ess0 = 0.5, ess1 = 0.05 ! snow aggregation coefficients: ess0*exp(ess1*min(temcg(mgs),0.0))
448 ! set ess1 = 0 to get a constant value of ess0
449 real , private :: esstem1 = -15. ! lower temperature where snow aggregation turns on
450 real , private :: esstem2 = -10. ! higher temperature for linear ramp of ess from zero at esstem1 to formula value at esstem2
451 real , private :: essrmax = 0.02 ! maximum snow radius (meters) for csacs
452 real , private :: essfrac1 = 0.5 ! snow mass fraction 1 for aggregation roll-off
453 real , private :: essfrac2 = 0.75 ! snow mass fraction 2 for aggregation roll-off
454 integer, private :: iessec0flag = 0 ! flag to activate aggregation roll-off
455 real , private :: ehsfrac = 1.0 ! multiplier for graupel collection efficiency in wet growth
456 real , private :: ehimin = 0.0 ! Minimum collection efficiency (graupel - ice crystal)
457 real , private :: ehimax = 1.0 ! Maximum collection efficiency (graupel - ice crystal)
458 real , private :: ehsmax = 0.5 ! Maximum collection efficiency (graupel - snow)
459 real , private :: ecollmx = 0.5 ! Maximum collision efficiency for graup/hail with ice; used only for charging rates
460 integer, private :: iglcnvi = 1 ! flag for riming conversion from cloud ice to rimed ice/graupel
461 integer, private :: iglcnvs = 2 ! flag for conversion from snow to rimed ice/graupel
462
463 real , private :: rz ! reflectivity conservation factor for graupel/rain
464 ! now calculated in icezvd_dr.F from alphah and rnu
465 ! currently only used for graupel melting to rain
466 real , private :: rzhl ! reflectivity conservation factor for hail/rain
467 ! now calculated in icezvd_dr.F from alphahl and rnu
468
469 real , private :: rzs ! reflectivity conservation factor for snow(imusnow=3) with rain (imurain=1)
470
471 real , private :: alphahacx = 0.0 ! assumed minimum shape parameter for zhacw and zhacr
472
473 real , private :: fconv = 1.0 ! factor to boost max graupel depletion by riming conversions in 10ICE
474
475 real , private :: rg0 = 400.0 ! reference graupel density for graupel fall speed
476
477 integer, private :: rcond = 2 ! (Z only) rcond = 2 includes rain condensation in loop with droplet condensation
478 ! 0 = no condensation on rain; 1 = bulk condensation on rain
479 integer, parameter, private :: icond = 1 ! (Z only) icond = 1 calculates ice deposition (crystals and snow) BEFORE droplet condensation
480 ! icond = 2 does not work (intended to calc. dep in loop with droplet cond.)
481 integer, private :: iqis0 = 2 ! = 1 for normal qis; = 2 to set qis to use T = 0C when T > 0C
482
483 real , private :: dfrz = 0.15e-3 ! 0.25e-3 ! minimum diameter of frozen drops from Bigg freezing (used for vfrz) for iacr > 1
484 ! and for ciacrf for iacr=4
485 real , private :: dmlt = 3.0e-3 ! maximum diameter for rain melting from graupel and hail
486 real , private :: dshd = 1.0e-3 ! nominal diameter for rain drops shed from graupel/hail
487 integer, private :: ivshdgs = 1 ! 0 = use 1mm for all shedding (non-mixedphase); 1 = use vshdgs with sheddiam
488 integer, private :: ished2cld = 0 ! 1: Send shed liquid (from wet growth) to cloud droplets
489
490 integer, private :: ihmlt = 2 ! 1=old melting with vmlt; 2=new melting using mean volume diam of graupel/hail
491 integer, private :: imltshddmr = 2 ! 0 (default)=mean diameter of drops produced during melting+shedding as before (using mean diameter of graupel/hail
492 ! and max mean diameter of rain)
493 ! 1=new method where mean diameter of rain during melting is adjusted linearly downward
494 ! toward 3 mm for large (> sheddiam) graupel and hail, to take into account shedding of
495 ! smaller drops. sheddiam0 controls the size of graupel/hail above which the assumed
496 ! mean diameter of rain is set to 3 mm
497 ! Only valid for ihmlt = 2 for ZVD(H) but also applies to ZVD(H)M
498 ! 2 = method that sets the resulting rain size ( vshdgs ) according to the mass-weighted diameter of the ice
499
500 real :: mltdiam1 = 9.0e-3, mltdiam2 = 16.0e-3, mltdiam3 = 19.0e-3, mltdiam4 = 200.0e-3, mltdiam05 = 4.5e-3
501
502 integer, private :: nsplinter = 0 ! number of ice splinters per freezing drop, if negative, then per resulting graupel particle
503 real, private :: lawson_splinter_fac = 2.5e-11 ! constant in Lawson et al. (2015, JAS) for ice particle production from freezing drops
504 integer, private :: isnwfrac = 0 ! 0= no snow fragmentation; 1 = turn on snow fragmentation (Schuur, 2000)
505
506! integer, private :: denscale = 1 ! 1=scale num. conc. and charge by air density for advection, 0=turn off for comparison
507
508 real, private :: qhdpvdn = -1.
509 real, private :: qhacidn = -1.
510
511 integer, private :: iraintypes = 0
512 logical, private :: mixedphase = .false. ! .false.=off, true=on to include mixed phase graupel
513 integer, private :: imixedphase = 0
514 logical, private :: qsdenmod = .false. ! true = modify snow density by linear interpolation of snow and rain density
515 logical, private :: qhdenmod = .false. ! true = modify graupel density by linear interpolation of graupel and rain density
516 logical, private :: qsvtmod = .false. ! true = modify snow fall speed by linear interpolation of snow and rain vt
517 real , private :: sheddiam = 8.0e-03 ! minimum diameter of graupel before shedding occurs
518 real :: sheddiamlg = 10.0e-03 ! diameter of hail to use fwmlarge
519 real :: sheddiam0 = 20.0e-03 ! diameter of hail at which all water is shed
520
521 integer :: ifwmhopt = 2 ! option for calculating maximum liquid fraction when fwmh and/or fwmhl is set to -1
522 ! 1 = maximum based on size of maximum mass diameter
523 ! 2 = integrate over spectrum for maximum liquid (experimental)
524
525 integer :: ihxw2rain = 0 ! = 0 no transfer
526 ! = 1 transfer completely melted (99.5%) graupel/hail to rain when fwmh/fwmhl is set to -1.
527
528 real , private :: fwms = 0.5 ! maximum liquid water fraction on snow
529 real , private :: fwmh = 0.5 ! maximum liquid water fraction on graupel
530 real , private :: fwmhl = 0.5 ! maximum liquid water fraction on hail
531 real :: fwmlarge = 0.2 ! maximum liquid water fraction on hail larger than sheddiam
532 integer :: ifwmfall = 0 ! whether to interpolate toward rain fall speed for graupel and hail
533 ! when diam < sheddiam and liquid fraction is predicted (0=no, 1=yes)
534
535 logical :: rescale_high_alpha = .false. ! whether to rescale number. conc. when alpha = alphamax (3-moment only)
536 logical :: rescale_low_alpha = .true. ! whether to rescale Z (graupel/hail) when alpha = alphamin (3-moment only)
537 logical :: rescale_low_alphar = .true. ! whether to rescale Z for rain when alpha = alphamin (3-moment only)
538 logical :: rescale_low_alphah = .true. ! whether to rescale Z for rain when alpha = alphamin (3-moment only)
539 logical :: rescale_low_alphahl = .true. ! whether to rescale Z for rain when alpha = alphamin (3-moment only)
540
541 real, parameter :: alpharmax = 8. ! limited for rwvent calculation
542
543 integer, private :: ihlcnh = -1 ! which graupel -> hail conversion to use
544 ! 1 = Milbrandt and Yau (2005) using Ziegler 1985 wet growth diameter
545 ! 2 = Straka and Mansell (2005) conversion using size threshold
546 ! 3 = Conversion using wet growth diameter
547 real, private :: hlcnhdia = 1.e-3 ! threshold diameter for graupel -> hail conversion for ihlcnh = 1 option.
548 real, private :: hlcnhqmin = 0.1e-3 ! minimum graupel mass content for graupel -> hail conversion (ihlcnh = 1)
549 real , private :: hldia1 = 10.0e-3 ! threshold diameter for graupel -> hail conversion for ihlcnh = 2 option.
550 integer, private :: incwet = 0 ! flag to do wet growth only on D > D_wet
551 integer, private :: iusedw = 0 ! flag to use experimental wet growth ice diameter for gr -> hl conversion (=1 turns on)
552 real , private :: dwmin = 5.0e-3 ! Minimum diameter with iusedw (can stay at 0 or be set to something larger)
553 real , private :: dwetmin = 5.0e-3 ! Minimum diameter with iusedw (can stay at 0 or be set to something larger)
554 real , private :: dwmax = 15.e-3 ! for ihlcnh, always convert this size and larger whether or not there is wet growth
555 real , private :: dwtempmin = 242. ! lowest temperature to allow wet growth conversion to hail
556 real , private :: dwehwmin = 0. ! Minimum ehw to use to find wet growth diameter (if > ehw0, then wet growth diam becomes smaller)
557 real , private :: dg0thresh = 0.15 ! graupel wet growth diameter above which we say do not bother
558 integer :: ifddenfac = 0 ! = 1 to use density threshold to count FD as GR when converting to HL
559 real :: fddenthresh = 500. ! if ifddenfac > 0, then hail from FD with lower density are considered to come from graupel
560 integer :: icvhl2h = 0 ! allow conversion of hail back to graupel when hail density gets close to minimum allowed
561
562 integer, private :: imurain = 1 ! 3 for gamma-volume, 1 for gamma-diameter DSD for rain.
563 integer, private :: imusnow = 3 ! 3 for gamma-volume, 1 for gamma-diameter DSD for snow (=1 NOT IMPLEMENTED!!).
564 integer, private :: iturbenhance = 0 ! warm-rain collision enhancement
565 ! 1 = enhance autoconversion only
566 ! 2 = add rain collection of cloud
567 ! 3 = add rain self-collection
568 integer, private :: isedonly = 0 ! 1= only do sedimentation and skip other microphysics
569 integer, private :: iferwisventr = 2 ! =1 for Ferrier rwvent, =2 for Wisner rwvent (imurain=1)
570 integer, private :: izwisventr = 2 ! =1 for old Ziegler rwvent, =2 for Wisner-style rwvent (imurain=3)
571 integer :: iresetmoments = 0 ! if >0, then set all moments to zero when one of them is zero (3-moment only)
572 integer, private :: imaxdiaopt = 3
573 ! = 1 use mean diameter for breakup
574 ! = 2 use maximum mass diameter for breakup
575 ! = 3 use mass-weighted diameter for breakup
576 integer :: iraintailbreak = 0 ! 1 = on
577 real :: draintail = 8.e-3 ! starting size for rain breakup
578 integer, private :: dmrauto = 0
579 ! = -1 no limiter on crcnw
580 ! = 0 limit crcnw when qr > 1.2*L (Cohard-Pinty 2002)
581 ! = 1 DTD version based on MY code
582 ! = 2 DTD mass-weighted version based on MY code
583 ! = 3 Milbrandt version (from Cohard and Pinty code
584 integer :: dmropt = 0 ! extra option for crcnw
585 integer :: dmhlopt = 0 ! options for graupel -> hail conversion
586 integer :: irescalerainopt = 3 ! 0 = default option
587 ! 1 = qx(mgs,lc) > qxmin(lc)
588 ! 2 = qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < 3.0
589 ! 3 = temcg(mgs) > 0.0.and. qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < 3.0
590 real :: rescale_wthresh = 3.0
591 real :: rescale_tempthresh = 0.0
592 real, parameter :: alpharaut = 0.0 ! MY2005 for autoconversion
593 real :: cxmin = 1.e-8 ! threshold cutoff for number concentration
594 real :: zxmin = 1.e-28 ! threshold cutoff for reflectivity moment
595
596 integer :: ithompsoncnoh = 0 ! For single moment graupel only
597 ! 0 = fixed intercept
598 ! 1 = intercept based on graupel mass
599
600 integer :: ivhmltsoak = 1 ! 0=off, 1=on : flag to simulate soaking (graupel/hail) during melting
601 ! when liquid fraction is not predicted
602 logical, private :: iwetsoak = .true. ! soak and freeze during wet growth or not
603 integer, private :: ioldlimiter = 0 ! test switch for new(=0) or old(=1) size limiter at the end of GS for 3-moment categories
604 integer, private :: isnowfall = 2 ! Option for choosing between snow fall speed parameters
605 ! 1 = original Zrnic et al. (Mansell et al. 2010)
606 ! 2 = Ferrier 1994 (results in slower fall speeds)
607
608 integer, private :: isnowdens = 1 ! Option for choosing between snow density options
609 ! 1 = constant of 100 kg m^-3
610 ! 2 = Option based on Cox
611
612 integer, private :: ibiggsnow = 3 ! 1 = switch conversion over to snow for small frozen drops from Bigg freezing
613 ! 2 = switch conversion over to snow for small frozen drops from rain-ice interaction
614 ! 3 = switch conversion over to snow for small frozen drops from both
615 real :: biggsnowdiam = -1.0 ! If >0, use for ibiggsnow threshold
616
617 integer, private :: ixtaltype = 1 ! =1 column, =2 disk (similar to Takahashi)
618
619 real, private :: takshedsize1 = 0.15 ! diameter (cm) of drop shed from ice with D > 1.9 cm
620 real, private :: takshedsize2 = 0.3 ! diameter (cm) of drop shed from ice with D < 1.9 cm and D > 0.8 cm
621 real, private :: takshedsize3 = 0.45 ! diameter (cm) of drop shed from ice with D < 1.6 cm and D > 0.8 cm
622 integer, private :: numshedregimes = 3
623
624 real, private :: evapfac = 1.0 ! Multiplier on rain evaporation rate
625 real, private :: depfac = 1.0 ! Multiplier on graupel/hail deposition/sublimation rate
626 real,private,parameter :: meltfac = 1.0 ! Multiplier on graupel/hail melting rate
627
628 integer, private :: ibinhmlr = 0 ! =1 use incomplete gammas to determine melting from larger and smaller sizes of graupel, and appropriate shed drop sizes
629 ! =2 to test melting by temporary bins
630 integer, private :: ibinhlmlr = 0 ! =1 use incomplete gammas to determine melting from larger and smaller sizes of hail, and appropriate shed drop sizes
631 ! =2 to test melting by temporary bins
632 integer, private :: ibinnum = 2 ! number of bins for melting of smaller ice (for ibinhmlr = 1)
633 integer, private :: iqhacrmlr = 1 ! turn on/off qhacrmlr
634 integer, private :: iqhlacrmlr = 1 ! turn on/off qhlacrmlr
635 integer, private :: iqhacwshr = 1 ! turn on/off qhacw for T > 0
636 integer, private :: iqhlacwshr = 1 ! turn on/off qhlacw for T > 0
637 real, private :: binmlrmxdia = 40.e-3 ! threshold diameter (graupel/hail) to switch bin-bulk melting to use standard chmlr
638 real, private :: binmlrzrrfac = 1.0 ! factor for reflectivity change ice that sheds while melting
639 real, private :: snowmeltdia = 0 ! If nonzero, sets the size of rain drops from melting snow.
640 real, private :: alphasmlr0 = 14.0 ! shape parameter for drops formed from melting/shedding snow
641 real, private :: delta_alphamlr = 0.5 ! offset from alphamax at which melting does not further collapse the shape parameter
642
643 integer :: iqvsopt = 0 ! =0 use old default for tabqvs; =1 use Bolton formulation (Rogers and Yau)
644
645 integer :: imaxsupopt = 4 ! how to treat saturation adjustment in two-moment droplets
646 ! 1 = add droplets with same mean mass as current droplets
647 ! 2 = add droplets with minimum radius of 30 microns
648 ! 3 = only add 1.5*cxmin to number concentration (allow max size to apply)
649 ! 4 = add droplets with minimum radius of 20 microns
650 real :: maxsupersat = 1.9 ! maximum supersaturation ratio, above which a saturation adustment is done
651 real :: maxlowtempss = 1.08 ! Sat. ratio threshold for allowing droplet nucleation at T < tfrh
652 real :: ssmxuf = 4.0 ! supersaturation at which to start using "ultrafine" CCN (if ccnuf > 0.)
653
654
655 integer, parameter :: icespheres = 0 ! turn ice spheres (frozen droplets) on (1) or off (0). NOT COMPLETE IN WRF/ARPS/CM1 CODE!
656 integer, parameter :: lqmx = 30
657 integer, parameter :: lt = 1
658 integer, parameter :: lv = 2
659 integer, parameter :: lc = 3
660 integer, parameter :: lr = 4
661 integer, parameter :: li = 5
662 integer, private :: lis = 0
663 integer, private :: ls = 6
664 integer, private :: lh = 7
665 integer, private :: lf = 0
666 integer, private :: lhl = 0
667
668 integer, private :: lccn = 9 ! 0 or 9, other indices adjusted accordingly
669 integer, private :: lccnuf = 0
670 integer, private :: lccna = 0
671 integer, private :: lcina = 0
672 integer, private :: lcin = 0
673 integer, private :: lnc = 9
674 integer, private :: lnr = 10
675 integer, private :: lni = 11
676 integer, private :: lnis = 0
677 integer, private :: lns = 12
678 integer, private :: lnh = 13
679 integer, private :: lnf = 0
680 integer, private :: lnhl = 0
681 integer, private :: lnhf = 0
682 integer, private :: lnhlf = 0
683 integer, private :: lss = 0
684 integer :: lvh = 15
685
686 integer, private :: lhab = 8
687 integer, private :: lg = 7
688
689! Particle volume
690
691 integer :: lvi = 0
692 integer :: lvs = 0
693 integer :: lvgl = 0
694 integer :: lvgm = 0
695 integer :: lvgh = 0
696 integer :: lvf = 0
697! integer :: lvh = 16
698 integer :: lvhl = 0
699
700! liquid water fraction (not predicted here but tested for)
701 integer :: lhw = 0
702 integer :: lfw = 0
703 integer :: lsw = 0
704 integer :: lhlw = 0
705 integer :: lhwlg = 0
706 integer :: lhlwlg = 0
707
708! reflectivity (6th moment) ! not predicted here but may be tested against
709
710 integer :: lzr = 0
711 integer :: lzi = 0
712 integer :: lzs = 0
713 integer :: lzgl = 0
714 integer :: lzgm = 0
715 integer :: lzgh = 0
716 integer :: lzf = 0
717 integer :: lzh = 0
718 integer :: lzhl = 0
719
720! Space charge
721
722 integer :: lscw = 0
723 integer :: lscr = 0
724 integer :: lsci = 0
725 integer :: lscis = 0
726 integer :: lscs = 0
727 integer :: lsch = 0
728 integer :: lscf = 0
729 integer :: lschl = 0
730 integer :: lscwi = 0
731 integer :: lscpi = 0
732 integer :: lscni = 0
733 integer :: lscpli = 0
734 integer :: lscnli = 0
735 integer :: lschab = 0
736
737 integer :: lscb = 0
738 integer :: lsce = 0
739 integer :: lsceq = 0
740
741! integer, parameter :: lscmx = 100
742
743 integer :: lne = 0 ! last varible for transforming
744
745 real :: cnoh0 = 4.0e+5
746 real :: hwdn1 = 700.0
747
748 real :: alphai = 0.0 ! shape parameter for ZIEG ice crystals ! not currently used
749 real :: alphas = 0.0 ! shape parameter for ZIEG snow ! used only for single moment
750 real :: alphar = 0.0 ! shape parameter for rain (imurain=1 only)
751 real, private :: alphah = 0.0 ! set in namelist!! shape parameter for ZIEG graupel
752 real, private :: alphahl = 1.0 ! set in namelist!! shape parameter for ZIEG hail
753
754 real :: dmuh = 1.0 ! power in exponential part (graupel)
755 real :: dmuhl = 1.0 ! power in exponential part (hail)
756
757 real, private :: alphamax = 15.
758 real, private :: alphamin = 0.
759 real, parameter :: rnumin = -0.8
760 real, parameter :: rnumax = 15.0
761
762
763 real :: cnu = 0.0 ! default value of droplet shape parameter. Can be diagnosed by setting idiagnosecnu=1
764 real, parameter :: rnu = -0.8, snu = -0.8, cinu = 0.0
765! parameter ( cnu = 0.0, rnu = -0.8, snu = -0.8, cinu = 0.0 )
766
767 real xnu(lc:lqmx) ! 1st shape parameter (mass)
768 real xmu(lc:lqmx) ! 2nd shape parameter (mass)
769 real dnu(lc:lqmx) ! 1st shape parameter (diameter)
770 real dmu(lc:lqmx) ! 2nd shape parameter (diameter)
771
772 real ax(lc:lqmx)
773 real bx(lc:lqmx)
774 real fx(lc:lqmx)
775
776 real da0 (lc:lqmx) ! collection coefficients from Seifert 2005
777 real dab0(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
778 real dab1(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
779 real da1 (lc:lqmx) ! collection coefficients from Seifert 2005
780 real bb (lc:lqmx)
781
782
783! put ipelec here for now....
784 integer :: ipelec = 0
785 integer :: isaund = 0
786 logical :: idoniconly = .false.
787 integer, private :: elec_on_time = -1 ! time (seconds) to turn on charge separation.
788 integer, private :: elec_ramp_time = 0 ! time (interval) for linear ramp after elec_on_time
789 ! (i.e., linear factor on chg sep to smoothly turn on elec)
790 ! full charging rate is achieved at time = elec_on_time + elec_ramp_time
791 integer :: jchgs = 3 ! number of points near boundary where charging is turned off (to keep lightning from getting wonky)
792 integer :: jchgn = 2
793 integer :: ichge = 3
794 integer :: ichgw = 2
795 real :: charging_border = 4000. ! width of no-charging zone from boundary
796 real, private :: delqnw = -1.0e-10!-1.0e-12 !
797 real, private :: delqxw = 1.0e-10! 1.0e-12 !
798 real :: tindmn = 233, tindmx = 298.0 ! min and max temperatures where inductive charging is allowed
799
800!
801! gamma function lookup table
802!
803 integer ngm0,ngm1,ngm2
804 parameter(ngm0=3001,ngm1=500,ngm2=500)
805 double precision, parameter :: dgam = 0.01, dgami = 100.
806 double precision gmoi(0:ngm0) ! ,gmod(0:ngm1,0:ngm2),gmdi(0:ngm1,0:ngm2)
807
808 integer, parameter :: nqiacralpha = 300 !480 ! 240 ! 120 ! 15
809 integer, parameter :: nqiacrratio = 400 ! 500 !50 ! 25
810! real, parameter :: maxratiolu = 25.
811 real, parameter :: maxratiolu = 100. ! 25.
812 real, parameter :: maxalphalu = 15.
813 real, parameter :: minalphalu = -0.95
814 real, parameter :: dqiacralpha = maxalphalu/float(nqiacralpha), dqiacrratio = maxratiolu/float(nqiacrratio)
815 real, parameter :: dqiacrratioinv = 1./dqiacrratio, dqiacralphainv = 1./dqiacralpha
816 integer, parameter :: ialpstart = minalphalu*dqiacralphainv
817 real :: ciacrratio(0:nqiacrratio,ialpstart:nqiacralpha)
818 real :: qiacrratio(0:nqiacrratio,ialpstart:nqiacralpha)
819 real :: ziacrratio(0:nqiacrratio,ialpstart:nqiacralpha)
820 double precision :: gamxinflu(0:nqiacrratio,ialpstart:nqiacralpha,12,2) ! last index for graupel (1) or hail (2)
821! real :: ciacrratio(0:nqiacrratio,0:nqiacralpha)
822! real :: qiacrratio(0:nqiacrratio,0:nqiacralpha)
823! real :: ziacrratio(0:nqiacrratio,0:nqiacralpha)
824! double precision :: gamxinflu(0:nqiacrratio,0:nqiacralpha,12,2) ! last index for graupel (1) or hail (2)
825
826! for 3-moment collection coefficients
827 real, save :: dab0lu(ialpstart:nqiacralpha,ialpstart:nqiacralpha,lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
828 real, save :: dab1lu(ialpstart:nqiacralpha,ialpstart:nqiacralpha,lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
829
830 integer, parameter :: ngdnmm = 9
831 real :: mmgraupvt(ngdnmm,3) ! Milbrandt and Morrison (2013) fall speed coefficients for graupel/hail
832
833 DATA mmgraupvt(:,1) / 50., 150., 250., 350., 450., 550., 650., 750., 850./
834 DATA mmgraupvt(:,2) / 62.923, 94.122, 114.74, 131.21, 145.26, 157.71, 168.98, 179.36, 189.02 /
835 DATA mmgraupvt(:,3) / 0.67819, 0.63789, 0.62197, 0.61240, 0.60572, 0.60066, 0.59663, 0.59330, 0.59048 /
836
837 integer lsc(lc:lqmx)
838 integer ln(lc:lqmx)
839 integer ipc(lc:lqmx)
840 integer lvol(lc:lqmx)
841 integer lz(lc:lqmx)
842 integer lliq(li:lqmx)
843 integer denscale(lc:lqmx) ! flag for density scaling (mixing ratio conversion)
844
845 integer ido(lc:lqmx)
846 logical ldovol
847
848 real xdn0(lc:lqmx)
849 real xdnmx(lc:lqmx), xdnmn(lc:lqmx)
850 real cdx(lc:lqmx)
851 real cno(lc:lqmx)
852 real xvmn(lc:lqmx), xvmx(lc:lqmx)
853 real qxmin(lc:lqmx)
854 real qxmin_init(lc:lqmx)
855
856 integer nqsat
857 parameter(nqsat=1000001) ! (nqsat=20001)
858 real fqsat,fqsati
859 parameter(fqsat=0.002,fqsati=1./fqsat)
860 real tabqvs(nqsat),tabqis(nqsat),dtabqvs(nqsat),dtabqis(nqsat)
861
862!
863! constants
864!
865 real, parameter :: ar = 841.99666 ! rain terminal velocity power law coefficient (LFO)
866 real, parameter :: br = 0.8 ! rain terminal velocity power law coefficient (LFO)
867 real, parameter :: aradcw = -0.27544 !
868 real, parameter :: bradcw = 0.26249e+06 !
869 real, parameter :: cradcw = -1.8896e+10 !
870 real, parameter :: dradcw = 4.4626e+14 !
871 real, parameter :: bta1 = 0.6 ! beta-1 constant used for ice nucleation by deposition (Ferrier 94, among others)
872 real, parameter :: cnit = 1.0e-02 ! No for ice nucleation by deposition (Cotton et al. 86)
873 real, parameter :: dragh = 0.60 ! coefficient used to adjust fall speed for hail versus graupel (Pruppacher and Klett 78)
874 real, parameter :: dnz00 = 1.225 ! reference/MSL air density
875 real, parameter :: rho00 = 1.225 ! reference/MSL air density
876! cs = 4.83607122 ! snow terminal velocity power law coefficient (LFO)
877! ds = 0.25 ! snow terminal velocity power law coefficient (LFO)
878! new values for cs and ds
879 real, parameter :: cs = 12.42 ! snow terminal velocity power law coefficient
880 real, parameter :: ds = 0.42 ! snow terminal velocity power law coefficient
881 real :: cp608 = 0.608 ! constant used in conversion of T to Tv
882 real :: gr = 9.8
883
884 real, parameter :: pi = 3.141592653589793
885 real, parameter :: piinv = 1./pi
886 real, parameter :: pid4 = pi/4.0
887
888!
889! max and min mean volumes
890!
891 real xvrmn, xvrmx0 ! min, max rain volumes
892 real xvsmn, xvsmx ! min, max snow volumes
893 real xvfmn, xvfmx ! min, max frozen drop volumes
894 real xvgmn, xvgmx ! min, max graupel volumes
895 real xvhmn, xvhmn0, xvhmx, xvhmx0 ! min, max hail volumes
896 real xvhlmn, xvhlmx ! min, max lg hail volumes
897
898 real, parameter :: dhlmn = 0.3e-3, dhlmx = 40.e-3
899 real, parameter :: dhmn0 = 0.3e-3
900 real, private :: dhmn = dhmn0, dhmx = -1.
901
902 real, parameter :: cwradn = 2.0e-6, xcradmn = cwradn ! minimum radius
903 real, parameter :: cwradx = 60.e-6, xcradmx = cwradx ! maximum radius
904 real, parameter :: cwc1 = 6.0/(pi*1000.)
905
906! parameter( xvcmn=4.188e-18 ) ! mks min volume = 3 micron radius
907 real, parameter :: xvcmn=0.523599*(2.*cwradn)**3 ! mks min volume = 2.5 micron radius
908 real, parameter :: xvcmx=0.523599*(2.*xcradmx)**3 ! mks max volume = 60 micron radius
909 real, parameter :: cwmasn = 1000.*xvcmn ! minimum mass, defined by radius of 5.0e-6
910 real, parameter :: cwmasx = 1000.*xvcmx ! maximum mass, defined by radius of 50.0e-6
911 real, parameter :: cwmasn5 = 1000.*0.523599*(2.*5.0e-6)**3 ! 5.23e-13
912
913 real, parameter :: xvimn=0.523599*(2.*5.e-6)**3 ! mks min volume = 5 micron radius
914 real, parameter :: xvimx=0.523599*(2.*1.e-3)**3 ! mks max volume = 1 mm radius (solid sphere approx)
915
916 real, private :: xvdmx = -1.0 ! 3.0e-3
917 real :: xvrmx
918 parameter( xvrmn=0.523599*(80.e-6)**3, xvrmx0=0.523599*(6.e-3)**3 ) !( was 4.1887e-9 ) ! mks
919 parameter( xvsmn=0.523599*(0.01e-3)**3, xvsmx=0.523599*(10.e-3)**3 ) !( was 4.1887e-9 ) ! mks
920 parameter( xvfmn=0.523599*(0.1e-3)**3, xvfmx=0.523599*(10.e-3)**3 ) ! mks xvfmx = (pi/6)*(10mm)**3
921 parameter( xvgmn=0.523599*(0.1e-3)**3, xvgmx=0.523599*(10.e-3)**3 ) ! mks xvfmx = (pi/6)*(10mm)**3
922 parameter( xvhmn0=0.523599*(0.3e-3)**3, xvhmx0=0.523599*(20.e-3)**3 ) ! mks xvfmx = (pi/6)*(20mm)**3
923 parameter( xvhlmn=0.523599*(dhlmn)**3, xvhlmx=0.523599*(dhlmx)**3 ) ! mks xvfmx = (pi/6)*(40mm)**3
924
925!
926! electrical permitivity of air C / (N m**2) - check the units
927!
928 real eperao
929 parameter(eperao = 8.8592e-12 )
930
931 real ec,eci ! fundamental unit of charge
932 parameter(ec = 1.602e-19)
933 parameter(eci = 1.0/ec)
934
935 real :: scwppmx = 20.0e-12
936 real :: scippmx = 20.0e-12
937!
938! constants
939!
940 real, parameter :: c1f3 = 1.0/3.0
941
942 real, parameter :: cai = 21.87455
943 real, parameter :: caw = 17.2693882
944 real, parameter :: cbi = 7.66
945 real, parameter :: cbw = 35.86
946
947 real, parameter :: cbwbolton = 29.65 ! constants for Bolton formulation
948 real, parameter :: cawbolton = 17.67
949
950 real, parameter :: tfrh = 233.15
951! --------------------------
952 ! For CCPP, the following variables should be set by the host model, but initial values are set just in case
953 real :: tfr = 273.15
954 real :: cp = 1004.0, rd = 287.04
955 real :: rw = 461.5 ! gas const. for water vapor
956 real :: cpl = 4190.0
957 real :: cpigb = 2106.0
958 real :: cpi = 1.0/1004.0
959 real :: cap = 287.04/1004.0
960 real :: tfrcbw = 273.15 - cbw
961 real :: tfrcbi = 273.15 - cbi
962 real :: rovcp = 287.04/1004.0
963 real :: rdorv = 0.622
964! --------------------------
965 real, parameter :: poo = 1.0e+05
966 real, parameter :: advisc0 = 1.832e-05 ! reference dynamic viscosity (SMT; see Beard & Pruppacher 71)
967 real, parameter :: advisc1 = 1.718e-05 ! dynamic viscosity constant used in thermal conductivity calc
968 real, parameter :: tka0 = 2.43e-02 ! reference thermal conductivity
969
970 ! GHB: Needed for eqtset=2 in cm1
971! REAL, PRIVATE :: cv = cp - rd
972 real, private, parameter :: cv = 717.0 ! specific heat at constant volume - air
973 REAL, PRIVATE, parameter :: cvv = 1408.5
974 ! GHB
975
976 real, parameter :: bfnu0 = (rnu + 2.0)/(rnu + 1.0)
977 real :: ventr, ventrn, ventc, c1sw
978
979
980 real :: cckm,ccne,ccnefac,cnexp,ccne0
981
982 integer, public :: na = 9
983 integer :: nxtra = 1
984 real gf4p5, gf4ds, gf4br
985 real gsnow1, gsnow53, gsnow73
986 real gfcinu1, gfcinu1p47, gfcinu2p47
987 real gfcinu1p22,gfcinu2p22
988 real gfcinu1p18,gfcinu2p18
989
990 real :: cwchtmp0 = 1.0
991 real :: cwchltmp0 = 1.0
992
993 real :: esctot = 1.0e-13
994
995 integer iexy(lc:lqmx,lc:lqmx)
996 integer :: ieswi = 1, ieswc = 1, ieswr = 0
997 integer :: iehlsw = 1, iehli = 1, iehlc = 1, iehlr = 0
998 integer :: iehwsw = 1, iehwi = 1, iehwc = 1, iehwr = 0
999
1000 logical, parameter :: do_satadj_for_wrfchem = .true.
1001
1002 integer, parameter :: ac_opt = 0 ! option flag for alternate aerosol (for NUWRF only)
1003 logical, private :: nuaccoinp = .false.
1004
1005! Note to users: Many of these options are for development and not guaranteed to perform well.
1006! Some may not be functional depending on the version of the code.
1007! Some may be useful for ensemble physics diversity. Feel free to contact Ted Mansell if you have questions
1008! in that regard.
1009 namelist /nssl_mp_params/ &
1010 ndebug, ncdebug,&
1011 iusewetgraupel, &
1012 iusewethail, &
1013 iusewetsnow, &
1014 idbzci, &
1015 vtmaxsed, &
1016 itfall,iscfall, &
1017 infall,irfall,isfall, &
1018 rssflg, &
1019 sssflg, &
1020 hssflg, &
1021 hlssflg, &
1022 irimdenopt,rimdenvwgt, &
1023 rimc1, rimc2, rimc3, rimc4, &
1024 idiagnosecnu, &
1025 icnuclimit, &
1026 irenuc, &
1027 restoreccn, ccntimeconst, cck, &
1028 decayufccn, ufccntimeconst, &
1029 switchccn, old_cccn, &
1030 ciintmx, &
1031 itype1, itype2, &
1032 icenucopt, in_freeze_rain_first, &
1033 naer, &
1034 icfn, &
1035 ibfc, iacr, icracr, &
1036 icracrthresh, &
1037 cwfrz2snowfrac, cwfrz2snowratio, &
1038 ibfr, &
1039 ibiggopt, &
1040 ibiggsmallrain, &
1041 ifrzg,ifiacrg, &
1042 ifrzs,ffrzs, &
1043 iacrsize, &
1044 cimas0, cimas1, cfnfac, &
1045 splintermass, &
1046 ewfac, &
1047 eii0, eii1, &
1048 eri0, esi0, &
1049 eri_cimin, &
1050 eii0hl, eii1hl, &
1051 ehs0, ehs1, &
1052 ess0, ess1, iessopt, &
1053 esstem1,esstem2, &
1054 ircnw, qminrncw,& ! single-moment only
1055 iglcnvi, &
1056 iglcnvs, &
1057 alphahacx, &
1058 fconv, &
1059 eqtot, &
1060 imeyers5, &
1061 iehw, &
1062 ierw, &
1063 iehr0c,iehlr0c, &
1064 alphai, &
1065 alphar, &
1066 alphas, & ! note that alphah and alphahl come through physics namelist
1067 cnu, &
1068 iscni,fscni, &
1069 dfrz, &
1070 dmlt, &
1071 rainfallfac, &
1072 icefallfac, &
1073 snowfallfac, &
1074 graupelfallfac, &
1075 hailfallfac, &
1076 icefallopt, &
1077 icdx,icdxhl, &
1078 axh,bxh,axf,bxf,axhl,bxhl, &
1079 cdhmin, cdhmax, &
1080 cdhdnmin, cdhdnmax, &
1081 cdhlmin, cdhlmax, &
1082 cdhldnmin, cdhldnmax, &
1083 ihmlt, &
1084 ehimin, &
1085 ehimax, &
1086 ehsmax, &
1087 ecollmx, &
1088 ehw0, ehlw0, &
1089 ehr0, ehlr0, &
1090 erw0, &
1091 exwmindiam, &
1092 nsplinter, &
1093 lawson_splinter_fac, &
1094 iqcinit, &
1095 ssmxinit, &
1096 xvdmx, &
1097 dhmn, dhmx, &
1098 fwms,fwmh,fwmhl, &
1099 ifwmhopt, &
1100 ihxw2rain, &
1101 fwmlarge, &
1102 ifwmfall, &
1103 iturbenhance, &
1104 qsdenmod,qhdenmod, &
1105 qsvtmod, &
1106 alphamin,alphamax, &
1107 isnwfrac, &
1108 rescale_low_alpha, &
1109 rescale_low_alphar, &
1110 rescale_low_alphah, &
1111 rescale_low_alphahl, &
1112 rescale_high_alpha, &
1113 ihlcnh, hldia1,iusedw, dwehwmin, dwmin, dwmax, dwtempmin, dg0thresh, &
1114 icvhl2h, hldnmn,hdnmn, &
1115 hlcnhdia, hlcnhqmin, &
1116 isedonly, &
1117 iresetmoments, &
1118 cxmin, zxmin, &
1119 imurain, &
1120 iferwisventr, &
1121 izwisventr, &
1122 qhdpvdn, &
1123 qhacidn, &
1124 sheddiam,sheddiamlg, &
1125 sheddiam0, &
1126 mltdiam1,mltdiam2,mltdiam3,mltdiam4,mltdiam05, &
1127 imaxdiaopt, &
1128 ithompsoncnoh, &
1129 cnohmn, &
1130 ivhmltsoak, &
1131 ioldlimiter, &
1132 isnowfall, &
1133 isnowdens, &
1134 ibiggsnow, &
1135 ixtaltype, &
1136 evapfac, &
1137 depfac, &
1138 dmrauto,irescalerainopt, dmropt,dmhlopt, &
1139 rescale_tempthresh, rescale_wthresh, &
1140 ibinhmlr,ibinhlmlr,imltshddmr, binmlrmxdia, binmlrzrrfac,ibinnum, &
1141 iqhacrmlr, iqhlacrmlr, &
1142 snowmeltdia, &
1143 delta_alphamlr, &
1144 iqvsopt, &
1145 maxsupersat, &
1146 do_accurate_sedimentation, interval_sedi_vt
1147! #####################################################################
1148! #####################################################################
1149
1150 CONTAINS
1151
1152! #####################################################################
1153! #####################################################################
1154
1155
1158 REAL function fqvs(t)
1159 implicit none
1160 real :: t
1161 fqvs = exp(caw*(t-273.15)/(t-cbw))
1162 END FUNCTION fqvs
1163
1166 REAL function fqis(t)
1167 implicit none
1168 real :: t
1169 fqis = exp(cai*(t-273.15)/(t-cbi))
1170 END FUNCTION fqis
1171
1172
1173
1174
1175! #####################################################################
1176! #####################################################################
1177
1178
1182 con_g, con_rd, con_cp, con_rv, con_t0c, con_cliq, con_csol, con_eps )
1183
1184 implicit none
1185 real, intent(in) :: con_g, con_rd, con_cp, con_rv, &
1186 con_t0c, con_cliq, con_csol, con_eps
1187
1188 gr = con_g
1189 tfr = con_t0c
1190 cp = con_cp
1191 rd = con_rd
1192 rw = con_rv
1193 rdorv = con_eps
1194 cpl = con_cliq ! 4190.0
1195 cpigb = con_csol ! 2106.0
1196 cpi = 1./cp
1197 cap = rd/cp
1198 tfrcbw = tfr - cbw
1199 tfrcbi = tfr - cbi
1200 rovcp = rd/cp
1201
1202
1203
1204 RETURN
1205 END SUBROUTINE nssl_2mom_init_const
1206
1207
1208! #####################################################################
1209! #####################################################################
1212 SUBROUTINE nssl_2mom_init( &
1213 & ims,ime, jms,jme, kms,kme, nssl_params, ipctmp, mixphase,ihvol,idoniconlytmp, &
1214 & nssl_graupelfallfac, &
1215 & nssl_hailfallfac, &
1216 & nssl_ehw0, &
1217 & nssl_ehlw0, &
1218 & nssl_icdx, &
1219 & nssl_icdxhl, &
1220 & nssl_icefallfac, &
1221 & nssl_snowfallfac, &
1222 & nssl_cccn, &
1223 & nssl_ufccn, &
1224 & nssl_alphah, &
1225 & nssl_alphahl, &
1226 & nssl_alphar, &
1227 & nssl_density_on, nssl_hail_on, nssl_ccn_on, nssl_icecrystals_on, ccn_is_ccna, &
1228 & errmsg, errflg, &
1229 & infileunit, &
1230 & myrank, mpiroot &
1231 )
1232
1233 implicit none
1234
1235 real, intent(in), optional :: &
1236 & nssl_graupelfallfac, &
1237 & nssl_hailfallfac, &
1238 & nssl_ehw0, &
1239 & nssl_ehlw0, &
1240 & nssl_icefallfac, &
1241 & nssl_snowfallfac, &
1242 & nssl_cccn, &
1243 & nssl_alphah, &
1244 & nssl_alphahl, &
1245 & nssl_alphar
1246 integer, intent(in), optional :: &
1247 & nssl_icdx, &
1248 & nssl_icdxhl, myrank, mpiroot, &
1249 & nssl_ufccn
1250 logical, intent(in), optional :: nssl_density_on, nssl_hail_on, nssl_ccn_on, nssl_icecrystals_on
1251 integer, intent(inout), optional :: ccn_is_ccna
1252
1253 integer, intent(in),optional :: infileunit
1254
1255 ! CCPP error handling
1256 character(len=*), intent( out) :: errmsg
1257 integer, intent( out) :: errflg
1258 integer, intent(in), optional :: ims,ime, jms,jme, kms,kme
1259
1260 real, intent(in), dimension(20), optional :: nssl_params
1261
1262
1263
1264 integer, intent(in) :: ipctmp,mixphase
1265 integer, optional, intent(in) :: ihvol
1266 logical, optional, intent(in) :: idoniconlytmp
1267
1268 integer :: igvol_local = 1
1269 logical :: wrote_namelist = .false.
1270 logical :: wrf_dm_on_monitor
1271 integer :: hail_on = -1, density_on = -1, icecrystals_on = 1
1272 integer :: ccn_on = -1
1273
1274 double precision :: arg
1275 real :: temq
1276 integer :: igam
1277 integer :: i,il,j,l
1278 integer :: ltmp
1279 integer :: isub
1280 real :: bxh1,bxhl1
1281
1282 real :: alp,ratio
1283 double precision :: x,y,y2,y7
1284 logical :: turn_on_ccna, turn_on_cina
1285 integer :: iufccn = 0
1286 integer :: istat
1287
1288 real :: alpjj, alpii, xnuii, xnujj
1289 integer :: ii, jj
1290
1291
1292 errmsg = ''
1293 errflg = 0
1294 turn_on_ccna = .false.
1295 turn_on_cina = .false.
1296
1297! IF ( present( igvol ) ) THEN
1298! igvol_local = igvol
1299! ENDIF
1300
1301 IF ( present( nssl_hail_on ) ) THEN
1302 IF ( nssl_hail_on ) THEN
1303 hail_on = 1
1304 ELSE
1305 hail_on = 0
1306 ENDIF
1307 ENDIF
1308
1309 IF ( present( nssl_density_on ) ) THEN
1310 IF ( nssl_density_on ) THEN
1311 density_on = 1
1312 ELSE
1313 density_on = 0
1314 ENDIF
1315 ENDIF
1316
1317 IF ( present( nssl_icecrystals_on ) ) THEN
1318 IF ( nssl_icecrystals_on ) THEN
1319 icecrystals_on = 1
1320 ELSE
1321 icecrystals_on = 0
1322 ! renucfrac = 1.0 ! why was this set to 1?
1323 ffrzs = 1.0
1324 ENDIF
1325 ENDIF
1326
1327
1328!
1329! set some global values from namelist input
1330!
1331
1332 IF ( present( nssl_params ) ) THEN
1333 ccn = abs( nssl_params(1) )
1334 alphah = nssl_params(2)
1335 alphahl = nssl_params(3)
1336 cnoh = nssl_params(4)
1337 cnohl = nssl_params(5)
1338 cnor = nssl_params(6)
1339 cnos = nssl_params(7)
1340 rho_qh = nssl_params(8)
1341 rho_qhl = nssl_params(9)
1342 rho_qs = nssl_params(10)
1343 IF ( nint(nssl_params(13)) == 1 ) THEN
1344 ! hack to switch CCN field to CCNA (activated ccn)
1345! invertccn = .true.
1346 turn_on_ccna = .true.
1347 irenuc = 7
1348 ENDIF
1349 ccnuf = abs( nssl_params(14) )
1350 IF ( present(nssl_ufccn) ) iufccn = nssl_ufccn
1351
1352 ENDIF
1353 alphar = nssl_params(15)
1354! ipelec = Nint(nssl_params(11))
1355! isaund = Nint(nssl_params(12))
1356
1357
1358 IF ( present(nssl_graupelfallfac) ) graupelfallfac = nssl_graupelfallfac
1359 IF ( present(nssl_hailfallfac) ) hailfallfac = nssl_hailfallfac
1360 IF ( present(nssl_ehw0) ) THEN
1361 IF ( nssl_ehw0 > 0.0 ) ehw0 = nssl_ehw0
1362 ENDIF
1363 IF ( present(nssl_ehlw0) ) THEN
1364 IF ( nssl_ehlw0 > 0.0 ) ehlw0 = nssl_ehlw0
1365 ENDIF
1366 IF ( present(nssl_icdx) ) icdx = nssl_icdx
1367 IF ( present(nssl_icdxhl) ) icdxhl = nssl_icdxhl
1368 IF ( present(nssl_icefallfac) ) icefallfac = nssl_icefallfac
1369 IF ( present(nssl_snowfallfac) ) snowfallfac = nssl_snowfallfac
1370 IF ( present(nssl_cccn) ) THEN
1371 IF (nssl_cccn > 1 ) ccn = nssl_cccn
1372 ENDIF
1373 IF ( present(nssl_alphah) ) THEN
1374 IF ( nssl_alphah > -1. ) alphah = nssl_alphah
1375 ENDIF
1376 IF ( present(nssl_alphahl) ) THEN
1377 IF ( nssl_alphahl > -1. ) alphahl = nssl_alphahl
1378 ENDIF
1379 IF ( present(nssl_alphar) ) THEN
1380 IF ( nssl_alphar > -1.0 ) alphar = nssl_alphar
1381 ENDIF
1382
1383
1384 ipconc = ipctmp
1385
1386 IF ( ipconc < 5 ) THEN
1387 ihlcnh = 0
1388 ENDIF
1389
1390 IF ( ihlcnh <= 0 ) THEN
1391 IF ( ipconc == 5 ) THEN
1392 ihlcnh = 3
1393 ELSEIF ( ipconc >= 6 ) THEN
1394 ihlcnh = 3
1395 ENDIF
1396 ENDIF
1397
1398
1399
1400
1401
1402 IF ( .false. ) THEN ! set to true to enable internal namelist read
1403 open(15,file='input.nml',status='old',form='formatted',action='read')
1404 rewind(15)
1405 read(15,nml=nssl_mp_params,iostat=istat)
1406 close(15)
1407 IF ( present ( myrank ) .and. present ( mpiroot ) ) THEN
1408 IF ( myrank == mpiroot ) THEN
1409 IF ( istat /= 0 ) THEN
1410 write(0,*) 'NSSL_2MOM_INIT: PROBLEM WITH NSSL_MP_PARAMS namelist: not found or bad token'
1411 ENDIF
1412
1413! write(0,*) 'iusewetsnow = ',iusewetsnow
1414
1415 open(15,file='nssl_mp_params.out',status='unknown',form='formatted')
1416 write(15,nml=nssl_mp_params)
1417 close(15)
1418 ENDIF
1419 ENDIF
1420 ENDIF
1421
1422
1423
1424 IF ( iufccn > 0 ) THEN ! make sure to use option that uses UF ccn
1425 irenuc = 7
1426 IF ( ccnuf <= 0.0 ) decayufccn = .true. ! assume surface emission and need decay
1427 IF ( i_uf_or_ccn > 0 ) THEN
1428 ufbackground = 0.0
1429 ccntimeconst = ufccntimeconst
1430 ENDIF
1431 ENDIF
1432
1433 IF ( present( nssl_ccn_on ) ) THEN
1434 IF ( nssl_ccn_on ) THEN
1435 ccn_on = 1
1436 ELSE
1437 ccn_on = 0
1438 irenuc = 2
1439 ENDIF
1440 ENDIF
1441
1442 IF ( irenuc >= 5 ) THEN
1443 turn_on_ccna = .true.
1444 IF ( present( nssl_ccn_on ) ) THEN
1445 IF ( .not. nssl_ccn_on ) THEN
1446 errmsg = 'NSSL_MP Error: Must have nssl_ccn_on=1 for irenuc >= 5!'
1447 errflg = 1
1448 return
1449 ENDIF
1450 ENDIF
1451 ENDIF
1452
1453 IF ( present( ccn_is_ccna ) .and. ccn_on == 1 ) THEN
1454 IF ( ccn_is_ccna > 0 ) THEN
1455 turn_on_ccna = .true.
1456 ELSE
1457 IF ( irenuc >= 5 ) THEN
1458 ccn_is_ccna = 1
1459 ENDIF
1460 ENDIF
1461 ENDIF
1462
1463 cwccn = ccn
1464
1465 lhab = 8
1466 lhl = 8
1467 IF ( icespheres >= 1 ) THEN
1468 lhab = lhab + 1
1469 lis = li + 1
1470 ls = ls + 1
1471 lh = lh + 1
1472 lhl = lhl + 1
1473 ENDIF
1474 IF ( hail_on == -1 ) THEN ! hail_on is not set
1475 hail_on = 1
1476 IF ( ihvol <= -1 .or. ihvol == 2 ) THEN
1477 IF ( ihvol == -1 .or. ihvol == -2 ) THEN
1478 lhab = lhab - 1 ! turns off hail
1479 lhl = 0
1480 hail_on = 0
1481 ! past me thought it would be a good idea to change graupel factors when hail is off....
1482 ! ehw0 = 0.75
1483 ! iehw = 2
1484 ! dfrz = Max( dfrz, 0.5e-3 )
1485 ENDIF
1486 IF ( ihvol == -2 .or. ihvol == 2 .or. icecrystals_on == 0 ) THEN ! ice crystals are turned off
1487 ! a value of 2? means to turn off ice crystals but turn on hail
1488 ! renucfrac = 1.0 ! why?
1489 ffrzs = 1.0
1490 ! idoci = 0 ! try this later
1491 ENDIF
1492 ENDIF
1493
1494 ELSE ! hail_on is set
1495 IF ( hail_on == 0 ) THEN
1496 lhab = lhab - 1 ! turns off hail
1497 lhl = 0
1498 ELSE
1499 ! assume default that hail is on
1500 ENDIF
1501 ENDIF
1502
1503 IF ( density_on == -1 ) THEN ! density flag not set, so default is to predict it
1504 density_on = 1
1505 ENDIF
1506
1507
1508 IF ( iresetmoments == 0 ) iresetmoments = 1 ! lhl
1509! write(0,*) 'wrf_init: lhab,lhl,hail_on,density_on = ',lhab,lhl,hail_on,density_on
1510
1511! IF ( ipelec > 0 ) idonic = .true.
1512
1513!
1514! Build lookup table for saturation mixing ratio (Soong and Ogura 73)
1515!
1516
1517 do l = 1,nqsat
1518 temq = 163.15 + (l-1)*fqsat
1519 IF ( iqvsopt == 0 ) THEN
1520 tabqvs(l) = exp(caw*(temq-273.15)/(temq-cbw))
1521 dtabqvs(l) = ((-caw*(-273.15 + temq))/(temq - cbw)**2 + &
1522 & caw/(temq - cbw))*tabqvs(l)
1523 ELSE
1524 tabqvs(l) = exp(caw*(temq-273.15)/(temq-cbw))
1525 dtabqvs(l) = ((-cawbolton*(-273.15 + temq))/(temq - cbwbolton)**2 + &
1526 & cawbolton/(temq - cbwbolton))*tabqvs(l)
1527 ENDIF
1528 tabqis(l) = exp(cai*(temq-273.15)/(temq-cbi))
1529 dtabqis(l) = ((-cai*(-273.15 + temq))/(temq - cbi)**2 + &
1530 & cai/(temq - cbi))*tabqis(l)
1531 end do
1532
1533 bx(lr) = 0.85
1534 ax(lr) = 1647.81
1535 fx(lr) = 135.477
1536
1537
1538 IF ( icdx == 6 ) THEN
1539 bx(lh) = 0.6 ! Milbrandt and Morrison (2013) for density of 550.
1540 ax(lh) = 157.71
1541! ELSEIF ( icdx == 1 ) THEN
1542! bx(lh) = bxh
1543! ax(lh) = axh
1544 ELSEIF ( icdx > 1 ) THEN
1545 bx(lh) = 0.5
1546 ax(lh) = 75.7149
1547 ELSEIF ( icdx == 0 ) THEN
1548 bx(lh) = 0.37 ! 0.6 ! Ferrier 1994 graupel
1549 ax(lh) = 19.3
1550 ELSE ! icdx < 0
1551! ax(lh) = 206.984 ! Ferrier 1994 hail/frozen drops
1552! bx(lh) = 0.6384
1553 bx(lh) = bxh
1554 ax(lh) = axh
1555 ENDIF
1556
1557! bx(lh) = 0.6
1558
1559 IF ( lhl .gt. 1 ) THEN
1560 IF ( icdxhl == 6 ) THEN
1561 bx(lhl) = 0.593 ! Milbrandt and Morrison (2013) for density of 750.
1562 ax(lhl) = 179.36
1563 ELSEIF (icdxhl == 0 ) THEN
1564 ax(lhl) = 206.984 ! Ferrier 1994
1565 bx(lhl) = 0.6384
1566 ELSEIF (icdxhl > 0 ) THEN
1567 bx(lhl) = 0.5
1568 ax(lhl) = 75.7149
1569 ELSE
1570 bx(lhl) = bxhl
1571 ax(lhl) = axhl
1572 ENDIF
1573 ENDIF
1574
1575! fill in the complete gamma function lookup table
1576 gmoi(0) = 1.d32
1577 do igam = 1,ngm0
1578 arg = dgam*igam
1579 gmoi(igam) = gamma_dp(arg)
1580 end do
1581
1582 ! build lookup table to compute the number and mass fractions of rain drops
1583 ! (imurain=1) greater than a given diameter. Used for qiacr and ciacr
1584 ! Uses incomplete gamma functions
1585 ! The terms with bxh or bxhl will be off if the actual bxh or bxhl is different from the base value (icdx=6 option)
1586
1587 bxh1 = bx(lh)
1588 bxhl1 = bx(max(lh,lhl))
1589
1590! DO j = 0,nqiacralpha
1591 DO j = ialpstart,nqiacralpha
1592 alp = float(j)*dqiacralpha
1593 y = gamma_dpr(1.+alp)
1594 y2 = gamma_dpr(2.+alp)
1595 DO i = 0,nqiacrratio
1596 ratio = float(i)*dqiacrratio
1597 x = gamxinfdp( 1.+alp, ratio )
1598! write(0,*) 'i, x/y = ',i, x/y
1599 ciacrratio(i,j) = x/y
1600
1601 ! graupel (.,.,.,1)
1602 gamxinflu(i,j,1,1) = x/y
1603 gamxinflu(i,j,2,1) = gamxinfdp( 2.0+alp, ratio )/y
1604 gamxinflu(i,j,3,1) = gamxinfdp( 2.5+alp+0.5*bxh1, ratio )/y
1605 gamxinflu(i,j,5,1) = (gamma_dpr(5.0+alp) - gamxinfdp( 5.0+alp, ratio ))/y
1606 gamxinflu(i,j,6,1) = (gamma_dpr(5.5+alp+0.5*bxh1) - gamxinfdp( 5.5+alp+0.5*bxh1, ratio ))/y
1607 gamxinflu(i,j,9,1) = gamxinfdp( 1.0+alp, ratio )/y
1608 gamxinflu(i,j,10,1)= gamxinfdp( 4.0+alp, ratio )/y
1609
1610 gamxinflu(i,j,12,1) = gamxinfdp( 2.0+alp, ratio )/y2
1611
1612 ! hail (.,.,.,2)
1613 gamxinflu(i,j,1,2) = gamxinflu(i,j,1,1)
1614 gamxinflu(i,j,2,2) = gamxinflu(i,j,2,1)
1615 gamxinflu(i,j,3,2) = gamxinfdp( 2.5+alp+0.5*bxhl1, ratio )/y
1616 gamxinflu(i,j,5,2) = gamxinflu(i,j,5,1)
1617 gamxinflu(i,j,6,2) = (gamma_dpr(5.5+alp+0.5*bxhl1) - gamxinfdp( 5.5+alp+0.5*bxhl1, ratio ))/y
1618 gamxinflu(i,j,9,2) = gamxinflu(i,j,9,1)
1619 gamxinflu(i,j,10,2)= gamxinflu(i,j,10,1)
1620
1621 IF ( alp > 1.1 ) THEN
1622! gamxinflu(i,j,7,1) = gamxinfdp( alp - 1., ratio )/y
1623 gamxinflu(i,j,7,1) = (gamma_dpr(alp - 1.) - gamxinfdp( alp - 1., ratio ))/y
1624! gamxinflu(i,j,8,1) = gamxinfdp( alp - 0.5 + 0.5*bxh, ratio )/y
1625 gamxinflu(i,j,8,1) = (gamma_dpr(alp - 0.5 + 0.5*bxh1) - gamxinfdp( alp - 0.5 + 0.5*bxh1, ratio ))/y
1626! gamxinflu(i,j,8,2) = gamxinfdp( alp - 0.5 + 0.5*bxhl1, ratio )/y
1627 gamxinflu(i,j,8,2) = (gamma_dpr(alp - 0.5 + 0.5*bxhl1) - gamxinfdp( alp - 0.5 + 0.5*bxhl1, ratio ))/y
1628 ELSE
1629! gamxinflu(i,j,7,1) = gamxinfdp( .1, ratio )/y
1630 gamxinflu(i,j,7,1) = (gamma_dpr(0.1) - gamxinfdp( 0.1, ratio ) )/y
1631! gamxinflu(i,j,8,1) = gamxinfdp( 1.1 - 0.5 + 0.5*bxh1, ratio )/y
1632! gamxinflu(i,j,8,2) = gamxinfdp( 1.1 - 0.5 + 0.5*bxhl1, ratio )/y
1633 gamxinflu(i,j,8,1) = (gamma_dpr(1.1 - 0.5 + 0.5*bxh1) - gamxinfdp( 1.1 - 0.5 + 0.5*bxh1, ratio ) )/y
1634 gamxinflu(i,j,8,2) = (gamma_dpr(1.1 - 0.5 + 0.5*bxhl1) - gamxinfdp( 1.1 - 0.5 + 0.5*bxhl1, ratio ) )/y
1635 ENDIF
1636
1637 gamxinflu(i,j,7,2) = gamxinflu(i,j,7,1)
1638
1639 ENDDO
1640 ENDDO
1641 ciacrratio(0,:) = 1.0
1642
1643 DO j = ialpstart,nqiacralpha
1644 alp = float(j)*dqiacralpha
1645 y = gamma_sp(4.+alp)
1646 y7 = gamma_sp(7.+alp)
1647 DO i = 0,nqiacrratio
1648 ratio = float(i)*dqiacrratio
1649
1650 ! mass fraction
1651 x = gamxinfdp( 4.+alp, ratio )
1652! write(0,*) 'i, x/y = ',i, x/y
1653 qiacrratio(i,j) = x/y
1654 gamxinflu(i,j,4,1) = x/y
1655 gamxinflu(i,j,4,2) = x/y
1656
1657 ! reflectivity fraction
1658 x = gamxinfdp( 7.+alp, ratio )
1659 ziacrratio(i,j) = x/y7
1660 gamxinflu(i,j,11,1) = x/y7
1661 gamxinflu(i,j,11,2) = x/y7
1662
1663 ENDDO
1664 ENDDO
1665 qiacrratio(0,:) = 1.0
1666
1667
1668 lccn = 0
1669 lccnuf = 0
1670 lccna = 0
1671 lnc = 0
1672 lnr = 0
1673 lni = 0
1674 lnis = 0
1675 lns = 0
1676 lnh = 0
1677 lnhl = 0
1678 lvh = 0
1679 lvhl = 0
1680 lzr = 0
1681 lzh = 0
1682 lzhl = 0
1683 lsw = 0
1684 lhw = 0
1685 lhlw = 0
1686
1687 denscale(:) = 0
1688
1689! lccn = 9
1690
1691
1692 IF ( ipconc == 0 ) THEN
1693 IF ( hail_on == 1 ) THEN ! turn on graupel density for 1-moment scheme
1694 lvh = 9
1695 ltmp = 9
1696 denscale(lvh) = 1
1697 ELSE ! no hail, 'LFO' scheme
1698 ltmp = lhab
1699 lhl = 0
1700 ENDIF
1701 ELSEIF ( ipconc == 5 ) THEN
1702 ltmp = lhab
1703 IF ( iufccn > 0 ) THEN
1704 ltmp = ltmp+1
1705 lccnuf = ltmp
1706 denscale(lccnuf) = 1
1707 ENDIF
1708 lccn= ltmp+1 ! 9
1709 lnc = ltmp+2 ! 10
1710 lnr = ltmp+3 ! 11
1711 lni = ltmp+4 !12
1712 lns = ltmp+5 !13
1713 lnh = ltmp+6 !14
1714 ltmp = lnh
1715 IF ( hail_on == 1 ) THEN
1716 ltmp = ltmp + 1
1717 lnhl = ltmp ! lhab+7 ! 15
1718 ENDIF
1719 IF ( density_on >= 1 ) THEN
1720 ltmp = ltmp + 1
1721 lvh = ltmp ! lhab+8 + isub ! 16 + isub ! isub adjusts to 15 if hail is off
1722! ltmp = lvh
1723 ENDIF
1724 denscale(lccn:ltmp) = 1
1725 IF ( density_on == 1 .and. hail_on == 1 ) THEN
1726 ltmp = ltmp + 1
1727 lvhl = ltmp
1728! ltmp = lvhl
1729 denscale(lvhl) = 1
1730 ENDIF
1731 IF ( mixedphase ) THEN
1732 ltmp = ltmp + 1
1733 lsw = ltmp
1734 ltmp = ltmp + 1
1735 lhw = ltmp
1736 IF ( lhl > 1 ) THEN
1737 ltmp = ltmp + 1
1738 lhlw = ltmp
1739 ENDIF
1740! ltmp = lhlw
1741 ENDIF
1742 ELSEIF ( ipconc >= 6 ) THEN
1743 ltmp = lhab
1744 IF ( iufccn > 0 ) THEN
1745 ltmp = ltmp+1
1746 lccnuf = ltmp
1747 denscale(lccnuf) = 1
1748 ENDIF
1749
1750 lccn= ltmp+1 ! 9
1751 lnc = ltmp+2 ! 10
1752 lnr = ltmp+3 ! 11
1753 lni = ltmp+4 !12
1754 lns = ltmp+5 !13
1755 lnh = ltmp+6 !14
1756 ltmp = lnh
1757 IF ( lhl > 0 ) THEN
1758 ltmp = ltmp + 1
1759 lnhl = ltmp ! lhab+7 ! 15
1760 ENDIF
1761 IF ( density_on == 1 ) THEN
1762 ltmp = ltmp + 1
1763 lvh = ltmp ! lhab+8 + isub ! 16 + isub ! isub adjusts to 15 if hail is off
1764 ENDIF
1765! ltmp = lvh
1766 denscale(lccn:ltmp) = 1
1767 IF ( density_on == 1 .and. hail_on == 1 ) THEN
1768 ltmp = ltmp + 1
1769 lvhl = ltmp
1770! ltmp = lvhl
1771 denscale(lvhl) = 1
1772 ENDIF
1773
1774 IF ( ipconc == 6 ) THEN
1775 ltmp = ltmp + 1
1776 lzh = ltmp
1777 ELSEIF ( ipconc == 7 ) THEN
1778 ltmp = ltmp + 1
1779 lzh = ltmp
1780 ltmp = ltmp + 1
1781 lzr = ltmp
1782 ELSEIF ( ipconc == 8 ) THEN
1783 ltmp = ltmp + 1
1784 lzh = ltmp
1785 ltmp = ltmp + 1
1786 lzr = ltmp
1787 IF ( lhl > 1 ) THEN
1788 ltmp = ltmp + 1
1789 lzhl = ltmp
1790 ENDIF
1791 ! write(0,*) 'ipcon,lzr = ',ipconc,lzr,lzh,lzhl
1792 ENDIF
1793! ltmp = lvh
1794 ! denscale(lccn:lvh) = 1
1795 IF ( mixedphase ) THEN
1796 ltmp = ltmp + 1
1797 lsw = ltmp
1798 ltmp = ltmp + 1
1799 lhw = ltmp
1800 IF ( lhl > 1 ) THEN
1801 ltmp = ltmp + 1
1802 lhlw = ltmp
1803 ENDIF
1804! ltmp = lhlw
1805 ENDIF
1806 ELSE
1807 errmsg = 'nssl_2mom_init: Invalid value of ipctmp'
1808 errflg = 1
1809 RETURN
1810 ENDIF
1811
1812
1813
1814 ! write(0,*) 'wrf_init: lh,lhl,lzh,lzhl = ',lh,lhl,lzh,lzhl
1815 ! write(0,*) 'wrf_init: ipconc = ',ipconc
1816 ! write(0,*) 'wrf_init: irenuc, turn_on_ccna = ',irenuc, turn_on_ccna
1817 IF ( turn_on_ccna ) THEN
1818 ltmp = ltmp + 1
1819 lccna = ltmp
1820 denscale(ltmp) = 1
1821 ENDIF
1822
1823 IF ( turn_on_cina ) THEN
1824 ltmp = ltmp + 1
1825 lcina = ltmp
1826 denscale(ltmp) = 1
1827 ENDIF
1828
1829 IF ( turn_on_cin .or. is_aerosol_aware ) THEN
1830 ltmp = ltmp + 1
1831 lcin = ltmp
1832 denscale(ltmp) = 1
1833!debug write(0,*) 'Setting lcin to ',lcin
1834 ENDIF
1835 na = ltmp
1836
1837 ln(lc) = lnc
1838 ln(lr) = lnr
1839 ln(li) = lni
1840 ln(ls) = lns
1841 ln(lh) = lnh
1842 IF ( lhl .gt. 1 ) ln(lhl) = lnhl
1843
1844 ipc(lc) = 2
1845 ipc(lr) = 3
1846 ipc(li) = 1
1847 ipc(ls) = 4
1848 ipc(lh) = 5
1849 IF ( lhl .gt. 1 ) ipc(lhl) = 5
1850
1851 ldovol = .false.
1852 lvol(:) = 0
1853 lvol(li) = lvi
1854 lvol(ls) = lvs
1855 lvol(lh) = lvh
1856 IF ( lhl .gt. 1 .and. lvhl .gt. 1 ) lvol(lhl) = lvhl
1857
1858 lne = max(lnh,lnhl)
1859 lne = max(lne,lvh)
1860 lne = max(lne,lvhl)
1861 lne = max(lne,na)
1862
1863 lsc(:) = 0
1864 lsc(lc) = lscw
1865 lsc(lr) = lscr
1866 lsc(li) = lsci
1867 lsc(ls) = lscs
1868 lsc(lh) = lsch
1869 IF ( lhl .gt. 1 ) lsc(lhl) = lschl
1870
1871
1872 DO il = lc,lhab
1873 ldovol = ldovol .or. ( lvol(il) .gt. 1 )
1874 ENDDO
1875
1876! write(0,*) 'nssl_2mom_init: ldovol = ',ldovol
1877
1878 lz(:) = 0
1879 lz(lr) = lzr
1880 lz(li) = lzi
1881 lz(ls) = lzs
1882 lz(lh) = lzh
1883 IF ( lhl .gt. 1 .and. lzhl > 1 ) lz(lhl) = lzhl
1884
1885 lliq(:) = 0
1886 lliq(ls) = lsw
1887 lliq(lh) = lhw
1888 IF ( lhl .gt. 1 ) lliq(lhl) = lhlw
1889 IF ( mixedphase ) THEN
1890! write(0,*) 'lsw,lhw,lhlw = ',lsw,lhw,lhlw
1891 ENDIF
1892
1893
1894
1895 xnu(lc) = cnu
1896 xmu(lc) = 1.
1897
1898 IF ( imurain == 3 ) THEN
1899 xnu(lr) = rnu
1900 xmu(lr) = 1.
1901 ELSEIF ( imurain == 1 ) THEN
1902 xnu(lr) = (alphar - 2.0)/3.0
1903 xmu(lr) = 1./3.
1904 ENDIF
1905
1906 xnu(li) = cinu
1907 xmu(li) = 1.
1908
1909 IF ( lis >= 1 ) THEN
1910 xnu(lis) = 0.0
1911 xmu(lis) = 1.
1912 ENDIF
1913
1914 dnu(lc) = 3.*xnu(lc) + 2. ! alphac
1915 dmu(lc) = 3.*xmu(lc)
1916
1917 dnu(lr) = 3.*xnu(lr) + 2. ! alphar
1918 dmu(lr) = 3.*xmu(lr)
1919
1920 xnu(ls) = snu
1921 xmu(ls) = 1.
1922
1923 dnu(ls) = 3.*xnu(ls) + 2. ! -0.4 ! alphas
1924 dmu(ls) = 3.*xmu(ls)
1925
1926
1927 dnu(lh) = alphah
1928 dmu(lh) = dmuh
1929
1930 xnu(lh) = (dnu(lh) - 2.)/3.
1931 xmu(lh) = dmuh/3.
1932
1933
1934 IF ( imurain == 3 ) THEN ! rain is gamma of volume
1935 rz = ((4. + alphah)*(5. + alphah)*(6. + alphah)*(1. + xnu(lr)))/ &
1936 & ((1 + alphah)*(2 + alphah)*(3 + alphah)*(2. + xnu(lr)))
1937
1938! IF ( ipconc .lt. 5 ) alphahl = alphah
1939
1940 rzhl = ((4. + alphahl)*(5. + alphahl)*(6. + alphahl)*(1. + xnu(lr)))/ &
1941 & ((1. + alphahl)*(2. + alphahl)*(3. + alphahl)*(2. + xnu(lr)))
1942
1943 rzs = 1. ! assume rain and snow are both gamma volume
1944
1945 ELSE ! rain is gamma of diameter
1946
1947 rz = ((4. + alphah)*(5. + alphah)*(6. + alphah)*(1. + alphar)*(2. + alphar)*(3. + alphar))/ &
1948 & ((1 + alphah)*(2 + alphah)*(3 + alphah)*(4. + alphar)*(5. + alphar)*(6. + alphar))
1949
1950 rzhl = ((4. + alphahl)*(5. + alphahl)*(6. + alphahl)*(1. + alphar)*(2. + alphar)*(3. + alphar))/ &
1951 & ((1 + alphahl)*(2 + alphahl)*(3 + alphahl)*(4. + alphar)*(5. + alphar)*(6. + alphar))
1952
1953
1954 rzs = &
1955 & ((1. + alphar)*(2. + alphar)*(3. + alphar)*(2. + xnu(ls)))/ &
1956 & ((4. + alphar)*(5. + alphar)*(6. + alphar)*(1. + xnu(ls)))
1957
1958
1959 ENDIF
1960
1961 IF ( ipconc <= 5 ) THEN
1962 imltshddmr = min(1, imltshddmr)
1963 ibinhmlr = 0
1964 ibinhlmlr = 0
1965 ENDIF
1966
1967 IF ( ipconc > 5 .and. (ibinhmlr == 0 .and. ibinhlmlr == 0 ) ) THEN
1968 imltshddmr = min(1, imltshddmr)
1969 ENDIF
1970
1971! write(0,*) 'rz,rzhl = ', rz,rzhl
1972
1973 IF ( ipconc .lt. 4 ) THEN
1974
1975 dnu(ls) = alphas
1976 dmu(ls) = 1.
1977
1978 xnu(ls) = (dnu(ls) - 2.)/3.
1979 xmu(ls) = 1./3.
1980
1981
1982 ENDIF
1983
1984 IF ( lhl .gt. 1 ) THEN
1985
1986 dnu(lhl) = alphahl
1987 dmu(lhl) = dmuhl
1988
1989 xnu(lhl) = (dnu(lhl) - 2.)/3.
1990 xmu(lhl) = dmuhl/3.
1991
1992 ENDIF
1993
1994 cno(lc) = 1.0e+08
1995 IF ( li .gt. 1 ) cno(li) = 1.0e+08
1996 cno(lr) = cnor
1997 IF ( ls .gt. 1 ) cno(ls) = cnos ! 8.0e+06
1998 IF ( lh .gt. 1 ) cno(lh) = cnoh ! 4.0e+05
1999 IF ( lhl .gt. 1 ) cno(lhl) = cnohl ! 4.0e+05
2000!
2001! density maximums and minimums
2002!
2003 xdnmx(:) = 900.0
2004
2005 xdnmx(lr) = 1000.0
2006 xdnmx(lc) = 1000.0
2007 xdnmx(li) = 917.0
2008 xdnmx(ls) = 300.0
2009 xdnmx(lh) = 900.0
2010 IF ( lhl .gt. 1 ) xdnmx(lhl) = 900.0
2011!
2012 xdnmn(:) = 900.0
2013
2014 xdnmn(lr) = 1000.0
2015 xdnmn(lc) = 1000.0
2016 xdnmn(li) = 100.0
2017 xdnmn(ls) = 100.0
2018 xdnmn(lh) = hdnmn
2019 IF ( lhl .gt. 1 ) xdnmn(lhl) = hldnmn
2020
2021 xdn0(:) = 900.0
2022
2023 xdn0(lc) = 1000.0
2024 xdn0(li) = 900.0
2025 xdn0(lr) = 1000.0
2026 xdn0(ls) = rho_qs ! 100.0
2027 xdn0(lh) = rho_qh ! (0.5)*(xdnmn(lh)+xdnmx(lh))
2028 IF ( lhl .gt. 1 ) xdn0(lhl) = rho_qhl ! 800.0
2029
2030!
2031! Set terminal velocities...
2032! also set drag coefficients
2033!
2034 cdx(lr) = 0.60
2035 cdx(lh) = 0.8 ! 1.0 ! 0.45
2036 cdx(ls) = 2.00
2037 IF ( lhl .gt. 1 ) cdx(lhl) = 0.45
2038
2039 ido(lc) = idocw
2040 ido(lr) = idorw
2041 ido(li) = idoci
2042 ido(ls) = idosw
2043 ido(lh) = idohw
2044 IF ( lhl .gt. 1 ) ido(lhl) = idohl
2045
2046 IF ( irfall .lt. 0 ) irfall = infall
2047 IF ( isfall .lt. 0 ) isfall = infall
2048 IF ( lzr > 0 ) irfall = 0
2049
2050 qccn = ccn/rho00
2051 qccnuf = ccnuf/rho00
2052 IF ( old_cccn > 0.0 ) THEN
2053 old_qccn = old_cccn/rho00
2054 ELSE
2055 old_qccn = qccn
2056 ENDIF
2057! xvcmx = (4./3.)*pi*xcradmx**3
2058
2059! set max rain diameter
2060 IF ( xvdmx .gt. 0.0 ) THEN
2061 xvrmx = 0.523599*(xvdmx)**3
2062 ELSE
2063 xvrmx = xvrmx0
2064 ENDIF
2065
2066 IF ( dhmn <= 0.0 ) THEN
2067 xvhmn = xvhmn0
2068! xvhmn = Min(xvhmn0, 0.523599*(dfrz)**3 )
2069 ELSE
2070 xvhmn = 0.523599*(dhmn)**3
2071! xvhmn = 0.523599*(Min(dhmn,dfrz))**3
2072 ENDIF
2073
2074 IF ( dhmx <= 0.0 ) THEN
2075 xvhmx = xvhmx0
2076 ELSE
2077 xvhmx = 0.523599*(dhmx)**3
2078 ENDIF
2079
2080 IF ( qhdpvdn < 0. ) qhdpvdn = xdnmn(lh)
2081 IF ( qhacidn < 0. ) qhacidn = xdnmn(lh)
2082
2083! load max/min diameters
2084 xvmn(lc) = xvcmn
2085 xvmn(li) = xvimn
2086 xvmn(lr) = xvrmn
2087 xvmn(ls) = xvsmn
2088 xvmn(lh) = xvhmn
2089
2090 xvmx(lc) = xvcmx
2091 xvmx(li) = xvimx
2092 xvmx(lr) = xvrmx
2093 xvmx(ls) = xvsmx
2094 xvmx(lh) = xvhmx
2095
2096 IF ( lhl .gt. 1 ) THEN
2097 xvmn(lhl) = xvhlmn
2098 xvmx(lhl) = xvhlmx
2099 ENDIF
2100
2101!
2102! cloud water constants in mks units
2103!
2104! cwmasn = 4.25e-15 ! radius of 1.0e-6
2105! cwmasn = 5.23e-13 ! minimum mass, defined by radius of 5.0e-6
2106! cwmasn5 = 5.23e-13
2107! cwradn = 5.0e-6 ! minimum radius
2108! cwmasx = 5.25e-10 ! maximum mass, defined by radius of 50.0e-6
2109! mwfac = 6.0**(1./3.)
2110 IF ( ipconc .ge. 2 ) THEN
2111! cwmasn = xvmn(lc)*1000. ! minimum mass, defined by minimum droplet volume
2112! cwradn = 1.0e-6 ! minimum radius
2113! cwmasx = xvmx(lc)*1000. ! maximum mass, defined by maximum droplet volume
2114
2115 ENDIF
2116! rwmasn = xvmn(lr)*1000. ! minimum mass, defined by minimum rain volume
2117! rwmasx = xvmx(lr)*1000. ! maximum mass, defined by maximum rain volume
2118
2119 IF ( lhl < 1 ) ifrzg = 1
2120
2121 ventr = 1.
2122 IF ( imurain == 3 ) THEN
2123! IF ( izwisventr == 1 ) THEN
2124 ventr = gamma_sp(rnu + 4./3.)/((rnu + 1.)**(1./3.)*gamma_sp(rnu + 1.)) ! Ziegler 1985
2125! ELSE
2126 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
2127! ventr = Gamma_sp(rnu + 4./3.)/((rnu + 1.)**(1./3.)*Gamma_sp(rnu + 1.)) ! Ziegler 1985, still use for first term in rwvent
2128! ventr = Gamma_sp(rnu + 4./3.)/Gamma_sp(rnu + 1.)
2129! ENDIF
2130 ELSE ! imurain == 1
2131! IF ( iferwisventr == 1 ) THEN
2132 ventr = gamma_sp(2. + alphar) ! Ferrier 1994
2133! ELSEIF ( iferwisventr == 2 ) THEN
2134 ventrn = gamma_sp(alphar + 2.5 + br/2.)/gamma_sp(alphar + 1.) ! adapted from Wisner et al. 1972
2135! ENDIF
2136 ENDIF
2137 ventc = gamma_sp(cnu + 4./3.)/(cnu + 1.)**(1./3.)/gamma_sp(cnu + 1.)
2138 c1sw = gamma_sp(snu + 4./3.)*(snu + 1.0)**(-1./3.)/gamma_sp(snu + 1.0)
2139
2140 ! set threshold mixing ratios
2141
2142 qxmin(:) = 1.0e-12
2143
2144 qxmin(lc) = 1.e-9
2145 qxmin(lr) = 1.e-7
2146 IF ( li > 1 ) qxmin(li) = 1.e-12
2147 IF ( ls > 1 ) qxmin(ls) = 1.e-7
2148 IF ( lh > 1 ) qxmin(lh) = 1.e-7
2149 IF ( lhl .gt. 1 ) qxmin(lhl) = 1.e-7
2150
2151 IF ( lc .gt. 1 .and. lnc .gt. 1 ) qxmin(lc) = 1.0e-13
2152 IF ( lr .gt. 1 .and. lnr .gt. 1 ) qxmin(lr) = 1.0e-12
2153
2154 IF ( li .gt. 1 .and. lni .gt. 1 ) qxmin(li ) = 1.0e-13
2155 IF ( ls .gt. 1 .and. lns .gt. 1 ) qxmin(ls ) = 1.0e-13
2156 IF ( lh .gt. 1 .and. lnh .gt. 1 ) qxmin(lh ) = 1.0e-12
2157 IF ( lhl.gt. 1 .and. lnhl.gt. 1 ) qxmin(lhl) = 1.0e-12
2158
2159 qxmin_init(:) = 1.0e-8 ! threshold for considering single-moment initial condition mixing ratios
2160 ! constants for droplet nucleation
2161
2162 cckm = cck-1.
2163 ccnefac = (1.63/(cck * beta(3./2., cck/2.)))**(cck/(cck + 2.0))
2164 cnexp = (3./2.)*cck/(cck+2.0)
2165! ccne is all the factors with w in eq. A7 in Mansell et al. 2010 (JAS). The constant changes
2166! if k (cck) is changed!
2167 ccne = ccnefac*1.e6*(1.e-6*abs(cwccn))**(2./(2.+cck))
2168 ccne0 = ccnefac*1.e6*(1.e-6)**(2./(2.+cck))
2169! write(0,*) 'cwccn, cck, ccne = ',cwccn,cck,ccne,ccnefac,cnexp
2170 IF ( cwccn .lt. 0.0 ) THEN
2171 cwccn = abs(cwccn)
2172 ccwmx = 50.e9 ! cwccn
2173 ELSE
2174 ccwmx = 50.e9 ! cwccn ! *1.4
2175 ENDIF
2176
2177!
2178!
2179! Set collection coefficients (Seifert and Beheng 05)
2180!
2181 bb(:) = 1.0/3.0
2182 bb(li) = 0.3429
2183 DO il = lc,lhab
2184 da0(il) = delbk(bb(il), xnu(il), xmu(il), 0)
2185 da1(il) = delbk(bb(il), xnu(il), xmu(il), 1)
2186
2187! write(0,*) 'il, da0, da1, xnu, xmu = ', il, da0(il), da1(il), xnu(il), xmu(il)
2188 ENDDO
2189
2190 dab0(:,:) = 0.0
2191 dab1(:,:) = 0.0
2192
2193 DO il = lc,lhab
2194 DO j = lc,lhab
2195 IF ( il .ne. j ) THEN
2196
2197 dab0(il,j) = delabk(bb(il), bb(j), xnu(il), xnu(j), xmu(il), xmu(j), 0)
2198 dab1(il,j) = delabk(bb(il), bb(j), xnu(il), xnu(j), xmu(il), xmu(j), 1)
2199
2200! write(0,*) 'il, j, dab0, dab1 = ',il, j, dab0(il,j), dab1(il,j)
2201 ENDIF
2202 ENDDO
2203 ENDDO
2204
2205 dab0lu(:,:,:,:) = 0.0
2206 dab1lu(:,:,:,:) = 0.0
2207
2208 IF ( ipconc >= 6 ) THEN
2209 DO il = lc,lhab ! collector
2210 DO j = lc,lhab ! collected
2211 IF ( il .ne. j ) THEN
2212
2213 DO jj = ialpstart,nqiacralpha
2214 alpjj = float(jj)*dqiacralpha
2215 xnujj = (alpjj - 2.)/3.
2216 DO ii = ialpstart,nqiacralpha
2217 alpii = float(ii)*dqiacralpha
2218 xnuii = (alpii - 2.)/3.
2219
2220 dab0lu(ii,jj,il,j) = delabk(bb(il), bb(j), xnuii, xnujj, xmu(il), xmu(j), 0)
2221 dab1lu(ii,jj,il,j) = delabk(bb(il), bb(j), xnuii, xnujj, xmu(il), xmu(j), 1)
2222
2223 ENDDO
2224 ENDDO
2225! write(0,*) 'il, j, dab0, dab1 = ',il, j, dab0(il,j), dab1(il,j)
2226 ENDIF
2227 ENDDO
2228 ENDDO
2229
2230 ENDIF
2231
2232 gf4br = gamma_sp(4.0+br)
2233 gf4ds = gamma_sp(4.0+ds)
2234 gf4p5 = gamma_sp(4.0+0.5)
2235 gfcinu1 = gamma_sp(cinu + 1.0)
2236 gfcinu1p47 = gamma_sp(cinu + 1.47167)
2237 gfcinu2p47 = gamma_sp(cinu + 2.47167)
2238 gfcinu1p22 = gamma_sp(cinu + 1.22117)
2239 gfcinu2p22 = gamma_sp(cinu + 2.22117)
2240 gfcinu1p18 = gamma_sp(cinu + 1.18333)
2241 gfcinu2p18 = gamma_sp(cinu + 2.18333)
2242
2243 gsnow1 = gamma_sp(snu + 1.0)
2244 gsnow53 = gamma_sp(snu + 5./3.)
2245 gsnow73 = gamma_sp(snu + 7./3.)
2246
2247 IF ( lh .gt. 1 ) cwchtmp0 = 6.0/pi*gamma_sp( (xnu(lh) + 1.)/xmu(lh) )/gamma_sp( (xnu(lh) + 2.)/xmu(lh) )
2248 IF ( lhl .gt. 1 ) cwchltmp0 = 6.0/pi*gamma_sp( (xnu(lhl) + 1)/xmu(lhl) )/gamma_sp( (xnu(lhl) + 2)/xmu(lhl) )
2249
2250
2251 iexy(:,:)=0; ! sets to zero the ones Imight have forgotten
2252
2253! snow
2254 iexy(ls,li) = ieswi
2255 iexy(ls,lc) = ieswc ; iexy(ls,lr) = ieswr ;
2256
2257! graupel
2258 iexy(lh,ls) = iehwsw ; iexy(lh,li) = iehwi ;
2259 iexy(lh,lc) = iehwc ; iexy(lh,lr) = iehwr ;
2260
2261! hail
2262 IF (lhl .gt. 1 ) THEN
2263 iexy(lhl,ls) = iehlsw ; iexy(lhl,li) = iehli ;
2264 iexy(lhl,lc) = iehlc ; iexy(lhl,lr) = iehlr ;
2265 ENDIF
2266
2267! IF ( icefallfac /= 1.0 ) write(0,*) 'icefallfac = ',icefallfac
2268! IF ( snowfallfac /= 1.0 ) write(0,*) 'snowfallfac = ',snowfallfac
2269
2270
2271 RETURN
2272END SUBROUTINE nssl_2mom_init
2273
2274! #####################################################################
2275! #####################################################################
2276
2279SUBROUTINE nssl_2mom_driver(qv, qc, qr, qi, qs, qh, qhl, ccw, crw, cci, csw, chw, chl, &
2280 cn, vhw, vhl, cna, cni, f_cn, f_cna, f_cina, &
2281 f_qc, f_qr, f_qi, f_qs, f_qh, f_qhl, &
2282 cnuf, f_cnuf, &
2283 zrw, zhw, zhl, f_zrw, f_zhw, f_zhl, f_vhw, f_vhl, &
2284 qsw, qhw, qhlw, &
2285 tt, th, pii, p, w, dn, dz, dtp, itimestep, &
2286 is_theta_or_temp, &
2287 ntmul, ntcnt, lastloop, &
2288 RAINNC,RAINNCV, &
2289 dx, dy, &
2290 axtra, &
2291 SNOWNC, SNOWNCV, GRPLNC, GRPLNCV, &
2292 SR,HAILNC, HAILNCV, &
2293 hail_maxk1, hail_max2d, nwp_diagnostics, &
2294 tkediss, &
2295 re_cloud, re_ice, re_snow, re_rain, &
2296 re_graup, re_hail, &
2297 has_reqc, has_reqi, has_reqs, has_reqr, &
2298 has_reqg, has_reqh, &
2299 rainncw2, rainnci2, &
2300 dbz, vzf,compdbz, &
2301 rscghis_2d,rscghis_2dp,rscghis_2dn, &
2302 scr,scw,sci,scs,sch,schl,sctot, &
2303 elec_physics, &
2304 induc,elecz,scion,sciona, &
2305 noninduc,noninducp,noninducn, &
2306 pcc2, pre2, depsubr, &
2307 mnucf2, melr2, ctr2, &
2308 rim1_2, rim2_2,rim3_2, &
2309 nctr2, nnuccd2, nnucf2, &
2310 effc2,effr2,effi2, &
2311 effs2, effg2, &
2312 fc2, fr2,fi2,fs2,fg2, &
2313 fnc2, fnr2,fni2,fns2,fng2, &
2314! qcond,qdep,qfrz,qrauto,qhcnvi,qhcollw,qscollw, &
2315! ncauto, niinit,nifrz, &
2316! re_liquid, re_graupel, re_hail, re_icesnow, &
2317! vtcloud, vtrain, vtsnow, vtgraupel, vthail, &
2318 ipelectmp, &
2319 diagflag,ke_diag, &
2320 errmsg, errflg, &
2321 nssl_progn, & ! wrf-chem
2322! 20130903 acd_mb_washout start
2323 wetscav_on, rainprod, evapprod, & ! wrf-chem
2324! 20130903 acd_mb_washout end
2325 cu_used, qrcuten, qscuten, qicuten, qccuten, & ! hm added
2326 ids,ide, jds,jde, kds,kde, & ! domain dims
2327 ims,ime, jms,jme, kms,kme, & ! memory dims
2328 its,ite, jts,jte, kts,kte) ! tile dims
2329
2330
2331
2332
2333
2334 implicit none
2335
2336
2337 !Subroutine arguments:
2338
2339 integer, intent(in):: &
2340 ids,ide, jds,jde, kds,kde, &
2341 ims,ime, jms,jme, kms,kme, &
2342 its,ite, jts,jte, kts,kte
2343 real, dimension(ims:ime, kms:kme, jms:jme), intent(inout):: &
2344 qv,qc,qr,qs,qh
2345 ! tt is air temperature -- used by CCPP instead of th (theta)
2346 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2347 th, tt, &
2348 zrw, zhw, zhl, &
2349 qsw, qhw, qhlw, &
2350 qi,qhl,ccw,crw,cci,csw,chw,chl,vhw,vhl
2351 integer, optional, intent(in) :: is_theta_or_temp
2352 logical, optional, intent(in) :: f_zrw, f_zhw, f_zhl, f_vhw, f_vhl ! not used yet
2353 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: dbz, vzf, cn, cna, cni, cnuf
2354 real, dimension(ims:ime, jms:jme), optional, intent(inout):: compdbz
2355 real, dimension(ims:ime, jms:jme), optional, intent(inout):: rscghis_2d, & ! 2D accumulation arrays for vertically-integrated charging rate
2356 rscghis_2dp, & ! 2D accumulation arrays for vertically-integrated charging rate (positive only)
2357 rscghis_2dn ! 2D accumulation arrays for vertically-integrated charging rate (negative only)
2358! real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout)::rscghis_3d
2359 integer, optional, intent(in) :: elec_physics
2360 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2361 scr,scw,sci,scs,sch,schl,sciona,sctot ! space charge
2362 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2363 induc,noninduc,noninducp,noninducn ! charging rates: inductive, noninductive (all, positive, negative to graupel)
2364 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(in) :: elecz ! elecsave = Ez
2365 real, dimension(ims:ime, kms:kme, jms:jme,2),optional, intent(inout) :: scion
2366 real, dimension(ims:ime, kms:kme, jms:jme), intent(in):: p,w,dz,dn
2367
2368 real, dimension(ims:ime, kms:kme, jms:jme), intent(in):: pii
2369 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2370 pcc2, pre2, depsubr, &
2371 mnucf2, melr2, ctr2, &
2372 rim1_2, rim2_2,rim3_2, &
2373 nctr2, nnuccd2, nnucf2, &
2374 effc2,effr2,effi2, &
2375 effs2, effg2, &
2376 fc2, fr2,fi2,fs2,fg2, &
2377 fnc2, fnr2,fni2,fns2,fng2
2378! qcond,qdep,qfrz,qrauto,qhcnvi,qhcollw,qscollw, &
2379! ncauto, niinit,nifrz, &
2380! re_liquid, re_graupel, re_hail, re_icesnow, &
2381! vtcloud, vtrain, vtsnow, vtgraupel, vthail
2382
2383 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout) :: axtra
2384
2385! WRF variables
2386 real, dimension(ims:ime, jms:jme) :: &
2387 rainnc,rainncv ! accumulated precip (NC) and rate (NCV)
2388 real, dimension(ims:ime, jms:jme), optional, intent(inout):: &
2389 snownc,snowncv,grplnc,grplncv,sr ! accumulated precip (NC) and rate (NCV)
2390 real, dimension(ims:ime, jms:jme), optional, intent(inout):: &
2391 hailnc,hailncv ! accumulated precip (NC) and rate (NCV)
2392 real, dimension(ims:ime, jms:jme), optional, intent(inout) :: hail_maxk1, hail_max2d
2393 integer, optional, intent(in) :: nwp_diagnostics
2394! for cm1, set nproctot=44 (or as needed) to get domain total rates
2395 integer, parameter :: nproc = 1
2396 double precision :: proctot(nproc),proctotmpi(nproc)
2397 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional, INTENT(INOUT):: re_cloud, re_ice, re_snow, &
2398 re_rain, re_graup, re_hail
2399 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional, INTENT(IN):: tkediss
2400 INTEGER, INTENT(IN), optional :: has_reqc, has_reqi, has_reqs, has_reqr, has_reqg, has_reqh
2401 real, dimension(ims:ime, jms:jme), intent(out), optional :: &
2402 rainncw2, rainnci2 ! liquid rain, ice, accumulation rates
2403 real, optional, intent(in) :: dx,dy
2404 real, intent(in):: dtp
2405 integer, intent(in):: itimestep !, ccntype
2406 integer, intent(in), optional :: ntmul, ntcnt
2407 logical, optional, intent(in) :: lastloop
2408 logical, optional, intent(in) :: diagflag, f_cna, f_cn, f_cina, f_cnuf
2409 logical, optional, intent(in) :: f_qc, f_qr, f_qi, f_qs, f_qh, f_qhl
2410 integer, optional, intent(in) :: ipelectmp, ke_diag
2411
2412 ! CCPP error handling
2413 character(len=*), intent( out) :: errmsg
2414 integer, intent( out) :: errflg
2415
2416 LOGICAL, INTENT(IN), OPTIONAL :: nssl_progn ! flags for wrf-chem
2417
2418! REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional,INTENT(INOUT):: qndrop
2419 LOGICAL :: flag_qndrop ! wrf-chem
2420 LOGICAL :: flag_qnifa , flag_qnwfa
2421 logical :: flag_cnuf = .false.
2422 logical :: flag_ccn = .false.
2423 logical :: flag_qi = .true.
2424 logical :: has_reqg_local = .false., has_reqh_local = .false.
2425 logical :: flag
2426 logical :: nwp_diagflag = .false.
2427 real :: cinchange, t7max,testmax,wmax
2428
2429! 20130903 acd_ck_washout start
2430! rainprod - total tendency of conversion of cloud water/ice and graupel to rain (kg kg-1 s-1)
2431! evapprod - tendency of evaporation of rain (kg kg-1 s-1)
2432! 20130903 acd_ck_washout end
2433 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional,INTENT(INOUT):: rainprod, evapprod
2434
2435! qrcuten, rain tendency from parameterized cumulus convection
2436! qscuten, snow tendency from parameterized cumulus convection
2437! qicuten, cloud ice tendency from parameterized cumulus convection
2438! mu : air mass in column
2439 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional, INTENT(IN):: qrcuten, qscuten, qicuten, qccuten
2440 INTEGER, optional, intent(in) :: cu_used
2441 LOGICAL, optional, intent(in) :: wetscav_on
2442
2443!
2444! local variables
2445!
2446 real, dimension(its:ite, 1, kts:kte) :: elec2 ! ez = elecsave slab
2447! real, dimension(its:ite, 1, kts:kte,2) :: scion2 ! 1=- , 2=+
2448 real, dimension(its:ite, kts:kte) :: rainprod2d, evapprod2d,tke2d
2449 real, dimension(its:ite, 1, kts:kte, na) :: an, ancuten
2450 real, dimension(its:ite, 1, kts:kte, nxtra) :: axtra2d
2451 real, dimension(its:ite, 1, kts:kte, 3) :: alpha2d
2452 real, dimension(its:ite, 1, kts:kte) :: t0,t1,t2,t3,t4,t5,t6,t7,t8,t9
2453 real, dimension(its:ite, 1, kts:kte) :: dn1,t00,t77,ssat,pn,wn,dz2d,dz2dinv,dbz2d,vzf2d
2454 real, dimension(its:ite, 1, na) :: xfall
2455 real, dimension(its:ite, 1) :: hailmax1d,hailmaxk1
2456 real, dimension(kts:kte, nproc) :: thproclocal
2457 integer, parameter :: nor = 0, ng = 0
2458 integer :: nx,ny,nz,ngs
2459 integer ix,jy,kz,i,j,k,il,n
2460 integer :: infdo
2461 real :: ssival, ssifac, t8s, t9s, qvapor
2462 integer :: ltemq
2463 double precision :: dp1
2464 integer :: jye, lnb
2465 integer :: imx,kmx
2466 real :: dbzmx,refl
2467 integer :: vzflag0 = 0
2468 logical :: makediag
2469 real :: dx1,dy1
2470 real, parameter :: cnin20 = 1.0e3
2471 real, parameter :: cnin10 = 5.0e1
2472 real, parameter :: cnin1a = 4.5
2473 real, parameter :: cnin2a = 12.96
2474 real, parameter :: cnin2b = 0.639
2475
2476 double precision :: cwmass1,cwmass2
2477 double precision :: rwmass1,rwmass2
2478 double precision :: icemass1,icemass2
2479 double precision :: swmass1,swmass2
2480 double precision :: grmass1,grmass2
2481 double precision :: hlmass1,hlmass2
2482 double precision :: wvol5,wvol10
2483 real :: tmp,dv,dv1,tmpchg
2484 real :: rdt
2485
2486 double precision :: dt1,dt2
2487 double precision :: timesed,timesed1,timesed2,timesed3, timegs, timenucond, timedbz,zmaxsed
2488 double precision :: timevtcalc,timesetvt
2489
2490 logical :: f_cnatmp, f_cinatmp
2491 logical :: has_wetscav
2492
2493 integer :: kediagloc
2494 integer :: iunit
2495
2496 real :: ycent, y, emissrate, emissrate0, emissrate1, z, fac, factot
2497 real :: fach(kts:kte)
2498
2499 logical, parameter :: debugdriver = .false.
2500
2501 integer :: loopcnt, loopmax, outerloopcnt
2502 logical :: lastlooptmp
2503
2504
2505! -------------------------------------------------------------------
2506
2507 errmsg = ''
2508 errflg = 0
2509
2510 rdt = 1.0/dtp
2511
2512 IF ( debugdriver ) write(0,*) 'N2M: entering routine'
2513
2514 flag_qndrop = .false.
2515 flag_qnifa = .false.
2516 flag_qnwfa = .false.
2517 flag_cnuf = .false.
2518 flag_ccn = .false.
2519 nwp_diagflag = .false.
2520
2521 IF ( PRESENT ( nssl_progn ) ) flag_qndrop = nssl_progn
2522 IF ( present ( f_cnuf ) ) flag_cnuf = f_cnuf
2523 IF ( present ( nwp_diagnostics ) ) nwp_diagflag = ( nwp_diagnostics > 0 )
2524
2525 IF ( present ( f_cn ) .and. present( cn ) ) THEN
2526 flag_ccn = f_cn
2527 ELSEIF ( present( cn ) ) THEN
2528 flag_ccn = .true.
2529 ENDIF
2530
2531 IF ( present( f_qi ) ) THEN
2532 flag_qi = f_qi
2533 ELSE
2534 IF ( ffrzs < 1.0 ) THEN
2535 flag_qi = .true.
2536 ELSE
2537 flag_qi = .false.
2538 ENDIF
2539 ENDIF
2540
2541 IF ( .not. flag_qi .and. ffrzs < 1.0 ) ffrzs = 1.0
2542
2543
2544 IF ( PRESENT ( has_reqg ) ) has_reqg_local = has_reqg > 0
2545 IF ( PRESENT ( has_reqh ) ) has_reqh_local = has_reqh > 0
2546
2547 loopmax = 1
2548 outerloopcnt = 1
2549 lastlooptmp = .true.
2550 IF ( present( ntmul ) .and. present( ntcnt ) .and. present( lastloop ) ) THEN
2551 loopmax = ntmul
2552 outerloopcnt = ntcnt
2553 lastlooptmp = lastloop
2554 ENDIF
2555
2556
2557 has_wetscav = .false.
2558 IF ( wrfchem_flag > 0 ) THEN
2559 IF ( PRESENT( wetscav_on ) ) THEN
2560 has_wetscav = wetscav_on
2561 ENDIF
2562 ENDIF
2563
2564 IF ( present( f_cna ) ) THEN
2565 f_cnatmp = f_cna
2566 ELSE
2567 f_cnatmp = .false.
2568 ENDIF
2569
2570 IF ( present( f_cina ) ) THEN
2571 f_cinatmp = f_cina
2572 ELSE
2573 f_cinatmp = .false.
2574 ENDIF
2575
2576 IF ( present( vzf ) ) vzflag0 = 1
2577
2578 IF ( present( ipelectmp ) ) THEN
2579 ipelec = ipelectmp
2580 ELSE
2581 ipelec = 0
2582 ENDIF
2583! IF ( present( dbz ) ) THEN
2584! DO jy = jts,jte
2585! DO kz = kts,kte
2586! DO ix = its,ite
2587! dbz(ix,kz,jy) = 0.0
2588! ENDDO
2589! ENDDO
2590! ENDDO
2591! ENDIF
2592
2593 IF ( present( dx ) .and. present( dy ) ) THEN
2594 dx1 = dx
2595 dy1 = dy
2596 ELSE
2597 dx1 = 1.0
2598 dy1 = 1.0
2599 ENDIF
2600
2601
2602 makediag = .true.
2603 IF ( present( diagflag ) ) THEN
2604 makediag = diagflag .or. itimestep == 1
2605 ENDIF
2606
2607 IF ( debugdriver ) write(0,*) 'N2M: makediag = ',makediag
2608
2609
2610 nx = ite-its+1
2611 ny = 1 ! set up as 2D slabs
2612 nz = kte-kts+1
2613 ngs = 64
2614
2615 IF ( .not. flag_ccn ) THEN
2616 renucfrac = 1.0
2617 ENDIF
2618
2619
2620
2621
2622! ENDIF ! itimestep == 1
2623
2624
2625! sedimentation settings
2626
2627 infdo = 2
2628
2629 IF ( infall .ne. 1 .or. iscfall .ge. 2 ) THEN
2630 infdo = 1
2631 ELSE
2632 infdo = 0
2633 ENDIF
2634
2635 IF ( infall .ge. 3 .or. ipconc .ge. 6 ) THEN
2636 infdo = 2
2637 ENDIF
2638
2639
2640 IF ( present( hailncv ) .and. lhl < 1 ) THEN ! for WRF 3.1 compatibility
2641 hailncv(its:ite,jts:jte) = 0.
2642 ENDIF
2643
2644 tke2d(:,:) = 0.0 ! initialize if not used
2645
2646 lnb = max(lh,lhl)+1 ! lnc
2647! IF ( lccn > 1 ) lnb = lccn
2648
2649 jye = jte
2650
2651 IF ( present( compdbz ) .and. makediag ) THEN
2652 DO jy = jts,jye
2653 DO ix = its,ite
2654 compdbz(ix,jy) = -3.0
2655 ENDDO
2656 ENDDO
2657 ENDIF
2658
2659 zmaxsed = 0.0d0
2660 timevtcalc = 0.0d0
2661 timesetvt = 0.0d0
2662 timesed = 0.0d0
2663 timesed1 = 0.0d0
2664 timesed2 = 0.0d0
2665 timesed3 = 0.0d0
2666 timegs = 0.0d0
2667 timenucond = 0.0d0
2668
2669
2670
2671 IF ( debugdriver ) write(0,*) 'N2M: jy loop 1, lhl,na = ',lhl,na,present(qhl)
2672
2673 ancuten(its:ite,1,kts:kte,:) = 0.0
2674 thproclocal(:,:) = 0.0
2675
2676
2677 DO jy = jts,jye
2678
2679! write(0,*) 'N2M: load an, jy,lccn = ',jy,lccn,qccn
2680
2681 IF ( present( pcc2 ) .and. makediag ) THEN
2682 axtra2d(its:ite,1,kts:kte,:) = 0.0
2683 ENDIF
2684
2685 IF ( nwp_diagflag ) THEN
2686 alpha2d(its:ite,1,kts:kte,1) = alphar
2687 alpha2d(its:ite,1,kts:kte,2) = alphah
2688 alpha2d(its:ite,1,kts:kte,3) = alphahl
2689 ENDIF
2690
2691
2692 ! copy from 3D array to 2D slab
2693
2694 DO kz = kts,kte
2695 DO ix = its,ite
2696 IF ( present( tt ) ) THEN
2697 an(ix,1,kz,lt) = tt(ix,kz,jy)/pii(ix,kz,jy)
2698 ELSE
2699 an(ix,1,kz,lt) = th(ix,kz,jy)
2700 ENDIF
2701 an(ix,1,kz,lv) = qv(ix,kz,jy)
2702 an(ix,1,kz,lc) = qc(ix,kz,jy)
2703 an(ix,1,kz,lr) = qr(ix,kz,jy)
2704 IF ( flag_qi ) THEN
2705 an(ix,1,kz,li) = qi(ix,kz,jy)
2706 ELSE
2707 an(ix,1,kz,li) = 0.0
2708 ENDIF
2709 an(ix,1,kz,ls) = qs(ix,kz,jy)
2710 an(ix,1,kz,lh) = qh(ix,kz,jy)
2711 IF ( lhl > 1 ) an(ix,1,kz,lhl) = qhl(ix,kz,jy)
2712 IF ( lccn > 1 ) THEN
2713 IF ( is_aerosol_aware .and. flag_qnwfa ) THEN
2714 !
2715 ELSEIF ( flag_ccn ) THEN
2716 IF ( lccna > 1 .and. .not. ( present( cna ) .and. f_cnatmp ) ) THEN
2717 an(ix,1,kz,lccna) = cn(ix,kz,jy)
2718 an(ix,1,kz,lccn) = qccn ! cn(ix,kz,jy)
2719 ELSE
2720 an(ix,1,kz,lccn) = cn(ix,kz,jy)
2721 ENDIF
2722 IF ( i_uf_or_ccn > 0 .and. lccnuf > 1 ) THEN ! UF ccn are extra regular ccn
2723 an(ix,1,kz,lccn) = an(ix,1,kz,lccn) + cnuf(ix,kz,jy)
2724 ENDIF
2725 ELSE
2726 IF ( lccna == 0 .and. ( .not. f_cnatmp ) ) THEN
2727 an(ix,1,kz,lccn) = qccn - ccw(ix,kz,jy)
2728 ELSE
2729 an(ix,1,kz,lccn) = qccn
2730 ENDIF
2731
2732 ENDIF
2733 ENDIF
2734
2735 IF ( lccnuf > 0 .and. flag_cnuf ) THEN
2736 IF ( i_uf_or_ccn == 0 ) THEN ! UF are UF
2737 an(ix,1,kz,lccnuf) = max(0.0, cnuf(ix,kz,jy) )
2738 ELSE ! UF were added to lccn
2739 an(ix,1,kz,lccnuf) = 0.0
2740 ENDIF
2741 ENDIF
2742
2743 IF ( lccna > 1 ) THEN
2744 IF ( present( cna ) .and. f_cnatmp ) THEN
2745 an(ix,1,kz,lccna) = cna(ix,kz,jy)
2746 ENDIF
2747 ENDIF
2748
2749 IF ( lcina > 1 ) THEN
2750 IF ( present( cni ) .and. f_cinatmp ) THEN
2751 an(ix,1,kz,lcina) = cni(ix,kz,jy)
2752 ENDIF
2753 ENDIF
2754
2755 IF ( ipconc >= 5 ) THEN
2756 an(ix,1,kz,lnc) = ccw(ix,kz,jy)
2757 IF ( constccw > 0.0 ) THEN
2758 an(ix,1,kz,lnc) = constccw
2759 ENDIF
2760 an(ix,1,kz,lnr) = crw(ix,kz,jy)
2761 IF ( present( cci ) ) THEN
2762 an(ix,1,kz,lni) = cci(ix,kz,jy)
2763 ELSE
2764 an(ix,1,kz,lni) = 0.0
2765 ENDIF
2766 an(ix,1,kz,lns) = csw(ix,kz,jy)
2767 an(ix,1,kz,lnh) = chw(ix,kz,jy)
2768 IF ( lhl > 1 ) an(ix,1,kz,lnhl) = chl(ix,kz,jy)
2769 ENDIF
2770 IF ( lvh > 0 ) an(ix,1,kz,lvh) = vhw(ix,kz,jy)
2771 IF ( lvhl > 0 .and. present( vhl ) ) an(ix,1,kz,lvhl) = vhl(ix,kz,jy)
2772
2773 IF ( ipconc >= 6 ) THEN
2774 IF ( lzr > 0 ) an(ix,1,kz,lzr) = zrw(ix,kz,jy)*zscale
2775 IF ( lzh > 0 ) an(ix,1,kz,lzh) = zhw(ix,kz,jy)*zscale
2776 IF ( lzhl > 0 ) an(ix,1,kz,lzhl) = zhl(ix,kz,jy)*zscale
2777 ENDIF
2778
2779
2780
2781 ENDDO
2782 ENDDO
2783
2784 DO kz = kts,kte
2785 DO ix = its,ite
2786
2787
2788 IF ( present( tt ) ) THEN
2789 t0(ix,1,kz) = tt(ix,kz,jy) ! temperature (Kelvin)
2790 ELSE
2791 t0(ix,1,kz) = th(ix,kz,jy)*pii(ix,kz,jy) ! temperature (Kelvin)
2792 ENDIF
2793 t00(ix,1,kz) = 380.0/p(ix,kz,jy)
2794 t77(ix,1,kz) = pii(ix,kz,jy)
2795 dbz2d(ix,1,kz) = 0.0
2796 vzf2d(ix,1,kz) = 0.0
2797 ENDDO
2798 ENDDO
2799
2800 DO ix = its,ite
2801 rainncv(ix,jy) = 0.0
2802 IF ( present( grplncv ) ) grplncv(ix,jy) = 0.0
2803 IF ( present( hailncv ) ) hailncv(ix,jy) = 0.0
2804 IF ( present( snowncv ) ) snowncv(ix,jy) = 0.0
2805 ENDDO
2806
2807 DO loopcnt = 1,loopmax
2808
2809 DO kz = kts,kte
2810 DO ix = its,ite
2811
2812
2813 t1(ix,1,kz) = 0.0
2814 t2(ix,1,kz) = 0.0
2815 t3(ix,1,kz) = 0.0
2816 t4(ix,1,kz) = 0.0
2817 t5(ix,1,kz) = 0.0
2818 t6(ix,1,kz) = 0.0
2819 t7(ix,1,kz) = 0.0
2820 t8(ix,1,kz) = 0.0
2821 t9(ix,1,kz) = 0.0
2822
2823 pn(ix,1,kz) = p(ix,kz,jy)
2824 wn(ix,1,kz) = w(ix,kz,jy)
2825! calculate dn1 in case we are substepping: rho = con_eps*prsl/(con_rd*tgrs*(qv_mp+con_eps))
2826 dn1(ix,1,kz) = rdorv*pn(ix,1,kz)/(rd*t0(ix,1,kz)*(an(ix,1,kz,lv) + rdorv))
2827! wmax = Max(wmax,wn(ix,1,kz))
2828 dz2d(ix,1,kz) = dz(ix,kz,jy)
2829 dz2dinv(ix,1,kz) = 1./dz(ix,kz,jy)
2830
2831 ltemq = int( (t0(ix,1,kz)-163.15)/fqsat+1.5 )
2832 ltemq = min( nqsat, max(1,ltemq) )
2833!
2834! saturation mixing ratio
2835!
2836 t8s = t00(ix,1,kz)*tabqvs(ltemq) !saturation mixing ratio wrt water
2837 t9s = t00(ix,1,kz)*tabqis(ltemq) !saturation mixing ratio wrt ice
2838
2839!
2840! calculate rate of nucleation
2841!
2842 ssival = min(t8s,max(an(ix,1,kz,lv),0.0))/t9s ! qv/qvi
2843
2844
2845 if ( ssival .gt. 1.0 ) then
2846!
2847 IF ( icenucopt == 1 ) THEN
2848
2849 if ( t0(ix,1,kz).le.268.15 ) then
2850
2851 dp1 = dn1(ix,1,kz)/rho00*cnin20*exp( min( 57.0 ,(cnin2a*(ssival-1.0)-cnin2b) ) )
2852 t7(ix,1,kz) = min(dp1, 1.0d30)
2853 end if
2854
2855!
2856! Default value of imeyers5 turns off nucleation by Meyer at higher temperatures
2857! This is really from Ferrier (1994), eq. 4.31 - 4.34
2858 IF ( imeyers5 ) THEN
2859 if ( t0(ix,1,kz).lt.tfr .and. t0(ix,1,kz).gt.268.15 ) then
2860 qvapor = max(an(ix,1,kz,lv),0.0)
2861 ssifac = 0.0
2862 if ( (qvapor-t9s) .gt. 1.0e-5 ) then
2863 if ( (t8s-t9s) .gt. 1.0e-5 ) then
2864 ssifac = (qvapor-t9s) /(t8s-t9s)
2865 ssifac = ssifac**cnin1a
2866 end if
2867 end if
2868 t7(ix,1,kz) = dn1(ix,1,kz)/rho00*cnin10*ssifac*exp(-(t0(ix,1,kz)-tfr)*bta1)
2869 end if
2870 ENDIF
2871
2872! t7max = Max(t7max, t7(ix,1,kz) )
2873
2874 ELSEIF ( icenucopt == 2 ) THEN ! Thompson/Cooper; Note Thompson 2004 has constants of
2875 ! 0.005 and 0.304 because the line function was estimated from Cooper plot
2876 ! Here, the fit line values from Cooper 1986 are converted. Very little difference
2877 ! in practice
2878
2879 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
2880
2881! write(0,*) 'Cooper t7,ssival = ',ix,kz,t7(ix,1,kz),ssival
2882
2883 ELSEIF ( icenucopt == 3 ) THEN ! Phillips (Meyers/DeMott)
2884
2885 if ( t0(ix,1,kz).le.268.15 .and. t0(ix,1,kz) > 243.15 ) then ! Meyers with factor of Psi=0.06
2886
2887 dp1 = 0.06*cnin20*exp( min( 57.0 ,(cnin2a*(ssival-1.0)-cnin2b) ) )
2888 t7(ix,1,kz) = min(dp1, 1.0d30)
2889 elseif ( t0(ix,1,kz) <= 243.15 ) then ! Phillips estimate of DeMott et al (2003) data
2890 dp1 = 1000.*( exp( min( 57.0 ,cnin2a*(ssival-1.1) ) ) )**0.3
2891 t7(ix,1,kz) = min(dp1, 1.0d30)
2892
2893 end if
2894
2895 ELSEIF ( icenucopt == 4 ) THEN ! DeMott 2010
2896
2897 IF ( t0(ix,1,kz) < 268.16 .and. t0(ix,1,kz) > 223.15 .and. ssival > 1.001 ) THEN !
2898
2899 ! a = 0.0000594, b = 3.33, c = 0.0264, d = 0.0033,
2900 ! nint = a*(-Tc)**b * naer**(c*(-Tc) + d)
2901 ! nint has units of per (standard) liter, so mult by 1.e3 and scale by dn/rho00
2902 ! naer needs units of cm**-3, so mult by 1.e-6
2903
2904 ! dp1 = 1.e3*0.0000594*(273.16 - t0(ix,1,kz))**3.33 * (1.e-6*cin*dn(ix,1,kz))**(0.0264*(273.16 - t0(ix,1,kz)) + 0.0033)
2905 tmp = 1.e-6*naer
2906 dp1 = 1.e3*dn1(ix,1,kz)/rho00*0.0000594*(273.16 - t0(ix,1,kz))**3.33 * tmp**(0.0264*(273.16 - t0(ix,1,kz)) + 0.0033)
2907 t7(ix,1,kz) = min(dp1, 1.0d30)
2908
2909 ELSE
2910 ! t7(ix,1,kz) = 0.0
2911 ENDIF
2912
2913 ENDIF ! icenucopt
2914
2915
2916!
2917 end if ! ( ssival .gt. 1.0 )
2918!
2919
2920 ENDDO ! ix
2921 ENDDO ! kz
2922
2923 IF ( wrfchem_flag > 0 ) THEN
2924 IF ( has_wetscav ) THEN
2925 IF ( PRESENT( rainprod ) ) rainprod2d(its:ite,kts:kte) = 0
2926 IF ( PRESENT( evapprod ) ) evapprod2d(its:ite,kts:kte) = 0
2927 ENDIF
2928 ENDIF
2929
2930
2931 ! transform from number mixing ratios to number conc.
2932
2933 IF ( loopcnt == 1 ) THEN
2934 DO il = lnb,na
2935 IF ( denscale(il) == 1 ) THEN
2936 DO kz = kts,kte
2937 DO ix = its,ite
2938 an(ix,1,kz,il) = an(ix,1,kz,il)*dn1(ix,1,kz) ! dn(ix,kz,jy)
2939 ENDDO
2940 ENDDO
2941 ENDIF
2942 ENDDO ! il
2943 ENDIF
2944
2945
2946! sedimentation
2947 xfall(:,:,:) = 0.0
2948
2949
2950! IF ( .true. ) THEN
2951
2952
2953! #ifndef CM1
2954! for real cases when hydrometeor mixing ratios have been initialized without concentrations
2955 IF ( itimestep == 1 .and. ipconc > 0 .and. loopcnt == 1 ) THEN
2956 call calcnfromq(nx,ny,nz,an,na,nor,nor,dn1)
2957 ENDIF
2958! IF ( itimestep == 3 .and. ipconc > 0 ) THEN
2959! call calcnfromq(nx,ny,nz,an,na,nor,nor,dn1)
2960! ENDIF
2961! #endif
2962
2963 IF ( present(cu_used) .and. &
2964 ( present( qrcuten ) .or. present( qscuten ) .or. &
2965 present( qicuten ) .or. present( qccuten ) ) ) THEN !{
2966
2967 IF ( cu_used == 1 ) THEN !{
2968 DO kz = kts,kte
2969 DO ix = its,ite
2970
2971 IF ( present( qrcuten ) ) ancuten(ix,1,kz,lr) = dtp*qrcuten(ix,kz,jy)
2972 IF ( present( qscuten ) ) ancuten(ix,1,kz,ls) = dtp*qscuten(ix,kz,jy)
2973 IF ( present( qicuten ) ) ancuten(ix,1,kz,li) = dtp*qicuten(ix,kz,jy)
2974 IF ( present( qccuten ) ) ancuten(ix,1,kz,lc) = dtp*qccuten(ix,kz,jy)
2975
2976 ENDDO
2977 ENDDO
2978
2979 call calcnfromcuten(nx,ny,nz,ancuten,an,na,nor,nor,dn1)
2980
2981 DO kz = kts,kte
2982 DO ix = its,ite
2983
2984
2985 IF ( ipconc >= 6 ) THEN
2986! IF ( lzr > 0 ) an(ix,1,kz,lzr) = an(ix,1,kz,lzr) + ancuten(ix,1,kz,lzr)
2987 ENDIF
2988
2989 ENDDO
2990 ENDDO
2991
2992 ENDIF !}
2993
2994 ENDIF !}
2995
2996
2997
2998
2999 call sediment1d(dtp,nx,ny,nz,an,na,nor,nor,xfall,dn1,dz2d,dz2dinv, &
3000 & t0,t7,infdo,jy,its,jts &
3001 & ,timesed1,timesed2,timesed3,zmaxsed,timesetvt)
3002
3003
3004! copy xfall to appropriate places...
3005
3006 IF ( debugdriver ) write(0,*) 'N2M: end sediment, jy = ',jy
3007
3008 DO ix = its,ite
3009 IF ( lhl > 1 ) THEN
3010 rainncv(ix,jy) = rainncv(ix,jy) + &
3011 dtp*dn1(ix,1,1)*(xfall(ix,1,lr) + xfall(ix,1,ls)*1000./xdn0(lr) + &
3012 & xfall(ix,1,lh)*1000./xdn0(lr) + xfall(ix,1,lhl)*1000./xdn0(lr) )
3013 ELSE
3014 rainncv(ix,jy) = rainncv(ix,jy) + &
3015 dtp*dn1(ix,1,1)*(xfall(ix,1,lr) + xfall(ix,1,ls)*1000./xdn0(lr) + &
3016 & xfall(ix,1,lh)*1000./xdn0(lr) )
3017 ENDIF
3018 IF ( present ( rainncw2 ) ) THEN ! rain only
3019 rainncw2(ix,jy) = rainncw2(ix,jy) + dtp*dn1(ix,1,1)*xfall(ix,1,lr)
3020 ENDIF
3021 IF ( present ( rainnci2 ) ) THEN ! ice only
3022 IF ( lhl > 1 ) THEN
3023 rainnci2(ix,jy) =rainnci2(ix,jy) + dtp*dn1(ix,1,1)*(xfall(ix,1,ls)*1000./xdn0(lr) + &
3024 & xfall(ix,1,lh)*1000./xdn0(lr) + xfall(ix,1,lhl)*1000./xdn0(lr) )
3025 ELSE
3026 rainnci2(ix,jy) = rainnci2(ix,jy) + dtp*dn1(ix,1,1)*(xfall(ix,1,ls)*1000./xdn0(lr) + &
3027 & xfall(ix,1,lh)*1000./xdn0(lr) )
3028 ENDIF
3029 ENDIF
3030 IF ( present( snowncv ) ) snowncv(ix,jy) = snowncv(ix,jy) + dtp*dn1(ix,1,1)*xfall(ix,1,ls)*1000./xdn0(lr)
3031 IF ( present( grplncv ) ) THEN
3032 IF ( lhl > 1 .and. .not. present( hailnc) ) THEN ! if no separate hail accum, then add to graupel
3033 grplncv(ix,jy) = grplncv(ix,jy) + dtp*dn1(ix,1,1)*(xfall(ix,1,lh) + xfall(ix,1,lhl)) *1000./xdn0(lr)
3034 ELSE
3035 grplncv(ix,jy) = grplncv(ix,jy) + dtp*dn1(ix,1,1)*xfall(ix,1,lh)*1000./xdn0(lr)
3036 ENDIF
3037 ENDIF
3038 IF ( loopcnt == loopmax ) rainnc(ix,jy) = rainnc(ix,jy) + rainncv(ix,jy)
3039
3040 IF ( present (snownc) .and. present (snowncv) .and. loopcnt == loopmax ) THEN
3041 snownc(ix,jy) = snownc(ix,jy) + snowncv(ix,jy)
3042 ENDIF
3043 IF ( lhl > 1 ) THEN
3044!#ifdef CM1
3045! IF ( .true. ) THEN
3046!#else
3047 IF ( present( hailnc ) ) THEN
3048!#endif
3049 hailncv(ix,jy) = dtp*dn1(ix,1,1)*xfall(ix,1,lhl)*1000./xdn0(lr)
3050 IF ( loopcnt == loopmax ) hailnc(ix,jy) = hailnc(ix,jy) + hailncv(ix,jy)
3051! ELSEIF ( present( GRPLNCV ) ) THEN ! if no separate hail accum, then add to graupel
3052! GRPLNCV(ix,jy) = GRPLNCV(ix,jy) + dtp*dn1(ix,1,1)*xfall(ix,1,lhl)*1000./xdn0(lr)
3053 ENDIF
3054 ENDIF
3055 IF ( present( grplncv ) .and. loopcnt == loopmax ) THEN
3056 grplnc(ix,jy) = grplnc(ix,jy) + grplncv(ix,jy)
3057 ENDIF
3058 IF ( present( sr ) .and. present (snowncv) .and. present(grplncv) .and. loopcnt == loopmax ) THEN
3059 IF ( present( hailnc ) ) THEN
3060 sr(ix,jy) = (snowncv(ix,jy)+hailncv(ix,jy)+grplncv(ix,jy))/(rainncv(ix,jy)+1.e-12)
3061 ELSE
3062 sr(ix,jy) = (snowncv(ix,jy)+grplncv(ix,jy))/(rainncv(ix,jy)+1.e-12)
3063 ENDIF
3064 ENDIF
3065 ENDDO
3066
3067! ENDIF ! .false.
3068
3069 IF ( isedonly /= 1 ) THEN
3070 ! call nssl_2mom_gs: main gather-scatter routine to calculate microphysics
3071
3072 IF ( debugdriver ) write(0,*) 'N2M: gs, jy = ',jy
3073! IF ( isedonly /= 2 ) THEN
3074
3075
3076 call nssl_2mom_gs &
3077 & (nx,ny,nz,na,jy &
3078 & ,nor,nor &
3079 & ,dtp,dz2d &
3080 & ,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9 &
3081 & ,an,dn1,t77 &
3082 & ,pn,wn,0 &
3083 & ,t00,t77, &
3084 & ventr,ventc,c1sw,1,ido, &
3085 & xdnmx,xdnmn, &
3086! & ln,ipc,lvol,lz,lliq, &
3087 & cdx, &
3088 & xdn0,dbz2d,tke2d, &
3089 & thproclocal,nproc,dx1,dy1,ngs, &
3090 & timevtcalc,axtra2d, makediag &
3091 & ,has_wetscav, rainprod2d, evapprod2d, alpha2d &
3092 & ,errmsg,errflg &
3093 & ,elec2,its,ids,ide,jds,jde &
3094 & )
3095
3096
3097
3098! recalculate dn1 after temperature changes: rho = con_eps*prsl/(con_rd*tgrs*(qv_mp+con_eps))
3099 DO kz = kts,kte
3100 DO ix = its,ite
3101 dn1(ix,1,kz) = rdorv*pn(ix,1,kz)/(rd*t0(ix,1,kz)*(an(ix,1,kz,lv) + rdorv))
3102 ENDDO
3103 ENDDO
3104
3105
3106 ENDIF ! isedonly /= 1
3107
3108 ! droplet nucleation/condensation/evaporation
3109 IF ( .true. ) THEN
3110 CALL nucond &
3111 & (nx,ny,nz,na,jy &
3112 & ,nor,nor,dtp,nx &
3113 & ,dz2d &
3114 & ,t0,t9 &
3115 & ,an,dn1,t77 &
3116 & ,pn,wn &
3117 & ,ngs &
3118 & ,axtra2d, makediag &
3119 & ,ssat,t00,t77,flag_qndrop)
3120
3121! recalculate dn1 after temperature changes
3122 DO kz = kts,kte
3123 DO ix = its,ite
3124 dn1(ix,1,kz) = rdorv*pn(ix,1,kz)/(rd*t0(ix,1,kz)*(an(ix,1,kz,lv) + rdorv))
3125 ENDDO
3126 ENDDO
3127
3128
3129 ENDIF
3130
3131
3132
3133
3134 ENDDO ! loopcnt=1,loopmax
3135 IF ( present( pcc2 ) .and. makediag ) THEN
3136 DO kz = kts,kte
3137 DO ix = its,ite
3138! example of using the 'axtra2d' array to get rates out of the microphysics routine for output.
3139! Search for 'axtra' to find example code below
3140! pcc2(ix,kz,jy) = axtra2d(ix,1,kz,1)
3141 ENDDO
3142 ENDDO
3143 ENDIF
3144
3145
3146! compute diagnostic S-band reflectivity if needed
3147 IF ( present( dbz ) .and. makediag .and. lastlooptmp ) THEN
3148 ! calc dbz
3149
3150 IF ( .true. ) THEN
3151 IF ( present(ke_diag) ) THEN
3152 kediagloc = ke_diag
3153 ELSE
3154 kediagloc = nz
3155 ENDIF
3156 call radardd02(nx,ny,nz,nor,na,an,t0, &
3157 & dbz2d,dn1,nz,cnoh,rho_qh,ipconc,kediagloc, 0)
3158 ENDIF ! .false.
3159
3160
3161 DO kz = kts,kediagloc ! kte
3162 DO ix = its,ite
3163 dbz(ix,kz,jy) = dbz2d(ix,1,kz)
3164 IF ( present( vzf ) ) THEN
3165 vzf(ix,kz,jy) = vzf2d(ix,1,kz)
3166 IF ( dbz2d(ix,1,kz) <= 0.0 ) THEN
3167 vzf(ix,kz,jy) = 0.0
3168 ELSEIF ( dbz2d(ix,1,kz) <= 15.0 ) THEN
3169 refl = 10**(0.1*dbz2d(ix,1,kz))
3170 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 )
3171 ENDIF
3172 ENDIF
3173 IF ( present( compdbz ) ) THEN
3174 compdbz(ix,jy) = max( compdbz(ix,jy), dbz2d(ix,1,kz) )
3175 ENDIF
3176 ENDDO
3177 ENDDO
3178
3179 ENDIF
3180
3181
3182
3183! Following Greg Thompson, calculation for effective radii. Used by RRTMG LW/SW schemes if enabled in module_physics_init.F
3184 IF ( present( has_reqc ).and. present( has_reqi ) .and. present( has_reqs ) .and. &
3185 present( re_cloud ).and. present( re_ice ) .and. present( re_snow ) .and. &
3186 lastlooptmp) THEN
3187 IF ( has_reqc.ne.0 .or. has_reqi.ne.0 .or. has_reqs.ne.0) THEN
3188 DO kz = kts,kte
3189 DO ix = its,ite
3190 re_cloud(ix,kz,jy) = 2.51e-6
3191 re_ice(ix,kz,jy) = 10.01e-6
3192 re_snow(ix,kz,jy) = 25.e-6
3193 t1(ix,1,kz) = 2.51e-6
3194 t2(ix,1,kz) = 10.01e-6
3195 t3(ix,1,kz) = 25.e-6
3196 t4(ix,1,kz) = 50.e-6
3197 ENDDO
3198 ENDDO
3199
3200
3201 call calc_eff_radius &
3202 & (nx,ny,nz,na,jy &
3203 & ,nor,nor &
3204 & ,t1=t1,t2=t2,t3=t3,t4=t4,t5=t5,t6=t6,f_t5=has_reqg_local, f_t6=has_reqh_local &
3205 & ,an=an,dn=dn1 )
3206
3207 DO kz = kts,kte
3208 DO ix = its,ite
3209 re_cloud(ix,kz,jy) = max(2.51e-6, min(t1(ix,1,kz), 50.e-6))
3210 re_ice(ix,kz,jy) = max(10.01e-6, min(t2(ix,1,kz), 125.e-6))
3211 re_snow(ix,kz,jy) = max(25.e-6, min(t3(ix,1,kz), 999.e-6))
3212 ! check for case where snow needs to be treated as cloud ice (for rrtmg radiation)
3213 IF ( .not. present(qi) ) re_ice(ix,kz,jy) = max(10.e-6, min(t3(ix,1,kz), 125.e-6))
3214 ENDDO
3215 ENDDO
3216
3217 IF ( present(has_reqr) .and. present( re_rain ) ) THEN
3218 IF ( has_reqr /= 0 ) THEN
3219 DO kz = kts,kte
3220 DO ix = its,ite
3221 re_rain(ix,kz,jy) = max(50.e-6, min(t4(ix,1,kz), 2999.e-6))
3222 ENDDO
3223 ENDDO
3224 ENDIF
3225 ENDIF
3226
3227 IF ( present(has_reqg) .and. present( re_graup ) ) THEN
3228 IF ( has_reqg /= 0 ) THEN
3229 DO kz = kts,kte
3230 DO ix = its,ite
3231 re_graup(ix,kz,jy) = max(50.e-6, min(t5(ix,1,kz), 10.e-3))
3232 ENDDO
3233 ENDDO
3234 ENDIF
3235 ENDIF
3236
3237 IF ( present(has_reqh) .and. present( re_hail ) ) THEN
3238 IF ( has_reqh /= 0 ) THEN
3239 DO kz = kts,kte
3240 DO ix = its,ite
3241 re_hail(ix,kz,jy) = max(50.e-6, min(t5(ix,1,kz), 40.e-3))
3242 ENDDO
3243 ENDDO
3244 ENDIF
3245 ENDIF
3246
3247 ENDIF
3248 ENDIF
3249
3250
3251 IF ( present( hail_maxk1 ) .and. present( hail_max2d ) .and. nwp_diagflag ) THEN
3252 DO ix = its,ite
3253 hailmax1d(ix,1) = hail_max2d(ix,jy)
3254 hailmaxk1(ix,1) = hail_maxk1(ix,jy)
3255 ENDDO
3256
3257 call hailmaxd(dtp,nx,ny,nz,an,na,nor,nor,alpha2d,dn1, &
3258 hailmax1d,hailmaxk1,1 )
3259
3260 DO ix = its,ite
3261 hail_max2d(ix,jy) = hailmax1d(ix,1)
3262 hail_maxk1(ix,jy) = hailmaxk1(ix,1)
3263 ENDDO
3264! ENDIF
3265 ENDIF
3266
3267! transform concentrations back to mixing ratios
3268 DO il = lnb,na
3269 IF ( denscale(il) == 1 ) THEN
3270 DO kz = kts,kte
3271 DO ix = its,ite
3272 an(ix,1,kz,il) = an(ix,1,kz,il)/dn1(ix,1,kz) ! dn(ix,kz,jy)
3273 ENDDO
3274 ENDDO
3275 ENDIF
3276 ENDDO ! il
3277
3278 ! copy 2D slabs back to 3D
3279
3280
3281 DO kz = kts,kte
3282 DO ix = its,ite
3283
3284 IF ( present( tt ) ) THEN
3285 tt(ix,kz,jy) = t0(ix,1,kz)
3286 ELSE
3287 th(ix,kz,jy) = an(ix,1,kz,lt)
3288 ENDIF
3289
3290 qv(ix,kz,jy) = an(ix,1,kz,lv)
3291 qc(ix,kz,jy) = an(ix,1,kz,lc)
3292 qr(ix,kz,jy) = an(ix,1,kz,lr)
3293 IF ( flag_qi ) qi(ix,kz,jy) = an(ix,1,kz,li)
3294 qs(ix,kz,jy) = an(ix,1,kz,ls)
3295 qh(ix,kz,jy) = an(ix,1,kz,lh)
3296 IF ( lhl > 1 ) qhl(ix,kz,jy) = an(ix,1,kz,lhl)
3297
3298 IF ( lccn > 1 .and. is_aerosol_aware .and. flag_qnwfa ) THEN
3299 ! not used here
3300 ELSEIF ( flag_ccn .and. lccn > 1 .and. .not. flag_qndrop) THEN
3301 IF ( lccna > 1 .and. .not. ( present( cna ) .and. f_cnatmp ) ) THEN
3302 cn(ix,kz,jy) = max(0.0, an(ix,1,kz,lccna) )
3303 ELSE
3304 cn(ix,kz,jy) = an(ix,1,kz,lccn)
3305 ENDIF
3306 ENDIF
3307 IF ( lccna > 1 ) THEN
3308 IF ( present( cna ) .and. f_cnatmp ) THEN
3309 cna(ix,kz,jy) = max(0.0, an(ix,1,kz,lccna) )
3310 ENDIF
3311 ENDIF
3312
3313 IF ( lcina > 1 ) THEN
3314 IF ( present( cni ) .and. f_cinatmp ) THEN
3315 cni(ix,kz,jy) = max(0.0, an(ix,1,kz,lcina) )
3316 ENDIF
3317 ENDIF
3318
3319 IF ( lccnuf > 0 .and. flag_cnuf ) THEN
3320 IF ( i_uf_or_ccn > 0 ) THEN ! UF are ccn and lccnuf is zero, so put cnuf into lccnuf to do decay
3321 an(ix,1,kz,lccnuf) = max(0.0, cnuf(ix,kz,jy) )
3322 ENDIF
3323 IF ( decayufccn ) THEN
3324 IF ( an(ix,1,kz,lccnuf) > ufbackground ) THEN
3325 an(ix,1,kz,lccnuf) = an(ix,1,kz,lccnuf) - (an(ix,1,kz,lccnuf) - &
3326 ufbackground)*(1.0 - exp(-dtp/ufccntimeconst))
3327 ENDIF
3328 ENDIF
3329 cnuf(ix,kz,jy) = an(ix,1,kz,lccnuf)
3330 ENDIF
3331
3332
3333
3334 IF ( ipconc >= 5 ) THEN
3335
3336 ccw(ix,kz,jy) = an(ix,1,kz,lnc)
3337 crw(ix,kz,jy) = an(ix,1,kz,lnr)
3338 IF ( present( cci ) ) cci(ix,kz,jy) = an(ix,1,kz,lni)
3339 csw(ix,kz,jy) = an(ix,1,kz,lns)
3340 chw(ix,kz,jy) = an(ix,1,kz,lnh)
3341 IF ( lhl > 1 ) chl(ix,kz,jy) = an(ix,1,kz,lnhl)
3342 ENDIF
3343
3344 IF ( ipconc >= 6 ) THEN
3345 IF ( lzr > 0 ) zrw(ix,kz,jy) = an(ix,1,kz,lzr) *zscaleinv
3346 IF ( lzh > 0 ) zhw(ix,kz,jy) = an(ix,1,kz,lzh) *zscaleinv
3347 IF ( lzhl > 0 ) zhl(ix,kz,jy) = an(ix,1,kz,lzhl)*zscaleinv
3348 ENDIF
3349
3350
3351
3352 IF ( lvh > 0 ) vhw(ix,kz,jy) = an(ix,1,kz,lvh)
3353 IF ( lvhl > 0 .and. present( vhl ) ) vhl(ix,kz,jy) = an(ix,1,kz,lvhl)
3354
3355#if ( WRF_CHEM == 1 )
3356 IF ( has_wetscav ) THEN
3357 IF ( loopmax > 1 ) THEN
3358 ! wrferror not supported
3359 ENDIF
3360 IF ( PRESENT( rainprod ) ) rainprod(ix,kz,jy) = rainprod2d(ix,kz)
3361 IF ( PRESENT( evapprod ) ) evapprod(ix,kz,jy) = evapprod2d(ix,kz)
3362 ENDIF
3363#endif
3364
3365 ENDDO
3366 ENDDO
3367
3368
3369 ENDDO ! jy
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379 RETURN
3380END SUBROUTINE nssl_2mom_driver
3381
3382! #####################################################################
3383! #####################################################################
3384
3387 REAL function gamma_sp(xx)
3388
3389 implicit none
3390 real xx
3391 integer j
3392
3393! Double precision ser,stp,tmp,x,y,cof(6)
3394
3395 real*8 ser,stp,tmp,x,y,cof(6)
3396 SAVE cof,stp
3397 DATA cof,stp/76.18009172947146d+0, &
3398 & -86.50532032941677d0, &
3399 & 24.01409824083091d0, &
3400 & -1.231739572450155d0, &
3401 & 0.1208650973866179d-2,&
3402 & -0.5395239384953d-5, &
3403 & 2.5066282746310005d0/
3404
3405 IF ( xx <= 0.0 ) THEN
3406 write(0,*) 'Argument to gamma must be > 0!! xx = ',xx
3407 ENDIF
3408
3409 x = xx
3410 y = x
3411 tmp = x + 5.5d0
3412 tmp = (x + 0.5d0)*log(tmp) - tmp
3413 ser = 1.000000000190015d0
3414 DO j=1,6
3415 y = y + 1.0d0
3416 ser = ser + cof(j)/y
3417 END DO
3418 gamma_sp = exp(tmp + log(stp*ser/x))
3419
3420 RETURN
3421 END FUNCTION gamma_sp
3422
3423! #####################################################################
3424
3427 DOUBLE PRECISION FUNCTION gamma_dpr(x)
3428 ! dp gamma with real input
3429 implicit none
3430 real :: x
3431 double precision :: xx
3432
3433 xx = x
3434
3435 gamma_dpr = gamma_dp(xx)
3436
3437 return
3438 end FUNCTION gamma_dpr
3439
3440
3441
3442
3443! #####################################################################
3444
3447 real function gamxinf(a1,x1)
3448
3449! ===================================================
3450! Purpose: Compute the incomplete gamma function
3451! from x to infinity
3452! Input : a --- Parameter ( a 170 )
3453! x --- Argument
3454! Output: GIM --- gamma(a,x) t=x,Infinity
3455! Routine called: GAMMA for computing gamma(x)
3456! ===================================================
3457
3458! IMPLICIT DOUBLE PRECISION (A-H,O-Z)
3459 implicit none
3460 real :: a1,x1
3461 double precision :: xam,dlog,s,r,ga,t0,a,x
3462 integer :: k
3463 double precision :: gin, gim
3464
3465 a = a1
3466 x = x1
3467 IF ( x1 <= 0.0 ) THEN
3468 gamxinf = gamma_sp(a1)
3469 return
3470 ENDIF
3471 xam=-x+a*dlog(x)
3472 IF (xam.GT.700.0.OR.a.GT.170.0) THEN
3473 WRITE(*,*)'a and/or x too large'
3474 ENDIF
3475 IF (x.EQ.0.0) THEN
3476 gin=0.0
3477 gim = gamma_sp(a1)
3478 ELSE IF (x.LE.1.0+a) THEN
3479 s=1.0d0/a
3480 r=s
3481 DO 10 k=1,60
3482 r=r*x/(a+k)
3483 s=s+r
3484 IF (dabs(r/s).LT.1.0d-15) GO TO 15
348510 CONTINUE
348615 gin=dexp(xam)*s
3487 ga = gamma_sp(a1)
3488 gim=ga-gin
3489 ELSE IF (x.GT.1.0+a) THEN
3490 t0=0.0d0
3491 DO 20 k=60,1,-1
3492 t0=(k-a)/(1.0d0+k/(x+t0))
349320 CONTINUE
3494 gim=dexp(xam)/(x+t0)
3495! GA = GAMMA_SP(A1)
3496! GIN=GA-GIM
3497 ENDIF
3498
3499 gamxinf = gim
3500 return
3501 END function gamxinf
3502
3503! #####################################################################
3504
3507 double precision function gamxinfdp(A1,X1)
3508
3509! ===================================================
3510! Purpose: Compute the incomplete gamma function
3511! from x to infinity
3512! Input : a --- Parameter ( a < 170 )
3513! x --- Argument
3514! Output: GIM --- Gamma(a,x) t=x,Infinity
3515! Routine called: GAMMA for computing gamma_dp(x)
3516! ===================================================
3517
3518! IMPLICIT DOUBLE PRECISION (A-H,O-Z)
3519 implicit none
3520 real :: a1,x1
3521! dont declare gamma_dp because it is within the module
3522! double precision :: gamma_dp
3523 double precision :: xam,dlog,s,r,ga,t0,a,x
3524 integer :: k
3525 double precision :: gin, gim
3526
3527 a = a1
3528 x = x1
3529 IF ( x1 <= 0.0 ) THEN
3530 gamxinfdp = gamma_dp(a)
3531 return
3532 ENDIF
3533 xam=-x+a*dlog(x)
3534 IF (xam.GT.700.0.OR.a.GT.170.0) THEN
3535 WRITE(*,*)'a and/or x too large'
3536 ENDIF
3537 IF (x.EQ.0.0) THEN
3538 gin=0.0
3539 gim = gamma_dp(a)
3540 ELSE IF (x.LE.1.0+a) THEN
3541 s=1.0d0/a
3542 r=s
3543 DO 10 k=1,60
3544 r=r*x/(a+k)
3545 s=s+r
3546 IF (dabs(r/s).LT.1.0d-15) GO TO 15
354710 CONTINUE
354815 gin=dexp(xam)*s
3549 ga = gamma_dp(a)
3550 gim=ga-gin
3551 ELSE IF (x.GT.1.0+a) THEN
3552 t0=0.0d0
3553 DO 20 k=60,1,-1
3554 t0=(k-a)/(1.0d0+k/(x+t0))
355520 CONTINUE
3556 gim=dexp(xam)/(x+t0)
3557! GA = GAMMA_dp(A)
3558! GIN=GA-GIM
3559 ENDIF
3560
3561 gamxinfdp = gim
3562 return
3563 END function gamxinfdp
3564
3565
3566! #####################################################################
3567
3570 real function gaminterp(ratio, alp, luindex, ilh)
3571
3572 implicit none
3573
3574 real, intent(in) :: ratio, alp
3575 integer, intent(in) :: ilh ! 1 = graupel, 2 = hail
3576 integer, intent(in) :: luindex ! which argument:
3577 ! gamxinflu(i,j,1,1) = x/y
3578 ! gamxinflu(i,j,2,1) = gamxinf( 2.0+alp, ratio )/y
3579 ! gamxinflu(i,j,3,1) = gamxinf( 2.5+alp+0.5*bxh, ratio )/y
3580 ! gamxinflu(i,j,5,1) = gamxinf( 5.0+alp, ratio )/y
3581 ! gamxinflu(i,j,6,1) = gamxinf( 5.5+alp+0.5*bxh, ratio )/y
3582
3583
3584 real :: delx, dely, tmp1, tmp2, temp3
3585 integer :: i,j,ip1,jp1 !,ilh
3586
3587! ilh = Abs(ilh0)
3588
3589
3590 i = min(nqiacrratio,int(ratio*dqiacrratioinv))
3591 j = int(max(0.0,min(maxalphalu,alp))*dqiacralphainv)
3592 delx = min(maxratiolu,ratio) - float(i)*dqiacrratio
3593 dely = alp - float(j)*dqiacralpha
3594 ip1 = min( i+1, nqiacrratio )
3595 jp1 = min( j+1, nqiacralpha )
3596
3597 ! interpolate along x, i.e., ratio;
3598 tmp1 = gamxinflu(i,j,luindex,ilh) + delx*dqiacrratioinv* &
3599 & (gamxinflu(ip1,j,luindex,ilh) - gamxinflu(i,j,luindex,ilh))
3600 tmp2 = gamxinflu(i,jp1,luindex,ilh) + delx*dqiacrratioinv* &
3601 & (gamxinflu(ip1,jp1,luindex,ilh) - gamxinflu(i,jp1,luindex,ilh))
3602
3603 ! interpolate along alpha;
3604
3605 gaminterp = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))
3606
3607 ! debug
3608! IF ( ilh0 < 0 ) THEN
3609! write(0,*) 'gaminterp: ',i,j,ilh,ratio,delx,dely,gamxinflu(i,j,luindex,ilh),tmp1,tmp2
3610! ENDIF
3611
3612 END FUNCTION gaminterp
3613! #####################################################################
3614
3615!**************************** GAML02 ***********************
3616! This calculates Gamma(0.2,x)/Gamma[0.2], where is a ratio
3617! It is used for qiacr with the gamma of volume to calculate what
3618! fraction of drops exceed a certain size (this version is for 40 micron drops)
3619! **********************************************************
3622 real function gaml02(x)
3623 implicit none
3624 integer ig, i, ii, n, np
3625 real x
3626 integer ng
3627 parameter(ng=12)
3628 real gamxg(ng), xg(ng)
3629 DATA xg/0.01,0.02,0.025,0.04,0.075,0.1,0.25,0.5,0.75,1.,2.,10./
3630 DATA gamxg/ &
3631 & 7.391019203578037e-8,0.02212726874591478,0.06959352407989682, &
3632 & 0.2355654024970809,0.46135930387500346,0.545435791452399, &
3633 & 0.7371571313308203, &
3634 & 0.8265676632204345,0.8640182781845841,0.8855756211304151, &
3635 & 0.9245079225301251, &
3636 & 0.9712578342732681/
3637 IF ( x .ge. xg(ng) ) THEN
3638 gaml02 = xg(ng)
3639 RETURN
3640 ENDIF
3641 IF ( x .lt. xg(1) ) THEN
3642 gaml02 = 0.0
3643 RETURN
3644 ENDIF
3645 DO ii = 1,ng-1
3646 i = ng - ii
3647 n = i
3648 np = n + 1
3649 IF ( x .ge. xg(i) ) THEN
3650! GOTO 2
3651 gaml02 = gamxg(n)+((x-xg(n))/(xg(np)-xg(n)))* &
3652 & ( gamxg(np) - gamxg(n) )
3653 RETURN
3654 ENDIF
3655 ENDDO
3656 RETURN
3657 END FUNCTION gaml02
3658
3659!**************************** GAML02d300 ***********************
3660! This calculates Gamma(0.2,x)/Gamma[0.2], where is a ratio
3661! It is used for qiacr with the gamma of volume to calculate what
3662! fraction of drops exceed a certain size (this version is for 300 micron drops) (see zieglerstuff.nb)
3663! **********************************************************
3666 real function gaml02d300(x)
3667 implicit none
3668 integer ig, i, ii, n, np
3669 real x
3670 integer ng
3671 parameter(ng=9)
3672 real gamxg(ng), xg(ng)
3673 DATA xg/0.04,0.075,0.1,0.25,0.5,0.75,1.,2.,10./
3674 DATA gamxg/ &
3675 & 0.0, &
3676 & 7.391019203578011e-8,0.0002260640810600053, &
3677 & 0.16567071824457152, &
3678 & 0.4231369044918005,0.5454357914523988, &
3679 & 0.6170290936864555, &
3680 & 0.7471346054110058,0.9037156157718299 /
3681 IF ( x .ge. xg(ng) ) THEN
3682 gaml02d300 = xg(ng)
3683 RETURN
3684 ENDIF
3685 IF ( x .lt. xg(1) ) THEN
3686 gaml02d300 = 0.0
3687 RETURN
3688 ENDIF
3689 DO ii = 1,ng-1
3690 i = ng - ii
3691 n = i
3692 np = n + 1
3693 IF ( x .ge. xg(i) ) THEN
3694! GOTO 2
3695 gaml02d300 = gamxg(n)+((x-xg(n))/(xg(np)-xg(n)))* &
3696 & ( gamxg(np) - gamxg(n) )
3697 RETURN
3698 ENDIF
3699 ENDDO
3700 RETURN
3701 END FUNCTION gaml02d300
3702!c
3703
3704! #####################################################################
3705! #####################################################################
3706
3707!**************************** GAML02 ***********************
3708! This calculates Gamma(0.2,x)/Gamma[0.2], where is a ratio
3709! It is used for qiacr with the gamma of volume to calculate what
3710! fraction of drops exceed a certain size (this version is for 500 micron drops) (see zieglerstuff.nb)
3711! **********************************************************
3714 real function gaml02d500(x)
3715 implicit none
3716 integer ig, i, ii, n, np
3717 real x
3718 integer ng
3719 parameter(ng=9)
3720 real gamxg(ng), xg(ng)
3721 DATA xg/0.04,0.075,0.1,0.25,0.5,0.75,1.,2.,10./
3722 DATA gamxg/ &
3723 & 0.0,0.0, &
3724 & 2.2346039e-13, 0.0221272687459, &
3725 & 0.23556540, 0.38710348, &
3726 & 0.48136183,0.6565833, &
3727 & 0.86918315 /
3728 IF ( x .ge. xg(ng) ) THEN
3729 gaml02d500 = xg(ng)
3730 RETURN
3731 ENDIF
3732 IF ( x .lt. xg(1) ) THEN
3733 gaml02d500 = 0.0
3734 RETURN
3735 ENDIF
3736 DO ii = 1,ng-1
3737 i = ng - ii
3738 n = i
3739 np = n + 1
3740 IF ( x .ge. xg(i) ) THEN
3741! GOTO 2
3742 gaml02d500 = gamxg(n)+((x-xg(n))/(xg(np)-xg(n)))* &
3743 & ( gamxg(np) - gamxg(n) )
3744 RETURN
3745 ENDIF
3746 ENDDO
3747 RETURN
3748 END FUNCTION gaml02d500
3749!c
3750
3751! #####################################################################
3752
3753! #####################################################################
3754
3755
3756 real function beta(p,q)
3757!
3758! ==========================================
3759! Purpose: Compute the beta function B(p,q)
3760! Input : p --- Parameter ( p > 0 )
3761! q --- Parameter ( q > 0 )
3762! Output: BT --- B(p,q)
3763! Routine called: GAMMA for computing gamma(x)
3764! ==========================================
3765!
3766! IMPLICIT real (A-H,O-Z)
3767 implicit none
3768 double precision p1,gp,q1,gq, ppq,gpq
3769 real p,q
3770
3771 p1 = p
3772 q1 = q
3773 CALL gammadp(p1,gp)
3774 CALL gammadp(q1,gq)
3775 ppq=p1+q1
3776 CALL gammadp(ppq,gpq)
3777 beta=gp*gq/gpq
3778 RETURN
3779 END function beta
3780
3781! #####################################################################
3782! #####################################################################
3783
3786 DOUBLE PRECISION FUNCTION gamma_dp(xx)
3787
3788 implicit none
3789 double precision xx
3790 integer j
3791
3792! Double precision ser,stp,tmp,x,y,cof(6)
3793
3794 real*8 ser,stp,tmp,x,y,cof(6)
3795 SAVE cof,stp
3796 DATA cof,stp/76.18009172947146d+0, &
3797 & -86.50532032941677d0, &
3798 & 24.01409824083091d0, &
3799 & -1.231739572450155d0, &
3800 & 0.1208650973866179d-2,&
3801 & -0.5395239384953d-5, &
3802 & 2.5066282746310005d0/
3803
3804 x = xx
3805 y = x
3806 tmp = x + 5.5d0
3807 tmp = (x + 0.5d0)*log(tmp) - tmp
3808 ser = 1.000000000190015d0
3809 DO j=1,6
3810 y = y + 1.0d0
3811 ser = ser + cof(j)/y
3812 END DO
3813 gamma_dp = exp(tmp + log(stp*ser/x))
3814
3815 RETURN
3816 END function gamma_dp
3817! #####################################################################
3818
3821 SUBROUTINE gammadp(X,GA)
3822!
3823! ==================================================
3824! Purpose: Compute gamma function Gamma(x)
3825! Input : x --- Argument of Gamma(x)
3826! ( x is not equal to 0,-1,-2,...)
3827! Output: GA --- gamma(x)
3828! ==================================================
3829!
3830! IMPLICIT DOUBLE PRECISION (A-H,O-Z)
3831 implicit none
3832
3833 double precision, parameter :: pi=3.141592653589793d0
3834 double precision :: x,ga,z,r,gr
3835 integer :: k,m1,m
3836
3837 double precision :: g(26)
3838
3839 IF (x.EQ.int(x)) THEN
3840 IF (x.GT.0.0d0) THEN
3841 ga=1.0d0
3842 m1=x-1
3843 DO k=2,m1
3844 ga=ga*k
3845 ENDDO
3846 ELSE
3847 ga=1.0d+300
3848 ENDIF
3849 ELSE
3850 IF (dabs(x).GT.1.0d0) THEN
3851 z=dabs(x)
3852 m=int(z)
3853 r=1.0d0
3854 DO k=1,m
3855 r=r*(z-k)
3856 ENDDO
3857 z=z-m
3858 ELSE
3859 z=x
3860 ENDIF
3861 DATA g/1.0d0,0.5772156649015329d0, &
3862 & -0.6558780715202538d0, -0.420026350340952d-1, &
3863 & 0.1665386113822915d0,-.421977345555443d-1, &
3864 & -.96219715278770d-2, .72189432466630d-2, &
3865 & -.11651675918591d-2, -.2152416741149d-3, &
3866 & .1280502823882d-3, -.201348547807d-4, &
3867 & -.12504934821d-5, .11330272320d-5, &
3868 & -.2056338417d-6, .61160950d-8, &
3869 & .50020075d-8, -.11812746d-8, &
3870 & .1043427d-9, .77823d-11, &
3871 & -.36968d-11, .51d-12, &
3872 & -.206d-13, -.54d-14, .14d-14, .1d-15/
3873 gr=g(26)
3874 DO k=25,1,-1
3875 gr=gr*z+g(k)
3876 ENDDO
3877 ga=1.0d0/(gr*z)
3878 IF (dabs(x).GT.1.0d0) THEN
3879 ga=ga*r
3880 IF (x.LT.0.0d0) ga=-pi/(x*ga*dsin(pi*x))
3881 ENDIF
3882 ENDIF
3883 RETURN
3884 END SUBROUTINE gammadp
3885
3886
3887! #####################################################################
3888! #####################################################################
3889!
3890!
3891! #####################################################################
3894 Function delbk(bb,nu,mu,k)
3895!
3896! Purpose: Caluculates collection coefficients following Siefert (2006)
3897!
3898! delbk is equation (90) (b collecting b -- self-collection)
3899! mass-diameter relationship: D = a*x**(b), where x = particle mass
3900! general distribution: n(x) = A*x**(nu)*Exp(-lam*x**(mu))
3901! where
3902! A = mu*N/(Gamma((nu+1)/mu)) *lam**((nu+1)/mu)
3903!
3904! lam = ( Gamma((nu+1)/mu)/Gamma((nu+2)/mu) * xbar )**(-mu)
3905!
3906! where xbar = L/N (mass content)/(number concentration) = q*rhoa/N
3907!
3908
3909 implicit none
3910 real delbk
3911 real nu, mu, bb
3912 integer k
3913
3914 real tmp, del
3915 real x1, x2, x3, x4
3916 integer i
3917
3918 tmp = ((1.0 + nu)/mu)
3919 i = int(dgami*(tmp))
3920 del = tmp - dgam*i
3921 x1 = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3922
3923 tmp = ((2.0 + nu)/mu)
3924 i = int(dgami*(tmp))
3925 del = tmp - dgam*i
3926 x2 = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3927
3928 tmp = ((1.0 + 2.0*bb + k + nu)/mu)
3929 i = int(dgami*(tmp))
3930 del = tmp - dgam*i
3931 x3 = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3932
3933! delbk = &
3934! & ((Gamma_sp((1.0 + nu)/mu)/Gamma_sp((2.0 + nu)/mu))**(2.0*bb + k)* &
3935! & Gamma_sp((1.0 + 2.0*bb + k + nu)/mu))/Gamma_sp((1.0 + nu)/mu)
3936
3937 delbk = &
3938 & ((x1/x2)**(2.0*bb + k)* &
3939 & x3)/x1
3940
3941 RETURN
3942 END Function delbk
3943
3944! #####################################################################
3945!
3946!
3947! #####################################################################
3948! Equation (91) in Seifert and Beheng (2006) ("a" collecting "b")
3951 Function delabk(ba,bb,nua,nub,mua,mub,k)
3952
3953 implicit none
3954 real delabk
3955 real nua, mua, ba
3956 integer k
3957 real nub, mub, bb
3958
3959 integer i
3960 real tmp,del
3961
3962 real g1pnua, g2pnua, g1pbapnua, g1pbbpk, g1pnub, g2pnub
3963
3964 tmp = (1. + nua)/mua
3965 i = int(dgami*(tmp))
3966 del = tmp - dgam*i
3967 IF ( i+1 > ngm0 ) THEN
3968 write(0,*) 'delabk: i+1 > ngm0!!!!',i,ngm0,nua,mua,tmp
3969 ENDIF
3970 g1pnua = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3971! write(91,*) 'delabk: g1pnua,gamma = ',g1pnua,Gamma_sp((1. + nua)/mua)
3972
3973 tmp = ((2. + nua)/mua)
3974 i = int(dgami*(tmp))
3975 del = tmp - dgam*i
3976 g2pnua = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3977
3978 tmp = ((1. + ba + nua)/mua)
3979 i = int(dgami*(tmp))
3980 del = tmp - dgam*i
3981 g1pbapnua = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3982
3983 tmp = ((1. + nub)/mub)
3984 i = int(dgami*(tmp))
3985 del = tmp - dgam*i
3986 g1pnub = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3987
3988 tmp = ((2 + nub)/mub)
3989 i = int(dgami*(tmp))
3990 del = tmp - dgam*i
3991 g2pnub = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3992
3993 tmp = ((1. + bb + k + nub)/mub)
3994 i = int(dgami*(tmp))
3995 del = tmp - dgam*i
3996 g1pbbpk = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
3997
3998 delabk = &
3999 & (2.*(g1pnua/g2pnua)**ba* &
4000 & g1pbapnua* &
4001 & (g1pnub/g2pnub)**(bb + k)* &
4002 & g1pbbpk)/ &
4003 & (g1pnua*g1pnub)
4004
4005 RETURN
4006 END Function delabk
4007
4008
4009
4010! #######################################################################
4011! HAILMAXD - calculated maximum expected hail size
4012! #######################################################################
4015 subroutine hailmaxd(dtp,nx,ny,nz,an,na,nor,norz,alpha2d,dn, &
4016 & hailmax1d,hailmaxk1,jslab )
4017!
4018! Calculate maximum hail size from the tail of of the distribution. The value
4019! of thresh_conc sets the minimum concentration in the integral over (Dmax, Inf).
4020! This uses the lookup tables for incomplete gamma functions and simply search for
4021! the expected value (and linearly interpolate) on D.
4022!
4023! Written by ERM 7/2023
4024!
4025!
4026!
4027 implicit none
4028
4029 integer nx,ny,nz,nor,norz,ngt,jgs,na,ia
4030 integer id ! =1 use density, =0 no density
4031! integer :: its,ite ! x-range to calculate
4032
4033 integer ng1
4034 parameter(ng1 = 1)
4035
4036 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
4037 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4038
4039! real gz(-nor+ng1:nz+nor),z1d(-nor+ng1:nz+nor,4)
4040 real dtp
4041 real alpha2d(-nor+1:nx+nor,1,-norz+1:nz+norz,3) ! array for PSD shape parameters
4042 real :: hailmax1d(nx,ny),hailmaxk1(nx,ny)
4043 integer infdo
4044 integer jslab ! which line of xfall to use
4045
4046 integer ix,jy,kz,ndfall,n,k,il,in
4047 double precision :: tmp, ratio, del, g1palp
4048 real, parameter :: dz = 200.
4049
4050 real :: db1(nx,nz+1),dtz1(nz+1,nx,0:1),dz2dinv(nz+1,nx),db1inv(nx,nz+1)
4051
4052 real :: rhovtzx(nz,nx)
4053
4054 real :: alp, diam, diam1, hwdn
4055
4056! real, parameter :: cmin = 0.001 ! threshold number per m^3 for maximum diamter (threshold from diag_nwp)
4057 DOUBLE PRECISION, PARAMETER:: thresh_conc = 0.0005d0 ! number conc. of graupel/hail per cubic meter
4058 real :: cwchtmp,cwchltmp, maxdia
4059
4060!-----------------------------------------------------------------------------
4061
4062 integer :: ixb, jyb, kzb
4063 integer :: ixe, jye, kze
4064 integer :: plo, phi
4065 integer :: ialp, i, j
4066
4067 logical :: debug_mpi = .true.
4068
4069! ###################################################################
4070
4071
4072 IF ( lh > 1 ) THEN
4073 cwchtmp = ((3. + dnu(lh))*(2. + dnu(lh))*(1.0 + dnu(lh)))**(-1./3.)
4074 ENDIF
4075 IF ( lhl > 1 ) THEN
4076 cwchltmp = ((3. + dnu(lhl))*(2. + dnu(lhl))*(1.0 + dnu(lhl)))**(-1./3.)
4077 ENDIF
4078
4079
4080 kzb = 1
4081 kze = nz
4082
4083 ixb = 1 ! aliased its
4084 ixe = nx ! aliased ite
4085
4086
4087 jy = jslab
4088 jgs = jy
4089
4090
4091! hailmax1d(:,jy) = 0.0
4092! hailmaxk1(:,jy) = 0.0
4093
4094 if ( ndebug .gt. 0 ) write(0,*) 'dbg = 3a'
4095
4096
4097! first graupel, even if hail is also predicted, since graupel can sometime be large on its own
4098 IF ( lh > 1 .and. lnh > 1 ) THEN
4099 DO kz = kzb,kze
4100 DO ix = ixb,ixe
4101 IF ( an(ix,jy,kz,lh) .gt. qxmin(lh) .and. an(ix,jy,kz,lnh) .gt. thresh_conc ) THEN
4102 IF ( lvh .gt. 1 ) THEN
4103 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
4104 ELSE
4105 hwdn = rho_qh
4106 ENDIF
4107
4108 tmp = 1. + alpha2d(ix,1,kz,2)
4109 i = int(dgami*(tmp))
4110 del = tmp - dgam*i
4111 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4112
4113 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lh)/(hwdn*an(ix,jy,kz,lnh))
4114 diam = (6.0*tmp/pi)**(1./3.)
4115 IF ( lzh > 1 ) THEN ! 3moment
4116 cwchtmp = ((3. + alpha2d(ix,1,kz,2))*(2. + alpha2d(ix,1,kz,2))*(1.0 + alpha2d(ix,1,kz,2)))**(-1./3.)
4117 ENDIF
4118 diam1 = diam*cwchtmp ! characteristic diameter, i.e., 1/lambda
4119 ! want cxd1 = thresh_conc
4120 ! tmp = gaminterp(ratio,alpha(mgs,lh),1,1)
4121 ! cxd1 = cx(mgs,lh)*(tmp)/g1palp
4122 ! tmp = thresh_conc*g1palp/cx
4123 !
4124 tmp = thresh_conc*g1palp/an(ix,jy,kz,lnh)
4125 alp = alpha2d(ix,1,kz,2)
4126 ! gamxinflu(i,j,luindex,ilh)
4127 j = int(max(0.0,min(maxalphalu,alp))*dqiacralphainv)
4128 ratio = 0.0
4129 maxdia = 0.0
4130 ! eventually could replace with bisection search, but final value of i is usually small
4131 ! compared to nqiacrratio
4132 DO i = 0,nqiacrratio-1
4133 IF ( gamxinflu(i,j,1,1) >= tmp .and. tmp >= gamxinflu(i+1,j,1,1) ) THEN
4134 ! interpolate here for FWIW
4135 ratio = i*dqiacrratio
4136 del = tmp - gamxinflu(i,j,1,1)
4137 ratio = (float(i) + del/(gamxinflu(i+1,j,1,1) - gamxinflu(i,j,1,1)))*dqiacrratio
4138 exit
4139 ENDIF
4140 ENDDO
4141
4142 IF ( ratio > 0.0 ) THEN
4143 maxdia = ratio*diam1 ! units of m
4144 ENDIF
4145
4146 IF ( kz == kzb ) THEN
4147 hailmaxk1(ix,jy) = max( maxdia, hailmaxk1(ix,jy) )
4148! IF ( maxdia > 0.1 ) THEN
4149! IF ( an(ix,jy,kz,lh) > 1.e-4 ) THEN
4150! write(0,*) 'maxdia,tmp,alp,ratio,diam,diam1= ',maxdia,tmp,alp,ratio,diam*100.,diam1*100.
4151! write(0,*) 'hwdn, cxhl, qx, g1palp = ',hwdn, an(ix,jy,kz,lnhl), an(ix,jy,kz,lhl), g1palp
4152! write(0,*) 'j,gamxinflu(0,2,4) = ',j,gamxinflu(0,j,1,1),gamxinflu(2,j,1,1), &
4153! gamxinflu(4,j,1,1)
4154! ENDIF
4155 ENDIF
4156
4157 hailmax1d(ix,jy) = max(maxdia, hailmax1d(ix,jy) )
4158
4159 !
4160
4161 ENDIF
4162
4163 ENDDO
4164 ENDDO
4165
4166 ENDIF ! lh
4167
4168! And diam for hail if present
4169 IF ( lhl > 1 .and. lnhl > 1 ) THEN
4170 DO kz = kzb,kze
4171 DO ix = ixb,ixe
4172 IF ( an(ix,jy,kz,lhl) .gt. qxmin(lhl) .and. an(ix,jy,kz,lnhl) .gt. thresh_conc ) THEN
4173 IF ( lvhl .gt. 1 ) THEN
4174 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
4175 ELSE
4176 hwdn = rho_qhl
4177 ENDIF
4178
4179 tmp = 1. + alpha2d(ix,1,kz,3)
4180 i = int(dgami*(tmp))
4181 del = tmp - dgam*i
4182 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4183
4184 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/(hwdn*an(ix,jy,kz,lnhl))
4185 diam = (6.0*tmp/pi)**(1./3.)
4186 IF ( lzhl > 1 ) THEN ! 3moment
4187 cwchltmp = ((3. + alpha2d(ix,1,kz,3))*(2. + alpha2d(ix,1,kz,3))*(1.0 + alpha2d(ix,1,kz,3)))**(-1./3.)
4188 ENDIF
4189 diam1 = diam*cwchltmp ! characteristic diameter, i.e., 1/lambda
4190 ! want cxd1 = thresh_conc
4191 ! tmp = gaminterp(ratio,alpha(mgs,lh),1,1)
4192 ! cxd1 = cx(mgs,lh)*(tmp)/g1palp
4193 ! tmp = thresh_conc*g1palp/cx
4194 !
4195 tmp = thresh_conc*g1palp/an(ix,jy,kz,lnhl)
4196 alp = alpha2d(ix,1,kz,3)
4197 ! gamxinflu(i,j,luindex,ilh)
4198 j = int(max(0.0,min(maxalphalu,alp))*dqiacralphainv)
4199 ratio = 0.0
4200 maxdia = 0.0
4201 ! eventually could replace with bisection search, but final value of i is usually small
4202 ! compared to nqiacrratio
4203 DO i = 0,nqiacrratio-1
4204 IF ( gamxinflu(i,j,1,1) >= tmp .and. tmp >= gamxinflu(i+1,j,1,1) ) THEN
4205 ! interpolate here for FWIW
4206 ratio = i*dqiacrratio
4207 del = tmp - gamxinflu(i,j,1,1)
4208 ratio = (float(i) + del/(gamxinflu(i+1,j,1,1) - gamxinflu(i,j,1,1)))*dqiacrratio
4209 exit
4210 ENDIF
4211 ENDDO
4212
4213 IF ( ratio > 0.0 ) THEN
4214 maxdia = ratio*diam1 ! units of m
4215 ENDIF
4216
4217 IF ( kz == kzb ) THEN
4218 hailmaxk1(ix,jy) = max( maxdia, hailmaxk1(ix,jy) )
4219! IF ( maxdia > 0.1 ) THEN
4220! IF ( an(ix,jy,kz,lhl) > 1.e-4 ) THEN
4221! write(0,*) 'maxdia,tmp,alp,ratio,diam,diam1= ',maxdia,tmp,alp,ratio,diam*100.,diam1*100.
4222! write(0,*) 'hwdn, cxhl, qx, g1palp = ',hwdn, an(ix,jy,kz,lnhl), an(ix,jy,kz,lhl), g1palp
4223! write(0,*) 'j,gamxinflu(0,2,4) = ',j,gamxinflu(0,j,1,1),gamxinflu(2,j,1,1), &
4224! gamxinflu(4,j,1,1)
4225! ENDIF
4226 ENDIF
4227
4228 hailmax1d(ix,jy) = max(maxdia, hailmax1d(ix,jy) )
4229
4230 !
4231
4232 ENDIF
4233
4234 ENDDO
4235 ENDDO
4236
4237 ENDIF
4238
4239
4240 END SUBROUTINE hailmaxd
4241! #######################################################################
4242! #######################################################################
4245 subroutine sediment1d(dtp,nx,ny,nz,an,na,nor,norz,xfall,dn,dz3d,dz3dinv, &
4246 & t0,t7,infdo,jslab,its,jts, &
4247 & timesed1,timesed2,timesed3,zmaxsed,timesetvt) ! used for timing
4248!
4249! Sedimentation driver -- column by column
4250!
4251! Written by ERM 10/2011
4252!
4253!
4254!
4255 implicit none
4256
4257 integer nx,ny,nz,nor,norz,ngt,jgs,na,ia
4258 integer id ! =1 use density, =0 no density
4259 integer :: its,jts ! SW point of local tile
4260
4261 integer ng1
4262 parameter(ng1 = 1)
4263
4264 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
4265 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4266 real dz3d(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4267 real dz3dinv(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4268 real t0(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4269 real t7(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4270
4271! real gz(-nor+ng1:nz+nor),z1d(-nor+ng1:nz+nor,4)
4272 real dtp
4273 real xfall(nx,ny,na) ! array for stuff landing on the ground
4274! real xfall0(nx,ny) ! dummy array
4275 integer infdo
4276 integer jslab ! which line of xfall to use
4277
4278 integer ix,jy,kz,ndfall,n,k,il,in
4279 real tmp, vtmax, dtptmp, dtfrac
4280 real, parameter :: dz = 200.
4281
4282! real :: xvt(nz+1,nx,3,lc:lhab) ! (nx,nz,2,lc:lhab) ! 1=mass-weighted, 2=number-weighted
4283! real :: tmpn(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
4284! real :: tmpn2(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
4285! real :: z(-nor+ng1:nx+nor,-norz+ng1:nz+norz,lr:lhab)
4286! real :: db1(nx,nz+1),dtz1(nz+1,nx,0:1),dz2dinv(nz+1,nx),db1inv(nx,nz+1)
4287
4288! real :: rhovtzx(nz,nx)
4289
4290 real, allocatable :: db1(:,:), dtz1(:,:,:),dz2dinv(:,:),db1inv(:,:) ! db1(nx,nz+1),dtz1(nz+1,nx,0:1),dz2dinv(nz+1,nx),db1inv(nx,nz+1)
4291 real, allocatable :: rhovtzx(:,:)
4292 real, allocatable :: xfall0(:,:), xvt(:,:,:,:),tmpn(:,:,:),tmpn2(:,:,:),z(:,:,:)
4293
4294 double precision :: timesed1,timesed2,timesed3, zmaxsed,timesetvt,dummy
4295 double precision :: dt1,dt2,dt3,dt4
4296
4297 integer :: ngs ! = 512
4298 integer :: ngscnt,mgs,ipconc0
4299
4300! real :: qx(ngs,lv:lhab)
4301! real :: qxw(ngs,ls:lhab)
4302! real :: cx(ngs,lc:lhab)
4303! real :: xv(ngs,lc:lhab)
4304! real :: vtxbar(ngs,lc:lhab,3)
4305! real :: xmas(ngs,lc:lhab)
4306! real :: xdn(ngs,lc:lhab)
4307! real :: xdia(ngs,lc:lhab,3)
4308! real :: vx(ngs,li:lhab)
4309! real :: alpha(ngs,lc:lhab)
4310! real :: zx(ngs,lr:lhab)
4311! logical :: hasmass(nx,lc+1:lhab)
4312!
4313! integer igs(ngs),kgs(ngs)
4314!
4315! real rho0(ngs),temcg(ngs)
4316!
4317! real temg(ngs)
4318!
4319! real rhovt(ngs)
4320!
4321! real cwnc(ngs),cinc(ngs)
4322! real fadvisc(ngs),cwdia(ngs),cipmas(ngs)
4323!
4324! real cimasn,cimasx,cnina(ngs),cimas(ngs)
4325!
4326! real cnostmp(ngs)
4327
4328 real, allocatable :: qx(:,:)
4329 real, allocatable :: qxw(:,:)
4330 real, allocatable :: cx(:,:)
4331 real, allocatable :: xv(:,:)
4332 real, allocatable :: vtxbar(:,:,:)
4333 real, allocatable :: xmas(:,:)
4334 real, allocatable :: xdn(:,:)
4335 real, allocatable :: xdia(:,:,:)
4336 real, allocatable :: vx(:,:)
4337 real, allocatable :: alpha(:,:)
4338 real, allocatable :: zx(:,:)
4339 logical, allocatable :: hasmass(:,:)
4340
4341 integer, allocatable :: igs(:),kgs(:)
4342
4343 real, allocatable :: rho0(:),temcg(:)
4344
4345 real, allocatable :: temg(:)
4346
4347 real, allocatable :: rhovt(:)
4348
4349 real, allocatable :: cwnc(:),cinc(:)
4350 real, allocatable :: fadvisc(:),cwdia(:),cipmas(:)
4351
4352 real, allocatable :: cnina(:),cimas(:)
4353
4354 real, allocatable :: cnostmp(:)
4355
4356 real :: cimasn,cimasx
4357
4358
4359!-----------------------------------------------------------------------------
4360
4361 integer :: ixb, jyb, kzb
4362 integer :: ixe, jye, kze
4363 integer :: plo, phi
4364
4365 logical :: debug_mpi = .true.
4366
4367! ###################################################################
4368
4369
4370 allocate( db1(nx,nz+1),dtz1(nz+1,nx,0:1),dz2dinv(nz+1,nx),db1inv(nx,nz+1),rhovtzx(nz,nx) )
4371 allocate( xfall0(nx,ny), xvt(nz+1,nx,3,lc:lhab), tmpn(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz) )
4372 allocate( tmpn2(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz), z(-nor+ng1:nx+nor,-norz+ng1:nz+norz,lr:lhab))
4373
4374 ngs = nz+3
4375
4376 allocate( qx(ngs,lv:lhab), &
4377 qxw(ngs,ls:lhab), &
4378 cx(ngs,lc:lhab), &
4379 xv(ngs,lc:lhab), &
4380 vtxbar(ngs,lc:lhab,3), &
4381 xmas(ngs,lc:lhab), &
4382 xdn(ngs,lc:lhab), &
4383 xdia(ngs,lc:lhab,3), &
4384 vx(ngs,li:lhab), &
4385 alpha(ngs,lc:lhab), &
4386 zx(ngs,lr:lhab), &
4387 hasmass(nx,lc+1:lhab), &
4388 igs(ngs),kgs(ngs), &
4389 rho0(ngs),temcg(ngs),temg(ngs), rhovt(ngs), &
4390 cwnc(ngs),cinc(ngs), &
4391 fadvisc(ngs),cwdia(ngs),cipmas(ngs), &
4392 cnina(ngs),cimas(ngs), &
4393 cnostmp(ngs) )
4394
4395 kzb = 1
4396 kze = nz
4397
4398 ixb = 1
4399 ixe = nx
4400
4401
4402 jy = 1
4403 jgs = jy
4404
4405
4406!
4407! zero the precip flux arrays (2d)
4408!
4409
4410 xvt(:,:,:,:) = 0.0
4411
4412 if ( ndebug .gt. 0 ) write(0,*) 'dbg = 3a'
4413
4414
4415 DO kz = kzb,kze
4416 DO ix = ixb,ixe
4417 db1(ix,kz) = dn(ix,jy,kz)
4418 db1inv(ix,kz) = 1./dn(ix,jy,kz)
4419 rhovtzx(kz,ix) = sqrt(rho00*min(1.0/0.05, db1inv(ix,kz))) ! prevent excessive rhovt
4420 ENDDO
4421 ENDDO
4422
4423 DO kz = kzb,kze
4424 DO ix = ixb,ixe
4425 dtz1(kz,ix,0) = dz3dinv(ix,jy,kz)
4426 dtz1(kz,ix,1) = dz3dinv(ix,jy,kz)*db1inv(ix,kz)
4427 dz2dinv(kz,ix) = dz3dinv(ix,jy,kz)
4428 ENDDO
4429 ENDDO
4430
4431 IF ( lzh .gt. 1 ) THEN
4432 DO kz = kzb,kze
4433 DO ix = ixb,ixe
4434 an(ix,jy,kz,lzh) = max( 0., an(ix,jy,kz,lzh) )
4435 ENDDO
4436 ENDDO
4437 ENDIF
4438
4439
4440 DO il = lc+1,lhab
4441 DO ix = ixb,ixe
4442! hasmass(ix,il) = Any( an(ix,jy,:,il) > qxmin(il) )
4443 ENDDO
4444 ENDDO
4445
4446
4447
4448
4449 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3a2'
4450
4451! loop over columns
4452 DO ix = ixb,ixe
4453
4454 dummy = 0.d0
4455
4456
4457 call ziegfall1d(nx,ny,nz,nor,norz,na,dtp,jgs,ix, &
4458 & xvt, rhovtzx, &
4459 & an,dn,ipconc,t0,t7,cwmasn,cwmasx, &
4460 & cwradn, &
4461 & qxmin,xdnmx,xdnmn,cdx,cno,xdn0,xvmn,xvmx, &
4462 & ngs,qx,qxw,cx,xv,vtxbar,xmas,xdn,xdia,vx,alpha,zx,igs,kgs, &
4463 & rho0,temcg,temg,rhovt,cwnc,cinc,fadvisc,cwdia,cipmas,cnina,cimas, &
4464 & cnostmp, &
4465 & infdo,0 &
4466 & )
4467
4468
4469! loop over each species and do sedimentation for all moments
4470 DO il = lc,lhab
4471 IF ( ido(il) == 0 ) cycle
4472
4473! IF ( .not. hasmass(ix,il) ) CYCLE
4474
4475! plo = nz
4476! phi = 0
4477
4478
4479 vtmax = 0.0
4480
4481 do kz = kzb,kze
4482
4483 ! apply limit vtmaxsed (08/20/2015)
4484 xvt(kz,ix,1,il) = min( vtmaxsed, xvt(kz,ix,1,il) )
4485 xvt(kz,ix,2,il) = min( vtmaxsed, xvt(kz,ix,2,il) )
4486 xvt(kz,ix,3,il) = min( vtmaxsed, xvt(kz,ix,3,il) )
4487
4488 vtmax = max(vtmax,xvt(kz,ix,1,il)*dz2dinv(kz,ix))
4489 vtmax = max(vtmax,xvt(kz,ix,2,il)*dz2dinv(kz,ix))
4490 vtmax = max(vtmax,xvt(kz,ix,3,il)*dz2dinv(kz,ix))
4491
4492! IF ( dtp*xvt(kz,ix,1,il)*dz2dinv(kz,ix) >= 0.7 .or. &
4493! & dtp*xvt(kz,ix,2,il)*dz2dinv(kz,ix) >= 0.7 .or. &
4494! & dtp*xvt(kz,ix,3,il)*dz2dinv(kz,ix) >= 0.7 ) THEN
4495!
4496! zmaxsed = Max(zmaxsed, float(kz) )
4497!! plo = Min(plo,kz)
4498!! phi = Max(phi,kz)
4499!
4500! ENDIF
4501
4502 ENDDO
4503
4504 IF ( vtmax == 0.0 ) cycle
4505
4506
4507
4508 IF ( dtp*vtmax .lt. 0.7 ) THEN ! check whether multiple steps are needed.
4509 ndfall = 1
4510 ELSE
4511 IF ( dtp > 20.0 ) THEN ! more stringent subdivision for large time steps
4512 ndfall = max(2, int(dtp*vtmax/0.7) + 1)
4513 ELSE ! more relaxed for small time steps, but might still be a problem for very thin vertical layers near the ground
4514 ndfall = 1+int(dtp*vtmax + 0.301)
4515 ENDIF
4516 ENDIF
4517
4518 IF ( ndfall .gt. 1 ) THEN
4519 dtptmp = dtp/real(ndfall)
4520! write(0,*) 'subdivide fallout on its,jts,ix,plo,phi = ',its,jts,ix,plo,phi
4521! write(0,*) 'for il,jsblab,c,ndfall = ',il,jslab,dtp*vtmax,ndfall
4522 ELSE
4523 dtptmp = dtp
4524 ENDIF
4525
4526 dtfrac = dtptmp/dtp
4527
4528
4529 DO n = 1,ndfall
4530
4531 IF ( do_accurate_sedimentation .and. n .ge. 2 .and. ( n == interval_sedi_vt*(n/interval_sedi_vt) ) ) THEN
4532!
4533! zero the precip flux arrays (2d)
4534!
4535
4536 dummy = 0.d0
4537
4538 xvt(kzb:kze,ix,1:3,il) = 0.0 ! reset to zero because routine will only compute points with q > qmin
4539
4540 call ziegfall1d(nx,ny,nz,nor,norz,na,dtp,jgs,ix, &
4541 & xvt, rhovtzx, &
4542 & an,dn,ipconc,t0,t7,cwmasn,cwmasx, &
4543 & cwradn, &
4544 & qxmin,xdnmx,xdnmn,cdx,cno,xdn0,xvmn,xvmx, &
4545 & ngs,qx,qxw,cx,xv,vtxbar,xmas,xdn,xdia,vx,alpha,zx,igs,kgs, &
4546 & rho0,temcg,temg,rhovt,cwnc,cinc,fadvisc,cwdia,cipmas,cnina,cimas, &
4547 & cnostmp, &
4548 & infdo,il)
4549
4550
4551 DO kz = kzb,kze
4552 ! apply limit vtmaxsed (08/20/2015)
4553 xvt(kz,ix,1,il) = min( vtmaxsed, xvt(kz,ix,1,il) )
4554 xvt(kz,ix,2,il) = min( vtmaxsed, xvt(kz,ix,2,il) )
4555 xvt(kz,ix,3,il) = min( vtmaxsed, xvt(kz,ix,3,il) )
4556 ENDDO
4557
4558
4559
4560
4561 ENDIF ! (n .ge. 2)
4562
4563
4564 IF ( il >= lr .and. ( infall .eq. 3 .or. infall .eq. 4 ) .and. ln(il) > 0 ) THEN
4565 IF ( (il .eq. lr .and. irfall .eq. infall .and. lzr < 1) .or. &
4566 (il .ge. lh .and. lz(il) .lt. 1 ) .or. (il == ls .and. isfall == infall ) ) THEN
4567 call calczgr1d(nx,ny,nz,nor,na,an,ixe,kze, &
4568 & z,db1,jgs,ipconc, dnu(il), il, ln(il), qxmin(il), xvmn(il), xvmx(il), lvol(il), xdn0(il), ix )
4569 ENDIF
4570 ENDIF
4571
4572 if (ndebug .gt. 0 ) write(0,*) 'dbg = 1b'
4573
4574! mixing ratio
4575
4576 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
4577 & an,db1,il,1,xfall,dtz1,ix)
4578
4579
4580 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3c'
4581
4582! volume
4583
4584 IF ( ldovol .and. il >= li ) THEN
4585 IF ( lvol(il) .gt. 1 ) THEN
4586 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
4587 & an,db1,lvol(il),0,xfall,dtz1,ix)
4588 ENDIF
4589 ENDIF
4590
4591! reflectivity
4592
4593 IF ( ipconc .ge. 6 ) THEN
4594 IF ( lz(il) .gt. 1 ) THEN
4595 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,3,il), &
4596 & an,db1,lz(il),0,xfall,dtz1,ix)
4597 ENDIF
4598 ENDIF
4599
4600 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3d'
4601
4602
4603 IF ( ipconc .gt. 0 ) THEN !{
4604 IF ( ipconc .ge. ipc(il) ) THEN
4605
4606 IF ( ( infall .ge. 2 .or. (infall .eq. 0 .and. il .lt. lh) ) .and. lz(il) .lt. 1) THEN !{
4607!
4608! load number conc. into tmpn to do fallout by mass-weighted mean fall speed
4609! to put a lower bound on number conc.
4610!
4611
4612 IF ( ( infall .eq. 3 .or. infall .eq. 4 ) .and. ( (il == ls .and. isfall .eq. infall ) &
4613 & .or. il .eq. lh .or. il .eq. lhl .or. il == lf .or. &
4614 & ( il .eq. lr .and. irfall .eq. infall) ) ) THEN
4615
4616 ! set up for method I+II
4617 DO kz = kzb,kze
4618! DO ix = ixb,ixe
4619 tmpn2(ix,jy,kz) = z(ix,kz,il)
4620! ENDDO
4621 ENDDO
4622 DO kz = kzb,kze
4623! DO ix = ixb,ixe
4624 tmpn(ix,jy,kz) = an(ix,jy,kz,ln(il))
4625! ENDDO
4626 ENDDO
4627
4628 ELSE
4629 ! set up for method II only
4630 DO kz = kzb,kze
4631! DO ix = ixb,ixe
4632 tmpn(ix,jy,kz) = an(ix,jy,kz,ln(il))
4633! ENDDO
4634 ENDDO
4635
4636 ENDIF
4637
4638 ENDIF !}
4639
4640
4641 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3f'
4642
4643 in = 2
4644 IF ( infall .eq. 1 ) in = 1
4645
4646 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,in,il), &
4647 & an,db1,ln(il),0,xfall,dtz1,ix)
4648
4649
4650 IF ( lz(il) .lt. 1 ) THEN ! if not 3-moment, run one of the correction schemes
4651 IF ( (infall .ge. 2 .or. infall .eq. 3) .and. .not. (infall .eq. 0 .and. il .ge. lh) &
4652 & .and. ( il .eq. lr .or. (il .ge. li .and. il .le. lhab) )) THEN
4653! : .or. il .eq. lhl )) THEN
4654
4655 xfall0(:,jgs) = 0.0
4656
4657 IF ( ( infall .eq. 3 .or. infall .eq. 4 ) .and. &
4658 & ( il .ge. lh .or. (il .eq. lr .and. irfall .eq. infall) &
4659 .or. (il .eq. ls .and. isfall .eq. infall) ) ) THEN
4660 call fallout1d(nx,ny,nz,nor,1,dtptmp,dtfrac,jgs,xvt(1,1,3,il), &
4661 & tmpn2,db1,1,0,xfall0,dtz1,ix)
4662 call fallout1d(nx,ny,nz,nor,1,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
4663 & tmpn,db1,1,0,xfall0,dtz1,ix)
4664 ELSE
4665 call fallout1d(nx,ny,nz,nor,1,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
4666 & tmpn,db1,1,0,xfall0,dtz1,ix)
4667 ENDIF
4668
4669 IF ( ( infall .eq. 3 .or. infall .eq. 4 ) .and. ( (il .eq. lr .and. irfall .eq. infall) &
4670 & .or. il .ge. lh .or. (il == ls .and. isfall .eq. infall ) ) ) THEN
4671! "Method I" - dbz correction
4672
4673 call calcnfromz1d(nx,ny,nz,nor,na,an,tmpn2,ixe,kze, &
4674 & z,db1,jgs,ipconc, dnu(il), il, ln(il), qxmin(il), xvmn(il), xvmx(il),tmpn, &
4675 & lvol(il), xdn0(il), infall, ix)
4676
4677 ELSEIF ( infall .eq. 5 .and. il .ge. lh .or. ( il == lr .and. irfall == 5 ) ) THEN
4678
4679 DO kz = kzb,kze
4680! DO ix = ixb,ixe
4681 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) ))
4682
4683! ENDDO
4684 ENDDO
4685
4686 ELSEIF ( .not. (il .eq. lr .and. irfall .eq. 0) .and. .not. (il .eq. ls .and. isfall .eq. 0) ) THEN
4687! "Method II" M-wgt N-fallout correction
4688
4689 DO kz = kzb,kze
4690! DO ix = ixb,ixe
4691
4692 an(ix,jgs,kz,ln(il)) = max( an(ix,jgs,kz,ln(il)), tmpn(ix,jy,kz) )
4693
4694! ENDDO
4695 ENDDO
4696 ENDIF
4697 ENDIF ! lz(il) .lt. 1
4698
4699
4700 ENDIF
4701 ENDIF
4702
4703
4704 ENDIF !}
4705
4706
4707 ENDDO ! n=1,ndfall
4708 ENDDO ! il
4709
4710 ENDDO ! ix
4711
4712
4713 deallocate( db1,dtz1,dz2dinv,db1inv,rhovtzx )
4714 deallocate( xfall0, xvt, tmpn )
4715 deallocate( tmpn2, z)
4716
4717 deallocate( qx, &
4718 qxw, &
4719 cx, &
4720 xv, &
4721 vtxbar, &
4722 xmas, &
4723 xdn, &
4724 xdia, &
4725 vx, &
4726 alpha, &
4727 zx, &
4728 hasmass, &
4729 igs,kgs, &
4730 rho0,temcg,temg, rhovt, &
4731 cwnc,cinc, &
4732 fadvisc,cwdia,cipmas, &
4733 cnina,cimas, &
4734 cnostmp )
4735
4736 RETURN
4737 END SUBROUTINE sediment1d
4738
4739
4740! #####################################################################
4741
4742!
4743! #####################################################################
4744
4745
4746!
4747!--------------------------------------------------------------------------
4748!
4749!--------------------------------------------------------------------------
4750!
4753 subroutine fallout1d(nx,ny,nz,nor,na,dtp,dtfrac,jgs,vt, &
4754 & a,db1,ia,id,xfall,dtz1,ixcol)
4755!
4756! First-order, upwind fallout scheme
4757!
4758! Written by ERM 6/10/2011
4759!
4760!
4761!
4762 implicit none
4763
4764 integer nx,ny,nz,nor,ngt,jgs,na,ia
4765 integer id ! =1 use density, =0 no density
4766 integer ng1
4767 parameter(ng1 = 1)
4768 integer :: ixcol
4769
4770! real dz3dinv(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
4771! real a(nx,ny,nz,na)
4772 real a(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,na) ! quantity to be 'advected'
4773 real vt(nz+1,nx) ! terminal speed for a
4774 real dtp,dtfrac
4775 real cmax
4776 real xfall(nx,ny,na) ! array for stuff landing on the ground
4777 real db1(nx,nz+1),dtz1(nz+1,nx,0:1)
4778
4779! Local
4780
4781 integer ix,jy,kz,n,k
4782 integer iv1,iv2
4783 real tmp
4784 integer imn,imx,kmn,kmx
4785 real qtmp1(nz+1)
4786
4787!-----------------------------------------------------------------------------
4788
4789 integer :: ixb, jyb, kzb
4790 integer :: ixe, jye, kze
4791
4792 logical :: debug_mpi = .true.
4793
4794! ###################################################################
4795
4796 jy = 1
4797
4798 iv1 = 0
4799 iv2 = 0
4800
4801 imn = nx
4802 imx = 1
4803 kmn = nz
4804 kmx = 1
4805
4806 cmax = 0.0
4807
4808 kzb = 1
4809 kze = nz
4810
4811 ixb = ixcol
4812 ixe = ixcol
4813 ix = ixcol
4814
4815 qtmp1(nz+1) = 0.0
4816
4817 DO kz = kzb,kze
4818! DO ix = ixb,ixe
4819! cmax = Max(cmax, vt(ix,kz)*dz3dinv(ix,jy,kz))
4820
4821 IF ( id == 1 ) THEN
4822 qtmp1(kz) = a(ix,jgs,kz,ia)*vt(kz,ix)*db1(ix,kz)
4823 ELSE
4824 qtmp1(kz) = a(ix,jgs,kz,ia)*vt(kz,ix)
4825 ENDIF
4826
4827 IF ( a(ix,jgs,kz,ia) .ne. 0.0 ) THEN
4828! imn = Min(ix,imn)
4829! imx = Max(ix,imx)
4830 kmn = min(kz,kmn)
4831 kmx = max(kz,kmx)
4832 ENDIF
4833! ENDDO
4834 ENDDO
4835
4836 kmn = max(1,kmn-1)
4837
4838! first check if fallout is worth doing
4839! IF ( cmax .eq. 0.0 .or. imn .gt. imx ) THEN
4840! RETURN
4841! ENDIF
4842
4843 IF ( kmn == 1 ) THEN
4844
4845 kz = 1
4846! do ix = imn,imx ! 1,nx-1
4847 xfall(ix,jy,ia) = xfall(ix,jy,ia) + a(ix,jgs,kz,ia)*vt(kz,ix)*dtfrac
4848! enddo
4849
4850 ENDIF
4851
4852 do kz = 1,nz
4853! do ix = 1,nx
4854 a(ix,jgs,kz,ia) = a(ix,jgs,kz,ia) + dtp*dtz1(kz,ix,id)*(qtmp1(kz+1) - qtmp1(kz) )
4855! enddo
4856 enddo
4857
4858
4859 RETURN
4860 END SUBROUTINE fallout1d
4861
4862! ##############################################################################
4863! ##############################################################################
4864
4867 subroutine calczgr1d(nx,ny,nz,nor,na,a,ixe,kze, &
4868 & z,db,jgs,ipconc, alpha, l,ln, qmin, xvmn,xvmx, lvol, rho_qx, ixcol)
4869
4870
4871 implicit none
4872
4873 integer nx,ny,nz,nor,na,ngt,jgs
4874 integer :: ixcol
4875 integer, parameter :: norz = 3
4876 real a(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,na)
4877 real z(-nor+1:nx+nor,-nor+1:nz+nor,lr:lhab) ! reflectivity
4878 real db(nx,nz+1) ! air density
4879! real gt(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,ngt)
4880
4881 integer ixe,kze
4882 real alpha
4883 real qmin
4884 real xvmn,xvmx
4885 integer ipconc
4886 integer l ! index for q
4887 integer ln ! index for N
4888 integer lvol ! index for volume
4889 real rho_qx
4890
4891
4892 integer ix,jy,kz
4893 real vr,qr,nrx,rd,xv,g1,zx,chw,xdn,ynu
4894
4895
4896 jy = jgs
4897 ix = ixcol
4898
4899 IF ( l .eq. lh .or. l .eq. lhl .or. ( l .eq. lr .and. imurain == 1 ) &
4900 .or. ( l .eq. ls .and. imusnow == 1 ) ) THEN
4901
4902
4903 DO kz = 1,kze
4904
4905
4906
4907 IF ( a(ix,jy,kz,l) .gt. qmin .and. a(ix,jy,kz,ln) .gt. 1.e-15 ) THEN
4908
4909 IF ( lvol .gt. 1 ) THEN
4910 IF ( a(ix,jy,kz,lvol) .gt. 0.0 ) THEN
4911 xdn = db(ix,kz)*a(ix,jy,kz,l)/a(ix,jy,kz,lvol)
4912 xdn = min( 900., max( hdnmn, xdn ) )
4913 ELSE
4914 xdn = rho_qx
4915 ENDIF
4916 ELSE
4917 xdn = rho_qx
4918 ENDIF
4919
4920 IF ( l == lr ) xdn = 1000.
4921
4922 qr = a(ix,jy,kz,l)
4923 xv = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
4924 chw = a(ix,jy,kz,ln)
4925
4926 IF ( xv .lt. xvmn .or. xv .gt. xvmx ) THEN
4927 xv = min( xvmx, max( xvmn,xv ) )
4928 chw = db(ix,kz)*a(ix,jy,kz,l)/(xv*xdn)
4929 ENDIF
4930
4931 g1 = (6.0 + alpha)*(5.0 + alpha)*(4.0 + alpha)/ &
4932 & ((3.0 + alpha)*(2.0 + alpha)*(1.0 + alpha))
4933 zx = g1*db(ix,kz)**2*(a(ix,jy,kz,l))*a(ix,jy,kz,l)/chw
4934! z(ix,kz,l) = 1.e18*zx*(6./(pi*1000.))**2
4935 z(ix,kz,l) = zx*(6./(pi*1000.))**2
4936
4937
4938! IF ( ny.eq.2 .and. kz .ge. 25 .and. kz .le. 29 .and. z(ix,kz,l) .gt. 0. ) THEN
4939! write(*,*) 'calczgr: z,dbz,xdn = ',ix,kz,z(ix,kz,l),10*log10(z(ix,kz,l)),xdn
4940! ENDIF
4941
4942 ELSE
4943
4944 z(ix,kz,l) = 0.0
4945
4946 ENDIF
4947
4948 ENDDO
4949
4950 ELSEIF ( (l == ls .and. imusnow == 3) .or. ( l .eq. lr .and. imurain == 3 ) ) THEN
4951
4952 xdn = rho_qx ! 1000.
4953 IF ( l == ls ) ynu = snu
4954 IF ( l == lr ) ynu = rnu
4955
4956 DO kz = 1,kze
4957
4958 IF ( a(ix,jy,kz,l) .gt. qmin .and. a(ix,jy,kz,ln) .gt. 1.e-15 ) THEN
4959
4960 vr = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
4961! z(ix,kz,l) = 3.6e18*(ynu+2.0)*a(ix,jy,kz,ln)*vr**2/(ynu+1.0)
4962 z(ix,kz,l) = 3.6*(ynu+2.0)*a(ix,jy,kz,ln)*vr**2/(ynu+1.0)
4963! qr = a(ix,jy,kz,lr)
4964! nrx = a(ix,jy,kz,lnr)
4965
4966 ELSE
4967
4968 z(ix,kz,l) = 0.0
4969
4970 ENDIF
4971
4972
4973 ENDDO
4974
4975 ENDIF
4976
4977 RETURN
4978
4979 END subroutine calczgr1d
4980
4981! ##############################################################################
4982! ##############################################################################
4983!
4984! Subroutine to correct number concentration to prevent reflectivity growth by
4985! sedimentation in 2-moment ZXX scheme.
4986! Calculation is in a slab (constant jgs)
4987!
4988
4991 subroutine calcnfromz1d(nx,ny,nz,nor,na,a,t0,ixe,kze, &
4992 & z0,db,jgs,ipconc, alpha, l,ln, qmin, xvmn,xvmx,t1, &
4993 & lvol, rho_qx, infall, ixcol)
4994
4995
4996 implicit none
4997
4998 integer nx,ny,nz,nor,na,ngt,jgs,ixcol
4999
5000 real a(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,na) ! sedimented N and q
5001 real t0(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor) ! sedimented reflectivity
5002 real t1(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor) ! sedimented N (by Vm)
5003! real gt(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,ngt)
5004 real z0(-nor+1:nx+nor,-nor+1:nz+nor,lr:lhab) ! initial reflectivity
5005
5006 real db(nx,nz+1) ! air density
5007
5008 integer ixe,kze
5009 real alpha
5010 real qmin
5011 real xvmn,xvmx
5012 integer ipconc
5013 integer l ! index for q
5014 integer ln ! index for N
5015 integer lvol ! index for volume
5016 real rho_qx
5017 integer infall
5018
5019
5020 integer ix,jy,kz
5021 double precision vr,qr,nrx,rd,g1,zx,chw,z,znew,zt,zxt
5022 real xv,xdn
5023 integer :: ndbz, nmwgt, nnwgt, nwlessthanz
5024
5025 ndbz = 0
5026 nmwgt = 0
5027 nnwgt = 0
5028 nwlessthanz = 0
5029
5030
5031
5032 jy = jgs
5033 ix = ixcol
5034
5035 IF ( l .eq. lh .or. l .eq. lhl .or. ( l == lr .and. imurain == 1 ) ) THEN
5036
5037 g1 = (6.0 + alpha)*(5.0 + alpha)*(4.0 + alpha)/ &
5038 & ((3.0 + alpha)*(2.0 + alpha)*(1.0 + alpha))
5039
5040 DO kz = 1,kze
5041
5042
5043 IF ( t0(ix,jy,kz) .gt. 0. ) THEN ! {
5044
5045 IF ( lvol .gt. 1 ) THEN
5046 IF ( a(ix,jy,kz,lvol) .gt. 0.0 ) THEN
5047 xdn = db(ix,kz)*a(ix,jy,kz,l)/a(ix,jy,kz,lvol)
5048 xdn = min( 900., max( hdnmn, xdn ) )
5049 ELSE
5050 xdn = rho_qx
5051 ENDIF
5052 ELSE
5053 xdn = rho_qx
5054 ENDIF
5055
5056 IF ( l == lr ) xdn = 1000.
5057
5058 qr = a(ix,jy,kz,l)
5059 xv = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
5060 chw = a(ix,jy,kz,ln)
5061
5062 IF ( xv .lt. xvmn .or. xv .gt. xvmx ) THEN
5063 xv = min( xvmx, max( xvmn,xv ) )
5064 chw = db(ix,kz)*a(ix,jy,kz,l)/(xv*xdn)
5065 ENDIF
5066
5067 zx = g1*db(ix,kz)**2*( a(ix,jy,kz,l))*a(ix,jy,kz,l)/chw
5068 z = zx*(6./(pi*1000.))**2
5069
5070
5071 IF ( (z .gt. t0(ix,jy,kz) .and. z .gt. 0.0 .and. &
5072 & t0(ix,jy,kz) .gt. z0(ix,kz,l) )) THEN !{
5073
5074 zx = t0(ix,jy,kz)/((6./(pi*1000.))**2)
5075
5076 nrx = g1*db(ix,kz)**2*( a(ix,jy,kz,l))*a(ix,jy,kz,l)/zx
5077 IF ( infall .eq. 3 ) THEN
5078 IF ( nrx .gt. a(ix,jy,kz,ln) ) THEN
5079 ndbz = ndbz + 1
5080 IF ( t1(ix,jy,kz) .lt. ndbz ) nwlessthanz = nwlessthanz + 1
5081 ELSE
5082 nnwgt = nnwgt + 1
5083 ENDIF
5084 a(ix,jy,kz,ln) = max( real(nrx), a(ix,jy,kz,ln) )
5085 ELSE
5086 IF ( nrx .gt. a(ix,jy,kz,ln) .and. t1(ix,jy,kz) .gt. a(ix,jy,kz,ln) ) THEN
5087 IF ( nrx .lt. t1(ix,jy,kz) ) THEN
5088 ndbz = ndbz + 1
5089 ELSE
5090 nmwgt = nmwgt + 1
5091 IF ( t1(ix,jy,kz) .lt. ndbz ) nwlessthanz = nwlessthanz + 1
5092 ENDIF
5093 ELSE
5094 nnwgt = nnwgt + 1
5095 ENDIF
5096
5097 a(ix,jy,kz,ln) = max(min( real(nrx), t1(ix,jy,kz) ), a(ix,jy,kz,ln) )
5098 ENDIF
5099
5100 ELSE ! } {
5101 IF ( t1(ix,jy,kz) .gt. 0 .and. a(ix,jy,kz,ln) .gt. 0 ) THEN
5102 IF ( t1(ix,jy,kz) .gt. a(ix,jy,kz,ln) ) THEN
5103 nmwgt = nmwgt + 1
5104 ELSE
5105 nnwgt = nnwgt + 1
5106 ENDIF
5107 ENDIF
5108 a(ix,jy,kz,ln) = max(t1(ix,jy,kz), a(ix,jy,kz,ln) )
5109 nrx = a(ix,jy,kz,ln)
5110
5111
5112
5113 ENDIF ! }
5114
5115 ! }
5116 ELSE ! {
5117 IF ( t1(ix,jy,kz) .gt. 0 .and. a(ix,jy,kz,ln) .gt. 0 ) THEN
5118 IF ( t1(ix,jy,kz) .gt. a(ix,jy,kz,ln) ) THEN
5119 nmwgt = nmwgt + 1
5120 ELSE
5121 nnwgt = nnwgt + 1
5122 ENDIF
5123 ENDIF
5124 endif! }
5125
5126 ENDDO
5127
5128
5129 ELSEIF ( l .eq. lr .and. imurain == 3) THEN
5130
5131 xdn = 1000.
5132
5133 DO kz = 1,kze
5134 IF ( t0(ix,jy,kz) .gt. 0. ) THEN
5135
5136 vr = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
5137 z = 3.6*(rnu+2.0)*a(ix,jy,kz,ln)*vr**2/(rnu+1.0)
5138
5139 IF ( z .gt. t0(ix,jy,kz) .and. z .gt. 0.0 .and. &
5140 & t0(ix,jy,kz) .gt. 0.0 &
5141 & .and. t0(ix,jy,kz) .gt. z0(ix,kz,l) ) THEN
5142
5143 vr = db(ix,kz)*a(ix,jy,kz,l)/(xdn)
5144 chw = a(ix,jy,kz,ln)
5145 nrx = 3.6*(rnu+2.0)*vr**2/((rnu+1.0)*t0(ix,jy,kz))
5146 IF ( infall .eq. 3 ) THEN
5147 a(ix,jy,kz,ln) = max( real(nrx), a(ix,jy,kz,ln) )
5148 ELSEIF ( infall .eq. 4 ) THEN
5149 a(ix,jy,kz,ln) = max( min( real(nrx), t1(ix,jy,kz)), a(ix,jy,kz,ln) )
5150 ENDIF
5151
5152 ELSE
5153
5154 a(ix,jy,kz,ln) = max(t1(ix,jy,kz), a(ix,jy,kz,ln) )
5155
5156 ENDIF
5157
5158 ELSE
5159
5160 a(ix,jy,kz,ln) = max(t1(ix,jy,kz), a(ix,jy,kz,ln) )
5161
5162 ENDIF
5163
5164
5165 ENDDO
5166
5167 ENDIF
5168
5169 RETURN
5170
5171 END subroutine calcnfromz1d
5172
5173
5174! ##############################################################################
5175! ##############################################################################
5176!
5177! Subroutine to calculate number concentrations from initial state that has only mixing ratio.
5178! Output N will be in #/m^3 in 'an' array, since sedimentation is done next.
5179! Output ccw,cci etc. will be in #/kg
5180
5181!
5182! 10.27.2015: Added hail calculation
5183!
5186 subroutine calcnfromq(nx,ny,nz,an,na,nor,norz,dn, &
5187 & qcw,qci,qsw,qrw,qhw,qhl, &
5188 & ccw,cci,csw,crw,chw,chl, &
5189 & cccn,cccna, vhw,vhl,qv,spechum, invertccn_flag, cwmasin )
5190
5191
5192
5193 implicit none
5194
5195 integer nx,ny,nz,nor,norz,na,ngt,jgs,ixcol
5196
5197 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na) ! scalars (q, N, Z)
5198
5199 real dn(nx,nz+1) ! air density
5200
5201 real, optional, dimension(nx,nz), intent(inout) :: qcw,qci,qsw,qrw,qhw,qhl, &
5202 ccw,cci,csw,crw,chw,chl, &
5203 cccn,cccna,vhw,vhl,qv, spechum
5204 logical, optional, intent(in) :: invertccn_flag
5205 real, optional :: cwmasin
5206
5207 integer ixe,kze
5208 real alpha
5209 real qmin
5210 real xvmn,xvmx
5211 integer ipconc
5212 integer lvol ! index for volume
5213 integer infall
5214
5215
5216 integer ix,jy,kz
5217 double precision vr,q,nrx,nrx2,rd,g1h,g1hl,g1r,g1s,zx,z,znew,zt,zxt,n1,laminv1
5218 double precision :: zr, zs, zh, dninv
5219 real, parameter :: xn0s = 3.0e6, xn0r = 8.0e6, xn0h = 2.0e5, xn0hl = 4.0e4
5220 real, parameter :: xdnr = 1000., xdns = 100. ,xdnh = 700.0, xdnhl = 900.0
5221 real, parameter :: zhlfac = 1./(pi*xdnhl*xn0hl)
5222 real, parameter :: zhfac = 1./(pi*xdnh*xn0h)
5223 real, parameter :: zrfac = 1./(pi*xdnr*xn0r)
5224 real, parameter :: zsfac = 1./(pi*xdns*xn0s)
5225 real, parameter :: g0 = (6.0)*(5.0)*(4.0)/((3.0)*(2.0)*(1.0))
5226 real, parameter :: xims=900.*0.523599*(2.*50.e-6)**3 ! mks (100 micron diam solid sphere approx)
5227 real, parameter :: xgms=xdnh*0.523599*(300.e-6)**3 ! mks (300 micron diam sphere approx)
5228 real, parameter :: cwmas09 = 1000.*0.523599*(2.*9.e-6)**3 ! mass of 9-micron radius droplet
5229
5230 real xv,xdn,cwmasinv
5231 integer :: ndbz, nmwgt, nnwgt, nwlessthanz
5232 double precision :: mixconv, mixconvqv, qsmax,qsmax2,qsmax3,qsmax4
5233 logical :: invertccn_local
5234
5235! ------------------------------------------------------------------
5236
5237 IF ( present( invertccn_flag ) ) THEN
5238 invertccn_local = invertccn_flag
5239 ELSE
5240 invertccn_local = .false.
5241 ENDIF
5242
5243 IF ( present( cwmasin ) ) THEN
5244 cwmasinv = 1.0/cwmasin
5245 ELSE
5246 cwmasinv = 1.0/cwmas09
5247 ENDIF
5248
5249 jy = 1
5250
5251
5252 g1h = (6.0 + alphah)*(5.0 + alphah)*(4.0 + alphah)/ &
5253 & ((3.0 + alphah)*(2.0 + alphah)*(1.0 + alphah))
5254
5255 g1hl = (6.0 + alphahl)*(5.0 + alphahl)*(4.0 + alphahl)/ &
5256 & ((3.0 + alphahl)*(2.0 + alphahl)*(1.0 + alphahl))
5257
5258 IF ( imurain == 3 ) THEN
5259 g1r = (rnu+2.0)/(rnu+1.0)
5260 ELSE ! imurain == 1
5261 g1r = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/ &
5262 & ((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
5263 ENDIF
5264
5265 g1s = (snu+2.0)/(snu+1.0)
5266 qsmax = 0
5267 qsmax2 = 0
5268 qsmax3 = 0
5269 qsmax4 = 0
5270! IF ( .not. present( qcw ) ) THEN
5271 DO kz = 1,nz
5272 DO ix = 1,nx ! ixcol
5273
5274! qv_mp = spechum/(1.0_kind_phys-spechum)
5275! IF ( convertdry ) THEN
5276! qc_mp = qc/(1.0_kind_phys-spechum)
5277 mixconv = 1
5278 IF ( present( spechum ) ) THEN ! convert to "dry" mixing ratios
5279 an(ix,jy,kz,lv) = spechum(ix,kz)/(1.0d0 - spechum(ix,kz))
5280 mixconv = 1.0d0/(1.0d0 - spechum(ix,kz))
5281 ELSE
5282 mixconv = 1.0d0
5283 ENDIF
5284 IF ( present( qv ) ) an(ix,jy,kz,lv) = qv(ix,kz) ! assume qv is "dry" mixing ratio if passed in
5285 IF ( present( qcw ) ) an(ix,jy,kz,lc) = qcw(ix,kz)*mixconv
5286 IF ( present( qrw ) ) an(ix,jy,kz,lr) = qrw(ix,kz)*mixconv
5287 IF ( present( qci ) ) an(ix,jy,kz,li) = qci(ix,kz)*mixconv
5288 IF ( present( qsw ) ) THEN
5289 an(ix,jy,kz,ls) = qsw(ix,kz)*mixconv
5290! qsmax = Max( qsmax, qsw(ix,kz) )
5291! qsmax2 = Max( qsmax2, an(ix,jy,kz,ls) )
5292 ENDIF
5293 IF ( present( qhw ) ) an(ix,jy,kz,lh) = qhw(ix,kz)*mixconv
5294 IF ( lhl > 1 .and. present( qhl ) ) an(ix,jy,kz,lhl) = qhl(ix,kz)*mixconv
5295 IF ( present( ccw ) ) an(ix,jy,kz,lnc) = ccw(ix,kz)*mixconv*dn(ix,kz)
5296 IF ( present( crw ) ) an(ix,jy,kz,lnr) = crw(ix,kz)*mixconv*dn(ix,kz)
5297 IF ( present( cci ) ) an(ix,jy,kz,lni) = cci(ix,kz)*mixconv*dn(ix,kz)
5298 IF ( present( csw ) ) an(ix,jy,kz,lns) = csw(ix,kz)*mixconv*dn(ix,kz)
5299 IF ( present( chw ) ) an(ix,jy,kz,lnh) = chw(ix,kz)*mixconv*dn(ix,kz)
5300 IF ( lhl > 1 .and. present( chl ) ) an(ix,jy,kz,lnhl) = chl(ix,kz)*mixconv*dn(ix,kz)
5301 IF ( lvh > 1 .and. present( vhw ) ) an(ix,jy,kz,lvh) = vhw(ix,kz)*mixconv
5302 IF ( lvhl > 1 .and. present( vhl ) ) an(ix,jy,kz,lvhl) = vhl(ix,kz)*mixconv
5303 IF ( lccn > 1 .and. present( cccn ) ) an(ix,jy,kz,lccn) = cccn(ix,kz)*mixconv*dn(ix,kz)
5304 IF ( lccna > 1 .and. present( cccna ) ) an(ix,jy,kz,lccna) = cccna(ix,kz)*mixconv
5305
5306 dninv = 1./dn(ix,kz)
5307
5308! IF ( .not. present( qcw ) ) THEN
5309 ! Cloud droplets
5310
5311 IF ( lnc > 1 ) THEN
5312 IF ( an(ix,jy,kz,lnc) <= cxmin .and. an(ix,jy,kz,lc) > qxmin_init(lc) ) THEN
5313
5314 an(ix,jy,kz,lnc) = min(qccn, an(ix,jy,kz,lc)*cwmasinv )*dn(ix,kz)
5315
5316 IF ( invertccn_local ) THEN
5317 an(ix,jy,kz,lccn) = an(ix,jy,kz,lccn) + an(ix,jy,kz,lnc)
5318 ELSE
5319
5320 IF ( lccn > 1 .and. lccna < 1 ) THEN
5321 an(ix,jy,kz,lccn) = an(ix,jy,kz,lccn) - an(ix,jy,kz,lnc)
5322 ENDIF
5323 IF ( lccna > 1 ) THEN
5324 an(ix,jy,kz,lccna) = an(ix,jy,kz,lccna) + an(ix,jy,kz,lnc)
5325 ENDIF
5326 ENDIF
5327
5328 ELSEIF ( an(ix,jy,kz,lc) <= qxmin(lc) .or. &
5329 ( an(ix,jy,kz,lnc) <= cxmin .and. an(ix,jy,kz,lc) <= qxmin_init(lc)) ) THEN
5330
5331 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lc)
5332 an(ix,jy,kz,lnc) = 0.0
5333 an(ix,jy,kz,lc) = 0.0
5334
5335 ENDIF
5336 ENDIF
5337
5338 ! Cloud ice
5339
5340 IF ( lni > 1 ) THEN
5341 IF ( an(ix,jy,kz,lni) <= cxmin .and. an(ix,jy,kz,li) > qxmin_init(li) ) THEN
5342 an(ix,jy,kz,lni) = dn(ix,kz)*an(ix,jy,kz,li)/xims
5343
5344 ELSEIF ( an(ix,jy,kz,li) <= qxmin(li) .or. &
5345 ( an(ix,jy,kz,lni) <= cxmin .and. an(ix,jy,kz,li) <= qxmin_init(li)) ) THEN
5346 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,li)
5347 an(ix,jy,kz,lni) = 0.0
5348 an(ix,jy,kz,li) = 0.0
5349 ENDIF
5350 ENDIF
5351
5352 ! rain
5353
5354 IF ( lnr > 1 ) THEN
5355 IF ( an(ix,jy,kz,lnr) <= 0.1*cxmin .and. an(ix,jy,kz,lr) > qxmin_init(lr) ) THEN
5356
5357 q = an(ix,jy,kz,lr)
5358
5359 laminv1 = (dn(ix,kz) * q * zrfac)**(0.25) ! inverse of slope
5360
5361 n1 = laminv1*xn0r ! number concentration for inv. exponential single moment input
5362
5363 nrx = n1*g1r/g0 ! number concentration for different shape parameter
5364
5365 an(ix,jy,kz,lnr) = nrx ! *dninv ! convert to number mixing ratio
5366
5367 ELSEIF ( an(ix,jy,kz,lr) <= qxmin(lr) .or. &
5368 ( an(ix,jy,kz,lnr) <= cxmin .and. an(ix,jy,kz,lr) <= qxmin_init(lr)) ) THEN
5369 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lr)
5370 an(ix,jy,kz,lnr) = 0.0
5371 an(ix,jy,kz,lr) = 0.0
5372 ENDIF
5373 ENDIF
5374
5375 IF ( lzr > 1 ) THEN ! set reflectivity moment
5376 IF ( an(ix,jy,kz,lr) > qxmin_init(lr) .and. an(ix,jy,kz,lzr) < zxmin .and. &
5377 an(ix,jy,kz,lnr) > cxmin ) THEN
5378 q = an(ix,jy,kz,lr)
5379 nrx = an(ix,jy,kz,lnr)
5380 an(ix,jy,kz,lzr) = 36.*g1r*dn(ix,kz)**2*q**2/(pi**2*xdnr**2*nrx) ! *dninv
5381 ENDIF
5382 ENDIF
5383
5384 ! snow
5385 IF ( lns > 1 ) THEN
5386 IF ( an(ix,jy,kz,lns) <= 0.1*cxmin .and. an(ix,jy,kz,ls) > qxmin_init(ls) ) THEN
5387
5388 q = an(ix,jy,kz,ls)
5389
5390 laminv1 = (dn(ix,kz) * q * zsfac)**(0.25) ! inverse of slope
5391
5392 n1 = laminv1*xn0s ! number concentration for inv. exponential single moment input
5393
5394 nrx = n1*g1s/g0 ! number concentration for different shape parameter
5395
5396 an(ix,jy,kz,lns) = nrx ! *dninv ! convert to number mixing ratio
5397
5398 ELSEIF ( an(ix,jy,kz,ls) <= qxmin(ls) .or. &
5399 ( an(ix,jy,kz,lns) <= cxmin .and. an(ix,jy,kz,ls) <= qxmin_init(ls)) ) THEN
5400 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,ls)
5401 an(ix,jy,kz,lns) = 0.0
5402 an(ix,jy,kz,ls) = 0.0
5403
5404 ENDIF
5405 ENDIF
5406
5407 ! graupel
5408
5409 IF ( lnh > 1 ) THEN
5410 IF ( an(ix,jy,kz,lnh) <= 0.1*cxmin .and. an(ix,jy,kz,lh) > qxmin_init(lh) ) THEN
5411 IF ( lvh > 1 ) THEN
5412 IF ( an(ix,jy,kz,lvh) <= 0.0 ) THEN
5413 an(ix,jy,kz,lvh) = an(ix,jy,kz,lh)/xdnh
5414 ENDIF
5415 ENDIF
5416
5417 q = an(ix,jy,kz,lh)
5418
5419 laminv1 = (dn(ix,kz) * q * zhfac)**(0.25) ! inverse of slope
5420
5421 n1 = laminv1*xn0h ! number concentration for inv. exponential single moment input
5422
5423 nrx = n1*g1h/g0 ! number concentration for different shape parameter
5424
5425 nrx2 = dn(ix,kz) * q / xgms
5426
5427 nrx = min( nrx, nrx2 )
5428
5429 IF ( nrx > cxmin ) THEN
5430 an(ix,jy,kz,lnh) = nrx ! *dninv ! convert to number mixing ratio
5431 ELSE
5432 an(ix,jy,kz,lh) = 0.0
5433 an(ix,jy,kz,lnh) = 0.0
5434 an(ix,jy,kz,lvh) = 0.0
5435 ENDIF
5436
5437 ELSEIF ( an(ix,jy,kz,lh) <= qxmin(lh) .or. &
5438 ( an(ix,jy,kz,lnh) <= cxmin .and. an(ix,jy,kz,lh) <= qxmin_init(lh)) ) THEN
5439
5440 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lh)
5441 an(ix,jy,kz,lh) = 0.0
5442
5443 ENDIF
5444 ENDIF
5445
5446 IF ( lzh > 1 ) THEN ! set reflectivity moment
5447 IF ( an(ix,jy,kz,lh) > qxmin_init(lh) .and. an(ix,jy,kz,lzh) < zxmin .and. &
5448 an(ix,jy,kz,lnh) > cxmin ) THEN
5449 q = an(ix,jy,kz,lh)
5450 nrx = an(ix,jy,kz,lnh)
5451 an(ix,jy,kz,lzh) = 36.*g1h*dn(ix,kz)**2*q**2/(pi**2*xdnh**2*nrx) ! *dninv
5452 ENDIF
5453 ENDIF
5454
5455 ! hail
5456
5457 IF ( lnhl > 1 .and. lhl > 1 ) THEN
5458 IF ( an(ix,jy,kz,lnhl) <= 0.1*cxmin .and. an(ix,jy,kz,lhl) > qxmin_init(lhl) ) THEN
5459 IF ( lvhl > 1 ) THEN
5460 IF ( an(ix,jy,kz,lvhl) <= 0.0 ) THEN
5461 an(ix,jy,kz,lvhl) = an(ix,jy,kz,lhl)/xdnhl
5462 ENDIF
5463 ENDIF
5464
5465 q = an(ix,jy,kz,lhl)
5466
5467 laminv1 = (dn(ix,kz) * q * zhlfac)**(0.25) ! inverse of slope
5468
5469 n1 = laminv1*xn0hl ! number concentration for inv. exponential single moment input
5470
5471 nrx = n1*g1hl/g0 ! number concentration for different shape parameter
5472
5473 an(ix,jy,kz,lnhl) = nrx ! *dninv ! convert to number mixing ratio
5474
5475 ELSEIF ( an(ix,jy,kz,lhl) <= qxmin(lhl) .or. &
5476 ( an(ix,jy,kz,lnhl) <= cxmin .and. an(ix,jy,kz,lhl) <= qxmin_init(lhl)) ) THEN
5477
5478 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lhl)
5479 an(ix,jy,kz,lhl) = 0.0
5480
5481 ENDIF
5482 ENDIF
5483
5484 IF ( lzhl > 1 ) THEN ! set reflectivity moment
5485 IF ( an(ix,jy,kz,lhl) > qxmin_init(lhl) .and. an(ix,jy,kz,lzhl) < zxmin .and. &
5486 an(ix,jy,kz,lnhl) > cxmin ) THEN
5487 q = an(ix,jy,kz,lhl)
5488 nrx = an(ix,jy,kz,lnhl)
5489 an(ix,jy,kz,lzhl) = 36.*g1hl*dn(ix,kz)**2*q**2/(pi**2*xdnhl**2*nrx) ! *dninv
5490 ENDIF
5491 ENDIF
5492
5493
5494! ENDIF
5495
5496! spechum = qv_mp/(1.0_kind_phys+qv_mp)
5497! IF ( convertdry ) THEN
5498! qc = qc_mp/(1.0_kind_phys+qv_mp)
5499 mixconvqv = 1
5500 IF ( present( spechum ) ) THEN ! convert back to "dry+vapor" mixing ratios
5501 !an(ix,jy,kz,lv) = spechum(ix,kz)/(1.0d0 - spechum(ix,kz))
5502 mixconvqv = 1.0d0/(1.0d0 + an(ix,jy,kz,lv))
5503 spechum(ix,kz) = an(ix,jy,kz,lv)*mixconvqv
5504 ELSE
5505 mixconvqv = 1.0d0
5506 ENDIF
5507
5508 IF ( present( qv ) ) qv(ix,kz) = an(ix,jy,kz,lv)
5509 IF ( present( qcw ) ) qcw(ix,kz) = an(ix,jy,kz,lc)*mixconvqv
5510 IF ( present( qrw ) ) qrw(ix,kz) = an(ix,jy,kz,lr)*mixconvqv
5511 IF ( present( qci ) ) qci(ix,kz) = an(ix,jy,kz,li)*mixconvqv
5512 IF ( present( qsw ) ) THEN
5513 qsw(ix,kz) = an(ix,jy,kz,ls)*mixconvqv
5514! qsmax3 = Max( qsmax3, qsw(ix,kz) )
5515! qsmax4 = Max( qsmax4, an(ix,jy,kz,ls) )
5516 ENDIF
5517 IF ( present( qhw ) ) qhw(ix,kz) = an(ix,jy,kz,lh)*mixconvqv
5518 IF ( lhl > 1 .and. present( qhl ) ) qhl(ix,kz) = an(ix,jy,kz,lhl)*mixconvqv
5519 IF ( present( ccw ) ) ccw(ix,kz) = an(ix,jy,kz,lnc)*mixconvqv*dninv
5520 IF ( present( crw ) ) crw(ix,kz) = an(ix,jy,kz,lnr)*mixconvqv*dninv
5521 IF ( present( cci ) ) cci(ix,kz) = an(ix,jy,kz,lni)*mixconvqv*dninv
5522 IF ( present( csw ) ) csw(ix,kz) = an(ix,jy,kz,lns)*mixconvqv*dninv
5523 IF ( present( chw ) ) chw(ix,kz) = an(ix,jy,kz,lnh)*mixconvqv*dninv
5524 IF ( lhl > 1 .and. present( chl ) ) chl(ix,kz) = an(ix,jy,kz,lnhl)*mixconvqv*dninv
5525 IF ( lvh > 1 .and. present( vhw ) ) vhw(ix,kz) = an(ix,jy,kz,lvh)*mixconvqv
5526 IF ( lvhl > 1 .and. present( vhl ) ) vhl(ix,kz) = an(ix,jy,kz,lvhl)*mixconvqv
5527 IF ( lccn > 1 .and. present( cccn ) ) cccn(ix,kz) = an(ix,jy,kz,lccn)*mixconvqv*dninv
5528 IF ( lccna > 1 .and. present( cccna ) ) cccna(ix,kz) = an(ix,jy,kz,lccna)*mixconvqv
5529
5530
5531 ENDDO ! ix
5532 ENDDO ! kz
5533! ELSE
5534! write(0,*) 'calcnfromq: lv = ',lv,lc,lr,li,ls,lh,lvh,lhl,lccn,lccna
5535! write(0,*) 'calcnfromq: nx,ny,nz,na = ',nx,ny,nz,na
5536!
5537! ENDIF
5538
5539! IF ( present( qsw ) ) THEN
5540! write(0,*) 'calcnfromq: qsmax = ',qsmax,qsmax2,qsmax3,qsmax4
5541! ENDIF
5542
5543 RETURN
5544
5545 END subroutine calcnfromq
5546
5547! ##############################################################################
5548! ##############################################################################
5549!
5550! Subroutine to calculate number concentrations from convection parameterization rates that have only mixing ratio.
5551! N will be in #/kg, NOT #/m^3, since sedimentation is done next.
5552!
5553
5554!
5555! 10.27.2015: Added hail calculation
5556!
5559 subroutine calcnfromcuten(nx,ny,nz,an,anold,na,nor,norz,dn)
5560
5561
5562 implicit none
5563
5564 integer nx,ny,nz,nor,norz,na,ngt,jgs,ixcol
5565
5566 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na) ! scalars (q, N, Z) from CUTEN arrays
5567 real anold(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na) ! scalars (q, N, Z)
5568
5569 real dn(nx,nz+1) ! air density
5570
5571 integer ixe,kze
5572 real alpha
5573 real qmin
5574 real xvmn,xvmx
5575 integer ipconc
5576 integer lvol ! index for volume
5577 integer infall
5578
5579
5580 integer ix,jy,kz
5581 double precision vr,q,nrx,rd,g1h,g1hl,g1r,g1s,zx,chw,z,znew,zt,zxt,n1,laminv1
5582 double precision :: zr, zs, zh, dninv
5583 real, parameter :: xn0s = 3.0e6, xn0r = 8.0e6, xn0h = 4.0e4, xn0hl = 4.0e4
5584 real, parameter :: xdnr = 1000., xdns = 100. ,xdnh = 700.0, xdnhl = 900.0
5585 real, parameter :: zhlfac = 1./(pi*xdnhl*xn0hl)
5586 real, parameter :: zhfac = 1./(pi*xdnh*xn0h)
5587 real, parameter :: zrfac = 1./(pi*xdnr*xn0r)
5588 real, parameter :: zsfac = 1./(pi*xdns*xn0s)
5589 real, parameter :: g0 = (6.0)*(5.0)*(4.0)/((3.0)*(2.0)*(1.0))
5590 real, parameter :: xims=900.*0.523599*(2.*50.e-6)**3 ! mks (100 micron diam solid sphere approx)
5591 real, parameter :: xcms=1000.*0.523599*(2.*7.5e-6)**3 ! mks (100 micron diam solid sphere approx)
5592
5593 real :: xmass,xv,xdn
5594 integer :: ndbz, nmwgt, nnwgt, nwlessthanz
5595
5596! ------------------------------------------------------------------
5597
5598
5599 jy = 1
5600
5601
5602 g1h = (6.0 + alphah)*(5.0 + alphah)*(4.0 + alphah)/ &
5603 & ((3.0 + alphah)*(2.0 + alphah)*(1.0 + alphah))
5604
5605 g1hl = (6.0 + alphahl)*(5.0 + alphahl)*(4.0 + alphahl)/ &
5606 & ((3.0 + alphahl)*(2.0 + alphahl)*(1.0 + alphahl))
5607
5608 IF ( imurain == 3 ) THEN
5609 g1r = (rnu+2.0)/(rnu+1.0)
5610 ELSE ! imurain == 1
5611 g1r = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/ &
5612 & ((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
5613 ENDIF
5614
5615 g1s = (snu+2.0)/(snu+1.0)
5616
5617 DO kz = 1,nz
5618 DO ix = 1,nx ! ixcol
5619
5620 dninv = 1./dn(ix,kz)
5621
5622 ! Cloud droplets
5623
5624 IF ( lnc > 1 ) THEN
5625! IF ( an(ix,jy,kz,lnc) <= 0.1*cxmin .and. an(ix,jy,kz,lc) > qxmin(lc) ) THEN
5626 IF ( an(ix,jy,kz,lnc) > qxmin(lc) ) THEN
5627 anold(ix,jy,kz,lnc) = anold(ix,jy,kz,lnc) + an(ix,jy,kz,lc)/xcms
5628 ENDIF
5629 ENDIF
5630
5631 ! Cloud ice
5632
5633 IF ( lni > 1 ) THEN
5634 IF ( an(ix,jy,kz,lni) > qxmin(li) ) THEN
5635 anold(ix,jy,kz,lni) = anold(ix,jy,kz,lni) + an(ix,jy,kz,li)/xims
5636 ENDIF
5637 ENDIF
5638
5639 ! rain
5640
5641 IF ( lnr > 1 ) THEN
5642 IF ( an(ix,jy,kz,lr) > qxmin(lr) ) THEN ! adding rain mass from CU scheme
5643
5644 IF ( .true. .or. (anold(ix,jy,kz,lr) - an(ix,jy,kz,lr)) < qxmin(lr) .or. anold(ix,jy,kz,lnr) < cxmin ) THEN
5645
5646 q = an(ix,jy,kz,lr)
5647
5648 laminv1 = (dn(ix,kz) * q * zrfac)**(0.25) ! inverse of slope
5649
5650 n1 = laminv1*xn0r ! number concentration for inv. exponential single moment input
5651
5652 nrx = n1*g1r/g0 ! number concentration for different shape parameter
5653
5654 anold(ix,jy,kz,lnr) = anold(ix,jy,kz,lnr) + nrx ! *dninv ! convert to number mixing ratio
5655
5656 ELSE
5657 ! assume mean particle mass of pre-existing snow
5658 xmass = anold(ix,jy,kz,lr)/anold(ix,jy,kz,lnr)
5659 anold(ix,jy,kz,lnr) = anold(ix,jy,kz,lnr) + an(ix,jy,kz,lr)/xmass
5660 ENDIF
5661
5662 IF ( lzr > 1 ) THEN ! set reflectivity moment
5663 an(ix,jy,kz,lzr) = 36.*g1r*dn(ix,kz)**2*q**2/(pi**2*xdnr**2*nrx) ! *dninv
5664 ENDIF
5665 ENDIF
5666 ENDIF
5667
5668 ! snow
5669 IF ( lns > 1 ) THEN
5670 IF ( an(ix,jy,kz,ls) > qxmin(ls) ) THEN ! adding snow mass from CU scheme
5671
5672 IF ( .true. .or. (anold(ix,jy,kz,ls) - an(ix,jy,kz,ls)) < qxmin(ls) .or. anold(ix,jy,kz,lns) < cxmin ) THEN
5673
5674 ! assume that there was no snow before this
5675
5676 q = an(ix,jy,kz,ls)
5677
5678 laminv1 = (dn(ix,kz) * q * zsfac)**(0.25) ! inverse of slope
5679
5680 n1 = laminv1*xn0s ! number concentration for inv. exponential single moment input
5681
5682 nrx = n1*g1s/g0 ! number concentration for different shape parameter
5683
5684 anold(ix,jy,kz,lns) = anold(ix,jy,kz,lns) + nrx ! *dninv ! convert to number mixing ratio
5685
5686 ELSE
5687 ! assume mean particle mass of pre-existing snow
5688 xmass = anold(ix,jy,kz,ls)/anold(ix,jy,kz,lns)
5689 anold(ix,jy,kz,lns) = anold(ix,jy,kz,lns) + an(ix,jy,kz,ls)/xmass
5690 ENDIF
5691
5692 ENDIF
5693 ENDIF
5694
5695 ! graupel
5696
5697! IF ( lnh > 1 ) THEN
5698! IF ( an(ix,jy,kz,lnh) <= 0.1*cxmin .and. an(ix,jy,kz,lh) > qxmin(lh) ) THEN
5699! IF ( lvh > 1 ) THEN
5700! IF ( an(ix,jy,kz,lvh) <= 0.0 ) THEN
5701! an(ix,jy,kz,lvh) = an(ix,jy,kz,lh)/xdnh
5702! ENDIF
5703! ENDIF
5704!
5705! q = an(ix,jy,kz,lh)
5706!
5707! laminv1 = (dn(ix,kz) * q * zhfac)**(0.25) ! inverse of slope
5708!
5709! n1 = laminv1*xn0h ! number concentration for inv. exponential single moment input
5710!
5711! nrx = n1*g1h/g0 ! number concentration for different shape parameter
5712!
5713! an(ix,jy,kz,lnh) = nrx ! *dninv ! convert to number mixing ratio
5714!
5715! IF ( lzh > 1 ) THEN ! set reflectivity moment
5716! an(ix,jy,kz,lzh) = 36.*g1h*dn(ix,kz)**2*q**2/(pi**2*xdnh**2*nrx) ! *dninv
5717! ENDIF
5718! ENDIF
5719! ENDIF
5720!
5721! ! hail
5722!
5723! IF ( lnhl > 1 .and. lhl > 1 ) THEN
5724! IF ( an(ix,jy,kz,lnhl) <= 0.1*cxmin .and. an(ix,jy,kz,lhl) > qxmin(lhl) ) THEN
5725! IF ( lvhl > 1 ) THEN
5726! IF ( an(ix,jy,kz,lvhl) <= 0.0 ) THEN
5727! an(ix,jy,kz,lvhl) = an(ix,jy,kz,lhl)/xdnhl
5728! ENDIF
5729! ENDIF
5730!
5731! q = an(ix,jy,kz,lhl)
5732!
5733! laminv1 = (dn(ix,kz) * q * zhlfac)**(0.25) ! inverse of slope
5734!
5735! n1 = laminv1*xn0hl ! number concentration for inv. exponential single moment input
5736!
5737! nrx = n1*g1hl/g0 ! number concentration for different shape parameter
5738!
5739! an(ix,jy,kz,lnhl) = nrx ! *dninv ! convert to number mixing ratio
5740!
5741! IF ( lzhl > 1 ) THEN ! set reflectivity moment
5742! an(ix,jy,kz,lzhl) = 36.*g1hl*dn(ix,kz)**2*q**2/(pi**2*xdnhl**2*nrx) ! *dninv
5743! ENDIF
5744! ENDIF
5745! ENDIF
5746
5747 ENDDO ! ix
5748 ENDDO ! kz
5749
5750 RETURN
5751
5752 END subroutine calcnfromcuten
5753
5754! #####################################################################
5755! #####################################################################
5756
5759 SUBROUTINE calc_eff_radius &
5760 & (nx,ny,nz,na,jyslab &
5761 & ,nor,norz &
5762 & ,t1,t2,t3,t4,t5,t6, f_t5,f_t6 &
5763 & ,qcw,qci,qsw,qrw &
5764 & ,ccw,cci,csw,crw &
5765 & ,an,dn )
5766
5767 implicit none
5768
5769 integer, parameter :: ng1 = 1
5770 integer :: nx,ny,nz,na
5771 integer :: ng
5772 integer :: nor,norz, jyslab ! ,nht,ngt,igsr
5773 real :: dtp ! time step
5774
5775
5776!
5777! external temporary arrays
5778!
5779
5780 real,optional :: t1(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5781 real,optional :: t2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5782 real,optional :: t3(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5783 real,optional :: t4(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5784 real,optional :: t5(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5785 real,optional :: t6(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5786 logical, optional :: f_t5, f_t6 ! flags to fill t5/t6 for graupel/hail
5787
5788 real, optional :: an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
5789 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5790 real, optional, dimension(nx,nz) :: qcw,qci,qsw,qrw,ccw,cci,csw,crw
5791
5792
5793
5794
5795
5796 ! local
5797
5798 real pb(-norz+ng1:nz+norz)
5799 real pinit(-norz+ng1:nz+norz)
5800
5801!
5802! declarations microphysics and for gather/scatter
5803!
5804 integer nxmpb,nzmpb,nxz
5805 integer mgs,ngs,numgs,inumgs
5806 parameter(ngs=1)
5807 integer ngscnt,igs(ngs),kgs(ngs)
5808 real rho0(ngs)
5809
5810 integer ix,kz,i,n, kp1
5811 integer :: jy, jgs
5812 integer ixb,ixe,jyb,jye,kzb,kze
5813
5814 integer itile,jtile,ktile
5815 integer ixend,jyend,kzend,kzbeg
5816 integer nxend,nyend,nzend,nzbeg
5817
5818 real :: qx(ngs,lv:lhab)
5819 real :: cx(ngs,lc:lhab)
5820 real :: xv(ngs,lc:lhab)
5821 real :: xmas(ngs,lc:lhab)
5822 real :: xdn(ngs,lc:lhab)
5823 real :: xdia(ngs,lc:lhab,3)
5824 real :: alpha(ngs,lc:lhab)
5825
5826 real :: gamc1,gamc2,gami1,gami2,gams1,gams2,gamr1,gamr2
5827 real :: factor_c, factor_i, factor_s, factor_r
5828 real :: lam_c, lam_i, lam_s, lam_r
5829 integer :: il
5830
5831
5832! -------------------------------------------------------------------------------
5833 itile = nx
5834 jtile = ny
5835 ktile = nz
5836 ixend = nx
5837 jyend = ny
5838 kzend = nz
5839 nxend = nx + 1
5840 nyend = ny + 1
5841 nzend = nz
5842 kzbeg = 1
5843 nzbeg = 1
5844
5845 jy = 1
5846 pb(:) = 0.0
5847 pinit(:) = 0.0
5848
5849 gamc1 = gamma_sp(2. + cnu)
5850 gamc2 = 1. ! Gamma[1 + alphac]
5851 gami1 = gamma_sp(2. + cinu)
5852 gami2 = 1. ! Gamma[1 + alphac]
5853 gams1 = gamma_sp(2. + snu)
5854 gams2 = gamma_sp(1. + snu)
5855 gamr1 = gamma_sp(2. + rnu)
5856 gamr2 = gamma_sp(1. + rnu)
5857
5858 factor_c = (1. + cnu)*gamma_sp(1. + cnu)/gamma_sp(5./3. + cnu)
5859 factor_i = (1. + cinu)*gamma_sp(1. + cinu)/gamma_sp(5./3. + cinu)
5860 factor_s = (1. + snu)*gamma_sp(1. + snu)/gamma_sp(5./3. + snu)
5861
5862 IF ( present(t4) ) THEN
5863 IF ( imurain == 3 ) THEN
5864 factor_r = (1. + rnu)*gamma_sp(1. + rnu)/gamma_sp(5./3. + rnu)
5865 ELSE
5866 factor_r = ((pi*(alphar+3.)*(alphar+1.)*(alphar+1.))/6.)**(1./3.)
5867 ENDIF
5868 ENDIF
5869
5870!
5871! jy = 1 ! working on a 2d slab
5872!! VERY IMPORTANT: SET jgs = jy
5873
5874 jgs = jy
5875
5876 mgs = 1
5877 DO kz = 1,nz
5878 DO ix = 1,nx ! ixcol
5879
5880 rho0(mgs) = dn(ix,jy,kz)
5881 IF ( present( an ) ) THEN
5882 DO il = lc,ls
5883 qx(mgs,il) = max(an(ix,jy,kz,il), 0.0)
5884 cx(mgs,il) = max(an(ix,jy,kz,ln(il)), 0.0)
5885 ENDDO
5886 ELSE
5887 qx(mgs,:) = 0.0
5888 cx(mgs,:) = 0.0
5889 IF ( present(qcw) ) qx(mgs,lc) = qcw(ix,kz)
5890 IF ( present(qci) ) qx(mgs,li) = qci(ix,kz)
5891 IF ( present(qsw) ) qx(mgs,ls) = qsw(ix,kz)
5892 IF ( present(qrw) ) qx(mgs,lr) = qrw(ix,kz)
5893 IF ( present(ccw) ) cx(mgs,lc) = ccw(ix,kz)*rho0(mgs)
5894 IF ( present(cci) ) cx(mgs,li) = cci(ix,kz)*rho0(mgs)
5895 IF ( present(csw) ) cx(mgs,ls) = csw(ix,kz)*rho0(mgs)
5896 IF ( present(crw) ) cx(mgs,lr) = crw(ix,kz)*rho0(mgs)
5897
5898 ENDIF
5899
5900 IF ( present( t1 ) .and. qx(mgs,lc) > qxmin(lc) .and. cx(mgs,lc) > cxmin ) THEN
5901! Lambda for cloud droplets
5902 lam_c = ((cx(mgs,lc)*(pi/6.)*xdn0(lc)*gamc1)/(qx(mgs,lc)*rho0(mgs)*gamc2))**(1./3.)
5903 t1(ix,jy,kz) = 0.5*factor_c/lam_c
5904 ENDIF
5905
5906 IF ( present( t2 ) .and. qx(mgs,li) > qxmin(li) .and. cx(mgs,li) > cxmin ) THEN
5907! Lambda for cloud ice
5908 lam_i = ((cx(mgs,li)*(pi/6.)*xdn0(li)*gami1)/(qx(mgs,li)*rho0(mgs)*gami2))**(1./3.)
5909 t2(ix,jy,kz) = 0.5*factor_i/lam_i
5910 ENDIF
5911
5912 IF ( present( t3 ) .and. qx(mgs,ls) > qxmin(ls) .and. cx(mgs,ls) > cxmin ) THEN
5913! Lambda for snow
5914 lam_s = ((cx(mgs,ls)*(pi/6.)*xdn0(ls)*gams1)/(qx(mgs,ls)*rho0(mgs)*gams2))**(1./3.)
5915 t3(ix,jy,kz) = 0.5*factor_s/lam_s
5916 ENDIF
5917
5918 IF ( present( t4 ) .and. present(qrw) .and. present(crw) ) THEN
5919 IF ( qx(mgs,lr) > max(1.e-8,qxmin(lr)) .and. cx(mgs,lr) > cxmin ) THEN
5920 IF ( imurain == 1 ) THEN ! gamma-diameter
5921! Lambda for rain
5922 lam_r = factor_r *((xdn0(lr)*cx(mgs,lr))/(qx(mgs,lr)*rho0(mgs)))**(1./3.)
5923 t4(ix,jy,kz) = 0.5*(alphar+3.)/lam_r
5924 ELSE ! gamma-volume
5925! Lambda for rain
5926 lam_r = ((cx(mgs,lr)*(pi/6.)*xdn0(lr)*gamr1)/(qx(mgs,lr)*rho0(mgs)*gamr2))**(1./3.)
5927 t4(ix,jy,kz) = 0.5*factor_r/lam_r
5928 ENDIF
5929 ENDIF
5930 ENDIF
5931
5932
5933 ENDDO ! ix
5934 ENDDO ! kz
5935
5936 RETURN
5937 END SUBROUTINE calc_eff_radius
5938
5939
5940! #####################################################################
5941! #####################################################################
5942
5945 SUBROUTINE qvexcess(ngs,mgs,qwvp0,qv0,qcw1,pres,thetap0,theta0, &
5946 & qvex,pi0,tabqvs,nqsat,fqsat,cbw,fcqv1,felvcp,ss1,pk,ngscnt)
5947
5948!#####################################################################
5949! Purpose: find the amount of vapor that can be condensed to liquid
5950!#####################################################################
5951
5952 implicit none
5953
5954 integer ngs,mgs,ngscnt
5955
5956 real theta2temp
5957
5958 real qvex
5959
5960 integer nqsat
5961 real fqsat, cbw
5962
5963 real ss1 ! 'target' supersaturation
5964!
5965! input arrays
5966!
5967 real qv0(ngs), qcw1(ngscnt), pres(ngs), qwvp0(mgs)
5968 real thetap0(ngs), theta0(ngs)
5969 real fcqv1(ngs), felvcp(ngs), pi0(ngs)
5970 real pk(ngs)
5971
5972 real tabqvs(nqsat)
5973!
5974! Local stuff
5975!
5976
5977 integer itertd
5978 integer ltemq
5979 real gamss
5980 real theta(ngs), qvap(ngs), pqs(ngs), qcw(ngs), qwv(ngs)
5981 real qcwtmp(ngs), qss(ngs), qvs(ngs), qwvp(ngs)
5982 real dqcw(ngs), dqwv(ngs), dqvcnd(ngs)
5983 real temg(ngs), temcg(ngs), thetap(ngs)
5984
5985 real tfr
5986 parameter( tfr = 273.15 )
5987
5988! real poo,cap
5989! parameter ( cap = rd/cp, poo = 1.0e+05 )
5990!
5991!
5992! Modified Straka adjustment (nearly identical to Tao et al. 1989 MWR)
5993!
5994!
5995!
5996! set up temperature and vapor arrays
5997!
5998 pqs(mgs) = (380.0)/(pres(mgs))
5999 thetap(mgs) = thetap0(mgs)
6000 theta(mgs) = thetap(mgs) + theta0(mgs)
6001 qwvp(mgs) = qwvp0(mgs)
6002 qvap(mgs) = max( (qwvp0(mgs) + qv0(mgs)), 0.0 )
6003 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
6004! temg(mgs) = theta2temp( theta(mgs), pres(mgs) )
6005!
6006!
6007!
6008! reset temporaries for cloud particles and vapor
6009!
6010
6011 qwv(mgs) = max( 0.0, qvap(mgs) )
6012 qcw(mgs) = max( 0.0, qcw1(mgs) )
6013!
6014!
6015 qcwtmp(mgs) = qcw(mgs)
6016 temcg(mgs) = temg(mgs) - tfr
6017 ltemq = (temg(mgs)-163.15)/fqsat+1.5
6018 ltemq = min( nqsat, max(1,ltemq) )
6019
6020 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
6021 qss(mgs) = (0.01*ss1 + 1.0)*qvs(mgs)
6022!
6023! iterate adjustment
6024!
6025 do itertd = 1,2
6026!
6027!
6028! calculate super-saturation
6029!
6030 dqcw(mgs) = 0.0
6031 dqwv(mgs) = ( qwv(mgs) - qss(mgs) )
6032!
6033! evaporation and sublimation adjustment
6034!
6035 if( dqwv(mgs) .lt. 0. ) then ! subsaturated
6036 if( qcw(mgs) .gt. -dqwv(mgs) ) then ! check if qc can make up all of the deficit
6037 dqcw(mgs) = dqwv(mgs)
6038 dqwv(mgs) = 0.
6039 else ! otherwise make all qc available for evap
6040 dqcw(mgs) = -qcw(mgs)
6041 dqwv(mgs) = dqwv(mgs) + qcw(mgs)
6042 end if
6043!
6044 qwvp(mgs) = qwvp(mgs) - ( dqcw(mgs) ) ! add to perturbation vapor
6045!
6046 qcw(mgs) = qcw(mgs) + dqcw(mgs)
6047
6048 thetap(mgs) = thetap(mgs) + &
6049 & 1./pi0(mgs)* &
6050 & (felvcp(mgs)*dqcw(mgs) )
6051
6052 end if ! dqwv(mgs) .lt. 0. (end of evap/sublim)
6053!
6054! condensation/deposition
6055!
6056 IF ( dqwv(mgs) .ge. 0. ) THEN
6057!
6058 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qss(mgs)/ &
6059 & ((temg(mgs)-cbw)**2))
6060!
6061!
6062 dqcw(mgs) = dqvcnd(mgs)
6063!
6064 thetap(mgs) = thetap(mgs) + &
6065 & (felvcp(mgs)*dqcw(mgs) ) &
6066 & / (pi0(mgs))
6067 qwvp(mgs) = qwvp(mgs) - ( dqvcnd(mgs) )
6068 qcw(mgs) = qcw(mgs) + dqcw(mgs)
6069!
6070 END IF ! dqwv(mgs) .ge. 0.
6071
6072 theta(mgs) = thetap(mgs) + theta0(mgs)
6073 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
6074! temg(mgs) = theta2temp( theta(mgs), pres(mgs) )
6075 qvap(mgs) = max((qwvp(mgs) + qv0(mgs)), 0.0)
6076 temcg(mgs) = temg(mgs) - tfr
6077! tqvcon = temg(mgs)-cbw
6078 ltemq = (temg(mgs)-163.15)/fqsat+1.5
6079 ltemq = min( nqsat, max(1,ltemq) )
6080 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
6081 qcw(mgs) = max( 0.0, qcw(mgs) )
6082 qwv(mgs) = max( 0.0, qvap(mgs))
6083 qss(mgs) = (0.01*ss1 + 1.0)*qvs(mgs)
6084 end do
6085!
6086! end the saturation adjustment iteration loop
6087!
6088!
6089 qvex = max(0.0, qcw(mgs) - qcw1(mgs) )
6090
6091 RETURN
6092 END SUBROUTINE qvexcess
6093
6094! #####################################################################
6095! #####################################################################
6096
6097
6098
6099
6100
6101!
6102! ##############################################################################
6103!
6106 SUBROUTINE setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno,cnostmp, &
6107 & xmas,vtxbar,xdn,xvmn0,xvmx0,xv,cdx,cdxgs, &
6108 & ipconc1,ndebug1,ngs,nz,kgs,fadvisc, &
6109 & cwmasn,cwmasx,cwradn,cnina,cimna,cimxa, &
6110 & itype1a,itype2a,temcg,infdo,alpha,ildo,axx,bxx)
6111! & itype1a,itype2a,temcg,infdo,alpha,ildo,axh,bxh,axhl,bxhl)
6112
6113
6114 implicit none
6115
6116 integer ngscnt,ngs0,ngs,nz
6117! integer infall ! whether to calculate number-weighted fall speeds
6118
6119 real xv(ngs,lc:lhab)
6120 real qx(ngs,lv:lhab)
6121 real qxw(ngs,ls:lhab)
6122 real cx(ngs,lc:lhab)
6123 real vtxbar(ngs,lc:lhab,3)
6124 real xmas(ngs,lc:lhab)
6125 real xdn(ngs,lc:lhab)
6126 real cdxgs(ngs,lc:lhab)
6127 real xdia(ngs,lc:lhab,3)
6128 real xvmn0(lc:lhab), xvmx0(lc:lhab)
6129 real qxmin(lc:lhab)
6130 real cdx(lc:lhab)
6131 real alpha(ngs,lc:lhab)
6132
6133 real rho0(ngs),rhovt(ngs),temcg(ngs)
6134 real cno(lc:lhab)
6135 real cnostmp(ngs)
6136
6137 real cwc1, cimna, cimxa
6138 real cnina(ngs)
6139 integer kgs(ngs)
6140 real fadvisc(ngs)
6141 real fsw
6142
6143 integer ipconc1
6144 integer ndebug1
6145
6146 integer, intent (in) :: itype1a,itype2a,infdo
6147 integer, intent (in) :: ildo ! which species to do, or all if ildo=0
6148
6149 real :: axx(ngs,lh:lhab),bxx(ngs,lh:lhab)
6150!! real :: axh(ngs),bxh(ngs)
6151! real :: axhl(ngs),bxhl(ngs)
6152
6153! Local vars
6154
6155
6156
6157 real swmasmx, dtmp
6158 real cd
6159 real cwc0 ! ,cwc1
6160 real :: cwch(ngscnt), cwchl(ngscnt)
6161 real :: cwchtmp,cwchltmp,xnutmp
6162 real pii
6163 real cimasx,cimasn
6164 real cwmasn,cwmasx,cwradn
6165 real cwrad
6166 real vr,rnux
6167 real alp
6168
6169 real ccimx
6170
6171 integer mgs
6172
6173 real arx,frx,vtrain,fw
6174 real fwlo,fwhi,rfwdiff
6175 real ar,br,cs,ds
6176! real gf4p5, gf4ds, gf4br, ifirst, gf1ds
6177! real gfcinu1, gfcinu1p47, gfcinu2p47
6178 real gr
6179 real rwrad,rwdia
6180 real mwfac
6181 integer il
6182
6183! save gf4p5, gf4ds, gf4br, ifirst, gf1ds
6184! save gfcinu1, gfcinu1p47, gfcinu2p47
6185! data ifirst /0/
6186
6187 real bta1,cnit
6188 parameter( bta1 = 0.6, cnit = 1.0e-02 )
6189 real x,y,tmp,del
6190 real aax,bbx,delrho
6191 integer :: indxr
6192 real mwt, nwt, zwt
6193 real, parameter :: rho00 = 1.225
6194 integer i
6195 real xvbarmax
6196
6197 integer l1, l2
6198
6199
6200!
6201! set values
6202!
6203! cwmasn = 5.23e-13 ! radius of 5.0e-6
6204! cwradn = 5.0e-6
6205! cwmasx = 5.25e-10 ! radius of 50.0e-6
6206
6207 fwlo = 0.2 ! water fraction to start weighting toward rain fall speed
6208 fwhi = 0.4 ! water fraction at which rain fall speed only is used
6209 rfwdiff = 1./(fwhi - fwlo)
6210
6211! pi = 4.0*atan(1.0)
6212 pii = piinv ! 1.0/pi
6213
6214 arx = 10.
6215 frx = 516.575 ! raind fit parameters for arx*(1 - Exp(-fx*d)), where d is rain diameter in meters.
6216
6217 ar = 841.99666
6218 br = 0.8
6219 gr = 9.8
6220! new values for cs and ds
6221 cs = 12.42
6222 ds = 0.42
6223
6224 IF ( ildo == 0 ) THEN
6225 l1 = lc
6226 l2 = lhab
6227 ELSE
6228 l1 = ildo
6229 l2 = ildo
6230 ENDIF
6231
6232! IF ( ifirst .eq. 0 ) THEN
6233! ifirst = 1
6234! gf4br = gamma(4.0+br)
6235! gf4ds = gamma(4.0+ds)
6236!! gf1ds = gamma(1.0+ds)
6237! gf4p5 = gamma(4.0+0.5)
6238! gfcinu1 = gamma(cinu + 1.0)
6239! gfcinu1p47 = gamma(cinu + 1.47167)
6240! gfcinu2p47 = gamma(cinu + 2.47167)
6241
6242 IF ( lh .gt. 1 ) THEN
6243 IF ( dmuh == 1.0 ) THEN
6244 cwchtmp = ((3. + dnu(lh))*(2. + dnu(lh))*(1.0 + dnu(lh)))**(-1./3.)
6245 ELSE
6246 cwchtmp = 6.0*pii*gamma_sp( (xnu(lh) + 1.)/xmu(lh) )/gamma_sp( (xnu(lh) + 2.)/xmu(lh) )
6247 ENDIF
6248 ENDIF
6249 IF ( lhl .gt. 1 ) THEN
6250 IF ( dmuhl == 1.0 ) THEN
6251 cwchltmp = ((3. + dnu(lhl))*(2. + dnu(lhl))*(1.0 + dnu(lhl)))**(-1./3.)
6252 ELSE
6253 cwchltmp = 6.0*pii*gamma_sp( (xnu(lhl) + 1)/xmu(lhl) )/gamma_sp( (xnu(lhl) + 2)/xmu(lhl) )
6254 ENDIF
6255 ENDIF
6256
6257 IF ( ipconc .le. 5 ) THEN
6258 IF ( lh .gt. 1 ) cwch(:) = cwchtmp
6259 IF ( lhl .gt. 1 ) cwchl(:) = cwchltmp
6260 ELSE
6261 DO mgs = 1,ngscnt
6262
6263 IF ( lh .gt. 1 .and. ( ildo == 0 .or. ildo == lh ) ) THEN
6264 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
6265 IF ( dmuh == 1.0 ) THEN
6266 cwch(mgs) = ((3. + alpha(mgs,lh))*(2. + alpha(mgs,lh))*(1.0 + alpha(mgs,lh)))**(-1./3.)
6267 ELSE
6268 xnutmp = (alpha(mgs,lh) - 2.0)/3.0
6269 cwch(mgs) = 6.0*pii*gamma_sp( (xnutmp + 1.)/xmu(lh) )/gamma_sp( (xnutmp + 2.)/xmu(lh) )
6270 ENDIF
6271 ELSE
6272 cwch(mgs) = cwchtmp
6273 ENDIF
6274 ENDIF
6275 IF ( lhl .gt. 1 .and. ( ildo == 0 .or. ildo == lhl ) ) THEN
6276 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
6277 IF ( dmuhl == 1.0 ) THEN
6278 cwchl(mgs) = ((3. + alpha(mgs,lhl))*(2. + alpha(mgs,lhl))*(1.0 + alpha(mgs,lhl)))**(-1./3.)
6279 ELSE
6280 xnutmp = (alpha(mgs,lhl) - 2.0)/3.0
6281 cwchl(mgs) = 6.0*pii*gamma_sp( (xnutmp + 1)/xmu(lhl) )/gamma_sp( (xnutmp + 2)/xmu(lhl) )
6282 ENDIF
6283 ELSE
6284 cwchl(mgs) = cwchltmp
6285 ENDIF
6286 ENDIF
6287
6288 ENDDO
6289
6290 ENDIF
6291
6292
6293 cimasn = min( cimas0, 6.88e-13)
6294 cimasx = 1.0e-8
6295 ccimx = 5000.0e3 ! max of 5000 per liter
6296
6297 cwc1 = 6.0/(pi*1000.)
6298 cwc0 = pii ! 6.0*pii
6299 mwfac = 6.0**(1./3.)
6300
6301
6302 if (ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set scale diameter'
6303!
6304
6305
6306!
6307! cloud water variables
6308! ################################################################
6309!
6310! DROPLETS
6311!
6312!
6313 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set cloud water variables'
6314
6315 IF ( ildo == 0 .or. ildo == lc ) THEN
6316
6317 do mgs = 1,ngscnt
6318 xv(mgs,lc) = 0.0
6319
6320 IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN !{
6321
6322 IF ( ipconc .ge. 2 ) THEN
6323 IF ( cx(mgs,lc) .gt. cxmin) THEN !{
6324 xmas(mgs,lc) = &
6325 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
6326 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6327 ELSE
6328 cx(mgs,lc) = max( cxmin, rho0(mgs)*qx(mgs,lc)/cwmasx )
6329 xmas(mgs,lc) = min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
6330 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6331
6332 ENDIF
6333 ELSE
6334 IF ( ipconc .lt. 2 ) THEN
6335 cx(mgs,lc) = rho0(mgs)*ccn/rho00 ! scales to local density, relative to standard air density
6336 ENDIF
6337 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. 0.01 ) THEN !{
6338 xmas(mgs,lc) = &
6339 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),xdn(mgs,lc)*xvmn(lc)), &
6340 & xdn(mgs,lc)*xvmx(lc) )
6341
6342 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6343 cx(mgs,lc) = qx(mgs,lc)*rho0(mgs)/xmas(mgs,lc)
6344
6345 ELSEIF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .le. 1.0e-9 ) THEN
6346 cx(mgs,lc) = max( cxmin, rho0(mgs)*qx(mgs,lc)/cwmasx )
6347 xmas(mgs,lc) = &
6348 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
6349 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6350
6351 ELSEIF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .le. 0.01 ) THEN
6352 xmas(mgs,lc) = xdn(mgs,lc)*4.*pi/3.*(5.0e-6)**3
6353 cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc)
6354 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6355
6356 ELSE
6357 xmas(mgs,lc) = cwmasn
6358 xv(mgs,lc) = xmas(mgs,lc)/1000.
6359! do not define ccw here! it can feed back to ccn!!! cx(mgs,lc) = 0.0 ! cwnc(mgs)
6360 ENDIF !}
6361 ENDIF !}
6362! IF ( ipconc .lt. 2 ) THEN
6363! xmas(mgs,lc) = &
6364! & min( max(qx(mgs,lc)*rho0(mgs)/cwnc(mgs),cwmasn),cwmasx )
6365! cx(mgs,lc) = Max(1.0,qx(mgs,lc)*rho0(mgs)/xmas(mgs,lc))
6366! ELSE
6367! cwnc(mgs) = an(igs(mgs),jgs,kgs(mgs),lnc)
6368! cx(mgs,lc) = cwnc(mgs)
6369! ENDIF
6370 xdia(mgs,lc,1) = (xmas(mgs,lc)*cwc1)**(1./3.)
6371 xdia(mgs,lc,2) = xdia(mgs,lc,1)**2
6372 xdia(mgs,lc,3) = xdia(mgs,lc,1)
6373 cwrad = 0.5*xdia(mgs,lc,1)
6374 IF ( fadvisc(mgs) > 0.0 ) THEN
6375 vtxbar(mgs,lc,1) = &
6376 & (2.0*gr*xdn(mgs,lc) *(cwrad**2)) &
6377 & /(9.0*fadvisc(mgs))
6378 ELSE
6379 vtxbar(mgs,lc,1) = 0.0
6380 ENDIF
6381
6382
6383 ELSE
6384 xmas(mgs,lc) = cwmasn
6385 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6386 IF ( qx(mgs,lc) <= 0.0 ) cx(mgs,lc) = 0.0
6387 IF ( ipconc .le. 1 ) cx(mgs,lc) = 0.01
6388 xdia(mgs,lc,1) = 2.*cwradn
6389 xdia(mgs,lc,2) = 4.*cwradn**2
6390 xdia(mgs,lc,3) = xdia(mgs,lc,1)
6391 vtxbar(mgs,lc,1) = 0.0
6392
6393 ENDIF !} qcw .gt. qxmin(lc)
6394
6395 end do
6396
6397 ENDIF
6398
6399
6400
6401!
6402! cloud ice variables
6403! columns
6404!
6405! ################################################################
6406!
6407! CLOUD ICE
6408!
6409 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set cip'
6410
6411 IF ( li .gt. 1 .and. ( ildo == 0 .or. ildo == li ) ) THEN
6412 do mgs = 1,ngscnt
6413 xdn(mgs,li) = 900.0
6414 IF ( ipconc .eq. 0 ) THEN
6415! cx(mgs,li) = min(cnit*exp(-temcg(mgs)*bta1),1.e+09)
6416 cx(mgs,li) = cnina(mgs)
6417 IF ( cimna .gt. 1.0 ) THEN
6418 cx(mgs,li) = max(cimna,cx(mgs,li))
6419 ENDIF
6420 IF ( cimxa .gt. 1.0 ) THEN
6421 cx(mgs,li) = min(cimxa,cx(mgs,li))
6422 ENDIF
6423! erm 3/28/2002
6424 IF ( itype1a .ge. 1 .or. itype2a .ge. 1 ) THEN
6425 cx(mgs,li) = max(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasx)
6426 cx(mgs,li) = min(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasn)
6427 ENDIF
6428!
6429 cx(mgs,li) = max(1.0e-20,cx(mgs,li))
6430! cx(mgs,li) = Min(ccimx, cx(mgs,li))
6431
6432
6433 ELSEIF ( ipconc .ge. 1 ) THEN
6434 IF ( qx(mgs,li) .gt. qxmin(li) ) THEN
6435 cx(mgs,li) = max(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasx)
6436 cx(mgs,li) = min(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasn)
6437! cx(mgs,li) = Max(1.0,cx(mgs,li))
6438 ENDIF
6439 ENDIF
6440
6441 IF ( qx(mgs,li) .gt. qxmin(li) ) THEN
6442 xmas(mgs,li) = &
6443 & max( qx(mgs,li)*rho0(mgs)/cx(mgs,li), cimasn )
6444! & min( max(qx(mgs,li)*rho0(mgs)/cx(mgs,li),cimasn),cimasx )
6445
6446! if ( temcg(mgs) .gt. 0.0 ) then
6447! xdia(mgs,li,1) = 0.0
6448! else
6449 if ( xmas(mgs,li) .gt. 0.0 ) THEN ! cimasn ) then
6450!c xdia(mgs,li,1) = 0.4892*(xmas(mgs,li)**(0.4554))
6451! xdia(mgs,li,1) = 0.1871*(xmas(mgs,li)**(0.3429))
6452
6453! xdia(mgs,li,1) = (132.694*5.40662/xmas(mgs,li))**(-1./2.9163) ! for inverse exponential distribution
6454 IF ( ixtaltype == 1 ) THEN ! column
6455 xdia(mgs,li,1) = 0.1871*(xmas(mgs,li)**(0.3429))
6456 xdia(mgs,li,3) = 0.1871*(xmas(mgs,li)**(0.3429))
6457 ELSEIF ( ixtaltype == 2 ) THEN ! disk
6458 xdia(mgs,li,1) = 0.277823*xmas(mgs,li)**0.359971
6459 xdia(mgs,li,3) = 0.277823*xmas(mgs,li)**0.359971
6460 ENDIF
6461 end if
6462! end if
6463! xdia(mgs,li,1) = max(xdia(mgs,li,1), 5.e-6)
6464! xdia(mgs,li,1) = min(xdia(mgs,li,1), 1000.e-6)
6465
6466 IF ( ipconc .ge. 0 ) THEN
6467! vtxbar(mgs,li,1) = rhovt(mgs)*49420.*40.0005/5.40662*xdia(mgs,li,1)**(1.415) ! mass-weighted
6468! vtxbar(mgs,li,1) = (4.942e4)*(xdia(mgs,li,1)**(1.4150))
6469 xv(mgs,li) = xmas(mgs,li)/xdn(mgs,li)
6470 IF ( icefallopt == 1 ) THEN ! default ice fall
6471 IF ( ixtaltype == 1 ) THEN ! column
6472 tmp = (67056.6300748612*rhovt(mgs))/ &
6473 & (((1.0 + cinu)/xv(mgs,li))**0.4716666666666667*gfcinu1)
6474 vtxbar(mgs,li,2) = tmp*gfcinu1p47
6475 vtxbar(mgs,li,1) = tmp*gfcinu2p47/(1. + cinu)
6476 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
6477 ELSEIF ( ixtaltype == 2 ) THEN ! disk -- but just use Ferrier (1994) snow fall speeds for now
6478 vtxbar(mgs,li,1) = 11.9495*rhovt(mgs)*(xv(mgs,li))**(0.14)
6479 vtxbar(mgs,li,2) = 7.02909*rhovt(mgs)*(xv(mgs,li))**(0.14)
6480 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
6481
6482 ENDIF
6483
6484 ELSEIF ( icefallopt == 2 ) THEN ! ! Ferrier ice fall speed
6485 tmp = (82.3166*rhovt(mgs))/ &
6486 & (((1.0 + cinu)/xv(mgs,li))**0.22117*gfcinu1)
6487 vtxbar(mgs,li,2) = tmp*gfcinu1p22
6488 vtxbar(mgs,li,1) = tmp*gfcinu2p22/(1. + cinu)
6489 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
6490
6491 ELSEIF ( icefallopt == 3 ) THEN ! ! Adjusted Ferrier (smaller exponent of 0.55 instead of 0.6635)
6492
6493 tmp = (47.6273*rhovt(mgs))/ &
6494 & (((1.0 + cinu)/xv(mgs,li))**0.18333*gfcinu1)
6495 vtxbar(mgs,li,2) = tmp*gfcinu1p18
6496 vtxbar(mgs,li,1) = tmp*gfcinu2p18/(1. + cinu)
6497 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
6498
6499 ENDIF
6500! vtxbar(mgs,li,1) = vtxbar(mgs,li,2)*(1.+cinu)/(1. + cinu)
6501! xdn(mgs,li) = min(max(769.8*xdia(mgs,li,1)**(-0.0140),300.0),900.0)
6502! xdn(mgs,li) = 900.0
6503 xdia(mgs,li,2) = xdia(mgs,li,1)**2
6504! vtxbar(mgs,li,1) = vtxbar(mgs,li,1)*rhovt(mgs)
6505 ELSE
6506 xdia(mgs,li,1) = max(xdia(mgs,li,1), 10.e-6)
6507 xdia(mgs,li,1) = min(xdia(mgs,li,1), 1000.e-6)
6508 vtxbar(mgs,li,1) = (4.942e4)*(xdia(mgs,li,1)**(1.4150))
6509! xdn(mgs,li) = min(max(769.8*xdia(mgs,li,1)**(-0.0140),300.0),900.0)
6510 xdn(mgs,li) = 900.0
6511 xdia(mgs,li,2) = xdia(mgs,li,1)**2
6512 vtxbar(mgs,li,1) = vtxbar(mgs,li,1)*rhovt(mgs)
6513 xv(mgs,li) = xmas(mgs,li)/xdn(mgs,li)
6514 ENDIF ! ipconc gt 3
6515 ELSE
6516 xmas(mgs,li) = 1.e-13
6517 IF ( qx(mgs,li) <= 0.0 ) cx(mgs,li) = 0.0
6518 xdn(mgs,li) = 900.0
6519 xdia(mgs,li,1) = 1.e-7
6520 xdia(mgs,li,2) = (1.e-14)
6521 xdia(mgs,li,3) = 1.e-7
6522 vtxbar(mgs,li,1) = 0.0
6523! cicap(mgs) = 0.0
6524! ciat(mgs) = 0.0
6525 ENDIF
6526
6527 IF ( icefallfac /= 1.0 ) THEN
6528 vtxbar(mgs,li,1) = icefallfac*vtxbar(mgs,li,1)
6529 vtxbar(mgs,li,2) = icefallfac*vtxbar(mgs,li,2)
6530 vtxbar(mgs,li,3) = icefallfac*vtxbar(mgs,li,3)
6531 ENDIF
6532
6533
6534
6535 end do
6536
6537 ENDIF ! li .gt. 1
6538
6539
6540! ################################################################
6541!
6542! RAIN
6543!
6544
6545!
6546 IF ( ildo == 0 .or. ildo == lr ) THEN
6547 do mgs = 1,ngscnt
6548 if ( qx(mgs,lr) .gt. qxmin(lr) ) then
6549
6550! IF ( qx(mgs,lr) .gt. 10.0e-3 ) &
6551! & write(0,*) 'RAIN1: ',igs(mgs),kgs(mgs),qx(mgs,lr)
6552
6553 if ( ipconc .ge. 3 ) then
6554 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*max(1.0e-11,cx(mgs,lr)))
6555 xvbarmax = xvmx(lr)
6556 IF ( imaxdiaopt == 1 ) THEN
6557 xvbarmax = xvmx(lr)
6558 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
6559 IF ( imurain == 1 ) THEN
6560 xvbarmax = xvmx(lr)/((3. + alpha(mgs,lr))**3/((3. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(1. + alpha(mgs,lr))))
6561 ELSEIF ( imurain == 3 ) THEN
6562
6563 ENDIF
6564 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
6565 IF ( imurain == 1 ) THEN
6566 xvbarmax = xvmx(lr)/((4. + alpha(mgs,lr))**3/((3. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(1. + alpha(mgs,lr))))
6567 ELSEIF ( imurain == 3 ) THEN
6568
6569 ENDIF
6570 ENDIF
6571
6572 IF ( xv(mgs,lr) .gt. xvbarmax ) THEN
6573 xv(mgs,lr) = xvbarmax
6574 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvbarmax*xdn(mgs,lr))
6575 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
6576 xv(mgs,lr) = xvmn(lr)
6577 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
6578 ENDIF
6579
6580
6581 xmas(mgs,lr) = xv(mgs,lr)*xdn(mgs,lr)
6582 xdia(mgs,lr,3) = (xmas(mgs,lr)*cwc1)**(1./3.) ! xdia(mgs,lr,1)
6583 IF ( imurain == 3 ) THEN
6584! xdia(mgs,lr,1) = (6.*pii*xv(mgs,lr)/(alpha(mgs,lr)+1.))**(1./3.)
6585 xdia(mgs,lr,1) = xdia(mgs,lr,3) ! formulae for Ziegler (1985) use mean volume diameter, not lambda**(-1)
6586 ELSE ! imurain == 1, Characteristic diameter (1/lambda)
6587 xdia(mgs,lr,1) = (6.*pii*xv(mgs,lr)/((alpha(mgs,lr)+3.)*(alpha(mgs,lr)+2.)*(alpha(mgs,lr)+1.)))**(1./3.)
6588 ENDIF
6589! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
6590
6591! Inverse exponential version:
6592! xdia(mgs,lr,1) =
6593! & (qx(mgs,lr)*rho0(mgs)
6594! & /(pi*xdn(mgs,lr)*cx(mgs,lr)))**(0.333333)
6595 ELSE
6596 xdia(mgs,lr,1) = &
6597 & (qx(mgs,lr)*rho0(mgs)/(pi*xdn(mgs,lr)*cno(lr)))**(0.25)
6598 xmas(mgs,lr) = xdn(mgs,lr)*(pi/6.)*xdia(mgs,lr,1)**3
6599 xdia(mgs,lr,3) = (xmas(mgs,lr)*cwc1)**(1./3.)
6600 cx(mgs,lr) = cno(lr)*xdia(mgs,lr,1)
6601 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr))
6602 end if
6603 else
6604 xdia(mgs,lr,1) = 1.e-9
6605 xdia(mgs,lr,3) = 1.e-9
6606 xmas(mgs,lr) = xdn(mgs,lr)*(pi/6.)*xdia(mgs,lr,1)**3
6607! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
6608 end if
6609 xdia(mgs,lr,2) = xdia(mgs,lr,1)**2
6610! xmas(mgs,lr) = xdn(mgs,lr)*(pi/6.)*xdia(mgs,lr,1)**3
6611 end do
6612
6613 ENDIF
6614! ################################################################
6615!
6616! SNOW
6617!
6618
6619 IF ( ls .gt. 1 .and. ( ildo == 0 .or. ildo == ls ) ) THEN
6620
6621 do mgs = 1,ngscnt
6622 if ( qx(mgs,ls) .gt. qxmin(ls) ) then
6623 if ( ipconc .ge. 4 ) then !
6624
6625 xmas(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(max(1.0e-9,cx(mgs,ls)))
6626 swmasmx = 13.7e-6
6627! IF ( xmas(mgs,ls) > swmasmx ) THEN
6628! xmas(mgs,ls) = swmasmx
6629! cx(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xmas(mgs,ls))
6630! ENDIF
6631
6632 IF ( isnowdens == 2 ) THEN ! Set values according to Cox relationship
6633
6634 xdn(mgs,ls) = 0.0346159*sqrt(cx(mgs,ls)/(qx(mgs,ls)*rho0(mgs)) )
6635 xdn(mgs,ls) = max( 100.0, xdn(mgs,ls) ) ! limit snow to 100. to keep other equations in line
6636
6637 IF ( xdn(mgs,ls) <= 900. ) THEN
6638 dtmp = sqrt( xmas(mgs,ls)/0.069 ) ! diameter (meters) of mean mass particle using Cox 1998 relation (m = p d^2)
6639 xv(mgs,ls) = 28.8887*xmas(mgs,ls)**(3./2.)
6640 ELSE ! at small sizes, assume ice spheres
6641 xdn(mgs,ls) = 900.
6642 xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*max(1.0e-9,cx(mgs,ls)))
6643 dtmp = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6644 ENDIF
6645
6646 ELSE ! leave xdn(ls) at default value
6647 xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*max(1.0e-9,cx(mgs,ls)))
6648 dtmp = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6649 ENDIF
6650
6651 xdia(mgs,ls,1) = dtmp ! (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6652
6653 IF ( xv(mgs,ls) .lt. xvmn(ls) .and. isnowdens == 1) THEN
6654 xv(mgs,ls) = max( xvmn(ls),xv(mgs,ls) )
6655 xmas(mgs,ls) = xv(mgs,ls)*xdn(mgs,ls)
6656 cx(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xmas(mgs,ls))
6657 xdia(mgs,ls,1) = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6658 ENDIF
6659
6660 IF ( xv(mgs,ls) .gt. xvmx(ls)*max(1.,100./min(100.,xdn(mgs,ls))) ) THEN
6661 xv(mgs,ls) = min( xvmx(ls), max( xvmn(ls),xv(mgs,ls) ) )
6662 xmas(mgs,ls) = 0.106214*xv(mgs,ls)**(2./3.)
6663 cx(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xmas(mgs,ls))
6664 xdn(mgs,ls) = 0.0346159*sqrt(cx(mgs,ls)/(qx(mgs,ls)*rho0(mgs)) )
6665 xdia(mgs,ls,1) = sqrt( xmas(mgs,ls)/0.069 )
6666 ENDIF
6667
6668 xdia(mgs,ls,3) = xdia(mgs,ls,1)
6669
6670 ELSE
6671 xdia(mgs,ls,1) = &
6672 & (qx(mgs,ls)*rho0(mgs)/(pi*xdn(mgs,ls)*cnostmp(mgs)))**(0.25)
6673 cx(mgs,ls) = cnostmp(mgs)*xdia(mgs,ls,1)
6674 xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*cx(mgs,ls))
6675 xdia(mgs,ls,3) = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6676 end if
6677 else
6678 xdia(mgs,ls,1) = 1.e-9
6679 xdia(mgs,ls,3) = 1.e-9
6680 cx(mgs,ls) = 0.0
6681
6682 IF ( isnowdens == 2 ) THEN ! Set values according to Cox relationship
6683 xdn(mgs,ls) = 90.
6684 ENDIF
6685
6686 end if
6687 xdia(mgs,ls,2) = xdia(mgs,ls,1)**2
6688! swdia3(mgs) = xdia(mgs,ls,2)*xdia(mgs,ls,1)
6689! xmas(mgs,ls) = xdn(mgs,ls)*(pi/6.)*swdia3(mgs)
6690 end do
6691
6692 ENDIF ! ls .gt 1
6693!
6694!
6695! ################################################################
6696!
6697! GRAUPEL
6698!
6699
6700 IF ( lh .gt. 1 .and. ( ildo == 0 .or. ildo == lh ) ) THEN
6701
6702 do mgs = 1,ngscnt
6703 if ( qx(mgs,lh) .gt. qxmin(lh) ) then
6704 if ( ipconc .ge. 5 ) then
6705
6706 xv(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*max(1.0e-9,cx(mgs,lh)))
6707 xmas(mgs,lh) = xv(mgs,lh)*xdn(mgs,lh)
6708
6709 IF ( xv(mgs,lh) .lt. xvmn(lh) .or. xv(mgs,lh) .gt. xvmx(lh) ) THEN
6710 xv(mgs,lh) = min( xvmx(lh), max( xvmn(lh),xv(mgs,lh) ) )
6711 xmas(mgs,lh) = xv(mgs,lh)*xdn(mgs,lh)
6712 cx(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xmas(mgs,lh))
6713 ENDIF
6714
6715 xdia(mgs,lh,3) = (xv(mgs,lh)*6.*pii)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
6716 IF ( dmuh == 1.0 ) THEN
6717 xdia(mgs,lh,1) = cwch(mgs)*xdia(mgs,lh,3)
6718 ELSE
6719 xdia(mgs,lh,1) = (xv(mgs,lh)*cwch(mgs))**(1./3.)
6720 ENDIF
6721
6722 ELSE
6723 xdia(mgs,lh,1) = &
6724 & (qx(mgs,lh)*rho0(mgs)/(pi*xdn(mgs,lh)*cno(lh)))**(0.25)
6725 cx(mgs,lh) = cno(lh)*xdia(mgs,lh,1)
6726 xv(mgs,lh) = max(xvmn(lh), rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) )
6727 xdia(mgs,lh,3) = (xv(mgs,lh)*6./pi)**(1./3.)
6728 end if
6729 else
6730 xdia(mgs,lh,1) = 1.e-9
6731 xdia(mgs,lh,3) = 1.e-9
6732 end if
6733 xdia(mgs,lh,2) = xdia(mgs,lh,1)**2
6734! hwdia3(mgs) = xdia(mgs,lh,2)*xdia(mgs,lh,1)
6735! xmas(mgs,lh) = xdn(mgs,lh)*(pi/6.)*hwdia3(mgs)
6736 end do
6737
6738 ENDIF
6739
6740!
6741! ################################################################
6742!
6743! HAIL
6744!
6745
6746 IF ( lhl .gt. 1 .and. ( ildo == 0 .or. ildo == lhl ) ) THEN
6747
6748 do mgs = 1,ngscnt
6749 if ( qx(mgs,lhl) .gt. qxmin(lhl) ) then
6750 if ( ipconc .ge. 5 ) then
6751
6752 xv(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*max(1.0e-9,cx(mgs,lhl)))
6753 xmas(mgs,lhl) = xv(mgs,lhl)*xdn(mgs,lhl)
6754! write(0,*) 'setvt: xv = ',xv(mgs,lhl),xdn(mgs,lhl),cx(mgs,lhl),xmas(mgs,lhl),qx(mgs,lhl)
6755
6756 IF ( xv(mgs,lhl) .lt. xvmn(lhl) .or. xv(mgs,lhl) .gt. xvmx(lhl) ) THEN
6757 xv(mgs,lhl) = min( xvmx(lhl), max( xvmn(lhl),xv(mgs,lhl) ) )
6758 xmas(mgs,lhl) = xv(mgs,lhl)*xdn(mgs,lhl)
6759 cx(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xmas(mgs,lhl))
6760 ENDIF
6761
6762 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6./pi)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
6763 IF ( dmuhl == 1.0 ) THEN
6764 xdia(mgs,lhl,1) = cwchl(mgs)*xdia(mgs,lhl,3)
6765 ELSE
6766 xdia(mgs,lhl,1) = (xv(mgs,lhl)*cwchl(mgs))**(1./3.)
6767 ENDIF
6768
6769! write(0,*) 'setvt: xv = ',xv(mgs,lhl),xdn(mgs,lhl),cx(mgs,lhl),xdia(mgs,lhl,3)
6770 ELSE
6771 xdia(mgs,lhl,1) = &
6772 & (qx(mgs,lhl)*rho0(mgs)/(pi*xdn(mgs,lhl)*cno(lhl)))**(0.25)
6773 cx(mgs,lhl) = cno(lhl)*xdia(mgs,lhl,1)
6774 xv(mgs,lhl) = max(xvmn(lhl), rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*cx(mgs,lhl)) )
6775 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6./pi)**(1./3.)
6776 end if
6777 else
6778 xdia(mgs,lhl,1) = 1.e-9
6779 xdia(mgs,lhl,3) = 1.e-9
6780 end if
6781 xdia(mgs,lhl,2) = xdia(mgs,lhl,1)**2
6782! hwdia3(mgs) = xdia(mgs,lh,2)*xdia(mgs,lh,1)
6783! xmas(mgs,lh) = xdn(mgs,lh)*(pi/6.)*hwdia3(mgs)
6784 end do
6785
6786 ENDIF
6787!
6788!
6789!
6790! Set terminal velocities...
6791! also set drag coefficients (moved to start of subroutine)
6792!
6793! cdx(lr) = 0.60
6794! cdx(lh) = 0.45
6795! cdx(lhl) = 0.45
6796! cdx(lf) = 0.45
6797! cdx(lgh) = 0.60
6798! cdx(lgm) = 0.80
6799! cdx(lgl) = 0.80
6800! cdx(lir) = 2.00
6801!
6802 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set terminal velocities'
6803!
6804!
6805! ################################################################
6806!
6807! RAIN
6808!
6809 IF ( ildo == 0 .or. ildo == lr ) THEN
6810 do mgs = 1,ngscnt
6811 if ( qx(mgs,lr) .gt. qxmin(lr) ) then
6812 IF ( ipconc .lt. 3 ) THEN
6813 vtxbar(mgs,lr,1) = rainfallfac*(ar*gf4br/6.0)*(xdia(mgs,lr,1)**br)*rhovt(mgs)
6814! write(91,*) 'vtxbar: ',vtxbar(mgs,lr,1),mgs,gf4br,xdia(mgs,lr,1),rhovt(mgs)
6815 ELSE
6816
6817 IF ( imurain == 1 ) THEN ! DSD of Diameter
6818
6819 ! using functional form of arx*(1 - Exp(-frx*diameter) ), with arx = arx = 10.
6820 ! and frx = 516.575 ! raind fit parameters for arx*(1 - Exp(-fx*d)), where d is rain diameter in meters.
6821 ! Similar form as in Atlas et al. (1973), who had 9.65 - 10.3*Exp[-600 * d]
6822
6823
6824 alp = alpha(mgs,lr)
6825
6826 vtxbar(mgs,lr,1) = rhovt(mgs)*arx*(1.0 - (1.0 + frx*xdia(mgs,lr,1))**(-alp - 4.0) ) ! mass weighted
6827
6828 IF ( infdo .ge. 1 .and. rssflg == 1 ) THEN
6829 vtxbar(mgs,lr,2) = rhovt(mgs)*arx*(1.0 - (1.0 + frx*xdia(mgs,lr,1))**(-alp - 1.0) ) ! number weighted
6830 ELSE
6831 vtxbar(mgs,lr,2) = vtxbar(mgs,lr,1)
6832 ENDIF
6833
6834 IF ( infdo .ge. 2 .and. rssflg == 1 ) THEN
6835 vtxbar(mgs,lr,3) = rhovt(mgs)*arx*(1.0 - (1.0 + frx*xdia(mgs,lr,1))**(-alp - 7.0) ) ! z-weighted
6836 ELSE
6837 vtxbar(mgs,lr,3) = vtxbar(mgs,lr,1)
6838 ENDIF
6839
6840! write(91,*) 'setvt: alp,vn,vm,vz = ',alp,vtxbar(mgs,lr,2), vtxbar(mgs,lr,1), vtxbar(mgs,lr,3),alpha(mgs,lr)
6841
6842 ELSEIF ( imurain == 3 ) THEN ! DSD of Volume
6843
6844 IF ( lzr < 1 ) THEN ! not 3-moment rain
6845 rwdia = min( xdia(mgs,lr,1), 8.0e-3 )
6846
6847 vtxbar(mgs,lr,1) = rhovt(mgs)*6.0*pii*( 0.04771 + 3788.0*rwdia - &
6848 & 1.105e6*rwdia**2 + 1.412e8*rwdia**3 - 6.527e9*rwdia**4)
6849
6850 IF ( infdo .ge. 1 ) THEN
6851 IF ( rssflg >= 1 ) THEN
6852 vtxbar(mgs,lr,2) = (0.09112 + 2714.0*rwdia - 4.872e5*rwdia**2 + &
6853 & 4.495e7*rwdia**3 - 1.626e9*rwdia**4)*rhovt(mgs)
6854 ELSE
6855 vtxbar(mgs,lr,2) = vtxbar(mgs,lr,1)
6856 ENDIF
6857 ENDIF
6858
6859 IF ( infdo .ge. 2 ) THEN ! Z-weighted fall speed
6860 vtxbar(mgs,lr,3) = rhovt(mgs)*( &
6861 & 0.0911229 + &
6862 & 9246.494*(rwdia) - &
6863 & 3.2839926e6*(rwdia**2) + &
6864 & 4.944093e8*(rwdia**3) - &
6865 & 2.631718e10*(rwdia**4) )
6866 ENDIF
6867
6868 ELSE ! 3-moment rain, gamma-volume
6869
6870 vr = xv(mgs,lr)
6871 rnux = alpha(mgs,lr)
6872
6873 IF ( infdo .ge. 1 .and. rssflg == 1) THEN ! number-weighted; DTD: added size-sorting flag
6874 vtxbar(mgs,lr,2) = rhovt(mgs)* &
6875 & (((1. + rnux)/vr)**(-1.333333)* &
6876 & (0.0911229*((1. + rnux)/vr)**1.333333*gamma_sp(1. + rnux) + &
6877 & (5430.3131*(1. + rnux)*gamma_sp(4./3. + rnux))/ &
6878 & vr - 1.0732802e6*((1. + rnux)/vr)**0.6666667* &
6879 & gamma_sp(1.666667 + rnux) + &
6880 & 8.584110982429507e7*((1. + rnux)/vr)**(1./3.)* &
6881 & gamma_sp(2. + rnux) - &
6882 & 2.3303765697228556e9*gamma_sp(7./3. + rnux)))/ &
6883 & gamma_sp(1. + rnux)
6884 ENDIF
6885
6886! mass-weighted
6887 vtxbar(mgs,lr,1) = rhovt(mgs)* &
6888 & (0.0911229*(1 + rnux)**1.3333333333333333*gamma_sp(2. + rnux) + &
6889 & 5430.313059683277*(1 + rnux)*vr**0.3333333333333333* &
6890 & gamma_sp(2.333333333333333 + rnux) - &
6891 & 1.0732802065650471e6*(1 + rnux)**0.6666666666666666*vr**0.6666666666666666* &
6892 & gamma_sp(2.6666666666666667 + rnux) + &
6893 & 8.584110982429507e7*(1 + rnux)**0.3333333333333333*vr*gamma_sp(3 + rnux) - &
6894 & 2.3303765697228556e9*vr**1.3333333333333333* &
6895 & gamma_sp(3.333333333333333 + rnux))/ &
6896 & ((1 + rnux)**2.333333333333333*gamma_sp(1 + rnux))
6897
6898 IF(infdo .ge. 1 .and. rssflg == 0) THEN ! No size-sorting, set N-weighted fall speed to mass-weighted
6899 vtxbar(mgs,lr,2) = vtxbar(mgs,lr,1)
6900 ENDIF
6901
6902 IF ( infdo .ge. 2 .and. rssflg == 1) THEN ! Z-weighted fall speed
6903 vtxbar(mgs,lr,3) = rhovt(mgs)* &
6904 & ((1. + rnux)*(0.0911229*(1 + rnux)**1.3333333333333333*gamma_sp(3. + rnux) + &
6905 & 5430.313059683277*(1 + rnux)*vr**0.3333333333333333* &
6906 & gamma_sp(3.3333333333333335 + rnux) - &
6907 & 1.0732802065650471e6*(1 + rnux)**0.6666666666666666* &
6908 & vr**0.6666666666666666*gamma_sp(3.6666666666666665 + rnux) + &
6909 & 8.5841109824295e7*(1 + rnux)**0.3333333333333333*vr*gamma_sp(4. + rnux) - &
6910 & 2.3303765697228556e9*vr**1.3333333333333333* &
6911 & gamma_sp(4.333333333333333 + rnux)))/ &
6912 & ((1 + rnux)**3.3333333333333335*(2 + rnux)*gamma_sp(1 + rnux))
6913
6914! write(0,*) 'setvt: mgs,lzr,infdo = ',mgs,lzr,infdo
6915! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,lr,1),vtxbar(mgs,lr,2),vtxbar(mgs,lr,3)
6916
6917 ELSEIF (infdo .ge. 2) THEN ! No size-sorting, set Z-weighted fall speed to mass-weighted
6918 vtxbar(mgs,lr,3) = vtxbar(mgs,lr,1)
6919 ENDIF
6920
6921
6922 ENDIF
6923 ENDIF ! imurain
6924
6925! IF ( rwrad*mwfac .gt. 6.0e-4 ) THEN
6926! vtxbar(mgs,lr,1) = 20.1*Sqrt(100.*rwrad*mwfac)*rhovt(mgs)
6927! ELSE
6928! vtxbar(mgs,lr,1) = 80.0e2*rwrad*rhovt(mgs)*mwfac
6929! ENDIF
6930! IF ( rwrad .gt. 6.0e-4 ) THEN
6931! vtxbar(mgs,lr,2) = 20.1*Sqrt(100.*rwrad)*rhovt(mgs)
6932! ELSE
6933! vtxbar(mgs,lr,2) = 80.0e2*rwrad*rhovt(mgs)
6934! ENDIF
6935 ENDIF ! ipconc
6936 else ! qr < qrmin
6937 vtxbar(mgs,lr,1) = 0.0
6938 vtxbar(mgs,lr,2) = 0.0
6939 end if
6940 end do
6941 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set rain vt'
6942
6943 ENDIF
6944!
6945! ################################################################
6946!
6947! SNOW !Zrnic et al. (1993)
6948!
6949 IF ( ls .gt. 1 .and. ( ildo == 0 .or. ildo == ls ) ) THEN
6950 do mgs = 1,ngscnt
6951 if ( qx(mgs,ls) .gt. qxmin(ls) ) then
6952 IF ( ipconc .ge. 4 ) THEN
6953 if ( mixedphase .and. qsvtmod ) then
6954 else
6955 IF ( isnowfall == 1 ) THEN
6956 ! original (Zrnic et al. 1993)
6957 vtxbar(mgs,ls,1) = 5.72462*rhovt(mgs)*(xv(mgs,ls))**(1./12.)
6958 ELSEIF ( isnowfall == 2 ) THEN
6959 ! Ferrier:
6960 IF ( isnowdens == 1 ) THEN
6961 vtxbar(mgs,ls,1) = 11.9495*rhovt(mgs)*(xv(mgs,ls))**(0.14)
6962 ELSE
6963 vtxbar(mgs,ls,1) = 11.9495*rhovt(mgs)*(xv(mgs,ls)*xdn(mgs,ls)/100.)**(0.14)
6964 ENDIF
6965 ELSEIF ( isnowfall == 3 ) THEN
6966 ! Cox, mass distrib:
6967 vtxbar(mgs,ls,1) = 50.092*rhovt(mgs)*(xmas(mgs,ls))**(0.2635)
6968 ENDIF
6969
6970 IF(abs(sssflg) >= 1) THEN
6971 IF ( isnowfall == 1 ) THEN
6972 vtxbar(mgs,ls,2) = 4.04091*rhovt(mgs)*(xv(mgs,ls))**(1./12.)
6973 ELSEIF ( isnowfall == 2 ) THEN
6974 ! Ferrier:
6975 IF ( isnowdens == 1 ) THEN
6976 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)
6977 ELSE
6978 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)
6979 ENDIF
6980 ELSEIF ( isnowfall == 3 ) THEN
6981 ! Cox, mass distrib:
6982 vtxbar(mgs,ls,2) = 21.6147*rhovt(mgs)*(xmas(mgs,ls))**(0.2635)
6983 ENDIF
6984 ELSE
6985 vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
6986 ENDIF
6987 IF ( infdo >= 2 ) THEN
6988 IF ( isnowfall == 1 ) THEN
6989 vtxbar(mgs,ls,3) = 6.12217*rhovt(mgs)*(xv(mgs,ls))**(1./12.) ! Zrnic et al 93
6990 ELSEIF ( isnowfall == 2 ) THEN
6991 vtxbar(mgs,ls,3) = 13.3436*rhovt(mgs)*(xv(mgs,ls))**(0.14) ! Ferrier 94
6992 ELSEIF ( isnowfall == 3 ) THEN
6993 ! Cox, mass distrib:
6994 vtxbar(mgs,ls,3) = 61.0914*rhovt(mgs)*(xmas(mgs,ls))**(0.2635)
6995 ENDIF
6996 ENDIF
6997
6998 IF ( sssflg < 0 .and. temcg(mgs) > abs(sssflg) ) THEN ! above a given temperature, effectively turn off size sorting
6999 vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
7000 vtxbar(mgs,ls,3) = vtxbar(mgs,ls,1)
7001 ENDIF
7002
7003 endif
7004 ELSE ! single-moment:
7005 vtxbar(mgs,ls,1) = (cs*gf4ds/6.0)*(xdia(mgs,ls,1)**ds)*rhovt(mgs)
7006 vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
7007 ENDIF
7008 else
7009 vtxbar(mgs,ls,1) = 0.0
7010 end if
7011
7012 IF ( snowfallfac /= 1.0 ) THEN
7013 vtxbar(mgs,ls,1) = snowfallfac*vtxbar(mgs,ls,1)
7014 vtxbar(mgs,ls,2) = snowfallfac*vtxbar(mgs,ls,2)
7015 vtxbar(mgs,ls,3) = snowfallfac*vtxbar(mgs,ls,3)
7016 ENDIF
7017
7018
7019 end do
7020 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set snow vt'
7021
7022 ENDIF ! ls .gt. 1
7023!
7024!
7025! ################################################################
7026!
7027! GRAUPEL !Wisner et al. (1972)
7028!
7029 IF ( lh .gt. 1 .and. ( ildo == 0 .or. ildo == lh ) ) THEN
7030
7031 do mgs = 1,ngscnt
7032 vtxbar(mgs,lh,1) = 0.0
7033 if ( qx(mgs,lh) .gt. qxmin(lh) ) then
7034 cd = cdx(lh)
7035 IF ( icdx .eq. 1 ) THEN
7036 cd = cdx(lh)
7037 ELSEIF ( icdx .eq. 2 ) THEN
7038! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(xdnmx(lh) - xdn(mgs,lh))/(xdnmx(lh)-xdnmn(lh)) ) )
7039! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lh))/(900. - 300.) ) )
7040 cd = max(0.45, min(1.0, 0.45 + 0.35*(800.0 - max( 500., min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
7041! cd = Max(0.55, Min(1.0, 0.55 + 0.25*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
7042 ELSEIF ( icdx .eq. 3 ) THEN
7043! cd = Max(0.45, Min(1.0, 0.45 + 0.55*(800.0 - Max( 300., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 300.) ) )
7044 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hdnmn, min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7045 ELSEIF ( icdx .eq. 4 ) THEN
7046 cd = max(cdhmin, min(cdhmax, cdhmin + (cdhmax-cdhmin)* &
7047 & (cdhdnmax - max( cdhdnmin, min( cdhdnmax, xdn(mgs,lh) ) ) )/(cdhdnmax - cdhdnmin) ) )
7048 ELSEIF ( icdx .eq. 5 ) THEN
7049 cd = cdx(lh)*(xdn(mgs,lh)/rho_qh)**(2./3.)
7050 ELSEIF ( icdx .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
7051 indxr = int( (xdn(mgs,lh)-50.)/100. ) + 1
7052 indxr = min( ngdnmm, max(1,indxr) )
7053
7054
7055 delrho = max( 0.0, 0.01*(xdn(mgs,lh) - mmgraupvt(indxr,1)) )
7056 IF ( indxr < ngdnmm ) THEN
7057
7058 axx(mgs,lh) = mmgraupvt(indxr,2) + delrho*(mmgraupvt(indxr+1,2) - mmgraupvt(indxr,2) )
7059 bxx(mgs,lh) = mmgraupvt(indxr,3) + delrho*(mmgraupvt(indxr+1,3) - mmgraupvt(indxr,3) )
7060
7061
7062 ELSE
7063 axx(mgs,lh) = mmgraupvt(indxr,2)
7064 bxx(mgs,lh) = mmgraupvt(indxr,3)
7065 ENDIF
7066
7067 aax = axx(mgs,lh)
7068 bbx = bxx(mgs,lh)
7069
7070 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hdnmn, min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7071
7072 ELSEIF ( icdx <= 0 ) THEN !
7073 aax = ax(lh)
7074 bbx = bx(lh)
7075 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hdnmn, min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7076 ELSE
7077 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hdnmn, min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7078 ENDIF
7079
7080 cdxgs(mgs,lh) = cd
7081 IF ( alpha(mgs,lh) .eq. 0.0 .and. icdx > 0 .and. icdx /= 6 ) THEN
7082! axx(mgs,lh) = (gf4p5/6.0)* &
7083! & Sqrt( (xdn(mgs,lh)*4.0*gr) / &
7084! & (3.0*cd*rho0(mgs)) )
7085 axx(mgs,lh) = sqrt(4.0*xdn(mgs,lh)*gr/(3.0*cd*rho00))
7086 bxx(mgs,lh) = 0.5
7087 vtxbar(mgs,lh,1) = (gf4p5/6.0)* rhovt(mgs)*axx(mgs,lh) * sqrt(xdia(mgs,lh,1))
7088! vtxbar(mgs,lh,1) = (gf4p5/6.0)* &
7089! & Sqrt( (xdn(mgs,lh)*xdia(mgs,lh,1)*4.0*gr) / &
7090! & (3.0*cd*rho0(mgs)) )
7091 ELSE
7092 IF ( icdx /= 6 ) bbx = bx(lh)
7093 tmp = 4. + alpha(mgs,lh) + bbx
7094 i = int(dgami*(tmp))
7095 del = tmp - dgam*i
7096 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7097
7098 tmp = 4. + alpha(mgs,lh)
7099 i = int(dgami*(tmp))
7100 del = tmp - dgam*i
7101 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7102
7103! aax = Max( 1.0, Min(2.0, (xdn(mgs,lh)/400.) ) )
7104! vtxbar(mgs,lh,1) = rhovt(mgs)*aax*ax(lh)*(xdia(mgs,lh,1)**bx(lh)*x)/y
7105
7106 IF ( icdx > 0 .and. icdx /= 6) THEN
7107 aax = sqrt(4.0*xdn(mgs,lh)*gr/(3.0*cd*rho00))
7108 vtxbar(mgs,lh,1) = rhovt(mgs)*aax* sqrt(xdia(mgs,lh,1)) * x/y
7109 axx(mgs,lh) = aax
7110 bxx(mgs,lh) = bbx
7111 ELSEIF (icdx == 6 ) THEN
7112 vtxbar(mgs,lh,1) = rhovt(mgs)*aax* xdia(mgs,lh,1)**bbx * x/y
7113 ELSE ! icdx < 0
7114 axx(mgs,lh) = ax(lh)
7115 bxx(mgs,lh) = bx(lh)
7116 vtxbar(mgs,lh,1) = rhovt(mgs)*ax(lh)*(xdia(mgs,lh,1)**bx(lh)*x)/y
7117 ENDIF
7118
7119! & Gamma_sp(4.0 + dnu(lh) + 0.6))/Gamma_sp(4. + dnu(lh))
7120 ENDIF
7121
7122 IF ( lwsm6 .and. ipconc == 0 ) THEN
7123! vtxbar(mgs,lh,1) = (330.*gf4ds/6.0)*(xdia(mgs,ls,1)**ds)*rhovt(mgs)
7124 vtxbar(mgs,lh,1) = (330.*gf4br/6.0)*(xdia(mgs,lh,1)**br)*rhovt(mgs)
7125 ENDIF
7126
7127 end if
7128 end do
7129 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt'
7130
7131 ENDIF ! lh .gt. 1
7132!
7133!
7134! ################################################################
7135!
7136! HAIL
7137!
7138 IF ( lhl .gt. 1 .and. ( ildo == 0 .or. ildo == lhl ) ) THEN
7139
7140 do mgs = 1,ngscnt
7141 vtxbar(mgs,lhl,1) = 0.0
7142 if ( qx(mgs,lhl) .gt. qxmin(lhl) ) then
7143
7144 IF ( icdxhl .eq. 1 ) THEN
7145 cd = cdx(lhl)
7146 ELSEIF ( icdxhl .eq. 3 ) THEN
7147! cd = Max(0.45, Min(1.0, 0.45 + 0.55*(800.0 - Max( 300., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 300.) ) )
7148 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hldnmn, min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
7149 ELSEIF ( icdxhl .eq. 4 ) THEN
7150 cd = max(cdhlmin, min(cdhlmax, cdhlmin + (cdhlmax-cdhlmin)* &
7151 & (cdhldnmax - max( cdhldnmin, min( cdhldnmax, xdn(mgs,lhl) ) ) )/(cdhldnmax - cdhldnmin) ) )
7152 ELSEIF ( icdxhl .eq. 5 ) THEN
7153 cd = cdx(lh)*(xdn(mgs,lhl)/rho_qh)**(2./3.)
7154 ELSEIF ( icdxhl .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
7155 indxr = int( (xdn(mgs,lhl)-50.)/100. ) + 1
7156 indxr = min( ngdnmm, max(1,indxr) )
7157
7158
7159 delrho = max( 0.0, 0.01*(xdn(mgs,lhl) - mmgraupvt(indxr,1)) )
7160 IF ( indxr < ngdnmm ) THEN
7161
7162 axx(mgs,lhl) = mmgraupvt(indxr,2) + delrho*(mmgraupvt(indxr+1,2) - mmgraupvt(indxr,2) )
7163 bxx(mgs,lhl) = mmgraupvt(indxr,3) + delrho*(mmgraupvt(indxr+1,3) - mmgraupvt(indxr,3) )
7164
7165
7166 ELSE
7167 axx(mgs,lhl) = mmgraupvt(indxr,2)
7168 bxx(mgs,lhl) = mmgraupvt(indxr,3)
7169 ENDIF
7170
7171 aax = axx(mgs,lhl)
7172 bbx = bxx(mgs,lhl)
7173
7174 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hldnmn, min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
7175
7176 ELSE
7177! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lhl))/(900. - 300.) ) )
7178! cd = Max(0.5, Min(0.8, 0.5 + 0.3*(xdnmx(lhl) - xdn(mgs,lhl))/(xdnmx(lhl)-xdnmn(lhl)) ) )
7179! cd = Max(0.45, Min(0.6, 0.45 + 0.15*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 500.) ) )
7180 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hldnmn, min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
7181 ENDIF
7182
7183 cdxgs(mgs,lhl) = cd
7184
7185 IF ( alpha(mgs,lhl) .eq. 0.0 .and. icdxhl > 0 .and. icdxhl /= 6) THEN
7186! axx(mgs,lhl) = (gf4p5/6.0)* &
7187! & Sqrt( (xdn(mgs,lhl)*4.0*gr) / &
7188! & (3.0*cd*rho0(mgs)) )
7189 axx(mgs,lhl) = sqrt(4.0*xdn(mgs,lhl)*gr/(3.0*cd*rho00))
7190 bxx(mgs,lhl) = 0.5
7191 vtxbar(mgs,lhl,1) = (gf4p5/6.0)* rhovt(mgs)*axx(mgs,lhl) * sqrt(xdia(mgs,lhl,1))
7192 ELSE
7193 IF ( icdxhl /= 6 ) bbx = bx(lhl)
7194 tmp = 4. + alpha(mgs,lhl) + bbx
7195 i = int(dgami*(tmp))
7196 del = tmp - dgam*i
7197 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7198
7199 tmp = 4. + alpha(mgs,lhl)
7200 i = int(dgami*(tmp))
7201 del = tmp - dgam*i
7202 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7203
7204 IF ( icdxhl > 0 .and. icdxhl /= 6) THEN
7205 aax = sqrt(4.0*xdn(mgs,lhl)*gr/(3.0*cd*rho00))
7206 vtxbar(mgs,lhl,1) = rhovt(mgs)*aax* sqrt(xdia(mgs,lhl,1)) * x/y
7207 axx(mgs,lhl) = aax
7208 bxx(mgs,lhl) = bbx
7209 ELSEIF ( icdxhl == 6 ) THEN
7210 vtxbar(mgs,lhl,1) = rhovt(mgs)*aax* (xdia(mgs,lhl,1))**bbx * x/y
7211 ELSE
7212 axx(mgs,lhl) = ax(lhl)
7213 bxx(mgs,lhl) = bx(lhl)
7214 vtxbar(mgs,lhl,1) = rhovt(mgs)*(ax(lhl)*xdia(mgs,lhl,1)**bx(lhl)*x)/y
7215 ENDIF
7216
7217! & Gamma_sp(4.0 + dnu(lh) + 0.6))/Gamma_sp(4. + dnu(lh))
7218 ENDIF
7219
7220
7221 end if
7222 end do
7223 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt'
7224
7225 ENDIF ! lhl .gt. 1
7226
7227
7228 IF ( infdo .ge. 1 ) THEN
7229
7230! DO il = lc,lhab
7231! IF ( il .ne. lr ) THEN
7232 DO mgs = 1,ngscnt
7233 IF ( ildo == 0 .or. ildo == lc ) THEN
7234 vtxbar(mgs,lc,2) = vtxbar(mgs,lc,1)
7235 ENDIF
7236 IF ( li .gt. 1 ) THEN
7237! vtxbar(mgs,li,2) = rhovt(mgs)*49420.*1.25447*xdia(mgs,li,1)**(1.415) ! n-wgt (Ferrier 94)
7238! vtxbar(mgs,li,2) = vtxbar(mgs,li,1)
7239
7240! test print stuff...
7241! IF ( xdia(mgs,li,1) .gt. 200.e-6 ) THEN
7242! tmp = (xv(mgs,li)*cwc0)**(1./3.)
7243! x = rhovt(mgs)*49420.*40.0005/5.40662*tmp**(1.415)
7244! y = rhovt(mgs)*49420.*1.25447*tmp**(1.415)
7245! write(6,*) 'Ice fall: ',vtxbar(mgs,li,1),x,y,tmp,xdia(mgs,li,1)
7246! ENDIF
7247 ENDIF
7248! vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
7249 ENDDO
7250
7251 IF ( lg .gt. lr ) THEN
7252
7253 DO il = lg,lhab
7254 IF ( ildo == 0 .or. ildo == il ) THEN
7255
7256 DO mgs = 1,ngscnt
7257 IF ( qx(mgs,il) .gt. qxmin(il) ) THEN
7258 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
7259
7260 ! DTD: allow for setting of number-weighted and z-weighted fall speeds to the mass-weighted value,
7261 ! effectively turning off size-sorting
7262
7263 IF ( il .eq. lh ) THEN ! {
7264
7265 IF ( icdx .eq. 1 ) THEN
7266 cd = cdx(lh)
7267 ELSEIF ( icdx .eq. 2 ) THEN
7268! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(xdnmx(lh) - xdn(mgs,lh))/(xdnmx(lh)-xdnmn(lh)) ) )
7269! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lh))/(900. - 300.) ) )
7270 cd = max(0.45, min(1.0, 0.45 + 0.35*(800.0 - max( 500., min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
7271! cd = Max(0.55, Min(1.0, 0.55 + 0.25*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
7272 ELSEIF ( icdx .eq. 3 ) THEN
7273! 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) ) )
7274 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hdnmn, min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7275 ELSEIF ( icdx .eq. 4 ) THEN
7276 cd = max(cdhmin, min(cdhmax, cdhmin + (cdhmax-cdhmin)* &
7277 & (cdhdnmax - max( cdhdnmin, min( cdhdnmax, xdn(mgs,lh) ) ) )/(cdhdnmax - cdhdnmin) ) )
7278 ELSEIF ( icdx .eq. 5 ) THEN
7279 cd = cdx(lh)*(xdn(mgs,lh)/rho_qh)**(2./3.)
7280 ELSEIF ( icdx .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
7281 aax = axx(mgs,lh)
7282 bbx = bxx(mgs,lh)
7283 ELSEIF ( icdx <= 0 ) THEN !
7284 aax = ax(lh)
7285 bbx = bx(lh)
7286 ENDIF
7287
7288 ELSEIF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
7289
7290 IF ( icdxhl .eq. 1 ) THEN
7291 cd = cdx(lhl)
7292 ELSEIF ( icdxhl .eq. 3 ) THEN
7293! cd = Max(0.45, Min(1.0, 0.45 + 0.55*(800.0 - Max( 300., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 300.) ) )
7294 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hldnmn, min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
7295 ELSEIF ( icdxhl .eq. 4 ) THEN
7296 cd = max(cdhlmin, min(cdhlmax, cdhlmin + (cdhlmax-cdhlmin)* &
7297 & (cdhldnmax - max( cdhldnmin, min( cdhldnmax, xdn(mgs,lhl) ) ) )/(cdhldnmax - cdhldnmin) ) )
7298 ELSEIF ( icdxhl == 5 ) THEN
7299! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lhl))/(900. - 300.) ) )
7300! cd = Max(0.5, Min(0.8, 0.5 + 0.3*(xdnmx(lhl) - xdn(mgs,lhl))/(xdnmx(lhl)-xdnmn(lhl)) ) )
7301 cd = max(0.45, min(0.6, 0.45 + 0.15*(800.0 - max( 500., min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 500.) ) )
7302 ELSEIF ( icdxhl .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
7303 aax = axx(mgs,lhl)
7304 bbx = bxx(mgs,lhl)
7305 ELSEIF ( icdxhl <= 0 ) THEN !
7306 aax = ax(lhl)
7307 bbx = bx(lhl)
7308 ENDIF
7309
7310 ENDIF ! }
7311
7312 IF ( alpha(mgs,il) .eq. 0. .and. infdo .lt. 2 .and. &
7313 ( ( il==lh .and. icdx > 0 .and. icdx /= 6) .or. ( il==lhl .and. icdxhl > 0 .and. icdxhl /= 6 ) ) ) THEN ! {
7314 vtxbar(mgs,il,2) = &
7315 & sqrt( (xdn(mgs,il)*xdia(mgs,il,1)*pi*gr) / &
7316 & (3.0*cd*max(0.05,rho0(mgs))) )
7317
7318 ELSE
7319 IF ( il == lh .and. icdx /= 6 ) bbx = bx(il)
7320 IF ( il == lhl .and. icdxhl /= 6 ) bbx = bx(il)
7321 tmp = 1. + alpha(mgs,il) + bbx
7322 i = int(dgami*(tmp))
7323 del = tmp - dgam*i
7324 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7325
7326 tmp = 1. + alpha(mgs,il)
7327 i = int(dgami*(tmp))
7328 del = tmp - dgam*i
7329 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7330
7331 IF ( il .eq. lh .or. il .eq. lhl) THEN ! {
7332 IF ( ( il==lh .and. icdx > 0 ) ) THEN
7333 IF ( icdx /= 6 ) THEN
7334 aax = sqrt(4.0*xdn(mgs,il)*gr/(3.0*cd*rho00))
7335 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bx(il) * x/y
7336 ELSE ! (icdx == 6 ) THEN
7337 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bbx * x/y
7338 ENDIF
7339
7340 ELSEIF ( ( il==lhl .and. icdxhl > 0 ) ) THEN
7341 IF ( icdxhl /= 6 ) THEN
7342 aax = sqrt(4.0*xdn(mgs,il)*gr/(3.0*cd*rho00))
7343 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bx(il) * x/y
7344 ELSE ! ( icdxhl == 6 )
7345 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bbx * x/y
7346 ENDIF
7347 ELSE ! get here if il==lh and icdx < 0 -- or -- il==lhl and icdxhl < 0
7348 aax = ax(il)
7349 vtxbar(mgs,il,2) = rhovt(mgs)*ax(il)*(xdia(mgs,il,1)**bx(il)*x)/y
7350 ENDIF
7351! vtxbar(mgs,il,2) = &
7352! & rhovt(mgs)*(xdn(mgs,il)/400.)*(75.715*xdia(mgs,il,1)**0.6* &
7353! & x)/y
7354! vtxbar(mgs,il,2) = &
7355! & rhovt(mgs)*(xdn(mgs,il)/400.)*(ax(il)*xdia(mgs,il,1)**bx(il)* &
7356! & x)/y
7357 IF ( infdo .ge. 2 ) THEN ! Z-weighted
7358
7359 tmp = 7. + alpha(mgs,il) + bbx
7360 i = int(dgami*(tmp))
7361 del = tmp - dgam*i
7362 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7363
7364 tmp = 7. + alpha(mgs,il)
7365 i = int(dgami*(tmp))
7366 del = tmp - dgam*i
7367 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7368
7369 vtxbar(mgs,il,3) = rhovt(mgs)* &
7370 & (aax*(xdia(mgs,il,1) )**bbx * &
7371 & x)/y
7372! & Gamma(7.0 + alpha(mgs,il) + bbx)/Gamma(7. + alpha(mgs,il))
7373 IF ( .not. (vtxbar(mgs,il,1) > -1. .and. vtxbar(mgs,il,1) < 200. ) .or. &
7374 .not. (vtxbar(mgs,il,3) > -1. .and. vtxbar(mgs,il,3) < 200. ) ) THEN
7375 write(0,*) 'Setvtz: problem with vtxbar1/3: ',il,vtxbar(mgs,il,1),vtxbar(mgs,il,3),aax,bbx,x,y
7376 write(0,*) 'q, number, diam1,3(mm) = ', qx(mgs,il),cx(mgs,il),1000.*xdia(mgs,il,1),1000.*xdia(mgs,il,3)
7377 ! call commasmpi_abort()
7378 ENDIF
7379! & (aax*(1.0/xdia(mgs,il,1) )**(- bx(il))* &
7380! & Gamma_sp(7.0 + alpha(mgs,il) + bx(il)))/Gamma_sp(7. + alpha(mgs,il))
7381 ENDIF
7382
7383 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt3'
7384
7385 ELSE ! hail
7386 vtxbar(mgs,il,2) = &
7387 & rhovt(mgs)*(ax(il)*xdia(mgs,il,1)**bx(il)* &
7388 & x)/y
7389
7390 IF ( infdo .ge. 2 ) THEN ! Z-weighted
7391 vtxbar(mgs,il,3) = rhovt(mgs)* &
7392 & (aax*(1.0/xdia(mgs,il,1) )**(- bbx)* &
7393 & gamma_sp(7.0 + alpha(mgs,il) + bbx))/gamma_sp(7. + alpha(mgs,il))
7394! & (ax(il)*(1.0/xdia(mgs,il,1) )**(- bx(il))* &
7395! & Gamma_sp(7.0 + alpha(mgs,il) + bx(il)))/Gamma_sp(7. + alpha(mgs,il))
7396 ENDIF
7397
7398 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt4'
7399
7400 ENDIF ! }
7401! & Gamma_sp(1.0 + dnu(il) + 0.6)/Gamma_sp(1. + dnu(il))
7402 ENDIF ! }
7403
7404! IF ( infdo .ge. 2 ) THEN ! Z-weighted
7405! vtxbar(mgs,il,3) = rhovt(mgs)* &
7406! & (ax(il)*(1.0/xdia(mgs,il,1) )**(- bx(il))* &
7407! & Gamma_sp(7.0 + alpha(mgs,il) + bx(il)))/Gamma_sp(7. + alpha(mgs,il))
7408! ENDIF
7409
7410! IF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
7411! write(0,*) 'setvt: ',qx(mgs,il),xdia(mgs,il,1),xdia(mgs,il,3),dnu(il),ax(il),bx(il)
7412! ENDIF
7413 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
7414 vtxbar(mgs,il,2) = vtxbar(mgs,il,1)
7415 vtxbar(mgs,il,3) = vtxbar(mgs,il,1)
7416 ELSE ! not lh or lhl
7417 vtxbar(mgs,il,2) = &
7418 & sqrt( (xdn(mgs,il)*xdia(mgs,il,1)*pi*gr) / &
7419 & (3.0*cdx(il)*max(0.05,rho0(mgs))) )
7420 vtxbar(mgs,il,3) = vtxbar(mgs,il,1)
7421
7422 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt5'
7423
7424
7425 ENDIF
7426 ELSE ! qx < qxmin
7427 vtxbar(mgs,il,2) = 0.0
7428
7429 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt6'
7430
7431 ENDIF
7432 ENDDO ! mgs
7433
7434 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt7'
7435
7436 ENDIF
7437 ENDDO ! il
7438
7439 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt8'
7440
7441 ENDIF ! lg .gt. 1
7442
7443! ENDIF
7444! ENDDO
7445
7446 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt9'
7447
7448! DO mgs = 1,ngscnt
7449! IF ( qx(mgs,lr) > qxmin(lr) ) THEN
7450! write(0,*) 'setvt2: mgs,lzr,infdo = ',mgs,lzr,infdo
7451! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,lr,1),vtxbar(mgs,lr,2),vtxbar(mgs,lr,3)
7452! ENDIF
7453! ENDDO
7454
7455 ENDIF ! infdo .ge. 1
7456
7457 IF ( lh > 0 .and. graupelfallfac /= 1.0 ) THEN
7458 DO mgs = 1,ngscnt
7459 vtxbar(mgs,lh,1) = graupelfallfac*vtxbar(mgs,lh,1)
7460 vtxbar(mgs,lh,2) = graupelfallfac*vtxbar(mgs,lh,2)
7461 vtxbar(mgs,lh,3) = graupelfallfac*vtxbar(mgs,lh,3)
7462 axx(mgs,lh) = graupelfallfac*axx(mgs,lh)
7463 ENDDO
7464 ENDIF
7465
7466 IF ( lhl > 0 .and. hailfallfac /= 1.0 ) THEN
7467 DO mgs = 1,ngscnt
7468 vtxbar(mgs,lhl,1) = hailfallfac*vtxbar(mgs,lhl,1)
7469 vtxbar(mgs,lhl,2) = hailfallfac*vtxbar(mgs,lhl,2)
7470 vtxbar(mgs,lhl,3) = hailfallfac*vtxbar(mgs,lhl,3)
7471 axx(mgs,lhl) = hailfallfac*axx(mgs,lhl)
7472 ENDDO
7473 ENDIF
7474
7475 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: END OF ROUTINE'
7476
7477!############ SETVTZ ############################
7478
7479 RETURN
7480 END SUBROUTINE setvtz
7481!--------------------------------------------------------------------------
7482
7483!
7484! ##############################################################################
7485
7486!
7487! subroutine to calculate fall speeds of hydrometeors
7488!
7489
7492 subroutine ziegfall1d(nx,ny,nz,nor,norz,na,dtp,jgs,ixcol, &
7493 & xvt, rhovtzx, &
7494 & an,dn,ipconc0,t0,t7,cwmasn,cwmasx, &
7495 & cwradn, &
7496 & qxmin,xdnmx,xdnmn,cdx,cno,xdn0,xvmn,xvmx, &
7497 & ngs,qx,qxw,cx,xv,vtxbar,xmas,xdn,xdia,vx,alpha,zx,igs,kgs, &
7498 & rho0,temcg,temg,rhovt,cwnc,cinc,fadvisc,cwdia,cipmas,cnina,cimas, &
7499 & cnostmp, &
7500 & infdo,ildo,timesetvt)
7501
7502! 12.16.2005: .F version use in transitional SWM model
7503!
7504! 10.10.2003: Added cimn and cimx to setting for cci and cip.
7505!
7506! TO DO LIST:
7507!
7508! need to set up values for:
7509! : cipdia,cidia,cwdia,cwmas,vtwbar,
7510! : rho0,temcg,cip,cci
7511!
7512! and need to put fallspeed values in cwvt etc.
7513!
7514
7515 implicit none
7516 integer ng1
7517 parameter(ng1 = 1)
7518
7519 integer, intent(in) :: ixcol ! which column to return
7520 integer, intent(in) :: ildo
7521
7522 integer nx,ny,nz,nor,norz,ngt,jgs,na
7523 real an(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,na)
7524 real dn(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
7525 real t0(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
7526 real t7(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
7527 real dtp,dtz1
7528
7529 real :: rhovtzx(nz,nx)
7530
7531 integer ndebugzf
7532 parameter(ndebugzf = 0)
7533
7534 integer ix,jy,kz,i,j,k,il
7535 integer infdo
7536!
7537!
7538 real xvt(nz+1,nx,3,lc:lhab) ! 1=mass-weighted, 2=number-weighted
7539
7540 real qxmin(lc:lhab)
7541 real xdn0(lc:lhab)
7542 real xvmn(lc:lhab), xvmx(lc:lhab)
7543 double precision,optional :: timesetvt
7544
7545 integer :: ngs
7546 integer :: ngscnt,mgs,ipconc0
7547! parameter ( ngs=200 )
7548
7549 real :: qx(ngs,lv:lhab)
7550 real :: qxw(ngs,ls:lhab)
7551 real :: cx(ngs,lc:lhab)
7552 real :: xv(ngs,lc:lhab)
7553 real :: vtxbar(ngs,lc:lhab,3)
7554 real :: xmas(ngs,lc:lhab)
7555 real :: xdn(ngs,lc:lhab)
7556 real :: cdxgs(ngs,lc:lhab)
7557 real :: xdia(ngs,lc:lhab,3)
7558 real :: vx(ngs,li:lhab)
7559 real :: alpha(ngs,lc:lhab)
7560 real :: zx(ngs,lr:lhab)
7561
7562 real xdnmx(lc:lhab), xdnmn(lc:lhab)
7563 real :: axx(ngs,lh:lhab), bxx(ngs,lh:lhab)
7564! real axh(ngs),bxh(ngs),axhl(ngs),bxhl(ngs)
7565
7566!
7567! drag coefficients
7568!
7569 real cdx(lc:lhab)
7570!
7571! Fixed intercept values for single moment scheme
7572!
7573 real cno(lc:lhab)
7574
7575 real cwccn0,cwmasn,cwmasx,cwradn
7576! real cwc0
7577
7578 integer nxmpb,nzmpb,nxz,numgs,inumgs
7579 integer kstag
7580 parameter(kstag=1)
7581
7582 integer igs(ngs),kgs(ngs)
7583
7584 real rho0(ngs),temcg(ngs)
7585
7586 real temg(ngs)
7587
7588 real rhovt(ngs)
7589
7590 real cwnc(ngs),cinc(ngs)
7591 real fadvisc(ngs),cwdia(ngs),cipmas(ngs)
7592
7593! real cimasn,cimasx,
7594 real :: cnina(ngs),cimas(ngs)
7595
7596 real :: cnostmp(ngs)
7597
7598! real pii
7599!
7600!
7601! general constants for microphysics
7602!
7603
7604!
7605! Miscellaneous
7606!
7607
7608 logical flag
7609 logical ldoliq
7610
7611
7612 real chw, qr, z, rd, alp, z1, g1, vr, nrx, tmp
7613
7614 real vtmax
7615 real xvbarmax
7616
7617 real, parameter :: c1r=19.0, c2r=0.6, c3r=1.8, c4r=17.0 ! rain
7618 real, parameter :: c1h=5.5, c2h=0.7, c3h=4.5, c4h=8.5 ! Graupel
7619 real, parameter :: c1hl=3.7, c2hl=0.3, c3hl=9.0, c4hl=6.5, c5hl=1.0, c6hl=6.5 ! Hail
7620
7621 integer l1, l2
7622
7623 double precision :: dpt1, dpt2
7624
7625
7626!-----------------------------------------------------------------------------
7627! MPI LOCAL VARIABLES
7628
7629 integer :: ixb, jyb, kzb
7630 integer :: ixe, jye, kze
7631
7632 logical :: debug_mpi = .false.
7633
7634
7635 if (ndebugzf .gt. 0 ) write(0,*) "ZIEGFALL: ENTERED SUBROUTINE"
7636
7637! #####################################################################
7638! BEGIN EXECUTABLE
7639! #####################################################################
7640!
7641
7642! constants
7643!
7644
7645 ldoliq = .false.
7646 IF ( ls .gt. 1 ) THEN
7647 DO il = ls,lhab
7648 ldoliq = ldoliq .or. ( lliq(il) .gt. 1 )
7649 ENDDO
7650 ENDIF
7651
7652! poo = 1.0e+05
7653! cp608 = 0.608
7654! cp = 1004.0
7655! cv = 717.0
7656! dnz00 = 1.225
7657! rho00 = 1.225
7658! cs = 4.83607122
7659! ds = 0.25
7660! new values for cs and ds
7661! cs = 12.42
7662! ds = 0.42
7663! pi = 4.0*atan(1.0)
7664! pii = piinv ! 1./pi
7665! pid4 = pi/4.0
7666! qccrit = 2.0e-03
7667! qscrit = 6.0e-04
7668! cwc0 = pii
7669
7670!
7671!
7672! general constants for microphysics
7673!
7674
7675!
7676! ci constants in mks units
7677!
7678! cimasn = 6.88e-13
7679! cimasx = 1.0e-8
7680!
7681! Set terminal velocities...
7682! also set drag coefficients
7683!
7684 jy = jgs
7685 nxmpb = ixcol
7686 nzmpb = 1
7687 nxz = 1*nz
7688! ngs = nz
7689 numgs = 1
7690
7691 IF ( ildo == 0 ) THEN
7692 l1 = lc
7693 l2 = lhab
7694 ELSE
7695 l1 = ildo
7696 l2 = ildo
7697 ENDIF
7698
7699
7700 do inumgs = 1,numgs
7701 ngscnt = 0
7702
7703
7704 do kz = nzmpb,nz
7705 do ix = ixcol,ixcol
7706 flag = .false.
7707
7708
7709 DO il = l1,l2
7710 flag = flag .or. ( an(ix,jy,kz,il) .gt. qxmin(il) )
7711 ENDDO
7712
7713 if ( flag ) then
7714! load temp quantities
7715
7716 ngscnt = ngscnt + 1
7717 igs(ngscnt) = ix
7718 kgs(ngscnt) = kz
7719 if ( ngscnt .eq. ngs ) goto 1100
7720 end if
7721 end do !!ix
7722 nxmpb = 1
7723 end do !! kz
7724
7725! if ( jy .eq. (ny-jstag) ) iend = 1
7726
7727 1100 continue
7728
7729 if ( ngscnt .eq. 0 ) go to 9998
7730!
7731! set temporaries for microphysics variables
7732!
7733
7734
7735!
7736! Reconstruct various quantities
7737!
7738 do mgs = 1,ngscnt
7739
7740 rho0(mgs) = dn(igs(mgs),jy,kgs(mgs))
7741 rhovt(mgs) = rhovtzx(kgs(mgs),ixcol) ! Sqrt(rho00/rho0(mgs))
7742 temg(mgs) = t0(igs(mgs),jy,kgs(mgs))
7743 temcg(mgs) = temg(mgs) - tfr
7744
7745
7746!
7747 end do
7748!
7749! only need fadvisc for
7750 IF ( lc .gt. 1 .and. (ildo == 0 .or. ildo == lc ) ) then
7751 do mgs = 1,ngscnt
7752 fadvisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))* &
7753 & (temg(mgs)/296.0)**(1.5)
7754 end do
7755 ENDIF
7756
7757 IF ( ipconc .eq. 0 ) THEN
7758 do mgs = 1,ngscnt
7759 cnina(mgs) = t7(igs(mgs),jgs,kgs(mgs))
7760 end do
7761 ENDIF
7762
7763
7764 IF ( ildo > 0 ) THEN
7765 vtxbar(:,ildo,:) = 0.0
7766 ELSE
7767 vtxbar(:,:,:) = 0.0
7768 ENDIF
7769
7770! do mgs = 1,ngscnt
7771! qx(mgs,lv) = max(an(igs(mgs),jy,kgs(mgs),lv), 0.0)
7772! ENDDO
7773 DO il = l1,l2
7774 do mgs = 1,ngscnt
7775 qx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),il), 0.0)
7776 ENDDO
7777 end do
7778
7779 cnostmp(:) = cno(ls)
7780 IF ( ipconc < 1 .and. lwsm6 .and. (ildo == 0 .or. ildo == ls )) THEN
7781 DO mgs = 1,ngscnt
7782 tmp = min( 0.0, temcg(mgs) )
7783 cnostmp(mgs) = min( 2.e8, 2.e6*exp(0.12*tmp) )
7784 ENDDO
7785 ENDIF
7786
7787
7788!
7789! set concentrations
7790!
7791 cx(:,:) = 0.0
7792
7793 if ( ipconc .ge. 1 .and. li .gt. 1 .and. (ildo == 0 .or. ildo == li ) ) then
7794 do mgs = 1,ngscnt
7795 cx(mgs,li) = max(an(igs(mgs),jy,kgs(mgs),lni), 0.0)
7796 end do
7797 end if
7798 if ( ipconc .ge. 2 .and. lc .gt. 1 .and. (ildo == 0 .or. ildo == lc ) ) then
7799 do mgs = 1,ngscnt
7800 cx(mgs,lc) = max(an(igs(mgs),jy,kgs(mgs),lnc), 0.0)
7801! cx(mgs,lc) = Min( ccwmx, cx(mgs,lc) )
7802 end do
7803 end if
7804 if ( ipconc .ge. 3 .and. lr .gt. 1 .and. (ildo == 0 .or. ildo == lr ) ) then
7805 do mgs = 1,ngscnt
7806 cx(mgs,lr) = max(an(igs(mgs),jy,kgs(mgs),lnr), 0.0)
7807! IF ( qx(mgs,lr) .le. qxmin(lr) ) THEN
7808! ELSE
7809! cx(mgs,lr) = Max( 0.0, cx(mgs,lr) )
7810! ENDIF
7811 end do
7812 end if
7813 if ( ipconc .ge. 4 .and. ls .gt. 1 .and. (ildo == 0 .or. ildo == ls ) ) then
7814 do mgs = 1,ngscnt
7815 cx(mgs,ls) = max(an(igs(mgs),jy,kgs(mgs),lns), 0.0)
7816! IF ( qx(mgs,ls) .le. qxmin(ls) ) THEN
7817! ELSE
7818! cx(mgs,ls) = Max( 0.0, cx(mgs,ls) )
7819! ENDIF
7820 end do
7821 end if
7822
7823 if ( ipconc .ge. 5 .and. lh .gt. 1 .and. (ildo == 0 .or. ildo == lh ) ) then
7824 do mgs = 1,ngscnt
7825
7826 cx(mgs,lh) = max(an(igs(mgs),jy,kgs(mgs),lnh), 0.0)
7827! IF ( qx(mgs,lh) .le. qxmin(lh) ) THEN
7828! ELSE
7829! cx(mgs,lh) = Max( 0.0, cx(mgs,lh) )
7830! ENDIF
7831
7832 end do
7833 ENDIF
7834
7835 if ( ipconc .ge. 5 .and. lhl .gt. 1 .and. (ildo == 0 .or. ildo == lhl ) ) then
7836 do mgs = 1,ngscnt
7837
7838 cx(mgs,lhl) = max(an(igs(mgs),jy,kgs(mgs),lnhl), 0.0)
7839! IF ( qx(mgs,lhl) .le. qxmin(lhl) ) THEN
7840! cx(mgs,lhl) = 0.0
7841! ELSEIF ( cx(mgs,lhl) .eq. 0.0 .and. qx(mgs,lhl) .lt. 3.0*qxmin(lhl) ) THEN
7842! qx(mgs,lhl) = 0.0
7843! ELSE
7844! cx(mgs,lhl) = Max( 0.0, cx(mgs,lhl) )
7845! ENDIF
7846
7847 end do
7848 end if
7849
7850 do mgs = 1,ngscnt
7851 xdn(mgs,lc) = xdn0(lc)
7852 xdn(mgs,lr) = xdn0(lr)
7853! IF ( ls .gt. 1 .and. lvs .eq. 0 ) xdn(mgs,ls) = xdn0(ls)
7854! IF ( lh .gt. 1 .and. lvh .eq. 0 ) xdn(mgs,lh) = xdn0(lh)
7855 IF ( li .gt. 1 ) xdn(mgs,li) = xdn0(li)
7856 IF ( ls .gt. 1 ) xdn(mgs,ls) = xdn0(ls)
7857 IF ( lh .gt. 1 ) xdn(mgs,lh) = xdn0(lh)
7858 IF ( lhl .gt. 1 ) xdn(mgs,lhl) = xdn0(lhl)
7859 end do
7860
7861!
7862! Set mean particle volume
7863!
7864 IF ( ldovol .and. (ildo == 0 .or. ildo >= li ) ) THEN
7865
7866 vx(:,:) = 0.0
7867
7868 DO il = l1,l2
7869
7870 IF ( lvol(il) .ge. 1 ) THEN
7871
7872 DO mgs = 1,ngscnt
7873 vx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),lvol(il)), 0.0)
7874 IF ( vx(mgs,il) .gt. rho0(mgs)*qxmin(il)*1.e-3 .and. qx(mgs,il) .gt. qxmin(il) ) THEN
7875 xdn(mgs,il) = min( xdnmx(il), max( xdnmn(il), rho0(mgs)*qx(mgs,il)/vx(mgs,il) ) )
7876 ENDIF
7877 ENDDO
7878
7879 ENDIF
7880
7881 ENDDO
7882
7883 ENDIF
7884
7885 DO il = lg,lhab
7886 DO mgs = 1,ngscnt
7887 alpha(mgs,il) = dnu(il)
7888 ENDDO
7889 ENDDO
7890
7891 IF ( imurain == 1 ) THEN
7892 alpha(:,lr) = alphar
7893 ELSEIF ( imurain == 3 ) THEN
7894 alpha(:,lr) = xnu(lr)
7895 ENDIF
7896
7897
7898 IF ( ipconc == 5 .and. imydiagalpha > 0 ) THEN
7899 DO mgs = 1,ngscnt
7900 IF ( qx(mgs,lr) .gt. qxmin(lr) .and. cx(mgs,lr) > cxmin ) THEN
7901 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr)) !
7902 xdia(mgs,lr,3) = (xv(mgs,lr)*6.0*cwc1)**(1./3.)
7903 alpha(mgs,lr) = min(alphamax, c1r*tanh(c2r*(xdia(mgs,lr,3)*1000. - c3r)) + c4r)
7904 ENDIF
7905 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. cx(mgs,lh) > cxmin ) THEN
7906 xv(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) !
7907 xdia(mgs,lh,3) = (xv(mgs,lh)*6.*piinv)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
7908 alpha(mgs,lh) = min(alphamax, c1h*tanh(c2h*(xdia(mgs,lh,3)*1000. - c3h)) + c4h)
7909 ENDIF
7910! alpha(:,lr) = 0. ! 10.
7911! alpha(:,lh) = 0. ! 10.
7912 IF ( lhl > 0 ) THEN
7913 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. cx(mgs,lhl) > cxmin ) THEN
7914 xv(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*cx(mgs,lhl)) !
7915 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6.*piinv)**(1./3.)
7916 IF ( xdia(mgs,lhl,3) < 0.008 ) THEN
7917 alpha(mgs,lhl) = min(alphamax, c1hl*tanh(c2hl*(xdia(mgs,lhl,3)*1000. - c3hl)) + c4hl)
7918 ELSE
7919 alpha(mgs,lhl) = min(alphamax, c5hl*xdia(mgs,lhl,3)*1000. + c6hl)
7920 ENDIF
7921 ENDIF
7922 ENDIF
7923 ENDDO
7924 ENDIF
7925
7926
7927!
7928! Set 6th moments
7929!
7930 IF ( ipconc .ge. 6 .or. lzr > 1) THEN
7931
7932 zx(:,:) = 0.0
7933
7934! DO il = lr,lhab
7935 DO il = l1,l2
7936
7937 IF ( lz(il) .ge. 1 ) THEN
7938
7939 DO mgs = 1,ngscnt
7940 zx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),lz(il)), 0.0)
7941 ENDDO
7942
7943
7944 ENDIF
7945
7946 ENDDO
7947
7948 ENDIF
7949
7950
7951
7952
7953
7954! Find shape parameter rain
7955
7956
7957 IF ( lz(lr) > 1 .and. (ildo == 0 .or. ildo == lr ) .and. imurain == 3 ) THEN ! { RAIN SHAPE PARAM
7958 il = lr
7959 DO mgs = 1,ngscnt
7960
7961 IF ( iresetmoments == 1 .or. iresetmoments == il ) THEN
7962! IF ( .false. .and. zx(mgs,lr) <= zxmin ) THEN
7963 IF ( zx(mgs,lr) <= zxmin ) THEN
7964 qx(mgs,lr) = 0.0
7965 cx(mgs,lr) = 0.0
7966 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
7967 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
7968 an(igs(mgs),jgs,kgs(mgs),ln(lr)) = cx(mgs,lr)
7969! ELSEIF ( zx(mgs,lr) <= 0.0 .and. cx(mgs,lr) > 0.0 .and. qx(mgs,il) .gt. qxmin(il)) THEN
7970! write(91,*) 'ZF: overdepletion of Zr: z,c,q = ',zx(mgs,il),cx(mgs,il),qx(mgs,il)
7971 ELSEIF ( cx(mgs,lr) <= cxmin ) THEN
7972 zx(mgs,lr) = 0.0
7973 qx(mgs,lr) = 0.0
7974 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
7975 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
7976 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
7977 ENDIF
7978 ENDIF
7979
7980
7981
7982 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
7983
7984 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*max(1.0e-11,cx(mgs,lr)))
7985 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
7986! tmp = cx(mgs,lr)
7987! xv(mgs,lr) = xvmx(lr)
7988! cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
7989! an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
7990! IF ( tmp < cx(mgs,il) ) THEN ! breakup
7991! g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
7992!! zx(mgs,lr) = zx(mgs,lr) + g1*(rho0(mgs)/(1000.))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
7993!! an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
7994! ENDIF
7995 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
7996 xv(mgs,lr) = xvmn(lr)
7997 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
7998 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
7999 ENDIF
8000
8001 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
8002! have mass and reflectivity but no concentration, so set concentration, using default alpha
8003 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8004 z = zx(mgs,il)
8005 qr = qx(mgs,il)
8006
8007 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*1000.*1000)
8008 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8009
8010 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > cxmin ) THEN
8011! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
8012 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8013 chw = cx(mgs,il)
8014 qr = qx(mgs,il)
8015
8016! xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(1000.*Max(1.0e-9,cx(mgs,lr)))
8017! vr = xv(mgs,lr)
8018
8019! z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
8020! zx(mgs,il) = z
8021! an(igs(mgs),jy,kgs(mgs),lz(il)) = z
8022
8023 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(xdn(mgs,lr)**2*chw)
8024 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8025
8026 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
8027! How did this happen?
8028 ! set values according to dBZ of -10, or Z = 0.1
8029! write(91,*) 'alpha = ',alpha(mgs,il)
8030 IF ( qx(mgs,il) < 1.e-8 ) THEN
8031 qx(mgs,il) = 0.0
8032 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8033 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8034 ELSE
8035! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
8036 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
8037 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8038
8039 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8040 z = zx(mgs,il)
8041 qr = qx(mgs,il)
8042 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*1000.*1000)
8043 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8044 ENDIF
8045 ENDIF
8046
8047 IF ( zx(mgs,lr) > 0.0 ) THEN
8048 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(1000.*max(1.0e-9,cx(mgs,lr)))
8049 vr = xv(mgs,lr)
8050! z = 36.*(alpha(kz)+2.0)*a(ix,jy,kz,lnr)*vr**2/((alpha(kz)+1.0)*pi**2)
8051 qr = qx(mgs,lr)
8052 nrx = cx(mgs,lr)
8053 z = zx(mgs,lr)
8054
8055! xv = (db(1,kz)*a(1,1,kz,lr))**2/(a(1,1,kz,lnr))
8056! rd = z*(pi/6.*1000.)**2/xv
8057
8058! determine shape parameter alpha by iteration
8059 IF ( z .gt. 0.0 ) THEN
8060! alpha(mgs,lr) = 3.
8061 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
8062 DO i = 1,20
8063! IF ( 100.*Abs(alp - alpha(mgs,lr))/Abs(alpha(mgs,lr)) .lt. 1. ) EXIT
8064 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
8065 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
8066 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
8067! write(0,*) 'i,alp = ',i,alp
8068 alp = max( rnumin, min( rnumax, alp ) )
8069 ENDDO
8070! write(0,*) 'kz, alp, alpha(kz) = ',kz,alp,alpha(mgs,lr),qr*1000,z*1.e18,vr,nrx
8071
8072
8073! check for artificial breakup (rain larger than allowed max size)
8074 IF ( xv(mgs,il) .gt. xvmx(il) ) THEN
8075 tmp = cx(mgs,il)
8076 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
8077 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
8078 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
8079 IF ( tmp < cx(mgs,il) ) THEN ! breakup
8080
8081 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8082 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
8083 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8084
8085 vr = xv(mgs,lr)
8086 qr = qx(mgs,lr)
8087 nrx = cx(mgs,lr)
8088 z = zx(mgs,lr)
8089
8090
8091! determine shape parameter alpha by iteration
8092 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
8093 DO i = 1,20
8094 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
8095 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
8096 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
8097 alp = max( rnumin, min( rnumax, alp ) )
8098 ENDDO
8099
8100
8101 ENDIF
8102 ENDIF
8103
8104!
8105! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
8106! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
8107!
8108! IF ( alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax ) THEN
8109 IF ( .true. .and. (alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax) ) THEN
8110
8111 IF ( rescale_high_alpha .and. alp >= rnumax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
8112 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8113 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(1./(xdn(mgs,il)))**2
8114 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
8115
8116 ELSEIF ( rescale_low_alphar .and. alp <= rnumin ) THEN
8117
8118 z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
8119 zx(mgs,il) = z
8120 an(igs(mgs),jy,kgs(mgs),lz(il)) = z
8121
8122 ENDIF
8123 ENDIF
8124
8125 ENDIF
8126 ENDIF
8127
8128 ELSE
8129
8130 zx(mgs,lr) = 0.0
8131 cx(mgs,lr) = 0.0
8132 an(igs(mgs),jgs,kgs(mgs),ln(lr)) = cx(mgs,lr)
8133 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
8134
8135 ENDIF
8136
8137 ENDDO
8138 ENDIF ! }
8139
8140
8141 IF ( ipconc .ge. 6 ) THEN
8142
8143! Find shape parameters for graupel,hail
8144
8145 DO il = lr,lhab
8146
8147 IF ( lz(il) .gt. 1 .and. (ildo == 0 .or. ildo == il ) .and. ( .not. ( il == lr .and. imurain == 3 )) ) THEN
8148
8149 DO mgs = 1,ngscnt
8150
8151 IF ( iresetmoments == 1 .or. iresetmoments == il .or. iresetmoments == -1 ) THEN
8152 IF ( zx(mgs,il) <= zxmin ) THEN ! .and. qx(mgs,il) > 0.05e-3 ) THEN
8153 qx(mgs,il) = 0.0
8154 cx(mgs,il) = 0.0
8155 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8156 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8157 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8158 ELSEIF ( iresetmoments == -1 .and. qx(mgs,il) < qxmin(il) ) THEN
8159 zx(mgs,il) = 0.0
8160 cx(mgs,il) = 0.0
8161 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8162
8163 qx(mgs,il) = 0.0
8164 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8165 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8166 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8167
8168 ELSEIF ( cx(mgs,il) <= cxmin .and. iresetmoments /= -1 ) THEN ! .and. qx(mgs,il) > 0.05e-3 ) THEN
8169!! write(91,*) 'cx=0; qx,zx = ',1000.*qx(mgs,il),1.e18*zx(mgs,il)
8170 zx(mgs,il) = 0.0
8171 qx(mgs,il) = 0.0
8172 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8173 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8174 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8175 ENDIF
8176 ENDIF
8177
8178 IF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= cxmin ) THEN
8179 zx(mgs,il) = 0.0
8180 cx(mgs,il) = 0.0
8181 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8182 qx(mgs,il) = 0.0
8183 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8184 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8185 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8186 ENDIF
8187
8188 IF ( qx(mgs,il) .gt. qxmin(il) ) THEN
8189
8190 xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*max(1.0e-9,cx(mgs,il)))
8191 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
8192
8193 IF ( xv(mgs,il) .lt. xvmn(il) ) THEN
8194! tmp = cx(mgs,il)
8195 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
8196 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
8197 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
8198! IF ( tmp < cx(mgs,il) ) THEN ! breakup
8199! g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8200! & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
8201! zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
8202! an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8203!
8204! ENDIF
8205 ENDIF
8206
8207 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
8208! have mass and reflectivity but no concentration, so set concentration, using default alpha
8209 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8210 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
8211 z = zx(mgs,il)
8212 qr = qx(mgs,il)
8213 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(z*(pi*xdn(mgs,il))**2)
8214 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8215
8216 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > cxmin ) THEN
8217! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
8218 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8219 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
8220 chw = cx(mgs,il)
8221 qr = qx(mgs,il)
8222! zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
8223 zx(mgs,il) = min(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
8224 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8225 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
8226! How did this happen?
8227! write(91,*) 'ziegfall: something screwy with moments: il = ',il
8228! write(91,*) 'q,n,z = ', 1.e3*qx(mgs,il),cx(mgs,il),zx(mgs,il)
8229! write(91,*) 'alpha = ',alpha(mgs,il)
8230
8231 IF ( qx(mgs,il) < 1.e-8 ) THEN
8232 qx(mgs,il) = 0.0
8233 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8234 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8235 ELSE
8236! write(0,*) 'alpha = ',alpha(mgs,il)
8237 ! set values according to dBZ of -10
8238! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
8239 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
8240 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8241
8242 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8243 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
8244 z = zx(mgs,il)
8245 qr = qx(mgs,il)
8246 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(z*(pi*xdn(mgs,il))**2)
8247 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8248 ENDIF
8249 ENDIF
8250 ENDIF
8251
8252 IF ( qx(mgs,il) .gt. qxmin(il) .and. cx(mgs,il) .gt. cxmin ) THEN
8253 chw = cx(mgs,il)
8254 qr = qx(mgs,il)
8255 z = zx(mgs,il)
8256
8257 IF ( zx(mgs,il) .gt. 0. ) THEN
8258
8259! rd = z*(pi/6.*1000.)**2*chw/(0.224*(dn(igs(mgs),jy,kgs(mgs))*qr)**2)
8260 rd = z*(pi/6.*xdn(mgs,il))**2*chw/((dn(igs(mgs),jy,kgs(mgs))*qr)**2)
8261
8262 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
8263 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd) - 1.0
8264 DO i = 1,10
8265 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
8266 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
8267 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
8268 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd) - 1.0
8269! write(0,*) 'i,alp = ',i,alp
8270 alp = max( alphamin, min( alphamax, alp ) )
8271 ENDDO
8272
8273
8274
8275! check for artificial breakup (graupel/hail larger than allowed max size)
8276
8277 IF ( imaxdiaopt == 1 ) THEN
8278 xvbarmax = xvmx(il)
8279 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
8280 xvbarmax = xvmx(il) /((3. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
8281 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
8282 xvbarmax = xvmx(il) /((4. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
8283 ENDIF
8284
8285 IF ( xv(mgs,il) .gt. xvbarmax ) THEN
8286 tmp = cx(mgs,il)
8287 xv(mgs,il) = min( xvbarmax, max( xvmn(il),xv(mgs,il) ) )
8288 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
8289 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
8290 IF ( tmp < cx(mgs,il) ) THEN ! breakup
8291 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8292 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
8293 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
8294 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8295
8296 chw = cx(mgs,il)
8297 qr = qx(mgs,il)
8298 z = zx(mgs,il)
8299
8300 rd = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
8301 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
8302 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd) - 1.0
8303 DO i = 1,10
8304 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
8305 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
8306 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
8307 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd) - 1.0
8308 alp = max( alphamin, min( alphamax, alp ) )
8309 ENDDO
8310
8311
8312 ENDIF
8313 ENDIF
8314
8315!
8316! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
8317! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
8318!
8319 IF ( (rescale_low_alpha .or. rescale_high_alpha ) .and. &
8320 & ( alpha(mgs,il) <= alphamin .or. alp == alphamin .or. alp == alphamax ) ) THEN
8321
8322 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8323 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
8324
8325 IF ( rescale_high_alpha .and. alp >= alphamax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
8326 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(6./(pi*xdn(mgs,il)))**2
8327 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
8328
8329 ELSEIF ( rescale_low_alpha .and. alp <= alphamin .and. .not. (il == lh .and. icvhl2h > 0 ) ) THEN
8330
8331!! z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*( 0.224*qr)*qr/chw
8332 z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
8333 z = z1*(6./(pi*xdn(mgs,il)))**2
8334 zx(mgs,il) = z
8335 an(igs(mgs),jy,kgs(mgs),lz(il)) = z
8336 ENDIF
8337 ENDIF
8338 ELSE
8339 ENDIF
8340 ENDIF
8341 ENDDO ! mgs
8342
8343 ENDIF ! lz(il) .gt. 1
8344
8345 ENDDO ! il
8346
8347! CALL cld_cpu('Z-MOMENT-ZFAll')
8348
8349 ENDIF
8350
8351 IF ( lzhl > 1 ) THEN
8352 IF ( lhl .gt. 1 ) THEN
8353
8354 ENDIF
8355 ENDIF
8356
8357
8358
8359!
8360! Set density
8361!
8362 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: call setvtz'
8363!
8364
8365 call setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno,cnostmp, &
8366 & xmas,vtxbar,xdn,xvmn,xvmx,xv,cdx,cdxgs, &
8367 & ipconc,ndebugzf,ngs,nz,kgs,fadvisc, &
8368 & cwmasn,cwmasx,cwradn,cnina,cimn,cimx, &
8369 & itype1,itype2,temcg,infdo,alpha,ildo,axx,bxx)
8370! & itype1,itype2,temcg,infdo,alpha,ildo,axh,bxh,axhl,bxhl)
8371
8372
8373
8374!
8375! put fall speeds into the x-z arrays
8376!
8377 DO il = l1,l2
8378 do mgs = 1,ngscnt
8379
8380 vtmax = 150.0
8381
8382
8383 IF ( vtxbar(mgs,il,2) .gt. vtxbar(mgs,il,1) .or. &
8384 & ( vtxbar(mgs,il,1) .gt. vtxbar(mgs,il,3) .and. vtxbar(mgs,il,3) > 0.0) ) THEN
8385
8386
8387! IF ( qx(mgs,il) > 1.e-4 .and. &
8388! & .not. ( il == lr .and. 1.e3*xdia(mgs,il,3) > 5.0 ) ) THEN
8389! write(0,*) 'infdo,mgs = ',infdo,lzr,mgs
8390! write(0,*) 'Moment problem with vtxbar for il at i,j,k = ',il,igs(mgs),jy,kgs(mgs)
8391! write(0,*) 'nx,ny,nz,ng = ',nx,ny,nz,nor
8392! write(0,*) 'cwmasn,cwmasx = ',cwmasn,cwmasx
8393! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,il,1),vtxbar(mgs,il,2),vtxbar(mgs,il,3)
8394! write(0,*) 'q,n,d = ', 1.e3*qx(mgs,il),cx(mgs,il),1.e3*xdia(mgs,il,3)
8395! IF ( il .ge. lr .and. lz(il) > 1 ) write(0,*) 'z = ', zx(mgs,il)
8396! IF ( il .ge. lg .or. il == lr ) THEN
8397! write(0,*) 'alpha = ',alpha(mgs,il)
8398! ENDIF
8399! ENDIF
8400
8401 vtxbar(mgs,il,1) = max( vtxbar(mgs,il,1), vtxbar(mgs,il,2) )
8402 vtxbar(mgs,il,3) = max( vtxbar(mgs,il,3), vtxbar(mgs,il,1) )
8403
8404 ENDIF
8405
8406
8407 IF ( vtxbar(mgs,il,1) .gt. vtmax .or. vtxbar(mgs,il,2) .gt. vtmax .or. &
8408 & vtxbar(mgs,il,3) .gt. vtmax ) THEN
8409
8410! IF ( ndebugzf >= 0 .and. 1.e3*qx(mgs,il) > 0.1 ) THEN
8411! write(0,*) 'infdo = ',infdo
8412! write(0,*) 'Problem with vtxbar for il at i,j,k = ',il,igs(mgs),jy,kgs(mgs)
8413! write(0,*) 'nx,ny,nz,ng = ',nx,ny,nz,nor
8414! write(0,*) 'cwmasn,cwmasx = ',cwmasn,cwmasx
8415! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,il,1),vtxbar(mgs,il,2),vtxbar(mgs,il,3)
8416! write(0,*) 'q,n,d = ', 1.e3*qx(mgs,il),cx(mgs,il),1.e3*xdia(mgs,il,3)
8417! IF ( il .ge. lr .and. lz(il) > 1 ) write(0,*) 'z = ', zx(mgs,il)
8418! IF ( il .ge. lg ) THEN
8419! write(0,*) 'alpha = ',alpha(mgs,il)
8420! ENDIF
8421! ENDIF
8422 vtxbar(mgs,il,1) = min(vtmax,vtxbar(mgs,il,1) )
8423 vtxbar(mgs,il,2) = min(vtmax,vtxbar(mgs,il,2) )
8424 vtxbar(mgs,il,3) = min(vtmax,vtxbar(mgs,il,3) )
8425
8426! call commasmpi_abort()
8427 ENDIF
8428
8429
8430 xvt(kgs(mgs),igs(mgs),1,il) = vtxbar(mgs,il,1)
8431 xvt(kgs(mgs),igs(mgs),2,il) = vtxbar(mgs,il,2)
8432 IF ( infdo .ge. 2 ) THEN
8433 xvt(kgs(mgs),igs(mgs),3,il) = vtxbar(mgs,il,3)
8434 ELSE
8435 xvt(kgs(mgs),igs(mgs),3,il) = 0.0
8436 ENDIF
8437
8438! xvt(kgs(mgs),igs(mgs),2,il) = xvt(kgs(mgs),igs(mgs),1,il)
8439
8440 enddo
8441 ENDDO
8442
8443
8444 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: COPIED FALL SPEEDS'
8445
8446
8447
8448 9998 continue
8449
8450 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: DONE WITH LOOP'
8451
8452 if ( kz .gt. nz-1 ) then
8453 go to 1200
8454 else
8455 nzmpb = kz
8456 end if
8457
8458 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: SET NZMPB'
8459
8460 end do !! inumgs
8461
8462 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: SET NXMPB'
8463
8464 1200 continue
8465
8466
8467! ENDDO ! ix
8468! ENDDO ! kz
8469
8470
8471 if (ndebugzf .gt. 0 ) write(0,*) "ZIEGFALL: EXITING SUBROUTINE"
8472
8473
8474 RETURN
8475 END subroutine ziegfall1d
8476
8477! #####################################################################
8478! #####################################################################
8479
8480
8481! #####################################################################
8482! #####################################################################
8483
8484! ##############################################################################
8487 subroutine radardd02(nx,ny,nz,nor,na,an,temk, &
8488 & dbz,db,nzdbz,cnoh0t,hwdn1t,ipconc,ke_diag, iunit)
8489!
8490! 11.13.2005: Changed values of indices for reordering of lip
8491!
8492! 07.13.2005: Fixed an error where cnoh was being used for graupel and frozen drops
8493!
8494! 01.24.2005: add ice crystal reflectivity using parameterization of
8495! Heymsfield (JAS, 1977). Could also try Ferrier for this, too.
8496!
8497! 09.28.2002 Test alterations for dry ice following Ferrier (1994)
8498! for equivalent melted diameter reflectivity.
8499! Converted to Fortran by ERM.
8500!
8501!Date: Tue, 21 Nov 2000 10:13:36 -0600 (CST)
8502!From: Matthew Gilmore <gilmore@hesston.met.tamu.edu>
8503!
8504!PRO RF_SPEC ; Computes Radar Reflectivity
8505!COMMON MAINB, data, x1d, y1d, z1d, iconst, rconst, labels, nx, ny, nz, dshft
8506!
8507!;MODIFICATION HISTORY
8508!; 5/99 -Svelta Veleva introduces variable dielf (const_ki_x) as a (weak)
8509!; function of density. This leads to slight modification of dielf such
8510!; that the snow reflectivity is slightly increased - not a big effect.
8511!; This is believed to be more accurate than assuming the dielectric
8512!; constant for snow is the same as for hail in previous versions.
8513!
8514!;On 6/13/99 I added the VIL computation (k=0 in vil array)
8515!;On 6/15/99 I removed the number concentration dependencies as a function
8516!; of temperature (only use for ferrier!)
8517!;On 6/15/99 I added the Composite reflectivity (k=1 in VIL array)
8518!;On 6/15/99 I added the Severe Hail Index computation (k=2 in vil array)
8519!;
8520!; 6/99 - Veleva and Seo argue that since graupel is more similar to
8521!; snow (in number conc and size density) than it is to hail, we
8522!; should not weight wetted graupel with the .95 exponent correction
8523!; factor as in the case of hail. An if-statement checks the size
8524!; density for wet hail/graupel and treats them appropriately.
8525!;
8526!; 6/22/99 - Added function to compute height of max rf and 40 dbz echo top
8527!; Also added vilqr which is the model vertical integrated liquid only
8528!; using qr. Will need to check...does not seem consistent with vilZ
8529!;
8530
8531
8532 implicit none
8533
8534 character(LEN=15), parameter :: microp = 'ZVD'
8535 integer nx,ny,nz,nor,na,ngt
8536 integer nzdbz ! how many levels actually to process
8537
8538 integer ng1,n10
8539 integer iunit
8540 integer, parameter :: printyn = 0
8541
8542 parameter( ng1 = 1 )
8543
8544 real cnoh0t,hwdn1t
8545 integer ke_diag
8546 integer ipconc
8547 real vr
8548
8549
8550 integer imapz,mzdist
8551
8552 integer vzflag
8553 integer, parameter :: norz = 3
8554 real an(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,na)
8555 real db(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor) ! air density
8556! real gt(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,ngt)
8557 real temk(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor) ! air temperature (kelvin)
8558 real dbz(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor) ! reflectivity
8559 real gz(-nor+1:nz+nor) ! ,z1d(-nor+1:nz+nor,4)
8560
8561! real g,rgas,eta,inveta
8562 real cr1, cr2 , hwdnsq,swdnsq
8563 real rwdnsq, dhmin, qrmin, qsmin, qhmin, qhlmin, tfr, tfrh, zrc
8564 real reflectmin, kw_sq
8565 real const_ki_sn, const_ki_h, ki_sq_sn
8566 real ki_sq_h, dielf_sn, dielf_h
8567 real pi
8568 logical ltest
8569
8570! Other data arrays
8571 real gtmp (nx,nz)
8572 real dtmp (nx,nz)
8573 real tmp
8574
8575 real*8 dtmps, dtmpr, dtmph, dtmphl, g1, zx, ze, x
8576
8577 integer i,j,k,ix,jy,kz,ihcnt
8578
8579 real*8 xcnoh, xcnos, dadh, dads, zhdryc, zsdryc, zhwetc,zswetc
8580 real*8 dadr
8581 real dbzmax,dbzmin
8582 parameter( dbzmin = 0 )
8583
8584 real cnow,cnoi,cnoip,cnoir,cnor,cnos
8585 real cnogl,cnogm,cnogh,cnof,cnoh,cnohl
8586
8587 real swdn, rwdn ,hwdn,gldn,gmdn,ghdn,fwdn,hldn
8588 real swdn0
8589
8590 real rwdnmx,cwdnmx,cidnmx,xidnmx,swdnmx,gldnmx,gmdnmx
8591 real ghdnmx,fwdnmx,hwdnmx,hldnmx
8592 real rwdnmn,cwdnmn,cidnmn,xidnmn,swdnmn,gldnmn,gmdnmn
8593 real ghdnmn,fwdnmn,hwdnmn,hldnmn
8594
8595 real gldnsq,gmdnsq,ghdnsq,fwdnsq,hldnsq
8596
8597 real dadgl,dadgm,dadgh,dadhl,dadf
8598 real zgldryc,zglwetc,zgmdryc, zgmwetc,zghdryc,zghwetc
8599 real zhldryc,zhlwetc,zfdryc,zfwetc
8600
8601 real dielf_gl,dielf_gm,dielf_gh,dielf_hl,dielf_fw
8602
8603 integer imx,jmx,kmx
8604
8605 real swdia,gldia,gmdia,ghdia,fwdia,hwdia,hldia
8606
8607 real csw,cgl,cgm,cgh,cfw,chw,chl
8608 real xvs,xvgl,xvgm,xvgh,xvf,xvh,xvhl
8609
8610 real cwc0
8611 integer izieg
8612 integer ice10
8613 real rhos
8614 parameter( rhos = 0.1 )
8615
8616 real qxw,qxw1 ! temp value for liquid water on ice mixing ratio
8617 real :: dnsnow
8618 real qh
8619
8620 real, parameter :: cwmasn = 5.23e-13 ! minimum mass, defined by radius of 5.0e-6
8621 real, parameter :: cwmasx = 5.25e-10 ! maximum mass, defined by radius of 50.0e-6
8622 real, parameter :: cwradn = 5.0e-6 ! minimum radius
8623
8624 real cwnccn(nz)
8625
8626 real :: vzsnow, vzrain, vzgraupel, vzhail
8627 real :: ksq
8628 real :: dtp
8629
8630
8631! #########################################################################
8632
8633 vzflag = 0
8634
8635 izieg = 0
8636 ice10 = 0
8637! g=9.806 ! g: gravity constant
8638! rgas=287.04 ! rgas: gas constant for dry air
8639! rcp=rgas/cp ! rcp: gamma constant
8640! eta=0.622
8641! inveta = 1./eta
8642! rcpinv = 1./rcp
8643! cpr=cp/rgas
8644! cvr=cv/rgas
8645 pi = 4.0*atan(1.)
8646 cwc0 = piinv ! 1./pi ! 6.0/pi
8647
8648 cnoh = cnoh0t
8649 hwdn = hwdn1t
8650
8651 rwdn = 1000.0
8652 swdn = 100.0
8653
8654 qrmin = 1.0e-05
8655 qsmin = 1.0e-06
8656 qhmin = 1.0e-05
8657
8658!
8659! default slope intercepts
8660!
8661 cnow = 1.0e+08
8662 cnoi = 1.0e+08
8663 cnoip = 1.0e+08
8664 cnoir = 1.0e+08
8665 cnor = 8.0e+06
8666 cnos = 8.0e+06
8667 cnogl = 4.0e+05
8668 cnogm = 4.0e+05
8669 cnogh = 4.0e+05
8670 cnof = 4.0e+05
8671 cnohl = 1.0e+03
8672
8673
8674 imx = 1
8675 jmx = 1
8676 kmx = 1
8677 i = 1
8678
8679
8680 IF ( microp(1:4) .eq. 'ZIEG' ) THEN ! na .ge. 14 .and. ipconc .ge. 3 ) THEN
8681
8682! write(0,*) 'Set reflectivity for ZIEG'
8683 izieg = 1
8684
8685 hwdn = hwdn1t ! 500.
8686
8687
8688 cnor = cno(lr)
8689 cnos = cno(ls)
8690 cnoh = cno(lh)
8691 qrmin = qxmin(lr)
8692 qsmin = qxmin(ls)
8693 qhmin = qxmin(lh)
8694 IF ( lhl .gt. 1 ) THEN
8695 cnohl = cno(lhl)
8696 qhlmin = qxmin(lhl)
8697 ENDIF
8698
8699 ELSEIF ( microp(1:3) .eq. 'ZVD' ) THEN ! na .ge. 14 .and. ipconc .ge. 3 ) THEN
8700
8701 izieg = 1
8702
8703 swdn0 = swdn
8704
8705 cnor = cno(lr)
8706 cnos = cno(ls)
8707 cnoh = cno(lh)
8708
8709 qrmin = qxmin(lr)
8710 qsmin = qxmin(ls)
8711 qhmin = qxmin(lh)
8712 IF ( lhl .gt. 1 ) THEN
8713 cnohl = cno(lhl)
8714 qhlmin = qxmin(lhl)
8715 ENDIF
8716! 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)
8717
8718
8719 ENDIF
8720
8721
8722! cdx(lr) = 0.60
8723!
8724! IF ( lh > 1 ) THEN
8725! cdx(lh) = 0.8 ! 1.0 ! 0.45
8726! cdx(ls) = 2.00
8727! ENDIF
8728!
8729! IF ( lhl .gt. 1 ) cdx(lhl) = 0.45
8730!
8731! xvmn(lc) = xvcmn
8732! xvmn(lr) = xvrmn
8733!
8734! xvmx(lc) = xvcmx
8735! xvmx(lr) = xvrmx
8736!
8737! IF ( lh > 1 ) THEN
8738! xvmn(ls) = xvsmn
8739! xvmn(lh) = xvhmn
8740! xvmx(ls) = xvsmx
8741! xvmx(lh) = xvhmx
8742! ENDIF
8743!
8744! IF ( lhl .gt. 1 ) THEN
8745! xvmn(lhl) = xvhlmn
8746! xvmx(lhl) = xvhlmx
8747! ENDIF
8748!
8749! xdnmx(lr) = 1000.0
8750! xdnmx(lc) = 1000.0
8751! IF ( lh > 1 ) THEN
8752! xdnmx(li) = 917.0
8753! xdnmx(ls) = 300.0
8754! xdnmx(lh) = 900.0
8755! ENDIF
8756! IF ( lhl .gt. 1 ) xdnmx(lhl) = 900.0
8757!!
8758! xdnmn(:) = 900.0
8759!
8760! xdnmn(lr) = 1000.0
8761! xdnmn(lc) = 1000.0
8762! IF ( lh > 1 ) THEN
8763! xdnmn(li) = 100.0
8764! xdnmn(ls) = 100.0
8765! xdnmn(lh) = hdnmn
8766! ENDIF
8767! IF ( lhl .gt. 1 ) xdnmn(lhl) = 500.0
8768!
8769! xdn0(:) = 900.0
8770!
8771! xdn0(lc) = 1000.0
8772! xdn0(lr) = 1000.0
8773! IF ( lh > 1 ) THEN
8774! xdn0(li) = 900.0
8775! xdn0(ls) = 100.0 ! 100.0
8776! xdn0(lh) = hwdn1t ! (0.5)*(xdnmn(lh)+xdnmx(lh))
8777! ENDIF
8778! IF ( lhl .gt. 1 ) xdn0(lhl) = 800.0
8779
8780!
8781! slope intercepts
8782!
8783! cnow = 1.0e+08
8784! cnoi = 1.0e+08
8785! cnoip = 1.0e+08
8786! cnoir = 1.0e+08
8787! cnor = 8.0e+06
8788! cnos = 8.0e+06
8789! cnogl = 4.0e+05
8790! cnogm = 4.0e+05
8791! cnogh = 4.0e+05
8792! cnof = 4.0e+05
8793!c cnoh = 4.0e+04
8794! cnohl = 1.0e+03
8795!
8796!
8797! density maximums and minimums
8798!
8799 rwdnmx = 1000.0
8800 cwdnmx = 1000.0
8801 cidnmx = 917.0
8802 xidnmx = 917.0
8803 swdnmx = 200.0
8804 gldnmx = 400.0
8805 gmdnmx = 600.0
8806 ghdnmx = 800.0
8807 fwdnmx = 900.0
8808 hwdnmx = 900.0
8809 hldnmx = 900.0
8810!
8811 rwdnmn = 1000.0
8812 cwdnmn = 1000.0
8813 xidnmn = 001.0
8814 cidnmn = 001.0
8815 swdnmn = 001.0
8816 gldnmn = 200.0
8817 gmdnmn = 400.0
8818 ghdnmn = 600.0
8819 fwdnmn = 700.0
8820 hwdnmn = 700.0
8821 hldnmn = 900.0
8822
8823
8824 gldn = (0.5)*(gldnmn+gldnmx) ! 300.
8825 gmdn = (0.5)*(gmdnmn+gmdnmx) ! 500.
8826 ghdn = (0.5)*(ghdnmn+ghdnmx) ! 700.
8827 fwdn = (0.5)*(fwdnmn+fwdnmx) ! 800.
8828 hldn = (0.5)*(hldnmn+hldnmx) ! 900.
8829
8830
8831 cr1 = 7.2e+20
8832 cr2 = 7.295e+19
8833 hwdnsq = hwdn**2
8834 swdnsq = swdn**2
8835 rwdnsq = rwdn**2
8836
8837 gldnsq = gldn**2
8838 gmdnsq = gmdn**2
8839 ghdnsq = ghdn**2
8840 fwdnsq = fwdn**2
8841 hldnsq = hldn**2
8842
8843 dhmin = 0.005
8844 tfr = 273.16
8845 tfrh = tfr - 8.0
8846 zrc = cr1*cnor
8847 reflectmin = 0.0
8848 kw_sq = 0.93
8849 dbzmax = dbzmin
8850
8851 ihcnt=0
8852
8853
8854!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8855! Dielectric Factor - Formulas implemented by Svetla Veleva
8856! following Battan, "Radar Meteorology" - p. 40
8857! The result of these calculations is that the dielf numerator (ki_sq) without
8858! the density ratio is .2116 for hail if using 917 density and .25 for
8859! snow if using 220 density.
8860!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8861 const_ki_sn = 0.5 - (0.5-0.46)/(917.-220.)*(swdn-220.)
8862 const_ki_h = 0.5 - (0.5-0.46)/(917.-220.)*(hwdn-220.)
8863 ki_sq_sn = (swdnsq/rwdnsq) * const_ki_sn**2
8864 ki_sq_h = (hwdnsq/rwdnsq) * const_ki_h**2
8865 dielf_sn = ki_sq_sn / kw_sq
8866 dielf_h = ki_sq_h / kw_sq
8867
8868!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8869! Use the next line if you want to hardwire dielf for dry hail for both dry
8870! snow and dry hail.
8871! This would be equivalent to what Straka had originally. (i.e, .21/.93)
8872!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8873 dielf_sn = (swdnsq/rwdnsq)*.21/ kw_sq
8874 dielf_h = (hwdnsq/rwdnsq)*.21/ kw_sq
8875
8876 dielf_gl = (gldnsq/rwdnsq)*.21/ kw_sq
8877 dielf_gm = (gmdnsq/rwdnsq)*.21/ kw_sq
8878 dielf_gh = (ghdnsq/rwdnsq)*.21/ kw_sq
8879 dielf_hl = (hldnsq/rwdnsq)*.21/ kw_sq
8880 dielf_fw = (fwdnsq/rwdnsq)*.21/ kw_sq
8881
8882!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8883! Notes on dielectric factors - from Eun-Kyoung Seo
8884!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8885! constants for both snow and hail would be (x=s,h).....
8886! xwdnsq/rwdnsq *0.21/kw_sq ! Straka/Smith - the original
8887! xwdnsq/rwdnsq *0.224 ! Ferrier - for particle sizes in equiv. drop diam
8888! xwdnsq/rwdnsq *0.176/kw_sq ! =0.189 in Smith - for particle sizes in equiv
8889! ice spheres
8890! xwdnsq/rwdnsq *0.208/kw_sq ! Smith 1984 - for particle sizes in equiv melted drop diameter
8891!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8892
8893
8894! VIL algorithm constants
8895! Ztop = 10.**(56./10) !56 dbz is the max rf used by WATADS in cell vil
8896
8897
8898! Hail detection algorithm constants
8899! ZL = 40.
8900! ZU = 50.
8901! Ho = 3400. !WATADS Defaults
8902! Hm20 = 6200. !WATADS Defaults
8903
8904! DO kz = 1,Min(nzdbz,nz-1)
8905
8906 DO jy=1,1
8907
8908 DO kz = 1,ke_diag ! nz
8909
8910 DO ix=1,nx
8911 dbz(ix,jy,kz) = 0.0
8912
8913 vzsnow = 0.0
8914 vzrain = 0.0
8915 vzgraupel = 0.0
8916 vzhail = 0.0
8917
8918 dtmph = 0.0
8919 dtmps = 0.0
8920 dtmphl = 0.0
8921 dtmpr = 0.0
8922 dadr = (db(ix,jy,kz)/(pi*rwdn*cnor))**(0.25)
8923!-----------------------------------------------------------------------
8924! Compute Rain Radar Reflectivity
8925!-----------------------------------------------------------------------
8926
8927 dtmp(ix,kz) = 0.0
8928 gtmp(ix,kz) = 0.0
8929 IF ( an(ix,jy,kz,lr) .ge. qrmin ) THEN
8930 IF ( ipconc .le. 2 ) THEN
8931 gtmp(ix,kz) = dadr*an(ix,jy,kz,lr)**(0.25)
8932 dtmp(ix,kz) = zrc*gtmp(ix,kz)**7
8933 ELSEIF ( lzr .gt. 1 ) THEN
8934 dtmp(ix,kz) = 1e18*an(ix,jy,kz,lzr)
8935 ELSEIF ( an(ix,jy,kz,lnr) .gt. 1.e-3 ) THEN
8936 IF ( imurain == 3 ) THEN
8937 vr = db(ix,jy,kz)*an(ix,jy,kz,lr)/(1000.*an(ix,jy,kz,lnr))
8938 dtmp(ix,kz) = 3.6e18*(rnu+2.)*an(ix,jy,kz,lnr)*vr**2/(rnu+1.)
8939 ELSE ! imurain == 1
8940 g1 = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
8941 zx = g1*(db(ix,jy,kz)*an(ix,jy,kz,lr))**2/an(ix,jy,kz,lnr)
8942 ze =1.e18*zx*(6./(pi*1000.))**2 ! note: using 1000. here for water density
8943 dtmp(ix,kz) = ze
8944 ENDIF
8945 ENDIF
8946 dtmpr = dtmp(ix,kz)
8947 ENDIF
8948
8949!-----------------------------------------------------------------------
8950! Compute snow and graupel reflectivity
8951!
8952! Lou modified to look at parcel temperature rather than base state
8953!-----------------------------------------------------------------------
8954
8955 IF( lhab .gt. lr ) THEN
8956
8957! qs2d = reform(data[*,*,k,10],[nx*ny])
8958! qh2d = reform(data[*,*,k,11],[nx*ny])
8959
8960!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8961! Only use the following lines if running Straka GEMS microphysics
8962! (Sam 1-d version modified by L Wicker does not use this)
8963!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8964! ;xcnoh = cnoh*exp(-0.025*(temp-tfr))
8965! ;xcnos = cnos*exp(-0.038*(temp-tfr))
8966! ;good = where(temp GT tfr, n_elements)
8967! ;IF n_elements NE 0 THEN xcnoh(good) = cnoh*exp(-0.075*(temp(good)-tfr))
8968! ;IF n_elements NE 0 THEN xcnos(good) = cnos*exp(-0.088*(temp(good)-tfr))
8969
8970!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8971! Only use the following lines if running Ferrier micro with No=No(T)
8972!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8973! ; NOSE = -.15
8974! ; NOGE = .0
8975! ; xcnoh = cnoh*(1.>exp(NOGE*(temp-tfr)) )
8976! ; xcnos = cnos*(1.>exp(NOSE*(temp-tfr)) )
8977
8978!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8979! Use the following lines if Nos and Noh are constant
8980! (As in Svetla version of Ferrier, GCE Tao, and SAM 1-d)
8981!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8982 xcnoh = cnoh
8983 xcnos = cnos
8984
8985!
8986! Temporary fix for predicted number concentration -- need a
8987! more appropriate reflectivity equation!
8988!
8989! IF ( an(ix,jy,kz,lns) .lt. 0.1 ) THEN
8990! swdia = (xvrmn*cwc0)**(1./3.)
8991! xcnos = an(ix,jy,kz,ls)*db(ix,jy,kz)/(xvrmn*swdn*swdia)
8992! ELSE
8993! ! changed back to diameter of mean volume!!!
8994! swdia =
8995! > (an(ix,jy,kz,ls)*db(ix,jy,kz)
8996! > /(pi*swdn*an(ix,jy,kz,lns)))**(1./3.)
8997!
8998! xcnos = an(ix,jy,kz,lns)/swdia
8999! ENDIF
9000
9001 IF ( ls .gt. 1 ) THEN ! {
9002
9003 IF ( lvs .gt. 1 ) THEN
9004 IF ( an(ix,jy,kz,lvs) .gt. 0.0 ) THEN
9005 swdn = db(ix,jy,kz)*an(ix,jy,kz,ls)/an(ix,jy,kz,lvs)
9006 swdn = min( 300., max( 100., swdn ) )
9007 ELSE
9008 swdn = swdn0
9009 ENDIF
9010
9011 ENDIF
9012
9013 IF ( ipconc .ge. 5 ) THEN ! {
9014
9015 xvs = db(ix,jy,kz)*an(ix,jy,kz,ls)/ &
9016 & (swdn*max(1.0e-3,an(ix,jy,kz,lns)))
9017 IF ( xvs .lt. xvsmn .or. xvs .gt. xvsmx ) THEN
9018 xvs = min( xvsmx, max( xvsmn,xvs ) )
9019 csw = db(ix,jy,kz)*an(ix,jy,kz,ls)/(xvs*swdn)
9020 ENDIF
9021
9022 swdia = (xvs*cwc0)**(1./3.)
9023 xcnos = an(ix,jy,kz,ls)*db(ix,jy,kz)/(xvs*swdn*swdia)
9024
9025 ENDIF ! }
9026 ENDIF ! }
9027
9028! IF ( an(ix,jy,kz,lnh) .lt. 0.1 ) THEN
9029! hwdia = (xvrmn*cwc0)**(1./3.)
9030! xcnoh = an(ix,jy,kz,lh)*db(ix,jy,kz)/(xvrmn*hwdn*hwdia)
9031! ELSE
9032! ! changed back to diameter of mean volume!!!
9033! hwdia =
9034! > (an(ix,jy,kz,lh)*db(ix,jy,kz)
9035! > /(pi*hwdn*an(ix,jy,kz,lnh)))**(1./3.)
9036!
9037! xcnoh = an(ix,jy,kz,lnh)/hwdia
9038! ENDIF
9039
9040 IF ( lh .gt. 1 ) THEN ! {
9041
9042 IF ( lvh .gt. 1 ) THEN
9043 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
9044 hwdn = db(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
9045 hwdn = min( 900., max( hdnmn, hwdn ) )
9046 ELSE
9047 hwdn = 500. ! hwdn1t
9048 ENDIF
9049 ELSE
9050 hwdn = hwdn1t
9051 ENDIF
9052
9053 IF ( ipconc .ge. 5 ) THEN ! {
9054
9055 xvh = db(ix,jy,kz)*an(ix,jy,kz,lh)/ &
9056 & (hwdn*max(1.0e-3,an(ix,jy,kz,lnh)))
9057 IF ( xvh .lt. xvhmn .or. xvh .gt. xvhmx ) THEN
9058 xvh = min( xvhmx, max( xvhmn,xvh ) )
9059 chw = db(ix,jy,kz)*an(ix,jy,kz,lh)/(xvh*hwdn)
9060 ENDIF
9061
9062 hwdia = (xvh*cwc0)**(1./3.)
9063 xcnoh = an(ix,jy,kz,lh)*db(ix,jy,kz)/(xvh*hwdn*hwdia)
9064
9065 ENDIF ! } ipconc .ge. 5
9066
9067 ENDIF ! }
9068
9069 dadh = 0.0
9070 dadhl = 0.0
9071 dads = 0.0
9072 IF ( xcnoh .gt. 0.0 ) THEN
9073 dadh = ( db(ix,jy,kz) /(pi*hwdn*xcnoh) )**(.25)
9074 zhdryc = 0.224*cr2*(db(ix,jy,kz)/rwdn)**2/xcnoh ! dielf_h*cr1*xcnoh ! SV - equiv formula as before but
9075 ! ratio of densities included in
9076 ! dielf_h rather than here following
9077 ! Battan.
9078 ELSE
9079 dadh = 0.0
9080 zhdryc = 0.0
9081 ENDIF
9082
9083 IF ( xcnos .gt. 0.0 ) THEN
9084 dads = ( db(ix,jy,kz) /(pi*swdn*xcnos) )**(.25)
9085 zsdryc = 0.224*cr2*(db(ix,jy,kz)/rwdn)**2/xcnos ! dielf_sn*cr1*xcnos ! SV - similar change as above
9086 ELSE
9087 dads = 0.0
9088 zsdryc = 0.0
9089 ENDIF
9090 zhwetc = zhdryc ! cr1*xcnoh !Hail/graupel version with .95 power bug removed
9091 zswetc = zsdryc ! cr1*xcnos
9092!
9093! snow contribution
9094!
9095 IF ( ls .gt. 1 ) THEN
9096
9097 gtmp(ix,kz) = 0.0
9098 qxw = 0.0
9099 qxw1 = 0.0
9100 dtmps = 0.0
9101 IF ( an(ix,jy,kz,ls) .ge. qsmin ) THEN !{
9102 IF ( ipconc .ge. 4 ) THEN ! (Ferrier 94) !{
9103
9104 if (lsw .gt. 1) THEN
9105 qxw = an(ix,jy,kz,lsw)
9106 qxw1 = 0.0
9107 ELSEIF ( ( iusewetsnow == 1 .or. iusewetsnow == 3) .and. temk(ix,jy,kz) .gt. tfr+1. &
9108 & .and. an(ix,jy,kz,ls) > an(ix,jy,kz,lr) .and. an(ix,jy,kz,lr) > qsmin) THEN
9109 qxw = min(0.5*an(ix,jy,kz,ls), an(ix,jy,kz,lr))
9110 qxw1 = qxw
9111 ENDIF
9112
9113 vr = xvs ! db(ix,jy,kz)*an(ix,jy,kz,lr)/(1000.*an(ix,jy,kz,lnr))
9114! gtmp(ix,kz) = 3.6e18*(0.243*rhos**2/0.93)*(snu+2.)*an(ix,jy,kz,lns)*vr**2/(snu+1.)
9115
9116 ksq = 0.189 ! Smith (1984, JAMC) for equiv. ice sphere
9117 IF ( an(ix,jy,kz,lns) .gt. 1.e-7 ) THEN
9118 ! IF ( .true. ) THEN
9119 IF ( qxw > qsmin .or. iusewetsnow >= 2 ) THEN ! old version
9120! gtmp(ix,kz) = 3.6e18*(snu+2.)*( 0.224*an(ix,jy,kz,ls) + 0.776*qxw)*an(ix,jy,kz,ls)/ &
9121! & (an(ix,jy,kz,lns)*(snu+1.)*rwdn**2)*db(ix,jy,kz)**2
9122 gtmp(ix,kz) = 3.6e18*(snu+2.)*( 0.224*(an(ix,jy,kz,ls)+qxw1) + 0.776*qxw)*(an(ix,jy,kz,ls)+qxw1)/ &
9123 & (an(ix,jy,kz,lns)*(snu+1.)*rwdn**2)*db(ix,jy,kz)**2
9124
9125 ELSE ! new form using a mass relationship m = p d^2 (instead of d^3 -- Cox 1988 QJRMS) so that density depends on size
9126 ! p = 0.106214 for m = p v^(2/3)
9127 dnsnow = 0.0346159*sqrt(an(ix,jy,kz,lns)/(an(ix,jy,kz,ls)*db(ix,jy,kz)) )
9128 IF ( .true. .or. dnsnow < 900. ) THEN
9129 gtmp(ix,kz) = 1.e18*323.3226* 0.106214**2*(ksq*an(ix,jy,kz,ls) + &
9130 & (1.-ksq)*qxw)*an(ix,jy,kz,ls)*db(ix,jy,kz)**2*gsnow73/ &
9131 & (an(ix,jy,kz,lns)*(917.)**2* gsnow1*(1.0+snu)**(4./3.))
9132 ELSE ! otherwise small enough to assume ice spheres?
9133 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)/ &
9134 & (an(ix,jy,kz,lns)*(snu+1.)*rwdn**2)*db(ix,jy,kz)**2
9135 ENDIF
9136
9137 ENDIF
9138
9139 ENDIF
9140
9141! tmp = Min(1.0,1.e3*(an(ix,jy,kz,ls))*db(ix,jy,kz))
9142! gtmp(ix,kz) = Max( 1.0*gtmp(ix,kz), 750.0*(tmp)**1.98)
9143 dtmps = gtmp(ix,kz)
9144 dtmp(ix,kz) = dtmp(ix,kz) + gtmp(ix,kz)
9145 ELSE ! }{ single-moment snow:
9146 gtmp(ix,kz) = dads*an(ix,jy,kz,ls)**(0.25)
9147
9148 IF ( gtmp(ix,kz) .gt. 0.0 ) THEN !{
9149 dtmps = zsdryc*an(ix,jy,kz,ls)**2/gtmp(ix,kz)
9150 IF ( temk(ix,jy,kz) .lt. tfr ) THEN
9151 dtmp(ix,kz) = dtmp(ix,kz) + &
9152 & zsdryc*an(ix,jy,kz,ls)**2/gtmp(ix,kz)
9153 ELSE
9154 dtmp(ix,kz) = dtmp(ix,kz) + &
9155 & zswetc*an(ix,jy,kz,ls)**2/gtmp(ix,kz)
9156 ENDIF
9157 ENDIF !}
9158 ENDIF !}
9159
9160 ENDIF !}
9161
9162 ENDIF
9163
9164
9165!
9166! ice crystal contribution (Heymsfield, 1977, JAS)
9167!
9168 IF ( li .gt. 1 .and. idbzci .ne. 0 ) THEN
9169
9170 IF ( idbzci == 1 .and. lni > 0 ) THEN
9171 ! assume spherical ice with density of 900 for dbz calc
9172 IF ( an(ix,jy,kz,li) > qxmin(li) .and. an(ix,jy,kz,lni) > 1.0 ) THEN
9173 vr = db(ix,jy,kz)*an(ix,jy,kz,li)/(900.*an(ix,jy,kz,lni))
9174 dtmp(ix,kz) = dtmp(ix,kz) + &
9175 & 0.224*3.6e18*(cinu+2.)*an(ix,jy,kz,lni)*vr**2/(cinu+1.)*(900./1000.)**2
9176 ENDIF
9177
9178 ELSEIF ( idbzci == 2 ) THEN
9179!
9180! ice crystal contribution (Heymsfield, 1977, JAS)
9181!
9182 gtmp(ix,kz) = 0.0
9183 IF ( an(ix,jy,kz,li) .ge. 0.1e-3 ) THEN
9184 gtmp(ix,kz) = min(1.0,1.e3*(an(ix,jy,kz,li))*db(ix,jy,kz))
9185 dtmp(ix,kz) = dtmp(ix,kz) + 750.0*(gtmp(ix,kz))**1.98
9186 ENDIF
9187
9188 ENDIF
9189
9190 ENDIF
9191
9192!
9193! graupel/hail contribution
9194!
9195 IF ( lh .gt. 1 ) THEN ! {
9196 gtmp(ix,kz) = 0.0
9197 dtmph = 0.0
9198 qxw = 0.0
9199
9200 IF ( izieg .ge. 1 .and. ipconc .ge. 5 ) THEN
9201
9202 ltest = .false.
9203 IF ( lzh > 1 ) THEN
9204 IF ( an(ix,jy,kz,lzh) > 0.0 .and. an(ix,jy,kz,lh) > qhmin .and. &
9205 an(ix,jy,kz,lnh) >= cxmin ) ltest = .true.
9206 ENDIF
9207
9208 IF ( ltest .or. (an(ix,jy,kz,lh) .ge. qhmin .and. an(ix,jy,kz,lnh) .ge. cxmin )) THEN
9209
9210 IF ( lvh .gt. 1 ) THEN
9211
9212 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
9213 hwdn = db(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
9214 hwdn = min( 900., max( 100., hwdn ) )
9215 ELSE
9216 hwdn = 500. ! hwdn1t
9217 ENDIF
9218
9219 ENDIF
9220
9221 chw = an(ix,jy,kz,lnh)
9222 IF ( chw .gt. 0.0 ) THEN ! (Ferrier 94)
9223 xvh = db(ix,jy,kz)*an(ix,jy,kz,lh)/(hwdn*max(1.0e-3,chw))
9224 IF ( xvh .lt. xvhmn .or. xvh .gt. xvhmx ) THEN
9225 xvh = min( xvhmx, max( xvhmn,xvh ) )
9226 chw = db(ix,jy,kz)*an(ix,jy,kz,lh)/(xvh*hwdn)
9227 ENDIF
9228
9229 qh = an(ix,jy,kz,lh)
9230
9231 IF ( lhw .gt. 1 ) THEN
9232 IF ( iusewetgraupel .eq. 1 ) THEN
9233 qxw = an(ix,jy,kz,lhw)
9234 ELSEIF ( iusewetgraupel .eq. 2 ) THEN
9235 IF ( hwdn .lt. 300. ) THEN
9236 qxw = an(ix,jy,kz,lhw)
9237 ENDIF
9238 ENDIF
9239 ELSEIF ( iusewetgraupel .eq. 3 ) THEN
9240 IF ( hwdn .lt. 300. .and. temk(ix,jy,kz) > tfr .and. an(ix,jy,kz,lr) > qhmin ) THEN
9241 qxw = min( an(ix,jy,kz,lh), an(ix,jy,kz,lr))
9242 qh = qh + qxw
9243 ENDIF
9244 ELSEIF ( iusewetgraupel == 4 .and. temk(ix,jy,kz) .gt. tfr+0.25 .and. an(ix,jy,kz,lh) > an(ix,jy,kz,lr) &
9245 & .and. an(ix,jy,kz,lr) > qhmin) THEN
9246 qxw = min(0.5*an(ix,jy,kz,lh), an(ix,jy,kz,lr))
9247 qh = qh + qxw
9248
9249 ENDIF
9250
9251 IF ( lzh .gt. 1 ) THEN
9252 x = (0.224*qh + 0.776*qxw)/an(ix,jy,kz,lh) ! weighted average of dielectric const
9253 dtmph = 1.e18*x*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
9254 dtmp(ix,kz) = dtmp(ix,kz) + dtmph
9255 ELSE
9256 g1 = (6.0 + alphah)*(5.0 + alphah)*(4.0 + alphah)/((3.0 + alphah)*(2.0 + alphah)*(1.0 + alphah))
9257! zx = g1*(db(ix,jy,kz)*an(ix,jy,kz,lh))**2/chw
9258! ze = 0.224*1.e18*zx*(6./(pi*1000.))**2
9259 zx = g1*db(ix,jy,kz)**2*( 0.224*qh + 0.776*qxw)*qh/chw
9260 ze =1.e18*zx*(6./(pi*1000.))**2
9261 dtmp(ix,kz) = dtmp(ix,kz) + ze
9262 dtmph = ze
9263 ENDIF
9264
9265 ENDIF
9266
9267 ! IF ( an(ix,jy,kz,lh) .gt. 1.0e-3 ) write(0,*) 'Graupel Z : ',dtmph,ze
9268 ENDIF
9269
9270 ELSE
9271
9272 dtmph = 0.0
9273
9274 IF ( an(ix,jy,kz,lh) .ge. qhmin ) THEN
9275 gtmp(ix,kz) = dadh*an(ix,jy,kz,lh)**(0.25)
9276 IF ( gtmp(ix,kz) .gt. 0.0 ) THEN
9277 dtmph = zhdryc*an(ix,jy,kz,lh)**2/gtmp(ix,kz)
9278 IF ( temk(ix,jy,kz) .lt. tfr ) THEN
9279 dtmp(ix,kz) = dtmp(ix,kz) + &
9280 & zhdryc*an(ix,jy,kz,lh)**2/gtmp(ix,kz)
9281 ELSE
9282! IF ( hwdn .gt. 700.0 ) THEN
9283 dtmp(ix,kz) = dtmp(ix,kz) + &
9284 & zhdryc*an(ix,jy,kz,lh)**2/gtmp(ix,kz)
9285!
9286! & (zhwetc*gtmp(ix,kz)**7)**0.95
9287! ELSE
9288! dtmp(ix,kz) = dtmp(ix,kz) + zhwetc*gtmp(ix,kz)**7
9289! ENDIF
9290 ENDIF
9291 ENDIF
9292 ENDIF
9293
9294
9295
9296 ENDIF
9297
9298
9299 ENDIF ! }
9300
9301 ENDIF ! na .gt. 5
9302
9303
9304 IF ( izieg .ge. 1 .and. lhl .gt. 1 ) THEN
9305
9306 hldn = 900.0
9307 gtmp(ix,kz) = 0.0
9308 dtmphl = 0.0
9309 qxw = 0.0
9310
9311
9312 IF ( lvhl .gt. 1 ) THEN
9313 IF ( an(ix,jy,kz,lvhl) .gt. 0.0 ) THEN
9314 hldn = db(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
9315 hldn = min( 900., max( 300., hldn ) )
9316 ELSE
9317 hldn = 900.
9318 ENDIF
9319 ELSE
9320 hldn = rho_qhl
9321 ENDIF
9322
9323
9324 IF ( ipconc .ge. 5 ) THEN
9325
9326 ltest = .false.
9327 IF ( lzhl > 1 ) THEN
9328 IF ( an(ix,jy,kz,lzhl) > 0.0 .and. an(ix,jy,kz,lhl) > qhlmin .and. &
9329 an(ix,jy,kz,lnhl) > 0.0 ) ltest = .true.
9330 ENDIF
9331
9332 IF ( ltest .or. ( an(ix,jy,kz,lhl) .ge. qhlmin .and. an(ix,jy,kz,lnhl) .gt. 0.) ) THEN !{
9333 chl = an(ix,jy,kz,lnhl)
9334 IF ( chl .gt. 0.0 ) THEN !{
9335 xvhl = db(ix,jy,kz)*an(ix,jy,kz,lhl)/ &
9336 & (hldn*max(1.0e-9,an(ix,jy,kz,lnhl)))
9337 IF ( xvhl .lt. xvhlmn .or. xvhl .gt. xvhlmx ) THEN ! {
9338 xvhl = min( xvhlmx, max( xvhlmn,xvhl ) )
9339 chl = db(ix,jy,kz)*an(ix,jy,kz,lhl)/(xvhl*hldn)
9340 ! do not update state in dbz calc. ! an(ix,jy,kz,lnhl) = chl
9341 ENDIF ! }
9342
9343 IF ( lhlw .gt. 1 ) THEN
9344 IF ( iusewethail .eq. 1 ) THEN
9345 qxw = an(ix,jy,kz,lhlw)
9346 ELSEIF ( iusewethail .eq. 2 ) THEN
9347 IF ( hldn .lt. 300. ) THEN
9348 qxw = an(ix,jy,kz,lhlw)
9349 ENDIF
9350 ENDIF
9351 ENDIF
9352
9353 IF ( lzhl .gt. 1 ) THEN !{
9354 x = (0.224*an(ix,jy,kz,lhl) + 0.776*qxw)/an(ix,jy,kz,lhl) ! weighted average of dielectric const
9355 dtmphl = 1.e18*x*an(ix,jy,kz,lzhl)*(hldn/rwdn)**2
9356 dtmp(ix,kz) = dtmp(ix,kz) + dtmphl
9357 ELSE !}
9358
9359 g1 = (6.0 + alphahl)*(5.0 + alphahl)*(4.0 + alphahl)/((3.0 + alphahl)*(2.0 + alphahl)*(1.0 + alphahl))
9360 zx = g1*db(ix,jy,kz)**2*( 0.224*an(ix,jy,kz,lhl) + 0.776*qxw)*an(ix,jy,kz,lhl)/chl
9361! zx = g1*(db(ix,jy,kz)*an(ix,jy,kz,lhl))**2/chl
9362 ze = 1.e18*zx*(6./(pi*1000.))**2 ! 3/28/2016 removed extra factor of 0.224
9363 dtmp(ix,kz) = dtmp(ix,kz) + ze
9364 dtmphl = ze
9365
9366 ENDIF !}
9367 endif!}
9368 ! IF ( an(ix,jy,kz,lh) .gt. 1.0e-3 ) write(0,*) 'Graupel Z : ',dtmph,ze
9369 ENDIF
9370
9371
9372 ELSE
9373
9374
9375 IF ( an(ix,jy,kz,lhl) .ge. qhlmin ) THEN ! {
9376 dadhl = ( db(ix,jy,kz) /(pi*hldn*cnohl) )**(.25)
9377 gtmp(ix,kz) = dadhl*an(ix,jy,kz,lhl)**(0.25)
9378 IF ( gtmp(ix,kz) .gt. 0.0 ) THEN ! {
9379
9380 zhldryc = 0.224*cr2*( db(ix,jy,kz)/rwdn)**2/cnohl
9381
9382 dtmphl = zhldryc*an(ix,jy,kz,lhl)**2/gtmp(ix,kz)
9383
9384 IF ( temk(ix,jy,kz) .lt. tfr ) THEN
9385 dtmp(ix,kz) = dtmp(ix,kz) + &
9386 & zhldryc*an(ix,jy,kz,lhl)**2/gtmp(ix,kz)
9387 ELSE
9388! IF ( hwdn .gt. 700.0 ) THEN
9389 dtmp(ix,kz) = dtmp(ix,kz) + &
9390 & zhldryc*an(ix,jy,kz,lhl)**2/gtmp(ix,kz)
9391!
9392! : (zhwetc*gtmp(ix,kz)**7)**0.95
9393! ELSE
9394! dtmp(ix,kz) = dtmp(ix,kz) + zhwetc*gtmp(ix,kz)**7
9395! ENDIF
9396 ENDIF
9397 ENDIF ! }
9398
9399 ENDIF ! }
9400
9401 ENDIF ! ipconc .ge. 5
9402
9403
9404 ENDIF ! izieg .ge. 1 .and. lhl .gt. 1
9405
9406
9407
9408 IF ( dtmp(ix,kz) .gt. 0.0 ) THEN
9409 dbz(ix,jy,kz) = max(dbzmin, 10.0*log10(dtmp(ix,kz)) )
9410
9411 IF ( dbz(ix,jy,kz) .gt. dbzmax ) THEN
9412 dbzmax = max(dbzmax,dbz(ix,jy,kz))
9413 imx = ix
9414 jmx = jy
9415 kmx = kz
9416 ENDIF
9417 ELSE
9418 dbz(ix,jy,kz) = dbzmin
9419 IF ( lh > 1 .and. lhl > 1) THEN
9420 IF ( an(ix,jy,kz,lh) > 1.0e-3 ) THEN
9421 write(0,*) 'radardbz: qr,qh,qhl = ',an(ix,jy,kz,lr), an(ix,jy,kz,lh),an(ix,jy,kz,lhl)
9422 write(0,*) 'radardbz: dtmps,dtmph,dadh,dadhl,dtmphl = ',dtmps,dtmph,dadh,dadhl,dtmphl
9423
9424 IF ( lzh>1 .and. lzhl>1 ) write(0,*) 'radardbz: zh, zhl = ',an(ix,jy,kz,lzh),an(ix,jy,kz,lzhl)
9425 ENDIF
9426 ENDIF
9427 ENDIF
9428
9429! IF ( an(ix,jy,kz,lh) .gt. 1.e-4 .and.
9430! & dbz(ix,jy,kz) .le. 0.0 ) THEN
9431! write(0,*) 'dbz = ',dbz(ix,jy,kz)
9432! write(0,*) 'Hail intercept: ',xcnoh,ix,kz
9433! write(0,*) 'Hail,snow q: ',an(ix,jy,kz,lh),an(ix,jy,kz,ls)
9434! write(0,*) 'Hail,snow c: ',an(ix,jy,kz,lnh),an(ix,jy,kz,lns)
9435! write(0,*) 'dtmps,dtmph = ',dtmps,dtmph
9436! ENDIF
9437 IF ( .not. dtmp(ix,kz) .lt. 1.e30 .or. dbz(ix,jy,kz) > 190.0 ) THEN
9438! IF ( ix == 31 .and. kz == 20 .and. jy == 23 ) THEN
9439! write(0,*) 'my_rank = ',my_rank
9440 write(0,*) 'ix,jy,kz = ',ix,jy,kz
9441 write(0,*) 'dbz = ',dbz(ix,jy,kz)
9442 write(0,*) 'db, zhdryc = ',db(ix,jy,kz),zhdryc
9443 write(0,*) 'Hail intercept: ',xcnoh,ix,kz
9444 write(0,*) 'Hail,snow q: ',an(ix,jy,kz,lh),an(ix,jy,kz,ls)
9445 write(0,*) 'graupel density hwdn = ',hwdn
9446 write(0,*) 'rain q: ',an(ix,jy,kz,lr)
9447 write(0,*) 'ice q: ',an(ix,jy,kz,li)
9448 IF ( lhl .gt. 1 ) write(0,*) 'Hail (lhl): ',an(ix,jy,kz,lhl)
9449 IF (ipconc .ge. 3 ) write(0,*) 'rain c: ',an(ix,jy,kz,lnr)
9450 IF ( lzr > 1 ) write(0,*) 'rain Z: ',an(ix,jy,kz,lzr)
9451 IF ( ipconc .ge. 5 ) THEN
9452 write(0,*) 'Hail,snow c: ',an(ix,jy,kz,lnh),an(ix,jy,kz,lns)
9453 IF ( lhl .gt. 1 ) write(0,*) 'Hail (lnhl): ',an(ix,jy,kz,lnhl)
9454 IF ( lzhl .gt. 1 ) THEN
9455 write(0,*) 'Hail (lzhl): ',an(ix,jy,kz,lzhl)
9456 write(0,*) 'chl,xvhl,dhl = ',chl,xvhl,(xvhl*6./3.14159)**(1./3.)
9457 write(0,*) 'xvhlmn,xvhlmx = ',xvhlmn,xvhlmx
9458 ENDIF
9459 ENDIF
9460 write(0,*) 'chw,xvh = ', chw,xvh
9461 write(0,*) 'dtmps,dtmph,dadh,dadhl,dtmphl = ',dtmps,dtmph,dadh,dadhl,dtmphl
9462 write(0,*) 'dtmpr = ',dtmpr
9463 write(0,*) 'gtmp = ',gtmp(ix,kz),dtmp(ix,kz)
9464 IF ( .not. (dbz(ix,jy,kz) .gt. -100 .and. dbz(ix,jy,kz) .lt. 200 ) ) THEN
9465 write(0,*) 'dbz out of bounds!'
9466 ENDIF
9467 ENDIF
9468
9469
9470 ENDDO ! ix
9471 ENDDO ! kz
9472 ENDDO ! jy
9473
9474
9475
9476
9477! write(0,*) 'na,lr = ',na,lr
9478 IF ( printyn .eq. 1 ) THEN
9479! IF ( dbzmax .gt. dbzmin ) THEN
9480 write(iunit,*) 'maxdbz,ijk = ',dbzmax,imx,jmx,kmx
9481 write(iunit,*) 'qrw = ',an(imx,jmx,kmx,lr)
9482
9483 IF ( lh .gt. 1 ) THEN
9484 write(iunit,*) 'qi = ',an(imx,jmx,kmx,li)
9485 write(iunit,*) 'qsw = ',an(imx,jmx,kmx,ls)
9486 write(iunit,*) 'qhw = ',an(imx,jmx,kmx,lh)
9487 IF ( lhl .gt. 1 ) write(iunit,*) 'qhl = ',an(imx,jmx,kmx,lhl)
9488 ENDIF
9489
9490
9491 ENDIF
9492
9493
9494 RETURN
9495 END subroutine radardd02
9496
9497
9498! ##############################################################################
9499! ##############################################################################
9500
9501
9504! #####################################################################
9505! #####################################################################
9506!
9507! Subroutine for explicit cloud condensation and droplet nucleation
9508!
9509! 11/30/2022: Fixed droplet evaporation heating term for CM1 eqtset=2 (was only doing eqtset=1)
9510!
9511 SUBROUTINE nucond &
9512 & (nx,ny,nz,na,jyslab &
9513 & ,nor,norz,dtp,nxi &
9514 & ,dz3d &
9515 & ,t0,t9 &
9516 & ,an,dn,p2 &
9517 & ,pn,w &
9518 & ,ngs &
9519 & ,axtra,io_flag &
9520 & ,ssfilt,t00,t77,flag_qndrop &
9521 & )
9522
9523
9524 implicit none
9525
9526! real :: cwmasn = 1000.*0.523599*(2.*2.e-6)**3
9527 integer :: nx,ny,nz,na,nxi
9528 integer :: nor,norz, jyslab ! ,nht,ngt,igsr
9529 real :: dtp ! time step
9530 logical :: flag_qndrop
9531
9532 integer, parameter :: ng1 = 1
9533
9534
9535!
9536! external temporary arrays
9537!
9538 real t00(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9539 real t77(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9540
9541 real t0(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9542! real t1(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9543! real t2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9544! real t3(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9545! real t4(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9546! real t5(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9547! real t6(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9548! real t7(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9549! real t8(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9550 real t9(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9551
9552
9553 real p2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz) ! perturbation Pi
9554 real pn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9555 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
9556 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9557
9558 real w(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9559! real qv(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9560
9561 real ssfilt(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9562
9563
9564 real pb(-norz+ng1:nz+norz)
9565 real pinit(-norz+ng1:nz+norz)
9566
9567 real dz3d(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9568
9569
9570 ! local
9571
9572
9573 real axtra(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz,nxtra)
9574 logical :: io_flag
9575
9576 real :: dv
9577 real :: ccnefactwo, sstmp, cn1, cnuctmp
9578
9579!
9580! declarations microphysics and for gather/scatter
9581!
9582 real, parameter :: cwmas30 = 1000.*0.523599*(2.*30.e-6)**3 ! mass of 30-micron radius droplet, for sat. adj.
9583 real, parameter :: cwmas20 = 1000.*0.523599*(2.*20.e-6)**3 ! mass of 20-micron radius droplet, for sat. adj.
9584 integer nxmpb,nzmpb,nxz
9585 integer mgs,ngs,numgs,inumgs
9586 integer ngscnt,igs(ngs),kgs(ngs)
9587 integer kgsp(ngs),kgsm(ngs)
9588 integer nsvcnt
9589
9590 integer ix,kz,i,n, kp1, km1
9591 integer :: jy, jgs
9592 integer ixb,ixe,jyb,jye,kzb,kze
9593
9594 integer itile,jtile,ktile
9595 integer ixend,jyend,kzend,kzbeg
9596 integer nxend,nyend,nzend,nzbeg
9597
9598!
9599! Variables for Ziegler warm rain microphysics
9600!
9601
9602
9603 real ccnc(ngs), ccna(ngs), cnuc(ngs), cwnccn(ngs)
9604 real :: ccnc_nu(ngs), ccnc_ac(ngs), ccnc_co(ngs)
9605 real ccncuf(ngs)
9606 real sscb ! 'cloud base' SS threshold
9607 parameter( sscb = 2.0 )
9608 integer idecss ! flag to turn on (=1) decay of ssmax when no cloud or ice crystals
9609 parameter( idecss = 1 )
9610 integer iba ! flag to do condensation/nucleation in 1st or 2nd loop
9611 ! =0 to use ad to calculate SS
9612 ! =1 to use an at end of main jy loop to calculate SS
9613 parameter(iba = 1)
9614 integer ifilt ! =1 to filter ssat, =0 to set ssfilt=ssat
9615 parameter( ifilt = 0 )
9616 real temp1,temp2 ! ,ssold
9617 real :: ssmax(ngs) ! maximum SS experienced by a parcel
9618 real ssmx
9619 real dnnet,dqnet
9620! real cnu,rnu,snu,cinu
9621! parameter ( cnu = 0.0, rnu = -0.8, snu = -0.8, cinu = 0.0 )
9622 real ventrx(ngs)
9623 real ventrxn(ngs)
9624 real volb, t2s
9625 real, parameter :: aa1 = 9.44e15, aa2 = 5.78e3 ! a1 in Ziegler
9626
9627 real ec0, ex1, ft, rhoinv(ngs)
9628
9629 real chw, g1, rd1
9630
9631 real ac1,bc, taus, c1,d1,e1,f1,p380,tmp,tmp2 ! , sstdy, super
9632 real tmpmx, fw, qctmp
9633 real x,y,del,r,alpr
9634 double precision :: vent1,vent2
9635 real g1palp
9636 real bs
9637 real v1, v2
9638 real d1r, d1i, d1s, e1i
9639 integer nc ! condensation step
9640 real dtcon,dtcon1,dtcon2 ! condensation time step (dtcon*nc = dtp)
9641 real delta
9642 integer ltemq1,ltemq1m ! ,ltemq1m2
9643 real dqv,qv1,ss1,ss2,qvs1,dqvs,dtemp,dt1 ! temporaries for condensation
9644
9645 real ssi1, ssi2, dqvi, dqvis, dqvii,qis1
9646 real dqvr, dqc, dqr, dqi, dqs
9647 real qv1m,qvs1m,ss1m,ssi1m,qis1m
9648 real cwmastmp
9649 real dcloud,dcloud2 ! ,as, bs
9650 real dcrit
9651 real cn(ngs), cnuf(ngs)
9652 real :: ccwmax
9653
9654 integer ltemq
9655
9656 integer il
9657
9658 real es(ngs) ! ss(ngs),
9659! real eis(ngs)
9660 real ssf(ngs),ssfkp1(ngs),ssfkm1(ngs),ssat0(ngs)
9661 real, parameter :: ssfcut = 4.0
9662 real ssfjp1(ngs),ssfjm1(ngs)
9663 real ssfip1(ngs),ssfim1(ngs)
9664
9665 real supcb, supmx
9666 parameter(supcb=0.5,supmx=238.0)
9667 real r2dxm, r2dym, r2dzm
9668 real dssdz, dssdy, dssdx
9669! real tqvcon
9670 real epsi,d
9671 parameter(epsi = 0.622, d = 0.266)
9672 real r1,qevap ! ,slv
9673
9674 real vr,nrx,qr,z1,z2,rdi,alp,xnutmp,xnuc
9675 real ctmp, ccwtmp
9676 real f5, qvs0 ! Kessler condensation factor
9677 real :: t0p1, t0p3
9678 real qvex
9679
9680! real, dimension(ngs) :: temp, tempc, elv, elf, els, pqs, theta, temg, temcg
9681 real dqvcnd(ngs),dqwv(ngs),dqcw(ngs),dqci(ngs)
9682 real temp(ngs),tempc(ngs)
9683 real temg(ngs),temcg(ngs),theta(ngs),qvap(ngs) ! ,tembzg(ngs)
9684 real temgx(ngs),temcgx(ngs)
9685 real qvs(ngs),qis(ngs),qss(ngs),pqs(ngs)
9686 real felv(ngs),felf(ngs),fels(ngs)
9687 real felvcp(ngs),felvpi(ngs)
9688 real gamw(ngs),gams(ngs) ! qciavl(ngs),
9689 real tsqr(ngs),ssi(ngs),ssw(ngs)
9690 real cc3(ngs),cqv1(ngs),cqv2(ngs)
9691 real qcwtmp(ngs),qtmp
9692
9693 real fvent(ngs) !,fraci(ngs),fracl(ngs)
9694 real fwvdf(ngs),ftka(ngs),fthdf(ngs)
9695 real fadvisc(ngs),fakvisc(ngs)
9696 real fci(ngs),fcw(ngs)
9697 real fschm(ngs),fpndl(ngs)
9698
9699 real pres(ngs),pipert(ngs)
9700 real pk(ngs)
9701 real rho0(ngs),pi0(ngs)
9702 real rhovt(ngs)
9703 real thetap(ngs),theta0(ngs),qwvp(ngs),qv0(ngs)
9704 real thsave(ngs)
9705 real qss0(ngs)
9706 real fcqv1(ngs)
9707 real wvel(ngs),wvelkm1(ngs)
9708
9709 real wvdf(ngs),tka(ngs)
9710 real advisc(ngs)
9711
9712 real rwvent(ngs)
9713
9714
9715 real :: qx(ngs,lv:lhab)
9716 real :: cx(ngs,lc:lhab)
9717 real :: xv(ngs,lc:lhab)
9718 real :: xmas(ngs,lc:lhab)
9719 real :: xdn(ngs,lc:lhab)
9720 real :: xdia(ngs,lc:lhab,3)
9721 real :: alpha(ngs,lc:lhab)
9722 real :: zx(ngs,lr:lhab)
9723
9724
9725 logical zerocx(lc:lqmx)
9726
9727 logical :: lprint
9728
9729 integer, parameter :: iunit = 0
9730
9731 real :: frac, hwdn, tmpg
9732
9733 real :: cvm,cpm,rmm
9734
9735 real, parameter :: cpv = 1885.0 ! specific heat of water vapor at constant pressure
9736
9737 integer :: kstag
9738
9739 integer :: count
9740
9741! -------------------------------------------------------------------------------
9742 itile = nxi
9743 jtile = ny
9744 ktile = nz
9745 ixend = nxi
9746 jyend = ny
9747 kzend = nz
9748 nxend = nxi + 1
9749 nyend = ny + 1
9750 nzend = nz
9751 kzbeg = 1
9752 nzbeg = 1
9753
9754 IF ( ac_opt > 0 ) ccnefactwo = (1.63e-3/(cck * beta(3./2., cck/2.)))**(1.0/(cck + 2.0))
9755 f5 = 237.3 * 17.27 * 2.5e6 / cp ! combined constants for rain condensation (Soong and Ogura 73)
9756
9757 jy = 1
9758 kstag = 0
9759 pb(:) = 0.0
9760 pinit(:) = 0.0
9761
9762 IF ( ipconc <= 1 .or. isedonly == 2 ) GOTO 2200
9763
9764!
9765! Ziegler nucleation
9766!
9767
9768! ssfilt(:,:,:) = 0.0
9769 ssmx = 0
9770 count = 0
9771
9772 do kz = 1,nz-kstag
9773 do ix = 1,nxi
9774
9775 temp1 = an(ix,jy,kz,lt)*t77(ix,jy,kz)
9776 t0(ix,jy,kz) = temp1
9777 ltemq = int( (temp1-163.15)/fqsat+1.5 )
9778 ltemq = min( nqsat, max(1,ltemq) )
9779
9780 c1 = t00(ix,jy,kz)*tabqvs(ltemq)
9781
9782 IF ( c1 > 0. ) THEN
9783 ssfilt(ix,jy,kz) = 100.*(an(ix,jy,kz,lv)/c1 - 1.0) ! from "new" values
9784 ENDIF
9785
9786 ENDDO
9787 ENDDO
9788
9789
9790!
9791! jy = 1 ! working on a 2d slab
9792!! VERY IMPORTANT: SET jgs = jy
9793
9794 jgs = jy
9795
9796!
9797!..Gather microphysics
9798!
9799 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: Gather stage'
9800
9801 nxmpb = 1
9802 nzmpb = 1
9803 nxz = nxi*nz
9804 numgs = nxz/ngs + 1
9805
9806
9807 do 2000 inumgs = 1,numgs
9808
9809 ngscnt = 0
9810
9811
9812 kzb = nzmpb
9813 kze = nz-kstag
9814 ! if (kzbeg .le. nzmpb .and. kzend .gt. nzmpb) kzb = nzmpb
9815
9816 ixb = nxmpb
9817 ixe = itile
9818
9819 do kz = kzb,kze
9820 do ix = nxmpb,nxi
9821
9822 pqs(1) = 380.0/(pn(ix,jy,kz) + pb(kz))
9823 theta(1) = an(ix,jy,kz,lt)
9824 temg(1) = t0(ix,jy,kz)
9825
9826 temcg(1) = temg(1) - tfr
9827 ltemq = (temg(1)-163.15)/fqsat+1.5
9828 ltemq = min( nqsat, max(1,ltemq) )
9829 qvs(1) = pqs(1)*tabqvs(ltemq)
9830 qis(1) = pqs(1)*tabqis(ltemq)
9831
9832 qss(1) = qvs(1)
9833
9834
9835 if ( temg(1) .lt. tfr ) then
9836 end if
9837!
9838 if ( (temg(1) .gt. tfrh .or. an(ix,jy,kz,lv)/qvs(1) > maxlowtempss ) .and. &
9839 & ( an(ix,jy,kz,lv) .gt. qss(1) .or. &
9840 & an(ix,jy,kz,lc) .gt. qxmin(lc) .or. &
9841 & ( an(ix,jy,kz,lr) .gt. qxmin(lr) .and. rcond == 2 ) &
9842 & )) then
9843 ngscnt = ngscnt + 1
9844 igs(ngscnt) = ix
9845 kgs(ngscnt) = kz
9846 if ( ngscnt .eq. ngs ) goto 2100
9847 end if
9848
9849 end do !ix
9850
9851 nxmpb = 1
9852 end do !kz
9853! if ( jy .eq. (ny-jstag) ) iend = 1
9854 2100 continue
9855
9856 if ( ngscnt .eq. 0 ) go to 29998
9857
9858 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: dbg = 8'
9859
9860! write(0,*) 'NUCOND: dbg = 8, ngscnt,ssmx = ',ngscnt,ssmx
9861
9862
9863 qx(:,:) = 0.0
9864 cx(:,:) = 0.0
9865 zx(:,:) = 0.0
9866
9867 xv(:,:) = 0.0
9868 xmas(:,:) = 0.0
9869
9870 IF ( imurain == 1 ) THEN
9871 alpha(:,lr) = alphar
9872 ELSEIF ( imurain == 3 ) THEN
9873 alpha(:,lr) = xnu(lr)
9874 ENDIF
9875
9876!
9877! define temporaries for state variables to be used in calculations
9878!
9879 DO mgs = 1,ngscnt
9880 qx(mgs,lv) = an(igs(mgs),jy,kgs(mgs),lv)
9881 DO il = lc,lhab
9882 qx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),il), 0.0)
9883 ENDDO
9884
9885 qcwtmp(mgs) = qx(mgs,lc)
9886
9887
9888 theta0(mgs) = an(igs(mgs),jy,kgs(mgs),lt) !
9889 thetap(mgs) = 0.0
9890 theta(mgs) = an(igs(mgs),jy,kgs(mgs),lt)
9891 qv0(mgs) = qx(mgs,lv)
9892 qwvp(mgs) = qx(mgs,lv) - qv0(mgs)
9893
9894 pres(mgs) = pn(igs(mgs),jy,kgs(mgs)) + pb(kgs(mgs))
9895 pipert(mgs) = p2(igs(mgs),jy,kgs(mgs))
9896 rho0(mgs) = dn(igs(mgs),jy,kgs(mgs))
9897 rhoinv(mgs) = 1.0/rho0(mgs)
9898 rhovt(mgs) = sqrt(rho00/rho0(mgs))
9899 pi0(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs))
9900 temg(mgs) = t0(igs(mgs),jy,kgs(mgs))
9901! pk(mgs) = t77(igs(mgs),jy,kgs(mgs)) ! ( pres(mgs) / poo ) ** cap
9902 pk(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs)) ! t77(igs(mgs),jy,kgs(mgs))
9903 temcg(mgs) = temg(mgs) - tfr
9904 qss0(mgs) = (380.0)/(pres(mgs))
9905 pqs(mgs) = (380.0)/(pres(mgs))
9906 ltemq = (temg(mgs)-163.15)/fqsat+1.5
9907 ltemq = min( nqsat, max(1,ltemq) )
9908 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
9909 qis(mgs) = pqs(mgs)*tabqis(ltemq)
9910!
9911 qvap(mgs) = max( (qwvp(mgs) + qv0(mgs)), 0.0 )
9912 es(mgs) = 6.1078e2*tabqvs(ltemq)
9913 qss(mgs) = qvs(mgs)
9914
9915
9916 temgx(mgs) = min(temg(mgs),313.15)
9917 temgx(mgs) = max(temgx(mgs),233.15)
9918 felv(mgs) = 2500837.367 * (273.15/temgx(mgs))**((0.167)+(3.67e-4)*temgx(mgs))
9919!
9920 IF ( eqtset <= 1 ) THEN
9921 felvcp(mgs) = felv(mgs)*cpi
9922 ELSE ! equation set 2 in cm1
9923 tmp = qx(mgs,li)+qx(mgs,ls)+qx(mgs,lh)
9924 IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
9925 IF ( lf > 1 ) tmp = tmp + qx(mgs,lf)
9926 cvm = cv+cvv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
9927 +cpigb*(tmp)
9928 cpm = cp+cpv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
9929 +cpigb*(tmp)
9930 rmm=rd+rw*qx(mgs,lv)
9931
9932 IF ( eqtset == 2 ) THEN
9933
9934 felvcp(mgs) = (felv(mgs)-rw*temg(mgs))/cvm
9935
9936 ELSE
9937 felvcp(mgs) = (felv(mgs)*cv/(cp) - rw*temg(mgs)*(1.0-rovcp*cpm/rmm))/cvm
9938 felvpi(mgs) = pi0(mgs)*rovcp*(felv(mgs)/(temg(mgs)) - rw*cpm/rmm)/cvm
9939 ENDIF
9940
9941 ENDIF
9942
9943 temcgx(mgs) = min(temg(mgs),273.15)
9944 temcgx(mgs) = max(temcgx(mgs),223.15)
9945 temcgx(mgs) = temcgx(mgs)-273.15
9946 felf(mgs) = 333690.6098 + (2030.61425)*temcgx(mgs) - (10.46708312)*temcgx(mgs)**2
9947!
9948 fels(mgs) = felv(mgs) + felf(mgs)
9949 fcqv1(mgs) = 4098.0258*felv(mgs)*cpi
9950
9951 wvdf(mgs) = (2.11e-05)*((temg(mgs)/tfr)**1.94)* &
9952 & (101325.0/(pb(kgs(mgs)) + pn(igs(mgs),jgs,kgs(mgs)))) ! diffusivity of water vapor, Hall and Pruppacher (76)
9953 advisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))* &
9954 & (temg(mgs)/296.0)**(1.5) ! dynamic viscosity (SMT; see Beard & Pruppacher 71)
9955 tka(mgs) = tka0*advisc(mgs)/advisc1 ! thermal conductivity
9956
9957
9958 ENDDO
9959
9960
9961
9962!
9963! load concentrations
9964!
9965 if ( ipconc .ge. 1 ) then
9966 do mgs = 1,ngscnt
9967 cx(mgs,li) = max(an(igs(mgs),jy,kgs(mgs),lni), 0.0)
9968 end do
9969 end if
9970 if ( ipconc .ge. 2 ) then
9971 do mgs = 1,ngscnt
9972 cx(mgs,lc) = max(an(igs(mgs),jy,kgs(mgs),lnc), 0.0)
9973 cwnccn(mgs) = cwccn*rho0(mgs)/rho00 ! background ccn count
9974 cn(mgs) = 0.0
9975 IF ( lss > 1 ) THEN
9976 ssmax(mgs) = an(igs(mgs),jy,kgs(mgs),lss)
9977 ELSE
9978 ssmax(mgs) = 0.0
9979 ENDIF
9980 IF ( lccn .gt. 1 .and. ac_opt == 0 ) THEN
9981 IF ( lccnuf .gt. 1 .and. i_uf_or_ccn > 0 ) THEN
9982 ccnc(mgs) = an(igs(mgs),jy,kgs(mgs),lccn) + an(igs(mgs),jy,kgs(mgs),lccnuf)
9983 ELSE
9984 ccnc(mgs) = an(igs(mgs),jy,kgs(mgs),lccn)
9985 ENDIF
9986 ELSE
9987 ccnc(mgs) = cwnccn(mgs)
9988 ENDIF
9989 IF ( lccnuf .gt. 1 .and. i_uf_or_ccn == 0 ) THEN
9990 ccncuf(mgs) = an(igs(mgs),jy,kgs(mgs),lccnuf)
9991 ELSE
9992 ccncuf(mgs) = 0.0
9993 ENDIF
9994 cnuf(mgs) = 0.0
9995 IF ( lccna > 1 ) THEN
9996 ccna(mgs) = an(igs(mgs),jy,kgs(mgs),lccna) ! predicted count of activated ccn
9997 ELSE
9998 IF ( lccn > 1 ) THEN
9999 ccna(mgs) = cwnccn(mgs) - ccnc(mgs) ! diagnose activated ccn as background value - remaining unactivated ccn
10000 ELSE
10001 ccna(mgs) = cx(mgs,lc) ! approximation of number of activated ccn
10002 ENDIF
10003 ENDIF
10004 end do
10005 end if
10006 if ( ipconc .ge. 3 ) then
10007 do mgs = 1,ngscnt
10008 cx(mgs,lr) = max(an(igs(mgs),jy,kgs(mgs),lnr), 0.0)
10009 end do
10010 end if
10011
10012! cnuc(1:ngscnt) = cwccn*rho0(mgs)/rho00*(1. - renucfrac) + ccnc(1:ngscnt)*renucfrac
10013 DO mgs = 1,ngscnt
10014 ! default value of renucfrac is 0.0
10015 IF ( irenuc /= 6 ) THEN
10016 cnuc(mgs) = max(ccnc(mgs),cwnccn(mgs))*(1. - renucfrac) + ccnc(mgs)*renucfrac
10017 ELSE
10018 cnuc(mgs) = max(ccnc(mgs),cwnccn(mgs))*(1. - renucfrac) + max(0.0,ccnc(mgs) - ccna(mgs))*renucfrac
10019 ENDIF
10020 IF ( renucfrac >= 0.999 ) THEN
10021 IF ( temg(mgs) < 265. ) THEN
10022 IF ( qx(mgs,lc) > 10.*qxmin(lc) .and. w(igs(mgs),jgs,kgs(mgs)) > 2.0 ) THEN
10023 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
10024 ELSE
10025 cnuc(mgs) = 0.1*cnuc(mgs)
10026 ENDIF
10027 ENDIF
10028 ENDIF
10029 ENDDO
10030
10031! Set density
10032!
10033 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: Set density'
10034
10035 do mgs = 1,ngscnt
10036 xdn(mgs,lc) = xdn0(lc)
10037 xdn(mgs,lr) = xdn0(lr)
10038 end do
10039
10040 ventrx(:) = ventr
10041 ventrxn(:) = ventrn
10042
10043
10044! Find shape parameter rain
10045
10046 IF ( lzr > 1 .and. rcond == 2 ) THEN ! { RAIN SHAPE PARAM
10047 DO mgs = 1,ngscnt
10048 zx(mgs,lr) = max(an(igs(mgs),jy,kgs(mgs),lzr), 0.0)
10049 ENDDO
10050
10051! CALL cld_cpu('Z-MOMENT-1r2')
10052 il = lr
10053 DO mgs = 1,ngscnt
10054
10055 IF ( zx(mgs,il) <= zxmin ) THEN
10056 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
10057 qx(mgs,il) = 0.0
10058 cx(mgs,il) = 0.0
10059 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
10060 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
10061 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
10062 ELSEIF ( cx(mgs,il) <= 0.0 ) THEN
10063 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
10064 zx(mgs,il) = 0.0
10065 qx(mgs,il) = 0.0
10066 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
10067 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
10068 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
10069 ENDIF
10070
10071 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
10072
10073 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*max(1.0e-11,cx(mgs,lr)))
10074 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
10075 xv(mgs,lr) = xvmx(lr)
10076 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
10077 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
10078 xv(mgs,lr) = xvmn(lr)
10079 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
10080 ENDIF
10081
10082 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
10083! have mass and reflectivity but no concentration, so set concentration, using default alpha
10084 IF ( imurain == 3 ) THEN
10085 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10086 z1 = zx(mgs,il)
10087 qr = qx(mgs,il)
10088 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z1*1000.*1000)
10089 ELSE
10090 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10091 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
10092 z1 = zx(mgs,il)
10093 qr = qx(mgs,il)
10094 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z1*1000.*1000)
10095
10096 ENDIF
10097! an(igs(mgs),jgs,kgs(mgs),ln(il)) = zx(mgs,il)
10098 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > 0.0 ) THEN
10099! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
10100 IF ( imurain == 3 ) THEN
10101 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10102 chw = cx(mgs,il)
10103 qr = qx(mgs,il)
10104 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(chw*1000.*1000)
10105 ELSE
10106 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10107 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
10108 chw = cx(mgs,il)
10109 qr = qx(mgs,il)
10110 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(chw*1000.*1000)
10111
10112 ENDIF
10113
10114 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
10115! How did this happen?
10116 ! set values according to dBZ of -10, or Z = 0.1
10117! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
10118 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
10119 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
10120
10121 IF ( imurain == 3 ) THEN
10122 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10123 z1 = zx(mgs,il)
10124 qr = qx(mgs,il)
10125 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z1*1000.*1000)
10126 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
10127 ELSEIF ( imurain == 1 ) THEN
10128 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10129 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
10130 z1 = zx(mgs,il)
10131 qr = qx(mgs,il)
10132 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(z1*(pi*xdn(mgs,il))**2)
10133 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
10134
10135 ENDIF
10136 ENDIF
10137
10138 IF ( zx(mgs,lr) > 0.0 ) THEN
10139 vr = rho0(mgs)*qx(mgs,lr)/(1000.*cx(mgs,lr))
10140! z1 = 36.*(alpha(kz)+2.0)*a(ix,jy,kz,lnr)*vr**2/((alpha(kz)+1.0)*pi**2)
10141 qr = qx(mgs,lr)
10142 nrx = cx(mgs,lr)
10143 z1 = zx(mgs,lr)
10144
10145! xv = (db(1,kz)*a(1,1,kz,lr))**2/(a(1,1,kz,lnr))
10146! rd = z1*(pi/6.*1000.)**2/xv
10147
10148
10149! determine shape parameter alpha by iteration
10150 IF ( z1 .gt. 0.0 ) THEN
10151
10152 IF ( imurain == 3 ) THEN
10153 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z1*pi**2) - 1.
10154! write(0,*) 'kz, alp, alpha(kz) = ',kz,alp,alpha(kz),rd,z1,xv
10155 DO i = 1,20
10156 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
10157 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
10158 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z1*pi**2) - 1.
10159! write(0,*) 'i,alp = ',i,alp
10160 alp = max( rnumin, min( rnumax, alp ) )
10161 ENDDO
10162
10163 ELSE ! imurain == 1
10164 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10165 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
10166
10167 rd1 = z1*(pi/6.*xdn(mgs,il))**2*nrx/(rho0(mgs)*qr)**2
10168
10169 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
10170 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd1) - 1.0
10171
10172 DO i = 1,10
10173 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
10174 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
10175
10176 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
10177 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd1) - 1.0
10178
10179 alp = max( alphamin, min( alphamax, alp ) )
10180 ENDDO
10181
10182
10183 ENDIF
10184! ENDIF
10185
10186!
10187! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
10188! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
10189!
10190 IF ( imurain == 3 ) THEN
10191 IF ( .true. .and. (alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax) ) THEN
10192
10193 IF ( rescale_high_alpha .and. alp >= rnumax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
10194 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10195 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z1*(1./(xdn(mgs,il)))**2
10196 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
10197
10198 ELSEIF ( rescale_low_alphar .and. alp <= rnumin ) THEN
10199
10200 z1 = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
10201 zx(mgs,il) = z1
10202 ENDIF
10203 ENDIF
10204
10205 ELSEIF ( imurain == 1 ) THEN
10206
10207 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10208 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
10209
10210 IF ( (rescale_low_alpha .or. rescale_high_alpha ) .and. &
10211 & ( alpha(mgs,il) <= alphamin .or. alp == alphamin .or. alp == alphamax ) ) THEN
10212
10213
10214
10215 IF ( rescale_high_alpha .and. alp >= alphamax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
10216 cx(mgs,il) = g1*rho0(mgs)**2*(qr)*qr/zx(mgs,lr)*(6./(pi*xdn(mgs,il)))**2
10217 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
10218
10219 ELSEIF ( rescale_low_alpha .and. alp <= alphamin ) THEN ! alpha = alphamin, so reset Z to prevent growth in C
10220 z1 = g1*rho0(mgs)**2*(qr)*qr/nrx
10221 z2 = z1*(6./(pi*xdn(mgs,il)))**2
10222 zx(mgs,il) = z2
10223 an(igs(mgs),jy,kgs(mgs),lz(il)) = z2
10224 ENDIF
10225 ENDIF ! imurain
10226
10227 ENDIF ! z > 0
10228
10229 tmp = alpha(mgs,lr) + 4./3.
10230 i = int(dgami*(tmp))
10231 del = tmp - dgam*i
10232 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10233
10234 tmp = alpha(mgs,lr) + 1.
10235 i = int(dgami*(tmp))
10236 del = tmp - dgam*i
10237 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10238
10239! ventrx(mgs) = Gamma(alpha(mgs,lr) + 4./3.)/(alpha(mgs,lr) + 1.)**(1./3.)/Gamma(alpha(mgs,lr) + 1.)
10240 ventrx(mgs) = x/(y*(alpha(mgs,lr) + 1.)**(1./3.))
10241
10242 IF ( imurain == 3 .and. izwisventr == 2 ) THEN
10243
10244 tmp = alpha(mgs,lr) + 1.5 + br/6.
10245 i = int(dgami*(tmp))
10246 del = tmp - dgam*i
10247 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10248
10249! ventrx(mgs) = Gamma(alpha(mgs,lr) + 1.5 + br/6.)/Gamma(alpha(mgs,lr) + 1.)
10250 ventrxn(mgs) = x/(y*(alpha(mgs,lr) + 1.)**((1.+br)/6. + 1./3.))
10251
10252 ELSEIF ( imurain == 1 .and. iferwisventr == 2 ) THEN
10253
10254 tmp = alpha(mgs,lr) + 2.5 + br/2.
10255 i = int(dgami*(tmp))
10256 del = tmp - dgam*i
10257 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10258
10259! ventrx(mgs) = Gamma(alpha(mgs,lr) + 1.5 + br/6.)/Gamma(alpha(mgs,lr) + 1.)
10260 ventrxn(mgs) = x/y
10261
10262
10263 ENDIF
10264
10265
10266 ENDIF
10267 ENDIF
10268
10269 ENDIF
10270
10271 ENDDO
10272! CALL cld_cpu('Z-MOMENT-1r2')
10273 ENDIF ! }
10274
10275
10276! write(0,*) 'NUCOND: Set ssf variables, ssmxinit =',ssmxinit
10277 ssmx = 0.0
10278 DO mgs = 1,ngscnt
10279
10280 kp1 = min(nz, kgs(mgs)+1 )
10281 wvel(mgs) = (0.5)*(w(igs(mgs),jgs,kp1) &
10282 & +w(igs(mgs),jgs,kgs(mgs)))
10283 wvelkm1(mgs) = (0.5)*(w(igs(mgs),jgs,kgs(mgs)) &
10284 & +w(igs(mgs),jgs,max(1,kgs(mgs)-1)))
10285
10286 ssat0(mgs) = ssfilt(igs(mgs),jgs,kgs(mgs))
10287 ssf(mgs) = ssfilt(igs(mgs),jgs,kgs(mgs))
10288! ssmx = Max( ssmx, ssf(mgs) )
10289
10290
10291 ssfkp1(mgs) = ssfilt(igs(mgs),jgs,min(nz-1,kgs(mgs)+1))
10292 ssfkm1(mgs) = ssfilt(igs(mgs),jgs,max(1,kgs(mgs)-1))
10293
10294! IF ( wvel(mgs) /= 0.0 ) write(0,*) 'mgs,wvel1,ssf = ',mgs,wvel(mgs),ssf(mgs)
10295
10296
10297 ENDDO
10298
10299
10300
10301!
10302! cloud water variables
10303!
10304
10305 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: Set cloud water variables'
10306
10307 do mgs = 1,ngscnt
10308 xv(mgs,lc) = 0.0
10309 IF ( ipconc .ge. 2 .and. cx(mgs,lc) .gt. 1.0e6 ) THEN
10310 xmas(mgs,lc) = &
10311 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
10312 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
10313 ELSE
10314 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. cxmin ) THEN
10315 xmas(mgs,lc) = &
10316 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),xdn(mgs,lc)*xvmn(lc)), &
10317 & xdn(mgs,lc)*xvmx(lc) )
10318
10319 cx(mgs,lc) = qx(mgs,lc)*rho0(mgs)/xmas(mgs,lc)
10320
10321 ELSEIF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .le. cxmin ) THEN
10322! xmas(mgs,lc) = xdn(mgs,lc)*4.*pi/3.*(5.0e-6)**3
10323! cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc)
10324 cx(mgs,lc) = max( cxmin, rho0(mgs)*qx(mgs,lc)/cwmasx )
10325 xmas(mgs,lc) = &
10326 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
10327 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
10328
10329 ELSE
10330 xmas(mgs,lc) = cwmasn
10331 ENDIF
10332 ENDIF
10333 xdia(mgs,lc,1) = (xmas(mgs,lc)*cwc1)**c1f3
10334
10335
10336 end do
10337!
10338! rain
10339!
10340 do mgs = 1,ngscnt
10341 if ( qx(mgs,lr) .gt. qxmin(lr) ) then
10342
10343 if ( ipconc .ge. 3 ) then
10344 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*max(1.0e-9,cx(mgs,lr)))
10345! parameter( xvmn(lr)=2.8866e-13, xvmx(lr)=4.1887e-9 ) ! mks
10346 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
10347 xv(mgs,lr) = xvmx(lr)
10348 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
10349 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
10350 xv(mgs,lr) = xvmn(lr)
10351 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
10352 ENDIF
10353
10354 xmas(mgs,lr) = xv(mgs,lr)*xdn(mgs,lr)
10355 xdia(mgs,lr,3) = (xmas(mgs,lr)*cwc1)**(1./3.) ! xdia(mgs,lr,1)
10356 IF ( imurain == 3 ) THEN
10357! xdia(mgs,lr,1) = (6.*pii*xv(mgs,lr)/(alpha(mgs,lr)+1.))**(1./3.)
10358 xdia(mgs,lr,1) = xdia(mgs,lr,3) ! formulae for Ziegler (1985) use mean volume diameter, not lambda**(-1)
10359 ELSE ! imurain == 1, Characteristic diameter (1/lambda)
10360 xdia(mgs,lr,1) = (6.*piinv*xv(mgs,lr)/((alpha(mgs,lr)+3.)*(alpha(mgs,lr)+2.)*(alpha(mgs,lr)+1.)))**(1./3.)
10361 ENDIF
10362! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
10363
10364! Inverse exponential version:
10365! xdia(mgs,lr,1) =
10366! > (qx(mgs,lr)*rho0(mgs)
10367! > /(pi*xdn(mgs,lr)*cx(mgs,lr)))**(0.333333)
10368 ELSE
10369 xdia(mgs,lr,1) = &
10370 & (qx(mgs,lr)*rho0(mgs)/(pi*xdn(mgs,lr)*cno(lr)))**(0.25)
10371 end if
10372 else
10373 xdia(mgs,lr,1) = 1.e-9
10374! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
10375 end if
10376
10377 end do
10378
10379
10380!
10381! Ventilation coefficients
10382
10383 do mgs = 1,ngscnt
10384
10385
10386 fadvisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))* &
10387 & (temg(mgs)/296.0)**(1.5)
10388
10389 fakvisc(mgs) = fadvisc(mgs)*rhoinv(mgs)
10390
10391 fwvdf(mgs) = (2.11e-05)*((temg(mgs)/tfr)**1.94)* &
10392 & (101325.0/(pres(mgs)))
10393
10394 fschm(mgs) = (fakvisc(mgs)/fwvdf(mgs))
10395
10396 fvent(mgs) = (fschm(mgs)**(1./3.)) * (fakvisc(mgs)**(-0.5))
10397
10398 end do
10399!
10400!
10401! Ziegler nucleation
10402!
10403!
10404! cloud evaporation, condensation, and nucleation
10405! sqsat -> qss(mgs)
10406
10407 DO mgs=1,ngscnt
10408 dcloud = 0.0
10409 ! Skip points at low temperature if SS stays less than 1.08,
10410 ! otherwise allow nucleation at low temp (will freeze at next time step)
10411 IF ( temg(mgs) .le. tfrh .and. qx(mgs,lv)/qvs(mgs) < maxlowtempss ) THEN
10412 cycle
10413 ENDIF
10414
10415 IF( ssat0(mgs) .GT. 0. .OR. ssf(mgs) .GT. 0. ) GO TO 620
10416!6/4 IF( qvap(mgs) .EQ. qss(mgs) ) GO TO 631
10417!
10418!.... EVAPORATION. QV IS LESS THAN qss(mgs).
10419!.... EVAPORATE CLOUD FIRST
10420!
10421 IF ( qx(mgs,lc) .LE. 0. ) GO TO 631
10422!.... CLOUD EVAPORATION.
10423! convert input 'cp' to cgs
10424 r1=1./(1. + caw*(273.15 - cbw)*qss(mgs)*felv(mgs)/ &
10425 & (cp*(temg(mgs) - cbw)**2))
10426 qevap= min( qx(mgs,lc), r1*(qss(mgs)-qvap(mgs)) )
10427
10428
10429 IF ( qx(mgs,lc) <= qevap ) THEN ! GO TO 63
10430 qwvp(mgs) = qwvp(mgs) + qx(mgs,lc)
10431 thetap(mgs) = thetap(mgs) - felvcp(mgs)*qx(mgs,lc)/(pi0(mgs))
10432 IF ( io_flag .and. nxtra > 1 ) THEN
10433 axtra(igs(mgs),jy,kgs(mgs),1) = -qx(mgs,lc)/dtp
10434 ENDIF
10435 qx(mgs,lc) = 0.
10436 IF ( restoreccn ) THEN
10437 IF ( lccna > 1 ) THEN
10438 ccna(mgs) = ccna(mgs) - restoreccnfrac*cx(mgs,lc)
10439 ELSEIF ( irenuc <= 2 ) THEN
10440 IF ( .not. invertccn ) THEN
10441 ccnc(mgs) = max( ccnc(mgs), min( qccn*rho0(mgs), ccnc(mgs) + restoreccnfrac*cx(mgs,lc) ) )
10442 ELSE
10443 ccnc(mgs) = ccnc(mgs) + restoreccnfrac*cx(mgs,lc)
10444 ENDIF
10445 ENDIF
10446 ENDIF
10447 cx(mgs,lc) = 0.
10448 ELSE
10449 qctmp = qx(mgs,lc)
10450 qwvp(mgs) = qwvp(mgs) + qevap
10451 qx(mgs,lc) = qx(mgs,lc) - qevap
10452 IF ( qx(mgs,lc) .le. 0. ) THEN
10453 IF ( restoreccn ) THEN
10454 IF ( lccna > 1 ) THEN
10455 ccna(mgs) = ccna(mgs) - restoreccnfrac*cx(mgs,lc)
10456 ELSEIF ( irenuc <= 2 ) THEN
10457! ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + cx(mgs,lc) ) )
10458! ccnc(mgs) = ccnc(mgs) + cx(mgs,lc)
10459 IF ( .not. invertccn ) THEN
10460 ccnc(mgs) = max( ccnc(mgs), min( qccn*rho0(mgs), ccnc(mgs) + restoreccnfrac*cx(mgs,lc) ) )
10461 ELSE
10462 ccnc(mgs) = ccnc(mgs) + restoreccnfrac*cx(mgs,lc)
10463 ENDIF
10464 ENDIF
10465 ENDIF
10466 cx(mgs,lc) = 0.
10467 ELSE
10468 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
10469 IF ( restoreccn ) THEN
10470 IF ( lccna > 1 ) THEN
10471 ccna(mgs) = ccna(mgs) - restoreccnfrac*tmp
10472 ELSEIF ( irenuc <= 2 ) THEN
10473 ! ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + tmp ) )
10474! ccnc(mgs) = ccnc(mgs) + tmp
10475 IF ( .not. invertccn ) THEN
10476 ccnc(mgs) = max( ccnc(mgs), min( qccn*rho0(mgs), ccnc(mgs) + restoreccnfrac*tmp ) )
10477 ELSE
10478 ccnc(mgs) = ccnc(mgs) + restoreccnfrac*tmp
10479 ENDIF
10480 ENDIF
10481 ENDIF
10482 cx(mgs,lc) = cx(mgs,lc) - tmp
10483 ENDIF
10484 thetap(mgs) = thetap(mgs) - felvcp(mgs)*qevap/(pi0(mgs))
10485 IF ( io_flag .and. nxtra > 1 ) THEN
10486 axtra(igs(mgs),jy,kgs(mgs),1) = -qevap/dtp
10487 ENDIF
10488
10489 ENDIF
10490
10491 GO TO 631
10492
10493
10494 620 CONTINUE
10495
10496!.... CLOUD CONDENSATION
10497
10498 IF ( qx(mgs,lc) .GT. qxmin(lc) .and. cx(mgs,lc) .ge. 1. ) THEN
10499
10500
10501
10502! ac1 = xdn(mgs,lc)*elv(kgs(mgs))**2*epsi/
10503! : (tka(kgs(mgs))*rw*temg(mgs)**2)
10504! took out xdn factor because it cancels later...
10505 ac1 = felv(mgs)**2/(tka(mgs)*rw*temg(mgs)**2)
10506
10507
10508! bc = xdn(mgs,lc)*rw*temg(mgs)/
10509! : (epsi*wvdf(kgs(mgs))*es(mgs))
10510! took out xdn factor because it cancels later...
10511 bc = rw*temg(mgs)/(wvdf(mgs)*es(mgs))
10512
10513! bs = rho0(mgs)*((rd*temg(mgs)/(epsi*es(mgs)))+
10514! : (epsi*elv(kgs(mgs))**2/(pres(mgs)*temg(mgs)*cp)))
10515
10516! taus = Min(dtp, xdn(mgs,lc)*rho0(mgs)*(ac1+bc)/
10517! : (4*pi*0.89298*BS*0.5*xdia(mgs,lc,1)*cx(mgs,lc)*xdn(mgs,lc)))
10518
10519!
10520 IF ( ssf(mgs) .gt. 0.0 .or. ssat0(mgs) .gt. 0.0 ) THEN
10521 IF ( ny .le. 2 ) THEN
10522! write(0,*) 'undershoot: ',ssf(mgs),
10523! : ( (qx(mgs,lv) - dcloud)/c1 - 1.0)*100.
10524 ENDIF
10525
10526
10527
10528 IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN
10529
10530 IF ( xdia(mgs,lc,1) .le. 0.0 ) THEN
10531 xmas(mgs,lc) = cwmasn
10532 xdia(mgs,lc,1) = (xmas(mgs,lc)*cwc1)**c1f3
10533 ENDIF
10534 d1 = (1./(ac1 + bc))*4.0*pi*ventc &
10535 & *0.5*xdia(mgs,lc,1)*cx(mgs,lc)*rhoinv(mgs)
10536
10537 ELSE
10538 d1 = 0.0
10539 ENDIF
10540
10541 IF ( rcond .eq. 2 .and. qx(mgs,lr) .gt. qxmin(lr) .and. cx(mgs,lr) > 1.e-9 ) THEN
10542 IF ( imurain == 3 ) THEN
10543 IF ( izwisventr == 1 ) THEN
10544 rwvent(mgs) = ventrx(mgs)*(1.6 + 124.9*(1.e-3*rho0(mgs)*qx(mgs,lr))**.2046)
10545 ELSE ! izwisventr = 2
10546! 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
10547 rwvent(mgs) = &
10548 & (0.78*ventrx(mgs) + 0.308*ventrxn(mgs)*fvent(mgs) &
10549 & *sqrt((ar*rhovt(mgs))) &
10550 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
10551 ENDIF
10552
10553 ELSE ! imurain == 1
10554
10555 IF ( iferwisventr == 1 ) THEN
10556 alpr = min(alpharmax,alpha(mgs,lr) )
10557! alpr = alpha(mgs,lr)
10558 x = 1. + alpr
10559
10560 tmp = 1 + alpr
10561 i = int(dgami*(tmp))
10562 del = tmp - dgam*i
10563 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10564
10565 tmp = 2.5 + alpr + 0.5*bx(lr)
10566 i = int(dgami*(tmp))
10567 del = tmp - dgam*i
10568 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp ! ratio of gamma functions
10569
10570! vent1 = dble(xdia(mgs,lr,1))**(-2. - alpr) ! Actually OK
10571! vent2 = dble(1./xdia(mgs,lr,1) + 0.5*fx(lr))**dble(2.5+alpr+0.5*bx(lr)) ! Actually OK
10572 vent1 = dble(xdia(mgs,lr,1))**(0.5 + 0.5*bx(lr)) ! 2016.2.26 Changed for consistency with derivation (recast formula)
10573 vent2 = dble(1. + 0.5*fx(lr)*xdia(mgs,lr,1))**dble(2.5+alpr+0.5*bx(lr))
10574
10575
10576 rwvent(mgs) = &
10577 & 0.78*x + &
10578 & 0.308*fvent(mgs)*y* &
10579 & sqrt(ax(lr)*rhovt(mgs))*(vent1/vent2)
10580
10581 ELSEIF ( iferwisventr == 2 ) THEN
10582
10583! 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
10584 x = 1. + alpha(mgs,lr)
10585
10586 rwvent(mgs) = &
10587 & (0.78*x + 0.308*ventrxn(mgs)*fvent(mgs) &
10588 & *sqrt((ar*rhovt(mgs))) &
10589 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
10590
10591
10592 ENDIF ! iferwisventr
10593
10594 ENDIF ! imurain
10595
10596 d1r = (1./(ac1 + bc))*4.0*pi*rwvent(mgs) &
10597 & *0.5*xdia(mgs,lr,1)*cx(mgs,lr)*rhoinv(mgs)
10598 ELSE
10599 d1r = 0.0
10600 ENDIF
10601
10602
10603 e1 = felvcp(mgs)/(pi0(mgs))
10604 f1 = pk(mgs) ! (pres(mgs)/poo)**cap
10605
10606!
10607! fifth trial to see what happens:
10608!
10609 ltemq = (temg(mgs)-163.15)/fqsat+1.5
10610 ltemq = min( nqsat, max(1,ltemq) )
10611 ltemq1 = ltemq
10612 temp1 = temg(mgs)
10613 p380 = 380.0/pres(mgs)
10614
10615! taus = Max( 0.05*dtp, Min(taus, 0.25*dtp ) )
10616! nc = NInt(dtp/Min(1.0,0.5*taus))
10617! dtcon = dtp/float(nc)
10618 ss1 = qx(mgs,lv)/qvs(mgs)
10619 ss2 = ss1
10620 temp2 = temp1
10621 qv1 = qx(mgs,lv)
10622 qvs1 = qvs(mgs)
10623 qis1 = qis(mgs)
10624 dt1 = 0.0
10625
10626
10627! dtcon = Max(dtcon,0.2)
10628! nc = Nint(dtp/dtcon)
10629
10630 ltemq1 = ltemq
10631! want to start out with a small time step to handle the steep slope
10632! and fast changes, then can switch to a larger step (dtcon2) for the
10633! rest of the big time step.
10634! base the initial time step (dtcon1) on the slope (delta)
10635 IF ( abs(ss1 - 1.0) .gt. 1.e-5 ) THEN
10636 delta = 0.5*(qv1-qvs1)/(d1*(ss1 - 1.0))
10637 ELSE
10638 delta = 0.1*dtp
10639 ENDIF
10640! delta is the extrapolated time to get halfway from qv1 to qvs1
10641! want at least 5 time steps to the halfway point, so multiply by 0.2
10642! for the initial time step
10643 dtcon1 = min(0.05,0.2*delta)
10644 nc = max(5,2*nint( (dtp-4.0*dtcon1)/delta))
10645 dtcon2 = (dtp-4.0*dtcon1)/nc
10646
10647 n = 1
10648 dt1 = 0.0
10649 nc = 0
10650 dqc = 0.0
10651 dqr = 0.0
10652 dqi = 0.0
10653 dqs = 0.0
10654 dqvii = 0.0
10655 dqvis = 0.0
10656
10657 rk2c: DO WHILE ( dt1 .lt. dtp )
10658 nc = 0
10659 IF ( n .le. 4 ) THEN
10660 dtcon = dtcon1
10661 ELSE
10662 dtcon = dtcon2
10663 ENDIF
10664 609 dqv = -(ss1 - 1.)*d1*dtcon
10665 dqvr = -(ss1 - 1.)*d1r*dtcon
10666 dtemp = -0.5*e1*f1*(dqv + dqvr)
10667! write(0,*) 'RK2c dqv1 = ',dqv
10668! calculate midpoint values:
10669 ! ltemq1m = ltemq1 + Nint(dtemp*fqsat + 0.5)
10670
10671 ! 7.6.2016: Test full calc of ltemq
10672 ltemq1m = (temp1+dtemp-163.15)*fqsati+1.5
10673 ltemq1m = min( nqsat, max(1,ltemq1m) )
10674
10675 IF ( ltemq1m .lt. 1 .or. ltemq1m .gt. nqsat ) THEN
10676 write(0,*) 'STOP in nucond line 1192 '
10677 write(0,*) ' ltemq1m,icond = ',ltemq1m,icond
10678 write(0,*) ' dtemp,e1,f1,dqv,dqvr = ', dtemp,e1,f1,dqv,dqvr
10679 write(0,*) ' d1,d1r,dtcon,ss1 = ',d1,d1r,dtcon,ss1
10680 write(0,*) ' dqc, dqr = ',dqc,dqr
10681 write(0,*) ' qv,qc,qr = ',qx(mgs,lv)*1000.,qx(mgs,lc)*1000.,qx(mgs,lr)*1000.
10682 write(0,*) ' i, j, k = ',igs(mgs),jy,kgs(mgs)
10683 write(0,*) ' dtcon1,dtcon2,delta = ',dtcon1,dtcon2,delta
10684 write(0,*) ' nc,dtp = ',nc,dtp
10685 write(0,*) ' rwvent,xdia,crw,ccw = ', rwvent(mgs),xdia(mgs,lr,1),cx(mgs,lr),cx(mgs,lc)
10686 write(0,*) ' fvent,alphar = ',fvent(mgs),alpha(mgs,lr)
10687 write(0,*) ' xvr,xmasr,xdnr,cwc1 = ',xv(mgs,lr),xmas(mgs,lr),xdn(mgs,lr),cwc1
10688 ENDIF
10689 dqvs = dtemp*p380*dtabqvs(ltemq1m)
10690 qv1m = qv1 + dqv + dqvr
10691! qv1mr = qv1r + dqvr
10692
10693 qvs1m = qvs1 + dqvs
10694 ss1m = qv1m/qvs1m
10695
10696 ! check for undersaturation when no ice is present, if so, then reduce time step
10697 IF ( ss1m .lt. 1. .and. (dqvii + dqvis) .eq. 0.0 ) THEN
10698 dtcon = (0.5*dtcon)
10699 IF ( dtcon .ge. dtcon1 ) THEN
10700 GOTO 609
10701 ELSE
10702 EXIT
10703 ENDIF
10704 ENDIF
10705! calculate full step:
10706 dqv = -(ss1m - 1.)*d1*dtcon
10707 dqvr = -(ss1m - 1.)*d1r*dtcon
10708
10709
10710! write(0,*) 'RK2a dqv1m = ',dqv
10711 dtemp = -e1*f1*(dqv + dqvr)
10712
10713 ! ltemq1 = ltemq1 + Nint(dtemp*fqsat + 0.5)
10714
10715 ! 7.6.2016: Test full calc of ltemq
10716 ltemq1 = (temp1+dtemp-163.15)*fqsati+1.5
10717 ltemq1 = min( nqsat, max(1,ltemq1) )
10718
10719 IF ( ltemq1 .lt. 1 .or. ltemq1 .gt. nqsat ) THEN
10720 write(0,*) 'STOP in nucond line 1230 '
10721 write(0,*) ' ltemq1m,icond = ',ltemq1m,icond
10722 write(0,*) ' dtemp,e1,dqv,dqvr = ', dtemp,e1,dqv,dqvr
10723 ENDIF
10724 dqvs = dtemp*p380*dtabqvs(ltemq1)
10725
10726 qv1 = qv1 + dqv + dqvr
10727
10728 dqc = dqc - dqv
10729 dqr = dqr - dqvr
10730
10731 qvs1 = qvs1 + dqvs
10732 ss1 = qv1/qvs1
10733 temp1 = temp1 + dtemp
10734 IF ( temp2 .eq. temp1 .or. ss2 .eq. ss1 .or. &
10735 & ss1 .eq. 1.00 .or. &
10736 & ( n .gt. 10 .and. ss1 .lt. 1.0005 ) ) THEN
10737! write(0,*) 'RK2c break'
10738 EXIT
10739 ELSE
10740 ss2 = ss1
10741 temp2 = temp1
10742 dt1 = dt1 + dtcon
10743 n = n + 1
10744 ENDIF
10745 ENDDO rk2c
10746
10747
10748 dcloud = dqc ! qx(mgs,lv) - qv1
10749 thetap(mgs) = thetap(mgs) + e1*(dcloud + dqr)
10750
10751
10752 IF ( eqtset > 2 ) THEN
10753 pipert(mgs) = pipert(mgs) + felvpi(mgs)*(dcloud + dqr)
10754 ENDIF
10755 IF ( io_flag .and. nxtra > 1 ) THEN
10756 axtra(igs(mgs),jy,kgs(mgs),1) = dcloud/dtp
10757 axtra(igs(mgs),jy,kgs(mgs),2) = axtra(igs(mgs),jy,kgs(mgs),2) + dqr/dtp
10758 ENDIF
10759 qwvp(mgs) = qwvp(mgs) - (dcloud + dqr)
10760 qx(mgs,lc) = qx(mgs,lc) + dcloud
10761 qx(mgs,lr) = qx(mgs,lr) + dqr
10762! t9(igs(mgs),jy,kgs(mgs)) = t9(igs(mgs),jy,kgs(mgs)) + (DCLOUD + dqr)/dtp*felv(mgs)/(cp*pi0(mgs)) !* &
10763!! & dx*dy*dz3d(igs(mgs),jy,kgs(mgs))
10764
10765
10766 IF ( lzr > 1 .and. rcond == 2 .and. qx(mgs,lr) .gt. qxmin(lr) &
10767 & .and. cx(mgs,lr) .gt. 1.e-9 ) THEN
10768 tmp = qx(mgs,lr)/cx(mgs,lr)
10769 IF ( imurain == 3 ) THEN
10770 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10771 ELSE
10772 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10773 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
10774
10775 ENDIF
10776 zx(mgs,lr) = zx(mgs,lr) + g1*(rho0(mgs)/(xdn(mgs,lr)))**2*( 2.*( tmp ) * dqr )
10777 ENDIF
10778
10779 theta(mgs) = thetap(mgs) + theta0(mgs)
10780 temg(mgs) = theta(mgs)*f1
10781 ltemq = (temg(mgs)-163.15)/fqsat+1.5
10782 ltemq = min( nqsat, max(1,ltemq) )
10783 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
10784! es(mgs) = 6.1078e2*tabqvs(ltemq)
10785
10786!
10787
10788 ENDIF ! dcloud .gt. 0.
10789
10790
10791 ELSE ! qc .le. qxmin(lc)
10792
10793! IF ( ssf(mgs) .gt. 0.0 .and. .not. flag_qndrop ) THEN ! flag_qndrop turns off primary nucleation when using wrf-chem with progn=1
10794 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
10795
10796 IF ( iqcinit == 1 ) THEN
10797
10798 qvs0 = 380.*exp(17.27*(temg(mgs)-273.)/(temg(mgs)- 36.))/pk(mgs)
10799
10800 dcloud = max(0.0, (qx(mgs,lv)-qvs0) / (1.+qvs0*f5/(temg(mgs)-36.)**2) )
10801
10802 ELSEIF ( iqcinit == 3 ) THEN
10803 r1=1./(1. + caw*(273.15 - cbw)*qss(mgs)*felvcp(mgs)/ &
10804 & ((temg(mgs) - cbw)**2))
10805 dcloud=r1*(qvap(mgs) - qvs(mgs)) ! KW model adjustment;
10806 ! this will put mass into qc if qv > sqsat exists
10807
10808 ELSEIF ( iqcinit == 2 ) THEN
10809! R1=1./(1. + caw*(273.15 - cbw)*qss(mgs)*felv(mgs)/
10810! : (cp*(temg(mgs) - cbw)**2))
10811! DCLOUD=R1*(qvap(mgs) - qvs(mgs)) ! KW model adjustment;
10812 ! this will put mass into qc if qv > sqsat exists
10813 ssmx = ssmxinit
10814
10815! IF ( ssf(mgs) > ssmx .and. ssmax(mgs) < 3.0 ) THEN
10816! IF ( ssf(mgs) > ssmx .and. ccnc(mgs) > 1.0 ) THEN
10817! IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 5.0 .and. ccnc(mgs) > 0.1*cwnccn(mgs) ) THEN ! this one works
10818! IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 20.0 ) THEN ! test -- fails
10819! IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 20.0 .and. ccnc(mgs) > 0.1*cwnccn(mgs)) THEN ! test -- is OK
10820 IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 20.0 .and. &
10821 ( ccnc(mgs) > 0.05*cwnccn(mgs) .or. ( ac_opt > 0 .and. ccnc_ac(mgs) - cx(mgs,lc) > 0.0 ) ) ) THEN ! test
10822! IF ( ssf(mgs) > ssmx ) THEN ! original condition
10823 CALL qvexcess(ngs,mgs,qwvp,qv0,qx(1,lc),pres,thetap,theta0,dcloud, &
10824 & pi0,tabqvs,nqsat,fqsat,cbw,fcqv1,felvcp,ssmx,pk,ngscnt)
10825 ELSE
10826 dcloud = 0.0
10827 ENDIF
10828 ENDIF
10829 ELSE
10830 dcloud = 0.0
10831 ENDIF
10832
10833 thetap(mgs) = thetap(mgs) + felvcp(mgs)*dcloud/(pi0(mgs))
10834 qwvp(mgs) = qwvp(mgs) - dcloud
10835 qx(mgs,lc) = qx(mgs,lc) + dcloud
10836 IF ( io_flag .and. nxtra > 1 ) THEN
10837 axtra(igs(mgs),jy,kgs(mgs),1) = dcloud/dtp
10838 ENDIF
10839 theta(mgs) = thetap(mgs) + theta0(mgs)
10840 temg(mgs) = theta(mgs)*pk(mgs) !( pres(mgs) / poo ) ** cap
10841! temg(mgs) = theta2temp( theta(mgs), pres(mgs) )
10842 ltemq = (temg(mgs)-163.15)/fqsat+1.5
10843 ltemq = min( nqsat, max(1,ltemq) )
10844 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
10845! es(mgs) = 6.1078e2*tabqvs(ltemq)
10846
10847!.... S. TWOMEY (1959)
10848! Note: get here if there is no previous cloud water and w > 0.
10849 cn(mgs) = 0.0
10850
10851 IF ( ncdebug .ge. 1 ) THEN
10852 write(iunit,*) 'at 613: ',qx(mgs,lc),cx(mgs,lc),wvel(mgs),ssmax(mgs),kgs(mgs)
10853 ENDIF
10854
10855 IF ( .not. flag_qndrop ) THEN ! { do not calculate number of droplets if using wrf-chem
10856
10857 IF ( ac_opt == 0 ) THEN
10858 cnuctmp = cnuc(mgs)
10859 ELSE
10860 cnuctmp = ccnc_ac(mgs)
10861 ENDIF
10862
10863! IF ( ssmax(mgs) .lt. sscb .and. qx(mgs,lc) .gt. qxmin(lc)) THEN
10864 IF ( dcloud .gt. qxmin(lc) .and. wvel(mgs) > 0.0) THEN
10865! CN(mgs) = CCNE*wvel(mgs)**cnexp ! *Min(1.0,1./dtp) ! 0.3465
10866 cn(mgs) = ccne0*cnuctmp**(2./(2.+cck))*wvel(mgs)**cnexp ! *Min(1.0,1./dtp) ! 0.3465
10867 IF ( ny .le. 2 .and. cn(mgs) .gt. 0.0 &
10868 & .and. ncdebug .ge. 1 ) THEN
10869 write(iunit,*) 'CN: ',cn(mgs)*1.e-6, cx(mgs,lc)*1.e-6, qx(mgs,lc)*1.e3, &
10870 & wvel(mgs), dcloud*1.e3
10871 IF ( cn(mgs) .gt. 1.0 ) write(iunit,*) 'cwrad = ', &
10872 & 1.e6*(rho0(mgs)*qx(mgs,lc)/cn(mgs)*cwc1)**c1f3, &
10873 & igs(mgs),kgs(mgs),temcg(mgs), &
10874 & 1.e3*an(igs(mgs),jgs,kgs(mgs)-1,lc)
10875 ENDIF
10876 IF ( iccwflg .eq. 1 ) THEN
10877 cn(mgs) = min(cwccn*rho0(mgs)/rho00, max(cn(mgs), &
10878 & rho0(mgs)*qx(mgs,lc)/(xdn(mgs,lc)*(4.*pi/3.)*(4.e-6)**3)))
10879 ENDIF
10880 ELSE
10881 cn(mgs) = 0.0
10882 dcloud = 0.0
10883! cn(mgs) = Min(cwccn, &
10884! & rho0(mgs)*dcloud/(xdn(mgs,lc)*(4.*pi/3.)*(4.e-6)**3) )
10885 ENDIF
10886
10887 IF ( cn(mgs) .gt. 0.0 ) THEN
10888 IF ( ac_opt == 0 ) THEN
10889 IF ( cn(mgs) .gt. ccnc(mgs) ) THEN
10890 cn(mgs) = ccnc(mgs)
10891! ccnc(mgs) = 0.0
10892 ENDIF
10893 ELSE
10894 cn(mgs) = min( cn(mgs), ccnc_ac(mgs) )
10895 ENDIF
10896! cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
10897 IF ( irenuc <= 2 .and. lccna < 1 ) ccnc(mgs) = max(0.0, ccnc(mgs) - cn(mgs))
10898 ccna(mgs) = ccna(mgs) + cn(mgs)
10899 ENDIF
10900
10901! write(91,*) 'nuc1: cn, ix, kz = ',cn(mgs),igs(mgs),kgs(mgs),wvel(mgs),cnexp,ccnc(mgs)
10902
10903 IF( cn(mgs) .GT. cx(mgs,lc) ) cx(mgs,lc) = cn(mgs)
10904 IF( cx(mgs,lc) .GT. 0. .AND. qx(mgs,lc) .le. qxmin(lc) ) THEN
10905 cx(mgs,lc) = 0.
10906 ELSE
10907 cx(mgs,lc) = min(cx(mgs,lc),rho0(mgs)*max(0.0,qx(mgs,lc))/cwmasn)
10908 ENDIF
10909
10910 ENDIF ! }.not. flag_qndrop
10911
10912 GOTO 613
10913
10914 END IF ! qc .gt. 0.
10915
10916! ES=EES(PIB(K)*PT)
10917! SQSAT=EPSI*ES/(PB(K)*1000.-ES)
10918
10919!.... CLOUD NUCLEATION
10920! T=PIB(K)*PT
10921! ES=1.E3*PB(K)*QV/EPSI
10922
10923 IF ( wvel(mgs) .le. 0. ) GO TO 616
10924 IF ( cx(mgs,lc) .le. 0. ) GO TO 613 !TWOMEY (1959) Nucleation
10925 IF ( kzbeg-1+kgs(mgs) .GT. 1 .and. qx(mgs,lc) .le. qxmin(lc)) GO TO 613 !TWOMEY (1959) Nucleation
10926 IF ( kzbeg-1+kgs(mgs) .eq. 1 .and. wvel(mgs) .gt. 0. ) GO TO 613 !TWOMEY (1959) Nucleation
10927!.... ATTEMPT ZIEGLER CLOUD NUCLEATION IN CLOUD INTERIOR UNLESS...
10928 616 IF ( ssf(mgs) .LE. supcb .AND. wvel(mgs) .GT. 0. ) GO TO 631 !... weakly saturated updraft
10929 IF ( kzbeg-1+kgs(mgs) .GT. 1 .AND. kzbeg-1+kgs(mgs) .LT. nzend-1 .AND. &
10930 & (ssfkp1(mgs) .GE. supmx .OR. &
10931 & ssf(mgs) .GE. supmx .OR. &
10932 & ssfkm1(mgs) .GE. supmx)) GO TO 631 !... too much vapour
10933 IF (ssf(mgs) .LT. 1.e-10 .OR. ssf(mgs) .GE. supmx) GO TO 631 !... at the extremes for ss
10934
10935!
10936! get here if ( qc > 0 and ss > supcb) or (w < 0)
10937!
10938
10939 if (ndebug .gt. 0) write(0,*) "ICEZVD_DR: Entered Ziegler Cloud Nucleation" !mpidebug
10940
10941 dssdz=0.
10942 r2dzm=0.50/dz3d(igs(mgs),jy,kgs(mgs))
10943
10944 IF ( irenuc >= 0 .and. ac_opt == 0 .and. .not. flag_qndrop ) THEN ! turn off nucleation when flag_qndrop (using WRF-CHEM for activation)
10945
10946 IF ( irenuc < 2 ) THEN !{
10947
10948 IF ( kzend == nzend ) THEN
10949 t0p3 = t0(igs(mgs),jgs,min(kze,kgs(mgs)+3))
10950 t0p1 = t0(igs(mgs),jgs,min(kze,kgs(mgs)+1))
10951 ELSE
10952 t0p3 = t0(igs(mgs),jgs,kgs(mgs)+3)
10953 t0p1 = t0(igs(mgs),jgs,kgs(mgs)+1)
10954 ENDIF
10955
10956 IF ( ( ssf(mgs) .gt. ssmax(mgs) .or. irenuc .eq. 1 ) &
10957 & .and. ( ( lccn .lt. 1 .and. &
10958 & cx(mgs,lc) .lt. cwccn*(min(1.0,rho0(mgs)))) .or. &
10959 & ( lccn .gt. 1 .and. ccnc(mgs) .gt. 0. ) ) &
10960 & ) THEN
10961 IF( kzbeg-1+kgs(mgs) .GT. 1 .AND. kzbeg-1+kgs(mgs) .LT. nzend-1 &
10962 & .and. ssf(mgs) .gt. 0.0 &
10963 & .and. ssfkp1(mgs) .LT. supmx .and. ssfkp1(mgs) .ge. 0.0 &
10964 & .AND. ssfkm1(mgs) .LT. supmx .AND. ssfkm1(mgs) .ge. 0.0 &
10965 & .AND. ssfkp1(mgs) .gt. ssfkm1(mgs) &
10966 & .and. t0p3 .gt. 233.2) THEN
10967 dssdz = (ssfkp1(mgs) - ssfkm1(mgs))*r2dzm
10968!
10969! otherwise check for cloud base condition with updraft:
10970!
10971 ELSEIF( kzbeg-1+kgs(mgs) .GT. 1 .AND. kzbeg-1+kgs(mgs) .LT. nzend-1 &
10972! IF( kgs(mgs) .GT. 1 .AND. kgs(mgs) .LT. NZ-1 & !)
10973 & .and. ssf(mgs) .gt. 0.0 .and. wvel(mgs) .gt. 0.0 &
10974 & .and. ssfkp1(mgs) .gt. 0.0 &
10975 & .AND. ssfkm1(mgs) .le. 0.0 .and. wvelkm1(mgs) .gt. 0.0 &
10976 & .AND. ssf(mgs) .gt. ssfkm1(mgs) &
10977 & .and. t0p1 .gt. 233.2) THEN
10978 dssdz = 2.*(ssf(mgs) - ssfkm1(mgs))*r2dzm ! 1-sided difference
10979 ENDIF
10980
10981 ENDIF
10982!
10983!CLZ IF(wijk.LE.0.) CN=CCN*ssfilt(ix,jy,kz)**CCK
10984! note: CCN -> cwccn, DELT -> dtp
10985 c1 = max(0.0, rho0(mgs)*(qx(mgs,lv) - qss(mgs))/ &
10986 & (xdn(mgs,lc)*(4.*pi/3.)*(4.e-6)**3))
10987 IF ( lccn .lt. 1 ) THEN
10988 cn(mgs) = cwccn*rho0(mgs)/rho00*cck*ssf(mgs)**cckm*dtp* &
10989 & max(0.0, &
10990 & (wvel(mgs)*dssdz) ) ! probably the vertical gradient dominates
10991 ELSE
10992 cn(mgs) = &
10993 & min(ccnc(mgs), cnuc(mgs)*cck*ssf(mgs)**cckm*dtp* &
10994 & max(0.0, &
10995 & ( wvel(mgs)*dssdz) ) )
10996! IF ( cn(mgs) .gt. 0 ) ccnc(mgs) = ccnc(mgs) - cn(mgs)
10997 ENDIF
10998
10999 IF ( cn(mgs) .gt. 0.0 ) THEN
11000 IF ( ccnc(mgs) .lt. 5.e7 .and. cn(mgs) .ge. 5.e7 ) THEN
11001 cn(mgs) = 5.e7
11002 ccnc(mgs) = 0.0
11003 ELSEIF ( cn(mgs) .gt. ccnc(mgs) ) THEN
11004 cn(mgs) = ccnc(mgs)
11005 ccnc(mgs) = 0.0
11006 ENDIF
11007 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11008 ccnc(mgs) = max(0.0, ccnc(mgs) - cn(mgs))
11009 ENDIF
11010
11011 ELSEIF ( irenuc == 2 ) THEN !} {
11012 ! simple Twomey scheme
11013! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11014 cn(mgs) = ccne0*cnuc(mgs)**(2./(2.+cck))*max(0.0,wvel(mgs))**cnexp ! *Min(1.0,1./dtp) ! 0.3465
11015! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
11016!!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11017 ! Philips, Donner et al. 2007, but results in too much limitation of
11018 ! nucleation
11019 cn(mgs) = min(cn(mgs), ccnc(mgs))
11020 cn(mgs) = min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11021 cn(mgs) = min( cn(mgs), max(0.0, (cnuc(mgs) - ccna(mgs) )) )
11022
11023 IF ( .false. .and. ny <= 2 ) THEN
11024 write(0,*) 'i,k, cwmasn = ',igs(mgs),kgs(mgs),cwmasn
11025 write(0,*) 'wvel, cnuc, cn = ',wvel(mgs),cnuc(mgs),cn(mgs)
11026 write(0,*) 'ccne0,cnexp,cck = ',ccne0,cnexp,cck
11027 write(0,*) 'part1, part2 = ',ccne0*cnuc(mgs)**(2./(2.+cck)), max(0.0,wvel(mgs))**cnexp
11028 write(0,*) 'ccnc, dqc, dqc/cwmasn = ',ccnc(mgs), dqc, 0.5*dqc/cwmasn
11029 ENDIF
11030
11031 IF ( icnuclimit > 0 ) THEN
11032 tmp = ccnc(mgs) + cx(mgs,lc)
11033 IF ( tmp < 330.34e6 ) THEN
11034 ccwmax = 1.1173e6 * (1.e-6*tmp)**0.9504
11035 ELSE
11036 ccwmax = 21.57e6 * (1.e-6*tmp)**0.44
11037 ENDIF
11038
11039! IF ( cn(mgs) > 0. ) THEN
11040! write(0,*) 'cn,tmp,ccwmax,cx,c-cx = ',cn(mgs),tmp,ccwmax,cx(mgs,lc),ccwmax - cx(mgs,lc)
11041! ENDIF
11042
11043 cn(mgs) = max( 0.0, min( cn(mgs), ccwmax - cx(mgs,lc) ) )
11044
11045 ENDIF
11046
11047 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11048
11049 IF ( lccna < 1 ) ccnc(mgs) = max(0.0, ccnc(mgs) - cn(mgs))
11050
11051 ELSEIF ( irenuc == 3 ) THEN !} {
11052 ! Phillips Donner Garner 2007
11053! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11054! CN(mgs) = cwccn*Min(ssf(mgs),ssfcut)**cck
11055
11056! Need to calculate new ssf since condensation has happened:
11057 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11058 ltemq = int( (temp1-163.15)/fqsat+1.5 )
11059 ltemq = min( nqsat, max(1,ltemq) )
11060
11061 c1= pqs(mgs)*tabqvs(ltemq)
11062
11063 ssf(mgs) = 0.0
11064 IF ( c1 > 0. ) THEN
11065 ssf(mgs) = 100.*(qx(mgs,lv)/c1 - 1.0) ! from "new" values
11066 ENDIF
11067 cn(mgs) = cnuc(mgs)*min(1.0, (ssf(mgs))**cck ) !
11068
11069 cn(mgs) = max( 0.0, cn(mgs) - ccna(mgs) ) ! this was from
11070 ! Philips, Donner et al. 2007, but results in too much limitation of
11071 ! nucleation
11072 cn(mgs) = min(cn(mgs), ccnc(mgs))
11073 cn(mgs) = min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11074
11075 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11076
11077 ! 6/13/2016: Phillips et al. appears not to decrement CCN, but only increments CCNa.
11078 ! This would allow an initially non-homogeneous (vertically, e.g.) initial value of CCN/rho_air
11079 ccnc(mgs) = max(0.0, ccnc(mgs) - cn(mgs))
11080
11081 ELSEIF ( irenuc == 4 ) THEN !} {
11082 ! modification of Phillips Donner Garner 2007
11083! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11084! CN(mgs) = CCNE0*cnuc(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp
11085! cn(mgs) = Min( cn(mgs), cnuc(mgs) )
11086! Need to calculate new ssf since condensation has happened:
11087 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11088 ltemq = int( (temp1-163.15)/fqsat+1.5 )
11089 ltemq = min( nqsat, max(1,ltemq) )
11090
11091 c1= pqs(mgs)*tabqvs(ltemq)
11092 IF ( c1 > 0. ) THEN
11093 ssf(mgs) = max(0.0, 100.*((qv0(mgs) + qwvp(mgs))/c1 - 1.0) ) ! from "new" values
11094 ELSE
11095 ssf(mgs) = 0.0
11096 ENDIF
11097 cn(mgs) = cnuc(mgs)*min(ssf2kmax, ssf(mgs)**cck) ! this allows cn(mgs) > cnuc(mgs)
11098
11099 cn(mgs) = max( 0.0, cn(mgs) - ccna(mgs) ) ! this was from
11100 ! Philips, Donner et al. 2007, but results in too much limitation of
11101 ! nucleation
11102! CN(mgs) = Min(cn(mgs), ccnc(mgs))
11103 cn(mgs) = min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11104
11105 IF ( cn(mgs) > 0.0 ) THEN
11106 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11107 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11108
11109 dcrit = 2.0*2.5e-7
11110
11111 dcloud = 1000.*dcrit**3*pi/6.*cn(mgs)
11112 qx(mgs,lc) = qx(mgs,lc) + dcloud
11113 thetap(mgs) = thetap(mgs) + felvcp(mgs)*dcloud/(pi0(mgs))
11114 qwvp(mgs) = qwvp(mgs) - dcloud
11115 ENDIF
11116 ! 6/13/2016: Phillips et al. appears not to decrement CCN, but only increments CCNa.
11117 ! This would allow an initially non-homogeneous (vertically, e.g.) initial value of CCN/rho_air
11118! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11119
11120
11121
11122 ELSEIF ( irenuc == 6 ) THEN !} {
11123
11124 ! simple Twomey scheme but limit activation to try to do most activation near cloud base, but keep some CCN available for renuclation
11125! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11126 cn(mgs) = 0.0
11127! 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
11128 IF ( ccna(mgs) < 0.7*cnuc(mgs) ) THEN ! here, assume we are near cloud base and use Twomey formulation
11129 cn(mgs) = min( 0.9*cnuc(mgs), ccne0*cnuc(mgs)**(2./(2.+cck))*max(0.0,wvel(mgs))**cnexp )! *Min(1.0,1./dtp) ! 0.3465
11130! IF ( cn(mgs) + ccna(mgs) > 0.71*cnuc ) THEN
11131 ! prevent this branch from activating more than 70% of CCN
11132 cn(mgs) = min( cn(mgs), max(0.0, (0.7*cnuc(mgs) - ccna(mgs) )) )
11133! CN(mgs) = Min( CN(mgs), Max(0.0, 0.71*ccnc(mgs) - ccna(mgs) ) )
11134
11135 ELSE
11136 ! 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.
11137
11138 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11139! t0(ix,jy,kz) = temp1
11140 ltemq = int( (temp1-163.15)/fqsat+1.5 )
11141 ltemq = min( nqsat, max(1,ltemq) )
11142
11143! c1 = t00(igs(mgs),jy,kgs(mgs))*tabqvs(ltemq)
11144 c1= pqs(mgs)*tabqvs(ltemq)
11145 IF ( c1 > 0. ) THEN
11146 ssf(mgs) = max(0.0, 100.*((qv0(mgs) + qwvp(mgs))/c1 - 1.0) ) ! from "new" values
11147 ELSE
11148 ssf(mgs) = 0.0
11149 ENDIF
11150
11151! CN(mgs) = cnuc(mgs)*Min(0.99, Min(ssf(mgs),ssfcut)**cck ) !
11152 cn(mgs) = cnuc(mgs)*min(2.0, max(0.0,ssf(mgs))**cck ) !
11153! CN(mgs) = cnuc(mgs)*Min(ssf(mgs),ssfcut)**cck !
11154
11155
11156 cn(mgs) = min(0.01*cnuc(mgs), max( 0.0, cn(mgs) - ccna(mgs) ) ) ! this was from
11157! cn(mgs) = 0.0
11158 ENDIF
11159! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
11160!!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11161 ! Philips, Donner et al. 2007, but results in too much limitation of
11162 ! nucleation
11163! CN(mgs) = Min(cn(mgs), ccnc(mgs))
11164! cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11165
11166 IF ( cn(mgs) > 0.0 ) THEN
11167 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11168
11169 ! create some small droplets at minimum size (CP 2000), although it adds very little liquid
11170
11171 dcrit = 2.0*2.5e-7
11172
11173 dcloud = 1000.*dcrit**3*pi/6.*cn(mgs)
11174 qx(mgs,lc) = qx(mgs,lc) + dcloud
11175 thetap(mgs) = thetap(mgs) + felvcp(mgs)*dcloud/(pi0(mgs))
11176 qwvp(mgs) = qwvp(mgs) - dcloud
11177 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11178 ENDIF
11179 ELSEIF ( irenuc == 5 ) THEN !} {
11180
11181 ! modification of Phillips Donner Garner 2007
11182! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11183! 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
11184 cn(mgs) = min( cnuc(mgs), ccne0*cnuc(mgs)**(2./(2.+cck))*max(0.0,wvel(mgs))**cnexp )
11185
11186
11187 IF ( ccna(mgs) >= cnuc(mgs) ) THEN ! apply limit after all "base" CCN have been depleted
11188 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11189 ltemq = int( (temp1-163.15)/fqsat+1.5 )
11190 ltemq = min( nqsat, max(1,ltemq) )
11191
11192 c1= pqs(mgs)*tabqvs(ltemq)
11193 IF ( c1 > 0. ) THEN
11194 ssf(mgs) = max(0.0, 100.*((qv0(mgs) + qwvp(mgs))/c1 - 1.0) ) ! from "new" values
11195 ELSE
11196 ssf(mgs) = 0.0
11197 ENDIF
11198
11199
11200 cn(mgs) = max( cn(mgs), cnuc(mgs)*min(ssf2kmax, ssf(mgs)**cck) ) ! this allows cn(mgs) > cnuc(mgs)
11201
11202 ! cn(mgs) = Min( cn(mgs), cnuc(mgs) )
11203
11204! IF ( ccna(mgs) >= cnuc(mgs) ) THEN ! apply limit after all "base" CCN have been depleted
11205 cn(mgs) = max( 0.0, cn(mgs) - ccna(mgs) ) ! this was from
11206
11207 ELSE
11208 cn(mgs) = min( cn(mgs), cnuc(mgs) - ccna(mgs) ) ! no more than remaining "base" CCN
11209 ENDIF
11210 ! Philips, Donner et al. 2007, but results in too much limitation of
11211 ! nucleation
11212! CN(mgs) = Min(cn(mgs), ccnc(mgs))
11213! cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11214 dcrit = 2.0*2.0e-6
11215 dcloud = 1000.*dcrit**3*pi/6.
11216 ! cn(mgs) = Min(cn(mgs), 0.5*dqc/dcloud) ! limit the nucleation mass to half of the condensation mass
11217 ! check new droplet size:
11218 ! tmp is number of droplets at diameter dcrit
11219 tmp = max(0.0, rho0(mgs)*qx(mgs,lc)/dcloud - cx(mgs,lc)) ! (cx(mgs,lc) + cn(mgs))
11220 cn(mgs) = min(tmp, cn(mgs) )
11221
11222
11223 IF ( cn(mgs) > 0.0 ) THEN
11224 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11225
11226 dcrit = 2.5e-7
11227
11228 dcloud = 1000.*dcrit**3*pi/6.*cn(mgs)
11229 qx(mgs,lc) = qx(mgs,lc) + dcloud
11230 thetap(mgs) = thetap(mgs) + felvcp(mgs)*dcloud/(pi0(mgs))
11231 qwvp(mgs) = qwvp(mgs) - dcloud
11232 ENDIF
11233 ! 6/13/2016: Phillips et al. appears not to decrement CCN, but only increments CCNa.
11234 ! This would allow an initially non-homogeneous (vertically, e.g.) initial value of CCN/rho_air
11235 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11236 ELSEIF ( irenuc == 7 .or. irenuc == 17 ) THEN !} {
11237
11238 ! simple Twomey scheme but limit activation to try to do most activation near cloud base, but keep some CCN available for renuclation
11239! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11240 cn(mgs) = 0.0
11241 IF ( irenuc == 7 ) THEN
11242 frac = 0.9
11243 ELSE
11244 frac = 0.98
11245 ENDIF
11246! 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
11247 IF ( ccna(mgs) < frac*cnuc(mgs) ) THEN ! { here, assume we are near cloud base and use Twomey formulation
11248 cn(mgs) = min( (frac+0.01)*cnuc(mgs), ccne0*cnuc(mgs)**(2./(2.+cck))*max(0.0,wvel(mgs))**cnexp )! *Min(1.0,1./dtp) ! 0.3465
11249! IF ( cn(mgs) + ccna(mgs) > 0.71*cnuc ) THEN
11250 ! prevent this branch from activating more than 70% of CCN
11251 cn(mgs) = min( cn(mgs), max(0.0, (frac*cnuc(mgs) - ccna(mgs) )) )
11252! CN(mgs) = Min( CN(mgs), Max(0.0, 0.71*ccnc(mgs) - ccna(mgs) ) )
11253 ! write(0,*) '1: k,cn = ',kgs(mgs),cn(mgs),ssf(mgs)
11254!! IF ( ccncuf(mgs) > 0.0 .and. cn(mgs) < 1.e-3 .and. ssmax(mgs) > 1.0 ) THEN
11255! IF ( ccncuf(mgs) > 0.0 .and. ssf(mgs) > ssmxuf .and. ssmax(mgs) > ssmxuf ) THEN
11256! CNuf(mgs) = Min( ccncuf(mgs), CCNE0*ccncuf(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp )! *Min(1.0,1./dtp) ! 0.3465
11257 ! IF ( cnuf(mgs) >= 0.0 ) write(0,*) '1: cnuf, k = ',cnuf(mgs),ccncuf(mgs),kgs(mgs)
11258! ENDIF
11259
11260
11261 ELSE ! }{
11262 ! 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.
11263
11264 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11265! t0(ix,jy,kz) = temp1
11266 ltemq = int( (temp1-163.15)/fqsat+1.5 )
11267 ltemq = min( nqsat, max(1,ltemq) )
11268
11269 ! c1 = t00(igs(mgs),jy,kgs(mgs))*tabqvs(ltemq)
11270 c1= pqs(mgs)*tabqvs(ltemq)
11271
11272 ssf(mgs) = 0.0
11273 IF ( c1 > 0. ) THEN
11274 ssf(mgs) = 100.*(qx(mgs,lv)/c1 - 1.0) ! from "new" values
11275 ENDIF
11276
11277! IF ( ssf(mgs) <= 1.0 .or. cnuc(mgs) > ccna(mgs) ) THEN
11278 IF ( ssf(mgs) <= 1.0 ) THEN
11279 cn(mgs) = cnuc(mgs)*min(1.0, max(0.0,ssf(mgs))**cck ) !
11280 ELSE
11281 cn(mgs) = cnuc(mgs)*min(2.0, max(0.0,0.03*(ssf(mgs)-1.0)+1.)**cck ) !
11282! write(0,*) 'iren7: ssf,ssmx = ',ssf(mgs),ssmax(mgs),cn(mgs),ccna(mgs),cnuc(mgs)
11283! write(0,*) 'c1,qv = ',c1,qx(mgs,lv),temp1,ltemq
11284 ENDIF
11285
11286 ! write(0,*) 'k,cn = ',kgs(mgs),cn(mgs),ssf(mgs)
11287 ! write(0,*) 'ccn-ccna = ',cnuc(mgs) - ccna(mgs),ccnc(mgs) - ccna(mgs)
11288! IF ( ccncuf(mgs) > 0.0 .and. cn(mgs) < 1.e-3 .and. ssmax(mgs) > 1.0 ) THEN
11289 IF ( ccncuf(mgs) > 0.0 .and. ssf(mgs) > ssmxuf .and. ( ssmax(mgs) > ssmxuf .or. lss < 1 ) ) THEN
11290 cnuf(mgs) = min( ccncuf(mgs), ccne0*ccncuf(mgs)**(2./(2.+cck))*max(0.0,wvel(mgs))**cnexp )! *Min(1.0,1./dtp) ! 0.3465
11291 ! IF ( cnuf(mgs) >= 0.0 ) write(0,*) 'cnuf, k = ',cnuf(mgs),ccncuf(mgs),kgs(mgs)
11292 ENDIF
11293
11294
11295! CN(mgs) = Min( Min(0.1,ssf(mgs)-1.)*cnuc(mgs), Max( 0.0, CN(mgs) - ccna(mgs) ) ) ! this was from
11296! 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
11297
11298 cn(mgs) = min(0.01*cnuc(mgs), max( 0.0, cn(mgs) - ccna(mgs) ) ) ! this was from
11299
11300 ENDIF ! }
11301! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
11302!!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11303 ! Philips, Donner et al. 2007, but results in too much limitation of
11304 ! nucleation
11305! CN(mgs) = Min(cn(mgs), ccnc(mgs))
11306! cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11307
11308
11309 IF ( icnuclimit > 0 ) THEN
11310! max droplet conc. based on Chandrakar et al. (2016) and Konwar et al. (2012)
11311 tmp = ccnc(mgs) - ccna(mgs) + cx(mgs,lc)
11312 IF ( tmp < 330.34e6 ) THEN
11313 ccwmax = 1.1173e6 * (1.e-6*tmp)**0.9504
11314 ELSE
11315 ccwmax = 21.57e6 * (1.e-6*tmp)**0.44
11316 ENDIF
11317
11318 cn(mgs) = max( 0.0, min( cn(mgs), ccwmax - cx(mgs,lc) ) )
11319
11320 ENDIF
11321
11322 IF ( cn(mgs) + cnuf(mgs) > 0.0 ) THEN
11323
11324 dcrit = 2.0*2.0e-6
11325 dcloud = 1000.*dcrit**3*pi/6.
11326 ! cn(mgs) = Min(cn(mgs), 0.5*dqc/dcloud) ! limit the nucleation mass to half of the condensation mass
11327 ! check new droplet size:
11328 ! tmp is number of droplets at diameter dcrit
11329 tmp = max(0.0, rho0(mgs)*qx(mgs,lc)/dcloud - cx(mgs,lc)) ! (cx(mgs,lc) + cn(mgs))
11330 cn(mgs) = min(tmp, cn(mgs) )
11331
11332 cx(mgs,lc) = cx(mgs,lc) + cn(mgs) + cnuf(mgs)
11333
11334
11335 ! create some small droplets at minimum size (CP 2000), although it adds very little liquid
11336
11337
11338 dcrit = 2.0*2.5e-7
11339 dcloud = 1000.*dcrit**3*pi/6.*(cn(mgs) + cnuf(mgs) )
11340 qx(mgs,lc) = qx(mgs,lc) + dcloud
11341 thetap(mgs) = thetap(mgs) + felvcp(mgs)*dcloud/(pi0(mgs))
11342 qwvp(mgs) = qwvp(mgs) - dcloud
11343 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11344 ccncuf(mgs) = max(0.0, ccncuf(mgs) - cnuf(mgs))
11345 ENDIF
11346
11347 ELSEIF ( irenuc == 8 ) THEN !} {
11348 ! simple Twomey scheme
11349! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11350
11351 cn(mgs) = 0.0
11352
11353 IF ( ccnc(mgs) > 0. ) THEN
11354 cn(mgs) = ccne0*ccnc(mgs)**(2./(2.+cck))*max(0.0,wvel(mgs))**cnexp ! *Min(1.0,1./dtp) ! 0.3465
11355! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
11356!!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11357 ! Philips, Donner et al. 2007, but results in too much limitation of
11358 ! nucleation
11359 cn(mgs) = min(cn(mgs), ccnc(mgs))
11360
11361 ELSEIF ( cx(mgs,lc) < 0.01e9 ) THEN
11362
11363 ! if a large fraction of CCN have been activated, then assume we are in the cloud interior and use local SSw as in Phillips et al. 2007.
11364
11365 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11366! t0(ix,jy,kz) = temp1
11367 ltemq = int( (temp1-163.15)/fqsat+1.5 )
11368 ltemq = min( nqsat, max(1,ltemq) )
11369
11370 ! c1 = t00(igs(mgs),jy,kgs(mgs))*tabqvs(ltemq)
11371 c1= pqs(mgs)*tabqvs(ltemq)
11372
11373 ssf(mgs) = 0.0
11374 IF ( c1 > 0. ) THEN
11375 ssf(mgs) = 100.*(qx(mgs,lv)/c1 - 1.0) ! from "new" values
11376 ENDIF
11377
11378! IF ( ssf(mgs) <= 1.0 .or. cnuc(mgs) > ccna(mgs) ) THEN
11379 IF ( ssf(mgs) <= 1.0 ) THEN
11380 cn(mgs) = 0.0
11381 ELSE
11382! CN(mgs) = 0.01e9*rho0(mgs)/rho00*Min(2.0, Max(0.0,0.03*(ssf(mgs)-1.0)+1.)**cck ) - cx(mgs,lc) !
11383 cn(mgs) = 0.01e9*min(2.0, max(0.0,0.03*(ssf(mgs)-1.0)+1.)**cck ) - cx(mgs,lc) !
11384 ENDIF
11385
11386 ENDIF
11387
11388 IF ( cn(mgs) > 0.0 ) THEN
11389 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11390
11391 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11392
11393 ! create some small droplets at minimum size (CP 2000), although it adds very little liquid
11394
11395 dcrit = 2.0*2.5e-7
11396
11397 dcloud = 1000.*dcrit**3*pi/6.*cn(mgs)
11398 qx(mgs,lc) = qx(mgs,lc) + dcloud
11399 thetap(mgs) = thetap(mgs) + felvcp(mgs)*dcloud/(pi0(mgs))
11400 qwvp(mgs) = qwvp(mgs) - dcloud
11401 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11402 ENDIF
11403
11404
11405
11406 ENDIF ! }
11407
11408 ccna(mgs) = ccna(mgs) + cn(mgs)
11409
11410 ENDIF ! irenuc >= 0 .and. .not. flag_qndrop
11411
11412 IF( cx(mgs,lc) .GT. 0. .AND. qx(mgs,lc) .LE. qxmin(lc)) cx(mgs,lc)=0.
11413 GO TO 631
11414!.... NUCLEATION ON CLOUD INFLOW BOUNDARY POINT
11415
11416 613 CONTINUE
11417
11418 631 CONTINUE
11419
11420!
11421! Check for supersaturation greater than ssmx and adjust down
11422!
11423 ssmx = maxsupersat
11424 qv1 = qv0(mgs) + qwvp(mgs)
11425 qvs1 = qvs(mgs)
11426
11427! IF ( flag_qndrop .and. do_satadj_for_wrfchem ) ssmx = 1.04 ! set lower threshold for progn=1 when using WRF-CHEM
11428
11429 IF ( qv1 .gt. (ssmx*qvs1) ) THEN
11430! use line below to disable saturation adjustment when flag_qndrop is true
11431! IF ( qv1 .gt. (ssmx*qvs1) .and. .not. flag_qndrop ) THEN
11432
11433 ss1 = qv1/qvs1
11434
11435 ssmx = 100.*(ssmx - 1.0)
11436
11437 qvex = 0.0
11438
11439 CALL qvexcess(ngs,mgs,qwvp,qv0,qx(1,lc),pres,thetap,theta0,qvex, &
11440 & pi0,tabqvs,nqsat,fqsat,cbw,fcqv1,felvcp,ssmx,pk,ngscnt)
11441
11442
11443
11444 IF ( qvex .gt. 0.0 ) THEN
11445 thetap(mgs) = thetap(mgs) + felvcp(mgs)*qvex/(pi0(mgs))
11446 IF ( io_flag .and. nxtra > 1 ) THEN
11447 axtra(igs(mgs),jy,kgs(mgs),1) = axtra(igs(mgs),jy,kgs(mgs),1) + qvex/dtp
11448 ENDIF
11449 qwvp(mgs) = qwvp(mgs) - qvex
11450 qx(mgs,lc) = qx(mgs,lc) + qvex
11451 IF ( .not. flag_qndrop) THEN
11452 IF ( imaxsupopt == 1 ) THEN
11453 cn(mgs) = min( max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/max( cwmasn5, xmas(mgs,lc) ) )
11454 ELSEIF ( imaxsupopt == 2 ) THEN
11455 cn(mgs) = min( max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/max( cwmasn5, max(cwmas30,xmas(mgs,lc)) ) )
11456 ELSEIF ( imaxsupopt == 3 ) THEN
11457 cn(mgs) = min( max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/max( cwmasn5, max(cwmasx,xmas(mgs,lc)) ) )
11458! cn(mgs) = 1.5*cxmin
11459 ELSEIF ( imaxsupopt == 4 ) THEN
11460 cn(mgs) = min( max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/max( cwmasn5, max(cwmas20,xmas(mgs,lc)) ) )
11461 ENDIF
11462 IF ( lccna > 1 ) THEN
11463 ccna(mgs) = ccna(mgs) + cn(mgs)
11464 ELSE
11465 ccnc(mgs) = max( 0.0, ccnc(mgs) - cn(mgs) )
11466 ENDIF
11467 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11468 ENDIF
11469
11470! write(iunit,*) 'theta = ',theta0(mgs) + thetap(mgs)
11471
11472! temg(mgs) = theta(mgs)*( pres(mgs) / poo ) ** cap
11473
11474 ENDIF
11475
11476
11477 ENDIF
11478
11479!
11480! Calculate droplet volume and check if it is within bounds.
11481! Adjust if necessary
11482!
11483! if (ndebug .gt. 0) write(0,*) "ICEZVD_DR: check droplet volume"
11484
11485
11486! cx(mgs,lc) = Min( cwnccn(mgs), cx(mgs,lc) )
11487 IF( cx(mgs,lc) > cxmin .AND. qx(mgs,lc) .GT. qxmin(lc)) THEN
11488! SVC(mgs) = rho0(mgs)*qx(mgs,lc)/(cx(mgs,lc)*xdn(mgs,lc))
11489 xmas(mgs,lc) = rho0(mgs)*qx(mgs,lc)/(cx(mgs,lc))
11490
11491 IF ( xmas(mgs,lc) < cwmasn .or. xmas(mgs,lc) > cwmasx ) THEN
11492 tmp = cx(mgs,lc)
11493 xmas(mgs,lc) = min( xmas(mgs,lc), cwmasx )
11494 xmas(mgs,lc) = max( xmas(mgs,lc), cwmasn )
11495 cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc)
11496! IF ( cx(mgs,lc) > tmp*1.1 ) THEN
11497! write(0,*) 'nucond: kgs, ccw1,2 = ',kgs(mgs),tmp,cx(mgs,lc)
11498! ENDIF
11499 ENDIF
11500 ENDIF
11501
11502
11503! IF( cx(mgs,lc) .GT. 10.e6 .AND. qx(mgs,lc) .GT. qxmin(lc) ) GO TO 681
11504! ccwtmp = cx(mgs,lc)
11505! cwmastmp = xmas(mgs,lc)
11506! xmas(mgs,lc) = Max(xmas(mgs,lc), cwmasn)
11507! IF (qx(mgs,lc) .GT. qxmin(lc) .AND. cx(mgs,lc) .le. 0.) THEN
11508! cx(mgs,lc) = Min(0.5*cwccn,rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc))
11509! xmas(mgs,lc) = rho0(mgs)*qx(mgs,lc)/cx(mgs,lc)
11510! ENDIF
11511! IF (cx(mgs,lc) .GT. 0. .AND. qx(mgs,lc) .GT. qxmin(lc)) &
11512! & xmas(mgs,lc) = rho0(mgs)*qx(mgs,lc)/cx(mgs,lc)
11513! IF (qx(mgs,lc) .GT. qxmin(lc) .AND. xmas(mgs,lc) .LT. cwmasn) &
11514! & xmas(mgs,lc) = cwmasn
11515! IF (qx(mgs,lc) .GT. qxmin(lc) .AND. xmas(mgs,lc) .GT. cwmasx) &
11516! & xmas(mgs,lc) = cwmasx
11517! IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN
11518! cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/Max(cwmasn,xmas(mgs,lc))
11519! ENDIF
11520!
11521!
11522! 681 CONTINUE
11523
11524
11525 IF ( ipconc .ge. 3 .and. rcond == 2 ) THEN
11526
11527
11528 IF (cx(mgs,lr) .GT. 0. .AND. qx(mgs,lr) .GT. qxmin(lr)) &
11529 & xv(mgs,lr)=rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr))
11530 IF (xv(mgs,lr) .GT. xvmx(lr)) xv(mgs,lr) = xvmx(lr)
11531 IF (xv(mgs,lr) .LT. xvmn(lr)) xv(mgs,lr) = xvmn(lr)
11532
11533 ENDIF
11534
11535
11536
11537 ENDDO ! mgs
11538
11539
11540! ################################################################
11541 DO mgs=1,ngscnt
11542 IF ( lss > 1 .and. ssf(mgs) .gt. ssmax(mgs) &
11543 & .and. ( idecss .eq. 0 .or. qx(mgs,lc) .gt. qxmin(lc)) ) THEN
11544 ssmax(mgs) = ssf(mgs)
11545 ENDIF
11546 ENDDO
11547!
11548
11549 do mgs = 1,ngscnt
11550 an(igs(mgs),jy,kgs(mgs),lt) = theta0(mgs) + thetap(mgs)
11551 an(igs(mgs),jy,kgs(mgs),lv) = qv0(mgs) + qwvp(mgs)
11552! 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)
11553!
11554 IF ( eqtset > 2 ) THEN
11555 p2(igs(mgs),jy,kgs(mgs)) = pipert(mgs)
11556 ENDIF
11557
11558 if ( ido(lc) .eq. 1 ) then
11559 an(igs(mgs),jy,kgs(mgs),lc) = qx(mgs,lc) + &
11560 & min( an(igs(mgs),jy,kgs(mgs),lc), 0.0 )
11561! qx(mgs,lc) = an(igs(mgs),jy,kgs(mgs),lc)
11562 end if
11563!
11564
11565 if ( ido(lr) .eq. 1 .and. rcond == 2 ) then
11566 an(igs(mgs),jy,kgs(mgs),lr) = qx(mgs,lr) + &
11567 & min( an(igs(mgs),jy,kgs(mgs),lr), 0.0 )
11568! qx(mgs,lr) = an(igs(mgs),jy,kgs(mgs),lr)
11569 end if
11570
11571 IF ( lzr > 1 .and. rcond == 2 ) THEN
11572 an(igs(mgs),jy,kgs(mgs),lzr) = zx(mgs,lr) + &
11573 & min( an(igs(mgs),jy,kgs(mgs),lzr), 0.0 )
11574 ENDIF
11575
11576
11577 IF ( ipconc .ge. 2 ) THEN
11578 an(igs(mgs),jy,kgs(mgs),lnc) = max(cx(mgs,lc) , 0.0)
11579 IF ( lss > 1 ) an(igs(mgs),jy,kgs(mgs),lss) = max( 0.0, ssmax(mgs) )
11580 IF ( ac_opt == 0 ) THEN
11581 IF ( lccn .gt. 1 .and. lccna .lt. 1 ) THEN
11582 an(igs(mgs),jy,kgs(mgs),lccn) = max(0.0, ccnc(mgs) )
11583 ENDIF
11584 ENDIF
11585 IF ( lccnuf .gt. 1 .and. .not. ( lccna .gt. 1 .and. i_uf_or_ccn > 0 ) ) THEN
11586 an(igs(mgs),jy,kgs(mgs),lccnuf) = max(0.0, ccncuf(mgs) )
11587 ENDIF
11588 IF ( lccna .gt. 1 ) THEN
11589 an(igs(mgs),jy,kgs(mgs),lccna) = max(0.0, ccna(mgs) )
11590 ENDIF
11591 ENDIF
11592 IF ( ipconc .ge. 3 .and. rcond == 2 ) THEN
11593 an(igs(mgs),jy,kgs(mgs),lnr) = max(cx(mgs,lr) , 0.0)
11594 ENDIF
11595 end do
11596
11597
1159829998 continue
11599
11600
11601 if ( kz .gt. nz-1 .and. ix .ge. nxi) then
11602 if ( ix .ge. nxi ) then
11603 go to 2200 ! exit gather scatter
11604 else
11605 nzmpb = kz
11606 endif
11607 else
11608 nzmpb = kz
11609 end if
11610
11611 if ( ix .ge. nxi ) then
11612 nxmpb = 1
11613 nzmpb = kz+1
11614 else
11615 nxmpb = ix+1
11616 end if
11617
11618 2000 continue ! inumgs
11619 2200 continue
11620!
11621! end of gather scatter (for this jy slice)
11622
11623
11624!#ifdef COMMAS
11625! GOTO 9999
11626!#endif
11627
11628! Redistribute inappreciable cloud particles and charge
11629!
11630! Redistribution everywhere in the domain...
11631!
11632 IF ( .true. ) THEN
11633
11634 frac = 1.0 ! 0.25 ! 1.0 ! 0.2
11635!
11636! alternate test version for ipconc .ge. 3
11637! just vaporize stuff to prevent noise in the number concentrations
11638
11639
11640 do kz = 1,nz
11641! do jy = 1,1
11642 do ix = 1,nxi
11643
11644 t0(ix,jy,kz) = an(ix,jy,kz,lt)*t77(ix,jy,kz)
11645
11646 zerocx(:) = .false.
11647 DO il = lc,lhab
11648 IF ( iresetmoments == 1 .or. iresetmoments == il ) THEN
11649 IF ( ln(il) > 1 ) zerocx(il) = ( an(ix,jy,kz,ln(il)) < cxmin )
11650 IF ( lz(il) > 1 ) zerocx(il) = ( zerocx(il) .or. an(ix,jy,kz,lz(il)) < zxmin )
11651 ELSE
11652 IF ( il == lc ) THEN
11653 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)
11654 ELSE
11655 IF ( ln(il) > 1 ) zerocx(il) = ( an(ix,jy,kz,ln(il)) <= 0 )
11656 ENDIF
11657 ENDIF
11658 ENDDO
11659
11660 IF ( lhl .gt. 1 ) THEN
11661
11662 IF ( lzhl .gt. 1 ) THEN
11663
11664 an(ix,jy,kz,lzhl) = max(0.0, an(ix,jy,kz,lzhl) )
11665
11666 IF ( an(ix,jy,kz,lhl) .ge. frac*qxmin(lhl) .and. rescale_low_alpha ) THEN ! check 6th moment
11667
11668 IF ( an(ix,jy,kz,lnhl) .gt. 0.0 ) THEN
11669
11670 IF ( lvhl .gt. 1 ) THEN
11671 IF ( an(ix,jy,kz,lvhl) .gt. 0.0 ) THEN
11672 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
11673 ELSE
11674 hwdn = xdn0(lhl)
11675 ENDIF
11676 hwdn = max( xdnmn(lhl), hwdn )
11677 ELSE
11678 hwdn = xdn0(lhl)
11679 ENDIF
11680
11681 chw = an(ix,jy,kz,lnhl)
11682 g1 = (6.0+alphamin)*(5.0+alphamin)*(4.0+alphamin)/ &
11683 & ((3.0+alphamin)*(2.0+alphamin)*(1.0+alphamin))
11684 z1 = g1*dn(ix,jy,kz)**2*( an(ix,jy,kz,lhl) )*an(ix,jy,kz,lhl)/chw
11685 z1 = z1*(6./(pi*hwdn))**2
11686 ELSE
11687 z1 = 0.0
11688 ENDIF
11689
11690 an(ix,jy,kz,lzhl) = min( z1, an(ix,jy,kz,lzhl) )
11691
11692 IF ( an(ix,jy,kz,lnhl) .lt. 1.e-5 ) THEN
11693! an(ix,jy,kz,lzhl) = 0.9*an(ix,jy,kz,lzhl)
11694 ENDIF
11695 ENDIF
11696
11697 ENDIF !lzhl
11698
11699 if ( an(ix,jy,kz,lhl) .lt. frac*qxmin(lhl) .or. zerocx(lhl) ) then
11700
11701! IF ( an(ix,jy,kz,lhl) .gt. 0 ) THEN
11702 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lhl)
11703 an(ix,jy,kz,lhl) = 0.0
11704! ENDIF
11705
11706 IF ( ipconc .ge. 5 ) THEN ! .and. an(ix,jy,kz,lnh) .gt. 0.0 ) THEN
11707 an(ix,jy,kz,lnhl) = 0.0
11708 ENDIF
11709
11710 IF ( lvhl .gt. 1 ) THEN
11711 an(ix,jy,kz,lvhl) = 0.0
11712 ENDIF
11713
11714 IF ( lhlw .gt. 1 ) THEN
11715 an(ix,jy,kz,lhlw) = 0.0
11716 ENDIF
11717
11718 IF ( lnhlf .gt. 1 ) THEN
11719 an(ix,jy,kz,lnhlf) = 0.0
11720 ENDIF
11721
11722 IF ( lzhl .gt. 1 ) THEN
11723 an(ix,jy,kz,lzhl) = 0.0
11724 ENDIF
11725
11726 ELSE
11727 IF ( lvol(lhl) .gt. 1 ) THEN ! check density
11728 IF ( an(ix,jy,kz,lvhl) .gt. 0.0 ) THEN
11729 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
11730 ELSE ! in case volume is zero but mass is above threshold (should not happen, of course)
11731 tmp = rho_qhl
11732 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
11733 ENDIF
11734
11735 IF ( tmp .lt. xdnmn(lhl) ) THEN
11736 tmp = max( xdnmn(lhl), tmp )
11737 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
11738 ENDIF
11739
11740 IF ( tmp .gt. xdnmx(lhl) .and. lhlw .le. 0 ) THEN ! no liquid allowed on hail
11741 tmp = min( xdnmx(lhl), tmp )
11742 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
11743 ELSEIF ( tmp .gt. xdnmx(lhl) .and. lhlw .gt. 1 ) THEN ! allow for liquid on hail
11744 fw = an(ix,jy,kz,lhlw)/an(ix,jy,kz,lhl)
11745! tmpmx = xdnmx(lhl) + fw*(xdnmx(lr) - xdnmx(lhl)) ! maximum possible average density
11746 ! it is not exactly linear, but approx. is close enough for this
11747! tmpmx = 1./( (1. - fw)/900. + fw/1000. ) is exact max, where 900 is xdnmx
11748
11749 tmpmx = xdnmx(lhl)/( 1. - fw*(1. - xdnmx(lhl)/xdnmx(lr) ))
11750
11751 IF ( tmp .gt. tmpmx ) THEN
11752 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmpmx
11753 ENDIF
11754
11755! IF ( tmp .gt. xdnmx(lhl) .and. an(ix,jy,kz,lhlw) .lt. qxmin(lhl) ) THEN
11756! tmp = Min( xdnmx(lhl), tmp )
11757! an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
11758! ELSEIF ( tmp .gt. xdnmx(lr) ) THEN
11759! tmp = xdnmx(lr)
11760! an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
11761! ENDIF
11762 ENDIF
11763
11764 IF ( lhlw .gt. 1 ) THEN ! check if basically pure water
11765 IF ( an(ix,jy,kz,lhlw) .gt. 0.98*an(ix,jy,kz,lhl) ) THEN
11766 tmp = xdnmx(lr)
11767 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
11768 ENDIF
11769 ENDIF
11770
11771 ENDIF
11772
11773
11774! CHECK INTERCEPT
11775 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
11776
11777 IF ( lvhl .gt. 1 ) THEN
11778 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
11779 ELSE
11780 hwdn = xdn0(lhl)
11781 ENDIF
11782 tmp = (hwdn*an(ix,jy,kz,lnhl))/(dn(ix,jy,kz)*an(ix,jy,kz,lhl))
11783 tmpg = an(ix,jy,kz,lnhl)*(tmp*(3.14159))**(1./3.)
11784 IF ( tmpg .lt. cnohlmn ) THEN
11785 tmp = ( (hwdn)/(dn(ix,jy,kz)*an(ix,jy,kz,lhl))*(3.14159))**(1./3.)
11786 an(ix,jy,kz,lnhl) = (cnohlmn/tmp)**(3./4.)
11787 ENDIF
11788
11789 ENDIF
11790! ELSE ! check mean size here?
11791
11792 end if
11793
11794 ENDIF !lhl
11795
11796
11797
11798 IF ( lzh .gt. 1 ) THEN
11799
11800 an(ix,jy,kz,lzh) = max(0.0, an(ix,jy,kz,lzh) )
11801
11802 IF ( .false. .and. an(ix,jy,kz,lh) .ge. frac*qxmin(lh) .and. rescale_low_alpha ) THEN
11803
11804 IF ( an(ix,jy,kz,lnh) .gt. 0.0 ) THEN
11805
11806 IF ( lvh .gt. 1 ) THEN
11807 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
11808 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
11809 ELSE
11810 hwdn = xdn0(lh)
11811 ENDIF
11812 hwdn = max( xdnmn(lh), hwdn )
11813 ELSE
11814 hwdn = xdn0(lh)
11815 ENDIF
11816
11817 chw = an(ix,jy,kz,lnh)
11818 g1 = (6.0+alphamin)*(5.0+alphamin)*(4.0+alphamin)/ &
11819 & ((3.0+alphamin)*(2.0+alphamin)*(1.0+alphamin))
11820 z1 = g1*dn(ix,jy,kz)**2*( an(ix,jy,kz,lh) )*an(ix,jy,kz,lh)/chw
11821 z1 = z1*(6./(pi*hwdn))**2
11822 ELSE
11823 z1 = 0.0
11824 ENDIF
11825
11826 an(ix,jy,kz,lzh) = min( z1, an(ix,jy,kz,lzh) )
11827
11828 IF ( an(ix,jy,kz,lnh) .lt. 1.e-5 ) THEN
11829! an(ix,jy,kz,lzh) = 0.9*an(ix,jy,kz,lzh)
11830 ENDIF
11831 ENDIF
11832
11833 ENDIF
11834
11835 if ( an(ix,jy,kz,lh) .lt. frac*qxmin(lh) .or. zerocx(lh) ) then
11836
11837! IF ( an(ix,jy,kz,lh) .gt. 0 ) THEN
11838 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lh)
11839 an(ix,jy,kz,lh) = 0.0
11840! ENDIF
11841
11842 IF ( ipconc .ge. 5 ) THEN ! .and. an(ix,jy,kz,lnh) .gt. 0.0 ) THEN
11843 an(ix,jy,kz,lnh) = 0.0
11844 ENDIF
11845
11846 IF ( lvh .gt. 1 ) THEN
11847 an(ix,jy,kz,lvh) = 0.0
11848 ENDIF
11849
11850 IF ( lhw .gt. 1 ) THEN
11851 an(ix,jy,kz,lhw) = 0.0
11852 ENDIF
11853
11854 IF ( lnhf .gt. 1 ) THEN
11855 an(ix,jy,kz,lnhf) = 0.0
11856 ENDIF
11857
11858 IF ( lzh .gt. 1 ) THEN
11859 an(ix,jy,kz,lzh) = 0.0
11860 ENDIF
11861
11862 ELSE
11863 IF ( lvol(lh) .gt. 1 ) THEN ! check density
11864 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
11865 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
11866 ELSE
11867 tmp = rho_qh
11868 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
11869 ENDIF
11870
11871 IF ( tmp .lt. xdnmn(lh) ) THEN
11872 tmp = max( xdnmn(lh), tmp )
11873 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
11874 ENDIF
11875
11876 IF ( tmp .gt. xdnmx(lh) .and. lhw .le. 0 ) THEN ! no liquid allowed on graupel
11877 tmp = min( xdnmx(lh), tmp )
11878 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
11879 ELSEIF ( tmp .gt. xdnmx(lh) .and. lhw .gt. 1 ) THEN ! allow for liquid on graupel
11880 fw = an(ix,jy,kz,lhw)/an(ix,jy,kz,lh)
11881! tmpmx = xdnmx(lh) + fw*(xdnmx(lr) - xdnmx(lh)) ! maximum possible average density
11882 ! it is not exactly linear, but approx. is close enough for this
11883! tmpmx = 1./( (1. - fw)/900. + fw/1000. ) is exact max, where 900 is xdnmx
11884 tmpmx = xdnmx(lh)/( 1. - fw*(1. - xdnmx(lh)/xdnmx(lr) ))
11885
11886 IF ( tmp .gt. tmpmx ) THEN
11887 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmpmx
11888 ENDIF
11889
11890! IF ( tmp .gt. xdnmx(lh) .and. an(ix,jy,kz,lhw) .lt. qxmin(lh) ) THEN
11891! tmp = Min( xdnmx(lh), tmp )
11892! an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
11893! ELSEIF ( tmp .gt. xdnmx(lr) ) THEN
11894! tmp = xdnmx(lr)
11895! an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
11896! ENDIF
11897
11898 ENDIF
11899
11900 IF ( lhw .gt. 1 ) THEN ! check if basically pure water
11901 IF ( an(ix,jy,kz,lhw) .gt. 0.98*an(ix,jy,kz,lh) ) THEN
11902 tmp = xdnmx(lr)
11903 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
11904 ENDIF
11905 ENDIF
11906
11907 ENDIF
11908
11909! CHECK INTERCEPT
11910 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
11911
11912 IF ( lvh .gt. 1 ) THEN
11913 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
11914 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
11915 ELSE
11916 hwdn = xdn0(lh)
11917 ENDIF
11918 hwdn = max( xdnmn(lh), hwdn )
11919 ELSE
11920 hwdn = xdn0(lh)
11921 ENDIF
11922 tmp = (hwdn*an(ix,jy,kz,lnh))/(dn(ix,jy,kz)*an(ix,jy,kz,lh))
11923 tmpg = an(ix,jy,kz,lnh)*(tmp*(3.14159))**(1./3.)
11924 IF ( tmpg .lt. cnohmn ) THEN
11925! 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.)
11926! tmpg = an(ix,jy,kz,lnh)**(4./3.)*( (hwdn)/(dn(ix,jy,kz)*an(ix,jy,kz,lh))*(3.14159))**(1./3.)
11927 tmp = ( (hwdn)/(dn(ix,jy,kz)*an(ix,jy,kz,lh))*(3.14159))**(1./3.)
11928 an(ix,jy,kz,lnh) = (cnohmn/tmp)**(3./4.)
11929 ENDIF
11930
11931 ENDIF
11932
11933 end if
11934
11935
11936 if ( an(ix,jy,kz,ls) .lt. frac*qxmin(ls) .or. zerocx(ls) & ! .or. an(ix,jy,kz,lns) .lt. 0.1 ! .and.
11937 & ) then
11938 IF ( t0(ix,jy,kz) .lt. 273.15 ) THEN
11939! IF ( an(ix,jy,kz,ls) .gt. 0 ) THEN
11940 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,ls)
11941 an(ix,jy,kz,ls) = 0.0
11942! ENDIF
11943
11944 IF ( ipconc .ge. 4 ) THEN ! .and. an(ix,jy,kz,lns) .gt. 0.0 ) THEN !
11945! an(ix,jy,kz,lni) = an(ix,jy,kz,lni) + an(ix,jy,kz,lns)
11946 an(ix,jy,kz,lns) = 0.0
11947 ENDIF
11948
11949 IF ( lvs .gt. 1 ) THEN
11950 an(ix,jy,kz,lvs) = 0.0
11951 ENDIF
11952
11953 IF ( lsw .gt. 1 ) THEN
11954 an(ix,jy,kz,lsw) = 0.0
11955 ENDIF
11956
11957 ELSE
11958! IF ( an(ix,jy,kz,ls) .gt. 0 ) THEN
11959 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,ls)
11960 an(ix,jy,kz,ls) = 0.0
11961! ENDIF
11962
11963 IF ( lvs .gt. 1 ) THEN
11964 an(ix,jy,kz,lvs) = 0.0
11965 ENDIF
11966
11967 IF ( lsw .gt. 1 ) THEN
11968 an(ix,jy,kz,lsw) = 0.0
11969 ENDIF
11970
11971 IF ( ipconc .ge. 4 ) THEN ! .and. an(ix,jy,kz,lns) .gt. 0.0 ) THEN !
11972! an(ix,jy,kz,lnr) = an(ix,jy,kz,lnr) + an(ix,jy,kz,lns)
11973 an(ix,jy,kz,lns) = 0.0
11974 ENDIF
11975
11976 ENDIF
11977
11978
11979 ELSEIF ( lvol(ls) .gt. 1 ) THEN ! check density
11980 IF ( an(ix,jy,kz,lvs) .gt. 0.0 ) THEN
11981 tmp = dn(ix,jy,kz)*an(ix,jy,kz,ls)/an(ix,jy,kz,lvs)
11982 IF ( tmp .gt. xdnmx(ls) .or. tmp .lt. xdnmn(ls) ) THEN
11983 tmp = min( xdnmx(ls), max( xdnmn(ls), tmp ) )
11984 an(ix,jy,kz,lvs) = dn(ix,jy,kz)*an(ix,jy,kz,ls)/tmp
11985 ENDIF
11986 ELSE
11987 tmp = rho_qs
11988 an(ix,jy,kz,lvs) = dn(ix,jy,kz)*an(ix,jy,kz,ls)/tmp
11989 ENDIF
11990
11991
11992 end if
11993
11994 IF ( lzr > 1 ) THEN
11995 an(ix,jy,kz,lzr) = max(0.0, an(ix,jy,kz,lzr) )
11996 ENDIF
11997
11998 if ( an(ix,jy,kz,lr) .lt. frac*qxmin(lr) .or. zerocx(lr) &
11999 & ) then
12000 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lr)
12001 an(ix,jy,kz,lr) = 0.0
12002 IF ( ipconc .ge. 3 ) THEN
12003! an(ix,jy,kz,lnc) = an(ix,jy,kz,lnc) + an(ix,jy,kz,lnr)
12004 an(ix,jy,kz,lnr) = 0.0
12005 ENDIF
12006
12007 IF ( lzr > 1 ) THEN
12008 an(ix,jy,kz,lzr) = 0.0
12009 ENDIF
12010
12011 end if
12012
12013!
12014! for qci
12015!
12016 IF ( an(ix,jy,kz,li) .le. frac*qxmin(li) .or. zerocx(li) & ! .or. an(ix,jy,kz,lni) .lt. 0.1
12017 & ) THEN
12018 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,li)
12019 an(ix,jy,kz,li)= 0.0
12020 IF ( ipconc .ge. 1 ) THEN
12021 an(ix,jy,kz,lni) = 0.0
12022 ENDIF
12023 ENDIF
12024
12025!
12026! for qis
12027!
12028 IF ( lis > 1 ) THEN ! {
12029 IF ( an(ix,jy,kz,lis) .le. frac*qxmin(lis) .or. zerocx(lis) & ! .or. an(ix,jy,kz,lni) .lt. 0.1
12030 & ) THEN ! { {
12031 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lis)
12032 an(ix,jy,kz,lis)= 0.0
12033 IF ( ipconc .ge. 1 ) THEN
12034 an(ix,jy,kz,lnis) = 0.0
12035 ENDIF
12036
12037 ELSEIF ( icespheres >= 2 ) THEN ! } {
12038 km1 = max(1, kz-1)
12039 IF ( 0.5*( w(ix,jy,kz) + w(ix,jy,kz+1)) < -1.0 .or. &
12040 & (icespheres == 3 .and. ( t0(ix,jy,kz) < 232.15 .or. an(ix,jy,kz,lc) < qxmin(lc) ) ) .or. &
12041 & (icespheres == 5 .and. ( t0(ix,jy,kz) < 232.15 .or. &
12042 & ( an(ix,jy,kz,lc) < qxmin(lc) .and. an(ix,jy,km1,lc) < qxmin(lc) )) ) .or. &
12043 & (icespheres == 4 .and. ( t0(ix,jy,kz) < 235.15 )) ) THEN ! transfer to regular ice crystals in downdraft or at low temp
12044 an(ix,jy,kz,li) = an(ix,jy,kz,li) + an(ix,jy,kz,lis)
12045 an(ix,jy,kz,lni) = an(ix,jy,kz,lni) + an(ix,jy,kz,lnis)
12046 an(ix,jy,kz,lis)= 0.0
12047 an(ix,jy,kz,lnis)= 0.0
12048
12049 ENDIF
12050
12051 ENDIF ! } }
12052 ENDIF ! }
12053
12054!
12055! for qcw
12056!
12057
12058 IF ( an(ix,jy,kz,lc) .le. frac*qxmin(lc) .or. zerocx(lc) &
12059 & ) THEN
12060 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lc)
12061 an(ix,jy,kz,lc)= 0.0
12062 IF ( ipconc .ge. 2 ) THEN
12063 IF ( lccn .gt. 1 .or. ac_opt == 1 ) THEN
12064 IF ( irenuc < 5 .and. lccna <= 1 ) THEN
12065 IF ( ac_opt == 0 ) THEN
12066 an(ix,jy,kz,lccn) = an(ix,jy,kz,lccn) + max(0.0,an(ix,jy,kz,lnc))
12067 ENDIF
12068 ELSEIF ( lccna > 1 ) THEN
12069 an(ix,jy,kz,lccna) = max( 0.0, an(ix,jy,kz,lccna) - max(0.0,an(ix,jy,kz,lnc)) )
12070 ENDIF
12071 ENDIF
12072 an(ix,jy,kz,lnc) = 0.0
12073 IF ( lccn > 1 ) an(ix,jy,kz,lccn) = max( 0.0, an(ix,jy,kz,lccn) )
12074
12075 IF ( lccna > 0 .and. ac_opt == 0 ) THEN ! apply exponential decay to activated CCN to restore to environmental value
12076 IF ( restoreccn ) THEN
12077 tmp = an(ix,jy,kz,li) + an(ix,jy,kz,ls)
12078
12079 IF ( an(ix,jy,kz,lccna) > 1. .and. tmp < qxmin(li) ) an(ix,jy,kz,lccna) = an(ix,jy,kz,lccna)*exp(-dtp/ccntimeconst)
12080 ENDIF
12081 ELSEIF ( lccn > 1 .and. restoreccn .and. ac_opt == 0 ) THEN
12082 ! in this case, we are treating the ccn field as ccna
12083 tmp = an(ix,jy,kz,li) + an(ix,jy,kz,ls)
12084! IF ( ny == 2 .and. ix == nx/2 ) THEN
12085! write(0,*) 'restore: k, qccn,exp = ',kz,qccn,dn(ix,jy,kz)*qccn,Exp(-dtp/ccntimeconst)
12086! 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)
12087! ENDIF
12088 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
12089 ! an(ix,jy,kz,lccn) = &
12090 ! an(ix,jy,kz,lccn) + Max(0.0 , dn(ix,jy,kz)*qccn - an(ix,jy,kz,lccn))*(1.0 - Exp(-dtp/ccntimeconst))
12091 ! Equivalent form after expanding last term:
12092 an(ix,jy,kz,lccn) = &
12093 dn(ix,jy,kz)*qccn - max(0.0 , dn(ix,jy,kz)*qccn - an(ix,jy,kz,lccn))*exp(-dtp/ccntimeconst)
12094 ENDIF
12095
12096 ENDIF
12097
12098 ENDIF
12099
12100 ENDIF
12101
12102 end do
12103! end do
12104 end do
12105
12106 ENDIF ! true/false
12107
12108 IF ( ndebug .ge. 1 ) write(6,*) 'END OF ICEZVD_DR'
12109!
12110!
12111
12112
12113 9999 RETURN
12114
12115 END SUBROUTINE nucond
12116
12117
12118! #####################################################################
12119! #####################################################################
12122
12123
12124
12125
12126!c--------------------------------------------------------------------------
12127!
12128!
12129!--------------------------------------------------------------------------
12130!
12131
12132 subroutine nssl_2mom_gs &
12133 & (nx,ny,nz,na,jyslab &
12134 & ,nor,norz &
12135 & ,dtp,gz &
12136 & ,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9 &
12137 & ,an,dn,p2 &
12138 & ,pn,w,iunit &
12139 & ,t00,t77, &
12140 & ventr,ventc,c1sw,jgs,ido, &
12141 & xdnmx,xdnmn, &
12142! & ln,ipc,lvol,lz,lliq, &
12143 & cdx, &
12144 & xdn0,tmp3d,tkediss &
12145 & ,thproc,numproc,dx1,dy1,ngs &
12146 & ,timevtcalc,axtra,io_flag &
12147 & , has_wetscav,rainprod2d, evapprod2d, alpha2d &
12148 & ,errmsg,errflg &
12149 & ,elec,its,ids,ide,jds,jde &
12150 & )
12151
12152
12153!
12154!--------------------------------------------------------------------------
12155!
12156! Ziegler 1985 parameterized microphysics (also Zrnic et al. 1993)
12157! 1) cloud water
12158! 2) rain
12159! 3) column ice
12160! 6) snow
12161! 11) graupel/hail
12162!
12163!--------------------------------------------------------------------------
12164!
12165! Notes:
12166!
12167! 4/27/2009: allows for liquid water to be advected on snow and graupel particles using flag "mixedphase"
12168!
12169! 3/14/2007: (APS) added qproc temp to make microphysic process timeseries
12170!
12171! 10/17/2006: added flag (iehw) to select how to calculate ehw
12172!
12173! 10/5/2006: switched chacr to integrated version rather than assuming that average rain
12174! drop mass does not change. This acts to reduce rain size somewhat via graupel
12175! collection.
12176! Use Mason data for ehw, with scaling toward ehw=1 as air density decreases.
12177!
12178! 10/3/2006: Turned off Meyers nucleation for T > -5 (can turn on with imeyers5 flag)
12179! Turned off contact nucleation in updrafts
12180!
12181! 7/24/2006: Turned on Meyers nucleation for -5 < T < 0
12182!
12183! 5/12/2006: Converted qsacw/csacw and qsaci/csaci to Z93
12184!
12185! 5/12/2006: Put a threshold on Bigg rain freezing. If the frozen drops
12186! have an average volume less than xvhmn, then the drops are put
12187! into snow instead of graupel/hail.
12188!
12189! Fixed bug when vapor deposition was limited.
12190!
12191! 5/13/2006: Note that qhacr has a large effect, but Z85 did not include it.
12192! Turned off qsacr (set to zero).
12193!
12194! 9/14/2007: erm: recalculate vx(lh) after setting xdn(lh) in case xdn was out of allowed range.
12195! added parameter rimc3 for minimum rime density. Default value set at 170. kg/m**3
12196! instead of previous use of 100. (Farley, 1987)
12197!
12198!--------------------------------------------------------------------------
12199!
12200! general declarations
12201!
12202!--------------------------------------------------------------------------
12203!
12204!
12205!
12206
12207
12208 implicit none
12209!
12210! integer icond
12211! parameter ( icond = 2 )
12212
12213 integer, parameter :: ng1 = 1
12214
12215 integer nx,ny,nz,na,nba,nv
12216 integer nor,norz,istag,jstag,kstag ! ,nht,ngt,igsr
12217 integer iwrite
12218 real dtp,dx,dy,dz
12219
12220 logical, intent(in) :: io_flag
12221
12222 integer itile,jtile,ktile
12223 integer ixbeg,jybeg
12224 integer ixend,jyend,kzend,kzbeg
12225 integer nxend,nyend,nzend,nzbeg
12226 integer :: my_rank = 0
12227 integer, parameter :: myprock = 1, nprock = 1
12228 logical, intent(in) :: has_wetscav
12229 integer, intent(in) :: numproc
12230 real, intent(inout) :: thproc(nz,numproc)
12231 real, intent(in) :: dx1,dy1
12232 real rainprod2d(-nor+1:nx+nor,-norz+ng1:nz+norz)
12233 real evapprod2d(-nor+1:nx+nor,-norz+ng1:nz+norz)
12234
12235
12236 real :: alpha2d(-nor+1:nx+nor,-norz+ng1:nz+norz,3)
12237
12238 real, parameter :: tfrdry = 243.15
12239
12240 logical lrescalelow(lc:lhab)
12241 real tkediss(-nor+1:nx+nor,-norz+ng1:nz+norz)
12242 real axtra(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz,nxtra)
12243
12244 real :: galpharaut
12245 real :: xvbarmax
12246
12247 integer jyslab,its,ids,ide,jds,jde ! domain boundaries
12248 integer, intent(in) :: iunit !,iunit0
12249 real qvex
12250 integer iraincv, icgxconv
12251 parameter( iraincv = 1, icgxconv = 1)
12252 real ffrz
12253 real :: ffrzh = 1.0
12254
12255 real qcitmp,cirdiatmp ! ,qiptmp,qirtmp
12256 real ccwtmp,ccitmp ! ,ciptmp,cirtmp
12257 real cpqc,cpci ! ,cpip,cpir
12258 real cpqc0,cpci0 ! ,cpip0,cpir0
12259 real scfac ! ,cpip1
12260
12261 double precision dp1
12262
12263 double precision frac, frach, xvfrz, xvbiggsnow
12264
12265 double precision :: timevtcalc
12266 double precision :: dpt1,dpt2
12267
12268 logical, parameter :: gammacheck = .false.
12269 integer :: luindex
12270 double precision :: tmpgam
12271 logical, parameter :: usegamxinfcnu = .false.
12272 logical, parameter :: usegamxinf = .false.
12273 logical, parameter :: usegamxinf2 = .false.
12274 logical, parameter :: usegamxinf3 = .false.
12275! real rar ! rime accretion rate as calculated from qxacw
12276
12277 ! CCPP error handling
12278 character(len=*), intent( out) :: errmsg
12279 integer, intent( out) :: errflg
12280! a few vars for time-split fallout
12281 real vtmax
12282 integer n,ndfall
12283
12284 double precision chgneg,chgpos,sctot
12285
12286 real temgtmp
12287
12288 real pb(-norz+ng1:nz+norz)
12289 real pinit(-norz+ng1:nz+norz)
12290
12291 real gz(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz) ! dz
12292
12293 real qimax,xni0,roqi0
12294
12295
12296 real dv
12297
12298 real dtptmp
12299 integer itest,nidx,id1,jd1,kd1
12300 parameter(itest=1)
12301 parameter(nidx=10)
12302 parameter(id1=1,jd1=1,kd1=1)
12303 integer ierr
12304 integer iend
12305
12306 integer ix,kz, il, ic, ir, icp1, irp1, ip1,jp1,kp1
12307 integer :: jy
12308 integer i,j,k,i1
12309 integer kzb,kze
12310 real slope1, slope2
12311 real x1, x2, x3
12312 real eps,eps2
12313 parameter(eps=1.e-20,eps2=1.e-5)
12314!
12315! Other elec. vars
12316!
12317 real temele
12318 real trev
12319
12320 logical ldovol, ishail, ltest, wtest
12321 logical , parameter :: alp0flag = .false.
12322!
12323!
12324! wind indicies
12325!
12326 integer mu,mv,mw
12327 parameter(mu=1,mv=2,mw=3)
12328!
12329! conversion parameters
12330!
12331 integer mqcw,mqxw,mtem,mrho,mtim
12332 parameter(mqcw=21,mqxw=21,mtem=21,mrho=5,mtim=6)
12333
12334 real xftim,xftimi,yftim, xftem,yftem, xfqcw,yfqcw, xfqxw,yfqxw
12335 parameter(xftim=0.05,xftimi = 1./xftim,yftim=1.)
12336 parameter(xftem=0.5,yftem=1.)
12337 parameter(xfqcw=2000.,yfqcw=1.)
12338 parameter(xfqxw=2000.,yfqxw=1.)
12339 real dtfac
12340 parameter( dtfac = 1.0 )
12341 integer ido(lc:lqmx)
12342
12343! integer iexy(lc:lqmx,lc:lqmx)
12344! integer ieswi, ieswir, ieswip, ieswc, ieswr
12345! integer ieglsw, iegli, ieglir, ieglip, ieglc, ieglr
12346! integer iegmsw, iegmi, iegmir, iegmip, iegmc, iegmr
12347! integer ieghsw, ieghi, ieghir, ieghip, ieghc, ieghr
12348! integer iefwsw, iefwi, iefwir, iefwip, iefwc, iefwr
12349! integer iehwsw, iehwi, iehwir, iehwip, iehwc, iehwr
12350! integer iehlsw, iehli, iehlir, iehlip, iehlc, iehlr
12351! real delqnsa, delqxsa, delqnsb, delqxsb, delqnia, delqxia
12352! real delqnra, delqxra
12353
12354 real delqnxa(lc:lqmx)
12355 real delqxxa(lc:lqmx)
12356!
12357! external temporary arrays
12358!
12359 real t00(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12360 real t77(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12361
12362 real t0(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12363 real t1(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12364 real t2(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12365 real t3(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12366 real t4(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12367 real t5(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12368 real t6(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12369 real t7(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12370 real t8(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12371 real t9(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12372
12373 real p2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz) ! perturbation Pi
12374 real pn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz)
12375 real an(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz,na)
12376 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz)
12377 real w(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz)
12378
12379 real tmp3d(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12380
12381!
12382! declarations microphyscs and for gather/scatter
12383!
12384 integer nxmpb,nzmpb,nxz
12385 integer jgs,mgs,ngs,numgs
12386 integer, parameter :: ngsz = 500
12387 integer ntt
12388 parameter(ntt=300)
12389
12390 real dvmgs(ngs)
12391
12392 integer ngscnt,igs(ngs),kgs(ngs)
12393 integer kgsp(ngs),kgsm(ngs),kgsm2(ngs)
12394 integer ncuse
12395 parameter(ncuse=0)
12396 integer il0(ngs),il5(ngs),il2(ngs),il3(ngs)
12397! integer il1m(ngs),il2m(ngs),il3m(ngs),il4m(ngs),il5m(ngs)
12398!
12399 real tdtol,temsav,tfrcbw,tfrcbi
12400 real, parameter :: thnuc = 235.15
12401!
12402! Ice Multiplication Arrays.
12403!
12404 real fimt1(ngs),fimta(ngs),fimt2(ngs) !,qmul1(ngs),qmul2(ngs)
12405 real xcwmas
12406!
12407!
12408! Variables for Ziegler warm rain microphysics
12409!
12410
12411
12412 real ccnc(ngs),ccin(ngs),cina(ngs),ccna(ngs)
12413 real cwnccn(ngs)
12414 real sscb ! 'cloud base' SS threshold
12415 parameter( sscb = 2.0 )
12416 integer idecss ! flag to turn on (=1) decay of ssmax when no cloud or ice crystals
12417 parameter( idecss = 1 )
12418 integer iba ! flag to do condensation/nucleation in 1st or 2nd loop
12419 ! =0 to use ad to calculate SS
12420 ! =1 to use an at end of main jy loop to calculate SS
12421 parameter(iba = 1)
12422 integer ifilt ! =1 to filter ssat, =0 to set ssfilt=ssat
12423 parameter( ifilt = 0 )
12424 real temp1,temp2 ! ,ssold
12425 real :: mwat, mice, dice, mwshed, fwmax, fw, mwcrit, massfactor, tmpdiam
12426 real, parameter :: shedalp = 3. ! set 3 for maximum mass diameter (same as area-weighted diameter), 4 for mass-weighted diameter
12427 real ssmax(ngs) ! maximum SS experienced by a parcel
12428 real ssmx
12429 real dnnet,dqnet
12430! real cnu,rnu,snu,cinu
12431! parameter ( cnu = 0.0, rnu = -0.8, snu = -0.8, cinu = 0.0 )
12432 real bfnu, bfnu0, bfnu1
12433 parameter( bfnu0 = (rnu + 2.0)/(rnu + 1.0) )
12434 real ventr, ventc
12435 real volb
12436 double precision t2s, xdp
12437 double precision xl2p(ngs),rb(ngs)
12438 real, parameter :: aa1 = 9.44e15, aa2 = 5.78e3 ! a1 in Ziegler
12439! snow parameters:
12440 real, parameter :: cexs = 0.1, cecs = 0.5
12441 real, parameter :: rvt = 0.104 ! ratio of collection kernels (Zrnic et al, 1993)
12442 real, parameter :: kfrag = 1.0e-6 ! rate coefficent for collisional splintering (Schuur & Rutledge 00b)
12443 real, parameter :: mfrag = 1.0e-10 ! assumed ice fragment mass for collisional splintering (Schuur & Rutledge 00b)
12444 double precision cautn(ngs), rh(ngs), nh(ngs)
12445 real ex1, ft, rhoinv(ngs)
12446 double precision ec0(ngs)
12447
12448 real ac1,bc, taus, c1,d1,e1,f1,p380,tmp,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,temp3 ! , sstdy, super
12449 real :: flim
12450 real dw,dwr
12451 double precision :: tmpz, tmpzmlt
12452 real ratio, delx, dely
12453 real dbigg,volt
12454 real chgtmp,fac,mixedphasefac
12455 real x,y,y2,del,r,rtmp,alpr
12456 double precision :: vent1,vent2
12457 double precision :: g1palp,g4palp
12458 double precision :: g1palpinf,g4palpinf
12459 real fqt !charge separation as fn of temperature from Dong and Hallett 1992
12460 real bs
12461 real v1, v2
12462 real d1r, d1i, d1s, e1i
12463 real c1sw ! integration factor for snow melting with snu = -0.8
12464 real, parameter :: vr1mm = 5.23599e-10 ! volume of 1mm diameter sphere (m**3)
12465 real, parameter :: vr3mm = 5.23599e-10*(3.0/1.)**3 ! volume of a 3 mm diameter sphere (m**3) (Rasmussen et al. 1984b, JAS)
12466 real, parameter :: vr4p5mm = 5.23599e-10*(4.5/1.)**3 ! volume of 4.5mm diameter sphere (m**3) (Rasmussen et al. 1984b, JAS)
12467 real vmlt,vshd, vshdgs(ngs,lh:lhab), maxmassfac(lc:lhab)
12468 real rhosm
12469 parameter( rhosm = 500. )
12470 integer nc ! condensation step
12471 real dtcon,dtcon1,dtcon2 ! condensation time step (dtcon*nc = dtp)
12472 real delta
12473 integer ltemq1,ltemq1m ! ,ltemq1m2
12474 real dqv,qv1,ss1,ss2,qvs1,dqvs,dtemp,dt1 ! temporaries for condensation
12475 real ssi1, ssi2, dqvi, dqvis, dqvii,qis1
12476 real dqvr, dqc, dqr, dqi, dqs
12477 real qv1m,qvs1m,ss1m,ssi1m,qis1m
12478 real cwmastmp
12479 real dcloud,dcloud2 ! ,as, bs
12480 real cn(ngs)
12481 double precision xvc, xvr
12482 real mwfac
12483! real es(ngs) ! ss(ngs),
12484! real eis(ngs)
12485
12486 real rwmasn,rwmasx
12487
12488 real vgra,vfrz
12489 parameter( vgra = 0.523599*(1.0e-3)**3 )
12490
12491! real, parameter :: epsi = 0.622
12492! real, parameter :: d = 0.266
12493 real :: d, dold, denom,denominv,vth
12494 double precision :: h1, h2, h3, h4,denomdp, denominvdp
12495 real r1,qevap ! ,slv
12496
12497 real vr,nrx,chw,g1,qr,z,z1,rdi,alp,xnutmp,xnuc,g1r,rd1,rdia,rmas
12498 real :: snowmeltmass = 0
12499
12500! real, parameter :: rhofrz = 900. ! density of graupel from newly-frozen rain
12501 real, parameter :: rimedens = 500. ! default rime density
12502
12503! real svc(ngs) ! droplet volume
12504!
12505! contact freezing nucleation
12506!
12507 real raero,kaero !assumd aerosol radius, thermal conductivity
12508 parameter( raero = 3.e-7, kaero = 5.39e-3 )
12509 real kb ! Boltzman constant J K-1
12510 parameter(kb = 1.3807e-23)
12511
12512 real knud(ngs),knuda(ngs) !knudsen number and correction factor
12513 real gtp(ngs) !G(T,p) = 1/(a' + b') Cotton 72b
12514 real dfar(ngs) !aerosol diffusivity
12515 real fn1(ngs),fn2(ngs),fnft(ngs)
12516
12517 real ccia(ngs)
12518 real ctfzbd(ngs),ctfzth(ngs),ctfzdi(ngs)
12519!
12520! misc
12521!
12522 real ni,nis,nr,d0
12523 real dqvcnd(ngs),dqwv(ngs),dqcw(ngs),dqci(ngs),dqcitmp(ngs),dqwvtmp(ngs)
12524 real tempc(ngs)
12525 real temg(ngs),temcg(ngs),theta(ngs),qvap(ngs)
12526 real temgkm1(ngs), temgkm2(ngs)
12527 real temgx(ngs),temcgx(ngs)
12528 real qvs(ngs),qis(ngs),qss(ngs),pqs(ngs)
12529 real elv(ngs),elf(ngs),els(ngs)
12530 real tsqr(ngs),ssi(ngs),ssw(ngs),ssi0(ngs)
12531 real qcwtmp(ngs),qtmp,qtot(ngs)
12532 real qcond(ngs)
12533 real ctmp, sctmp
12534 real cimasn,cimasx,ccimx
12535 real pid4
12536 real cs,ds,gf7,gf6,gf5,gf4,gf3,gf2,gf1
12537 real gcnup1,gcnup2
12538 real gf73rds, gf83rds
12539 real gamice73fac, gamsnow73fac
12540 real gf43rds, gf53rds
12541 real aradcw,bradcw,cradcw,dradcw,cwrad,rwrad,rwradmn
12542 parameter( rwradmn = 50.e-6 )
12543 real dh0
12544 real dg0(ngs),df0(ngs)
12545 real dhwet(ngs),dhlwet(ngs),dfwet(ngs)
12546
12547 real clionpmx,clionnmx
12548 parameter(clionpmx=1.e9,clionnmx=1.e9) ! Takahashi 84
12549!
12550! other arrays
12551
12552 real fwet1(ngs),fwet2(ngs)
12553 real fmlt1(ngs),fmlt2(ngs),fmlt1e(ngs)
12554 real fvds(ngs),fvce(ngs),fiinit(ngs)
12555 real fvent(ngs),fraci(ngs),fracl(ngs)
12556!
12557 real fai(ngs),fav(ngs),fbi(ngs),fbv(ngs)
12558 real felv(ngs),fels(ngs),felf(ngs)
12559 real felvcp(ngs),felscp(ngs),felfcp(ngs)
12560 real felvpi(ngs),felspi(ngs),felfpi(ngs)
12561 real felvs(ngs),felss(ngs) ! ,felfs(ngs)
12562 real fwvdf(ngs),ftka(ngs),fthdf(ngs)
12563 real fadvisc(ngs),fakvisc(ngs)
12564 real fci(ngs),fcw(ngs) ! heat capacities of ice and liquid
12565 real fschm(ngs),fpndl(ngs)
12566 real fgamw(ngs),fgams(ngs)
12567 real fcqv1(ngs),fcqv2(ngs),fcc3(ngs)
12568
12569 real cvm,cpm,rmm
12570
12571 real, parameter :: cpv = 1885.0 ! specific heat of water vapor at constant pressure
12572!
12573 real fcci(ngs), fcip(ngs)
12574!
12575 real :: sfm1(ngs),sfm2(ngs)
12576 real :: gfm1(ngs),gfm2(ngs)
12577 real :: ffm1(ngs),ffm2(ngs)
12578 real :: hfm1(ngs),hfm2(ngs)
12579
12580 logical :: wetsfc(ngs),wetsfchl(ngs),wetsfcf(ngs)
12581 logical :: wetgrowth(ngs), wetgrowthhl(ngs), wetgrowthf(ngs)
12582
12583 real qitmp(ngs),qistmp(ngs)
12584
12585 real rzxh(ngs), rzxhl(ngs), rzxhlh(ngs), rzxhlf(ngs)
12586 real rzxs(ngs), rzxf(ngs)
12587! real axh(ngs),bxh(ngs),axhl(ngs),bxhl(ngs)
12588 real cdh(ngs),cdhl(ngs)
12589 real :: axx(ngs,lh:lhab),bxx(ngs,lh:lhab)
12590 real vt2ave(ngs)
12591
12592 real :: qcwresv(ngs), ccwresv(ngs) ! "reserved" droplet mass and number that are too small for accretion
12593
12594 real :: lfsave(ngs,6)
12595 real :: qx(ngs,lv:lhab)
12596 real :: qxw(ngs,ls:lhab)
12597 real :: qxwlg(ngs,lh:lhab)
12598 real :: chxf(ngs,lh:lhab)
12599 real :: cx(ngs,lc:lhab)
12600 real :: cxmxd(ngs,lc:lhab)
12601 real :: qxmxd(ngs,lv:lhab)
12602 real :: scx(ngs,lc:lhab)
12603 real :: xv(ngs,lc:lhab)
12604 real :: vtxbar(ngs,lc:lhab,3)
12605 real :: xmas(ngs,lc:lhab)
12606 real :: xdn(ngs,lc:lhab)
12607 real :: xdntmp(ngs,lc:lhab)
12608 real :: cdxgs(ngs,lc:lhab)
12609 real :: xdia(ngs,lc:lhab,3)
12610 real :: vtwtdia(ngs,lr:lhab) ! sweep-out volume weighted diameter
12611 real :: rarx(ngs,ls:lhab)
12612 real :: vx(ngs,li:lhab)
12613 real :: rimdn(ngs,li:lhab)
12614 real :: raindn(ngs,li:lhab)
12615 real :: alpha(ngs,lc:lhab)
12616 real :: dab0lh(ngs,lc:lhab,lc:lhab)
12617 real :: dab1lh(ngs,lc:lhab,lc:lhab)
12618 real :: zx(ngs,lr:lhab)
12619 real :: zxmxd(ngs,lr:lhab)
12620 real :: g1x(ngs,lr:lhab)
12621
12622
12623 real :: qsimxdep(ngs) ! max sublimation of qi+qs+qis
12624 real :: qsimxsub(ngs) ! max depositionof qi+qs+qis
12625 logical,parameter :: DoSublimationFix = .true.
12626 real :: qrtmp(ngs),qvtmp(ngs),qctmp(ngs)
12627 real :: felvcptmp,felscptmp,qsstmp
12628 real :: thetatmp, thetaptmp, temcgtmp,qvaptmp
12629 real :: qvstmp, qisstmp, qvptmp, qitmp1, qctmp1
12630
12631 real :: galphrout
12632
12633 real ventrx(ngs)
12634 real ventrxn(ngs)
12635 real g1shr, alphashr
12636 real g1mlr, alphamlr
12637 real g1smlr, alphasmlr
12638 real massfacshr, massfacmlr
12639
12640 real :: qhgt8mm ! ice mass greater than 8mm
12641 real :: qhwgt8mm ! ice + max water mass greater than 8mm
12642 real :: qhgt10mm ! mass greater than 10mm
12643 real :: qhgt20mm ! mass greater than 20mm
12644 real :: fwmhtmp
12645 real, parameter :: fwmhtmptem = -15. ! temperature at which fwmhtmp fully switches to liquid water only being on large particles
12646 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
12647 real, parameter :: srasheym = 0.1389 ! slope fraction from Rasmussen and Heymsfield
12648!
12649 real swvent(ngs),hwvent(ngs),rwvent(ngs),hlvent(ngs),hwventy(ngs),hlventy(ngs),rwventz(ngs)
12650 real hxventtmp
12651 real hlventinc(ngs),hwventinc(ngs)
12652 integer, parameter :: ndiam = 10
12653 integer :: numdiam
12654 real hwvent0(ndiam+4),hlvent0 ! 0 to d1
12655 real hwvent1,hlvent1 ! d1 to infinity
12656 real hwvent2,hlvent2 ! d2 to infinity
12657 real gama0,gamb0
12658 real gama1,gamb1
12659 real gama2,gamb2
12660! real, parameter :: mltdiam1 = 9.0e-3, mltdiam1p5 = 16.0e-3, mltdiam2 = 19.0e-3, mltdiam3 = 200.0e-3, mltdiam05 = 4.5e-3
12661 real :: mltdiam(ndiam+4)
12662 real mltmass0inv,mltmass1inv,mltmass2inv, mltmass1cgs, mltmass2cgs,mltmass3inv, mltmass3cgs
12663 real qhmlr0, qhmlr05, qhmlr1, qhmlr2,qhmlr3, qhmlr12, qhmlr23
12664 real qhlmlr0, qhlmlr05, qhlmlr1, qhlmlr2,qhlmlr3, qhlmlr12, qhlmlr23
12665 real qxd1, cxd1, zxd1 ! mass and number up to mltdiam1
12666 real qxd05, cxd05 ! mass and number up to mltdiam1/2
12667
12668 real :: qxd(ndiam+4), cxd(ndiam+4), qhml(ndiam+4), qhml0(ndiam+4)
12669 real :: dqxd(ndiam+4), dcxd(ndiam+4), dqhml(ndiam+4)
12670
12671
12672 real civent(ngs)
12673 real isvent(ngs)
12674!
12675 real xmascw(ngs)
12676 real xdnmx(lc:lhab), xdnmn(lc:lhab)
12677 real dnmx
12678 real :: xdiamxmas(ngs,lc:lhab)
12679!
12680 real cilen(ngs) ! ,ciplen(ngs)
12681!
12682!
12683 real rwcap(ngs),swcap(ngs)
12684 real hwcap(ngs)
12685 real hlcap(ngs)
12686 real cicap(ngs)
12687 real iscap(ngs)
12688
12689 real qvimxd(ngs)
12690 real qimxd(ngs),qismxd(ngs),qcmxd(ngs),qrmxd(ngs),qsmxd(ngs),qhmxd(ngs),qhlmxd(ngs)
12691 real cimxd(ngs),ccmxd(ngs),crmxd(ngs),csmxd(ngs),chmxd(ngs)
12692 real cionpmxd(ngs),cionnmxd(ngs)
12693 real clionpmxd(ngs),clionnmxd(ngs)
12694
12695
12696 real elec(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz) ! Ez (elecsave)
12697
12698!
12699!
12700 ! Hallett-Mossop arrays
12701 real chmul1(ngs),chlmul1(ngs),csmul1(ngs),csmul(ngs)
12702 real qhmul1(ngs),qhlmul1(ngs),qsmul1(ngs),qsmul(ngs)
12703
12704 ! splinters from drop freezing
12705 real csplinter(ngs),qsplinter(ngs)
12706 real csplinter2(ngs),qsplinter2(ngs)
12707!
12708!
12709! concentration arrays...
12710!
12711 real :: chlcnh(ngs), vhlcnh(ngs), vhlcnhl(ngs)
12712 real :: chlcnhhl(ngs) ! number of new hail particles (may be different from number of lost graupel)
12713 real cracif(ngs), ciacrf(ngs)
12714 real cracr(ngs)
12715
12716!
12717 real ciint(ngs), crfrz(ngs), crfrzf(ngs), crfrzs(ngs)
12718 real cicint(ngs)
12719 real cipint(ngs)
12720 real ciacw(ngs), cwacii(ngs)
12721 real ciacr(ngs), craci(ngs)
12722 real csacw(ngs)
12723 real csacr(ngs)
12724 real csaci(ngs), csacs(ngs)
12725 real cracw(ngs)
12726 real chacw(ngs), chacr(ngs)
12727 real :: chlacw(ngs)
12728 real chaci(ngs), chacs(ngs)
12729!
12730 real :: chlacr(ngs)
12731 real :: chlaci(ngs), chlacs(ngs)
12732 real crcnw(ngs)
12733 real cidpv(ngs),cisbv(ngs)
12734 real cisdpv(ngs),cissbv(ngs)
12735 real cimlr(ngs),cismlr(ngs)
12736
12737 real chlsbv(ngs), chldpv(ngs)
12738 real chlmlr(ngs), chlmlrr(ngs)
12739 real chlfmlr(ngs)
12740! real chlmlrsave(ngs),chlsave(ngs),qhlsave(ngs)
12741 real chlshr(ngs), chlshrr(ngs)
12742
12743
12744 real chdpv(ngs),chsbv(ngs)
12745 real chmlr(ngs),chcev(ngs)
12746 real chmlrr(ngs)
12747 real chshr(ngs), chshrr(ngs)
12748
12749 real csdpv(ngs),cssbv(ngs)
12750 real csmlr(ngs),csmlrr(ngs),cscev(ngs)
12751 real csshr(ngs), csshrr(ngs)
12752
12753 real crcev(ngs)
12754 real crshr(ngs)
12755 real cwshw(ngs), qwshw(ngs)
12756!
12757!
12758! arrays for w-ac-x ; x-ac-w
12759!
12760!
12761!
12762 real qrcnw(ngs), qwcnr(ngs)
12763 real zrcnw(ngs),zracr(ngs),zracw(ngs),zrcev(ngs)
12764
12765 real qracw(ngs) ! qwacr(ngs),
12766 real qiacw(ngs) !, qwaci(ngs)
12767
12768 real qsacw(ngs) ! ,qwacs(ngs),
12769 real qhacw(ngs) ! qwach(ngs),
12770 real :: qhlacw(ngs), qxacwtmp, qxacrtmp, qxacitmp, qxacstmp !
12771 real vhacw(ngs), vsacw(ngs), vhlacw(ngs), vhlacr(ngs)
12772
12773 real qfcev(ngs)
12774 real qfmul1(ngs),cfmul1(ngs)
12775!
12776 real qsacws(ngs)
12777
12778!
12779! arrays for x-ac-r and r-ac-x;
12780!
12781 real qsacr(ngs),qracs(ngs)
12782 real qhacr(ngs),qhacrmlr(ngs),qhacwmlr(ngs) ! ,qrach(ngs)
12783 real vhacr(ngs), zhacr(ngs), zhacrf(ngs), zrach(ngs), zrachl(ngs)
12784 real qiacr(ngs),qraci(ngs)
12785
12786 real ziacr(ngs)
12787
12788 real qracif(ngs),qiacrf(ngs),qiacrs(ngs),ciacrs(ngs)
12789
12790 real :: qhlacr(ngs),qhlacrmlr(ngs), qhlacwmlr(ngs)
12791 real qsacrs(ngs) !,qracss(ngs)
12792!
12793! ice - ice interactions
12794!
12795 real qsaci(ngs)
12796 real qsacis(ngs)
12797 real qhaci(ngs)
12798 real qhacs(ngs)
12799
12800 real :: qhacis(ngs)
12801 real :: chacis(ngs)
12802 real :: chacis0(ngs)
12803
12804 real :: csaci0(ngs) ! collision rate only
12805 real :: chaci0(ngs) ! collision rate only
12806 real :: chacs0(ngs) ! collision rate only
12807 real :: chlaci0(ngs)
12808 real :: chlacis(ngs)
12809 real :: chlacis0(ngs)
12810 real :: chlacs0(ngs)
12811
12812 real :: qsaci0(ngs) ! collision rate only
12813 real :: qsacis0(ngs) ! collision rate only
12814 real :: qhaci0(ngs) ! collision rate only
12815 real :: qhacis0(ngs) ! collision rate only
12816 real :: qhacs0(ngs) ! collision rate only
12817 real :: qhlaci0(ngs)
12818 real :: qhlacis0(ngs)
12819 real :: qhlacs0(ngs)
12820
12821 real :: qhlaci(ngs)
12822 real :: qhlacis(ngs)
12823 real :: qhlacs(ngs)
12824!
12825! conversions
12826!
12827 real qrfrz(ngs) ! , qirirhr(ngs)
12828 real zrfrz(ngs), zrfrzf(ngs), zrfrzs(ngs)
12829 real ziacrf(ngs), zhcnsh(ngs), zhcnih(ngs)
12830 real zhacw(ngs), zhacs(ngs), zhaci(ngs)
12831 real zhmlr(ngs), zhdsv(ngs), zhsbv(ngs), zhlcnh(ngs), zhshr(ngs)
12832 real zfacw(ngs), zfacs(ngs), zfaci(ngs)
12833 real zfmlr(ngs), zfdsv(ngs), zfsbv(ngs), zhlcnf(ngs), zfshr(ngs), zfshrr(ngs)
12834 real zhmlrtmp,zhmlr0inf,zhlmlr0inf
12835 real zhmlrr(ngs),zhlmlrr(ngs),zhshrr(ngs),zhlshrr(ngs),zfmlrr(ngs)
12836! real zsmlr(ngs)
12837 real zsmlrr(ngs), zsshr(ngs), zsshrr(ngs)
12838 real zhcns(ngs), zhcni(ngs)
12839 real zhwdn(ngs), zfwdn(ngs) ! change in Z due to density changes
12840 real zhldn(ngs) ! change in Z due to density changes
12841
12842 real zhlacw(ngs), zhlacs(ngs), zhlacr(ngs)
12843 real zhlmlr(ngs), zhldsv(ngs), zhlsbv(ngs), zhlshr(ngs)
12844
12845
12846 real vrfrzf(ngs), viacrf(ngs)
12847 real qrfrzs(ngs), qrfrzf(ngs)
12848 real qwfrz(ngs), qwctfz(ngs)
12849 real cwfrz(ngs), cwctfz(ngs)
12850 real qwfrzis(ngs), qwctfzis(ngs) ! droplet freezing to ice spheres
12851 real cwfrzis(ngs), cwctfzis(ngs)
12852 real qwfrzc(ngs), qwctfzc(ngs) ! droplet freezing to columns
12853 real cwfrzc(ngs), cwctfzc(ngs)
12854 real qwfrzp(ngs), qwctfzp(ngs) ! droplet freezing to plates
12855 real cwfrzp(ngs), cwctfzp(ngs)
12856 real xcolmn(ngs), xplate(ngs)
12857 real ciihr(ngs), qiihr(ngs)
12858 real cicichr(ngs), qicichr(ngs)
12859 real cipiphr(ngs), qipiphr(ngs)
12860 real qscni(ngs), cscni(ngs), cscnis(ngs)
12861 real qscnvi(ngs), cscnvi(ngs), cscnvis(ngs)
12862 real qhcns(ngs), chcns(ngs), chcnsh(ngs), vhcns(ngs)
12863 real qscnh(ngs), cscnh(ngs), vscnh(ngs)
12864 real qhcni(ngs), chcni(ngs), chcnih(ngs), vhcni(ngs)
12865 real qiint(ngs),qipipnt(ngs),qicicnt(ngs)
12866 real cninm(ngs),cnina(ngs),cninp(ngs),wvel(ngs),wvelkm1(ngs)
12867 real tke(ngs)
12868 real uvel(ngs),vvel(ngs)
12869!
12870 real qidpv(ngs),qisbv(ngs) ! qicnv(ngs),qievv(ngs),
12871 real qimlr(ngs),qidsv(ngs),qisdsv(ngs),qidsvp(ngs) ! ,qicev(ngs)
12872 real qismlr(ngs)
12873
12874!
12875!
12876 real :: qhldpv(ngs), qhlsbv(ngs) ! qhlcnv(ngs),qhlevv(ngs),
12877 real :: qhlmlr(ngs), qhldsv(ngs), qhlmlrsave(ngs)
12878 real :: qhlwet(ngs), qhldry(ngs), qhlshr(ngs), qxwettmp
12879!
12880 real :: qrfz(ngs),qsfz(ngs),qhfz(ngs),qhlfz(ngs)
12881 real :: qffz(ngs)
12882!
12883 real qhdpv(ngs),qhsbv(ngs) ! qhcnv(ngs),qhevv(ngs),
12884 real qhmlr(ngs),qhdsv(ngs),qhcev(ngs),qhcndv(ngs),qhevv(ngs)
12885 real qhlcev(ngs), chlcev(ngs)
12886 real qhwet(ngs),qhdry(ngs),qhshr(ngs)
12887 real qhshrp(ngs)
12888 real qhshh(ngs) !accreted water that remains on graupel
12889 real qhmlh(ngs) !melt water that remains on graupel
12890 real qhfzh(ngs) !water that freezes on mixed-phase graupel
12891 real qffzf(ngs) !water that freezes on mixed-phase FD
12892 real qhlfzhl(ngs) !water that freezes on mixed-phase hail
12893
12894 real qhmlrlg(ngs),qhlmlrlg(ngs) ! melting from the larger diameters
12895 real qhfzhlg(ngs) !water that freezes on mixed-phase graupel (large sizes)
12896 real qhlfzhllg(ngs) !water that freezes on mixed-phase hail (large sizes)
12897 real qhlcevlg(ngs), chlcevlg(ngs)
12898 real qhcevlg(ngs), chcevlg(ngs)
12899
12900 real vhfzh(ngs), vffzf(ngs) ! change in volume from water that freezes on mixed-phase graupel, frozen drops
12901 real vhlfzhl(ngs) ! change in volume from water that freezes on mixed-phase hail
12902
12903 real vhshdr(ngs) !accreted water that leaves on graupel (mixedphase)
12904 real vhlshdr(ngs) !accreted water that leaves on hail (mixedphase)
12905 real vhmlr(ngs) !melt water that leaves graupel (single phase)
12906 real vhlmlr(ngs) !melt water that leaves hail (single phase)
12907 real vhsoak(ngs) ! aquired water that seeps into graupel.
12908 real vhlsoak(ngs) ! aquired water that seeps into hail.
12909
12910!
12911 real qsdpv(ngs),qssbv(ngs) ! qscnv(ngs),qsevv(ngs),
12912 real qsmlr(ngs),qsdsv(ngs),qscev(ngs),qscndv(ngs),qsevv(ngs)
12913 real qswet(ngs),qsdry(ngs),qsshr(ngs)
12914 real qsshrp(ngs)
12915 real qsfzs(ngs)
12916!
12917!
12918 real qipdpv(ngs),qipsbv(ngs)
12919 real qipmlr(ngs),qipdsv(ngs)
12920!
12921 real qirdpv(ngs),qirsbv(ngs)
12922 real qirmlr(ngs),qirdsv(ngs),qirmlw(ngs)
12923!
12924 real qgldpv(ngs),qglsbv(ngs)
12925 real qglmlr(ngs),qgldsv(ngs)
12926 real qglwet(ngs),qgldry(ngs),qglshr(ngs)
12927 real qglshrp(ngs)
12928!
12929 real qgmdpv(ngs),qgmsbv(ngs)
12930 real qgmmlr(ngs),qgmdsv(ngs)
12931 real qgmwet(ngs),qgmdry(ngs),qgmshr(ngs)
12932 real qgmshrp(ngs)
12933 real qghdpv(ngs),qghsbv(ngs)
12934 real qghmlr(ngs),qghdsv(ngs)
12935 real qghwet(ngs),qghdry(ngs),qghshr(ngs)
12936 real qghshrp(ngs)
12937!
12938 real qrztot(ngs),qrzmax(ngs),qrzfac(ngs)
12939 real qrcev(ngs)
12940 real qrshr(ngs)
12941 real fsw(ngs),fhw(ngs),fhlw(ngs),ffw(ngs) !liquid water fractions
12942 real fswmax(ngs),fhwmax(ngs),fhlwmax(ngs) !liquid water fractions
12943 real ffwmax(ngs)
12944 real qhcnf(ngs)
12945 real :: qhlcnh(ngs)
12946 real qhcngh(ngs),qhcngm(ngs),qhcngl(ngs)
12947
12948 real :: qhcnhl(ngs), chcnhl(ngs), zhcnhl(ngs), vhcnhl(ngs) ! conversion of low-density hail back to graupel
12949
12950 real eiw(ngs),eii(ngs),eiri(ngs),eipir(ngs),eisw(ngs)
12951 real erw(ngs),esw(ngs),eglw(ngs),eghw(ngs),efw(ngs)
12952 real ehxw(ngs),ehlw(ngs),egmw(ngs),ehw(ngs)
12953 real err(ngs),esr(ngs),eglr(ngs),eghr(ngs),efr(ngs)
12954 real ehxr(ngs),ehlr(ngs),egmr(ngs)
12955 real eri(ngs),esi(ngs),egli(ngs),eghi(ngs),efi(ngs),efis(ngs)
12956 real ehxi(ngs),ehli(ngs),egmi(ngs),ehi(ngs),ehis(ngs),ehlis(ngs)
12957 real ers(ngs),ess(ngs),egls(ngs),eghs(ngs),efs(ngs),ehs(ngs),ehsfac(ngs)
12958 real ehscnv(ngs)
12959 real ehxs(ngs),ehls(ngs),egms(ngs),egmip(ngs)
12960
12961 real ehsclsn(ngs),ehiclsn(ngs),ehisclsn(ngs)
12962 real efsclsn(ngs),eficlsn(ngs),efisclsn(ngs)
12963 real ehlsclsn(ngs),ehliclsn(ngs),ehlisclsn(ngs)
12964 real esiclsn(ngs)
12965
12966 real :: ehs_collsn = 0.5, ehi_collsn = 1.0
12967 real :: efs_collsn = 0.5, efi_collsn = 1.0
12968 real :: ehls_collsn = 1.0, ehli_collsn = 1.0
12969 real :: esi_collsn = 1.0
12970
12971 real ew(8,6)
12972 real cwr(8,2) ! radius and inverse of interval
12973 data cwr / 2.0, 3.0, 4.0, 6.0, 8.0, 10.0, 15.0, 20.0 , & ! radius
12974 & 1.0, 1.0, 0.5, 0.5, 0.5, 0.2, 0.2, 1. / ! inverse of interval
12975 integer icwr(ngs), igwr(ngs), irwr(ngs), ihlr(ngs), ifwr(ngs)
12976 real grad(6,2) ! graupel radius and inverse of interval
12977 data grad / 100., 200., 300., 400., 600., 1000., &
12978 & 1.e-2,1.e-2,1.e-2,5.e-3,2.5e-3, 1. /
12979!droplet radius: 2 3 4 6 8 10 15 20
12980 data ew /0.03, 0.07, 0.17, 0.41, 0.58, 0.69, 0.82, 0.88, & ! 100
12981! : 0.07, 0.13, 0.27, 0.48, 0.65, 0.73, 0.84, 0.91, ! 150
12982 & 0.10, 0.20, 0.34, 0.58, 0.70, 0.78, 0.88, 0.92, & ! 200
12983 & 0.15, 0.31, 0.44, 0.65, 0.75, 0.83, 0.96, 0.91, & ! 300
12984 & 0.17, 0.37, 0.50, 0.70, 0.81, 0.87, 0.93, 0.96, & ! 400
12985 & 0.17, 0.40, 0.54, 0.71, 0.83, 0.88, 0.94, 0.98, & ! 600
12986 & 0.15, 0.37, 0.52, 0.74, 0.82, 0.88, 0.94, 0.98 / ! 1000
12987! : 0.11, 0.34, 0.49, 0.71, 0.83, 0.88, 0.94, 0.95 / ! 1400
12988
12989
12990 real da0lr(ngs),da1lr(ngs)
12991 real da0lc(ngs),da1lc(ngs)
12992 real da0lh(ngs)
12993 real da0lhl(ngs)
12994 real da0lf(ngs)
12995 real :: da0lx(ngs,lr:lhab)
12996
12997 real va0 (lc:lqmx) ! collection coefficients from Seifert 2005
12998 real vab0(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
12999 real vab1(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
13000 real va1 (lc:lqmx) ! collection coefficients from Seifert 2005
13001 real ehip(ngs),ehlip(ngs),ehlir(ngs)
13002 real erir(ngs),esir(ngs),eglir(ngs),egmir(ngs),eghir(ngs)
13003 real efir(ngs),ehir(ngs),eirw(ngs),eirir(ngs),ehr(ngs)
13004 real erip(ngs),esip(ngs),eglip(ngs),eghip(ngs)
13005 real efip(ngs),eipi(ngs),eipw(ngs),eipip(ngs)
13006!
13007! arrays for production terms
13008!
13009 real ptotal(ngs) ! , pqtot(ngs)
13010!
13011 real pqcwi(ngs),pqcii(ngs),pqrwi(ngs),pqisi(ngs)
13012 real pqswi(ngs),pqhwi(ngs),pqwvi(ngs)
13013 real pqgli(ngs),pqghi(ngs),pqfwi(ngs)
13014 real pqgmi(ngs),pqhli(ngs) ! ,pqhxi(ngs)
13015 real pqiri(ngs),pqipi(ngs) ! pqwai(ngs),
13016 real pqlwsi(ngs),pqlwhi(ngs),pqlwhli(ngs),pqlwfi(ngs)
13017
13018 real pqlwlghi(ngs),pqlwlghli(ngs)
13019 real pqlwlghd(ngs),pqlwlghld(ngs)
13020
13021
13022
13023
13024 real pvhwi(ngs), pvhwd(ngs)
13025 real pvfwi(ngs), pvfwd(ngs)
13026 real pvhli(ngs), pvhld(ngs)
13027 real pvswi(ngs), pvswd(ngs)
13028!
13029 real pqcwd(ngs),pqcid(ngs),pqrwd(ngs),pqisd(ngs), pqcwdacc(ngs)
13030 real pqswd(ngs),pqhwd(ngs),pqwvd(ngs)
13031 real pqgld(ngs),pqghd(ngs),pqfwd(ngs)
13032 real pqgmd(ngs),pqhld(ngs) ! ,pqhxd(ngs)
13033 real pqird(ngs),pqipd(ngs) ! pqwad(ngs),
13034 real pqlwsd(ngs),pqlwhd(ngs),pqlwhld(ngs),pqlwfd(ngs)
13035!
13036! real pqxii(ngs,nhab),pqxid(ngs,nhab)
13037!
13038 real pctot(ngs)
13039 real pcipi(ngs), pcipd(ngs)
13040 real pciri(ngs), pcird(ngs)
13041 real pccwi(ngs), pccwd(ngs), pccwdacc(ngs)
13042 real pccii(ngs), pccid(ngs)
13043 real pcisi(ngs), pcisd(ngs)
13044 real pccin(ngs)
13045 real pcrwi(ngs), pcrwd(ngs)
13046 real pcswi(ngs), pcswd(ngs)
13047 real pchwi(ngs), pchwd(ngs)
13048 real pchli(ngs), pchld(ngs)
13049 real pcfwi(ngs), pcfwd(ngs)
13050 real pcgli(ngs), pcgld(ngs)
13051 real pcgmi(ngs), pcgmd(ngs)
13052 real pcghi(ngs), pcghd(ngs)
13053
13054 real pzrwi(ngs), pzrwd(ngs)
13055 real pzhwi(ngs), pzhwd(ngs)
13056 real pzfwi(ngs), pzfwd(ngs)
13057 real pzhli(ngs), pzhld(ngs)
13058 real pzswi(ngs), pzswd(ngs)
13059
13060!
13061! other arrays
13062!
13063 real dqisdt(ngs) !,advisc(ngs) !dqwsdt(ngs), ,schm(ngs),pndl(ngs)
13064
13065 real qss0(ngs)
13066
13067 real qsacip(ngs)
13068 real pres(ngs),pipert(ngs)
13069 real pk(ngs)
13070 real rho0(ngs),pi0(ngs)
13071 real rhovt(ngs),sqrtrhovt
13072 real thetap(ngs),theta0(ngs),qwvp(ngs),qv0(ngs)
13073 real thsave(ngs)
13074 real ptwfzi(ngs),ptimlw(ngs)
13075 real psub(ngs),pvap(ngs),pfrz(ngs),ptem(ngs),pmlt(ngs),pevap(ngs),pdep(ngs),ptem2(ngs)
13076
13077 real cnostmp(ngs) ! for diagnosed snow intercept
13078!
13079! iholef = 1 to do hole filling technique version 1
13080! which uses all hydrometerors to do hole filling of all hydrometeors
13081! iholef = 2 to do hole filling technique version 2
13082! which uses an individual hydrometeror species to do hole
13083! filling of a species of a hydrometeor
13084!
13085! iholen = interval that hole filling is done
13086!
13087 integer iholef
13088 integer iholen
13089 parameter(iholef = 1)
13090 parameter(iholen = 1)
13091 real cqtotn,cqtotn1
13092 real cctotn
13093 real citotn
13094 real crtotn
13095 real cstotn
13096 real cvtotn
13097 real cftotn
13098 real cgltotn
13099 real cghtotn
13100 real chtotn
13101 real cqtotp,cqtotp1
13102 real cctotp
13103 real citotp
13104 real ciptotp
13105 real crtotp
13106 real cstotp
13107 real cvtotp
13108 real cftotp
13109 real chltotp
13110 real cgltotp
13111 real cgmtotp
13112 real cghtotp
13113 real chtotp
13114 real cqfac
13115 real ccfac
13116 real cifac
13117 real cipfac
13118 real crfac
13119 real csfac
13120 real cvfac
13121 real cffac
13122 real cglfac
13123 real cghfac
13124 real chfac
13125
13126 real ssifac, qvapor
13127!
13128! Miscellaneous variables
13129!
13130 real, parameter :: cwmas30 = 1000.*0.523599*(2.*30.e-6)**3 ! mass of 30-micron radius droplet, for sat. adj.
13131 real, parameter :: cwmas20 = 1000.*0.523599*(2.*20.e-6)**3 ! mass of 20-micron radius droplet, for sat. adj.
13132 integer ireadqf,lrho,lqsw,lqgl,lqgm ,lqgh
13133 integer lqrw
13134 real vt
13135 real arg ! gamma is a function
13136 real erbnd1, fdgt1, costhe1
13137 real qeps
13138 real dyi2,dzi2,bta1,cnit,dragh,dnz00,pii ! ,cp608
13139 real qccrit,gf4br,gf4ds,gf4p5, gf3ds, gf1ds
13140 real gf1palp(ngs) ! for storing Gamma[1.0 + alphar]
13141
13142
13143 real xdn0(lc:lhab)
13144 real xdn_new,drhodt
13145
13146 integer l ,ltemq,inumgs, idelq
13147
13148 real brz,arz,temq
13149
13150 real ssival,tqvcon
13151 real cdx(lc:lhab)
13152 real cnox
13153 real cval,aval,eval,fval,gval ,qsign,ftelwc,qconkq,elecfac,altelecfac
13154 real qconm,qconn,cfce15,gf8,gf4i,gf3p5,gf1a,gf1p5,qdiff,argrcnw
13155 real c4,bradp,bl2,bt2,dthr,hrifac, hdia0,hdia1,civenta,civentb
13156 real civentc,civentd,civente,civentf,civentg,cireyn,xcivent
13157 real cipventa,cipventb,cipventc,cipventd,cipreyn,cirventa
13158 real cirventb
13159 integer igmrwa,igmrwb,igmswa, igmswb,igmfwa,igmfwb,igmhwa,igmhwb
13160 real rwventa ,rwventb,swventa,swventb,fwventa,fwventb,fwventc
13161 real hwventa,hwventb
13162 real hwventc, hlventa, hlventb, hlventc
13163 real glventa, glventb, glventc
13164 real gmventa, gmventb, gmventc, ghventa, ghventb, ghventc
13165 real dzfacp, dzfacm, cmassin, cwdiar
13166 real rimmas, rhobar
13167 real argtim, argqcw, argqxw, argtem
13168 real frcswsw, frcswgl, frcswgm, frcswgh, frcswfw, frcswsw1
13169 real frcglgl, frcglgm, frcglgh, frcglfw, frcglgl1
13170 real frcgmgl, frcgmgm, frcgmgh, frcgmfw, frcgmgm1
13171 real frcghgl, frcghgm, frcghgh, frcghfw, frcghgh1
13172 real frcfwgl, frcfwgm, frcfwgh, frcfwfw, frcfwfw1
13173 real frcswrsw, frcswrgl, frcswrgm, frcswrgh, frcswrfw
13174 real frcswrsw1
13175 real frcrswsw, frcrswgl, frcrswgm, frcrswgh, frcrswfw
13176 real frcrswsw1
13177 real frcglrgl, frcglrgm, frcglrgh, frcglrfw, frcglrgl1
13178 real frcrglgl
13179 real frcrglgm, frcrglgh, frcrglfw, frcrglgl1
13180 real frcgmrgl, frcgmrgm, frcgmrgh, frcgmrfw, frcgmrgm1
13181 real frcrgmgl, frcrgmgm, frcrgmgh, frcrgmfw, frcrgmgm1
13182 real total, qweps, gf2a, gf4a, dqldt, dqidt, dqdt
13183 real frcghrgl, frcghrgm, frcghrgh, frcghrfw, frcghrgh1, frcrghgl
13184 real frcrghgm, frcrghgh, frcrghfw, frcrghgh1
13185 real a1,a2,a3,a4,a5,a6
13186 real gamss
13187 real cdw, cdi, denom1, denom2, delqci1, delqip1
13188 real cirtotn, ciptotn, cgmtotn, chltotn, cirtotp
13189 real cgmfac, chlfac, cirfac
13190 integer igmhla, igmhlb, igmgla, igmglb, igmgma, igmgmb
13191 integer igmgha, igmghb
13192 integer idqis, item, itim0
13193 integer iqgl, iqgm, iqgh, iqrw, iqsw
13194 integer itertd, ia
13195
13196 integer :: infdo
13197
13198 real tau, ewtmp
13199
13200 integer cntnic_noliq
13201 real q_noliqmn, q_noliqmx
13202 real scsacimn, scsacimx
13203
13204 real :: dtpinv
13205
13206! arrays for temporary bin space
13207
13208 real :: xden,xmlt,cmlt,cmlttot,fventm,fventh,am,ah,felfinv,dmwdt
13209
13210 real :: qhmlrtmp,qhmlrtmp2, chmlrtmp, chmlrtmpd1inf, chlmlrtmp, zhlmlrtmp, zhlmlrrtmp, qvs0,tmpcmlt
13211
13212 real :: term1,term2,term3,term4
13213 real :: qaacw ! combined qsacw-qhacw for WSM6 variation
13214 real :: cwchtmp
13215
13216 real, parameter :: c1r=19.0, c2r=0.6, c3r=1.8, c4r=17.0 ! rain
13217 real, parameter :: c1h=5.5, c2h=0.7, c3h=4.5, c4h=8.5 ! Graupel
13218 real, parameter :: c1hl=3.7, c2hl=0.3, c3hl=9.0, c4hl=6.5, c5hl=1.0, c6hl=6.5 ! Hail
13219
13220
13221! inline functions for Newton method
13222 real :: galpha, dgalpha
13223 real :: a_in
13224 logical, parameter :: newton = .false.
13225
13226
13227 galpha(a_in) = ((4. + a_in)*(5. + a_in)*(6. + a_in))/((1. + a_in)*(2. + a_in)*(3. + a_in))
13228 dgalpha(a_in) = (876. + 1260.*a_in + 621.*a_in**2 + 126.*a_in**3 + 9.*a_in**4)/ &
13229 & (36. + 132.*a_in + 193.*a_in**2 + 144.*a_in**3 + 58.*a_in**4 + 12.*a_in**5 + a_in**6)
13230!
13231! ####################################################################
13232!
13233! Start routine
13234!
13235! ####################################################################
13236
13237
13238
13239!
13240
13241 pb(:) = 0.0
13242 pinit(:) = 0.0
13243 itile = nx
13244 jtile = ny
13245 ktile = nz
13246 ixend = nx
13247 jyend = ny
13248 kzend = nz
13249 nxend = nx + 1
13250 nyend = ny + 1
13251 nzend = nz
13252 kzbeg = 1
13253 nzbeg = 1
13254
13255 istag = 0
13256 jstag = 0
13257 kstag = 1
13258
13259 lrescalelow(:) = rescale_low_alpha
13260 lrescalelow(lr) = rescale_low_alphar .and. rescale_low_alpha
13261 lrescalelow(lh) = rescale_low_alphah .and. rescale_low_alpha
13262 IF ( lf > 1 ) lrescalelow(lf) = rescale_low_alphah .and. rescale_low_alpha
13263 IF ( lhl > 1 ) lrescalelow(lhl) = rescale_low_alphahl .and. rescale_low_alpha
13264
13265
13266!
13267! slope intercepts
13268!
13269
13270 IF ( ngs .lt. nz ) THEN
13271! write(0,*) 'Error in ICEZVD: Must have ngs .ge. nz!'
13272! STOP
13273 ENDIF
13274
13275 cntnic_noliq = 0
13276 q_noliqmn = 0.0
13277 q_noliqmx = 0.0
13278 scsacimn = 0.0
13279 scsacimx = 0.0
13280
13281 ldovol = .false.
13282
13283 DO il = lc,lhab
13284 ldovol = ldovol .or. ( lvol(il) .gt. 1 )
13285 ENDDO
13286
13287
13288 ffrzh = 1
13289! DO il = lc,lhab
13290! write(iunit,*) 'delqnxa(',il,') = ',delqnxa(il)
13291! ENDDO
13292
13293!
13294! density maximums and minimums
13295!
13296
13297!
13298! Set terminal velocities...
13299! also set drag coefficients
13300!
13301
13302 dtpinv = 1.d0/dtp
13303
13304!
13305
13306!
13307! electricity constants
13308!
13309! mixing ratio epsilon
13310!
13311 qeps = 1.0e-20
13312
13313! rebound efficiency (erbnd)
13314!
13315!
13316!
13317! constants
13318!
13319
13320! cp608 = 0.608
13321 aradcw = -0.27544
13322 bradcw = 0.26249e+06
13323 cradcw = -1.8896e+10
13324 dradcw = 4.4626e+14
13325 bta1 = 0.6
13326 cnit = 1.0e-02
13327 dragh = 0.60
13328 dnz00 = 1.225
13329! cs = 4.83607122
13330! ds = 0.25
13331! new values for cs and ds
13332 cs = 12.42
13333 ds = 0.42
13334 pii = piinv ! 1./pi
13335 pid4 = pi/4.0
13336! qscrit = 6.0e-04
13337 gf1 = 1.0 ! gamma(1.0)
13338 gf1p5 = 0.8862269255 ! gamma(1.5)
13339 gf2 = 1.0 ! gamma(2.0)
13340 gf3 = 2.0 ! gamma(3.0)
13341 gf3p5 = 3.32335097 ! gamma(3.5)
13342 gf4 = 6.00 ! gamma(4.0)
13343 gf5 = 24.0 ! gamma(5.0)
13344 gf6 = 120.0 ! gamma(6.0)
13345 gf7 = 720.0 ! gamma(7.0)
13346 gf4br = 17.837861981813607 ! gamma(4.0+br)
13347 gf4ds = 10.41688578110938 ! gamma(4.0+ds)
13348 gf4p5 = 11.63172839656745 ! gamma(4.0+0.5)
13349 gf3ds = 3.0458730354120997 ! gamma(3.0+ds)
13350 gf1ds = 0.8863557896089221 ! gamma(1.0+ds)
13351
13352 gf43rds = 0.8929795116 ! gamma(4./3.)
13353 gf53rds = 0.9027452930 ! gamma(5./3.)
13354 gf73rds = 1.190639349 ! gamma(7./3.)
13355 gf83rds = 1.504575488 ! gamma(8./3.)
13356
13357 gamice73fac = (gamma_sp(7./3. + cinu))**3/ (gamma_sp(1. + cinu)**3 * (1. + cinu)**4)
13358 gamsnow73fac = (gamma_sp(7./3. + snu))**3/ (gamma_sp(1. + snu)**3 * (1. + snu)**4)
13359
13360! gcnup1 = Gamma_sp(cnu + 1.)
13361! gcnup2 = Gamma_sp(cnu + 2.)
13362!
13363! constants
13364!
13365!
13366! general constants for microphysics
13367!
13368 brz = 100.0
13369 arz = 0.66
13370
13371 bfnu1 = (4. + alphar)*(5. + alphar)*(6. + alphar)/ &
13372 & ((1. + alphar)*(2. + alphar)*(3. + alphar))
13373
13374 galpharaut = (6.+alpharaut)*(5.+alpharaut)*(4.+alpharaut)/ &
13375 & ((3.+alpharaut)*(2.+alpharaut)*(1.+alpharaut))
13376
13377 vfrz = 0.523599*(dfrz)**3
13378 vmlt = min(xvmx(lr), 0.523599*(dmlt)**3 )
13379 vshd = min(xvmx(lr), 0.523599*(dshd)**3 )
13380
13381 IF ( snowmeltdia > 0.0 ) THEN
13382 snowmeltmass = pi/6.0 * 1000. * snowmeltdia**3 ! maximum rain particle mass from melting snow (if snowmeltdia > 0)
13383 ENDIF
13384
13385 tdtol = 1.0e-05
13386 tfrcbw = tfr - cbw
13387 tfrcbi = tfr - cbi
13388
13389 IF ( mixedphase ) THEN
13390 ibinhmlr = 0
13391 ibinhlmlr = 0
13392 ENDIF
13393!
13394!
13395! #ifdef COMMAS
13396! print*,'ventr,ventc = ',ventr,ventc
13397
13398!
13399! Set up look up tables for supersaturation w.r.t. liq and ice
13400!
13401!VD$L SKIP
13402! do l = 1,nqsat
13403! temq = 163.15 + (l-1)*fqsat
13404! tabqvs(l) = exp(caw*(temq-273.15)/(temq-cbw))
13405! tabqis(l) = exp(cai*(temq-273.15)/(temq-cbi))
13406! end do
13407
13408 mltmass0inv = 1.0/( 1000.0* xvmx(lr) ) ! for drops melting from ice with diameter > 1.9cm
13409 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
13410 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)
13411 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
13412 mltmass1cgs = 1.0*(4.0*pi/3.0)*((0.5*takshedsize1)**3)
13413 mltmass2cgs = 1.0*(4.0*pi/3.0)*((0.5*takshedsize2)**3)
13414 mltmass3cgs = 1.0*(4.0*pi/3.0)*((0.5*takshedsize3)**3)
13415
13416! real, parameter :: mltdiam1 = 9.0e-3, mltdiam2 = 19.0e-3, mltdiam05 = 4.5e-3
13417
13418 IF ( ibinnum == 1 ) THEN
13419 numdiam = 1 ! must have numdiam < ndiam because numdiam+1 holds values for the interval of mltdiam(numdiam) to mltdiam(ndiam+1)
13420 mltdiam(1) = 4.5e-3
13421 ELSEIF ( ibinnum == 2 ) THEN
13422 numdiam = 2 ! must have numdiam < ndiam because numdiam+1 holds values for the interval of mltdiam(numdiam) to mltdiam(ndiam+1)
13423 mltdiam(1) = mltdiam1/6. ! 1.5e-3
13424 mltdiam(2) = mltdiam1/2. ! 4.5e-3
13425 ELSEIF ( ibinnum > 2 ) THEN
13426 numdiam = min(ibinnum, ndiam)
13427 DO k = 1,numdiam
13428 mltdiam(k) = (k - 0.5)*mltdiam1/float(numdiam)
13429 ENDDO
13430
13431 ELSE
13432 numdiam = 5 ! must have numdiam < ndiam because numdiam+1 holds values for the interval of mltdiam(numdiam) to mltdiam(ndiam+1)
13433 mltdiam(1) = 0.5e-3
13434 mltdiam(2) = 1.0e-3
13435 mltdiam(3) = 2.0e-3
13436 mltdiam(4) = 4.0e-3
13437 mltdiam(5) = 6.0e-3
13438 ENDIF
13439
13440
13441 IF ( numshedregimes == 2 ) THEN
13442 mltdiam(ndiam+1) = mltdiam1 ! 9.0e-3
13443 mltdiam(ndiam+2) = mltdiam3 ! 19.0e-3
13444 mltdiam(ndiam+3) = mltdiam4 !100.0e-3
13445 ELSEIF ( numshedregimes == 3 ) THEN
13446 mltdiam(ndiam+1) = mltdiam1 ! 9.0e-3
13447 mltdiam(ndiam+2) = mltdiam2 ! 16.0e-3
13448 mltdiam(ndiam+3) = mltdiam3 ! 19.0e-3
13449 mltdiam(ndiam+4) = mltdiam4 !200.0e-3
13450 ENDIF
13451
13452 kzb = 1
13453 kze = ktile
13454! if (kzend .eq. nzend) kze = kzend-kzbeg+1-kstag
13455
13456!
13457! cw constants in mks units
13458!
13459! cwmasn = 4.25e-15 ! radius of 1.0e-6
13460 mwfac = 6.0**(1./3.)
13461 IF ( ipconc .ge. 2 ) THEN
13462! cwmasn = xvmn(lc)*1000.
13463! cwradn = 1.0e-6
13464! cwmasx = xvmx(lc)*1000.
13465 ENDIF
13466 rwmasn = xvmn(lr)*1000.
13467 rwmasx = xvmx(lr)*1000.
13468
13469 IF ( biggsnowdiam > 0.0 ) THEN
13470 xvbiggsnow = (pi/6.0)*biggsnowdiam**3
13471 ELSE
13472 xvbiggsnow = xvmn(lh)
13473 ENDIF
13474
13475!
13476! ci constants in mks units
13477!
13478 cimasn = min(cimas0, cimas1) ! 12 microns for 0.1871*(xmas(mgs,li)**(0.3429))
13479 cimasx = 1.0e-8 ! 338 microns
13480 ccimx = 5000.0e3 ! max of 5000 per liter
13481
13482!
13483! constants for paramerization
13484!
13485!
13486! set save counter (number of saves): nsvcnt
13487!
13488! nsvcnt = 0
13489 iend = 0
13490
13491
13492! timetd1 = etime(tarray)
13493! timetd1 = tarray(1)
13494
13495!
13496!***********************************************************
13497! start jy loop
13498!***********************************************************
13499!
13500
13501! do 9999 jy = 1,ny-jstag
13502!
13503! VERY IMPORTANT: SET jy = jgs
13504!
13505 jy = jgs
13506
13507
13508! t1(:,:,:) = 0
13509! t2(:,:,:) = 0
13510! t3(:,:,:) = 0
13511! t4(:,:,:) = 0
13512! t5(:,:,:) = 0
13513! t6(:,:,:) = 0
13514! t8(:,:,:) = 0
13515
13516 IF ( ipconc < 2 ) THEN ! Make a copy of cloud droplet mixing ratio to use for homogeneous freezing
13517 DO kz = 1,kze
13518 DO ix = 1,itile
13519 t9(ix,jy,kz) = an(ix,jy,kz,lc)
13520 ENDDO
13521 ENDDO
13522 ENDIF
13523
13524!
13525!..Gather microphysics
13526!
13527 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: ENTER GATHER STAGE'
13528
13529
13530
13531 nxmpb = 1
13532 nzmpb = 1
13533 nxz = itile*nz
13534 numgs = nxz/ngs + 1
13535! write(0,*) 'ICEZVD_GS: ENTER GATHER STAGE: nx,nz,nxz,numgs,ngs = ',nx,nz,nxz,numgs,ngs
13536
13537 do 1000 inumgs = 1,numgs
13538 ngscnt = 0
13539
13540 do kz = nzmpb,kze
13541 do ix = nxmpb,itile
13542
13543 pqs(1) = t00(ix,jy,kz)
13544
13545 theta(1) = an(ix,jy,kz,lt)
13546 temg(1) = t0(ix,jy,kz)
13547 temcg(1) = temg(1) - tfr
13548 tqvcon = temg(1)-cbw
13549 ltemq = (temg(1)-163.15)/fqsat + 1.5
13550 ltemq = min( nqsat, max(1,ltemq) )
13551 qvs(1) = pqs(1)*tabqvs(ltemq)
13552 IF ( iqis0 == 1 .or. temg(1) <= tfr+0.5 ) THEN
13553 qis(1) = pqs(1)*tabqis(ltemq)
13554 ELSE
13555 ltemq = (tfr - 163.15)/fqsat + 1.5
13556 qis(1) = pqs(1)*tabqis(ltemq)
13557 ENDIF
13558
13559 qss(1) = qvs(1)
13560
13561 if ( temg(1) .lt. tfr ) then
13562 qss(1) = qis(1)
13563 end if
13564!
13565 ishail = .false.
13566 IF ( lhl > 1 ) THEN
13567 IF ( an(ix,jy,kz,lhl) .gt. qxmin(lhl) ) ishail = .true.
13568 ENDIF
13569
13570
13571
13572 if ( an(ix,jy,kz,lv) .gt. qss(1) .or. &
13573 & an(ix,jy,kz,lc) .gt. qxmin(lc) .or. &
13574 & an(ix,jy,kz,li) .gt. qxmin(li) .or. &
13575 & an(ix,jy,kz,lr) .gt. qxmin(lr) .or. &
13576 & an(ix,jy,kz,ls) .gt. qxmin(ls) .or. &
13577 & an(ix,jy,kz,lh) .gt. qxmin(lh) .or. ishail ) then
13578 ngscnt = ngscnt + 1
13579 igs(ngscnt) = ix
13580 kgs(ngscnt) = kz
13581 if ( ngscnt .eq. ngs ) goto 1100
13582 end if
13583 enddo !ix
13584 nxmpb = 1
13585 enddo !kz
13586 1100 continue
13587
13588 if ( ngscnt .eq. 0 ) go to 9998
13589
13590 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: dbg = 5, ngscnt = ',ngscnt
13591
13592! write(0,*) 'allocating qc'
13593
13594
13595 xv(:,:) = 0.0
13596 xmas(:,:) = 0.0
13597 vtxbar(:,:,:) = 0.0
13598 xdia(:,:,:) = 0.0
13599 raindn(:,:) = 900.
13600 cx(:,:) = 0.0
13601 IF ( lnhf > 1 .or. lnhlf > 1 ) chxf(:,:) = 0.0
13602 alpha(:,:) = 0.0
13603 DO il = li,lhab
13604 DO mgs = 1,ngscnt
13605 rimdn(mgs,il) = rimedens ! xdn0(il)
13606 ENDDO
13607 ENDDO
13608!
13609! define temporaries for state variables to be used in calculations
13610!
13611 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: dbg = def temps'
13612 do mgs = 1,ngscnt
13613 kgsm(mgs) = max(kgs(mgs)-1,1)
13614 kgsp(mgs) = min(kgs(mgs)+1,nz-1)
13615 kgsm2(mgs) = max(kgs(mgs)-2,1)
13616 theta0(mgs) = an(igs(mgs),jy,kgs(mgs),lt)
13617 thetap(mgs) = an(igs(mgs),jy,kgs(mgs),lt) - theta0(mgs)
13618 theta(mgs) = an(igs(mgs),jy,kgs(mgs),lt)
13619 qv0(mgs) = an(igs(mgs),jy,kgs(mgs),lv)
13620 qwvp(mgs) = an(igs(mgs),jy,kgs(mgs),lv) - qv0(mgs) ! qv0(mgs) is full qv, so qwvp starts as zero!
13621
13622 pres(mgs) = pn(igs(mgs),jy,kgs(mgs)) + pb(kgs(mgs))
13623 pipert(mgs) = p2(igs(mgs),jy,kgs(mgs))
13624 rho0(mgs) = dn(igs(mgs),jy,kgs(mgs))
13625 rhoinv(mgs) = 1.0/rho0(mgs)
13626 rhovt(mgs) = sqrt(rho00/max(0.05,rho0(mgs))) ! prevent excessive rhovt
13627 pi0(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs))
13628 temg(mgs) = t0(igs(mgs),jy,kgs(mgs))
13629 temgkm1(mgs) = t0(igs(mgs),jy,kgsm(mgs))
13630 temgkm2(mgs) = t0(igs(mgs),jy,kgsm2(mgs))
13631 pk(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs)) ! t77(igs(mgs),jy,kgs(mgs))
13632 temcg(mgs) = temg(mgs) - tfr
13633 qss0(mgs) = (380.0)/(pres(mgs))
13634 pqs(mgs) = (380.0)/(pres(mgs))
13635 ltemq = (temg(mgs)-163.15)/fqsat+1.5
13636 ltemq = min( nqsat, max(1,ltemq) )
13637 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
13638 IF ( iqis0 == 1 .or. temg(mgs) <= tfr+0.5 ) THEN
13639 qis(mgs) = pqs(mgs)*tabqis(ltemq)
13640 ELSE
13641 ltemq = (tfr - 163.15)/fqsat + 1.5
13642 qis(mgs) = pqs(mgs)*tabqis(ltemq)
13643 ENDIF
13644 qss(mgs) = qvs(mgs)
13645! es(mgs) = 6.1078e2*tabqvs(ltemq)
13646! eis(mgs) = 6.1078e2*tabqis(ltemq)
13647 cnostmp(mgs) = cno(ls)
13648!
13649
13650 il5(mgs) = 0
13651 if ( temg(mgs) .lt. tfr ) then
13652 il5(mgs) = 1
13653 end if
13654 enddo !mgs
13655
13656 IF ( ipconc < 1 .and. lwsm6 ) THEN
13657 DO mgs = 1,ngscnt
13658 tmp = min( 0.0, temcg(mgs) )
13659 cnostmp(mgs) = min( 2.e8, 2.e6*exp(0.12*tmp) )
13660 ENDDO
13661 ENDIF
13662
13663
13664!
13665! zero arrays that are used but not otherwise set (tm)
13666!
13667 do mgs = 1,ngscnt
13668 qhshr(mgs) = 0.0
13669 end do
13670!
13671! set temporaries for microphysics variables
13672!
13673 DO il = lv,lhab
13674 do mgs = 1,ngscnt
13675 qx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),il), 0.0)
13676 ENDDO
13677 end do
13678
13679 qxw(:,:) = 0.0
13680 qxwlg(:,:) = 0.0
13681
13682
13683
13684
13685!
13686! set concentrations
13687!
13688! ssmax = 0.0
13689
13690
13691 if ( ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) 'ICEZVD_GS: dbg = 5b'
13692
13693 if ( ipconc .ge. 1 ) then
13694 do mgs = 1,ngscnt
13695 cx(mgs,li) = max(an(igs(mgs),jy,kgs(mgs),lni), 0.0)
13696 IF ( qx(mgs,li) .le. qxmin(li) ) THEN
13697 cx(mgs,li) = 0.0
13698 ENDIF
13699
13700 IF ( lcina .gt. 1 ) THEN
13701 cina(mgs) = an(igs(mgs),jy,kgs(mgs),lcina)
13702 ELSE
13703 cina(mgs) = cx(mgs,li)
13704 ENDIF
13705 IF ( lcin > 1 ) THEN
13706 ccin(mgs) = an(igs(mgs),jy,kgs(mgs),lcin)
13707 ENDIF
13708 end do
13709 end if
13710 if ( ipconc .ge. 2 ) then
13711 do mgs = 1,ngscnt
13712 cx(mgs,lc) = max(an(igs(mgs),jy,kgs(mgs),lnc), 0.0)
13713! cx(mgs,lc) = Min( ccwmx, cx(mgs,lc) )
13714 IF ( qx(mgs,lc) .le. qxmin(lc) ) THEN
13715 cx(mgs,lc) = 0.0
13716 ENDIF
13717 IF ( lss > 1 ) THEN
13718 ssmax(mgs) = an(igs(mgs),jy,kgs(mgs),lss)
13719 ENDIF
13720 IF ( lccn .gt. 1 ) THEN
13721 ccnc(mgs) = an(igs(mgs),jy,kgs(mgs),lccn)
13722 ELSE
13723 ccnc(mgs) = 0.0
13724 ENDIF
13725 IF ( lccna .gt. 1 ) THEN
13726 ccna(mgs) = an(igs(mgs),jy,kgs(mgs),lccna)
13727 ELSE
13728 ccna(mgs) = cx(mgs,lc)
13729 ENDIF
13730 end do
13731! ELSE
13732! cx(mgs,lc) = Abs(ccn)
13733 end if
13734 if ( ipconc .ge. 3 ) then
13735 do mgs = 1,ngscnt
13736 cx(mgs,lr) = max(an(igs(mgs),jy,kgs(mgs),lnr), 0.0)
13737 IF ( qx(mgs,lr) .le. qxmin(lr) ) THEN
13738! cx(mgs,lr) = 0.0
13739 ELSEIF ( cx(mgs,lr) .eq. 0.0 .and. qx(mgs,lr) .lt. 3.0*qxmin(lr) ) THEN
13740 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,lr)
13741 qx(mgs,lr) = 0.0
13742 ELSE
13743 cx(mgs,lr) = max( 1.e-9, cx(mgs,lr) )
13744 ENDIF
13745 end do
13746 end if
13747 if ( ipconc .ge. 4 ) then
13748 do mgs = 1,ngscnt
13749 cx(mgs,ls) = max(an(igs(mgs),jy,kgs(mgs),lns), 0.0)
13750 IF ( qx(mgs,ls) .le. qxmin(ls) ) THEN
13751! cx(mgs,ls) = 0.0
13752 ELSEIF ( cx(mgs,ls) .eq. 0.0 .and. qx(mgs,ls) .lt. 3.0*qxmin(ls) ) THEN
13753 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,ls)
13754 qx(mgs,ls) = 0.0
13755 ELSE
13756 cx(mgs,ls) = max( 1.e-9, cx(mgs,ls) )
13757
13758 IF ( ilimit .ge. ipc(ls) ) THEN
13759 tmp = (xdn0(ls)*cx(mgs,ls))/(rho0(mgs)*qx(mgs,ls))
13760 tmp2 = (tmp*(3.14159))**(1./3.)
13761 cnox = cx(mgs,ls)*(tmp2)
13762 IF ( cnox .gt. 3.0*cno(ls) ) THEN
13763 cx(mgs,ls) = 3.0*cno(ls)/tmp2
13764 ENDIF
13765 ENDIF
13766 ENDIF
13767 end do
13768 end if
13769 if ( ipconc .ge. 5 ) then
13770 do mgs = 1,ngscnt
13771
13772 cx(mgs,lh) = max(an(igs(mgs),jy,kgs(mgs),lnh), 0.0)
13773 IF ( qx(mgs,lh) .le. qxmin(lh) ) THEN
13774! cx(mgs,lh) = 0.0
13775 ELSEIF ( cx(mgs,lh) .eq. 0.0 .and. qx(mgs,lh) .lt. 3.0*qxmin(lh) ) THEN
13776 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,lh)
13777 qx(mgs,lh) = 0.0
13778 ELSE
13779 cx(mgs,lh) = max( 1.e-9, cx(mgs,lh) )
13780 IF ( ilimit .ge. ipc(lh) ) THEN
13781 tmp = (xdn0(lh)*cx(mgs,lh))/(rho0(mgs)*qx(mgs,lh))
13782 tmp2 = (tmp*(3.14159))**(1./3.)
13783 cnox = cx(mgs,lh)*(tmp2)
13784 IF ( cnox .gt. 3.0*cno(lh) ) THEN
13785 cx(mgs,lh) = 3.0*cno(lh)/tmp2
13786 ENDIF
13787 ENDIF
13788 ENDIF
13789
13790
13791 end do
13792
13793
13794 end if
13795
13796 if ( lhl .gt. 1 .and. ipconc .ge. 5 ) then
13797 do mgs = 1,ngscnt
13798
13799 cx(mgs,lhl) = max(an(igs(mgs),jy,kgs(mgs),lnhl), 0.0)
13800 IF ( qx(mgs,lhl) .le. qxmin(lhl) ) THEN
13801 cx(mgs,lhl) = 0.0
13802 ELSEIF ( cx(mgs,lhl) .eq. 0.0 .and. qx(mgs,lhl) .lt. 3.0*qxmin(lhl) ) THEN
13803 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,lhl)
13804 qx(mgs,lhl) = 0.0
13805 ELSE
13806 cx(mgs,lhl) = max( 1.e-9, cx(mgs,lhl) )
13807 IF ( ilimit .ge. ipc(lhl) ) THEN
13808 tmp = (xdn0(lhl)*cx(mgs,lhl))/(rho0(mgs)*qx(mgs,lhl))
13809 tmp2 = (tmp*(3.14159))**(1./3.)
13810 cnox = cx(mgs,lhl)*(tmp2)
13811 IF ( cnox .gt. 3.0*cno(lhl) ) THEN
13812 cx(mgs,lhl) = 3.0*cno(lhl)/tmp2
13813 ENDIF
13814 ENDIF
13815 ENDIF
13816
13817
13818 end do
13819 end if
13820
13821!
13822! Set mean particle volume
13823!
13824 IF ( ldovol ) THEN
13825
13826 vx(:,:) = 0.0
13827
13828 DO il = li,lhab
13829
13830 IF ( lvol(il) .ge. 1 ) THEN
13831
13832 DO mgs = 1,ngscnt
13833 vx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),lvol(il)), 0.0)
13834 ENDDO
13835
13836 ENDIF
13837
13838 ENDDO
13839
13840 ENDIF
13841
13842
13843!
13844! Set liquid water fraction
13845!
13846 fhw(:) = 0.0
13847 fsw(:) = 0.0
13848 fhlw(:) = 0.0
13849
13850
13851
13852!
13853! 6th moments
13854!
13855
13856 IF ( ipconc .ge. 6 ) THEN
13857 zx(:,:) = 0.0
13858 DO il = lr,lhab
13859 IF ( lz(il) .gt. 1 ) THEN
13860 DO mgs = 1,ngscnt
13861 zx(mgs,il) = max( an(igs(mgs),jy,kgs(mgs),lz(il)), 0.0 )
13862 ENDDO
13863 ENDIF
13864 ENDDO
13865
13866 ENDIF
13867
13868 IF ( ipconc .ge. 6 ) THEN
13869
13870 IF ( lz(lr) .lt. 1 ) THEN
13871 g1x(:,lr) = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/ &
13872 & ((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
13873
13874
13875 DO mgs = 1,ngscnt
13876 IF ( cx(mgs,lr) .gt. 0.0 .and. qx(mgs,lr) .gt. qxmin(lr) ) THEN
13877
13878 vr = rho0(mgs)*qx(mgs,lr)/(1000.*cx(mgs,lr))
13879 IF ( lzr < 1 ) THEN
13880 IF ( imurain == 3 ) THEN
13881 zx(mgs,lr) = 3.6476*(rnu+2.0)*cx(mgs,lr)*vr**2/(rnu+1.0)
13882 ELSE ! imurain == 1
13883 zx(mgs,lr) = 3.6476*g1x(mgs,lr)*cx(mgs,lr)*vr**2
13884 ENDIF
13885 ENDIF
13886
13887 ENDIF
13888 ENDDO
13889 ENDIF
13890
13891 ENDIF
13892
13893
13894 scx(:,:) = 0.0
13895!
13896! set shape parameters
13897!
13898 if ( ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'ICEZVD_GS: dbg = set alpha'
13899 IF ( imurain == 1 ) THEN
13900 alpha(:,lr) = alphar
13901 ELSEIF ( imurain == 3 ) THEN
13902 alpha(:,lr) = xnu(lr)
13903 ENDIF
13904
13905 alpha(:,li) = xnu(li)
13906 alpha(:,lc) = xnu(lc)
13907
13908 IF ( imusnow == 1 ) THEN
13909 alpha(:,ls) = alphas
13910 ELSEIF ( imusnow == 3 ) THEN
13911 alpha(:,ls) = xnu(ls)
13912 ENDIF
13913
13914 if ( ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'ICEZVD_GS: dbg = set dab'
13915
13916 DO il = lr,lhab
13917 do mgs = 1,ngscnt
13918 IF ( il .ge. lg ) alpha(mgs,il) = dnu(il)
13919
13920
13921 DO ic = lc,lhab
13922 dab0lh(mgs,il,ic) = dab0(il,ic) ! dab0(ic,il)
13923 dab1lh(mgs,il,ic) = dab1(il,ic) ! dab1(ic,il)
13924 ENDDO
13925 end do
13926 ENDDO
13927
13928
13929! DO mgs = 1,ngscnt
13930 DO il = lr,lhab
13931 da0lx(:,il) = da0(il)
13932 ENDDO
13933 da0lh(:) = da0(lh)
13934 da0lr(:) = da0(lr)
13935 da1lr(:) = da1(lr)
13936 da0lc(:) = da0(lc)
13937 da1lc(:) = da1(lc)
13938
13939 if ( ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'ICEZVD_GS: dbg = set rz'
13940
13941 IF ( lzh < 1 .or. lzhl < 1 ) THEN
13942 rzxhlh(:) = rzhl/rz
13943 ELSEIF ( lzh > 1 .and. lzhl > 1 ) THEN
13944 rzxhlh(:) = 1.
13945 ENDIF
13946 IF ( lzr > 1 ) THEN
13947 rzxh(:) = 1.
13948 rzxhl(:) = 1.
13949 ELSE
13950 rzxh(:) = rz
13951 rzxhl(:) = rzhl
13952 ENDIF
13953
13954 IF ( imurain == 1 .and. imusnow == 3 .and. lzr < 1 ) THEN
13955 rzxs(:) = rzs
13956 ELSEIF ( imurain == imusnow .or. lzr > 1 ) THEN
13957 rzxs(:) = 1.
13958 ENDIF
13959 ! ENDDO
13960
13961 IF ( lhl .gt. 1 ) THEN
13962 DO mgs = 1,ngscnt
13963 da0lhl(mgs) = da0(lhl)
13964 ENDDO
13965 ENDIF
13966
13967 ventrx(:) = ventr
13968 ventrxn(:) = ventrn
13969 gf1palp(:) = gamma_sp(1.0 + alphar)
13970
13971!
13972! set factors
13973!
13974 do mgs = 1,ngscnt
13975!
13976 ssi(mgs) = qx(mgs,lv)/qis(mgs)
13977 ssw(mgs) = qx(mgs,lv)/qvs(mgs)
13978!
13979 tsqr(mgs) = temg(mgs)**2
13980!
13981 temgx(mgs) = min(temg(mgs),313.15)
13982 temgx(mgs) = max(temgx(mgs),233.15)
13983 felv(mgs) = 2500837.367 * (273.15/temgx(mgs))**((0.167)+(3.67e-4)*temgx(mgs))
13984!
13985 temcgx(mgs) = min(temg(mgs),273.15)
13986 temcgx(mgs) = max(temcgx(mgs),223.15)
13987 temcgx(mgs) = temcgx(mgs)-273.15
13988
13989! felf = latent heat of fusion, fels = LH of sublimation, felv = LH of vaporization
13990 felf(mgs) = 333690.6098 + (2030.61425)*temcgx(mgs) - (10.46708312)*temcgx(mgs)**2
13991!
13992 fels(mgs) = felv(mgs) + felf(mgs)
13993!
13994 felvs(mgs) = felv(mgs)*felv(mgs)
13995 felss(mgs) = fels(mgs)*fels(mgs)
13996
13997 IF ( eqtset <= 1 ) THEN
13998 felvcp(mgs) = felv(mgs)*cpi
13999 felscp(mgs) = fels(mgs)*cpi
14000 felfcp(mgs) = felf(mgs)*cpi
14001 ELSE
14002
14003 ! equations from appendix in Bryan and Morrison (2012, MWR)
14004 ! note that rw is Rv in the paper, and rd is R.
14005
14006 tmp = qx(mgs,li)+qx(mgs,ls)+qx(mgs,lh)
14007 IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
14008 IF ( lf > 1 ) tmp = tmp + qx(mgs,lf)
14009 cvm = cv+cvv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
14010 +cpigb*(tmp)
14011
14012 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
14013 felvcp(mgs) = (felv(mgs)-rw*temg(mgs))/cvm
14014 felscp(mgs) = (fels(mgs)-rw*temg(mgs))/cvm
14015 felfcp(mgs) = felf(mgs)/cvm
14016
14017 ELSE
14018 ! equivalent version that applies separate updates of latent heating to theta and pi, when both are returned.
14019
14020 cpm = cp+cpv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
14021 +cpigb*(tmp)
14022 rmm=rd+rw*qx(mgs,lv)
14023
14024 felvcp(mgs) = (felv(mgs)*cv/(cp) - rw*temg(mgs)*(1.0-rovcp*cpm/rmm))/cvm
14025 felscp(mgs) = (fels(mgs)*cv/(cp) - rw*temg(mgs)*(1.0-rovcp*cpm/rmm))/cvm
14026 felfcp(mgs) = felf(mgs)*cv/(cp*cvm)
14027
14028 felvpi(mgs) = pi0(mgs)*rovcp*(felv(mgs)/(temg(mgs)) - rw*cpm/rmm)/cvm
14029 felspi(mgs) = pi0(mgs)*rovcp*(fels(mgs)/(temg(mgs)) - rw*cpm/rmm)/cvm
14030 felfpi(mgs) = pi0(mgs)*rovcp*(felf(mgs)/(cvm*temg(mgs)))
14031
14032 ENDIF
14033
14034 ENDIF
14035!
14036 fgamw(mgs) = felvcp(mgs)/pi0(mgs)
14037 fgams(mgs) = felscp(mgs)/pi0(mgs)
14038!
14039 fcqv1(mgs) = 4098.0258*pi0(mgs)*fgamw(mgs)
14040 fcqv2(mgs) = 5807.6953*pi0(mgs)*fgams(mgs)
14041 fcc3(mgs) = felfcp(mgs)/pi0(mgs)
14042!
14043! fwvdf = water vapor diffusivity
14044 fwvdf(mgs) = (2.11e-05)*((temg(mgs)/tfr)**1.94)*(101325.0/(pres(mgs)))
14045!
14046! fadvisc = 'd' for dynamic viscosity
14047! fakvisc = 'k' for kinematic viscosity
14048 fadvisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))*(temg(mgs)/296.0)**(1.5) ! dynamic visc.
14049!
14050 fakvisc(mgs) = fadvisc(mgs)*rhoinv(mgs) ! divide by rho_air to get kinematic visc. (note the 'k' vs. 'd')
14051!
14052 temcgx(mgs) = min(temg(mgs),273.15)
14053 temcgx(mgs) = max(temcgx(mgs),233.15)
14054 temcgx(mgs) = temcgx(mgs)-273.15
14055 fci(mgs) = (2.118636 + 0.007371*(temcgx(mgs)))*(1.0e+03)
14056!
14057 if ( temg(mgs) .lt. 273.15 ) then
14058 temcgx(mgs) = min(temg(mgs),273.15)
14059 temcgx(mgs) = max(temcgx(mgs),233.15)
14060 temcgx(mgs) = temcgx(mgs)-273.15
14061 fcw(mgs) = 4203.1548 + (1.30572e-2)*((temcgx(mgs)-35.)**2) &
14062 & + (1.60056e-5)*((temcgx(mgs)-35.)**4)
14063 end if
14064 if ( temg(mgs) .ge. 273.15 ) then
14065 temcgx(mgs) = min(temg(mgs),308.15)
14066 temcgx(mgs) = max(temcgx(mgs),273.15)
14067 temcgx(mgs) = temcgx(mgs)-273.15
14068 fcw(mgs) = 4243.1688 + (3.47104e-1)*(temcgx(mgs)**2)
14069 end if
14070!
14071 ftka(mgs) = tka0*fadvisc(mgs)/advisc1 ! thermal conductivity: proportional to dynamic viscosity
14072 fthdf(mgs) = ftka(mgs)*cpi*rhoinv(mgs)
14073!
14074 fschm(mgs) = (fakvisc(mgs)/fwvdf(mgs)) ! Schmidt number
14075 fpndl(mgs) = (fakvisc(mgs)/fthdf(mgs)) ! Prandl number (only used for bin melting)
14076!
14077 fai(mgs) = (fels(mgs)**2)/(ftka(mgs)*rw*temg(mgs)**2)
14078 fbi(mgs) = (1.0/(rho0(mgs)*fwvdf(mgs)*qis(mgs)))
14079 fav(mgs) = (felv(mgs)**2)/(ftka(mgs)*rw*temg(mgs)**2)
14080 fbv(mgs) = (1.0/(rho0(mgs)*fwvdf(mgs)*qvs(mgs)))
14081
14082 kp1 = min(nz, kgs(mgs)+1 )
14083 wvel(mgs) = (0.5)*(w(igs(mgs),jgs,kp1) &
14084 & +w(igs(mgs),jgs,kgs(mgs)))
14085
14086!
14087 end do
14088!
14089!
14090! ice habit fractions
14091!
14092!
14093!
14094! Set density
14095!
14096 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: Set density'
14097!
14098
14099 do mgs = 1,ngscnt
14100 xdn(mgs,li) = xdn0(li)
14101 xdn(mgs,lc) = xdn0(lc)
14102 xdn(mgs,lr) = xdn0(lr)
14103 xdn(mgs,ls) = xdn0(ls)
14104 xdn(mgs,lh) = xdn0(lh)
14105 IF ( lvol(ls) .gt. 1 ) THEN
14106 IF ( vx(mgs,ls) .gt. 0.0 .and. qx(mgs,ls) .gt. qxmin(ls) ) THEN
14107 xdn(mgs,ls) = min( xdnmx(ls), max( xdnmn(ls), rho0(mgs)*qx(mgs,ls)/vx(mgs,ls) ) )
14108 ENDIF
14109 ENDIF
14110
14111 IF ( lvol(lh) .gt. 1 ) THEN
14112 IF ( vx(mgs,lh) .gt. 0.0 .and. qx(mgs,lh) .gt. qxmin(lh) ) THEN
14113 IF ( mixedphase ) THEN
14114 ELSE
14115 dnmx = xdnmx(lh)
14116 ENDIF
14117 xdn(mgs,lh) = min( dnmx, max( xdnmn(lh), rho0(mgs)*qx(mgs,lh)/vx(mgs,lh) ) )
14118 vx(mgs,lh) = rho0(mgs)*qx(mgs,lh)/xdn(mgs,lh)
14119
14120 ELSEIF ( vx(mgs,lh) == 0.0 .and. qx(mgs,lh) .gt. qxmin(lh) ) THEN ! if volume is zero, need to initialize the default value
14121
14122 vx(mgs,lh) = rho0(mgs)*qx(mgs,lh)/xdn(mgs,lh)
14123
14124 ENDIF
14125 ENDIF
14126
14127
14128 IF ( lhl .gt. 1 ) THEN
14129
14130 xdn(mgs,lhl) = xdn0(lhl)
14131 xdntmp(mgs,lhl) = xdn0(lhl)
14132
14133 IF ( lvol(lhl) .gt. 1 ) THEN
14134 IF ( vx(mgs,lhl) .gt. 0.0 .and. qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
14135
14136 IF ( mixedphase .and. lhlw > 1 ) THEN
14137 ELSE
14138 dnmx = xdnmx(lhl)
14139 ENDIF
14140
14141 xdn(mgs,lhl) = min( dnmx, max( xdnmn(lhl), rho0(mgs)*qx(mgs,lhl)/vx(mgs,lhl) ) )
14142 vx(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/xdn(mgs,lhl)
14143 xdntmp(mgs,lhl) = xdn(mgs,lhl)
14144
14145 ELSEIF ( vx(mgs,lhl) == 0.0 .and. qx(mgs,lhl) .gt. qxmin(lhl) ) THEN ! if volume is zero, need to initialize the default value
14146
14147 vx(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/xdn(mgs,lhl)
14148
14149 ENDIF
14150 ENDIF
14151
14152 ENDIF
14153
14154
14155 end do
14156
14157 IF ( ipconc == 5 .and. imydiagalpha == 2 ) THEN
14158
14159 cwchtmp = ((3. + dnu(lh))*(2. + dnu(lh))*(1.0 + dnu(lh)))**(-1./3.)
14160
14161 DO mgs = 1,ngscnt
14162 !IF ( igs(mgs) == 19 ) write(0,*) 'k,qr,qh,cr,ch = ',kgs(mgs),qx(mgs,lr),cx(mgs,lr),qx(mgs,lh),cx(mgs,lh)
14163 IF ( qx(mgs,lr) .gt. qxmin(lr) .and. cx(mgs,lr) > cxmin ) THEN
14164 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr)) !
14165 xdia(mgs,lr,3) = (xv(mgs,lr)*6.0*cwc1)**(1./3.)
14166 ! alpha(mgs,lr) = Min(alphamax, c1r*tanh(c2r*(xdia(mgs,lr,3)*1000. - c3r)) + c4r)
14167 ! IF ( igs(mgs) == 19 ) write(0,*) 'imy: i,k,alpr,xdia = ',igs(mgs),kgs(mgs),alpha(mgs,lr),xdia(mgs,lr,3)*1000.
14168
14169 ! M&M-C 2010:
14170 tmp = 4. + alphar
14171 i = int(dgami*(tmp))
14172 del = tmp - dgam*i
14173 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14174
14175 tmp = 1. + alphar
14176 i = int(dgami*(tmp))
14177 del = tmp - dgam*i
14178 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14179
14180 tmp = (x/y)**(1./3.)*xdia(mgs,lr,3)*cwchtmp
14181
14182 alpha(mgs,lr) = min(15., 11.8*(1000.*tmp - 0.7)**2 + 2.)
14183 ENDIF
14184 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. cx(mgs,lh) > cxmin ) THEN
14185! MY 2005:
14186 xv(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) !
14187 xdia(mgs,lh,3) = (xv(mgs,lh)*6.*piinv)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
14188! alpha(mgs,lh) = Min(alphamax, c1h*tanh(c2h*(xdia(mgs,lh,3)*1000. - c3h)) + c4h)
14189
14190 ! M&M-C 2010:
14191 tmp = 4. + dnu(lh)
14192 i = int(dgami*(tmp))
14193 del = tmp - dgam*i
14194 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14195
14196 tmp = 1. + dnu(lh)
14197 i = int(dgami*(tmp))
14198 del = tmp - dgam*i
14199 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14200
14201 tmp = (x/y)**(1./3.)*xdia(mgs,lh,3)*cwchtmp
14202
14203 alpha(mgs,lh) = min(15., 11.8*(1000.*tmp - 0.7)**2 + 2.)
14204 ! alphan(mgs,lh) = alpha(mgs,lh)
14205
14206 ! IF ( igs(mgs) == 19 ) write(0,*) 'imy: i,k,alph,xdia = ',igs(mgs),kgs(mgs),alpha(mgs,lh),xdia(mgs,lh,3)*1000.
14207 il = lh
14208 DO ic = lc,lh-1 ! lhab
14209 i = nint( alpha(mgs,il)*dqiacralphainv )
14210 IF ( ic == lc .or. ic == li .or. ic == ls .or. (ic == lr .and. imurain == 3) ) THEN
14211 alp = (3.*alpha(mgs,ic) + 2.)
14212 j = nint( (3.*alpha(mgs,ic) + 2.)*dqiacralphainv )
14213 ELSE ! IF ( ic == lr .and. imurain == 1 ) ! rain
14214 alp = alpha(mgs,ic)
14215 j = nint( alpha(mgs,ic)*dqiacralphainv )
14216 ENDIF
14217
14218 dab0lh(mgs,ic,il) = dab0lu(j,i,ic,il)
14219 dab1lh(mgs,ic,il) = dab1lu(j,i,ic,il)
14220 dab0lh(mgs,il,ic) = dab0lu(i,j,il,ic)
14221 dab1lh(mgs,il,ic) = dab1lu(i,j,il,ic)
14222 ENDDO
14223 ENDIF
14224! alpha(:,lr) = 0. ! 10.
14225! alpha(:,lh) = 0. ! 10.
14226 IF ( lhl > 0 ) THEN
14227 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. cx(mgs,lhl) > cxmin ) THEN
14228 xv(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*cx(mgs,lhl)) !
14229 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6.*piinv)**(1./3.)
14230 IF ( xdia(mgs,lhl,3) < 0.008 ) THEN
14231 alpha(mgs,lhl) = min(alphamax, c1hl*tanh(c2hl*(xdia(mgs,lhl,3)*1000. - c3hl)) + c4hl)
14232 ELSE
14233 alpha(mgs,lhl) = min(alphamax, c5hl*xdia(mgs,lhl,3)*1000. + c6hl)
14234 ENDIF
14235
14236 il = lhl
14237 DO ic = lc,lh-1 ! lhab
14238 i = nint( alpha(mgs,il)*dqiacralphainv )
14239 IF ( ic == lc .or. ic == li .or. ic == ls .or. (ic == lr .and. imurain == 3) ) THEN
14240 alp = (3.*alpha(mgs,ic) + 2.)
14241 j = nint( (3.*alpha(mgs,ic) + 2.)*dqiacralphainv )
14242 ELSE ! IF ( ic == lr .and. imurain == 1 ) ! rain
14243 alp = alpha(mgs,ic)
14244 j = nint( alpha(mgs,ic)*dqiacralphainv )
14245 ENDIF
14246
14247 dab0lh(mgs,ic,il) = dab0lu(j,i,ic,il)
14248 dab1lh(mgs,ic,il) = dab1lu(j,i,ic,il)
14249 dab0lh(mgs,il,ic) = dab0lu(i,j,il,ic)
14250 dab1lh(mgs,il,ic) = dab1lu(i,j,il,ic)
14251 ENDDO
14252
14253 ENDIF
14254 ENDIF
14255
14256
14257
14258 ENDDO
14259 ENDIF
14260
14261
14262 IF ( imurain == 3 ) THEN
14263 IF ( lzr > 1 ) THEN
14264 alphashr = 0.0
14265 alphamlr = -2.0/3.0
14266 alphasmlr = -2.0/3.0
14267 ELSE
14268 alphashr = xnu(lr)
14269 alphamlr = xnu(lr)
14270 alphasmlr = xnu(lr)
14271 ENDIF
14272! massfacshr = ( (2. + 3.*(1. +alphashr) )/( 3.*(1. + alphashr) ) )**(1./3.) ! this is the diameter factor
14273! massfacmlr = ( (2. + 3.*(1. +alphamlr) )/( 3.*(1. + alphamlr) ) )**(1./3.)
14274 massfacshr = ( (2. + 3.*(1. +alphashr) )**3/( 3.*(1. + alphashr) ) ) ! this is the mass or volume factor
14275 massfacmlr = ( (2. + 3.*(1. +alphamlr) )**3/( 3.*(1. + alphamlr) ) )
14276 ELSEIF ( imurain == 1 ) THEN
14277 IF ( lzr > 1 ) THEN
14278 alphashr = 4.0
14279 alphamlr = 4.0
14280 alphasmlr = alphasmlr0
14281 ELSE
14282 alphashr = alphar
14283 alphamlr = alphar
14284 alphasmlr = alphar
14285 ENDIF
14286! massfacshr = (3.0 + alphashr)*((3.+alphashr)*(2.+alphashr)*(1. + alphashr) )**(-1./3.) ! this is the diameter factor
14287! massfacmlr = (3.0 + alphamlr)*((3.+alphamlr)*(2.+alphamlr)*(1. + alphamlr) )**(-1./3.)
14288 massfacshr = (3.0 + alphashr)**3/((3.+alphashr)*(2.+alphashr)*(1. + alphashr) ) ! this is the mass or volume factor
14289 massfacmlr = (3.0 + alphamlr)**3/((3.+alphamlr)*(2.+alphamlr)*(1. + alphamlr) )
14290 ENDIF
14291
14292! Find shape parameter rain
14293
14294 g1shr = 1.0
14295 g1mlr = 1.0
14296 g1smlr = 1.0
14297
14298! CALL cld_cpu('Z-MOMENT-1')
14299
14300 IF ( ipconc >= 6 ) THEN
14301
14302 ! set base g1x in case rain is not 3-moment
14303 IF ( ipconc >= 6 .and. imurain == 3 ) THEN
14304 il = lr
14305 DO mgs = 1,ngscnt
14306! g1x(mgs,il) = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14307 g1x(mgs,il) = (alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0))
14308 ENDDO
14309 ENDIF
14310
14311 IF (lzr > 1 ) THEN
14312 IF ( imurain == 3 ) THEN
14313 g1shr = (alphashr+2.0)/((alphashr+1.0))
14314 g1mlr = (alphamlr+2.0)/((alphamlr+1.0))
14315 g1smlr = (alphasmlr+2.0)/((alphasmlr+1.0))
14316 ELSEIF ( imurain == 1 ) THEN
14317! g1shr = 36.*(6.0 + alphashr)*(5.0 + alphashr)*(4.0 + alphashr)/ &
14318! & (pi**2*(3.0 + alphashr)*(2.0 + alphashr)*(1.0 + alphashr))
14319 g1shr = (6.0 + alphashr)*(5.0 + alphashr)*(4.0 + alphashr)/ &
14320 & ((3.0 + alphashr)*(2.0 + alphashr)*(1.0 + alphashr))
14321! g1mlr = 36.*(6.0 + alphamlr)*(5.0 + alphamlr)*(4.0 + alphamlr)/ &
14322! & (pi**2*(3.0 + alphamlr)*(2.0 + alphamlr)*(1.0 + alphamlr))
14323 g1mlr = (6.0 + alphamlr)*(5.0 + alphamlr)*(4.0 + alphamlr)/ &
14324 & ((3.0 + alphamlr)*(2.0 + alphamlr)*(1.0 + alphamlr))
14325 g1smlr = (6.0 + alphasmlr)*(5.0 + alphasmlr)*(4.0 + alphasmlr)/ &
14326 & ((3.0 + alphasmlr)*(2.0 + alphasmlr)*(1.0 + alphasmlr))
14327 ENDIF
14328 ENDIF
14329
14330 IF ( lzr > 1 .and. imurain == 3 ) THEN ! { RAIN SHAPE PARAM
14331
14332
14333! CALL cld_cpu('Z-MOMENT-1r')
14334 il = lr
14335 DO mgs = 1,ngscnt
14336
14337
14338 IF ( iresetmoments == 1 .or. iresetmoments == il .or. iresetmoments == -1 ) THEN ! .or. qx(mgs,il) <= qxmin(il) THEN
14339 IF ( zx(mgs,il) <= zxmin ) THEN ! .and. qx(mgs,il) > 0.05e-3 THEN
14340!! write(91,*) 'zx=0; qx,cx = ',1000.*qx(mgs,il),cx(mgs,il)
14341 qx(mgs,il) = 0.0
14342 cx(mgs,il) = 0.0
14343 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14344 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14345 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14346 ELSEIF ( iresetmoments == -1 .and. qx(mgs,il) < qxmin(il) ) THEN
14347 zx(mgs,il) = 0.0
14348 cx(mgs,il) = 0.0
14349 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14350
14351 qx(mgs,il) = 0.0
14352 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14353 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14354 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14355
14356 ELSEIF ( cx(mgs,il) <= cxmin .and. iresetmoments /= -1 ) THEN ! .and. qx(mgs,il) > 0.05e-3 THEN
14357
14358 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
14359 zx(mgs,lr) = 0.0
14360 qx(mgs,lr) = 0.0
14361 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
14362 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
14363 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
14364 ENDIF
14365 ENDIF
14366
14367 IF ( .false. .and. zx(mgs,il) <= zxmin .and. cx(mgs,il) <= cxmin ) THEN
14368 zx(mgs,il) = 0.0
14369 cx(mgs,il) = 0.0
14370 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14371
14372 qx(mgs,il) = 0.0
14373 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14374 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14375 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14376 ENDIF
14377
14378 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
14379
14380 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*max(1.0e-11,cx(mgs,lr)))
14381 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
14382! xv(mgs,lr) = xvmx(lr)
14383! cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
14384 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
14385 xv(mgs,lr) = xvmn(lr)
14386 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
14387 ENDIF
14388
14389 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
14390! have mass and reflectivity but no concentration, so set concentration, using default alpha
14391 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14392 z = zx(mgs,il)
14393 qr = qx(mgs,il)
14394 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*xdn(mgs,lr)**2)
14395! an(igs(mgs),jgs,kgs(mgs),ln(il)) = zx(mgs,il)
14396 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > 0.0 ) THEN
14397! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
14398 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14399 chw = cx(mgs,il)
14400 qr = qx(mgs,il)
14401 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(xdn(mgs,lr)**2*chw)
14402 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
14403
14404 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
14405! How did this happen?
14406 ! set values according to dBZ of -10, or Z = 0.1
14407! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
14408 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
14409 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14410
14411 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14412 z = zx(mgs,il)
14413 qr = qx(mgs,il)
14414 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*1000.*1000)
14415 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14416 ENDIF
14417
14418 IF ( zx(mgs,lr) > 0.0 ) THEN
14419 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(1000.*cx(mgs,lr))
14420 vr = xv(mgs,lr)
14421 qr = qx(mgs,lr)
14422 nrx = cx(mgs,lr)
14423 z = zx(mgs,lr)
14424
14425! xv = (db(1,kz)*a(1,1,kz,lr))**2/(a(1,1,kz,lnr))
14426! rd = z*(pi/6.*1000.)**2/xv
14427
14428! determine shape parameter alpha by iteration
14429 IF ( z .gt. 0.0 ) THEN
14430! alpha(mgs,lr) = 3.
14431 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
14432 DO i = 1,20
14433 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
14434 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
14435 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
14436 alp = max( rnumin, min( rnumax, alp ) )
14437 ENDDO
14438
14439! check for artificial breakup (rain larger than allowed max size)
14440 IF ( (xv(mgs,il) .gt. xvmx(il) .or. (ioldlimiter >= 2 .and. xv(mgs,il) .gt. xvmx(il)/8.) )) THEN
14441 tmp = cx(mgs,il)
14442 IF ( ioldlimiter >= 2 ) THEN ! MY-style active breakup
14443 x = (6.*rho0(mgs)*qx(mgs,il)/(pi*xdn(mgs,il)*cx(mgs,il)))**(1./3.)
14444 x1 = max(0.0e-3, x - 3.0e-3)
14445 x2 = max(0.5, x/6.0e-3)
14446 x3 = x2**3
14447 cx(mgs,il) = cx(mgs,il)*max((1.+2.222e3*x1**2), x3)
14448 xv(mgs,il) = xv(mgs,il)/max((1.+2.222e3*x1**2), x3)
14449 ELSE ! simple cutoff
14450 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
14451 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
14452 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
14453 ENDIF
14454 !xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
14455 !cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
14456
14457 IF ( tmp < cx(mgs,il) ) THEN ! breakup
14458
14459 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14460 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
14461 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14462
14463 vr = xv(mgs,lr)
14464 qr = qx(mgs,lr)
14465 nrx = cx(mgs,lr)
14466 z = zx(mgs,lr)
14467
14468
14469! determine shape parameter alpha by iteration
14470 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
14471 DO i = 1,20
14472 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
14473 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
14474 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
14475 alp = max( rnumin, min( rnumax, alp ) )
14476 ENDDO
14477
14478
14479 ENDIF
14480 ENDIF
14481
14482!
14483! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
14484! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
14485!
14486 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14487 IF ( .true. .and. (alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax) ) THEN
14488
14489 IF ( rescale_high_alpha .and. alp >= rnumax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
14490 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(1./(xdn(mgs,il)))**2
14491 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
14492
14493 ELSEIF ( rescale_low_alphar .and. alp <= rnumin ) THEN
14494 z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
14495 zx(mgs,il) = z
14496 an(igs(mgs),jy,kgs(mgs),lz(il)) = zx(mgs,il)
14497 ENDIF
14498 ENDIF
14499
14500 ! set g1x to use as G factor later. If alpha is in the range ( rnumin < alpha < rnumax ), then
14501 ! this will be the same as computing G from alpha. If alpha = rnumax, however, it probably means that
14502 ! the moments are not matched correctly, so we compute G from the moments instead so that the dZ/dt rates
14503 ! stay consistent with dN/dt and dq/dt.
14504 IF ( alp >= rnumax - 0.01 ) THEN
14505! g1x(mgs,il) = 6**2*zx(mgs,il)/(cx(mgs,il)*(pi*xv(mgs,lr))**2)
14506! g1x(mgs,il) = xdn(mgs,il)*zx(mgs,il)*cx(mgs,il)/((rho0(mgs)*qx(mgs,lr))**2)
14507 g1x(mgs,il) = (pi*xdn(mgs,il))**2*zx(mgs,il)*cx(mgs,il)/((6.*rho0(mgs)*qx(mgs,il))**2)
14508 ELSE
14509 g1x(mgs,il) = g1
14510 ENDIF
14511
14512 tmp = alpha(mgs,lr) + 4./3.
14513 i = int(dgami*(tmp))
14514 del = tmp - dgam*i
14515 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14516
14517 tmp = alpha(mgs,lr) + 1.
14518 i = int(dgami*(tmp))
14519 del = tmp - dgam*i
14520 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14521
14522 gf1palp(mgs) = y
14523
14524! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 4./3.)/(alpha(mgs,lr) + 1.)**(1./3.)/Gamma_sp(alpha(mgs,lr) + 1.)
14525 ventrx(mgs) = x/(y*(alpha(mgs,lr) + 1.)**(1./3.))
14526
14527 IF ( imurain == 3 .and. izwisventr == 2 ) THEN
14528
14529 tmp = alpha(mgs,lr) + 1.5 + br/6.
14530 i = int(dgami*(tmp))
14531 del = tmp - dgam*i
14532 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14533
14534! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 1.5 + br/6.)/Gamma_sp(alpha(mgs,lr) + 1.)
14535 ventrxn(mgs) = x/(y*(alpha(mgs,lr) + 1.)**((1.+br)/6. + 1./3.))
14536
14537! This whole section is imurain == 3, so this branch never runs
14538! ELSEIF ( imurain == 1 .and. iferwisventr == 2 ) THEN
14539!
14540! tmp = alpha(mgs,lr) + 2.5 + br/2.
14541! i = Int(dgami*(tmp))
14542! del = tmp - dgam*i
14543! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14544!
14545!! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 1.5 + br/6.)/Gamma_sp(alpha(mgs,lr) + 1.)
14546! ventrxn(mgs) = x/y
14547
14548
14549 ENDIF
14550
14551 ENDIF
14552 ENDIF
14553
14554 ENDIF
14555
14556 ENDDO
14557! CALL cld_cpu('Z-MOMENT-1r')
14558 ENDIF ! }
14559
14560 ENDIF ! ipconc >= 6
14561
14562! Find shape parameters for graupel and hail
14563 IF ( ipconc .ge. 6 ) THEN
14564
14565 DO il = lr,lhab
14566
14567 ! set base values of g1x
14568 IF ( (.not. ( il == lr .and. imurain == 3 )) .and. ( il == lr .or. il == lh .or. il == lhl .or. il == lf ) ) THEN
14569 DO mgs = 1,ngscnt
14570 g1x(mgs,il) = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
14571 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
14572 ENDDO
14573 ENDIF
14574
14575 IF ( lz(il) .gt. 1 .and. ( .not. ( il == lr .and. imurain == 3 )) ) THEN
14576
14577 DO mgs = 1,ngscnt
14578
14579
14580 IF ( iresetmoments == 1 .or. iresetmoments == il .or. iresetmoments == -1 ) THEN ! .or. qx(mgs,il) <= qxmin(il) ) THEN
14581 IF ( zx(mgs,il) <= zxmin ) THEN ! .and. qx(mgs,il) > 0.05e-3 ) THEN
14582!! write(91,*) 'zx=0; qx,cx = ',1000.*qx(mgs,il),cx(mgs,il)
14583 qx(mgs,il) = 0.0
14584 cx(mgs,il) = 0.0
14585 zx(mgs,il) = 0.0
14586 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14587 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14588 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14589 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14590 ELSEIF ( iresetmoments == -1 .and. qx(mgs,il) < qxmin(il) ) THEN
14591 zx(mgs,il) = 0.0
14592 cx(mgs,il) = 0.0
14593 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14594
14595 qx(mgs,il) = 0.0
14596 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14597 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14598 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14599
14600 ELSEIF ( cx(mgs,il) <= cxmin .and. iresetmoments /= -1 ) THEN ! .and. qx(mgs,il) > 0.05e-3 ) THEN
14601 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
14602 zx(mgs,il) = 0.0
14603 cx(mgs,il) = 0.0
14604 qx(mgs,il) = 0.0
14605 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14606 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14607 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14608 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14609 ENDIF
14610 ENDIF
14611
14612 IF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= cxmin ) THEN
14613 zx(mgs,il) = 0.0
14614 cx(mgs,il) = 0.0
14615 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14616
14617 qx(mgs,il) = 0.0
14618 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14619 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14620 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14621 ENDIF
14622
14623 IF ( qx(mgs,il) .gt. qxmin(il) ) THEN
14624
14625 xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*max(1.0e-9,cx(mgs,il)))
14626 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
14627
14628 IF ( xv(mgs,il) .lt. xvmn(il) ) THEN
14629 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
14630 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
14631 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
14632 ENDIF
14633
14634 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
14635! have mass and reflectivity but no concentration, so set concentration, using default alpha
14636 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
14637 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
14638 z = zx(mgs,il)
14639 qr = qx(mgs,il)
14640! cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z
14641 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(z*(pi*xdn(mgs,il))**2)
14642
14643 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > cxmin ) THEN
14644! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
14645! g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
14646! & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
14647 chw = cx(mgs,il)
14648 qr = qx(mgs,il)
14649! zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
14650! zx(mgs,il) = Min(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
14651 g1 = (6.0 + alphamax)*(5.0 + alphamax)*(4.0 + alphamax)/ &
14652 & ((3.0 + alphamax)*(2.0 + alphamax)*(1.0 + alphamax))
14653 zx(mgs,il) = max(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
14654 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14655
14656 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
14657! How did this happen?
14658 ! set values according to dBZ of -10, or Z = 0.1
14659! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
14660 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
14661 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14662
14663 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
14664 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
14665 z = zx(mgs,il)
14666 qr = qx(mgs,il)
14667! cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z
14668 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(z*(pi*xdn(mgs,il))**2)
14669 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14670 ELSE
14671
14672 chw = cx(mgs,il)
14673 qr = qx(mgs,il)
14674 z = zx(mgs,il)
14675
14676 IF ( zx(mgs,il) .gt. 0. ) THEN
14677
14678! rdi = z*(pi/6.*1000.)**2*chw/((rho0(mgs)*qr)**2)
14679 rdi = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
14680
14681! alp = 1.e18*(6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/
14682! : ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
14683 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
14684 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
14685! print*,'kz, alp, alpha(mgs,il) = ',kz,alp,alpha(mgs,il),rdi,z,xv
14686 alp = max( alphamin, min( alphamax, alp ) )
14687
14688 IF ( newton ) THEN
14689 DO i = 1,10
14690 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
14691 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
14692 alp = alp + ( galpha(alp) - rdi )/dgalpha(alp)
14693 alp = max( alphamin, min( alphamax, alp ) )
14694 ENDDO
14695
14696 ELSE
14697 DO i = 1,10
14698! IF ( 100.*Abs(alp - alpha(mgs,il))/(Abs(alpha(mgs,il))+1.e-5) .lt. 1. ) EXIT
14699 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
14700 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
14701! alp = 1.e18*(6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/
14702! : ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
14703 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
14704 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
14705! print*,'i,alp = ',i,alp
14706 alp = max( alphamin, min( alphamax, alp ) )
14707 ENDDO
14708 ENDIF
14709
14710
14711! check for artificial breakup (graupel/hail larger than allowed max size)
14712 IF ( imaxdiaopt == 1 ) THEN
14713 xvbarmax = xvmx(il)
14714 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
14715 xvbarmax = xvmx(il) /((3. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
14716 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
14717 xvbarmax = xvmx(il) /((4. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
14718 ELSE
14719 xvbarmax = xvmx(il)
14720 ENDIF
14721
14722 IF ( xv(mgs,il) .gt. xvbarmax .or. (il == lr .and. ioldlimiter >= 2 .and. xv(mgs,il) .gt. xvmx(il)/8.)) THEN
14723 tmp = cx(mgs,il)
14724 IF( ioldlimiter >= 2 .and. il == lr) THEN ! MY-style drop limiter for rain
14725 x = (6.*rho0(mgs)*qx(mgs,il)/(pi*xdn(mgs,il)*cx(mgs,il)))**(1./3.)
14726 x1 = max(0.0e-3, x - 3.0e-3)
14727 x2 = max(0.5, x/6.0e-3)
14728 x3 = x2**3
14729 cx(mgs,il) = cx(mgs,il)*max((1.+2.222e3*x1**2), x3)
14730 xv(mgs,il) = xv(mgs,il)/max((1.+2.222e3*x1**2), x3)
14731 ELSE
14732 xv(mgs,il) = min( xvbarmax, max( xvmn(il),xv(mgs,il) ) )
14733 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
14734 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
14735 ENDIF
14736 IF ( tmp < cx(mgs,il) ) THEN ! artificial breakup has happened, so need to adjust reflectivity and find new shape parameter
14737 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
14738 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
14739 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
14740 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14741
14742 chw = cx(mgs,il)
14743 qr = qx(mgs,il)
14744 z = zx(mgs,il)
14745
14746 rdi = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
14747 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
14748 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
14749 DO i = 1,10
14750 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
14751 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
14752 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
14753 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
14754 alp = max( alphamin, min( alphamax, alp ) )
14755 ENDDO
14756
14757
14758 ENDIF
14759 ENDIF
14760
14761!
14762! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
14763! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
14764!
14765 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
14766 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
14767
14768 IF ( ( lrescalelow(il) .or. rescale_high_alpha ) .and. &
14769 & ( alpha(mgs,il) <= alphamin .or. alp == alphamin .or. alp == alphamax ) ) THEN
14770
14771
14772
14773 IF ( rescale_high_alpha .and. alp >= alphamax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
14774 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(6./(pi*xdn(mgs,il)))**2
14775 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
14776
14777 ELSEIF ( lrescalelow(il) .and. alp <= alphamin .and. .not. (il == lh .and. icvhl2h > 0 ) .and. &
14778 .not. ( il == lr .and. .not. rescale_low_alphar ) ) THEN ! alpha = alphamin, so reset Z to prevent growth in C
14779 wtest = .false.
14780 IF ( irescalerainopt == 0 ) THEN
14781 wtest = .false.
14782 ELSEIF ( irescalerainopt == 1 ) THEN
14783 wtest = qx(mgs,lc) > qxmin(lc)
14784 ELSEIF ( irescalerainopt == 2 ) THEN
14785 wtest = qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < rescale_wthresh
14786 ELSEIF ( irescalerainopt == 3 ) THEN
14787 wtest = temcg(mgs) > rescale_tempthresh .and. qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < rescale_wthresh
14788 ENDIF
14789
14790 IF ( il == lr .and. ( wtest ) ) THEN
14791! IF ( temcg(mgs) > 0.0 .and. il == lr .and. qx(mgs,lc) > qxmin(lc) ) THEN
14792 ! certain situations where rain number is adjusted instead of Z. Helps avoid rain being 'zapped' by autoconverted
14793 ! drops (i.e., favor preserving Z when alpha tries to go negative)
14794 chw = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(6./(pi*xdn(mgs,il)))**2 ! g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z1
14795 cx(mgs,il) = chw
14796 an(igs(mgs),jy,kgs(mgs),ln(il)) = chw
14797 ELSE
14798
14799 ! Usual resetting of reflectivity moment to force consisntency between Q, N, Z, and alpha when alpha = alphamin
14800 z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
14801 z = z1*(6./(pi*xdn(mgs,il)))**2
14802 zx(mgs,il) = z
14803 an(igs(mgs),jy,kgs(mgs),lz(il)) = z
14804 ENDIF
14805 ENDIF
14806 ENDIF
14807
14808
14809 ! set g1x to use as G factor later. If alpha is in the range ( rnumin < alpha < rnumax ), then
14810 ! this will be the same as computing G from alpha. If alpha = rnumax, however, it probably means that
14811 ! the moments are not matched correctly, so we compute G from the moments instead so that the dZ/dt rates
14812 ! stay consistent with dN/dt and dq/dt.
14813! g1x(mgs,il) = zx(mgs,il)*chw*(pi*xdn(mgs,il))**2/(6.*qr*dn(igs(mgs),jy,kgs(mgs)))**2
14814! g1x(mgs,il) = g1 ! zx(mgs,il)*cx(mgs,il)/(qr)**2
14815 IF ( alp >= alphamax - 0.5 ) THEN
14816! g1x(mgs,il) = 6**2*zx(mgs,il)/(cx(mgs,il)*(pi*xv(mgs,lr))**2)
14817! g1x(mgs,il) = (xdn(mgs,il))**2*zx(mgs,il)*cx(mgs,il)/((rho0(mgs)*qx(mgs,il))**2)
14818 g1x(mgs,il) = (pi*xdn(mgs,il))**2*zx(mgs,il)*cx(mgs,il)/((6.*rho0(mgs)*qx(mgs,il))**2)
14819 ELSE
14820 g1x(mgs,il) = g1
14821 ENDIF
14822
14823 ENDIF
14824
14825! IF ( ny .eq. 2 ) THEN
14826! IF ( qr .gt. 1.e-3 ) THEN
14827! write(0,*) 'alphah at nstep,i,k = ',dtp*(nstep-1),igs(mgs),kgs(mgs),alpha(mgs,il),qr*1000.
14828! ENDIF
14829! ENDIF
14830
14831
14832 ENDIF ! .true.
14833
14834 IF ( il == lr ) THEN
14835
14836! tmp = alpha(mgs,lr) + 4./3.
14837! i = Int(dgami*(tmp))
14838! del = tmp - dgam*i
14839! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14840!
14841! tmp = alpha(mgs,lr) + 1.
14842! i = Int(dgami*(tmp))
14843! del = tmp - dgam*i
14844! y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14845!
14846!! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 4./3.)/(alpha(mgs,lr) + 1.)**(1./3.)/Gamma_sp(alpha(mgs,lr) + 1.)
14847! ventrx(mgs) = x/(y*(alpha(mgs,lr) + 1.)**(1./3.))
14848
14849
14850 tmp = alpha(mgs,lr) + 1.
14851 i = int(dgami*(tmp))
14852 del = tmp - dgam*i
14853 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14854
14855 gf1palp(mgs) = y
14856
14857 IF ( iferwisventr == 2 ) THEN
14858 tmp = alpha(mgs,lr) + 2.5 + br/2.
14859 i = int(dgami*(tmp))
14860 del = tmp - dgam*i
14861 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14862
14863! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 1.5 + br/6.)/Gamma_sp(alpha(mgs,lr) + 1.)
14864
14865 ventrxn(mgs) = x/y
14866
14867 ENDIF
14868
14869 ENDIF ! il==lr
14870
14871
14872 ELSE ! below mass threshold
14873! g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/
14874! & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
14875! z1 = g1*rho0(mgs)**2*(qr)*qr/chw
14876! z = 1.e18*z1*(6./(pi*1000.))**2
14877! z = z1*(6./(pi*1000.))**2
14878! zx(mgs,il) = z
14879! an(igs(mgs),jy,kgs(mgs),lz(il)) = z
14880 ENDIF ! ( qx(mgs,il) .gt. qxmin(il) )
14881
14882
14883
14884! ENDIF
14885 ENDDO ! mgs
14886
14887! CALL cld_cpu('Z-DELABK')
14888
14889! IF ( il == lr ) THEN
14890! xnutmp = (alpha(mgs,il) - 2.)/3.
14891! da0lr(mgs) = delbk(bb(il), xnutmp, xmu(il), 0)
14892! ENDIF
14893
14894 IF ( .not. ( il == lr .and. imurain == 3 ) ) THEN
14895! CALL cld_cpu('Z-DELABK')
14896 DO mgs = 1,ngscnt
14897 IF ( qx(mgs,il) > qxmin(il) ) THEN
14898 xnutmp = (alpha(mgs,il) - 2.)/3.
14899
14900! IF ( .true. ) THEN
14901 DO ic = lc,lh-1 ! lhab
14902 IF ( il .ne. ic .and. qx(mgs,ic) .gt. qxmin(ic)) THEN
14903 xnuc = xnu(ic)
14904 IF ( ic == lc .and. idiagnosecnu > 0 ) xnuc = alpha(mgs,lc) ! alpha for droplets is actually nu
14905 IF ( il /= lr .and. ic == lr .and. lzr > 1 ) THEN
14906 IF ( imurain == 3 ) THEN
14907 xnuc = alpha(mgs,lr) ! alpha is nu already
14908 ELSE
14909 xnuc = ( alpha(mgs,lr) - 2. )/3. ! convert alpha to nu
14910 ENDIF
14911 ENDIF
14912 ! delabk(ba,bb,nua,nub,mua,mub,k), where a (il) is collector and b (ic) is collected
14913 IF ( .false. ) THEN
14914 dab0lh(mgs,ic,il) = delabk(bb(ic), bb(il), xnuc, xnutmp, xmu(ic), xmu(il), 0) !dab0(il,ic)
14915 dab1lh(mgs,ic,il) = delabk(bb(ic), bb(il), xnuc, xnutmp, xmu(ic), xmu(il), 1) !dab1(il,ic)
14916 dab0lh(mgs,il,ic) = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic), 0) !dab0(il,ic)
14917 dab1lh(mgs,il,ic) = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic), 1) !dab1(il,ic)
14918 ELSE ! use lookup table -- not interpolating yet because table resolution of 0.05 is good enough
14919 i = nint( alpha(mgs,il)*dqiacralphainv )
14920 IF ( ic == lc .or. ic == li .or. ic == ls .or. (ic == lr .and. imurain == 3) ) THEN
14921 alp = (3.*alpha(mgs,ic) + 2.)
14922 j = nint( (3.*alpha(mgs,ic) + 2.)*dqiacralphainv )
14923 ELSE ! IF ( ic == lr .and. imurain == 1 ) ! rain
14924 alp = alpha(mgs,ic)
14925 j = nint( alpha(mgs,ic)*dqiacralphainv )
14926 ENDIF
14927
14928 dab0lh(mgs,ic,il) = dab0lu(j,i,ic,il)
14929 dab1lh(mgs,ic,il) = dab1lu(j,i,ic,il)
14930 dab0lh(mgs,il,ic) = dab0lu(i,j,il,ic)
14931 dab1lh(mgs,il,ic) = dab1lu(i,j,il,ic)
14932
14933! tmp1 = dab0lu(j,i,ic,il)
14934! tmp2 = dab1lu(j,i,ic,il)
14935! tmp3 = dab0lu(i,j,il,ic)
14936! tmp4 = dab1lu(i,j,il,ic)
14937! tmp5 = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(ic), xmu(il), 0) !dab0(il,ic)
14938! tmp6 = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(ic), xmu(il), 1) !dab1(il,ic)
14939! tmp5 = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic), 0) !dab0(il,ic)
14940! tmp6 = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic), 1) !dab1(il,ic)
14941
14942 IF ( .false. .and. ny <= 2 ) THEN
14943 write(0,*)
14944 write(0,*) 'bb: ', bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic)
14945 write(0,*) 'il,ic = ',il,ic,alpha(mgs,il),i,xnuc,alp,j
14946 write(0,*) 'dab0lh,tmp1 = ',dab0lh(mgs,ic,il),tmp1
14947 write(0,*) 'dab1lh,tmp2 = ',dab1lh(mgs,ic,il),tmp2
14948 write(0,*) 'dab0lh,tmp3 = ',dab0lh(mgs,il,ic),tmp3,tmp5
14949 write(0,*) 'dab1lh,tmp4 = ',dab1lh(mgs,il,ic),tmp4,tmp6
14950
14951 ENDIF
14952
14953 ENDIF
14954
14955 ENDIF
14956 ENDDO
14957
14958! ENDIF
14959
14960 da0lx(mgs,il) = delbk(bb(il), xnutmp, xmu(il), 0)
14961 IF ( il .eq. lh ) THEN
14962 da0lh(mgs) = delbk(bb(il), xnutmp, xmu(il), 0)
14963 IF ( lzr > 1 ) THEN
14964 rzxh(mgs) = 1.
14965 ELSE
14966 rzxh(mgs) = ((4. + alpha(mgs,il))*(5. + alpha(mgs,il))*(6. + alpha(mgs,il))*(1. + xnu(lr)))/ &
14967 & ((1. + alpha(mgs,il))*(2. + alpha(mgs,il))*(3. + alpha(mgs,il))*(2. + xnu(lr)))
14968 ENDIF
14969
14970 IF ( lzhl < 1 ) THEN
14971 rzxhlh(mgs) = rzxhl(mgs)/(((4. + alpha(mgs,il))*(5. + alpha(mgs,il))*(6. + alpha(mgs,il))*(1. + xnu(lr)))/ &
14972 & ((1. + alpha(mgs,il))*(2. + alpha(mgs,il))*(3. + alpha(mgs,il))*(2. + xnu(lr))))
14973 ENDIF
14974 ELSEIF ( il .eq. lhl ) THEN
14975 da0lhl(mgs) = delbk(bb(il), xnutmp, xmu(il), 0)
14976 IF ( lzr > 1 ) THEN
14977 rzxhl(mgs) = 1.
14978 ELSE
14979 rzxhl(mgs) = ((4.0 + alpha(mgs,il))*(5. + alpha(mgs,il))*(6. + alpha(mgs,il))*(1. + xnu(lr)))/ &
14980 & ((1. + alpha(mgs,il))*(2. + alpha(mgs,il))*(3. + alpha(mgs,il))*(2. + xnu(lr)))
14981 ENDIF
14982 ELSEIF ( il == lr ) THEN
14983 xnutmp = (alpha(mgs,il) - 2.)/3.
14984 da0lr(mgs) = delbk(bb(il), xnutmp, xmu(il), 0)
14985 da1lr(mgs) = delbk(bb(il), xnutmp, xmu(il), 1)
14986 ENDIF
14987
14988 ENDIF ! ( qx(mgs,il) > qxmin(il) )
14989 ENDDO ! mgs
14990! CALL cld_cpu('Z-DELABK')
14991 ENDIF ! il /= lr
14992
14993! CALL cld_cpu('Z-DELABK')
14994
14995 ENDIF ! lz(il) .gt. 1
14996
14997 ENDDO ! il
14998
14999 ENDIF ! ipconc .ge. 6
15000
15001! CALL cld_cpu('Z-MOMENT-1')
15002
15003!
15004! set some values for ice nucleation
15005!
15006 do mgs = 1,ngscnt
15007 kp1 = min(nz, kgs(mgs)+1 )
15008! wvel(mgs) = (0.5)*(w(igs(mgs),jgs,kp1) &
15009! & +w(igs(mgs),jgs,kgs(mgs)))
15010
15011
15012 wvelkm1(mgs) = (0.5)*(w(igs(mgs),jgs,kgs(mgs)) &
15013 & +w(igs(mgs),jgs,kgsm(mgs)))
15014 cninm(mgs) = t7(igs(mgs),jgs,kgsm(mgs))
15015 cnina(mgs) = t7(igs(mgs),jgs,kgs(mgs))
15016 cninp(mgs) = t7(igs(mgs),jgs,kgsp(mgs))
15017 end do
15018
15019!
15020! Set a couple of cloud variables...
15021!
15022
15023! SUBROUTINE setvt(ngscnt,qx,qxmin,cx,rho0,rhovt,xdia,cno,
15024! : xmas,xdn,xvmn,xvmx,xv,cdx,
15025! : ipconc,ndebug)
15026! SUBROUTINE setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno, &
15027! & xmas,vtxbar,xdn,xvmn,xvmx,xv,cdx, &
15028! & ipconc1,ndebug1,ngs,nz,kgs,cwnccn,fadvisc, &
15029! & cwmasn,cwmasx,cwradn,cnina,cimna,cimxa, &
15030! & itype1a,itype2a,temcg,infdo,alpha)
15031
15032
15033 infdo = 1
15034 IF ( rimdenvwgt > 0 ) infdo = 1
15035
15036 call setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno,cnostmp, &
15037 & xmas,vtxbar,xdn,xvmn,xvmx,xv,cdx,cdxgs, &
15038 & ipconc,ndebug,ngs,nz,kgs,fadvisc, &
15039 & cwmasn,cwmasx,cwradn,cnina,cimn,cimx, &
15040 & itype1,itype2,temcg,infdo,alpha,0,axx,bxx) ! ,cdh,cdhl)
15041! & itype1,itype2,temcg,infdo,alpha,0,axh,bxh,axhl,bxhl) ! ,cdh,cdhl)
15042
15043
15044 IF ( lwsm6 .and. ipconc == 0 ) THEN
15045 tmp = max(qxmin(lh), qxmin(ls))
15046 DO mgs = 1,ngscnt
15047 total = qx(mgs,lh) + qx(mgs,ls)
15048 IF ( total > tmp ) THEN
15049 vt2ave(mgs) = (qx(mgs,lh)*vtxbar(mgs,lh,1) + qx(mgs,ls)*vtxbar(mgs,ls,1))/total
15050 ELSE
15051 vt2ave(mgs) = 0.0
15052 ENDIF
15053 ENDDO
15054 ENDIF
15055
15056
15057!
15058! Set number concentrations (need xdia from setvt)
15059!
15060 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: Set concentration'
15061 IF ( ipconc .lt. 1 ) THEN
15062 cina(1:ngscnt) = cx(1:ngscnt,li)
15063 ENDIF
15064 if ( ipconc .lt. 5 ) then
15065 do mgs = 1,ngscnt
15066
15067
15068 IF ( ipconc .lt. 3 ) THEN
15069! cx(mgs,lr) = 0.0
15070 if ( qx(mgs,lr) .gt. qxmin(lh) ) then
15071! cx(mgs,lr) = cno(lr)*xdia(mgs,lr,1)
15072! xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr))
15073 end if
15074 ENDIF
15075
15076 IF ( ipconc .lt. 4 ) THEN
15077! tmp = cx(mgs,ls)
15078! cx(mgs,ls) = 0.0
15079 if ( qx(mgs,ls) .gt. qxmin(ls) ) then
15080! cx(mgs,ls) = cno(ls)*xdia(mgs,ls,1)
15081! xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*cx(mgs,ls))
15082 end if
15083 ENDIF ! ( ipconc .lt. 4 )
15084
15085 IF ( ipconc .lt. 5 ) THEN
15086
15087
15088! cx(mgs,lh) = 0.0
15089 if ( qx(mgs,lh) .gt. qxmin(lh) ) then
15090! cx(mgs,lh) = cno(lh)*xdia(mgs,lh,1)
15091! xv(mgs,lh) = Max(xvmn(lh), rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) )
15092! xdia(mgs,lh,3) = (xv(mgs,lh)*6./pi)**(1./3.)
15093 end if
15094
15095 ENDIF ! ( ipconc .lt. 5 )
15096
15097 end do
15098 end if
15099
15100 IF ( ipconc .ge. 2 ) THEN
15101 DO mgs = 1,ngscnt
15102
15103 rb(mgs) = 0.5*xdia(mgs,lc,1)*(1./(1.+alpha(mgs,lc)))**(1./6.)
15104 xl2p(mgs) = max(0.0d0, 2.7e-2*xdn(mgs,lc)*cx(mgs,lc)*xv(mgs,lc)* &
15105 & ((0.5e20*rb(mgs)**3*xdia(mgs,lc,1))-0.4) )
15106 IF ( rb(mgs) .gt. 3.51e-6 ) THEN
15107! rh(mgs) = Max( 0.5d0*xdia(mgs,lc,1), 6.3d-4/(1.d6*(rb(mgs) - 3.5d-6)) )
15108 rh(mgs) = max( 41.d-6, 6.3d-4/(1.d6*(rb(mgs) - 3.5d-6)) )
15109 ELSE
15110 rh(mgs) = 41.d-6
15111 ENDIF
15112 IF ( xl2p(mgs) .gt. 0.0 ) THEN
15113 nh(mgs) = 4.2d9*xl2p(mgs)
15114 ELSE
15115 nh(mgs) = 1.e30
15116 ENDIF
15117 ENDDO
15118 ENDIF
15119
15120!
15121!
15122!
15123!
15124! maximum depletion tendency by any one source
15125!
15126!
15127 if( ndebug .ge. 0 ) THEN
15128!mpi! write(0,*) 'Set depletion max/min1'
15129 endif
15130 do mgs = 1,ngscnt
15131 qvimxd(mgs) = 0.70*(qx(mgs,lv)-qis(mgs))*dtpinv ! depletion by all vap. dep to ice.
15132
15133 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
15134
15135 qvimxd(mgs) = max(qvimxd(mgs), 0.0)
15136
15137 frac = 0.1d0
15138 qimxd(mgs) = frac*qx(mgs,li)*dtpinv
15139 qcmxd(mgs) = frac*qx(mgs,lc)*dtpinv
15140 qrmxd(mgs) = frac*qx(mgs,lr)*dtpinv
15141 qsmxd(mgs) = frac*qx(mgs,ls)*dtpinv
15142 qhmxd(mgs) = frac*qx(mgs,lh)*dtpinv
15143 IF ( lhl > 1 ) qhlmxd(mgs) = frac*qx(mgs,lhl)*dtpinv
15144 end do
15145!
15146 if( ndebug .ge. 0 ) THEN
15147!mpi! write(0,*) 'Set depletion max/min2'
15148 endif
15149
15150 do mgs = 1,ngscnt
15151!
15152 if ( qx(mgs,lc) .le. qxmin(lc) ) then
15153 ccmxd(mgs) = 0.20*cx(mgs,lc)*dtpinv
15154 else
15155 IF ( ipconc .ge. 2 ) THEN
15156 ccmxd(mgs) = frac*cx(mgs,lc)*dtpinv
15157 ELSE
15158 ccmxd(mgs) = frac*qx(mgs,lc)/(xmas(mgs,lc)*rho0(mgs)*dtp)
15159 ENDIF
15160 end if
15161!
15162 if ( qx(mgs,li) .le. qxmin(li) ) then
15163 cimxd(mgs) = frac*cx(mgs,li)*dtpinv
15164 else
15165 IF ( ipconc .ge. 1 ) THEN
15166 cimxd(mgs) = frac*cx(mgs,li)*dtpinv
15167 ELSE
15168 cimxd(mgs) = frac*qx(mgs,li)/(xmas(mgs,li)*rho0(mgs)*dtp)
15169 ENDIF
15170 end if
15171!
15172!
15173 crmxd(mgs) = 0.10*cx(mgs,lr)*dtpinv
15174 csmxd(mgs) = frac*cx(mgs,ls)*dtpinv
15175 chmxd(mgs) = frac*cx(mgs,lh)*dtpinv
15176
15177 ccmxd(mgs) = frac*cx(mgs,lc)*dtpinv
15178 cimxd(mgs) = frac*cx(mgs,li)*dtpinv
15179 crmxd(mgs) = frac*cx(mgs,lr)*dtpinv
15180 csmxd(mgs) = frac*cx(mgs,ls)*dtpinv
15181 chmxd(mgs) = frac*cx(mgs,lh)*dtpinv
15182
15183 qxmxd(mgs,lv) = max(0.0, 0.1*(qx(mgs,lv) - qvs(mgs))*dtpinv)
15184
15185 DO il = lc,lhab
15186 qxmxd(mgs,il) = frac*qx(mgs,il)*dtpinv
15187 cxmxd(mgs,il) = frac*cx(mgs,il)*dtpinv
15188 ENDDO
15189
15190 end do
15191
15192
15193
15194
15195 IF ( ipconc >= 6 ) THEN
15196 frac = 0.4d0
15197 zxmxd(:,:) = 0.0
15198 DO il = lr,lhab
15199 IF ( lz(il) > 0 .or. ( il == lr ) ) THEN
15200 DO mgs = 1,ngscnt
15201 zxmxd(mgs,il) = frac*zx(mgs,il)*dtpinv
15202 ENDDO
15203 ENDIF
15204 ENDDO
15205 ENDIF
15206
15207
15208
15209
15210 ! default factors between mean volume and maximum mass volume
15211 maxmassfac(lc) = ( (2. + 3.*(1. + xnu(lc)) )**3/( 3.*(1. + xnu(lc)) ) )
15212 maxmassfac(li) = ( (2. + 3.*(1. + xnu(li)) )**3/( 3.*(1. + xnu(li)) ) )
15213
15214 IF ( imurain == 3 ) THEN
15215 maxmassfac(lr) = ( (2. + 3.*(1. + xnu(lr)) )**3/( 3.*(1. + xnu(lr)) ) )
15216 ELSE
15217 maxmassfac(lr) = (3.0 + alphar)**3/ &
15218 & ((3.+alphar)*(2.+alphar)*(1. + alphar) )
15219 ENDIF
15220
15221 IF ( imusnow == 3 ) THEN
15222 maxmassfac(ls) = ( (2. + 3.*(1. + alphas) )**3/( 3.*(1. + alphas) ) )
15223 ELSE
15224 maxmassfac(ls) = (3.0 + alphas)**3/ &
15225 & ((3.+alphas)*(2.+alphas)*(1. + alphas) )
15226 ENDIF
15227
15228 maxmassfac(lh) = (3.0 + alphah)**3/ &
15229 & ((3.+alphah)*(2.+alphah)*(1. + alphah) )
15230
15231 IF ( lhl > 1 ) THEN
15232 maxmassfac(lhl) = (3.0 + alphahl)**3/ &
15233 & ((3.+alphahl)*(2.+alphahl)*(1. + alphahl) )
15234 ENDIF
15235
15236
15237
15238 DO mgs = 1,ngscnt
15239 DO il = lh,lhab ! graupel and hail only (and frozen drops)
15240
15241 vshdgs(mgs,il) = vshd ! base value
15242
15243 IF ( qx(mgs,il) > qxmin(il) .and. ivshdgs > 0 ) THEN
15244
15245 ! tmpdiam is weighted diameter of d^(shedalp-1), so for shedalp=3, this is the area-weighted diameter or maximum mass diameter.
15246 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
15247
15248 IF ( tmpdiam > sheddiam0 ) THEN
15249 vshdgs(mgs,il) = 0.523599*(1.5e-3)**3/massfacshr ! 1.5mm drops from very large ice
15250 ELSEIF ( tmpdiam > sheddiam ) THEN ! intermediate size
15251 vshdgs(mgs,il) = 0.523599*(3.0e-3)**3/massfacshr ! 3.0mm drops from medium-large ice
15252 ELSE
15253! vshdgs(mgs,il) = Min( xvmx(lr), xv(mgs,il)*xdn(mgs,il)*0.001 ) ! size of drop from melted mean ice particle
15254 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
15255 ENDIF
15256 ENDIF
15257 ENDDO
15258 ENDDO
15259
15260!
15261!
15262! microphysics source terms (1/s) for mixing ratios
15263!
15264!
15265!
15266! Collection efficiencies:
15267!
15268 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: Set collection efficiencies'
15269!
15270 do mgs = 1,ngscnt
15271!
15272!
15273!
15274 qcwresv(mgs) = 0.0
15275 ccwresv(mgs) = 0.0
15276
15277 erw(mgs) = 0.0
15278 esw(mgs) = 0.0
15279 ehw(mgs) = 0.0
15280 efw(mgs) = 0.0
15281 ehlw(mgs) = 0.0
15282! ehxw(mgs) = 0.0
15283!
15284 err(mgs) = 0.0
15285 esr(mgs) = 0.0
15286 il2(mgs) = 0
15287 il3(mgs) = 0
15288 ehr(mgs) = 0.0
15289 ehlr(mgs) = 0.0
15290! ehxr(mgs) = 0.0
15291!
15292 eri(mgs) = 0.0
15293 esi(mgs) = 0.0
15294 ehi(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehi*ehiclsn
15295 ehis(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehi*ehiclsn
15296 ehli(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehli*ehliclsn
15297 ehlis(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehli*ehliclsn
15298! ehxi(mgs) = 0.0
15299!
15300 ers(mgs) = 0.0
15301 ess(mgs) = 0.0
15302 ehs(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehs*ehsclsn
15303 ehsfac(mgs) = 1.0 ! factor based on ice saturation
15304 ehls(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehls*ehlsclsn
15305 ehscnv(mgs) = 0.0
15306! ehxs(mgs) = 0.0
15307!
15308 eiw(mgs) = 0.0
15309 eii(mgs) = 0.0
15310 ehsclsn(mgs) = 0.0
15311 ehiclsn(mgs) = 0.0
15312 ehlsclsn(mgs) = 0.0
15313 ehliclsn(mgs) = 0.0
15314 esiclsn(mgs) = 0.0
15315
15316
15317! reserve droplets
15318 IF ( exwmindiam > 0 .and. qx(mgs,lc) > qxmin(lc) ) THEN
15319 tmp = cx(mgs,lc)*exp(- (exwmindiam/xdia(mgs,lc,1))**3 )
15320 ccwresv(mgs) = min( cx(mgs,lc), max( 2.e6, cx(mgs,lc) - tmp ) )
15321
15322 tmp = cx(mgs,lc) - ccwresv(mgs)
15323
15324 volt = pi/6.*(exwmindiam)**3
15325 qcwresv(mgs) = qx(mgs,lc) - tmp*xdn0(lc)*rhoinv(mgs)*(volt + xv(mgs,lc))
15326
15327
15328 IF ( .false. .and. qx(mgs,lc) > 0.1e-3 ) THEN
15329
15330 write(0,*) 'cx,qx,crsv,qrsv = ',cx(mgs,lc),qx(mgs,lc),ccwresv(mgs),qcwresv(mgs)
15331
15332 ENDIF
15333
15334 ENDIF
15335
15336
15337 icwr(mgs) = 1
15338 IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN
15339 cwrad = 0.5*xdia(mgs,lc,1)
15340 DO il = 1,8
15341 IF ( cwrad .ge. 1.e-6*cwr(il,1) ) icwr(mgs) = il
15342 ENDDO
15343 ENDIF
15344
15345
15346 irwr(mgs) = 1
15347 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
15348 rwrad = 0.5*xdia(mgs,lr,3) ! changed to mean volume diameter (10/6/06)
15349 DO il = 1,6
15350 IF ( rwrad .ge. 1.e-6*grad(il,1) ) irwr(mgs) = il
15351 ENDDO
15352 ENDIF
15353
15354
15355 igwr(mgs) = 1
15356! IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
15357! rwrad = 0.5*xdia(mgs,lr,1)
15358! setting erw = 1 always, so now use igwr for graupel
15359 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
15360 rwrad = 0.5*xdia(mgs,lh,3) ! changed to mean volume diameter (10/6/06)
15361 DO il = 1,6
15362 IF ( rwrad .ge. 1.e-6*grad(il,1) ) igwr(mgs) = il
15363 ENDDO
15364 ENDIF
15365
15366
15367 IF ( lhl .gt. 1 ) THEN ! hail is turned on
15368 ihlr(mgs) = 1
15369 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
15370 rwrad = 0.5*xdia(mgs,lhl,3) ! changed to mean volume diameter (10/6/06)
15371 DO il = 1,6
15372 IF ( rwrad .ge. 1.e-6*grad(il,1) ) ihlr(mgs) = il
15373 ENDDO
15374 ENDIF
15375 ENDIF
15376
15377!
15378!
15379! Ice-Ice: Collection (cxc) efficiencies
15380!
15381!
15382 if ( qx(mgs,li) .gt. qxmin(li) ) then
15383! IF ( ipconc .ge. 14 ) THEN
15384! eii(mgs)=0.1*exp(0.1*temcg(mgs))
15385! if ( temg(mgs) .lt. 243.15 .and. qx(mgs,lc) .gt. 1.e-6 ) then
15386! eii(mgs)=0.1
15387! end if
15388!
15389! ELSE
15390 eii(mgs) = exp(0.025*min(temcg(mgs),0.0)) ! alpha1 from LFO83 (21)
15391! ENDIF
15392 if ( temg(mgs) .gt. 273.15 ) eii(mgs) = 1.0
15393 end if
15394!
15395!
15396!
15397! Ice-cloud water: Collection (cxc) efficiencies
15398!
15399!
15400 eiw(mgs) = 0.0
15401 if ( qx(mgs,li).gt.qxmin(li) .and. qx(mgs,lc).gt.qxmin(lc) ) then
15402
15403
15404 if (xdia(mgs,lc,1).gt.ewi_dcmin .and. xdia(mgs,li,1).gt.ewi_dimin) then
15405! erm 5/10/2007 test following change:
15406! if (xdia(mgs,lc,1).gt.12.0e-06 .and. xdia(mgs,li,1).gt.50.0e-06) then
15407 eiw(mgs) = 0.5
15408 end if
15409 if ( temg(mgs) .ge. 273.15 ) eiw(mgs) = 0.0
15410 end if
15411
15412!
15413!
15414!
15415! Rain: Collection (cxc) efficiencies
15416!
15417!
15418 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,lc).gt.qxmin(lc) ) then
15419
15420 IF ( lnr .gt. 1 ) THEN
15421 erw(mgs) = 1.0
15422
15423 ELSE
15424
15425! cwrad = 0.5*xdia(mgs,lc,1)
15426! erw(mgs) =
15427! > min((aradcw + cwrad*(bradcw + cwrad*
15428! < (cradcw + cwrad*(dradcw)))), 1.0)
15429! IF ( xdia(mgs,lc,1) .lt. 2.4e-06 .or. xdia(mgs,lr,1) .le. 50.0e-6 ) THEN
15430! erw(mgs)=0.0
15431! ENDIF
15432! erw(mgs) = ew(icwr(mgs),igwr(mgs))
15433! interpolate along droplet radius
15434 ic = icwr(mgs)
15435 icp1 = min( 8, ic+1 )
15436 ir = irwr(mgs)
15437 irp1 = min( 6, ir+1 )
15438 cwrad = 0.5*xdia(mgs,lc,3)
15439 rwrad = 0.5*xdia(mgs,lr,3)
15440
15441 slope1 = (ew(icp1, ir ) - ew(ic,ir ))*cwr(ic,2)
15442 slope2 = (ew(icp1, irp1) - ew(ic,irp1))*cwr(ic,2)
15443
15444! write(iunit,*) 'slop1: ',slope1,slope2,ew(ic,ir),cwr(ic,2)
15445
15446 x1 = ew(ic, ir) + slope1*max(0.0, (cwrad - cwr(ic,1)) )
15447 x2 = ew(icp1,ir) + slope2*max(0.0, (cwrad - cwr(ic,1)) )
15448
15449 slope1 = (x2 - x1)*grad(ir,2)
15450
15451 erw(mgs) = max(0.0, x1 + slope1*max(0.0, (rwrad - grad(ir,1)) ))
15452
15453! write(iunit,*) 'erw: ',erw(mgs),1.e6*cwrad,1.e6*rwrad,ic,ir,x1,x2
15454! write(iunit,*)
15455
15456 erw(mgs) = max(0.0, erw(mgs) )
15457 IF ( rwrad .lt. 50.e-6 ) THEN
15458 erw(mgs) = 0.0
15459 ELSEIF ( rwrad .lt. 100.e-6 ) THEN ! linear change from zero at 50 to erw at 100 microns
15460 erw(mgs) = erw(mgs)*(rwrad - 50.e-6)/50.e-6
15461 ENDIF
15462
15463 ENDIF
15464 end if
15465 IF ( cx(mgs,lc) .le. 0.0 ) erw(mgs) = 0.0
15466!
15467 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,lr).gt.qxmin(lr) ) then
15468 err(mgs)=1.0
15469 end if
15470!
15471 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,ls).gt.qxmin(ls) ) then
15472 ers(mgs)=1.0
15473 end if
15474!
15475 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,li).gt.qxmin(li) ) then
15476! IF ( vtxbar(mgs,lr,1) .gt. vtxbar(mgs,li,1) .and.
15477! : xdia(mgs,lr,3) .gt. 200.e-6 .and. xdia(mgs,li,3) .gt. 100.e-6 ) THEN
15478 eri(mgs) = eri0
15479! cwrad = 0.5*xdia(mgs,li,3)
15480! eri(mgs) =
15481! > 1.0*min((aradcw + cwrad*(bradcw + cwrad*
15482! < (cradcw + cwrad*(dradcw)))), 1.0)
15483! ENDIF
15484! if ( xdia(mgs,li,1) .lt. 10.e-6 ) eri(mgs)=0.0
15485 if ( xdia(mgs,li,3) .lt. eri_cimin ) eri(mgs)=0.0
15486 end if
15487!
15488!
15489! Snow aggregates: Collection (cxc) efficiencies
15490!
15491! Modified by ERM with a linear function for small droplets and large
15492! snow agg. based numerical data from Wang and Ji (1992) in P&K 1997 (Fig. 14-13), which
15493! allows collection of very small droplets, albeit at low efficiency. But slow
15494! fall speeds of snow make up for the efficiency.
15495!
15496 esw(mgs) = 0.0
15497 if ( qx(mgs,ls).gt.qxmin(ls) .and. qx(mgs,lc).gt.qxmin(lc) ) then
15498 esw(mgs) = 0.5
15499 if ( xdia(mgs,lc,1) .gt. 15.e-6 .and. xdia(mgs,ls,1) .gt. 100.e-6) then
15500 esw(mgs) = 0.5
15501 ELSEIF ( xdia(mgs,ls,1) .ge. 500.e-6 ) THEN
15502 esw(mgs) = min(0.5, 0.05 + (0.8-0.05)/(40.e-6)*xdia(mgs,lc,1) )
15503 ENDIF
15504 end if
15505!
15506 if ( qx(mgs,ls).gt.qxmin(ls) .and. qx(mgs,lr).gt.qxmin(lr) &
15507 & .and. temg(mgs) .lt. tfr - 1. &
15508 & ) then
15509 esr(mgs)=exp(-(40.e-6)**3/xv(mgs,lr))*exp(-40.e-6/xdia(mgs,ls,1))
15510 IF ( qx(mgs,ls) < 1.e-4 .and. qx(mgs,lr) < 1.e-4 ) il2(mgs) = 1
15511 end if
15512
15513 IF ( ipconc < 3 .and. temg(mgs) < tfr .and. qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,lr) < 1.e-4 ) THEN
15514 il3(mgs) = 1
15515 ENDIF
15516!
15517! if ( qx(mgs,ls).gt.qxmin(ls) ) then
15518 if ( temcg(mgs) < 0.0 ) then
15519
15520 IF ( ipconc .lt. 4 .or. temcg(mgs) < esstem1 ) THEN
15521 ess(mgs) = 0.0
15522! ess(mgs)=0.1*exp(0.1*min(temcg(mgs),0.0))
15523! ess(mgs)=min(0.1,ess(mgs))
15524
15525 ELSE
15526
15527 fac = abs(ess0)
15528 IF ( iessopt == 2 ) THEN ! experimental code
15529! IF ( wvel(mgs) > 2.0 .or. wvel(mgs) < -0.5 .or. ssi(mgs) < 1.0 ) THEN
15530 IF ( wvel(mgs) > 2.0 ) THEN
15531 ! assume convective cell or downdraft
15532 fac = 0.0
15533 ELSEIF ( wvel(mgs) > 1.0 ) THEN ! transition to stratiform range of values
15534 fac = max(0.0, 2.0 - wvel(mgs))*fac
15535 ENDIF
15536 ELSEIF ( iessopt == 3 ) THEN ! factor based on ice supersat
15537 IF ( ssi(mgs) <= 1.0 ) THEN
15538 fac = 0.0
15539 ehsfac(mgs) = 0.0
15540 ELSEIF ( ssi(mgs) <= 1.02 ) THEN
15541 fac = fac*(ssi(mgs) - 1.0)/0.02
15542 ehsfac(mgs) = (ssi(mgs) - 1.0)/0.02
15543 ENDIF
15544 ELSEIF ( iessopt == 4 ) THEN ! factor based on ice supersat; very roughly based on Hosler et al. 1957 (J. Met.)
15545 IF ( ssi(mgs) <= 1.0 ) THEN
15546 fac = 0.1
15547 ehsfac(mgs) = 0.1
15548 ELSEIF ( ssi(mgs) <= 1.005 ) THEN
15549 fac = max(0.1, fac*(ssi(mgs) - 1.0)/0.005)
15550 ehsfac(mgs) = max(0.1, (ssi(mgs) - 1.0)/0.005)
15551 ENDIF
15552 ENDIF
15553
15554 IF ( temcg(mgs) > esstem1 .and. temcg(mgs) < esstem2 ) THEN ! only nonzero for T > esstem1
15555 ess(mgs) = fac*exp(ess1*(esstem2) )*(temcg(mgs) - esstem1)/(esstem2 - esstem1) ! linear ramp up from zero at esstem1 to value at esstem2
15556 ELSEIF ( temcg(mgs) >= esstem2 ) THEN
15557 ess(mgs) = fac*exp(ess1*min( temcg(mgs), 0.0 ) )
15558 ENDIF
15559
15560 ENDIF
15561 end if
15562!
15563 if ( qx(mgs,ls).gt.qxmin(ls) .and. qx(mgs,li).gt.qxmin(li) ) then
15564 esiclsn(mgs) = esi_collsn
15565! IF ( ipconc .lt. 4 ) THEN
15566 IF ( ipconc < 1 .and. lwsm6 ) THEN
15567 esi(mgs) = exp(0.7*min(temcg(mgs),0.0))
15568 ELSE
15569 esi(mgs) = esi0*exp(0.1*min(temcg(mgs),0.0))
15570 esi(mgs) = min(0.1,esi(mgs))
15571 ENDIF
15572 IF ( ipconc .le. 3 ) THEN
15573 esi(mgs) = exp(0.025*min(temcg(mgs),0.0)) ! LFO
15574! esi(mgs) = Min(0.5, exp(0.025*min(temcg(mgs),0.0)) ) ! LFO
15575! esi(mgs)=0.5*exp(0.1*min(temcg(mgs),0.0)) ! 10ice
15576 ENDIF
15577! ELSE ! zrnic/ziegler 1993
15578! esi(mgs)= 0.1 ! 0.5*exp(0.1*min(temcg(mgs),0.0))
15579! ENDIF
15580 if ( temg(mgs) .gt. 273.15 ) esi(mgs) = 0.0
15581 end if
15582!
15583!
15584!
15585!
15586! Graupel: Collection (cxc) efficiencies
15587!
15588!
15589 xmascw(mgs) = xmas(mgs,lc)
15590 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lc).gt.qxmin(lc) ) then !{
15591 ehw(mgs) = 1.0
15592 IF ( iehw .eq. 0 ) THEN
15593 ehw(mgs) = ehw0 ! default value is 1.0
15594 ELSEIF ( iehw .eq. 1 .or. iehw .eq. 10 ) THEN
15595 cwrad = 0.5*xdia(mgs,lc,1)
15596 ehw(mgs) = min( ehw0, &
15597 & ewfac*min((aradcw + cwrad*(bradcw + cwrad* &
15598 & (cradcw + cwrad*(dradcw)))), 1.0) )
15599
15600 ELSEIF ( iehw .eq. 2 .or. iehw .eq. 10 ) THEN
15601 ic = icwr(mgs)
15602 icp1 = min( 8, ic+1 )
15603 ir = igwr(mgs)
15604 irp1 = min( 6, ir+1 )
15605 cwrad = 0.5*xdia(mgs,lc,1)
15606 rwrad = 0.5*xdia(mgs,lh,3) ! changed to mean volume diameter
15607
15608 slope1 = (ew(icp1, ir ) - ew(ic,ir ))*cwr(ic,2)
15609 slope2 = (ew(icp1, irp1) - ew(ic,irp1))*cwr(ic,2)
15610
15611! write(iunit,*) 'slop1: ',slope1,slope2,ew(ic,ir),cwr(ic,2)
15612
15613 x1 = ew(ic, ir) + slope1*max(0.0, (cwrad - cwr(ic,1)) )
15614 x2 = ew(icp1,ir) + slope2*max(0.0, (cwrad - cwr(ic,1)) )
15615
15616 slope1 = (x2 - x1)*grad(ir,2)
15617
15618 tmp = max( 0.0, min( 1.0, x1 + slope1*max(0.0, (rwrad - grad(ir,1)) ) ) )
15619 ehw(mgs) = min( ehw(mgs), tmp )
15620
15621! write(iunit,*) 'ehw: ',ehw(mgs),1.e6*cwrad,1.e6*rwrad,ic,ir,x1,x2
15622! write(iunit,*)
15623
15624! ehw(mgs) = Max( 0.2, ehw(mgs) )
15625! assume that ehw = 1 for zero air resistance (rho0 = 0.0) and extrapolate toward that
15626! ehw(mgs) = ehw(mgs) + (ehw(mgs) - 1.0)*(rho0(mgs) - rho00)/rho00
15627! ehw(mgs) = ehw(mgs) + (1.0 - ehw(mgs))*((Max(0.0,rho00 - rho0(mgs)))/rho00)**2
15628
15629 ELSEIF ( iehw .eq. 3 .or. iehw .eq. 10 ) THEN ! use fraction of droplets greater than dmincw diameter
15630 tmp = exp(- (dmincw/xdia(mgs,lc,1))**3)
15631 xmascw(mgs) = xmas(mgs,lc) + xdn0(lc)*(pi*dmincw**3/6.0) ! this is the average mass of the droplets with d > dmincw
15632 ehw(mgs) = min( ehw(mgs), tmp )
15633 ELSEIF ( iehw .eq. 4 .or. iehw .eq. 10 ) THEN ! Cober and List 1993, eq. 19-20
15634 tmp = &
15635 & 2.0*xdn(mgs,lc)*vtxbar(mgs,lh,1)*(0.5*xdia(mgs,lc,1))**2 &
15636 & /(9.0*fadvisc(mgs)*0.5*xdia(mgs,lh,3))
15637 tmp = max( 1.5, min(10.0, tmp) )
15638 ehw(mgs) = min( ehw(mgs), 0.55*log10(2.51*tmp) )
15639 ENDIF
15640 if ( xdia(mgs,lc,1) .lt. 2.4e-06 ) ehw(mgs)=0.0
15641
15642 ehw(mgs) = min( ehw0, ehw(mgs) )
15643
15644 IF ( ibfc == -1 .and. temcg(mgs) < -41.0 ) THEN
15645 ehw(mgs) = 0.0
15646 ENDIF
15647
15648 end if !}
15649!
15650 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lr).gt.qxmin(lr) &
15651! & .and. temg(mgs) .lt. tfr &
15652 & ) then
15653! ehr(mgs) = Exp(-(40.e-6)**3/xv(mgs,lr))*Exp(-40.e-6/xdia(mgs,lh,1))
15654! ehr(mgs) = 1.0
15655 ehr(mgs) = exp(-(40.e-6)/xdia(mgs,lr,3))*exp(-40.e-6/xdia(mgs,lh,3))
15656 ehr(mgs) = min( ehr0, ehr(mgs) )
15657 end if
15658!
15659 IF ( qx(mgs,ls).gt.qxmin(ls) ) THEN
15660 IF ( ipconc .ge. 4 ) THEN
15661 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
15662 ELSE
15663 ehscnv(mgs) = exp(0.09*min(temcg(mgs),0.0))
15664 ENDIF
15665
15666 IF ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lc) >= qxmin(lc) ) THEN
15667! ehsclsn(mgs) = ehs_collsn
15668! ehs(mgs) = ehscnv(mgs)*ehsfac(mgs)*Min(1.0, Max(0.0,xdn(mgs,lh) - 300.)/300. )
15669! ELSEIF ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lc) >= qxmin(lc) ) then
15670 ehsclsn(mgs) = ehs_collsn
15671 IF ( xdia(mgs,ls,3) < 40.e-6 ) THEN
15672 ehsclsn(mgs) = 0.0
15673 ELSEIF ( xdia(mgs,ls,3) < 150.e-6 ) THEN
15674 ehsclsn(mgs) = ehs_collsn*(xdia(mgs,ls,3) - 40.e-6)/(150.e-6 - 40.e-6)
15675 ELSE
15676 ehsclsn(mgs) = ehs_collsn
15677 ENDIF
15678! 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
15679 ehs(mgs) = ehscnv(mgs)*min(1.0, max(0.0,xdn(mgs,lh) - 300.)/300. ) ! shut off qhacs as graupel goes to low density; limits scavenging of snow in bright band
15680! ehs(mgs) = ehscnv(mgs) ! *Min(1.0, Max(0.0,xdn(mgs,lh) - 300.)/300. ) ! shut off qhacs as graupel goes to low density
15681 ehs(mgs) = min(ehs(mgs),ehsmax)
15682 end if
15683 ENDIF
15684!
15685 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,li).gt.qxmin(li) ) then
15686 ehiclsn(mgs) = ehi_collsn
15687 ehi(mgs)=eii0*exp(eii1*min(temcg(mgs),0.0))
15688 ehi(mgs) = min( ehimax, max( ehi(mgs), ehimin ) )
15689! if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehi(mgs) = 0.0
15690 end if
15691
15692 IF ( lis > 1 ) THEN
15693 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lis).gt.qxmin(lis) ) then
15694 ehisclsn(mgs) = ehi_collsn
15695 ehis(mgs)=eii0*exp(eii1*min(temcg(mgs),0.0))
15696 ehis(mgs) = min( ehimax, max( ehis(mgs), ehimin ) )
15697! if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehis(mgs) = 0.0
15698 end if
15699 ENDIF
15700
15701
15702!
15703!
15704! Hail: Collection (cxc) efficiencies
15705!
15706!
15707 IF ( lhl .gt. 1 ) THEN
15708
15709 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,lc).gt.qxmin(lc) ) then
15710 IF ( iehw == 3 ) iehlw = 3
15711 IF ( iehw == 4 ) iehlw = 4
15712 ehlw(mgs) = ehlw0
15713 IF ( iehlw .eq. 0 ) THEN
15714 ehlw(mgs) = ehlw0 ! default value is 1.0
15715 ELSEIF ( iehlw .eq. 1 .or. iehlw .eq. 10 ) THEN
15716 cwrad = 0.5*xdia(mgs,lc,1)
15717 ehlw(mgs) = min( ehlw0, &
15718 & ewfac*min((aradcw + cwrad*(bradcw + cwrad* &
15719 & (cradcw + cwrad*(dradcw)))), 1.0) )
15720
15721 ELSEIF ( iehlw .eq. 2 .or. iehlw .eq. 10 ) THEN
15722 ic = icwr(mgs)
15723 icp1 = min( 8, ic+1 )
15724 ir = ihlr(mgs)
15725 irp1 = min( 6, ir+1 )
15726 cwrad = 0.5*xdia(mgs,lc,1)
15727 rwrad = 0.5*xdia(mgs,lhl,3) ! changed to mean volume diameter
15728
15729 slope1 = (ew(icp1, ir ) - ew(ic,ir ))*cwr(ic,2)
15730 slope2 = (ew(icp1, irp1) - ew(ic,irp1))*cwr(ic,2)
15731
15732 x1 = ew(ic, ir) + slope1*(cwrad - cwr(ic,1))
15733 x2 = ew(icp1,ir) + slope2*(cwrad - cwr(ic,1))
15734
15735 slope1 = (x2 - x1)*grad(ir,2)
15736
15737 tmp = max( 0.0, min( 1.0, x1 + slope1*(rwrad - grad(ir,1)) ) )
15738 ehlw(mgs) = min( ehlw(mgs), tmp )
15739 ehlw(mgs) = min( ehlw0, ehlw(mgs) )
15740! ehw(mgs) = Max( 0.2, ehw(mgs) )
15741! assume that ehw = 1 for zero air resistance (rho0 = 0.0) and extrapolate toward that
15742! ehw(mgs) = ehw(mgs) + (ehw(mgs) - 1.0)*(rho0(mgs) - rho00)/rho00
15743! ehlw(mgs) = ehlw(mgs) + (1.0 - ehlw(mgs))*((Max(0.0,rho00 - rho0(mgs)))/rho00)**2
15744
15745 ELSEIF ( iehlw .eq. 3 .or. iehlw .eq. 10 ) THEN ! use fraction of droplets greater than 15 micron diameter
15746 tmp = exp(- (dmincw/xdia(mgs,lc,1))**3)
15747 ehlw(mgs) = min( ehlw(mgs), tmp )
15748 ELSEIF ( iehlw .eq. 4 .or. iehlw .eq. 10 ) THEN ! Cober and List 1993
15749 tmp = &
15750 & 2.0*xdn(mgs,lc)*vtxbar(mgs,lhl,1)*(0.5*xdia(mgs,lc,1))**2 &
15751 & /(9.0*fadvisc(mgs)*0.5*xdia(mgs,lhl,3))
15752 tmp = max( 1.5, min(10.0, tmp) )
15753 ehlw(mgs) = min( ehlw(mgs), 0.55*log10(2.51*tmp) )
15754 ENDIF
15755 if ( xdia(mgs,lc,1) .lt. 2.4e-06 ) ehlw(mgs)=0.0
15756 ehlw(mgs) = min( ehlw0, ehlw(mgs) )
15757
15758 IF ( ibfc == -1 .and. temcg(mgs) < -41.0 ) THEN
15759 ehlw(mgs) = 0.0
15760 ENDIF
15761
15762 end if
15763!
15764 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,lr).gt.qxmin(lr) &
15765! & .and. temg(mgs) .lt. tfr &
15766 & ) then
15767 ehlr(mgs) = 1.0
15768 ehlr(mgs) = min( ehlr0, ehlr(mgs) )
15769 end if
15770!
15771 IF ( qx(mgs,ls).gt.qxmin(ls) ) THEN
15772 if ( qx(mgs,lhl).gt.qxmin(lhl) ) then
15773 ehlsclsn(mgs) = ehls_collsn
15774 ehls(mgs) = ehscnv(mgs)
15775 ehls(mgs) = min(ehls(mgs),ehsmax)
15776 end if
15777 ENDIF
15778!
15779 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,li).gt.qxmin(li) ) then
15780 ehliclsn(mgs) = ehli_collsn
15781 ehli(mgs)=eii0hl*exp(eii1hl*min(temcg(mgs),0.0))
15782 ehli(mgs) = min( ehimax, max( ehli(mgs), ehimin ) )
15783 if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehli(mgs) = 0.0
15784 end if
15785
15786 IF ( lis > 1 ) THEN
15787 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,lis).gt.qxmin(lis) ) then
15788 ehlisclsn(mgs) = ehli_collsn
15789 ehlis(mgs)=eii0*exp(eii1*min(temcg(mgs),0.0))
15790 ehlis(mgs) = min( ehimax, max( ehlis(mgs), ehimin ) )
15791 if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehlis(mgs) = 0.0
15792 end if
15793 ENDIF
15794
15795
15796 ENDIF ! lhl .gt. 1
15797
15798 ENDDO ! mgs loop for collection efficiencies
15799
15800!
15801!
15802!
15803! Set flags for plates vs. columns
15804!
15805!
15806 do mgs = 1,ngscnt
15807!
15808 xplate(mgs) = 0.0
15809 xcolmn(mgs) = 1.0
15810!
15811! if ( temcg(mgs) .lt. 0. .and. temcg(mgs) .ge. -4. ) then
15812! xplate(mgs) = 1.0
15813! xcolmn(mgs) = 0.0
15814! end if
15815!c
15816! if ( temcg(mgs) .lt. -4. .and. temcg(mgs) .ge. -9. ) then
15817! xplate(mgs) = 0.0
15818! xcolmn(mgs) = 1.0
15819! end if
15820!c
15821! if ( temcg(mgs) .lt. -9. .and. temcg(mgs) .ge. -22.5 ) then
15822! xplate(mgs) = 1.0
15823! xcolmn(mgs) = 0.0
15824! end if
15825!c
15826! if ( temcg(mgs) .lt. -22.5 .and. temcg(mgs) .ge. -90. ) then
15827! xplate(mgs) = 0.0
15828! xcolmn(mgs) = 1.0
15829! end if
15830!
15831 end do
15832
15833
15834
15835!
15836!
15837!
15838! Collection growth equations....
15839!
15840!
15841 if (ndebug .gt. 0 ) write(0,*) 'Collection: rain collects xxxxx'
15842!
15843 do mgs = 1,ngscnt
15844 qracw(mgs) = 0.0
15845 IF ( qx(mgs,lr) .gt. qxmin(lr) .and. erw(mgs) .gt. 0.0 ) THEN
15846 IF ( ipconc .lt. 3 ) THEN
15847 IF ( erw(mgs) .gt. 0.0 .and. qx(mgs,lr) .gt. 1.e-7 ) THEN
15848 vt = (ar*(xdia(mgs,lc,1)**br))*rhovt(mgs)
15849 qracw(mgs) = &
15850 & (0.25)*pi*erw(mgs)*(qx(mgs,lc)-qcwresv(mgs))*cx(mgs,lr) &
15851! > *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,lc,1)) &
15852 & *max(0.0, vtxbar(mgs,lr,1)-vt) &
15853 & *( gf3*xdia(mgs,lr,2) &
15854 & + 2.0*gf2*xdia(mgs,lr,1)*xdia(mgs,lc,1) &
15855 & + gf1*xdia(mgs,lc,2) )
15856! qracw(mgs) = 0.0
15857! write(iunit,*) 'qracw,cx =',qracw(mgs),1.e6*xdia(mgs,lr,1),erw(mgs)
15858! 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
15859! write(iunit,*) 'vtr: ',vtxbar(mgs,lr,1), ar*gf4br/6.0*xdia(mgs,lr,1)**br, rhovt(mgs),
15860! : ar*gf4br/6.0*xdia(mgs,lr,1)**br * rhovt(mgs)
15861 ENDIF
15862 ELSE
15863
15864 IF ( dmrauto <= 0 .or. rho0(mgs)*qx(mgs,lr) > 1.2*xl2p(mgs) ) THEN
15865 rwrad = 0.5*xdia(mgs,lr,3)
15866 IF ( rwrad .gt. rh(mgs) ) THEN ! .or. cx(mgs,lr) .gt. nh(mgs) ) THEN
15867 IF ( rwrad .gt. rwradmn ) THEN
15868! DM1CCC=A2*XNC*XNR*XVC*(((CNU+2.)/(CNU+1.))*XVC+XVR) ! (A12)
15869! NOTE: Result is independent of imurain, assumes mucloud = 3
15870 qracw(mgs) = erw(mgs)*aa2*cx(mgs,lr)*cx(mgs,lc)*xmas(mgs,lc)* &
15871 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)/(alpha(mgs,lc) + 1.) + xv(mgs,lr))/rho0(mgs) !*rhoinv(mgs)
15872 ELSE
15873
15874 IF ( imurain == 3 ) THEN
15875
15876! DM1CCC=A1*XNC*XNR*(((CNU+3.)*(CNU+2.)/(CNU+1.)**2)*XVC**3+ ! (A14)
15877! 1 ((RNU+2.)/(RNU+1.))*XVC*XVR**2)
15878
15879! qracw(mgs) = aa1*cx(mgs,lr)*cx(mgs,lc)*xdn(mgs,lc)* &
15880! & ((cnu + 3.)*(cnu + 2.)*xv(mgs,lc)**3/(cnu + 1.)**2 + &
15881! & (alpha(mgs,lr) + 2.)*xv(mgs,lc)*xv(mgs,lr)**2/(alpha(mgs,lr) + 1.))/rho0(mgs) !*rhoinv(mgs)
15882! save multiplies by converting cx*xdn*xv/rho0 to qx
15883 qracw(mgs) = aa1*cx(mgs,lr)*(qx(mgs,lc)-qcwresv(mgs))* &
15884 & ((alpha(mgs,lc) + 3.)*(alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.)**2 + &
15885 & (alpha(mgs,lr) + 2.)*xv(mgs,lr)**2/(alpha(mgs,lr) + 1.))
15886
15887 ELSE ! imurain == 1
15888
15889 qracw(mgs) = aa1*cx(mgs,lr)*(qx(mgs,lc)-qcwresv(mgs))* &
15890 & ((alpha(mgs,lc) + 3.)*(alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.)**2 + &
15891 & (alpha(mgs,lr) + 6.)*(alpha(mgs,lr) + 5.)*(alpha(mgs,lr) + 4.)*xv(mgs,lr)**2/ &
15892 & ((alpha(mgs,lr) + 3.)*(alpha(mgs,lr) + 2.)*(alpha(mgs,lr) + 1.)))
15893
15894 ENDIF
15895
15896 ENDIF
15897 ENDIF
15898 ENDIF
15899 ENDIF
15900! qracw(mgs) = Min(qracw(mgs), qx(mgs,lc))
15901 qracw(mgs) = min(qracw(mgs), qcmxd(mgs))
15902 ENDIF
15903 end do
15904!
15905 do mgs = 1,ngscnt
15906 qraci(mgs) = 0.0
15907 craci(mgs) = 0.0
15908 qracs(mgs) = 0.0
15909 IF ( eri(mgs) .gt. 0.0 .and. iacr .ge. 1 .and. xdia(mgs,lr,3) .gt. 2.*rwradmn ) THEN
15910 IF ( ipconc .ge. 3 ) THEN
15911
15912 tmp = eri(mgs)*aa2*cx(mgs,lr)*cx(mgs,li)* &
15913 & ((cinu + 2.)*xv(mgs,li)/(cinu + 1.) + xv(mgs,lr))
15914
15915 qraci(mgs) = min( qxmxd(mgs,li), tmp*xmas(mgs,li)*rhoinv(mgs) )
15916 craci(mgs) = min( cxmxd(mgs,li), tmp )
15917
15918! vt = Sqrt((vtxbar(mgs,lr,1)-vtxbar(mgs,li,1))**2 +
15919! : 0.04*vtxbar(mgs,lr,1)*vtxbar(mgs,li,1) )
15920!
15921! qraci(mgs) = 0.25*pi*eri(mgs)*cx(mgs,lr)*qx(mgs,li)*vt*
15922! : ( da0(lr)*xdia(mgs,lr,3)**2 +
15923! : dab1(lr,li)*xdia(mgs,lr,3)*xdia(mgs,li,3) +
15924! : da1(li)*xdia(mgs,li,3)**2 )
15925!
15926!
15927! vt = Sqrt((vtxbar(mgs,lr,1)-vtxbar(mgs,li,1))**2 +
15928! : 0.04*vtxbar(mgs,lr,1)*vtxbar(mgs,li,1) )
15929!
15930! craci(mgs) = 0.25*pi*eri(mgs)*cx(mgs,lr)*cx(mgs,li)*vt*
15931! : ( da0(lr)*xdia(mgs,lr,3)**2 +
15932! : dab0(lr,li)*xdia(mgs,lr,3)*xdia(mgs,li,3) +
15933! : da0(li)*xdia(mgs,li,3)**2 )
15934!
15935! qraci(mgs) = Min( qraci(mgs), qxmxd(mgs,li) )
15936! craci(mgs) = Min( craci(mgs), cxmxd(mgs,li) )
15937
15938 ELSE
15939 qraci(mgs) = &
15940 & min( &
15941 & (0.25)*pi*eri(mgs)*qx(mgs,li)*cx(mgs,lr) &
15942 & *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,li,1)) &
15943 & *( gf3*xdia(mgs,lr,2) &
15944 & + 2.0*gf2*xdia(mgs,lr,1)*xdia(mgs,li,1) &
15945 & + gf1*xdia(mgs,li,2) ) &
15946 & , qimxd(mgs))
15947 ENDIF
15948 if ( temg(mgs) .gt. 268.15 ) then
15949 qraci(mgs) = 0.0
15950 end if
15951 ENDIF
15952 end do
15953!
15954 IF ( ipconc < 3 ) THEN
15955 do mgs = 1,ngscnt
15956 qracs(mgs) = 0.0
15957 IF ( ers(mgs) .gt. 0.0 .and. ipconc < 3 ) THEN
15958 IF ( lwsm6 .and. ipconc == 0 ) THEN
15959 vt = vt2ave(mgs)
15960 ELSE
15961 vt = vtxbar(mgs,ls,1)
15962 ENDIF
15963 qracs(mgs) = &
15964 & min( &
15965 & ((0.25)*pi/gf4)*ers(mgs)*qx(mgs,ls)*cx(mgs,lr) &
15966 & *abs(vtxbar(mgs,lr,1)-vt) &
15967 & *( gf6*gf1*xdia(mgs,ls,2) &
15968 & + 2.0*gf5*gf2*xdia(mgs,ls,1)*xdia(mgs,lr,1) &
15969 & + gf4*gf3*xdia(mgs,lr,2) ) &
15970 & , qsmxd(mgs))
15971 ENDIF
15972 end do
15973 ENDIF
15974
15975!
15976!
15977 if (ndebug .gt. 0 ) write(0,*) 'Collection: snow collects xxxxx'
15978!
15979 do mgs = 1,ngscnt
15980 qsacw(mgs) = 0.0
15981 csacw(mgs) = 0.0
15982 vsacw(mgs) = 0.0
15983 IF ( esw(mgs) .gt. 0.0 ) THEN
15984
15985 IF ( ipconc .ge. 4 ) THEN
15986! QSACC=CECS*RVT*A2*XNC*XNS*XVC*ROS*
15987! * (((CNU+2.)/(CNU+1.))*XVC+XVS)/RO
15988
15989! tmp = esw(mgs)*rvt*aa2*cx(mgs,ls)*cx(mgs,lc)*
15990! : ((cnu + 2.)*xv(mgs,lc)/(cnu + 1.) + xv(mgs,ls))
15991 tmp = 1.0*rvt*aa2*cx(mgs,ls)*cx(mgs,lc)* &
15992 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)/(alpha(mgs,lc) + 1.) + xv(mgs,ls))
15993
15994 qsacw(mgs) = min( qxmxd(mgs,lc), tmp*xmas(mgs,lc)*rhoinv(mgs) )
15995 csacw(mgs) = min( cxmxd(mgs,lc), tmp )
15996
15997 IF ( lvol(ls) .gt. 1 ) THEN
15998 IF ( temg(mgs) .lt. 273.15) THEN
15999 rimdn(mgs,ls) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16000 & *((0.60)*vtxbar(mgs,ls,1)) &
16001 & /(temg(mgs)-273.15))**(rimc2)
16002 rimdn(mgs,ls) = min( max( rimc3, rimdn(mgs,ls) ), rimc4 )
16003 ELSE
16004 rimdn(mgs,ls) = 1000.
16005 ENDIF
16006
16007 vsacw(mgs) = rho0(mgs)*qsacw(mgs)/rimdn(mgs,ls)
16008
16009 ENDIF
16010
16011
16012! qsacw(mgs) = cecs*aa2*cx(mgs,ls)*cx(mgs,lc)*xmas(mgs,lc)*
16013! : ((alpha(mgs,lc) + 2.)*xv(mgs,lc)/(alpha(mgs,lc) + 1.) + xv(mgs,ls))*rhoinv(mgs)
16014 ELSE
16015! qsacw(mgs) =
16016! > min(
16017! > ((0.25)*pi)*esw(mgs)*qx(mgs,lc)*cx(mgs,ls)
16018! > *abs(vtxbar(mgs,ls,1)-vtxbar(mgs,lc,1))
16019! > *( gf3*xdia(mgs,ls,2)
16020! > + 2.0*gf2*xdia(mgs,ls,1)*xdia(mgs,lc,1)
16021! > + gf1*xdia(mgs,lc,2) )
16022! < , qcmxd(mgs))
16023
16024 vt = abs(vtxbar(mgs,ls,1)-vtxbar(mgs,lc,1))
16025
16026 qsacw(mgs) = 0.25*pi*esw(mgs)*cx(mgs,ls)*qx(mgs,lc)*vt* &
16027 & ( da0(ls)*xdia(mgs,ls,3)**2 + &
16028 & dab1(ls,lc)*xdia(mgs,ls,3)*xdia(mgs,lc,3) + &
16029 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
16030 qsacw(mgs) = min( qsacw(mgs), qxmxd(mgs,ls) )
16031 csacw(mgs) = rho0(mgs)*qsacw(mgs)/xmas(mgs,lc)
16032 ENDIF
16033 ENDIF
16034 end do
16035!
16036!
16037 do mgs = 1,ngscnt
16038 qsaci(mgs) = 0.0
16039 csaci(mgs) = 0.0
16040 csaci0(mgs) = 0.0
16041 IF ( ipconc .ge. 4 ) THEN
16042 IF ( esi(mgs) .gt. 0.0 .or. ( ipelec > 0 .and. esiclsn(mgs) > 0.0 )) THEN
16043! QSCOI=CEXS*RVT*A2*XNCI*XNS*XVCI*ROS*
16044! * (((CINU+2.)/(CINU+1.))*VCIP+XVS)/RO
16045
16046 tmp = esiclsn(mgs)*rvt*aa2*cx(mgs,ls)*cx(mgs,li)* &
16047 & ((cinu + 2.)*xv(mgs,li)/(cinu + 1.) + xv(mgs,ls))
16048
16049 qsaci(mgs) = min( qxmxd(mgs,li), esi(mgs)*tmp*xmas(mgs,li)*rhoinv(mgs) )
16050 csaci0(mgs) = tmp
16051 csaci(mgs) = min(cxmxd(mgs,li), esi(mgs)*tmp )
16052
16053! qsaci(mgs) =
16054! > min(
16055! > ((0.25)*pi)*esi(mgs)*qx(mgs,li)*cx(mgs,ls)
16056! > *abs(vtxbar(mgs,ls,1)-vtxbar(mgs,li,1))
16057! > *( gf3*xdia(mgs,ls,2)
16058! > + 2.0*gf2*xdia(mgs,ls,1)*xdia(mgs,li,1)
16059! > + gf1*xdia(mgs,li,2) )
16060! < , qimxd(mgs))
16061 ENDIF
16062 ELSE !
16063 IF ( esi(mgs) .gt. 0.0 ) THEN
16064 qsaci(mgs) = &
16065 & min( &
16066 & ((0.25)*pi)*esi(mgs)*qx(mgs,li)*cx(mgs,ls) &
16067 & *abs(vtxbar(mgs,ls,1)-vtxbar(mgs,li,1)) &
16068 & *( gf3*xdia(mgs,ls,2) &
16069 & + 2.0*gf2*xdia(mgs,ls,1)*xdia(mgs,li,1) &
16070 & + gf1*xdia(mgs,li,2) ) &
16071 & , qimxd(mgs))
16072 ENDIF
16073 ENDIF
16074 end do
16075!
16076!
16077!
16078 do mgs = 1,ngscnt
16079 qsacr(mgs) = 0.0
16080 qsacrs(mgs) = 0.0
16081 csacr(mgs) = 0.0
16082 IF ( esr(mgs) .gt. 0.0 ) THEN
16083 IF ( ipconc .ge. 3 ) THEN
16084! vt = Sqrt((vtxbar(mgs,ls,1)-vtxbar(mgs,lr,1))**2 +
16085! : 0.04*vtxbar(mgs,ls,1)*vtxbar(mgs,lr,1) )
16086! qsacr(mgs) = esr(mgs)*cx(mgs,ls)*vt*
16087! : qx(mgs,lr)*0.25*pi*
16088! : (3.02787*xdia(mgs,lr,2) +
16089! : 3.30669*xdia(mgs,ls,1)*xdia(mgs,lr,1) +
16090! : 2.*xdia(mgs,ls,2))
16091! qsacr(mgs) = Min( qsacr(mgs), qrmxd(mgs) )
16092! csacr(mgs) = qsacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
16093! csacr(mgs) = min(csacr(mgs),crmxd(mgs))
16094 ELSE
16095 IF ( lwsm6 .and. ipconc == 0 ) THEN
16096 vt = vt2ave(mgs)
16097 ELSE
16098 vt = vtxbar(mgs,ls,1)
16099 ENDIF
16100
16101 qsacr(mgs) = &
16102 & min( &
16103 & ((0.25)*pi/gf4)*esr(mgs)*qx(mgs,lr)*cx(mgs,ls) &
16104 & *abs(vtxbar(mgs,lr,1)-vt) &
16105 & *( gf6*gf1*xdia(mgs,lr,2) &
16106 & + 2.0*gf5*gf2*xdia(mgs,lr,1)*xdia(mgs,ls,1) &
16107 & + gf4*gf3*xdia(mgs,ls,2) ) &
16108 & , qrmxd(mgs))
16109 ENDIF
16110 ENDIF
16111 end do
16112!
16113!
16114!
16115
16116 if (ndebug .gt. 0 ) write(0,*) 'Collection: graupel collects xxxxx'
16117!
16118 do mgs = 1,ngscnt
16119 qhacw(mgs) = 0.0
16120 qhacwmlr(mgs) = 0.0
16121 rarx(mgs,lh) = 0.0
16122 vhacw(mgs) = 0.0
16123 vhsoak(mgs) = 0.0
16124 zhacw(mgs) = 0.0
16125
16126 IF ( .false. ) THEN
16127 vtmax = (gz(igs(mgs),jgs,kgs(mgs))*dtpinv)
16128 vtxbar(mgs,lh,1) = min( vtmax, vtxbar(mgs,lh,1))
16129 vtxbar(mgs,lh,2) = min( vtmax, vtxbar(mgs,lh,2))
16130 vtxbar(mgs,lh,3) = min( vtmax, vtxbar(mgs,lh,3))
16131 ENDIF
16132 IF ( ehw(mgs) .gt. 0.0 ) THEN
16133
16134 IF ( ipconc .ge. 2 ) THEN
16135
16136 IF ( .false. ) THEN
16137 qhacw(mgs) = (ehw(mgs)*(qx(mgs,lc)-qcwresv(mgs))*cx(mgs,lh)*pi* &
16138 & abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1))* &
16139 & (2.0*xdia(mgs,lh,1)*(xdia(mgs,lh,1) + &
16140 & xdia(mgs,lc,1)*gf73rds) + &
16141 & xdia(mgs,lc,2)*gf83rds))/4.
16142
16143 ELSE ! using Seifert coefficients
16144 vt = abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1))
16145
16146 qhacw(mgs) = 0.25*pi*ehw(mgs)*cx(mgs,lh)*(qx(mgs,lc)-qcwresv(mgs))*vt* &
16147 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16148 & dab1lh(mgs,lh,lc)*xdia(mgs,lh,3)*xdia(mgs,lc,3) + &
16149 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
16150
16151 ENDIF
16152 qhacw(mgs) = min( qhacw(mgs), 0.5*qx(mgs,lc)*dtpinv )
16153
16154 IF ( lzh .gt. 1 ) THEN
16155 tmp = qx(mgs,lh)/cx(mgs,lh)
16156
16157!! g1 = (6.0 + alpha(mgs,lh))*(5.0 + alpha(mgs,lh))*(4.0 + alpha(mgs,lh))/
16158!! : ((3.0 + alpha(mgs,lh))*(2.0 + alpha(mgs,lh))*(1.0 + alpha(mgs,lh)))
16159! alp = Max( 1.0, alpha(mgs,lh)+1. )
16160! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/
16161! : ((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
16162! zhacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacw(mgs) )
16163 ENDIF
16164
16165 ELSE
16166 qhacw(mgs) = &
16167 & min( &
16168 & ((0.25)*pi)*ehw(mgs)*(qx(mgs,lc)-qcwresv(mgs))*cx(mgs,lh) &
16169 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1)) &
16170 & *( gf3*xdia(mgs,lh,2) &
16171 & + 2.0*gf2*xdia(mgs,lh,1)*xdia(mgs,lc,1) &
16172 & + gf1*xdia(mgs,lc,2) ) &
16173 & , 0.5*(qx(mgs,lc)-qcwresv(mgs))*dtpinv)
16174! < , qxmxd(mgs,lc))
16175! < , qcmxd(mgs))
16176
16177
16178 IF ( lwsm6 .and. qsacw(mgs) > 0.0 .and. qhacw(mgs) > 0.0) THEN
16179 qaacw = ( qx(mgs,ls)*qsacw(mgs) + qx(mgs,lh)*qhacw(mgs) )/(qx(mgs,ls) + qx(mgs,lh))
16180! qaacw = Min( qaacw, 0.5*(qsacw(mgs) + qhacw(mgs) ) )
16181 qsacw(mgs) = qaacw
16182 qhacw(mgs) = qaacw
16183 ENDIF
16184
16185 ENDIF
16186
16187 qhacwmlr(mgs) = qhacw(mgs)
16188 IF ( temg(mgs) > tfr .and. iqhacwshr == 0 ) THEN
16189 qhacw(mgs) = 0.0
16190 ENDIF
16191
16192 IF ( lvol(lh) .gt. 1 .or. lhl .gt. 1 ) THEN ! calculate rime density for graupel volume and/or for graupel conversion to hail
16193
16194 IF ( temg(mgs) .lt. 273.15) THEN
16195 IF ( irimdenopt == 1 ) THEN ! Heymsfield and Pflaum (1985)
16196 vt = ( (1.0-rimdenvwgt)*vtxbar(mgs,lh,1) + rimdenvwgt*vtxbar(mgs,lh,2) )
16197
16198 rimdn(mgs,lh) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16199 & *((0.60)*vt ) &
16200 & /(temg(mgs)-273.15))**(rimc2)
16201! rimdn(mgs,lh) = Min( Max( hdnmn, rimc3, rimdn(mgs,lh) ), rimc4 )
16202 rimdn(mgs,lh) = min( max( rimc3, rimdn(mgs,lh) ), rimc4 )
16203
16204! IF ( igs(mgs) == 30 ) THEN
16205! 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)
16206! write(0,*) 'diam: char, mean, maxmass = ',xdia(mgs,lh,1),xdia(mgs,lh,3),(alpha(mgs,lh)+3.)*xdia(mgs,lh,1)
16207! write(0,*) 'ax,bx,cd,xdn = ',axx(mgs,lh),bxx(mgs,lh),cdxgs(mgs,lh),xdn(mgs,lh)
16208! 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)
16209! write(0,*) 'rimdn,alpha = ',rimdn(mgs,lh),alpha(mgs,lh)
16210! ENDIF
16211
16212 ELSEIF ( irimdenopt == 2 ) THEN ! Cober and List (1993)
16213
16214 tmp = (-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16215 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lh,1) + rimdenvwgt*vtxbar(mgs,lh,2) ) &
16216 & /(temg(mgs)-273.15))
16217 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
16218
16219 rimdn(mgs,lh) = 1000.*(0.051 + 0.114*tmp - 0.0055*tmp**2)
16220
16221 ELSEIF ( irimdenopt == 3 .or. irimdenopt == 4) THEN ! Macklin (3) or Saunders and Hosseini 2001
16222
16223 tmp = (-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16224 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lh,1) + rimdenvwgt*vtxbar(mgs,lh,2) ) &
16225 & /(temg(mgs)-273.15))
16226 ! tmp = Min( 5.5/0.6, Max( 0.3/0.6, tmp ) )
16227
16228 IF ( irimdenopt == 3 ) THEN
16229 rimdn(mgs,lh) = min(900., max( 170., 110.*tmp**0.76 ) )
16230 ELSEIF ( irimdenopt == 4 ) THEN ! Saunders and Hosseini
16231 rimdn(mgs,lh) = min(917., max( 10., 900.0*(1.0 - 0.905**tmp ) ) )
16232 ENDIF
16233
16234 ENDIF
16235 ELSE
16236 rimdn(mgs,lh) = 1000.
16237 ENDIF
16238
16239 IF ( lvol(lh) > 1 ) vhacw(mgs) = rho0(mgs)*qhacw(mgs)/rimdn(mgs,lh)
16240
16241 ENDIF
16242
16243 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. ipelec .ge. 1 ) THEN
16244 rarx(mgs,lh) = &
16245 & qhacw(mgs)*1.0e3*rho0(mgs)/((pi/2.0)*xdia(mgs,lh,2)*cx(mgs,lh))
16246 ENDIF
16247
16248 ENDIF
16249 end do
16250!
16251!
16252 do mgs = 1,ngscnt
16253 qhaci(mgs) = 0.0
16254 qhaci0(mgs) = 0.0
16255 IF ( ehi(mgs) .gt. 0.0 ) THEN
16256 IF ( ipconc .ge. 5 ) THEN
16257
16258 vt = sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,li,1))**2 + &
16259 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,li,1) )
16260
16261 qhaci0(mgs) = 0.25*pi*ehiclsn(mgs)*cx(mgs,lh)*qx(mgs,li)*vt* &
16262 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16263 & dab1lh(mgs,lh,li)*xdia(mgs,lh,3)*xdia(mgs,li,3) + &
16264 & da1(li)*xdia(mgs,li,3)**2 )
16265 qhaci(mgs) = min( ehi(mgs)*qhaci0(mgs), qimxd(mgs) )
16266 ELSE
16267 qhaci(mgs) = &
16268 & min( &
16269 & ((0.25)*pi)*ehi(mgs)*ehiclsn(mgs)*qx(mgs,li)*cx(mgs,lh) &
16270 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,li,1)) &
16271 & *( gf3*xdia(mgs,lh,2) &
16272 & + 2.0*gf2*xdia(mgs,lh,1)*xdia(mgs,li,1) &
16273 & + gf1*xdia(mgs,li,2) ) &
16274 & , qimxd(mgs))
16275 ENDIF
16276 ENDIF
16277 end do
16278
16279
16280 IF ( lis > 1 .and. ipconc >= 5 ) THEN
16281 do mgs = 1,ngscnt
16282 qhacis(mgs) = 0.0
16283 qhacis0(mgs) = 0.0
16284 IF ( ehis(mgs) .gt. 0.0 ) THEN
16285
16286 vt = sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,lis,1))**2 + &
16287 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,lis,1) )
16288
16289 qhacis0(mgs) = 0.25*pi*ehisclsn(mgs)*cx(mgs,lh)*qx(mgs,lis)*vt* &
16290 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16291 & dab1lh(mgs,lh,lis)*xdia(mgs,lh,3)*xdia(mgs,lis,3) + &
16292 & da1(li)*xdia(mgs,lis,3)**2 )
16293 qhacis(mgs) = min( ehis(mgs)*qhacis0(mgs), qxmxd(mgs,lis) )
16294 ENDIF
16295 end do
16296 ENDIF
16297
16298!
16299!
16300 do mgs = 1,ngscnt
16301 qhacs(mgs) = 0.0
16302 qhacs0(mgs) = 0.0
16303 IF ( ehs(mgs) .gt. 0.0 ) THEN
16304 IF ( ipconc .ge. 5 ) THEN
16305
16306 vt = sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1))**2 + &
16307 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,ls,1) )
16308
16309 qhacs0(mgs) = 0.25*pi*ehsclsn(mgs)*cx(mgs,lh)*qx(mgs,ls)*vt* &
16310 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16311 & dab1lh(mgs,lh,ls)*xdia(mgs,lh,3)*xdia(mgs,ls,3) + &
16312 & da1(ls)*xdia(mgs,ls,3)**2 )
16313
16314 qhacs(mgs) = min( ehs(mgs)*qhacs0(mgs), qsmxd(mgs) )
16315
16316 ELSE
16317 qhacs(mgs) = &
16318 & min( &
16319 & ((0.25)*pi/gf4)*ehs(mgs)*ehsclsn(mgs)*qx(mgs,ls)*cx(mgs,lh) &
16320 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1)) &
16321 & *( gf6*gf1*xdia(mgs,ls,2) &
16322 & + 2.0*gf5*gf2*xdia(mgs,ls,1)*xdia(mgs,lh,1) &
16323 & + gf4*gf3*xdia(mgs,lh,2) ) &
16324 & , qsmxd(mgs))
16325 ENDIF
16326 ENDIF
16327 end do
16328!
16329 do mgs = 1,ngscnt
16330 qhacr(mgs) = 0.0
16331 qhacrmlr(mgs) = 0.0
16332 vhacr(mgs) = 0.0
16333 chacr(mgs) = 0.0
16334 zhacr(mgs) = 0.0
16335 IF ( temg(mgs) .gt. tfr ) raindn(mgs,lh) = 1000.0
16336
16337 IF ( ehr(mgs) .gt. 0.0 ) THEN
16338 IF ( ipconc .ge. 3 ) THEN
16339 vt = sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,lr,1))**2 + &
16340 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,lr,1) )
16341! qhacr(mgs) = ehr(mgs)*cx(mgs,lh)*vt*
16342! : qx(mgs,lr)*0.25*pi*
16343! : (3.02787*xdia(mgs,lr,2) +
16344! : 3.30669*xdia(mgs,lh,1)*xdia(mgs,lr,1) +
16345! : 2.*xdia(mgs,lh,2))
16346
16347 qhacr(mgs) = 0.25*pi*ehr(mgs)*cx(mgs,lh)*qx(mgs,lr)*vt* &
16348 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16349 & dab1lh(mgs,lh,lr)*xdia(mgs,lh,3)*xdia(mgs,lr,3) + &
16350 & da1lr(mgs)*xdia(mgs,lr,3)**2 )
16351! & da1(lr)*xdia(mgs,lr,3)**2 )
16352! IF ( qhacr(mgs) .gt. 0. .or. tmp .gt. 0.0 ) write(0,*) 'qhacr= ',qhacr(mgs),tmp
16353!! qhacr(mgs) = Min( qhacr(mgs), qrmxd(mgs) )
16354!! chacr(mgs) = qhacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
16355!! chacr(mgs) = min(chacr(mgs),crmxd(mgs))
16356
16357 qhacr(mgs) = min( qhacr(mgs), qxmxd(mgs,lr) )
16358
16359 qhacrmlr(mgs) = qhacr(mgs)
16360
16361 IF ( temg(mgs) > tfr .and. iehr0c == 0 ) THEN
16362 qhacr(mgs) = 0.0
16363
16364 IF ( iqhacrmlr == 0 ) THEN
16365 qhacrmlr(mgs) = -qhacw(mgs)
16366 ENDIF
16367
16368 ELSE
16369! chacr(mgs) = Min( qhacr(mgs)*rho0(mgs)/xmas(mgs,lr), cxmxd(mgs,lr) )
16370
16371! chacr(mgs) = ehr(mgs)*cx(mgs,lh)*vt*
16372! : cx(mgs,lr)*0.25*pi*
16373! : (0.69874*xdia(mgs,lr,2) +
16374! : 1.24001*xdia(mgs,lh,1)*xdia(mgs,lr,1) +
16375! : 2.*xdia(mgs,lh,2))
16376
16377 chacr(mgs) = 0.25*pi*ehr(mgs)*cx(mgs,lh)*cx(mgs,lr)*vt* &
16378 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16379 & dab0lh(mgs,lh,lr)*xdia(mgs,lh,3)*xdia(mgs,lr,3) + &
16380 & da0lr(mgs)*xdia(mgs,lr,3)**2 )
16381
16382! IF ( qhacr(mgs) .gt. 0. .or. tmp .gt. 0.0 ) write(0,*) 'chacr= ',chacr(mgs),tmp
16383
16384! chacr(mgs) = qhacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
16385 chacr(mgs) = min(chacr(mgs),crmxd(mgs))
16386
16387 IF ( lzh .gt. 1 ) THEN
16388 tmp = qx(mgs,lh)/cx(mgs,lh)
16389
16390! g1 = (6.0 + alpha(mgs,lh))*(5.0 + alpha(mgs,lh))*(4.0 + alpha(mgs,lh))/
16391! : ((3.0 + alpha(mgs,lh))*(2.0 + alpha(mgs,lh))*(1.0 + alpha(mgs,lh)))
16392! alp = Max( 1.0, alpha(mgs,lh)+1. )
16393! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/
16394! : ((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
16395! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) - tmp**2 * chacr(mgs) )
16396! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qhacr(mgs) )
16397 ENDIF
16398 ENDIF ! temg > tfr
16399
16400 ELSE
16401 IF ( lwsm6 .and. ipconc == 0 ) THEN
16402 vt = vt2ave(mgs)
16403 ELSE
16404 vt = vtxbar(mgs,lh,1)
16405 ENDIF
16406
16407 qhacr(mgs) = &
16408 & min( &
16409 & ((0.25)*pi/gf4)*ehr(mgs)*qx(mgs,lr)*cx(mgs,lh) &
16410 & *abs(vt-vtxbar(mgs,lr,1)) &
16411 & *( gf6*gf1*xdia(mgs,lr,2) &
16412 & + 2.0*gf5*gf2*xdia(mgs,lr,1)*xdia(mgs,lh,1) &
16413 & + gf4*gf3*xdia(mgs,lh,2) ) &
16414 & , qrmxd(mgs))
16415
16416 IF ( temg(mgs) > tfr ) THEN
16417 IF ( iqhacrmlr >= 1 ) qhacrmlr(mgs) = qhacr(mgs)
16418 qhacr(mgs) = 0.0
16419 ENDIF
16420
16421 ENDIF
16422 IF ( lvol(lh) .gt. 1 .or. lhl .gt. 1 ) THEN ! calculate rime density for graupel volume and/or for graupel conversion to hail
16423
16424 IF ( temg(mgs) .lt. 273.15) THEN
16425 raindn(mgs,lh) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lr,3)) &
16426 & *((0.60)*vt) &
16427 & /(temg(mgs)-273.15))**(rimc2)
16428
16429 raindn(mgs,lh) = min( max( rimc3, rimdn(mgs,lh) ), rimc4 )
16430 ELSE
16431 raindn(mgs,lh) = 1000.
16432 ENDIF
16433
16434 IF ( lvol(lh) > 1 ) vhacr(mgs) = rho0(mgs)*qhacr(mgs)/raindn(mgs,lh)
16435 ENDIF
16436 ENDIF
16437 end do
16438
16439!
16440!
16441 if (ndebug .gt. 0 ) write(0,*) 'Collection: hail collects xxxxx'
16442!
16443
16444 do mgs = 1,ngscnt
16445 qhlacw(mgs) = 0.0
16446 qhlacwmlr(mgs) = 0.0
16447 vhlacw(mgs) = 0.0
16448 vhlsoak(mgs) = 0.0
16449 IF ( lhl > 1 .and. .true.) THEN
16450 vtmax = (gz(igs(mgs),jgs,kgs(mgs))*dtpinv)
16451 vtxbar(mgs,lhl,1) = min( vtmax, vtxbar(mgs,lhl,1))
16452 vtxbar(mgs,lhl,2) = min( vtmax, vtxbar(mgs,lhl,2))
16453 vtxbar(mgs,lhl,3) = min( vtmax, vtxbar(mgs,lhl,3))
16454 ENDIF
16455
16456 IF ( lhl > 0 ) THEN
16457 rarx(mgs,lhl) = 0.0
16458 ENDIF
16459
16460 IF ( lhl .gt. 1 .and. ehlw(mgs) .gt. 0.0 ) THEN
16461
16462
16463! IF ( ipconc .ge. 2 ) THEN
16464
16465 vt = abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,lc,1))
16466
16467 qhlacw(mgs) = 0.25*pi*ehlw(mgs)*cx(mgs,lhl)*(qx(mgs,lc)-qcwresv(mgs))*vt* &
16468 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
16469 & dab1lh(mgs,lhl,lc)*xdia(mgs,lhl,3)*xdia(mgs,lc,3) + &
16470 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
16471
16472
16473 qhlacw(mgs) = min( qhlacw(mgs), 0.5*qx(mgs,lc)*dtpinv )
16474
16475 qhlacwmlr(mgs) = qhlacw(mgs)
16476 IF ( temg(mgs) > tfr .and. iqhlacwshr == 0 ) THEN
16477 qhlacw(mgs) = 0.0
16478 ENDIF
16479
16480 IF ( lvol(lhl) .gt. 1 ) THEN
16481
16482 IF ( temg(mgs) .lt. 273.15) THEN
16483 IF ( irimdenopt == 1 ) THEN ! Heymsfeld and Pflaum (1985)
16484 rimdn(mgs,lhl) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16485 & *((0.60)*( (1.0-rimdenvwgt)*vtxbar(mgs,lhl,1) + rimdenvwgt*vtxbar(mgs,lhl,2) )) &
16486 & /(temg(mgs)-273.15))**(rimc2)
16487 rimdn(mgs,lhl) = min( max( hldnmn, rimc3, rimdn(mgs,lhl) ), rimc4 )
16488
16489 ELSEIF ( irimdenopt == 2 ) THEN ! Cober and List (1993)
16490 tmp = -0.5*(1.e+06)*xdia(mgs,lc,1) &
16491 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lhl,1) + rimdenvwgt*vtxbar(mgs,lhl,2) ) &
16492 & /(temg(mgs)-273.15)
16493 tmp = min( 5.5/0.6, max( 0.3/0.6, tmp ) )
16494
16495 rimdn(mgs,lhl) = 1000.*(0.051 + 0.114*tmp - 0.005*tmp**2)
16496
16497 ELSEIF ( irimdenopt == 3 .or. irimdenopt == 4) THEN ! Macklin (3) or Saunders and Hosseini 2001
16498 tmp = -0.5*(1.e+06)*xdia(mgs,lc,1) &
16499 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lhl,1) + rimdenvwgt*vtxbar(mgs,lhl,2) ) &
16500 & /(temg(mgs)-273.15)
16501 ! tmp = Min( 5.5/0.6, Max( 0.3/0.6, tmp ) )
16502
16503 IF ( irimdenopt == 3 ) THEN
16504 rimdn(mgs,lhl) = min(900., max( 170., 110.*tmp**0.76 ) )
16505 ELSEIF ( irimdenopt == 4 ) THEN ! Saunders and Hosseini
16506 rimdn(mgs,lhl) = min(917., max( 10., 900.0*(1.0 - 0.905**tmp ) ) )
16507 ENDIF
16508
16509 ENDIF
16510 ELSE
16511 rimdn(mgs,lhl) = 1000.
16512 ENDIF
16513
16514 vhlacw(mgs) = rho0(mgs)*qhlacw(mgs)/rimdn(mgs,lhl)
16515
16516 ENDIF
16517
16518
16519 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. ipelec .ge. 1 ) THEN
16520 rarx(mgs,lhl) = &
16521 & qhlacw(mgs)*1.0e3*rho0(mgs)/((pi/2.0)*xdia(mgs,lhl,2)*cx(mgs,lhl))
16522 ENDIF
16523
16524 ENDIF
16525 end do
16526
16527 qhlaci(:) = 0.0
16528 qhlaci0(:) = 0.0
16529 IF ( lhl .gt. 1 ) THEN
16530 do mgs = 1,ngscnt
16531 IF ( ehli(mgs) .gt. 0.0 ) THEN
16532 IF ( ipconc .ge. 5 ) THEN
16533
16534 vt = sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,li,1))**2 + &
16535 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,li,1) )
16536
16537 qhlaci0(mgs) = 0.25*pi*ehliclsn(mgs)*cx(mgs,lhl)*qx(mgs,li)*vt* &
16538 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
16539 & dab1lh(mgs,lhl,li)*xdia(mgs,lhl,3)*xdia(mgs,li,3) + &
16540 & da1(li)*xdia(mgs,li,3)**2 )
16541 ! qhlaci(mgs) = Min( qhlaci(mgs), qimxd(mgs) )
16542 qhlaci(mgs) = min( ehli(mgs)*qhlaci0(mgs), qimxd(mgs) )
16543 ENDIF
16544 ENDIF
16545 end do
16546 ENDIF
16547!
16548 qhlacs(:) = 0.0
16549 qhlacs0(:) = 0.0
16550 IF ( lhl .gt. 1 ) THEN
16551 do mgs = 1,ngscnt
16552 IF ( ehls(mgs) .gt. 0.0) THEN
16553 IF ( ipconc .ge. 5 ) THEN
16554
16555 vt = sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,ls,1))**2 + &
16556 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,ls,1) )
16557
16558 qhlacs0(mgs) = 0.25*pi*ehlsclsn(mgs)*cx(mgs,lhl)*qx(mgs,ls)*vt* &
16559 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
16560 & dab1lh(mgs,lhl,ls)*xdia(mgs,lhl,3)*xdia(mgs,ls,3) + &
16561 & da1(ls)*xdia(mgs,ls,3)**2 )
16562
16563 qhlacs(mgs) = min( ehls(mgs)*qhlacs0(mgs), qsmxd(mgs) )
16564 ENDIF
16565 ENDIF
16566 end do
16567 ENDIF
16568
16569
16570 do mgs = 1,ngscnt
16571 qhlacr(mgs) = 0.0
16572 qhlacrmlr(mgs) = 0.0
16573 chlacr(mgs) = 0.0
16574 vhlacr(mgs) = 0.0
16575 IF ( lhl .gt. 1 .and. temg(mgs) .gt. tfr ) raindn(mgs,lhl) = 1000.0
16576
16577 IF ( lhl .gt. 1 .and. ehlr(mgs) .gt. 0.0 ) THEN
16578 IF ( ipconc .ge. 3 ) THEN
16579 vt = sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,lr,1))**2 + &
16580 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,lr,1) )
16581
16582 qhlacr(mgs) = 0.25*pi*ehlr(mgs)*cx(mgs,lhl)*qx(mgs,lr)*vt* &
16583 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
16584 & dab1lh(mgs,lhl,lr)*xdia(mgs,lhl,3)*xdia(mgs,lr,3) + &
16585 & da1lr(mgs)*xdia(mgs,lr,3)**2 )
16586! & da1(lr)*xdia(mgs,lr,3)**2 )
16587! IF ( qhacr(mgs) .gt. 0. .or. tmp .gt. 0.0 ) write(0,*) 'qhacr= ',qhacr(mgs),tmp
16588!! qhacr(mgs) = Min( qhacr(mgs), qrmxd(mgs) )
16589!! chacr(mgs) = qhacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
16590!! chacr(mgs) = min(chacr(mgs),crmxd(mgs))
16591
16592 qhlacr(mgs) = min( qhlacr(mgs), qxmxd(mgs,lr) )
16593
16594
16595 IF ( iqhlacrmlr >= 1 ) qhlacrmlr(mgs) = qhlacr(mgs)
16596
16597 IF ( temg(mgs) > tfr .and. iehlr0c == 0) THEN
16598 qhlacr(mgs) = 0.0
16599 IF ( iqhlacrmlr == 0 ) THEN
16600 qhlacrmlr(mgs) = -qhlacw(mgs)
16601 ENDIF
16602 ELSE
16603 chlacr(mgs) = 0.25*pi*ehlr(mgs)*cx(mgs,lhl)*cx(mgs,lr)*vt* &
16604 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
16605 & dab0lh(mgs,lhl,lr)*xdia(mgs,lhl,3)*xdia(mgs,lr,3) + &
16606 & da0lr(mgs)*xdia(mgs,lr,3)**2 )
16607
16608 chlacr(mgs) = min(chlacr(mgs),crmxd(mgs))
16609
16610 IF ( lvol(lhl) .gt. 1 ) THEN
16611 vhlacr(mgs) = rho0(mgs)*qhlacr(mgs)/raindn(mgs,lhl)
16612 ENDIF
16613 ENDIF
16614 ENDIF
16615 ENDIF
16616 end do
16617
16618
16619
16620!
16621!
16622!
16623!
16624! if (ndebug .gt. 0 ) write(0,*) 'Collection: Cloud collects xxxxx'
16625
16626 if (ndebug .gt. 0 ) write(0,*) 'Collection: cloud ice collects xxxx2'
16627!
16628 do mgs = 1,ngscnt
16629 qiacw(mgs) = 0.0
16630 IF ( eiw(mgs) .gt. 0.0 ) THEN
16631
16632 vt = sqrt((vtxbar(mgs,li,1)-vtxbar(mgs,lc,1))**2 + &
16633 & 0.04*vtxbar(mgs,li,1)*vtxbar(mgs,lc,1) )
16634
16635 qiacw(mgs) = 0.25*pi*eiw(mgs)*cx(mgs,li)*qx(mgs,lc)*vt* &
16636 & ( da0(li)*xdia(mgs,li,3)**2 + &
16637 & dab1(li,lc)*xdia(mgs,li,3)*xdia(mgs,lc,3) + &
16638 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
16639
16640 qiacw(mgs) = min( qiacw(mgs), qxmxd(mgs,lc) )
16641 ENDIF
16642 end do
16643
16644
16645!
16646!
16647 if (ndebug .gt. 0 ) write(0,*) 'Collection: cloud ice collects xxxx8'
16648!
16649 do mgs = 1,ngscnt
16650 qiacr(mgs) = 0.0
16651 qiacrf(mgs) = 0.0
16652 qiacrs(mgs) = 0.0
16653 ciacrs(mgs) = 0.0
16654 ciacr(mgs) = 0.0
16655 ciacrf(mgs) = 0.0
16656 viacrf(mgs) = 0.0
16657 csplinter(mgs) = 0.0
16658 qsplinter(mgs) = 0.0
16659 csplinter2(mgs) = 0.0
16660 qsplinter2(mgs) = 0.0
16661 IF ( iacr .ge. 1 .and. eri(mgs) .gt. 0.0 &
16662 & .and. temg(mgs) .le. 270.15 ) THEN
16663 IF ( ipconc .ge. 3 ) THEN
16664 ni = 0.0
16665 IF ( xdia(mgs,li,1) .ge. 10.e-6 ) THEN
16666 ni = ni + cx(mgs,li)*exp(- (40.e-6/xdia(mgs,li,1))**3 )
16667 ENDIF
16668 IF ( imurain == 1 ) THEN ! gamma of diameter
16669 IF ( iacrsize /= 4 ) THEN
16670 IF ( iacrsize .eq. 1 ) THEN
16671 ratio = 500.e-6/xdia(mgs,lr,1)
16672 ELSEIF ( iacrsize .eq. 2 ) THEN
16673 ratio = 300.e-6/xdia(mgs,lr,1)
16674 ELSEIF ( iacrsize .eq. 3 ) THEN
16675 ratio = 40.e-6/xdia(mgs,lr,1)
16676 ELSEIF ( iacrsize .eq. 5 ) THEN
16677 ratio = 150.e-6/xdia(mgs,lr,1)
16678 ENDIF
16679 i = min(nqiacrratio,int(ratio*dqiacrratioinv))
16680 j = int(max(0.0,min(15.,alpha(mgs,lr)))*dqiacralphainv)
16681! j = Int(Max(minalphalu,Min(maxalphalu,alpha(mgs,lr)))*dqiacralphainv)
16682 delx = ratio - float(i)*dqiacrratio
16683 dely = alpha(mgs,lr) - float(j)*dqiacralpha
16684 ip1 = min( i+1, nqiacrratio )
16685 jp1 = min( j+1, nqiacralpha )
16686
16687 ! interpolate along x, i.e., ratio
16688 tmp1 = ciacrratio(i,j) + delx*dqiacrratioinv*(ciacrratio(ip1,j) - ciacrratio(i,j))
16689 tmp2 = ciacrratio(i,jp1) + delx*dqiacrratioinv*(ciacrratio(ip1,jp1) - ciacrratio(i,jp1))
16690
16691 ! interpolate along alpha
16692
16693 nr = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*cx(mgs,lr)
16694
16695 ! interpolate along x, i.e., ratio;
16696 tmp1 = qiacrratio(i,j) + delx*dqiacrratioinv*(qiacrratio(ip1,j) - qiacrratio(i,j))
16697 tmp2 = qiacrratio(i,jp1) + delx*dqiacrratioinv*(qiacrratio(ip1,jp1) - qiacrratio(i,jp1))
16698
16699 ! interpolate along alpha;
16700
16701 qr = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*qx(mgs,lr)
16702
16703 ELSE ! iacrsize == 4 : use all
16704 nr = cx(mgs,lr)
16705 qr = qx(mgs,lr)
16706 ENDIF
16707
16708 vt = sqrt((vtxbar(mgs,lr,1)-vtxbar(mgs,li,1))**2 + &
16709 & 0.04*vtxbar(mgs,lr,1)*vtxbar(mgs,li,1) )
16710
16711 qiacr(mgs) = 0.25*pi*eri(mgs)*ni*qr*vt* &
16712 & ( da0(li)*xdia(mgs,li,3)**2 + &
16713 & dab1lh(mgs,li,lr)*xdia(mgs,lh,3)*xdia(mgs,li,3) + &
16714 & da1(lr)*xdia(mgs,lr,3)**2 )
16715
16716 qiacr(mgs) = min( qrmxd(mgs), qiacr(mgs) )
16717
16718
16719 ciacr(mgs) = 0.25*pi*eri(mgs)*ni*nr*vt* &
16720 & ( da0(li)*xdia(mgs,li,3)**2 + &
16721 & dab0lh(mgs,li,lr)*xdia(mgs,lr,3)*xdia(mgs,li,3) + &
16722 & da0(lr)*xdia(mgs,lr,3)**2 )
16723
16724 ciacr(mgs) = min( crmxd(mgs), ciacr(mgs) )
16725
16726! write(iunit,*) 'qiacr: ',cx(mgs,lr),nr,qx(mgs,lr),qr,qiacr(mgs),ciacr(mgs)
16727! write(iunit,*) 'xdia r li = ',xdia(mgs,lr,3),xdia(mgs,li,3),xdia(mgs,lr,1),xdia(mgs,li,1)
16728! write(iunit,*) 'i,j,ratio = ',i,j,ciacrratio(i,j),qiacrratio(i,j)
16729! write(iunit,*) 'ni,ci = ',ni,cx(mgs,li),qx(mgs,li)
16730
16731 ELSEIF ( imurain == 3 ) THEN ! gamma of volume
16732! Set nr to the number of drops greater than 40 microns.
16733 arg = 1000.*xdia(mgs,lr,3)
16734! nr = cx(mgs,lr)*gaml02( arg )
16735! IF ( iacr .eq. 1 ) THEN
16736 IF ( ipconc .ge. 3 ) THEN
16737 IF ( iacrsize .eq. 1 ) THEN
16738 nr = cx(mgs,lr)*gaml02d500( arg ) ! number greater than 500 microns in diameter
16739 ELSEIF ( iacrsize .eq. 2 .or. iacrsize .eq. 5 ) THEN
16740 nr = cx(mgs,lr)*gaml02d300( arg ) ! number greater than 300 microns in diameter
16741 ELSEIF ( iacrsize .eq. 3 ) THEN
16742 nr = cx(mgs,lr)*gaml02( arg ) ! number greater than 40 microns in diameter
16743 ELSEIF ( iacrsize .eq. 4 ) THEN
16744 nr = cx(mgs,lr) ! all raindrops
16745 ENDIF
16746 ELSE
16747 nr = cx(mgs,lr)*gaml02( arg )
16748 ENDIF
16749! ELSEIF ( iacr .eq. 2 ) THEN
16750! nr = cx(mgs,lr)*gaml02d300( arg ) ! number greater than 300 microns in diameter
16751! ENDIF
16752 IF ( ni .gt. 0.0 .and. nr .gt. 0.0 ) THEN
16753 d0 = xdia(mgs,lr,3)
16754 qiacr(mgs) = xdn(mgs,lr)*rhoinv(mgs)* &
16755 & (0.217239*(0.522295*(d0**5) + &
16756 & 49711.81*(d0**6) - &
16757 & 1.673016e7*(d0**7)+ &
16758 & 2.404471e9*(d0**8) - &
16759 & 1.22872e11*(d0**9))*ni*nr)
16760 qiacr(mgs) = min( qrmxd(mgs), qiacr(mgs) )
16761 ciacr(mgs) = &
16762 & (0.217239*(0.2301947*(d0**2) + &
16763 & 15823.76*(d0**3) - &
16764 & 4.167685e6*(d0**4) + &
16765 & 4.920215e8*(d0**5) - &
16766 & 2.133344e10*(d0**6))*ni*nr)
16767 ciacr(mgs) = min( crmxd(mgs), ciacr(mgs) )
16768! ciacr(mgs) = qiacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
16769 ENDIF
16770 ENDIF
16771 IF ( iacr .eq. 1 .or. iacr .eq. 3 ) THEN
16772 ciacrf(mgs) = min(ciacr(mgs), qiacr(mgs)/(1.0*vr1mm*1000.0)*rho0(mgs) ) ! *rzxh(mgs)
16773 ELSEIF ( iacr .eq. 2 ) THEN
16774 ciacrf(mgs) = ciacr(mgs) ! *rzxh(mgs)
16775 ELSEIF ( iacr .eq. 4 ) THEN
16776 ciacrf(mgs) = min(ciacr(mgs), qiacr(mgs)/(1.0*vfrz*1000.0)*rho0(mgs) ) ! *rzxh(mgs)
16777 ELSEIF ( iacr .eq. 5 ) THEN
16778 ciacrf(mgs) = ciacr(mgs)*rzxh(mgs)
16779 ENDIF
16780! crfrzf(mgs) = Min(crfrz(mgs), qrfrz(mgs)/(bfnu*27.0*vr1mm*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
16781 ENDIF
16782
16783
16784 ELSE ! single-moment rain
16785 qiacr(mgs) = &
16786 & min( &
16787 & ((0.25/gf4)*pi)*eri(mgs)*cx(mgs,li)*qx(mgs,lr) &
16788 & *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,li,1)) &
16789 & *( gf6*gf1*xdia(mgs,lr,2) &
16790 & + 2.0*gf5*gf2*xdia(mgs,lr,1)*xdia(mgs,li,1) &
16791 & + gf4*gf3*xdia(mgs,li,2) ) &
16792 & , qrmxd(mgs))
16793 ENDIF
16794! if ( temg(mgs) .gt. 268.15 ) then
16795! qiacr(mgs) = 0.0
16796! ciacr(mgs) = 0.0
16797! end if
16798
16799 IF ( ipconc .ge. 1 ) THEN
16800 IF ( nsplinter .ge. 1000 ) THEN
16801 ! Lawson et al. 2015 JAS
16802 ! ave. diam of freezing drops in microns
16803 IF ( qiacr(mgs)*dtp > qxmin(lh) .and. ciacr(mgs) > 1.e-3 ) THEN
16804 tmpdiam = 1.e6*( 6.*qiacr(mgs)/(1000.*pi*ciacr(mgs) ) )**(1./3.) ! avg. diameter of newly frozen drops in microns
16805 csplinter(mgs) = lawson_splinter_fac*tmpdiam**4*ciacr(mgs)
16806 ENDIF
16807 ELSEIF ( nsplinter .ge. 0 ) THEN
16808 csplinter(mgs) = nsplinter*ciacr(mgs)
16809 ELSE
16810 csplinter(mgs) = -nsplinter*ciacrf(mgs)
16811 ENDIF
16812 qsplinter(mgs) = min(0.1*qiacr(mgs), csplinter(mgs)*splintermass/rho0(mgs) ) ! makes splinters smaller if too much mass is taken from graupel
16813 ENDIF
16814
16815 frach = 1.0
16816 IF ( ibiggsnow == 2 .or. ibiggsnow == 3 ) THEN
16817 IF ( ciacr(mgs) > qxmin(lh) ) THEN
16818 xvfrz = rho0(mgs)*qiacr(mgs)/(ciacr(mgs)*900.) ! mean volume of frozen drops; 900. for frozen drop density
16819 frach = 0.5 *(1. + tanh(0.2e12 *( xvfrz - 1.15*xvbiggsnow)))
16820
16821 qiacrs(mgs) = (1.-frach)*qiacr(mgs)
16822 ciacrs(mgs) = (1.-frach)*ciacrf(mgs) ! *rzxh(mgs)
16823
16824 ENDIF
16825 ENDIF
16826
16827 qiacrf(mgs) = frach*qiacr(mgs)
16828 ciacrf(mgs) = frach*ciacrf(mgs)
16829
16830 IF ( lvol(lh) > 1 ) THEN
16831 viacrf(mgs) = rho0(mgs)*qiacrf(mgs)/rhofrz
16832 ENDIF
16833
16834 end do
16835!
16836!
16837!
16838!
16839
16840! snow aggregation here
16841 if ( ipconc .ge. 4 ) then !
16842 do mgs = 1,ngscnt
16843 csacs(mgs) = 0.0
16844 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
16845
16846 IF ( iessec0flag == 0 ) THEN
16847 ec0(mgs) = 1.0
16848 ELSE
16849 tmp = xv(mgs,ls)/(xvmx(ls)*max(1.,100./min(100.,xdn(mgs,ls)))) ! fraction of max snow mass
16850 IF ( tmp .lt. essfrac1 ) THEN
16851 ec0(mgs) = 1.0
16852 ELSEIF ( tmp .ge. essfrac2 ) THEN
16853 ec0(mgs) = 0.0
16854 ELSE
16855 ec0(mgs) = (essfrac2 - tmp)/(essfrac2 - essfrac1)
16856 ENDIF
16857 ENDIF
16858
16859 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
16860! 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
16861 csacs(mgs) = min(csacs(mgs),csmxd(mgs))
16862 ENDIF
16863 end do
16864 end if
16865!
16866!
16867 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 11'
16868 if ( ipconc .ge. 2 .or. ipelec .ge. 9 ) then
16869 do mgs = 1,ngscnt
16870 ciacw(mgs) = 0.0
16871 IF ( eiw(mgs) .gt. 0.0 ) THEN
16872 ciacw(mgs) = qiacw(mgs)*rho0(mgs)/xmas(mgs,lc)
16873 ciacw(mgs) = min(ciacw(mgs),ccmxd(mgs))
16874 ENDIF
16875 end do
16876
16877 end if
16878
16879 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 18'
16880 if ( ipconc .ge. 2 .or. ipelec .ge. 1 ) then
16881 do mgs = 1,ngscnt
16882 cracw(mgs) = 0.0
16883 cracr(mgs) = 0.0
16884 ec0(mgs) = 1.e9
16885 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. qx(mgs,lr) .gt. qxmin(lr) &
16886 & .and. qracw(mgs) .gt. 0.0 ) THEN
16887
16888 IF ( ipconc .lt. 3 ) THEN
16889 IF ( erw(mgs) .gt. 0.0 ) THEN
16890 cracw(mgs) = &
16891 & ((0.25)*pi)*erw(mgs)*(cx(mgs,lc) - ccwresv(mgs))*cx(mgs,lr) &
16892 & *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,lc,1)) &
16893 & *( gf1*xdia(mgs,lc,2) &
16894 & + 2.0*gf2*xdia(mgs,lc,1)*xdia(mgs,lr,1) &
16895 & + gf3*xdia(mgs,lr,2) )
16896 ENDIF
16897 ELSE ! IF ( ipconc .ge. 3 .and.
16898 IF ( dmrauto <= 0 .or. rho0(mgs)*qx(mgs,lr) > 1.2*xl2p(mgs) ) THEN !{
16899 IF ( 0.5*xdia(mgs,lr,3) .gt. rh(mgs) ) THEN ! { .or. cx(mgs,lr) .gt. nh(mgs)
16900! IF ( qx(mgs,lc) .gt. qxmin(lc) .and. qx(mgs,lr) .gt. qxmin(lr) ) THEN
16901 IF ( 0.5*xdia(mgs,lr,3) .gt. rwradmn ) THEN ! r > 50.e-6
16902! DM0CCC=A2*XNC*XNR*(XVC+XVR) ! (A11)
16903! NOTE: murain drops out, so same result for imurain = 1 and 3
16904 cracw(mgs) = aa2*cx(mgs,lr)*(cx(mgs,lc) - ccwresv(mgs))*(xv(mgs,lc) + xv(mgs,lr))
16905 ELSE
16906 IF ( imurain == 3 ) THEN
16907! DM0CCC=A1*XNC*XNR*(((CNU+2.)/(CNU+1.))*XVC**2+((RNU+2.)/(RNU+1.))*XVR**2) ! (A13)
16908 cracw(mgs) = aa1*cx(mgs,lr)*(cx(mgs,lc) - ccwresv(mgs))* &
16909 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.) + &
16910 & (alpha(mgs,lr) + 2.)*xv(mgs,lr)**2/(alpha(mgs,lr) + 1.))
16911 ELSE ! imurain == 1 USE CP00 for rain DSD in diameter
16912 cracw(mgs) = aa1*cx(mgs,lr)*(cx(mgs,lc) - ccwresv(mgs))* &
16913 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.) + &
16914 & (alpha(mgs,lr) + 6.)*(alpha(mgs,lr) + 5.)*(alpha(mgs,lr) + 4.)*xv(mgs,lr)**2/ &
16915 & ((alpha(mgs,lr) + 3.)*(alpha(mgs,lr) + 2.)*(alpha(mgs,lr) + 1.)) )
16916 ENDIF ! imurain
16917 ENDIF
16918 ENDIF ! } rh
16919 ENDIF ! } dmrauto
16920 ENDIF ! ipconc
16921 ENDIF ! qc > qcmin & qr > qrmin
16922
16923! Rain self collection (cracr) and break-up (factor of ec0)
16924!
16925!
16926 ec0(mgs) = 2.e9
16927 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
16928 rwrad = 0.5*xdia(mgs,lr,3)
16929
16930
16931 ! check median volume diameter
16932 IF ( icracrthresh > 1 ) THEN
16933 IF ( imurain == 1 ) THEN
16934 tmp = (3.67+alpha(mgs,lr))*xdia(mgs,lr,1) ! median volume diameter; units of mm (Ulbrich 1983, JCAM)
16935 ELSE ! imurain == 3,
16936 tmp = (1.678+alpha(mgs,lr))**(1./3.)*xdia(mgs,lr,1) ! units of mm (using method of Ulbrich 1983. See ventillation_stuff.nb)
16937 ENDIF
16938 ELSE
16939 tmp = xdia(mgs,lr,3) - 0.1e-3
16940 ENDIF
16941
16942! IF ( xdia(mgs,lr,3) .gt. 2.0e-3 .or. icracr <= 0 ) THEN
16943 IF ( tmp .gt. 1.9e-3 .or. icracr <= 0 ) THEN
16944 ec0(mgs) = 0.0
16945 cracr(mgs) = 0.0
16946 ELSE
16947 IF ( dmrauto <= 0 .or. rho0(mgs)*qx(mgs,lr) > 1.2*xl2p(mgs) ) THEN
16948 IF ( xdia(mgs,lr,3) .lt. 6.1e-4 ) THEN
16949 ec0(mgs) = 1.0
16950 ELSE
16951 ec0(mgs) = exp(-50.0*(50.0*(xdia(mgs,lr,3) - 6.0e-4)))
16952 ENDIF
16953
16954
16955 IF ( rwrad .ge. 50.e-6 ) THEN
16956 cracr(mgs) = ec0(mgs)*aa2*cx(mgs,lr)**2*xv(mgs,lr)
16957 ELSE
16958 IF ( imurain == 3 ) THEN
16959 cracr(mgs) = ec0(mgs)*aa1*(cx(mgs,lr)*xv(mgs,lr))**2* &
16960 & (alpha(mgs,lr) + 2.)/(alpha(mgs,lr) + 1.)
16961 ELSE ! imurain == 1
16962 cracr(mgs) = ec0(mgs)*aa1*(cx(mgs,lr)*xv(mgs,lr))**2* &
16963 & (alpha(mgs,lr) + 6.)*(alpha(mgs,lr) + 5.)*(alpha(mgs,lr) + 4.)/ &
16964 & ((alpha(mgs,lr) + 3.)*(alpha(mgs,lr) + 2.)*(alpha(mgs,lr) + 1.))
16965
16966 ENDIF
16967 ENDIF
16968! cracr(mgs) = Min(cracr(mgs),crmxd(mgs))
16969 ENDIF
16970 ENDIF
16971 ENDIF
16972
16973! cracw(mgs) = min(cracw(mgs),cxmxd(mgs,lc))
16974 end do
16975 end if
16976
16977!
16978!
16979!
16980! Graupel
16981!
16982 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22ii'
16983 chacw(:) = 0.0
16984 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
16985 do mgs = 1,ngscnt
16986
16987 IF ( ipconc .ge. 5 ) THEN
16988 IF ( qhacw(mgs) .gt. 0.0 .and. xmas(mgs,lc) .gt. 0.0 ) THEN
16989
16990! This is the explict version of chacw, which turns out to be very close to the
16991! approximation that the droplet size does not change, to within a few percent.
16992! This may _not_ be the case for cnu other than zero!
16993! chacw(mgs) = (ehw(mgs)*cx(mgs,lc)*cx(mgs,lh)*(pi/4.)*
16994! : abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1))*
16995! : (2.0*xdia(mgs,lh,1)*(xdia(mgs,lh,1) +
16996! : xdia(mgs,lc,1)*gf43rds) +
16997! : xdia(mgs,lc,2)*gf53rds))
16998
16999! chacw(mgs) = Min( chacw(mgs), 0.6*cx(mgs,lc)*dtpinv )
17000
17001! chacw(mgs) = qhacw(mgs)*rho0(mgs)/xmas(mgs,lc)
17002 chacw(mgs) = qhacw(mgs)*rho0(mgs)/xmascw(mgs)
17003! chacw(mgs) = min(chacw(mgs),cxmxd(mgs,lc))
17004 chacw(mgs) = min( chacw(mgs), 0.5*(cx(mgs,lc) - ccwresv(mgs))*dtpinv )
17005 ELSE
17006 qhacw(mgs) = 0.0
17007 ENDIF
17008 ELSE
17009 ! single-moment
17010 chacw(mgs) = &
17011 & ((0.25)*pi)*ehw(mgs)*cx(mgs,lc)*cx(mgs,lh) &
17012 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1)) &
17013 & *( gf1*xdia(mgs,lc,2) &
17014 & + 2.0*gf2*xdia(mgs,lc,1)*xdia(mgs,lh,1) &
17015 & + gf3*xdia(mgs,lh,2) )
17016 chacw(mgs) = min(chacw(mgs),0.5*cx(mgs,lc)*dtpinv)
17017! chacw(mgs) = min(chacw(mgs),cxmxd(mgs,lc))
17018! chacw(mgs) = min(chacw(mgs),ccmxd(mgs))
17019 ENDIF
17020 end do
17021 end if
17022!
17023 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22kk'
17024 chaci(:) = 0.0
17025 chaci0(:) = 0.0
17026 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17027 do mgs = 1,ngscnt
17028 IF ( ehi(mgs) .gt. 0.0 .or. ( ehiclsn(mgs) > 0.0 .and. ipelec > 0 )) THEN
17029 IF ( ipconc .ge. 5 ) THEN
17030
17031 vt = sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,li,1))**2 + &
17032 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,li,1) )
17033
17034 chaci0(mgs) = 0.25*pi*ehiclsn(mgs)*cx(mgs,lh)*cx(mgs,li)*vt* &
17035 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
17036 & dab0lh(mgs,lh,li)*xdia(mgs,lh,3)*xdia(mgs,li,3) + &
17037 & da0(li)*xdia(mgs,li,3)**2 )
17038
17039 ELSE
17040 chaci0(mgs) = &
17041 & ((0.25)*pi)*ehiclsn(mgs)*cx(mgs,li)*cx(mgs,lh) &
17042 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,li,1)) &
17043 & *( gf1*xdia(mgs,li,2) &
17044 & + 2.0*gf2*xdia(mgs,li,1)*xdia(mgs,lh,1) &
17045 & + gf3*xdia(mgs,lh,2) )
17046 ENDIF
17047
17048 chaci(mgs) = min(ehi(mgs)*chaci0(mgs),cimxd(mgs))
17049 ENDIF
17050 end do
17051 end if
17052
17053
17054 chacis(:) = 0.0
17055 if ( lis > 1 .and. ipconc .ge. 5 .or. ipelec .ge. 1 ) then
17056 do mgs = 1,ngscnt
17057 IF ( ehis(mgs) .gt. 0.0 .or. ( ehisclsn(mgs) > 0.0 .and. ipelec > 0 )) THEN
17058
17059 vt = sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,lis,1))**2 + &
17060 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,lis,1) )
17061
17062 chacis0(mgs) = 0.25*pi*ehisclsn(mgs)*cx(mgs,lh)*cx(mgs,lis)*vt* &
17063 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
17064 & dab0lh(mgs,lh,lis)*xdia(mgs,lh,3)*xdia(mgs,lis,3) + &
17065 & da0(lis)*xdia(mgs,lis,3)**2 )
17066
17067
17068 chacis(mgs) = min(ehis(mgs)*chacis0(mgs),cxmxd(mgs,lis))
17069 ENDIF
17070 end do
17071 end if
17072!
17073!
17074 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22nn'
17075 chacs(:) = 0.0
17076 chacs0(:) = 0.0
17077 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17078 do mgs = 1,ngscnt
17079 IF ( ehs(mgs) .gt. 0 ) THEN
17080 IF ( ipconc .ge. 5 .or. ( ehsclsn(mgs) > 0.0 .and. ipelec > 0 ) ) THEN
17081
17082 vt = sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1))**2 + &
17083 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,ls,1) )
17084
17085 chacs0(mgs) = 0.25*pi*ehsclsn(mgs)*cx(mgs,lh)*cx(mgs,ls)*vt* &
17086 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
17087 & dab0lh(mgs,lh,ls)*xdia(mgs,lh,3)*xdia(mgs,ls,3) + &
17088 & da0(ls)*xdia(mgs,ls,3)**2 )
17089
17090 ELSE
17091 chacs0(mgs) = &
17092 & ((0.25)*pi)*ehsclsn(mgs)*cx(mgs,ls)*cx(mgs,lh) &
17093 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1)) &
17094 & *( gf3*gf1*xdia(mgs,ls,2) &
17095 & + 2.0*gf2*gf2*xdia(mgs,ls,1)*xdia(mgs,lh,1) &
17096 & + gf1*gf3*xdia(mgs,lh,2) )
17097 ENDIF
17098 chacs(mgs) = min(ehs(mgs)*chacs0(mgs),csmxd(mgs))
17099 ENDIF
17100 end do
17101 end if
17102
17103
17104!
17105!
17106! Hail
17107!
17108 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22ii'
17109 chlacw(:) = 0.0
17110 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17111 do mgs = 1,ngscnt
17112
17113 IF ( lhl .gt. 1 .and. ipconc .ge. 5 ) THEN
17114 IF ( qhlacw(mgs) .gt. 0.0 .and. xmas(mgs,lc) .gt. 0.0 ) THEN
17115
17116! This is the explict version of chacw, which turns out to be very close to the
17117! approximation that the droplet size does not change, to within a few percent.
17118! This may _not_ be the case for cnu other than zero!
17119! chlacw(mgs) = (ehlw(mgs)*cx(mgs,lc)*cx(mgs,lhl)*(pi/4.)*
17120! : abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,lc,1))*
17121! : (2.0*xdia(mgs,lhl,1)*(xdia(mgs,lhl,1) +
17122! : xdia(mgs,lc,1)*gf43rds) +
17123! : xdia(mgs,lc,2)*gf53rds))
17124
17125! chlacw(mgs) = Min( chlacw(mgs), 0.6*cx(mgs,lc)*dtpinv )
17126
17127! chlacw(mgs) = qhlacw(mgs)*rho0(mgs)/xmas(mgs,lc)
17128 chlacw(mgs) = qhlacw(mgs)*rho0(mgs)/xmascw(mgs)
17129! chlacw(mgs) = min(chlacw(mgs),cxmxd(mgs,lc))
17130 chlacw(mgs) = min( chlacw(mgs), 0.5*cx(mgs,lc)*dtpinv )
17131 ELSE
17132 qhlacw(mgs) = 0.0
17133 ENDIF
17134! ELSE
17135! chlacw(mgs) =
17136! > ((0.25)*pi)*ehlw(mgs)*cx(mgs,lc)*cx(mgs,lhl)
17137! > *abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,lc,1))
17138! > *( gf1*xdia(mgs,lc,2)
17139! > + 2.0*gf2*xdia(mgs,lc,1)*xdia(mgs,lhl,1)
17140! > + gf3*xdia(mgs,lhl,2) )
17141! chlacw(mgs) = min(chlacw(mgs),0.5*cx(mgs,lc)*dtpinv)
17142! chlacw(mgs) = min(chlacw(mgs),cxmxd(mgs,lc))
17143! chlacw(mgs) = min(chlacw(mgs),ccmxd(mgs))
17144 ENDIF
17145 end do
17146 end if
17147!
17148 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22kk'
17149 chlaci(:) = 0.0
17150 chlaci0(:) = 0.0
17151 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17152 do mgs = 1,ngscnt
17153 IF ( lhl .gt. 1 .and. ( ehli(mgs) .gt. 0.0 .or. (ipelec > 0 .and. ehliclsn(mgs) > 0.0) ) ) THEN
17154 IF ( ipconc .ge. 5 ) THEN
17155
17156 vt = sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,li,1))**2 + &
17157 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,li,1) )
17158
17159 chlaci0(mgs) = 0.25*pi*ehliclsn(mgs)*cx(mgs,lhl)*cx(mgs,li)*vt* &
17160 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
17161 & dab0(lhl,li)*xdia(mgs,lhl,3)*xdia(mgs,li,3) + &
17162 & da0(li)*xdia(mgs,li,3)**2 )
17163
17164! ELSE
17165! chlaci(mgs) =
17166! > ((0.25)*pi)*ehli(mgs)*cx(mgs,li)*cx(mgs,lhl)
17167! > *abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,li,1))
17168! > *( gf1*xdia(mgs,li,2)
17169! > + 2.0*gf2*xdia(mgs,li,1)*xdia(mgs,lhl,1)
17170! > + gf3*xdia(mgs,lhl,2) )
17171 ENDIF
17172
17173 chlaci(mgs) = min(ehli(mgs)*chlaci0(mgs),cimxd(mgs))
17174 ENDIF
17175 end do
17176 end if
17177
17178
17179 IF ( lis > 1 .and. ipconc .ge. 5) THEN
17180
17181 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22kk'
17182 chlacis(:) = 0.0
17183 chlacis0(:) = 0.0
17184 do mgs = 1,ngscnt
17185 IF ( lhl .gt. 1 .and. ( ehlis(mgs) .gt. 0.0 .or. (ipelec > 0 .and. ehlisclsn(mgs) > 0.0) ) ) THEN
17186
17187 vt = sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,lis,1))**2 + &
17188 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,lis,1) )
17189
17190 chlacis0(mgs) = 0.25*pi*ehlisclsn(mgs)*cx(mgs,lhl)*cx(mgs,lis)*vt* &
17191 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
17192 & dab0(lhl,lis)*xdia(mgs,lhl,3)*xdia(mgs,lis,3) + &
17193 & da0(lis)*xdia(mgs,lis,3)**2 )
17194
17195
17196 chlacis(mgs) = min(ehlis(mgs)*chlacis0(mgs),cxmxd(mgs,lis))
17197 ENDIF
17198 end do
17199 ENDIF
17200
17201!
17202!
17203 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22jj'
17204 chlacs(:) = 0.0
17205 chlacs0(:) = 0.0
17206 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17207 do mgs = 1,ngscnt
17208 IF ( lhl .gt. 1 .and. ( ehls(mgs) .gt. 0.0 .or. (ipelec > 0 .and. ehlsclsn(mgs) > 0.0) ) ) THEN
17209 IF ( ipconc .ge. 5 ) THEN
17210
17211 vt = sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,ls,1))**2 + &
17212 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,ls,1) )
17213
17214 chlacs0(mgs) = 0.25*pi*ehlsclsn(mgs)*cx(mgs,lhl)*cx(mgs,ls)*vt* &
17215 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
17216 & dab0(lhl,ls)*xdia(mgs,lhl,3)*xdia(mgs,ls,3) + &
17217 & da0(ls)*xdia(mgs,ls,3)**2 )
17218
17219! ELSE
17220! chlacs(mgs) =
17221! > ((0.25)*pi)*ehls(mgs)*cx(mgs,ls)*cx(mgs,lhl)
17222! > *abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,ls,1))
17223! > *( gf3*gf1*xdia(mgs,ls,2)
17224! > + 2.0*gf2*gf2*xdia(mgs,ls,1)*xdia(mgs,lhl,1)
17225! > + gf1*gf3*xdia(mgs,lhl,2) )
17226 ENDIF
17227 chlacs(mgs) = min(ehls(mgs)*chlacs0(mgs),csmxd(mgs))
17228 ENDIF
17229 end do
17230 end if
17231
17232!
17233! Ziegler (1985) autoconversion
17234!
17235!
17236 IF ( ipconc .ge. 2 ) THEN
17237 if (ndebug .gt. 0 ) write(0,*) 'conc 26a'
17238
17239 DO mgs = 1,ngscnt
17240 zrcnw(mgs) = 0.0
17241 qrcnw(mgs) = 0.0
17242 crcnw(mgs) = 0.0
17243 cautn(mgs) = 0.0
17244 ENDDO
17245
17246 IF ( dmrauto >= -1 ) THEN !{
17247 DO mgs = 1,ngscnt
17248! qracw(mgs) = 0.0
17249! cracw(mgs) = 0.0
17250 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. 1000. .and. temg(mgs) .gt. tfrh+4.) THEN
17251 !( .and. w(igs(mgs),jgs,kgs(mgs)) > 5.0) THEN ! DTD: added w threshold for testing
17252 volb = xv(mgs,lc)*(1./(1.+alpha(mgs,lc)))**(1./2.)
17253 cautn(mgs) = min(ccmxd(mgs), &
17254 & ((alpha(mgs,lc)+2.)/(alpha(mgs,lc)+1.))*aa1*cx(mgs,lc)**2*xv(mgs,lc)**2)
17255 cautn(mgs) = max( 0.0d0, cautn(mgs) )
17256 IF ( rb(mgs) .le. 7.51d-6 .or. dmrauto == -1) THEN
17257 t2s = 1.d30
17258! cautn(mgs) = 0.0
17259 ELSE
17260! XL2P=2.7E-2*XNC*XVC*((1.E12*RB**3*RC)-0.4)
17261
17262! T2S=3.72E-3/(((1.E4*RB)-7.5)*XNC*XVC)
17263! t2s = 3.72E-3/(((1.e6*rb)-7.5)*cx(mgs,lc)*xv(mgs,lc))
17264! t2s = 3.72/(((1.e6*rb(mgs))-7.5)*rho0(mgs)*qx(mgs,lc))
17265 t2s = 3.72/(1.e6*(rb(mgs)-7.500d-6)*rho0(mgs)*qx(mgs,lc))
17266
17267 qrcnw(mgs) = max( 0.0d0, xl2p(mgs)/(t2s*rho0(mgs)) )
17268 crcnw(mgs) = max( 0.0d0, min(3.5e9*xl2p(mgs)/t2s,0.5*cautn(mgs)) )
17269
17270 IF ( dmrauto == 0 ) THEN
17271 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)
17272 crcnw(mgs) = cx(mgs,lr)/qx(mgs,lr)*qrcnw(mgs)
17273 ELSEIF ( ( dmropt == 1 .or. dmropt == 3 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17274 tmp = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17275 crcnw(mgs) = min(tmp,crcnw(mgs) )
17276 ELSEIF ( ( dmropt == 4 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17277 tmp = crcnw(mgs)
17278 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17279 ! try mass-weighted average of old and new Dmr using converted qc mass
17280 crcnw(mgs) = (tmp*qrcnw(mgs)+tmp2*qx(mgs,lr))/(qrcnw(mgs)+qx(mgs,lr))
17281 ELSEIF ( ( dmropt == 5 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17282 tmp = crcnw(mgs)
17283 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17284 ! try mass-weighted average of old and new Dmr using full qc mass
17285 crcnw(mgs) = (tmp*qx(mgs,lc)+tmp2*qx(mgs,lr))/(qx(mgs,lc)+qx(mgs,lr))
17286 ELSEIF ( ( dmropt == 6 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17287 tmp = crcnw(mgs)
17288 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17289 ! try mass*diameter-weighted average of old and new Dmr (using full qc mass)
17290 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))
17291 ELSEIF ( ( dmropt == 7 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17292 tmp = crcnw(mgs)
17293 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17294 ! try diameter-weighted average of old and new Dmr
17295 crcnw(mgs) = (tmp*xdia(mgs,lc,3)+tmp2*xdia(mgs,lr,3))/(xdia(mgs,lc,3)+xdia(mgs,lr,3))
17296 ELSEIF ( ( dmropt == 8 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17297 tmp = crcnw(mgs)
17298 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17299 ! try sqrt(diameter)-weighted average of old and new Dmr
17300 crcnw(mgs) = (tmp*sqrt(xdia(mgs,lc,3))+tmp2*sqrt(xdia(mgs,lr,3)))/(sqrt(xdia(mgs,lc,3))+sqrt(xdia(mgs,lr,3)))
17301 ENDIF
17302 ELSEIF ( dmrauto == 1 .and. cx(mgs,lr) > cxmin) THEN
17303 IF ( qx(mgs,lr) > qxmin(lr) ) THEN
17304 tmp = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17305 crcnw(mgs) = min(tmp,crcnw(mgs) )
17306 ENDIF
17307 ELSEIF ( dmrauto == 2 .and. cx(mgs,lr) > cxmin) THEN
17308 tmp = crcnw(mgs)
17309 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17310 ! try mass-weighted average of old and new Dmr
17311 crcnw(mgs) = (tmp*qrcnw(mgs)+tmp2*qx(mgs,lr))/(qrcnw(mgs)+qx(mgs,lr))
17312 ELSEIF ( dmrauto == 3 .and. cx(mgs,lr) > cxmin) THEN ! adapted from MY/CP code
17313 tmp = max( 2.d0*rh(mgs), dble( xdia(mgs,lr,3) ) )
17314 crcnw(mgs) = rho0(mgs)*qrcnw(mgs)/(pi/6.*1000.*tmp**3)
17315 ENDIF
17316
17317 IF ( crcnw(mgs) < 1.e-30 ) qrcnw(mgs) = 0.0
17318
17319 IF ( ipconc >= 6 ) THEN
17320 IF ( lzr > 1 .and. qrcnw(mgs) > 0.0 ) THEN
17321! vr = rho0(mgs)*qrcnw(mgs)/(1000.*crcnw(mgs))
17322! zrcnw(mgs) = 36.*(xnu(lr)+2.0)*crcnw(mgs)*vr**2/((xnu(lr)+1.0)*pi**2)
17323 ! DTD: If rain exists at a grid point already either use the alpha-preserving Z-rate eqn. (dmrauto == 1)
17324 ! or a mass-weighted average of the alpha-preserving Z-rate eqn. and the init. rate eqn. (dmrauto == 2)
17325 ! or the original initiation rate equation (dmrauto == 0). Not sure if this is the correct way to go but seems to work ok.
17326 IF (qx(mgs,lr) .gt. qxmin(lr) .and. ( dmrauto == 1 .or. dmrauto ==2 ) ) THEN
17327 tmp3 = qx(mgs,lr)/cx(mgs,lr)
17328 tmp4 = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2* &
17329 & ( 2.*tmp3 * qrcnw(mgs) - tmp3**2 * crcnw(mgs) )
17330 if (imurain == 3) then
17331 vr = rho0(mgs)*qrcnw(mgs)/(1000.)
17332 tmp3 = 36.*(xnu(lc)+2.0)*vr**2/(crcnw(mgs)*(xnu(lc)+1.0)*pi**2)
17333 else
17334 tmp3 = galpharaut*(6.*rho0(mgs)*qrcnw(mgs)/(pi*xdn0(lr)))**2/crcnw(mgs)
17335 endif
17336 IF ( dmrauto == 1 ) THEN ! Preserve alpha
17337 zrcnw(mgs) = tmp4
17338 ELSEIF ( dmrauto == 2 ) THEN ! Mass-weighted average
17339 zrcnw(mgs) = (tmp3*qrcnw(mgs)+tmp4*qx(mgs,lr))/(qrcnw(mgs)+qx(mgs,lr))
17340 ENDIF
17341 else ! original formulation
17342 IF ( imurain == 3 ) THEN
17343 vr = rho0(mgs)*qrcnw(mgs)/(1000.) ! crcnw(mgs) not divided here but is in next line, cancels one factor in the numerator
17344 zrcnw(mgs) = 36.*(xnu(lc)+2.0)*vr**2/(crcnw(mgs)*(xnu(lc)+1.0)*pi**2)
17345 ELSE ! rain in gamma of diameter
17346 IF ( dmropt <= 1 .or. dmropt >= 4 .or. ( qx(mgs,lr) < qxmin(lr) .and. cx(mgs,lr) < cxmin ) ) THEN
17347 zrcnw(mgs) = galpharaut*(6.*rho0(mgs)*qrcnw(mgs)/(pi*xdn0(lr)))**2/crcnw(mgs)
17348 ELSE
17349 tmp3 = qx(mgs,lr)/cx(mgs,lr)
17350 zrcnw(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2* &
17351 & ( 2.*tmp3 * qrcnw(mgs) - tmp3**2 * crcnw(mgs) )
17352 ENDIF
17353! vr = rho0(mgs)*qrcnw(mgs)/(1000.) ! crcnw(mgs) not divided here but is in next line, cancels one factor in the numerator
17354! zrcnw(mgs) = 36.*(xnu(lc)+2.0)*vr**2/(crcnw(mgs)*(xnu(lc)+1.0)*pi**2)
17355 ENDIF
17356 endif
17357! z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
17358 ENDIF
17359 ENDIF ! ipconc >= 6
17360! IF ( crcnw(mgs) .gt. cautn(mgs) .and. crcnw(mgs) .gt. 1.0 )
17361! : THEN
17362! write(0,*) 'crcnw,cautn ',crcnw(mgs)/cautn(mgs),
17363! : crcnw(mgs),cautn(mgs),igs(mgs),kgs(mgs),t2s,qx(mgs,lr)
17364! write(0,*) ' ',qx(mgs,lc),cx(mgs,lc),0.5e6*xdia(mgs,lc,1)
17365! write(0,*) ' ',rho0(mgs)*qrcnw(mgs)/crcnw(mgs),
17366! : 1.e6*(( 3/(4.*pi))*rho0(mgs)*qrcnw(mgs)/
17367! : (crcnw(mgs)*xdn(mgs,lr)))**(1./3.),rh(mgs)*1.e6,rwrad(mgs)
17368! ELSEIF ( crcnw(mgs) .gt. 1.0 .and. cautn(mgs) .gt. 0.) THEN
17369! write(0,*) 'crcnw,cautn ',crcnw(mgs)/cautn(mgs),
17370! : crcnw(mgs),cautn(mgs),igs(mgs),kgs(mgs),t2s
17371! write(0,*) ' ',rho0(mgs)*qrcnw(mgs)/crcnw(mgs),
17372! : 1.e6*(( 3*pi/4.)*rho0(mgs)*qrcnw(mgs)/
17373! : (crcnw(mgs)*xdn(mgs,lr)))**(1./3.)
17374! ENDIF
17375! crcnw(mgs) = Min(cautn(mgs),3.5e9*xl2p(mgs)/t2s)
17376
17377! IF ( qrcnw(mgs) .gt. 0.3e-2 ) THEN
17378! write(0,*) 'QRCNW'
17379! write(0,*) qrcnw(mgs),crcnw(mgs),cautn(mgs)
17380! write(0,*) xl2p,t2s,rho0(mgs),xv(mgs,lc),cx(mgs,lc),qx(mgs,lc)
17381! write(0,*) rb,0.5*xdia(mgs,lc,1),mgs,igs(mgs),kgs(mgs)
17382! ENDIF
17383! qrcnw(mgs) = Min(qrcnw(mgs),qcmxd(mgs))
17384 ENDIF
17385
17386
17387 ENDIF
17388 ENDDO
17389
17390 ENDIF !} dmrauto >= 0
17391
17392
17393
17394 ELSE
17395
17396!
17397! Berry 1968 auto conversion for rain (Orville & Kopp 1977)
17398!
17399!
17400 if ( ircnw .eq. 4 ) then
17401 do mgs = 1,ngscnt
17402! sconvmix(lcw,mgs) = 0.0
17403 qrcnw(mgs) = 0.0
17404 qdiff = max((qx(mgs,lc)-qminrncw),0.0)
17405 if ( qdiff .gt. 0.0 .and. xdia(mgs,lc,1) .gt. 20.0e-6 ) then
17406 argrcnw = &
17407 & ((1.2e-4)+(1.596e-12)*(cx(mgs,lc)*1.0e-6) &
17408 & /(cwdisp*qdiff*1.0e-3*rho0(mgs)))
17409 qrcnw(mgs) = (rho0(mgs)*1e-3)*(qdiff**2)/argrcnw
17410! sconvmix(lcw,mgs) = max(sconvmix(lcw,mgs),0.0)
17411 qrcnw(mgs) = (max(qrcnw(mgs),0.0))
17412 end if
17413 end do
17414
17415 ENDIF
17416!
17417!
17418!
17419! Berry 1968 auto conversion for rain (Ferrier 1994)
17420!
17421!
17422 if ( ircnw .eq. 5 ) then
17423 do mgs = 1,ngscnt
17424 qrcnw(mgs) = 0.0
17425 qrcnw(mgs) = 0.0
17426 qccrit = (pi/6.)*(cx(mgs,lc)*cwdiap**3)*xdn(mgs,lc)/rho0(mgs)
17427 qdiff = max((qx(mgs,lc)-qccrit),0.)
17428 if ( qdiff .gt. 0.0 .and. cx(mgs,lc) .gt. 1.0 ) then
17429 argrcnw = &
17430! > ((1.2e-4)+(1.596e-12)*cx(mgs,lc)/(cwdisp*rho0(mgs)*qdiff)) &
17431 & ((1.2e-4)+(1.596e-12)*cx(mgs,lc)*1.0e-3/(cwdisp*rho0(mgs)*qdiff))
17432 qrcnw(mgs) = &
17433! > timflg(mgs)*rho0(mgs)*(qdiff**2)/argrcnw &
17434 & 1.0e-3*rho0(mgs)*(qdiff**2)/argrcnw
17435 qrcnw(mgs) = min(qxmxd(mgs,lc), (max(qrcnw(mgs),0.0)) )
17436
17437! write(iunit,*) 'qrcnw,cx =',qrcnw(mgs),cx(mgs,lc),mgs,1.e3*qx(mgs,lc),cno(lr)
17438 end if
17439 end do
17440 end if
17441
17442!
17443!
17444! kessler auto conversion for rain.
17445!
17446 if ( ircnw .eq. 2 ) then
17447 do mgs = 1,ngscnt
17448 qrcnw(mgs) = 0.0
17449 qrcnw(mgs) = (0.001)*max((qx(mgs,lc)-qminrncw),0.0)
17450 end do
17451 end if
17452!
17453! c4 = pi/6
17454! c1 = 0.12-0.32 for colorado storms...typically 0.3-0.4
17455! berry reinhart type conversion (proctor 1988)
17456!
17457 if ( ircnw .eq. 1 ) then
17458 do mgs = 1,ngscnt
17459 qrcnw(mgs) = 0.0
17460 c1 = 0.2
17461 c4 = pi/(6.0)
17462 bradp = &
17463 & (1.e+06) * ((c1/(0.38))**(1./3.)) * (xdia(mgs,lc,1)*(0.5))
17464 bl2 = &
17465 & (0.027) * ((100.0)*(bradp**3)*(xdia(mgs,lc,1)*(0.5)) - (0.4))
17466 bt2 = (bradp -7.5) / (3.72)
17467 qrcnw(mgs) = 0.0
17468 if ( bl2 .gt. 0.0 .and. bt2 .gt. 0.0 ) then
17469 qrcnw(mgs) = bl2 * bt2 * rho0(mgs) &
17470 & * qx(mgs,lc) * qx(mgs,lc)
17471 end if
17472 end do
17473 end if
17474
17475
17476
17477 ENDIF ! ( ipconc .ge. 2 )
17478
17479!
17480!
17481!
17482! Bigg Freezing of Rain
17483!
17484 if (ndebug .gt. 0 ) write(0,*) 'conc 27a'
17485 qrfrz(:) = 0.0
17486 qrfrzs(:) = 0.0
17487 qrfrzf(:) = 0.0
17488 vrfrzf(:) = 0.0
17489 crfrz(:) = 0.0
17490 crfrzs(:) = 0.0
17491 crfrzf(:) = 0.0
17492 zrfrz(:) = 0.0
17493 zrfrzs(:) = 0.0
17494 zrfrzf(:) = 0.0
17495 qwcnr(:) = 0.0
17496
17497 IF ( .not. ( ipconc == 0 .and. lwsm6 ) ) THEN
17498
17499 do mgs = 1,ngscnt
17500 if ( qx(mgs,lr) .gt. qxmin(lr) .and. temcg(mgs) .lt. -5. .and. ibiggopt > 0 ) then
17501! brz = 100.0
17502! arz = 0.66
17503 IF ( ipconc .lt. 3 ) THEN
17504 qrfrz(mgs) = &
17505 & min( &
17506 & (20.0)*(pi**2)*brz*(xdn(mgs,lr)/rho0(mgs)) &
17507 & *cx(mgs,lr)*(xdia(mgs,lr,1)**6) &
17508 & *(exp(max(-arz*temcg(mgs), 0.0))-1.0) &
17509 & , qrmxd(mgs))
17510 qrfrzf(mgs) = qrfrz(mgs)
17511
17512! ELSEIF ( ipconc .ge. 3 .and. xv(mgs,lr) .gt. 1.1*xvmn(lr) ) THEN
17513 ELSEIF ( ipconc .ge. 3 ) THEN
17514! tmp = brz*cx(mgs,lr)*(Exp(Max( -arz*temcg(mgs), 0.0 )) - 1.0)
17515! crfrz(mgs) = xv(mgs,lr)*tmp
17516
17517 frach = 1.0d0
17518
17519! IF ( ibiggopt == 2 .and. imurain == 1 .and. lzr < 1 ) THEN ! lzr check because results are weird for 3-moment
17520 IF ( ibiggopt == 2 .and. imurain == 1 ) THEN !
17521 ! integrate from Bigg diameter (for given supercooling Ts) to infinity
17522
17523 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)
17524 ! 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
17525 ! volt is given in cm**3, so convert to m**3
17526 dbigg = (6./pi* volt )**(1./3.)
17527
17528 ! perhaps should also test that W > V_t_dbigg, i.e., that drops the size of dbigg are being lifted and cooled.
17529 IF ( dbigg < 8.e-3 ) THEN !{ only bother if freezing diameter is reasonable
17530
17531 ratio = min(maxratiolu, dbigg/xdia(mgs,lr,1) )
17532
17533 i = min(nqiacrratio,int(ratio*dqiacrratioinv))
17534 IF ( alp0flag ) THEN
17535 j = int(max(0.0,min(15.,alpha(mgs,lr)))*dqiacralphainv)
17536 ELSE
17537 j = int(max(minalphalu,min(maxalphalu,alpha(mgs,lr)))*dqiacralphainv)
17538 ENDIF
17539 delx = ratio - float(i)*dqiacrratio
17540 dely = alpha(mgs,lr) - float(j)*dqiacralpha
17541 ip1 = min( i+1, nqiacrratio )
17542 jp1 = min( j+1, nqiacralpha )
17543
17544 ! interpolate along x, i.e., ratio;
17545 tmp1 = ciacrratio(i,j) + delx*dqiacrratioinv*(ciacrratio(ip1,j) - ciacrratio(i,j))
17546 tmp2 = ciacrratio(i,jp1) + delx*dqiacrratioinv*(ciacrratio(ip1,jp1) - ciacrratio(i,jp1))
17547
17548 ! interpolate along alpha;
17549
17550 crfrz(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*cx(mgs,lr)*dtpinv
17551 crfrzf(mgs) = crfrz(mgs)
17552 ! interpolate along x, i.e., ratio;
17553 tmp1 = qiacrratio(i,j) + delx*dqiacrratioinv*(qiacrratio(ip1,j) - qiacrratio(i,j))
17554 tmp2 = qiacrratio(i,jp1) + delx*dqiacrratioinv*(qiacrratio(ip1,jp1) - qiacrratio(i,jp1))
17555
17556 ! interpolate along alpha;
17557
17558 qrfrz(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*qx(mgs,lr)*dtpinv
17559 qrfrzf(mgs) = qrfrz(mgs)
17560
17561 IF ( qrfrz(mgs)*dtp < qxmin(lh) .or. crfrz(mgs)*dtp < cxmin ) THEN
17562
17563 crfrz(mgs) = 0.0
17564 qrfrz(mgs) = 0.0
17565 qrfrzf(mgs) = 0.0
17566
17567 ELSE !{
17568
17569
17570 IF ( ipconc >= 6 .and. lzr > 1 ) THEN
17571 ! interpolate along x, i.e., ratio;
17572 tmp1 = ziacrratio(i,j) + delx*dqiacrratioinv*(ziacrratio(ip1,j) - ziacrratio(i,j))
17573 tmp2 = ziacrratio(i,jp1) + delx*dqiacrratioinv*(ziacrratio(ip1,jp1) - ziacrratio(i,jp1))
17574
17575 ! interpolate along alpha;
17576
17577 zrfrz(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*zx(mgs,lr)*dtpinv
17578 ENDIF
17579
17580 IF ( ibiggsmallrain > 0 .and. xv(mgs,lr) < 2.*xvmn(lr) .and. ( ibiggsnow == 1 .or. ibiggsnow == 3 ) ) THEN
17581! IF ( ibiggsmallrain > 0 .and. xv(mgs,lr) < xvbiggsnow .and. ( ibiggsnow == 1 .or. ibiggsnow == 3 ) ) THEN
17582 ! rain drops are so small that they cannot be pushed smaller, so put into snow (or cloud ice, depending on ifrzs)
17583 crfrzf(mgs) = 0.0
17584 qrfrzf(mgs) = 0.0
17585 crfrzs(mgs) = crfrz(mgs)
17586 qrfrzs(mgs) = qrfrz(mgs)
17587
17588 IF ( ipconc >= 6 .and. lzr > 1 ) THEN
17589 zrfrzs(mgs) = zrfrz(mgs)
17590 zrfrzf(mgs) = 0.
17591 ENDIF
17592 ELSEIF ( dbigg < max( biggsnowdiam, max(dfrz,dhmn)) .and. ( ibiggsnow == 1 .or. ibiggsnow == 3 ) ) THEN ! { convert some to snow or ice crystals
17593 ! temporarily store qrfrz and crfrz in snow terms and caclulate new crfrzf, qrfrzf, and zrfrzf. Leave crfrz etc. alone!
17594
17595 crfrzs(mgs) = crfrz(mgs)
17596 qrfrzs(mgs) = qrfrz(mgs)
17597
17598 IF ( ibiggsmallrain > 0 .and. xv(mgs,lr) < 1.2*xvmn(lr) ) THEN
17599 ! rain drops are so small that they cannot be pushed smaller, so put into snow (or cloud ice, depending on ifrzs)
17600 crfrzf(mgs) = 0.0
17601 qrfrzf(mgs) = 0.0
17602
17603 IF (ipconc >= 6 .and. lzr > 1 ) THEN
17604 zrfrzs(mgs) = zrfrz(mgs)
17605 zrfrzf(mgs) = 0.
17606 ENDIF
17607 ELSE !{
17608
17609 ! recalculate using dhmn for ratio
17610 ratio = min( maxratiolu, max(dfrz,dhmn)/xdia(mgs,lr,1) )
17611
17612 i = min(nqiacrratio,int(ratio*dqiacrratioinv))
17613! j = Int(Max(0.0,Min(15.,alpha(mgs,lr)))*dqiacralphainv)
17614! j = Int(Max(alphamin,Min(alphamax,alpha(mgs,lr)))*dqiacralphainv)
17615 IF ( alp0flag ) THEN
17616 j = int(max(0.0,min(15.,alpha(mgs,lr)))*dqiacralphainv)
17617 ELSE
17618 j = int(max(minalphalu,min(maxalphalu,alpha(mgs,lr)))*dqiacralphainv)
17619 ENDIF
17620 delx = ratio - float(i)*dqiacrratio
17621 dely = alpha(mgs,lr) - float(j)*dqiacralpha
17622 ip1 = min( i+1, nqiacrratio )
17623 jp1 = min( j+1, nqiacralpha )
17624
17625 ! interpolate along x, i.e., ratio;
17626 tmp1 = ciacrratio(i,j) + delx*dqiacrratioinv*(ciacrratio(ip1,j) - ciacrratio(i,j))
17627 tmp2 = ciacrratio(i,jp1) + delx*dqiacrratioinv*(ciacrratio(ip1,jp1) - ciacrratio(i,jp1))
17628
17629
17630 ! interpolate along alpha;
17631
17632 crfrzf(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*cx(mgs,lr)*dtpinv
17633
17634 ! interpolate along x, i.e., ratio;
17635 tmp1 = qiacrratio(i,j) + delx*dqiacrratioinv*(qiacrratio(ip1,j) - qiacrratio(i,j))
17636 tmp2 = qiacrratio(i,jp1) + delx*dqiacrratioinv*(qiacrratio(ip1,jp1) - qiacrratio(i,jp1))
17637
17638 ! interpolate along alpha;
17639
17640 qrfrzf(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*qx(mgs,lr)*dtpinv
17641
17642 ! now subtract off the difference
17643 crfrzs(mgs) = crfrzs(mgs) - crfrzf(mgs)
17644 qrfrzs(mgs) = qrfrzs(mgs) - qrfrzf(mgs)
17645
17646 IF ( ipconc >= 6 .and. lzr > 1 ) THEN
17647 zrfrzs(mgs) = zrfrz(mgs)
17648 ! interpolate along x, i.e., ratio;
17649 tmp1 = ziacrratio(i,j) + delx*dqiacrratioinv*(ziacrratio(ip1,j) - ziacrratio(i,j))
17650 tmp2 = ziacrratio(i,jp1) + delx*dqiacrratioinv*(ziacrratio(ip1,jp1) - ziacrratio(i,jp1))
17651
17652 ! interpolate along alpha;
17653
17654 zrfrzf(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*zx(mgs,lr)*dtpinv
17655 zrfrzs(mgs) = zrfrzs(mgs) - zrfrzf(mgs)
17656 zrfrzf(mgs) = (1000./900.)**2*zrfrzf(mgs)
17657 ENDIF
17658 ENDIF ! }
17659 ELSE
17660 crfrzs(mgs) = 0.0
17661 qrfrzs(mgs) = 0.0
17662 zrfrzs(mgs) = 0.0
17663 ENDIF ! }
17664
17665 ENDIF !}
17666
17667 IF ( (qrfrz(mgs))*dtp > qx(mgs,lr) ) THEN
17668 fac = ( qrfrz(mgs) )*dtp/qx(mgs,lr)
17669 qrfrz(mgs) = fac*qrfrz(mgs)
17670 qrfrzs(mgs) = fac*qrfrzs(mgs)
17671 qrfrzf(mgs) = fac*qrfrzf(mgs)
17672 crfrz(mgs) = fac*crfrz(mgs)
17673 crfrzs(mgs) = fac*crfrzs(mgs)
17674 crfrzf(mgs) = fac*crfrzf(mgs)
17675 IF ( ipconc >= 6 .and. lzr > 1 ) THEN
17676 zrfrz(mgs) = fac*zrfrz(mgs)
17677 zrfrzf(mgs) = fac*zrfrzf(mgs)
17678 ENDIF
17679 ENDIF
17680
17681 ENDIF !}
17682
17683! IF ( (crfrzs(mgs) + crfrz(mgs))*dtp > cx(mgs,lr) ) THEN
17684! fac = ( crfrzs(mgs) + crfrz(mgs) )*dtp/cx(mgs,lr)
17685! crfrz(mgs) = fac*crfrz(mgs)
17686! crfrzs(mgs) = fac*crfrzs(mgs)
17687! ENDIF
17688
17689! qrfrzf(mgs) = qrfrz(mgs)
17690! crfrzf(mgs) = crfrz(mgs)
17691
17692 ! qrfrz(mgs) = qrfrzf(mgs) + qrfrzs(mgs)
17693 ! crfrz(mgs) = crfrzf(mgs) + crfrzs(mgs)
17694
17695
17696 ELSEIF ( ibiggopt == 1 ) THEN
17697 ! Z85, eq. A34
17698 tmp = xv(mgs,lr)*brz*cx(mgs,lr)*(exp(max( -arz*temcg(mgs), 0.0 )) - 1.0)
17699 IF ( .false. .and. tmp .gt. cxmxd(mgs,lr) ) THEN ! {
17700! write(iunit,*) 'Bigg Freezing problem!',mgs,igs(mgs),kgs(mgs)
17701! write(iunit,*) 'tmp, cx(lr), xv = ',tmp, cx(mgs,lr), xv(mgs,lr), (Exp(Max( -arz*temcg(mgs), 0.0 )) - 1.0)
17702! write(iunit,*) 'qr,temcg = ',qx(mgs,lr)*1000.,temcg(mgs)
17703 crfrz(mgs) = cxmxd(mgs,lr) ! cx(mgs,lr)*dtpinv
17704 qrfrz(mgs) = qxmxd(mgs,lr) ! qx(mgs,lr)*dtpinv
17705! STOP
17706 ELSE ! } {
17707 crfrz(mgs) = tmp
17708 ! crfrzfmx = cx(mgs,lr)*Exp(-4./3.*pi*(40.e-6)**3/xv(mgs,lr))
17709 ! IF ( crfrz(mgs) .gt. crfrzmx ) THEN
17710 ! crfrz(mgs) = crfrzmx
17711 ! qrfrz(mgs) = bfnu*xmas(mgs,lr)*rhoinv(mgs)*crfrzmx
17712 ! qwcnr(mgs) = cx(mgs,lr) - crfrzmx
17713 ! ELSE
17714 IF ( lzr < 1 ) THEN
17715 IF ( imurain == 3 ) THEN
17716 bfnu = bfnu0
17717 ELSE !imurain == 1
17718 bfnu = bfnu1
17719 ENDIF
17720 ELSE
17721 ! bfnu = 1.0 ! (alpha(mgs,lr)+2.0)/(alpha(mgs,lr)+1.)
17722 IF ( imurain == 3 ) THEN
17723 bfnu = (alpha(mgs,lr)+2.0)/(alpha(mgs,lr)+1.)
17724 ELSE !imurain == 1
17725! bfnu = bfnu1
17726 bfnu = (4. + alpha(mgs,lr))*(5. + alpha(mgs,lr))*(6. + alpha(mgs,lr))/ &
17727 & ((1. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(3. + alpha(mgs,lr)))
17728! bfnu = 1.
17729 ENDIF
17730 ENDIF
17731 qrfrz(mgs) = bfnu*xmas(mgs,lr)*rhoinv(mgs)*crfrz(mgs)
17732
17733 qrfrz(mgs) = min( qrfrz(mgs), 1.*qx(mgs,lr)*dtpinv ) ! qxmxd(mgs,lr)
17734 crfrz(mgs) = min( crfrz(mgs), 1.*cx(mgs,lr)*dtpinv ) !cxmxd(mgs,lr)
17735 qrfrz(mgs) = min( qrfrz(mgs), qx(mgs,lr) )
17736 qrfrzf(mgs) = qrfrz(mgs)
17737 ENDIF !}
17738
17739
17740
17741
17742 IF ( crfrz(mgs) .gt. qxmin(lh) ) THEN !{ Yes, it compares cx and qxmin, but this is just to be sure that
17743 ! crfrz is greater than zero in the division
17744! IF ( xdia(mgs,lr,1) .lt. 200.e-6 ) THEN
17745! IF ( xv(mgs,lr) .lt. xvmn(lh) ) THEN
17746
17747 IF ( (ibiggsnow == 1 .or. ibiggsnow == 3 ) .and. ibiggopt /= 2 ) THEN
17748 xvfrz = rho0(mgs)*qrfrz(mgs)/(crfrz(mgs)*900.) ! mean volume of frozen drops; 900. for frozen drop density
17749 frach = 0.5 *(1. + tanh(0.2e12 *( xvfrz - 1.15*xvmn(lh))))
17750
17751 qrfrzs(mgs) = (1.-frach)*qrfrz(mgs)
17752 crfrzs(mgs) = (1.-frach)*crfrz(mgs) ! *rzxh(mgs)
17753! qrfrzf(mgs) = frach*qrfrz(mgs)
17754
17755 ENDIF
17756
17757 IF ( ipconc .ge. 14 .and. 1.e-3*rho0(mgs)*qrfrz(mgs)/crfrz(mgs) .lt. xvmn(lh) ) THEN
17758 qrfrzs(mgs) = qrfrz(mgs)
17759 crfrzs(mgs) = crfrz(mgs) ! *rzxh(mgs)
17760 ELSE
17761! crfrz(mgs) = Min( crfrz(mgs), 0.1*cx(mgs,lr)*dtpinv ) ! cxmxd(mgs,lr)
17762! qrfrz(mgs) = Min( qrfrz(mgs), 0.1*qx(mgs,lr)*dtpinv ) ! qxmxd(mgs,lr)
17763 qrfrzf(mgs) = frach*qrfrz(mgs)
17764! crfrzf(mgs) = Min( qrfrz(mgs)*rho0(mgs)/(xdn(mgs,lh)*vgra), crfrz(mgs) )
17765 IF ( ibfr .le. 1 ) THEN
17766 crfrzf(mgs) = frach*min(crfrz(mgs), qrfrz(mgs)/(bfnu*1.0*vr1mm*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
17767 ELSEIF ( ibfr .eq. 5 ) THEN
17768 crfrzf(mgs) = frach*min(crfrz(mgs), qrfrz(mgs)/(bfnu*vfrz*1000.0)*rho0(mgs) )*rzxh(mgs) !*crfrz(mgs)
17769 ELSEIF ( ibfr .eq. 2 ) THEN
17770 crfrzf(mgs) = frach*min(crfrz(mgs), qrfrz(mgs)/(bfnu*vfrz*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
17771 ELSEIF ( ibfr .eq. 6 ) THEN
17772 crfrzf(mgs) = frach*max(crfrz(mgs), qrfrz(mgs)/(bfnu*9.*xv(mgs,lr)*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
17773 ELSE
17774 crfrzf(mgs) = frach*crfrz(mgs)
17775 ENDIF
17776! crfrzf(mgs) = Min(crfrz(mgs), qrfrz(mgs)/(bfnu*xvmn(lh)*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
17777! IF ( lz(lr) > 1 .and. lz(lh) > 1 ) THEN
17778! crfrzf(mgs) = crfrz(mgs)
17779! ENDIF
17780
17781 ENDIF
17782! crfrz(mgs) = Min( cxmxd(mgs,lr), rho0(mgs)*qrfrz(mgs)/xmas(mgs,lr) )
17783 ELSE
17784 crfrz(mgs) = 0.0
17785 qrfrz(mgs) = 0.0
17786 ENDIF !}
17787
17788 ENDIF ! ibiggopt
17789
17790 IF ( lvol(lh) .gt. 1 ) THEN
17791 vrfrzf(mgs) = rho0(mgs)*qrfrzf(mgs)/rhofrz
17792 ENDIF
17793
17794
17795 IF ( nsplinter .ne. 0 ) THEN
17796 IF ( nsplinter .ge. 1000 ) THEN
17797 ! Lawson et al. 2015 JAS
17798 ! ave. diam of freezing drops in microns
17799 tmp = 0
17800 IF ( qrfrz(mgs)*dtp > qxmin(lh) .and. crfrz(mgs) > 1.e-3 ) THEN
17801 tmpdiam = 1.e6*( 6.*qrfrz(mgs)/(1000.*pi*crfrz(mgs) ))**(1./3.) ! avg. diameter of newly frozen drops in microns
17802 tmp = lawson_splinter_fac*tmpdiam**4*crfrz(mgs)
17803 ENDIF
17804 ELSEIF ( nsplinter .gt. 0 ) THEN
17805 tmp = nsplinter*crfrz(mgs)
17806 ELSE
17807 tmp = -nsplinter*crfrzf(mgs)
17808 ENDIF
17809 csplinter2(mgs) = tmp
17810 qsplinter2(mgs) = min(0.1*qrfrz(mgs), tmp*splintermass/rho0(mgs) ) ! makes splinters smaller if too much mass is taken from graupel
17811
17812! csplinter(mgs) = csplinter(mgs) + tmp
17813! qsplinter(mgs) = qsplinter(mgs) + Min(0.1*qrfrz(mgs), tmp*splintermass/rho0(mgs) ) ! makes splinters smaller if too much mass is taken from graupel
17814 ENDIF
17815! IF ( temcg(mgs) .lt. -31.0 ) THEN
17816! qrfrz(mgs) = qx(mgs,lr)*dtpinv + qrcnw(mgs)
17817! qrfrzf(mgs) = qrfrz(mgs)
17818! crfrz(mgs) = cx(mgs,lr)*dtpinv + crcnw(mgs)
17819! crfrzf(mgs) = Min(crfrz(mgs), qrfrz(mgs)/(bfnu*1.0*vr1mm*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
17820! ENDIF
17821! qrfrz(mgs) = 6.0*xdn(mgs,lr)*xv(mgs,lr)**2*tmp*rhoinv(mgs)
17822! qrfrz(mgs) = Min( qrfrz(mgs), ffrz*qrmxd(mgs) )
17823! crfrz(mgs) = Min( crmxd(mgs), ffrz*crfrz(mgs))
17824! crfrz(mgs) = Min(crmxd(mgs),qrfrz(mgs)*rho0(mgs)/xmas(mgs,lr))
17825 ENDIF
17826! if ( temg(mgs) .gt. 268.15 ) then
17827 else
17828! end if
17829 end if
17830 end do
17831
17832 ENDIF
17833!
17834! Homogeneous freezing of cloud drops to ice crystals
17835! following Bigg (1953) and Ferrier (1994).
17836!
17837 if (ndebug .gt. 0 ) write(0,*) 'conc 25b'
17838 do mgs = 1,ngscnt
17839 qwfrz(mgs) = 0.0
17840 cwfrz(mgs) = 0.0
17841 qwfrzc(mgs) = 0.0
17842 cwfrzc(mgs) = 0.0
17843 qwfrzp(mgs) = 0.0
17844 cwfrzp(mgs) = 0.0
17845 IF ( ibfc .ge. 1 .and. ibfc /= 3 .and. temg(mgs) < 268.15 ) THEN
17846! if ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. 1. .and. &
17847! & .not. (ipconc .ge. 2 .and. xdia(mgs,lc,1) .lt. 10.e-6) ) then
17848 if ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. cxmin ) THEN
17849 IF ( ipconc < 2 ) THEN
17850 qwfrz(mgs) = ((2.0)*(brz)/(xdn(mgs,lc)*cx(mgs,lc))) &
17851 & *(exp(max(-arz*temcg(mgs), 0.0))-1.0) &
17852 & *rho0(mgs)*(qx(mgs,lc)**2)
17853 qwfrz(mgs) = max(qwfrz(mgs), 0.0)
17854 qwfrz(mgs) = min(qwfrz(mgs),qcmxd(mgs))
17855 cwfrz(mgs) = qwfrz(mgs)*rho0(mgs)/xmas(mgs,li)
17856 ELSEIF ( ipconc .ge. 2 ) THEN
17857 IF ( xdia(mgs,lc,3) > 0.e-6 ) THEN
17858 volt = exp( 16.2 + 1.0*temcg(mgs) )* 1.0e-6 ! Ts == -temcg ; volt comes from the fit in Fig. 1 in Bigg 1953
17859 ! for mean temperature for freezing: -ln (V) = a*Ts - b
17860 ! volt is given in cm**3, so factor of 1.e-6 to convert to m**3
17861! dbigg = (6./pi* volt )**(1./3.)
17862
17863 IF ( alpha(mgs,lc) == 0.0 ) THEN
17864 cwfrz(mgs) = cx(mgs,lc)*exp(-volt/xv(mgs,lc))*dtpinv ! number of droplets with volume greater than volt
17865!turn off limit so that all can freeze at low temp
17866!!! cwfrz(mgs) = Min(cwfrz(mgs),ccmxd(mgs))
17867
17868 qwfrz(mgs) = cwfrz(mgs)*xdn0(lc)*rhoinv(mgs)*(volt + xv(mgs,lc))
17869 ELSE
17870 ratio = (1. + alpha(mgs,lc))*volt/xv(mgs,lc)
17871
17872 IF ( .false. .and. usegamxinfcnu ) THEN
17873 i = nint(dgami*(1. + alpha(mgs,lc)))
17874 gcnup1 = gmoi(i)
17875 i = nint(dgami*(2. + alpha(mgs,lc)))
17876 gcnup2 = gmoi(i)
17877
17878 cwfrz(mgs) = cx(mgs,lc)*gamxinf(1.+alpha(mgs,lc), ratio)/(dtp*gcnup1) ! gamxinflu(i,j,1,1)
17879
17880 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)
17881
17882 ELSE
17883
17884 ratio = min( maxratiolu, ratio )
17885! write(0,*) 'cwfrz: temp,ratio = ',temcg(mgs),ratio
17886! write(0,*) 'cwfrz: xv,volt,qx = ',xv(mgs,lc),volt,qx(mgs,lc)
17887! write(0,*) 'cwfrz: i,j,k = ',igs(mgs),jgs,kgs(mgs)
17888 tmp = gaminterp(ratio,alpha(mgs,lc),1,1)
17889! write(0,*) 'cwfrz: tmp1 = ',tmp
17890 cwfrz(mgs) = cx(mgs,lc)*tmp*dtpinv ! Gamxinf(1.+alpha(mgs,lc), ratio)/(dtp*gcnup1) ! gamxinflu(i,j,1,1)
17891
17892 tmp = gaminterp(ratio,alpha(mgs,lc),12,1)
17893! write(0,*) 'cwfrz: tmp2 = ',tmp
17894 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)
17895
17896 ENDIF
17897
17898 ENDIF
17899
17900 ENDIF
17901 ENDIF
17902 if ( temg(mgs) .gt. 268.15 ) then
17903 qwfrz(mgs) = 0.0
17904 cwfrz(mgs) = 0.0
17905 end if
17906 end if
17907 ENDIF
17908!
17909 if ( xplate(mgs) .eq. 1 ) then
17910 qwfrzp(mgs) = qwfrz(mgs)
17911 cwfrzp(mgs) = cwfrz(mgs)
17912 end if
17913!
17914 if ( xcolmn(mgs) .eq. 1 ) then
17915 qwfrzc(mgs) = qwfrz(mgs)
17916 cwfrzc(mgs) = cwfrz(mgs)
17917 end if
17918
17919!
17920! qwfrzp(mgs) = 0.0
17921! qwfrzc(mgs) = qwfrz(mgs)
17922!
17923 end do
17924!
17925!
17926! Contact freezing nucleation: factor is to convert from L-1
17927! T < -2C: via Meyers et al. JAM July, 1992 (31, 708-721)
17928!
17929 if (ndebug .gt. 0 ) write(0,*) 'conc 25a'
17930 do mgs = 1,ngscnt
17931
17932 ccia(mgs) = 0.0
17933
17934 cwctfz(mgs) = 0.0
17935 qwctfz(mgs) = 0.0
17936 ctfzbd(mgs) = 0.0
17937 ctfzth(mgs) = 0.0
17938 ctfzdi(mgs) = 0.0
17939
17940 cwctfzc(mgs) = 0.0
17941 qwctfzc(mgs) = 0.0
17942 cwctfzp(mgs) = 0.0
17943 qwctfzp(mgs) = 0.0
17944 IF ( icfn .ge. 1 ) THEN
17945
17946 IF ( temg(mgs) .lt. 271.15 .and. qx(mgs,lc) .gt. qxmin(lc)) THEN
17947
17948! find available # of ice nuclei & limit value to max depletion of cloud water
17949
17950 IF ( icfn .ge. 2 ) THEN
17951 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)
17952 !ccia(mgs) = Min(cwctfz(mgs), ccmxd(mgs) )
17953
17954! now find how many of these collect cloud water to form IN
17955! Cotton et al 1986
17956
17957 knud(mgs) = 2.28e-5 * temg(mgs) / ( pres(mgs)*raero ) !Walko et al. 1995
17958 knuda(mgs) = 1.257 + 0.4*exp(-1.1/knud(mgs)) !Pruppacher & Klett 1997 eqn 11-16
17959 gtp(mgs) = 1. / ( fai(mgs) + fbi(mgs) ) !Byers 65 / Cotton 72b
17960 dfar(mgs) = kb*temg(mgs)*(1.+knuda(mgs)*knud(mgs))/(6.*pi*fadvisc(mgs)*raero) !P&K 1997 eqn 11-15
17961 fn1(mgs) = 2.*pi*xdia(mgs,lc,1)*cx(mgs,lc)*ccia(mgs)
17962 fn2(mgs) = -gtp(mgs)*(ssw(mgs)-1.)*felv(mgs)/pres(mgs)
17963 fnft(mgs) = 0.4*(1.+1.45*knud(mgs)+0.4*knud(mgs)*exp(-1./knud(mgs)))*(ftka(mgs)+2.5*knud(mgs)*kaero) &
17964 & / ( (1.+3.*knud(mgs))*(2*ftka(mgs)+5.*knud(mgs)*kaero+kaero) )
17965
17966
17967! Brownian diffusion
17968 ctfzbd(mgs) = fn1(mgs)*dfar(mgs)
17969
17970! Thermophoretic contact nucleation
17971 ctfzth(mgs) = fn1(mgs)*fn2(mgs)*fnft(mgs)/rho0(mgs)
17972
17973! Diffusiophoretic contact nucleation
17974 ctfzdi(mgs) = fn1(mgs)*fn2(mgs)*rw*temg(mgs)/(felv(mgs)*rho0(mgs))
17975
17976 cwctfz(mgs) = max( ctfzbd(mgs) + ctfzth(mgs) + ctfzdi(mgs) , 0.)
17977
17978! Sum of the contact nucleation processes
17979! IF ( cx(mgs,lc) .gt. 1.e6) write(0,*) 'ctfzbd,etc = ',cwctfz(mgs),ctfzbd(mgs),ctfzth(mgs),ctfzdi(mgs)
17980! IF ( wvel(mgs) .lt. -0.05 ) write(6,*) 'ctfzbd,etc = ',ctfzbd(mgs),ctfzth(mgs),ctfzdi(mgs),cx(mgs,lc)*1e-6,wvel(mgs)
17981! IF ( ssw(mgs) .lt. 1.0 .and. cx(mgs,lc) .gt. 1.e6 .and. cwctfz(mgs) .gt. 1. ) THEN
17982! write(6,*) 'ctfzbd,etc = ',ctfzbd(mgs),ctfzth(mgs),ctfzdi(mgs),cx(mgs,lc)*1e-6,wvel(mgs),fn1(mgs),fn2(mgs)
17983! write(6,*) 'more = ',nstep,ssw(mgs),dfar(mgs),gtp(mgs),felv(mgs),pres(mgs)
17984! ENDIF
17985
17986 ELSEIF ( icfn .eq. 1 ) THEN
17987 IF ( wvel(mgs) .lt. -0.05 ) THEN ! older kludgy version
17988 cwctfz(mgs) = cfnfac*exp( (-2.80) - (0.262)*temcg(mgs) )
17989 cwctfz(mgs) = min((1.0e3)*cwctfz(mgs), ccmxd(mgs) ) !convert to m-3
17990 ENDIF
17991 ENDIF ! icfn
17992
17993 IF ( ipconc .ge. 2 ) THEN
17994 cwctfz(mgs) = min( cwctfz(mgs)*dtpinv, ccmxd(mgs) )
17995 qwctfz(mgs) = xmas(mgs,lc)*cwctfz(mgs)/rho0(mgs)
17996 ELSE
17997 qwctfz(mgs) = (cimasn)*cwctfz(mgs)/(dtp*rho0(mgs))
17998 qwctfz(mgs) = max(qwctfz(mgs), 0.0)
17999 qwctfz(mgs) = min(qwctfz(mgs),qcmxd(mgs))
18000 ENDIF
18001
18002!
18003 if ( xplate(mgs) .eq. 1 ) then
18004 qwctfzp(mgs) = qwctfz(mgs)
18005 cwctfzp(mgs) = cwctfz(mgs)
18006 end if
18007!
18008 if ( xcolmn(mgs) .eq. 1 ) then
18009 qwctfzc(mgs) = qwctfz(mgs)
18010 cwctfzc(mgs) = cwctfz(mgs)
18011 end if
18012
18013! IF ( cwctfz(mgs)*dtp > 0.5 .and. dtp*qwctfz(mgs) > qxmin(li) ) THEN
18014! write(91,*) 'cwctfz: ',cwctfz(mgs),qwctfz(mgs) ! ,cwctfzc(mgs),qwctfzc(mgs)
18015! ENDIF
18016
18017!
18018! qwctfzc(mgs) = qwctfz(mgs)
18019! qwctfzp(mgs) = 0.0
18020!
18021 end if
18022
18023 ENDIF ! icfn
18024
18025 end do
18026!
18027!
18028!
18029! Hobbs-Rangno ice enhancement (Ferrier, 1994)
18030!
18031 if (ndebug .gt. 0 ) write(0,*) 'conc 23a'
18032 dthr = 300.0
18033 hrifac = (1.e-3)*((0.044)*(0.01**3))
18034 do mgs = 1,ngscnt
18035 ciihr(mgs) = 0.0
18036 qiihr(mgs) = 0.0
18037 cicichr(mgs) = 0.0
18038 qicichr(mgs) = 0.0
18039 cipiphr(mgs) = 0.0
18040 qipiphr(mgs) = 0.0
18041 IF ( ihrn .ge. 1 ) THEN
18042 if ( qx(mgs,lc) .gt. qxmin(lc) ) then
18043 if ( temg(mgs) .lt. 273.15 ) then
18044! write(iunit,'(3(1x,i3),3(1x,1pe12.5))')
18045! : igs(mgs),jgs,kgs(mgs),cx(mgs,lc),rho0(mgs),qx(mgs,lc)
18046! write(iunit,'(1pe15.6)')
18047! : log(cx(mgs,lc)*(1.e-6)/(3.0)),
18048! : ((1.e-3)*rho0(mgs)*qx(mgs,lc)),
18049! : (cx(mgs,lc)*(1.e-6)),
18050! : ((1.e-3)*rho0(mgs)*qx(mgs,lc))/(cx(mgs,lc)*(1.e-6)),
18051! : (alog(cx(mgs,lc)*(1.e-6)/(3.0)) *
18052! > ((1.e-3)*rho0(mgs)*qx(mgs,lc))/(cx(mgs,lc)*(1.e-6)))
18053
18054 IF ( log(cx(mgs,lc)*(1.e-6)/(3.0)) .gt. 0.0 ) THEN
18055 ciihr(mgs) = ((1.69e17)/dthr) &
18056 & *(log(cx(mgs,lc)*(1.e-6)/(3.0)) * &
18057 & ((1.e-3)*rho0(mgs)*qx(mgs,lc))/(cx(mgs,lc)*(1.e-6)))**(7./3.)
18058 ciihr(mgs) = ciihr(mgs)*(1.0e6)
18059 qiihr(mgs) = hrifac*ciihr(mgs)/rho0(mgs)
18060 qiihr(mgs) = max(qiihr(mgs), 0.0)
18061 qiihr(mgs) = min(qiihr(mgs),qcmxd(mgs))
18062 ENDIF
18063!
18064 if ( xplate(mgs) .eq. 1 ) then
18065 qipiphr(mgs) = qiihr(mgs)
18066 cipiphr(mgs) = ciihr(mgs)
18067 end if
18068!
18069 if ( xcolmn(mgs) .eq. 1 ) then
18070 qicichr(mgs) = qiihr(mgs)
18071 cicichr(mgs) = ciihr(mgs)
18072 end if
18073!
18074! qipiphr(mgs) = 0.0
18075! qicichr(mgs) = qiihr(mgs)
18076!
18077 end if
18078 end if
18079 ENDIF ! ihrn
18080 end do
18081!
18082!
18083!
18084! simple frozen rain to hail conversion. All of the
18085! frozen rain larger than 5.0e-3 m in diameter are converted
18086! to hail. This is done by considering the equation for
18087! frozen rain mixing ratio:
18088!
18089!
18090! qfw = [ cno(lf) * pi * fwdn / (6 rhoair) ]
18091!
18092! /inf
18093! * | fwdia*3 exp(-dia/fwdia) d(dia)
18094! /Do
18095!
18096! The amount to be reclassified as hail is the integral above from
18097! Do to inf where Do is 5.0e-3 m.
18098!
18099!
18100! qfauh = [ cno(lf) * pi * fwdn / (6 rhoair) ]
18101!
18102!
18103
18104
18105 hdia0 = 300.0e-6
18106 do mgs = 1,ngscnt
18107 qscnvi(mgs) = 0.0
18108 cscnvi(mgs) = 0.0
18109 cscnvis(mgs) = 0.0
18110! IF ( .false. ) THEN
18111! IF ( temg(mgs) .lt. tfr .and. ssi(mgs) .gt. 1.01 .and. qx(mgs,li) .gt. qxmin(li) ) THEN
18112 IF ( temg(mgs) .lt. tfr .and. qx(mgs,li) .gt. qxmin(li) ) THEN
18113 IF ( ipconc .ge. 4 .and. .false. ) THEN
18114 if ( cx(mgs,li) .gt. 10. .and. xdia(mgs,li,1) .gt. 50.e-6 ) then !{
18115 cirdiatmp = &
18116 & (qx(mgs,li)*rho0(mgs) &
18117 & /(pi*xdn(mgs,li)*cx(mgs,li)))**(1./3.)
18118 IF ( cirdiatmp .gt. 100.e-6 ) THEN !{
18119 qscnvi(mgs) = &
18120 & ((pi*xdn(mgs,li)*cx(mgs,li)) / (6.0*rho0(mgs)*dtp)) &
18121 & *exp(-hdia0/cirdiatmp) &
18122 & *( (hdia0**3) + 3.0*(hdia0**2)*cirdiatmp &
18123 & + 6.0*(hdia0)*(cirdiatmp**2) + 6.0*(cirdiatmp**3) )
18124 qscnvi(mgs) = &
18125 & min(qscnvi(mgs),qimxd(mgs))
18126 IF ( ipconc .ge. 4 ) THEN
18127 cscnvi(mgs) = min( cimxd(mgs), cx(mgs,li)*exp(-hdia0/cirdiatmp))
18128 ENDIF
18129 ENDIF ! }
18130 end if ! }
18131
18132 ELSEIF ( ipconc .lt. 4 ) THEN
18133
18134 qscnvi(mgs) = 0.001*eii(mgs)*max((qx(mgs,li)-1.e-3),0.0)
18135 qscnvi(mgs) = min(qscnvi(mgs),qxmxd(mgs,li))
18136 cscnvi(mgs) = qscnvi(mgs)*rho0(mgs)/xmas(mgs,li)
18137 cscnvis(mgs) = 0.5*cscnvi(mgs)
18138
18139 ENDIF
18140 ENDIF
18141! ENDIF
18142 end do
18143
18144
18145
18146!
18147! Ventilation coeficients
18148!
18149 do mgs = 1,ngscnt
18150 fvent(mgs) = (fschm(mgs)**(1./3.)) * (fakvisc(mgs)**(-0.5))
18151 end do
18152!
18153!
18154 if ( ndebug .gt. 0 ) write(0,*) 'civent'
18155!
18156 civenta = 1.258e4
18157 civentb = 2.331
18158 civentc = 5.662e4
18159 civentd = 2.373
18160 civente = 0.8241
18161 civentf = -0.042
18162 civentg = 1.70
18163
18164 do mgs = 1,ngscnt
18165 IF ( icond .eq. 1 .or. temg(mgs) .le. tfrh &
18166 & .or. (qx(mgs,lr) .le. qxmin(lr) .and. qx(mgs,lc) .le. qxmin(lc)) ) THEN
18167 IF ( qx(mgs,li) .gt. qxmin(li) ) THEN
18168 cireyn = &
18169 & (civenta*xdia(mgs,li,1)**civentb &
18170 & +civentc*xdia(mgs,li,1)**civentd) &
18171 & / &
18172 & (civente*xdia(mgs,li,1)**civentf+civentg)
18173 xcivent = (fschm(mgs)**(1./3.))*((cireyn/fakvisc(mgs))**0.5)
18174 if ( xcivent .lt. 1.0 ) then
18175 civent(mgs) = 1.0 + 0.14*xcivent**2
18176 end if
18177 if ( xcivent .ge. 1.0 ) then
18178 civent(mgs) = 0.86 + 0.28*xcivent
18179 end if
18180 ELSE
18181 civent(mgs) = 0.0
18182 ENDIF
18183
18184
18185 ENDIF ! icond .eq. 1
18186 end do
18187
18188!
18189!
18190 igmrwa = 100.0*2.0
18191 igmrwb = 100.*((5.0+br)/2.0)
18192 rwventa = (0.78)*gmoi(igmrwa) ! 0.78
18193 rwventb = (0.308)*gmoi(igmrwb) ! 0.562825
18194 do mgs = 1,ngscnt
18195 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
18196 IF ( ipconc .ge. 3 ) THEN
18197 IF ( imurain == 3 ) THEN
18198 IF ( izwisventr == 1 ) THEN
18199 rwvent(mgs) = ventrx(mgs)*(1.6 + 124.9*(1.e-3*rho0(mgs)*qx(mgs,lr))**.2046)
18200 ELSE ! izwisventr = 2
18201! 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
18202 rwvent(mgs) = &
18203 & (0.78*ventrx(mgs) + 0.308*ventrxn(mgs)*fvent(mgs) &
18204 & *sqrt((ar*rhovt(mgs))) &
18205 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
18206 ENDIF
18207
18208 ELSE ! imurain == 1
18209 ! linear interpolation of complete gamma function
18210! tmp = 2. + alpha(mgs,lr)
18211! i = Int(dgami*(tmp))
18212! del = tmp - dgam*i
18213! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18214
18215 IF ( iferwisventr == 1 ) THEN
18216
18217 ! Ferrier fall speed in the ventillation term [uses fx(lr) ]
18218
18219 alpr = min(alpharmax,alpha(mgs,lr) )
18220
18221 x = 1. + alpha(mgs,lr)
18222
18223 IF ( ipconc >= 6 .and. lzr > 1 ) THEN ! 3 moment
18224 tmp = 1. + alpr ! alpha(mgs,lr)
18225 i = int(dgami*(tmp))
18226 del = tmp - dgam*i
18227 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18228
18229 tmp = 2.5 + alpha(mgs,lr) + 0.5*bx(lr)
18230 i = int(dgami*(tmp))
18231 del = tmp - dgam*i
18232 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp ! ratio of gamma functions
18233 ELSE
18234 y = ventrxn(mgs)
18235 ENDIF
18236
18237! vent1 = dble(xdia(mgs,lr,1))**(-2. - alpr) ! Actually OK
18238! vent2 = dble(1./xdia(mgs,lr,1) + 0.5*fx(lr))**dble(2.5+alpr+0.5*bx(lr)) ! Actually OK
18239 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)
18240 vent2 = dble(1. + 0.5*fx(lr)*xdia(mgs,lr,1))**dble(2.5+alpr+0.5*bx(lr))
18241
18242
18243 rwvent(mgs) = &
18244 & 0.78*x + &
18245 & 0.308*fvent(mgs)*y* &
18246 & sqrt(ax(lr)*rhovt(mgs))*(vent1/vent2)
18247
18248 rwventz(mgs) = 0.0
18249
18250! rwventz(mgs) = &
18251! & 0.78*x + &
18252! & 0.308*fvent(mgs)*y* &
18253! & Sqrt(ax(lr)*rhovt(mgs))*(vent1/vent2)
18254
18255
18256 ELSEIF ( iferwisventr == 2 ) THEN
18257
18258! 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
18259 x = 1. + alpha(mgs,lr)
18260
18261 rwvent(mgs) = &
18262 & (0.78*x + 0.308*ventrxn(mgs)*fvent(mgs) &
18263 & *sqrt((ar*rhovt(mgs))) &
18264 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
18265
18266
18267 IF ( ipconc >= 7 ) THEN
18268 alpr = min(alpharmax,alpha(mgs,lr) )
18269
18270 tmp = alpr + 5.5 + br/2.
18271 i = int(dgami*(tmp))
18272 del = tmp - dgam*i
18273 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18274
18275! rwventz(mgs) = &
18276! & 0.78*(4. + alpha(mgs,lr))*(3. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(1. + alpha(mgs,lr)) + &
18277 rwventz(mgs) = &
18278 & 0.78*(4. + alpr)*(3. + alpr)*(2. + alpr)*(1. + alpr) + &
18279 & 0.308*fvent(mgs)* &
18280 & sqrt(ax(lr)*rhovt(mgs))*(y/gf1palp(mgs))*(xdia(mgs,lr,1)**((1.0+br)/2.0))
18281
18282 ENDIF
18283
18284
18285 ENDIF ! iferwisventr
18286
18287 ENDIF ! imurain
18288 ELSE
18289 rwvent(mgs) = &
18290 & (rwventa + rwventb*fvent(mgs) &
18291 & *sqrt((ar*rhovt(mgs))) &
18292 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
18293 ENDIF
18294 ELSE
18295 rwvent(mgs) = 0.0
18296 ENDIF
18297 end do
18298!
18299 igmswa = 100.0*2.0
18300 igmswb = 100.*((5.0+ds)/2.0)
18301 swventa = (0.78)*gmoi(igmswa)
18302 swventb = (0.308)*gmoi(igmswb)
18303 do mgs = 1,ngscnt
18304 IF ( qx(mgs,ls) .gt. qxmin(ls) ) THEN
18305 IF ( ipconc .ge. 4 ) THEN
18306 swvent(mgs) = 0.65 + 0.44*fvent(mgs)*sqrt(vtxbar(mgs,ls,1)*xdia(mgs,ls,1))
18307 ELSE
18308! 10-ice version:
18309 swvent(mgs) = &
18310 & (swventa + swventb*fvent(mgs) &
18311 & *sqrt((cs*rhovt(mgs))) &
18312 & *(xdia(mgs,ls,1)**((1.0+ds)/2.0)) )
18313 ENDIF
18314 ELSE
18315 swvent(mgs) = 0.0
18316 ENDIF
18317 end do
18318!
18319!
18320
18321 igmhwa = 100.0*2.0
18322 igmhwb = 100.0*2.75
18323 hwventa = (0.78)*gmoi(igmhwa)
18324 hwventb = (0.308)*gmoi(igmhwb)
18325! hwventc = (4.0*gr/(3.0*cdx(lh)))**(0.25)
18326 hwvent(:) = 0.0
18327 hwventy(:) = 0.0
18328
18329 do mgs = 1,ngscnt
18330 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
18331 hwventc = (4.0*gr/(3.0*cdxgs(mgs,lh)))**(0.25)
18332 IF ( .false. .or. alpha(mgs,lh) .eq. 0.0 ) THEN
18333 hwvent(mgs) = &
18334 & ( hwventa + hwventb*hwventc*fvent(mgs) &
18335 & *((xdn(mgs,lh)/rho0(mgs))**(0.25)) &
18336 & *(xdia(mgs,lh,1)**(0.75)))
18337 ELSE ! Ferrier 1994, eq. B.36
18338 ! linear interpolation of complete gamma function
18339! tmp = 2. + alpha(mgs,lh)
18340! i = Int(dgami*(tmp))
18341! del = tmp - dgam*i
18342! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18343
18344! note that hwvent includes a division by Gamma(1+alpha), so Gamma(2+alpha)/Gamma(1+alpha) = 1 + alpha
18345! and g1palp = Gamma(1+alpha) divides into y
18346 x = 1. + alpha(mgs,lh)
18347
18348 tmp = 1 + alpha(mgs,lh)
18349 i = int(dgami*(tmp))
18350 del = tmp - dgam*i
18351 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18352
18353 tmp = 2.5 + alpha(mgs,lh) + 0.5*bxx(mgs,lh)
18354 i = int(dgami*(tmp))
18355 del = tmp - dgam*i
18356 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp
18357
18358
18359 hwventy(mgs) = 0.308*fvent(mgs)*(xdia(mgs,lh,1)**(0.5 + 0.5*bxx(mgs,lh)))*sqrt(axx(mgs,lh)*rhovt(mgs))
18360 hwvent(mgs) = &
18361 & ( 0.78*x + y*hwventy(mgs) ) ! &
18362! & 0.308*fvent(mgs)*y*(xdia(mgs,lh,1)**(0.5 + 0.5*bxx(mgs,lh)))* &
18363! & Sqrt(axx(mgs,lh)*rhovt(mgs)) )
18364
18365 ENDIF
18366 ELSE
18367 hwvent(mgs) = 0.0
18368 hwventy(mgs) = 0.0
18369 ENDIF
18370 end do
18371
18372
18373 hlvent(:) = 0.0
18374 hlventy(:) = 0.0
18375
18376 IF ( lhl .gt. 1 ) THEN
18377 igmhwa = 100.0*2.0
18378 igmhwb = 100.0*2.75
18379 hwventa = (0.78)*gmoi(igmhwa)
18380 hwventb = (0.308)*gmoi(igmhwb)
18381! hwventc = (4.0*gr/(3.0*cdx(lhl)))**(0.25)
18382 do mgs = 1,ngscnt
18383 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
18384 hwventc = (4.0*gr/(3.0*cdxgs(mgs,lhl)))**(0.25)
18385
18386 IF ( .false. .or. alpha(mgs,lhl) .eq. 0.0 ) THEN
18387 hlvent(mgs) = &
18388 & ( hwventa + hwventb*hwventc*fvent(mgs) &
18389 & *((xdn(mgs,lhl)/rho0(mgs))**(0.25)) &
18390 & *(xdia(mgs,lhl,1)**(0.75)))
18391 ELSE ! Ferrier 1994, eq. B.36
18392 ! linear interpolation of complete gamma function
18393! tmp = 2. + alpha(mgs,lhl)
18394! i = Int(dgami*(tmp))
18395! del = tmp - dgam*i
18396! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18397
18398! note that hlvent includes a division by Gamma(1+alpha), so x = Gamma(2+alpha)/Gamma(1+alpha) = 1 + alpha
18399! and g1palp = Gamma(1+alpha) divides into y
18400
18401 x = 1. + alpha(mgs,lhl)
18402
18403 tmp = 1 + alpha(mgs,lhl)
18404 i = int(dgami*(tmp))
18405 del = tmp - dgam*i
18406 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18407
18408 tmp = 2.5 + alpha(mgs,lhl) + 0.5*bxx(mgs,lhl)
18409 i = int(dgami*(tmp))
18410 del = tmp - dgam*i
18411 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp ! ratio of gamma functions
18412
18413 hlventy(mgs) = 0.308*fvent(mgs)*(xdia(mgs,lhl,1)**(0.5 + 0.5*bxx(mgs,lhl)))*sqrt(axx(mgs,lhl)*rhovt(mgs))
18414
18415 hlvent(mgs) = 0.78*x + y*hlventy(mgs) ! &
18416! & 0.308*fvent(mgs)*y*(xdia(mgs,lhl,1)**(0.5 + 0.5*bxx(mgs,lhl)))* &
18417! & Sqrt(axx(mgs,lhl)*rhovt(mgs)))
18418! : Sqrt(xdn(mgs,lhl)*ax(lhl)*rhovt(mgs)/rg0))/tmp
18419
18420 ENDIF
18421 ENDIF
18422 end do
18423 ENDIF
18424
18425!
18426!
18427!
18428! Wet growth constants
18429!
18430 do mgs = 1,ngscnt
18431 fwet1(mgs) = &
18432 & (2.0*pi)* &
18433 & ( felv(mgs)*fwvdf(mgs)*rho0(mgs)*(qss0(mgs)-qx(mgs,lv)) &
18434 & -ftka(mgs)*temcg(mgs) ) &
18435 & / ( rho0(mgs)*(felf(mgs)+fcw(mgs)*temcg(mgs)) )
18436 fwet2(mgs) = &
18437 & (1.0)-fci(mgs)*temcg(mgs) &
18438 & / ( felf(mgs)+fcw(mgs)*temcg(mgs) )
18439 end do
18440!
18441! Melting constants
18442!
18443 do mgs = 1,ngscnt
18444 fmlt1(mgs) = (2.0*pi)* &
18445 & ( felv(mgs)*fwvdf(mgs)*(qss0(mgs)-qx(mgs,lv)) &
18446 & -ftka(mgs)*temcg(mgs)/rho0(mgs) ) &
18447 & / (felf(mgs))
18448 fmlt2(mgs) = -fcw(mgs)*temcg(mgs)/felf(mgs)
18449 fmlt1e(mgs) = (2.0*pi)* &
18450 & ( felv(mgs)*fwvdf(mgs)*(qss0(mgs)-qx(mgs,lv)) ) / (felf(mgs))
18451 end do
18452!
18453! Vapor Deposition constants
18454!
18455 do mgs = 1,ngscnt
18456 fvds(mgs) = &
18457 & (4.0*pi/rho0(mgs))*(ssi(mgs)-1.0)* &
18458 & (1.0/(fai(mgs)+fbi(mgs)))
18459 end do
18460 do mgs = 1,ngscnt
18461 fvce(mgs) = &
18462 & (4.0*pi/rho0(mgs))*(ssw(mgs)-1.0)* &
18463 & (1.0/(fav(mgs)+fbv(mgs)))
18464 end do
18465
18466!
18467! deposition, sublimation, and melting of snow, graupel and hail
18468!
18469 qsmlr(:) = 0.0
18470 qimlr(:) = 0.0 ! this is not used. qi melts to qc way down in the code.
18471 qhmlr(:) = 0.0
18472 qhlmlr(:) = 0.0
18473 IF ( lhwlg > 1 ) THEN
18474 qhmlrlg(:) = 0.0
18475 qhlmlrlg(:) = 0.0
18476 ENDIF
18477 qhfzh(:) = 0.0
18478 qffzf(:) = 0.0
18479 qhlfzhl(:) = 0.0
18480 qhfzhlg(:) = 0.0
18481 qhlfzhllg(:) = 0.0
18482 vhfzh(:) = 0.0
18483 vffzf(:) = 0.0
18484 vhlfzhl(:) = 0.0
18485 qsfzs(:) = 0.0
18486! zsmlr(:) = 0.0
18487 zhmlr(:) = 0.0
18488 zhmlrr(:) = 0.0
18489 zsmlrr(:) = 0.0
18490 zhshr(:) = 0.0
18491 zhlmlr(:) = 0.0
18492 zhlshr(:) = 0.0
18493
18494 zhshrr(:) = 0.0
18495 zhlmlrr(:) = 0.0
18496 zhlshrr(:) = 0.0
18497
18498 csmlr(:) = 0.0
18499 csmlrr(:) = 0.0
18500 chmlr(:) = 0.0
18501 chmlrr(:) = 0.0
18502 chlmlr(:) = 0.0
18503 chlfmlr(:) = 0.0
18504! chlmlrsave(:) = 0.0
18505! qhlmlrsave(:) = 0.0
18506! chlsave(:) = 0.0
18507! qhlsave(:) = 0.0
18508 chlmlrr(:) = 0.0
18509
18510
18511 if ( .not. mixedphase ) then !{
18512 do mgs = 1,ngscnt
18513!
18514 IF ( temg(mgs) .gt. tfr ) THEN
18515
18516 IF ( qx(mgs,ls) .gt. qxmin(ls) ) THEN
18517 qsmlr(mgs) = &
18518 & min( &
18519 & (c1sw*fmlt1(mgs)*cx(mgs,ls)*swvent(mgs)*xdia(mgs,ls,1) ) & ! /rhosm &
18520 & , 0.0 )
18521 ENDIF
18522
18523
18524! IF ( qx(mgs,ls) .gt. 0.1e-4 ) write(0,*) 'qsmlr: ',qsmlr(mgs),qx(mgs,ls),cx(mgs,ls),fmlt1(mgs),
18525! : temcg(mgs),swvent(mgs),xdia(mgs,ls,1),qss0(mgs)-qx(mgs,lv)
18526! ELSE
18527! qsmlr(mgs) = 0.0
18528! ENDIF
18529! 10ice version:
18530! > min(
18531! > (fmlt1(mgs)*cx(mgs,ls)*swvent(mgs)*xdia(mgs,ls,1) +
18532! > fmlt2(mgs)*(qsacr(mgs)+qsacw(mgs)) )
18533! < , 0.0 )
18534
18535 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
18536
18537 IF ( ibinhmlr == 0 .or. lzh < 1 ) THEN
18538 qhmlr(mgs) = &
18539 & meltfac*min( &
18540 & fmlt1(mgs)*cx(mgs,lh)*hwvent(mgs)*xdia(mgs,lh,1) &
18541 & + fmlt2(mgs)*(qhacrmlr(mgs)+qhacwmlr(mgs)) &
18542 & , 0.0 )
18543 ELSEIF ( ibinhmlr == 1 ) THEN ! use incomplete gamma functions to approximate the bin results
18544
18545 errmsg = 'ibinhmlr = 1 not available for 2-moment'
18546 errflg = 1
18547 RETURN
18548
18549 ELSEIF ( ibinhmlr == 2 .or. ibinhmlr == 3 ) THEN
18550
18551 ENDIF
18552
18553
18554 IF ( ivhmltsoak > 0 .and. qhmlr(mgs) < 0.0 .and. lvol(lh) > 1 .and. xdn(mgs,lh) .lt. xdnmx(lh) ) THEN
18555 ! act as if 100% of the meltwater were soaked into the graupel
18556 v1 = (1. - xdn(mgs,lh)/xdnmx(lh))*(vx(mgs,lh) + rho0(mgs)*qhmlr(mgs)/xdn(mgs,lh) )/(dtp) ! volume available for filling
18557 v2 = -1.0*rho0(mgs)*qhmlr(mgs)/xdnmx(lh) ! volume of melted ice if it were refrozen in the matrix
18558
18559 vhsoak(mgs) = min(v1,v2)
18560
18561 ENDIF
18562
18563 ENDIF ! qx(mgs,lh) .gt. qxmin(lh)
18564
18565
18566 IF ( lhl .gt. 1 .and. lhlw < 1 ) THEN
18567
18568 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
18569 IF ( ibinhlmlr == 0 .or. lzhl < 1) THEN
18570 qhlmlr(mgs) = &
18571 & meltfac*min( &
18572 & fmlt1(mgs)*cx(mgs,lhl)*hlvent(mgs)*xdia(mgs,lhl,1) &
18573 & + fmlt2(mgs)*(qhlacrmlr(mgs)+qhlacwmlr(mgs)) &
18574 & , 0.0 )
18575
18576 ELSEIF ( ibinhlmlr == 1 ) THEN ! use incomplete gamma functions to approximate the bin results
18577
18578! #ifdef 1
18579! #if (defined 1) && defined( COMMAS ) || defined( COMMASTMP )
18580
18581 ELSEIF ( ibinhlmlr == -1 ) THEN ! OLD VERSION use incomplete gamma functions to approximate the bin results
18582
18583 ENDIF ! ibinhlmlr
18584
18585
18586 IF ( ivhmltsoak > 0 .and. qhlmlr(mgs) < 0.0 .and. lvol(lhl) > 1 .and. xdn(mgs,lhl) .lt. xdnmx(lhl) ) THEN
18587 ! act as if 50% of the meltwater were soaked into the graupel
18588 v1 = (1. - xdn(mgs,lhl)/xdnmx(lhl))*(vx(mgs,lhl) + rho0(mgs)*qhlmlr(mgs)/xdn(mgs,lhl) )/(dtp) ! volume available for filling
18589 v2 = -1.0*rho0(mgs)*qhlmlr(mgs)/xdnmx(lhl) ! volume of melted ice if it were refrozen in the matrix
18590
18591 vhlsoak(mgs) = min(v1,v2)
18592
18593 ENDIF
18594
18595 ENDIF
18596 ENDIF
18597
18598 ENDIF
18599
18600!
18601! qimlr(mgs) = max( qimlr(mgs), -qimxd(mgs) )
18602! qsmlr(mgs) = max( qsmlr(mgs), -qsmxd(mgs) )
18603! erm 5/10/2007 changed to next line:
18604 if ( .not. mixedphase ) qsmlr(mgs) = max( qsmlr(mgs), min( -qsmxd(mgs), -0.7*qx(mgs,ls)*dtpinv ) )
18605 IF ( .not. mixedphase ) THEN
18606 qhmlr(mgs) = max( qhmlr(mgs), min( -qhmxd(mgs), -0.95*qx(mgs,lh)*dtpinv ) )
18607 chmlr(mgs) = max( chmlr(mgs), min( -chmxd(mgs), -0.95*cx(mgs,lh)*dtpinv ) )
18608 ENDIF
18609! qhmlr(mgs) = max( max( qhmlr(mgs), -qhmxd(mgs) ) , -0.5*qx(mgs,lh)*dtpinv ) !limits to 1/2 qh or max depletion
18610 qhmlh(mgs) = 0. ! not used
18611
18612
18613 ! Rasmussen and Heymsfield say melt water remains on graupel up to 9 mm before shedding
18614
18615
18616 IF ( lhl .gt. 1 .and. lhlw < 1 ) THEN
18617 qhlmlr(mgs) = max( qhlmlr(mgs), min( -qxmxd(mgs,lhl), -0.95*qx(mgs,lhl)*dtpinv ) )
18618 chlmlr(mgs) = max( chlmlr(mgs), min( -cxmxd(mgs,lhl), -0.95*cx(mgs,lhl)*dtpinv ) )
18619 ENDIF
18620
18621!
18622 end do
18623
18624 endif ! } not mixedphase
18625!
18626 if ( ipconc .ge. 1 ) then
18627 do mgs = 1,ngscnt
18628 cimlr(mgs) = (cx(mgs,li)/(qx(mgs,li)+1.e-20))*qimlr(mgs)
18629 IF ( .not. mixedphase ) THEN !{
18630 IF ( xdia(mgs,ls,1) .gt. 1.e-6 .and. -qsmlr(mgs) .ge. 0.5*qxmin(ls) .and. ipconc .ge. 4 ) THEN
18631! csmlr(mgs) = rho0(mgs)*qsmlr(mgs)/(xv(mgs,ls)*rhosm)
18632 csmlr(mgs) = (cx(mgs,ls)/(qx(mgs,ls)))*qsmlr(mgs)
18633 ELSEIF ( qx(mgs,ls) > qxmin(ls) ) THEN
18634 csmlr(mgs) = (cx(mgs,ls)/(qx(mgs,ls)))*qsmlr(mgs)
18635 ENDIF
18636
18637 csmlrr(mgs) = csmlr(mgs)/rzxs(mgs)
18638 IF ( -csmlrr(mgs)*dtp > cxmin .and. -qsmlr(mgs)*dtp > qxmin(lr) .and. snowmeltdia > 0.0 ) THEN
18639 rmas = rho0(mgs)*qsmlr(mgs)/csmlrr(mgs)
18640 IF ( rmas > snowmeltmass ) THEN
18641 csmlrr(mgs) = rho0(mgs)*qsmlr(mgs)/snowmeltmass
18642 ENDIF
18643 ENDIF
18644
18645
18646
18647! IF ( xdia(mgs,lh,1) .gt. 1.e-6 .and. Abs(qhmlr(mgs)) .ge. qxmin(lh) ) THEN
18648! chmlr(mgs) = rho0(mgs)*qhmlr(mgs)/(pi*xdn(mgs,lh)*xdia(mgs,lh,1)**3) ! out of hail
18649! chmlr(mgs) = Max( chmlr(mgs), -chmxd(mgs) )
18650! ELSE
18651 IF ( ibinhmlr == 0 .or. lzh < 1 ) THEN
18652 chmlr(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhmlr(mgs)
18653 IF ( imltshddmr == 3 .and. qhmlr(mgs) < -qxmin(lh) ) THEN
18654 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
18655 !
18656 ! IF ( tmpdiam > sheddiam ) THEN ! let size get smaller until it reaches sheddiam
18657 ! chmlr(mgs) = 0.0
18658 ! ENDIF
18659
18660 ! test to remove the part of the melting associated with large ice particles so they get smaller
18661
18662 tmp = 1. + alpha(mgs,lh)
18663 i = int(dgami*(tmp))
18664 del = tmp - dgam*i
18665 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18666
18667 ratio = min( maxratiolu, mltdiam1/xdia(mgs,lh,1) )
18668
18669 x = gamxinfdp(2. + alpha(mgs,lh), ratio)/g1palp
18670 y = gamxinfdp(2.5 + alpha(mgs,lh) + 0.5*bxx(mgs,lh), ratio)/g1palp
18671
18672 hwvent1 = 0.78*x + y*hwventy(mgs)
18673
18674 qhlmlr1 = min( fmlt1(mgs)*cx(mgs,lh)*hwvent1*xdia(mgs,lh,1), 0.0 )
18675
18676 chmlr(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*(qhmlr(mgs) - qhlmlr1)
18677
18678
18679 ENDIF
18680! IF ( igs(mgs) == 40 ) THEN
18681! write(0,*) 'is this running? chmlr = ',kgs(mgs), chmlr(mgs)
18682! ENDIF
18683 ENDIF
18684! ENDIF
18685
18686
18687 IF ( chmlr(mgs) < 0.0 .and. (ibinhmlr < 1 .or. lzh < 1) ) THEN ! { already done if ibinhmlr > 0
18688 IF ( ipconc >= 6 .and. lzr .gt. 1 .and. lzh < 1 .and. qx(mgs,lh) > qxmin(lh) ) THEN ! Only compute if rain is 3-moment but graupel is not, otherwise is computed later
18689 tmp = qx(mgs,lh)/cx(mgs,lh)
18690 alp = alpha(mgs,lh)
18691 g1 = g1x(mgs,lh) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
18692
18693 zhmlr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*tmp * qhmlr(mgs) - tmp**2 * chmlr(mgs) )
18694
18695 ENDIF
18696
18697 IF ( ibinhmlr == 0 .or. lzh < 1 ) THEN
18698 IF ( ihmlt .eq. 1 ) THEN
18699 chmlrr(mgs) = min( chmlr(mgs), rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*vmlt) ) ! into rain
18700 ELSEIF ( ihmlt .eq. 2 ) THEN
18701 IF ( xv(mgs,lh) .gt. 0.0 .and. chmlr(mgs) .lt. 0.0 ) THEN
18702! chmlrr(mgs) = Min( chmlr(mgs), rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lh)*xv(mgs,lh)) ) ! into rain
18703! guess what, this is the same as chmlr: rho0*qhmlr/xmas(lh) --> cx/qx = rho0/xmas
18704 IF(imltshddmr == 1) THEN
18705 ! DTD: If Dmg < sheddiam, then assume complete melting into
18706 ! maximal raindrop. Between sheddiam and sheddiam0 mm, linearly ramp down to a 3 mm shed drop
18707 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
18708 tmp2 = -rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*vr3mm) ! conc. change for a 3 mm mean drop diameter
18709
18710 chmlrr(mgs) = tmp*(sheddiam0-xdia(mgs,lh,3))/(sheddiam0-sheddiam)+tmp2*(xdia(mgs,lh,3)-sheddiam)/(sheddiam0-sheddiam) ! old version
18711 chmlrr(mgs) = -max(tmp,min(tmp2,chmlrr(mgs)))
18712 ELSEIF ( imltshddmr == 2 .or. imltshddmr == 3 ) THEN
18713 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
18714 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
18715 chmlrr(mgs) = rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lh)) ! into rain
18716 ELSE ! Old method
18717 chmlrr(mgs) = rho0(mgs)*qhmlr(mgs)/(min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lh)*xv(mgs,lh))) ! into rain
18718 ENDIF
18719 ELSE
18720 chmlrr(mgs) = chmlr(mgs)
18721 ENDIF
18722 ELSEIF ( ihmlt .eq. 0 ) THEN
18723 chmlrr(mgs) = chmlr(mgs)
18724 ENDIF
18725
18726 ELSE ! ibinhmlr < 0? Already have an outer IF test for ibinhmlr < 1
18727 chmlrr(mgs) = min( chmlrr(mgs), rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*xvmx(lr)) ) ! into rain
18728 ENDIF
18729
18730 ENDIF ! } ( chmlr(mgs) < 0.0 .and. ibinhmlr < 1)
18731
18732 IF ( lhl .gt. 1 .and. lhlw < 1 .and. .not. mixedphase .and. qhlmlr(mgs) < 0.0 ) THEN ! {
18733
18734 IF ( ibinhlmlr == 0 .or. lzhl < 1 ) THEN
18735! IF ( xdia(mgs,lhl,1) .gt. 1.e-6 .and. Abs(qhlmlr(mgs)) .ge. qxmin(lhl) ) THEN
18736! chlmlr(mgs) = rho0(mgs)*qhlmlr(mgs)/(pi*xdn(mgs,lhl)*xdia(mgs,lhl,1)**3) ! out of hail
18737! chlmlr(mgs) = Max( chlmlr(mgs), -cxmxd(mgs,lhl) )
18738! ELSE
18739 chlmlr(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlmlr(mgs)
18740 IF ( imltshddmr == 3 .and. qhlmlr(mgs) < -qxmin(lhl) ) THEN
18741! IF ( .false. .and. imltshddmr == 3 ) THEN
18742! tmpdiam = (shedalp+alpha(mgs,lhl))*xdia(mgs,lhl,1)
18743!
18744! IF ( tmpdiam > sheddiam ) THEN ! let size get smaller until it reaches sheddiam
18745! chlmlr(mgs) = 0.0
18746! ENDIF
18747
18748 ! test to remove the part of the melting associated with large ice particles so they get smaller
18749!
18750 tmp = 1. + alpha(mgs,lhl)
18751 i = int(dgami*(tmp))
18752 del = tmp - dgam*i
18753 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18754
18755 ratio = min( maxratiolu, mltdiam1/xdia(mgs,lhl,1) )
18756
18757 x = gamxinfdp(2. + alpha(mgs,lhl), ratio)/g1palp
18758 y = gamxinfdp(2.5 + alpha(mgs,lhl) + 0.5*bxx(mgs,lhl), ratio)/g1palp
18759
18760 hwvent1 = 0.78*x + y*hlventy(mgs)
18761
18762 qhlmlr1 = min( fmlt1(mgs)*cx(mgs,lhl)*hwvent1*xdia(mgs,lhl,1), 0.0 )
18763
18764 chlmlr(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*min(0.0, qhlmlr(mgs) - qhlmlr1)
18765
18766 ENDIF
18767! ENDIF
18768 ENDIF
18769
18770 IF ( ibinhlmlr == 0 .or. lzhl < 1 ) THEN !{
18771 IF ( ihmlt .eq. 1 ) THEN
18772 chlmlrr(mgs) = min( chlmlr(mgs), rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*vmlt) ) ! into rain
18773 ELSEIF ( ihmlt .eq. 2 ) THEN
18774 IF ( xv(mgs,lhl) .gt. 0.0 .and. chlmlr(mgs) .lt. 0.0 ) THEN
18775! chlmlrr(mgs) = rho0(mgs)*qhlmlr(mgs)/(Min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lhl)*xv(mgs,lhl))) ! into rain
18776! chlmlrr(mgs) = Min( chlmlr(mgs), rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lhl)*xv(mgs,lhl)) ) ! into rain
18777 IF(imltshddmr == 1 ) THEN
18778 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
18779 tmp2 = -rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*vr3mm) ! conc. change for a 3 mm mean drop diameter
18780 chlmlrr(mgs) = tmp*(20.e-3-xdia(mgs,lhl,3))/(20.e-3-sheddiam)+tmp2*(xdia(mgs,lhl,3)-sheddiam)/(20.e-3-sheddiam)
18781 chlmlrr(mgs) = -max(tmp,min(tmp2,chlmlrr(mgs)))
18782 ELSEIF ( imltshddmr == 2 .or. imltshddmr == 3 ) THEN
18783 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
18784 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
18785 chlmlrr(mgs) = rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lhl)) ! into rain
18786 ELSE ! old method
18787 chlmlrr(mgs) = rho0(mgs)*qhlmlr(mgs)/(min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lhl)*xv(mgs,lhl))) ! into rain
18788 ENDIF
18789 ELSE
18790 chlmlrr(mgs) = chlmlr(mgs)
18791 ENDIF
18792 ELSEIF ( ihmlt .eq. 0 ) THEN
18793 chlmlrr(mgs) = chlmlr(mgs)
18794 ENDIF
18795
18796 ELSE ! } { ibinhlmlr > 0
18797 chlmlrr(mgs) = min( chlmlrr(mgs), rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*xvmx(lr)) ) ! into rain
18798 ENDIF !}
18799
18800
18801 IF ( ipconc >= 8 .and. lzhl .gt. 1 .and. ibinhlmlr <= 0 ) THEN
18802 IF ( cx(mgs,lhl) > 0.0 ) THEN
18803
18804 tmp = qx(mgs,lhl)/cx(mgs,lhl)
18805 alp = alpha(mgs,lhl)
18806! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
18807 g1 = g1x(mgs,lhl) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
18808
18809 zhlmlr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( tmp * qhlmlr(mgs) )
18810 ENDIF
18811 ENDIF
18812 ENDIF ! }
18813
18814 ENDIF ! }.not. mixedphase
18815
18816! 10ice versions:
18817! chmlr(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhmlr(mgs)
18818! chmlrr(mgs) = chmlr(mgs)
18819 end do
18820 end if
18821
18822!
18823! deposition/sublimation of ice
18824!
18825 DO mgs = 1,ngscnt
18826
18827 rwcap(mgs) = (0.5)*xdia(mgs,lr,1)
18828 swcap(mgs) = (0.5)*xdia(mgs,ls,1)
18829 hwcap(mgs) = (0.5)*xdia(mgs,lh,1)
18830 IF ( lhl .gt. 1 ) hlcap(mgs) = (0.5)*xdia(mgs,lhl,1)
18831
18832 if ( qx(mgs,li).gt.qxmin(li) .and. xdia(mgs,li,1) .gt. 0.0 ) then
18833!
18834! from Cotton, 1972 (Part II)
18835!
18836 cilen(mgs) = 0.4764*(xdia(mgs,li,1))**(0.958)
18837 cval = xdia(mgs,li,1)
18838 aval = cilen(mgs)
18839 eval = sqrt(1.0-(aval**2)/(cval**2))
18840 fval = min(0.99,eval)
18841 gval = alog( abs( (1.+fval)/(1.-fval) ) )
18842 cicap(mgs) = cval*fval / gval
18843 ELSE
18844 cicap(mgs) = 0.0
18845 end if
18846 ENDDO
18847!
18848!
18849 qhdsv(:) = 0.0
18850 qhldsv(:) = 0.0
18851
18852 do mgs = 1,ngscnt
18853 IF ( icond .eq. 1 .or. temg(mgs) .le. tfrh &
18854 & .or. (qx(mgs,lr) .le. qxmin(lr) .and. qx(mgs,lc) .le. qxmin(lc)) ) THEN
18855 qidsv(mgs) = &
18856 & fvds(mgs)*cx(mgs,li)*civent(mgs)*cicap(mgs)*depfac
18857 qsdsv(mgs) = &
18858 & fvds(mgs)*cx(mgs,ls)*swvent(mgs)*swcap(mgs)*depfac
18859
18860! IF ( ny .eq. 2 .and. igs(mgs) .eq. 302 .and. temg(mgs) .le. tfrh+10 .and. qx(mgs,lv) .gt. qis(mgs)
18861! : .and. qx(mgs,li) .gt. qxmin(li) ) THEN
18862! write(0,*) 'qidsv = ',nstep,kgs(mgs),qidsv(mgs),temg(mgs)-tfrh,100.*(qx(mgs,lv)/qis(mgs) - 1.),1.e6*xdia(mgs,li,1),
18863! : fvds(mgs),civent(mgs),cicap(mgs)
18864! ENDIF
18865 ELSE
18866 qidsv(mgs) = 0.0
18867 qsdsv(mgs) = 0.0
18868 ENDIF
18869 qhdsv(mgs) = &
18870 & fvds(mgs)*cx(mgs,lh)*hwvent(mgs)*hwcap(mgs)*depfac
18871
18872 IF ( lhl .gt. 1 ) qhldsv(mgs) = fvds(mgs)*cx(mgs,lhl)*hlvent(mgs)*hlcap(mgs)*depfac
18873!
18874!
18875 end do
18876!
18877
18878
18879! #include "nssl.qlimit.F"
18880
18881!
18882! Use a test saturation adjustment to set limits on ice deposition/sublimation
18883! and rain evaporation
18884!
18885!
18886 IF ( dosublimationfix ) THEN
18887
18888 do mgs = 1,ngscnt
18889
18890 qitmp(mgs) = qx(mgs,li) + qx(mgs,ls) + qx(mgs,lh)
18891 IF ( lis > 1 ) qitmp(mgs) = qitmp(mgs) + qx(mgs,lis)
18892 IF ( lhl > 1 ) qitmp(mgs) = qitmp(mgs) + qx(mgs,lhl)
18893 qrtmp(mgs) = qx(mgs,lr)
18894 qctmp(mgs) = qx(mgs,lc)
18895 qsimxdep(mgs) = 0.0
18896 qsimxsub(mgs) = 0.0
18897 dqcitmp(mgs) = 0.0
18898
18899
18900! IF ( ( qitmp(mgs) > qxmin(li) .or. qrtmp(mgs) > qxmin(lr) ) ) THEN
18901 IF ( qitmp(mgs) > qxmin(li) ) THEN
18902
18903 qitmp1 = qitmp(mgs)
18904 qctmp1 = qctmp(mgs)
18905 felvcptmp = felvcp(mgs)
18906 felscptmp = felscp(mgs)
18907 qvtmp(mgs) = qx(mgs,lv)
18908 qss(mgs) = qvs(mgs)
18909 qsstmp = qvs(mgs)
18910 qvstmp = qvs(mgs)
18911 qisstmp = qis(mgs)
18912 thetatmp = theta(mgs)
18913 thetaptmp = thetap(mgs)
18914 temgtmp = temg(mgs)
18915 temcgtmp = temcg(mgs)
18916 qvaptmp = qx(mgs,lv) ! qwvp(mgs) + qv0(mgs)
18917 qvptmp = 0.0 ! qwvp(mgs) ! qv pertubation
18918
18919 qsstmp = qisstmp
18920
18921
18922 dqwvtmp(mgs) = ( qvtmp(mgs) - qsstmp )
18923
18924 do itertd = 1,2
18925
18926!
18927! calculate super-saturation
18928!
18929 IF ( itertd == 1 ) THEN
18930
18931 ELSE
18932 dqcitmp(mgs) = dqci(mgs)
18933 ! dqwvtmp(mgs) = dqwv(mgs)
18934 ENDIF
18935
18936 dqcw(mgs) = 0.0
18937 dqci(mgs) = 0.0
18938 dqwv(mgs) = ( qvtmp(mgs) - qsstmp )
18939!
18940! evaporation and sublimation adjustment
18941!
18942 if( dqwv(mgs) .lt. 0. ) then ! { subsaturated
18943 if( qitmp(mgs) .gt. -dqwv(mgs) ) then ! check if qi can make up all the deficit
18944 dqci(mgs) = dqwv(mgs)
18945 dqwv(mgs) = 0.
18946 else ! otherwise make all ice available for sublimation
18947 dqci(mgs) = -qitmp(mgs)
18948 dqwv(mgs) = dqwv(mgs) + qitmp(mgs)
18949 end if
18950!
18951 qvptmp = qvptmp - ( dqcw(mgs) + dqci(mgs) ) ! add to perturbation vapor
18952
18953 IF ( itertd == 2 .and. eqtset > 1 ) THEN
18954 ! if eqtset == 2, then need to update the latent heats for change in hydrometeor content
18955 tmp = qitmp(mgs) !+ qx(mgs,lh)
18956! IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
18957 cvm = cv+cvv*qvtmp(mgs)+cpl*(qx(mgs,lc)+qrtmp(mgs)) &
18958 +cpigb*(tmp)
18959
18960 felvcptmp = (felv(mgs)-rw*temg(mgs))/cvm
18961 felscptmp = (fels(mgs)-rw*temg(mgs))/cvm
18962 ENDIF
18963
18964
18965! qitmp(mgs) = qx(mgs,li)
18966 qctmp(mgs) = qctmp(mgs) + dqcw(mgs) ! dqcw is zero
18967 qitmp(mgs) = qitmp(mgs) + dqci(mgs)
18968 thetaptmp = thetaptmp + &
18969 & 1./pi0(mgs)* &
18970 & (felvcp(mgs)*dqcw(mgs) +felscp(mgs)*dqci(mgs))
18971
18972
18973 end if ! } dqwv(mgs) .lt. 0. (end of evap/sublim)
18974!
18975! condensation/deposition
18976!
18977 IF ( dqwv(mgs) .ge. 0. ) THEN ! {
18978
18979! write(iunit,*) 'satadj: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qx(mgs,lv),qx(mgs,lc)
18980!
18981! qitmp(mgs) = qx(mgs,li)
18982 fracl(mgs) = 0.0
18983 fraci(mgs) = 1.0
18984 if ( temg(mgs) .lt. tfr .and. temg(mgs) .gt. thnuc ) then
18985! fracl(mgs) = max(min(1.,(temg(mgs)-233.15)/(20.)),0.0)
18986! fraci(mgs) = 1.0-fracl(mgs)
18987 end if
18988 if ( temg(mgs) .le. thnuc ) then
18989 fraci(mgs) = 1.0
18990 fracl(mgs) = 0.0
18991 end if
18992! fraci(mgs) = 1.0-fracl(mgs)
18993
18994 gamss = (felvcp(mgs)*fracl(mgs) + felscp(mgs)*fraci(mgs)) &
18995 & / (pi0(mgs))
18996
18997 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv2(mgs)*qsstmp/ &
18998 & ((temg(mgs)-cbi)**2))
18999
19000 if ( temg(mgs) .ge. tfr ) then
19001 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qsstmp/ &
19002 & ((temg(mgs)-cbw)**2))
19003 end if
19004
19005 delqci1=qx(mgs,li)
19006
19007
19008 dqcw(mgs) = dqvcnd(mgs)*fracl(mgs) ! is zero
19009 dqci(mgs) = dqvcnd(mgs)*fraci(mgs)
19010
19011 thetaptmp = thetaptmp + &
19012 & (felvcp(mgs)*dqcw(mgs) + felscp(mgs)*dqci(mgs)) &
19013 & / (pi0(mgs))
19014
19015 qvptmp = qvptmp - ( dqvcnd(mgs) )
19016 qctmp(mgs) = qctmp(mgs) + dqcw(mgs)
19017 qitmp(mgs) = qitmp(mgs) + dqci(mgs)
19018
19019 IF ( itertd == 2 .and. eqtset > 1 ) THEN
19020 ! if eqtset == 2, then need to update the latent heats for change in hydrometeor content
19021 tmp = qitmp(mgs) ! + qx(mgs,lh)
19022! IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
19023 cvm = cv+cvv*qvtmp(mgs)+cpl*(qctmp(mgs) +qrtmp(mgs)) &
19024 +cpigb*(tmp)
19025
19026 felvcptmp = (felv(mgs)-rw*temg(mgs))/cvm
19027 felscptmp = (fels(mgs)-rw*temg(mgs))/cvm
19028 ENDIF
19029
19030 IF ( eqtset > 2 ) THEN
19031 pipert(mgs) = pipert(mgs) + (0 &
19032 & +felspi(mgs)*dqci(mgs) &
19033 & +felvpi(mgs)*dqcw(mgs))*dtp
19034 ENDIF
19035
19036!
19037!
19038 END IF ! } dqwv(mgs) .ge. 0.
19039
19040
19041!
19042 IF ( itertd == 1 ) THEN
19043 ! update temporary saturation values
19044
19045 thetatmp = thetaptmp + theta0(mgs)
19046 temgtmp = thetatmp*pk(mgs) ! ( pres(mgs) / poo ) ** cap
19047 qvaptmp = max((qvptmp + qv0(mgs)), 0.0)
19048 temcgtmp = temgtmp - tfr
19049 tqvcon = temgtmp-cbw
19050 ltemq = (temgtmp-163.15)/fqsat+1.5
19051 ltemq = min( nqsat, max(1,ltemq) )
19052 qvstmp = pqs(mgs)*tabqvs(ltemq)
19053 qisstmp = pqs(mgs)*tabqis(ltemq)
19054 qctmp(mgs) = max( 0.0, qctmp(mgs) )
19055 qitmp(mgs) = max( 0.0, qitmp(mgs) )
19056 qvtmp(mgs) = max( 0.0, qvaptmp )
19057
19058! qsstmp = qvstmp
19059 qsstmp = qisstmp
19060
19061 ELSE
19062 ! set max depletion
19063 qctmp(mgs) = max( 0.0, qctmp(mgs) )
19064 qitmp(mgs) = max( 0.0, qitmp(mgs) )
19065
19066 IF ( qitmp(mgs) < qitmp1 ) THEN
19067 qsimxsub(mgs) = (qitmp1 - qitmp(mgs))*dtpinv
19068 ELSEIF ( qitmp(mgs) > qitmp1 ) THEN
19069 qsimxdep(mgs) = (qitmp(mgs) - qitmp1)*dtpinv
19070 ENDIF
19071
19072
19073 ENDIF
19074! pceds(mgs) = (thetap(mgs) - thsave(mgs))*dtpinv
19075! write(iunit,*) 'satadj2: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qxtmp,qctmp(mgs)
19076!
19077! end the saturation adjustment iteration loop
19078!
19079 end do ! itertd
19080
19081 ENDIF
19082
19083 end do ! mgs
19084
19085 ELSE
19086
19087 DO mgs = 1,ngscnt
19088 qsimxdep(mgs) = qvimxd(mgs)
19089 qsimxsub(mgs) = 1.e20
19090 ENDDO
19091
19092 ENDIF
19093
19094! end of qlimit
19095
19096 qhcev(:) = 0.0
19097 chcev(:) = 0.0
19098 qhlcev(:) = 0.0
19099 chlcev(:) = 0.0
19100 qfcev(:) = 0.0
19101
19102 do mgs = 1,ngscnt
19103 qisbv(mgs) = 0.0
19104 qssbv(mgs) = 0.0
19105 qidpv(mgs) = 0.0
19106 qsdpv(mgs) = 0.0
19107 qhsbv(mgs) = 0.0
19108 qscev(mgs) = 0.0
19109 cscev(mgs) = 0.0
19110 IF ( icond .eq. 1 .or. temg(mgs) .le. tfrh &
19111 & .or. (qx(mgs,lr) .le. qxmin(lr) .and. qx(mgs,lc) .le. qxmin(lc)) ) THEN ! last condition (qr<qmin & qc<qmin) for case icond=0
19112! qisbv(mgs) = max( min(qidsv(mgs), 0.0), -qimxd(mgs) )
19113! qssbv(mgs) = max( min(qsdsv(mgs), 0.0), -qsmxd(mgs) )
19114! erm 5/10/2007:
19115 qisbv(mgs) = max( min(qidsv(mgs), 0.0), min( -qimxd(mgs), -0.5*qx(mgs,li)*dtpinv ) )
19116 IF ( temg(mgs) < tfr .or. .not. qsmlr(mgs) < 0.0 ) THEN
19117 qssbv(mgs) = max( min(qsdsv(mgs), 0.0), min( -qsmxd(mgs), -0.5*qx(mgs,ls)*dtpinv ) )
19118 ENDIF
19119 qidpv(mgs) = max(qidsv(mgs), 0.0)
19120 qsdpv(mgs) = max(qsdsv(mgs), 0.0)
19121
19122 IF ( qsmlr(mgs) < 0.0 .and. .not. mixedphase ) THEN ! switch snow sublimation to evaporation if there is melting
19123
19124 qscev(mgs) = evapfac* &
19125 & 4.0*pi*(qx(mgs,lv)-qss0(mgs))*cx(mgs,ls)*swcap(mgs)*swvent(mgs)/(qss0(mgs)*(fav(mgs)+fbv(mgs)))
19126 qscev(mgs) = max( min(0.0,qscev(mgs)), min( -qsmxd(mgs), -0.5*qx(mgs,ls)*dtpinv ) )
19127 ELSE
19128
19129 ENDIF
19130
19131
19132
19133 ELSE
19134 qisbv(mgs) = 0.0
19135 qssbv(mgs) = 0.0
19136 qidpv(mgs) = 0.0
19137 qsdpv(mgs) = 0.0
19138 ENDIF
19139
19140 qhsbv(mgs) = 0.0
19141 qhdpv(mgs) = 0.0
19142 IF ( qx(mgs,lh) > qxmin(lh) ) THEN
19143 IF ( temg(mgs) < tfr .or. .not. qhmlr(mgs) < 0.0 ) THEN
19144 ! no liquid from melting, so evaporation is greater. Thus can calculate sublimation rate
19145 qhsbv(mgs) = max( min(qhdsv(mgs), 0.0), -qhmxd(mgs) )
19146 qhdpv(mgs) = max(qhdsv(mgs), 0.0)
19147 ENDIF
19148
19149 IF ( .true. .and. qhmlr(mgs) < 0.0 .and. .not. mixedphase ) THEN
19150 ! Liquid is forming, so find the evaporation that was subtracted from melting (if it is not condensing)
19151! qhcev(mgs) = &
19152! & evapfac*min( &
19153! & fmlt1e(mgs)*cx(mgs,lh)*hwvent(mgs)*xdia(mgs,lh,1), 0.0 )
19154
19155 qhcev(mgs) = evapfac*2.0*pi*(qx(mgs,lv)-qss0(mgs))* &
19156 & cx(mgs,lh)*xdia(mgs,lh,1)*hwvent(mgs)/(qss0(mgs)*(fav(mgs)+fbv(mgs)))
19157
19158 qhcev(mgs) = max(qhcev(mgs), -qhmxd(mgs))
19159 IF ( temg(mgs) > tfr ) qhcev(mgs) = min(0.0, qhcev(mgs) )
19160
19161 ENDIF
19162 ENDIF
19163
19164
19165 qhlsbv(mgs) = 0.0
19166 qhldpv(mgs) = 0.0
19167 IF ( lhl .gt. 1 ) THEN
19168 IF ( qx(mgs,lhl) > qxmin(lhl) ) THEN
19169 IF ( temg(mgs) < tfr .or. .not. qhlmlr(mgs) < 0.0 ) THEN
19170 qhlsbv(mgs) = max( min(qhldsv(mgs), 0.0), -qxmxd(mgs,lhl) )
19171 qhldpv(mgs) = max(qhldsv(mgs), 0.0)
19172 ENDIF
19173 IF ( qhlmlr(mgs) < 0.0 .and. .not. mixedphase ) THEN
19174 ! Liquid is forming, so find the evaporation that was subtracted from melting (if it is not condensing)
19175 qhlcev(mgs) = evapfac*2.0*pi*(qx(mgs,lv)-qss0(mgs))* &
19176 & cx(mgs,lhl)*xdia(mgs,lhl,1)*hlvent(mgs)/(qss0(mgs)*(fav(mgs)+fbv(mgs)))
19177
19178 qhlcev(mgs) = max(qhlcev(mgs), -qhlmxd(mgs))
19179 IF ( temg(mgs) > tfr ) qhlcev(mgs) = min(0.0, qhlcev(mgs) )
19180
19181 ENDIF
19182 ENDIF
19183 ENDIF
19184
19185 temp1 = qidpv(mgs) + qsdpv(mgs) + qhdpv(mgs) + qhldpv(mgs)
19186
19187! IF ( temp1 .gt. qvimxd(mgs) ) THEN
19188
19189! frac = qvimxd(mgs)/temp1
19190
19191 IF ( temp1 .gt. qsimxdep(mgs) ) THEN
19192 frac = qsimxdep(mgs)/temp1
19193
19194 qidpv(mgs) = frac*qidpv(mgs)
19195 qsdpv(mgs) = frac*qsdpv(mgs)
19196 qhdpv(mgs) = frac*qhdpv(mgs)
19197 qhldpv(mgs) = frac*qhldpv(mgs)
19198
19199! IF ( ny .eq. 2 .and. igs(mgs) .eq. 302 .and. temg(mgs) .le. tfrh+10 .and. qx(mgs,lv) .gt. qis(mgs)
19200! : .and. qx(mgs,li) .gt. qxmin(li) ) THEN
19201! write(0,*) 'qidpv,frac = ',kgs(mgs),qidpv(mgs),frac
19202! ENDIF
19203
19204 ENDIF
19205
19206 temp1 = qisbv(mgs) + qssbv(mgs) + qhsbv(mgs) + qhlsbv(mgs)
19207
19208
19209 IF ( temp1 < -qsimxsub(mgs) ) THEN
19210 frac = -qsimxsub(mgs)/temp1
19211
19212 qisbv(mgs) = frac*qisbv(mgs)
19213 qssbv(mgs) = frac*qssbv(mgs)
19214 qhsbv(mgs) = frac*qhsbv(mgs)
19215 qhlsbv(mgs) = frac*qhlsbv(mgs)
19216
19217! IF ( ny .eq. 2 .and. igs(mgs) .eq. 302 .and. temg(mgs) .le. tfrh+10 .and. qx(mgs,lv) .gt. qis(mgs)
19218! : .and. qx(mgs,li) .gt. qxmin(li) ) THEN
19219! write(0,*) 'qidpv,frac = ',kgs(mgs),qidpv(mgs),frac
19220! ENDIF
19221
19222 ENDIF
19223
19224
19225 end do
19226!
19227!
19228 if ( ipconc .ge. 1 ) then
19229 do mgs = 1,ngscnt
19230 cssbv(mgs) = (cx(mgs,ls)/(qx(mgs,ls)+1.e-20))*qssbv(mgs)
19231 cisbv(mgs) = (cx(mgs,li)/(qx(mgs,li)+1.e-20))*qisbv(mgs)
19232 chsbv(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhsbv(mgs)
19233 IF ( lhl .gt. 1 ) chlsbv(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlsbv(mgs)
19234 csdpv(mgs) = 0.0 ! (cx(mgs,ls)/(qx(mgs,ls)+1.e-20))*qsdpv(mgs)
19235 cidpv(mgs) = 0.0 ! (cx(mgs,li)/(qx(mgs,li)+1.e-20))*qidpv(mgs)
19236 cisdpv(mgs) = 0.0
19237 chdpv(mgs) = 0.0 ! (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhdpv(mgs)
19238 chldpv(mgs) = 0.0
19239 end do
19240 end if
19241
19242!
19243! Aggregation or size conversion of small crystals to snow
19244!
19245 if (ndebug .gt. 0 ) write(0,*) 'conc 29a'
19246 do mgs = 1,ngscnt
19247 qscni(mgs) = 0.0
19248 cscni(mgs) = 0.0
19249 cscnis(mgs) = 0.0
19250 if ( ipconc .ge. 4 .and. iscni .ge. 1 .and. qx(mgs,li) .gt. qxmin(li) ) then
19251 IF ( iscni .eq. 1 ) THEN
19252 qscni(mgs) = &
19253 & pi*rho0(mgs)*((0.25)/(6.0)) &
19254 & *eii(mgs)*(qx(mgs,li)**2)*(xdia(mgs,li,2)) &
19255 & *vtxbar(mgs,li,1)/xmas(mgs,li)
19256 cscni(mgs) = min(cimxd(mgs),qscni(mgs)*rho0(mgs)/xmas(mgs,li))
19257 cscnis(mgs) = 0.5*cscni(mgs)
19258 ELSEIF ( iscni .eq. 2 .or. iscni .eq. 4 .or. iscni .eq. 5 ) THEN ! Zeigler 1985/Zrnic 1993, sort of
19259 IF ( iscni .ne. 5 .and. qidpv(mgs) .gt. 0.0 .and. xdia(mgs,li,3) .ge. 100.e-6 ) THEN
19260 ! convert larger crystals to snow
19261! IF ( xdia(mgs,ls,3) .gt. xdia(mgs,li,3) ) THEN
19262! qscni(mgs) = Max(0.1,xdia(mgs,li,3)/xdia(mgs,ls,3))*qidpv(mgs)
19263! erm 9/5/08 changed max to min
19264 qscni(mgs) = min(0.5, xdia(mgs,li,3)/200.e-6)*qidpv(mgs)
19265! ELSE
19266! qscni(mgs) = 0.1*qidpv(mgs)
19267! ENDIF
19268 cscni(mgs) = fscni*qscni(mgs)*rho0(mgs)/max(rho_qs*xvmn(ls),xmas(mgs,li))
19269! cscni(mgs) = fscni*Min(cimxd(mgs),qscni(mgs)*rho0(mgs)/Max(xdn(mgs,ls)*xvmn(ls),xmas(mgs,li)))
19270! cscni(mgs) = Min(cimxd(mgs),qscni(mgs)*rho0(mgs)/xmas(mgs,li) )
19271! IF ( xdia(mgs,ls,3) .le. 200.e-6 ) THEN
19272 cscnis(mgs) = cscni(mgs)
19273! ELSE
19274! cscnis(mgs) = 0.0
19275! ENDIF
19276 ENDIF
19277
19278 IF ( iscni .ne. 4 ) THEN
19279 ! crystal aggregation to become snow
19280! erm 9/5/08 commented second line and added xv to 1st line (zrnic et al 1993)
19281 tmp = ess(mgs)*rvt*aa2*cx(mgs,li)*cx(mgs,li)*xv(mgs,li)
19282! : ((cinu + 2.)*xv(mgs,li)/(cinu + 1.) + xv(mgs,li))
19283
19284! csacs(mgs) = rvt*aa2*ess(mgs)*cx(mgs,ls)**2*xv(mgs,ls)
19285
19286 qscni(mgs) = qscni(mgs) + min( qxmxd(mgs,li), 2.0*tmp*xmas(mgs,li)*rhoinv(mgs) )
19287 cscni(mgs) = cscni(mgs) + min( cxmxd(mgs,li), 2.0*tmp )
19288 cscnis(mgs) = cscnis(mgs) + min( cxmxd(mgs,li), tmp )
19289 ENDIF
19290 ELSEIF ( iscni .eq. 3 ) THEN ! LFO
19291 qscni(mgs) = 0.001*eii(mgs)*max((qx(mgs,li)-1.e-3),0.0)
19292 qscni(mgs) = min(qscni(mgs),qxmxd(mgs,li))
19293 cscni(mgs) = qscni(mgs)*rho0(mgs)/xmas(mgs,li)
19294 cscnis(mgs) = 0.5*cscni(mgs)
19295! write(iunit,*) 'qscni, qi = ',qscni(mgs),qx(mgs,li),igs(mgs),kgs(mgs)
19296 ENDIF
19297
19298 ELSEIF ( ipconc < 4 ) THEN ! LFO
19299 IF ( lwsm6 ) THEN
19300 qimax = rhoinv(mgs)*roqimax
19301 qscni(mgs) = min(0.90*qx(mgs,li), max( 0.0, (qx(mgs,li) - qimax)*dtpinv ) )
19302 ELSE
19303 qscni(mgs) = 0.001*eii(mgs)*max((qx(mgs,li)-1.e-3),0.0)
19304 qscni(mgs) = min(qscni(mgs),qxmxd(mgs,li))
19305 ENDIF
19306 else ! 10-ice version
19307 if ( iscni > 0 .and. qx(mgs,li) .gt. qxmin(li) ) then
19308 qscni(mgs) = &
19309 & pi*rho0(mgs)*((0.25)/(6.0)) &
19310 & *eii(mgs)*(qx(mgs,li)**2)*(xdia(mgs,li,2)) &
19311 & *vtxbar(mgs,li,1)/xmas(mgs,li)
19312 cscni(mgs) = min(cimxd(mgs),qscni(mgs)*rho0(mgs)/xmas(mgs,li))
19313 end if
19314
19315 end if
19316 end do
19317
19318
19319
19320
19321
19322!
19323!
19324! compute dry growth rate of snow, graupel, and hail
19325!
19326 do mgs = 1,ngscnt
19327!
19328 qsdry(mgs) = qsacr(mgs) + qsacw(mgs) &
19329 & + qsaci(mgs)
19330!
19331 qhdry(mgs) = qhaci(mgs) + qhacs(mgs) &
19332 & + qhacr(mgs) &
19333 & + qhacw(mgs)
19334!
19335
19336 qhldry(mgs) = 0.0
19337 IF ( lhl .gt. 1 ) THEN
19338 qhldry(mgs) = qhlaci(mgs) + qhlacs(mgs) &
19339 & + qhlacr(mgs) &
19340 & + qhlacw(mgs)
19341 ENDIF
19342 end do
19343!
19344! set wet growth and shedding
19345!
19346 do mgs = 1,ngscnt
19347
19348 IF ( tfrdry < temg(mgs) .and. temg(mgs) < tfr ) THEN
19349!
19350! qswet(mgs) =
19351! > ( xdia(mgs,ls,1)*swvent(mgs)*cx(mgs,ls)*fwet1(mgs)
19352! > + fwet2(mgs)*(qsaci(mgs)+qsacir(mgs)
19353! > +qsacip(mgs)) )
19354! qswet(mgs) = max( 0.0, qswet(mgs))
19355!
19356! IF ( dnu(lh) .ne. 0. ) THEN
19357! qhwet(mgs) = qhdry(mgs)
19358! ELSE
19359 IF ( incwet == 0 ) THEN
19360 qhwet(mgs) = &
19361 & ( xdia(mgs,lh,1)*hwvent(mgs)*cx(mgs,lh)*fwet1(mgs) &
19362 & + fwet2(mgs)*(qhaci(mgs) + qhacs(mgs)) )
19363 qhwet(mgs) = max( 0.0, qhwet(mgs))
19364 ELSE
19365 ENDIF
19366
19367! ENDIF
19368
19369
19370 qhlwet(mgs) = 0.0
19371 IF ( lhl .gt. 1 ) THEN
19372 IF ( incwet == 0 ) THEN
19373 qhlwet(mgs) = &
19374 & ( xdia(mgs,lhl,1)*hlvent(mgs)*cx(mgs,lhl)*fwet1(mgs) &
19375 & + fwet2(mgs)*(qhlaci(mgs) + qhlacs(mgs)) )
19376 qhlwet(mgs) = max( 0.0, qhlwet(mgs))
19377
19378 ELSE
19379 ENDIF ! incwet
19380 ENDIF
19381
19382 ELSE
19383
19384 qhwet(mgs) = qhdry(mgs)
19385 qhlwet(mgs) = qhldry(mgs)
19386 ENDIF
19387!
19388! qhlwet(mgs) = qhldry(mgs)
19389
19390 end do
19391
19392!
19393! shedding rate
19394!
19395 qsshr(:) = 0.0
19396 qhshr(:) = 0.0
19397 qhlshr(:) = 0.0
19398 qhshh(:) = 0.0
19399 csshr(:) = 0.0
19400 csshrr(:) = 0.0
19401 chshr(:) = 0.0
19402 chlshr(:) = 0.0
19403 chshrr(:) = 0.0
19404 chlshrr(:) = 0.0
19405 vhshdr(:) = 0.0
19406 vhlshdr(:) = 0.0
19407 wetsfc(:) = .false.
19408 wetgrowth(:) = .false.
19409 wetsfchl(:) = .false.
19410 wetgrowthhl(:) = .false.
19411
19412 do mgs = 1,ngscnt
19413!
19414!
19415!
19416 qhshr(mgs) = min( 0.0, qhwet(mgs) - qhdry(mgs) ) ! water that freezes should never be more than what sheds
19417
19418
19419
19420 qhlshr(mgs) = min( 0.0, qhlwet(mgs) - qhldry(mgs) )
19421
19422!
19423! limit wet growth to only higher density particles
19424!
19425 qsshr(mgs) = 0.0
19426!
19427!
19428! no shedding for temperatures < 243.15
19429!
19430 if ( temg(mgs) .lt. 243.15 ) then
19431 qsshr(mgs) = 0.0
19432 qhshr(mgs) = 0.0
19433 qhlshr(mgs) = 0.0
19434 vhshdr(mgs) = 0.0
19435 vhlshdr(mgs) = 0.0
19436 wetsfc(mgs) = .false.
19437 wetgrowth(mgs) = .false.
19438 wetsfchl(mgs) = .false.
19439 wetgrowthhl(mgs) = .false.
19440 end if
19441!
19442! shed all at temperatures > 273.15
19443!
19444 if ( temg(mgs) .gt. tfr ) then
19445
19446 IF ( .false. ) THEN ! old and incorrect -- Thanks to Shaofeng Hua for noticing this error (9/17/2017)
19447 qsshr(mgs) = -qsdry(mgs)
19448 qhshr(mgs) = -qhdry(mgs)
19449 qhlshr(mgs) = -qhldry(mgs)
19450 ELSE ! new and correct
19451 ! note that the qxacr terms should be zero here, so shedding at T > 0 is all from the droplets
19452 qsshr(mgs) = - qsacr(mgs) - qsacw(mgs) ! -qsdry(mgs)
19453 qhlshr(mgs) = - qhlacw(mgs) - qhlacr(mgs) ! -qhldry(mgs)
19454 qhshr(mgs) = - qhacw(mgs) - qhacr(mgs) ! -qhdry(mgs)
19455
19456 ENDIF
19457
19458 vhshdr(mgs) = -vhacw(mgs) - vhacr(mgs)
19459 vhlshdr(mgs) = -vhlacw(mgs) - vhlacr(mgs)
19460 qhwet(mgs) = 0.0
19461 qhlwet(mgs) = 0.0
19462 end if
19463!
19464! if (qhshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) THEN
19465 wetsfc(mgs) = (qhshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) .or. ( qhmlr(mgs) < -qxmin(lh) .and. temg(mgs) > tfr )
19466 wetgrowth(mgs) = (qhshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr )
19467! ENDIF
19468 if (qhlshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) THEN
19469 wetsfchl(mgs) = (qhlshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) .or. ( qhlmlr(mgs) < -qxmin(lhl) .and. temg(mgs) > tfr )
19470 wetgrowthhl(mgs) = (qhlshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr )
19471 ENDIF
19472
19473 end do
19474!
19475 if ( ipconc .ge. 1 ) then
19476 do mgs = 1,ngscnt
19477 csshr(mgs) = 0.0 ! (cx(mgs,ls)/(qx(mgs,ls)+1.e-20))*Min(0.0,qsshr(mgs))
19478
19479 chshr(mgs) = 0.0 ! no change to graupel number concentration for wet-growth shedding
19480
19481 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
19482 ! Base the drop size on the shedding regime
19483 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
19484 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
19485 chshrr(mgs) = rho0(mgs)*qhshr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lh)) ! into rain
19486
19487
19488
19489 chlshr(mgs) = 0.0
19490 chlshrr(mgs) = 0.0
19491 IF ( lhl .gt. 1 ) THEN
19492! chlshr(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlshr(mgs)
19493
19494
19495 chlshr(mgs) = 0.0 ! no change to hail number concentration for wet-growth shedding
19496
19497 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
19498 ! Base the drop size on the shedding regime
19499 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
19500 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
19501 chlshrr(mgs) = rho0(mgs)*qhlshr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lhl)) ! into rain
19502
19503 ENDIF ! ( lhl > 1 )
19504
19505
19506 end do
19507 end if
19508
19509
19510
19511!
19512! final decisions
19513!
19514 do mgs = 1,ngscnt
19515!
19516! Snow
19517!
19518 if ( qsshr(mgs) .lt. 0.0 ) then
19519 qsdpv(mgs) = 0.0
19520 qssbv(mgs) = 0.0
19521 else
19522 qsshr(mgs) = 0.0
19523 end if
19524!
19525! if ( qsdry(mgs) .lt. qswet(mgs) ) then
19526! qswet(mgs) = 0.0
19527! else
19528! qsdry(mgs) = 0.0
19529! end if
19530!
19531
19532! graupel
19533!
19534!
19535 if ( wetgrowth(mgs) .or. (mixedphase .and. fhw(mgs) .gt. 0.05 .and. temg(mgs) .gt. 243.15) ) then
19536
19537
19538! soaking (when not advected liquid water film with graupel)
19539
19540 IF ( lvol(lh) .gt. 1 .and. .not. mixedphase) THEN
19541 ! rescale volumes to maximum density
19542 IF ( iwetsoak ) THEN
19543
19544 rimdn(mgs,lh) = xdnmx(lh)
19545 raindn(mgs,lh) = xdnmx(lh)
19546 vhacw(mgs) = qhacw(mgs)*rho0(mgs)/rimdn(mgs,lh)
19547 vhacr(mgs) = qhacr(mgs)*rho0(mgs)/raindn(mgs,lh)
19548! IF ( lvol(lh) .gt. 1 .and. wetgrowth(mgs) ) THEN
19549 IF ( xdn(mgs,lh) .lt. xdnmx(lh) ) THEN
19550 ! soak some liquid into the graupel
19551! v1 = xdnmx(lh)*vx(mgs,lh)/(xdn(mgs,lh)*dtp) ! volume available for filling
19552 v1 = (1. - xdn(mgs,lh)/xdnmx(lh))*vx(mgs,lh)/(dtp) ! volume available for filling
19553! tmp = (vx(mgs,lh)/rho0(mgs))*(xdnmx(lh) - xdn(mgs,lh)) ! max mixing ratio of liquid water that can be added
19554 v2 = rho0(mgs)*qhwet(mgs)/xdnmx(lh) ! volume of frozen accretion
19555
19556 vhsoak(mgs) = min(v1,v2)
19557
19558
19559 ENDIF
19560
19561 ENDIF
19562
19563 vhshdr(mgs) = min(0.0, rho0(mgs)*qhwet(mgs)/xdnmx(lh) - vhacw(mgs) - vhacr(mgs) )
19564
19565 ELSEIF ( lvol(lh) .gt. 1 .and. mixedphase ) THEN
19566! vhacw(mgs) = rho0(mgs)*qhacw(mgs)/xdn0(lr)
19567! vhacr(mgs) = rho0(mgs)*qhacr(mgs)/xdn0(lr)
19568 ENDIF
19569
19570
19571 qhdpv(mgs) = 0.0
19572! qhsbv(mgs) = 0.0
19573 chdpv(mgs) = 0.0
19574! chsbv(mgs) = 0.0
19575
19576! collection efficiency modification
19577
19578 IF ( ehi(mgs) .gt. 0.0 ) THEN
19579 qhaci(mgs) = min(qimxd(mgs),qhaci0(mgs)) ! effectively sets collection eff to 1
19580 chaci(mgs) = min(cimxd(mgs),chaci0(mgs)) ! effectively sets collection eff to 1
19581 ENDIF
19582 IF ( ehs(mgs) .gt. 0.0 ) THEN
19583! qhacs(mgs) = Min(qsmxd(mgs),qhacs(mgs)/ehs(mgs)) ! effectively sets collection eff to 1
19584 qhacs(mgs) = min(qsmxd(mgs),qhacs0(mgs)) !/ehs(mgs) ! divide out the collection efficiency
19585 chacs(mgs) = min(csmxd(mgs),chacs0(mgs)) !/ehs(mgs) ! divide out the collection efficiency
19586 ehs(mgs) = ehsmax ! 1.0 ! min(ehsfrac*ehs(mgs),ehsmax) ! modify it
19587 qhacs(mgs) = min(qsmxd(mgs),qhacs(mgs)) ! plug it back in
19588 ENDIF
19589
19590! be sure to catch particles with wet surfaces but not in wet growth to turn off Hallett-Mossop
19591 wetsfc(mgs) = .true.
19592
19593 else
19594! qhshr(mgs) = 0.0
19595 end if
19596!
19597!
19598! hail
19599!
19600! if ( lhl .gt. 1 .and. qhlshr(mgs) .lt. 0.0 ) then
19601 if ( lhl > 1 .and. ( wetgrowthhl(mgs) .or. (mixedphase .and. fhlw(mgs) .gt. 0.05 .and. temg(mgs) .gt. 243.15) ) ) then
19602! if ( wetgrowthhl(mgs) ) then
19603
19604
19605 qhldpv(mgs) = 0.0
19606! qhlsbv(mgs) = 0.0
19607 chldpv(mgs) = 0.0
19608! chlsbv(mgs) = 0.0
19609
19610
19611
19612
19613 IF ( lvol(lhl) .gt. 1 .and. .not. mixedphase ) THEN
19614! IF ( lvol(lhl) .gt. 1 .and. wetgrowthhl(mgs) ) THEN
19615
19616 IF ( iwetsoak ) THEN
19617
19618 rimdn(mgs,lhl) = xdnmx(lhl)
19619 raindn(mgs,lhl) = xdnmx(lhl)
19620 vhlacw(mgs) = qhlacw(mgs)*rho0(mgs)/rimdn(mgs,lhl)
19621 vhlacr(mgs) = qhlacr(mgs)*rho0(mgs)/raindn(mgs,lhl)
19622
19623 IF ( xdn(mgs,lhl) .lt. xdnmx(lhl) ) THEN
19624 ! soak some liquid into the hail
19625! v1 = xdnmx(lhl)*vx(mgs,lhl)/(xdn(mgs,lhl)*dtp) ! volume available for filling
19626 v1 = (1. - xdn(mgs,lhl)/xdnmx(lhl))*vx(mgs,lhl)/(dtp) ! volume available for filling
19627! tmp = (vx(mgs,lhl)/rho0(mgs))*(xdnmx(lhl) - xdn(mgs,lhl)) ! max mixing ratio of liquid water that can be added
19628 v2 = rho0(mgs)*qhlwet(mgs)/xdnmx(lhl) ! volume of frozen accretion
19629 IF ( v1 > v2 ) THEN ! all the frozen stuff fits in
19630 vhlsoak(mgs) = v2
19631 ELSE ! fill up the available space
19632 vhlsoak(mgs) = v1
19633 ENDIF
19634! vhlacw(mgs) = 0.0
19635! vhlacr(mgs) = Max( 0.0, v2 - v1 )
19636 ELSE
19637 vhlsoak(mgs) = 0.0
19638! vhlacw(mgs) = 0.0
19639! vhlacr(mgs) = rho0(mgs)*qhlwet(mgs)/raindn(mgs,lhl)
19640
19641 ENDIF
19642
19643 ENDIF
19644
19645 vhlshdr(mgs) = min(0.0, rho0(mgs)*qhlwet(mgs)/xdnmx(lhl) - vhlacw(mgs) - vhlacr(mgs) )
19646
19647
19648 ELSEIF ( lvol(lhl) .gt. 1 .and. mixedphase ) THEN
19649! vhlacw(mgs) = rho0(mgs)*qhlacw(mgs)/xdn0(lr)
19650! vhlacr(mgs) = rho0(mgs)*qhlacr(mgs)/xdn0(lr)
19651 ENDIF
19652
19653 IF ( ehli(mgs) .gt. 0.0 ) THEN
19654 qhlaci(mgs) = min(qimxd(mgs),qhlaci0(mgs)) ! effectively sets collection eff to 1
19655 chlaci(mgs) = min(cimxd(mgs),chlaci0(mgs)) ! effectively sets collection eff to 1
19656 ENDIF
19657
19658! IF ( ehls(mgs) .gt. 0.0 ) THEN
19659! qhlacs(mgs) = Min(qsmxd(mgs),qhlacs(mgs)/ehls(mgs))
19660! ENDIF
19661 IF ( ehls(mgs) .gt. 0.0 ) THEN
19662 qhlacs(mgs) = min(qsmxd(mgs),qhlacs0(mgs)) !/ehls(mgs) ! divide out the collection efficiency
19663 chlacs(mgs) = min(csmxd(mgs),chlacs0(mgs)) !/ehls(mgs) ! divide out the collection efficiency
19664 ehls(mgs) = ehsmax ! 1.0 ! min(ehsfrac*ehs(mgs),ehsmax) ! modify it
19665! qhlacs(mgs) = Min(qsmxd(mgs),qhlacs(mgs)) ! plug it back in
19666 ENDIF
19667
19668
19669! qhlwet(mgs) = 1.0
19670
19671! be sure to catch particles with wet surfaces but not in wet growth to turn off Hallett-Mossop
19672 wetsfchl(mgs) = .true.
19673
19674
19675 else
19676! qhlshr(mgs) = 0.0
19677! qhlwet(mgs) = 0.0
19678 end if
19679
19680 end do
19681!
19682! Ice -> graupel conversion
19683!
19684 DO mgs = 1,ngscnt
19685
19686 qhcni(mgs) = 0.0
19687 chcni(mgs) = 0.0
19688 chcnih(mgs) = 0.0
19689 vhcni(mgs) = 0.0
19690
19691 IF ( iglcnvi .ge. 1 ) THEN
19692 IF ( temg(mgs) .lt. 273.0 .and. qiacw(mgs) - qidpv(mgs) .gt. 0.0 ) THEN
19693
19694
19695 tmp = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
19696 & *((0.60)*vtxbar(mgs,li,1)) &
19697 & /(temg(mgs)-273.15))**(rimc2)
19698 tmp = min( max( rimc3, tmp ), 900.0 )
19699
19700 ! Assume that half the volume of the embryo is rime with density 'tmp'
19701 ! m = rhoi*(V/2) + rhorime*(V/2) = (rhoi + rhorime)*V/2
19702 ! V = 2*m/(rhoi + rhorime)
19703
19704! write(0,*) 'rime dens = ',tmp
19705
19706 IF ( tmp .ge. 200.0 .or. iglcnvi >= 2 ) THEN
19707 r = max( 0.5*(xdn(mgs,li) + tmp), xdnmn(lh) )
19708! r = Max( r, 400. )
19709 qhcni(mgs) = (qiacw(mgs) - qidpv(mgs)) ! *float(iglcnvi)
19710 chcni(mgs) = cx(mgs,li)*qhcni(mgs)/qx(mgs,li)
19711! chcnih(mgs) = rho0(mgs)*qhcni(mgs)/(1.6e-10)
19712 chcnih(mgs) = min(chcni(mgs), rho0(mgs)*qhcni(mgs)/(r*xvmn(lh)) )
19713! vhcni(mgs) = rho0(mgs)*2.0*qhcni(mgs)/(xdn(mgs,li) + tmp)
19714 vhcni(mgs) = rho0(mgs)*qhcni(mgs)/r
19715 ENDIF
19716
19717 ELSEIF ( iglcnvi == 3 ) THEN
19718
19719 IF ( temg(mgs) .lt. 273.0 .and. qiacw(mgs)*dtp > 2.*qxmin(lh) .and. gamice73fac*xmas(mgs,li) > xdnmn(lh)*xvmn(lh) ) THEN
19720
19721
19722 tmp = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
19723 & *((0.60)*vtxbar(mgs,li,1)) &
19724 & /(temg(mgs)-273.15))**(rimc2)
19725 tmp = min( max( rimc3, tmp ), 900.0 )
19726
19727 ! Assume that half the volume of the embryo is rime with density 'tmp'
19728 ! m = rhoi*(V/2) + rhorime*(V/2) = (rhoi + rhorime)*V/2
19729 ! V = 2*m/(rhoi + rhorime)
19730
19731! write(0,*) 'rime dens = ',tmp
19732 ! convert to particles with the mass of the mass-weighted diameter
19733 ! massofmwr = gamice73fac*xmas(mgs,li)
19734
19735 IF ( tmp .ge. xdnmn(lh) ) THEN
19736 r = max( 0.5*(xdn(mgs,li) + tmp), xdnmn(lh) )
19737! r = Max( r, 400. )
19738 qhcni(mgs) = 0.5*qiacw(mgs)
19739 chcni(mgs) = qhcni(mgs)/(gamice73fac*xmas(mgs,li))
19740 chcnih(mgs) = min(chcni(mgs), rho0(mgs)*qhcni(mgs)/(r*xvmn(lh)) )
19741! vhcni(mgs) = rho0(mgs)*2.0*qhcni(mgs)/(xdn(mgs,li) + tmp)
19742 vhcni(mgs) = rho0(mgs)*qhcni(mgs)/r
19743 ENDIF
19744
19745 ENDIF
19746
19747
19748 ENDIF
19749 ENDIF
19750
19751
19752 ENDDO
19753
19754
19755 qhlcnh(:) = 0.0
19756 chlcnh(:) = 0.0
19757 chlcnhhl(:) = 0.0
19758 vhlcnh(:) = 0.0
19759 vhlcnhl(:) = 0.0
19760 zhlcnh(:) = 0.0
19761
19762 qhcnhl(:) = 0.0
19763 chcnhl(:) = 0.0
19764 vhcnhl(:) = 0.0
19765 zhcnhl(:) = 0.0
19766
19767
19768 IF ( lhl .gt. 1 ) THEN
19769
19770 IF ( ihlcnh == 1 .or. ihlcnh == 3 ) THEN
19771
19772!
19773! Graupel (h) conversion to hail (hl) based on Milbrandt and Yau 2005b
19774!
19775 DO mgs = 1,ngscnt
19776
19777! IF ( lhl .gt. 1 .and. ipconc .ge. 5 .and. qx(mgs,lh) .gt. 1.0e-3 .and.
19778! : xdn(mgs,lh) .gt. 750. .and. qhshr(mgs) .lt. 0.0 .and.
19779! : xdia(mgs,lh,3) .gt. 1.e-3 ) THEN
19780 IF ( hlcnhdia > 0 ) THEN
19781 ltest = xdia(mgs,lh,3) .gt. hlcnhdia ! test on mean volume diameter
19782 ELSE
19783! ltest = xdia(mgs,lh,1)*(3. + alpha(mgs,lh)) > Abs( hlcnhdia ) ! test on maximum mass diameter
19784 ltest = xdia(mgs,lh,1)*(4. + alpha(mgs,lh)) > abs( hlcnhdia ) ! test on mass-weighted diameter
19785 ENDIF
19786
19787 IF ( iusedw == 0 .and. ihlcnh == 1 ) THEN
19788 dg0(mgs) = -1.
19789 ELSE
19790 IF (((qhacw(mgs) + qhacr(mgs))*dtp > qxmin(lh) .and. qx(mgs,lh) > hlcnhqmin .and. temg(mgs) .le. tfr-2.0 &
19791 .and. temg(mgs) .gt. dwtempmin ) .or. ( wetgrowth(mgs) .and. qx(mgs,lh) > hlcnhqmin ) ) THEN
19792! dw = 0.01*( Exp( -temcg(mgs)/( 1.1e4 * rho0(mgs)*ehw(mgs)*qx(mgs,lc) - 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0 ) ) - 1.0 )
19793! dwr = 0.01*( Exp( -temcg(mgs)/( 1.1e4 * rho0(mgs)*(ehw(mgs)*qx(mgs,lc)+ehr(mgs)*qx(mgs,lr)) - &
19794! 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0 ) ) - 1.0 )
19795 x = 1.1e4 * rho0(mgs)*(ehw(mgs)*qx(mgs,lc)+ehr(mgs)*qx(mgs,lr)) - &
19796 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0
19797 IF ( x > 1.e-20 ) THEN
19798 arg = min(70.0, (-temcg(mgs)/x )) ! prevent overflow of the exp function in 32 bit
19799 dwr = 0.01*(exp(arg) - 1.0)
19800 ELSE
19801 dwr = 1.e30
19802 ENDIF
19803 d = dwr
19804 IF ( dwr < 0.2 .and. dwr > 0.0 .and. rho0(mgs)*(qx(mgs,lc)+qx(mgs,lr)) > 1.e-4 ) THEN
19805 sqrtrhovt = sqrt( rhovt(mgs) )
19806 fventh = sqrtrhovt*(fpndl(mgs)**(1./3.)) * (fakvisc(mgs))**(-0.5)
19807 fventm = sqrtrhovt*(fschm(mgs)**(1./3.)) * (fakvisc(mgs))**(-0.5)
19808 ltemq = (tfr-163.15)/fqsat+1.5
19809 qvs0 = pqs(mgs)*tabqvs(ltemq)
19810 denomdp = felf(mgs) + fcw(mgs)*temcg(mgs)
19811 denominvdp = 1.d0/(felf(mgs) + fcw(mgs)*temcg(mgs))
19812
19813! write(91,*) 'dw,dwr,temcg = ',100.*dw,100.*dwr,temcg(mgs)
19814 h1 = ( -ftka(mgs)*temcg(mgs) - felv(mgs)*fwvdf(mgs)*rho0(mgs)*(qx(mgs,lv) - qvs0) )
19815 h2 = ehi(mgs)*qx(mgs,li)*rho0(mgs)*fci(mgs)*temcg(mgs)
19816 h3 = max(dwehwmin, ehw(mgs))*qx(mgs,lc)
19817 h4 = ehr(mgs)* qx(mgs,lr)
19818 ! iterate to find minimum diameter for wet growth. Start with value of dwr
19819 DO n = 1,10
19820 d = max(d, 1.e-4)
19821 dold = d
19822 vth = axx(mgs,lh)*d**bxx(mgs,lh)
19823 x2 = fventh*sqrtrhovt*sqrt(d*vth)
19824 IF ( x2 > 1.4 ) THEN
19825 ah = 0.78 + 0.308*x2 ! heat ventillation
19826 ELSE
19827 ah = 1.0 + 0.108*x2**2 ! mass ventillation (Beard and Pruppacher 1971, eq. 9)
19828 ENDIF
19829
19830 IF ( .false. ) THEN ! this option includes 'am' separate from ah, which makes only small differences. Otherwise equivalent to second option
19831 x1 = fventm*sqrtrhovt*sqrt(d*vth)
19832 IF ( x1 > 1.4 ) THEN
19833 am = 0.78 + 0.308*x1 ! mass ventillation (Beard and Pruppacher 1971, eq. 8)
19834 ELSE
19835 am = 1.0 + 0.108*x1**2 ! mass ventillation (Beard and Pruppacher 1971, eq. 9)
19836 ENDIF
19837
19838 d = 8.*denominvdp*( am*felv(mgs)*fwvdf(mgs)*rho0(mgs)*(qvs0 - qx(mgs,lv)) - ah*ftka(mgs)*temcg(mgs) )/ &
19839 (dtp* ( ( max(0.001,vth - vtxbar(mgs,lc,1))*h3 + &
19840 max(0.001,vth - vtxbar(mgs,lr,1))*h4) *rho0(mgs) + &
19841 max(0.001,vth - vtxbar(mgs,li,1))*h2*denominvdp))
19842
19843 ELSE
19844
19845 ! Based on Farley and Orville (1986), eq. 5-9 but neglecting the Ci*(T0-Ts) term in (8) since we want Ts=T0
19846 ! Simplified mass rates as dm_w/dt = pi/4*d**2*(Vh - Vc)*rhoair*qc*ehw, etc.
19847 d = 8.*ah*h1/ &
19848 ( ( max(0.001,vth - vtxbar(mgs,lc,1))*h3 + &
19849 max(0.001,vth - vtxbar(mgs,lr,1))*h4) *rho0(mgs)*denomdp + &
19850 max(0.001,vth - vtxbar(mgs,li,1))*h2)
19851
19852 ENDIF
19853 IF ( abs(dold - d)/dold < 0.05 .or. ( n > 3 .and. d > dg0thresh ) ) EXIT
19854
19855 ENDDO
19856 ENDIF
19857
19858 dg0(mgs) = min( dwmax, max( d, dwmin ) )
19859 ELSE
19860 IF ( qx(mgs,lh) > qxmin(lh) .and. qx(mgs,lh) > hlcnhqmin .and. temg(mgs) .le. tfr-2.0 ) THEN
19861 dg0(mgs) = dwmax
19862 ELSE
19863 dg0(mgs) = dg0thresh + 0.0001
19864 ENDIF
19865 ENDIF
19866
19867 IF ( ihlcnh == 3 .and. (qhacw(mgs) + qhacr(mgs))*dtp > qxmin(lh) .and. qx(mgs,lh) > hlcnhqmin &
19868 .and. temg(mgs) .le. tfr-2.0 ) THEN
19869 ! set a secondary condition on to capture large graupel that is riming but not in wet growth
19870 dg0(mgs) = min( dg0(mgs), dg0thresh - 0.0001 )
19871 ENDIF
19872
19873 ENDIF
19874
19875 wtest = (dg0(mgs) > 0.0 .and. dg0(mgs) < dg0thresh )
19876
19877 IF ( ihlcnh == 1 ) THEN ! .or. iusedw == 0 THEN
19878
19879 IF ( ( wetgrowth(mgs) .and. (xdn(mgs,lh) .gt. hldnmn .or. lvh < 1 ) .and. & ! correct this when hail gets turned on
19880 & rimdn(mgs,lh) .gt. 800. .and. &
19881 & ltest .and. qx(mgs,lh) .gt. hlcnhqmin ) .or. wtest ) THEN ! {
19882! : xdia(mgs,lh,3) .gt. 2.e-3 .and. qx(mgs,lh) .gt. 1.0e-3 THEN ! 0823.2008 erm test
19883! IF ( xdia(mgs,lh,3) .gt. 1.e-3 ) THEN
19884 IF ( qhacw(mgs) .gt. 0.0 .and. qhacw(mgs) .gt. qhaci(mgs) .and. temg(mgs) .le. tfr-2.0 ) THEN ! {
19885 ! dh0 is the diameter dividing wet growth from dry growth (Ziegler 1985), modified by MY05
19886! dh0 = 0.01*(exp(temcg(mgs)/(1.1e4*(qx(mgs,lc)+qx(mgs,lr)) -
19887! : 1.3e3*qx(mgs,li) + 1.0e-3 ) ) - 1.0)
19888 IF ( wtest ) THEN
19889 dh0 = dg0(mgs)
19890 ELSE
19891 x = (1.1e4*(rho0(mgs)*qx(mgs,lc)) - 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0e-3 )
19892 IF ( x > 1.e-20 ) THEN
19893 arg = min(70.0, (-temcg(mgs)/x )) ! prevent overflow of the exp function in 32 bit
19894 dh0 = 0.01*(exp(arg) - 1.0)
19895 ELSE
19896 dh0 = 1.e30
19897 ENDIF
19898 ENDIF ! wtest
19899! dh0 = Max( dh0, 5.e-3 )
19900
19901! IF ( dh0 .gt. 0.0 ) write(0,*) 'dh0 = ',dh0
19902! IF ( dh0 .gt. 1.0e-4 ) THEN
19903 IF ( xdia(mgs,lh,3)/dh0 .gt. 0.1 ) THEN !{
19904! IF ( xdia(mgs,lh,3) .lt. 20.*dh0 .and. dh0 .lt. 2.0*xdia(mgs,lh,3) ) THEN
19905 tmp = qhacw(mgs) + qhacr(mgs) + qhaci(mgs) + qhacs(mgs)
19906! qtmp = Min( 1.0, xdia(mgs,lh,3)/(2.0*dh0) )*(tmp)
19907 qtmp = min( 100.0, xdia(mgs,lh,3)/(2.0*dh0) )*(tmp)
19908 qhlcnh(mgs) = min( qxmxd(mgs,lh), qtmp )
19909
19910 IF ( ipconc .ge. 5 ) THEN !{
19911! dh0 = Max( xdia(mgs,lh,3), Min( dh0, 5.e-3 ) ) ! do not create hail greater than 5mm diam. unless the graupel is larger
19912 IF ( .not. wtest ) dh0 = min( dh0, 10.e-3 ) ! do not create hail greater than 10mm diam., which is the max graupel size
19913 IF ( qx(mgs,lhl) > 0.1e-3 ) dh0 = max( dh0, xdia(mgs,lhl,3) ) ! when enough hail is established, do not dilute the size
19914 chlcnhhl(mgs) = min( cxmxd(mgs,lh), rho0(mgs)*qhlcnh(mgs)/(pi*xdn(mgs,lh)*dh0**3/6.0) )
19915
19916 r = rho0(mgs)*qhlcnh(mgs)/(xdn(mgs,lh)*xv(mgs,lh)) ! number of graupel particles at mean volume diameter
19917 chlcnh(mgs) = max( chlcnhhl(mgs), r )
19918 ENDIF !}
19919
19920 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
19921 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/max(xdnmn(lhl), xdn(mgs,lh))
19922
19923 ENDIF !}
19924
19925 ENDIF ! }
19926 ENDIF ! }
19927
19928 ELSEIF ( ihlcnh == 3 ) THEN !{
19929
19930
19931 IF ( wtest .and. &
19932 ( qhacw(mgs)*dtp > qxmin(lh) .and. temg(mgs) .lt. tfr-2. .and. qx(mgs,lh) > hlcnhqmin ) ) THEN
19933 ! convert number, mass, and reflectivity for d > dw
19934 IF ( ipconc == 5 ) THEN
19935 ! dg0(mgs) = Min( dg0(mgs), hldia1 )
19936 !dg0(mgs) = hldia1
19937 ENDIF
19938
19939 ratio = min( maxratiolu, dg0(mgs)/xdia(mgs,lh,1) )
19940
19941
19942 ! mass
19943 tmp2 = gaminterp(ratio,alpha(mgs,lh),4,1)
19944 IF ( ipconc == 5 ) THEN
19945 ! tmp2 = Min( 0.25, tmp2 )
19946 ENDIF
19947 qxd1 = qx(mgs,lh)*(tmp2)
19948 qhlcnh(mgs) = dtpinv*qxd1
19949 flim = 1.0
19950 tmp3 = qxmxd(mgs,lh)
19951 IF (qxd1 > tmp3 ) THEN
19952! flim = tmp3/(qxd1)
19953! qhlcnh(mgs) = flim*qhlcnh(mgs)
19954 ENDIF
19955
19956
19957
19958 IF ( ( qxd1 > qxmin(lhl) .and. ipconc > 5 ) .or. ( qxd1 > 10.*qxmin(lhl) .and. ipconc == 5) ) THEN
19959
19960 ! number
19961 tmp = gaminterp(ratio,alpha(mgs,lh),1,1)
19962 IF ( ipconc == 5 ) THEN
19963 ! tmp = Min( 0.2, tmp )
19964 ENDIF
19965 cxd1 = flim*cx(mgs,lh)*( tmp)
19966 chlcnh(mgs) = dtpinv*cxd1
19967 chlcnhhl(mgs) = chlcnh(mgs)
19968
19969 IF ( qx(mgs,lhl) > qxmin(lhl) .and. dmhlopt > 0 ) THEN
19970 tmp = rho0(mgs)*qhlcnh(mgs)/chlcnhhl(mgs)
19971 IF ( tmp < xmas(mgs,lhl) ) THEN
19972 ! dh0 = ( qxd1*dh0 + qx(mgs,lhl)*xmas(mgs,lhl))/( qxd1 + qx(mgs,lhl)) ! weighted average
19973 dh0 = (( qxd1*tmp**(1./3.) + qx(mgs,lhl)*xmas(mgs,lhl)**(1./3.))/( qxd1 + qx(mgs,lhl)))**3 ! weighted average
19974 chlcnhhl(mgs) = min( chlcnhhl(mgs), rho0(mgs)*qhlcnh(mgs)/dh0 )
19975 ELSE
19976! dh0 = Max( dh0, xmas(mgs,lhl) ) ! when enough hail is established, do not dilute the size
19977 ENDIF
19978 ENDIF
19979
19980
19981 ! reflectivity
19982 IF ( ipconc >= 6 .and. lzh > 1 .and. lzhl > 1 ) THEN
19983 tmp3 = gaminterp(ratio,alpha(mgs,lh),11,1)
19984 zxd1 = flim*zx(mgs,lh)*(tmp3)
19985 zhlcnh(mgs) = dtpinv*zxd1
19986 ELSE
19987 zxd1 = 0
19988 ENDIF
19989
19990 ELSE
19991 qhlcnh(mgs) = 0.0
19992 ENDIF
19993
19994 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
19995 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/max(xdnmn(lhl), xdn(mgs,lh))
19996
19997 ENDIF
19998
19999
20000 ENDIF !}
20001
20002 ENDDO
20003
20004 ELSEIF ( ihlcnh == 2 ) THEN ! 10-ice type conversion
20005
20006!
20007! Staka and Mansell (2005) type conversion
20008!
20009! hldia1 is set in micro_module and namelist
20010! IF ( .true. ) THEN
20011
20012 ! convert number, mass, and reflectivity for d > hldia1,
20013 ! regardless of wet growth status, but as long as riming > 0
20014 DO mgs = 1,ngscnt
20015 IF ( qhacw(mgs)*dtp > qxmin(lh) .and. temg(mgs) .lt. tfr-2. .and. qx(mgs,lh) > qxmin(lh) ) THEN
20016 ratio = min( maxratiolu, hldia1/xdia(mgs,lh,1) )
20017
20018 ! number
20019 tmp = gaminterp(ratio,alpha(mgs,lh),1,1)
20020 cxd1 = cx(mgs,lh)*( tmp)
20021 chlcnh(mgs) = dtpinv*cxd1
20022 chlcnhhl(mgs) = chlcnh(mgs)
20023
20024 ! mass
20025 tmp2 = gaminterp(ratio,alpha(mgs,lh),4,1)
20026 qxd1 = qx(mgs,lh)*(tmp2)
20027 qhlcnh(mgs) = dtpinv*qxd1
20028
20029 ! reflectivity
20030 IF ( lzh > 1 .and. lzhl > 1 ) THEN
20031 tmp3 = gaminterp(ratio,alpha(mgs,lh),11,1)
20032 zxd1 = zx(mgs,lh)*(tmp3)
20033 zhlcnh(mgs) = dtpinv*zxd1
20034 ELSE
20035 zxd1 = 0
20036 ENDIF
20037 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
20038 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/max(xdnmn(lhl), xdn(mgs,lh))
20039
20040 ENDIF
20041
20042 ENDDO
20043! ENDIF
20044 ELSEIF ( ihlcnh == 0 ) THEN
20045
20046 do mgs = 1,ngscnt
20047! qhlcnh(mgs) = 0.0
20048! chlcnh(mgs) = 0.0
20049 if ( wetgrowth(mgs) .and. temg(mgs) .lt. tfr-5. .and. qx(mgs,lh) > qxmin(lh) ) then
20050 if ( qhacw(mgs).gt.1.e-6 .and. xdn(mgs,lh) > 700. ) then
20051 qhlcnh(mgs) = &
20052 ((pi*xdn(mgs,lh)*cx(mgs,lh)) / (6.0*rho0(mgs)*dtp)) &
20053 *exp(-hldia1/xdia(mgs,lh,1)) &
20054 *( (hldia1**3) + 3.0*(hldia1**2)*xdia(mgs,lh,1) &
20055 + 6.0*(hldia1)*(xdia(mgs,lh,1)**2) + 6.0*(xdia(mgs,lh,1)**3) )
20056 qhlcnh(mgs) = min(qhlcnh(mgs),qhmxd(mgs))
20057 IF ( ipconc .ge. 5 ) THEN
20058 chlcnh(mgs) = min( cxmxd(mgs,lh), cx(mgs,lh)*exp(-hldia1/xdia(mgs,lh,1)))
20059 chlcnhhl(mgs) = chlcnh(mgs)
20060! chlcnh(mgs) = Min( cxmxd(mgs,lh), rho0(mgs)*qhlcnh(mgs)/(2.0*xmas(mgs,lh) ))
20061 ENDIF
20062 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
20063 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/max(xdnmn(lhl), xdn(mgs,lh))
20064 end if
20065 end if
20066 end do
20067
20068! ENDIF ! true
20069
20070 ENDIF ! ihlcnh options
20071
20072 ! convert low-density hail to graupel
20073 IF ( icvhl2h >= 1 ) THEN
20074 DO mgs = 1,ngscnt
20075 IF ( qx(mgs,lhl) > qxmin(lhl) .and. xdn(mgs,lhl) < 0.5*(xdnmn(lhl) + xdnmx(lhl)) ) THEN
20076 tmp = min(0.95, 1. - 0.5*(1. + tanh(0.125*(xdn(mgs,lhl) - 1.01*xdnmn(lhl) )) ))
20077 qhcnhl(mgs) = tmp*qx(mgs,lhl)*dtpinv
20078 chcnhl(mgs) = cx(mgs,lhl)*qhcnhl(mgs)/qx(mgs,lhl)
20079 vhcnhl(mgs) = vx(mgs,lhl)*qhcnhl(mgs)/qx(mgs,lhl)
20080
20081 ENDIF
20082 ENDDO
20083
20084 ENDIF
20085
20086 ENDIF ! lhl > 1
20087
20088
20089
20090
20091!
20092! Ziegler snow conversion to graupel
20093!
20094 DO mgs = 1,ngscnt
20095
20096 qhcns(mgs) = 0.0
20097 chcns(mgs) = 0.0
20098 chcnsh(mgs) = 0.0
20099 vhcns(mgs) = 0.0
20100
20101 qscnh(mgs) = 0.0
20102 cscnh(mgs) = 0.0
20103 vscnh(mgs) = 0.0
20104
20105 IF ( ipconc .ge. 5 ) THEN
20106
20107 ! test attempt at converting graupel to snow when not riming but growing by deposition
20108 IF ( temg(mgs) < tfr .and. qx(mgs,lh) .gt. qxmin(lh) .and. qhdpv(mgs) > qxmin(lh)*dtpinv &
20109 & .and. qhacw(mgs) < qxmin(lh)*dtpinv ) THEN
20110 IF ( xdn(mgs,lh) < 290. ) THEN
20111! qscnh(mgs) = 2.*qhdpv(mgs)
20112! cscnh(mgs) = cx(mgs,lh)*qscnh(mgs)/qx(mgs,lh)
20113! vscnh(mgs) = rho0(mgs)*qscnh(mgs)/xdn(mgs,lh)
20114 ENDIF
20115 ENDIF
20116
20117
20118 IF ( qx(mgs,ls) .gt. qxmin(ls) .and. qsacw(mgs) .gt. 0.0 ) THEN
20119
20120! DATA VGRA/1.413E-2/ ! this is the volume (cm**3) of a 3mm diam. sphere
20121! vgra = 1.4137e-8 m**3
20122
20123! DNNET=DNCNV-DNAGG
20124! DQNET=QXCON+QSACC+SDEP
20125!
20126! DNSCNV=EXP(-(ROS*XNS*VGRA/(RO*QI)))*((1.-(XNS*VGRA*ROS/
20127! / (RO*QI)))*DNNET + (XNS**2*VGRA*ROS/(RO*QI**2))*DQNET)
20128! IF(DNSCNV.LT.0.) DNSCNV=0.
20129!
20130! QIHC=(ROS*VGRA/RO)*DNSCNV
20131!
20132! QH=QH+DT*QIHC
20133! QI=QI-DT*QIHC
20134! XNH=XNH+DT*DNSCNV
20135! XNS=XNS-DT*DNSCNV
20136
20137 IF ( iglcnvs .eq. 1 ) THEN ! Zrnic, Ziegler et al (1993)
20138
20139 dnnet = cscnvis(mgs) + cscnis(mgs) - csacs(mgs)
20140 dqnet = qscnvi(mgs) + qscni(mgs) + qsacw(mgs) + qsdpv(mgs) + qssbv(mgs)
20141
20142 a3 = 1./(rho0(mgs)*qx(mgs,ls))
20143 a1 = exp( - xdn(mgs,ls)*cx(mgs,ls)*vgra*a3 ) !! EXP(-(ROS*XNS*VGRA/(RO*QI)))
20144! (1.-(XNS*VGRA*ROS/(RO*QI)))*DNNET
20145 a2 = (1.-(cx(mgs,ls)*vgra*xdn(mgs,ls)*a3))*dnnet
20146! (XNS**2*VGRA*ROS/(RO*QI**2))*DQNET
20147 a4 = cx(mgs,ls)**2*vgra*xdn(mgs,ls)*a3/qx(mgs,ls)*dqnet
20148
20149 chcns(mgs) = max( 0.0, a1*(a2 + a4) )
20150 chcns(mgs) = min( chcns(mgs), cxmxd(mgs,ls) )
20151 chcnsh(mgs) = chcns(mgs)
20152
20153 qhcns(mgs) = min( xdn(mgs,ls)*vgra*rhoinv(mgs)*chcns(mgs), qxmxd(mgs,ls) )
20154 vhcns(mgs) = rho0(mgs)*qhcns(mgs)/max(xdn(mgs,ls),xdnmn(lh))
20155! vhcns(mgs) = rho0(mgs)*qhcns(mgs)/Max(xdn(mgs,ls),400.)
20156
20157 ELSEIF ( iglcnvs .ge. 2 ) THEN ! treat like ice crystals, i.e., check for rime density (ERM)
20158
20159 IF ( temg(mgs) .lt. 273.0 .and. ( qsacw(mgs) - qsdpv(mgs) .gt. 0.0 .or. &
20160 ( iglcnvs >= 3 .and. qsacw(mgs)*dtp > 2.*qxmin(lh) .and. gamsnow73fac*xmas(mgs,ls) > xdnmn(lh)*xvmn(lh) ) ) ) THEN !{
20161
20162
20163 tmp = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
20164 & *((0.60)*vtxbar(mgs,ls,1)) &
20165 & /(temg(mgs)-273.15))**(rimc2)
20166! tmp = Min( Max( rimc3, tmp ), 900.0 )
20167 tmp = min( tmp , 900.0 )
20168
20169 ! Assume that half the volume of the embryo is rime with density 'tmp'
20170 ! m = rhoi*(V/2) + rhorime*(V/2) = (rhoi + rhorime)*V/2
20171 ! V = 2*m/(rhoi + rhorime)
20172
20173! write(0,*) 'rime dens = ',tmp
20174
20175 IF ( iglcnvs == 2 ) THEN !{
20176 IF ( tmp .ge. 200.0 ) THEN
20177 r = max( 0.5*(xdn(mgs,ls) + tmp), xdnmn(lh) )
20178! r = Max( r, 400. )
20179 qhcns(mgs) = (qsacw(mgs) - qsdpv(mgs))
20180 chcns(mgs) = cx(mgs,ls)*qhcns(mgs)/qx(mgs,ls)
20181! chcnih(mgs) = rho0(mgs)*qhcni(mgs)/(1.6e-10)
20182 chcnsh(mgs) = min(chcns(mgs), rho0(mgs)*qhcns(mgs)/(r*xvmn(lh)) )
20183! vhcni(mgs) = rho0(mgs)*2.0*qhcni(mgs)/(xdn(mgs,li) + tmp)
20184 vhcns(mgs) = rho0(mgs)*qhcns(mgs)/r
20185 ENDIF
20186
20187 ELSEIF ( iglcnvs == 3 ) THEN
20188
20189 ! convert to particles with the mass of the mass-weighted diameter
20190 ! massofmwr = gamice73fac*xmas(mgs,li)
20191
20192 IF ( tmp > xdnmn(lh) ) THEN
20193 r = max( 0.5*(xdn(mgs,ls) + tmp), xdnmn(lh) )
20194! r = Max( r, 400. )
20195 qhcns(mgs) = 0.5*qsacw(mgs)
20196 chcns(mgs) = qhcns(mgs)/(gamsnow73fac*xmas(mgs,ls))
20197 chcns(mgs) = min( chcns(mgs), cx(mgs,ls)*qhcns(mgs)/qx(mgs,ls))
20198 chcnsh(mgs) = min(chcns(mgs), rho0(mgs)*qhcns(mgs)/(r*xvmn(lh)) )
20199 vhcns(mgs) = rho0(mgs)*qhcns(mgs)/r
20200 ENDIF
20201
20202 ENDIF !}
20203
20204 ENDIF !}
20205
20206 ENDIF
20207
20208
20209 ENDIF
20210
20211 ELSE ! single moment lfo
20212
20213 qhcns(mgs) = 0.001*ehscnv(mgs)*max((qx(mgs,ls)-6.e-4),0.0)
20214 qhcns(mgs) = min(qhcns(mgs),qxmxd(mgs,ls))
20215 IF ( lvol(lh) .ge. 1 ) vhcns(mgs) = rho0(mgs)*qhcns(mgs)/max(xdn(mgs,ls),400.)
20216
20217 ENDIF
20218 ENDDO
20219!
20220!
20221! heat budget for rain---not all rain that collects ice can freeze
20222!
20223!
20224!
20225 if ( irwfrz .gt. 0 .and. .not. mixedphase) then
20226!
20227 do mgs = 1,ngscnt
20228!
20229! compute total rain that freeze when it interacts with cloud ice
20230!
20231 qrztot(mgs) = qrfrz(mgs) + qiacr(mgs) + qsacr(mgs)
20232!
20233! compute the maximum amount of rain that can freeze
20234! Used to limit freezing to 4*qrmxd, but now allow all rain to freeze if possible
20235!
20236 qrzmax(mgs) = &
20237 & ( xdia(mgs,lr,1)*rwvent(mgs)*cx(mgs,lr)*fwet1(mgs) )
20238 qrzmax(mgs) = max(qrzmax(mgs), 0.0)
20239 qrzmax(mgs) = min(qrztot(mgs), qrzmax(mgs))
20240 qrzmax(mgs) = min(qx(mgs,lr)*dtpinv, qrzmax(mgs))
20241
20242 IF ( temcg(mgs) < -30. ) THEN ! allow all to freeze if T < -30 because fwet becomes invalid (negative)
20243 qrzmax(mgs) = qx(mgs,lr)*dtpinv
20244 ENDIF
20245! qrzmax(mgs) = min(4.*qrmxd(mgs), qrzmax(mgs))
20246!
20247! compute the correction factor
20248!
20249! IF ( qrztot(mgs) .gt. qxmin(lr) ) THEN
20250 IF ( qrztot(mgs) .gt. qrzmax(mgs) .and. qrztot(mgs) .gt. qxmin(lr) ) THEN
20251 qrzfac(mgs) = qrzmax(mgs)/(qrztot(mgs))
20252 ELSE
20253 qrzfac(mgs) = 1.0
20254 ENDIF
20255 qrzfac(mgs) = min(1.0, qrzfac(mgs))
20256!
20257 end do
20258!
20259!
20260! now correct the above sources
20261!
20262!
20263 do mgs = 1,ngscnt
20264 if ( temg(mgs) .le. 273.15 .and. qrzfac(mgs) .lt. 1.0 ) then
20265 qrfrz(mgs) = qrzfac(mgs)*qrfrz(mgs)
20266 qrfrzs(mgs) = qrzfac(mgs)*qrfrzs(mgs)
20267 qrfrzf(mgs) = qrzfac(mgs)*qrfrzf(mgs)
20268 qiacr(mgs) = qrzfac(mgs)*qiacr(mgs)
20269 qsacr(mgs) = qrzfac(mgs)*qsacr(mgs)
20270 qiacrf(mgs) = qrzfac(mgs)*qiacrf(mgs)
20271 qiacrs(mgs) = qrzfac(mgs)*qiacrs(mgs)
20272 crfrz(mgs) = qrzfac(mgs)*crfrz(mgs)
20273 crfrzf(mgs) = qrzfac(mgs)*crfrzf(mgs)
20274 crfrzs(mgs) = qrzfac(mgs)*crfrzs(mgs)
20275 ciacr(mgs) = qrzfac(mgs)*ciacr(mgs)
20276 ciacrf(mgs) = qrzfac(mgs)*ciacrf(mgs)
20277 ciacrs(mgs) = qrzfac(mgs)*ciacrs(mgs)
20278
20279! IF ( lzh .gt. 1 ) THEN
20280! zrfrzf(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,lr)+2.)/(xdn0(lr)**2*(alpha(mgs,lr)+1.)) * &
20281! ( 2.*tmp * qrfrzf(mgs) - tmp**2 * crfrzf(mgs) )
20282! ENDIF
20283
20284 vrfrzf(mgs) = qrzfac(mgs)*vrfrzf(mgs)
20285 viacrf(mgs) = qrzfac(mgs)*viacrf(mgs)
20286 end if
20287 end do
20288!
20289!
20290!
20291 end if
20292!
20293!
20294!
20295! evaporation of rain
20296!
20297!
20298!
20299 qrcev(:) = 0.0
20300 crcev(:) = 0.0
20301
20302
20303 do mgs = 1,ngscnt
20304!
20305 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
20306
20307 qrcev(mgs) = &
20308 & fvce(mgs)*cx(mgs,lr)*rwvent(mgs)*rwcap(mgs)*evapfac
20309! this line to allow condensation on rain:
20310 IF ( rcond .eq. 1 ) THEN
20311 qrcev(mgs) = min(qrcev(mgs), qxmxd(mgs,lv))
20312! this line to have evaporation only:
20313 ELSE
20314 qrcev(mgs) = min(qrcev(mgs), 0.0)
20315 ENDIF
20316
20317 qrcev(mgs) = max(qrcev(mgs), -qrmxd(mgs))
20318! if ( temg(mgs) .lt. 273.15 ) qrcev(mgs) = 0.0
20319 IF ( qrcev(mgs) .lt. 0. .and. lnr > 1 ) THEN
20320! qrcev(mgs) = -qrmxd(mgs)
20321! crcev(mgs) = (rho0(mgs)/(xmas(mgs,lr)+1.e-20))*qrcev(mgs)
20322 IF ( icrcev == 1 ) THEN
20323 crcev(mgs) = (cx(mgs,lr)/(qx(mgs,lr)))*qrcev(mgs)
20324 ELSEIF ( icrcev == 2 ) THEN
20325 crcev(mgs) = (cx(mgs,lr)/(qx(mgs,lr)))*qrcev(mgs)*vtxbar(mgs,lr,2)/vtxbar(mgs,lr,1)
20326 ELSE
20327 crcev(mgs) = 0.0
20328 ENDIF
20329 ELSE
20330 crcev(mgs) = 0.0
20331 ENDIF
20332! if ( temg(mgs) .lt. 273.15 ) crcev(mgs) = 0.0
20333!
20334 ENDIF
20335
20336 end do
20337!
20338! evaporation/condensation of wet graupel and snow
20339!
20340 IF ( lhwlg > 1 ) THEN
20341 qhcevlg(:) = 0.0
20342 chcevlg(:) = 0.0
20343 ENDIF
20344 IF ( lhlwlg > 1 ) THEN
20345 qhlcevlg(:) = 0.0
20346 chlcevlg(:) = 0.0
20347 ENDIF
20348
20349
20350!
20351!
20352!
20353! ICE MULTIPLICATION: Two modes (rimpa, and rimpb)
20354! (following Cotton et al. 1986)
20355!
20356
20357 chmul1(:) = 0.0
20358 chlmul1(:) = 0.0
20359 csmul1(:) = 0.0
20360!
20361 qhmul1(:) = 0.0
20362 qhlmul1(:) = 0.0
20363 qsmul1(:) = 0.0
20364 do mgs = 1,ngscnt
20365
20366 ltest = qx(mgs,lh) .gt. qxmin(lh)
20367 IF ( lhl > 1 ) ltest = ltest .or. qx(mgs,lhl) .gt. qxmin(lhl)
20368
20369 IF ( (itype1 .ge. 1 .or. itype2 .ge. 1 ) &
20370 & .and. qx(mgs,lc) .gt. qxmin(lc)) THEN
20371 if ( temg(mgs) .ge. 265.15 .and. temg(mgs) .le. 271.15 ) then
20372 IF ( ipconc .ge. 2 ) THEN
20373 IF ( xv(mgs,lc) .gt. 0.0 &
20374 & .and. ltest &
20375! .and. itype2 .ge. 2 &
20376 & ) THEN
20377!
20378! Ziegler et al. 1986 Hallett-Mossop process. VSTAR = 7.23e-15 (vol of 12micron radius)
20379!
20380 IF ( alpha(mgs,lc) == 0.0 ) THEN
20381 ex1 = (1./250.)*exp(-7.23e-15/xv(mgs,lc))
20382 ELSE
20383
20384 ratio = (1. + alpha(mgs,lc))*(7.23e-15)/xv(mgs,lc)
20385
20386 IF ( usegamxinfcnu ) THEN
20387 i = nint(dgami*(1. + alpha(mgs,lc)))
20388 gcnup1 = gmoi(i)
20389 ex1 = (1./250.)*gamxinf(1.+alpha(mgs,lc), ratio)/(gcnup1)
20390 ELSE
20391 ratio = min( maxratiolu, ratio )
20392 tmp = gaminterp(ratio,alpha(mgs,lc),1,1)
20393 ex1 = (1./250.)*tmp
20394 ENDIF
20395 ENDIF
20396 IF ( itype2 .le. 2 ) THEN
20397 ft = max(0.0,min(1.0,-0.11*temcg(mgs)**2 - 1.1*temcg(mgs)-1.7))
20398 ELSE
20399 IF ( temg(mgs) .ge. 265.15 .and. temg(mgs) .le. 267.15 ) THEN
20400 ft = 0.5
20401 ELSEIF (temg(mgs) .ge. 267.15 .and. temg(mgs) .le. 269.15 ) THEN
20402 ft = 1.0
20403 ELSEIF (temg(mgs) .ge. 269.15 .and. temg(mgs) .le. 271.15 ) THEN
20404 ft = 0.5
20405 ELSE
20406 ft = 0.0
20407 ENDIF
20408 ENDIF
20409! rhoinv = 1./rho0(mgs)
20410! DNSTAR = ex1*cglacw(mgs)
20411
20412 IF ( ft > 0.0 ) THEN
20413
20414 IF ( itype2 > 0 ) THEN
20415 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. (.not. wetsfc(mgs)) ) THEN
20416 chmul1(mgs) = ft*ex1*chacw(mgs)
20417! 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
20418 qhmul1(mgs) = cimas0*chmul1(mgs)*rhoinv(mgs)
20419 ENDIF
20420 IF ( lhl .gt. 1 ) THEN
20421 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. (.not. wetsfchl(mgs)) ) THEN
20422 chlmul1(mgs) = (ft*ex1*chlacw(mgs))
20423 qhlmul1(mgs) = cimas0*chlmul1(mgs)*rhoinv(mgs)
20424 ENDIF
20425 ENDIF
20426 ENDIF ! itype2
20427
20428 IF ( itype1 > 0 ) THEN
20429 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. (.not. wetsfc(mgs)) ) THEN
20430 tmp = ft*(3.5e+08)*rho0(mgs)*qhacw(mgs)
20431 chmul1(mgs) = chmul1(mgs) + tmp
20432 qhmul1(mgs) = qhmul1(mgs) + cimas0*tmp*rhoinv(mgs)
20433 ENDIF
20434 IF ( lhl .gt. 1 ) THEN
20435 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. (.not. wetsfchl(mgs)) ) THEN
20436 tmp = ft*(3.5e+08)*rho0(mgs)*qhlacw(mgs)
20437 chlmul1(mgs) = chlmul1(mgs) + tmp
20438 qhlmul1(mgs) = qhlmul1(mgs) + cimas0*tmp*rhoinv(mgs)
20439 ENDIF
20440 ENDIF
20441 ENDIF ! itype1
20442
20443
20444 ENDIF ! ft
20445
20446 ENDIF ! xv(mgs,lc) .gt. 0.0 .and.
20447
20448 ELSE ! ipconc .lt. 2
20449!
20450! define the temperature function
20451!
20452 fimt1(mgs) = 0.0
20453!
20454! Cotton et al. (1986) version
20455!
20456 if ( temg(mgs) .ge. 268.15 .and. temg(mgs) .le. 270.15 ) then
20457 fimt1(mgs) = 1.0 -(temg(mgs)-268.15)/2.0
20458 elseif (temg(mgs) .le. 268.15 .and. temg(mgs) .ge. 265.15 ) then
20459 fimt1(mgs) = 1.0 +(temg(mgs)-268.15)/3.0
20460 ELSE
20461 fimt1(mgs) = 0.0
20462 end if
20463!
20464! Ferrier (1994) version
20465!
20466 if ( temg(mgs) .ge. 265.15 .and. temg(mgs) .le. 267.15 ) then
20467 fimt1(mgs) = 0.5
20468 elseif (temg(mgs) .ge. 267.15 .and. temg(mgs) .le. 269.15 ) then
20469 fimt1(mgs) = 1.0
20470 elseif (temg(mgs) .ge. 269.15 .and. temg(mgs) .le. 271.15 ) then
20471 fimt1(mgs) = 0.5
20472 ELSE
20473 fimt1(mgs) = 0.0
20474 end if
20475!
20476!
20477! type I: 350 splinters are formed for every 1e-3 grams of cloud
20478! water accreted by graupel/hail (note converted to MKS units)
20479! 3.5e+8 has units of 1/kg
20480!
20481 IF ( itype1 .ge. 1 ) THEN
20482 fimta(mgs) = (3.5e+08)*rho0(mgs)
20483 ELSE
20484 fimta(mgs) = 0.0
20485 ENDIF
20486
20487!
20488!
20489! type II: 1 splinter formed for every 250 cloud droplets larger than
20490! 24 micons in diameter (12 microns in radius) accreted by
20491! graupel/hail
20492!
20493!
20494 fimt2(mgs) = 0.0
20495 xcwmas = xmas(mgs,lc) * 1000.
20496!
20497 IF ( itype2 .ge. 1 ) THEN
20498 if ( xcwmas.lt.1.26e-9 ) then
20499 fimt2(mgs) = 0.0
20500 end if
20501 if ( xcwmas .le. 3.55e-9 .and. xcwmas .ge. 1.26e-9 ) then
20502 fimt2(mgs) = (2.27)*alog(xcwmas) + 13.39
20503 end if
20504 if ( xcwmas .gt. 3.55e-9 ) then
20505 fimt2(mgs) = 1.0
20506 end if
20507
20508 fimt2(mgs) = min(fimt2(mgs),1.0)
20509 fimt2(mgs) = max(fimt2(mgs),0.0)
20510
20511 ENDIF
20512!
20513! qhmul2 = 0.0
20514! qsmul2 = 0.0
20515!
20516! qhmul2 =
20517! > (4.0e-03)*fimt1(mgs)*fimt2(mgs)*qhacw(mgs)
20518! qsmul2 =
20519! > (4.0e-03)*fimt1(mgs)*fimt2(mgs)*qsacw(mgs)
20520!
20521! cimas0 = (1.0e-12)
20522! cimas0 = 2.5e-10
20523 IF ( .not. wetsfc(mgs) ) THEN
20524 chmul1(mgs) = fimt1(mgs)*(fimta(mgs) + &
20525 & (4.0e-03)*fimt2(mgs))*qhacw(mgs)
20526 ENDIF
20527!
20528 qhmul1(mgs) = chmul1(mgs)*(cimas0/rho0(mgs))
20529
20530 IF ( lhl .gt. 1 ) THEN
20531 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. (.not. wetsfchl(mgs)) ) THEN
20532 tmp = fimt1(mgs)*(fimta(mgs) + &
20533 & (4.0e-03)*fimt2(mgs))*qhlacw(mgs)
20534 chlmul1(mgs) = tmp
20535 qhlmul1(mgs) = cimas0*tmp*rhoinv(mgs)
20536 ENDIF
20537 ENDIF
20538
20539! qsmul1(mgs) = csmul1(mgs)*(cimas0/rho0(mgs))
20540!
20541 ENDIF ! ( ipconc .ge. 2 )
20542
20543 end if ! (in temperature range)
20544
20545 ENDIF ! ( itype1 .eq. 1 .or. itype2 .eq. 1)
20546!
20547 end do
20548!
20549!
20550!
20551! end if
20552!
20553! end do
20554!
20555!
20556! ICE MULTIPLICATION FROM SNOW
20557! Lo and Passarelli 82 / Willis and Heymsfield 89 / Schuur and Rutledge 00b
20558! using kfrag as fragmentation rate (s-1) / 500 microns as char mean diam for max snow mix ratio
20559!
20560 csmul(:) = 0.0
20561 qsmul(:) = 0.0
20562
20563 IF ( isnwfrac /= 0 ) THEN
20564 do mgs = 1,ngscnt
20565 IF (temg(mgs) .gt. 265.0) THEN !{
20566 if (xdia(mgs,ls,1) .gt. 100.e-6 .and. xdia(mgs,ls,1) .lt. 2.0e-3) then ! equiv diameter 100microns to 2mm
20567
20568 tmp = rhoinv(mgs)*pi*xdn(mgs,ls)*cx(mgs,ls)*(500.e-6)**3
20569 qsmul(mgs) = max( kfrag*( qx(mgs,ls) - tmp ) , 0.0 )
20570
20571 qsmul(mgs) = min( qxmxd(mgs,li), qsmul(mgs) )
20572 csmul(mgs) = min( cxmxd(mgs,li), rho0(mgs)*qsmul(mgs)/mfrag )
20573
20574 endif
20575 ENDIF !}
20576 enddo
20577 ENDIF
20578
20579!
20580! frozen rain-rain interaction....
20581!
20582!
20583!
20584!
20585! rain-ice interaction
20586!
20587!
20588 do mgs = 1,ngscnt
20589 qracif(mgs) = qraci(mgs)
20590 cracif(mgs) = craci(mgs)
20591! ciacrf(mgs) = ciacr(mgs)
20592 end do
20593!
20594!
20595! vapor to pristine ice crystals UP
20596!
20597!
20598!
20599! compute the nucleation rate
20600!
20601! do mgs = 1,ngscnt
20602! idqis = 0
20603! if ( ssi(mgs) .gt. 1.0 ) idqis = 1
20604! fiinit(mgs) = (felv(mgs)**2)/(cp*rw)
20605! dqisdt(mgs) = (qx(mgs,lv)-qis(mgs))/
20606! > (1.0 + fiinit(mgs)*qis(mgs)/tsqr(mgs))
20607! qidsvp(mgs) = dqisdt(mgs)
20608! cnnt = min(cnit*exp(-temcg(mgs)*bta1),1.0e+09)
20609! qiint(mgs) =
20610! > il5(mgs)*idqis*(1.0*dtpinv)
20611! < *min((6.88e-13)*cnnt/rho0(mgs), 0.25*dqisdt(mgs))
20612! end do
20613!
20614! Meyers et al. (1992; JAS) and Ferrier (1994) primary ice nucleation
20615!
20616 cmassin = cimasn ! 6.88e-13
20617 do mgs = 1,ngscnt
20618 qiint(mgs) = 0.0
20619 ciint(mgs) = 0.0
20620 qicicnt(mgs) = 0.0
20621 cicint(mgs) = 0.0
20622 qipipnt(mgs) = 0.0
20623 cipint(mgs) = 0.0
20624 ccitmp = 0.0
20625 IF ( icenucopt == 1 .or. icenucopt == -10 .or. icenucopt == -11 ) THEN
20626 if ( ( temg(mgs) .lt. 268.15 .or. &
20627! : ( imeyers5 .and. temg(mgs) .lt. 273.0) ) .and. &
20628 & ( imeyers5 .and. temg(mgs) .lt. 272.0 .and. temgkm2(mgs) .lt. tfr) ) .and. &
20629 & ciintmx .gt. (cx(mgs,li)+ccitmp) &
20630! : .and. cninm(mgs) .gt. 0. &
20631 & ) then
20632 fiinit(mgs) = (felv(mgs)**2)/(cp*rw)
20633 dqisdt(mgs) = (qx(mgs,lv)-qis(mgs))/ &
20634 & (1.0 + fiinit(mgs)*qis(mgs)/tsqr(mgs))
20635! qidsvp(mgs) = dqisdt(mgs)
20636 idqis = 0
20637 if ( ssi(mgs) .gt. 1.0 ) THEN
20638 idqis = 1
20639 dzfacp = max( float(kgsp(mgs)-kgs(mgs)), 0.0 )
20640 dzfacm = max( float(kgs(mgs)-kgsm(mgs)), 0.0 )
20641 qiint(mgs) = &
20642 & idqis*il5(mgs) &
20643 & *(cmassin/rho0(mgs)) &
20644 & *max(0.0,wvel(mgs)) &
20645 & *max((cninp(mgs)-cninm(mgs)),0.0)/gz(igs(mgs),jgs,kgs(mgs)) &
20646 & /((dzfacp+dzfacm))
20647
20648 qiint(mgs) = min(qiint(mgs), max(0.25*dqisdt(mgs),0.0))
20649 ciint(mgs) = qiint(mgs)*rho0(mgs)/cmassin
20650
20651!
20652! limit new crystals so it does not increase the current concentration
20653! above ciintmx 20,000 per liter (2.e7 per m**3)
20654!
20655! ciintmx = 1.e9
20656! ciintmx = 1.e9
20657 IF ( icenucopt /= -10 ) THEN
20658
20659 IF ( lcin > 1 ) THEN
20660 ciint(mgs) = min(ciint(mgs), ccin(mgs)*dtpinv) ! because ciint is a *rate*
20661 ccin(mgs) = ccin(mgs) - ciint(mgs)*dtp
20662 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
20663 ELSEIF ( lcina > 1 ) THEN
20664 ciint(mgs) = max(0.0, min( ciint(mgs), min( cnina(mgs), ciintmx ) - cina(mgs) ))
20665 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
20666
20667 ELSEIF ( icenucopt == 1 .and. ciint(mgs) .gt. max(0.0, ciintmx - cx(mgs,li) - ccitmp )*dtpinv ) THEN
20668 ciint(mgs) = max(0.0, ciintmx - (cx(mgs,li)) )*dtpinv
20669 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
20670
20671 ELSEIF ( icenucopt == -11 .and. dtp*ciint(mgs) .gt. ( cnina(mgs) - (cx(mgs,li) - ccitmp))) THEN
20672 ciint(mgs) = max(0.0, cnina(mgs) - (cx(mgs,li)+ccitmp)*dtpinv )
20673 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
20674
20675 ENDIF
20676 ENDIF
20677
20678 end if
20679 endif
20680
20681 ELSEIF ( icenucopt == 2 .or. icenucopt == -1 .or. icenucopt == -2 ) THEN
20682
20683 IF ( ( temg(mgs) .lt. 268.15 .and. ssw(mgs) > 1.0 ) .or. ssi(mgs) > 1.25 ) THEN
20684 IF ( lcin > 1 ) THEN
20685 ciint(mgs) = min(cnina(mgs), ccin(mgs))
20686 ciint(mgs) = min( ciint(mgs), max(0.0, ciintmx - (cx(mgs,li) - ccitmp) ) ) ! do not initiate ice beyond concentration of ciintmx
20687 ccin(mgs) = ccin(mgs) - ciint(mgs)
20688 ciint(mgs) = ciint(mgs)*dtpinv ! convert total initiation to a rate
20689 ELSE
20690 ciint(mgs) = max( 0.0, cnina(mgs) - cina(mgs) )*dtpinv
20691 ENDIF
20692 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
20693
20694 fiinit(mgs) = (felv(mgs)**2)/(cp*rw)
20695 dqisdt(mgs) = (qx(mgs,lv)-qis(mgs))/(1.0 + fiinit(mgs)*qis(mgs)/tsqr(mgs))
20696 qiint(mgs) = min(qiint(mgs), max(0.25*dqisdt(mgs),0.0))
20697 ciint(mgs) = qiint(mgs)*rho0(mgs)/cmassin
20698 ENDIF
20699
20700
20701
20702 ELSEIF ( icenucopt == 3 .or. icenucopt == 4 .or. icenucopt == 10 ) THEN
20703 IF ( temg(mgs) .lt. 268.15 ) THEN
20704 IF ( lcin > 1 ) THEN
20705 ciint(mgs) = min(cnina(mgs), ccin(mgs))
20706 ciint(mgs) = min( ciint(mgs), max(0.0, ciintmx - (cx(mgs,li) + ccitmp) ) ) ! do not initiate ice beyond concentration of ciintmx
20707 ccin(mgs) = ccin(mgs) - ciint(mgs)
20708 ciint(mgs) = ciint(mgs)*dtpinv ! convert total initiation to a rate
20709 ELSE
20710 ciint(mgs) = max( 0.0, cnina(mgs) - cina(mgs) )*dtpinv
20711 ENDIF
20712 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
20713 ENDIF
20714
20715 ENDIF
20716!
20717 if ( xplate(mgs) .eq. 1 ) then
20718 qipipnt(mgs) = qiint(mgs)
20719 cipint(mgs) = ciint(mgs)
20720 end if
20721!
20722 if ( xcolmn(mgs) .eq. 1 ) then
20723 qicicnt(mgs) = qiint(mgs)
20724 cicint(mgs) = ciint(mgs)
20725 end if
20726!
20727! qipipnt(mgs) = 0.0
20728! qicicnt(mgs) = qiint(mgs)
20729!
20730 end do
20731!
20732!
20733
20734!
20735! vapor to cloud droplets UP
20736!
20737 if (ndebug .gt. 0 ) write(0,*) 'dbg = 8'
20738!
20739!
20740 if (ndebug .gt. 0 ) write(0,*) 'Collection: set 3-component'
20741!
20742! time for riming....
20743!
20744! rimtim = 240.0
20745! dtrim = rimtim
20746! xacrtim = 120.0
20747! tranfr = 0.50
20748! tranfw = 0.50
20749!
20750! coefficients for riming
20751!
20752! rimc1 = 300.00
20753! rimc2 = 0.44
20754!
20755!
20756! zero some arrays
20757!
20758!
20759 do mgs = 1,ngscnt
20760 qrshr(mgs) = 0.0
20761 qwshw(mgs) = 0.0
20762 cwshw(mgs) = 0.0
20763 qsshrp(mgs) = 0.0
20764 qhshrp(mgs) = 0.0
20765 end do
20766!
20767!
20768! first sum all of the shed rain
20769!
20770!
20771 do mgs = 1,ngscnt
20772 qrshr(mgs) = qsshr(mgs) + qhshr(mgs) + qhlshr(mgs)
20773 crshr(mgs) = chshrr(mgs)/rzxh(mgs) + chlshrr(mgs)/rzxhl(mgs)
20774
20775
20776 IF ( ipconc .ge. 3 ) THEN
20777! crshr(mgs) = Max(crshr(mgs), rho0(mgs)*qrshr(mgs)/(xdn(mgs,lr)*vr1mm) )
20778 ENDIF
20779 end do
20780!
20781!
20782!
20783
20784!
20785!
20786!
20787!
20788 IF ( ipconc .ge. 1 ) THEN
20789!
20790!
20791! concentration production terms
20792!
20793! YYY
20794!
20795!
20796! DO mgs = 1,ngscnt
20797 pccwi(:) = 0.0
20798 pccwd(:) = 0.0
20799 pccwdacc(:) = 0.0
20800 pccii(:) = 0.0
20801 pccin(:) = 0.0
20802 pccid(:) = 0.0
20803 pcisi(:) = 0.0
20804 pcisd(:) = 0.0
20805 pcrwi(:) = 0.0
20806 pcrwd(:) = 0.0
20807 pcswi(:) = 0.0
20808 pcswd(:) = 0.0
20809 pchwi(:) = 0.0
20810 pchwd(:) = 0.0
20811 pchli(:) = 0.0
20812 pchld(:) = 0.0
20813! ENDDO
20814!
20815! Cloud ice
20816!
20817! IF ( ipconc .ge. 1 ) THEN
20818
20819 IF ( warmonly < 0.5 ) THEN
20820 IF ( ffrzs < 1.0 ) THEN
20821 do mgs = 1,ngscnt
20822 pccii(mgs) = &
20823 & il5(mgs)*cicint(mgs) &
20824 & +il5(mgs)*((1.0-cwfrz2snowfrac)*cwfrzc(mgs)+cwctfzc(mgs) &
20825 & +cicichr(mgs)) &
20826 & +chmul1(mgs) &
20827 & +chlmul1(mgs) &
20828 & + csplinter(mgs) + csplinter2(mgs) &
20829 & +csmul(mgs)
20830
20831 pccii(mgs) = pccii(mgs)*(1.0 - ffrzs)
20832
20833! > + nsplinter*(crfrzf(mgs) + crfrz(mgs))
20834 pccid(mgs) = &
20835 & il5(mgs)*(-cscni(mgs) - cscnvi(mgs) & ! - cwaci(mgs) &
20836 & -craci(mgs) &
20837 & -csaci(mgs) &
20838 & -chaci(mgs) - chlaci(mgs) &
20839 & -chcni(mgs)) &
20840 & +il5(mgs)*cisbv(mgs) &
20841 & -(1.-il5(mgs))*cimlr(mgs)
20842
20843 pccin(mgs) = ciint(mgs)
20844
20845
20846 end do
20847 ENDIF ! ffrzs
20848 ELSEIF ( warmonly < 0.8 ) THEN
20849 do mgs = 1,ngscnt
20850
20851! qiint(mgs) = 0.0
20852! cicint(mgs) = 0.0
20853! qicicnt(mgs) = 0.0
20854
20855 pccii(mgs) = &
20856 & il5(mgs)*cicint(mgs) &
20857 & +il5(mgs)*((1.0-cwfrz2snowfrac)*cwfrzc(mgs)+cwctfzc(mgs) &
20858 & +cicichr(mgs)) &
20859 & +chmul1(mgs) &
20860 & +chlmul1(mgs) &
20861 & + csplinter(mgs) + csplinter2(mgs) &
20862 & +csmul(mgs)
20863
20864 pccii(mgs) = pccii(mgs)*(1. - ffrzs)
20865 pccid(mgs) = &
20866! & il5(mgs)*(-cscni(mgs) - cscnvi(mgs) & ! - cwaci(mgs) &
20867! & -craci(mgs) &
20868! & -csaci(mgs) &
20869! & -chaci(mgs) - chlaci(mgs) &
20870! & -chcni(mgs)) &
20871 & +il5(mgs)*cisbv(mgs) &
20872 & -(1.-il5(mgs))*cimlr(mgs)
20873
20874 pccin(mgs) = ciint(mgs)
20875
20876 end do
20877 ENDIF ! warmonly
20878
20879
20880! ENDIF ! ( ipconc .ge. 1 )
20881!
20882! Cloud water
20883!
20884 IF ( ipconc .ge. 2 ) THEN
20885
20886 do mgs = 1,ngscnt
20887 pccwi(mgs) = (0.0) - cwshw(mgs) ! + (1-il5(mgs))*(-cirmlw(mgs))
20888
20889 IF ( warmonly < 0.5 ) THEN
20890 pccwd(mgs) = &
20891 & - cautn(mgs) + &
20892 & il5(mgs)*(-ciacw(mgs)-cwfrz(mgs)-cwctfzp(mgs) &
20893 & -cwctfzc(mgs) &
20894 & ) &
20895 & -cracw(mgs) -csacw(mgs) -chacw(mgs) - chlacw(mgs)
20896
20897
20898 ELSEIF ( warmonly < 0.8 ) THEN
20899 pccwd(mgs) = &
20900 & - cautn(mgs) + &
20901 & il5(mgs)*( &
20902 & -ciacw(mgs)-cwfrz(mgs)-cwctfzp(mgs) &
20903 & -cwctfzc(mgs) &
20904 & ) &
20905 & -cracw(mgs) -chacw(mgs) -chlacw(mgs)
20906 ELSE
20907
20908! tmp3d(igs(mgs),jy,kgs(mgs)) = crcnw(mgs)
20909
20910! cracw(mgs) = 0.0 ! turn off accretion
20911! qracw(mgs) = 0.0
20912! crcev(mgs) = 0.0 ! turn off evap
20913! qrcev(mgs) = 0.0 ! turn off evap
20914! cracr(mgs) = 0.0 ! turn off self collection
20915
20916
20917! cautn(mgs) = 0.0
20918! crcnw(mgs) = 0.0
20919! qrcnw(mgs) = 0.0
20920
20921 pccwd(mgs) = &
20922 & - cautn(mgs) -cracw(mgs)
20923 ENDIF
20924
20925
20926 IF ( .false. .and. exwmindiam > 0.0 .and. ccwresv(mgs) > 0.0 ) THEN
20927 pccwdacc(mgs) = &
20928 & il5(mgs)*(-ciacw(mgs) &
20929 & ) &
20930 & -cracw(mgs) -csacw(mgs) -chacw(mgs) - chlacw(mgs)
20931
20932 IF ( -pccwdacc(mgs)*dtp .gt. cx(mgs,lc) - ccwresv(mgs) ) THEN
20933
20934 frac = -(cx(mgs,lc) - ccwresv(mgs) )/(pccwdacc(mgs)*dtp)
20935 pccwdacc(mgs) = -(cx(mgs,lc) - ccwresv(mgs) )*dtpinv
20936
20937 ciacw(mgs) = frac*ciacw(mgs)
20938 cracw(mgs) = frac*cracw(mgs)
20939 csacw(mgs) = frac*csacw(mgs)
20940 chacw(mgs) = frac*chacw(mgs)
20941 cautn(mgs) = frac*cautn(mgs)
20942
20943 IF ( lhl .gt. 1 ) chlacw(mgs) = frac*chlacw(mgs)
20944
20945! resum
20946 pccwd(mgs) = &
20947 & - cautn(mgs) + &
20948 & il5(mgs)*(-ciacw(mgs)-cwfrzp(mgs)-cwctfzp(mgs) &
20949 & -cwfrzc(mgs)-cwctfzc(mgs) &
20950 & -il5(mgs)*(ciihr(mgs)) &
20951 & ) &
20952 & -cracw(mgs) -csacw(mgs) -chacw(mgs) - chlacw(mgs)
20953
20954 ENDIF
20955
20956 ENDIF
20957
20958
20959 IF ( -pccwd(mgs)*dtp .gt. cx(mgs,lc) ) THEN
20960! write(0,*) 'OUCH! pccwd(mgs)*dtp .gt. ccw(mgs) ',pccwd(mgs),cx(mgs,lc)
20961! write(0,*) 'qc = ',qx(mgs,lc)
20962! write(0,*) -ciacw(mgs)-cwfrzp(mgs)-cwctfzp(mgs)-cwfrzc(mgs)-cwctfzc(mgs)
20963! write(0,*) -cracw(mgs) -csacw(mgs) -chacw(mgs)
20964! write(0,*) - cautn(mgs)
20965
20966 frac = -cx(mgs,lc)/(pccwd(mgs)*dtp)
20967 pccwd(mgs) = -cx(mgs,lc)*dtpinv
20968
20969 ciacw(mgs) = frac*ciacw(mgs)
20970 cwfrz(mgs) = frac*cwfrz(mgs)
20971 cwfrzp(mgs) = frac*cwfrzp(mgs)
20972 cwctfzp(mgs) = frac*cwctfzp(mgs)
20973 cwfrzc(mgs) = frac*cwfrzc(mgs)
20974 cwctfzc(mgs) = frac*cwctfzc(mgs)
20975 cwctfz(mgs) = frac*cwctfz(mgs)
20976 cracw(mgs) = frac*cracw(mgs)
20977 csacw(mgs) = frac*csacw(mgs)
20978 chacw(mgs) = frac*chacw(mgs)
20979 cautn(mgs) = frac*cautn(mgs)
20980
20981 pccii(mgs) = pccii(mgs) - (1.-frac)*il5(mgs)*(cwfrzc(mgs)+cwctfzc(mgs))*(1. - ffrzs)
20982 IF ( lhl .gt. 1 ) chlacw(mgs) = frac*chlacw(mgs)
20983
20984! STOP
20985 ENDIF
20986
20987 end do
20988
20989 ENDIF ! ipconc
20990
20991!
20992! Rain
20993!
20994 IF ( ipconc .ge. 3 ) THEN
20995
20996 do mgs = 1,ngscnt
20997
20998 IF ( warmonly < 0.5 ) THEN
20999 pcrwi(mgs) = &
21000! > cracw(mgs) + &
21001 & crcnw(mgs) &
21002 & +(1-il5(mgs))*( &
21003 & -chmlrr(mgs)/rzxh(mgs) &
21004 & -chlmlrr(mgs)/rzxhl(mgs) &
21005! & -csmlr(mgs)/rzxs(mgs) &
21006 & -csmlrr(mgs) &
21007 & - cimlr(mgs) ) &
21008 & -crshr(mgs) !null at this point when wet snow/graupel included
21009 pcrwd(mgs) = &
21010 & il5(mgs)*(-ciacr(mgs) - crfrz(mgs) ) & ! - cipacr(mgs))
21011! > -csacr(mgs) &
21012 & - chacr(mgs) - chlacr(mgs) &
21013 & +crcev(mgs) &
21014 & - cracr(mgs)
21015! > -il5(mgs)*ciracr(mgs)
21016
21017
21018 ELSEIF ( warmonly < 0.8 ) THEN
21019 pcrwi(mgs) = &
21020 & crcnw(mgs) &
21021 & +(1-il5(mgs))*( &
21022 & -chmlrr(mgs)/rzxh(mgs) &
21023 & -chlmlrr(mgs)/rzxhl(mgs) &
21024! & -csmlr(mgs) &
21025 & -csmlrr(mgs) &
21026 & - cimlr(mgs) ) &
21027 & -crshr(mgs) !null at this point when wet snow/graupel included
21028 pcrwd(mgs) = &
21029 & il5(mgs)*( - crfrz(mgs) ) & ! - cipacr(mgs))
21030 & - chacr(mgs) &
21031 & - chlacr(mgs) &
21032 & +crcev(mgs) &
21033 & - cracr(mgs)
21034 ELSE
21035 pcrwi(mgs) = &
21036 & crcnw(mgs)
21037 pcrwd(mgs) = &
21038 & +crcev(mgs) &
21039 & - cracr(mgs)
21040
21041! tmp3d(igs(mgs),jy,kgs(mgs)) = vtxbar(mgs,lr,1) ! crcnw(mgs) ! (pcrwi(mgs) + pcrwd(mgs))
21042! pcrwi(mgs) = 0.0
21043! pcrwd(mgs) = 0.0
21044! qrcnw(mgs) = 0.0
21045
21046 ENDIF
21047
21048
21049 frac = 0.0
21050 IF ( -pcrwd(mgs)*dtp .gt. cx(mgs,lr) ) THEN
21051! write(0,*) 'OUCH! pcrwd(mgs)*dtp .gt. crw(mgs) ',pcrwd(mgs)*dtp,cx(mgs,lr),mgs,igs(mgs),kgs(mgs)
21052! write(0,*) -ciacr(mgs)
21053! write(0,*) -crfrz(mgs)
21054! write(0,*) -chacr(mgs)
21055! write(0,*) crcev(mgs)
21056! write(0,*) -cracr(mgs)
21057
21058 frac = -cx(mgs,lr)/(pcrwd(mgs)*dtp)
21059 pcrwd(mgs) = -cx(mgs,lr)*dtpinv
21060
21061 ciacr(mgs) = frac*ciacr(mgs)
21062 ciacrf(mgs) = frac*ciacrf(mgs)
21063 ciacrs(mgs) = frac*ciacrs(mgs)
21064 crfrz(mgs) = frac*crfrz(mgs)
21065 crfrzf(mgs) = frac*crfrzf(mgs)
21066 crfrzs(mgs) = frac*crfrzs(mgs)
21067 chacr(mgs) = frac*chacr(mgs)
21068 chlacr(mgs) = frac*chlacr(mgs)
21069 crcev(mgs) = frac*crcev(mgs)
21070 cracr(mgs) = frac*cracr(mgs)
21071
21072! STOP
21073 ENDIF
21074
21075 end do
21076
21077 ENDIF
21078
21079
21080 IF ( warmonly < 0.5 ) THEN
21081
21082!
21083! Snow
21084!
21085 IF ( ipconc .ge. 4 ) THEN !
21086
21087 do mgs = 1,ngscnt
21088 pcswi(mgs) = &
21089 & il5(mgs)*(cscnis(mgs) + cscnvis(mgs) ) &
21090 & + cwfrz2snowfrac*cwfrz(mgs)/cwfrz2snowratio &
21091 & + cscnh(mgs)
21092
21093 IF ( ffrzs > 0.0 ) THEN
21094 pcswi(mgs) = pcswi(mgs) + ffrzs* ( &
21095 & il5(mgs)*cicint(mgs) &
21096 & +il5(mgs)*(cwfrzc(mgs)+cwctfzc(mgs) &
21097 & +cicichr(mgs)) &
21098 & +chmul1(mgs) &
21099 & +chlmul1(mgs) &
21100 & + csplinter(mgs) + csplinter2(mgs) &
21101 & +csmul(mgs) )
21102 ENDIF
21103
21104
21105 IF ( ess0 < 0.0 ) THEN
21106 csacs(mgs) = max(0.0, csacs(mgs) - (ifrzs)*(crfrzs(mgs) + ciacrs(mgs)))
21107 ENDIF
21108
21109 pcswd(mgs) = &
21110! : cracs(mgs) &
21111 & -chacs(mgs) - chlacs(mgs) &
21112 & -chcns(mgs) &
21113 & +(1-il5(mgs))*csmlr(mgs) + csshr(mgs) & ! + csshrp(mgs)
21114! > +il5(mgs)*(cssbv(mgs)) &
21115 & + cssbv(mgs) &
21116 & - csacs(mgs)
21117
21118 frac = 0.0
21119 IF ( imixedphase == 0 ) THEN
21120 IF ( cx(mgs,ls) + dtp*(pcswi(mgs) + pcswd(mgs)) < 0.0 ) THEN
21121 frac = (-cx(mgs,ls) + pcswi(mgs)*dtp)/(pcswd(mgs)*dtp)
21122
21123 pcswd(mgs) = frac*pcswd(mgs)
21124
21125 chacs(mgs) = frac*chacs(mgs)
21126 chlacs(mgs) = frac*chlacs(mgs)
21127 chcns(mgs) = frac*chcns(mgs)
21128 csmlr(mgs) = frac*csmlr(mgs)
21129 csshr(mgs) = frac*csshr(mgs)
21130 cssbv(mgs) = frac*cssbv(mgs)
21131 csacs(mgs) = frac*csacs(mgs)
21132
21133 ENDIF
21134 ENDIF
21135
21136
21137
21138 pccii(mgs) = pccii(mgs) &
21139 & + (1. - ifrzs)*crfrzs(mgs) &
21140 & + (1. - ifrzs)*ciacrs(mgs)
21141
21142 pcswi(mgs) = pcswi(mgs) &
21143 & + (ifrzs)*crfrzs(mgs) &
21144 & + (ifrzs)*ciacrs(mgs)
21145
21146 end do
21147
21148 ENDIF
21149
21150!
21151! Graupel
21152!
21153 IF ( ipconc .ge. 5 ) THEN !
21154 do mgs = 1,ngscnt
21155 pchwi(mgs) = &
21156 & +(ffrzh*ifrzg*crfrzf(mgs) &
21157 & +il5(mgs)*ffrzh*ifiacrg*(ciacrf(mgs) )) &
21158 & + f2h*chcnsh(mgs) + f2h*chcnih(mgs) + chcnhl(mgs)
21159
21160 pchwd(mgs) = &
21161 & (1-il5(mgs))*chmlr(mgs) &
21162! > + il5(mgs)*chsbv(mgs) &
21163 & + chsbv(mgs) &
21164 & - il5(mgs)*chlcnh(mgs) &
21165 & - cscnh(mgs)
21166
21167 end do
21168
21169
21170
21171!
21172
21173!
21174! Hail
21175!
21176 IF ( lhl .gt. 1 .and. lnhl > 1 ) THEN !
21177 do mgs = 1,ngscnt
21178 pchli(mgs) = (ffrzh*(1.0-ifrzg)*crfrzf(mgs) +il5(mgs)*ffrzh*(1.0-ifiacrg)*(ciacrf(mgs) )) &
21179 & + chlcnhhl(mgs) *rzxhlh(mgs)
21180
21181 pchld(mgs) = &
21182 & (1-il5(mgs))*chlmlr(mgs) &
21183! > + il5(mgs)*chlsbv(mgs) &
21184 & + chlsbv(mgs) - chcnhl(mgs)
21185
21186 IF ( imixedphase == 0 ) THEN
21187 frac = 0.0
21188 IF ( cx(mgs,lhl) + dtp*(pchli(mgs) + pchld(mgs)) < 0.0 ) THEN
21189 ! rescale depletion
21190
21191 frac = (-cx(mgs,lhl) + pchli(mgs)*dtp)/(pchld(mgs)*dtp)
21192
21193 chlmlr(mgs) = frac*chlmlr(mgs)
21194 chlsbv(mgs) = frac*chlsbv(mgs)
21195 chcnhl(mgs) = frac*chcnhl(mgs)
21196
21197 pchld(mgs) = frac*pchld(mgs)
21198
21199 ENDIF
21200 ENDIF
21201
21202 end do
21203
21204 ENDIF
21205!
21206
21207 ENDIF ! (ipconc .ge. 5 )
21208
21209 ELSEIF ( warmonly < 0.8 ) THEN
21210
21211!
21212! Graupel
21213!
21214 IF ( ipconc .ge. 5 ) THEN !
21215 do mgs = 1,ngscnt
21216 pchwi(mgs) = &
21217 & +ifrzg*(crfrzf(mgs) ) ! +il5(mgs)*(ciacrf(mgs) ))
21218
21219 pchwd(mgs) = &
21220 & (1-il5(mgs))*chmlr(mgs) &
21221 & - il5(mgs)*chlcnh(mgs)
21222 end do
21223!
21224! Hail
21225!
21226 IF ( lhl .gt. 1 ) THEN !
21227 do mgs = 1,ngscnt
21228 pchli(mgs) = (1.0-ifrzg)*(crfrzf(mgs)) & ! +il5(mgs)*(ciacrf(mgs) )) &
21229 & + chlcnhhl(mgs) *rzxhl(mgs)/rzxh(mgs)
21230
21231 pchld(mgs) = &
21232 & (1-il5(mgs))*chlmlr(mgs) ! &
21233! > + il5(mgs)*chlsbv(mgs) &
21234! & + chlsbv(mgs)
21235
21236! IF ( pchli(mgs) .ne. 0. .or. pchld(mgs) .ne. 0 ) THEN
21237! write(0,*) 'dr: pchli,pchld = ', pchli(mgs),pchld(mgs), igs(mgs),kgs(mgs)
21238! ENDIF
21239 end do
21240
21241 ENDIF
21242
21243 ENDIF ! ipconc >= 5
21244
21245 ENDIF ! warmonly
21246
21247!
21248
21249!
21250! Balance and checks for continuity.....within machine precision...
21251!
21252 do mgs = 1,ngscnt
21253 pctot(mgs) = pccwi(mgs) +pccwd(mgs) + &
21254 & pccii(mgs) +pccid(mgs) + &
21255 & pcrwi(mgs) +pcrwd(mgs) + &
21256 & pcswi(mgs) +pcswd(mgs) + &
21257 & pchwi(mgs) +pchwd(mgs) + &
21258 & pchli(mgs) +pchld(mgs)
21259 end do
21260!
21261!
21262 ENDIF ! ( ipconc .ge. 1 )
21263!
21264!
21265!
21266!
21267!
21268! GOGO
21269! production terms for mass
21270!
21271!
21272 pqwvi(:) = 0.0
21273 pqwvd(:) = 0.0
21274 pqcwi(:) = 0.0
21275 pqcwd(:) = 0.0
21276 pqcwdacc(:) = 0.0
21277 pqcii(:) = 0.0
21278 pqcid(:) = 0.0
21279 pqrwi(:) = 0.0
21280 pqrwd(:) = 0.0
21281 pqswi(:) = 0.0
21282 pqswd(:) = 0.0
21283 pqhwi(:) = 0.0
21284 pqhwd(:) = 0.0
21285 pqhli(:) = 0.0
21286 pqhld(:) = 0.0
21287 pqlwsi(:) = 0.0
21288 pqlwsd(:) = 0.0
21289 pqlwhi(:) = 0.0
21290 pqlwhd(:) = 0.0
21291 pqlwlghi(:) = 0.0
21292 pqlwlghd(:) = 0.0
21293 pqlwlghli(:) = 0.0
21294 pqlwlghld(:) = 0.0
21295 pqlwhli(:) = 0.0
21296 pqlwhld(:) = 0.0
21297 IF ( ipconc > 5 ) THEN
21298 pzhwi(:) = 0.0
21299 pzhwd(:) = 0.0
21300 pzrwi(:) = 0.0
21301 pzrwd(:) = 0.0
21302 pzhli(:) = 0.0
21303 pzhld(:) = 0.0
21304 ENDIF
21305
21306
21307!
21308! Vapor
21309!
21310 IF ( warmonly < 0.5 ) THEN
21311 do mgs = 1,ngscnt
21312
21313! NOTE: ANY CHANGES HERE ALSO NEED TO GO INTO THE RESUM FARTHER DOWN!
21314 pqwvi(mgs) = &
21315 & -min(0.0, qrcev(mgs)) &
21316 & -min(0.0, qhcev(mgs)) &
21317 & -min(0.0, qhlcev(mgs)) &
21318 & -min(0.0, qscev(mgs)) &
21319! > +il5(mgs)*(-qhsbv(mgs) - qhlsbv(mgs) ) &
21320 & -qhsbv(mgs) - qhlsbv(mgs) &
21321 & -qssbv(mgs) &
21322 & -il5(mgs)*qisbv(mgs)
21323
21324 pqwvd(mgs) = &
21325 & -max(0.0, qrcev(mgs)) &
21326 & -max(0.0, qhcev(mgs)) &
21327 & -max(0.0, qhlcev(mgs)) &
21328 & -max(0.0, qscev(mgs)) &
21329 & +il5(mgs)*(-qiint(mgs) &
21330 & -qhdpv(mgs) -qsdpv(mgs) - qhldpv(mgs)) &
21331 & -il5(mgs)*qidpv(mgs)
21332
21333 end do
21334
21335 ELSEIF ( warmonly < 0.8 ) THEN
21336 do mgs = 1,ngscnt
21337 pqwvi(mgs) = &
21338 & -min(0.0, qrcev(mgs)) &
21339 & -il5(mgs)*qisbv(mgs)
21340 pqwvd(mgs) = &
21341 & +il5(mgs)*(-qiint(mgs) &
21342! & -qhdpv(mgs) ) & !- qhldpv(mgs)) &
21343 & -qhdpv(mgs) - qhldpv(mgs)) &
21344! & -qhdpv(mgs) -qsdpv(mgs) - qhldpv(mgs)) &
21345 & -max(0.0, qrcev(mgs)) &
21346 & -il5(mgs)*qidpv(mgs)
21347 end do
21348
21349 ELSE
21350 do mgs = 1,ngscnt
21351 pqwvi(mgs) = &
21352 & -min(0.0, qrcev(mgs))
21353 pqwvd(mgs) = &
21354 & -max(0.0, qrcev(mgs))
21355 end do
21356
21357 ENDIF ! warmonly
21358!
21359! Cloud water
21360!
21361 do mgs = 1,ngscnt
21362
21363 pqcwi(mgs) = (0.0) + qwcnr(mgs) - qwshw(mgs)
21364
21365 IF ( warmonly < 0.5 ) THEN
21366 pqcwd(mgs) = &
21367 & il5(mgs)*(-qiacw(mgs)-qwfrz(mgs)-qwctfz(mgs)) &
21368 & -il5(mgs)*(qiihr(mgs)) &
21369 & -qracw(mgs) -qsacw(mgs) -qrcnw(mgs) -qhacw(mgs) - qhlacw(mgs) !&
21370! & -il5(mgs)*(qwfrzp(mgs))
21371 ELSEIF ( warmonly < 0.8 ) THEN
21372 pqcwd(mgs) = &
21373 & il5(mgs)*(-qiacw(mgs)-qwfrz(mgs)-qwctfz(mgs)) &
21374 & -il5(mgs)*(qiihr(mgs)) &
21375 & -qracw(mgs) -qrcnw(mgs) -qhacw(mgs) -qhlacw(mgs)
21376 ELSE
21377 pqcwd(mgs) = &
21378 & -qracw(mgs) - qrcnw(mgs)
21379 ENDIF
21380
21381
21382 IF ( pqcwd(mgs) .lt. 0.0 .and. -pqcwd(mgs)*dtp .gt. qx(mgs,lc) ) THEN
21383
21384 frac = -max(0.0,qx(mgs,lc))/(pqcwd(mgs)*dtp)
21385 pqcwd(mgs) = -qx(mgs,lc)*dtpinv
21386
21387 qiacw(mgs) = frac*qiacw(mgs)
21388! qwfrzp(mgs) = frac*qwfrzp(mgs)
21389! qwctfzp(mgs) = frac*qwctfzp(mgs)
21390 qwfrzc(mgs) = frac*qwfrzc(mgs)
21391 qwfrz(mgs) = frac*qwfrz(mgs)
21392 qwctfzc(mgs) = frac*qwctfzc(mgs)
21393 qwctfz(mgs) = frac*qwctfz(mgs)
21394 qracw(mgs) = frac*qracw(mgs)
21395 qsacw(mgs) = frac*qsacw(mgs)
21396 qhacw(mgs) = frac*qhacw(mgs)
21397 vhacw(mgs) = frac*vhacw(mgs)
21398 qrcnw(mgs) = frac*qrcnw(mgs)
21399 qwfrzp(mgs) = frac*qwfrzp(mgs)
21400 IF ( lhl .gt. 1 ) THEN
21401 qhlacw(mgs) = frac*qhlacw(mgs)
21402 vhlacw(mgs) = frac*vhlacw(mgs)
21403 ENDIF
21404! IF ( lzh .gt. 1 ) zhacw(mgs) = frac*zhacw(mgs)
21405
21406! STOP
21407 ENDIF
21408
21409
21410 end do
21411!
21412! Cloud ice
21413!
21414 IF ( warmonly < 0.5 ) THEN
21415
21416 do mgs = 1,ngscnt
21417 IF ( ffrzs < 1.0 ) THEN
21418 pqcii(mgs) = &
21419 & il5(mgs)*qicicnt(mgs) &
21420 & +il5(mgs)*((1.0-cwfrz2snowfrac)*qwfrzc(mgs)+qwctfzc(mgs)) &
21421 & +il5(mgs)*(qicichr(mgs)) &
21422 & +qsmul(mgs) &
21423 & +qhmul1(mgs) + qhlmul1(mgs) &
21424 & + qsplinter(mgs) + qsplinter2(mgs)
21425! > + cimas0*nsplinter*(crfrzf(mgs) + crfrz(mgs))/rho0(mgs)
21426 ENDIF
21427
21428 pqcii(mgs) = pqcii(mgs)*(1.0 - ffrzs) &
21429 & +il5(mgs)*qidpv(mgs) &
21430 & +il5(mgs)*qiacw(mgs)
21431
21432 pqcid(mgs) = &
21433 & il5(mgs)*(-qscni(mgs) - qscnvi(mgs) & ! -qwaci(mgs) &
21434 & -qraci(mgs) &
21435 & -qsaci(mgs) ) &
21436 & -qhaci(mgs) &
21437 & -qhlaci(mgs) &
21438 & +il5(mgs)*qisbv(mgs) &
21439 & +(1.-il5(mgs))*qimlr(mgs) &
21440 & - qhcni(mgs)
21441 end do
21442
21443
21444 ELSEIF ( warmonly < 0.8 ) THEN
21445
21446 do mgs = 1,ngscnt
21447 pqcii(mgs) = &
21448 & il5(mgs)*qicicnt(mgs)*(1. - ffrzs) &
21449 & +il5(mgs)*((1.0-cwfrz2snowfrac)*qwfrzc(mgs)+qwctfzc(mgs))*(1. - ffrzs) &
21450 & +il5(mgs)*(qicichr(mgs))*(1. - ffrzs) &
21451! & +il5(mgs)*(qicichr(mgs)) &
21452! & +qsmul(mgs) &
21453 & +qhmul1(mgs) + qhlmul1(mgs) &
21454 & + qsplinter(mgs) + qsplinter2(mgs) &
21455 & +il5(mgs)*qidpv(mgs) &
21456 & +il5(mgs)*qiacw(mgs) ! & ! (qiacwi(mgs)+qwacii(mgs)) &
21457! & +il5(mgs)*(qwfrzc(mgs)+qwctfzc(mgs)) &
21458! & +il5(mgs)*(qicichr(mgs)) &
21459! & +qsmul(mgs) &
21460! & +qhmul1(mgs) + qhlmul1(mgs) &
21461! & + qsplinter(mgs) + qsplinter2(mgs)
21462
21463 pqcid(mgs) = &
21464! & il5(mgs)*(-qscni(mgs) - qscnvi(mgs) & ! -qwaci(mgs) &
21465! & -qraci(mgs) &
21466! & -qsaci(mgs) ) &
21467! & -qhaci(mgs) &
21468! & -qhlaci(mgs) &
21469 & +il5(mgs)*qisbv(mgs) &
21470 & +(1.-il5(mgs))*qimlr(mgs) ! &
21471! & - qhcni(mgs)
21472 end do
21473
21474 ENDIF
21475!
21476! Rain
21477!
21478
21479 do mgs = 1,ngscnt
21480 IF ( warmonly < 0.5 ) THEN
21481 pqrwi(mgs) = &
21482 & qracw(mgs) + qrcnw(mgs) + max(0.0, qrcev(mgs)) &
21483 & +(1-il5(mgs))*( &
21484 & -qhmlr(mgs) & !null at this point when wet snow/graupel included
21485 & -qsmlr(mgs) - qhlmlr(mgs) &
21486 & -qimlr(mgs)) &
21487! & -qsshr(mgs) & !null at this point when wet snow/graupel included
21488! & -qhshr(mgs) & !null at this point when wet snow/graupel included
21489! & -qhlshr(mgs) &
21490 & - qrshr(mgs)
21491
21492 pqrwd(mgs) = &
21493 & il5(mgs)*(-qiacr(mgs)-qrfrz(mgs)) &
21494 & - qsacr(mgs) - qhacr(mgs) - qhlacr(mgs) - qwcnr(mgs) &
21495 & + min(0.0,qrcev(mgs))
21496 ELSEIF ( warmonly < 0.8 ) THEN
21497 pqrwi(mgs) = &
21498 & qracw(mgs) + qrcnw(mgs) + max(0.0, qrcev(mgs)) &
21499 & +(1-il5(mgs))*( &
21500 & -qhlmlr(mgs) & !null at this point when wet snow/graupel included
21501 & -qhmlr(mgs) ) & !null at this point when wet snow/graupel included
21502 & -qhshr(mgs) & !null at this point when wet snow/graupel included
21503 & -qhlshr(mgs) !null at this point when wet snow/graupel included
21504 pqrwd(mgs) = &
21505 & il5(mgs)*(-qrfrz(mgs)) &
21506 & - qhacr(mgs) &
21507 & - qhlacr(mgs) &
21508 & + min(0.0,qrcev(mgs))
21509 ELSE
21510 pqrwi(mgs) = &
21511 & qracw(mgs) + qrcnw(mgs) + max(0.0, qrcev(mgs))
21512 pqrwd(mgs) = min(0.0,qrcev(mgs))
21513 ENDIF ! warmonly
21514
21515
21516 ! IF ( pqrwd(mgs) .lt. 0.0 .and. -(pqrwd(mgs) + pqrwi(mgs))*dtp .gt. qx(mgs,lr) ) THEN
21517 IF ( pqrwd(mgs) .lt. 0.0 .and. -(pqrwd(mgs) + pqrwi(mgs))*dtp .gt. qx(mgs,lr) ) THEN
21518
21519 frac = (-qx(mgs,lr) + pqrwi(mgs)*dtp)/(pqrwd(mgs)*dtp)
21520! pqrwd(mgs) = -qx(mgs,lr)*dtpinv + pqrwi(mgs)
21521
21522 pqwvi(mgs) = pqwvi(mgs) &
21523 & + min(0.0, qrcev(mgs)) &
21524 & - frac*min(0.0, qrcev(mgs))
21525 pqwvd(mgs) = pqwvd(mgs) &
21526 & + max(0.0, qrcev(mgs)) &
21527 & - frac*max(0.0, qrcev(mgs))
21528
21529 qiacr(mgs) = frac*qiacr(mgs)
21530 qiacrf(mgs) = frac*qiacrf(mgs)
21531 qiacrs(mgs) = frac*qiacrs(mgs)
21532 viacrf(mgs) = frac*viacrf(mgs)
21533 qrfrz(mgs) = frac*qrfrz(mgs)
21534 qrfrzs(mgs) = frac*qrfrzs(mgs)
21535 qrfrzf(mgs) = frac*qrfrzf(mgs)
21536 vrfrzf(mgs) = frac*vrfrzf(mgs)
21537 qsacr(mgs) = frac*qsacr(mgs)
21538 qhacr(mgs) = frac*qhacr(mgs)
21539 vhacr(mgs) = frac*vhacr(mgs)
21540 qrcev(mgs) = frac*qrcev(mgs)
21541 qhlacr(mgs) = frac*qhlacr(mgs)
21542 vhlacr(mgs) = frac*vhlacr(mgs)
21543 qhcev(mgs) = frac*qhcev(mgs)
21544 qhlcev(mgs) = frac*qhlcev(mgs)
21545
21546
21547 IF ( warmonly < 0.5 ) THEN
21548 pqrwd(mgs) = &
21549 & il5(mgs)*(-qiacr(mgs)-qrfrz(mgs) - qsacr(mgs)) &
21550 & - qhacr(mgs) - qhlacr(mgs) - qwcnr(mgs) &
21551 & + min(0.0,qrcev(mgs))
21552 ELSEIF ( warmonly < 0.8 ) THEN
21553 pqrwd(mgs) = &
21554 & il5(mgs)*(-qrfrz(mgs)) &
21555 & - qhacr(mgs) &
21556 & - qhlacr(mgs) &
21557 & + min(0.0,qrcev(mgs))
21558 ELSE
21559 pqrwd(mgs) = min(0.0,qrcev(mgs))
21560 ENDIF ! warmonly
21561
21562!
21563! Resum for vapor since qrcev has changed
21564!
21565 IF ( qrcev(mgs) .ne. 0.0 ) THEN
21566 pqwvi(mgs) = &
21567 & -min(0.0, qrcev(mgs)) &
21568 & -min(0.0, qhcev(mgs)) &
21569 & -min(0.0, qhlcev(mgs)) &
21570 & -min(0.0, qscev(mgs)) &
21571! > +il5(mgs)*(-qhsbv(mgs) - qhlsbv(mgs) ) &
21572 & -qhsbv(mgs) - qhlsbv(mgs) &
21573 & -qssbv(mgs) &
21574 & -il5(mgs)*qisbv(mgs)
21575
21576 pqwvd(mgs) = &
21577 & -max(0.0, qrcev(mgs)) &
21578 & -max(0.0, qhcev(mgs)) &
21579 & -max(0.0, qhlcev(mgs)) &
21580 & -max(0.0, qscev(mgs)) &
21581 & +il5(mgs)*(-qiint(mgs) &
21582 & -qhdpv(mgs) -qsdpv(mgs) - qhldpv(mgs)) &
21583 & -il5(mgs)*qidpv(mgs)
21584
21585 ENDIF
21586
21587
21588! STOP
21589 ENDIF
21590
21591
21592 end do
21593
21594 IF ( warmonly < 0.5 ) THEN
21595
21596!
21597! Snow
21598!
21599 do mgs = 1,ngscnt
21600 pqswi(mgs) = &
21601 & il5(mgs)*(qscni(mgs)+qsaci(mgs)+qsdpv(mgs) &
21602 & + qscnvi(mgs) &
21603 & + ifrzs*(qiacrs(mgs) + qrfrzs(mgs)) &
21604 & + il5(mgs)*(( qwfrzc(mgs) + qwctfzc(mgs) + qicichr(mgs) )*ffrzs &
21605 & + (1.0 - ffrzs)*cwfrz2snowfrac*qwfrz(mgs) ) &
21606 & + il2(mgs)*qsacr(mgs)) &
21607 & + il5(mgs)*qicicnt(mgs)*ffrzs &
21608 & + il3(mgs)*(qiacrf(mgs)+qracif(mgs)) & ! only applies for ipconc <= 3
21609 & + max(0.0, qscev(mgs)) &
21610 & + qsacw(mgs) + qscnh(mgs) &
21611 & + ffrzs*(qsmul(mgs) &
21612 & +qhmul1(mgs) + qhlmul1(mgs) &
21613 & + qsplinter(mgs) + qsplinter2(mgs))
21614 pqswd(mgs) = &
21615! > -qfacs(mgs) ! -qwacs(mgs) &
21616 & -qracs(mgs)*(1-il2(mgs)) -qhacs(mgs) - qhlacs(mgs) &
21617 & -qhcns(mgs) &
21618 & +(1-il5(mgs))*qsmlr(mgs) + qsshr(mgs) & !null at this point when wet snow included
21619! > +il5(mgs)*(qssbv(mgs)) &
21620 & + qssbv(mgs) &
21621 & + min(0.0, qscev(mgs)) &
21622 & -qsmul(mgs)
21623
21624
21625 IF ( imixedphase == 0 .and. pqswd(mgs) .lt. 0.0 ) THEN
21626 IF ( qx(mgs,ls) + dtp*(pqswi(mgs) + pqswd(mgs)) < 0.0 ) THEN
21627 frac = (-qx(mgs,ls) + pqswi(mgs)*dtp)/(pqswd(mgs)*dtp)
21628
21629 pqswd(mgs) = frac*pqswd(mgs)
21630
21631 qracs(mgs) = frac*qracs(mgs) ! only used for single moment at this time
21632 qhacs(mgs) = frac*qhacs(mgs)
21633 qhlacs(mgs) = frac*qhlacs(mgs)
21634 qhcns(mgs) = frac*qhcns(mgs)
21635 qsmlr(mgs) = frac*qsmlr(mgs)
21636 qsshr(mgs) = frac*qsshr(mgs)
21637 qssbv(mgs) = frac*qssbv(mgs)
21638 qsmul(mgs) = frac*qsmul(mgs)
21639 IF ( qscev(mgs) < 0.0 ) qscev(mgs) = frac*qscev(mgs)
21640
21641 ENDIF
21642 ENDIF
21643
21644 pqcii(mgs) = pqcii(mgs) &
21645 & + (1. - ifrzs)*qrfrzs(mgs) &
21646 & + (1. - ifrzs)*qiacrs(mgs)
21647
21648 end do
21649
21650!
21651! Graupel
21652!
21653 do mgs = 1,ngscnt
21654 pqhwi(mgs) = &
21655 & +il5(mgs)*(ffrzh*ifrzg*qrfrzf(mgs) + (1-il3(mgs))*ffrzh*ifiacrg*(qiacrf(mgs)+qracif(mgs))) &
21656 & + (1-il2(mgs))*(qracs(mgs) + qsacr(mgs)) & ! only used for ipconc < 3
21657 & +il5(mgs)*(qhdpv(mgs)) &
21658 & +max(0.0, qhcev(mgs)) &
21659 & +qhacr(mgs)+qhacw(mgs) &
21660 & +qhacs(mgs)+qhaci(mgs) &
21661 & + f2h*qhcns(mgs) + f2h*qhcni(mgs) + qhcnhl(mgs)
21662 pqhwd(mgs) = &
21663 & qhshr(mgs) & !null at this point when wet graupel included
21664 & +(1-il5(mgs))*qhmlr(mgs) & !null at this point when wet graupel included
21665! > +il5(mgs)*qhsbv(mgs) &
21666 & + qhsbv(mgs) &
21667 & + min(0.0, qhcev(mgs)) &
21668 & -qhmul1(mgs) - qhlcnh(mgs) - qscnh(mgs) &
21669 & - ffrzh*(qsplinter(mgs) + qsplinter2(mgs))
21670! > - cimas0*nsplinter*(crfrzf(mgs) + crfrz(mgs))/rho0(mgs)
21671
21672 end do
21673
21674
21675!
21676! Hail
21677!
21678 IF ( lhl .gt. 1 ) THEN
21679
21680 do mgs = 1,ngscnt
21681 pqhli(mgs) = &
21682 & +il5(mgs)*(qhldpv(mgs) + ((1.0-ifrzg)*qrfrzf(mgs) + (1.0-ifiacrg)*(qiacrf(mgs)+ qracif(mgs)))) &
21683 & +max(0.0, qhlcev(mgs)) &
21684 & +qhlacr(mgs)+qhlacw(mgs) &
21685 & +qhlacs(mgs)+qhlaci(mgs) &
21686 & + qhlcnh(mgs)
21687 pqhld(mgs) = &
21688 & qhlshr(mgs) &
21689 & +(1-il5(mgs))*qhlmlr(mgs) &
21690! > +il5(mgs)*qhlsbv(mgs) &
21691 & + qhlsbv(mgs) &
21692 & + min(0.0, qhlcev(mgs)) &
21693 & -qhlmul1(mgs) - qhcnhl(mgs)
21694
21695 IF ( imixedphase == 0 ) THEN
21696 frac = 0.0
21697 IF ( qx(mgs,lhl) + dtp*(pqhli(mgs) + pqhld(mgs)) < 0.0 ) THEN
21698 ! rescale depletion
21699
21700 frac = (-qx(mgs,lhl) + pqhli(mgs)*dtp)/(pqhld(mgs)*dtp)
21701
21702 qhlmlr(mgs) = frac*qhlmlr(mgs)
21703 qhlsbv(mgs) = frac*qhlsbv(mgs)
21704 qhcnhl(mgs) = frac*qhcnhl(mgs)
21705 qhlmul1(mgs) = frac*qhlmul1(mgs)
21706 IF ( qhlcev(mgs) < 0.0 ) qhlcev(mgs) = frac*qhlcev(mgs)
21707
21708 pqhld(mgs) = frac*pqhld(mgs)
21709
21710 ENDIF
21711 ENDIF
21712
21713
21714 end do
21715
21716 ENDIF ! lhl
21717
21718 ELSEIF ( warmonly < 0.8 ) THEN
21719!
21720! Graupel
21721!
21722 do mgs = 1,ngscnt
21723 pqhwi(mgs) = &
21724 & +il5(mgs)*ifrzg*(qrfrzf(mgs) ) &
21725 & +il5(mgs)*(qhdpv(mgs)) &
21726 & +qhacr(mgs)+qhacw(mgs)
21727 pqhwd(mgs) = &
21728 & qhshr(mgs) & !null at this point when wet graupel included
21729 & - qhlcnh(mgs) &
21730 & - qhmul1(mgs) &
21731 & - qsplinter(mgs) - qsplinter2(mgs) &
21732 & +(1-il5(mgs))*qhmlr(mgs) !null at this point when wet graupel included
21733 end do
21734
21735!
21736! Hail
21737!
21738 IF ( lhl .gt. 1 ) THEN
21739
21740 do mgs = 1,ngscnt
21741 pqhli(mgs) = &
21742 & +il5(mgs)*(qhldpv(mgs) ) & ! + (1.0-ifrzg)*(qiacrf(mgs)+qrfrzf(mgs) + qracif(mgs))) &
21743 & +il5(mgs)*(1.0-ifrzg)*(qrfrzf(mgs) ) &
21744 & +qhlacr(mgs)+qhlacw(mgs) &
21745! & +qhlacs(mgs)+qhlaci(mgs) &
21746 & + qhlcnh(mgs)
21747 pqhld(mgs) = &
21748 & qhlshr(mgs) &
21749 & +(1-il5(mgs))*qhlmlr(mgs) &
21750! > +il5(mgs)*qhlsbv(mgs) &
21751 & + qhlsbv(mgs) &
21752 & -qhlmul1(mgs) - qhcnhl(mgs)
21753
21754 end do
21755
21756 ENDIF ! lhl
21757
21758 ENDIF ! warmonly
21759
21760!
21761! Liquid water on snow and graupel
21762!
21763
21764 vhmlr(:) = 0.0
21765 vhlmlr(:) = 0.0
21766 vhfzh(:) = 0.0
21767 vhlfzhl(:) = 0.0
21768
21769 IF ( mixedphase ) THEN
21770 ELSE ! set arrays for non-mixedphase graupel
21771
21772! vhshdr(:) = 0.0
21773 vhmlr(:) = qhmlr(:) ! not actually volume, but treated as q in rate equation
21774! vhsoak(:) = 0.0
21775
21776! vhlshdr(:) = 0.0
21777 vhlmlr(:) = qhlmlr(:) ! not actually volume, but treated as q in rate equation
21778! vhlmlr(:) = rho0(:)*qhlmlr(:)/xdn(:,lhl)
21779! vhlsoak(:) = 0.0
21780
21781 ENDIF ! mixedphase
21782
21783
21784
21785!
21786! Graupel reflectivity
21787!
21788 if (ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'graupel reflectivity'
21789
21790 do mgs = 1,ngscnt
21791
21792! zhmlr(mgs) = 0.0
21793! zhshr(mgs) = 0.0
21794! zhmlrr(mgs) = 0.0
21795! zhshrr(mgs) = 0.0
21796 zhdsv(mgs) = 0.0
21797! IF ( lf < 1 ) THEN
21798 IF ( ffrzh > 0.0 ) THEN
21799 ziacr(mgs) = 0.0
21800 ziacrf(mgs) = 0.0
21801 ENDIF
21802! ENDIF
21803 zhcns(mgs) = 0.0
21804 zhcni(mgs) = 0.0
21805 zhacs(mgs) = 0.0
21806 zhaci(mgs) = 0.0
21807
21808 ENDDO
21809
21810 IF ( lzh .gt. 1 ) THEN !
21811 do mgs = 1,ngscnt
21812
21813
21814 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. cx(mgs,lh) .gt. 0.0 ) THEN
21815 tmp = qx(mgs,lh)/cx(mgs,lh)
21816 alp = max( alphamin, alpha(mgs,lh) )
21817! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
21818 g1 = g1x(mgs,lh) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
21819! g1r = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
21820
21821 zhaci(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qhaci(mgs) )
21822 zhacs(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qhacs(mgs) )
21823
21824 IF ( .not. mixedphase .and. ibinhmlr < 1 ) THEN
21825 zhmlr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*tmp * qhmlr(mgs) - tmp**2 * chmlr(mgs) )
21826 ENDIF
21827
21828 zhshr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshr(mgs) )
21829
21830! IF ( lzr > 0 .and. qhshr(mgs) /= 0.0 .and. chshrr(mgs) /= 0.0 .and. ibinhmlr < 1 ) THEN
21831 IF ( lzr > 0 .and. qhshr(mgs) /= 0.0 .and. chshrr(mgs) /= 0.0 ) THEN
21832! IF ( temg(mgs) > tfr + 2.0 ) THEN
21833! zhshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshrr(mgs) )
21834! IF ( zhshrr(mgs) > 0. ) THEN
21835! zhshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshr(mgs) )
21836! ENDIF
21837! z1 = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) ) ! should this be g1shr?
21838! zhshrr(mgs) = Max( z1, zhshrr(mgs))
21839! ELSE
21840! zhshrr(mgs) = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) )
21841
21842
21843 IF ( temg(mgs) >= tfr ) THEN
21844 ! zhshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn0(lr)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshrr(mgs) )
21845 ! IF ( zhshrr(mgs) > 0.0 ) THEN
21846 ! zhshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn0(lr)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshr(mgs) )
21847 ! ENDIF
21848 IF ( (shedalp + alpha(mgs,lh))*xdia(mgs,lh,1) < sheddiam ) THEN ! if not shedding small drops, then use alpha of hail
21849 z1 = g1*(6.0*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) )
21850 ELSE
21851 z1 = g1shr*(6.0*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) ) ! should this be g1shr?
21852 ENDIF
21853 zhshrr(mgs) = z1
21854! z1 = g1mlr*(rho0(mgs)/(xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) ) ! should this be g1shr?
21855! zhshrr(mgs) = Max( z1, zhshrr(mgs))
21856 ELSE
21857 zhshrr(mgs) = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) )
21858 ENDIF
21859
21860 zhshrr(mgs) = min( 0.0, zhshrr(mgs) )
21861 ENDIF
21862
21863 IF ( zhshr(mgs) > 0.0 ) THEN
21864 write(0,*) 'Problem with zhshr! zhshr,qhshr,chshr = ',zhshr(mgs),qhshr(mgs),chshr(mgs)
21865 write(0,*) 'g1,tmp, qx,cx,zx = ',g1,tmp,qx(mgs,lh),cx(mgs,lh),zx(mgs,lh)
21866 write(0,*) ( 2.*tmp * qhshr(mgs) - tmp**2 * chshr(mgs) ), 2.*tmp * qhshr(mgs), - tmp**2 * chshr(mgs)
21867 write(0,*) 'temcg = ',temcg(mgs),'chshr recalc = ',(cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhshr(mgs)
21868
21869 stop
21870 ENDIF
21871
21872
21873! zhshr(mgs) = (xdn0(lr)/(xdn(mgs,lh)))**2*( zx(mgs,lh) * qhshr(mgs) )
21874
21875 qtmp = qhdpv(mgs) + qhcev(mgs) + qhsbv(mgs)
21876 ctmp = chdpv(mgs) + chcev(mgs) + chsbv(mgs)
21877
21878 zhdsv(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qtmp - tmp**2 * ctmp )
21879
21880 alp = max( alphahacx, alpha(mgs,lh) )
21881! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
21882 g1 = g1x(mgs,lh) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
21883
21884 IF ( .true. ) THEN ! {
21885 IF ( qhacr(mgs) .gt. 0.0 ) THEN
21886! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacr(mgs) )
21887
21888! g1r = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
21889! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacr(mgs) )
21890 zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacr(mgs) )
21891! zhacrf(mgs) = g1*zhacr
21892
21893
21894! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lh)+dtp*qhacr(mgs))**2)/(cx(mgs,lh))
21895
21896 IF ( z > zx(mgs,lh) ) THEN
21897! zhacr(mgs) = (z - zx(mgs,lh))*dtpinv
21898 ELSE
21899! zhacr(mgs) = 0.0
21900 ENDIF
21901 ENDIF
21902
21903! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) )
21904! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) - tmp**2 * chacr(mgs) )
21905
21906! alp = Max( 1.0, alpha(mgs,lh)+1. )
21907! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/
21908! : ((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
21909 IF ( qhacw(mgs) .gt. 0.0 ) THEN
21910! zhacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacw(mgs) )
21911 zhacw(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacw(mgs) )
21912
21913! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lh)+dtp*(qhacw(mgs)-qhmul1(mgs)))**2)/(cx(mgs,lh))
21914 IF ( z > zx(mgs,lh) ) THEN
21915! zhacw(mgs) = (z - zx(mgs,lh))*dtpinv
21916 ENDIF
21917 ENDIF
21918
21919 ELSE ! } { ! this is not used because of the 'true' above
21920
21921 IF ( qhacw(mgs) .gt. 0.0 .or. qhacr(mgs) .gt. 0.0 ) THEN
21922 z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lh)+dtp*(qhacr(mgs) + qhacw(mgs)-qhmul1(mgs)))**2)/(cx(mgs,lh))
21923! zhacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacw(mgs) )
21924 IF ( z > zx(mgs,lh) ) THEN
21925 zhacw(mgs) = (z - zx(mgs,lh))*dtpinv
21926 ENDIF
21927 ENDIF
21928
21929 ENDIF ! }
21930
21931 IF ( qhlcnh(mgs) .gt. 0.0 .and. ihlcnh < 2 ) THEN
21932 zhlcnh(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qhlcnh(mgs) - tmp**2 * chlcnh(mgs) )
21933 ENDIF
21934 ENDIF
21935! qsplinter(mgs)
21936 IF ( ffrzh*qiacrf(mgs) .gt. 0.0 .and. cx(mgs,lr) .gt. 0.0 .and. qx(mgs,lr) .gt. qxmin(lr) ) THEN
21937 tmp = qx(mgs,lr)/cx(mgs,lr)
21938! alp = 3.0
21939! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
21940 IF ( imurain == 3 ) THEN
21941 ! note that 3.6476 = (6/pi)**2
21942 ziacr(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,lr)+2.)/(xdn0(lr)**2*(alpha(mgs,lr)+1.))* &
21943 & ( 2.*tmp * qiacrf(mgs) - tmp**2 * ciacrf(mgs) )
21944 ELSE ! imurain == 1
21945 ziacr(mgs) = 3.6476*rho0(mgs)**2*g1x(mgs,lr)/(xdn0(lr)**2)* &
21946 & ( 2.*tmp * qiacrf(mgs) - tmp**2 * ciacrf(mgs) )
21947 ENDIF
21948 ziacr(mgs) = min( ziacr(mgs), zxmxd(mgs,lr) )
21949! ziacrf(mgs) = (xdn(mgs,lr)/xdn(mgs,lh))**2 * ziacr(mgs)
21950 ziacrf(mgs) = (xdn(mgs,lr)/xdnmx(lh))**2 * ziacr(mgs)
21951! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*tmp * (qiacrf(mgs) - qsplinter(mgs)) - tmp**2 * ciacrf(mgs) )
21952! ziacrf(mgs) = Min( ziacrf(mgs), z )
21953 ENDIF
21954
21955
21956
21957 IF ( ffrzh*qrfrzf(mgs) .gt. 0.0 .and. cx(mgs,lr) .gt. 0.0 ) THEN
21958 tmp = qx(mgs,lr)/cx(mgs,lr)
21959! alp = 3.0
21960! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
21961 IF ( imurain == 3 ) THEN
21962 zrfrz(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,lr)+2.)/(xdn0(lr)**2*(alpha(mgs,lr)+1.)) * &
21963 & ( 2.*tmp * qrfrzf(mgs) - tmp**2 * crfrzf(mgs) )
21964 zrfrzf(mgs) = (xdn(mgs,lr)/xdn(mgs,lh))**2 * zrfrz(mgs)
21965 ELSEIF ( imurain == 1 .and. ibiggopt /= 2 ) THEN
21966! zrfrz(mgs) = 3.6476*rho0(mgs)**2*g1x(mgs,lr)/(xdn0(lr)**2) * &
21967! & ( 2.*tmp * qrfrzf(mgs) - tmp**2 * crfrz(mgs) )
21968 zrfrz(mgs) = 3.6476*rho0(mgs)**2*g1x(mgs,lr)/(xdn0(lr)**2) * &
21969 & ( 2.*tmp * qrfrz(mgs) - tmp**2 * crfrz(mgs) )
21970 zrfrzf(mgs) = 3.6476*rho0(mgs)**2*g1x(mgs,lr)/(rhofrz**2) * &
21971 & ( 2.*tmp * qrfrzf(mgs) - tmp**2 * crfrzf(mgs) )
21972 ENDIF
21973 zrfrz(mgs) = min( zrfrz(mgs), max(0.4,qrfrz(mgs)/qx(mgs,lr))*zx(mgs,lr)*dtpinv )
21974! zrfrzf(mgs) = (xdn(mgs,lr)/xdn(mgs,lh))**2 * zrfrz(mgs)
21975! zrfrzf(mgs) = (xdn(mgs,lr)/xdnmx(lh))**2 * zrfrz(mgs)
21976! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*tmp * (qrfrzf(mgs)-qsplinter2(mgs)) - tmp**2 * crfrzf(mgs) )
21977! zrfrzf(mgs) = Min( zrfrzf(mgs), z )
21978 ! change this to be alpha=0?
21979 ENDIF
21980
21981 IF ( lhl > 1 .and. qhcnhl(mgs) .gt. 0.0 ) THEN
21982 tmp = qx(mgs,lhl)/cx(mgs,lhl)
21983 zhcnhl(mgs) = g1x(mgs,lhl)*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*( tmp ) * qhcnhl(mgs) - tmp**2 * chcnhl(mgs) )
21984
21985 ENDIF
21986
21987 IF ( qhcns(mgs) > 0.0 .and. chcns(mgs) > 0.0 .and. cx(mgs,ls) > cxmin .and. vhcns(mgs) > 0 ) THEN
21988 tmp = qx(mgs,ls)/cx(mgs,ls)
21989 r = rho0(mgs)*qhcns(mgs)/vhcns(mgs) ! density of new graupel particles
21990 IF ( imusnow == 3 ) THEN
21991 zhcns(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,ls)+2.)/(r**2*(alpha(mgs,ls)+1.)) * &
21992 & ( 2.*tmp * qhcns(mgs) - tmp**2 * chcns(mgs) )
21993 ELSE
21994 write(0,*) 'Value of imusnow not valid. Must be 3 (fix me for =1). imusnow = ',imusnow
21995 stop
21996 ENDIF
21997 ENDIF
21998
21999 IF ( qhcni(mgs) > 0.0 .and. chcni(mgs) > 0.0 .and. cx(mgs,li) > cxmin .and. vhcni(mgs) > 0 ) THEN
22000 tmp = qx(mgs,li)/cx(mgs,li)
22001 r = rho0(mgs)*qhcni(mgs)/vhcni(mgs) ! density of new graupel particles
22002 zhcni(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,li)+2.)/(r**2*(alpha(mgs,li)+1.)) * &
22003 & ( 2.*tmp * qhcni(mgs) - tmp**2 * chcni(mgs) )
22004 ENDIF
22005
22006
22007 pzhwi(mgs) = &
22008 & +ifrzg*ffrzh*(zrfrzf(mgs) &
22009 & +il5(mgs)*ifiacrg*(ziacrf(mgs) ) ) &
22010! : + zhcnsh(mgs) + zhcnih(mgs) &
22011 & + zhacw(mgs) &
22012 & + zhacr(mgs) &
22013 & + zhcnhl(mgs) &
22014 & + zhacs(mgs) &
22015 & + zhaci(mgs) &
22016 & + f2h*zhcni(mgs) + f2h*zhcns(mgs) &
22017 & + max( 0.0, zhdsv(mgs) )
22018
22019 pzhwd(mgs) = 0.0 &
22020 & + (1-il5(mgs))*zhmlr(mgs) &
22021 & + zhshr(mgs) &
22022 & + min( 0.0, zhdsv(mgs) ) &
22023 & - il5(mgs)*zhlcnh(mgs)
22024
22025
22026 IF ( igs(mgs) == 44 .and. kgs(mgs) == 23 .or. dtp*( pqhwi(mgs) + pqhwd(mgs) ) > qxmin(lh) ) THEN
22027! write(0,*) 'i,k,time = ',igs(mgs),kgs(mgs),time_real
22028! write(0,*) 'pzhwi,d = ',pzhwi(mgs),pzhwd(mgs),dtp*( pzhwi(mgs) + pzhwd(mgs) ),zx(mgs,lh)
22029! write(0,*) 'pqhwi,d = ',pqhwi(mgs),pqhwd(mgs),dtp*( pqhwi(mgs) + pqhwd(mgs) ),qx(mgs,lh)
22030! write(0,*) 'pchwi,d = ',pchwi(mgs),pchwd(mgs),dtp*( pchwi(mgs) + pchwd(mgs) ),cx(mgs,lh)
22031 ENDIF
22032
22033
22034! IF ( zhcnhl(mgs) < 0.0 ) THEN
22035! write(0,*) 'Problem with zhcnhl! zhcnhl,qhcnhl,chcnhl = ',zhcnhl(mgs),qhcnhl(mgs),chcnhl(mgs)
22036! write(0,*) 'g1,tmp = ',g1x(mgs,lhl),tmp
22037! write(0,*) ( 2.*( tmp ) * qhcnhl(mgs) - tmp**2 * chcnhl(mgs) )
22038!
22039!! STOP
22040! ENDIF
22041 end do
22042
22043 if (ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'end graupel reflectivity'
22044
22045 ENDIF
22046
22047!
22048! Hail reflectivity
22049!
22050
22051 do mgs = 1,ngscnt
22052
22053 zhldsv(mgs) = 0.0
22054 zhlacr(mgs) = 0.0
22055 zhlacw(mgs) = 0.0
22056
22057 ENDDO
22058
22059 IF ( lzhl .gt. 1 .or. ( lzr > 1 .and. lnhl > 1 ) ) THEN ! also run for 2-moment hail for 3-moment rain sources
22060
22061 if (ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'hail reflectivity'
22062
22063 do mgs = 1,ngscnt
22064
22065 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. cx(mgs,lhl) .gt. 0.0 ) THEN
22066 tmp = qx(mgs,lhl)/cx(mgs,lhl)
22067 alp = max( alphamin, alpha(mgs,lhl) )
22068! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22069 g1 = g1x(mgs,lhl) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22070
22071 IF ( .not. mixedphase .and. qhlmlr(mgs) /= 0.0 .and. chlmlr(mgs) /= 0.0 .and. ibinhlmlr < 1 ) THEN
22072 zhlmlr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*tmp * qhlmlr(mgs) - tmp**2 * chlmlr(mgs) )
22073 ENDIF
22074
22075 zhlshr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*tmp * qhlshr(mgs) - tmp**2 * chlshr(mgs) )
22076 IF ( lzr > 1 .and. qhlshr(mgs) /= 0.0 .and. chlshrr(mgs) /= 0.0 ) THEN
22077 IF ( temg(mgs) >= tfr ) THEN
22078 ! zhlshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn0(lr)))**2*( 2.*tmp * qhlshr(mgs) - tmp**2 * chlshrr(mgs) )
22079 ! IF ( zhlshrr(mgs) > 0.0 ) THEN
22080 ! zhlshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn0(lr)))**2*( 2.*tmp * qhlshr(mgs) - tmp**2 * chlshr(mgs) )
22081 ! ENDIF
22082 IF ( (shedalp + alpha(mgs,lhl))*xdia(mgs,lhl,1) < sheddiam ) THEN ! if not shedding small drops, then use alpha of hail
22083 z1 = g1*(6.0*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlshr(mgs)**2/ chlshrr(mgs) )
22084 ELSE
22085 z1 = g1shr*(6.0*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlshr(mgs)**2/ chlshrr(mgs) ) ! should this be g1shr?
22086 ENDIF
22087 zhlshrr(mgs) = z1
22088! z1 = g1mlr*(rho0(mgs)/(xdn(mgs,lr)))**2*( qhlshr(mgs)**2/ chlshrr(mgs) ) ! should this be g1shr?
22089! zhlshrr(mgs) = Max( z1, zhlshrr(mgs))
22090 ELSE
22091 zhlshrr(mgs) = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlshr(mgs)**2/ chlshrr(mgs) )
22092 ENDIF
22093
22094 zhlshrr(mgs) = min( 0.0, zhlshrr(mgs) )
22095 ENDIF
22096
22097 IF ( zhlshr(mgs) > 0.0 ) THEN
22098 write(0,*) 'Problem with zhlshr! zhlshr,qhlshr,chlshr = ',zhlshr(mgs),qhlshr(mgs),chlshr(mgs)
22099 write(0,*) 'g1,tmp, qx,cx,zx = ',g1,tmp,qx(mgs,lhl),cx(mgs,lhl),zx(mgs,lhl)
22100 write(0,*) ( 2.*tmp * qhlshr(mgs) - tmp**2 * chlshr(mgs) ), 2.*tmp * qhlshr(mgs), - tmp**2 * chlshr(mgs)
22101 write(0,*) 'temcg = ',temcg(mgs),'chlshr recalc = ',(cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlshr(mgs)
22102
22103 stop
22104 ENDIF
22105! zhlshr(mgs) = Min( 0.0, zhlshr(mgs) )
22106
22107! zhlshr(mgs) = (xdn0(lr)/(xdn(mgs,lhl)))**2*( zx(mgs,lhl) * qhlshr(mgs) )
22108
22109 qtmp = qhldpv(mgs) + qhlcev(mgs)
22110 ctmp = chldpv(mgs) + chlcev(mgs)
22111
22112 zhldsv(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*( tmp ) * qtmp - tmp**2 * ctmp )
22113
22114 alp = max( alphahacx, alpha(mgs,lhl) )
22115! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22116 g1 = g1x(mgs,lhl) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22117
22118 IF ( .true. ) THEN ! {
22119 IF ( qhlacr(mgs) .gt. 0.0 ) THEN
22120! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lhl)+dtp*qhlacr(mgs))**2)/(cx(mgs,lhl))
22121 zhlacr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*( tmp ) * qhlacr(mgs) )
22122! zhlacr(mgs) = Min( zxmxd(mgs,lr), zhlacr(mgs) )
22123
22124! IF ( z > zx(mgs,lhl) ) THEN
22125! zhlacr(mgs) = (z - zx(mgs,lhl))*dtpinv
22126! ELSE
22127! zhlacr(mgs) = 0.0
22128! ENDIF
22129 ENDIF
22130
22131! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) )
22132! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) - tmp**2 * chacr(mgs) )
22133
22134 IF ( qhlacw(mgs) .gt. 0.0 ) THEN
22135 alp = max( 3.0, alpha(mgs,lhl)+1. )
22136 g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22137
22138! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lhl)+dtp*(qhlacw(mgs)-qhlmul1(mgs)))**2)/(cx(mgs,lhl))
22139! zhlacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lhl)/cx(mgs,lhl)) * qhlacw(mgs) )
22140 zhlacw(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*tmp * qhlacw(mgs) )
22141
22142! IF ( z > zx(mgs,lhl) ) THEN
22143! zhlacw(mgs) = (z - zx(mgs,lhl))*dtpinv
22144! ENDIF
22145 g1 = g1x(mgs,lhl) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22146 ENDIF
22147
22148 ELSE ! } .false. {
22149
22150 IF ( qhlacw(mgs) .gt. 0.0 .or. qhlacr(mgs) .gt. 0.0 ) THEN
22151 z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lhl)+dtp*(qhlacr(mgs) + qhlacw(mgs)-qhlmul1(mgs)))**2)/(cx(mgs,lhl))
22152! zhlacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lhl)/cx(mgs,lhl)) * qhlacw(mgs) )
22153 IF ( z > zx(mgs,lhl) ) THEN
22154 zhlacw(mgs) = (z - zx(mgs,lhl))*dtpinv
22155 ENDIF
22156 ENDIF
22157
22158 ENDIF ! }
22159
22160 ENDIF
22161! qsplinter(mgs)
22162
22163 IF ( lzhl > 1 ) THEN
22164 pzhli(mgs) = ffrzh*(((1.0-ifrzg)*zrfrzf(mgs) &
22165 & +il5(mgs)*(1.0-ifiacrg)*ziacrf(mgs) )) &
22166 & + il5(mgs)*zhlcnh(mgs) &
22167 & + zhlacw(mgs) &
22168 & + zhlacr(mgs) &
22169! : + zhlacs(mgs) &
22170 & + max( 0.0, zhldsv(mgs) )
22171
22172 pzhld(mgs) = 0.0 &
22173 & + (1-il5(mgs))*zhlmlr(mgs) &
22174 & + zhlshr(mgs) &
22175 & - zhcnhl(mgs) &
22176 & + min( 0.0, zhldsv(mgs) )
22177
22178
22179 IF ( .not. ( -1.0 < pzhli(mgs) .and. pzhli(mgs) < 1.e20 ) ) THEN
22180 write(iunit,*) 'Problem with pzhli!'
22181 write(iunit,*) 'zhlcnh,zhlacw,zhlacr,zhldsv = ',zhlcnh(mgs),zhlacw(mgs),zhlacr(mgs),zhldsv(mgs)
22182 ENDIF
22183
22184 IF ( .not. ( -1.0e20 < pzhld(mgs) .and. pzhld(mgs) < 1. ) ) THEN
22185 write(iunit,*) 'Problem with pzhld!'
22186 write(iunit,*) 'zhlmlr,zhlshr,zhldsv = ',zhlmlr(mgs),zhlshr(mgs),zhldsv(mgs)
22187 ENDIF
22188
22189 ENDIF ! lzhl > 1
22190
22191 end do
22192
22193 ENDIF
22194
22195!
22196! rain reflectivity
22197!
22198 if (ndebug .gt. 0 ) write(0,*) 'WARMZIEG: dbg = 11'
22199
22200 IF ( lzr .gt. 1 ) THEN !
22201
22202 DO mgs = 1,ngscnt
22203
22204 zracw(mgs) = 0.0
22205 zracr(mgs) = 0.0
22206 zrcev(mgs) = 0.0
22207 zrach(mgs) = 0.0
22208 zrachl(mgs) = 0.0
22209 zsshr(mgs) = 0.0
22210 zsshrr(mgs) = 0.0
22211! zsmlr(mgs) = 0.0
22212 zsmlrr(mgs) = 0.0
22213
22214 IF ( qx(mgs,ls) .gt. qxmin(ls) .and. ( csmlr(mgs) /= 0.0 .or. csshr(mgs) /= 0.0 .or. &
22215 csmlrr(mgs) /= 0.0 .or. csshrr(mgs) /= 0.0) ) THEN !{
22216 tmp = qx(mgs,ls)/cx(mgs,ls)
22217 g1 = 36.*(xnu(ls)+2.0)/((xnu(ls)+1.0)*pi**2)
22218 IF ( .not. mixedphase ) THEN
22219! zsmlr(mgs) = (xdn(mgs,ls)/xdn(mgs,lr))**2*g1*(rho0(mgs)/(xdn(mgs,ls)))**2* &
22220! & ( 2.*tmp * qsmlr(mgs) - tmp**2 * csmlr(mgs) )
22221
22222 IF ( csmlrr(mgs) /= 0.0 ) THEN
22223 z1 = g1smlr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qsmlr(mgs)**2/ csmlrr(mgs) )
22224 zsmlrr(mgs) = z1
22225 ENDIF
22226 ENDIF
22227
22228! zsshr(mgs) = (xdn(mgs,ls)/xdn(mgs,lr))**2*g1*(rho0(mgs)/(xdn(mgs,ls)))**2* &
22229! & ( 2.*tmp * qsshr(mgs) - tmp**2 * csshr(mgs) )
22230
22231 IF ( csshrr(mgs) /= 0.0 ) THEN
22232 z1 = g1smlr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qsshr(mgs)**2/ csshrr(mgs) )
22233 zsshrr(mgs) = z1
22234 ENDIF
22235
22236 ENDIF !}
22237
22238 IF ( .not. mixedphase ) THEN !{
22239 IF ( zhmlr(mgs) < 0.0 .and. chmlrr(mgs) /= 0.0 .and. ibinhmlr == 0 ) THEN !{
22240 tmp = qx(mgs,lh)/cx(mgs,lh)
22241! zhmlrr(mgs) = Min(0.0, (xdn(mgs,lh)/xdn(mgs,lr))**2 * &
22242! & g1x(mgs,lh)*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*tmp * qhmlr(mgs) - tmp**2 * chmlrr(mgs) ) )
22243
22244! IF ( zhmlrr(mgs) >= 0. ) THEN
22245! zhmlrr(mgs) = (xdn(mgs,lh)/xdn(mgs,lr))**2 * zhmlr(mgs)
22246! ENDIF
22247 IF ( (shedalp + alpha(mgs,lh))*xdia(mgs,lh,1) < sheddiam ) THEN ! if not shedding small drops, then use alpha of graupel
22248 z1 = g1x(mgs,lh)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhmlr(mgs)**2/ chmlrr(mgs) )
22249 ELSE ! assume drops are shed off, so use either alpha for shedding or graupel alpha, whichever gives the lower g-factor (i.e., larger alpha)
22250 z1 = min(g1x(mgs,lh),g1shr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhmlr(mgs)**2/ chmlrr(mgs) )
22251 ENDIF
22252 zhmlrr(mgs) = z1
22253! z1 = g1mlr*(rho0(mgs)/(xdn(mgs,lr)))**2*( qhmlr(mgs)**2/ chmlrr(mgs) )
22254! zhmlrr(mgs) = Max( z1, zhmlrr(mgs))
22255 ENDIF !}
22256
22257
22258! zhshrr(mgs) = (xdn(mgs,lh)/xdn(mgs,lr))**2 * zhshr(mgs)
22259
22260 IF ( lhl > 1 .and. qhlmlr(mgs) /= 0 .and. ibinhlmlr == 0) THEN
22261 tmp = qx(mgs,lhl)/cx(mgs,lhl)
22262! zhlmlrr(mgs) = Min(0.0, (xdn(mgs,lhl)/xdn(mgs,lr))**2 * &
22263! & g1x(mgs,lhl)*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*tmp * qhlmlr(mgs) - tmp**2 * chlmlrr(mgs) ) )
22264
22265! IF ( zhlmlrr(mgs) >= 0. ) THEN ! should be negative, if not, then use alternate calculation
22266! zhlmlrr(mgs) = (xdn(mgs,lhl)/xdn(mgs,lr))**2 * zhlmlr(mgs)
22267! ENDIF
22268
22269 IF ( (shedalp + alpha(mgs,lhl))*xdia(mgs,lhl,1) < sheddiam ) THEN ! if not shedding small drops, then use alpha of hail
22270 z1 = g1x(mgs,lhl)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlmlr(mgs)**2/ chlmlrr(mgs) )
22271 ELSE ! assume drops are shed off, so use either alpha for shedding or graupel alpha, whichever gives the lower g-factor (i.e., larger alpha)
22272 z1 = min(g1x(mgs,lhl),g1shr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlmlr(mgs)**2/ chlmlrr(mgs) )
22273! z1 = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlmlr(mgs)**2/ chlmlrr(mgs) )
22274 ENDIF
22275 zhlmlrr(mgs) = z1
22276
22277! z1 = g1mlr*(rho0(mgs)/(xdn(mgs,lr)))**2*( qhlmlr(mgs)**2/ chlmlrr(mgs) )
22278! zhlmlrr(mgs) = Max( z1, zhlmlrr(mgs))
22279! zhlmlr(mgs) =
22280! zhlshrr(mgs) = (xdn(mgs,lhl)/xdn(mgs,lr))**2 * zhlshr(mgs)
22281 ENDIF
22282
22283 ENDIF ! }
22284
22285 IF ( qx(mgs,lr) .gt. qxmin(lr) .and. cx(mgs,lr) .gt. 0.0 ) THEN
22286
22287 tmp = qx(mgs,lr)/cx(mgs,lr)
22288 g1 = g1x(mgs,lr) ! 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
22289
22290
22291 IF ( qracw(mgs) > 0.0 .and. cx(mgs,lr) > 0.0 ) THEN
22292 zracw(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*tmp * qracw(mgs) )
22293 ENDIF
22294
22295 IF ( cracr(mgs) > 0.0 .and. cx(mgs,lr) > 0.0 ) THEN
22296 zracr(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*1000.))**2*( tmp**2 * cracr(mgs) )
22297 ENDIF
22298
22299 qtmp = qrcev(mgs)
22300 ctmp = crcev(mgs)
22301
22302! IF ( .false. .or. iferwisventr == 2 ) THEN
22303! zrcev(mgs) = Min(0.0, (12./(pii*xdn(mgs,lr)))*xdia(mgs,lr,1)**3*fvce(mgs)*rwcap(mgs)*rwventz(mgs) )
22304! ELSE
22305 zrcev(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( 2.*( tmp ) * qtmp - tmp**2 * ctmp )
22306
22307
22308 IF ( iferwisventr == 2 ) THEN
22309 vent1 = min(0.0, (12./(pii*xdn(mgs,lr)))*xdia(mgs,lr,1)**3*fvce(mgs)*rwcap(mgs)*rwventz(mgs))
22310 zrcev(mgs) = max( zrcev(mgs), vent1 )
22311 ENDIF
22312! IF ( ny == 2 .and. igs(mgs) == 20 ) THEN
22313! write(0,*) 'k,zrcevold,new,maxdep : ',kgs(mgs),zrcev(mgs),vent1,-zxmxd(mgs,lr),alpha(mgs,lr),cx(mgs,lr)
22314! ENDIF
22315
22316
22317! ENDIF
22318 zrcev(mgs) = max( zrcev(mgs), -zxmxd(mgs,lr) )
22319
22320 IF ( qhacr(mgs) > 0.0 ) THEN
22321 zrach(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2* &
22322 & ( 2.*( qx(mgs,lr)/cx(mgs,lr)) * qhacr(mgs) - tmp**2 * chacr(mgs) )
22323 zrach(mgs) = min( zrach(mgs), zxmxd(mgs,lr) )
22324
22325 ENDIF
22326
22327 IF ( lhl > 1 .and. qhlacr(mgs) > 0.0 ) THEN
22328 zrachl(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2* &
22329 & ( 2.*( qx(mgs,lr)/cx(mgs,lr)) * qhlacr(mgs) - tmp**2 * chlacr(mgs) )
22330 zrachl(mgs) = min( zrachl(mgs), zxmxd(mgs,lr) )
22331 ENDIF
22332
22333
22334
22335 ENDIF
22336
22337 pzrwi(mgs) = zrcnw(mgs) + zracw(mgs) + zracr(mgs) &
22338 & + max( 0.,zrcev(mgs) ) &
22339 & - (1-il5(mgs))*zsmlrr(mgs) &
22340 & - zsshrr(mgs) &
22341 & - (1-il5(mgs))*zhmlrr(mgs) &
22342 & - zhshrr(mgs) &
22343 & - (1-il5(mgs))*zhlmlrr(mgs) &
22344 & - zhlshrr(mgs)
22345
22346
22347 pzrwd(mgs) = 0.0 &
22348 & + min(0.,zrcev(mgs) ) &
22349 & - zrach(mgs) &
22350 & - zrachl(mgs) &
22351 & - zrfrz(mgs) &
22352 & - il5(mgs)*(ziacr(mgs) )
22353
22354
22355 IF ( zx(mgs,lr) + dtp*(pzrwi(mgs)+pzrwd(mgs)) <= 0.0 &
22356 .and. qx(mgs,lr) > qxmin(lr) ) THEN
22357 pzrwd(mgs) = -zx(mgs,lr)*dtpinv - pzrwi(mgs)
22358 ENDIF
22359
22360 ENDDO
22361
22362 ENDIF
22363
22364
22365
22366!
22367! Snow volume
22368!
22369 IF ( lvol(ls) .gt. 1 ) THEN
22370 do mgs = 1,ngscnt
22371! pvswi(mgs) = rho0(mgs)*( pqswi(mgs) )/xdn0(ls)
22372
22373 pvswi(mgs) = rho0(mgs)*( &
22374!aps > il5*qsfzs(mgs)/xdn(mgs,ls) &
22375!aps > -il5*qsfzs(mgs)/xdn(mgs,lr) &
22376 & +il5(mgs)*(qscni(mgs)+qsaci(mgs)+qsdpv(mgs) &
22377 & + qscnvi(mgs) + (1. - ifrzs)*qiacrs(mgs) &
22378 & + (1. - ifrzs)*qrfrzs(mgs) &
22379 & )/xdn0(ls) &
22380 & + (qsacr(mgs))/rimdn(mgs,ls) ) + vsacw(mgs)
22381! > + (qsacw(mgs) + qsacr(mgs))/rimdn(mgs,ls) )
22382 pvswd(mgs) = rho0(mgs)*( pqswd(mgs) )/xdn0(ls) &
22383! > -qhacs(mgs)
22384! > -qhcns(mgs)
22385! > +(1-il5(mgs))*qsmlr(mgs) + qsshr(mgs)
22386! > +il5(mgs)*(qssbv(mgs))
22387 & -rho0(mgs)*qsmul(mgs)/xdn0(ls)
22388!aps > +rho0(mgs)*(1-il5(mgs))*(
22389!aps > qsmlr(mgs)/xdn(mgs,ls)
22390!aps > +(qscev-qsmlr(mgs))/xdn(mgs,lr) )
22391 end do
22392
22393!aps IF (mixedphase) THEN
22394!aps pvswd(mgs) = pvswd(mgs)
22395!aps > + rho0(mgs)*qsshr(mgs)/xdn(mgs,lr)
22396!aps ENDIF
22397
22398 ENDIF
22399!
22400! Graupel volume
22401!
22402 IF ( lvol(lh) .gt. 1 ) THEN
22403 DO mgs = 1,ngscnt
22404! pvhwi(mgs) = rho0(mgs)*( (pqhwi(mgs) )/xdn0(lh) )
22405
22406! pvhwi(mgs) = rho0(mgs)*( (pqhwi(mgs) - il5(mgs)*qrfrzf(mgs) )/xdn0(lh) !
22407! : + il5(mgs)*qrfrzf(mgs)/rhofrz )
22408
22409 pvhwi(mgs) = rho0(mgs)*( &
22410 & +il5(mgs)*( ifiacrg*ffrzh*qracif(mgs))/rhofrz &
22411!erm > + il5(mgs)*qhfzh(mgs)/rhofrz !aps: or use xdnmx(lh)? &
22412 & + ( il5(mgs)*qhdpv(mgs)/qhdpvdn &
22413 & + (qhacs(mgs) + qhaci(mgs))/qhacidn ) ) &
22414 & + rho0(mgs)*max(0.0, qhcev(mgs))/1000. & ! only used in mixed phase: evaporation/condensation of liquid water coating
22415! > + qhacs(mgs) + qhaci(mgs) )/xdn0(ls) ) &
22416 & + f2h*vhcns(mgs) &
22417 & + vhacr(mgs) + vhacw(mgs) + vhfzh(mgs) & ! qhacw(mgs)/rimdn(mgs,lh)
22418! > + vhfrh(mgs) &
22419 & + f2h*vhcni(mgs) + (ifiacrg*viacrf(mgs) + ifrzg*vrfrzf(mgs))*ffrzh
22420! > +qhacr(mgs)/raindn(mgs,lh) + qhacw(mgs)/rimdn(mgs,lh)
22421
22422! pvhwd(mgs) = rho0(mgs)*(pqhwd(mgs) )/xdn0(lh)
22423
22424 pvhwd(mgs) = rho0(mgs)*( &
22425! > qhshr(mgs)/xdn0(lr) &
22426! > - il5(mgs)*qhfzh(mgs)/xdn(mgs,lr) &
22427 & +( (1-il5(mgs))*vhmlr(mgs) &
22428! > +il5(mgs)*qhsbv(mgs) &
22429 & + qhsbv(mgs) &
22430 & + min(0.0, qhcev(mgs)) &
22431 & -qhmul1(mgs) )/xdn(mgs,lh) ) &
22432 & - vhlcnh(mgs) + vhshdr(mgs) - vhsoak(mgs) - vscnh(mgs)
22433
22434! IF (mixedphase) THEN
22435! pvhwd(mgs) = pvhwd(mgs)
22436! > + rho0(mgs)*qhshr(mgs)/xdn(mgs,lh) !xdn(mgs,lr)
22437! ENDIF
22438
22439 IF ( lzh > 1 .and. qx(mgs,lh) > qxmin(lh) ) THEN
22440! Calculate change in reflectivity due to density changes
22441
22442 xdn_new = rho0(mgs)*(qx(mgs,lh) + dtp*(pqhwi(mgs) + pqhwd(mgs) ))/ &
22443 & (vx(mgs,lh) + dtp*(pvhwi(mgs) + pvhwd(mgs)) )
22444
22445 IF ( mixedphase ) THEN
22446 IF ( qxw(mgs,lh) .gt. 0.0 ) THEN
22447 dnmx = xdnmx(lr)
22448 ELSE
22449 dnmx = xdnmx(lh)
22450 ENDIF
22451 ELSE
22452 dnmx = xdnmx(lh)
22453 ENDIF
22454
22455 xdn_new = max( min( xdn_new, dnmx ), xdnmn(lh) )
22456
22457 drhodt = (xdn_new - xdn(mgs,lh))*dtpinv
22458
22459 zhwdn(mgs) = -2.*g1x(mgs,lh)*(rho0(mgs)*qx(mgs,lh)*6.*pii )**2/(cx(mgs,lh)*xdn(mgs,lh)**3)*drhodt
22460
22461 pzhwi(mgs) = pzhwi(mgs) + max(0.0, zhwdn(mgs))
22462 pzhwd(mgs) = pzhwd(mgs) + min(0.0, zhwdn(mgs))
22463
22464
22465 ENDIF
22466 IF ( .false. .and. ny .eq. 2 .and. kgs(mgs) .eq. 9 .and. igs(mgs) .eq. 19 ) THEN
22467
22468 write(iunit,*)
22469 write(iunit,*) 'Graupel at ',igs(mgs),kgs(mgs)
22470!
22471 write(iunit,*) il5(mgs)*qrfrzf(mgs), qrfrzf(mgs) - qrfrz(mgs)
22472 write(iunit,*) il5(mgs)*qiacrf(mgs)
22473 write(iunit,*) il5(mgs)*qracif(mgs)
22474 write(iunit,*) 'qhcns',qhcns(mgs)
22475 write(iunit,*) 'qhcni',qhcni(mgs)
22476 write(iunit,*) il5(mgs)*(qhdpv(mgs))
22477 write(iunit,*) 'qhacr ',qhacr(mgs)
22478 write(iunit,*) 'qhacw', qhacw(mgs)
22479 write(iunit,*) 'qhacs', qhacs(mgs)
22480 write(iunit,*) 'qhaci', qhaci(mgs)
22481 write(iunit,*) 'pqhwi = ',pqhwi(mgs)
22482 write(iunit,*)
22483 write(iunit,*) 'qhcev',qhcev(mgs)
22484 write(iunit,*)
22485 write(iunit,*) 'qhshr',qhshr(mgs)
22486 write(iunit,*) 'qhmlr', (1-il5(mgs))*qhmlr(mgs)
22487 write(iunit,*) 'qhsbv', qhsbv(mgs)
22488 write(iunit,*) 'qhlcnh',-qhlcnh(mgs)
22489 write(iunit,*) 'qhmul1',-qhmul1(mgs)
22490 write(iunit,*) 'pqhwd = ', pqhwd(mgs)
22491 write(iunit,*)
22492 write(iunit,*) 'Volume'
22493 write(iunit,*)
22494 write(iunit,*) 'pvhwi',pvhwi(mgs)
22495 write(iunit,*) 'vhcns', vhcns(mgs)
22496 write(iunit,*) 'vhacr,vhacw',vhacr(mgs), vhacw(mgs) ! qhacw(mgs)/rimdn(mgs,lh)
22497 write(iunit,*) 'vhcni',vhcni(mgs)
22498 write(iunit,*)
22499 write(iunit,*) 'pvhwd',pvhwd(mgs)
22500 write(iunit,*) 'vhlcnh,vhshdr,vhsoak ', vhlcnh(mgs), vhshdr(mgs), vhsoak(mgs)
22501 write(iunit,*) 'vhmlr', vhmlr(mgs)
22502 write(iunit,*)
22503! write(iunit,*)
22504! write(iunit,*)
22505! write(iunit,*)
22506 write(iunit,*) 'Concentration'
22507 write(iunit,*) pchwi(mgs),pchwd(mgs)
22508 write(iunit,*) crfrzf(mgs)
22509 write(iunit,*) chcns(mgs)
22510 write(iunit,*) ciacrf(mgs)
22511
22512
22513 ENDIF
22514
22515
22516 ENDDO
22517
22518 ENDIF
22519!
22520!
22521!
22522
22523!
22524! Hail volume
22525!
22526 IF ( lhl .gt. 1 ) THEN
22527 IF ( lvol(lhl) .gt. 1 ) THEN
22528 DO mgs = 1,ngscnt
22529
22530 pvhli(mgs) = rho0(mgs)*( &
22531 & + ( il5(mgs)*(((1.0-ifiacrg)*ffrzh*qracif(mgs))/rhofrz + qhldpv(mgs) ) &
22532! & + Max(0.0, qhlcev(mgs)) &
22533! & + qhlacs(mgs) + qhlaci(mgs) )/xdnmn(lhl) ) & ! xdn0(ls) ) &
22534! & + qhlacs(mgs) + qhlaci(mgs) )/xdnmn(lh) ) & ! yes, this is 'lh' on purpose
22535 & + qhlacs(mgs) + qhlaci(mgs) )/500. ) & ! changed to 500 instead of min graupel density to keep hail density from dropping too much
22536 & + rho0(mgs)*max(0.0, qhlcev(mgs))/1000. &
22537 & + vhlcnhl(mgs) + ((1.0-ifiacrg)*ffrzh*viacrf(mgs) + (1.0-ifrzg)*ffrzh*vrfrzf(mgs)) &
22538 & + vhlacr(mgs) + vhlacw(mgs) + vhlfzhl(mgs) ! qhlacw(mgs)/rimdn(mgs,lhl)
22539
22540 pvhld(mgs) = rho0(mgs)*( &
22541 & +( qhlsbv(mgs) &
22542 & + min(0.0, qhlcev(mgs)) &
22543 & -qhlmul1(mgs) )/xdn(mgs,lhl) ) &
22544! & + vhlmlr(mgs) &
22545 & + rho0(mgs)*(1-il5(mgs))*vhlmlr(mgs)/xdn(mgs,lhl) &
22546 & + vhlshdr(mgs) - vhlsoak(mgs)
22547
22548 IF ( lzhl > 1 .and. qx(mgs,lhl) > qxmin(lhl) ) THEN
22549! Calculate change in reflectivity due to density changes
22550
22551 xdn_new = rho0(mgs)*(qx(mgs,lhl) + dtp*(pqhli(mgs) + pqhld(mgs) ))/ &
22552 & (vx(mgs,lhl) + dtp*(pvhli(mgs) + pvhld(mgs)) )
22553
22554 IF ( mixedphase ) THEN
22555 IF ( qxw(mgs,lhl) .gt. 0.0 ) THEN
22556 dnmx = xdnmx(lr)
22557 ELSE
22558 dnmx = xdnmx(lhl)
22559 ENDIF
22560 ELSE
22561 dnmx = xdnmx(lhl)
22562 ENDIF
22563 xdn_new = max( min( xdn_new, dnmx ), xdnmn(lhl) )
22564
22565 drhodt = (xdn_new - xdn(mgs,lhl))*dtpinv
22566
22567 zhldn(mgs) = -2.*g1x(mgs,lhl)*(rho0(mgs)*qx(mgs,lhl)*6.*pii )**2/(cx(mgs,lhl)*xdn(mgs,lhl)**3)*drhodt
22568
22569 pzhli(mgs) = pzhli(mgs) + max(0.0, zhldn(mgs))
22570 pzhld(mgs) = pzhld(mgs) + min(0.0, zhldn(mgs))
22571
22572
22573 ENDIF
22574
22575 ENDDO
22576
22577 ENDIF
22578 ENDIF
22579
22580
22581 if ( ndebug .ge. 1 ) then
22582 do mgs = 1,ngscnt
22583!
22584 ptotal(mgs) = 0.
22585 ptotal(mgs) = ptotal(mgs) &
22586 & + pqwvi(mgs) + pqwvd(mgs) &
22587 & + pqcwi(mgs) + pqcwd(mgs) &
22588 & + pqcii(mgs) + pqcid(mgs) &
22589 & + pqrwi(mgs) + pqrwd(mgs) &
22590 & + pqswi(mgs) + pqswd(mgs) &
22591 & + pqhwi(mgs) + pqhwd(mgs) &
22592 & + pqhli(mgs) + pqhld(mgs)
22593!
22594
22595
22596
22597 ENDDO
22598
22599 do mgs = 1,ngscnt
22600
22601 if ( ( (ndebug .ge. 0 ) .and. abs(ptotal(mgs)) .gt. eqtot ) &
22602! if ( ( abs(ptotal(mgs)) .gt. eqtot )
22603! : .or. pqswi(mgs)*dtp .gt. 1.e-3
22604! : .or. pqhwi(mgs)*dtp .gt. 1.e-3
22605! : .or. dtp*(pqrwi(mgs)+pqrwd(mgs)) .gt. 10.0e-3
22606! : .or. dtp*(pccii(mgs)+pccid(mgs)) .gt. 1.e7
22607! : .or. dtp*(pcipi(mgs)+pcipd(mgs)) .gt. 1.e7 &
22608 & .or. .not. (ptotal(mgs) .lt. 1.0 .and. ptotal(mgs) .gt. -1.0) & ! this line is basically checking for NaNs
22609 & ) then
22610 write(iunit,*) 'YIKES! ','ptotal1',mgs,igs(mgs),jgs, &
22611 & kgs(mgs),ptotal(mgs)
22612
22613 write(iunit,*) 't7: ', t7(igs(mgs),jgs,kgs(mgs))
22614 write(iunit,*) 'cci,ccw,crw,rdia: ',cx(mgs,li),cx(mgs,lc),cx(mgs,lr),0.5*xdia(mgs,lr,1)
22615 write(iunit,*) 'qc,qi,qr : ',qx(mgs,lc),qx(mgs,li),qx(mgs,lr)
22616 write(iunit,*) 'rmas, qrcalc : ',xmas(mgs,lr),xmas(mgs,lr)*cx(mgs,lr)/rho0(mgs)
22617 write(iunit,*) 'vti,vtc,eiw,vtr: ',vtxbar(mgs,li,1),vtxbar(mgs,lc,1),eiw(mgs),vtxbar(mgs,lr,1)
22618 write(iunit,*) 'cidia,cwdia,qcmxd: ', xdia(mgs,li,1),xdia(mgs,lc,1),qcmxd(mgs)
22619 write(iunit,*) 'snow: ',qx(mgs,ls),cx(mgs,ls),swvent(mgs),vtxbar(mgs,ls,1),xdia(mgs,ls,1)
22620 write(iunit,*) 'graupel: ',qx(mgs,lh),cx(mgs,lh),hwvent(mgs),vtxbar(mgs,lh,1),xdia(mgs,lh,1)
22621 IF ( lhl .gt. 1 ) write(iunit,*) 'hail: ',qx(mgs,lhl),cx(mgs,lhl),hlvent(mgs),vtxbar(mgs,lhl,1),xdia(mgs,lhl,1)
22622
22623
22624 write(iunit,*) 'li: ',xdia(mgs,li,1),xdia(mgs,li,2),xmas(mgs,li),qx(mgs,li), &
22625 & vtxbar(mgs,li,1)
22626
22627
22628 write(iunit,*) 'rain cx,xv : ',cx(mgs,lr),xv(mgs,lr)
22629 write(iunit,*) 'temcg = ', temcg(mgs)
22630
22631 write(iunit,*) 'v ', pqwvi(mgs) ,pqwvd(mgs)
22632 write(iunit,*) 'c ', pqcwi(mgs) ,pqcwd(mgs)
22633 write(iunit,*) 'ci', pqcii(mgs) ,pqcid(mgs)
22634 write(iunit,*) 'r ', pqrwi(mgs) ,pqrwd(mgs)
22635 write(iunit,*) 's ', pqswi(mgs) ,pqswd(mgs)
22636 write(iunit,*) 'h ', pqhwi(mgs) ,pqhwd(mgs)
22637 write(iunit,*) 'hl', pqhli(mgs) ,pqhld(mgs)
22638 tmp = pqwvi(mgs) + pqwvd(mgs) &
22639 & + pqcwi(mgs) + pqcwd(mgs) &
22640 & + pqcii(mgs) + pqcid(mgs) &
22641 & + pqrwi(mgs) + pqrwd(mgs) &
22642 & + pqswi(mgs) + pqswd(mgs) &
22643 & + pqhwi(mgs) + pqhwd(mgs) &
22644 & + pqhli(mgs) + pqhld(mgs)
22645
22646 write(iunit,*) 'total = ',tmp
22647 write(iunit,*) 'END OF OUTPUT OF SOURCE AND SINK'
22648
22649!
22650! print production terms
22651!
22652 write(iunit,*)
22653 write(iunit,*) 'Vapor'
22654!
22655 write(iunit,*) -min(0.0,qrcev(mgs))
22656 write(iunit,*) -il5(mgs)*qhsbv(mgs)
22657 write(iunit,*) -il5(mgs)*qhlsbv(mgs)
22658 write(iunit,*) -il5(mgs)*qssbv(mgs)
22659 write(iunit,*) -il5(mgs)*qisbv(mgs)
22660 write(iunit,*) 'pqwvi= ', pqwvi(mgs)
22661 write(iunit,*) -max(0.0,qrcev(mgs))
22662 write(iunit,*) -max(0.0,qhcev(mgs))
22663 write(iunit,*) -max(0.0,qhlcev(mgs))
22664 write(iunit,*) -max(0.0,qscev(mgs))
22665 write(iunit,*) -il5(mgs)*qiint(mgs)
22666 write(iunit,*) -il5(mgs)*qhdpv(mgs)
22667 write(iunit,*) -il5(mgs)*qhldpv(mgs)
22668 write(iunit,*) -il5(mgs)*qsdpv(mgs)
22669 write(iunit,*) -il5(mgs)*qidpv(mgs)
22670 write(iunit,*) 'pqwvd = ', pqwvd(mgs)
22671!
22672 write(iunit,*)
22673 write(iunit,*) 'Cloud ice'
22674!
22675 write(iunit,*) il5(mgs)*qicicnt(mgs)
22676 write(iunit,*) il5(mgs)*qidpv(mgs)
22677 write(iunit,*) il5(mgs)*qiacw(mgs)
22678 write(iunit,*) il5(mgs)*qwfrzc(mgs)
22679 write(iunit,*) il5(mgs)*qwctfzc(mgs)
22680 write(iunit,*) il5(mgs)*qicichr(mgs)
22681 write(iunit,*) qhmul1(mgs)
22682 write(iunit,*) qhlmul1(mgs)
22683 write(iunit,*) 'pqcii = ', pqcii(mgs)
22684 write(iunit,*) -il5(mgs)*qscni(mgs)
22685 write(iunit,*) -il5(mgs)*qscnvi(mgs)
22686 write(iunit,*) -il5(mgs)*qraci(mgs)
22687 write(iunit,*) -il5(mgs)*qsaci(mgs)
22688 write(iunit,*) -il5(mgs)*qhaci(mgs)
22689 write(iunit,*) -il5(mgs)*qhlaci(mgs)
22690 write(iunit,*) il5(mgs)*qisbv(mgs)
22691 write(iunit,*) (1.-il5(mgs))*qimlr(mgs)
22692 write(iunit,*) -il5(mgs)*qhcni(mgs)
22693 write(iunit,*) 'pqcid = ', pqcid(mgs)
22694 write(iunit,*) ' Conc:'
22695 write(iunit,*) pccii(mgs),pccid(mgs)
22696 write(iunit,*) il5(mgs),cicint(mgs)
22697 write(iunit,*) cwfrzc(mgs),cwctfzc(mgs)
22698 write(iunit,*) cicichr(mgs)
22699 write(iunit,*) chmul1(mgs)
22700 write(iunit,*) chlmul1(mgs)
22701 write(iunit,*) csmul(mgs)
22702!
22703!
22704!
22705!
22706 write(iunit,*)
22707 write(iunit,*) 'Cloud water'
22708!
22709 write(iunit,*) 'pqcwi =', pqcwi(mgs)
22710 write(iunit,*) -il5(mgs)*qiacw(mgs)
22711 write(iunit,*) -il5(mgs)*qwfrzc(mgs)
22712 write(iunit,*) -il5(mgs)*qwctfzc(mgs)
22713! write(iunit,*) -il5(mgs)*qwfrzp(mgs)
22714! write(iunit,*) -il5(mgs)*qwctfzp(mgs)
22715 write(iunit,*) -il5(mgs)*qiihr(mgs)
22716 write(iunit,*) -il5(mgs)*qicichr(mgs)
22717 write(iunit,*) -il5(mgs)*qipiphr(mgs)
22718 write(iunit,*) -qracw(mgs)
22719 write(iunit,*) -qsacw(mgs)
22720 write(iunit,*) -qrcnw(mgs)
22721 write(iunit,*) -qhacw(mgs)
22722 write(iunit,*) -qhlacw(mgs)
22723 write(iunit,*) 'pqcwd = ', pqcwd(mgs)
22724
22725
22726 write(iunit,*)
22727 write(iunit,*) 'Concentration:'
22728 write(iunit,*) -cautn(mgs)
22729 write(iunit,*) -cracw(mgs)
22730 write(iunit,*) -csacw(mgs)
22731 write(iunit,*) -chacw(mgs)
22732 write(iunit,*) -ciacw(mgs)
22733 write(iunit,*) -cwfrzp(mgs)
22734 write(iunit,*) -cwctfzp(mgs)
22735 write(iunit,*) -cwfrzc(mgs)
22736 write(iunit,*) -cwctfzc(mgs)
22737 write(iunit,*) pccwd(mgs)
22738!
22739 write(iunit,*)
22740 write(iunit,*) 'Rain '
22741!
22742 write(iunit,*) qracw(mgs)
22743 write(iunit,*) qrcnw(mgs)
22744 write(iunit,*) max(0.0, qrcev(mgs))
22745 write(iunit,*) -(1-il5(mgs))*qhmlr(mgs)
22746 write(iunit,*) -(1-il5(mgs))*qhlmlr(mgs)
22747 write(iunit,*) -(1-il5(mgs))*qsmlr(mgs)
22748 write(iunit,*) -(1-il5(mgs))*qimlr(mgs)
22749 write(iunit,*) -qrshr(mgs)
22750 write(iunit,*) 'pqrwi = ', pqrwi(mgs)
22751 write(iunit,*) -qsshr(mgs)
22752 write(iunit,*) -qhshr(mgs)
22753 write(iunit,*) -qhlshr(mgs)
22754 write(iunit,*) -il5(mgs)*qiacr(mgs),qiacr(mgs), qiacrf(mgs)
22755 write(iunit,*) -il5(mgs)*qrfrz(mgs)
22756 write(iunit,*) -qsacr(mgs)
22757 write(iunit,*) -qhacr(mgs)
22758 write(iunit,*) -qhlacr(mgs)
22759 write(iunit,*) qrcev(mgs)
22760 write(iunit,*) 'pqrwd = ', pqrwd(mgs)
22761 write(iunit,*) 'qrzfac = ', qrzfac(mgs)
22762!
22763
22764 write(iunit,*)
22765 write(iunit,*) 'Rain concentration'
22766 write(iunit,*) pcrwi(mgs)
22767 write(iunit,*) crcnw(mgs)
22768 write(iunit,*) 1-il5(mgs)
22769 write(iunit,*) -chmlr(mgs),-csmlr(mgs)
22770 write(iunit,*) -crshr(mgs)
22771 write(iunit,*) pcrwd(mgs)
22772 write(iunit,*) il5(mgs)
22773 write(iunit,*) -ciacr(mgs),-crfrz(mgs)
22774 write(iunit,*) -csacr(mgs),-chacr(mgs)
22775 write(iunit,*) +crcev(mgs)
22776 write(iunit,*) cracr(mgs)
22777! write(iunit,*) -il5(mgs)*ciracr(mgs)
22778
22779
22780 write(iunit,*)
22781 write(iunit,*) 'Snow'
22782!
22783 write(iunit,*) il5(mgs)*qscni(mgs), qscnvi(mgs)
22784 write(iunit,*) il5(mgs)*qsaci(mgs)
22785 write(iunit,*) il5(mgs)*qrfrzs(mgs)
22786 write(iunit,*) il5(mgs)*qiacrs(mgs),il3(mgs)*(qiacrf(mgs)+qracif(mgs)),il3(mgs),qiacrf(mgs),qracif(mgs)
22787 write(iunit,*) il5(mgs)*qsdpv(mgs), qscev(mgs)
22788 write(iunit,*) qsacw(mgs)
22789 write(iunit,*) qsacr(mgs), qscnh(mgs)
22790 write(iunit,*) 'pqswi = ',pqswi(mgs)
22791 write(iunit,*) -qhcns(mgs)
22792 write(iunit,*) -qracs(mgs)
22793 write(iunit,*) -qhacs(mgs)
22794 write(iunit,*) -qhlacs(mgs)
22795 write(iunit,*) (1-il5(mgs))*qsmlr(mgs)
22796 write(iunit,*) qsshr(mgs)
22797! write(iunit,*) qsshrp(mgs)
22798 write(iunit,*) il5(mgs)*(qssbv(mgs))
22799 write(iunit,*) 'pqswd = ', pqswd(mgs)
22800 write(iunit,*) -qracs(mgs)*(1-il2(mgs)) , qhacs(mgs) , qhlacs(mgs)
22801 write(iunit,*) -qhcns(mgs)
22802 write(iunit,*) +(1-il5(mgs))*qsmlr(mgs) , qsshr(mgs)
22803 write(iunit,*) qssbv(mgs)
22804 write(iunit,*) min(0.0, qscev(mgs))
22805 write(iunit,*) -qsmul(mgs)
22806!
22807!
22808 write(iunit,*)
22809 write(iunit,*) 'Graupel'
22810!
22811 write(iunit,*) il5(mgs)*qrfrzf(mgs), qrfrzf(mgs) - qrfrz(mgs)
22812 write(iunit,*) il5(mgs)*qiacrf(mgs)
22813 write(iunit,*) il5(mgs)*qracif(mgs)
22814 write(iunit,*) qhcns(mgs)
22815 write(iunit,*) qhcni(mgs)
22816 write(iunit,*) il5(mgs)*(qhdpv(mgs))
22817 write(iunit,*) qhacr(mgs)
22818 write(iunit,*) qhacw(mgs)
22819 write(iunit,*) qhacs(mgs)
22820 write(iunit,*) qhaci(mgs)
22821 write(iunit,*) 'pqhwi = ',pqhwi(mgs)
22822 write(iunit,*)
22823 write(iunit,*) qhshr(mgs)
22824 write(iunit,*) (1-il5(mgs))*qhmlr(mgs)
22825 write(iunit,*) il5(mgs),qhsbv(mgs)
22826 write(iunit,*) -qhlcnh(mgs)
22827 write(iunit,*) -qhmul1(mgs)
22828 write(iunit,*) 'pqhwd = ', pqhwd(mgs)
22829 write(iunit,*) 'Concentration'
22830 write(iunit,*) pchwi(mgs),pchwd(mgs)
22831 write(iunit,*) crfrzf(mgs)
22832 write(iunit,*) chcns(mgs)
22833 write(iunit,*) ciacrf(mgs)
22834
22835!
22836 write(iunit,*)
22837 write(iunit,*) 'Hail'
22838!
22839 write(iunit,*) qhlcnh(mgs)
22840 write(iunit,*) il5(mgs)*(qhldpv(mgs))
22841 write(iunit,*) qhlacr(mgs)
22842 write(iunit,*) qhlacw(mgs)
22843 write(iunit,*) qhlacs(mgs)
22844 write(iunit,*) qhlaci(mgs)
22845 write(iunit,*) pqhli(mgs)
22846 write(iunit,*)
22847 write(iunit,*) qhlshr(mgs)
22848 write(iunit,*) (1-il5(mgs))*qhlmlr(mgs)
22849 write(iunit,*) il5(mgs)*qhlsbv(mgs)
22850 write(iunit,*) pqhld(mgs)
22851 write(iunit,*) 'Concentration'
22852 write(iunit,*) pchli(mgs),pchld(mgs)
22853 write(iunit,*) chlcnh(mgs)
22854!
22855! Balance and checks for continuity.....within machine precision...
22856!
22857!
22858 write(iunit,*) 'END OF OUTPUT OF SOURCE AND SINK'
22859 write(iunit,*) 'PTOTAL',ptotal(mgs)
22860!
22861 end if ! ptotal out of bounds or NaN
22862!
22863 end do
22864!
22865
22866 end if ! ( nstep/12*12 .eq. nstep )
22867
22868!
22869! latent heating from phase changes (except qcw, qci cond, and evap)
22870!
22871 do mgs = 1,ngscnt
22872 IF ( warmonly < 0.5 ) THEN
22873 pfrz(mgs) = &
22874 & (1-il5(mgs))* &
22875 & (qhmlr(mgs)+ &
22876 & qsmlr(mgs)+qhlmlr(mgs)) & !+qhmlh(mgs)) &
22877 & +il5(mgs)*(1-imixedphase)*( &
22878 & qsacw(mgs)+qhacw(mgs) + qhlacw(mgs) &
22879 & +qsacr(mgs)+qhacr(mgs) + qhlacr(mgs) &
22880 & +qsshr(mgs) &
22881 & +qhshr(mgs) &
22882 & +qhlshr(mgs) &
22883 & +qrfrz(mgs)+qiacr(mgs) &
22884 & ) &
22885 & +il5(mgs)*(qwfrz(mgs) &
22886 & +qwctfz(mgs)+qiihr(mgs) &
22887 & +qiacw(mgs))
22888 pmlt(mgs) = &
22889 & (1-il5(mgs))* &
22890 & (qhmlr(mgs)+qsmlr(mgs)+ &
22891 & qhlmlr(mgs)) !+qhmlh(mgs))
22892 ! NOTE: psub is sum of sublimation and deposition
22893 psub(mgs) = &
22894 & il5(mgs)*( &
22895 & + qsdpv(mgs) + qhdpv(mgs) &
22896 & + qhldpv(mgs) &
22897 & + qidpv(mgs) + qisbv(mgs) ) &
22898 & + qssbv(mgs) + qhsbv(mgs) &
22899 & + qhlsbv(mgs) &
22900 & +il5(mgs)*(qiint(mgs))
22901 pvap(mgs) = &
22902 & qrcev(mgs) + qhcev(mgs) + qscev(mgs) + qhlcev(mgs) + qfcev(mgs)
22903 pevap(mgs) = &
22904 & min(0.0,qrcev(mgs)) + min(0.0,qhcev(mgs)) + min(0.0,qscev(mgs)) + min(0.0,qhlcev(mgs)) &
22905 + min(0.0,qfcev(mgs))
22906 ! NOTE: pdep is the deposition part only
22907 pdep(mgs) = &
22908 & il5(mgs)*( &
22909 & + qsdpv(mgs) + qhdpv(mgs) &
22910 & + qhldpv(mgs) &
22911 & + qidpv(mgs) ) &
22912 & +il5(mgs)*(qiint(mgs))
22913 ELSEIF ( warmonly < 0.8 ) THEN
22914 pfrz(mgs) = &
22915 & (1-il5(mgs))* &
22916 & (qhmlr(mgs)+qhlmlr(mgs)) & !+qhmlh(mgs)) &
22917 & +il5(mgs)*(qhfzh(mgs)+qhlfzhl(mgs)) &
22918 & +il5(mgs)*( &
22919 & +qhshr(mgs) &
22920 & +qhlshr(mgs) &
22921 & +qrfrz(mgs)+qwfrz(mgs) &
22922 & +qwctfz(mgs)+qiihr(mgs) &
22923 & +qiacw(mgs) &
22924 & +qhacw(mgs) + qhlacw(mgs) &
22925 & +qhacr(mgs) + qhlacr(mgs) )
22926 psub(mgs) = 0.0 + &
22927 & il5(mgs)*( &
22928 & + qhdpv(mgs) &
22929 & + qhldpv(mgs) &
22930 & + qidpv(mgs) + qisbv(mgs) ) &
22931 & +il5(mgs)*(qiint(mgs))
22932 pvap(mgs) = &
22933 & qrcev(mgs) + qhcev(mgs) + qhlcev(mgs) + qfcev(mgs)
22934 ELSE
22935 pfrz(mgs) = 0.0
22936 psub(mgs) = 0.0
22937 pvap(mgs) = qrcev(mgs)
22938 ENDIF ! warmonly
22939 ptem(mgs) = &
22940 & (1./pi0(mgs))* &
22941 & (felfcp(mgs)*pfrz(mgs) &
22942 & +felscp(mgs)*psub(mgs) &
22943 & +felvcp(mgs)*pvap(mgs))
22944 thetap(mgs) = thetap(mgs) + dtp*ptem(mgs)
22945 ptem2(mgs) = ptem(mgs)
22946 IF ( eqtset > 2 ) THEN
22947 pipert(mgs) = pipert(mgs) + (felfpi(mgs)*pfrz(mgs) &
22948 & +felspi(mgs)*psub(mgs) &
22949 & +felvpi(mgs)*pvap(mgs))*dtp
22950 ENDIF
22951 end do
22952
22953
22954
22955
22956!
22957! sum the sources and sinks for qwvp, qcw, qci, qrw, qsw
22958!
22959!
22960 do mgs = 1,ngscnt
22961
22962
22963 qwvp(mgs) = qwvp(mgs) + &
22964 & dtp*(pqwvi(mgs)+pqwvd(mgs))
22965 qx(mgs,lc) = qx(mgs,lc) + &
22966 & dtp*(pqcwi(mgs)+pqcwd(mgs))
22967 qx(mgs,lr) = qx(mgs,lr) + &
22968 & dtp*(pqrwi(mgs)+pqrwd(mgs))
22969 qx(mgs,li) = qx(mgs,li) + &
22970 & dtp*(pqcii(mgs)+pqcid(mgs))
22971 qx(mgs,ls) = qx(mgs,ls) + &
22972 & dtp*(pqswi(mgs)+pqswd(mgs))
22973 qx(mgs,lh) = qx(mgs,lh) + &
22974 & dtp*(pqhwi(mgs)+pqhwd(mgs))
22975
22976 IF ( lhl .gt. 1 ) THEN
22977 qx(mgs,lhl) = qx(mgs,lhl) + &
22978 & dtp*(pqhli(mgs)+pqhld(mgs))
22979 ENDIF
22980
22981
22982 end do
22983
22984! sum sources for particle volume
22985
22986 IF ( ldovol ) THEN
22987
22988 do mgs = 1,ngscnt
22989
22990 IF ( lvol(ls) .gt. 1 ) THEN
22991 vx(mgs,ls) = vx(mgs,ls) + &
22992 & dtp*(pvswi(mgs)+pvswd(mgs))
22993 ENDIF
22994
22995 IF ( lvol(lh) .gt. 1 ) THEN
22996 vx(mgs,lh) = vx(mgs,lh) + &
22997 & dtp*(pvhwi(mgs)+pvhwd(mgs))
22998! > rho0(mgs)*dtp*(pqhwi(mgs)+pqhwd(mgs))/xdn0(lh)
22999 ENDIF
23000
23001 IF ( lhl .gt. 1 ) THEN
23002 IF ( lvol(lhl) .gt. 1 ) THEN
23003 vx(mgs,lhl) = vx(mgs,lhl) + &
23004 & dtp*(pvhli(mgs)+pvhld(mgs))
23005! > rho0(mgs)*dtp*(pqhwi(mgs)+pqhwd(mgs))/xdn0(lh)
23006 ENDIF
23007 ENDIF
23008
23009 ENDDO
23010
23011 ENDIF ! ldovol
23012
23013!
23014!
23015!
23016! concentrations
23017!
23018 if ( ipconc .ge. 1 ) then
23019 do mgs = 1,ngscnt
23020 cx(mgs,li) = cx(mgs,li) + &
23021 & dtp*(pccii(mgs)+pccid(mgs))
23022 cina(mgs) = cina(mgs) + pccin(mgs)*dtp
23023 IF ( ipconc .ge. 2 ) THEN
23024 cx(mgs,lc) = cx(mgs,lc) + &
23025 & dtp*(pccwi(mgs)+pccwd(mgs))
23026 ENDIF
23027 IF ( ipconc .ge. 3 ) THEN
23028 cx(mgs,lr) = cx(mgs,lr) + &
23029 & dtp*(pcrwi(mgs)+pcrwd(mgs))
23030 ENDIF
23031 IF ( ipconc .ge. 4 ) THEN
23032 cx(mgs,ls) = cx(mgs,ls) + &
23033 & dtp*(pcswi(mgs)+pcswd(mgs))
23034 ENDIF
23035 IF ( ipconc .ge. 5 ) THEN
23036 cx(mgs,lh) = cx(mgs,lh) + &
23037 & dtp*(pchwi(mgs)+pchwd(mgs))
23038 IF ( lhl .gt. 1 ) THEN
23039 cx(mgs,lhl) = cx(mgs,lhl) + &
23040 & dtp*(pchli(mgs)+pchld(mgs))
23041
23042
23043
23044
23045 ENDIF
23046 ENDIF
23047 IF ( ipconc .ge. 6 ) THEN
23048 IF ( lzr .gt. 1 ) THEN
23049 zx(mgs,lr) = zx(mgs,lr) + &
23050 & dtp*(pzrwi(mgs)+pzrwd(mgs))
23051 ENDIF
23052 IF ( lzs .gt. 1 ) THEN
23053 zx(mgs,ls) = zx(mgs,ls) + &
23054 & dtp*(pzswi(mgs)+pzswd(mgs))
23055 ENDIF
23056 IF ( lzh .gt. 1 ) THEN
23057 zx(mgs,lh) = zx(mgs,lh) + &
23058 & dtp*(pzhwi(mgs)+pzhwd(mgs))
23059 ENDIF
23060 IF ( lzhl .gt. 1 ) THEN
23061 zx(mgs,lhl) = zx(mgs,lhl) + &
23062 & dtp*(pzhli(mgs)+pzhld(mgs))
23063! IF ( pchli(mgs) .ne. 0. .or. pchld(mgs) .ne. 0 ) THEN
23064! write(0,*) 'dr: cx,pchli,pchld = ', cx(mgs,lhl),pchli(mgs),pchld(mgs), igs(mgs),kgs(mgs)
23065! ENDIF
23066 ENDIF
23067 ENDIF
23068 end do
23069 end if
23070
23071 IF ( has_wetscav ) THEN
23072 DO mgs = 1,ngscnt
23073 evapprod2d(igs(mgs),kgs(mgs)) = -(qrcev(mgs) + qssbv(mgs) + qhsbv(mgs) + qhlsbv(mgs))
23074 rainprod2d(igs(mgs),kgs(mgs)) = qrcnw(mgs) + qracw(mgs) + qsacw(mgs) + qhacw(mgs) + qhlacw(mgs) + &
23075 qraci(mgs) + qsaci(mgs) + qhaci(mgs) + qhlaci(mgs) + qscni(mgs)
23076 ENDDO
23077 ENDIF
23078!
23079!
23080!
23081! start saturation adjustment
23082!
23083 if (ndebug .gt. 0 ) write(0,*) 'conc 30a'
23084! include 'sam.jms.satadj.sgi'
23085!
23086!
23087!
23088! Modified Straka adjustment (nearly identical to Tao et al. 1989 MWR)
23089!
23090!
23091!
23092! set up temperature and vapor arrays
23093!
23094 do mgs = 1,ngscnt
23095 pqs(mgs) = (380.0)/(pres(mgs))
23096 theta(mgs) = thetap(mgs) + theta0(mgs)
23097 qvap(mgs) = max( (qwvp(mgs) + qv0(mgs)), 0.0 )
23098 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
23099 end do
23100!
23101! melting of cloud ice
23102!
23103 do mgs = 1,ngscnt
23104 qcwtmp(mgs) = qx(mgs,lc)
23105 ptimlw(mgs) = 0.0
23106 end do
23107!
23108 do mgs = 1,ngscnt
23109 qitmp(mgs) = qx(mgs,li)
23110 if( temg(mgs) .gt. tfr .and. &
23111 & qitmp(mgs) .gt. 0.0 ) then
23112 qx(mgs,lc) = qx(mgs,lc) + qitmp(mgs)
23113! pfrz(mgs) = pfrz(mgs) - qitmp(mgs)*dtpinv
23114 ptem(mgs) = ptem(mgs) + &
23115 & (1./pi0(mgs))* &
23116 & felfcp(mgs)*(- qitmp(mgs)*dtpinv)
23117 IF ( eqtset > 2 ) THEN
23118 pipert(mgs) = pipert(mgs) - (felfpi(mgs)*qitmp(mgs))
23119 ENDIF
23120 pmlt(mgs) = pmlt(mgs) - qitmp(mgs)*dtpinv
23121 scx(mgs,lc) = scx(mgs,lc) + scx(mgs,li)
23122 thetap(mgs) = thetap(mgs) - &
23123 & fcc3(mgs)*qitmp(mgs)
23124 ptimlw(mgs) = -fcc3(mgs)*qitmp(mgs)*dtpinv
23125 cx(mgs,lc) = cx(mgs,lc) + cx(mgs,li)
23126 qx(mgs,li) = 0.0
23127 cx(mgs,li) = 0.0
23128 scx(mgs,li) = 0.0
23129 vx(mgs,li) = 0.0
23130 qitmp(mgs) = 0.0
23131 end if
23132 end do
23133
23134!
23135!
23136
23137
23138! do mgs = 1,ngscnt
23139! qimlw(mgs) = (qcwtmp(mgs)-qx(mgs,lc))*dtpinv
23140! end do
23141!
23142! homogeneous freezing of cloud water
23143!
23144 IF ( warmonly < 0.8 ) THEN
23145
23146 do mgs = 1,ngscnt
23147 qcwtmp(mgs) = qx(mgs,lc)
23148 ptwfzi(mgs) = 0.0
23149 end do
23150!
23151 do mgs = 1,ngscnt
23152
23153! if( temg(mgs) .lt. tfrh ) THEN
23154! write(0,*) 'GS: mgs,temp,qc,qi = ',mgs,temg(mgs),temcg(mgs),qx(mgs,lc),qx(mgs,li)
23155! ENDIF
23156
23157 ctmp = 0.0
23158 frac = 0.0
23159 qtmp = 0.0
23160
23161! if( ( temg(mgs) .lt. thnuc + 2. .or. (ibfc == 2 .and. temg(mgs) < thnuc + 10. ) ) .and. &
23162! & qx(mgs,lc) .gt. qxmin(lc) .and. (ipconc < 2 .or. ibfc == 0 .or. ibfc == 2 )) then
23163! commented for test (12/01/2015):
23164! if( temg(mgs) .lt. thnuc + 0. .and. &
23165! & qx(mgs,lc) .gt. 0.0 .and. (ipconc < 2 .or. ibfc == 0 )) then
23166 if( ( ( temg(mgs) .lt. thnuc + 0.) .or. (temg(mgs) .lt. thnuc + 2. .and. ibfc >= 3) ) .and. &
23167 & qx(mgs,lc) .gt. 0.0 .and. (ipconc < 2 .or. ibfc == 0 .or. ibfc == 2)) then
23168
23169 IF ( ibfc >= 3 ) THEN
23170 frac = max( 0.25, min( 1., ((thnuc + 2.) - temg(mgs) )/4.0 ) )
23171 ELSEIF ( ibfc /= 2 .or. ipconc < 2 ) THEN
23172 frac = max( 0.25, min( 1., ((thnuc + 1.) - temg(mgs) )/4.0 ) )
23173 ELSE
23174 volt = exp( 16.2 + 1.0*temcg(mgs) )* 1.0e-6 ! Ts == -temcg ; volt comes from the fit in Fig. 1 in Bigg 1953
23175 ! for mean temperature for freezing: -ln (V) = a*Ts - b
23176 ! volt is given in cm**3, so factor of 1.e-6 to convert to m**3
23177
23178 cwfrz(mgs) = cx(mgs,lc)*exp(-volt/xv(mgs,lc)) ! number of droplets with volume greater than volt
23179
23180 qtmp = cwfrz(mgs)*xdn0(lc)*rhoinv(mgs)*(volt + xv(mgs,lc))
23181 frac = qtmp/qx(mgs,lc) ! reset number frozen to same fraction as mass. This makes
23182 ! sure that cwfrz and qwfrz are consistent and prevents
23183 ! spurious creation of ice crystals.
23184
23185 ENDIF
23186 qtmp = frac*qx(mgs,lc)
23187
23188 IF ( ibfc == 4 .and. lis >= 1 ) THEN
23189 qx(mgs,lis) = qx(mgs,lis) + qtmp
23190 ELSE
23191 qx(mgs,li) = qx(mgs,li) + qtmp ! qx(mgs,lc)
23192 ENDIF
23193 pfrz(mgs) = pfrz(mgs) + qtmp*dtpinv
23194 ptem(mgs) = ptem(mgs) + &
23195 & (1./pi0(mgs))* &
23196 & felfcp(mgs)*(qtmp*dtpinv)
23197
23198 IF ( eqtset > 2 ) THEN
23199 pipert(mgs) = pipert(mgs) + felfpi(mgs)*qtmp
23200 ENDIF
23201
23202! IF ( lvol(li) .gt. 1 ) vx(mgs,li) = vx(mgs,li) + rho0(mgs)*qx(mgs,lc)/xdn0(li)
23203 IF ( lvol(li) .gt. 1 ) vx(mgs,li) = vx(mgs,li) + rho0(mgs)*qtmp/xdn0(li)
23204
23205 IF ( ipconc .ge. 2 ) THEN
23206 ctmp = frac*cx(mgs,lc)
23207! cx(mgs,li) = cx(mgs,li) + cx(mgs,lc)
23208 IF ( ibfc == 4 .and. lis >= 1 ) THEN
23209 cx(mgs,lis) = cx(mgs,lis) + ctmp
23210 ELSE
23211 cx(mgs,li) = cx(mgs,li) + ctmp
23212 ENDIF
23213 ELSE ! (ipconc .lt. 2 )
23214 ctmp = 0.0
23215 IF ( t9(igs(mgs),jgs,kgs(mgs)-1) .gt. qx(mgs,lc) ) THEN
23216 qtmp = frac*t9(igs(mgs),jgs,kgs(mgs)-1)
23217
23218! cx(mgs,lc) = cx(mgs,lc)*qx(mgs,lc)*rho0(mgs)/qtmp
23219 ctmp = cx(mgs,lc)*qx(mgs,lc)*rho0(mgs)/qtmp
23220 ELSE
23221 cx(mgs,lc) = max(0.0,wvel(mgs))*dtp*cwccn &
23222 & /gz(igs(mgs),jgs,kgs(mgs))
23223 cx(mgs,lc) = cwccn
23224 ENDIF
23225
23226 IF ( ipconc .ge. 1 ) cx(mgs,li) = min(ccimx, cx(mgs,li) + cx(mgs,lc))
23227 ENDIF
23228
23229 sctmp = frac*scx(mgs,lc)
23230! scx(mgs,li) = scx(mgs,li) + scx(mgs,lc)
23231 scx(mgs,li) = scx(mgs,li) + sctmp
23232! thetap(mgs) = thetap(mgs) + fcc3(mgs)*qx(mgs,lc)
23233! ptwfzi(mgs) = fcc3(mgs)*qx(mgs,lc)*dtpinv
23234! qx(mgs,lc) = 0.0
23235! cx(mgs,lc) = 0.0
23236! scx(mgs,lc) = 0.0
23237 thetap(mgs) = thetap(mgs) + fcc3(mgs)*qtmp
23238 ptwfzi(mgs) = fcc3(mgs)*qtmp*dtpinv
23239 qx(mgs,lc) = qx(mgs,lc) - qtmp
23240 cx(mgs,lc) = cx(mgs,lc) - ctmp
23241 scx(mgs,lc) = scx(mgs,lc) - sctmp
23242 end if
23243 end do
23244
23245 ENDIF ! warmonly
23246!
23247! do mgs = 1,ngscnt
23248! qwfzi(mgs) = (qcwtmp(mgs)-qx(mgs,lc))*dtpinv ! Not used?? (ERM)
23249! end do
23250!
23251! reset temporaries for cloud particles and vapor
23252!
23253 qcond(:) = 0.0
23254
23255 IF ( ipconc .le. 1 .and. lwsm6 ) THEN ! Explicit cloud condensation/evaporation (Rutledge and Hobbs 1983)
23256 DO mgs = 1,ngscnt
23257
23258 qcwtmp(mgs) = qx(mgs,lc)
23259 theta(mgs) = thetap(mgs) + theta0(mgs)
23260 temgtmp = temg(mgs)
23261! temg(mgs) = theta(mgs)*(p2(igs(mgs),jgs,kgs(mgs)) ) ! *pk(mgs) ! ( pres(mgs) / poo ) ** cap
23262! temsav = temg(mgs)
23263! thsave(mgs) = thetap(mgs)
23264 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
23265 temcg(mgs) = temg(mgs) - tfr
23266 ltemq = (temg(mgs)-163.15)/fqsat+1.5
23267 ltemq = min( nqsat, max(1,ltemq) )
23268
23269 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
23270
23271 IF ( ( qvap(mgs) > qvs(mgs) .or. qx(mgs,lc) > qxmin(lc) ) .and. temg(mgs) > tfrh ) THEN
23272 tmp = (qvap(mgs) - qvs(mgs))/(1. + qvs(mgs)*felv(mgs)**2/(cp*rw*temg(mgs)**2) )
23273 qcond(mgs) = min( max( 0.0, tmp ), (qvap(mgs)-qvs(mgs)) )
23274 IF ( qx(mgs,lc) > qxmin(lc) .and. tmp < 0.0 ) THEN ! evaporation
23275 qcond(mgs) = max( tmp, -qx(mgs,lc) )
23276 ENDIF
23277 qwvp(mgs) = qwvp(mgs) - qcond(mgs)
23278 qvap(mgs) = qvap(mgs) - qcond(mgs)
23279 qx(mgs,lc) = max( 0.0, qx(mgs,lc) + qcond(mgs) )
23280 thetap(mgs) = thetap(mgs) + felvcp(mgs)*qcond(mgs)/(pi0(mgs))
23281
23282 ENDIF
23283
23284 ENDDO
23285
23286 ENDIF
23287
23288
23289 IF ( ipconc .le. 1 .and. .not. lwsm6 ) THEN
23290! IF ( ipconc .le. 1 ) THEN
23291
23292 do mgs = 1,ngscnt
23293 qx(mgs,lv) = max( 0.0, qvap(mgs) )
23294 qx(mgs,lc) = max( 0.0, qx(mgs,lc) )
23295 qx(mgs,li) = max( 0.0, qx(mgs,li) )
23296 qitmp(mgs) = qx(mgs,li)
23297 end do
23298!
23299!
23300 do mgs = 1,ngscnt
23301 qcwtmp(mgs) = qx(mgs,lc)
23302 qitmp(mgs) = qx(mgs,li)
23303 theta(mgs) = thetap(mgs) + theta0(mgs)
23304 temgtmp = temg(mgs)
23305 temg(mgs) = theta(mgs)*(pinit(kgs(mgs)) + p2(igs(mgs),jgs,kgs(mgs)) ) ! *pk(mgs) ! ( pres(mgs) / poo ) ** cap
23306 temsav = temg(mgs)
23307 thsave(mgs) = thetap(mgs)
23308 temcg(mgs) = temg(mgs) - tfr
23309 tqvcon = temg(mgs)-cbw
23310 ltemq = (temg(mgs)-163.15)/fqsat+1.5
23311 ltemq = min( nqsat, max(1,ltemq) )
23312
23313 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
23314 qis(mgs) = pqs(mgs)*tabqis(ltemq)
23315 qss(mgs) = qvs(mgs)
23316 if ( temg(mgs) .lt. tfr ) then
23317 if( qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) ) &
23318 & qss(mgs) = qvs(mgs)
23319 if( qx(mgs,lc) .le. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
23320 & qss(mgs) = qis(mgs)
23321 if( qx(mgs,lc) .gt. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
23322 & qss(mgs) = (qx(mgs,lc)*qvs(mgs) + qitmp(mgs)*qis(mgs)) / &
23323 & (qx(mgs,lc) + qitmp(mgs))
23324 end if
23325 end do
23326!
23327! iterate adjustment
23328!
23329 do itertd = 1,2
23330!
23331 do mgs = 1,ngscnt
23332!
23333! calculate super-saturation
23334!
23335 qitmp(mgs) = qx(mgs,li)
23336 fcci(mgs) = 0.0
23337 fcip(mgs) = 0.0
23338 dqcw(mgs) = 0.0
23339 dqci(mgs) = 0.0
23340 dqwv(mgs) = ( qx(mgs,lv) - qss(mgs) )
23341!
23342! evaporation and sublimation adjustment
23343!
23344 if( dqwv(mgs) .lt. 0. ) then ! subsaturated
23345 if( qx(mgs,lc) .gt. -dqwv(mgs) ) then ! check if qc can make up all of the deficit
23346 dqcw(mgs) = dqwv(mgs)
23347 dqwv(mgs) = 0.
23348 else ! otherwise make all qc available for evap
23349 dqcw(mgs) = -qx(mgs,lc)
23350 dqwv(mgs) = dqwv(mgs) + qx(mgs,lc)
23351 end if
23352!
23353 if( qitmp(mgs) .gt. -dqwv(mgs) ) then ! check if qi can make up all the deficit
23354 dqci(mgs) = dqwv(mgs)
23355 dqwv(mgs) = 0.
23356 else ! otherwise make all ice available for sublimation
23357 dqci(mgs) = -qitmp(mgs)
23358 dqwv(mgs) = dqwv(mgs) + qitmp(mgs)
23359 end if
23360!
23361 qwvp(mgs) = qwvp(mgs) - ( dqcw(mgs) + dqci(mgs) ) ! add to perturbation vapor
23362!
23363! This next line removed 3/19/2003 thanks to Adam Houston,
23364! who found the bug in the 3-ICE code
23365! qwvp(mgs) = max(qwvp(mgs), 0.0)
23366 qitmp(mgs) = qx(mgs,li)
23367 IF ( qitmp(mgs) .ge. qxmin(li) ) THEN
23368 fcci(mgs) = qx(mgs,li)/(qitmp(mgs))
23369 ELSE
23370 fcci(mgs) = 1.0
23371 ENDIF
23372 qx(mgs,lc) = qx(mgs,lc) + dqcw(mgs)
23373 qx(mgs,li) = qx(mgs,li) + dqci(mgs) * fcci(mgs)
23374 thetap(mgs) = thetap(mgs) + &
23375 & 1./pi0(mgs)* &
23376 & (felvcp(mgs)*dqcw(mgs) +felscp(mgs)*dqci(mgs))
23377
23378 IF ( eqtset > 2 ) THEN
23379 pipert(mgs) = pipert(mgs) &
23380 & +(felspi(mgs)*dqci(mgs) &
23381 & +felvpi(mgs)*dqcw(mgs))*dtp
23382 ENDIF
23383
23384 end if ! dqwv(mgs) .lt. 0. (end of evap/sublim)
23385!
23386! condensation/deposition
23387!
23388 IF ( dqwv(mgs) .ge. 0. ) THEN
23389
23390! write(iunit,*) 'satadj: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qx(mgs,lv),qx(mgs,lc)
23391!
23392 qitmp(mgs) = qx(mgs,li)
23393 fracl(mgs) = 1.0
23394 fraci(mgs) = 0.0
23395 if ( temg(mgs) .lt. tfr .and. temg(mgs) .gt. thnuc ) then
23396 fracl(mgs) = max(min(1.,(temg(mgs)-233.15)/(20.)),0.0)
23397 fraci(mgs) = 1.0-fracl(mgs)
23398 end if
23399 if ( temg(mgs) .le. thnuc ) then
23400 fraci(mgs) = 1.0
23401 fracl(mgs) = 0.0
23402 end if
23403 fraci(mgs) = 1.0-fracl(mgs)
23404!
23405 gamss = (felvcp(mgs)*fracl(mgs) + felscp(mgs)*fraci(mgs)) &
23406 & / (pi0(mgs))
23407!
23408 IF ( temg(mgs) .lt. tfr ) then
23409 IF (qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) ) then
23410 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qss(mgs)/ &
23411 & ((temg(mgs)-cbw)**2))
23412 END IF
23413 IF ( qx(mgs,lc) .eq. 0.0 .and. qitmp(mgs) .gt. qxmin(li) ) then
23414 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv2(mgs)*qss(mgs)/ &
23415 & ((temg(mgs)-cbi)**2))
23416 END IF
23417 IF ( qx(mgs,lc) .gt. 0.0 .and. qitmp(mgs) .gt. qxmin(li) ) then
23418 cdw = caw*pi0(mgs)*tfrcbw/((temg(mgs)-cbw)**2)
23419 cdi = cai*pi0(mgs)*tfrcbi/((temg(mgs)-cbi)**2)
23420 denom1 = qx(mgs,lc) + qitmp(mgs)
23421 denom2 = 1.0 + gamss* &
23422 & (qx(mgs,lc)*qvs(mgs)*cdw + qitmp(mgs)*qis(mgs)*cdi) / denom1
23423 dqvcnd(mgs) = dqwv(mgs) / denom2
23424 END IF
23425
23426 ENDIF ! temg(mgs) .lt. tfr
23427!
23428 if ( temg(mgs) .ge. tfr ) then
23429 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qss(mgs)/ &
23430 & ((temg(mgs)-cbw)**2))
23431 end if
23432!
23433 delqci1=qx(mgs,li)
23434!
23435 IF ( qitmp(mgs) .gt. qxmin(li) ) THEN
23436 fcci(mgs) = qx(mgs,li)/(qitmp(mgs))
23437 ELSE
23438 fcci(mgs) = 1.0
23439 ENDIF
23440!
23441 dqcw(mgs) = dqvcnd(mgs)*fracl(mgs)
23442 dqci(mgs) = dqvcnd(mgs)*fraci(mgs)
23443!
23444 thetap(mgs) = thetap(mgs) + &
23445 & (felvcp(mgs)*dqcw(mgs) + felscp(mgs)*dqci(mgs)) &
23446 & / (pi0(mgs))
23447
23448 IF ( eqtset > 2 ) THEN
23449 pipert(mgs) = pipert(mgs) + (0 &
23450 & +felspi(mgs)*dqci(mgs) &
23451 & +felvpi(mgs)*dqcw(mgs))*dtp
23452 ENDIF
23453
23454 qwvp(mgs) = qwvp(mgs) - ( dqvcnd(mgs) )
23455 qx(mgs,lc) = qx(mgs,lc) + dqcw(mgs)
23456! IF ( qitmp(mgs) .gt. qxmin(li) ) THEN
23457 qx(mgs,li) = qx(mgs,li) + dqci(mgs)*fcci(mgs)
23458 qitmp(mgs) = qx(mgs,li)
23459! ENDIF
23460!
23461! delqci(mgs) = dqci(mgs)*fcci(mgs)
23462!
23463 END IF ! dqwv(mgs) .ge. 0.
23464 end do
23465!
23466 do mgs = 1,ngscnt
23467 qitmp(mgs) = qx(mgs,li)
23468 theta(mgs) = thetap(mgs) + theta0(mgs)
23469 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
23470 qvap(mgs) = max((qwvp(mgs) + qv0(mgs)), 0.0)
23471 temcg(mgs) = temg(mgs) - tfr
23472 tqvcon = temg(mgs)-cbw
23473 ltemq = (temg(mgs)-163.15)/fqsat+1.5
23474 ltemq = min( nqsat, max(1,ltemq) )
23475 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
23476 qis(mgs) = pqs(mgs)*tabqis(ltemq)
23477 qx(mgs,lc) = max( 0.0, qx(mgs,lc) )
23478 qitmp(mgs) = max( 0.0, qitmp(mgs) )
23479 qx(mgs,lv) = max( 0.0, qvap(mgs))
23480! if ( temg(mgs) .lt. tfr ) then
23481! if( qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) )
23482! > qss(mgs) = qvs(mgs)
23483!c if( qx(mgs,lc) .le. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li))
23484! if( qx(mgs,lc) .eq. 0.0 .and. qitmp(mgs) .gt. qxmin(li))
23485! > qss(mgs) = qis(mgs)
23486!c if( qx(mgs,lc) .gt. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li))
23487! if( qx(mgs,lc) .gt. 0.0 .and. qitmp(mgs) .gt. qxmin(li))
23488! > qss(mgs) = (qx(mgs,lc)*qvs(mgs) + qitmp(mgs)*qis(mgs)) /
23489! > (qx(mgs,lc) + qitmp(mgs))
23490! else
23491! qss(mgs) = qvs(mgs)
23492! end if
23493 qss(mgs) = qvs(mgs)
23494 if ( temg(mgs) .lt. tfr ) then
23495 if( qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) ) &
23496 & qss(mgs) = qvs(mgs)
23497 if( qx(mgs,lc) .le. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
23498 & qss(mgs) = qis(mgs)
23499 if( qx(mgs,lc) .gt. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
23500 & qss(mgs) = (qx(mgs,lc)*qvs(mgs) + qitmp(mgs)*qis(mgs)) / &
23501 & (qx(mgs,lc) + qitmp(mgs))
23502 end if
23503! pceds(mgs) = (thetap(mgs) - thsave(mgs))*dtpinv
23504! write(iunit,*) 'satadj2: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qx(mgs,lv),qx(mgs,lc)
23505 end do
23506!
23507! end the saturation adjustment iteration loop
23508!
23509 end do
23510
23511 ENDIF ! ( ipconc .le. 1 )
23512
23513!
23514! spread the growth owing to vapor diffusion onto the
23515! ice crystal categories using the
23516!
23517! END OF SATURATION ADJUSTMENT
23518!
23519
23520 if (ndebug .gt. 0 ) write(0,*) 'conc 30b'
23521!
23522!
23523! end of saturation adjustment
23524
23525!
23526!
23527! !DIR$ IVDEP
23528 do mgs = 1,ngscnt
23529 t0(igs(mgs),jy,kgs(mgs)) = temg(mgs)
23530 end do
23531!
23532! Load the save arrays
23533!
23534
23535
23536! Sample code for using the axtra array to load microphysical rates or quantities for output
23537!
23538! Note that indices 1 and 2 are used in the nucond subroutine for condensation/evap of droplets (1) and
23539! condensation of rain (2)
23540!
23541! IF ( io_flag .and. nxtra > 1 ) THEN
23542! DO mgs = 1,ngscnt
23543! axtra(igs(mgs),jy,kgs(mgs),3) = pfrz(mgs) !
23544! axtra(igs(mgs),jy,kgs(mgs),4) = qrcev(mgs) ! pre2
23545! axtra(igs(mgs),jy,kgs(mgs),5) = psub(mgs) ! depsubr
23546! axtra(igs(mgs),jy,kgs(mgs),6) = qrfrz(mgs) ! rain freezing (Bigg)
23547! axtra(igs(mgs),jy,kgs(mgs),7) = pmlt(mgs) ! melr2
23548! ENDDO
23549! ENDIF
23550
23551
23552
23553 if (ndebug .gt. 0 ) write(0,*) 'gs 11'
23554
23555 do mgs = 1,ngscnt
23556!
23557 an(igs(mgs),jy,kgs(mgs),lt) = &
23558 & theta0(mgs) + thetap(mgs)
23559 an(igs(mgs),jy,kgs(mgs),lv) = qwvp(mgs) + qv0(mgs) !
23560
23561 IF ( eqtset > 2 ) THEN
23562 p2(igs(mgs),jy,kgs(mgs)) = pipert(mgs)
23563 ENDIF
23564!
23565
23566 DO il = lc,lhab
23567 IF ( ido(il) .eq. 1 ) THEN
23568 IF ( lf > 1 .and. il == lf ) THEN
23569 lfsave(mgs,1) = an(igs(mgs),jy,kgs(mgs),il)
23570 lfsave(mgs,2) = qx(mgs,il)
23571 ENDIF
23572 an(igs(mgs),jy,kgs(mgs),il) = qx(mgs,il) + &
23573 & min( an(igs(mgs),jy,kgs(mgs),il), 0.0 )
23574 qx(mgs,il) = an(igs(mgs),jy,kgs(mgs),il)
23575 ENDIF
23576 ENDDO
23577
23578 IF ( lcina > 1 ) THEN
23579 an(igs(mgs),jy,kgs(mgs),lcina) = cina(mgs)
23580 ENDIF
23581
23582
23583
23584
23585
23586!
23587! 6th moments
23588!
23589
23590 IF ( ipconc .ge. 6 ) THEN
23591 DO il = lr,lhab
23592 IF ( lz(il) .gt. 1 ) THEN
23593 IF ( lf > 1 .and. il == lf ) THEN
23594 lfsave(mgs,3) = an(igs(mgs),jy,kgs(mgs),lz(il))
23595 lfsave(mgs,4) = zx(mgs,il)
23596 ENDIF
23597
23598 an(igs(mgs),jy,kgs(mgs),lz(il)) = zx(mgs,il) + &
23599 & min( an(igs(mgs),jy,kgs(mgs),lz(il)), 0.0 )
23600 zx(mgs,il) = an(igs(mgs),jy,kgs(mgs),lz(il))
23601
23602 ENDIF
23603 ENDDO
23604
23605 ENDIF
23606!
23607 end do
23608!
23609
23610 if ( ipconc .ge. 1 ) then
23611 DO il = lc,lhab !{
23612
23613! write(0,*) 'limiter loop: il,ipc,lz: ',il,ipc(il),lz(il),ipconc
23614
23615 IF ( ipconc .ge. ipc(il) .and. ido(il) > 0 ) THEN ! {
23616
23617 IF ( ipconc .ge. 4 .and. ipc(il) .ge. 1 ) THEN ! {
23618
23619! write(0,*) 'MY limiter: il,ipc,lz: ',il,ipc(il),lz(il),lr,lzr
23620! STOP
23621
23622 IF ( lz(il) <= 1 .or. ioldlimiter == 1 ) THEN ! { { is a two-moment category so dont worry about reflectivity
23623
23624
23625 DO mgs = 1,ngscnt
23626 IF ( qx(mgs,il) .le. 0.0 ) THEN
23627 cx(mgs,il) = 0.0
23628 ELSE !{
23629 IF ( cx(mgs,il) .gt. cxmin ) THEN !{
23630! xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*Max(1.0e-9,cx(mgs,il)))
23631! xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*Max(cxmin,cx(mgs,il)))
23632 xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*cx(mgs,il))
23633
23634! IF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
23635! write(0,*) 'dr: xv,cx,qx,xdn,ln = ',xv(mgs,il),cx(mgs,il),qx(mgs,il),xdn(mgs,il),ln(il)
23636! ENDIF
23637
23638 ! 8/26/2015 erm: apply imaxdiaopt for 2-moment also
23639 IF ( imaxdiaopt == 1 .or. il == lc .or. il == li .or. (il == lr .and. imurain == 3) .or. &
23640 & (il == ls .and. imusnow == 3 ) ) THEN
23641 xvbarmax = xvmx(il)
23642 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
23643 xvbarmax = xvmx(il) /((3. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
23644 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
23645 xvbarmax = xvmx(il) /((4. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
23646 ELSE
23647 xvbarmax = xvmx(il)
23648 ENDIF
23649
23650 tmp = 1.0
23651 IF ( il == ls ) THEN
23652 xvbarmax = xvbarmax*max(1.,100./min(100.,xdn(mgs,ls)))
23653 ENDIF
23654
23655 IF ( xv(mgs,il) .lt. xvmn(il) .or. xv(mgs,il) .gt. xvbarmax ) THEN
23656 xv(mgs,il) = min( xvbarmax, xv(mgs,il) )
23657 xv(mgs,il) = max( xvmn(il), xv(mgs,il) )
23658 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xv(mgs,il)*xdn(mgs,il))
23659 ENDIF
23660
23661 ENDIF !}
23662
23663! IF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
23664! write(0,*) 'dr: xv,cx,= ',xv(mgs,il),cx(mgs,il)
23665! ENDIF
23666
23667 ENDIF !}
23668 ENDDO ! mgs
23669
23670 ELSE ! } { is three-moment, so have to adjust Z if size is too large
23671 IF ( il == lr .and. imurain == 3 ) THEN ! { { RAIN
23672
23673! rdmx =
23674! rdmn =
23675
23676 DO mgs = 1,ngscnt
23677
23678
23679 IF ( iresetmoments == 1 .or. iresetmoments == il ) THEN
23680 IF ( zx(mgs,lr) <= zxmin ) THEN
23681 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
23682 qx(mgs,lr) = 0.0
23683 cx(mgs,lr) = 0.0
23684 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
23685 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
23686 an(igs(mgs),jgs,kgs(mgs),ln(lr)) = cx(mgs,lr)
23687 ELSEIF ( cx(mgs,lr) <= cxmin ) THEN
23688 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
23689 zx(mgs,lr) = 0.0
23690 qx(mgs,lr) = 0.0
23691 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
23692 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
23693 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
23694 ENDIF
23695 ENDIF
23696
23697 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
23698
23699 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*max(1.0e-11,cx(mgs,lr)))
23700 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
23701! xv(mgs,lr) = xvmx(lr)
23702! cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
23703 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
23704 xv(mgs,lr) = xvmn(lr)
23705 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
23706 ENDIF
23707
23708 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
23709! have mass and reflectivity but no concentration, so set concentration, using default alpha
23710 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
23711 z = zx(mgs,il)
23712 qr = qx(mgs,il)
23713 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*xdn(mgs,lr)**2)
23714! an(igs(mgs),jgs,kgs(mgs),ln(il)) = zx(mgs,il)
23715 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > 0.0 ) THEN
23716! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
23717 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
23718 chw = cx(mgs,il)
23719 qr = qx(mgs,il)
23720 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(xdn(mgs,lr)**2*chw)
23721 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
23722
23723 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
23724! How did this happen?
23725 ! set values according to dBZ of -10, or Z = 0.1
23726! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
23727 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
23728 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
23729
23730 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
23731 z = zx(mgs,il)
23732 qr = qx(mgs,il)
23733 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*1000.*1000)
23734 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
23735 ENDIF
23736
23737 IF ( zx(mgs,lr) > 0.0 ) THEN
23738 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(1000.*cx(mgs,lr))
23739 vr = xv(mgs,lr)
23740 qr = qx(mgs,lr)
23741 nrx = cx(mgs,lr)
23742 z = zx(mgs,lr)
23743
23744! xv = (db(1,kz)*a(1,1,kz,lr))**2/(a(1,1,kz,lnr))
23745! rd = z*(pi/6.*1000.)**2/xv
23746
23747! determine shape parameter alpha by iteration
23748 IF ( z .gt. 0.0 ) THEN
23749 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
23750 DO i = 1,20
23751 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
23752 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
23753 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
23754 alp = max( rnumin, min( rnumax, alp ) )
23755 ENDDO
23756
23757! check for artificial breakup (rain larger than allowed max size)
23758 IF ( xv(mgs,il) .gt. xvmx(il) .or. (ioldlimiter == 2 .and. xv(mgs,il) .gt. xvmx(il)/8.) ) THEN
23759 tmp = cx(mgs,il)
23760! write(0,*) 'MY limiter: xv: ',xv(mgs,il), xv(mgs,il)/(xvmx(il)/8.)
23761! STOP
23762 IF ( ioldlimiter == 2 ) THEN ! MY-style active breakup
23763 x = (6.*rho0(mgs)*qx(mgs,il)/(pi*xdn(mgs,il)*cx(mgs,il)))**(1./3.)
23764 x1 = max(0.0e-3, x - 3.0e-3)
23765 x2 = max(0.5, x/6.0e-3)
23766 x3 = x2**3
23767 cx(mgs,il) = cx(mgs,il)*max((1.+2.222e3*x1**2), x3)
23768 xv(mgs,il) = xv(mgs,il)/max((1.+2.222e3*x1**2), x3)
23769 ELSE ! simple cutoff
23770 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
23771 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
23772 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
23773 ENDIF
23774 !xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
23775 !cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
23776
23777
23778 IF ( tmp < cx(mgs,il) ) THEN ! breakup
23779
23780 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
23781 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
23782 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
23783
23784 vr = xv(mgs,lr)
23785 qr = qx(mgs,lr)
23786 nrx = cx(mgs,lr)
23787 z = zx(mgs,lr)
23788
23789
23790! determine shape parameter alpha by iteration
23791 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
23792 DO i = 1,20
23793 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
23794 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
23795 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
23796 alp = max( rnumin, min( rnumax, alp ) )
23797 ENDDO
23798
23799
23800 ENDIF
23801 ENDIF
23802
23803!
23804! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
23805! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
23806!
23807 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
23808 IF ( .true. .and. (alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax) ) THEN
23809
23810 IF ( rescale_high_alpha .and. alp >= rnumax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
23811 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(1./(xdn(mgs,il)))**2
23812 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
23813
23814 ELSEIF ( rescale_low_alphar .and. alp <= rnumin ) THEN
23815 z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
23816 zx(mgs,il) = z
23817 an(igs(mgs),jy,kgs(mgs),lz(il)) = zx(mgs,il)
23818 ENDIF
23819 ENDIF
23820
23821
23822
23823 ENDIF
23824 ENDIF
23825
23826 ENDIF
23827
23828 ENDDO
23829! CALL cld_cpu('Z-MOMENT-1r')
23830
23831
23832 ELSEIF ( il == lh .or. il == lhl .or. il == lf .or. (il == lr .and. imurain == 1 )) THEN ! } { Rain, GRAUPEL OR HAIL
23833
23834
23835
23836 DO mgs = 1,ngscnt
23837
23838 IF ( lf > 1 .and. il == lf ) THEN
23839 lfsave(mgs,5) = an(igs(mgs),jy,kgs(mgs),ln(il))
23840 lfsave(mgs,6) = cx(mgs,il)
23841 ENDIF
23842
23843 IF ( il == lhl .and. lnhlf > 1 ) THEN
23844 IF ( cx(mgs,lhl) > cxmin ) THEN
23845 frac = chxf(mgs,lhl)/cx(mgs,lhl)
23846 ELSE
23847 frac = 0.0
23848 ENDIF
23849 ENDIF
23850
23851 IF ( il == lh .and. lnhf > 1 ) THEN
23852 IF ( cx(mgs,lh) > cxmin ) THEN
23853 frach = chxf(mgs,lh)/cx(mgs,lh)
23854 ELSE
23855 frach = 0.0
23856 ENDIF
23857 ENDIF
23858
23859
23860
23861 IF ( iresetmoments == 1 .or. iresetmoments == il .or. iresetmoments == -1 ) THEN ! { .or. qx(mgs,il) <= qxmin(il)
23862 IF ( zx(mgs,il) <= zxmin ) THEN ! .and. qx(mgs,il) > 0.05e-3
23863!! write(91,*) 'zx=0; qx,cx = ',1000.*qx(mgs,il),cx(mgs,il)
23864 qx(mgs,il) = 0.0
23865 cx(mgs,il) = 0.0
23866 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
23867 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
23868 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
23869 ELSEIF ( iresetmoments == -1 .and. qx(mgs,il) < qxmin(il) ) THEN
23870 zx(mgs,il) = 0.0
23871 cx(mgs,il) = 0.0
23872 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
23873
23874 qx(mgs,il) = 0.0
23875 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
23876 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
23877 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
23878
23879 ELSEIF ( cx(mgs,il) <= cxmin .and. iresetmoments /= -1 ) THEN ! .and. qx(mgs,il) > 0.05e-3
23880 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
23881 zx(mgs,il) = 0.0
23882 qx(mgs,il) = 0.0
23883 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
23884 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
23885 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
23886 ENDIF
23887 ELSE
23888 IF ( zx(mgs,il) < 0.0 ) THEN ! .and. qx(mgs,il) > 0.05e-3
23889 zx(mgs,il) = 0.0
23890 ENDIF
23891 ENDIF !}
23892
23893
23894 IF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= cxmin ) THEN
23895 zx(mgs,il) = 0.0
23896 cx(mgs,il) = 0.0
23897 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
23898 qx(mgs,il) = 0.0
23899 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
23900 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
23901 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
23902 ENDIF
23903
23904 IF ( qx(mgs,il) .gt. qxmin(il) ) THEN !{
23905
23906 xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*max(1.0e-9,cx(mgs,il)))
23907 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
23908
23909 IF ( xv(mgs,il) .lt. xvmn(il) ) THEN
23910 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
23911 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
23912 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
23913 ENDIF
23914
23915 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN !{
23916! have mass and reflectivity but no concentration, so set concentration, using default alpha
23917 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
23918 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
23919 z = zx(mgs,il)
23920 qr = qx(mgs,il)
23921! cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z
23922 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(z*(pi*xdn(mgs,il))**2)
23923
23924
23925 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > 0.0 ) THEN
23926! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
23927! g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
23928! & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
23929 chw = cx(mgs,il)
23930 qr = qx(mgs,il)
23931! zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
23932! zx(mgs,il) = Min(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
23933 g1 = (6.0 + alphamax)*(5.0 + alphamax)*(4.0 + alphamax)/ &
23934 & ((3.0 + alphamax)*(2.0 + alphamax)*(1.0 + alphamax))
23935 zx(mgs,il) = max(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
23936 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
23937
23938 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
23939! How did this happen?
23940 ! set values according to dBZ of -10, or Z = 0.1
23941! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
23942
23943! write(0,*) 'GS: moment problem! il,c,z,q = ',il,cx(mgs,il),zx(mgs,il),qx(mgs,il)
23944
23945 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
23946 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
23947
23948 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
23949 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
23950 z = zx(mgs,il)
23951 qr = qx(mgs,il)
23952! cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z
23953 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(z*(pi*xdn(mgs,il))**2)
23954 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
23955
23956! write(0,*) 'GS: moment problem! reset il,c,z,q = ',il,cx(mgs,il),zx(mgs,il),qx(mgs,il)
23957
23958 ELSE
23959 ! have all valid moments, so find shape parameter
23960 chw = cx(mgs,il)
23961 qr = qx(mgs,il)
23962 z = zx(mgs,il)
23963
23964 IF ( zx(mgs,il) .gt. 0. ) THEN !{
23965
23966! rdi = z*(pi/6.*1000.)**2*chw/((rho0(mgs)*qr)**2)
23967 rdi = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
23968
23969! alp = 1.e18*(6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/
23970! : ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
23971 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
23972 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
23973! print*,'kz, alp, alpha(mgs,il) = ',kz,alp,alpha(mgs,il),rdi,z,xv
23974 DO i = 1,10
23975! IF ( 100.*Abs(alp - alpha(mgs,il))/(Abs(alpha(mgs,il))+1.e-5) .lt. 1. ) EXIT
23976 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
23977 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
23978! alp = 1.e18*(6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/
23979! : ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
23980 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
23981 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
23982! print*,'i,alp = ',i,alp
23983 alp = max( alphamin, min( alphamax, alp ) )
23984 ENDDO
23985
23986
23987! check for artificial breakup (graupel/hail larger than allowed max size)
23988 IF ( xv(mgs,il) .gt. xvmx(il) ) THEN !{
23989 tmp = cx(mgs,il)
23990
23991
23992 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
23993 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
23994 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
23995 IF ( tmp < cx(mgs,il) ) THEN ! breakup
23996 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
23997 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
23998 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
23999 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
24000
24001 chw = cx(mgs,il)
24002 qr = qx(mgs,il)
24003 z = zx(mgs,il)
24004
24005 rdi = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
24006 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
24007 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24008 DO i = 1,10
24009 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
24010 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
24011 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
24012 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24013 alp = max( alphamin, min( alphamax, alp ) )
24014 ENDDO
24015
24016
24017 ENDIF
24018 ENDIF !}
24019
24020!
24021! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
24022! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
24023!
24024 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
24025 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
24026
24027 IF ( ( lrescalelow(il) .or. rescale_high_alpha ) .and. &
24028 & ( alpha(mgs,il) <= alphamin .or. alp == alphamin .or. alp == alphamax ) ) THEN !{
24029
24030 IF ( rescale_high_alpha .and. alp >= alphamax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
24031 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(6./(pi*xdn(mgs,il)))**2
24032 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
24033
24034 ELSEIF ( lrescalelow(il) .and. alp <= alphamin .and. .not. (il == lh .and. icvhl2h > 0 ) .and. &
24035 .not. ( il == lr .and. .not. rescale_low_alphar ) ) THEN ! alpha = alphamin, so reset Z to prevent growth in C
24036
24037 wtest = .false.
24038 IF ( irescalerainopt == 0 ) THEN
24039 wtest = .false.
24040 ELSEIF ( irescalerainopt == 1 ) THEN
24041 wtest = qx(mgs,lc) > qxmin(lc)
24042 ELSEIF ( irescalerainopt == 2 ) THEN
24043 wtest = qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < rescale_wthresh
24044 ELSEIF ( irescalerainopt == 3 ) THEN
24045 wtest = temcg(mgs) > rescale_tempthresh .and. qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < rescale_wthresh
24046 ENDIF
24047
24048 IF ( il == lr .and. ( wtest .or. .not. rescale_low_alphar ) ) THEN
24049 ! certain situations where rain number is adjusted instead of Z. Helps avoid rain being 'zapped' by autoconverted
24050 ! drops (i.e., favor preserving Z when alpha tries to go negative)
24051 chw = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(6./(pi*xdn(mgs,il)))**2 ! g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z1
24052 cx(mgs,il) = chw
24053 an(igs(mgs),jy,kgs(mgs),ln(il)) = chw
24054 ELSE
24055 ! Usual resetting of reflectivity moment to force consisntency between Q, N, Z, and alpha when alpha = alphamin
24056 z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
24057 z = z1*(6./(pi*xdn(mgs,il)))**2
24058 zx(mgs,il) = z
24059 an(igs(mgs),jy,kgs(mgs),lz(il)) = z
24060 ENDIF
24061
24062! z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
24063! z = z1*(6./(pi*xdn(mgs,il)))**2
24064! zx(mgs,il) = z
24065! an(igs(mgs),jy,kgs(mgs),lz(il)) = z
24066 ENDIF
24067
24068 ENDIF !}
24069
24070
24071 ENDIF !}
24072
24073
24074 ENDIF ! !}
24075
24076
24077
24078 ENDIF !}
24079
24080 IF ( lzr > 1 ) THEN
24081 alpha2d(igs(mgs),kgs(mgs),1) = max(alphamin, min(alphamax, alpha(mgs,lr) ))
24082 ENDIF
24083 IF ( lzh > 1 ) THEN
24084 alpha2d(igs(mgs),kgs(mgs),2) = max(alphamin, min(alphamax, alpha(mgs,lh) ))
24085 ENDIF
24086 IF ( lzhl > 1 ) THEN
24087 alpha2d(igs(mgs),kgs(mgs),3) = max(alphamin, min(alphamax, alpha(mgs,lhl) ))
24088 ENDIF
24089
24090 IF ( il == lhl .and. lnhlf > 1 ) THEN
24091 ! update chxf in case cx has changed
24092 chxf(mgs,lhl) = frac*cx(mgs,lhl)
24093 ENDIF
24094 IF ( il == lh .and. lnhf > 1 ) THEN
24095 ! update chxf in case cx has changed
24096 chxf(mgs,lh) = frach*cx(mgs,lh)
24097 ENDIF
24098
24099
24100! IF ( lf > 0 .and. il == lf .and. kgs(mgs) <= 20 .and. ( cx(mgs,lf) + dtp*( pcfwi(mgs) + pcfwd(mgs) ) > 200. .or. cx(mgs,lf) > 400. )) THEN
24101! write(0,*) 'ix,jy, kz, cf = ',igs(mgs)+ixbeg,jy+jybeg,kgs(mgs), an(igs(mgs),jy,kgs(mgs),ln(lf)),lfsave(mgs,5),lfsave(mgs,6)
24102! write(0,*) 'qold,qxold,zold,zxold = ',lfsave(mgs,1),lfsave(mgs,2),lfsave(mgs,3),lfsave(mgs,4)
24103! write(0,*) 'cf_new,pcfwi,pcfwd = ',cx(mgs,lf),cx(mgs,lf) + dtp*( pcfwi(mgs) + pcfwd(mgs) ),pcfwi(mgs) + pcfwd(mgs)
24104!
24105! ENDIF
24106
24107 ENDDO ! mgs
24108
24109! CALL cld_cpu('Z-DELABK')
24110
24111
24112! CALL cld_cpu('Z-DELABK')
24113
24114
24115
24116
24117 ENDIF ! } }
24118
24119 ENDIF ! }}
24120 ENDIF ! }
24121
24122 DO mgs = 1,ngscnt
24123
24124 IF ( il == lh ) THEN
24125 IF ( lnhf > 1 ) THEN ! number of graupel from frozen drops
24126 an(igs(mgs),jy,kgs(mgs),lnhf) = max( chxf(mgs,lh), 0.0)
24127 ENDIF
24128 ENDIF
24129
24130 IF ( il == lhl ) THEN
24131
24132 IF ( lnhlf > 1 ) THEN ! number of hail from frozen drops
24133! an(igs(mgs),jy,kgs(mgs),lnhlf) = Min( cx(mgs,lhl), Max( chxf(mgs,lhl), 0.0) )
24134 an(igs(mgs),jy,kgs(mgs),lnhlf) = max( chxf(mgs,lhl), 0.0)
24135 ENDIF
24136 ENDIF
24137 an(igs(mgs),jy,kgs(mgs),ln(il)) = max(cx(mgs,il), 0.0)
24138 ENDDO
24139 ENDIF ! }
24140 ENDDO ! il }
24141
24142 IF ( lcin > 1 ) THEN
24143 do mgs = 1,ngscnt
24144 an(igs(mgs),jy,kgs(mgs),lcin) = max(0.0, ccin(mgs))
24145 end do
24146 ENDIF
24147
24148 IF ( ipconc .ge. 2 ) THEN
24149 do mgs = 1,ngscnt
24150 IF ( lss > 1 ) THEN
24151 an(igs(mgs),jy,kgs(mgs),lss) = max(0.0, ssmax(mgs) )
24152 ENDIF
24153
24154 IF ( lccn > 1 ) THEN
24155 an(igs(mgs),jy,kgs(mgs),lccn) = max(0.0, ccnc(mgs) )
24156 ENDIF
24157 end do
24158 ENDIF
24159
24160 ELSEIF ( ipconc .eq. 0 .and. lni .gt. 1 ) THEN
24161
24162 DO mgs = 1,ngscnt
24163 an(igs(mgs),jy,kgs(mgs),lni) = max(cx(mgs,li), 0.0)
24164 ENDDO
24165
24166
24167 end if
24168
24169 IF ( ldovol ) THEN
24170
24171 DO il = li,lhab
24172
24173 IF ( lvol(il) .ge. 1 ) THEN
24174
24175 DO mgs = 1,ngscnt
24176
24177 an(igs(mgs),jy,kgs(mgs),lvol(il)) = max( 0.0, vx(mgs,il) )
24178 ENDDO
24179
24180 ENDIF
24181
24182 ENDDO
24183
24184 ENDIF
24185!
24186!
24187!
24188!
24189!
24190 if (ndebug .gt. 0 ) write(0,*) 'gs 12'
24191
24192
24193
24194 if (ndebug .gt. 0 ) write(0,*) 'gs 13'
24195
24196 9998 continue
24197
24198 if ( kz .gt. nz-1 .and. ix .ge. itile) then
24199 if ( ix .ge. itile ) then
24200 go to 1200 ! exit gather scatter
24201 else
24202 nzmpb = kz
24203 endif
24204 else
24205 nzmpb = kz
24206 end if
24207
24208 if ( ix .ge. itile ) then
24209 nxmpb = 1
24210 nzmpb = kz+1
24211 else
24212 nxmpb = ix+1
24213 end if
24214
24215 1000 continue
24216 1200 continue
24217!
24218! end of gather scatter (for this jy slice)
24219!
24220!
24221
24222 return
24223 end subroutine nssl_2mom_gs
24224!
24225!--------------------------------------------------------------------------
24226!
24227
24228
24229
24230!
24231!--------------------------------------------------------------------------
24232!
24233
24234
24235END MODULE module_mp_nssl_2mom
subroutine radardd02(nx, ny, nz, nor, na, an, temk, dbz, db, nzdbz, cnoh0t, hwdn1t, ipconc, ke_diag, iunit)
Radar reflectivity calculation. Assumes ideal Rayleigh scattering.
subroutine calcnfromz1d(nx, ny, nz, nor, na, a, t0, ixe, kze, z0, db, jgs, ipconc, alpha, l, ln, qmin, xvmn, xvmx, t1, lvol, rho_qx, infall, ixcol)
Subroutine to correct number concentration to prevent reflectivity growth.
real function, private delbk(bb, nu, mu, k)
Function calculates collection coefficients following Siefert (2006)
subroutine calcnfromcuten(nx, ny, nz, an, anold, na, nor, norz, dn)
Subroutine to calculate number concentrations from convection parameterization rates that have only m...
subroutine, public calc_eff_radius(nx, ny, nz, na, jyslab, nor, norz, t1, t2, t3, t4, t5, t6, f_t5, f_t6, qcw, qci, qsw, qrw, ccw, cci, csw, crw, an, dn)
Subroutine to calculate effective radii for use by radiation routines.
double precision function, private gamma_dp(xx)
Douple-precision complete gamma function (double precision argument)
subroutine calczgr1d(nx, ny, nz, nor, na, a, ixe, kze, z, db, jgs, ipconc, alpha, l, ln, qmin, xvmn, xvmx, lvol, rho_qx, ixcol)
Calculates temporary reflectivity moment for adaptive size-sorting limiter.
double precision function, private gamma_dpr(x)
Douple-precision complete gamma function (single precision input)
real function, private fqis(t)
This function is for saturation vapor pressure with respect to ice.
subroutine ziegfall1d(nx, ny, nz, nor, norz, na, dtp, jgs, ixcol, xvt, rhovtzx, an, dn, ipconc0, t0, t7, cwmasn, cwmasx, cwradn, qxmin, xdnmx, xdnmn, cdx, cno, xdn0, xvmn, xvmx, ngs, qx, qxw, cx, xv, vtxbar, xmas, xdn, xdia, vx, alpha, zx, igs, kgs, rho0, temcg, temg, rhovt, cwnc, cinc, fadvisc, cwdia, cipmas, cnina, cimas, cnostmp, infdo, ildo, timesetvt)
Column-wise front end to setvtz for sedimentation.
subroutine, public nssl_2mom_driver(qv, qc, qr, qi, qs, qh, qhl, ccw, crw, cci, csw, chw, chl, cn, vhw, vhl, cna, cni, f_cn, f_cna, f_cina, f_qc, f_qr, f_qi, f_qs, f_qh, f_qhl, cnuf, f_cnuf, zrw, zhw, zhl, f_zrw, f_zhw, f_zhl, f_vhw, f_vhl, qsw, qhw, qhlw, tt, th, pii, p, w, dn, dz, dtp, itimestep, is_theta_or_temp, ntmul, ntcnt, lastloop, rainnc, rainncv, dx, dy, axtra, snownc, snowncv, grplnc, grplncv, sr, hailnc, hailncv, hail_maxk1, hail_max2d, nwp_diagnostics, tkediss, re_cloud, re_ice, re_snow, re_rain, re_graup, re_hail, has_reqc, has_reqi, has_reqs, has_reqr, has_reqg, has_reqh, rainncw2, rainnci2, dbz, vzf, compdbz, rscghis_2d, rscghis_2dp, rscghis_2dn, scr, scw, sci, scs, sch, schl, sctot, elec_physics, induc, elecz, scion, sciona, noninduc, noninducp, noninducn, pcc2, pre2, depsubr, mnucf2, melr2, ctr2, rim1_2, rim2_2, rim3_2, nctr2, nnuccd2, nnucf2, effc2, effr2, effi2, effs2, effg2, fc2, fr2, fi2, fs2, fg2, fnc2, fnr2, fni2, fns2, fng2, ipelectmp, diagflag, ke_diag, errmsg, errflg, nssl_progn, wetscav_on, rainprod, evapprod, cu_used, qrcuten, qscuten, qicuten, qccuten, ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, its, ite, jts, jte, kts, kte)
Driver subroutine that copies state data to local 2D arrays for microphysics calls.
subroutine nucond(nx, ny, nz, na, jyslab, nor, norz, dtp, nxi, dz3d, t0, t9, an, dn, p2, pn, w, ngs, axtra, io_flag, ssfilt, t00, t77, flag_qndrop)
Droplet nucleation routine. Explicit condensation/evaporation. Tiny mixing ratio cleanup.
subroutine, public calcnfromq(nx, ny, nz, an, na, nor, norz, dn, qcw, qci, qsw, qrw, qhw, qhl, ccw, cci, csw, crw, chw, chl, cccn, cccna, vhw, vhl, qv, spechum, invertccn_flag, cwmasin)
Subroutine to calculate number concentrations from initial state that has only mixing ratio.
subroutine nssl_2mom_gs(nx, ny, nz, na, jyslab, nor, norz, dtp, gz, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, an, dn, p2, pn, w, iunit, t00, t77, ventr, ventc, c1sw, jgs, ido, xdnmx, xdnmn, cdx, xdn0, tmp3d, tkediss, thproc, numproc, dx1, dy1, ngs, timevtcalc, axtra, io_flag, has_wetscav, rainprod2d, evapprod2d, alpha2d, errmsg, errflg, elec, its, ids, ide, jds, jde)
Main microphysical processes routine.
real function, private gaml02d500(x)
Function calculates Gamma(0.2,x)/Gamma[0.2] for 500 micro drops ( imurain == 3 )
real function gaminterp(ratio, alp, luindex, ilh)
Function to interpolate from a table of incomplete gamma function values.
subroutine hailmaxd(dtp, nx, ny, nz, an, na, nor, norz, alpha2d, dn, hailmax1d, hailmaxk1, jslab)
Hail max size subroutine.
subroutine, private gammadp(x, ga)
Double-precision complete gamma function subroutine (used by beta function routine)
subroutine qvexcess(ngs, mgs, qwvp0, qv0, qcw1, pres, thetap0, theta0, qvex, pi0, tabqvs, nqsat, fqsat, cbw, fcqv1, felvcp, ss1, pk, ngscnt)
Subroutine that returns the maximum possible condensation.
real function, private gamma_sp(xx)
Single-precision complete gamma function.
subroutine sediment1d(dtp, nx, ny, nz, an, na, nor, norz, xfall, dn, dz3d, dz3dinv, t0, t7, infdo, jslab, its, jts, timesed1, timesed2, timesed3, zmaxsed, timesetvt)
Sedimentation driver subroutine. Calls fallout column by column.
double precision function, private gamxinfdp(a1, x1)
Double-precision incomplete gamma function (single precision args)
real function, private gaml02(x)
Function calculates Gamma(0.2,x)/Gamma[0.2] for 40 micro drops ( imurain == 3 )
real function, private gaml02d300(x)
Function calculates fraction of drops larger than 300 microns ( imurain == 3 )
real function, private fqvs(t)
This function is for saturation vapor pressure with respect to liquid water.
real function, private delabk(ba, bb, nua, nub, mua, mub, k)
Function calculates collection coefficients following Siefert (2006)
subroutine, public nssl_2mom_init_const(con_g, con_rd, con_cp, con_rv, con_t0c, con_cliq, con_csol, con_eps)
NSSL MP subroutine to initialize physical constants provided by host model.
subroutine, public nssl_2mom_init(ims, ime, jms, jme, kms, kme, nssl_params, ipctmp, mixphase, ihvol, idoniconlytmp, nssl_graupelfallfac, nssl_hailfallfac, nssl_ehw0, nssl_ehlw0, nssl_icdx, nssl_icdxhl, nssl_icefallfac, nssl_snowfallfac, nssl_cccn, nssl_ufccn, nssl_alphah, nssl_alphahl, nssl_alphar, nssl_density_on, nssl_hail_on, nssl_ccn_on, nssl_icecrystals_on, ccn_is_ccna, errmsg, errflg, infileunit, myrank, mpiroot)
NSSL MP setup routine (sets local options and array indices)
subroutine fallout1d(nx, ny, nz, nor, na, dtp, dtfrac, jgs, vt, a, db1, ia, id, xfall, dtz1, ixcol)
Column sedimentation fallout subroutine.
subroutine setvtz(ngscnt, qx, qxmin, qxw, cx, rho0, rhovt, xdia, cno, cnostmp, xmas, vtxbar, xdn, xvmn0, xvmx0, xv, cdx, cdxgs, ipconc1, ndebug1, ngs, nz, kgs, fadvisc, cwmasn, cwmasx, cwradn, cnina, cimna, cimxa, itype1a, itype2a, temcg, infdo, alpha, ildo, axx, bxx)
Mean hydrometeor size and fall speed calculations.
real function, private gamxinf(a1, x1)
single-precision incomplete gamma function (single precision args)
This module contains 1/2/3-moment bulk microphysics scheme based on a combination of Straka and Manse...