CCPP SciDoc v7.0.x  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: "Apr 17 2025" at "12:17:55"
6!---------------------------------------------------------------------
7
35!
36! Possible parameters to adjust:
37!
38! ccn : base cloud condensation nuclei concentration (use namelist.input value "nssl_cccn")
39! alphah, alphahl : Size distribution shape parameters for graupel (h) and hail (hl)
40! infall : changes sedimentation options to see effects (see below)
41!
42! lightning model references:
43!
44! Fierro, A. O., E.R. Mansell, C. Ziegler and D. R. MacGorman 2013: The
45! implementation of an explicit charging and discharge lightning scheme
46! within the WRF-ARW model: Benchmark simulations of a continental squall line, a
47! tropical cyclone and a winter storm. Monthly Weather Review, Volume 141, 2390-2415
48!
49! Mansell et al. 2005: Charge structure and lightning sensitivity in a simulated
50! multicell thunderstorm. J. Geophys. Res., 110, D12101, doi:10.1029/2004JD005287
51!
52! Note: Some parameters below apply to unreleased features.
53!
54!
55!---------------------------------------------------------------------
56! Feb. 2025
57! - More accurate saturation mixing ratio calculation (iqvsopt=1)
58! - Changed default droplet renucleation to irenuc=5, which allows extra nucleation at high supersaturation
59! - Default explicit rain breakup for 3-moment (irainbreak=2)
60! - Imposed reflectivity conservation in graupel->hail conversion (ihlcnh=3) and Bigg
61! freezing (both 2- and 3-moment)
62! - Option (nsplinter=1001) for ice crystal production by drop freezing/shattering (Sullivan et al. 2018)
63! - Option (incwet = 1) to treat wet growth only for D > Dwet rather than all or nothing; results in
64! slightly greater hail production due to maintaining dry growth at D < Dwet
65! - Improved logic for sedimentation
66! - Separated flushing of small masses into its own subroutine (smallvalues)
67! - Some syntax fixes for issues with old versions of gfortran
68!---------------------------------------------------------------------
69! Apr. 2023 (WRF-4.6)
70! - Update to 3-moment for rain, graupel, and hail
71! - Change default graupel/hail fall speeds to icdx/icdxhl=6 (Milbrandt & Morrison 2013)
72! and also set default ehw0=0.9 and ehlw0=0.9 to compensate for lower fall speeds.
73! - Change default hail conversion to ihlcnh=-1, and then =1 for 2-mom or =3 for 3-mom,
74! using wet growth diameter to convert large graupel
75!---------------------------------------------------------------------
76! Sept. 2021:
77! Fixes:
78! Restored previous formulation of snow reflectivity, as it was realized that the last change incorrectly assumed a fixed
79! density independent of size. Generally lower snow reflectivity values as a result (no effect on microphysics)
80! Other:
81! Generic fall speed coeffecients (axx,bxx) to accomodate future frozen drops category (no effect)
82! Reordered collection coefficients (dab1lh) to be consistent (no effect)
83! Switched to full calculation of rain number loss via collection by graupel (chacr; to be consisted with collection by hail) (minor effects)
84!---------------------------------------------------------------------
85! April 2021:
86! Fixes:
87! Fall speed air density factor limited to air density of 0.05 (for very high model top) to mitigate excessive fall speeds
88! Fixed issue of spurious creation of large concentrations of very small droplets and transient large condensation (also increased minimum droplet size)
89! Fixed issue of negligible "seed" values of graupel from Bigg freezing at relatively high temperatures (thanks to S. Lasher-Trapp)
90! Minor bug fix in effective radius calculation of snow. (thanks to T. Iguchi)
91! Updates:
92! Enabled regeneration of CCN by droplet evaporation and background restore (default time constant of 3600s)
93! 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).
94! Enabled radar reflectivity from cloud ice (new formulation) ( idbzci = 1 )
95! Added internal option for ice crystal nucleation by DeMott et al. (2010, PNAS) (inucopt=4)
96! Allow greater fraction of hail to melt in one time step
97! Reduced minimum number concentration from 1e-4 to 1e-8 (based on CAPS input)
98! Added internal namelist for easier access to internal variables for development/testing and easier setup for ensemble microphysics diversity
99! (namelist read is disabled by default)
100! Increased resolution of lookup table for incomplete gamma functions
101!
102!---------------------------------------------------------------------
103! Sept. 2019:
104! Bug fixes:
105! - Effective radius calculation was only done at history times. Now every time step (though should be just before radiation is called)
106! - Snow reflectivity: Previous "fix" was incorrect and yields snow dBZ that is too low. Reverted to old version which was correct
107! - Incorrectly updated a state value in the reflectivity code. (Could cause small differences if reflectivity is not calculated)
108! Updates:
109! - 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.
110! - Graupel and hail drag coefficients are returned from fall speed subroutine to use in ventilation coeffs. for consistency (minor change)
111! - Added (compile) option flag to turn on diagnosis of cloud droplet shape parameter based on number concentration
112! - Added (compile) option flag icracr to turn off rain self-collection
113! - 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
114! - Put limit on snow volume (2 cm) in aggregation rate
115!---------------------------------------------------------------------
116! WRF 4.0 update:
117! Major:
118! Fixed excessive sublimation that could occur in very strong downdrafts (3.9.1.1 update)
119!
120! Minor:
121! icefallopt=3 : New ice crystal fall speed that has faster speeds for small ice particles. Main effect
122! is on anvil clouds to help them decay a bit faster. Old behavior can be recovered with icefallopt=1
123! Cosmetic: removed stray single quotes because some preprocessors complain about unclosed quotes even in comments
124!
125!---------------------------------------------------------------------
126! WRF 3.9.1.1 update:
127!
128! Added a check on overdepletion of ice by sublimation, which could sometimes result in water supersaturation
129! Bug fix: setting of t7 used 'dn' instead of 'dn1' (Thanks to Chunxi Zhang)
130!
131!---------------------------------------------------------------------
132! WRF 3.9 updates:
133!
134! 2-moment scheme now creates number concentration tendencies from cumulus scheme mass mixing ratio rates
135! Renamed internal gamma function routine from 'gamma' to 'gamma_sp' to avoid name conflicts
136! Restored older settings that allow snow aggregation starting at T > -25C
137! Adjusted Meyers number of activated nuclei by the local air density to compensate for using data at surface
138! Minor updates to rain-ice crystal and hail-rain collection efficiencies
139!
140!
141! Reduced minimum mean snow diameter from 100 microns to 10 microns
142!
143!---------------------------------------------------------------------
144! WRF 3.8 updates:
145! Fixed issue with reflectivity conservation for graupel melting into rain. Rain number concentrations were too low,
146! resulting in excessive reflectivity of a couple dBZ
147! Changed default value of iusewetgraupel to 1 (turns off diagnostic meltwater on graupel for reflectivity)
148! Apply a 70 m/s fall speed limit for sedimentation
149! Changed vapor ice nucleation to Meyers-Ferrier method (original scheme)
150! New method for Bigg freezing (ibiggopt=2)
151! Reduced snow aggregration efficiency and restricted aggregation to higher temperatures (assuming dendrites and mechanical aggregation)
152! Increased maximum graupel-droplet collection efficiency when hail is turned off (nssl_2momg)
153! Updates for compatibility with WRF-NMM
154! Added calculation of hail number concentration in calcnfromq (creates number concentration from mixing ratio
155! when starting from an analysis). And fixed error in graupel intercept
156! Bug fix in snow fall speeds
157! Further fix in snow reflectivity
158! Use diameter of maximum mass rather than mean diamter when checking maximum size
159! Helped performance in sedimentation with flag "do_accurate_sedimentation" to control recalculation of fall speeds when
160! more than one sub-time step is needed (often happens with large time steps and small dz near the ground):
161! = .true. : recalculates fall speed after each substep (more accurate)
162! = .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
163! Increased maximum mean droplet radius from 40 to 60 microns, which alleviates spurious number concentration increases at low CCN concentration.
164! Removed a duplicate factor from hail reflectivity that was causing a loss of about 6 dBZ (since WRF 3.5).
165!
166!---------------------------------------------------------------------
167
168
169
172
177 IMPLICIT NONE
178
179 public nssl_2mom_driver
180 public nssl_2mom_init
182 public calc_eff_radius
183 public calcnfromq
184
187 private delbk, delabk
188 private gammadp
189
190 logical, private :: cleardiag = .false.
191 PRIVATE
192
193#if ( WRF_CHEM == 1 )
194 integer, parameter :: wrfchem_flag = 1
195#else
196 integer, parameter :: wrfchem_flag = 0
197#endif
198
199 LOGICAL, PRIVATE:: is_aerosol_aware = .false.
200
201 logical, private :: turn_on_cin = .false.
202
203 integer, private :: eqtset = 1 ! Flag for use with cm1 to use alternate equation set (changes latent heating rates)
204 ! value of > 2 invokes the equivalent version of eqtset=2 that applies updates to both theta and Pi.
205 double precision, parameter, public :: zscale = 1.0d0 ! 1.000e-10
206 double precision, parameter, public :: zscaleinv = 1.0d0/zscale ! 1.000e-10
207
208
209 real, parameter :: warmonly = 0.0 ! testing parameter, set to 1.0 to reduce to warm-rain physics (ice variables stay zero)
210
211 logical, parameter :: lwsm6 = .false. ! act like wsm6 for some single moment interactions
212
213! some constants from WSM6
214 real, parameter :: dimax = 500.e-6 ! limited maximum value for the cloud-ice diamter
215 real, parameter :: roqimax = 2.08e22*dimax**8
216
217! Params for dbz:
218 integer :: iuseferrier = 1 ! =1: use dry graupel only from Ferrier 1994; = 0: Use Smith (wet graupel)
219 integer :: idbzci = 1
220 integer :: iusewetgraupel = 1 ! =1 to turn on use of QHW for graupel reflectivity (only for ZVDM -- mixedphase)
221 ! =2 turn on for graupel density less than 300. only
222 integer :: iusewethail = 0 ! =1 to turn on use of QHW for graupel reflectivity (only for ZVDM -- mixedphase)
223 integer :: iusewetsnow = 0 ! =1 to turn on diagnosed bright band; =2 'old' snow reflectivity (dry), =3 'old' snow dbz + brightband
224! microphysics
225
226 real, private :: rho_qr = 1000., cnor = 8.0e5 ! cnor is set in namelist!! rain params
227 real, private :: rho_qs = 100., cnos = 3.0e6 ! set in namelist!! snow params
228 real, private :: rho_qh = 500., cnoh = 4.0e5 ! set in namelist!! graupel params
229 real, private :: rho_qhl= 800., cnohl = 4.0e4 ! set in namelist!! hail params
230
231 real, private :: hdnmn = 170.0 ! minimum graupel density (for variable density graupel)
232 real, private :: hldnmn = 500.0 ! minimum hail density (for variable density hail)
233
234 real :: cnohmn = 1.e-2 ! minimum intercept for 2-moment graupel (alphah < 0.5)
235 real :: cnohlmn = 1.e-2 ! minimum intercept for 2-moment hail (alphahl < 0.5)
236
237! Autoconversion parameters
238
239 real , private :: qcmincwrn = 2.0e-3 ! qc threshold for autonconversion (LFO; for 10ICE use qminrncw for ircnw != 5)
240 real , private :: cwdiap = 20.0e-6 ! threshold diameter of cloud drops (Ferrier 1994 autoconversion)
241 real , private :: cwdisp = 0.15 ! assume droplet dispersion parameter (can be 0.3 for maritime)
242 real , private :: ccn = 0.6e+09 ! set in namelist!! Central plains CCN value
243 real , private :: ccnuf = 0 ! set in namelist!! Central plains CCN value
244 real , public :: qccn, qccnuf ! ccn "mixing ratio"
245 real , private :: old_qccn = -1.0
246 integer, private :: iauttim = 1 ! 10-ice rain delay flag
247 real , private :: auttim = 300. ! 10-ice rain delay time
248 real , private :: qcwmntim = 1.0e-5 ! 10-ice rain delay min qc for time accrual
249
250#if (NMM_CORE == 1)
251! NMM WRF core does not have special boundary conditions for CCN, therefore set invertccn to true
252 logical, parameter :: invertccn = .true. ! =true for base state of ccn=0, =false for ccn initialized in the base state
253#else
254 logical, private :: invertccn = .false. ! =true for base state of ccn=0, =false for ccn initialized in the base state
255#endif
256 logical :: switchccn = .false.
257 real :: old_cccn = -1.0
258 logical :: restoreccn = .true. ! whether or not to nudge CCN back to base state (qccn) (only applies if CCNA is NOT predicted)
259 real :: ccntimeconst = 3600. ! time constant for CCN restore (either for CCNA or when restoreccn = true)
260 real, private :: restoreccnfrac = 1.0 ! fraction of evaporated droplets that restore CCN
261 real :: ufccntimeconst = 6.*3600. ! time constant for UFCCN decay (Blossey et al. 2018)
262 real :: ufbackground = 0.1e9 ! background ccnuf value (Blossey et al.)
263 logical :: decayufccn = .false.
264 integer :: i_uf_or_ccn = 0 ! 0 = ship adds UF; 1 = treat UF as regular ccn (add to qccn)
265
266! sedimentation flags
267! itfall -> 0 = 1st order fallout (other options removed)
268! iscfall, infall -> fallout options for charge and number concentration, respectively
269! 1 = mass-weighted fall speed; 2 = number-weighted fallspeed.
270 integer, private :: itfall = 0
271 integer, private :: iscfall = 1
272 integer, private :: irfall = -1
273 integer, private :: iifall = 0
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 = 5 ! =1 to always allow renucleation of droplets within the cloud (do no use, obsolete)
348 ! =2 renucleation following Twomey/Cohard&Pinty
349 ! =5 Similar to 7 but can produce extra activated nuclei from the 'smaller' CCN at higher SS
350 ! =7 New renucleation that requires prediction of the number of activated nuclei
351 ! i.e., not only at cloud base
352 integer, private :: irenuc3d = 0 ! =1 to include horizontal gradient in renucleation of droplets within the cloud
353 real :: renucfrac = 0.0 ! = 0 : cnuc = cwccn
354 ! = 1 : cnuc = actual available CCN
355 ! otherwise cnuc = cwccn*(1. - renufrac) + ccnc(1:ngscnt)*renucfrac
356 real :: ssf2kmax = 10. ! max value for ssf**cck in irenuc=4 or 5
357 real , private :: cck = 0.6 ! exponent in Twomey expression
358 real , private :: ciintmx = 1.0e6 ! limit on ice concentration from primary nucleation
359
360 real , private :: cwccn ! , cwmasn,cwmasx
361 real , private :: ccwmx
362
363 integer, private :: idocw = 1, idorw = 1, idoci = 1, idoir = 1, idoip = 1, idosw = 1
364 integer, private :: idogl = 1, idogm = 1, idogh = 1, idofw = 1, idohw = 1, idohl = 1
365! integer, private :: ido(3:14) = / 12*1 /
366
367
368! 0,2, 5.00e-10, 1, 0, 0, 0 : itype1,itype2,cimas0,icfn,ihrn,ibfc,iacr
369 integer, private :: itype1 = 0, itype2 = 2 ! controls Hallett-Mossop process
370 integer, private :: in_freeze_rain_first = 0 ! =1 use IN to freezed rain drops (if none, then freeze droplets)
371 integer, private :: icenucopt = 1 ! =1 Meyers/Ferrier primary ice nucleation; =2 Thompson/Cooper, =3 Phillips (Meyers/Demott), =4 DeMott (2010)
372 real, private :: naer = 1.0e6 ! background large aerosol conc. for DeMott
373 integer, private :: icfn = 2 ! contact freezing: 0 = off; 1 = hack (ok for single moment); 2 = full Cotton/Meyers version
374 integer, private :: ihrn = 0 ! Hobbs-Rangno ice multiplication (Ferrier, 1994; use in 10-ice only)
375 integer, private :: ibfc = 1 ! Flag to use Bigg freezing on droplets (0 = off (uses alternate freezing), 1 = on)
376 real, private :: cwfrz2snowfrac = 0.0 ! fraction of freezing droplet mass to send to snow
377 real, private :: cwfrz2snowratio = 5. ! Assumed number of frozen droplets in a cluster
378 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
379 integer, private :: iacr = 2 ! Flag for drop contact freezing with crytals
380 ! (0=off; 1=drops > 500micron diameter; 2 = > 300micron)
381 integer, private :: icrcev = 1 ! 1 = old crcev; 2 = crcev scaled by vtrain ratio (num/mass); 3 = set to zero
382 integer, private :: icracr = 1 ! Flag to turn rain self-collection on/off (=0 to turn off)
383 integer, private :: icracrthresh = 1 ! For rain self-coll. thresh. use: 1 = mean diam of 2mm; 2 = rain median volume diam of 1.9mm
384 integer, private :: ibfr = 2 ! Flag for Bigg freezing conversion of freezing drops to graupel
385 ! (1=min graupel size is vr1mm; 2=use min size of dfrz, 5= as for 2 and apply dbz conservation)
386 integer, private :: ibiggopt = 2 ! 1 = old Bigg; 2 = experimental Bigg (only for imurain = 1, however)
387 integer :: ibiggsmallrain = 0 ! 1 = When rain is too small, freeze none to graupel and send all to snow (experimental)
388 integer, private :: iacrsize = 5 ! assumed min size of drops freezing by capture
389 ! 1: > 500 micron diam
390 ! 2: > 300 micron
391 ! 3: > 40 micron
392 ! 4: all sizes
393 ! 5: > 150 micron (only for imurain = 1)
394 real , private :: cimas0 = 6.62e-11 ! default mass of Hallett-Mossop crystals
395 ! 6.62e-11kg results in half the diam. (60 microns) of old default value of 5.0e-10
396 real , private :: cimas1 = 6.88e-13 ! default mass of new ice crystals
397 real , private :: splintermass = 6.88e-13
398 real , private :: cfnfac = 0.1 ! Hack factor that goes with icfn=1
399 integer, private :: iscni = 4 ! default option for ice crystal aggregation/conversion to snow
400 real , private :: fscni = 1.0 ! factor for calculating cscni
401 logical, private :: imeyers5 = .false. ! .false.=off, true=on for Meyers ice nucleation for temp > -5 C
402 real , private :: dmincw = 15.0e-6 ! minimum droplet diameter for collection for iehw=3
403 integer, private :: iehw = 1 ! 0 -> ehw=ehw0; 1 -> old ehw; 2 -> test ehw with Mason table data
404 integer, private :: iefw = 1 ! 0 -> ehw=ehw0; 1 -> old ehw; 2 -> test ehw with Mason table data
405 integer, private :: iehlw = 1 ! 0 -> ehlw=ehlw0; 1 -> old ehlw; 2 -> test ehlw with Mason table data
406 ! For ehw/ehlw = 1, ehw0/ehlw0 act as maximum limit on collection efficiency (defaults are 1.0)
407 integer, private :: ierw = 1 ! for single-moment rain (LFO/Z)
408 integer, private :: iehr0c = 0 ! 0 -> no collection for T > 0C; 1 -> turn on collection/shedding for T > 0C
409 integer, private :: iehlr0c = 0 ! 0 -> no collection for T > 0C; 1 -> turn on collection/shedding for T > 0C
410 real , private :: eiw0 = 0.5 ! constant or max assumed ice-crystal-droplet collection efficiency
411 real , private :: esw0 = 0.5 ! constant or max assumed snow-droplet collection efficiency
412 real , private :: ehw0 = 0.9 ! constant or max assumed graupel-droplet collection efficiency
413 real , private :: erw0 = 1.0 ! constant assumed rain-droplet collection efficiency
414 real , private :: ehlw0 = 0.9 ! constant or max assumed hail-droplet collection efficiency
415 real , private :: efw0 = 0.5 ! constant or max assumed graupel-droplet collection efficiency
416 real :: ehr0 = 1.0 ! constant or max assumed graupel-rain collection efficiency
417 real :: efr0 = 1.0 ! constant or max assumed graupel-rain collection efficiency
418 real :: ehlr0 = 1.0 ! constant or max assumed hail-rain collection efficiency
419 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)
420
421
422 real , private :: esilfo0 = 1.0 ! factor for LFO collection efficiency of snow for cloud ice.
423 real , private :: ehslfo0 = 1.0 ! factor for LFO collection efficiency of hail/graupel for snow.
424
425 integer, private :: ircnw = 5 ! single-moment warm-rain autoconversion option. 5= Ferrier 1994.
426 real , private :: qminrncw = 2.0e-3 ! qc threshold for rain autoconversion (NA for ircnw=5)
427
428 integer, private :: iqcinit = 2 ! For ZVDxx schemes, flag to choose which way to initialize droplets
429 ! 1 = Soong-Ogura adjustment
430 ! 2 = Saturation adjustment to value of ssmxinit
431 ! 3 = KW adjustment
432
433 real , private :: ssmxinit = 0.4 ! saturation percentage to adjust down to for initial cloud
434 ! formation (ZVDxx scheme only)
435
436 real , private :: ewfac = 1.0 ! hack factor applied to graupel and hail collection eff. for droplets
437 real , private :: eii0 = 0.1 ,eii1 = 0.1 ! graupel-crystal coll. eff. parameters: eii0*exp(eii1*min(temcg(mgs),0.0))
438 ! set eii1 = 0 to get a constant value of eii0
439 real , private :: eii0hl = 0.2 ,eii1hl = 0.0 ! hail-crystal coll. eff. parameters: eii0hl*exp(eii1hl*min(temcg(mgs),0.0))
440 ! set eii1hl = 0 to get a constant value of eii0hl
441 real, private :: ewi_dcmin = 15.0e-06 ! minimum droplet diameter for nonzero ewi
442 real, private :: ewi_dimin = 30.0e-06 ! minimum ice crystal diameter for nonzero ewi
443 real , private :: eri0 = 0.1 ! rain efficiency to collect ice crystals
444 real , private :: eri_cimin = 10.e-6 ! minimum ice crystal diameter for collection by rain
445 real , private :: esi0 = 0.1 ! linear factor in snow-ice collection efficiency
446 real , private :: ehs0 = 0.1, ehs1 = 0.1 ! graupel-snow coll. eff. parameters: ehs0*exp(ehs1*min(temcg(mgs),0.0))
447 ! set ehs1 = 0 to get a constant value of ehs0
448 integer :: iessopt = 1 ! 1 = Original (no factor); 2 = factor based on wvel; 3 = factor based on SSI
449 ! 4 = as 3 but sets min factor of 0.1 and goes to full value at 0.5% SSI
450 real , private :: ess0 = 0.5, ess1 = 0.05 ! snow aggregation coefficients: ess0*exp(ess1*min(temcg(mgs),0.0))
451 ! set ess1 = 0 to get a constant value of ess0
452 real , private :: esstem1 = -15. ! lower temperature where snow aggregation turns on
453 real , private :: esstem2 = -10. ! higher temperature for linear ramp of ess from zero at esstem1 to formula value at esstem2
454 real , private :: essrmax = 0.02 ! maximum snow radius (meters) for csacs
455 real , private :: essfrac1 = 0.5 ! snow mass fraction 1 for aggregation roll-off
456 real , private :: essfrac2 = 0.75 ! snow mass fraction 2 for aggregation roll-off
457 integer, private :: iessec0flag = 0 ! flag to activate aggregation roll-off
458 real , private :: ehsfrac = 1.0 ! multiplier for graupel collection efficiency in wet growth
459 real , private :: ehimin = 0.0 ! Minimum collection efficiency (graupel - ice crystal)
460 real , private :: ehimax = 1.0 ! Maximum collection efficiency (graupel - ice crystal)
461 real , private :: ehsmax = 0.5 ! Maximum collection efficiency (graupel - snow)
462 real , private :: ecollmx = 0.5 ! Maximum collision efficiency for graup/hail with ice; used only for charging rates
463 integer, private :: iglcnvi = 1 ! flag for riming conversion from cloud ice to rimed ice/graupel
464 integer, private :: iglcnvs = 2 ! flag for conversion from snow to rimed ice/graupel
465
466 real , private :: rz ! reflectivity conservation factor for graupel/rain
467 ! now calculated in icezvd_dr.F from alphah and rnu
468 ! currently only used for graupel melting to rain
469 real , private :: rzhl ! reflectivity conservation factor for hail/rain
470 ! now calculated in icezvd_dr.F from alphahl and rnu
471
472 real , private :: rzs ! reflectivity conservation factor for snow(imusnow=3) with rain (imurain=1)
473
474 real , private :: alphahacx = 0.0 ! assumed minimum shape parameter for zhacw and zhacr
475
476 real , private :: fconv = 1.0 ! factor to boost max graupel depletion by riming conversions in 10ICE
477
478 real , private :: rg0 = 400.0 ! reference graupel density for graupel fall speed
479
480 integer, private :: rcond = 2 ! (Z only) rcond = 2 includes rain condensation in loop with droplet condensation
481 ! 0 = no condensation on rain; 1 = bulk condensation on rain
482 integer, parameter, private :: icond = 1 ! (Z only) icond = 1 calculates ice deposition (crystals and snow) BEFORE droplet condensation
483 ! icond = 2 does not work (intended to calc. dep in loop with droplet cond.)
484 integer, private :: iqis0 = 2 ! = 1 for normal qis; = 2 to set qis to use T = 0C when T > 0C
485
486 real , private :: dfrz = 0.15e-3 ! 0.25e-3 ! minimum diameter of frozen drops from Bigg freezing (used for vfrz) for iacr > 1
487 ! and for ciacrf for iacr=4
488 real , private :: dmlt = 3.0e-3 ! maximum diameter for rain melting from graupel and hail
489 real , private :: dshd = 1.0e-3 ! nominal diameter for rain drops shed from graupel/hail
490 integer, private :: ivshdgs = 1 ! 0 = use 1mm for all shedding (non-mixedphase); 1 = use vshdgs with sheddiam
491 integer, private :: ished2cld = 0 ! 1: Send shed liquid (from wet growth) to cloud droplets
492
493 integer, private :: ihmlt = 2 ! 1=old melting with vmlt; 2=new melting using mean volume diam of graupel/hail
494 integer, private :: imltshddmr = 2 ! 0 (default)=mean diameter of drops produced during melting+shedding as before (using mean diameter of graupel/hail
495 ! and max mean diameter of rain)
496 ! 1=new method where mean diameter of rain during melting is adjusted linearly downward
497 ! toward 3 mm for large (> sheddiam) graupel and hail, to take into account shedding of
498 ! smaller drops. sheddiam0 controls the size of graupel/hail above which the assumed
499 ! mean diameter of rain is set to 3 mm
500 ! Only valid for ihmlt = 2 for ZVD(H) but also applies to ZVD(H)M
501 ! 2 = method that sets the resulting rain size ( vshdgs ) according to the mass-weighted diameter of the ice
502
503 real :: mltdiam1 = 9.0e-3, mltdiam2 = 16.0e-3, mltdiam3 = 19.0e-3, mltdiam4 = 200.0e-3, mltdiam05 = 4.5e-3
504
505 integer, private :: nsplinter = 0 ! number of ice splinters per freezing drop, if negative, then per resulting graupel particle
506 real, private :: lawson_splinter_fac = 2.5e-11 ! constant in Lawson et al. (2015, JAS) for ice particle production from freezing drops
507 integer, private :: isnwfrac = 0 ! 0= no snow fragmentation; 1 = turn on snow fragmentation (Schuur, 2000)
508
509! integer, private :: denscale = 1 ! 1=scale num. conc. and charge by air density for advection, 0=turn off for comparison
510
511 real, private :: qhdpvdn = -1.
512 real, private :: qhacidn = -1.
513
514 integer, private :: iraintypes = 0
515 logical, private :: mixedphase = .false. ! .false.=off, true=on to include mixed phase graupel
516 integer, private :: imixedphase = 0
517 logical, private :: qsdenmod = .false. ! true = modify snow density by linear interpolation of snow and rain density
518 logical, private :: qhdenmod = .false. ! true = modify graupel density by linear interpolation of graupel and rain density
519 logical, private :: qsvtmod = .false. ! true = modify snow fall speed by linear interpolation of snow and rain vt
520 real , private :: sheddiam = 8.0e-03 ! minimum diameter of graupel before shedding occurs
521 real :: sheddiamlg = 10.0e-03 ! diameter of hail to use fwmlarge
522 real :: sheddiam0 = 20.0e-03 ! diameter of hail at which all water is shed
523
524 real :: fwmhtmptem = -15. ! temperature at which fwmhtmp fully switches to liquid water only being on large particles
525 integer :: ifwmhtmptemopt = 1 ! option to use fwmhtmptem (1) or dwet (2) for max liquid at T < 0.
526 integer :: ifwmhopt = 2 ! option for calculating maximum liquid fraction when fwmh and/or fwmhl is set to -1
527 ! 1 = maximum based on size of maximum mass diameter
528 ! 2 = integrate over spectrum for maximum liquid (experimental)
529
530 integer :: ihxw2rain = 0 ! = 0 no transfer
531 ! = 1 transfer completely melted (99.5%) graupel/hail to rain when fwmh/fwmhl is set to -1.
532
533 real , private :: fwms = 0.5 ! maximum liquid water fraction on snow
534 real , private :: fwmh = 0.5 ! maximum liquid water fraction on graupel
535 real , private :: fwmhl = 0.5 ! maximum liquid water fraction on hail
536 real :: fwmlarge = 0.2 ! maximum liquid water fraction on hail larger than sheddiam
537 integer :: ifwmfall = 0 ! whether to interpolate toward rain fall speed for graupel and hail
538 ! when diam < sheddiam and liquid fraction is predicted (0=no, 1=yes)
539
540 logical :: rescale_high_alpha = .false. ! whether to rescale number. conc. when alpha = alphamax (3-moment only)
541 logical :: rescale_low_alpha = .true. ! whether to rescale Z (graupel/hail) when alpha = alphamin (3-moment only)
542 logical :: rescale_low_alphar = .true. ! whether to rescale Z for rain when alpha = alphamin (3-moment only)
543 logical :: rescale_low_alphah = .true. ! whether to rescale Z for rain when alpha = alphamin (3-moment only)
544 logical :: rescale_low_alphahl = .true. ! whether to rescale Z for rain when alpha = alphamin (3-moment only)
545
546 real, parameter :: alpharmax = 8. ! limited for rwvent calculation
547
548 integer, private :: ihlcnh = -1 ! which graupel -> hail conversion to use
549 ! 1 = Milbrandt and Yau (2005) using Ziegler 1985 wet growth diameter
550 ! 2 = Straka and Mansell (2005) conversion using size threshold
551 ! 3 = Conversion using wet growth diameter
552 real, private :: hlcnhdia = 1.e-3 ! threshold diameter for graupel -> hail conversion for ihlcnh = 1 option.
553 real, private :: hlcnhqmin = 0.1e-3 ! minimum graupel mass content for graupel -> hail conversion (ihlcnh = 1)
554 real , private :: hldia1 = 10.0e-3 ! threshold diameter for graupel -> hail conversion for ihlcnh = 2 option.
555 integer, private :: incwet = 0 ! flag to do wet growth only on D > D_wet
556 integer, private :: iusedw = 0 ! flag to use experimental wet growth ice diameter for gr -> hl conversion (=1 turns on)
557 real , private :: dwmin = 5.0e-3 ! Minimum diameter with iusedw (can stay at 0 or be set to something larger)
558 real , private :: dwetmin = 5.0e-3 ! Minimum diameter with iusedw (can stay at 0 or be set to something larger)
559 real , private :: dwmax = 15.e-3 ! for ihlcnh, always convert this size and larger whether or not there is wet growth
560 real , private :: dwtempmin = 242. ! lowest temperature to allow wet growth conversion to hail
561 real , private :: dwehwmin = 0. ! Minimum ehw to use to find wet growth diameter (if > ehw0, then wet growth diam becomes smaller)
562 real , private :: dg0thresh = 0.15 ! graupel wet growth diameter above which we say do not bother
563 real , private :: wetgrthtoffset = -1. ! maximum temperature (Celcius) for wet growth (shedding)
564 real , private :: hailcnvtoffset = -2. ! maximum temperature (Celcius) for hail conversion
565 integer :: ifddenfac = 0 ! = 1 to use density threshold to count FD as GR when converting to HL
566 real :: fddenthresh = 500. ! if ifddenfac > 0, then hail from FD with lower density are considered to come from graupel
567 integer :: icvhl2h = 0 ! allow conversion of hail back to graupel when hail density gets close to minimum allowed
568
569 integer, private :: imurain = 1 ! 3 for gamma-volume, 1 for gamma-diameter DSD for rain.
570 integer, private :: imusnow = 3 ! 3 for gamma-volume, 1 for gamma-diameter DSD for snow (=1 NOT IMPLEMENTED!!).
571 integer, private :: iturbenhance = 0 ! warm-rain collision enhancement
572 ! 1 = enhance autoconversion only
573 ! 2 = add rain collection of cloud
574 ! 3 = add rain self-collection
575 integer, private :: isedonly = 0 ! 1= only do sedimentation and skip other microphysics
576 integer, private :: iferwisventr = 2 ! =1 for Ferrier rwvent, =2 for Wisner rwvent (imurain=1)
577 integer, private :: izwisventr = 2 ! =1 for old Ziegler rwvent, =2 for Wisner-style rwvent (imurain=3)
578 integer :: iresetmoments = 0 ! if >0, then set all moments to zero when one of them is zero (3-moment only)
579 integer, private :: imaxdiaopt = 3
580 ! = 1 use mean diameter for breakup
581 ! = 2 use maximum mass diameter for breakup
582 ! = 3 use mass-weighted diameter for breakup
583 integer :: irainbreak = -1 ! -1 : auto sets off for 2-moment and on (=2) for 3-moment
584 ! 0 = off
585 ! 1 = on (no diameter dependence) (recommend using option 2)
586 ! 2 = (recommended) as for 1, but apply factor of 1-ec0 to turn off a smaller diameter (ec0 is rain self-coll factor)
587 ! 10 = as for 1, but sets ec0=1 for rain self-collection (i.e., no passive breakup); set higher rainbreakfac for this option
588 ! 11 = breakup for DSD tail only; uses draintail etc.
589 integer :: ibincracr = 0
590 real :: rainbreakfac = 1.0e6 ! 1.e6 for irainbreak=2 (reduce double counting); 2.0e6 for lower hand fit for irainbreak=10; 2.542e6 for 'best' fit
591 real :: draintail = 10.e-3 ! starting size for rain breakup (irainbreak = 11)
592 real :: drsmall = 1.e-3 ! size of small drops from breakup (irainbreak = 11)
593 real :: qrbrthresh1 = 0.1e-3 ! lower threshold rain content (kg/m^3) for large drop breakup (irainbreak=11)
594 real :: qrbrthresh2 = 1.0e-3 ! upper threshold rain content (kg/m^3) for large drop breakup (irainbreak=11)
595 integer, private :: dmrauto = 0
596 ! = -1 no limiter on crcnw
597 ! = 0 limit crcnw when qr > 1.2*L (Cohard-Pinty 2002)
598 ! = 1 DTD version based on MY code
599 ! = 2 DTD mass-weighted version based on MY code
600 ! = 3 Milbrandt version (from Cohard and Pinty code
601 integer :: dmropt = 0 ! extra option for crcnw
602 integer :: dmhlopt = 0 ! options for graupel -> hail conversion
603 integer :: irescalerainopt = 3 ! 0 = default option
604 ! 1 = qx(mgs,lc) > qxmin(lc)
605 ! 2 = qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < 3.0
606 ! 3 = temcg(mgs) > 0.0.and. qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < 3.0
607 real :: rescale_wthresh = 3.0
608 real :: rescale_tempthresh = 0.0
609 real, parameter :: alpharaut = 0.0 ! MY2005 for autoconversion
610 real :: cxmin = 1.e-8 ! threshold cutoff for number concentration
611 real :: zxmin = 1.e-28 ! threshold cutoff for reflectivity moment
612
613 integer :: ithompsoncnoh = 0 ! For single moment graupel only
614 ! 0 = fixed intercept
615 ! 1 = intercept based on graupel mass
616
617 integer :: ivhmltsoak = 1 ! 0=off, 1=on : flag to simulate soaking (graupel/hail) during melting
618 ! when liquid fraction is not predicted
619 logical, private :: iwetsoak = .true. ! soak and freeze during wet growth or not
620 integer, private :: ioldlimiter = 0 ! test switch for new(=0) or old(=1) size limiter at the end of GS for 3-moment categories
621 integer, private :: isnowfall = 2 ! Option for choosing between snow fall speed parameters
622 ! 1 = original Zrnic et al. (Mansell et al. 2010)
623 ! 2 = Ferrier 1994 (results in slower fall speeds)
624
625 integer, private :: isnowdens = 1 ! Option for choosing between snow density options
626 ! 1 = constant of 100 kg m^-3
627 ! 2 = Option based on Cox
628
629 integer, private :: ibiggsnow = 3 ! 1 = switch conversion over to snow for small frozen drops from Bigg freezing
630 ! 2 = switch conversion over to snow for small frozen drops from rain-ice interaction
631 ! 3 = switch conversion over to snow for small frozen drops from both
632 real :: biggsnowdiam = -1.0 ! If >0, use for ibiggsnow threshold
633
634 integer, private :: ixtaltype = 1 ! =1 column, =2 disk (similar to Takahashi)
635
636 real, private :: takshedsize1 = 0.15 ! diameter (cm) of drop shed from ice with D > 1.9 cm
637 real, private :: takshedsize2 = 0.3 ! diameter (cm) of drop shed from ice with D < 1.9 cm and D > 0.8 cm
638 real, private :: takshedsize3 = 0.45 ! diameter (cm) of drop shed from ice with D < 1.6 cm and D > 0.8 cm
639 integer, private :: numshedregimes = 3
640
641 real, private :: evapfac = 1.0 ! Multiplier on rain evaporation rate
642 real, private :: depfac = 1.0 ! Multiplier on graupel/hail deposition/sublimation rate
643 real,private,parameter :: meltfac = 1.0 ! Multiplier on graupel/hail melting rate
644
645 integer, private :: ibinhmlr = 0 ! =1 use incomplete gammas to determine melting from larger and smaller sizes of graupel, and appropriate shed drop sizes
646 ! =2 to test melting by temporary bins
647 integer, private :: ibinhlmlr = 0 ! =1 use incomplete gammas to determine melting from larger and smaller sizes of hail, and appropriate shed drop sizes
648 ! =2 to test melting by temporary bins
649 integer, private :: ibinnum = 2 ! number of bins for melting of smaller ice (for ibinhmlr = 1)
650 integer, private :: iqhacrmlr = 1 ! turn on/off qhacrmlr
651 integer, private :: iqhlacrmlr = 1 ! turn on/off qhlacrmlr
652 integer, private :: iqhacwshr = 1 ! turn on/off qhacw for T > 0
653 integer, private :: iqhlacwshr = 1 ! turn on/off qhlacw for T > 0
654 real, private :: binmlrmxdia = 40.e-3 ! threshold diameter (graupel/hail) to switch bin-bulk melting to use standard chmlr
655 real, private :: binmlrzrrfac = 1.0 ! factor for reflectivity change ice that sheds while melting
656 real, private :: snowmeltdia = 0 ! If nonzero, sets the size of rain drops from melting snow.
657 real, private :: alphasmlr0 = 14.0 ! shape parameter for drops formed from melting/shedding snow
658 real, private :: delta_alphamlr = 0.5 ! offset from alphamax at which melting does not further collapse the shape parameter
659
660 integer, private :: iqvsopt = 1 ! =0 use old default for tabqvs with e/p approx; =1 use Bolton formulation (Rogers and Yau) with e/(p-e)
661
662 integer :: imaxsupopt = 4 ! how to treat saturation adjustment in two-moment droplets
663 ! 1 = add droplets with same mean mass as current droplets
664 ! 2 = add droplets with minimum radius of 30 microns
665 ! 3 = only add 1.5*cxmin to number concentration (allow max size to apply)
666 ! 4 = add droplets with minimum radius of 20 microns
667 real :: maxsupersat = 1.9 ! maximum supersaturation ratio, above which a saturation adustment is done
668 real :: maxlowtempss = 1.08 ! Sat. ratio threshold for allowing droplet nucleation at T < tfrh
669 real :: ssmxuf = 4.0 ! supersaturation at which to start using "ultrafine" CCN (if ccnuf > 0.)
670
671
672 integer, parameter :: icespheres = 0 ! turn ice spheres (frozen droplets) on (1) or off (0). NOT COMPLETE IN WRF/ARPS/CM1 CODE!
673 integer, parameter :: lqmx = 30
674 integer, parameter :: lt = 1
675 integer, parameter :: lv = 2
676 integer, parameter :: lc = 3
677 integer, parameter :: lr = 4
678 integer, parameter :: li = 5
679 integer, private :: lis = 0
680 integer, private :: ls = 6
681 integer, private :: lh = 7
682 integer, private :: lf = 0
683 integer, private :: lhl = 0
684
685 integer, private :: lccn = 9 ! 0 or 9, other indices adjusted accordingly
686 integer, private :: lccnuf = 0
687 integer, private :: lccna = 0
688 integer, private :: lccnaco = 0
689 integer, private :: lccnanu = 0
690 integer, private :: lcina = 0
691 integer, private :: lcin = 0
692 integer, private :: lnc = 9
693 integer, private :: lnr = 10
694 integer, private :: lni = 11
695 integer, private :: lnis = 0
696 integer, private :: lns = 12
697 integer, private :: lnh = 13
698 integer, private :: lnf = 0
699 integer, private :: lnhl = 0
700 integer, private :: lnhf = 0
701 integer, private :: lnhlf = 0
702 integer, private :: lss = 0
703 integer :: lvh = 15
704
705 integer, private :: lhab = 8
706 integer, private :: lg = 7
707
708! Particle volume
709
710 integer :: lvi = 0
711 integer :: lvs = 0
712 integer :: lvgl = 0
713 integer :: lvgm = 0
714 integer :: lvgh = 0
715 integer :: lvf = 0
716! integer :: lvh = 16
717 integer :: lvhl = 0
718
719! liquid water fraction (not predicted here but tested for)
720 integer :: lhw = 0
721 integer :: lfw = 0
722 integer :: lsw = 0
723 integer :: lhlw = 0
724 integer :: lhwlg = 0
725 integer :: lhlwlg = 0
726
727! reflectivity (6th moment) ! not predicted here but may be tested against
728
729 integer :: lzr = 0
730 integer :: lzi = 0
731 integer :: lzs = 0
732 integer :: lzgl = 0
733 integer :: lzgm = 0
734 integer :: lzgh = 0
735 integer :: lzf = 0
736 integer :: lzh = 0
737 integer :: lzhl = 0
738
739! Space charge
740
741 integer :: lscw = 0
742 integer :: lscr = 0
743 integer :: lsci = 0
744 integer :: lscis = 0
745 integer :: lscs = 0
746 integer :: lsch = 0
747 integer :: lscf = 0
748 integer :: lschl = 0
749 integer :: lscwi = 0
750 integer :: lscpi = 0
751 integer :: lscni = 0
752 integer :: lscpli = 0
753 integer :: lscnli = 0
754 integer :: lschab = 0
755
756 integer :: lscb = 0
757 integer :: lsce = 0
758 integer :: lsceq = 0
759
760! integer, parameter :: lscmx = 100
761
762 integer :: lne = 0 ! last varible for transforming
763
764 real :: cnoh0 = 4.0e+5
765 real :: hwdn1 = 700.0
766
767 real :: alphai = 0.0 ! shape parameter for ZIEG ice crystals ! not currently used
768 real :: alphas = 0.0 ! shape parameter for ZIEG snow ! used only for single moment
769 real :: alphar = 0.0 ! shape parameter for rain (imurain=1 only)
770 real, private :: alphah = 0.0 ! set in namelist!! shape parameter for ZIEG graupel
771 real, private :: alphahl = 1.0 ! set in namelist!! shape parameter for ZIEG hail
772
773 real :: dmuh = 1.0 ! power in exponential part (graupel)
774 real :: dmuhl = 1.0 ! power in exponential part (hail)
775
776 real, private :: alphamax = 15.
777 real, private :: alphamin = 0.
778 real, parameter :: rnumin = -0.8
779 real, parameter :: rnumax = 15.0
780
781
782 real :: cnu = 0.0 ! default value of droplet shape parameter. Can be diagnosed by setting idiagnosecnu=1
783 real, parameter :: rnu = -0.8, snu = -0.8, cinu = 0.0
784! parameter ( cnu = 0.0, rnu = -0.8, snu = -0.8, cinu = 0.0 )
785
786 real xnu(lc:lqmx) ! 1st shape parameter (mass)
787 real xmu(lc:lqmx) ! 2nd shape parameter (mass)
788 real dnu(lc:lqmx) ! 1st shape parameter (diameter)
789 real dmu(lc:lqmx) ! 2nd shape parameter (diameter)
790
791 real ax(lc:lqmx)
792 real bx(lc:lqmx)
793 real fx(lc:lqmx)
794
795 real da0 (lc:lqmx) ! collection coefficients from Seifert 2005
796 real dab0(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
797 real dab1(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
798 real da1 (lc:lqmx) ! collection coefficients from Seifert 2005
799 real bb (lc:lqmx)
800
801
802! put ipelec here for now....
803 integer :: ipelec = 0
804 integer :: isaund = 0
805 logical :: idoniconly = .false.
806 integer, private :: elec_on_time = -1 ! time (seconds) to turn on charge separation.
807 integer, private :: elec_ramp_time = 0 ! time (interval) for linear ramp after elec_on_time
808 ! (i.e., linear factor on chg sep to smoothly turn on elec)
809 ! full charging rate is achieved at time = elec_on_time + elec_ramp_time
810 integer :: jchgs = 3 ! number of points near boundary where charging is turned off (to keep lightning from getting wonky)
811 integer :: jchgn = 2
812 integer :: ichge = 3
813 integer :: ichgw = 2
814 real :: charging_border = 4000. ! width of no-charging zone from boundary
815 real, private :: delqnw = -1.0e-10!-1.0e-12 !
816 real, private :: delqxw = 1.0e-10! 1.0e-12 !
817 real :: tindmn = 233, tindmx = 298.0 ! min and max temperatures where inductive charging is allowed
818
819 integer, private :: imorrgdnglimit = 0 ! flag to impose limit on graupel slope parameter
820 real, private :: morrdnglimit = 2000.e-6
821
822!
823! gamma function lookup table
824!
825 integer ngm0,ngm1,ngm2
826 parameter(ngm0=3001,ngm1=500,ngm2=500)
827 double precision, parameter :: dgam = 0.01, dgami = 100.
828 double precision gmoi(0:ngm0) ! ,gmod(0:ngm1,0:ngm2),gmdi(0:ngm1,0:ngm2)
829
830 integer, parameter :: nqiacralpha = 300 !480 ! 240 ! 120 ! 15
831 integer, parameter :: nqiacrratio = 400 ! 500 !50 ! 25
832! real, parameter :: maxratiolu = 25.
833 real, parameter :: maxratiolu = 100. ! 25.
834 real, parameter :: maxalphalu = 15.
835 real, parameter :: minalphalu = -0.95
836 real, parameter :: dqiacralpha = maxalphalu/float(nqiacralpha), dqiacrratio = maxratiolu/float(nqiacrratio)
837 real, parameter :: dqiacrratioinv = 1./dqiacrratio, dqiacralphainv = 1./dqiacralpha
838 integer, parameter :: ialpstart = minalphalu*dqiacralphainv
839 real :: ciacrratio(0:nqiacrratio,ialpstart:nqiacralpha)
840 real :: qiacrratio(0:nqiacrratio,ialpstart:nqiacralpha)
841 real :: ziacrratio(0:nqiacrratio,ialpstart:nqiacralpha)
842 double precision :: gamxinflu(0:nqiacrratio,ialpstart:nqiacralpha,12,2) ! last index for graupel (1) or hail (2)
843! real :: ciacrratio(0:nqiacrratio,0:nqiacralpha)
844! real :: qiacrratio(0:nqiacrratio,0:nqiacralpha)
845! real :: ziacrratio(0:nqiacrratio,0:nqiacralpha)
846! double precision :: gamxinflu(0:nqiacrratio,0:nqiacralpha,12,2) ! last index for graupel (1) or hail (2)
847
848! for 3-moment collection coefficients
849 real, save :: dab0lu(ialpstart:nqiacralpha,ialpstart:nqiacralpha,lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
850 real, save :: dab1lu(ialpstart:nqiacralpha,ialpstart:nqiacralpha,lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
851
852 integer, parameter :: ngdnmm = 9
853 real :: mmgraupvt(ngdnmm,3) ! Milbrandt and Morrison (2013) fall speed coefficients for graupel/hail
854
855 DATA mmgraupvt(:,1) / 50., 150., 250., 350., 450., 550., 650., 750., 850./
856 DATA mmgraupvt(:,2) / 62.923, 94.122, 114.74, 131.21, 145.26, 157.71, 168.98, 179.36, 189.02 /
857 DATA mmgraupvt(:,3) / 0.67819, 0.63789, 0.62197, 0.61240, 0.60572, 0.60066, 0.59663, 0.59330, 0.59048 /
858
859 integer lsc(lc:lqmx)
860 integer ln(lc:lqmx)
861 integer ipc(lc:lqmx)
862 integer lvol(lc:lqmx)
863 integer lz(lc:lqmx)
864 integer lliq(li:lqmx)
865 integer linfall(lc:lqmx)
866 integer denscale(lc:lqmx) ! flag for density scaling (mixing ratio conversion)
867
868 integer ido(lc:lqmx)
869 logical ldovol
870
871 real xdn0(lc:lqmx)
872 real xdnmx(lc:lqmx), xdnmn(lc:lqmx)
873 real cdx(lc:lqmx)
874 real cno(lc:lqmx)
875 real xvmn(lc:lqmx), xvmx(lc:lqmx)
876 real qxmin(lc:lqmx)
877 real qxmin_init(lc:lqmx)
878
879 integer nqsat
880 parameter(nqsat=1000001) ! (nqsat=20001)
881 real fqsat,fqsati
882 parameter(fqsat=0.002,fqsati=1./fqsat)
883 real tabqvs(nqsat),tabqis(nqsat),dtabqvs(nqsat),dtabqis(nqsat)
884
885!
886! constants
887!
888 real, parameter :: ar = 841.99666 ! rain terminal velocity power law coefficient (LFO)
889 real, parameter :: br = 0.8 ! rain terminal velocity power law coefficient (LFO)
890 real, parameter :: aradcw = -0.27544 !
891 real, parameter :: bradcw = 0.26249e+06 !
892 real, parameter :: cradcw = -1.8896e+10 !
893 real, parameter :: dradcw = 4.4626e+14 !
894 real, parameter :: bta1 = 0.6 ! beta-1 constant used for ice nucleation by deposition (Ferrier 94, among others)
895 real, parameter :: cnit = 1.0e-02 ! No for ice nucleation by deposition (Cotton et al. 86)
896 real, parameter :: dragh = 0.60 ! coefficient used to adjust fall speed for hail versus graupel (Pruppacher and Klett 78)
897 real, parameter :: dnz00 = 1.225 ! reference/MSL air density
898 real, parameter :: rho00 = 1.225 ! reference/MSL air density
899! cs = 4.83607122 ! snow terminal velocity power law coefficient (LFO)
900! ds = 0.25 ! snow terminal velocity power law coefficient (LFO)
901! new values for cs and ds
902 real, parameter :: cs = 12.42 ! snow terminal velocity power law coefficient
903 real, parameter :: ds = 0.42 ! snow terminal velocity power law coefficient
904 real :: cp608 = 0.608 ! constant used in conversion of T to Tv
905 real :: gr = 9.8
906
907 real, parameter :: pi = 3.141592653589793
908 real, parameter :: piinv = 1./pi
909 real, parameter :: pid4 = pi/4.0
910
911!
912! max and min mean volumes
913!
914 real xvrmn, xvrmx0 ! min, max rain volumes
915 real xvsmn, xvsmx ! min, max snow volumes
916 real xvfmn, xvfmx ! min, max frozen drop volumes
917 real xvgmn, xvgmx ! min, max graupel volumes
918 real xvhmn, xvhmn0, xvhmx, xvhmx0 ! min, max hail volumes
919 real xvhlmn, xvhlmx, xvhlmx0 ! min, max lg hail volumes
920
921 real, parameter :: dhlmn = 0.3e-3
922 real, parameter :: dhmn0 = 0.3e-3
923 real, private :: dhmn = dhmn0, dhmx = -1., dhlmx = -1. ! 40.e-3
924
925 real, parameter :: cwradn = 2.0e-6, xcradmn = cwradn ! minimum radius
926 real, parameter :: cwradx = 60.e-6, xcradmx = cwradx ! maximum radius
927 real, parameter :: cwc1 = 6.0/(pi*1000.)
928
929! parameter( xvcmn=4.188e-18 ) ! mks min volume = 3 micron radius
930 real, parameter :: xvcmn=0.523599*(2.*cwradn)**3 ! mks min volume = 2.5 micron radius
931 real, parameter :: xvcmx=0.523599*(2.*xcradmx)**3 ! mks max volume = 60 micron radius
932 real, parameter :: cwmasn = 1000.*xvcmn ! minimum mass, defined by radius of 5.0e-6
933 real, parameter :: cwmasx = 1000.*xvcmx ! maximum mass, defined by radius of 50.0e-6
934 real, parameter :: cwmasn5 = 1000.*0.523599*(2.*5.0e-6)**3 ! 5.23e-13
935
936 real, parameter :: xvimn=0.523599*(2.*5.e-6)**3 ! mks min volume = 5 micron radius
937 real, parameter :: xvimx=0.523599*(2.*1.e-3)**3 ! mks max volume = 1 mm radius (solid sphere approx)
938
939 real, private :: xvdmx = -1.0 ! 3.0e-3
940 real :: xvrmx
941 parameter( xvrmn=0.523599*(80.e-6)**3, xvrmx0=0.523599*(6.e-3)**3 ) !( was 4.1887e-9 ) ! mks
942 parameter( xvsmn=0.523599*(0.01e-3)**3, xvsmx=0.523599*(10.e-3)**3 ) !( was 4.1887e-9 ) ! mks
943 parameter( xvfmn=0.523599*(0.1e-3)**3, xvfmx=0.523599*(10.e-3)**3 ) ! mks xvfmx = (pi/6)*(10mm)**3
944 parameter( xvgmn=0.523599*(0.1e-3)**3, xvgmx=0.523599*(10.e-3)**3 ) ! mks xvfmx = (pi/6)*(10mm)**3
945 parameter( xvhmn0=0.523599*(0.3e-3)**3, xvhmx0=0.523599*(20.e-3)**3 ) ! mks xvfmx = (pi/6)*(20mm)**3
946 parameter( xvhlmn=0.523599*(dhlmn)**3, xvhlmx0=0.523599*(40.e-3)**3 ) ! mks xvfmx = (pi/6)*(40mm)**3
947
948!
949! electrical permitivity of air C / (N m**2) - check the units
950!
951 real eperao
952 parameter(eperao = 8.8592e-12 )
953
954 real ec,eci ! fundamental unit of charge
955 parameter(ec = 1.602e-19)
956 parameter(eci = 1.0/ec)
957
958 real :: scwppmx = 20.0e-12
959 real :: scippmx = 20.0e-12
960!
961! constants
962!
963 real, parameter :: c1f3 = 1.0/3.0
964
965 real, parameter :: cai = 21.87455
966 real, parameter :: caw = 17.2693882
967 real, parameter :: cbi = 7.66
968 real, parameter :: cbw = 35.86
969
970 real, parameter :: cbwbolton = 29.65 ! constants for Bolton formulation
971 real, parameter :: cawbolton = 17.67
972 real, parameter :: esbolton = 6.112e2
973
974 real, parameter :: tfrh = 233.15
975! --------------------------
976 ! For CCPP, the following variables should be set by the host model, but initial values are set just in case
977 real :: tfr = 273.15
978 real :: cp = 1004.0, rd = 287.04
979 real :: rw = 461.5 ! gas const. for water vapor
980 real :: cpl = 4190.0
981 real :: cpigb = 2106.0
982 real :: cpi = 1.0/1004.0
983 real :: cap = 287.04/1004.0
984 real :: tfrcbw = 273.15 - cbw
985 real :: tfrcbi = 273.15 - cbi
986 real :: rovcp = 287.04/1004.0
987 real :: rdorv = 0.622
988! --------------------------
989 real, parameter :: poo = 1.0e+05
990 real, parameter :: advisc0 = 1.832e-05 ! reference dynamic viscosity (SMT; see Beard & Pruppacher 71)
991 real, parameter :: advisc1 = 1.718e-05 ! dynamic viscosity constant used in thermal conductivity calc
992 real, parameter :: tka0 = 2.43e-02 ! reference thermal conductivity
993
994 ! GHB: Needed for eqtset=2 in cm1
995! REAL, PRIVATE :: cv = cp - rd
996 real, private, parameter :: cv = 717.0 ! specific heat at constant volume - air
997 REAL, PRIVATE, parameter :: cvv = 1408.5
998 ! GHB
999
1000 real, parameter :: bfnu0 = (rnu + 2.0)/(rnu + 1.0)
1001 real :: ventr, ventrn, ventc, c1sw
1002
1003
1004 real :: cckm,ccne,ccnefac,cnexp,ccne0
1005
1006 integer, public :: na = 9
1007 integer :: nxtra = 1
1008 real gf4p5, gf4ds, gf4br
1009 real gsnow1, gsnow53, gsnow73
1010 real gfcinu1, gfcinu1p47, gfcinu2p47
1011 real gfcinu1p22,gfcinu2p22
1012 real gfcinu1p18,gfcinu2p18
1013
1014 real :: cwchtmp0 = 1.0
1015 real :: cwchltmp0 = 1.0
1016
1017 real :: esctot = 1.0e-13
1018
1019 integer iexy(lc:lqmx,lc:lqmx)
1020 integer :: ieswi = 1, ieswc = 1, ieswr = 0
1021 integer :: iehlsw = 1, iehli = 1, iehlc = 1, iehlr = 0
1022 integer :: iehwsw = 1, iehwi = 1, iehwc = 1, iehwr = 0
1023
1024 logical, parameter :: do_satadj_for_wrfchem = .true.
1025
1026 integer, private :: lcn_nu = 0 ! 27 ! need to check no conflict with other variables
1027 integer, private :: lcn_ac = 0 ! 28
1028 integer, private :: lcn_co = 0 ! 29
1029 integer, private :: lcinp = 0 ! 30
1030 integer, private :: ac_opt = 0 ! option flag for: (1 and 2 currently for NUWRF only)
1031 ! 0 : normal NSSL CCN physics
1032 ! 1 : accumulation mode CN following Fridland et al. (2012, 2017),
1033 ! where CCN number is sum of unactivated CCN and droplet concentrations
1034 ! 2 : As for 1 but have three modes (but does not partition activated CCN)
1035 ! 11: As for 1 but track activated CCN as a separate category (CN category advects only)
1036 ! 22: As for 11 but 3 modes, each with its own activation tracer
1037 real, private :: ac_wthresh = 10.0 ! for W < ac_wthresh, use max of sswater and diagnosed SS; otherwise use sswater
1038 logical, private :: nuaccoinp = .false.
1039
1040! T.Iguchi Y2021 Update
1041! logical :: ac_only = .true. ! flag for considering ac_mode of CN only, or all nu,ac,co modes (still under construction)
1042
1043 logical, private :: arg_para = .true. ! flag for Abdul-Razzak_and_Ghan parameterization works similarly to flag_qndrop, and neglects irenuc, ccna(mgs), and cnuc(mgs)
1044 real, private :: nu_pmr = 7.5 * 1.e-3 * 1.e-6 ! aerosol radius (meter); these parameter values follow Cheng et al. (2007QJ)
1045 real, private :: nu_pgw = 0.53 ! Unlike original Abdul-Razzak_and_Ghan, this value is used without log (Cheng et al. 2007QJ)
1046 real, private :: nu_kappa = 0.07 ! ammonium sulfate as CCN (Petters and Kreidenweis, 2007ACP)
1047 real, private :: ac_pmr = 3.8 * 1.e-2 * 1.e-6 ! aerosol radius (meter)
1048 real, private :: ac_pgw = 0.69
1049 real, private :: ac_kappa = 0.61 ! ammonium sulfate as CCN (Petters and Kreidenweis, 2007ACP)
1050 real, private :: co_pmr = 0.51 * 1.e-6 ! aerosol radius (meter)
1051 real, private :: co_pgw = 0.77
1052 real, private :: co_kappa = 0.61 ! ammonium sulfate as CCN (Petters and Kreidenweis, 2007ACP)
1053
1054 real, parameter :: cn_minlimit = 1.e3 ! 1.e3 m-3 = 0.001 cm-3
1055
1056 logical :: dm15_para = .false. ! flag for DeMott et al. (2015) parameterization for heterogenous freezing, regardless of "ibfc"
1057
1058! Note to users: Many of these options are for development and not guaranteed to perform well.
1059! Some may not be functional depending on the version of the code.
1060! Some may be useful for ensemble physics diversity. Feel free to contact Ted Mansell if you have questions
1061! in that regard.
1062 namelist /nssl_mp_params/ &
1063! nuwrf 3-mode params
1064 ac_opt,arg_para, &
1065 ac_kappa, ac_pmr, ac_pgw, &
1066 nu_kappa, nu_pmr, nu_pgw, &
1067 co_kappa, co_pmr, co_pgw, &
1068! ---
1069 ndebug, ncdebug,&
1070 iusewetgraupel, &
1071 iusewethail, &
1072 iusewetsnow, &
1073 idbzci, &
1074 vtmaxsed, &
1075 itfall,iscfall, &
1076 infall,irfall,isfall,iifall, &
1077 rssflg, &
1078 sssflg, &
1079 hssflg, &
1080 hlssflg, &
1081 irainbreak, rainbreakfac, &
1082 irimdenopt,rimdenvwgt, &
1083 rimc1, rimc2, rimc3, rimc4, &
1084 idiagnosecnu, &
1085 icnuclimit, &
1086 irenuc, ccn, &
1087 restoreccn, ccntimeconst, cck, &
1088 decayufccn, ufccntimeconst, &
1089 switchccn, old_cccn, &
1090 ciintmx, &
1091 itype1, itype2, &
1092 icenucopt, in_freeze_rain_first, &
1093 naer, &
1094 icfn, &
1095 ibfc, iacr, icracr, &
1096 icracrthresh, &
1097 cwfrz2snowfrac, cwfrz2snowratio, &
1098 ibfr, &
1099 ibiggopt, &
1100 ibiggsmallrain, &
1101 ifrzg,ifiacrg, &
1102 ifrzs,ffrzs, &
1103 iacrsize, &
1104 cimas0, cimas1, cfnfac, &
1105 splintermass, &
1106 ewfac, &
1107 eii0, eii1, &
1108 eri0, esi0, &
1109 eri_cimin, &
1110 eii0hl, eii1hl, &
1111 ehs0, ehs1, &
1112 ess0, ess1, iessopt, &
1113 esstem1,esstem2, &
1114 ircnw, qminrncw,& ! single-moment only
1115 iglcnvi, &
1116 iglcnvs, &
1117 alphahacx, &
1118 fconv, &
1119 eqtot, &
1120 imeyers5, &
1121 iehw, &
1122 ierw, &
1123 iehr0c,iehlr0c, &
1124 alphai, &
1125 alphar, &
1126 alphas, & ! note that alphah and alphahl come through physics namelist
1127 cnu, &
1128 iscni,fscni, &
1129 dfrz, &
1130 dmlt, &
1131 rainfallfac, &
1132 icefallfac, &
1133 snowfallfac, &
1134 graupelfallfac, &
1135 hailfallfac, &
1136 icefallopt, &
1137 icdx,icdxhl, &
1138 axh,bxh,axf,bxf,axhl,bxhl, &
1139 cdhmin, cdhmax, &
1140 cdhdnmin, cdhdnmax, &
1141 cdhlmin, cdhlmax, &
1142 cdhldnmin, cdhldnmax, &
1143 ihmlt, &
1144 ehimin, &
1145 ehimax, &
1146 ehsmax, &
1147 ecollmx, &
1148 eiw0, esw0, &
1149 ehw0, ehlw0, &
1150 ehr0, ehlr0, &
1151 erw0, &
1152 exwmindiam, &
1153 nsplinter, &
1154 lawson_splinter_fac, &
1155 iqcinit, &
1156 ssmxinit, &
1157 xvdmx, &
1158 dhmn, dhmx, dhlmx, &
1159 fwms,fwmh,fwmhl, &
1160 ifwmhopt, &
1161 ihxw2rain, &
1162 fwmlarge, &
1163 ifwmfall, &
1164 iturbenhance, &
1165 qsdenmod,qhdenmod, &
1166 qsvtmod, &
1167 alphamin,alphamax, &
1168 isnwfrac, &
1169 rescale_low_alpha, &
1170 rescale_low_alphar, &
1171 rescale_low_alphah, &
1172 rescale_low_alphahl, &
1173 rescale_high_alpha, &
1174 ihlcnh, hldia1,iusedw, dwehwmin, dwmin, dwmax, dwtempmin, dg0thresh, incwet, &
1175 wetgrthtoffset, hailcnvtoffset, &
1176 icvhl2h, hldnmn,hdnmn, &
1177 hlcnhdia, hlcnhqmin, &
1178 isedonly, &
1179 iresetmoments, &
1180 cxmin, zxmin, &
1181 imurain, &
1182 iferwisventr, &
1183 izwisventr, &
1184 qhdpvdn, &
1185 qhacidn, &
1186 sheddiam,sheddiamlg, &
1187 sheddiam0, &
1188 mltdiam1,mltdiam2,mltdiam3,mltdiam4,mltdiam05, &
1189 imaxdiaopt, &
1190 ithompsoncnoh, &
1191 cnohmn, &
1192 ivhmltsoak, &
1193 ioldlimiter, &
1194 isnowfall, &
1195 isnowdens, &
1196 ibiggsnow, &
1197 ixtaltype, &
1198 evapfac, &
1199 depfac, &
1200 dmrauto,irescalerainopt, dmropt,dmhlopt, &
1201 rescale_tempthresh, rescale_wthresh, &
1202 ibinhmlr,ibinhlmlr,imltshddmr, binmlrmxdia, binmlrzrrfac,ibinnum, &
1203 iqhacrmlr, iqhlacrmlr, &
1204 snowmeltdia, &
1205 delta_alphamlr, &
1206 iqvsopt, &
1207 maxsupersat, &
1208 do_accurate_sedimentation, interval_sedi_vt
1209! #####################################################################
1210! #####################################################################
1211
1212 CONTAINS
1213
1214! #####################################################################
1215! #####################################################################
1216
1217
1220 REAL function fqvs(t)
1221 implicit none
1222 real :: t
1223 fqvs = exp(caw*(t-273.15)/(t-cbw))
1224 END FUNCTION fqvs
1225
1228 REAL function fqis(t)
1229 implicit none
1230 real :: t
1231 fqis = exp(cai*(t-273.15)/(t-cbi))
1232 END FUNCTION fqis
1233
1234
1235!==========================================================================================!
1236
1237
1238
1239! #####################################################################
1240! #####################################################################
1241
1242
1246 con_g, con_rd, con_cp, con_rv, con_t0c, con_cliq, con_csol, con_eps )
1247
1248 implicit none
1249 real, intent(in) :: con_g, con_rd, con_cp, con_rv, &
1250 con_t0c, con_cliq, con_csol, con_eps
1251
1252 gr = con_g
1253 tfr = con_t0c
1254 cp = con_cp
1255 rd = con_rd
1256 rw = con_rv
1257 rdorv = con_eps
1258 cpl = con_cliq ! 4190.0
1259 cpigb = con_csol ! 2106.0
1260 cpi = 1./cp
1261 cap = rd/cp
1262 tfrcbw = tfr - cbw
1263 tfrcbi = tfr - cbi
1264 rovcp = rd/cp
1265
1266
1267
1268 RETURN
1269 END SUBROUTINE nssl_2mom_init_const
1270
1271
1272! #####################################################################
1273! #####################################################################
1276 SUBROUTINE nssl_2mom_init( &
1277 & ims,ime, jms,jme, kms,kme, nssl_params, ipctmp, mixphase,ihvol,idoniconlytmp, &
1278 & namelist_filename, internal_nml, &
1279 & nssl_graupelfallfac, &
1280 & nssl_hailfallfac, &
1281 & nssl_ehw0, &
1282 & nssl_ehlw0, &
1283 & nssl_icdx, &
1284 & nssl_icdxhl, &
1285 & nssl_icefallfac, &
1286 & nssl_snowfallfac, &
1287 & nssl_cccn, &
1288 & nssl_ufccn, &
1289 & nssl_alphah, &
1290 & nssl_alphahl, &
1291 & nssl_alphar, &
1292 & nssl_density_on, nssl_hail_on, nssl_ccn_on, nssl_icecrystals_on, ccn_is_ccna, &
1293 & nssl_ccn_opt, &
1294 & errmsg, errflg, &
1295 & infileunit, &
1296 & myrank, mpiroot &
1297 )
1298
1299 implicit none
1300
1301 real, intent(in), optional :: &
1302 & nssl_graupelfallfac, &
1303 & nssl_hailfallfac, &
1304 & nssl_ehw0, &
1305 & nssl_ehlw0, &
1306 & nssl_icefallfac, &
1307 & nssl_snowfallfac, &
1308 & nssl_cccn, &
1309 & nssl_alphah, &
1310 & nssl_alphahl, &
1311 & nssl_alphar
1312 integer, intent(in), optional :: &
1313 & nssl_icdx, &
1314 & nssl_icdxhl, myrank, mpiroot, &
1315 & nssl_ufccn, &
1316 & nssl_ccn_opt
1317 logical, intent(in), optional :: nssl_density_on, nssl_ccn_on, nssl_hail_on, nssl_icecrystals_on
1318 integer, intent(inout), optional :: ccn_is_ccna
1319
1320 integer, intent(in),optional :: infileunit
1321
1322 integer,parameter::strsize=64
1323 character(len=*), intent(in), optional :: internal_nml(:)
1324 character(len=strsize), intent(in), optional :: namelist_filename
1325 character(len=strsize) :: namelist_inputfile
1326
1327 ! CCPP error handling
1328 character(len=*), intent( out) :: errmsg
1329 integer, intent( out) :: errflg
1330 integer, intent(in), optional :: ims,ime, jms,jme, kms,kme
1331
1332 real, intent(in), dimension(20), optional :: nssl_params
1333
1334
1335
1336 integer, intent(in) :: ipctmp,mixphase
1337 integer, optional, intent(in) :: ihvol
1338 logical, optional, intent(in) :: idoniconlytmp
1339
1340 integer :: igvol_local = 1
1341 logical :: wrote_namelist = .false.
1342 logical :: wrf_dm_on_monitor
1343 integer :: hail_on = -1, density_on = -1, icecrystals_on = 1
1344 integer :: ccn_on = -1
1345
1346 double precision :: arg,cwch
1347 real :: temq
1348 integer :: igam
1349 integer :: i,il,j,l
1350 integer :: ltmp
1351 integer :: isub
1352 real :: bxh1,bxhl1
1353
1354 real :: alp,ratio
1355 double precision :: x,y,y2,y7
1356 logical :: turn_on_ccna, turn_on_cina
1357 integer :: iufccn = 0
1358 integer :: istat
1359
1360 real :: alpjj, alpii, xnuii, xnujj
1361 integer :: ii, jj
1362
1363
1364 errmsg = ''
1365 errflg = 0
1366 turn_on_ccna = .false.
1367 turn_on_cina = .false.
1368
1369! IF ( present( igvol ) ) THEN
1370! igvol_local = igvol
1371! ENDIF
1372
1373 IF ( present( nssl_hail_on ) ) THEN
1374 IF ( nssl_hail_on ) THEN
1375 hail_on = 1
1376 ELSE
1377 hail_on = 0
1378 ENDIF
1379 ENDIF
1380
1381 IF ( present( nssl_density_on ) ) THEN
1382 IF ( nssl_density_on ) THEN
1383 density_on = 1
1384 ELSE
1385 density_on = 0
1386 ENDIF
1387 ENDIF
1388
1389 IF ( present( nssl_icecrystals_on ) ) THEN
1390 IF ( nssl_icecrystals_on ) THEN
1391 icecrystals_on = 1
1392 ELSE
1393 icecrystals_on = 0
1394 ! renucfrac = 1.0 ! why was this set to 1?
1395 ffrzs = 1.0
1396 ENDIF
1397 ENDIF
1398
1399
1400!
1401! set some global values from namelist input
1402!
1403
1404 IF ( present( nssl_params ) ) THEN
1405 ccn = abs( nssl_params(1) )
1406 alphah = nssl_params(2)
1407 alphahl = nssl_params(3)
1408 cnoh = nssl_params(4)
1409 cnohl = nssl_params(5)
1410 cnor = nssl_params(6)
1411 cnos = nssl_params(7)
1412 rho_qh = nssl_params(8)
1413 rho_qhl = nssl_params(9)
1414 rho_qs = nssl_params(10)
1415 IF ( nint(nssl_params(13)) == 1 ) THEN
1416 ! hack to switch CCN field to CCNA (activated ccn)
1417! invertccn = .true.
1418 turn_on_ccna = .true.
1419 irenuc = 5
1420 ENDIF
1421 ccnuf = abs( nssl_params(14) )
1422 IF ( present(nssl_ufccn) ) iufccn = nssl_ufccn
1423
1424 ENDIF
1425 alphar = nssl_params(15)
1426! ipelec = Nint(nssl_params(11))
1427! isaund = Nint(nssl_params(12))
1428
1429
1430 IF ( present(nssl_graupelfallfac) ) graupelfallfac = nssl_graupelfallfac
1431 IF ( present(nssl_hailfallfac) ) hailfallfac = nssl_hailfallfac
1432 IF ( present(nssl_ehw0) ) THEN
1433 IF ( nssl_ehw0 > 0.0 ) ehw0 = nssl_ehw0
1434 ENDIF
1435 IF ( present(nssl_ehlw0) ) THEN
1436 IF ( nssl_ehlw0 > 0.0 ) ehlw0 = nssl_ehlw0
1437 ENDIF
1438 IF ( present(nssl_icdx) ) icdx = nssl_icdx
1439 IF ( present(nssl_icdxhl) ) icdxhl = nssl_icdxhl
1440 IF ( present(nssl_icefallfac) ) icefallfac = nssl_icefallfac
1441 IF ( present(nssl_snowfallfac) ) snowfallfac = nssl_snowfallfac
1442 IF ( present(nssl_cccn) ) THEN
1443 IF (nssl_cccn > 1 ) ccn = nssl_cccn
1444 ENDIF
1445 IF ( present(nssl_alphah) ) THEN
1446 IF ( nssl_alphah > -1. ) alphah = nssl_alphah
1447 ENDIF
1448 IF ( present(nssl_alphahl) ) THEN
1449 IF ( nssl_alphahl > -1. ) alphahl = nssl_alphahl
1450 ENDIF
1451 IF ( present(nssl_alphar) ) THEN
1452 IF ( nssl_alphar > -1.0 ) alphar = nssl_alphar
1453 ENDIF
1454
1455
1456 ipconc = ipctmp
1457
1458
1459 IF ( ihlcnh <= 0 ) THEN
1460 IF ( ipconc < 5 ) THEN
1461 ihlcnh = 0
1462 ELSEIF ( ipconc == 5 ) THEN
1463 ihlcnh = 3
1464 ELSEIF ( ipconc >= 6 ) THEN
1465 ihlcnh = 3
1466 ENDIF
1467 ENDIF
1468
1469 ! turn on active rain breakup by default for 3-moment rain since it has no implicit breakup from sedimentation
1470 ! Check this after namelist read so that user can set irainbreak=0 to turn off
1471 IF ( irainbreak == -1 ) THEN
1472 IF ( ipconc >= 6 ) THEN
1473 irainbreak = 2
1474 ELSE
1475 irainbreak = 0
1476 ENDIF
1477 ENDIF
1478
1479#ifdef INTERNAL_FILE_NML
1480 read (internal_nml, nml = nssl_mp_params, iostat=istat)
1481#else
1482
1483 namelist_inputfile = 'namelist.input' ! default for WRF/cm1
1484 IF ( present( namelist_filename ) ) THEN
1485 namelist_inputfile = namelist_filename
1486 ELSE
1487 namelist_inputfile = 'input.nml'
1488 ENDIF
1489
1490 open(15,file=trim(namelist_inputfile),status='old',form='formatted',action='read')
1491 rewind(15)
1492 read(15,nml=nssl_mp_params,iostat=istat)
1493 close(15)
1494#endif
1495 IF ( .true. ) THEN ! set to true to enable internal namelist read
1496 IF ( present ( myrank ) .and. present ( mpiroot ) ) THEN
1497 IF ( myrank == mpiroot ) THEN
1498 IF ( istat /= 0 ) THEN
1499 write(0,*) 'NSSL_2MOM_INIT: PROBLEM WITH NSSL_MP_PARAMS namelist: not found or bad token'
1500 ENDIF
1501
1502! write(0,*) 'iusewetsnow = ',iusewetsnow
1503
1504 open(15,file='nssl_mp_params.out',status='unknown',form='formatted')
1505 write(15,nml=nssl_mp_params)
1506 close(15)
1507 ENDIF
1508 ENDIF
1509 ENDIF
1510
1511 IF ( iufccn > 0 ) THEN ! make sure to use option that uses UF ccn
1512 irenuc = 7
1513 IF ( ccnuf <= 0.0 ) decayufccn = .true. ! assume surface emission and need decay
1514 IF ( i_uf_or_ccn > 0 ) THEN
1515 ufbackground = 0.0
1516 ccntimeconst = ufccntimeconst
1517 ENDIF
1518 ENDIF
1519
1520 IF ( present( nssl_ccn_on ) ) THEN
1521 IF ( nssl_ccn_on ) THEN
1522 ccn_on = 1
1523 IF ( present( nssl_ccn_opt ) ) THEN
1524 IF ( nssl_ccn_opt > 10 ) ac_opt = 22
1525 ENDIF
1526 ELSE
1527 ccn_on = 0
1528 irenuc = 2
1529 ENDIF
1530 ENDIF
1531
1532 IF ( irenuc >= 5 ) THEN
1533 turn_on_ccna = .true.
1534 IF ( present( nssl_ccn_on ) ) THEN
1535 IF ( .not. nssl_ccn_on ) THEN
1536 errmsg = 'NSSL_MP Error: Must have nssl_ccn_on=1/true for irenuc >= 5!'
1537 errflg = 1
1538 return
1539 ENDIF
1540 ENDIF
1541 ENDIF
1542
1543 IF ( present( ccn_is_ccna ) .and. ccn_on == 1 ) THEN
1544 IF ( ccn_is_ccna > 0 ) THEN
1545 turn_on_ccna = .true.
1546 ELSE
1547 IF ( irenuc >= 5 ) THEN
1548 ccn_is_ccna = 1
1549 ENDIF
1550 ENDIF
1551 ENDIF
1552
1553 cwccn = ccn
1554
1555 lhab = 8
1556 lhl = 8
1557 IF ( icespheres >= 1 ) THEN
1558 lhab = lhab + 1
1559 lis = li + 1
1560 ls = ls + 1
1561 lh = lh + 1
1562 lhl = lhl + 1
1563 ENDIF
1564 IF ( hail_on == -1 ) THEN ! hail_on is not set
1565 hail_on = 1
1566 IF ( ihvol <= -1 .or. ihvol == 2 ) THEN
1567 IF ( ihvol == -1 .or. ihvol == -2 ) THEN
1568 lhab = lhab - 1 ! turns off hail
1569 lhl = 0
1570 hail_on = 0
1571 ! past me thought it would be a good idea to change graupel factors when hail is off....
1572 ! ehw0 = 0.75
1573 ! iehw = 2
1574 ! dfrz = Max( dfrz, 0.5e-3 )
1575 ENDIF
1576 IF ( ihvol == -2 .or. ihvol == 2 .or. icecrystals_on == 0 ) THEN ! ice crystals are turned off
1577 ! a value of 2? means to turn off ice crystals but turn on hail
1578 ! renucfrac = 1.0 ! why?
1579 ffrzs = 1.0
1580 ! idoci = 0 ! try this later
1581 ENDIF
1582 ENDIF
1583
1584 ELSE ! hail_on is set
1585 IF ( hail_on == 0 ) THEN
1586 lhab = lhab - 1 ! turns off hail
1587 lhl = 0
1588 ELSE
1589 ! assume default that hail is on
1590 ENDIF
1591 ENDIF
1592
1593 IF ( density_on == -1 ) THEN ! density flag not set, so default is to predict it
1594 density_on = 1
1595 ENDIF
1596
1597
1598 IF ( iresetmoments == 0 ) iresetmoments = 1 ! lhl
1599! write(0,*) 'wrf_init: lhab,lhl,hail_on,density_on = ',lhab,lhl,hail_on,density_on
1600
1601! IF ( ipelec > 0 ) idonic = .true.
1602
1603!
1604! Build lookup table for saturation mixing ratio (Soong and Ogura 73)
1605!
1606
1607 do l = 1,nqsat
1608 temq = 163.15 + (l-1)*fqsat
1609 IF ( iqvsopt == 0 ) THEN
1610 tabqvs(l) = exp(caw*(temq-273.15)/(temq-cbw))
1611 dtabqvs(l) = ((-caw*(-273.15 + temq))/(temq - cbw)**2 + &
1612 & caw/(temq - cbw))*tabqvs(l)
1613 ELSE
1614 tabqvs(l) = exp(cawbolton*(temq-273.15)/(temq-cbwbolton))
1615 dtabqvs(l) = ((-cawbolton*(-273.15 + temq))/(temq - cbwbolton)**2 + &
1616 & cawbolton/(temq - cbwbolton))*tabqvs(l)
1617 ENDIF
1618 tabqis(l) = exp(cai*(temq-273.15)/(temq-cbi))
1619 dtabqis(l) = ((-cai*(-273.15 + temq))/(temq - cbi)**2 + &
1620 & cai/(temq - cbi))*tabqis(l)
1621
1622 end do
1623
1624 bx(lr) = 0.85
1625 ax(lr) = 1647.81
1626 fx(lr) = 135.477
1627
1628
1629 IF ( icdx == 6 ) THEN
1630 bx(lh) = 0.6 ! Milbrandt and Morrison (2013) for density of 550.
1631 ax(lh) = 157.71
1632! ELSEIF ( icdx == 1 ) THEN
1633! bx(lh) = bxh
1634! ax(lh) = axh
1635 ELSEIF ( icdx > 1 ) THEN
1636 bx(lh) = 0.5
1637 ax(lh) = 75.7149
1638 ELSEIF ( icdx == 0 ) THEN
1639 bx(lh) = 0.37 ! 0.6 ! Ferrier 1994 graupel
1640 ax(lh) = 19.3
1641 ELSE ! icdx < 0
1642! ax(lh) = 206.984 ! Ferrier 1994 hail/frozen drops
1643! bx(lh) = 0.6384
1644 bx(lh) = bxh
1645 ax(lh) = axh
1646 ENDIF
1647
1648! bx(lh) = 0.6
1649
1650 IF ( lhl .gt. 1 ) THEN
1651 IF ( icdxhl == 6 ) THEN
1652 bx(lhl) = 0.593 ! Milbrandt and Morrison (2013) for density of 750.
1653 ax(lhl) = 179.36
1654 ELSEIF (icdxhl == 0 ) THEN
1655 ax(lhl) = 206.984 ! Ferrier 1994
1656 bx(lhl) = 0.6384
1657 ELSEIF (icdxhl > 0 ) THEN
1658 bx(lhl) = 0.5
1659 ax(lhl) = 75.7149
1660 ELSE
1661 bx(lhl) = bxhl
1662 ax(lhl) = axhl
1663 ENDIF
1664 ENDIF
1665
1666! fill in the complete gamma function lookup table
1667 gmoi(0) = 1.d32
1668 do igam = 1,ngm0
1669 arg = dgam*igam
1670 gmoi(igam) = gamma_dp(arg)
1671 end do
1672
1673 ! build lookup table to compute the number and mass fractions of particles
1674 ! (mu=1) greater than a given diameter. Used for qiacr and ciacr
1675 ! Uses incomplete gamma functions
1676 ! The terms with bxh or bxhl will be off if the actual bxh or bxhl is different from the base value (icdx=6 option)
1677
1678 bxh1 = bx(lh)
1679 bxhl1 = bx(max(lh,lhl))
1680
1681! DO j = 0,nqiacralpha
1682 DO j = ialpstart,nqiacralpha
1683 alp = float(j)*dqiacralpha
1684 y = gamma_dpr(1.+alp)
1685 y2 = gamma_dpr(2.+alp)
1686 DO i = 0,nqiacrratio
1687 ratio = float(i)*dqiacrratio
1688 x = gamxinfdp( 1.+alp, ratio )
1689! write(0,*) 'i, x/y = ',i, x/y
1690 ciacrratio(i,j) = x/y
1691
1692 ! graupel (.,.,.,1)
1693 gamxinflu(i,j,1,1) = x/y
1694 gamxinflu(i,j,2,1) = gamxinfdp( 2.0+alp, ratio )/y
1695 gamxinflu(i,j,3,1) = gamxinfdp( 2.5+alp+0.5*bxh1, ratio )/y
1696 gamxinflu(i,j,5,1) = (gamma_dpr(5.0+alp) - gamxinfdp( 5.0+alp, ratio ))/y
1697 gamxinflu(i,j,6,1) = (gamma_dpr(5.5+alp+0.5*bxh1) - gamxinfdp( 5.5+alp+0.5*bxh1, ratio ))/y
1698 gamxinflu(i,j,9,1) = gamxinfdp( 1.0+alp, ratio )/y
1699 gamxinflu(i,j,10,1)= gamxinfdp( 4.0+alp, ratio )/y
1700
1701 gamxinflu(i,j,12,1) = gamxinfdp( 2.0+alp, ratio )/y2
1702
1703 ! hail (.,.,.,2)
1704 gamxinflu(i,j,1,2) = gamxinflu(i,j,1,1)
1705 gamxinflu(i,j,2,2) = gamxinflu(i,j,2,1)
1706 gamxinflu(i,j,3,2) = gamxinfdp( 2.5+alp+0.5*bxhl1, ratio )/y
1707 gamxinflu(i,j,5,2) = gamxinflu(i,j,5,1)
1708 gamxinflu(i,j,6,2) = (gamma_dpr(5.5+alp+0.5*bxhl1) - gamxinfdp( 5.5+alp+0.5*bxhl1, ratio ))/y
1709 gamxinflu(i,j,9,2) = gamxinflu(i,j,9,1)
1710 gamxinflu(i,j,10,2)= gamxinflu(i,j,10,1)
1711
1712 IF ( alp > 1.1 ) THEN
1713! gamxinflu(i,j,7,1) = gamxinfdp( alp - 1., ratio )/y
1714 gamxinflu(i,j,7,1) = (gamma_dpr(alp - 1.) - gamxinfdp( alp - 1., ratio ))/y
1715! gamxinflu(i,j,8,1) = gamxinfdp( alp - 0.5 + 0.5*bxh, ratio )/y
1716 gamxinflu(i,j,8,1) = (gamma_dpr(alp - 0.5 + 0.5*bxh1) - gamxinfdp( alp - 0.5 + 0.5*bxh1, ratio ))/y
1717! gamxinflu(i,j,8,2) = gamxinfdp( alp - 0.5 + 0.5*bxhl1, ratio )/y
1718 gamxinflu(i,j,8,2) = (gamma_dpr(alp - 0.5 + 0.5*bxhl1) - gamxinfdp( alp - 0.5 + 0.5*bxhl1, ratio ))/y
1719 ELSE
1720! gamxinflu(i,j,7,1) = gamxinfdp( .1, ratio )/y
1721 gamxinflu(i,j,7,1) = (gamma_dpr(0.1) - gamxinfdp( 0.1, ratio ) )/y
1722! gamxinflu(i,j,8,1) = gamxinfdp( 1.1 - 0.5 + 0.5*bxh1, ratio )/y
1723! gamxinflu(i,j,8,2) = gamxinfdp( 1.1 - 0.5 + 0.5*bxhl1, ratio )/y
1724 gamxinflu(i,j,8,1) = (gamma_dpr(1.1 - 0.5 + 0.5*bxh1) - gamxinfdp( 1.1 - 0.5 + 0.5*bxh1, ratio ) )/y
1725 gamxinflu(i,j,8,2) = (gamma_dpr(1.1 - 0.5 + 0.5*bxhl1) - gamxinfdp( 1.1 - 0.5 + 0.5*bxhl1, ratio ) )/y
1726 ENDIF
1727
1728 gamxinflu(i,j,7,2) = gamxinflu(i,j,7,1)
1729
1730 ENDDO
1731 ENDDO
1732 ciacrratio(0,:) = 1.0
1733
1734 DO j = ialpstart,nqiacralpha
1735 alp = float(j)*dqiacralpha
1736 y = gamma_sp(4.+alp)
1737 y7 = gamma_sp(7.+alp)
1738 DO i = 0,nqiacrratio
1739 ratio = float(i)*dqiacrratio
1740
1741 ! mass fraction
1742 x = gamxinfdp( 4.+alp, ratio )
1743! write(0,*) 'i, x/y = ',i, x/y
1744 qiacrratio(i,j) = x/y
1745 gamxinflu(i,j,4,1) = x/y
1746 gamxinflu(i,j,4,2) = x/y
1747
1748 ! reflectivity fraction
1749 x = gamxinfdp( 7.+alp, ratio )
1750 ziacrratio(i,j) = x/y7
1751 gamxinflu(i,j,11,1) = x/y7
1752 gamxinflu(i,j,11,2) = x/y7
1753
1754 ENDDO
1755 ENDDO
1756 qiacrratio(0,:) = 1.0
1757
1758
1759 lccn = 0
1760 lccnuf = 0
1761 lccna = 0
1762 lccnaco = 0
1763 lccnanu = 0
1764 lnc = 0
1765 lnr = 0
1766 lni = 0
1767 lnis = 0
1768 lns = 0
1769 lnh = 0
1770 lnhl = 0
1771 lvh = 0
1772 lvhl = 0
1773 lzr = 0
1774 lzh = 0
1775 lzhl = 0
1776 lsw = 0
1777 lhw = 0
1778 lhlw = 0
1779
1780 denscale(:) = 0
1781
1782! lccn = 9
1783
1784
1785 IF ( ipconc == 0 ) THEN
1786 IF ( hail_on == 1 ) THEN ! turn on graupel density for 1-moment scheme
1787 IF ( density_on >= 1 ) THEN ! turn on graupel density for 1-moment scheme
1788 lvh = 9
1789 ltmp = 9
1790 denscale(lvh) = 1
1791 ELSE
1792 ltmp = lhab
1793 lvh = 0
1794 lvhl = 0
1795 ENDIF
1796 ELSE ! no hail, 'LFO' scheme
1797 ltmp = lhab
1798 lhl = 0
1799 ENDIF
1800 ELSEIF ( ipconc == 5 ) THEN
1801 ltmp = lhab
1802 IF ( iufccn > 0 ) THEN
1803 ltmp = ltmp+1
1804 lccnuf = ltmp
1805 denscale(lccnuf) = 1
1806 ENDIF
1807 lccn= ltmp+1 ! 9
1808 lnc = ltmp+2 ! 10
1809 lnr = ltmp+3 ! 11
1810 lni = ltmp+4 !12
1811 lns = ltmp+5 !13
1812 lnh = ltmp+6 !14
1813 ltmp = lnh
1814 IF ( hail_on == 1 ) THEN
1815 ltmp = ltmp + 1
1816 lnhl = ltmp ! lhab+7 ! 15
1817 ENDIF
1818 IF ( density_on >= 1 ) THEN
1819 ltmp = ltmp + 1
1820 lvh = ltmp ! lhab+8 + isub ! 16 + isub ! isub adjusts to 15 if hail is off
1821! ltmp = lvh
1822 ENDIF
1823 denscale(lccn:ltmp) = 1
1824 IF ( density_on == 1 .and. hail_on == 1 ) THEN
1825 ltmp = ltmp + 1
1826 lvhl = ltmp
1827! ltmp = lvhl
1828 denscale(lvhl) = 1
1829 ENDIF
1830 IF ( mixedphase ) THEN
1831 ltmp = ltmp + 1
1832 lsw = ltmp
1833 ltmp = ltmp + 1
1834 lhw = ltmp
1835 IF ( lhl > 1 ) THEN
1836 ltmp = ltmp + 1
1837 lhlw = ltmp
1838 ENDIF
1839! ltmp = lhlw
1840 ENDIF
1841 ELSEIF ( ipconc >= 6 ) THEN
1842 ltmp = lhab
1843 IF ( iufccn > 0 ) THEN
1844 ltmp = ltmp+1
1845 lccnuf = ltmp
1846 denscale(lccnuf) = 1
1847 ENDIF
1848
1849 lccn= ltmp+1 ! 9
1850 lnc = ltmp+2 ! 10
1851 lnr = ltmp+3 ! 11
1852 lni = ltmp+4 !12
1853 lns = ltmp+5 !13
1854 lnh = ltmp+6 !14
1855 ltmp = lnh
1856 IF ( lhl > 0 ) THEN
1857 ltmp = ltmp + 1
1858 lnhl = ltmp ! lhab+7 ! 15
1859 ENDIF
1860 IF ( density_on == 1 ) THEN
1861 ltmp = ltmp + 1
1862 lvh = ltmp ! lhab+8 + isub ! 16 + isub ! isub adjusts to 15 if hail is off
1863 ENDIF
1864! ltmp = lvh
1865 denscale(lccn:ltmp) = 1
1866 IF ( density_on == 1 .and. hail_on == 1 ) THEN
1867 ltmp = ltmp + 1
1868 lvhl = ltmp
1869! ltmp = lvhl
1870 denscale(lvhl) = 1
1871 ENDIF
1872
1873 IF ( ipconc == 6 ) THEN
1874 ltmp = ltmp + 1
1875 lzh = ltmp
1876 ELSEIF ( ipconc == 7 ) THEN
1877 ltmp = ltmp + 1
1878 lzh = ltmp
1879 ltmp = ltmp + 1
1880 lzr = ltmp
1881 ELSEIF ( ipconc == 8 ) THEN
1882 ltmp = ltmp + 1
1883 lzh = ltmp
1884 ltmp = ltmp + 1
1885 lzr = ltmp
1886 IF ( lhl > 1 ) THEN
1887 ltmp = ltmp + 1
1888 lzhl = ltmp
1889 ENDIF
1890 ! write(0,*) 'ipcon,lzr = ',ipconc,lzr,lzh,lzhl
1891 ENDIF
1892! ltmp = lvh
1893 ! denscale(lccn:lvh) = 1
1894 IF ( mixedphase ) THEN
1895 ltmp = ltmp + 1
1896 lsw = ltmp
1897 ltmp = ltmp + 1
1898 lhw = ltmp
1899 IF ( lhl > 1 ) THEN
1900 ltmp = ltmp + 1
1901 lhlw = ltmp
1902 ENDIF
1903! ltmp = lhlw
1904 ENDIF
1905 ELSE
1906 errmsg = 'nssl_2mom_init: Invalid value of ipctmp'
1907 errflg = 1
1908 RETURN
1909 ENDIF
1910
1911
1912
1913 ! write(0,*) 'wrf_init: lh,lhl,lzh,lzhl = ',lh,lhl,lzh,lzhl
1914 ! write(0,*) 'wrf_init: ipconc = ',ipconc
1915 ! write(0,*) 'wrf_init: irenuc, turn_on_ccna = ',irenuc, turn_on_ccna
1916 IF ( turn_on_ccna ) THEN
1917 ltmp = ltmp + 1
1918 lccna = ltmp
1919 denscale(ltmp) = 1
1920 ENDIF
1921
1922 IF ( turn_on_cina ) THEN
1923 ltmp = ltmp + 1
1924 lcina = ltmp
1925 denscale(ltmp) = 1
1926 ENDIF
1927
1928 IF ( turn_on_cin .or. is_aerosol_aware ) THEN
1929 ltmp = ltmp + 1
1930 lcin = ltmp
1931 denscale(ltmp) = 1
1932!debug write(0,*) 'Setting lcin to ',lcin
1933 ENDIF
1934 na = ltmp
1935
1936 ln(:) = 0
1937 ln(lc) = lnc
1938 ln(lr) = lnr
1939 ln(li) = lni
1940 ln(ls) = lns
1941 ln(lh) = lnh
1942 IF ( lhl .gt. 1 ) ln(lhl) = lnhl
1943
1944 ipc(:) = 0
1945 ipc(lc) = 2
1946 ipc(lr) = 3
1947 ipc(li) = 1
1948 ipc(ls) = 4
1949 ipc(lh) = 5
1950 IF ( lhl .gt. 1 ) ipc(lhl) = 5
1951
1952 ldovol = .false.
1953 lvol(:) = 0
1954 lvol(li) = lvi
1955 lvol(ls) = lvs
1956 lvol(lh) = lvh
1957 IF ( lhl .gt. 1 .and. lvhl .gt. 1 ) lvol(lhl) = lvhl
1958
1959 lne = max(lnh,lnhl)
1960 lne = max(lne,lvh)
1961 lne = max(lne,lvhl)
1962 lne = max(lne,na)
1963
1964 lsc(:) = 0
1965 lsc(lc) = lscw
1966 lsc(lr) = lscr
1967 lsc(li) = lsci
1968 lsc(ls) = lscs
1969 lsc(lh) = lsch
1970 IF ( lhl .gt. 1 ) lsc(lhl) = lschl
1971
1972
1973 DO il = lc,lhab
1974 ldovol = ldovol .or. ( lvol(il) .gt. 1 )
1975 ENDDO
1976
1977! write(0,*) 'nssl_2mom_init: ldovol = ',ldovol
1978
1979 lz(:) = 0
1980 lz(lr) = lzr
1981 lz(li) = lzi
1982 lz(ls) = lzs
1983 lz(lh) = lzh
1984 IF ( lhl .gt. 1 .and. lzhl > 1 ) lz(lhl) = lzhl
1985
1986 lliq(:) = 0
1987 lliq(ls) = lsw
1988 lliq(lh) = lhw
1989 IF ( lhl .gt. 1 ) lliq(lhl) = lhlw
1990 IF ( mixedphase ) THEN
1991! write(0,*) 'lsw,lhw,lhlw = ',lsw,lhw,lhlw
1992 ENDIF
1993
1994
1995
1996 xnu(lc) = cnu
1997 xmu(lc) = 1.
1998
1999 IF ( imurain == 3 ) THEN
2000 xnu(lr) = rnu
2001 xmu(lr) = 1.
2002 ELSEIF ( imurain == 1 ) THEN
2003 xnu(lr) = (alphar - 2.0)/3.0
2004 xmu(lr) = 1./3.
2005 ENDIF
2006
2007 xnu(li) = cinu
2008 xmu(li) = 1.
2009
2010 IF ( lis >= 1 ) THEN
2011 xnu(lis) = 0.0
2012 xmu(lis) = 1.
2013 ENDIF
2014
2015 dnu(lc) = 3.*xnu(lc) + 2. ! alphac
2016 dmu(lc) = 3.*xmu(lc)
2017
2018 dnu(lr) = 3.*xnu(lr) + 2. ! alphar
2019 dmu(lr) = 3.*xmu(lr)
2020
2021 xnu(ls) = snu
2022 xmu(ls) = 1.
2023
2024 dnu(ls) = 3.*xnu(ls) + 2. ! -0.4 ! alphas
2025 dmu(ls) = 3.*xmu(ls)
2026
2027
2028 dnu(lh) = alphah
2029 dmu(lh) = dmuh
2030
2031 xnu(lh) = (dnu(lh) - 2.)/3.
2032 xmu(lh) = dmuh/3.
2033
2034
2035 IF ( imurain == 3 ) THEN ! rain is gamma of volume
2036 rz = ((4. + alphah)*(5. + alphah)*(6. + alphah)*(1. + xnu(lr)))/ &
2037 & ((1 + alphah)*(2 + alphah)*(3 + alphah)*(2. + xnu(lr)))
2038
2039! IF ( ipconc .lt. 5 ) alphahl = alphah
2040
2041 rzhl = ((4. + alphahl)*(5. + alphahl)*(6. + alphahl)*(1. + xnu(lr)))/ &
2042 & ((1. + alphahl)*(2. + alphahl)*(3. + alphahl)*(2. + xnu(lr)))
2043
2044 rzs = 1. ! assume rain and snow are both gamma volume
2045
2046 ELSE ! rain is gamma of diameter
2047
2048 rz = ((4. + alphah)*(5. + alphah)*(6. + alphah)*(1. + alphar)*(2. + alphar)*(3. + alphar))/ &
2049 & ((1 + alphah)*(2 + alphah)*(3 + alphah)*(4. + alphar)*(5. + alphar)*(6. + alphar))
2050
2051 rzhl = ((4. + alphahl)*(5. + alphahl)*(6. + alphahl)*(1. + alphar)*(2. + alphar)*(3. + alphar))/ &
2052 & ((1 + alphahl)*(2 + alphahl)*(3 + alphahl)*(4. + alphar)*(5. + alphar)*(6. + alphar))
2053
2054
2055 rzs = &
2056 & ((1. + alphar)*(2. + alphar)*(3. + alphar)*(2. + xnu(ls)))/ &
2057 & ((4. + alphar)*(5. + alphar)*(6. + alphar)*(1. + xnu(ls)))
2058
2059
2060 ENDIF
2061
2062 IF ( ipconc <= 5 ) THEN
2063 imltshddmr = min(1, imltshddmr)
2064 ibinhmlr = 0
2065 ibinhlmlr = 0
2066 ENDIF
2067
2068 IF ( ipconc > 5 .and. (ibinhmlr == 0 .and. ibinhlmlr == 0 ) ) THEN
2069 imltshddmr = min(1, imltshddmr)
2070 ENDIF
2071
2072! write(0,*) 'rz,rzhl = ', rz,rzhl
2073
2074 IF ( ipconc .lt. 4 ) THEN
2075
2076 dnu(ls) = alphas
2077 dmu(ls) = 1.
2078
2079 xnu(ls) = (dnu(ls) - 2.)/3.
2080 xmu(ls) = 1./3.
2081
2082
2083 ENDIF
2084
2085 IF ( lhl .gt. 1 ) THEN
2086
2087 dnu(lhl) = alphahl
2088 dmu(lhl) = dmuhl
2089
2090 xnu(lhl) = (dnu(lhl) - 2.)/3.
2091 xmu(lhl) = dmuhl/3.
2092
2093 ENDIF
2094
2095 cno(lc) = 1.0e+08
2096 IF ( li .gt. 1 ) cno(li) = 1.0e+08
2097 cno(lr) = cnor
2098 IF ( ls .gt. 1 ) cno(ls) = cnos ! 8.0e+06
2099 IF ( lh .gt. 1 ) cno(lh) = cnoh ! 4.0e+05
2100 IF ( lhl .gt. 1 ) cno(lhl) = cnohl ! 4.0e+05
2101!
2102! density maximums and minimums
2103!
2104 xdnmx(:) = 900.0
2105
2106 xdnmx(lr) = 1000.0
2107 xdnmx(lc) = 1000.0
2108 xdnmx(li) = 917.0
2109 xdnmx(ls) = 300.0
2110 xdnmx(lh) = 900.0
2111 IF ( lhl .gt. 1 ) xdnmx(lhl) = 900.0
2112!
2113 xdnmn(:) = 900.0
2114
2115 xdnmn(lr) = 1000.0
2116 xdnmn(lc) = 1000.0
2117 xdnmn(li) = 100.0
2118 xdnmn(ls) = 100.0
2119 xdnmn(lh) = hdnmn
2120 IF ( lhl .gt. 1 ) xdnmn(lhl) = hldnmn
2121
2122 xdn0(:) = 900.0
2123
2124 xdn0(lc) = 1000.0
2125 xdn0(li) = 900.0
2126 xdn0(lr) = 1000.0
2127 xdn0(ls) = rho_qs ! 100.0
2128 xdn0(lh) = rho_qh ! (0.5)*(xdnmn(lh)+xdnmx(lh))
2129 IF ( lhl .gt. 1 ) xdn0(lhl) = rho_qhl ! 800.0
2130
2131!
2132! Set terminal velocities...
2133! also set drag coefficients
2134!
2135 cdx(lr) = 0.60
2136 cdx(lh) = 0.8 ! 1.0 ! 0.45
2137 cdx(ls) = 2.00
2138 IF ( lhl .gt. 1 ) cdx(lhl) = 0.45
2139
2140 ido(lc) = idocw
2141 ido(lr) = idorw
2142 ido(li) = idoci
2143 ido(ls) = idosw
2144 ido(lh) = idohw
2145 IF ( lhl .gt. 1 ) ido(lhl) = idohl
2146
2147 linfall(:) = infall
2148 linfall(lc) = 0
2149 IF ( irfall .lt. 0 ) irfall = infall
2150 IF ( isfall .lt. 0 ) isfall = infall
2151 IF ( iifall .lt. 0 ) iifall = infall
2152 IF ( lzr > 0 ) irfall = 0
2153 IF ( lzs > 0 ) isfall = 0
2154 IF ( lzh > 0 ) linfall(lh) = 0
2155 IF ( lzhl > 0 .and. lhl > 0 ) linfall(lhl) = 0
2156 IF ( lzr > 0 .and. lf > 0 ) linfall(lf) = 0
2157 linfall(lr) = irfall
2158 linfall(ls) = isfall
2159 linfall(li) = iifall
2160
2161 qccn = ccn/rho00
2162 qccnuf = ccnuf/rho00
2163 IF ( old_cccn > 0.0 ) THEN
2164 old_qccn = old_cccn/rho00
2165 ELSE
2166 old_qccn = qccn
2167 ENDIF
2168! xvcmx = (4./3.)*pi*xcradmx**3
2169
2170! set max rain diameter
2171 IF ( xvdmx .gt. 0.0 ) THEN
2172 xvrmx = 0.523599*(xvdmx)**3
2173 ELSE
2174 xvrmx = xvrmx0
2175 ENDIF
2176
2177 IF ( dhmn <= 0.0 ) THEN
2178 xvhmn = xvhmn0
2179! xvhmn = Min(xvhmn0, 0.523599*(dfrz)**3 )
2180 ELSE
2181 xvhmn = 0.523599*(dhmn)**3
2182! xvhmn = 0.523599*(Min(dhmn,dfrz))**3
2183 ENDIF
2184
2185 IF ( dhmx <= 0.0 ) THEN
2186 xvhmx = xvhmx0
2187 ELSE
2188 xvhmx = 0.523599*(dhmx)**3
2189 ENDIF
2190
2191 IF ( dhlmx <= 0.0 ) THEN
2192 xvhlmx = xvhlmx0
2193 ELSE
2194 xvhlmx = 0.523599*(dhlmx)**3
2195 ENDIF
2196
2197 IF ( ipconc == 5 .and. imorrgdnglimit >= 1 ) THEN
2198 ! convert morrdnglimit to xvhmx equivalent
2199 cwch = ((3. + alphah)*(2. + alphah)*(1.0 + alphah))**(-1./3.)
2200 xvhmx = pi/6.0*(morrdnglimit/cwch)**3
2201 dhmx = morrdnglimit/cwch
2202 ENDIF
2203
2204 IF ( qhdpvdn < 0. ) qhdpvdn = xdnmn(lh)
2205 IF ( qhacidn < 0. ) qhacidn = xdnmn(lh)
2206
2207! load max/min diameters
2208 xvmn(lc) = xvcmn
2209 xvmn(li) = xvimn
2210 xvmn(lr) = xvrmn
2211 xvmn(ls) = xvsmn
2212 xvmn(lh) = xvhmn
2213
2214 xvmx(lc) = xvcmx
2215 xvmx(li) = xvimx
2216 xvmx(lr) = xvrmx
2217 xvmx(ls) = xvsmx
2218 xvmx(lh) = xvhmx
2219
2220 IF ( lhl .gt. 1 ) THEN
2221 xvmn(lhl) = xvhlmn
2222 xvmx(lhl) = xvhlmx
2223 ENDIF
2224
2225!
2226! cloud water constants in mks units
2227!
2228! cwmasn = 4.25e-15 ! radius of 1.0e-6
2229! cwmasn = 5.23e-13 ! minimum mass, defined by radius of 5.0e-6
2230! cwmasn5 = 5.23e-13
2231! cwradn = 5.0e-6 ! minimum radius
2232! cwmasx = 5.25e-10 ! maximum mass, defined by radius of 50.0e-6
2233! mwfac = 6.0**(1./3.)
2234 IF ( ipconc .ge. 2 ) THEN
2235! cwmasn = xvmn(lc)*1000. ! minimum mass, defined by minimum droplet volume
2236! cwradn = 1.0e-6 ! minimum radius
2237! cwmasx = xvmx(lc)*1000. ! maximum mass, defined by maximum droplet volume
2238
2239 ENDIF
2240! rwmasn = xvmn(lr)*1000. ! minimum mass, defined by minimum rain volume
2241! rwmasx = xvmx(lr)*1000. ! maximum mass, defined by maximum rain volume
2242
2243 IF ( lhl < 1 ) ifrzg = 1
2244
2245 ventr = 1.
2246 IF ( imurain == 3 ) THEN
2247! IF ( izwisventr == 1 ) THEN
2248 ventr = gamma_sp(rnu + 4./3.)/((rnu + 1.)**(1./3.)*gamma_sp(rnu + 1.)) ! Ziegler 1985
2249! ELSE
2250 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
2251! ventr = Gamma_sp(rnu + 4./3.)/((rnu + 1.)**(1./3.)*Gamma_sp(rnu + 1.)) ! Ziegler 1985, still use for first term in rwvent
2252! ventr = Gamma_sp(rnu + 4./3.)/Gamma_sp(rnu + 1.)
2253! ENDIF
2254 ELSE ! imurain == 1
2255! IF ( iferwisventr == 1 ) THEN
2256 ventr = gamma_sp(2. + alphar) ! Ferrier 1994
2257! ELSEIF ( iferwisventr == 2 ) THEN
2258 ventrn = gamma_sp(alphar + 2.5 + br/2.)/gamma_sp(alphar + 1.) ! adapted from Wisner et al. 1972
2259! ENDIF
2260 ENDIF
2261 ventc = gamma_sp(cnu + 4./3.)/(cnu + 1.)**(1./3.)/gamma_sp(cnu + 1.)
2262 c1sw = gamma_sp(snu + 4./3.)*(snu + 1.0)**(-1./3.)/gamma_sp(snu + 1.0)
2263
2264 ! set threshold mixing ratios
2265
2266 qxmin(:) = 1.0e-12
2267
2268 qxmin(lc) = 1.e-9
2269 qxmin(lr) = 1.e-7
2270 IF ( li > 1 ) qxmin(li) = 1.e-12
2271 IF ( ls > 1 ) qxmin(ls) = 1.e-7
2272 IF ( lh > 1 ) qxmin(lh) = 1.e-7
2273 IF ( lhl .gt. 1 ) qxmin(lhl) = 1.e-7
2274
2275 IF ( lc .gt. 1 .and. lnc .gt. 1 ) qxmin(lc) = 1.0e-13
2276 IF ( lr .gt. 1 .and. lnr .gt. 1 ) qxmin(lr) = 1.0e-12
2277
2278 IF ( li .gt. 1 .and. lni .gt. 1 ) qxmin(li ) = 1.0e-13
2279 IF ( ls .gt. 1 .and. lns .gt. 1 ) qxmin(ls ) = 1.0e-13
2280 IF ( lh .gt. 1 .and. lnh .gt. 1 ) qxmin(lh ) = 1.0e-12
2281 IF ( lhl.gt. 1 .and. lnhl.gt. 1 ) qxmin(lhl) = 1.0e-12
2282
2283 qxmin_init(:) = 1.0e-8 ! threshold for considering single-moment initial condition mixing ratios
2284 ! constants for droplet nucleation
2285
2286 cckm = cck-1.
2287 ccnefac = (1.63/(cck * beta(3./2., cck/2.)))**(cck/(cck + 2.0))
2288 cnexp = (3./2.)*cck/(cck+2.0)
2289! ccne is all the factors with w in eq. A7 in Mansell et al. 2010 (JAS). The constant changes
2290! if k (cck) is changed!
2291 ccne = ccnefac*1.e6*(1.e-6*abs(cwccn))**(2./(2.+cck))
2292 ccne0 = ccnefac*1.e6*(1.e-6)**(2./(2.+cck))
2293! write(0,*) 'cwccn, cck, ccne = ',cwccn,cck,ccne,ccnefac,cnexp
2294 IF ( cwccn .lt. 0.0 ) THEN
2295 cwccn = abs(cwccn)
2296 ccwmx = 50.e9 ! cwccn
2297 ELSE
2298 ccwmx = 50.e9 ! cwccn ! *1.4
2299 ENDIF
2300
2301!
2302!
2303! Set collection coefficients (Seifert and Beheng 05)
2304!
2305 bb(:) = 1.0/3.0
2306 bb(li) = 0.3429
2307 DO il = lc,lhab
2308 da0(il) = delbk(bb(il), xnu(il), xmu(il), 0)
2309 da1(il) = delbk(bb(il), xnu(il), xmu(il), 1)
2310
2311! write(0,*) 'il, da0, da1, xnu, xmu = ', il, da0(il), da1(il), xnu(il), xmu(il)
2312 ENDDO
2313
2314 dab0(:,:) = 0.0
2315 dab1(:,:) = 0.0
2316
2317 DO il = lc,lhab
2318 DO j = lc,lhab
2319 IF ( il .ne. j ) THEN
2320
2321 dab0(il,j) = delabk(bb(il), bb(j), xnu(il), xnu(j), xmu(il), xmu(j), 0)
2322 dab1(il,j) = delabk(bb(il), bb(j), xnu(il), xnu(j), xmu(il), xmu(j), 1)
2323
2324! write(0,*) 'il, j, dab0, dab1 = ',il, j, dab0(il,j), dab1(il,j)
2325 ENDIF
2326 ENDDO
2327 ENDDO
2328
2329 dab0lu(:,:,:,:) = 0.0
2330 dab1lu(:,:,:,:) = 0.0
2331
2332 IF ( ipconc >= 6 ) THEN
2333 DO il = lc,lhab ! collector
2334 DO j = lc,lhab ! collected
2335 IF ( il .ne. j ) THEN
2336
2337 DO jj = ialpstart,nqiacralpha
2338 alpjj = float(jj)*dqiacralpha
2339 xnujj = (alpjj - 2.)/3.
2340 DO ii = ialpstart,nqiacralpha
2341 alpii = float(ii)*dqiacralpha
2342 xnuii = (alpii - 2.)/3.
2343
2344 dab0lu(ii,jj,il,j) = delabk(bb(il), bb(j), xnuii, xnujj, xmu(il), xmu(j), 0)
2345 dab1lu(ii,jj,il,j) = delabk(bb(il), bb(j), xnuii, xnujj, xmu(il), xmu(j), 1)
2346
2347 ENDDO
2348 ENDDO
2349! write(0,*) 'il, j, dab0, dab1 = ',il, j, dab0(il,j), dab1(il,j)
2350 ENDIF
2351 ENDDO
2352 ENDDO
2353
2354 ENDIF
2355
2356 gf4br = gamma_sp(4.0+br)
2357 gf4ds = gamma_sp(4.0+ds)
2358 gf4p5 = gamma_sp(4.0+0.5)
2359 gfcinu1 = gamma_sp(cinu + 1.0)
2360 gfcinu1p47 = gamma_sp(cinu + 1.47167)
2361 gfcinu2p47 = gamma_sp(cinu + 2.47167)
2362 gfcinu1p22 = gamma_sp(cinu + 1.22117)
2363 gfcinu2p22 = gamma_sp(cinu + 2.22117)
2364 gfcinu1p18 = gamma_sp(cinu + 1.18333)
2365 gfcinu2p18 = gamma_sp(cinu + 2.18333)
2366
2367 gsnow1 = gamma_sp(snu + 1.0)
2368 gsnow53 = gamma_sp(snu + 5./3.)
2369 gsnow73 = gamma_sp(snu + 7./3.)
2370
2371 IF ( lh .gt. 1 ) cwchtmp0 = 6.0/pi*gamma_sp( (xnu(lh) + 1.)/xmu(lh) )/gamma_sp( (xnu(lh) + 2.)/xmu(lh) )
2372 IF ( lhl .gt. 1 ) cwchltmp0 = 6.0/pi*gamma_sp( (xnu(lhl) + 1)/xmu(lhl) )/gamma_sp( (xnu(lhl) + 2)/xmu(lhl) )
2373
2374
2375 iexy(:,:)=0; ! sets to zero the ones Imight have forgotten
2376
2377! snow
2378 iexy(ls,li) = ieswi
2379 iexy(ls,lc) = ieswc ; iexy(ls,lr) = ieswr ;
2380
2381! graupel
2382 iexy(lh,ls) = iehwsw ; iexy(lh,li) = iehwi ;
2383 iexy(lh,lc) = iehwc ; iexy(lh,lr) = iehwr ;
2384
2385! hail
2386 IF (lhl .gt. 1 ) THEN
2387 iexy(lhl,ls) = iehlsw ; iexy(lhl,li) = iehli ;
2388 iexy(lhl,lc) = iehlc ; iexy(lhl,lr) = iehlr ;
2389 ENDIF
2390
2391! IF ( icefallfac /= 1.0 ) write(0,*) 'icefallfac = ',icefallfac
2392! IF ( snowfallfac /= 1.0 ) write(0,*) 'snowfallfac = ',snowfallfac
2393
2394 RETURN
2395END SUBROUTINE nssl_2mom_init
2396
2397! #####################################################################
2398! #####################################################################
2399
2402SUBROUTINE nssl_2mom_driver(qv, qc, qr, qi, qs, qh, qhl, ccw, crw, cci, csw, chw, chl, &
2403 cn, vhw, vhl, cna, cni, f_cn, f_cna, f_cina, &
2404 f_qc, f_qr, f_qi, f_qs, f_qh, f_qhl, &
2405 cn_nu, cn_co, cinp, f_cnnu, f_cnco, f_cinp, &
2406 cna_co, cna_nu, f_cnaco, f_cnanu, &
2407 cnuf, f_cnuf, cn_ac, f_cnac, &
2408 zrw, zhw, zhl, f_zrw, f_zhw, f_zhl, f_vhw, f_vhl, &
2409 qsw, qhw, qhlw, &
2410 tt, th, pii, p, w, dn, dz, dtp, itimestep, &
2411 is_theta_or_temp, &
2412 ntmul, ntcnt, lastloop, &
2413 RAINNC,RAINNCV, &
2414 dx, dy, &
2415 axtra, &
2416 SNOWNC, SNOWNCV, GRPLNC, GRPLNCV, &
2417 SR,HAILNC, HAILNCV, &
2418 hail_maxk1, hail_max2d, nwp_diagnostics, &
2419 tkediss, &
2420 re_cloud, re_ice, re_snow, re_rain, &
2421 re_graup, re_hail, &
2422 has_reqc, has_reqi, has_reqs, has_reqr, &
2423 has_reqg, has_reqh, &
2424 rainncw2, rainnci2, &
2425 dbz, vzf,compdbz, &
2426 rscghis_2d,rscghis_2dp,rscghis_2dn, &
2427 scr,scw,sci,scs,sch,schl,sctot, &
2428 elec_physics, &
2429 induc,elecz,scion,sciona,f_scion,f_sciona, &
2430 noninduc,noninducp,noninducn, &
2431 ssat3d,ssati,nssl_ssat_output, &
2432 pcc2, pre2, depsubr, &
2433 mnucf2, melr2, ctr2, &
2434 rim1_2, rim2_2,rim3_2, &
2435 nctr2, nnuccd2, nnucf2, &
2436 effc2,effr2,effi2, &
2437 effs2, effg2, &
2438 fc2, fr2,fi2,fs2,fg2, &
2439 fnc2, fnr2,fni2,fns2,fng2, &
2440! qcond,qdep,qfrz,qrauto,qhcnvi,qhcollw,qscollw, &
2441! ncauto, niinit,nifrz, &
2442! re_liquid, re_graupel, re_hail, re_icesnow, &
2443! vtcloud, vtrain, vtsnow, vtgraupel, vthail, &
2444 ipelectmp, &
2445 isedonly_in, &
2446 diagflag,ke_diag, &
2447 errmsg, errflg, &
2448 nssl_progn, & ! wrf-chem
2449! 20130903 acd_mb_washout start
2450 wetscav_on, rainprod, evapprod, & ! wrf-chem
2451! 20130903 acd_mb_washout end
2452 cu_used, qrcuten, qscuten, qicuten, qccuten, & ! hm added
2453 ids,ide, jds,jde, kds,kde, & ! domain dims
2454 ims,ime, jms,jme, kms,kme, & ! memory dims
2455 its,ite, jts,jte, kts,kte) ! tile dims
2456
2457
2458
2459
2460
2461 implicit none
2462
2463
2464 !Subroutine arguments:
2465
2466 integer, intent(in):: &
2467 ids,ide, jds,jde, kds,kde, &
2468 ims,ime, jms,jme, kms,kme, &
2469 its,ite, jts,jte, kts,kte
2470 real, dimension(ims:ime, kms:kme, jms:jme), intent(inout):: &
2471 qv,qc,qr,qs,qh
2472 ! tt is air temperature -- used by CCPP instead of th (theta)
2473 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2474 th, tt, &
2475 zrw, zhw, zhl, &
2476 qsw, qhw, qhlw, &
2477 qi,qhl,ccw,crw,cci,csw,chw,chl,vhw,vhl
2478 integer, optional, intent(in) :: is_theta_or_temp
2479 logical, optional, intent(in) :: f_zrw, f_zhw, f_zhl, f_vhw, f_vhl ! not used yet
2480 integer, optional, intent(in) :: nssl_ssat_output
2481 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: dbz, vzf, cn, cna, cni, cnuf
2482 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: cn_nu, cn_ac, cn_co, cinp, cna_co, cna_nu
2483 logical, optional, intent(in) :: f_cnnu, f_cnac, f_cnco, f_cinp, f_cnaco, f_cnanu
2484
2485 real, dimension(ims:ime, jms:jme), optional, intent(inout):: compdbz
2486 real, dimension(ims:ime, jms:jme), optional, intent(inout):: rscghis_2d, & ! 2D accumulation arrays for vertically-integrated charging rate
2487 rscghis_2dp, & ! 2D accumulation arrays for vertically-integrated charging rate (positive only)
2488 rscghis_2dn ! 2D accumulation arrays for vertically-integrated charging rate (negative only)
2489! real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout)::rscghis_3d
2490 integer, optional, intent(in) :: elec_physics
2491 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2492 scr,scw,sci,scs,sch,schl,sciona,sctot ! space charge
2493 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2494 induc,noninduc,noninducp,noninducn ! charging rates: inductive, noninductive (all, positive, negative to graupel)
2495 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(in) :: elecz ! elecsave = Ez
2496 real, dimension(ims:ime, kms:kme, jms:jme, 2),optional, intent(inout) :: scion
2497 real, dimension(ims:ime, kms:kme, jms:jme), intent(in):: p,w,dz,dn
2498
2499 real, dimension(ims:ime, kms:kme, jms:jme), intent(in):: pii
2500 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout):: &
2501 ssat3d, ssati, &
2502 pcc2, pre2, depsubr, &
2503 mnucf2, melr2, ctr2, &
2504 rim1_2, rim2_2,rim3_2, &
2505 nctr2, nnuccd2, nnucf2, &
2506 effc2,effr2,effi2, &
2507 effs2, effg2, &
2508 fc2, fr2,fi2,fs2,fg2, &
2509 fnc2, fnr2,fni2,fns2,fng2
2510! qcond,qdep,qfrz,qrauto,qhcnvi,qhcollw,qscollw, &
2511! ncauto, niinit,nifrz, &
2512! re_liquid, re_graupel, re_hail, re_icesnow, &
2513! vtcloud, vtrain, vtsnow, vtgraupel, vthail
2514
2515 real, dimension(ims:ime, kms:kme, jms:jme), optional, intent(inout) :: axtra
2516
2517! WRF variables
2518 real, dimension(ims:ime, jms:jme) :: &
2519 rainnc,rainncv ! accumulated precip (NC) and rate (NCV)
2520 real, dimension(ims:ime, jms:jme), optional, intent(inout):: &
2521 snownc,snowncv,grplnc,grplncv,sr ! accumulated precip (NC) and rate (NCV)
2522 real, dimension(ims:ime, jms:jme), optional, intent(inout):: &
2523 hailnc,hailncv ! accumulated precip (NC) and rate (NCV)
2524 real, dimension(ims:ime, jms:jme), optional, intent(inout) :: hail_maxk1, hail_max2d
2525 integer, optional, intent(in) :: nwp_diagnostics
2526! for cm1, set nproctot=44 (or as needed) to get domain total rates
2527 integer, parameter :: nproc = 1
2528 double precision :: proctot(nproc),proctotmpi(nproc)
2529 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional, INTENT(INOUT):: re_cloud, re_ice, re_snow, &
2530 re_rain, re_graup, re_hail
2531 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional, INTENT(IN):: tkediss
2532 INTEGER, INTENT(IN), optional :: has_reqc, has_reqi, has_reqs, has_reqr, has_reqg, has_reqh
2533 real, dimension(ims:ime, jms:jme), intent(out), optional :: &
2534 rainncw2, rainnci2 ! liquid rain, ice, accumulation rates
2535 real, optional, intent(in) :: dx,dy
2536 real, intent(in) :: dtp
2537 integer, intent(in) :: itimestep !, ccntype
2538 integer, intent(in), optional :: ntmul, ntcnt
2539 logical, optional, intent(in) :: lastloop
2540 logical, optional, intent(in) :: diagflag, f_cna, f_cn, f_cina, f_cnuf
2541 logical, optional, intent(in) :: f_qc, f_qr, f_qi, f_qs, f_qh, f_qhl
2542 logical, optional, intent(in) :: f_scion,f_sciona
2543 integer, optional, intent(in) :: ipelectmp, ke_diag, isedonly_in
2544
2545 ! CCPP error handling
2546 character(len=*), intent( out) :: errmsg
2547 integer, intent( out) :: errflg
2548
2549 LOGICAL, INTENT(IN), OPTIONAL :: nssl_progn ! flags for wrf-chem
2550
2551! REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional,INTENT(INOUT):: qndrop
2552 LOGICAL :: flag_qndrop ! wrf-chem
2553 LOGICAL :: flag_qnifa , flag_qnwfa
2554 logical :: flag_cnuf = .false.
2555 logical :: flag_ccn = .false.
2556 logical :: flag_qi = .true.
2557 logical :: has_reqr_local = .false., has_reqg_local = .false., has_reqh_local = .false.
2558 logical :: flag
2559 logical :: nwp_diagflag = .false.
2560 real :: cinchange, t7max,testmax,wmax
2561
2562! 20130903 acd_ck_washout start
2563! rainprod - total tendency of conversion of cloud water/ice and graupel to rain (kg kg-1 s-1)
2564! evapprod - tendency of evaporation of rain (kg kg-1 s-1)
2565! 20130903 acd_ck_washout end
2566 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional,INTENT(INOUT):: rainprod, evapprod
2567
2568! qrcuten, rain tendency from parameterized cumulus convection
2569! qscuten, snow tendency from parameterized cumulus convection
2570! qicuten, cloud ice tendency from parameterized cumulus convection
2571! mu : air mass in column
2572 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), optional, INTENT(IN):: qrcuten, qscuten, qicuten, qccuten
2573 INTEGER, optional, intent(in) :: cu_used
2574 LOGICAL, optional, intent(in) :: wetscav_on
2575
2576!
2577! local variables
2578!
2579 real, dimension(its:ite, 1, kts:kte) :: elec2 ! ez = elecsave slab
2580! real, dimension(its:ite, 1, kts:kte,2) :: scion2 ! 1=- , 2=+
2581 real, dimension(its:ite, kts:kte) :: rainprod2d, evapprod2d,tke2d
2582 real, dimension(its:ite, 1, kts:kte, na) :: an, ancuten
2583 real, dimension(its:ite, 1, kts:kte, nxtra) :: axtra2d
2584 real, dimension(its:ite, 1, kts:kte, 3) :: alpha2d
2585 real, dimension(its:ite, 1, kts:kte) :: t0,t1,t2,t3,t4,t5,t6,t7,t8,t9
2586 real, dimension(its:ite, 1, kts:kte) :: dn1,t00,t77,ssat,pn,wn,dz2d,dz2dinv,dbz2d,vzf2d
2587 real, dimension(its:ite, 1, na) :: xfall
2588 real, dimension(its:ite, 1) :: hailmax1d,hailmaxk1
2589 real, dimension(kts:kte, nproc) :: thproclocal
2590 integer, parameter :: nor = 0, ng = 0
2591 integer :: nx,ny,nz,ngs
2592 integer ix,jy,kz,i,j,k,il,n
2593 integer :: infdo
2594 real :: ssival, ssifac, t8s, t9s, qvapor
2595 integer :: ltemq
2596 double precision :: dp1
2597 integer :: jye, lnb
2598 integer :: imx,kmx
2599 real :: dbzmx,refl
2600 integer :: vzflag0 = 0
2601 logical :: makediag
2602 real :: dx1,dy1
2603 real, parameter :: cnin20 = 1.0e3
2604 real, parameter :: cnin10 = 5.0e1
2605 real, parameter :: cnin1a = 4.5
2606 real, parameter :: cnin2a = 12.96
2607 real, parameter :: cnin2b = 0.639
2608
2609 double precision :: cwmass1,cwmass2
2610 double precision :: rwmass1,rwmass2
2611 double precision :: icemass1,icemass2
2612 double precision :: swmass1,swmass2
2613 double precision :: grmass1,grmass2
2614 double precision :: hlmass1,hlmass2
2615 double precision :: wvol5,wvol10
2616 real :: tmp,dv,dv1,tmpchg
2617 real :: rdt
2618 real :: temp1, c1
2619
2620 double precision :: dt1,dt2
2621 double precision :: timesed,timesed1,timesed2,timesed3, timegs, timenucond, timedbz,zmaxsed
2622 double precision :: timevtcalc,timesetvt
2623
2624 logical :: f_cnatmp, f_cinatmp, f_cnacotmp, f_cnanutmp
2625 logical :: has_wetscav
2626
2627 integer :: kediagloc
2628 integer :: iunit
2629 integer :: isedonly_local
2630
2631 real :: ycent, y, emissrate, emissrate0, emissrate1, z, fac, factot
2632 real :: fach(kts:kte)
2633
2634 logical, parameter :: debugdriver = .false.
2635
2636 integer :: loopcnt, loopmax, outerloopcnt
2637 logical :: lastlooptmp
2638
2639
2640! -------------------------------------------------------------------
2641
2642 errmsg = ''
2643 errflg = 0
2644
2645 rdt = 1.0/dtp
2646
2647 IF ( debugdriver ) write(0,*) 'N2M: entering routine'
2648
2649 flag_qndrop = .false.
2650 flag_qnifa = .false.
2651 flag_qnwfa = .false.
2652 flag_cnuf = .false.
2653 flag_ccn = .false.
2654 nwp_diagflag = .false.
2655
2656 IF ( PRESENT ( nssl_progn ) ) flag_qndrop = nssl_progn
2657 IF ( present ( f_cnuf ) ) flag_cnuf = f_cnuf
2658 IF ( present ( nwp_diagnostics ) ) nwp_diagflag = ( nwp_diagnostics > 0 )
2659
2660 IF ( present ( f_cn ) .and. present( cn ) ) THEN
2661 flag_ccn = f_cn
2662 ELSEIF ( present( cn ) ) THEN
2663 flag_ccn = .true.
2664 ENDIF
2665
2666 IF ( present( f_qi ) ) THEN
2667 flag_qi = f_qi
2668 ELSE
2669 IF ( ffrzs < 1.0 ) THEN
2670 flag_qi = .true.
2671 ELSE
2672 flag_qi = .false.
2673 ENDIF
2674 ENDIF
2675
2676 IF ( .not. flag_qi .and. ffrzs < 1.0 ) ffrzs = 1.0
2677
2678
2679 IF ( PRESENT ( has_reqr ) ) has_reqr_local = has_reqr > 0
2680 IF ( PRESENT ( has_reqg ) ) has_reqg_local = has_reqg > 0
2681 IF ( PRESENT ( has_reqh ) ) has_reqh_local = has_reqh > 0
2682
2683 loopmax = 1
2684 outerloopcnt = 1
2685 lastlooptmp = .true.
2686 IF ( present( ntmul ) .and. present( ntcnt ) .and. present( lastloop ) ) THEN
2687 loopmax = ntmul
2688 outerloopcnt = ntcnt
2689 lastlooptmp = lastloop
2690 ENDIF
2691
2692
2693 has_wetscav = .false.
2694 IF ( wrfchem_flag > 0 ) THEN
2695 IF ( PRESENT( wetscav_on ) ) THEN
2696 has_wetscav = wetscav_on
2697 ENDIF
2698 ENDIF
2699
2700 IF ( present( f_cna ) ) THEN
2701 f_cnatmp = f_cna
2702 ELSE
2703 f_cnatmp = .false.
2704 ENDIF
2705
2706 IF ( present( f_cina ) ) THEN
2707 f_cinatmp = f_cina
2708 ELSE
2709 f_cinatmp = .false.
2710 ENDIF
2711
2712 IF ( present( vzf ) ) vzflag0 = 1
2713
2714 IF ( present( ipelectmp ) ) THEN
2715 ipelec = ipelectmp
2716 ELSE
2717 ipelec = 0
2718 ENDIF
2719
2720 IF ( present( isedonly_in ) ) THEN
2721 isedonly_local = isedonly_in
2722 ELSE
2723 isedonly_local = 0
2724 ENDIF
2725
2726! IF ( present( dbz ) ) THEN
2727! DO jy = jts,jte
2728! DO kz = kts,kte
2729! DO ix = its,ite
2730! dbz(ix,kz,jy) = 0.0
2731! ENDDO
2732! ENDDO
2733! ENDDO
2734! ENDIF
2735
2736 IF ( present( dx ) .and. present( dy ) ) THEN
2737 dx1 = dx
2738 dy1 = dy
2739 ELSE
2740 dx1 = 1.0
2741 dy1 = 1.0
2742 ENDIF
2743
2744
2745 makediag = .true.
2746 IF ( present( diagflag ) ) THEN
2747 makediag = diagflag .or. itimestep == 1
2748 ENDIF
2749
2750 IF ( debugdriver ) write(0,*) 'N2M: makediag = ',makediag
2751
2752
2753 nx = ite-its+1
2754 ny = 1 ! set up as 2D slabs
2755 nz = kte-kts+1
2756 ngs = 64
2757
2758 IF ( .not. flag_ccn ) THEN
2759 renucfrac = 1.0
2760 ENDIF
2761
2762
2763
2764
2765! ENDIF ! itimestep == 1
2766
2767
2768! sedimentation settings
2769
2770 infdo = 2
2771
2772 IF ( infall .ne. 1 .or. iscfall .ge. 2 ) THEN
2773 infdo = 1
2774 ELSE
2775 infdo = 0
2776 ENDIF
2777
2778 IF ( any(linfall(:) .ge. 3 ) .or. ipconc .ge. 6 ) THEN
2779 infdo = 2
2780 ENDIF
2781
2782 IF ( present( hailncv ) .and. lhl < 1 ) THEN ! for WRF 3.1 compatibility
2783 hailncv(its:ite,jts:jte) = 0.
2784 ENDIF
2785
2786 tke2d(:,:) = 0.0 ! initialize if not used
2787
2788 lnb = max(lh,lhl)+1 ! lnc
2789! IF ( lccn > 1 ) lnb = lccn
2790
2791 jye = jte
2792
2793 IF ( present( compdbz ) .and. makediag ) THEN
2794 DO jy = jts,jye
2795 DO ix = its,ite
2796 compdbz(ix,jy) = -3.0
2797 ENDDO
2798 ENDDO
2799 ENDIF
2800
2801 zmaxsed = 0.0d0
2802 timevtcalc = 0.0d0
2803 timesetvt = 0.0d0
2804 timesed = 0.0d0
2805 timesed1 = 0.0d0
2806 timesed2 = 0.0d0
2807 timesed3 = 0.0d0
2808 timegs = 0.0d0
2809 timenucond = 0.0d0
2810
2811
2812
2813 IF ( debugdriver ) write(0,*) 'N2M: jy loop 1, lhl,na = ',lhl,na,present(qhl)
2814
2815 ancuten(its:ite,1,kts:kte,:) = 0.0
2816 thproclocal(:,:) = 0.0
2817
2818
2819 DO jy = jts,jye
2820
2821! write(0,*) 'N2M: load an, jy,lccn = ',jy,lccn,qccn
2822
2823 IF ( ( present( pcc2 ) .or. present( axtra ) ) .and. makediag ) THEN
2824 axtra2d(its:ite,1,kts:kte,:) = 0.0
2825 ENDIF
2826
2827 IF ( nwp_diagflag ) THEN
2828 alpha2d(its:ite,1,kts:kte,1) = alphar
2829 alpha2d(its:ite,1,kts:kte,2) = alphah
2830 alpha2d(its:ite,1,kts:kte,3) = alphahl
2831 ENDIF
2832
2833
2834 ! copy from 3D array to 2D slab
2835
2836 DO kz = kts,kte
2837 DO ix = its,ite
2838 IF ( present( tt ) ) THEN
2839 an(ix,1,kz,lt) = tt(ix,kz,jy)/pii(ix,kz,jy)
2840 ELSE
2841 an(ix,1,kz,lt) = th(ix,kz,jy)
2842 ENDIF
2843 an(ix,1,kz,lv) = qv(ix,kz,jy)
2844 an(ix,1,kz,lc) = qc(ix,kz,jy)
2845 an(ix,1,kz,lr) = qr(ix,kz,jy)
2846 IF ( flag_qi ) THEN
2847 an(ix,1,kz,li) = qi(ix,kz,jy)
2848 ELSE
2849 an(ix,1,kz,li) = 0.0
2850 ENDIF
2851 an(ix,1,kz,ls) = qs(ix,kz,jy)
2852 an(ix,1,kz,lh) = qh(ix,kz,jy)
2853 IF ( lhl > 1 ) an(ix,1,kz,lhl) = qhl(ix,kz,jy)
2854 IF ( lccn > 1 ) THEN
2855 IF ( is_aerosol_aware .and. flag_qnwfa ) THEN
2856 !
2857 ELSEIF ( flag_ccn ) THEN
2858 IF ( lccna > 1 .and. .not. ( present( cna ) .and. f_cnatmp ) ) THEN
2859 an(ix,1,kz,lccna) = cn(ix,kz,jy)
2860 an(ix,1,kz,lccn) = qccn ! cn(ix,kz,jy)
2861 ELSE
2862 an(ix,1,kz,lccn) = cn(ix,kz,jy)
2863 ENDIF
2864 IF ( i_uf_or_ccn > 0 .and. lccnuf > 1 ) THEN ! UF ccn are extra regular ccn
2865 an(ix,1,kz,lccn) = an(ix,1,kz,lccn) + cnuf(ix,kz,jy)
2866 ENDIF
2867 ELSE
2868 IF ( lccna == 0 .and. ( .not. f_cnatmp ) ) THEN
2869 an(ix,1,kz,lccn) = qccn - ccw(ix,kz,jy)
2870 ELSE
2871 an(ix,1,kz,lccn) = qccn
2872 ENDIF
2873
2874 ENDIF
2875 ENDIF
2876
2877 IF ( lccnuf > 0 .and. flag_cnuf ) THEN
2878 IF ( i_uf_or_ccn == 0 ) THEN ! UF are UF
2879 an(ix,1,kz,lccnuf) = max(0.0, cnuf(ix,kz,jy) )
2880 ELSE ! UF were added to lccn
2881 an(ix,1,kz,lccnuf) = 0.0
2882 ENDIF
2883 ENDIF
2884
2885 IF ( lccna > 1 ) THEN
2886 IF ( present( cna ) .and. f_cnatmp ) THEN
2887 an(ix,1,kz,lccna) = max(0.0, cna(ix,kz,jy) )
2888 ENDIF
2889 ENDIF
2890
2891 IF ( lcina > 1 ) THEN
2892 IF ( present( cni ) .and. f_cinatmp ) THEN
2893 an(ix,1,kz,lcina) = cni(ix,kz,jy)
2894 ENDIF
2895 ENDIF
2896
2897 IF ( ipconc >= 5 ) THEN
2898 an(ix,1,kz,lnc) = ccw(ix,kz,jy)
2899 IF ( constccw > 0.0 ) THEN
2900 an(ix,1,kz,lnc) = constccw
2901 ENDIF
2902 an(ix,1,kz,lnr) = crw(ix,kz,jy)
2903 IF ( present( cci ) ) THEN
2904 an(ix,1,kz,lni) = cci(ix,kz,jy)
2905 ELSE
2906 an(ix,1,kz,lni) = 0.0
2907 ENDIF
2908 an(ix,1,kz,lns) = csw(ix,kz,jy)
2909 an(ix,1,kz,lnh) = chw(ix,kz,jy)
2910 IF ( lhl > 1 ) an(ix,1,kz,lnhl) = chl(ix,kz,jy)
2911 ENDIF
2912 IF ( lvh > 0 .and. present( vhw ) ) an(ix,1,kz,lvh) = vhw(ix,kz,jy)
2913 IF ( lvhl > 0 .and. present( vhl ) ) an(ix,1,kz,lvhl) = vhl(ix,kz,jy)
2914
2915 IF ( ipconc >= 6 ) THEN
2916 IF ( lzr > 0 ) an(ix,1,kz,lzr) = zrw(ix,kz,jy)*zscale
2917 IF ( lzh > 0 ) an(ix,1,kz,lzh) = zhw(ix,kz,jy)*zscale
2918 IF ( lzhl > 0 ) an(ix,1,kz,lzhl) = zhl(ix,kz,jy)*zscale
2919 ENDIF
2920
2921
2922
2923 ENDDO
2924 ENDDO
2925
2926 DO kz = kts,kte
2927 DO ix = its,ite
2928
2929
2930 IF ( present( tt ) ) THEN
2931 t0(ix,1,kz) = tt(ix,kz,jy) ! temperature (Kelvin)
2932 ELSE
2933 t0(ix,1,kz) = th(ix,kz,jy)*pii(ix,kz,jy) ! temperature (Kelvin)
2934 ENDIF
2935 t00(ix,1,kz) = 380.0/p(ix,kz,jy)
2936 t77(ix,1,kz) = pii(ix,kz,jy)
2937 dbz2d(ix,1,kz) = 0.0
2938 vzf2d(ix,1,kz) = 0.0
2939 ENDDO
2940 ENDDO
2941
2942 DO ix = its,ite
2943 rainncv(ix,jy) = 0.0
2944 IF ( present( grplncv ) ) grplncv(ix,jy) = 0.0
2945 IF ( present( hailncv ) ) hailncv(ix,jy) = 0.0
2946 IF ( present( snowncv ) ) snowncv(ix,jy) = 0.0
2947 ENDDO
2948
2949 DO loopcnt = 1,loopmax
2950
2951 DO kz = kts,kte
2952 DO ix = its,ite
2953
2954
2955 t1(ix,1,kz) = 0.0
2956 t2(ix,1,kz) = 0.0
2957 t3(ix,1,kz) = 0.0
2958 t4(ix,1,kz) = 0.0
2959 t5(ix,1,kz) = 0.0
2960 t6(ix,1,kz) = 0.0
2961 t7(ix,1,kz) = 0.0
2962 t8(ix,1,kz) = 0.0
2963 t9(ix,1,kz) = 0.0
2964
2965 pn(ix,1,kz) = p(ix,kz,jy)
2966 wn(ix,1,kz) = w(ix,kz,jy)
2967! calculate dn1 in case we are substepping: rho = con_eps*prsl/(con_rd*tgrs*(qv_mp+con_eps))
2968 dn1(ix,1,kz) = rdorv*pn(ix,1,kz)/(rd*t0(ix,1,kz)*(an(ix,1,kz,lv) + rdorv))
2969! wmax = Max(wmax,wn(ix,1,kz))
2970 dz2d(ix,1,kz) = dz(ix,kz,jy)
2971 dz2dinv(ix,1,kz) = 1./dz(ix,kz,jy)
2972
2973 ltemq = int( (t0(ix,1,kz)-163.15)/fqsat+1.5 )
2974 ltemq = min( nqsat, max(1,ltemq) )
2975!
2976! saturation mixing ratio
2977!
2978 IF ( iqvsopt == 0 ) THEN
2979 t8s = t00(ix,1,kz)*tabqvs(ltemq) !saturation mixing ratio wrt water
2980 ELSE
2981 t8s = rdorv*esbolton*tabqvs(ltemq)/(pn(ix,1,kz) - esbolton*tabqvs(ltemq))
2982 ENDIF
2983 t9s = t00(ix,1,kz)*tabqis(ltemq) !saturation mixing ratio wrt ice
2984
2985!
2986! calculate rate of nucleation
2987!
2988 ssival = min(t8s,max(an(ix,1,kz,lv),0.0))/t9s ! qv/qvi
2989
2990
2991 if ( ssival .gt. 1.0 ) then
2992!
2993 IF ( icenucopt == 1 ) THEN
2994
2995 if ( t0(ix,1,kz).le.268.15 ) then
2996
2997 dp1 = dn1(ix,1,kz)/rho00*cnin20*exp( min( 57.0 ,(cnin2a*(ssival-1.0)-cnin2b) ) )
2998 t7(ix,1,kz) = min(dp1, 1.0d30)
2999 end if
3000
3001!
3002! Default value of imeyers5 turns off nucleation by Meyer at higher temperatures
3003! This is really from Ferrier (1994), eq. 4.31 - 4.34
3004 IF ( imeyers5 ) THEN
3005 if ( t0(ix,1,kz).lt.tfr .and. t0(ix,1,kz).gt.268.15 ) then
3006 qvapor = max(an(ix,1,kz,lv),0.0)
3007 ssifac = 0.0
3008 if ( (qvapor-t9s) .gt. 1.0e-5 ) then
3009 if ( (t8s-t9s) .gt. 1.0e-5 ) then
3010 ssifac = (qvapor-t9s) /(t8s-t9s)
3011 ssifac = ssifac**cnin1a
3012 end if
3013 end if
3014 t7(ix,1,kz) = dn1(ix,1,kz)/rho00*cnin10*ssifac*exp(-(t0(ix,1,kz)-tfr)*bta1)
3015 end if
3016 ENDIF
3017
3018! t7max = Max(t7max, t7(ix,1,kz) )
3019
3020 ELSEIF ( icenucopt == 2 ) THEN ! Thompson/Cooper; Note Thompson 2004 has constants of
3021 ! 0.005 and 0.304 because the line function was estimated from Cooper plot
3022 ! Here, the fit line values from Cooper 1986 are converted. Very little difference
3023 ! in practice
3024
3025 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
3026
3027! write(0,*) 'Cooper t7,ssival = ',ix,kz,t7(ix,1,kz),ssival
3028
3029 ELSEIF ( icenucopt == 3 ) THEN ! Phillips (Meyers/DeMott)
3030
3031 if ( t0(ix,1,kz).le.268.15 .and. t0(ix,1,kz) > 243.15 ) then ! Meyers with factor of Psi=0.06
3032
3033 dp1 = 0.06*cnin20*exp( min( 57.0 ,(cnin2a*(ssival-1.0)-cnin2b) ) )
3034 t7(ix,1,kz) = min(dp1, 1.0d30)
3035 elseif ( t0(ix,1,kz) <= 243.15 ) then ! Phillips estimate of DeMott et al (2003) data
3036 dp1 = 1000.*( exp( min( 57.0 ,cnin2a*(ssival-1.1) ) ) )**0.3
3037 t7(ix,1,kz) = min(dp1, 1.0d30)
3038
3039 end if
3040
3041 ELSEIF ( icenucopt == 4 ) THEN ! DeMott 2010
3042
3043 IF ( t0(ix,1,kz) < 268.16 .and. t0(ix,1,kz) > 223.15 .and. ssival > 1.001 ) THEN !
3044
3045 ! a = 0.0000594, b = 3.33, c = 0.0264, d = 0.0033,
3046 ! nint = a*(-Tc)**b * naer**(c*(-Tc) + d)
3047 ! nint has units of per (standard) liter, so mult by 1.e3 and scale by dn/rho00
3048 ! naer needs units of cm**-3, so mult by 1.e-6
3049
3050 ! 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)
3051 tmp = 1.e-6*naer
3052 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)
3053 t7(ix,1,kz) = min(dp1, 1.0d30)
3054
3055 ELSE
3056 ! t7(ix,1,kz) = 0.0
3057 ENDIF
3058
3059 ENDIF ! icenucopt
3060
3061
3062!
3063 end if ! ( ssival .gt. 1.0 )
3064!
3065
3066 ENDDO ! ix
3067 ENDDO ! kz
3068
3069 IF ( wrfchem_flag > 0 ) THEN
3070 IF ( has_wetscav ) THEN
3071 IF ( PRESENT( rainprod ) ) rainprod2d(its:ite,kts:kte) = 0
3072 IF ( PRESENT( evapprod ) ) evapprod2d(its:ite,kts:kte) = 0
3073 ENDIF
3074 ENDIF
3075
3076
3077 ! transform from number mixing ratios to number conc.
3078
3079 IF ( loopcnt == 1 ) THEN
3080 DO il = lnb,na
3081 IF ( denscale(il) == 1 ) THEN
3082 DO kz = kts,kte
3083 DO ix = its,ite
3084 an(ix,1,kz,il) = an(ix,1,kz,il)*dn1(ix,1,kz) ! dn(ix,kz,jy)
3085 ENDDO
3086 ENDDO
3087 ENDIF
3088 ENDDO ! il
3089 ENDIF
3090
3091
3092! sedimentation
3093 xfall(:,:,:) = 0.0
3094
3095
3096! IF ( .true. ) THEN
3097
3098
3099! for real cases when hydrometeor mixing ratios have been initialized without concentrations
3100 IF ( itimestep == 1 .and. ipconc > 0 .and. loopcnt == 1 ) THEN
3101 call calcnfromq(nx,ny,nz,an,na,nor,nor,dn1)
3102 ENDIF
3103
3104 IF ( present(cu_used) .and. &
3105 ( present( qrcuten ) .or. present( qscuten ) .or. &
3106 present( qicuten ) .or. present( qccuten ) ) ) THEN !{
3107
3108 IF ( cu_used == 1 ) THEN !{
3109 DO kz = kts,kte
3110 DO ix = its,ite
3111
3112 IF ( present( qrcuten ) ) ancuten(ix,1,kz,lr) = dtp*qrcuten(ix,kz,jy)
3113 IF ( present( qscuten ) ) ancuten(ix,1,kz,ls) = dtp*qscuten(ix,kz,jy)
3114 IF ( present( qicuten ) ) ancuten(ix,1,kz,li) = dtp*qicuten(ix,kz,jy)
3115 IF ( present( qccuten ) ) ancuten(ix,1,kz,lc) = dtp*qccuten(ix,kz,jy)
3116
3117 ENDDO
3118 ENDDO
3119
3120 call calcnfromcuten(nx,ny,nz,ancuten,an,na,nor,nor,dn1)
3121
3122 ENDIF !}
3123
3124 ENDIF !}
3125
3126
3127 IF ( isedonly_local == 0 ) THEN
3128
3129 call sediment1d(dtp,nx,ny,nz,an,na,nor,nor,xfall,dn1,dz2d,dz2dinv, &
3130 & t0,t7,infdo,jy,its,jts &
3131 & ,timesed1,timesed2,timesed3,zmaxsed,timesetvt)
3132
3133
3134! copy xfall to appropriate places...
3135
3136 IF ( debugdriver ) write(0,*) 'N2M: end sediment, jy = ',jy
3137
3138 DO ix = its,ite
3139 IF ( lhl > 1 ) THEN
3140 rainncv(ix,jy) = rainncv(ix,jy) + &
3141 dtp*dn1(ix,1,1)*(xfall(ix,1,lr) + xfall(ix,1,ls)*1000./xdn0(lr) + &
3142 & xfall(ix,1,lh)*1000./xdn0(lr) + xfall(ix,1,lhl)*1000./xdn0(lr) )
3143 ELSE
3144 rainncv(ix,jy) = rainncv(ix,jy) + &
3145 dtp*dn1(ix,1,1)*(xfall(ix,1,lr) + xfall(ix,1,ls)*1000./xdn0(lr) + &
3146 & xfall(ix,1,lh)*1000./xdn0(lr) )
3147 ENDIF
3148 IF ( present ( rainncw2 ) ) THEN ! rain only
3149 rainncw2(ix,jy) = rainncw2(ix,jy) + dtp*dn1(ix,1,1)*xfall(ix,1,lr)
3150 ENDIF
3151 IF ( present ( rainnci2 ) ) THEN ! ice only
3152 IF ( lhl > 1 ) THEN
3153 rainnci2(ix,jy) = rainnci2(ix,jy) + dtp*dn1(ix,1,1)*(xfall(ix,1,ls)*1000./xdn0(lr) + &
3154 & xfall(ix,1,lh)*1000./xdn0(lr) + xfall(ix,1,lhl)*1000./xdn0(lr) )
3155 ELSE
3156 rainnci2(ix,jy) = rainnci2(ix,jy) + dtp*dn1(ix,1,1)*(xfall(ix,1,ls)*1000./xdn0(lr) + &
3157 & xfall(ix,1,lh)*1000./xdn0(lr) )
3158 ENDIF
3159 ENDIF
3160 IF ( present( snowncv ) ) snowncv(ix,jy) = snowncv(ix,jy) + dtp*dn1(ix,1,1)*xfall(ix,1,ls)*1000./xdn0(lr)
3161 IF ( present( grplncv ) ) THEN
3162 IF ( lhl > 1 .and. .not. present( hailnc) ) THEN ! if no separate hail accum, then add to graupel
3163 grplncv(ix,jy) = grplncv(ix,jy) + dtp*dn1(ix,1,1)*(xfall(ix,1,lh) + xfall(ix,1,lhl)) *1000./xdn0(lr)
3164 ELSE
3165 grplncv(ix,jy) = grplncv(ix,jy) + dtp*dn1(ix,1,1)*xfall(ix,1,lh)*1000./xdn0(lr)
3166 ENDIF
3167 ENDIF
3168 IF ( loopcnt == loopmax ) rainnc(ix,jy) = rainnc(ix,jy) + rainncv(ix,jy)
3169
3170 IF ( present (snownc) .and. present (snowncv) .and. loopcnt == loopmax ) THEN
3171 snownc(ix,jy) = snownc(ix,jy) + snowncv(ix,jy)
3172 ENDIF
3173 IF ( lhl > 1 ) THEN
3174 IF ( present( hailnc ) ) THEN
3175 hailncv(ix,jy) = dtp*dn1(ix,1,1)*xfall(ix,1,lhl)*1000./xdn0(lr)
3176 IF ( loopcnt == loopmax ) hailnc(ix,jy) = hailnc(ix,jy) + hailncv(ix,jy)
3177! ELSEIF ( present( GRPLNCV ) ) THEN ! if no separate hail accum, then add to graupel
3178! GRPLNCV(ix,jy) = GRPLNCV(ix,jy) + dtp*dn1(ix,1,1)*xfall(ix,1,lhl)*1000./xdn0(lr)
3179 ENDIF
3180 ENDIF
3181 IF ( present( grplncv ) .and. loopcnt == loopmax ) THEN
3182 grplnc(ix,jy) = grplnc(ix,jy) + grplncv(ix,jy)
3183 ENDIF
3184 IF ( present( sr ) .and. present (snowncv) .and. present(grplncv) .and. loopcnt == loopmax ) THEN
3185 IF ( present( hailnc ) ) THEN
3186 sr(ix,jy) = (snowncv(ix,jy)+hailncv(ix,jy)+grplncv(ix,jy))/(rainncv(ix,jy)+1.e-12)
3187 ELSE
3188 sr(ix,jy) = (snowncv(ix,jy)+grplncv(ix,jy))/(rainncv(ix,jy)+1.e-12)
3189 ENDIF
3190 ENDIF
3191 ENDDO
3192
3193 ENDIF ! isedonly_local
3194
3195! ENDIF ! .false.
3196
3197 IF ( isedonly /= 1 ) THEN
3198 ! call nssl_2mom_gs: main gather-scatter routine to calculate microphysics
3199
3200 IF ( debugdriver ) write(0,*) 'N2M: gs, jy = ',jy
3201! IF ( isedonly /= 2 ) THEN
3202
3203
3204 call nssl_2mom_gs &
3205 & (nx,ny,nz,na,jy &
3206 & ,nor,nor &
3207 & ,dtp,dz2d &
3208 & ,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9 &
3209 & ,an,dn1,t77 &
3210 & ,pn,wn,0 &
3211 & ,t00,t77, &
3212 & ventr,ventc,c1sw,1,ido, &
3213 & xdnmx,xdnmn, &
3214! & ln,ipc,lvol,lz,lliq, &
3215 & cdx, &
3216 & xdn0,dbz2d,tke2d, &
3217 & thproclocal,nproc,dx1,dy1,ngs, &
3218 & timevtcalc,axtra2d, makediag &
3219 & ,has_wetscav, rainprod2d, evapprod2d, alpha2d &
3220 & ,errmsg,errflg &
3221 & ,elec2,its,ids,ide,jds,jde &
3222 & )
3223
3224
3225
3226! recalculate dn1 after temperature changes: rho = con_eps*prsl/(con_rd*tgrs*(qv_mp+con_eps))
3227 DO kz = kts,kte
3228 DO ix = its,ite
3229 dn1(ix,1,kz) = rdorv*pn(ix,1,kz)/(rd*t0(ix,1,kz)*(an(ix,1,kz,lv) + rdorv))
3230 ENDDO
3231 ENDDO
3232
3233
3234 ENDIF ! isedonly /= 1
3235
3236 ! droplet nucleation/condensation/evaporation
3237 IF ( .true. ) THEN
3238 CALL nucond &
3239 & (nx,ny,nz,na,jy &
3240 & ,nor,nor,dtp,nx &
3241 & ,dz2d &
3242 & ,t0,t9 &
3243 & ,an,dn1,t77 &
3244 & ,pn,wn &
3245 & ,ngs &
3246 & ,axtra2d, makediag &
3247 & ,ssat,t00,t77,flag_qndrop)
3248
3249! Clean up tiny values of mixing ratio and final checks on max/min sizes
3250 CALL smallvalues &
3251 & (nx,ny,nz,na,jy &
3252 & ,nor,nor,dtp,nx &
3253 & ,t0 &
3254 & ,an,dn1,wn &
3255 & ,t77,flag_qndrop)
3256
3257! recalculate dn1 after temperature changes
3258 DO kz = kts,kte
3259 DO ix = its,ite
3260 dn1(ix,1,kz) = rdorv*pn(ix,1,kz)/(rd*t0(ix,1,kz)*(an(ix,1,kz,lv) + rdorv))
3261 ENDDO
3262 ENDDO
3263
3264
3265 ENDIF
3266
3267
3268
3269
3270 ENDDO ! loopcnt=1,loopmax
3271 IF ( present( pcc2 ) .and. makediag ) THEN
3272 DO kz = kts,kte
3273 DO ix = its,ite
3274! example of using the 'axtra2d' array to get rates out of the microphysics routine for output.
3275! Search for 'axtra' to find example code below
3276! pcc2(ix,kz,jy) = axtra2d(ix,1,kz,1)
3277 ENDDO
3278 ENDDO
3279 ENDIF
3280
3281 IF ( ( present( ssat3d ) .and. present( nssl_ssat_output ) ) .and. makediag ) THEN
3282 DO kz = kts,kte
3283 DO ix = its,ite
3284
3285 ! updated temperature and qv
3286 temp1 = t0(ix,1,kz) ! an(ix,1,kz,lt)*t77(ix,1,kz)
3287 ltemq = int( (temp1-163.15)/fqsat+1.5 )
3288 ltemq = min( nqsat, max(1,ltemq) )
3289
3290 IF ( present( ssat3d ) .and. nssl_ssat_output >= 1 ) THEN
3291
3292! c1 = t00(ix,1,kz)*tabqvs(ltemq)
3293 IF ( iqvsopt == 0 ) THEN
3294 c1 = (380.0/pn(ix,1,kz))*tabqvs(ltemq)
3295 ELSEIF ( iqvsopt == 1 ) THEN
3296 c1 = rdorv*esbolton*tabqvs(ltemq)/(pn(ix,1,kz) - esbolton*tabqvs(ltemq))
3297 ENDIF
3298
3299 IF ( c1 > 0. ) THEN
3300 ssat3d(ix,kz,jy) = 100.*(an(ix,1,kz,lv)/c1 - 1.0) ! from "new" values
3301 ENDIF
3302
3303 ENDIF
3304
3305 IF ( present( ssati ) .and. nssl_ssat_output >= 2 ) THEN
3306 t9s = (380.0/pn(ix,1,kz))*tabqis(ltemq) !saturation mixing ratio wrt ice
3307 ssati(ix,kz,jy) = 100.*(an(ix,1,kz,lv)/t9s - 1.0) ! Min(t8s,max(an(ix,1,kz,lv),0.0))/t9s ! qv/qvi
3308 ENDIF
3309
3310 ENDDO
3311 ENDDO
3312 ENDIF
3313
3314
3315
3316! compute diagnostic S-band reflectivity if needed
3317 IF ( present( dbz ) .and. makediag .and. lastlooptmp ) THEN
3318 ! calc dbz
3319
3320 IF ( .true. ) THEN
3321 IF ( present(ke_diag) ) THEN
3322 kediagloc = ke_diag
3323 ELSE
3324 kediagloc = nz
3325 ENDIF
3326 call radardd02(nx,ny,nz,nor,na,an,t0, &
3327 & dbz2d,dn1,nz,cnoh,rho_qh,ipconc,kediagloc, 0)
3328 ENDIF ! .false.
3329
3330
3331 DO kz = kts,kediagloc ! kte
3332 DO ix = its,ite
3333 dbz(ix,kz,jy) = dbz2d(ix,1,kz)
3334 IF ( present( vzf ) ) THEN
3335 vzf(ix,kz,jy) = vzf2d(ix,1,kz)
3336 IF ( dbz2d(ix,1,kz) <= 0.0 ) THEN
3337 vzf(ix,kz,jy) = 0.0
3338 ELSEIF ( dbz2d(ix,1,kz) <= 15.0 ) THEN
3339 refl = 10**(0.1*dbz2d(ix,1,kz))
3340 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 )
3341 ENDIF
3342 ENDIF
3343 IF ( present( compdbz ) ) THEN
3344 compdbz(ix,jy) = max( compdbz(ix,jy), dbz2d(ix,1,kz) )
3345 ENDIF
3346 ENDDO
3347 ENDDO
3348
3349 ENDIF
3350
3351
3352
3353! Following Greg Thompson, calculation for effective radii. Used by RRTMG LW/SW schemes if enabled in module_physics_init.F
3354 IF ( present( has_reqc ).and. present( has_reqi ) .and. present( has_reqs ) .and. &
3355 present( re_cloud ).and. present( re_ice ) .and. present( re_snow ) .and. &
3356 lastlooptmp) THEN
3357 IF ( has_reqc.ne.0 .or. has_reqi.ne.0 .or. has_reqs.ne.0) THEN
3358 DO kz = kts,kte
3359 DO ix = its,ite
3360 re_cloud(ix,kz,jy) = 2.51e-6
3361 re_ice(ix,kz,jy) = 10.01e-6
3362 re_snow(ix,kz,jy) = 25.e-6
3363 t1(ix,1,kz) = 2.51e-6
3364 t2(ix,1,kz) = 10.01e-6
3365 t3(ix,1,kz) = 25.e-6
3366 t4(ix,1,kz) = 50.e-6
3367 ENDDO
3368 ENDDO
3369
3370
3371 call calc_eff_radius &
3372 & (nx,ny,nz,na,jy &
3373 & ,nor,nor &
3374 & ,t1=t1,t2=t2,t3=t3,t4=t4,t5=t5,t6=t6 &
3375 & ,f_t4=has_reqr_local,f_t5=has_reqg_local, f_t6=has_reqh_local &
3376 & ,an=an,dn=dn1 )
3377
3378 DO kz = kts,kte
3379 DO ix = its,ite
3380 re_cloud(ix,kz,jy) = max(2.51e-6, min(t1(ix,1,kz), 50.e-6))
3381 re_ice(ix,kz,jy) = max(10.01e-6, min(t2(ix,1,kz), 125.e-6))
3382 re_snow(ix,kz,jy) = max(25.e-6, min(t3(ix,1,kz), 999.e-6))
3383 ! check for case where snow needs to be treated as cloud ice (for rrtmg radiation)
3384 IF ( .not. present(qi) ) re_ice(ix,kz,jy) = max(10.e-6, min(t3(ix,1,kz), 125.e-6))
3385 ENDDO
3386 ENDDO
3387
3388 IF ( present(has_reqr) .and. present( re_rain ) ) THEN
3389 IF ( has_reqr /= 0 ) THEN
3390 DO kz = kts,kte
3391 DO ix = its,ite
3392 re_rain(ix,kz,jy) = max(50.e-6, min(t4(ix,1,kz), 2999.e-6))
3393 ENDDO
3394 ENDDO
3395 ENDIF
3396 ENDIF
3397
3398 IF ( present(has_reqg) .and. present( re_graup ) ) THEN
3399 IF ( has_reqg /= 0 ) THEN
3400 DO kz = kts,kte
3401 DO ix = its,ite
3402 re_graup(ix,kz,jy) = max(50.e-6, min(t5(ix,1,kz), 10.e-3))
3403 ENDDO
3404 ENDDO
3405 ENDIF
3406 ENDIF
3407
3408 IF ( present(has_reqh) .and. present( re_hail ) ) THEN
3409 IF ( has_reqh /= 0 ) THEN
3410 DO kz = kts,kte
3411 DO ix = its,ite
3412 re_hail(ix,kz,jy) = max(50.e-6, min(t5(ix,1,kz), 40.e-3))
3413 ENDDO
3414 ENDDO
3415 ENDIF
3416 ENDIF
3417
3418 ENDIF
3419 ENDIF
3420
3421
3422 IF ( present( hail_maxk1 ) .and. present( hail_max2d ) .and. nwp_diagflag ) THEN
3423 DO ix = its,ite
3424 hailmax1d(ix,1) = hail_max2d(ix,jy)
3425 hailmaxk1(ix,1) = hail_maxk1(ix,jy)
3426 ENDDO
3427
3428 call hailmaxd(dtp,nx,ny,nz,an,na,nor,nor,alpha2d,dn1, &
3429 hailmax1d,hailmaxk1,1 )
3430
3431 DO ix = its,ite
3432 hail_max2d(ix,jy) = hailmax1d(ix,1)
3433 hail_maxk1(ix,jy) = hailmaxk1(ix,1)
3434 ENDDO
3435! ENDIF
3436 ENDIF
3437
3438! transform concentrations back to mixing ratios
3439 DO il = lnb,na
3440 IF ( denscale(il) == 1 ) THEN
3441 DO kz = kts,kte
3442 DO ix = its,ite
3443 an(ix,1,kz,il) = an(ix,1,kz,il)/dn1(ix,1,kz) ! dn(ix,kz,jy)
3444 ENDDO
3445 ENDDO
3446 ENDIF
3447 ENDDO ! il
3448
3449 ! copy 2D slabs back to 3D
3450
3451
3452 DO kz = kts,kte
3453 DO ix = its,ite
3454
3455 IF ( present( tt ) ) THEN
3456 tt(ix,kz,jy) = t0(ix,1,kz)
3457 ELSE
3458 th(ix,kz,jy) = an(ix,1,kz,lt)
3459 ENDIF
3460
3461 qv(ix,kz,jy) = an(ix,1,kz,lv)
3462 qc(ix,kz,jy) = an(ix,1,kz,lc)
3463 qr(ix,kz,jy) = an(ix,1,kz,lr)
3464 IF ( flag_qi ) qi(ix,kz,jy) = an(ix,1,kz,li)
3465 qs(ix,kz,jy) = an(ix,1,kz,ls)
3466 qh(ix,kz,jy) = an(ix,1,kz,lh)
3467 IF ( lhl > 1 ) qhl(ix,kz,jy) = an(ix,1,kz,lhl)
3468
3469 IF ( lccn > 1 .and. is_aerosol_aware .and. flag_qnwfa ) THEN
3470 ! not used here
3471 ELSEIF ( flag_ccn .and. lccn > 1 .and. .not. flag_qndrop) THEN
3472 IF ( lccna > 1 .and. .not. ( present( cna ) .and. f_cnatmp ) ) THEN
3473 cn(ix,kz,jy) = max(0.0, an(ix,1,kz,lccna) )
3474 ELSE
3475 cn(ix,kz,jy) = an(ix,1,kz,lccn)
3476 ENDIF
3477 ENDIF
3478 IF ( lccna > 1 ) THEN
3479 IF ( present( cna ) .and. f_cnatmp ) THEN
3480 cna(ix,kz,jy) = max(0.0, an(ix,1,kz,lccna) )
3481 ENDIF
3482 ENDIF
3483
3484 IF ( lcina > 1 ) THEN
3485 IF ( present( cni ) .and. f_cinatmp ) THEN
3486 cni(ix,kz,jy) = max(0.0, an(ix,1,kz,lcina) )
3487 ENDIF
3488 ENDIF
3489
3490 IF ( lccnuf > 0 .and. flag_cnuf ) THEN
3491 IF ( i_uf_or_ccn > 0 ) THEN ! UF are ccn and lccnuf is zero, so put cnuf into lccnuf to do decay
3492 an(ix,1,kz,lccnuf) = max(0.0, cnuf(ix,kz,jy) )
3493 ENDIF
3494 IF ( decayufccn ) THEN
3495 IF ( an(ix,1,kz,lccnuf) > ufbackground ) THEN
3496 an(ix,1,kz,lccnuf) = an(ix,1,kz,lccnuf) - (an(ix,1,kz,lccnuf) - &
3497 ufbackground)*(1.0 - exp(-dtp/ufccntimeconst))
3498 ENDIF
3499 ENDIF
3500 cnuf(ix,kz,jy) = an(ix,1,kz,lccnuf)
3501 ENDIF
3502
3503
3504
3505 IF ( ipconc >= 5 ) THEN
3506
3507 ccw(ix,kz,jy) = an(ix,1,kz,lnc)
3508 crw(ix,kz,jy) = an(ix,1,kz,lnr)
3509 IF ( present( cci ) ) cci(ix,kz,jy) = an(ix,1,kz,lni)
3510 csw(ix,kz,jy) = an(ix,1,kz,lns)
3511 chw(ix,kz,jy) = an(ix,1,kz,lnh)
3512 IF ( lhl > 1 ) chl(ix,kz,jy) = an(ix,1,kz,lnhl)
3513 ENDIF
3514
3515 IF ( ipconc >= 6 ) THEN
3516 IF ( lzr > 0 ) zrw(ix,kz,jy) = an(ix,1,kz,lzr) *zscaleinv
3517 IF ( lzh > 0 ) zhw(ix,kz,jy) = an(ix,1,kz,lzh) *zscaleinv
3518 IF ( lzhl > 0 ) zhl(ix,kz,jy) = an(ix,1,kz,lzhl)*zscaleinv
3519 ENDIF
3520
3521
3522
3523 IF ( lvh > 0 .and. present( vhw ) ) vhw(ix,kz,jy) = an(ix,1,kz,lvh)
3524 IF ( lvhl > 0 .and. present( vhl ) ) vhl(ix,kz,jy) = an(ix,1,kz,lvhl)
3525
3526#if ( WRF_CHEM == 1 )
3527 IF ( has_wetscav ) THEN
3528 IF ( loopmax > 1 ) THEN
3529 ! wrferror not supported
3530 ENDIF
3531 IF ( PRESENT( rainprod ) ) rainprod(ix,kz,jy) = rainprod2d(ix,kz)
3532 IF ( PRESENT( evapprod ) ) evapprod(ix,kz,jy) = evapprod2d(ix,kz)
3533 ENDIF
3534#endif
3535
3536 ENDDO
3537 ENDDO
3538
3539 ENDDO ! jy
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549 RETURN
3550END SUBROUTINE nssl_2mom_driver
3551
3552! #####################################################################
3553! #####################################################################
3554
3557 REAL function gamma_sp(xx)
3558
3559 implicit none
3560 real xx
3561 integer j
3562
3563 double precision :: ser,stp,tmp,x,y,cof(6)
3564 SAVE cof,stp
3565 DATA cof /76.18009172947146d+0, &
3566 & -86.50532032941677d0, &
3567 & 24.01409824083091d0, &
3568 & -1.231739572450155d0, &
3569 & 0.1208650973866179d-2,&
3570 & -0.5395239384953d-5/
3571 DATA stp/2.5066282746310005d0/
3572
3573 IF ( xx <= 0.0 ) THEN
3574 write(0,*) 'Argument to gamma must be > 0!! xx = ',xx
3575 ENDIF
3576
3577 x = xx
3578 y = x
3579 tmp = x + 5.5d0
3580 tmp = (x + 0.5d0)*log(tmp) - tmp
3581 ser = 1.000000000190015d0
3582 DO j=1,6
3583 y = y + 1.0d0
3584 ser = ser + cof(j)/y
3585 END DO
3586 gamma_sp = exp(tmp + log(stp*ser/x))
3587
3588 RETURN
3589 END FUNCTION gamma_sp
3590
3591! #####################################################################
3592
3595 DOUBLE PRECISION FUNCTION gamma_dpr(x)
3596 ! dp gamma with real input
3597 implicit none
3598 real :: x
3599 double precision :: xx
3600
3601 xx = x
3602
3603 gamma_dpr = gamma_dp(xx)
3604
3605 return
3606 end FUNCTION gamma_dpr
3607
3608
3609
3610
3611! #####################################################################
3612
3615 real function gamxinf(a1,x1)
3616
3617! ===================================================
3618! Purpose: Compute the incomplete gamma function
3619! from x to infinity
3620! Input : a --- Parameter ( a 170 )
3621! x --- Argument
3622! Output: GIM --- gamma(a,x) t=x,Infinity
3623! Routine called: GAMMA for computing gamma(x)
3624! ===================================================
3625
3626! IMPLICIT DOUBLE PRECISION (A-H,O-Z)
3627 implicit none
3628 real :: a1,x1
3629 double precision :: xam,dlog,s,r,ga,t0,a,x
3630 integer :: k
3631 double precision :: gin, gim
3632
3633 a = a1
3634 x = x1
3635 IF ( x1 <= 0.0 ) THEN
3636 gamxinf = gamma_sp(a1)
3637 return
3638 ENDIF
3639 xam=-x+a*dlog(x)
3640 IF (xam.GT.700.0.OR.a.GT.170.0) THEN
3641 WRITE(*,*)'a and/or x too large'
3642 ENDIF
3643 IF (x.EQ.0.0) THEN
3644 gin=0.0
3645 gim = gamma_sp(a1)
3646 ELSE IF (x.LE.1.0+a) THEN
3647 s=1.0d0/a
3648 r=s
3649 DO 10 k=1,60
3650 r=r*x/(a+k)
3651 s=s+r
3652 IF (dabs(r/s).LT.1.0d-15) GO TO 15
365310 CONTINUE
365415 gin=dexp(xam)*s
3655 ga = gamma_sp(a1)
3656 gim=ga-gin
3657 ELSE IF (x.GT.1.0+a) THEN
3658 t0=0.0d0
3659 DO 20 k=60,1,-1
3660 t0=(k-a)/(1.0d0+k/(x+t0))
366120 CONTINUE
3662 gim=dexp(xam)/(x+t0)
3663! GA = GAMMA_SP(A1)
3664! GIN=GA-GIM
3665 ENDIF
3666
3667 gamxinf = gim
3668 return
3669 END function gamxinf
3670
3671! #####################################################################
3672
3675 double precision function gamxinfdp(A1,X1)
3676
3677! ===================================================
3678! Purpose: Compute the incomplete gamma function
3679! from x to infinity
3680! Input : a --- Parameter ( a < 170 )
3681! x --- Argument
3682! Output: GIM --- Gamma(a,x) t=x,Infinity
3683! Routine called: GAMMA for computing gamma_dp(x)
3684! ===================================================
3685
3686! IMPLICIT DOUBLE PRECISION (A-H,O-Z)
3687 implicit none
3688 real :: a1,x1
3689! dont declare gamma_dp because it is within the module
3690! double precision :: gamma_dp
3691 double precision :: xam,dlog,s,r,ga,t0,a,x
3692 integer :: k
3693 double precision :: gin, gim
3694
3695 a = a1
3696 x = x1
3697 IF ( x1 <= 0.0 ) THEN
3698 gamxinfdp = gamma_dp(a)
3699 return
3700 ENDIF
3701 xam=-x+a*dlog(x)
3702 IF (xam.GT.700.0.OR.a.GT.170.0) THEN
3703 WRITE(*,*)'a and/or x too large'
3704 ENDIF
3705 IF (x.EQ.0.0) THEN
3706 gin=0.0
3707 gim = gamma_dp(a)
3708 ELSE IF (x.LE.1.0+a) THEN
3709 s=1.0d0/a
3710 r=s
3711 DO 10 k=1,60
3712 r=r*x/(a+k)
3713 s=s+r
3714 IF (dabs(r/s).LT.1.0d-15) GO TO 15
371510 CONTINUE
371615 gin=dexp(xam)*s
3717 ga = gamma_dp(a)
3718 gim=ga-gin
3719 ELSE IF (x.GT.1.0+a) THEN
3720 t0=0.0d0
3721 DO 20 k=60,1,-1
3722 t0=(k-a)/(1.0d0+k/(x+t0))
372320 CONTINUE
3724 gim=dexp(xam)/(x+t0)
3725! GA = GAMMA_dp(A)
3726! GIN=GA-GIM
3727 ENDIF
3728
3729 gamxinfdp = gim
3730 return
3731 END function gamxinfdp
3732
3733
3734! #####################################################################
3735
3738 real function gaminterp(ratio, alp, luindex, ilh)
3739
3740 implicit none
3741
3742 real, intent(in) :: ratio, alp
3743 integer, intent(in) :: ilh ! 1 = graupel, 2 = hail
3744 integer, intent(in) :: luindex ! which argument:
3745 ! gamxinflu(i,j,1,1) = x/y
3746 ! gamxinflu(i,j,2,1) = gamxinf( 2.0+alp, ratio )/y
3747 ! gamxinflu(i,j,3,1) = gamxinf( 2.5+alp+0.5*bxh, ratio )/y
3748 ! gamxinflu(i,j,5,1) = gamxinf( 5.0+alp, ratio )/y
3749 ! gamxinflu(i,j,6,1) = gamxinf( 5.5+alp+0.5*bxh, ratio )/y
3750
3751
3752 real :: delx, dely, tmp1, tmp2, temp3
3753 integer :: i,j,ip1,jp1 !,ilh
3754
3755! ilh = Abs(ilh0)
3756
3757
3758 i = min(nqiacrratio,int(ratio*dqiacrratioinv))
3759 j = int(max(0.0,min(maxalphalu,alp))*dqiacralphainv)
3760 delx = min(maxratiolu,ratio) - float(i)*dqiacrratio
3761 dely = alp - float(j)*dqiacralpha
3762 ip1 = min( i+1, nqiacrratio )
3763 jp1 = min( j+1, nqiacralpha )
3764
3765 ! interpolate along x, i.e., ratio;
3766 tmp1 = gamxinflu(i,j,luindex,ilh) + delx*dqiacrratioinv* &
3767 & (gamxinflu(ip1,j,luindex,ilh) - gamxinflu(i,j,luindex,ilh))
3768 tmp2 = gamxinflu(i,jp1,luindex,ilh) + delx*dqiacrratioinv* &
3769 & (gamxinflu(ip1,jp1,luindex,ilh) - gamxinflu(i,jp1,luindex,ilh))
3770
3771 ! interpolate along alpha;
3772
3773 gaminterp = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))
3774
3775 ! debug
3776! IF ( ilh0 < 0 ) THEN
3777! write(0,*) 'gaminterp: ',i,j,ilh,ratio,delx,dely,gamxinflu(i,j,luindex,ilh),tmp1,tmp2
3778! ENDIF
3779
3780 END FUNCTION gaminterp
3781! #####################################################################
3782
3783!**************************** GAML02 ***********************
3784! This calculates Gamma(0.2,x)/Gamma[0.2], where is a ratio
3785! It is used for qiacr with the gamma of volume to calculate what
3786! fraction of drops exceed a certain size (this version is for 40 micron drops)
3787! **********************************************************
3790 real function gaml02(x)
3791 implicit none
3792 integer ig, i, ii, n, np
3793 real x
3794 integer ng
3795 parameter(ng=12)
3796 real gamxg(ng), xg(ng)
3797 DATA xg/0.01,0.02,0.025,0.04,0.075,0.1,0.25,0.5,0.75,1.,2.,10./
3798 DATA gamxg/ &
3799 & 7.391019203578037e-8,0.02212726874591478,0.06959352407989682, &
3800 & 0.2355654024970809,0.46135930387500346,0.545435791452399, &
3801 & 0.7371571313308203, &
3802 & 0.8265676632204345,0.8640182781845841,0.8855756211304151, &
3803 & 0.9245079225301251, &
3804 & 0.9712578342732681/
3805 IF ( x .ge. xg(ng) ) THEN
3806 gaml02 = xg(ng)
3807 RETURN
3808 ENDIF
3809 IF ( x .lt. xg(1) ) THEN
3810 gaml02 = 0.0
3811 RETURN
3812 ENDIF
3813 DO ii = 1,ng-1
3814 i = ng - ii
3815 n = i
3816 np = n + 1
3817 IF ( x .ge. xg(i) ) THEN
3818! GOTO 2
3819 gaml02 = gamxg(n)+((x-xg(n))/(xg(np)-xg(n)))* &
3820 & ( gamxg(np) - gamxg(n) )
3821 RETURN
3822 ENDIF
3823 ENDDO
3824 RETURN
3825 END FUNCTION gaml02
3826
3827!**************************** GAML02d300 ***********************
3828! This calculates Gamma(0.2,x)/Gamma[0.2], where is a ratio
3829! It is used for qiacr with the gamma of volume to calculate what
3830! fraction of drops exceed a certain size (this version is for 300 micron drops) (see zieglerstuff.nb)
3831! **********************************************************
3834 real function gaml02d300(x)
3835 implicit none
3836 integer ig, i, ii, n, np
3837 real x
3838 integer ng
3839 parameter(ng=9)
3840 real gamxg(ng), xg(ng)
3841 DATA xg/0.04,0.075,0.1,0.25,0.5,0.75,1.,2.,10./
3842 DATA gamxg/ &
3843 & 0.0, &
3844 & 7.391019203578011e-8,0.0002260640810600053, &
3845 & 0.16567071824457152, &
3846 & 0.4231369044918005,0.5454357914523988, &
3847 & 0.6170290936864555, &
3848 & 0.7471346054110058,0.9037156157718299 /
3849 IF ( x .ge. xg(ng) ) THEN
3850 gaml02d300 = xg(ng)
3851 RETURN
3852 ENDIF
3853 IF ( x .lt. xg(1) ) THEN
3854 gaml02d300 = 0.0
3855 RETURN
3856 ENDIF
3857 DO ii = 1,ng-1
3858 i = ng - ii
3859 n = i
3860 np = n + 1
3861 IF ( x .ge. xg(i) ) THEN
3862! GOTO 2
3863 gaml02d300 = gamxg(n)+((x-xg(n))/(xg(np)-xg(n)))* &
3864 & ( gamxg(np) - gamxg(n) )
3865 RETURN
3866 ENDIF
3867 ENDDO
3868 RETURN
3869 END FUNCTION gaml02d300
3870!c
3871
3872! #####################################################################
3873! #####################################################################
3874
3875!**************************** GAML02 ***********************
3876! This calculates Gamma(0.2,x)/Gamma[0.2], where is a ratio
3877! It is used for qiacr with the gamma of volume to calculate what
3878! fraction of drops exceed a certain size (this version is for 500 micron drops) (see zieglerstuff.nb)
3879! **********************************************************
3882 real function gaml02d500(x)
3883 implicit none
3884 integer ig, i, ii, n, np
3885 real x
3886 integer ng
3887 parameter(ng=9)
3888 real gamxg(ng), xg(ng)
3889 DATA xg/0.04,0.075,0.1,0.25,0.5,0.75,1.,2.,10./
3890 DATA gamxg/ &
3891 & 0.0,0.0, &
3892 & 2.2346039e-13, 0.0221272687459, &
3893 & 0.23556540, 0.38710348, &
3894 & 0.48136183,0.6565833, &
3895 & 0.86918315 /
3896 IF ( x .ge. xg(ng) ) THEN
3897 gaml02d500 = xg(ng)
3898 RETURN
3899 ENDIF
3900 IF ( x .lt. xg(1) ) THEN
3901 gaml02d500 = 0.0
3902 RETURN
3903 ENDIF
3904 DO ii = 1,ng-1
3905 i = ng - ii
3906 n = i
3907 np = n + 1
3908 IF ( x .ge. xg(i) ) THEN
3909! GOTO 2
3910 gaml02d500 = gamxg(n)+((x-xg(n))/(xg(np)-xg(n)))* &
3911 & ( gamxg(np) - gamxg(n) )
3912 RETURN
3913 ENDIF
3914 ENDDO
3915 RETURN
3916 END FUNCTION gaml02d500
3917!c
3918
3919! #####################################################################
3920
3921! #####################################################################
3922
3923
3924 real function beta(p,q)
3925!
3926! ==========================================
3927! Purpose: Compute the beta function B(p,q)
3928! Input : p --- Parameter ( p > 0 )
3929! q --- Parameter ( q > 0 )
3930! Output: BT --- B(p,q)
3931! Routine called: GAMMA for computing gamma(x)
3932! ==========================================
3933!
3934! IMPLICIT real (A-H,O-Z)
3935 implicit none
3936 double precision p1,gp,q1,gq, ppq,gpq
3937 real p,q
3938
3939 p1 = p
3940 q1 = q
3941 CALL gammadp(p1,gp)
3942 CALL gammadp(q1,gq)
3943 ppq=p1+q1
3944 CALL gammadp(ppq,gpq)
3945 beta=gp*gq/gpq
3946 RETURN
3947 END function beta
3948
3949! #####################################################################
3950! #####################################################################
3951
3954 DOUBLE PRECISION FUNCTION gamma_dp(xx)
3955
3956 implicit none
3957 double precision :: xx
3958 integer j
3959
3960 double precision ser,stp,tmp,x,y,cof(6)
3961 SAVE cof,stp
3962 DATA cof /76.18009172947146d+0, &
3963 & -86.50532032941677d0, &
3964 & 24.01409824083091d0, &
3965 & -1.231739572450155d0, &
3966 & 0.1208650973866179d-2,&
3967 & -0.5395239384953d-5/
3968 DATA stp/2.5066282746310005d0/
3969
3970 x = xx
3971 y = x
3972 tmp = x + 5.5d0
3973 tmp = (x + 0.5d0)*log(tmp) - tmp
3974 ser = 1.000000000190015d0
3975 DO j=1,6
3976 y = y + 1.0d0
3977 ser = ser + cof(j)/y
3978 END DO
3979 gamma_dp = exp(tmp + log(stp*ser/x))
3980
3981 RETURN
3982 END function gamma_dp
3983! #####################################################################
3984
3987 SUBROUTINE gammadp(X,GA)
3988!
3989! ==================================================
3990! Purpose: Compute gamma function Gamma(x)
3991! Input : x --- Argument of Gamma(x)
3992! ( x is not equal to 0,-1,-2,...)
3993! Output: GA --- gamma(x)
3994! ==================================================
3995!
3996! IMPLICIT DOUBLE PRECISION (A-H,O-Z)
3997 implicit none
3998
3999 double precision, parameter :: pi=3.141592653589793d0
4000 double precision :: x,ga,z,r,gr
4001 integer :: k,m1,m
4002
4003 double precision :: g(26)
4004
4005 DATA g/1.0d0,0.5772156649015329d0, &
4006 & -0.6558780715202538d0, -0.420026350340952d-1, &
4007 & 0.1665386113822915d0,-.421977345555443d-1, &
4008 & -.96219715278770d-2, .72189432466630d-2, &
4009 & -.11651675918591d-2, -.2152416741149d-3, &
4010 & .1280502823882d-3, -.201348547807d-4, &
4011 & -.12504934821d-5, .11330272320d-5, &
4012 & -.2056338417d-6, .61160950d-8, &
4013 & .50020075d-8, -.11812746d-8, &
4014 & .1043427d-9, .77823d-11, &
4015 & -.36968d-11, .51d-12, &
4016 & -.206d-13, -.54d-14, .14d-14, .1d-15/
4017
4018 IF (x.EQ.int(x)) THEN
4019 IF (x.GT.0.0d0) THEN
4020 ga=1.0d0
4021 m1=x-1
4022 DO k=2,m1
4023 ga=ga*k
4024 ENDDO
4025 ELSE
4026 ga=1.0d+300
4027 ENDIF
4028 ELSE
4029 IF (dabs(x).GT.1.0d0) THEN
4030 z=dabs(x)
4031 m=int(z)
4032 r=1.0d0
4033 DO k=1,m
4034 r=r*(z-k)
4035 ENDDO
4036 z=z-m
4037 ELSE
4038 z=x
4039 ENDIF
4040 gr=g(26)
4041 DO k=25,1,-1
4042 gr=gr*z+g(k)
4043 ENDDO
4044 ga=1.0d0/(gr*z)
4045 IF (dabs(x).GT.1.0d0) THEN
4046 ga=ga*r
4047 IF (x.LT.0.0d0) ga=-pi/(x*ga*dsin(pi*x))
4048 ENDIF
4049 ENDIF
4050 RETURN
4051 END SUBROUTINE gammadp
4052
4053
4054! #####################################################################
4055! #####################################################################
4056!
4057!
4058! #####################################################################
4061 Function delbk(bb,nu,mu,k)
4062!
4063! Purpose: Caluculates collection coefficients following Siefert (2006)
4064!
4065! delbk is equation (90) (b collecting b -- self-collection)
4066! mass-diameter relationship: D = a*x**(b), where x = particle mass
4067! general distribution: n(x) = A*x**(nu)*Exp(-lam*x**(mu))
4068! where
4069! A = mu*N/(Gamma((nu+1)/mu)) *lam**((nu+1)/mu)
4070!
4071! lam = ( Gamma((nu+1)/mu)/Gamma((nu+2)/mu) * xbar )**(-mu)
4072!
4073! where xbar = L/N (mass content)/(number concentration) = q*rhoa/N
4074!
4075
4076 implicit none
4077 real delbk
4078 real nu, mu, bb
4079 integer k
4080
4081 real tmp, del
4082 real x1, x2, x3, x4
4083 integer i
4084
4085 tmp = ((1.0 + nu)/mu)
4086 i = int(dgami*(tmp))
4087 del = tmp - dgam*i
4088 x1 = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4089
4090 tmp = ((2.0 + nu)/mu)
4091 i = int(dgami*(tmp))
4092 del = tmp - dgam*i
4093 x2 = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4094
4095 tmp = ((1.0 + 2.0*bb + k + nu)/mu)
4096 i = int(dgami*(tmp))
4097 del = tmp - dgam*i
4098 x3 = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4099
4100! delbk = &
4101! & ((Gamma_sp((1.0 + nu)/mu)/Gamma_sp((2.0 + nu)/mu))**(2.0*bb + k)* &
4102! & Gamma_sp((1.0 + 2.0*bb + k + nu)/mu))/Gamma_sp((1.0 + nu)/mu)
4103
4104 delbk = &
4105 & ((x1/x2)**(2.0*bb + k)* &
4106 & x3)/x1
4107
4108 RETURN
4109 END Function delbk
4110
4111! #####################################################################
4112!
4113!
4114! #####################################################################
4115! Equation (91) in Seifert and Beheng (2006) ("a" collecting "b")
4118 Function delabk(ba,bb,nua,nub,mua,mub,k)
4119
4120 implicit none
4121 real delabk
4122 real nua, mua, ba
4123 integer k
4124 real nub, mub, bb
4125
4126 integer i
4127 real tmp,del
4128
4129 real g1pnua, g2pnua, g1pbapnua, g1pbbpk, g1pnub, g2pnub
4130
4131 tmp = (1. + nua)/mua
4132 i = int(dgami*(tmp))
4133 del = tmp - dgam*i
4134 IF ( i+1 > ngm0 ) THEN
4135 write(0,*) 'delabk: i+1 > ngm0!!!!',i,ngm0,nua,mua,tmp
4136 ENDIF
4137 g1pnua = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4138! write(91,*) 'delabk: g1pnua,gamma = ',g1pnua,Gamma_sp((1. + nua)/mua)
4139
4140 tmp = ((2. + nua)/mua)
4141 i = int(dgami*(tmp))
4142 del = tmp - dgam*i
4143 g2pnua = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4144
4145 tmp = ((1. + ba + nua)/mua)
4146 i = int(dgami*(tmp))
4147 del = tmp - dgam*i
4148 g1pbapnua = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4149
4150 tmp = ((1. + nub)/mub)
4151 i = int(dgami*(tmp))
4152 del = tmp - dgam*i
4153 g1pnub = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4154
4155 tmp = ((2 + nub)/mub)
4156 i = int(dgami*(tmp))
4157 del = tmp - dgam*i
4158 g2pnub = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4159
4160 tmp = ((1. + bb + k + nub)/mub)
4161 i = int(dgami*(tmp))
4162 del = tmp - dgam*i
4163 g1pbbpk = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4164
4165 delabk = &
4166 & (2.*(g1pnua/g2pnua)**ba* &
4167 & g1pbapnua* &
4168 & (g1pnub/g2pnub)**(bb + k)* &
4169 & g1pbbpk)/ &
4170 & (g1pnua*g1pnub)
4171
4172 RETURN
4173 END Function delabk
4174
4175
4176
4177! #######################################################################
4178! HAILMAXD - calculated maximum expected hail size
4179! #######################################################################
4182 subroutine hailmaxd(dtp,nx,ny,nz,an,na,nor,norz,alpha2d,dn, &
4183 & hailmax1d,hailmaxk1,jslab )
4184!
4185! Calculate maximum hail size from the tail of of the distribution. The value
4186! of thresh_conc sets the minimum concentration in the integral over (Dmax, Inf).
4187! This uses the lookup tables for incomplete gamma functions and simply search for
4188! the expected value (and linearly interpolate) on D.
4189!
4190! Written by ERM 7/2023
4191!
4192!
4193!
4194 implicit none
4195
4196 integer nx,ny,nz,nor,norz,ngt,jgs,na,ia
4197 integer id ! =1 use density, =0 no density
4198! integer :: its,ite ! x-range to calculate
4199
4200 integer ng1
4201 parameter(ng1 = 1)
4202
4203 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
4204 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4205
4206! real gz(-nor+ng1:nz+nor),z1d(-nor+ng1:nz+nor,4)
4207 real dtp
4208 real alpha2d(-nor+1:nx+nor,1,-norz+1:nz+norz,3) ! array for PSD shape parameters
4209 real :: hailmax1d(nx,ny),hailmaxk1(nx,ny)
4210 integer infdo
4211 integer jslab ! which line of xfall to use
4212
4213 integer ix,jy,kz,ndfall,n,k,il,in
4214 double precision :: tmp, ratio, del, g1palp
4215 real, parameter :: dz = 200.
4216
4217 real :: db1(nx,nz+1),dtz1(nz+1,nx,0:1),dz2dinv(nz+1,nx),db1inv(nx,nz+1)
4218
4219 real :: rhovtzx(nz,nx)
4220
4221 real :: alp, diam, diam1, hwdn
4222
4223! real, parameter :: cmin = 0.001 ! threshold number per m^3 for maximum diamter (threshold from diag_nwp)
4224 DOUBLE PRECISION, PARAMETER:: thresh_conc = 0.0005d0 ! number conc. of graupel/hail per cubic meter
4225 real :: cwchtmp,cwchltmp, maxdia
4226
4227!-----------------------------------------------------------------------------
4228
4229 integer :: ixb, jyb, kzb
4230 integer :: ixe, jye, kze
4231 integer :: plo, phi
4232 integer :: ialp, i, j
4233
4234 logical :: debug_mpi = .false.
4235
4236! ###################################################################
4237
4238
4239 IF ( lh > 1 ) THEN
4240 cwchtmp = ((3. + dnu(lh))*(2. + dnu(lh))*(1.0 + dnu(lh)))**(-1./3.)
4241 ENDIF
4242 IF ( lhl > 1 ) THEN
4243 cwchltmp = ((3. + dnu(lhl))*(2. + dnu(lhl))*(1.0 + dnu(lhl)))**(-1./3.)
4244 ENDIF
4245
4246
4247 kzb = 1
4248 kze = nz
4249
4250 ixb = 1 ! aliased its
4251 ixe = nx ! aliased ite
4252
4253
4254 jy = jslab
4255 jgs = jy
4256
4257
4258! hailmax1d(:,jy) = 0.0
4259! hailmaxk1(:,jy) = 0.0
4260
4261 if ( ndebug .gt. 0 ) write(0,*) 'dbg = 3a'
4262
4263
4264! first graupel, even if hail is also predicted, since graupel can sometime be large on its own
4265 IF ( lh > 1 .and. lnh > 1 ) THEN
4266 DO kz = kzb,kze
4267 DO ix = ixb,ixe
4268 IF ( an(ix,jy,kz,lh) .gt. qxmin(lh) .and. an(ix,jy,kz,lnh) .gt. thresh_conc ) THEN
4269 IF ( lvh .gt. 1 ) THEN
4270 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
4271 ELSE
4272 hwdn = rho_qh
4273 ENDIF
4274
4275 tmp = 1. + alpha2d(ix,1,kz,2)
4276 i = int(dgami*(tmp))
4277 del = tmp - dgam*i
4278 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4279
4280 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lh)/(hwdn*an(ix,jy,kz,lnh))
4281 diam = (6.0*tmp/pi)**(1./3.)
4282 IF ( lzh > 1 ) THEN ! 3moment
4283 cwchtmp = ((3. + alpha2d(ix,1,kz,2))*(2. + alpha2d(ix,1,kz,2))*(1.0 + alpha2d(ix,1,kz,2)))**(-1./3.)
4284 ENDIF
4285 diam1 = diam*cwchtmp ! characteristic diameter, i.e., 1/lambda
4286 ! want cxd1 = thresh_conc
4287 ! tmp = gaminterp(ratio,alpha(mgs,lh),1,1)
4288 ! cxd1 = cx(mgs,lh)*(tmp)/g1palp
4289 ! tmp = thresh_conc*g1palp/cx
4290 !
4291 tmp = thresh_conc*g1palp/an(ix,jy,kz,lnh)
4292 alp = alpha2d(ix,1,kz,2)
4293 ! gamxinflu(i,j,luindex,ilh)
4294 j = int(max(0.0,min(maxalphalu,alp))*dqiacralphainv)
4295 ratio = 0.0
4296 maxdia = 0.0
4297 ! eventually could replace with bisection search, but final value of i is usually small
4298 ! compared to nqiacrratio
4299 DO i = 0,nqiacrratio-1
4300 IF ( gamxinflu(i,j,1,1) >= tmp .and. tmp >= gamxinflu(i+1,j,1,1) ) THEN
4301 ! interpolate here for FWIW
4302 ratio = i*dqiacrratio
4303 del = tmp - gamxinflu(i,j,1,1)
4304 ratio = (float(i) + del/(gamxinflu(i+1,j,1,1) - gamxinflu(i,j,1,1)))*dqiacrratio
4305 exit
4306 ENDIF
4307 ENDDO
4308
4309 IF ( ratio > 0.0 ) THEN
4310 maxdia = ratio*diam1 ! units of m
4311 ENDIF
4312
4313 IF ( kz == kzb ) THEN
4314 hailmaxk1(ix,jy) = max( maxdia, hailmaxk1(ix,jy) )
4315! IF ( maxdia > 0.1 ) THEN
4316! IF ( an(ix,jy,kz,lh) > 1.e-4 ) THEN
4317! write(0,*) 'maxdia,tmp,alp,ratio,diam,diam1= ',maxdia,tmp,alp,ratio,diam*100.,diam1*100.
4318! write(0,*) 'hwdn, cxhl, qx, g1palp = ',hwdn, an(ix,jy,kz,lnhl), an(ix,jy,kz,lhl), g1palp
4319! write(0,*) 'j,gamxinflu(0,2,4) = ',j,gamxinflu(0,j,1,1),gamxinflu(2,j,1,1), &
4320! gamxinflu(4,j,1,1)
4321! ENDIF
4322 ENDIF
4323
4324 hailmax1d(ix,jy) = max(maxdia, hailmax1d(ix,jy) )
4325
4326 !
4327
4328 ENDIF
4329
4330 ENDDO
4331 ENDDO
4332
4333 ENDIF ! lh
4334
4335! And diam for hail if present
4336 IF ( lhl > 1 .and. lnhl > 1 ) THEN
4337 DO kz = kzb,kze
4338 DO ix = ixb,ixe
4339 IF ( an(ix,jy,kz,lhl) .gt. qxmin(lhl) .and. an(ix,jy,kz,lnhl) .gt. thresh_conc ) THEN
4340 IF ( lvhl .gt. 1 ) THEN
4341 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
4342 ELSE
4343 hwdn = rho_qhl
4344 ENDIF
4345
4346 tmp = 1. + alpha2d(ix,1,kz,3)
4347 i = int(dgami*(tmp))
4348 del = tmp - dgam*i
4349 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
4350
4351 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/(hwdn*an(ix,jy,kz,lnhl))
4352 diam = (6.0*tmp/pi)**(1./3.)
4353 IF ( lzhl > 1 ) THEN ! 3moment
4354 cwchltmp = ((3. + alpha2d(ix,1,kz,3))*(2. + alpha2d(ix,1,kz,3))*(1.0 + alpha2d(ix,1,kz,3)))**(-1./3.)
4355 ENDIF
4356 diam1 = diam*cwchltmp ! characteristic diameter, i.e., 1/lambda
4357 ! want cxd1 = thresh_conc
4358 ! tmp = gaminterp(ratio,alpha(mgs,lh),1,1)
4359 ! cxd1 = cx(mgs,lh)*(tmp)/g1palp
4360 ! tmp = thresh_conc*g1palp/cx
4361 !
4362 tmp = thresh_conc*g1palp/an(ix,jy,kz,lnhl)
4363 alp = alpha2d(ix,1,kz,3)
4364 ! gamxinflu(i,j,luindex,ilh)
4365 j = int(max(0.0,min(maxalphalu,alp))*dqiacralphainv)
4366 ratio = 0.0
4367 maxdia = 0.0
4368 ! eventually could replace with bisection search, but final value of i is usually small
4369 ! compared to nqiacrratio
4370 DO i = 0,nqiacrratio-1
4371 IF ( gamxinflu(i,j,1,1) >= tmp .and. tmp >= gamxinflu(i+1,j,1,1) ) THEN
4372 ! interpolate here for FWIW
4373 ratio = i*dqiacrratio
4374 del = tmp - gamxinflu(i,j,1,1)
4375 ratio = (float(i) + del/(gamxinflu(i+1,j,1,1) - gamxinflu(i,j,1,1)))*dqiacrratio
4376 exit
4377 ENDIF
4378 ENDDO
4379
4380 IF ( ratio > 0.0 ) THEN
4381 maxdia = ratio*diam1 ! units of m
4382 ENDIF
4383
4384 IF ( kz == kzb ) THEN
4385 hailmaxk1(ix,jy) = max( maxdia, hailmaxk1(ix,jy) )
4386! IF ( maxdia > 0.1 ) THEN
4387! IF ( an(ix,jy,kz,lhl) > 1.e-4 ) THEN
4388! write(0,*) 'maxdia,tmp,alp,ratio,diam,diam1= ',maxdia,tmp,alp,ratio,diam*100.,diam1*100.
4389! write(0,*) 'hwdn, cxhl, qx, g1palp = ',hwdn, an(ix,jy,kz,lnhl), an(ix,jy,kz,lhl), g1palp
4390! write(0,*) 'j,gamxinflu(0,2,4) = ',j,gamxinflu(0,j,1,1),gamxinflu(2,j,1,1), &
4391! gamxinflu(4,j,1,1)
4392! ENDIF
4393 ENDIF
4394
4395 hailmax1d(ix,jy) = max(maxdia, hailmax1d(ix,jy) )
4396
4397 !
4398
4399 ENDIF
4400
4401 ENDDO
4402 ENDDO
4403
4404 ENDIF
4405
4406
4407 END SUBROUTINE hailmaxd
4408! #######################################################################
4409! #######################################################################
4412 subroutine sediment1d(dtp,nx,ny,nz,an,na,nor,norz,xfall,dn,dz3d,dz3dinv, &
4413 & t0,t7,infdo,jslab,its,jts, &
4414 & timesed1,timesed2,timesed3,zmaxsed,timesetvt) ! used for timing
4415!
4416! Sedimentation driver -- column by column
4417!
4418! Written by ERM 10/2011
4419!
4420!
4421!
4422 implicit none
4423
4424 integer nx,ny,nz,nor,norz,ngt,jgs,na,ia
4425 integer id ! =1 use density, =0 no density
4426 integer :: its,jts ! SW point of local tile
4427
4428 integer ng1
4429 parameter(ng1 = 1)
4430
4431 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
4432 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4433 real dz3d(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4434 real dz3dinv(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4435 real t0(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4436 real t7(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
4437
4438! real gz(-nor+ng1:nz+nor),z1d(-nor+ng1:nz+nor,4)
4439 real dtp
4440 real xfall(nx,ny,na) ! array for stuff landing on the ground
4441 integer infdo
4442 integer jslab ! which line of xfall to use
4443
4444 integer ix,jy,kz,ndfall,n,k,il,in
4445 real tmp, vtmax, dtptmp, dtfrac
4446 real, parameter :: dz = 200.
4447
4448 real, allocatable :: db1(:,:), dtz1(:,:,:),dz2dinv(:,:),db1inv(:,:) ! db1(nx,nz+1),dtz1(nz+1,nx,0:1),dz2dinv(nz+1,nx),db1inv(nx,nz+1)
4449 real, allocatable :: rhovtzx(:,:)
4450 real, allocatable :: xfall0(:,:), xvt(:,:,:,:),tmpn(:,:,:),tmpn2(:,:,:),z(:,:,:)
4451
4452 double precision :: timesed1,timesed2,timesed3, zmaxsed,timesetvt,dummy
4453 double precision :: dt1,dt2,dt3,dt4
4454
4455 integer :: ngs ! = 512
4456 integer :: ngscnt,mgs,ipconc0
4457
4458
4459 real, allocatable :: qx(:,:)
4460 real, allocatable :: qxw(:,:)
4461 real, allocatable :: cx(:,:)
4462 real, allocatable :: xv(:,:)
4463 real, allocatable :: vtxbar(:,:,:)
4464 real, allocatable :: xmas(:,:)
4465 real, allocatable :: xdn(:,:)
4466 real, allocatable :: xdia(:,:,:)
4467 real, allocatable :: vx(:,:)
4468 real, allocatable :: alpha(:,:)
4469 real, allocatable :: zx(:,:)
4470 logical, allocatable :: hasmass(:,:)
4471
4472 integer, allocatable :: igs(:),kgs(:)
4473
4474 real, allocatable :: rho0(:),temcg(:)
4475
4476 real, allocatable :: temg(:)
4477
4478 real, allocatable :: rhovt(:)
4479
4480 real, allocatable :: cwnc(:),cinc(:)
4481 real, allocatable :: fadvisc(:),cwdia(:),cipmas(:)
4482
4483 real, allocatable :: cnina(:),cimas(:)
4484
4485 real, allocatable :: cnostmp(:)
4486
4487 real :: cimasn,cimasx
4488
4489
4490!-----------------------------------------------------------------------------
4491
4492 integer :: ixb, jyb, kzb
4493 integer :: ixe, jye, kze
4494 integer :: plo, phi
4495
4496! ###################################################################
4497
4498
4499 allocate( db1(nx,nz+1),dtz1(nz+1,nx,0:1),dz2dinv(nz+1,nx),db1inv(nx,nz+1),rhovtzx(nz,nx) )
4500 allocate( xfall0(nx,ny), xvt(nz+1,nx,3,lc:lhab), tmpn(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz) )
4501 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))
4502
4503 ngs = nz+3
4504
4505 allocate( qx(ngs,lv:lhab), &
4506 qxw(ngs,ls:lhab), &
4507 cx(ngs,lc:lhab), &
4508 xv(ngs,lc:lhab), &
4509 vtxbar(ngs,lc:lhab,3), &
4510 xmas(ngs,lc:lhab), &
4511 xdn(ngs,lc:lhab), &
4512 xdia(ngs,lc:lhab,3), &
4513 vx(ngs,li:lhab), &
4514 alpha(ngs,lc:lhab), &
4515 zx(ngs,lr:lhab), &
4516 hasmass(nx,lc+1:lhab), &
4517 igs(ngs),kgs(ngs), &
4518 rho0(ngs),temcg(ngs),temg(ngs), rhovt(ngs), &
4519 cwnc(ngs),cinc(ngs), &
4520 fadvisc(ngs),cwdia(ngs),cipmas(ngs), &
4521 cnina(ngs),cimas(ngs), &
4522 cnostmp(ngs) )
4523
4524 kzb = 1
4525 kze = nz
4526
4527 ixb = 1
4528 ixe = nx
4529
4530
4531 jy = 1
4532 jgs = jy
4533
4534
4535!
4536! zero the precip flux arrays (2d)
4537!
4538
4539 xvt(:,:,:,:) = 0.0
4540
4541 if ( ndebug .gt. 0 ) write(0,*) 'dbg = 3a'
4542
4543
4544 DO kz = kzb,kze
4545 DO ix = ixb,ixe
4546 db1(ix,kz) = dn(ix,jy,kz)
4547 db1inv(ix,kz) = 1./dn(ix,jy,kz)
4548 rhovtzx(kz,ix) = sqrt(rho00*min(1.0/0.05, db1inv(ix,kz))) ! prevent excessive rhovt
4549 ENDDO
4550 ENDDO
4551
4552 DO kz = kzb,kze
4553 DO ix = ixb,ixe
4554 dtz1(kz,ix,0) = dz3dinv(ix,jy,kz)
4555 dtz1(kz,ix,1) = dz3dinv(ix,jy,kz)*db1inv(ix,kz)
4556 dz2dinv(kz,ix) = dz3dinv(ix,jy,kz)
4557 ENDDO
4558 ENDDO
4559
4560 IF ( lzh .gt. 1 ) THEN
4561 DO kz = kzb,kze
4562 DO ix = ixb,ixe
4563 an(ix,jy,kz,lzh) = max( 0., an(ix,jy,kz,lzh) )
4564 ENDDO
4565 ENDDO
4566 ENDIF
4567
4568
4569 DO il = lc+1,lhab
4570 DO ix = ixb,ixe
4571! hasmass(ix,il) = Any( an(ix,jy,:,il) > qxmin(il) )
4572 ENDDO
4573 ENDDO
4574
4575
4576
4577
4578 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3a2'
4579
4580! loop over columns
4581 DO ix = ixb,ixe
4582
4583 dummy = 0.d0
4584
4585
4586 call ziegfall1d(nx,ny,nz,nor,norz,na,dtp,jgs,ix, &
4587 & xvt, rhovtzx, &
4588 & an,dn,ipconc,t0,t7,cwmasn,cwmasx, &
4589 & cwradn, &
4590 & qxmin,xdnmx,xdnmn,cdx,cno,xdn0,xvmn,xvmx, &
4591 & ngs,qx,qxw,cx,xv,vtxbar,xmas,xdn,xdia,vx,alpha,zx,igs,kgs, &
4592 & rho0,temcg,temg,rhovt,cwnc,cinc,fadvisc,cwdia,cipmas,cnina,cimas, &
4593 & cnostmp, &
4594 & infdo,0 &
4595 & )
4596
4597
4598! loop over each species and do sedimentation for all moments
4599 DO il = lc,lhab
4600 IF ( ido(il) == 0 ) cycle
4601
4602! IF ( .not. hasmass(ix,il) ) CYCLE
4603
4604! plo = nz
4605! phi = 0
4606
4607
4608 vtmax = 0.0
4609
4610 do kz = kzb,kze
4611
4612 ! apply limit vtmaxsed (08/20/2015)
4613 xvt(kz,ix,1,il) = min( vtmaxsed, xvt(kz,ix,1,il) )
4614 xvt(kz,ix,2,il) = min( vtmaxsed, xvt(kz,ix,2,il) )
4615 xvt(kz,ix,3,il) = min( vtmaxsed, xvt(kz,ix,3,il) )
4616
4617 vtmax = max(vtmax,xvt(kz,ix,1,il)*dz2dinv(kz,ix))
4618 vtmax = max(vtmax,xvt(kz,ix,2,il)*dz2dinv(kz,ix))
4619 vtmax = max(vtmax,xvt(kz,ix,3,il)*dz2dinv(kz,ix))
4620
4621! IF ( dtp*xvt(kz,ix,1,il)*dz2dinv(kz,ix) >= 0.7 .or. &
4622! & dtp*xvt(kz,ix,2,il)*dz2dinv(kz,ix) >= 0.7 .or. &
4623! & dtp*xvt(kz,ix,3,il)*dz2dinv(kz,ix) >= 0.7 ) THEN
4624!
4625! zmaxsed = Max(zmaxsed, float(kz) )
4626!! plo = Min(plo,kz)
4627!! phi = Max(phi,kz)
4628!
4629! ENDIF
4630
4631 ENDDO
4632
4633 IF ( vtmax == 0.0 ) cycle
4634
4635
4636
4637 IF ( dtp*vtmax .lt. 0.7 ) THEN ! check whether multiple steps are needed.
4638 ndfall = 1
4639 ELSE
4640 IF ( dtp > 20.0 ) THEN ! more stringent subdivision for large time steps
4641 ndfall = max(2, int(dtp*vtmax/0.7) + 1)
4642 ELSE ! more relaxed for small time steps, but might still be a problem for very thin vertical layers near the ground
4643 ndfall = 1+int(dtp*vtmax + 0.301)
4644 ENDIF
4645 ENDIF
4646
4647 IF ( ndfall .gt. 1 ) THEN
4648 dtptmp = dtp/real(ndfall)
4649! write(0,*) 'subdivide fallout on its,jts,ix,plo,phi = ',its,jts,ix,plo,phi
4650! write(0,*) 'for il,jsblab,c,ndfall = ',il,jslab,dtp*vtmax,ndfall
4651 ELSE
4652 dtptmp = dtp
4653 ENDIF
4654
4655 dtfrac = dtptmp/dtp
4656
4657
4658 DO n = 1,ndfall
4659
4660 IF ( do_accurate_sedimentation .and. n .ge. 2 .and. ( n == interval_sedi_vt*(n/interval_sedi_vt) ) ) THEN
4661!
4662! zero the precip flux arrays (2d)
4663!
4664
4665 dummy = 0.d0
4666
4667 xvt(kzb:kze,ix,1:3,il) = 0.0 ! reset to zero because routine will only compute points with q > qmin
4668
4669 call ziegfall1d(nx,ny,nz,nor,norz,na,dtp,jgs,ix, &
4670 & xvt, rhovtzx, &
4671 & an,dn,ipconc,t0,t7,cwmasn,cwmasx, &
4672 & cwradn, &
4673 & qxmin,xdnmx,xdnmn,cdx,cno,xdn0,xvmn,xvmx, &
4674 & ngs,qx,qxw,cx,xv,vtxbar,xmas,xdn,xdia,vx,alpha,zx,igs,kgs, &
4675 & rho0,temcg,temg,rhovt,cwnc,cinc,fadvisc,cwdia,cipmas,cnina,cimas, &
4676 & cnostmp, &
4677 & infdo,il)
4678
4679
4680 DO kz = kzb,kze
4681 ! apply limit vtmaxsed (08/20/2015)
4682 xvt(kz,ix,1,il) = min( vtmaxsed, xvt(kz,ix,1,il) )
4683 xvt(kz,ix,2,il) = min( vtmaxsed, xvt(kz,ix,2,il) )
4684 xvt(kz,ix,3,il) = min( vtmaxsed, xvt(kz,ix,3,il) )
4685 ENDDO
4686
4687
4688
4689
4690 ENDIF ! (n .ge. 2)
4691
4692
4693 IF ( il >= lr .and. ( linfall(il) .eq. 3 .or. linfall(il) .eq. 4 ) .and. ln(il) > 0 ) THEN
4694 call calczgr1d(nx,ny,nz,nor,na,an,ixe,kze, &
4695 & z,db1,jgs,ipconc, dnu(il), il, ln(il), qxmin(il), xvmn(il), xvmx(il), lvol(il), xdn0(il), ix )
4696 ENDIF
4697
4698 if (ndebug .gt. 0 ) write(0,*) 'dbg = 1b'
4699
4700! mixing ratio
4701
4702 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
4703 & an,db1,il,1,xfall,dtz1,ix)
4704
4705
4706 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3c'
4707
4708! volume
4709
4710 IF ( ldovol .and. il >= li ) THEN
4711 IF ( lvol(il) .gt. 1 ) THEN
4712 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
4713 & an,db1,lvol(il),0,xfall,dtz1,ix)
4714 ENDIF
4715 ENDIF
4716
4717! reflectivity
4718
4719 IF ( ipconc .ge. 6 ) THEN
4720 IF ( lz(il) .gt. 1 ) THEN
4721 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,3,il), &
4722 & an,db1,lz(il),0,xfall,dtz1,ix)
4723 ENDIF
4724 ENDIF
4725
4726 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3d'
4727
4728
4729 IF ( ipconc .gt. 0 ) THEN !{
4730 IF ( ipconc .ge. ipc(il) ) THEN
4731
4732 IF ( ( linfall(il) .ge. 2 ) .and. lz(il) .lt. 1) THEN !{
4733!
4734! load number conc. into tmpn to do fallout by mass-weighted mean fall speed
4735! to put a lower bound on number conc.
4736!
4737
4738 IF ( linfall(il) == 3 .or. linfall(il) == 4 ) THEN
4739 ! set up for method I or I+II
4740 DO kz = kzb,kze
4741 tmpn2(ix,jy,kz) = z(ix,kz,il)
4742 ENDDO
4743 DO kz = kzb,kze
4744 tmpn(ix,jy,kz) = an(ix,jy,kz,ln(il))
4745 ENDDO
4746
4747 ELSE
4748 ! set up for method II only
4749 DO kz = kzb,kze
4750 tmpn(ix,jy,kz) = an(ix,jy,kz,ln(il))
4751 ENDDO
4752
4753 ENDIF
4754
4755 ENDIF !}
4756
4757
4758 if (ndebug .gt. 0 ) write(0,*) 'dbg = 3f'
4759
4760 in = 2
4761 IF ( linfall(il) .eq. 1 ) in = 1
4762
4763 call fallout1d(nx,ny,nz,nor,na,dtptmp,dtfrac,jgs,xvt(1,1,in,il), &
4764 & an,db1,ln(il),0,xfall,dtz1,ix)
4765
4766
4767 IF ( lz(il) .lt. 1 ) THEN ! { if not 3-moment, run one of the correction schemes
4768 IF ( linfall(il) >= 2 ) THEN
4769 xfall0(:,jgs) = 0.0
4770
4771 IF ( ( infall .eq. 3 .or. infall .eq. 4 ) .and. &
4772 & ( il .ge. lh .or. (il .eq. lr .and. irfall .eq. infall) &
4773 .or. (il .eq. ls .and. isfall .eq. infall) ) ) THEN
4774 call fallout1d(nx,ny,nz,nor,1,dtptmp,dtfrac,jgs,xvt(1,1,3,il), &
4775 & tmpn2,db1,1,0,xfall0,dtz1,ix)
4776 call fallout1d(nx,ny,nz,nor,1,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
4777 & tmpn,db1,1,0,xfall0,dtz1,ix)
4778 ELSE
4779 call fallout1d(nx,ny,nz,nor,1,dtptmp,dtfrac,jgs,xvt(1,1,1,il), &
4780 & tmpn,db1,1,0,xfall0,dtz1,ix)
4781 ENDIF
4782
4783 IF ( linfall(il) == 3 .or. linfall(il) == 4 ) THEN
4784 ! "Method I" - dbz correction
4785 ! Uses input tmpn2 (temp. Z-moment) to determine if new N and q values in an(:,:,:,ln(il))
4786 ! cause an increase in reflectivity moment. If so, either use N from mass-wgt Vt (tmpn) to replace
4787 ! new N (infall=3; I) or use smaller N from tmpn or calculated from q and temporary Z (infall=4; I+II)
4788 ! Uses 'z' array to check if new reflectivity is greater than pre-sedimentation reflectivity
4789 call calcnfromz1d(nx,ny,nz,nor,na,an,tmpn2,ixe,kze, &
4790 & z,db1,jgs,ipconc, dnu(il), il, ln(il), qxmin(il), xvmn(il), xvmx(il),tmpn, &
4791 & lvol(il), xdn0(il), infall, ix)
4792
4793 ELSEIF ( linfall(il) .eq. 5 .and. il .ge. lh .or. ( il == lr .and. irfall == 5 ) ) THEN
4794
4795 DO kz = kzb,kze
4796 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) ))
4797 ENDDO
4798
4799 ELSEIF ( .not. (il .eq. lr .and. irfall .eq. 0) .and. .not. (il .eq. ls .and. isfall .eq. 0) ) THEN
4800! "Method II" M-wgt N-fallout correction
4801
4802 DO kz = kzb,kze
4803 an(ix,jgs,kz,ln(il)) = max( an(ix,jgs,kz,ln(il)), tmpn(ix,jy,kz) )
4804 ENDDO
4805 ENDIF !}
4806 ENDIF
4807
4808
4809 ENDIF !} lz(il) .lt. 1
4810 ENDIF ! ipconc > ipc
4811
4812
4813 ENDIF !} (ipconc > 0)
4814
4815
4816 ENDDO ! n=1,ndfall
4817 ENDDO ! il
4818
4819 ENDDO ! ix
4820
4821
4822 deallocate( db1,dtz1,dz2dinv,db1inv,rhovtzx )
4823 deallocate( xfall0, xvt, tmpn )
4824 deallocate( tmpn2, z)
4825
4826 deallocate( qx, &
4827 qxw, &
4828 cx, &
4829 xv, &
4830 vtxbar, &
4831 xmas, &
4832 xdn, &
4833 xdia, &
4834 vx, &
4835 alpha, &
4836 zx, &
4837 hasmass, &
4838 igs,kgs, &
4839 rho0,temcg,temg, rhovt, &
4840 cwnc,cinc, &
4841 fadvisc,cwdia,cipmas, &
4842 cnina,cimas, &
4843 cnostmp )
4844
4845 RETURN
4846 END SUBROUTINE sediment1d
4847
4848
4849! #####################################################################
4850
4851!
4852! #####################################################################
4853
4854
4855!
4856!--------------------------------------------------------------------------
4857!
4858!--------------------------------------------------------------------------
4859!
4862 subroutine fallout1d(nx,ny,nz,nor,na,dtp,dtfrac,jgs,vt, &
4863 & a,db1,ia,id,xfall,dtz1,ixcol)
4864!
4865! First-order, upwind fallout scheme
4866!
4867! Written by ERM 6/10/2011
4868!
4869!
4870!
4871 implicit none
4872
4873 integer nx,ny,nz,nor,ngt,jgs,na,ia
4874 integer id ! =1 use density, =0 no density
4875 integer ng1
4876 parameter(ng1 = 1)
4877 integer :: ixcol
4878
4879! real dz3dinv(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
4880! real a(nx,ny,nz,na)
4881 real a(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,na) ! quantity to be 'advected'
4882 real vt(nz+1,nx) ! terminal speed for a
4883 real dtp,dtfrac
4884 real cmax
4885 real xfall(nx,ny,na) ! array for stuff landing on the ground
4886 real db1(nx,nz+1),dtz1(nz+1,nx,0:1)
4887
4888! Local
4889
4890 integer ix,jy,kz,n,k
4891 integer iv1,iv2
4892 real tmp
4893 integer imn,imx,kmn,kmx
4894 real qtmp1(nz+1)
4895
4896!-----------------------------------------------------------------------------
4897
4898 integer :: ixb, jyb, kzb
4899 integer :: ixe, jye, kze
4900
4901! ###################################################################
4902
4903 jy = 1
4904
4905 iv1 = 0
4906 iv2 = 0
4907
4908 imn = nx
4909 imx = 1
4910 kmn = nz
4911 kmx = 1
4912
4913 cmax = 0.0
4914
4915 kzb = 1
4916 kze = nz
4917
4918 ixb = ixcol
4919 ixe = ixcol
4920 ix = ixcol
4921
4922 qtmp1(nz+1) = 0.0
4923
4924 DO kz = kzb,kze
4925! DO ix = ixb,ixe
4926! cmax = Max(cmax, vt(ix,kz)*dz3dinv(ix,jy,kz))
4927
4928 IF ( id == 1 ) THEN
4929 qtmp1(kz) = a(ix,jgs,kz,ia)*vt(kz,ix)*db1(ix,kz)
4930 ELSE
4931 qtmp1(kz) = a(ix,jgs,kz,ia)*vt(kz,ix)
4932 ENDIF
4933
4934 IF ( a(ix,jgs,kz,ia) .ne. 0.0 ) THEN
4935! imn = Min(ix,imn)
4936! imx = Max(ix,imx)
4937 kmn = min(kz,kmn)
4938 kmx = max(kz,kmx)
4939 ENDIF
4940! ENDDO
4941 ENDDO
4942
4943 kmn = max(1,kmn-1)
4944
4945! first check if fallout is worth doing
4946! IF ( cmax .eq. 0.0 .or. imn .gt. imx ) THEN
4947! RETURN
4948! ENDIF
4949
4950 IF ( kmn == 1 ) THEN
4951
4952 kz = 1
4953! do ix = imn,imx ! 1,nx-1
4954 xfall(ix,jy,ia) = xfall(ix,jy,ia) + a(ix,jgs,kz,ia)*vt(kz,ix)*dtfrac
4955! enddo
4956
4957 ENDIF
4958
4959 do kz = 1,nz
4960! do ix = 1,nx
4961 a(ix,jgs,kz,ia) = a(ix,jgs,kz,ia) + dtp*dtz1(kz,ix,id)*(qtmp1(kz+1) - qtmp1(kz) )
4962! enddo
4963 enddo
4964
4965
4966 RETURN
4967 END SUBROUTINE fallout1d
4968
4969! ##############################################################################
4970! ##############################################################################
4971
4974 subroutine calczgr1d(nx,ny,nz,nor,na,a,ixe,kze, &
4975 & z,db,jgs,ipconc, alpha, l,ln, qmin, xvmn,xvmx, lvol, rho_qx, ixcol)
4976
4977
4978 implicit none
4979
4980 integer nx,ny,nz,nor,na,ngt,jgs
4981 integer :: ixcol
4982 integer, parameter :: norz = 3
4983 real a(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,na)
4984 real z(-nor+1:nx+nor,-nor+1:nz+nor,lr:lhab) ! reflectivity
4985 real db(nx,nz+1) ! air density
4986! real gt(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,ngt)
4987
4988 integer ixe,kze
4989 real alpha
4990 real qmin
4991 real xvmn,xvmx
4992 integer ipconc
4993 integer l ! index for q
4994 integer ln ! index for N
4995 integer lvol ! index for volume
4996 real rho_qx
4997
4998
4999 integer ix,jy,kz
5000 real vr,qr,nrx,rd,xv,g1,zx,chw,xdn,ynu
5001
5002
5003 jy = jgs
5004 ix = ixcol
5005
5006 IF ( l .eq. lh .or. l .eq. lhl .or. ( l .eq. lr .and. imurain == 1 ) &
5007 .or. ( l .eq. ls .and. imusnow == 1 ) ) THEN
5008
5009
5010 DO kz = 1,kze
5011
5012
5013
5014 IF ( a(ix,jy,kz,l) .gt. qmin .and. a(ix,jy,kz,ln) .gt. 1.e-15 ) THEN
5015
5016 IF ( lvol .gt. 1 ) THEN
5017 IF ( a(ix,jy,kz,lvol) .gt. 0.0 ) THEN
5018 xdn = db(ix,kz)*a(ix,jy,kz,l)/a(ix,jy,kz,lvol)
5019 xdn = min( 900., max( hdnmn, xdn ) )
5020 ELSE
5021 xdn = rho_qx
5022 ENDIF
5023 ELSE
5024 xdn = rho_qx
5025 ENDIF
5026
5027 IF ( l == lr ) xdn = 1000.
5028
5029 qr = a(ix,jy,kz,l)
5030 xv = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
5031 chw = a(ix,jy,kz,ln)
5032
5033 IF ( xv .lt. xvmn .or. xv .gt. xvmx ) THEN
5034 xv = min( xvmx, max( xvmn,xv ) )
5035 chw = db(ix,kz)*a(ix,jy,kz,l)/(xv*xdn)
5036 ENDIF
5037
5038 g1 = (6.0 + alpha)*(5.0 + alpha)*(4.0 + alpha)/ &
5039 & ((3.0 + alpha)*(2.0 + alpha)*(1.0 + alpha))
5040 zx = g1*db(ix,kz)**2*(a(ix,jy,kz,l))*a(ix,jy,kz,l)/chw
5041! z(ix,kz,l) = 1.e18*zx*(6./(pi*1000.))**2
5042 z(ix,kz,l) = zx*(6./(pi*1000.))**2
5043
5044
5045! IF ( ny.eq.2 .and. kz .ge. 25 .and. kz .le. 29 .and. z(ix,kz,l) .gt. 0. ) THEN
5046! write(*,*) 'calczgr: z,dbz,xdn = ',ix,kz,z(ix,kz,l),10*log10(z(ix,kz,l)),xdn
5047! ENDIF
5048
5049 ELSE
5050
5051 z(ix,kz,l) = 0.0
5052
5053 ENDIF
5054
5055 ENDDO
5056
5057 ELSEIF ( (l == ls .and. imusnow == 3) .or. ( l .eq. lr .and. imurain == 3 ) ) THEN
5058
5059 xdn = rho_qx ! 1000.
5060 IF ( l == ls ) ynu = snu
5061 IF ( l == lr ) ynu = rnu
5062
5063 DO kz = 1,kze
5064
5065 IF ( a(ix,jy,kz,l) .gt. qmin .and. a(ix,jy,kz,ln) .gt. 1.e-15 ) THEN
5066
5067 vr = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
5068! z(ix,kz,l) = 3.6e18*(ynu+2.0)*a(ix,jy,kz,ln)*vr**2/(ynu+1.0)
5069 z(ix,kz,l) = 3.6*(ynu+2.0)*a(ix,jy,kz,ln)*vr**2/(ynu+1.0)
5070! qr = a(ix,jy,kz,lr)
5071! nrx = a(ix,jy,kz,lnr)
5072
5073 ELSE
5074
5075 z(ix,kz,l) = 0.0
5076
5077 ENDIF
5078
5079
5080 ENDDO
5081
5082 ENDIF
5083
5084 RETURN
5085
5086 END subroutine calczgr1d
5087
5088! ##############################################################################
5089! ##############################################################################
5090!
5091! Subroutine to correct number concentration to prevent reflectivity growth by
5092! sedimentation in 2-moment ZXX scheme.
5093! Calculation is in a slab (constant jgs)
5094!
5095
5098 subroutine calcnfromz1d(nx,ny,nz,nor,na,a,t0,ixe,kze, &
5099 & z0,db,jgs,ipconc, alpha, l,ln, qmin, xvmn,xvmx,t1, &
5100 & lvol, rho_qx, infall, ixcol)
5101
5102
5103 implicit none
5104
5105 integer nx,ny,nz,nor,na,ngt,jgs,ixcol
5106
5107 real a(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,na) ! sedimented N and q
5108 real t0(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor) ! sedimented reflectivity
5109 real t1(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor) ! sedimented N (by Vm)
5110! real gt(-nor+1:nx+nor,-nor+1:ny+nor,-nor+1:nz+nor,ngt)
5111 real z0(-nor+1:nx+nor,-nor+1:nz+nor,lr:lhab) ! initial reflectivity
5112
5113 real db(nx,nz+1) ! air density
5114
5115 integer ixe,kze
5116 real alpha
5117 real qmin
5118 real xvmn,xvmx
5119 integer ipconc
5120 integer l ! index for q
5121 integer ln ! index for N
5122 integer lvol ! index for volume
5123 real rho_qx
5124 integer infall
5125
5126
5127 integer ix,jy,kz
5128 double precision vr,qr,nrx,rd,g1,zx,chw,z,znew,zt,zxt
5129 real xv,xdn
5130 integer :: ndbz, nmwgt, nnwgt, nwlessthanz
5131
5132 ndbz = 0
5133 nmwgt = 0
5134 nnwgt = 0
5135 nwlessthanz = 0
5136
5137
5138
5139 jy = jgs
5140 ix = ixcol
5141
5142 IF ( l .eq. lh .or. l .eq. lhl .or. ( l == lr .and. imurain == 1 ) ) THEN
5143
5144 g1 = (6.0 + alpha)*(5.0 + alpha)*(4.0 + alpha)/ &
5145 & ((3.0 + alpha)*(2.0 + alpha)*(1.0 + alpha))
5146
5147 DO kz = 1,kze
5148
5149
5150 IF ( t0(ix,jy,kz) .gt. 0. ) THEN ! {
5151
5152 IF ( lvol .gt. 1 ) THEN
5153 IF ( a(ix,jy,kz,lvol) .gt. 0.0 ) THEN
5154 xdn = db(ix,kz)*a(ix,jy,kz,l)/a(ix,jy,kz,lvol)
5155 xdn = min( 900., max( hdnmn, xdn ) )
5156 ELSE
5157 xdn = rho_qx
5158 ENDIF
5159 ELSE
5160 xdn = rho_qx
5161 ENDIF
5162
5163 IF ( l == lr ) xdn = 1000.
5164
5165 qr = a(ix,jy,kz,l)
5166 xv = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
5167 chw = a(ix,jy,kz,ln)
5168
5169 IF ( xv .lt. xvmn .or. xv .gt. xvmx ) THEN
5170 xv = min( xvmx, max( xvmn,xv ) )
5171 chw = db(ix,kz)*a(ix,jy,kz,l)/(xv*xdn)
5172 ENDIF
5173
5174 zx = g1*db(ix,kz)**2*( a(ix,jy,kz,l))*a(ix,jy,kz,l)/chw
5175 z = zx*(6./(pi*1000.))**2
5176
5177
5178 IF ( (z .gt. t0(ix,jy,kz) .and. z .gt. 0.0 .and. &
5179 & t0(ix,jy,kz) .gt. z0(ix,kz,l) )) THEN !{
5180
5181 zx = t0(ix,jy,kz)/((6./(pi*1000.))**2)
5182
5183 nrx = g1*db(ix,kz)**2*( a(ix,jy,kz,l))*a(ix,jy,kz,l)/zx
5184 IF ( infall .eq. 3 ) THEN
5185 IF ( nrx .gt. a(ix,jy,kz,ln) ) THEN
5186 ndbz = ndbz + 1
5187 IF ( t1(ix,jy,kz) .lt. ndbz ) nwlessthanz = nwlessthanz + 1
5188 ELSE
5189 nnwgt = nnwgt + 1
5190 ENDIF
5191 a(ix,jy,kz,ln) = max( real(nrx), a(ix,jy,kz,ln) )
5192 ELSE
5193 IF ( nrx .gt. a(ix,jy,kz,ln) .and. t1(ix,jy,kz) .gt. a(ix,jy,kz,ln) ) THEN
5194 IF ( nrx .lt. t1(ix,jy,kz) ) THEN
5195 ndbz = ndbz + 1
5196 ELSE
5197 nmwgt = nmwgt + 1
5198 IF ( t1(ix,jy,kz) .lt. ndbz ) nwlessthanz = nwlessthanz + 1
5199 ENDIF
5200 ELSE
5201 nnwgt = nnwgt + 1
5202 ENDIF
5203
5204 a(ix,jy,kz,ln) = max(min( real(nrx), t1(ix,jy,kz) ), a(ix,jy,kz,ln) )
5205 ENDIF
5206
5207 ELSE ! } {
5208 IF ( t1(ix,jy,kz) .gt. 0 .and. a(ix,jy,kz,ln) .gt. 0 ) THEN
5209 IF ( t1(ix,jy,kz) .gt. a(ix,jy,kz,ln) ) THEN
5210 nmwgt = nmwgt + 1
5211 ELSE
5212 nnwgt = nnwgt + 1
5213 ENDIF
5214 ENDIF
5215 a(ix,jy,kz,ln) = max(t1(ix,jy,kz), a(ix,jy,kz,ln) )
5216 nrx = a(ix,jy,kz,ln)
5217
5218
5219
5220 ENDIF ! }
5221
5222 ! }
5223 ELSE ! {
5224 IF ( t1(ix,jy,kz) .gt. 0 .and. a(ix,jy,kz,ln) .gt. 0 ) THEN
5225 IF ( t1(ix,jy,kz) .gt. a(ix,jy,kz,ln) ) THEN
5226 nmwgt = nmwgt + 1
5227 ELSE
5228 nnwgt = nnwgt + 1
5229 ENDIF
5230 ENDIF
5231 endif! }
5232
5233 ENDDO
5234
5235
5236 ELSEIF ( l .eq. lr .and. imurain == 3) THEN
5237
5238 xdn = 1000.
5239
5240 DO kz = 1,kze
5241 IF ( t0(ix,jy,kz) .gt. 0. ) THEN
5242
5243 vr = db(ix,kz)*a(ix,jy,kz,l)/(xdn*a(ix,jy,kz,ln))
5244 z = 3.6*(rnu+2.0)*a(ix,jy,kz,ln)*vr**2/(rnu+1.0)
5245
5246 IF ( z .gt. t0(ix,jy,kz) .and. z .gt. 0.0 .and. &
5247 & t0(ix,jy,kz) .gt. 0.0 &
5248 & .and. t0(ix,jy,kz) .gt. z0(ix,kz,l) ) THEN
5249
5250 vr = db(ix,kz)*a(ix,jy,kz,l)/(xdn)
5251 chw = a(ix,jy,kz,ln)
5252 nrx = 3.6*(rnu+2.0)*vr**2/((rnu+1.0)*t0(ix,jy,kz))
5253 IF ( infall .eq. 3 ) THEN
5254 a(ix,jy,kz,ln) = max( real(nrx), a(ix,jy,kz,ln) )
5255 ELSEIF ( infall .eq. 4 ) THEN
5256 a(ix,jy,kz,ln) = max( min( real(nrx), t1(ix,jy,kz)), a(ix,jy,kz,ln) )
5257 ENDIF
5258
5259 ELSE
5260
5261 a(ix,jy,kz,ln) = max(t1(ix,jy,kz), a(ix,jy,kz,ln) )
5262
5263 ENDIF
5264
5265 ELSE
5266
5267 a(ix,jy,kz,ln) = max(t1(ix,jy,kz), a(ix,jy,kz,ln) )
5268
5269 ENDIF
5270
5271
5272 ENDDO
5273
5274 ENDIF
5275
5276 RETURN
5277
5278 END subroutine calcnfromz1d
5279
5280
5281! ##############################################################################
5282! ##############################################################################
5283!
5284! Subroutine to calculate number concentrations from initial state that has only mixing ratio.
5285! Output N will be in #/m^3 in 'an' array, since sedimentation is done next.
5286! Output ccw,cci etc. will be in #/kg
5287
5288!
5289! 10.27.2015: Added hail calculation
5290!
5293 subroutine calcnfromq(nx,ny,nz,an,na,nor,norz,dn, &
5294 & qcw,qci,qsw,qrw,qhw,qhl, &
5295 & ccw,cci,csw,crw,chw,chl, &
5296 & cccn,cccna, vhw,vhl,qv,spechum, invertccn_flag, cwmasin )
5297
5298
5299
5300 implicit none
5301
5302 integer nx,ny,nz,nor,norz,na,ngt,jgs,ixcol
5303
5304 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na) ! scalars (q, N, Z)
5305
5306 real dn(nx,nz+1) ! air density
5307
5308 real, optional, dimension(nx,nz), intent(inout) :: qcw,qci,qsw,qrw,qhw,qhl, &
5309 ccw,cci,csw,crw,chw,chl, &
5310 cccn,cccna,vhw,vhl,qv, spechum
5311 logical, optional, intent(in) :: invertccn_flag
5312 real, optional :: cwmasin
5313
5314 integer ixe,kze
5315 real alpha
5316 real qmin
5317 real xvmn,xvmx
5318 integer ipconc
5319 integer lvol ! index for volume
5320 integer infall
5321
5322
5323 integer ix,jy,kz
5324 double precision vr,q,nrx,nrx2,rd,g1h,g1hl,g1r,g1s,zx,z,znew,zt,zxt,n1,laminv1
5325 double precision :: zr, zs, zh, dninv
5326 real, parameter :: xn0s = 3.0e8, xn0r = 8.0e6, xn0h = 2.0e5, xn0hl = 4.0e4
5327 real, parameter :: xdnr = 1000., xdns = 100. ,xdnh = 700.0, xdnhl = 900.0
5328 real, parameter :: zhlfac = 1./(pi*xdnhl*xn0hl)
5329 real, parameter :: zhfac = 1./(pi*xdnh*xn0h)
5330 real, parameter :: zrfac = 1./(pi*xdnr*xn0r)
5331 real, parameter :: zsfac = 1./(pi*xdns*xn0s)
5332 real, parameter :: g0 = (6.0)*(5.0)*(4.0)/((3.0)*(2.0)*(1.0))
5333 real, parameter :: xims=900.*0.523599*(2.*50.e-6)**3 ! mks (100 micron diam solid sphere approx)
5334 real, parameter :: xgms=xdnh*0.523599*(300.e-6)**3 ! mks (300 micron diam sphere approx)
5335 real, parameter :: cwmas09 = 1000.*0.523599*(2.*9.e-6)**3 ! mass of 9-micron radius droplet
5336
5337 real xv,xdn,cwmasinv
5338 integer :: ndbz, nmwgt, nnwgt, nwlessthanz
5339 double precision :: mixconv, mixconvqv, qsmax,qsmax2,qsmax3,qsmax4
5340 logical :: invertccn_local
5341
5342! ------------------------------------------------------------------
5343
5344 IF ( present( invertccn_flag ) ) THEN
5345 invertccn_local = invertccn_flag
5346 ELSE
5347 invertccn_local = .false.
5348 ENDIF
5349
5350 IF ( present( cwmasin ) ) THEN
5351 cwmasinv = 1.0/cwmasin
5352 ELSE
5353 cwmasinv = 1.0/cwmas09
5354 ENDIF
5355
5356 jy = 1
5357
5358
5359 g1h = (6.0 + alphah)*(5.0 + alphah)*(4.0 + alphah)/ &
5360 & ((3.0 + alphah)*(2.0 + alphah)*(1.0 + alphah))
5361
5362 g1hl = (6.0 + alphahl)*(5.0 + alphahl)*(4.0 + alphahl)/ &
5363 & ((3.0 + alphahl)*(2.0 + alphahl)*(1.0 + alphahl))
5364
5365 IF ( imurain == 3 ) THEN
5366 g1r = (rnu+2.0)/(rnu+1.0)
5367 ELSE ! imurain == 1
5368 g1r = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/ &
5369 & ((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
5370 ENDIF
5371
5372 g1s = (snu+2.0)/(snu+1.0)
5373 qsmax = 0
5374 qsmax2 = 0
5375 qsmax3 = 0
5376 qsmax4 = 0
5377! IF ( .not. present( qcw ) ) THEN
5378 DO kz = 1,nz
5379 DO ix = 1,nx ! ixcol
5380
5381! qv_mp = spechum/(1.0_kind_phys-spechum)
5382! IF ( convertdry ) THEN
5383! qc_mp = qc/(1.0_kind_phys-spechum)
5384 mixconv = 1
5385 IF ( present( spechum ) ) THEN ! convert to "dry" mixing ratios
5386 an(ix,jy,kz,lv) = spechum(ix,kz)/(1.0d0 - spechum(ix,kz))
5387 mixconv = 1.0d0/(1.0d0 - spechum(ix,kz))
5388 ELSE
5389 mixconv = 1.0d0
5390 ENDIF
5391 IF ( present( qv ) ) an(ix,jy,kz,lv) = qv(ix,kz) ! assume qv is "dry" mixing ratio if passed in
5392 IF ( present( qcw ) ) an(ix,jy,kz,lc) = qcw(ix,kz)*mixconv
5393 IF ( present( qrw ) ) an(ix,jy,kz,lr) = qrw(ix,kz)*mixconv
5394 IF ( present( qci ) ) an(ix,jy,kz,li) = qci(ix,kz)*mixconv
5395 IF ( present( qsw ) ) THEN
5396 an(ix,jy,kz,ls) = qsw(ix,kz)*mixconv
5397! qsmax = Max( qsmax, qsw(ix,kz) )
5398! qsmax2 = Max( qsmax2, an(ix,jy,kz,ls) )
5399 ENDIF
5400 IF ( present( qhw ) ) an(ix,jy,kz,lh) = qhw(ix,kz)*mixconv
5401 IF ( lhl > 1 .and. present( qhl ) ) an(ix,jy,kz,lhl) = qhl(ix,kz)*mixconv
5402 IF ( present( ccw ) ) an(ix,jy,kz,lnc) = ccw(ix,kz)*mixconv*dn(ix,kz)
5403 IF ( present( crw ) ) an(ix,jy,kz,lnr) = crw(ix,kz)*mixconv*dn(ix,kz)
5404 IF ( present( cci ) ) an(ix,jy,kz,lni) = cci(ix,kz)*mixconv*dn(ix,kz)
5405 IF ( present( csw ) ) an(ix,jy,kz,lns) = csw(ix,kz)*mixconv*dn(ix,kz)
5406 IF ( present( chw ) ) an(ix,jy,kz,lnh) = chw(ix,kz)*mixconv*dn(ix,kz)
5407 IF ( lhl > 1 .and. present( chl ) ) an(ix,jy,kz,lnhl) = chl(ix,kz)*mixconv*dn(ix,kz)
5408 IF ( lvh > 1 .and. present( vhw ) ) an(ix,jy,kz,lvh) = vhw(ix,kz)*mixconv
5409 IF ( lvhl > 1 .and. present( vhl ) ) an(ix,jy,kz,lvhl) = vhl(ix,kz)*mixconv
5410 IF ( lccn > 1 .and. present( cccn ) ) an(ix,jy,kz,lccn) = cccn(ix,kz)*mixconv*dn(ix,kz)
5411 IF ( lccna > 1 .and. present( cccna ) ) an(ix,jy,kz,lccna) = cccna(ix,kz)*mixconv
5412
5413 dninv = 1./dn(ix,kz)
5414
5415! IF ( .not. present( qcw ) ) THEN
5416 ! Cloud droplets
5417
5418 IF ( lnc > 1 ) THEN
5419 IF ( an(ix,jy,kz,lnc) <= cxmin .and. an(ix,jy,kz,lc) > qxmin_init(lc) ) THEN
5420
5421 an(ix,jy,kz,lnc) = min(qccn, an(ix,jy,kz,lc)*cwmasinv )*dn(ix,kz)
5422
5423 IF ( invertccn_local ) THEN
5424 an(ix,jy,kz,lccn) = an(ix,jy,kz,lccn) + an(ix,jy,kz,lnc)
5425 ELSE
5426
5427 IF ( lccn > 1 .and. lccna < 1 ) THEN
5428 an(ix,jy,kz,lccn) = an(ix,jy,kz,lccn) - an(ix,jy,kz,lnc)
5429 ENDIF
5430 IF ( lccna > 1 ) THEN
5431 an(ix,jy,kz,lccna) = an(ix,jy,kz,lccna) + an(ix,jy,kz,lnc)
5432 ENDIF
5433 ENDIF
5434
5435 ELSEIF ( an(ix,jy,kz,lc) <= qxmin(lc) .or. &
5436 ( an(ix,jy,kz,lnc) <= cxmin .and. an(ix,jy,kz,lc) <= qxmin_init(lc)) ) THEN
5437
5438 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lc)
5439 an(ix,jy,kz,lnc) = 0.0
5440 an(ix,jy,kz,lc) = 0.0
5441
5442 ENDIF
5443 ENDIF
5444
5445 ! Cloud ice
5446
5447 IF ( lni > 1 ) THEN
5448 IF ( an(ix,jy,kz,lni) <= cxmin .and. an(ix,jy,kz,li) > qxmin_init(li) ) THEN
5449 an(ix,jy,kz,lni) = dn(ix,kz)*an(ix,jy,kz,li)/xims
5450
5451 ELSEIF ( an(ix,jy,kz,li) <= qxmin(li) .or. &
5452 ( an(ix,jy,kz,lni) <= cxmin .and. an(ix,jy,kz,li) <= qxmin_init(li)) ) THEN
5453 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,li)
5454 an(ix,jy,kz,lni) = 0.0
5455 an(ix,jy,kz,li) = 0.0
5456 ENDIF
5457 ENDIF
5458
5459 ! rain
5460
5461 IF ( lnr > 1 ) THEN
5462 IF ( an(ix,jy,kz,lnr) <= 0.1*cxmin .and. an(ix,jy,kz,lr) > qxmin_init(lr) ) THEN
5463
5464 q = an(ix,jy,kz,lr)
5465
5466 laminv1 = (dn(ix,kz) * q * zrfac)**(0.25) ! inverse of slope
5467
5468 n1 = laminv1*xn0r ! number concentration for inv. exponential single moment input
5469
5470 nrx = n1*g1r/g0 ! number concentration for different shape parameter
5471
5472 an(ix,jy,kz,lnr) = nrx ! *dninv ! convert to number mixing ratio
5473
5474 ELSEIF ( an(ix,jy,kz,lr) <= qxmin(lr) .or. &
5475 ( an(ix,jy,kz,lnr) <= cxmin .and. an(ix,jy,kz,lr) <= qxmin_init(lr)) ) THEN
5476 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lr)
5477 an(ix,jy,kz,lnr) = 0.0
5478 an(ix,jy,kz,lr) = 0.0
5479 ENDIF
5480 ENDIF
5481
5482 IF ( lzr > 1 ) THEN ! set reflectivity moment
5483 IF ( an(ix,jy,kz,lr) > qxmin_init(lr) .and. an(ix,jy,kz,lzr) < zxmin .and. &
5484 an(ix,jy,kz,lnr) > cxmin ) THEN
5485 q = an(ix,jy,kz,lr)
5486 nrx = an(ix,jy,kz,lnr)
5487 an(ix,jy,kz,lzr) = 36.*g1r*dn(ix,kz)**2*q**2/(pi**2*xdnr**2*nrx) ! *dninv
5488 ENDIF
5489 ENDIF
5490
5491 ! snow
5492 IF ( lns > 1 ) THEN
5493 IF ( an(ix,jy,kz,lns) <= 0.1*cxmin .and. an(ix,jy,kz,ls) > qxmin_init(ls) ) THEN
5494
5495 q = an(ix,jy,kz,ls)
5496
5497 laminv1 = (dn(ix,kz) * q * zsfac)**(0.25) ! inverse of slope
5498
5499 n1 = laminv1*xn0s ! number concentration for inv. exponential single moment input
5500
5501 nrx = n1*g1s/g0 ! number concentration for different shape parameter
5502
5503 an(ix,jy,kz,lns) = nrx ! *dninv ! convert to number mixing ratio
5504
5505 ELSEIF ( an(ix,jy,kz,ls) <= qxmin(ls) .or. &
5506 ( an(ix,jy,kz,lns) <= cxmin .and. an(ix,jy,kz,ls) <= qxmin_init(ls)) ) THEN
5507 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,ls)
5508 an(ix,jy,kz,lns) = 0.0
5509 an(ix,jy,kz,ls) = 0.0
5510
5511 ENDIF
5512 ENDIF
5513
5514 ! graupel
5515
5516 IF ( lnh > 1 ) THEN
5517 IF ( an(ix,jy,kz,lnh) <= 0.1*cxmin .and. an(ix,jy,kz,lh) > qxmin_init(lh) ) THEN
5518 IF ( lvh > 1 ) THEN
5519 IF ( an(ix,jy,kz,lvh) <= 0.0 ) THEN
5520 an(ix,jy,kz,lvh) = an(ix,jy,kz,lh)/xdnh
5521 ENDIF
5522 ENDIF
5523
5524 q = an(ix,jy,kz,lh)
5525
5526 laminv1 = (dn(ix,kz) * q * zhfac)**(0.25) ! inverse of slope
5527
5528 n1 = laminv1*xn0h ! number concentration for inv. exponential single moment input
5529
5530 nrx = n1*g1h/g0 ! number concentration for different shape parameter
5531
5532 nrx2 = dn(ix,kz) * q / xgms
5533
5534 nrx = min( nrx, nrx2 )
5535
5536 IF ( nrx > cxmin ) THEN
5537 an(ix,jy,kz,lnh) = nrx ! *dninv ! convert to number mixing ratio
5538 ELSE
5539 an(ix,jy,kz,lh) = 0.0
5540 an(ix,jy,kz,lnh) = 0.0
5541 an(ix,jy,kz,lvh) = 0.0
5542 ENDIF
5543
5544 ELSEIF ( an(ix,jy,kz,lh) <= qxmin(lh) .or. &
5545 ( an(ix,jy,kz,lnh) <= cxmin .and. an(ix,jy,kz,lh) <= qxmin_init(lh)) ) THEN
5546
5547 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lh)
5548 an(ix,jy,kz,lh) = 0.0
5549
5550 ENDIF
5551 ENDIF
5552
5553 IF ( lzh > 1 ) THEN ! set reflectivity moment
5554 IF ( an(ix,jy,kz,lh) > qxmin_init(lh) .and. an(ix,jy,kz,lzh) < zxmin .and. &
5555 an(ix,jy,kz,lnh) > cxmin ) THEN
5556 q = an(ix,jy,kz,lh)
5557 nrx = an(ix,jy,kz,lnh)
5558 an(ix,jy,kz,lzh) = 36.*g1h*dn(ix,kz)**2*q**2/(pi**2*xdnh**2*nrx) ! *dninv
5559 ENDIF
5560 ENDIF
5561
5562 ! hail
5563
5564 IF ( lnhl > 1 .and. lhl > 1 ) THEN
5565 IF ( an(ix,jy,kz,lnhl) <= 0.1*cxmin .and. an(ix,jy,kz,lhl) > qxmin_init(lhl) ) THEN
5566 IF ( lvhl > 1 ) THEN
5567 IF ( an(ix,jy,kz,lvhl) <= 0.0 ) THEN
5568 an(ix,jy,kz,lvhl) = an(ix,jy,kz,lhl)/xdnhl
5569 ENDIF
5570 ENDIF
5571
5572 q = an(ix,jy,kz,lhl)
5573
5574 laminv1 = (dn(ix,kz) * q * zhlfac)**(0.25) ! inverse of slope
5575
5576 n1 = laminv1*xn0hl ! number concentration for inv. exponential single moment input
5577
5578 nrx = n1*g1hl/g0 ! number concentration for different shape parameter
5579
5580 an(ix,jy,kz,lnhl) = nrx ! *dninv ! convert to number mixing ratio
5581
5582 ELSEIF ( an(ix,jy,kz,lhl) <= qxmin(lhl) .or. &
5583 ( an(ix,jy,kz,lnhl) <= cxmin .and. an(ix,jy,kz,lhl) <= qxmin_init(lhl)) ) THEN
5584
5585 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lhl)
5586 an(ix,jy,kz,lhl) = 0.0
5587
5588 ENDIF
5589 ENDIF
5590
5591 IF ( lzhl > 1 ) THEN ! set reflectivity moment
5592 IF ( an(ix,jy,kz,lhl) > qxmin_init(lhl) .and. an(ix,jy,kz,lzhl) < zxmin .and. &
5593 an(ix,jy,kz,lnhl) > cxmin ) THEN
5594 q = an(ix,jy,kz,lhl)
5595 nrx = an(ix,jy,kz,lnhl)
5596 an(ix,jy,kz,lzhl) = 36.*g1hl*dn(ix,kz)**2*q**2/(pi**2*xdnhl**2*nrx) ! *dninv
5597 ENDIF
5598 ENDIF
5599
5600
5601! ENDIF
5602
5603! spechum = qv_mp/(1.0_kind_phys+qv_mp)
5604! IF ( convertdry ) THEN
5605! qc = qc_mp/(1.0_kind_phys+qv_mp)
5606 mixconvqv = 1
5607 IF ( present( spechum ) ) THEN ! convert back to "dry+vapor" mixing ratios
5608 !an(ix,jy,kz,lv) = spechum(ix,kz)/(1.0d0 - spechum(ix,kz))
5609 mixconvqv = 1.0d0/(1.0d0 + an(ix,jy,kz,lv))
5610 spechum(ix,kz) = an(ix,jy,kz,lv)*mixconvqv
5611 ELSE
5612 mixconvqv = 1.0d0
5613 ENDIF
5614
5615 IF ( present( qv ) ) qv(ix,kz) = an(ix,jy,kz,lv)
5616 IF ( present( qcw ) ) qcw(ix,kz) = an(ix,jy,kz,lc)*mixconvqv
5617 IF ( present( qrw ) ) qrw(ix,kz) = an(ix,jy,kz,lr)*mixconvqv
5618 IF ( present( qci ) ) qci(ix,kz) = an(ix,jy,kz,li)*mixconvqv
5619 IF ( present( qsw ) ) THEN
5620 qsw(ix,kz) = an(ix,jy,kz,ls)*mixconvqv
5621! qsmax3 = Max( qsmax3, qsw(ix,kz) )
5622! qsmax4 = Max( qsmax4, an(ix,jy,kz,ls) )
5623 ENDIF
5624 IF ( present( qhw ) ) qhw(ix,kz) = an(ix,jy,kz,lh)*mixconvqv
5625 IF ( lhl > 1 .and. present( qhl ) ) qhl(ix,kz) = an(ix,jy,kz,lhl)*mixconvqv
5626 IF ( present( ccw ) ) ccw(ix,kz) = an(ix,jy,kz,lnc)*mixconvqv*dninv
5627 IF ( present( crw ) ) crw(ix,kz) = an(ix,jy,kz,lnr)*mixconvqv*dninv
5628 IF ( present( cci ) ) cci(ix,kz) = an(ix,jy,kz,lni)*mixconvqv*dninv
5629 IF ( present( csw ) ) csw(ix,kz) = an(ix,jy,kz,lns)*mixconvqv*dninv
5630 IF ( present( chw ) ) chw(ix,kz) = an(ix,jy,kz,lnh)*mixconvqv*dninv
5631 IF ( lhl > 1 .and. present( chl ) ) chl(ix,kz) = an(ix,jy,kz,lnhl)*mixconvqv*dninv
5632 IF ( lvh > 1 .and. present( vhw ) ) vhw(ix,kz) = an(ix,jy,kz,lvh)*mixconvqv
5633 IF ( lvhl > 1 .and. present( vhl ) ) vhl(ix,kz) = an(ix,jy,kz,lvhl)*mixconvqv
5634 IF ( lccn > 1 .and. present( cccn ) ) cccn(ix,kz) = an(ix,jy,kz,lccn)*mixconvqv*dninv
5635 IF ( lccna > 1 .and. present( cccna ) ) cccna(ix,kz) = an(ix,jy,kz,lccna)*mixconvqv
5636
5637
5638 ENDDO ! ix
5639 ENDDO ! kz
5640! ELSE
5641! write(0,*) 'calcnfromq: lv = ',lv,lc,lr,li,ls,lh,lvh,lhl,lccn,lccna
5642! write(0,*) 'calcnfromq: nx,ny,nz,na = ',nx,ny,nz,na
5643!
5644! ENDIF
5645
5646! IF ( present( qsw ) ) THEN
5647! write(0,*) 'calcnfromq: qsmax = ',qsmax,qsmax2,qsmax3,qsmax4
5648! ENDIF
5649
5650 RETURN
5651
5652 END subroutine calcnfromq
5653
5654! ##############################################################################
5655! ##############################################################################
5656!
5657! Subroutine to calculate number concentrations from convection parameterization rates that have only mixing ratio.
5658! N will be in #/kg, NOT #/m^3, since sedimentation is done next.
5659!
5660
5661!
5662! 10.27.2015: Added hail calculation
5663!
5666 subroutine calcnfromcuten(nx,ny,nz,an,anold,na,nor,norz,dn)
5667
5668
5669 implicit none
5670
5671 integer nx,ny,nz,nor,norz,na,ngt,jgs,ixcol
5672
5673 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na) ! scalars (q, N, Z) from CUTEN arrays
5674 real anold(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na) ! scalars (q, N, Z)
5675
5676 real dn(nx,nz+1) ! air density
5677
5678 integer ixe,kze
5679 real alpha
5680 real qmin
5681 real xvmn,xvmx
5682 integer ipconc
5683 integer lvol ! index for volume
5684 integer infall
5685
5686
5687 integer ix,jy,kz
5688 double precision vr,q,nrx,rd,g1h,g1hl,g1r,g1s,zx,chw,z,znew,zt,zxt,n1,laminv1
5689 double precision :: zr, zs, zh, dninv
5690 real, parameter :: xn0s = 3.0e6, xn0r = 8.0e6, xn0h = 4.0e4, xn0hl = 4.0e4
5691 real, parameter :: xdnr = 1000., xdns = 100. ,xdnh = 700.0, xdnhl = 900.0
5692 real, parameter :: zhlfac = 1./(pi*xdnhl*xn0hl)
5693 real, parameter :: zhfac = 1./(pi*xdnh*xn0h)
5694 real, parameter :: zrfac = 1./(pi*xdnr*xn0r)
5695 real, parameter :: zsfac = 1./(pi*xdns*xn0s)
5696 real, parameter :: g0 = (6.0)*(5.0)*(4.0)/((3.0)*(2.0)*(1.0))
5697 real, parameter :: xims=900.*0.523599*(2.*50.e-6)**3 ! mks (100 micron diam solid sphere approx)
5698 real, parameter :: xcms=1000.*0.523599*(2.*7.5e-6)**3 ! mks (100 micron diam solid sphere approx)
5699
5700 real :: xmass,xv,xdn
5701 integer :: ndbz, nmwgt, nnwgt, nwlessthanz
5702
5703! ------------------------------------------------------------------
5704
5705
5706 jy = 1
5707
5708
5709 g1h = (6.0 + alphah)*(5.0 + alphah)*(4.0 + alphah)/ &
5710 & ((3.0 + alphah)*(2.0 + alphah)*(1.0 + alphah))
5711
5712 g1hl = (6.0 + alphahl)*(5.0 + alphahl)*(4.0 + alphahl)/ &
5713 & ((3.0 + alphahl)*(2.0 + alphahl)*(1.0 + alphahl))
5714
5715 IF ( imurain == 3 ) THEN
5716 g1r = (rnu+2.0)/(rnu+1.0)
5717 ELSE ! imurain == 1
5718 g1r = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/ &
5719 & ((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
5720 ENDIF
5721
5722 g1s = (snu+2.0)/(snu+1.0)
5723
5724 DO kz = 1,nz
5725 DO ix = 1,nx ! ixcol
5726
5727 dninv = 1./dn(ix,kz)
5728
5729 ! Cloud droplets
5730
5731 IF ( lnc > 1 ) THEN
5732! IF ( an(ix,jy,kz,lnc) <= 0.1*cxmin .and. an(ix,jy,kz,lc) > qxmin(lc) ) THEN
5733 IF ( an(ix,jy,kz,lnc) > qxmin(lc) ) THEN
5734 anold(ix,jy,kz,lnc) = anold(ix,jy,kz,lnc) + an(ix,jy,kz,lc)/xcms
5735 ENDIF
5736 ENDIF
5737
5738 ! Cloud ice
5739
5740 IF ( lni > 1 ) THEN
5741 IF ( an(ix,jy,kz,lni) > qxmin(li) ) THEN
5742 anold(ix,jy,kz,lni) = anold(ix,jy,kz,lni) + an(ix,jy,kz,li)/xims
5743 ENDIF
5744 ENDIF
5745
5746 ! rain
5747
5748 IF ( lnr > 1 ) THEN
5749 IF ( an(ix,jy,kz,lr) > qxmin(lr) ) THEN ! adding rain mass from CU scheme
5750
5751 IF ( .true. .or. (anold(ix,jy,kz,lr) - an(ix,jy,kz,lr)) < qxmin(lr) .or. anold(ix,jy,kz,lnr) < cxmin ) THEN
5752
5753 q = an(ix,jy,kz,lr)
5754
5755 laminv1 = (dn(ix,kz) * q * zrfac)**(0.25) ! inverse of slope
5756
5757 n1 = laminv1*xn0r ! number concentration for inv. exponential single moment input
5758
5759 nrx = n1*g1r/g0 ! number concentration for different shape parameter
5760
5761 anold(ix,jy,kz,lnr) = anold(ix,jy,kz,lnr) + nrx ! *dninv ! convert to number mixing ratio
5762
5763 ELSE
5764 ! assume mean particle mass of pre-existing snow
5765 xmass = anold(ix,jy,kz,lr)/anold(ix,jy,kz,lnr)
5766 anold(ix,jy,kz,lnr) = anold(ix,jy,kz,lnr) + an(ix,jy,kz,lr)/xmass
5767 ENDIF
5768
5769 IF ( lzr > 1 ) THEN ! set reflectivity moment
5770 an(ix,jy,kz,lzr) = 36.*g1r*dn(ix,kz)**2*q**2/(pi**2*xdnr**2*nrx) ! *dninv
5771 ENDIF
5772 ENDIF
5773 ENDIF
5774
5775 ! snow
5776 IF ( lns > 1 ) THEN
5777 IF ( an(ix,jy,kz,ls) > qxmin(ls) ) THEN ! adding snow mass from CU scheme
5778
5779 IF ( .true. .or. (anold(ix,jy,kz,ls) - an(ix,jy,kz,ls)) < qxmin(ls) .or. anold(ix,jy,kz,lns) < cxmin ) THEN
5780
5781 ! assume that there was no snow before this
5782
5783 q = an(ix,jy,kz,ls)
5784
5785 laminv1 = (dn(ix,kz) * q * zsfac)**(0.25) ! inverse of slope
5786
5787 n1 = laminv1*xn0s ! number concentration for inv. exponential single moment input
5788
5789 nrx = n1*g1s/g0 ! number concentration for different shape parameter
5790
5791 anold(ix,jy,kz,lns) = anold(ix,jy,kz,lns) + nrx ! *dninv ! convert to number mixing ratio
5792
5793 ELSE
5794 ! assume mean particle mass of pre-existing snow
5795 xmass = anold(ix,jy,kz,ls)/anold(ix,jy,kz,lns)
5796 anold(ix,jy,kz,lns) = anold(ix,jy,kz,lns) + an(ix,jy,kz,ls)/xmass
5797 ENDIF
5798
5799 ENDIF
5800 ENDIF
5801
5802 ! graupel
5803
5804! IF ( lnh > 1 ) THEN
5805! IF ( an(ix,jy,kz,lnh) <= 0.1*cxmin .and. an(ix,jy,kz,lh) > qxmin(lh) ) THEN
5806! IF ( lvh > 1 ) THEN
5807! IF ( an(ix,jy,kz,lvh) <= 0.0 ) THEN
5808! an(ix,jy,kz,lvh) = an(ix,jy,kz,lh)/xdnh
5809! ENDIF
5810! ENDIF
5811!
5812! q = an(ix,jy,kz,lh)
5813!
5814! laminv1 = (dn(ix,kz) * q * zhfac)**(0.25) ! inverse of slope
5815!
5816! n1 = laminv1*xn0h ! number concentration for inv. exponential single moment input
5817!
5818! nrx = n1*g1h/g0 ! number concentration for different shape parameter
5819!
5820! an(ix,jy,kz,lnh) = nrx ! *dninv ! convert to number mixing ratio
5821!
5822! IF ( lzh > 1 ) THEN ! set reflectivity moment
5823! an(ix,jy,kz,lzh) = 36.*g1h*dn(ix,kz)**2*q**2/(pi**2*xdnh**2*nrx) ! *dninv
5824! ENDIF
5825! ENDIF
5826! ENDIF
5827!
5828! ! hail
5829!
5830! IF ( lnhl > 1 .and. lhl > 1 ) THEN
5831! IF ( an(ix,jy,kz,lnhl) <= 0.1*cxmin .and. an(ix,jy,kz,lhl) > qxmin(lhl) ) THEN
5832! IF ( lvhl > 1 ) THEN
5833! IF ( an(ix,jy,kz,lvhl) <= 0.0 ) THEN
5834! an(ix,jy,kz,lvhl) = an(ix,jy,kz,lhl)/xdnhl
5835! ENDIF
5836! ENDIF
5837!
5838! q = an(ix,jy,kz,lhl)
5839!
5840! laminv1 = (dn(ix,kz) * q * zhlfac)**(0.25) ! inverse of slope
5841!
5842! n1 = laminv1*xn0hl ! number concentration for inv. exponential single moment input
5843!
5844! nrx = n1*g1hl/g0 ! number concentration for different shape parameter
5845!
5846! an(ix,jy,kz,lnhl) = nrx ! *dninv ! convert to number mixing ratio
5847!
5848! IF ( lzhl > 1 ) THEN ! set reflectivity moment
5849! an(ix,jy,kz,lzhl) = 36.*g1hl*dn(ix,kz)**2*q**2/(pi**2*xdnhl**2*nrx) ! *dninv
5850! ENDIF
5851! ENDIF
5852! ENDIF
5853
5854 ENDDO ! ix
5855 ENDDO ! kz
5856
5857 RETURN
5858
5859 END subroutine calcnfromcuten
5860
5861! #####################################################################
5862! #####################################################################
5863
5866 SUBROUTINE calc_eff_radius &
5867 & (nx,ny,nz,na,jyslab &
5868 & ,nor,norz &
5869 & ,t1,t2,t3,t4,t5,t6, f_t4, f_t5,f_t6 &
5870 & ,qcw,qci,qsw,qrw &
5871 & ,ccw,cci,csw,crw &
5872 & ,an,dn )
5873
5874 implicit none
5875
5876 integer, parameter :: ng1 = 1
5877 integer :: nx,ny,nz,na
5878 integer :: ng
5879 integer :: nor,norz, jyslab ! ,nht,ngt,igsr
5880 real :: dtp ! time step
5881
5882
5883!
5884! external temporary arrays
5885!
5886
5887 real,optional :: t1(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5888 real,optional :: t2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5889 real,optional :: t3(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5890 real,optional :: t4(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5891 real,optional :: t5(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5892 real,optional :: t6(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5893 logical, optional :: f_t4, f_t5, f_t6 ! flags to fill t4/t5/t6 for rain/graupel/hail
5894
5895 real, optional :: an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
5896 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
5897 real, optional, dimension(nx,nz) :: qcw,qci,qsw,qrw,ccw,cci,csw,crw
5898
5899
5900 ! local
5901
5902 real pb(-norz+ng1:nz+norz)
5903 real pinit(-norz+ng1:nz+norz)
5904
5905!
5906! declarations microphysics and for gather/scatter
5907!
5908 integer nxmpb,nzmpb,nxz
5909 integer mgs,ngs,numgs,inumgs
5910 parameter(ngs=1)
5911 integer ngscnt,igs(ngs),kgs(ngs)
5912 real rho0(ngs)
5913
5914 integer ix,kz,i,n, kp1
5915 integer :: jy, jgs
5916 integer ixb,ixe,jyb,jye,kzb,kze
5917
5918 integer itile,jtile,ktile
5919 integer ixend,jyend,kzend,kzbeg
5920 integer nxend,nyend,nzend,nzbeg
5921
5922 real :: qx(ngs,lv:lhab)
5923 real :: cx(ngs,lc:lhab)
5924 real :: xv(ngs,lc:lhab)
5925 real :: xmas(ngs,lc:lhab)
5926 real :: xdn(ngs,lc:lhab)
5927 real :: xdia(ngs,lc:lhab,3)
5928 real :: alpha(ngs,lc:lhab)
5929
5930 real :: gamc1,gamc2,gami1,gami2,gams1,gams2, factor_c, factor_i, factor_s
5931 real :: lam_c, lam_i, lam_s, lam_r, lam_h, lam_hl
5932 real :: gamr1,gamr2,gamh1,gamh2,factor_r,factor_h,factor_hl
5933 integer :: il
5934 real :: hwdn,hldn
5935 double precision :: numh, numhl,denomh,denomhl
5936
5937 logical :: flag_t4, flag_t5, flag_t6
5938
5939 real, parameter :: qmin = 1.e-8
5940 real, parameter :: volmin = 1.e-30
5941
5942
5943! -------------------------------------------------------------------------------
5944 itile = nx
5945 jtile = ny
5946 ktile = nz
5947 ixend = nx
5948 jyend = ny
5949 kzend = nz
5950 nxend = nx + 1
5951 nyend = ny + 1
5952 nzend = nz
5953 kzbeg = 1
5954 nzbeg = 1
5955
5956 flag_t4 = .false.
5957 flag_t5 = .false.
5958 flag_t6 = .false.
5959
5960 IF ( present(f_t4) ) THEN
5961 IF ( present(f_t4) ) THEN
5962 flag_t4 = f_t4
5963 ENDIF
5964 ENDIF
5965
5966 IF ( present(f_t5) ) THEN
5967 IF ( present(f_t5) ) THEN
5968 flag_t5 = f_t5
5969 ENDIF
5970 ENDIF
5971
5972 IF ( present(f_t6) ) THEN
5973 IF ( present(f_t6) ) THEN
5974 flag_t6 = f_t6
5975 ENDIF
5976 ENDIF
5977
5978 jy = 1
5979 pb(:) = 0.0
5980 pinit(:) = 0.0
5981
5982 gamc1 = gamma_sp(2. + cnu)
5983 gamc2 = 1. ! Gamma[1 + alphac]
5984 gami1 = gamma_sp(2. + cinu)
5985 gami2 = 1. ! Gamma[1 + alphac]
5986 gams1 = gamma_sp(2. + snu)
5987 gams2 = gamma_sp(1. + snu)
5988 gamr1 = gamma_sp(2. + rnu)
5989 gamr2 = gamma_sp(1. + rnu)
5990
5991 factor_c = (1. + cnu)*gamma_sp(1. + cnu)/gamma_sp(5./3. + cnu)
5992 factor_i = (1. + cinu)*gamma_sp(1. + cinu)/gamma_sp(5./3. + cinu)
5993 factor_s = (1. + snu)*gamma_sp(1. + snu)/gamma_sp(5./3. + snu)
5994
5995 IF ( present(t4) ) THEN
5996 IF ( imurain == 3 ) THEN
5997 factor_r = (1. + rnu)*gamma_sp(1. + rnu)/gamma_sp(5./3. + rnu)
5998 ELSE
5999 factor_r = ((pi*(alphar+3.)*(alphar+1.)*(alphar+1.))/6.)**(1./3.)
6000 ENDIF
6001 ENDIF
6002
6003 factor_h = ((pi*(alphah+3.)*(alphah+1.)*(alphah+1.))/6.)**(1./3.)
6004 factor_hl = ((pi*(alphahl+3.)*(alphahl+1.)*(alphahl+1.))/6.)**(1./3.)
6005
6006!
6007! jy = 1 ! working on a 2d slab
6008!! VERY IMPORTANT: SET jgs = jy
6009
6010 jgs = jy
6011
6012 mgs = 1
6013 DO kz = 1,nz
6014 DO ix = 1,nx ! ixcol
6015
6016 rho0(mgs) = dn(ix,jy,kz)
6017 IF ( present( an ) ) THEN
6018 DO il = lc,lhab
6019 qx(mgs,il) = max(an(ix,jy,kz,il), 0.0)
6020 cx(mgs,il) = max(an(ix,jy,kz,ln(il)), 0.0)
6021 ENDDO
6022 ELSE
6023 qx(mgs,:) = 0.0
6024 cx(mgs,:) = 0.0
6025 IF ( present(qcw) ) qx(mgs,lc) = qcw(ix,kz)
6026 IF ( present(qci) ) qx(mgs,li) = qci(ix,kz)
6027 IF ( present(qsw) ) qx(mgs,ls) = qsw(ix,kz)
6028 IF ( present(qrw) ) qx(mgs,lr) = qrw(ix,kz)
6029 IF ( present(ccw) ) cx(mgs,lc) = ccw(ix,kz)*rho0(mgs)
6030 IF ( present(cci) ) cx(mgs,li) = cci(ix,kz)*rho0(mgs)
6031 IF ( present(csw) ) cx(mgs,ls) = csw(ix,kz)*rho0(mgs)
6032 IF ( present(crw) ) cx(mgs,lr) = crw(ix,kz)*rho0(mgs)
6033
6034 ENDIF
6035
6036 IF ( present( t1 ) .and. qx(mgs,lc) > qxmin(lc) .and. cx(mgs,lc) > cxmin ) THEN
6037! Lambda for cloud droplets
6038 lam_c = ((cx(mgs,lc)*(pi/6.)*xdn0(lc)*gamc1)/(qx(mgs,lc)*rho0(mgs)*gamc2))**(1./3.)
6039 t1(ix,jy,kz) = 0.5*factor_c/lam_c
6040 ENDIF
6041
6042 IF ( present( t2 ) .and. qx(mgs,li) > qxmin(li) .and. cx(mgs,li) > cxmin ) THEN
6043! Lambda for cloud ice
6044 lam_i = ((cx(mgs,li)*(pi/6.)*xdn0(li)*gami1)/(qx(mgs,li)*rho0(mgs)*gami2))**(1./3.)
6045 t2(ix,jy,kz) = 0.5*factor_i/lam_i
6046 ENDIF
6047
6048 IF ( present( t3 ) .and. qx(mgs,ls) > qxmin(ls) .and. cx(mgs,ls) > cxmin ) THEN
6049! Lambda for snow
6050 lam_s = ((cx(mgs,ls)*(pi/6.)*xdn0(ls)*gams1)/(qx(mgs,ls)*rho0(mgs)*gams2))**(1./3.)
6051 t3(ix,jy,kz) = 0.5*factor_s/lam_s
6052 ENDIF
6053
6054 IF ( present( t4 ) .and.( ( present(qrw) .and. present(crw) ) .or. flag_t4 ) ) THEN
6055 IF ( qx(mgs,lr) > max(qmin,qxmin(lr)) .and. cx(mgs,lr) > cxmin ) THEN
6056 IF ( imurain == 1 ) THEN ! gamma-diameter
6057! Lambda for rain
6058 lam_r = factor_r *((xdn0(lr)*cx(mgs,lr))/(qx(mgs,lr)*rho0(mgs)))**(1./3.)
6059 t4(ix,jy,kz) = 0.5*(alphar+3.)/lam_r
6060 ELSE ! gamma-volume
6061! Lambda for rain
6062 lam_r = ((cx(mgs,lr)*(pi/6.)*xdn0(lr)*gamr1)/(qx(mgs,lr)*rho0(mgs)*gamr2))**(1./3.)
6063 t4(ix,jy,kz) = 0.5*factor_r/lam_r
6064 ENDIF
6065 ENDIF
6066 ENDIF
6067
6068 IF ( present(t5) .and. flag_t5 ) THEN
6069
6070 ! first: case when hail is off
6071
6072 IF ( lhl < 1 .or. flag_t6 ) THEN
6073 ! graupel only
6074 IF ( qx(mgs,lh) > max(qmin,qxmin(lh)) ) THEN
6075 ! Lambda for graupel
6076 hwdn = xdn0(lh)
6077 IF ( lvh > 1 ) THEN ! variable density
6078 IF ( an(ix,jy,kz,lvh) > volmin ) THEN
6079 hwdn = rho0(mgs)*qx(mgs,lh)/an(ix,jy,kz,lvh)
6080 ENDIF
6081 ENDIF
6082
6083 lam_h = factor_h *((hwdn*cx(mgs,lh))/(qx(mgs,lh)*rho0(mgs)))**(1./3.)
6084 t5(ix,jy,kz) = 0.5*(alphah+3.)/lam_h
6085 ENDIF
6086
6087 ELSE ! have hail, too, but do not have t6 array
6088
6089 IF ( qx(mgs,lh) > max(qmin,qxmin(lh)) .and. qx(mgs,lhl) < max(qmin,qxmin(lhl)) ) THEN
6090! Lambda for graupel
6091 hwdn = xdn0(lh)
6092 IF ( lvh > 1 ) THEN ! variable density
6093 IF ( an(ix,jy,kz,lvh) > volmin ) THEN
6094 hwdn = rho0(mgs)*qx(mgs,lh)/an(ix,jy,kz,lvh)
6095 ENDIF
6096 ENDIF
6097
6098 lam_h = factor_h *((hwdn*cx(mgs,lh))/(qx(mgs,lh)*rho0(mgs)))**(1./3.)
6099 t5(ix,jy,kz) = 0.5*(alphah+3.)/lam_h
6100
6101 ELSEIF ( qx(mgs,lh) < max(qmin,qxmin(lh)) .and. qx(mgs,lhl) > max(qmin,qxmin(lhl)) ) THEN
6102! Lambda for hail
6103 hldn = xdn0(lhl)
6104 IF ( lvhl > 1 ) THEN ! variable density
6105 IF ( an(ix,jy,kz,lvhl) > volmin ) THEN
6106 hldn = rho0(mgs)*qx(mgs,lhl)/an(ix,jy,kz,lvhl)
6107 ENDIF
6108 ENDIF
6109
6110 lam_hl = factor_hl *((hldn*cx(mgs,lhl))/(qx(mgs,lhl)*rho0(mgs)))**(1./3.)
6111 t5(ix,jy,kz) = 0.5*(alphahl+3.)/lam_hl
6112
6113 ELSEIF ( qx(mgs,lh) > max(qmin,qxmin(lh)) .and. qx(mgs,lhl) > max(qmin,qxmin(lhl)) ) THEN
6114! r_eff graupel and hail combined
6115
6116 hldn = xdn0(lhl)
6117 IF ( lvhl > 1 ) THEN ! variable density
6118 IF ( an(ix,jy,kz,lvhl) > volmin ) THEN
6119 hldn = rho0(mgs)*qx(mgs,lhl)/an(ix,jy,kz,lvhl)
6120 ENDIF
6121 ENDIF
6122
6123 hwdn = xdn0(lh)
6124 IF ( lvh > 1 ) THEN ! variable density
6125 IF ( an(ix,jy,kz,lvh) > volmin ) THEN
6126 hwdn = rho0(mgs)*qx(mgs,lh)/an(ix,jy,kz,lvh)
6127 ENDIF
6128 ENDIF
6129
6130 lam_h = factor_h *((hwdn*cx(mgs,lh))/(qx(mgs,lh)*rho0(mgs)))**(1./3.)
6131 lam_hl = factor_hl *((hldn*cx(mgs,lhl))/(qx(mgs,lhl)*rho0(mgs)))**(1./3.)
6132
6133 numh = cx(mgs,lh)*(alphah+3.)*(alphah+2.)*(alphah+1.)/lam_h**3
6134 numhl = cx(mgs,lhl)*(alphahl+3.)*(alphahl+2.)*(alphahl+1.)/lam_hl**3
6135
6136 denomh = cx(mgs,lh)*(alphah+2.)*(alphah+1.)/lam_h**2
6137 denomhl = cx(mgs,lhl)*(alphahl+2.)*(alphahl+1.)/lam_hl**2
6138
6139 t5(ix,jy,kz) = 0.5*(numh + numhl)/(denomh + denomhl)
6140
6141
6142 ENDIF ! no t6 array
6143
6144 ENDIF ! lhl
6145
6146 ENDIF ! flag_t5
6147
6148 IF ( present(t6) .and. flag_t6 .and. lhl > 1 ) THEN
6149
6150 IF ( qx(mgs,lhl) > max(qmin,qxmin(lhl)) ) THEN
6151! Lambda for hail
6152 hldn = xdn0(lhl)
6153 IF ( lvhl > 1 ) THEN ! variable density
6154 IF ( an(ix,jy,kz,lvhl) > volmin ) THEN
6155 hldn = rho0(mgs)*qx(mgs,lhl)/an(ix,jy,kz,lvhl)
6156 ENDIF
6157 ENDIF
6158
6159 lam_hl = factor_hl *((hldn*cx(mgs,lhl))/(qx(mgs,lhl)*rho0(mgs)))**(1./3.)
6160 t6(ix,jy,kz) = 0.5*(alphahl+3.)/lam_hl
6161
6162 ENDIF
6163
6164 ENDIF ! t6
6165
6166
6167 ENDDO ! ix
6168 ENDDO ! kz
6169
6170 RETURN
6171 END SUBROUTINE calc_eff_radius
6172
6173
6174! #####################################################################
6175! #####################################################################
6176
6179 SUBROUTINE qvexcess(ngs,mgs,qwvp0,qv0,qcw1,pres,thetap0,theta0, &
6180 & qvex,pi0,tabqvs,nqsat,fqsat,cbw,fcqv1,felvcp,ss1,pk,ngscnt)
6181
6182!#####################################################################
6183! Purpose: find the amount of vapor that can be condensed to liquid
6184!#####################################################################
6185
6186 implicit none
6187
6188 integer ngs,mgs,ngscnt
6189
6190 real theta2temp
6191
6192 real qvex
6193
6194 integer nqsat
6195 real fqsat, cbw
6196
6197 real ss1 ! 'target' supersaturation
6198!
6199! input arrays
6200!
6201 real qv0(ngs), qcw1(ngscnt), pres(ngs), qwvp0(mgs)
6202 real thetap0(ngs), theta0(ngs)
6203 real fcqv1(ngs), felvcp(ngs), pi0(ngs)
6204 real pk(ngs)
6205
6206 real tabqvs(nqsat)
6207!
6208! Local stuff
6209!
6210
6211 integer itertd
6212 integer ltemq
6213 real gamss, tmp
6214 real theta(ngs), qvap(ngs), pqs(ngs), qcw(ngs), qwv(ngs)
6215 real qcwtmp(ngs), qss(ngs), qvs(ngs), qwvp(ngs)
6216 real dqcw(ngs), dqwv(ngs), dqvcnd(ngs)
6217 real temg(ngs), temcg(ngs), thetap(ngs)
6218
6219 real tfr
6220 parameter( tfr = 273.15 )
6221
6222! real poo,cap
6223! parameter ( cap = rd/cp, poo = 1.0e+05 )
6224!
6225!
6226! Modified Straka adjustment (nearly identical to Tao et al. 1989 MWR)
6227!
6228!
6229!
6230! set up temperature and vapor arrays
6231!
6232 pqs(mgs) = (380.0)/(pres(mgs))
6233 thetap(mgs) = thetap0(mgs)
6234 theta(mgs) = thetap(mgs) + theta0(mgs)
6235 qwvp(mgs) = qwvp0(mgs)
6236 qvap(mgs) = max( (qwvp0(mgs) + qv0(mgs)), 0.0 )
6237 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
6238! temg(mgs) = theta2temp( theta(mgs), pres(mgs) )
6239!
6240!
6241!
6242! reset temporaries for cloud particles and vapor
6243!
6244
6245 qwv(mgs) = max( 0.0, qvap(mgs) )
6246 qcw(mgs) = max( 0.0, qcw1(mgs) )
6247!
6248!
6249 qcwtmp(mgs) = qcw(mgs)
6250 temcg(mgs) = temg(mgs) - tfr
6251 ltemq = (temg(mgs)-163.15)/fqsat+1.5
6252 ltemq = min( nqsat, max(1,ltemq) )
6253
6254 IF ( iqvsopt == 0 ) THEN
6255 pqs(mgs) = (380.0)/(pres(mgs))
6256 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
6257 ELSEIF ( iqvsopt == 1 ) THEN
6258 qvs(mgs) = rdorv*esbolton*tabqvs(ltemq)/(pres(mgs) - esbolton*tabqvs(ltemq))
6259 ENDIF
6260
6261 qss(mgs) = (0.01*ss1 + 1.0)*qvs(mgs)
6262!
6263! iterate adjustment
6264!
6265 do itertd = 1,2
6266!
6267!
6268! calculate super-saturation
6269!
6270 dqcw(mgs) = 0.0
6271 dqwv(mgs) = ( qwv(mgs) - qss(mgs) )
6272!
6273! evaporation and sublimation adjustment
6274!
6275 if( dqwv(mgs) .lt. 0. ) then ! subsaturated
6276 if( qcw(mgs) .gt. -dqwv(mgs) ) then ! check if qc can make up all of the deficit
6277 dqcw(mgs) = dqwv(mgs)
6278 dqwv(mgs) = 0.
6279 else ! otherwise make all qc available for evap
6280 dqcw(mgs) = -qcw(mgs)
6281 dqwv(mgs) = dqwv(mgs) + qcw(mgs)
6282 end if
6283!
6284 qwvp(mgs) = qwvp(mgs) - ( dqcw(mgs) ) ! add to perturbation vapor
6285!
6286 qcw(mgs) = qcw(mgs) + dqcw(mgs)
6287
6288 thetap(mgs) = thetap(mgs) + &
6289 & 1./pi0(mgs)* &
6290 & (felvcp(mgs)*dqcw(mgs) )
6291
6292 end if ! dqwv(mgs) .lt. 0. (end of evap/sublim)
6293!
6294! condensation/deposition
6295!
6296 IF ( dqwv(mgs) .ge. 0. ) THEN
6297!
6298 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qss(mgs)/ &
6299 & ((temg(mgs)-cbw)**2))
6300!
6301!
6302 dqcw(mgs) = dqvcnd(mgs)
6303!
6304 thetap(mgs) = thetap(mgs) + &
6305 & (felvcp(mgs)*dqcw(mgs) ) &
6306 & / (pi0(mgs))
6307 qwvp(mgs) = qwvp(mgs) - ( dqvcnd(mgs) )
6308 qcw(mgs) = qcw(mgs) + dqcw(mgs)
6309!
6310 END IF ! dqwv(mgs) .ge. 0.
6311
6312 theta(mgs) = thetap(mgs) + theta0(mgs)
6313 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
6314! temg(mgs) = theta2temp( theta(mgs), pres(mgs) )
6315 qvap(mgs) = max((qwvp(mgs) + qv0(mgs)), 0.0)
6316 temcg(mgs) = temg(mgs) - tfr
6317! tqvcon = temg(mgs)-cbw
6318 ltemq = (temg(mgs)-163.15)/fqsat+1.5
6319 ltemq = min( nqsat, max(1,ltemq) )
6320 IF ( iqvsopt == 0 ) THEN
6321 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
6322 ELSEIF ( iqvsopt == 1 ) THEN
6323 qvs(mgs) = rdorv*esbolton*tabqvs(ltemq)/(pres(mgs) - esbolton*tabqvs(ltemq))
6324 ENDIF
6325 qcw(mgs) = max( 0.0, qcw(mgs) )
6326 qwv(mgs) = max( 0.0, qvap(mgs))
6327 qss(mgs) = (0.01*ss1 + 1.0)*qvs(mgs)
6328 end do
6329!
6330! end the saturation adjustment iteration loop
6331!
6332!
6333 qvex = max(0.0, qcw(mgs) - qcw1(mgs) )
6334
6335 RETURN
6336 END SUBROUTINE qvexcess
6337
6338! #####################################################################
6339! #####################################################################
6340
6341
6342
6343
6344
6345!
6346! ##############################################################################
6347!
6350 SUBROUTINE setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno,cnostmp, &
6351 & xmas,vtxbar,xdn,xvmn0,xvmx0,xv,cdx,cdxgs, &
6352 & ipconc1,ndebug1,ngs,nz,igs,kgs,fadvisc, &
6353 & cwmasn,cwmasx,cwradn,cnina,cimna,cimxa, &
6354 & itype1a,itype2a,temcg,infdo,alpha,axx,bxx,ildo)
6355! & itype1a,itype2a,temcg,infdo,alpha,ildo,axh,bxh,axhl,bxhl)
6356
6357
6358 implicit none
6359
6360 integer ngscnt,ngs0,ngs,nz
6361! integer infall ! whether to calculate number-weighted fall speeds
6362
6363 real xv(ngs,lc:lhab)
6364 real qx(ngs,lv:lhab)
6365 real qxw(ngs,ls:lhab)
6366 real cx(ngs,lc:lhab)
6367 real vtxbar(ngs,lc:lhab,3)
6368 real xmas(ngs,lc:lhab)
6369 real xdn(ngs,lc:lhab)
6370 real cdxgs(ngs,lc:lhab)
6371 real xdia(ngs,lc:lhab,3)
6372 real xvmn0(lc:lhab), xvmx0(lc:lhab)
6373 real qxmin(lc:lhab)
6374 real cdx(lc:lhab)
6375 real alpha(ngs,lc:lhab)
6376
6377 real rho0(ngs),rhovt(ngs),temcg(ngs)
6378 real cno(lc:lhab)
6379 real cnostmp(ngs)
6380
6381 real cwc1, cimna, cimxa
6382 real cnina(ngs)
6383 integer igs(ngs),kgs(ngs)
6384 real fadvisc(ngs)
6385 real fsw
6386
6387 integer ipconc1
6388 integer ndebug1
6389
6390 integer, intent (in) :: itype1a,itype2a,infdo
6391 integer, intent (in) :: ildo ! which species to do, or all if ildo=0
6392
6393 real :: axx(ngs,lh:lhab),bxx(ngs,lh:lhab)
6394!! real :: axh(ngs),bxh(ngs)
6395! real :: axhl(ngs),bxhl(ngs)
6396
6397! Local vars
6398
6399
6400
6401 real swmasmx, dtmp
6402 real cd
6403 real cwc0 ! ,cwc1
6404 real :: cwch(ngscnt), cwchl(ngscnt)
6405 real :: cwchtmp,cwchltmp,xnutmp
6406 real pii
6407 real cimasx,cimasn
6408 real cwmasn,cwmasx,cwradn
6409 real cwrad
6410 real vr,rnux
6411 real alp
6412
6413 real ccimx
6414
6415 integer mgs
6416
6417 real arx,frx,vtrain,fw
6418 real fwlo,fwhi,rfwdiff
6419 real ar,br,cs,ds
6420! real gf4p5, gf4ds, gf4br, ifirst, gf1ds
6421! real gfcinu1, gfcinu1p47, gfcinu2p47
6422 real gr
6423 real rwrad,rwdia
6424 real mwfac
6425 integer il
6426
6427! save gf4p5, gf4ds, gf4br, ifirst, gf1ds
6428! save gfcinu1, gfcinu1p47, gfcinu2p47
6429! data ifirst /0/
6430
6431 real bta1,cnit
6432 parameter( bta1 = 0.6, cnit = 1.0e-02 )
6433 real x,y,tmp,del
6434 real aax,bbx,delrho
6435 integer :: indxr
6436 real mwt, nwt, zwt
6437 real, parameter :: rho00 = 1.225
6438 integer i
6439 real xvbarmax
6440
6441 integer l1, l2
6442
6443
6444!
6445! set values
6446!
6447! cwmasn = 5.23e-13 ! radius of 5.0e-6
6448! cwradn = 5.0e-6
6449! cwmasx = 5.25e-10 ! radius of 50.0e-6
6450
6451 fwlo = 0.2 ! water fraction to start weighting toward rain fall speed
6452 fwhi = 0.4 ! water fraction at which rain fall speed only is used
6453 rfwdiff = 1./(fwhi - fwlo)
6454
6455! pi = 4.0*atan(1.0)
6456 pii = piinv ! 1.0/pi
6457
6458 arx = 10.
6459 frx = 516.575 ! raind fit parameters for arx*(1 - Exp(-fx*d)), where d is rain diameter in meters.
6460
6461 ar = 841.99666
6462 br = 0.8
6463 gr = 9.8
6464! new values for cs and ds
6465 cs = 12.42
6466 ds = 0.42
6467
6468 IF ( ildo == 0 ) THEN
6469 l1 = lc
6470 l2 = lhab
6471 ELSE
6472 l1 = ildo
6473 l2 = ildo
6474 ENDIF
6475
6476! IF ( ifirst .eq. 0 ) THEN
6477! ifirst = 1
6478! gf4br = gamma(4.0+br)
6479! gf4ds = gamma(4.0+ds)
6480!! gf1ds = gamma(1.0+ds)
6481! gf4p5 = gamma(4.0+0.5)
6482! gfcinu1 = gamma(cinu + 1.0)
6483! gfcinu1p47 = gamma(cinu + 1.47167)
6484! gfcinu2p47 = gamma(cinu + 2.47167)
6485
6486 IF ( lh .gt. 1 ) THEN
6487 IF ( dmuh == 1.0 ) THEN
6488 cwchtmp = ((3. + dnu(lh))*(2. + dnu(lh))*(1.0 + dnu(lh)))**(-1./3.)
6489 ELSE
6490 cwchtmp = 6.0*pii*gamma_sp( (xnu(lh) + 1.)/xmu(lh) )/gamma_sp( (xnu(lh) + 2.)/xmu(lh) )
6491 ENDIF
6492 ENDIF
6493 IF ( lhl .gt. 1 ) THEN
6494 IF ( dmuhl == 1.0 ) THEN
6495 cwchltmp = ((3. + dnu(lhl))*(2. + dnu(lhl))*(1.0 + dnu(lhl)))**(-1./3.)
6496 ELSE
6497 cwchltmp = 6.0*pii*gamma_sp( (xnu(lhl) + 1)/xmu(lhl) )/gamma_sp( (xnu(lhl) + 2)/xmu(lhl) )
6498 ENDIF
6499 ENDIF
6500
6501 IF ( ipconc .le. 5 ) THEN
6502 IF ( lh .gt. 1 ) cwch(:) = cwchtmp
6503 IF ( lhl .gt. 1 ) cwchl(:) = cwchltmp
6504 ELSE
6505 DO mgs = 1,ngscnt
6506
6507 IF ( lh .gt. 1 .and. ( ildo == 0 .or. ildo == lh ) ) THEN
6508 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
6509 IF ( dmuh == 1.0 ) THEN
6510 cwch(mgs) = ((3. + alpha(mgs,lh))*(2. + alpha(mgs,lh))*(1.0 + alpha(mgs,lh)))**(-1./3.)
6511 ELSE
6512 xnutmp = (alpha(mgs,lh) - 2.0)/3.0
6513 cwch(mgs) = 6.0*pii*gamma_sp( (xnutmp + 1.)/xmu(lh) )/gamma_sp( (xnutmp + 2.)/xmu(lh) )
6514 ENDIF
6515 ELSE
6516 cwch(mgs) = cwchtmp
6517 ENDIF
6518 ENDIF
6519 IF ( lhl .gt. 1 .and. ( ildo == 0 .or. ildo == lhl ) ) THEN
6520 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
6521 IF ( dmuhl == 1.0 ) THEN
6522 cwchl(mgs) = ((3. + alpha(mgs,lhl))*(2. + alpha(mgs,lhl))*(1.0 + alpha(mgs,lhl)))**(-1./3.)
6523 ELSE
6524 xnutmp = (alpha(mgs,lhl) - 2.0)/3.0
6525 cwchl(mgs) = 6.0*pii*gamma_sp( (xnutmp + 1)/xmu(lhl) )/gamma_sp( (xnutmp + 2)/xmu(lhl) )
6526 ENDIF
6527 ELSE
6528 cwchl(mgs) = cwchltmp
6529 ENDIF
6530 ENDIF
6531
6532 ENDDO
6533
6534 ENDIF
6535
6536
6537 cimasn = min( cimas0, 6.88e-13)
6538 cimasx = 1.0e-8
6539 ccimx = 5000.0e3 ! max of 5000 per liter
6540
6541 cwc1 = 6.0/(pi*1000.)
6542 cwc0 = pii ! 6.0*pii
6543 mwfac = 6.0**(1./3.)
6544
6545
6546 if (ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set scale diameter'
6547!
6548
6549
6550!
6551! cloud water variables
6552! ################################################################
6553!
6554! DROPLETS
6555!
6556!
6557 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set cloud water variables'
6558
6559 IF ( ildo == 0 .or. ildo == lc ) THEN
6560
6561 do mgs = 1,ngscnt
6562 xv(mgs,lc) = 0.0
6563
6564 IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN !{
6565
6566 IF ( ipconc .ge. 2 ) THEN
6567 IF ( cx(mgs,lc) .gt. cxmin) THEN !{
6568 xmas(mgs,lc) = &
6569 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
6570 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6571 ELSE
6572 cx(mgs,lc) = max( cxmin, rho0(mgs)*qx(mgs,lc)/cwmasx )
6573 xmas(mgs,lc) = min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
6574 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6575
6576 ENDIF
6577 ELSE
6578 IF ( ipconc .lt. 2 ) THEN
6579 cx(mgs,lc) = rho0(mgs)*ccn/rho00 ! scales to local density, relative to standard air density
6580 ENDIF
6581 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. 0.01 ) THEN !{
6582 xmas(mgs,lc) = &
6583 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),xdn(mgs,lc)*xvmn(lc)), &
6584 & xdn(mgs,lc)*xvmx(lc) )
6585
6586 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6587 cx(mgs,lc) = qx(mgs,lc)*rho0(mgs)/xmas(mgs,lc)
6588
6589 ELSEIF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .le. 1.0e-9 ) THEN
6590 cx(mgs,lc) = max( cxmin, rho0(mgs)*qx(mgs,lc)/cwmasx )
6591 xmas(mgs,lc) = &
6592 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
6593 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6594
6595 ELSEIF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .le. 0.01 ) THEN
6596 xmas(mgs,lc) = xdn(mgs,lc)*4.*pi/3.*(5.0e-6)**3
6597 cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc)
6598 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6599
6600 ELSE
6601 xmas(mgs,lc) = cwmasn
6602 xv(mgs,lc) = xmas(mgs,lc)/1000.
6603! do not define ccw here! it can feed back to ccn!!! cx(mgs,lc) = 0.0 ! cwnc(mgs)
6604 ENDIF !}
6605 ENDIF !}
6606! IF ( ipconc .lt. 2 ) THEN
6607! xmas(mgs,lc) = &
6608! & min( max(qx(mgs,lc)*rho0(mgs)/cwnc(mgs),cwmasn),cwmasx )
6609! cx(mgs,lc) = Max(1.0,qx(mgs,lc)*rho0(mgs)/xmas(mgs,lc))
6610! ELSE
6611! cwnc(mgs) = an(igs(mgs),jgs,kgs(mgs),lnc)
6612! cx(mgs,lc) = cwnc(mgs)
6613! ENDIF
6614 xdia(mgs,lc,1) = (xmas(mgs,lc)*cwc1)**(1./3.)
6615 xdia(mgs,lc,2) = xdia(mgs,lc,1)**2
6616 xdia(mgs,lc,3) = xdia(mgs,lc,1)
6617 cwrad = 0.5*xdia(mgs,lc,1)
6618 IF ( fadvisc(mgs) > 0.0 ) THEN
6619 vtxbar(mgs,lc,1) = &
6620 & (2.0*gr*xdn(mgs,lc) *(cwrad**2)) &
6621 & /(9.0*fadvisc(mgs))
6622 ELSE
6623 vtxbar(mgs,lc,1) = 0.0
6624 ENDIF
6625
6626
6627 ELSE
6628 xmas(mgs,lc) = cwmasn
6629 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
6630 IF ( qx(mgs,lc) <= 0.0 ) cx(mgs,lc) = 0.0
6631 IF ( ipconc .le. 1 ) cx(mgs,lc) = 0.01
6632 xdia(mgs,lc,1) = 2.*cwradn
6633 xdia(mgs,lc,2) = 4.*cwradn**2
6634 xdia(mgs,lc,3) = xdia(mgs,lc,1)
6635 vtxbar(mgs,lc,1) = 0.0
6636
6637 ENDIF !} qcw .gt. qxmin(lc)
6638
6639 end do
6640
6641 ENDIF
6642
6643
6644
6645!
6646! cloud ice variables
6647! columns
6648!
6649! ################################################################
6650!
6651! CLOUD ICE
6652!
6653 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set cip'
6654
6655 IF ( li .gt. 1 .and. ( ildo == 0 .or. ildo == li ) ) THEN
6656 do mgs = 1,ngscnt
6657 xdn(mgs,li) = 900.0
6658 IF ( ipconc .eq. 0 ) THEN
6659! cx(mgs,li) = min(cnit*exp(-temcg(mgs)*bta1),1.e+09)
6660 cx(mgs,li) = cnina(mgs)
6661 IF ( cimna .gt. 1.0 ) THEN
6662 cx(mgs,li) = max(cimna,cx(mgs,li))
6663 ENDIF
6664 IF ( cimxa .gt. 1.0 ) THEN
6665 cx(mgs,li) = min(cimxa,cx(mgs,li))
6666 ENDIF
6667! erm 3/28/2002
6668 IF ( itype1a .ge. 1 .or. itype2a .ge. 1 ) THEN
6669 cx(mgs,li) = max(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasx)
6670 cx(mgs,li) = min(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasn)
6671 ENDIF
6672!
6673 cx(mgs,li) = max(1.0e-20,cx(mgs,li))
6674! cx(mgs,li) = Min(ccimx, cx(mgs,li))
6675
6676
6677 ELSEIF ( ipconc .ge. 1 ) THEN
6678 IF ( qx(mgs,li) .gt. qxmin(li) ) THEN
6679 cx(mgs,li) = max(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasx)
6680 cx(mgs,li) = min(cx(mgs,li),qx(mgs,li)*rho0(mgs)/cimasn)
6681! cx(mgs,li) = Max(1.0,cx(mgs,li))
6682 ENDIF
6683 ENDIF
6684
6685 IF ( qx(mgs,li) .gt. qxmin(li) ) THEN
6686 xmas(mgs,li) = &
6687 & max( qx(mgs,li)*rho0(mgs)/cx(mgs,li), cimasn )
6688! & min( max(qx(mgs,li)*rho0(mgs)/cx(mgs,li),cimasn),cimasx )
6689
6690! if ( temcg(mgs) .gt. 0.0 ) then
6691! xdia(mgs,li,1) = 0.0
6692! else
6693 if ( xmas(mgs,li) .gt. 0.0 ) THEN ! cimasn ) then
6694!c xdia(mgs,li,1) = 0.4892*(xmas(mgs,li)**(0.4554))
6695! xdia(mgs,li,1) = 0.1871*(xmas(mgs,li)**(0.3429))
6696
6697! xdia(mgs,li,1) = (132.694*5.40662/xmas(mgs,li))**(-1./2.9163) ! for inverse exponential distribution
6698 IF ( ixtaltype == 1 ) THEN ! column
6699 xdia(mgs,li,1) = 0.1871*(xmas(mgs,li)**(0.3429))
6700 xdia(mgs,li,3) = 0.1871*(xmas(mgs,li)**(0.3429))
6701 ELSEIF ( ixtaltype == 2 ) THEN ! disk
6702 xdia(mgs,li,1) = 0.277823*xmas(mgs,li)**0.359971
6703 xdia(mgs,li,3) = 0.277823*xmas(mgs,li)**0.359971
6704 ENDIF
6705 end if
6706! end if
6707! xdia(mgs,li,1) = max(xdia(mgs,li,1), 5.e-6)
6708! xdia(mgs,li,1) = min(xdia(mgs,li,1), 1000.e-6)
6709
6710 IF ( ipconc .ge. 0 ) THEN
6711! vtxbar(mgs,li,1) = rhovt(mgs)*49420.*40.0005/5.40662*xdia(mgs,li,1)**(1.415) ! mass-weighted
6712! vtxbar(mgs,li,1) = (4.942e4)*(xdia(mgs,li,1)**(1.4150))
6713 xv(mgs,li) = xmas(mgs,li)/xdn(mgs,li)
6714 IF ( icefallopt == 1 ) THEN ! default ice fall
6715 IF ( ixtaltype == 1 ) THEN ! column
6716 tmp = (67056.6300748612*rhovt(mgs))/ &
6717 & (((1.0 + cinu)/xv(mgs,li))**0.4716666666666667*gfcinu1)
6718 vtxbar(mgs,li,2) = tmp*gfcinu1p47
6719 vtxbar(mgs,li,1) = tmp*gfcinu2p47/(1. + cinu)
6720 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
6721 ELSEIF ( ixtaltype == 2 ) THEN ! disk -- but just use Ferrier (1994) snow fall speeds for now
6722 vtxbar(mgs,li,1) = 11.9495*rhovt(mgs)*(xv(mgs,li))**(0.14)
6723 vtxbar(mgs,li,2) = 7.02909*rhovt(mgs)*(xv(mgs,li))**(0.14)
6724 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
6725
6726 ENDIF
6727
6728 ELSEIF ( icefallopt == 2 ) THEN ! ! Ferrier ice fall speed
6729 tmp = (82.3166*rhovt(mgs))/ &
6730 & (((1.0 + cinu)/xv(mgs,li))**0.22117*gfcinu1)
6731 vtxbar(mgs,li,2) = tmp*gfcinu1p22
6732 vtxbar(mgs,li,1) = tmp*gfcinu2p22/(1. + cinu)
6733 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
6734
6735 ELSEIF ( icefallopt == 3 ) THEN ! ! Adjusted Ferrier (smaller exponent of 0.55 instead of 0.6635)
6736
6737 tmp = (47.6273*rhovt(mgs))/ &
6738 & (((1.0 + cinu)/xv(mgs,li))**0.18333*gfcinu1)
6739 vtxbar(mgs,li,2) = tmp*gfcinu1p18
6740 vtxbar(mgs,li,1) = tmp*gfcinu2p18/(1. + cinu)
6741 vtxbar(mgs,li,3) = vtxbar(mgs,li,1)
6742
6743 ENDIF
6744! vtxbar(mgs,li,1) = vtxbar(mgs,li,2)*(1.+cinu)/(1. + cinu)
6745! xdn(mgs,li) = min(max(769.8*xdia(mgs,li,1)**(-0.0140),300.0),900.0)
6746! xdn(mgs,li) = 900.0
6747 xdia(mgs,li,2) = xdia(mgs,li,1)**2
6748! vtxbar(mgs,li,1) = vtxbar(mgs,li,1)*rhovt(mgs)
6749 ELSE
6750 xdia(mgs,li,1) = max(xdia(mgs,li,1), 10.e-6)
6751 xdia(mgs,li,1) = min(xdia(mgs,li,1), 1000.e-6)
6752 vtxbar(mgs,li,1) = (4.942e4)*(xdia(mgs,li,1)**(1.4150))
6753! xdn(mgs,li) = min(max(769.8*xdia(mgs,li,1)**(-0.0140),300.0),900.0)
6754 xdn(mgs,li) = 900.0
6755 xdia(mgs,li,2) = xdia(mgs,li,1)**2
6756 vtxbar(mgs,li,1) = vtxbar(mgs,li,1)*rhovt(mgs)
6757 xv(mgs,li) = xmas(mgs,li)/xdn(mgs,li)
6758 ENDIF ! ipconc gt 3
6759 ELSE
6760 xmas(mgs,li) = 1.e-13
6761 IF ( qx(mgs,li) <= 0.0 ) cx(mgs,li) = 0.0
6762 xdn(mgs,li) = 900.0
6763 xdia(mgs,li,1) = 1.e-7
6764 xdia(mgs,li,2) = (1.e-14)
6765 xdia(mgs,li,3) = 1.e-7
6766 vtxbar(mgs,li,1) = 0.0
6767! cicap(mgs) = 0.0
6768! ciat(mgs) = 0.0
6769 ENDIF
6770
6771 IF ( icefallfac /= 1.0 ) THEN
6772 vtxbar(mgs,li,1) = icefallfac*vtxbar(mgs,li,1)
6773 vtxbar(mgs,li,2) = icefallfac*vtxbar(mgs,li,2)
6774 vtxbar(mgs,li,3) = icefallfac*vtxbar(mgs,li,3)
6775 ENDIF
6776
6777
6778
6779 end do
6780
6781 ENDIF ! li .gt. 1
6782
6783
6784! ################################################################
6785!
6786! RAIN
6787!
6788
6789!
6790 IF ( ildo == 0 .or. ildo == lr ) THEN
6791 do mgs = 1,ngscnt
6792 if ( qx(mgs,lr) .gt. qxmin(lr) ) then
6793
6794! IF ( qx(mgs,lr) .gt. 10.0e-3 ) &
6795! & write(0,*) 'RAIN1: ',igs(mgs),kgs(mgs),qx(mgs,lr)
6796
6797 if ( ipconc .ge. 3 ) then
6798 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*max(1.0e-11,cx(mgs,lr)))
6799 xvbarmax = xvmx(lr)
6800 IF ( imaxdiaopt == 1 ) THEN
6801 xvbarmax = xvmx(lr)
6802 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
6803 IF ( imurain == 1 ) THEN
6804 xvbarmax = xvmx(lr)/((3. + alpha(mgs,lr))**3/((3. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(1. + alpha(mgs,lr))))
6805 ELSEIF ( imurain == 3 ) THEN
6806
6807 ENDIF
6808 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
6809 IF ( imurain == 1 ) THEN
6810 xvbarmax = xvmx(lr)/((4. + alpha(mgs,lr))**3/((3. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(1. + alpha(mgs,lr))))
6811 ELSEIF ( imurain == 3 ) THEN
6812
6813 ENDIF
6814 ENDIF
6815
6816 IF ( xv(mgs,lr) .gt. xvbarmax ) THEN
6817 xv(mgs,lr) = xvbarmax
6818 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvbarmax*xdn(mgs,lr))
6819 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
6820 xv(mgs,lr) = xvmn(lr)
6821 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
6822 ENDIF
6823
6824
6825 xmas(mgs,lr) = xv(mgs,lr)*xdn(mgs,lr)
6826 xdia(mgs,lr,3) = (xmas(mgs,lr)*cwc1)**(1./3.) ! xdia(mgs,lr,1)
6827 IF ( imurain == 3 ) THEN
6828! xdia(mgs,lr,1) = (6.*pii*xv(mgs,lr)/(alpha(mgs,lr)+1.))**(1./3.)
6829 xdia(mgs,lr,1) = xdia(mgs,lr,3) ! formulae for Ziegler (1985) use mean volume diameter, not lambda**(-1)
6830 ELSE ! imurain == 1, Characteristic diameter (1/lambda)
6831 xdia(mgs,lr,1) = (6.*pii*xv(mgs,lr)/((alpha(mgs,lr)+3.)*(alpha(mgs,lr)+2.)*(alpha(mgs,lr)+1.)))**(1./3.)
6832 ENDIF
6833! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
6834
6835! Inverse exponential version:
6836! xdia(mgs,lr,1) =
6837! & (qx(mgs,lr)*rho0(mgs)
6838! & /(pi*xdn(mgs,lr)*cx(mgs,lr)))**(0.333333)
6839 ELSE
6840 xdia(mgs,lr,1) = &
6841 & (qx(mgs,lr)*rho0(mgs)/(pi*xdn(mgs,lr)*cno(lr)))**(0.25)
6842 xmas(mgs,lr) = xdn(mgs,lr)*(pi/6.)*xdia(mgs,lr,1)**3
6843 xdia(mgs,lr,3) = (xmas(mgs,lr)*cwc1)**(1./3.)
6844 cx(mgs,lr) = cno(lr)*xdia(mgs,lr,1)
6845 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr))
6846 end if
6847 else
6848 xdia(mgs,lr,1) = 1.e-9
6849 xdia(mgs,lr,3) = 1.e-9
6850 xmas(mgs,lr) = xdn(mgs,lr)*(pi/6.)*xdia(mgs,lr,1)**3
6851! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
6852 end if
6853 xdia(mgs,lr,2) = xdia(mgs,lr,1)**2
6854! xmas(mgs,lr) = xdn(mgs,lr)*(pi/6.)*xdia(mgs,lr,1)**3
6855 end do
6856
6857 ENDIF
6858! ################################################################
6859!
6860! SNOW
6861!
6862
6863 IF ( ls .gt. 1 .and. ( ildo == 0 .or. ildo == ls ) ) THEN
6864
6865 do mgs = 1,ngscnt
6866 if ( qx(mgs,ls) .gt. qxmin(ls) ) then
6867 if ( ipconc .ge. 4 ) then !
6868
6869 xmas(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(max(1.0e-9,cx(mgs,ls)))
6870 swmasmx = 13.7e-6
6871! IF ( xmas(mgs,ls) > swmasmx ) THEN
6872! xmas(mgs,ls) = swmasmx
6873! cx(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xmas(mgs,ls))
6874! ENDIF
6875
6876 IF ( isnowdens == 2 ) THEN ! Set values according to Cox relationship
6877
6878 xdn(mgs,ls) = 0.0346159*sqrt(cx(mgs,ls)/(qx(mgs,ls)*rho0(mgs)) )
6879 xdn(mgs,ls) = max( 100.0, xdn(mgs,ls) ) ! limit snow to 100. to keep other equations in line
6880
6881 IF ( xdn(mgs,ls) <= 900. ) THEN
6882 dtmp = sqrt( xmas(mgs,ls)/0.069 ) ! diameter (meters) of mean mass particle using Cox 1998 relation (m = p d^2)
6883 xv(mgs,ls) = 28.8887*xmas(mgs,ls)**(3./2.)
6884 ELSE ! at small sizes, assume ice spheres
6885 xdn(mgs,ls) = 900.
6886 xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*max(1.0e-9,cx(mgs,ls)))
6887 dtmp = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6888 ENDIF
6889
6890 ELSE ! leave xdn(ls) at default value
6891 xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*max(1.0e-9,cx(mgs,ls)))
6892 dtmp = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6893 ENDIF
6894
6895 xdia(mgs,ls,1) = dtmp ! (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6896
6897 IF ( xv(mgs,ls) .lt. xvmn(ls) .and. isnowdens == 1) THEN
6898 xv(mgs,ls) = max( xvmn(ls),xv(mgs,ls) )
6899 xmas(mgs,ls) = xv(mgs,ls)*xdn(mgs,ls)
6900 cx(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xmas(mgs,ls))
6901 xdia(mgs,ls,1) = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6902 ENDIF
6903
6904 IF ( xv(mgs,ls) .gt. xvmx(ls)*max(1.,100./min(100.,xdn(mgs,ls))) ) THEN
6905 xv(mgs,ls) = min( xvmx(ls), max( xvmn(ls),xv(mgs,ls) ) )
6906 xmas(mgs,ls) = 0.106214*xv(mgs,ls)**(2./3.)
6907 cx(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xmas(mgs,ls))
6908 xdn(mgs,ls) = 0.0346159*sqrt(cx(mgs,ls)/(qx(mgs,ls)*rho0(mgs)) )
6909 xdia(mgs,ls,1) = sqrt( xmas(mgs,ls)/0.069 )
6910 ENDIF
6911
6912 xdia(mgs,ls,3) = xdia(mgs,ls,1)
6913
6914 ELSE
6915 xdia(mgs,ls,1) = &
6916 & (qx(mgs,ls)*rho0(mgs)/(pi*xdn(mgs,ls)*cnostmp(mgs)))**(0.25)
6917 cx(mgs,ls) = cnostmp(mgs)*xdia(mgs,ls,1)
6918 xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*cx(mgs,ls))
6919 xdia(mgs,ls,3) = (xv(mgs,ls)*cwc0*6.0)**(1./3.)
6920 end if
6921 else
6922 xdia(mgs,ls,1) = 1.e-9
6923 xdia(mgs,ls,3) = 1.e-9
6924 cx(mgs,ls) = 0.0
6925
6926 IF ( isnowdens == 2 ) THEN ! Set values according to Cox relationship
6927 xdn(mgs,ls) = 90.
6928 ENDIF
6929
6930 end if
6931 xdia(mgs,ls,2) = xdia(mgs,ls,1)**2
6932! swdia3(mgs) = xdia(mgs,ls,2)*xdia(mgs,ls,1)
6933! xmas(mgs,ls) = xdn(mgs,ls)*(pi/6.)*swdia3(mgs)
6934 end do
6935
6936 ENDIF ! ls .gt 1
6937!
6938!
6939! ################################################################
6940!
6941! GRAUPEL
6942!
6943
6944 IF ( lh .gt. 1 .and. ( ildo == 0 .or. ildo == lh ) ) THEN
6945
6946 do mgs = 1,ngscnt
6947 if ( qx(mgs,lh) .gt. qxmin(lh) ) then
6948 if ( ipconc .ge. 5 ) then
6949
6950 xv(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*max(1.0e-9,cx(mgs,lh)))
6951 xmas(mgs,lh) = xv(mgs,lh)*xdn(mgs,lh)
6952
6953 IF ( xv(mgs,lh) .lt. xvmn(lh) .or. xv(mgs,lh) .gt. xvmx(lh) ) THEN
6954 xv(mgs,lh) = min( xvmx(lh), max( xvmn(lh),xv(mgs,lh) ) )
6955 xmas(mgs,lh) = xv(mgs,lh)*xdn(mgs,lh)
6956 cx(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xmas(mgs,lh))
6957 ENDIF
6958
6959 xdia(mgs,lh,3) = (xv(mgs,lh)*6.*pii)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
6960 IF ( dmuh == 1.0 ) THEN
6961 xdia(mgs,lh,1) = cwch(mgs)*xdia(mgs,lh,3)
6962 ELSE
6963 xdia(mgs,lh,1) = (xv(mgs,lh)*cwch(mgs))**(1./3.)
6964 ENDIF
6965
6966 ELSE
6967 xdia(mgs,lh,1) = &
6968 & (qx(mgs,lh)*rho0(mgs)/(pi*xdn(mgs,lh)*cno(lh)))**(0.25)
6969 cx(mgs,lh) = cno(lh)*xdia(mgs,lh,1)
6970 xv(mgs,lh) = max(xvmn(lh), rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) )
6971 xdia(mgs,lh,3) = (xv(mgs,lh)*6./pi)**(1./3.)
6972 end if
6973 else
6974 xdia(mgs,lh,1) = 1.e-9
6975 xdia(mgs,lh,3) = 1.e-9
6976 end if
6977 xdia(mgs,lh,2) = xdia(mgs,lh,1)**2
6978! hwdia3(mgs) = xdia(mgs,lh,2)*xdia(mgs,lh,1)
6979! xmas(mgs,lh) = xdn(mgs,lh)*(pi/6.)*hwdia3(mgs)
6980 end do
6981
6982 ENDIF
6983
6984!
6985! ################################################################
6986!
6987! HAIL
6988!
6989
6990 IF ( lhl .gt. 1 .and. ( ildo == 0 .or. ildo == lhl ) ) THEN
6991
6992 do mgs = 1,ngscnt
6993 if ( qx(mgs,lhl) .gt. qxmin(lhl) ) then
6994 if ( ipconc .ge. 5 ) then
6995
6996 xv(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*max(1.0e-9,cx(mgs,lhl)))
6997 xmas(mgs,lhl) = xv(mgs,lhl)*xdn(mgs,lhl)
6998! write(0,*) 'setvt: xv = ',xv(mgs,lhl),xdn(mgs,lhl),cx(mgs,lhl),xmas(mgs,lhl),qx(mgs,lhl)
6999
7000 IF ( xv(mgs,lhl) .lt. xvmn(lhl) .or. xv(mgs,lhl) .gt. xvmx(lhl) ) THEN
7001 xv(mgs,lhl) = min( xvmx(lhl), max( xvmn(lhl),xv(mgs,lhl) ) )
7002 xmas(mgs,lhl) = xv(mgs,lhl)*xdn(mgs,lhl)
7003 cx(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xmas(mgs,lhl))
7004 ENDIF
7005
7006 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6./pi)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
7007 IF ( dmuhl == 1.0 ) THEN
7008 xdia(mgs,lhl,1) = cwchl(mgs)*xdia(mgs,lhl,3)
7009 ELSE
7010 xdia(mgs,lhl,1) = (xv(mgs,lhl)*cwchl(mgs))**(1./3.)
7011 ENDIF
7012
7013! write(0,*) 'setvt: xv = ',xv(mgs,lhl),xdn(mgs,lhl),cx(mgs,lhl),xdia(mgs,lhl,3)
7014 ELSE
7015 xdia(mgs,lhl,1) = &
7016 & (qx(mgs,lhl)*rho0(mgs)/(pi*xdn(mgs,lhl)*cno(lhl)))**(0.25)
7017 cx(mgs,lhl) = cno(lhl)*xdia(mgs,lhl,1)
7018 xv(mgs,lhl) = max(xvmn(lhl), rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*cx(mgs,lhl)) )
7019 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6./pi)**(1./3.)
7020 end if
7021 else
7022 xdia(mgs,lhl,1) = 1.e-9
7023 xdia(mgs,lhl,3) = 1.e-9
7024 end if
7025 xdia(mgs,lhl,2) = xdia(mgs,lhl,1)**2
7026! hwdia3(mgs) = xdia(mgs,lh,2)*xdia(mgs,lh,1)
7027! xmas(mgs,lh) = xdn(mgs,lh)*(pi/6.)*hwdia3(mgs)
7028 end do
7029
7030 ENDIF
7031!
7032!
7033!
7034! Set terminal velocities...
7035! also set drag coefficients (moved to start of subroutine)
7036!
7037! cdx(lr) = 0.60
7038! cdx(lh) = 0.45
7039! cdx(lhl) = 0.45
7040! cdx(lf) = 0.45
7041! cdx(lgh) = 0.60
7042! cdx(lgm) = 0.80
7043! cdx(lgl) = 0.80
7044! cdx(lir) = 2.00
7045!
7046 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set terminal velocities'
7047!
7048!
7049! ################################################################
7050!
7051! RAIN
7052!
7053 IF ( ildo == 0 .or. ildo == lr ) THEN
7054 do mgs = 1,ngscnt
7055 if ( qx(mgs,lr) .gt. qxmin(lr) ) then
7056 IF ( ipconc .lt. 3 ) THEN
7057 vtxbar(mgs,lr,1) = rainfallfac*(ar*gf4br/6.0)*(xdia(mgs,lr,1)**br)*rhovt(mgs)
7058! write(91,*) 'vtxbar: ',vtxbar(mgs,lr,1),mgs,gf4br,xdia(mgs,lr,1),rhovt(mgs)
7059 ELSE
7060
7061 IF ( imurain == 1 ) THEN ! DSD of Diameter
7062
7063 ! using functional form of arx*(1 - Exp(-frx*diameter) ), with arx = arx = 10.
7064 ! and frx = 516.575 ! raind fit parameters for arx*(1 - Exp(-fx*d)), where d is rain diameter in meters.
7065 ! Similar form as in Atlas et al. (1973), who had 9.65 - 10.3*Exp[-600 * d]
7066
7067
7068 alp = alpha(mgs,lr)
7069
7070 vtxbar(mgs,lr,1) = rhovt(mgs)*arx*(1.0 - (1.0 + frx*xdia(mgs,lr,1))**(-alp - 4.0) ) ! mass weighted
7071
7072 IF ( infdo .ge. 1 .and. rssflg == 1 ) THEN
7073 vtxbar(mgs,lr,2) = rhovt(mgs)*arx*(1.0 - (1.0 + frx*xdia(mgs,lr,1))**(-alp - 1.0) ) ! number weighted
7074 ELSE
7075 vtxbar(mgs,lr,2) = vtxbar(mgs,lr,1)
7076 ENDIF
7077
7078 IF ( infdo .ge. 2 .and. rssflg == 1 ) THEN
7079 vtxbar(mgs,lr,3) = rhovt(mgs)*arx*(1.0 - (1.0 + frx*xdia(mgs,lr,1))**(-alp - 7.0) ) ! z-weighted
7080 ELSE
7081 vtxbar(mgs,lr,3) = vtxbar(mgs,lr,1)
7082 ENDIF
7083
7084! write(91,*) 'setvt: alp,vn,vm,vz = ',alp,vtxbar(mgs,lr,2), vtxbar(mgs,lr,1), vtxbar(mgs,lr,3),alpha(mgs,lr)
7085
7086 ELSEIF ( imurain == 3 ) THEN ! DSD of Volume
7087
7088 IF ( lzr < 1 ) THEN ! not 3-moment rain
7089 rwdia = min( xdia(mgs,lr,1), 8.0e-3 )
7090
7091 vtxbar(mgs,lr,1) = rhovt(mgs)*6.0*pii*( 0.04771 + 3788.0*rwdia - &
7092 & 1.105e6*rwdia**2 + 1.412e8*rwdia**3 - 6.527e9*rwdia**4)
7093
7094 IF ( infdo .ge. 1 ) THEN
7095 IF ( rssflg >= 1 ) THEN
7096 vtxbar(mgs,lr,2) = (0.09112 + 2714.0*rwdia - 4.872e5*rwdia**2 + &
7097 & 4.495e7*rwdia**3 - 1.626e9*rwdia**4)*rhovt(mgs)
7098 ELSE
7099 vtxbar(mgs,lr,2) = vtxbar(mgs,lr,1)
7100 ENDIF
7101 ENDIF
7102
7103 IF ( infdo .ge. 2 ) THEN ! Z-weighted fall speed
7104 vtxbar(mgs,lr,3) = rhovt(mgs)*( &
7105 & 0.0911229 + &
7106 & 9246.494*(rwdia) - &
7107 & 3.2839926e6*(rwdia**2) + &
7108 & 4.944093e8*(rwdia**3) - &
7109 & 2.631718e10*(rwdia**4) )
7110 ENDIF
7111
7112 ELSE ! 3-moment rain, gamma-volume
7113
7114 vr = xv(mgs,lr)
7115 rnux = alpha(mgs,lr)
7116
7117 IF ( infdo .ge. 1 .and. rssflg == 1) THEN ! number-weighted; DTD: added size-sorting flag
7118 vtxbar(mgs,lr,2) = rhovt(mgs)* &
7119 & (((1. + rnux)/vr)**(-1.333333)* &
7120 & (0.0911229*((1. + rnux)/vr)**1.333333*gamma_sp(1. + rnux) + &
7121 & (5430.3131*(1. + rnux)*gamma_sp(4./3. + rnux))/ &
7122 & vr - 1.0732802e6*((1. + rnux)/vr)**0.6666667* &
7123 & gamma_sp(1.666667 + rnux) + &
7124 & 8.584110982429507e7*((1. + rnux)/vr)**(1./3.)* &
7125 & gamma_sp(2. + rnux) - &
7126 & 2.3303765697228556e9*gamma_sp(7./3. + rnux)))/ &
7127 & gamma_sp(1. + rnux)
7128 ENDIF
7129
7130! mass-weighted
7131 vtxbar(mgs,lr,1) = rhovt(mgs)* &
7132 & (0.0911229*(1 + rnux)**1.3333333333333333*gamma_sp(2. + rnux) + &
7133 & 5430.313059683277*(1 + rnux)*vr**0.3333333333333333* &
7134 & gamma_sp(2.333333333333333 + rnux) - &
7135 & 1.0732802065650471e6*(1 + rnux)**0.6666666666666666*vr**0.6666666666666666* &
7136 & gamma_sp(2.6666666666666667 + rnux) + &
7137 & 8.584110982429507e7*(1 + rnux)**0.3333333333333333*vr*gamma_sp(3 + rnux) - &
7138 & 2.3303765697228556e9*vr**1.3333333333333333* &
7139 & gamma_sp(3.333333333333333 + rnux))/ &
7140 & ((1 + rnux)**2.333333333333333*gamma_sp(1 + rnux))
7141
7142 IF(infdo .ge. 1 .and. rssflg == 0) THEN ! No size-sorting, set N-weighted fall speed to mass-weighted
7143 vtxbar(mgs,lr,2) = vtxbar(mgs,lr,1)
7144 ENDIF
7145
7146 IF ( infdo .ge. 2 .and. rssflg == 1) THEN ! Z-weighted fall speed
7147 vtxbar(mgs,lr,3) = rhovt(mgs)* &
7148 & ((1. + rnux)*(0.0911229*(1 + rnux)**1.3333333333333333*gamma_sp(3. + rnux) + &
7149 & 5430.313059683277*(1 + rnux)*vr**0.3333333333333333* &
7150 & gamma_sp(3.3333333333333335 + rnux) - &
7151 & 1.0732802065650471e6*(1 + rnux)**0.6666666666666666* &
7152 & vr**0.6666666666666666*gamma_sp(3.6666666666666665 + rnux) + &
7153 & 8.5841109824295e7*(1 + rnux)**0.3333333333333333*vr*gamma_sp(4. + rnux) - &
7154 & 2.3303765697228556e9*vr**1.3333333333333333* &
7155 & gamma_sp(4.333333333333333 + rnux)))/ &
7156 & ((1 + rnux)**3.3333333333333335*(2 + rnux)*gamma_sp(1 + rnux))
7157
7158! write(0,*) 'setvt: mgs,lzr,infdo = ',mgs,lzr,infdo
7159! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,lr,1),vtxbar(mgs,lr,2),vtxbar(mgs,lr,3)
7160
7161 ELSEIF (infdo .ge. 2) THEN ! No size-sorting, set Z-weighted fall speed to mass-weighted
7162 vtxbar(mgs,lr,3) = vtxbar(mgs,lr,1)
7163 ENDIF
7164
7165
7166 ENDIF
7167 ENDIF ! imurain
7168
7169! IF ( rwrad*mwfac .gt. 6.0e-4 ) THEN
7170! vtxbar(mgs,lr,1) = 20.1*Sqrt(100.*rwrad*mwfac)*rhovt(mgs)
7171! ELSE
7172! vtxbar(mgs,lr,1) = 80.0e2*rwrad*rhovt(mgs)*mwfac
7173! ENDIF
7174! IF ( rwrad .gt. 6.0e-4 ) THEN
7175! vtxbar(mgs,lr,2) = 20.1*Sqrt(100.*rwrad)*rhovt(mgs)
7176! ELSE
7177! vtxbar(mgs,lr,2) = 80.0e2*rwrad*rhovt(mgs)
7178! ENDIF
7179 ENDIF ! ipconc
7180 else ! qr < qrmin
7181 vtxbar(mgs,lr,1) = 0.0
7182 vtxbar(mgs,lr,2) = 0.0
7183 end if
7184 end do
7185 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set rain vt'
7186
7187 ENDIF
7188!
7189! ################################################################
7190!
7191! SNOW !Zrnic et al. (1993)
7192!
7193 IF ( ls .gt. 1 .and. ( ildo == 0 .or. ildo == ls ) ) THEN
7194 do mgs = 1,ngscnt
7195 if ( qx(mgs,ls) .gt. qxmin(ls) ) then
7196 IF ( ipconc .ge. 4 ) THEN
7197 if ( mixedphase .and. qsvtmod ) then
7198 else
7199 IF ( isnowfall == 1 ) THEN
7200 ! original (Zrnic et al. 1993)
7201 vtxbar(mgs,ls,1) = 5.72462*rhovt(mgs)*(xv(mgs,ls))**(1./12.)
7202 ELSEIF ( isnowfall == 2 ) THEN
7203 ! Ferrier:
7204 IF ( isnowdens == 1 ) THEN
7205 vtxbar(mgs,ls,1) = 11.9495*rhovt(mgs)*(xv(mgs,ls))**(0.14)
7206 ELSE
7207 vtxbar(mgs,ls,1) = 11.9495*rhovt(mgs)*(xv(mgs,ls)*xdn(mgs,ls)/100.)**(0.14)
7208 ENDIF
7209 ELSEIF ( isnowfall == 3 ) THEN
7210 ! Cox, mass distrib:
7211 vtxbar(mgs,ls,1) = 50.092*rhovt(mgs)*(xmas(mgs,ls))**(0.2635)
7212 ENDIF
7213
7214 IF(abs(sssflg) >= 1) THEN
7215 IF ( isnowfall == 1 ) THEN
7216 vtxbar(mgs,ls,2) = 4.04091*rhovt(mgs)*(xv(mgs,ls))**(1./12.)
7217 ELSEIF ( isnowfall == 2 ) THEN
7218 ! Ferrier:
7219 IF ( isnowdens == 1 ) THEN
7220 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)
7221 ELSE
7222 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)
7223 ENDIF
7224 ELSEIF ( isnowfall == 3 ) THEN
7225 ! Cox, mass distrib:
7226 vtxbar(mgs,ls,2) = 21.6147*rhovt(mgs)*(xmas(mgs,ls))**(0.2635)
7227 ENDIF
7228 ELSE
7229 vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
7230 ENDIF
7231 IF ( infdo >= 2 ) THEN
7232 IF ( isnowfall == 1 ) THEN
7233 vtxbar(mgs,ls,3) = 6.12217*rhovt(mgs)*(xv(mgs,ls))**(1./12.) ! Zrnic et al 93
7234 ELSEIF ( isnowfall == 2 ) THEN
7235 vtxbar(mgs,ls,3) = 13.3436*rhovt(mgs)*(xv(mgs,ls))**(0.14) ! Ferrier 94
7236 ELSEIF ( isnowfall == 3 ) THEN
7237 ! Cox, mass distrib:
7238 vtxbar(mgs,ls,3) = 61.0914*rhovt(mgs)*(xmas(mgs,ls))**(0.2635)
7239 ENDIF
7240 ENDIF
7241
7242 IF ( sssflg < 0 .and. temcg(mgs) > abs(sssflg) ) THEN ! above a given temperature, effectively turn off size sorting
7243 vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
7244 vtxbar(mgs,ls,3) = vtxbar(mgs,ls,1)
7245 ENDIF
7246
7247 endif
7248 ELSE ! single-moment:
7249 vtxbar(mgs,ls,1) = (cs*gf4ds/6.0)*(xdia(mgs,ls,1)**ds)*rhovt(mgs)
7250 vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
7251 ENDIF
7252 else
7253 vtxbar(mgs,ls,1) = 0.0
7254 end if
7255
7256 IF ( snowfallfac /= 1.0 ) THEN
7257 vtxbar(mgs,ls,1) = snowfallfac*vtxbar(mgs,ls,1)
7258 vtxbar(mgs,ls,2) = snowfallfac*vtxbar(mgs,ls,2)
7259 vtxbar(mgs,ls,3) = snowfallfac*vtxbar(mgs,ls,3)
7260 ENDIF
7261
7262
7263 end do
7264 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set snow vt'
7265
7266 ENDIF ! ls .gt. 1
7267!
7268!
7269! ################################################################
7270!
7271! GRAUPEL !Wisner et al. (1972)
7272!
7273 IF ( lh .gt. 1 .and. ( ildo == 0 .or. ildo == lh ) ) THEN
7274
7275 do mgs = 1,ngscnt
7276 vtxbar(mgs,lh,1) = 0.0
7277 if ( qx(mgs,lh) .gt. qxmin(lh) ) then
7278 cd = cdx(lh)
7279 IF ( icdx .eq. 1 ) THEN
7280 cd = cdx(lh)
7281 ELSEIF ( icdx .eq. 2 ) THEN
7282! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(xdnmx(lh) - xdn(mgs,lh))/(xdnmx(lh)-xdnmn(lh)) ) )
7283! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lh))/(900. - 300.) ) )
7284 cd = max(0.45, min(1.0, 0.45 + 0.35*(800.0 - max( 500., min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
7285! cd = Max(0.55, Min(1.0, 0.55 + 0.25*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
7286 ELSEIF ( icdx .eq. 3 ) THEN
7287! cd = Max(0.45, Min(1.0, 0.45 + 0.55*(800.0 - Max( 300., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 300.) ) )
7288 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hdnmn, min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7289 ELSEIF ( icdx .eq. 4 ) THEN
7290 cd = max(cdhmin, min(cdhmax, cdhmin + (cdhmax-cdhmin)* &
7291 & (cdhdnmax - max( cdhdnmin, min( cdhdnmax, xdn(mgs,lh) ) ) )/(cdhdnmax - cdhdnmin) ) )
7292 ELSEIF ( icdx .eq. 5 ) THEN
7293 cd = cdx(lh)*(xdn(mgs,lh)/rho_qh)**(2./3.)
7294 ELSEIF ( icdx .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
7295 indxr = int( (xdn(mgs,lh)-50.)/100. ) + 1
7296 indxr = min( ngdnmm, max(1,indxr) )
7297
7298
7299 delrho = max( 0.0, 0.01*(xdn(mgs,lh) - mmgraupvt(indxr,1)) )
7300 IF ( indxr < ngdnmm ) THEN
7301
7302 axx(mgs,lh) = mmgraupvt(indxr,2) + delrho*(mmgraupvt(indxr+1,2) - mmgraupvt(indxr,2) )
7303 bxx(mgs,lh) = mmgraupvt(indxr,3) + delrho*(mmgraupvt(indxr+1,3) - mmgraupvt(indxr,3) )
7304
7305
7306 ELSE
7307 axx(mgs,lh) = mmgraupvt(indxr,2)
7308 bxx(mgs,lh) = mmgraupvt(indxr,3)
7309 ENDIF
7310
7311 aax = axx(mgs,lh)
7312 bbx = bxx(mgs,lh)
7313
7314 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hdnmn, min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7315
7316 ELSEIF ( icdx <= 0 ) THEN !
7317 aax = ax(lh)
7318 bbx = bx(lh)
7319 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hdnmn, min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7320 ELSE
7321 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hdnmn, min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7322 ENDIF
7323
7324 cdxgs(mgs,lh) = cd
7325 IF ( alpha(mgs,lh) .eq. 0.0 .and. icdx > 0 .and. icdx /= 6 ) THEN
7326! axx(mgs,lh) = (gf4p5/6.0)* &
7327! & Sqrt( (xdn(mgs,lh)*4.0*gr) / &
7328! & (3.0*cd*rho0(mgs)) )
7329 axx(mgs,lh) = sqrt(4.0*xdn(mgs,lh)*gr/(3.0*cd*rho00))
7330 bxx(mgs,lh) = 0.5
7331 vtxbar(mgs,lh,1) = (gf4p5/6.0)* rhovt(mgs)*axx(mgs,lh) * sqrt(xdia(mgs,lh,1))
7332! vtxbar(mgs,lh,1) = (gf4p5/6.0)* &
7333! & Sqrt( (xdn(mgs,lh)*xdia(mgs,lh,1)*4.0*gr) / &
7334! & (3.0*cd*rho0(mgs)) )
7335 ELSE
7336 IF ( icdx /= 6 ) bbx = bx(lh)
7337 tmp = 4. + alpha(mgs,lh) + bbx
7338 i = int(dgami*(tmp))
7339 del = tmp - dgam*i
7340 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7341
7342 tmp = 4. + alpha(mgs,lh)
7343 i = int(dgami*(tmp))
7344 del = tmp - dgam*i
7345 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7346
7347! aax = Max( 1.0, Min(2.0, (xdn(mgs,lh)/400.) ) )
7348! vtxbar(mgs,lh,1) = rhovt(mgs)*aax*ax(lh)*(xdia(mgs,lh,1)**bx(lh)*x)/y
7349
7350 IF ( icdx > 0 .and. icdx /= 6) THEN
7351 aax = sqrt(4.0*xdn(mgs,lh)*gr/(3.0*cd*rho00))
7352 vtxbar(mgs,lh,1) = rhovt(mgs)*aax* sqrt(xdia(mgs,lh,1)) * x/y
7353 axx(mgs,lh) = aax
7354 bxx(mgs,lh) = bbx
7355 ELSEIF (icdx == 6 ) THEN
7356 vtxbar(mgs,lh,1) = rhovt(mgs)*aax* xdia(mgs,lh,1)**bbx * x/y
7357 ELSE ! icdx < 0
7358 axx(mgs,lh) = ax(lh)
7359 bxx(mgs,lh) = bx(lh)
7360 vtxbar(mgs,lh,1) = rhovt(mgs)*ax(lh)*(xdia(mgs,lh,1)**bx(lh)*x)/y
7361 ENDIF
7362
7363! & Gamma_sp(4.0 + dnu(lh) + 0.6))/Gamma_sp(4. + dnu(lh))
7364 ENDIF
7365
7366 IF ( lwsm6 .and. ipconc == 0 ) THEN
7367! vtxbar(mgs,lh,1) = (330.*gf4ds/6.0)*(xdia(mgs,ls,1)**ds)*rhovt(mgs)
7368 vtxbar(mgs,lh,1) = (330.*gf4br/6.0)*(xdia(mgs,lh,1)**br)*rhovt(mgs)
7369 ENDIF
7370
7371 end if
7372 end do
7373 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt'
7374
7375 ENDIF ! lh .gt. 1
7376!
7377!
7378! ################################################################
7379!
7380! HAIL
7381!
7382 IF ( lhl .gt. 1 .and. ( ildo == 0 .or. ildo == lhl ) ) THEN
7383
7384 do mgs = 1,ngscnt
7385 vtxbar(mgs,lhl,1) = 0.0
7386 if ( qx(mgs,lhl) .gt. qxmin(lhl) ) then
7387
7388 IF ( icdxhl .eq. 1 ) THEN
7389 cd = cdx(lhl)
7390 ELSEIF ( icdxhl .eq. 3 ) THEN
7391! cd = Max(0.45, Min(1.0, 0.45 + 0.55*(800.0 - Max( 300., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 300.) ) )
7392 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hldnmn, min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
7393 ELSEIF ( icdxhl .eq. 4 ) THEN
7394 cd = max(cdhlmin, min(cdhlmax, cdhlmin + (cdhlmax-cdhlmin)* &
7395 & (cdhldnmax - max( cdhldnmin, min( cdhldnmax, xdn(mgs,lhl) ) ) )/(cdhldnmax - cdhldnmin) ) )
7396 ELSEIF ( icdxhl .eq. 5 ) THEN
7397 cd = cdx(lh)*(xdn(mgs,lhl)/rho_qh)**(2./3.)
7398 ELSEIF ( icdxhl .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
7399 indxr = int( (xdn(mgs,lhl)-50.)/100. ) + 1
7400 indxr = min( ngdnmm, max(1,indxr) )
7401
7402
7403 delrho = max( 0.0, 0.01*(xdn(mgs,lhl) - mmgraupvt(indxr,1)) )
7404 IF ( indxr < ngdnmm ) THEN
7405
7406 axx(mgs,lhl) = mmgraupvt(indxr,2) + delrho*(mmgraupvt(indxr+1,2) - mmgraupvt(indxr,2) )
7407 bxx(mgs,lhl) = mmgraupvt(indxr,3) + delrho*(mmgraupvt(indxr+1,3) - mmgraupvt(indxr,3) )
7408
7409
7410 ELSE
7411 axx(mgs,lhl) = mmgraupvt(indxr,2)
7412 bxx(mgs,lhl) = mmgraupvt(indxr,3)
7413 ENDIF
7414
7415 aax = axx(mgs,lhl)
7416 bbx = bxx(mgs,lhl)
7417
7418 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hldnmn, min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
7419
7420 ELSE
7421! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lhl))/(900. - 300.) ) )
7422! cd = Max(0.5, Min(0.8, 0.5 + 0.3*(xdnmx(lhl) - xdn(mgs,lhl))/(xdnmx(lhl)-xdnmn(lhl)) ) )
7423! cd = Max(0.45, Min(0.6, 0.45 + 0.15*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 500.) ) )
7424 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hldnmn, min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
7425 ENDIF
7426
7427 cdxgs(mgs,lhl) = cd
7428
7429 IF ( alpha(mgs,lhl) .eq. 0.0 .and. icdxhl > 0 .and. icdxhl /= 6) THEN
7430! axx(mgs,lhl) = (gf4p5/6.0)* &
7431! & Sqrt( (xdn(mgs,lhl)*4.0*gr) / &
7432! & (3.0*cd*rho0(mgs)) )
7433 axx(mgs,lhl) = sqrt(4.0*xdn(mgs,lhl)*gr/(3.0*cd*rho00))
7434 bxx(mgs,lhl) = 0.5
7435 vtxbar(mgs,lhl,1) = (gf4p5/6.0)* rhovt(mgs)*axx(mgs,lhl) * sqrt(xdia(mgs,lhl,1))
7436 ELSE
7437 IF ( icdxhl /= 6 ) bbx = bx(lhl)
7438 tmp = 4. + alpha(mgs,lhl) + bbx
7439 i = int(dgami*(tmp))
7440 del = tmp - dgam*i
7441 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7442
7443 tmp = 4. + alpha(mgs,lhl)
7444 i = int(dgami*(tmp))
7445 del = tmp - dgam*i
7446 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7447
7448 IF ( icdxhl > 0 .and. icdxhl /= 6) THEN
7449 aax = sqrt(4.0*xdn(mgs,lhl)*gr/(3.0*cd*rho00))
7450 vtxbar(mgs,lhl,1) = rhovt(mgs)*aax* sqrt(xdia(mgs,lhl,1)) * x/y
7451 axx(mgs,lhl) = aax
7452 bxx(mgs,lhl) = bbx
7453 ELSEIF ( icdxhl == 6 ) THEN
7454 vtxbar(mgs,lhl,1) = rhovt(mgs)*aax* (xdia(mgs,lhl,1))**bbx * x/y
7455 ELSE
7456 axx(mgs,lhl) = ax(lhl)
7457 bxx(mgs,lhl) = bx(lhl)
7458 vtxbar(mgs,lhl,1) = rhovt(mgs)*(ax(lhl)*xdia(mgs,lhl,1)**bx(lhl)*x)/y
7459 ENDIF
7460
7461! & Gamma_sp(4.0 + dnu(lh) + 0.6))/Gamma_sp(4. + dnu(lh))
7462 ENDIF
7463
7464
7465 end if
7466 end do
7467 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt'
7468
7469 ENDIF ! lhl .gt. 1
7470
7471
7472 IF ( infdo .ge. 1 ) THEN
7473
7474! DO il = lc,lhab
7475! IF ( il .ne. lr ) THEN
7476 DO mgs = 1,ngscnt
7477 IF ( ildo == 0 .or. ildo == lc ) THEN
7478 vtxbar(mgs,lc,2) = vtxbar(mgs,lc,1)
7479 ENDIF
7480 IF ( li .gt. 1 ) THEN
7481! vtxbar(mgs,li,2) = rhovt(mgs)*49420.*1.25447*xdia(mgs,li,1)**(1.415) ! n-wgt (Ferrier 94)
7482! vtxbar(mgs,li,2) = vtxbar(mgs,li,1)
7483
7484! test print stuff...
7485! IF ( xdia(mgs,li,1) .gt. 200.e-6 ) THEN
7486! tmp = (xv(mgs,li)*cwc0)**(1./3.)
7487! x = rhovt(mgs)*49420.*40.0005/5.40662*tmp**(1.415)
7488! y = rhovt(mgs)*49420.*1.25447*tmp**(1.415)
7489! write(6,*) 'Ice fall: ',vtxbar(mgs,li,1),x,y,tmp,xdia(mgs,li,1)
7490! ENDIF
7491 ENDIF
7492! vtxbar(mgs,ls,2) = vtxbar(mgs,ls,1)
7493 ENDDO
7494
7495 IF ( lg .gt. lr ) THEN
7496
7497 DO il = lg,lhab
7498 IF ( ildo == 0 .or. ildo == il ) THEN
7499
7500 DO mgs = 1,ngscnt
7501 IF ( qx(mgs,il) .gt. qxmin(il) ) THEN
7502 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
7503
7504 ! DTD: allow for setting of number-weighted and z-weighted fall speeds to the mass-weighted value,
7505 ! effectively turning off size-sorting
7506
7507 IF ( il .eq. lh ) THEN ! {
7508
7509 IF ( icdx .eq. 1 ) THEN
7510 cd = cdx(lh)
7511 ELSEIF ( icdx .eq. 2 ) THEN
7512! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(xdnmx(lh) - xdn(mgs,lh))/(xdnmx(lh)-xdnmn(lh)) ) )
7513! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lh))/(900. - 300.) ) )
7514 cd = max(0.45, min(1.0, 0.45 + 0.35*(800.0 - max( 500., min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
7515! cd = Max(0.55, Min(1.0, 0.55 + 0.25*(800.0 - Max( 500., Min( 800.0, xdn(mgs,lh) ) ) )/(800. - 500.) ) )
7516 ELSEIF ( icdx .eq. 3 ) THEN
7517! 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) ) )
7518 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hdnmn, min( 800.0, xdn(mgs,lh) ) ) )/(800. - 170.0) ) )
7519 ELSEIF ( icdx .eq. 4 ) THEN
7520 cd = max(cdhmin, min(cdhmax, cdhmin + (cdhmax-cdhmin)* &
7521 & (cdhdnmax - max( cdhdnmin, min( cdhdnmax, xdn(mgs,lh) ) ) )/(cdhdnmax - cdhdnmin) ) )
7522 ELSEIF ( icdx .eq. 5 ) THEN
7523 cd = cdx(lh)*(xdn(mgs,lh)/rho_qh)**(2./3.)
7524 ELSEIF ( icdx .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
7525 aax = axx(mgs,lh)
7526 bbx = bxx(mgs,lh)
7527 ELSEIF ( icdx <= 0 ) THEN !
7528 aax = ax(lh)
7529 bbx = bx(lh)
7530 ENDIF
7531
7532 ELSEIF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
7533
7534 IF ( icdxhl .eq. 1 ) THEN
7535 cd = cdx(lhl)
7536 ELSEIF ( icdxhl .eq. 3 ) THEN
7537! cd = Max(0.45, Min(1.0, 0.45 + 0.55*(800.0 - Max( 300., Min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 300.) ) )
7538 cd = max(0.45, min(1.2, 0.45 + 0.55*(800.0 - max( hldnmn, min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 170.0) ) )
7539 ELSEIF ( icdxhl .eq. 4 ) THEN
7540 cd = max(cdhlmin, min(cdhlmax, cdhlmin + (cdhlmax-cdhlmin)* &
7541 & (cdhldnmax - max( cdhldnmin, min( cdhldnmax, xdn(mgs,lhl) ) ) )/(cdhldnmax - cdhldnmin) ) )
7542 ELSEIF ( icdxhl == 5 ) THEN
7543! cd = Max(0.6, Min(1.0, 0.6 + 0.4*(900.0 - xdn(mgs,lhl))/(900. - 300.) ) )
7544! cd = Max(0.5, Min(0.8, 0.5 + 0.3*(xdnmx(lhl) - xdn(mgs,lhl))/(xdnmx(lhl)-xdnmn(lhl)) ) )
7545 cd = max(0.45, min(0.6, 0.45 + 0.15*(800.0 - max( 500., min( 800.0, xdn(mgs,lhl) ) ) )/(800. - 500.) ) )
7546 ELSEIF ( icdxhl .eq. 6 ) THEN ! Milbrandt and Morrison (2013)
7547 aax = axx(mgs,lhl)
7548 bbx = bxx(mgs,lhl)
7549 ELSEIF ( icdxhl <= 0 ) THEN !
7550 aax = ax(lhl)
7551 bbx = bx(lhl)
7552 ENDIF
7553
7554 ENDIF ! }
7555
7556 IF ( alpha(mgs,il) .eq. 0. .and. infdo .lt. 2 .and. &
7557 ( ( il==lh .and. icdx > 0 .and. icdx /= 6) .or. ( il==lhl .and. icdxhl > 0 .and. icdxhl /= 6 ) ) ) THEN ! {
7558 vtxbar(mgs,il,2) = &
7559 & sqrt( (xdn(mgs,il)*xdia(mgs,il,1)*pi*gr) / &
7560 & (3.0*cd*max(0.05,rho0(mgs))) )
7561
7562 ELSE
7563 IF ( il == lh .and. icdx /= 6 ) bbx = bx(il)
7564 IF ( il == lhl .and. icdxhl /= 6 ) bbx = bx(il)
7565 tmp = 1. + alpha(mgs,il) + bbx
7566 i = int(dgami*(tmp))
7567 del = tmp - dgam*i
7568 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7569
7570 tmp = 1. + alpha(mgs,il)
7571 i = int(dgami*(tmp))
7572 del = tmp - dgam*i
7573 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7574
7575 IF ( il .eq. lh .or. il .eq. lhl) THEN ! {
7576 IF ( ( il==lh .and. icdx > 0 ) ) THEN
7577 IF ( icdx /= 6 ) THEN
7578 aax = sqrt(4.0*xdn(mgs,il)*gr/(3.0*cd*rho00))
7579 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bx(il) * x/y
7580 ELSE ! (icdx == 6 ) THEN
7581 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bbx * x/y
7582 ENDIF
7583
7584 ELSEIF ( ( il==lhl .and. icdxhl > 0 ) ) THEN
7585 IF ( icdxhl /= 6 ) THEN
7586 aax = sqrt(4.0*xdn(mgs,il)*gr/(3.0*cd*rho00))
7587 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bx(il) * x/y
7588 ELSE ! ( icdxhl == 6 )
7589 vtxbar(mgs,il,2) = rhovt(mgs)*aax* xdia(mgs,il,1)**bbx * x/y
7590 ENDIF
7591 ELSE ! get here if il==lh and icdx < 0 -- or -- il==lhl and icdxhl < 0
7592 aax = ax(il)
7593 vtxbar(mgs,il,2) = rhovt(mgs)*ax(il)*(xdia(mgs,il,1)**bx(il)*x)/y
7594 ENDIF
7595! vtxbar(mgs,il,2) = &
7596! & rhovt(mgs)*(xdn(mgs,il)/400.)*(75.715*xdia(mgs,il,1)**0.6* &
7597! & x)/y
7598! vtxbar(mgs,il,2) = &
7599! & rhovt(mgs)*(xdn(mgs,il)/400.)*(ax(il)*xdia(mgs,il,1)**bx(il)* &
7600! & x)/y
7601 IF ( infdo .ge. 2 ) THEN ! Z-weighted
7602
7603 tmp = 7. + alpha(mgs,il) + bbx
7604 i = int(dgami*(tmp))
7605 del = tmp - dgam*i
7606 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7607
7608 tmp = 7. + alpha(mgs,il)
7609 i = int(dgami*(tmp))
7610 del = tmp - dgam*i
7611 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
7612
7613 vtxbar(mgs,il,3) = rhovt(mgs)* &
7614 & (aax*(xdia(mgs,il,1) )**bbx * &
7615 & x)/y
7616! & Gamma(7.0 + alpha(mgs,il) + bbx)/Gamma(7. + alpha(mgs,il))
7617 IF ( .not. (vtxbar(mgs,il,1) > -1. .and. vtxbar(mgs,il,1) < 250. ) .or. &
7618 .not. (vtxbar(mgs,il,3) > -1. .and. vtxbar(mgs,il,3) < 250. ) ) THEN
7619 write(0,*) 'Setvtz: problem with vtxbar1/3: ',il,vtxbar(mgs,il,1),vtxbar(mgs,il,3),aax,bbx,x,y
7620 write(0,*) 'q, number, diam1,3(mm) = ', qx(mgs,il),cx(mgs,il),1000.*xdia(mgs,il,1),1000.*xdia(mgs,il,3)
7621 ! call commasmpi_abort()
7622 ENDIF
7623! & (aax*(1.0/xdia(mgs,il,1) )**(- bx(il))* &
7624! & Gamma_sp(7.0 + alpha(mgs,il) + bx(il)))/Gamma_sp(7. + alpha(mgs,il))
7625 ENDIF
7626
7627 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt3'
7628
7629 ELSE ! hail
7630 vtxbar(mgs,il,2) = &
7631 & rhovt(mgs)*(ax(il)*xdia(mgs,il,1)**bx(il)* &
7632 & x)/y
7633
7634 IF ( infdo .ge. 2 ) THEN ! Z-weighted
7635 vtxbar(mgs,il,3) = rhovt(mgs)* &
7636 & (aax*(1.0/xdia(mgs,il,1) )**(- bbx)* &
7637 & gamma_sp(7.0 + alpha(mgs,il) + bbx))/gamma_sp(7. + alpha(mgs,il))
7638! & (ax(il)*(1.0/xdia(mgs,il,1) )**(- bx(il))* &
7639! & Gamma_sp(7.0 + alpha(mgs,il) + bx(il)))/Gamma_sp(7. + alpha(mgs,il))
7640 ENDIF
7641
7642 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set hail vt4'
7643
7644 ENDIF ! }
7645! & Gamma_sp(1.0 + dnu(il) + 0.6)/Gamma_sp(1. + dnu(il))
7646 ENDIF ! }
7647
7648! IF ( infdo .ge. 2 ) THEN ! Z-weighted
7649! vtxbar(mgs,il,3) = rhovt(mgs)* &
7650! & (ax(il)*(1.0/xdia(mgs,il,1) )**(- bx(il))* &
7651! & Gamma_sp(7.0 + alpha(mgs,il) + bx(il)))/Gamma_sp(7. + alpha(mgs,il))
7652! ENDIF
7653
7654! IF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
7655! write(0,*) 'setvt: ',qx(mgs,il),xdia(mgs,il,1),xdia(mgs,il,3),dnu(il),ax(il),bx(il)
7656! ENDIF
7657 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
7658 vtxbar(mgs,il,2) = vtxbar(mgs,il,1)
7659 vtxbar(mgs,il,3) = vtxbar(mgs,il,1)
7660 ELSE ! not lh or lhl
7661 vtxbar(mgs,il,2) = &
7662 & sqrt( (xdn(mgs,il)*xdia(mgs,il,1)*pi*gr) / &
7663 & (3.0*cdx(il)*max(0.05,rho0(mgs))) )
7664 vtxbar(mgs,il,3) = vtxbar(mgs,il,1)
7665
7666 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt5'
7667
7668
7669 ENDIF
7670 ELSE ! qx < qxmin
7671 vtxbar(mgs,il,2) = 0.0
7672
7673 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt6'
7674
7675 ENDIF
7676 ENDDO ! mgs
7677
7678 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt7'
7679
7680 ENDIF
7681 ENDDO ! il
7682
7683 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt8'
7684
7685 ENDIF ! lg .gt. 1
7686
7687! ENDIF
7688! ENDDO
7689
7690 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: Set graupel vt9'
7691
7692! DO mgs = 1,ngscnt
7693! IF ( qx(mgs,lr) > qxmin(lr) ) THEN
7694! write(0,*) 'setvt2: mgs,lzr,infdo = ',mgs,lzr,infdo
7695! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,lr,1),vtxbar(mgs,lr,2),vtxbar(mgs,lr,3)
7696! ENDIF
7697! ENDDO
7698
7699 ENDIF ! infdo .ge. 1
7700
7701 IF ( lh > 0 .and. graupelfallfac /= 1.0 ) THEN
7702 DO mgs = 1,ngscnt
7703 vtxbar(mgs,lh,1) = graupelfallfac*vtxbar(mgs,lh,1)
7704 vtxbar(mgs,lh,2) = graupelfallfac*vtxbar(mgs,lh,2)
7705 vtxbar(mgs,lh,3) = graupelfallfac*vtxbar(mgs,lh,3)
7706 axx(mgs,lh) = graupelfallfac*axx(mgs,lh)
7707 ENDDO
7708 ENDIF
7709
7710 IF ( lhl > 0 .and. hailfallfac /= 1.0 ) THEN
7711 DO mgs = 1,ngscnt
7712 vtxbar(mgs,lhl,1) = hailfallfac*vtxbar(mgs,lhl,1)
7713 vtxbar(mgs,lhl,2) = hailfallfac*vtxbar(mgs,lhl,2)
7714 vtxbar(mgs,lhl,3) = hailfallfac*vtxbar(mgs,lhl,3)
7715 axx(mgs,lhl) = hailfallfac*axx(mgs,lhl)
7716 ENDDO
7717 ENDIF
7718
7719 if ( ndebug1 .gt. 0 ) write(0,*) 'SETVTZ: END OF ROUTINE'
7720
7721!############ SETVTZ ############################
7722
7723 RETURN
7724 END SUBROUTINE setvtz
7725!--------------------------------------------------------------------------
7726
7727!
7728! ##############################################################################
7729
7730!
7731! subroutine to calculate fall speeds of hydrometeors
7732!
7733
7736 subroutine ziegfall1d(nx,ny,nz,nor,norz,na,dtp,jgs,ixcol, &
7737 & xvt, rhovtzx, &
7738 & an,dn,ipconc0,t0,t7,cwmasn,cwmasx, &
7739 & cwradn, &
7740 & qxmin,xdnmx,xdnmn,cdx,cno,xdn0,xvmn,xvmx, &
7741 & ngs,qx,qxw,cx,xv,vtxbar,xmas,xdn,xdia,vx,alpha,zx,igs,kgs, &
7742 & rho0,temcg,temg,rhovt,cwnc,cinc,fadvisc,cwdia,cipmas,cnina,cimas, &
7743 & cnostmp, &
7744 & infdo,ildo,timesetvt)
7745
7746! 12.16.2005: .F version use in transitional SWM model
7747!
7748! 10.10.2003: Added cimn and cimx to setting for cci and cip.
7749!
7750! TO DO LIST:
7751!
7752! need to set up values for:
7753! : cipdia,cidia,cwdia,cwmas,vtwbar,
7754! : rho0,temcg,cip,cci
7755!
7756! and need to put fallspeed values in cwvt etc.
7757!
7758
7759 implicit none
7760 integer ng1
7761 parameter(ng1 = 1)
7762
7763 integer, intent(in) :: ixcol ! which column to return
7764 integer, intent(in) :: ildo
7765
7766 integer nx,ny,nz,nor,norz,ngt,jgs,na
7767 real an(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,na)
7768 real dn(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
7769 real t0(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
7770 real t7(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor)
7771 real dtp,dtz1
7772
7773 real :: rhovtzx(nz,nx)
7774
7775 integer ndebugzf
7776 parameter(ndebugzf = 0)
7777
7778 integer ix,jy,kz,i,j,k,il
7779 integer infdo
7780!
7781!
7782 real xvt(nz+1,nx,3,lc:lhab) ! 1=mass-weighted, 2=number-weighted
7783
7784 real qxmin(lc:lhab)
7785 real xdn0(lc:lhab)
7786 real xvmn(lc:lhab), xvmx(lc:lhab)
7787 double precision,optional :: timesetvt
7788
7789 integer :: ngs
7790 integer :: ngscnt,mgs,ipconc0
7791! parameter ( ngs=200 )
7792
7793 real :: qx(ngs,lv:lhab)
7794 real :: qxw(ngs,ls:lhab)
7795 real :: cx(ngs,lc:lhab)
7796 real :: xv(ngs,lc:lhab)
7797 real :: vtxbar(ngs,lc:lhab,3)
7798 real :: xmas(ngs,lc:lhab)
7799 real :: xdn(ngs,lc:lhab)
7800 real :: cdxgs(ngs,lc:lhab)
7801 real :: xdia(ngs,lc:lhab,3)
7802 real :: vx(ngs,li:lhab)
7803 real :: alpha(ngs,lc:lhab)
7804 real :: zx(ngs,lr:lhab)
7805
7806 real xdnmx(lc:lhab), xdnmn(lc:lhab)
7807 real :: axx(ngs,lh:lhab), bxx(ngs,lh:lhab)
7808! real axh(ngs),bxh(ngs),axhl(ngs),bxhl(ngs)
7809
7810!
7811! drag coefficients
7812!
7813 real cdx(lc:lhab)
7814!
7815! Fixed intercept values for single moment scheme
7816!
7817 real cno(lc:lhab)
7818
7819 real cwccn0,cwmasn,cwmasx,cwradn
7820! real cwc0
7821
7822 integer nxmpb,nzmpb,nxz,numgs,inumgs
7823 integer kstag
7824 parameter(kstag=1)
7825
7826 integer igs(ngs),kgs(ngs)
7827
7828 real rho0(ngs),temcg(ngs)
7829
7830 real temg(ngs)
7831
7832 real rhovt(ngs)
7833
7834 real cwnc(ngs),cinc(ngs)
7835 real fadvisc(ngs),cwdia(ngs),cipmas(ngs)
7836
7837! real cimasn,cimasx,
7838 real :: cnina(ngs),cimas(ngs)
7839
7840 real :: cnostmp(ngs)
7841
7842! real pii
7843!
7844!
7845! general constants for microphysics
7846!
7847
7848!
7849! Miscellaneous
7850!
7851
7852 logical flag
7853 logical ldoliq
7854
7855
7856 real chw, qr, z, rd, alp, z1, g1, vr, nrx, tmp, tmpc, tmpz
7857
7858 real vtmax
7859 real xvbarmax
7860
7861 real, parameter :: c1r=19.0, c2r=0.6, c3r=1.8, c4r=17.0 ! rain
7862 real, parameter :: c1h=5.5, c2h=0.7, c3h=4.5, c4h=8.5 ! Graupel
7863 real, parameter :: c1hl=3.7, c2hl=0.3, c3hl=9.0, c4hl=6.5, c5hl=1.0, c6hl=6.5 ! Hail
7864
7865 integer l1, l2
7866
7867 double precision :: dpt1, dpt2
7868
7869
7870!-----------------------------------------------------------------------------
7871! MPI LOCAL VARIABLES
7872
7873 integer :: ixb, jyb, kzb
7874 integer :: ixe, jye, kze
7875
7876 logical :: debug_mpi = .false.
7877
7878
7879 if (ndebugzf .gt. 0 ) write(0,*) "ZIEGFALL1D: ENTERED SUBROUTINE"
7880
7881! #####################################################################
7882! BEGIN EXECUTABLE
7883! #####################################################################
7884!
7885
7886! constants
7887!
7888
7889 ldoliq = .false.
7890 IF ( ls .gt. 1 ) THEN
7891 DO il = ls,lhab
7892 ldoliq = ldoliq .or. ( lliq(il) .gt. 1 )
7893 ENDDO
7894 ENDIF
7895
7896! poo = 1.0e+05
7897! cp608 = 0.608
7898! cp = 1004.0
7899! cv = 717.0
7900! dnz00 = 1.225
7901! rho00 = 1.225
7902! cs = 4.83607122
7903! ds = 0.25
7904! new values for cs and ds
7905! cs = 12.42
7906! ds = 0.42
7907! pi = 4.0*atan(1.0)
7908! pii = piinv ! 1./pi
7909! pid4 = pi/4.0
7910! qccrit = 2.0e-03
7911! qscrit = 6.0e-04
7912! cwc0 = pii
7913
7914!
7915!
7916! general constants for microphysics
7917!
7918
7919!
7920! ci constants in mks units
7921!
7922! cimasn = 6.88e-13
7923! cimasx = 1.0e-8
7924!
7925! Set terminal velocities...
7926! also set drag coefficients
7927!
7928 jy = jgs
7929 nxmpb = ixcol
7930 nzmpb = 1
7931 nxz = 1*nz
7932! ngs = nz
7933 numgs = 1
7934
7935 IF ( ildo == 0 ) THEN
7936 l1 = lc
7937 l2 = lhab
7938 ELSE
7939 l1 = ildo
7940 l2 = ildo
7941 ENDIF
7942
7943
7944 do inumgs = 1,numgs
7945 ngscnt = 0
7946
7947
7948 do kz = 1,nz
7949 do ix = ixcol,ixcol
7950 flag = .false.
7951
7952 DO il = l1,l2
7953 flag = flag .or. ( an(ix,jy,kz,il) > 0.0 )
7954 ENDDO
7955
7956 if ( flag ) then
7957! load temp quantities
7958
7959 ngscnt = ngscnt + 1
7960 igs(ngscnt) = ix
7961 kgs(ngscnt) = kz
7962 if ( ngscnt .eq. nz ) goto 1100
7963 end if
7964 end do !!ix
7965 nxmpb = 1
7966 end do !! kz
7967
7968! if ( jy .eq. (ny-jstag) ) iend = 1
7969
7970 1100 continue
7971
7972 if ( ngscnt .eq. 0 ) go to 9998
7973!
7974! set temporaries for microphysics variables
7975!
7976
7977
7978!
7979! Reconstruct various quantities
7980!
7981 do mgs = 1,ngscnt
7982
7983 rho0(mgs) = dn(igs(mgs),jy,kgs(mgs))
7984 rhovt(mgs) = rhovtzx(kgs(mgs),ixcol) ! Sqrt(rho00/rho0(mgs))
7985 temg(mgs) = t0(igs(mgs),jy,kgs(mgs))
7986 temcg(mgs) = temg(mgs) - tfr
7987
7988
7989!
7990 end do
7991!
7992! only need fadvisc for droplets
7993 IF ( lc .gt. 1 .and. (ildo == 0 .or. ildo == lc ) ) then
7994 do mgs = 1,ngscnt
7995 fadvisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))* &
7996 & (temg(mgs)/296.0)**(1.5)
7997 end do
7998 ENDIF
7999
8000 IF ( ipconc .eq. 0 ) THEN
8001 do mgs = 1,ngscnt
8002 cnina(mgs) = t7(igs(mgs),jgs,kgs(mgs))
8003 end do
8004 ENDIF
8005
8006
8007 IF ( ildo > 0 ) THEN
8008 vtxbar(:,ildo,:) = 0.0
8009 ELSE
8010 vtxbar(:,:,:) = 0.0
8011 ENDIF
8012
8013! do mgs = 1,ngscnt
8014! qx(mgs,lv) = max(an(igs(mgs),jy,kgs(mgs),lv), 0.0)
8015! ENDDO
8016 DO il = l1,l2
8017 do mgs = 1,ngscnt
8018 qx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),il), 0.0)
8019 ENDDO
8020 end do
8021
8022 cnostmp(:) = cno(ls)
8023 IF ( ipconc < 1 .and. lwsm6 .and. (ildo == 0 .or. ildo == ls )) THEN
8024 DO mgs = 1,ngscnt
8025 tmp = min( 0.0, temcg(mgs) )
8026 cnostmp(mgs) = min( 2.e8, 2.e6*exp(0.12*tmp) )
8027 ENDDO
8028 ENDIF
8029
8030
8031!
8032! set concentrations
8033!
8034 cx(:,:) = 0.0
8035
8036 if ( ipconc .ge. 1 .and. li .gt. 1 .and. (ildo == 0 .or. ildo == li ) ) then
8037 do mgs = 1,ngscnt
8038 cx(mgs,li) = max(an(igs(mgs),jy,kgs(mgs),lni), 0.0)
8039 end do
8040 end if
8041
8042 if ( ipconc .ge. 2 .and. lc .gt. 1 .and. (ildo == 0 .or. ildo == lc ) ) then
8043 do mgs = 1,ngscnt
8044 cx(mgs,lc) = max(an(igs(mgs),jy,kgs(mgs),lnc), 0.0)
8045 end do
8046 end if
8047
8048 if ( ipconc .ge. 3 .and. lr .gt. 1 .and. (ildo == 0 .or. ildo == lr ) ) then
8049 do mgs = 1,ngscnt
8050 cx(mgs,lr) = max(an(igs(mgs),jy,kgs(mgs),lnr), 0.0)
8051 end do
8052 end if
8053
8054 if ( ipconc .ge. 4 .and. ls .gt. 1 .and. (ildo == 0 .or. ildo == ls ) ) then
8055 do mgs = 1,ngscnt
8056 cx(mgs,ls) = max(an(igs(mgs),jy,kgs(mgs),lns), 0.0)
8057 end do
8058 end if
8059
8060 if ( ipconc .ge. 5 .and. lh .gt. 1 .and. (ildo == 0 .or. ildo == lh ) ) then
8061 do mgs = 1,ngscnt
8062 cx(mgs,lh) = max(an(igs(mgs),jy,kgs(mgs),lnh), 0.0)
8063 end do
8064 ENDIF
8065
8066 if ( ipconc .ge. 5 .and. lhl .gt. 1 .and. (ildo == 0 .or. ildo == lhl ) ) then
8067 do mgs = 1,ngscnt
8068 cx(mgs,lhl) = max(an(igs(mgs),jy,kgs(mgs),lnhl), 0.0)
8069 end do
8070 end if
8071
8072 ! Vaporize tiny values
8073 DO il = l1,l2
8074 IF ( lz(il) < 1 .and. ln(il) > 1 ) THEN
8075 do mgs = 1,ngscnt
8076 IF ( cx(mgs,il) <= cxmin .or. qx(mgs,il) < qxmin(il) ) THEN
8077 cx(mgs,il) = 0.0
8078 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8079 qx(mgs,il) = 0.0
8080 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8081 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8082 ENDIF
8083 end do
8084 ENDIF
8085 ENDDO
8086
8087 do mgs = 1,ngscnt
8088 xdn(mgs,lc) = xdn0(lc)
8089 xdn(mgs,lr) = xdn0(lr)
8090! IF ( ls .gt. 1 .and. lvs .eq. 0 ) xdn(mgs,ls) = xdn0(ls)
8091! IF ( lh .gt. 1 .and. lvh .eq. 0 ) xdn(mgs,lh) = xdn0(lh)
8092 IF ( li .gt. 1 ) xdn(mgs,li) = xdn0(li)
8093 IF ( ls .gt. 1 ) xdn(mgs,ls) = xdn0(ls)
8094 IF ( lh .gt. 1 ) xdn(mgs,lh) = xdn0(lh)
8095 IF ( lhl .gt. 1 ) xdn(mgs,lhl) = xdn0(lhl)
8096 end do
8097
8098!
8099! Set mean particle volume
8100!
8101 IF ( ldovol .and. (ildo == 0 .or. ildo >= li ) ) THEN
8102
8103 vx(:,:) = 0.0
8104
8105 DO il = l1,l2
8106
8107 IF ( lvol(il) .ge. 1 ) THEN
8108
8109 DO mgs = 1,ngscnt
8110 vx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),lvol(il)), 0.0)
8111 IF ( vx(mgs,il) .gt. rho0(mgs)*qxmin(il)*1.e-3 .and. qx(mgs,il) .gt. qxmin(il) ) THEN
8112 xdn(mgs,il) = min( xdnmx(il), max( xdnmn(il), rho0(mgs)*qx(mgs,il)/vx(mgs,il) ) )
8113 ENDIF
8114 ENDDO
8115
8116 ENDIF
8117
8118 ENDDO
8119
8120 ENDIF
8121
8122 DO il = lg,lhab
8123 DO mgs = 1,ngscnt
8124 alpha(mgs,il) = dnu(il)
8125 ENDDO
8126 ENDDO
8127
8128 IF ( imurain == 1 ) THEN
8129 alpha(:,lr) = alphar
8130 ELSEIF ( imurain == 3 ) THEN
8131 alpha(:,lr) = xnu(lr)
8132 ENDIF
8133
8134
8135 IF ( ipconc == 5 .and. imydiagalpha > 0 ) THEN
8136 DO mgs = 1,ngscnt
8137 IF ( qx(mgs,lr) .gt. qxmin(lr) .and. cx(mgs,lr) > cxmin ) THEN
8138 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr)) !
8139 xdia(mgs,lr,3) = (xv(mgs,lr)*6.0*cwc1)**(1./3.)
8140 alpha(mgs,lr) = min(alphamax, c1r*tanh(c2r*(xdia(mgs,lr,3)*1000. - c3r)) + c4r)
8141 ENDIF
8142 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. cx(mgs,lh) > cxmin ) THEN
8143 xv(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) !
8144 xdia(mgs,lh,3) = (xv(mgs,lh)*6.*piinv)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
8145 alpha(mgs,lh) = min(alphamax, c1h*tanh(c2h*(xdia(mgs,lh,3)*1000. - c3h)) + c4h)
8146 ENDIF
8147! alpha(:,lr) = 0. ! 10.
8148! alpha(:,lh) = 0. ! 10.
8149 IF ( lhl > 0 ) THEN
8150 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. cx(mgs,lhl) > cxmin ) THEN
8151 xv(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*cx(mgs,lhl)) !
8152 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6.*piinv)**(1./3.)
8153 IF ( xdia(mgs,lhl,3) < 0.008 ) THEN
8154 alpha(mgs,lhl) = min(alphamax, c1hl*tanh(c2hl*(xdia(mgs,lhl,3)*1000. - c3hl)) + c4hl)
8155 ELSE
8156 alpha(mgs,lhl) = min(alphamax, c5hl*xdia(mgs,lhl,3)*1000. + c6hl)
8157 ENDIF
8158 ENDIF
8159 ENDIF
8160 ENDDO
8161 ENDIF
8162
8163
8164!
8165! Set 6th moments
8166!
8167 IF ( ipconc .ge. 6 .or. lzr > 1) THEN
8168
8169 zx(:,:) = 0.0
8170
8171! DO il = lr,lhab
8172 DO il = l1,l2
8173
8174 IF ( lz(il) .ge. 1 ) THEN
8175
8176 DO mgs = 1,ngscnt
8177 zx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),lz(il)), 0.0)
8178 ENDDO
8179
8180
8181 ENDIF
8182
8183 ENDDO
8184
8185 ENDIF
8186
8187
8188
8189
8190
8191! Find shape parameter rain
8192
8193
8194 IF ( lz(lr) > 1 .and. (ildo == 0 .or. ildo == lr ) .and. imurain == 3 ) THEN ! { RAIN SHAPE PARAM
8195 il = lr
8196 DO mgs = 1,ngscnt
8197
8198 IF ( iresetmoments == 1 .or. iresetmoments == il ) THEN
8199! IF ( .false. .and. zx(mgs,lr) <= zxmin ) THEN
8200 IF ( zx(mgs,lr) <= zxmin ) THEN
8201 qx(mgs,lr) = 0.0
8202 cx(mgs,lr) = 0.0
8203 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
8204 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
8205 an(igs(mgs),jgs,kgs(mgs),ln(lr)) = cx(mgs,lr)
8206! ELSEIF ( zx(mgs,lr) <= 0.0 .and. cx(mgs,lr) > 0.0 .and. qx(mgs,il) .gt. qxmin(il)) THEN
8207! write(91,*) 'ZF: overdepletion of Zr: z,c,q = ',zx(mgs,il),cx(mgs,il),qx(mgs,il)
8208 ELSEIF ( cx(mgs,lr) <= cxmin ) THEN
8209 zx(mgs,lr) = 0.0
8210 qx(mgs,lr) = 0.0
8211 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
8212 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
8213 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
8214 ENDIF
8215 ENDIF
8216
8217
8218
8219 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
8220
8221 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*max(1.0e-11,cx(mgs,lr)))
8222 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
8223! tmp = cx(mgs,lr)
8224! xv(mgs,lr) = xvmx(lr)
8225! cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
8226! an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8227! IF ( tmp < cx(mgs,il) ) THEN ! breakup
8228! g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8229!! zx(mgs,lr) = zx(mgs,lr) + g1*(rho0(mgs)/(1000.))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
8230!! an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
8231! ENDIF
8232 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
8233 xv(mgs,lr) = xvmn(lr)
8234 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
8235 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8236 ENDIF
8237
8238 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
8239! have mass and reflectivity but no concentration, so set concentration, using default alpha
8240 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8241 z = zx(mgs,il)
8242 qr = qx(mgs,il)
8243
8244 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*1000.*1000)
8245 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8246
8247 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > cxmin ) THEN
8248! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
8249 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8250 chw = cx(mgs,il)
8251 qr = qx(mgs,il)
8252
8253! xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(1000.*Max(1.0e-9,cx(mgs,lr)))
8254! vr = xv(mgs,lr)
8255
8256! z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
8257! zx(mgs,il) = z
8258! an(igs(mgs),jy,kgs(mgs),lz(il)) = z
8259
8260 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(xdn(mgs,lr)**2*chw)
8261 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8262
8263 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
8264! How did this happen?
8265 ! set values according to dBZ of -10, or Z = 0.1
8266! write(91,*) 'alpha = ',alpha(mgs,il)
8267 IF ( qx(mgs,il) < 1.e-8 ) THEN
8268 qx(mgs,il) = 0.0
8269 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8270 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8271 ELSE
8272! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
8273 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
8274 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8275
8276 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8277 z = zx(mgs,il)
8278 qr = qx(mgs,il)
8279 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*1000.*1000)
8280 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8281 ENDIF
8282 ENDIF
8283
8284 IF ( zx(mgs,lr) > 0.0 ) THEN
8285 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(1000.*max(1.0e-9,cx(mgs,lr)))
8286 vr = xv(mgs,lr)
8287! z = 36.*(alpha(kz)+2.0)*a(ix,jy,kz,lnr)*vr**2/((alpha(kz)+1.0)*pi**2)
8288 qr = qx(mgs,lr)
8289 nrx = cx(mgs,lr)
8290 z = zx(mgs,lr)
8291
8292! xv = (db(1,kz)*a(1,1,kz,lr))**2/(a(1,1,kz,lnr))
8293! rd = z*(pi/6.*1000.)**2/xv
8294
8295! determine shape parameter alpha by iteration
8296 IF ( z .gt. 0.0 ) THEN
8297! alpha(mgs,lr) = 3.
8298 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
8299 DO i = 1,20
8300! IF ( 100.*Abs(alp - alpha(mgs,lr))/Abs(alpha(mgs,lr)) .lt. 1. ) EXIT
8301 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
8302 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
8303 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
8304! write(0,*) 'i,alp = ',i,alp
8305 alp = max( rnumin, min( rnumax, alp ) )
8306 ENDDO
8307! write(0,*) 'kz, alp, alpha(kz) = ',kz,alp,alpha(mgs,lr),qr*1000,z*1.e18,vr,nrx
8308
8309
8310! check for artificial breakup (rain larger than allowed max size)
8311 IF ( xv(mgs,il) .gt. xvmx(il) ) THEN
8312 tmp = cx(mgs,il)
8313 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
8314 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
8315 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
8316 IF ( tmp < cx(mgs,il) ) THEN ! breakup
8317
8318 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8319 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
8320 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8321
8322 vr = xv(mgs,lr)
8323 qr = qx(mgs,lr)
8324 nrx = cx(mgs,lr)
8325 z = zx(mgs,lr)
8326
8327
8328! determine shape parameter alpha by iteration
8329 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
8330 DO i = 1,20
8331 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
8332 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
8333 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
8334 alp = max( rnumin, min( rnumax, alp ) )
8335 ENDDO
8336
8337
8338 ENDIF
8339 ENDIF
8340
8341!
8342! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
8343! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
8344!
8345! IF ( alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax ) THEN
8346 IF ( .true. .and. (alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax) ) THEN
8347
8348 IF ( rescale_high_alpha .and. alp >= rnumax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
8349 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
8350 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(1./(xdn(mgs,il)))**2
8351 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
8352
8353 ELSEIF ( rescale_low_alphar .and. alp <= rnumin ) THEN
8354
8355 z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
8356 zx(mgs,il) = z
8357 an(igs(mgs),jy,kgs(mgs),lz(il)) = z
8358
8359 ENDIF
8360 ENDIF
8361
8362 ENDIF
8363 ENDIF
8364
8365 ELSE
8366
8367 zx(mgs,lr) = 0.0
8368 cx(mgs,lr) = 0.0
8369 an(igs(mgs),jgs,kgs(mgs),ln(lr)) = cx(mgs,lr)
8370 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
8371
8372 ENDIF
8373
8374 ENDDO
8375 ENDIF ! }
8376
8377
8378 IF ( ipconc .ge. 6 ) THEN
8379
8380! Find shape parameters for graupel,hail
8381
8382 DO il = lr,lhab
8383
8384 IF ( lz(il) .gt. 1 .and. (ildo == 0 .or. ildo == il ) .and. ( .not. ( il == lr .and. imurain == 3 )) ) THEN
8385
8386 DO mgs = 1,ngscnt
8387
8388 IF ( iresetmoments == 1 .or. iresetmoments == il .or. iresetmoments == -1 ) THEN
8389 IF ( zx(mgs,il) <= zxmin ) THEN ! .and. qx(mgs,il) > 0.05e-3 ) THEN
8390 qx(mgs,il) = 0.0
8391 cx(mgs,il) = 0.0
8392 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8393 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8394 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8395 ELSEIF ( iresetmoments == -1 .and. qx(mgs,il) < qxmin(il) ) THEN
8396 zx(mgs,il) = 0.0
8397 cx(mgs,il) = 0.0
8398 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8399
8400 qx(mgs,il) = 0.0
8401 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8402 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8403 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8404
8405 ELSEIF ( cx(mgs,il) <= cxmin .and. iresetmoments /= -1 ) THEN ! .and. qx(mgs,il) > 0.05e-3 ) THEN
8406!! write(91,*) 'cx=0; qx,zx = ',1000.*qx(mgs,il),1.e18*zx(mgs,il)
8407 zx(mgs,il) = 0.0
8408 qx(mgs,il) = 0.0
8409 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8410 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8411 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8412 ENDIF
8413 ENDIF
8414
8415 IF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= cxmin ) THEN
8416 zx(mgs,il) = 0.0
8417 cx(mgs,il) = 0.0
8418 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8419 qx(mgs,il) = 0.0
8420 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8421 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8422 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8423 ENDIF
8424
8425 IF ( qx(mgs,il) .gt. qxmin(il) ) THEN
8426
8427 xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*max(1.0e-9,cx(mgs,il)))
8428 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
8429
8430 IF ( xv(mgs,il) .lt. xvmn(il) ) THEN
8431! tmp = cx(mgs,il)
8432 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
8433 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
8434 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
8435! IF ( tmp < cx(mgs,il) ) THEN ! breakup
8436! g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8437! & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
8438! zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
8439! an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8440!
8441! ENDIF
8442 ENDIF
8443
8444 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
8445! have mass and reflectivity but no concentration, so set concentration, using default alpha
8446 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8447 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
8448 z = zx(mgs,il)
8449 qr = qx(mgs,il)
8450 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(z*(pi*xdn(mgs,il))**2)
8451 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8452
8453 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > cxmin ) THEN
8454! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
8455 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8456 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
8457 chw = cx(mgs,il)
8458 qr = qx(mgs,il)
8459! zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
8460 zx(mgs,il) = min(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
8461 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8462 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
8463! How did this happen?
8464! write(91,*) 'ziegfall: something screwy with moments: il = ',il
8465! write(91,*) 'q,n,z = ', 1.e3*qx(mgs,il),cx(mgs,il),zx(mgs,il)
8466! write(91,*) 'alpha = ',alpha(mgs,il)
8467
8468 IF ( qx(mgs,il) < 1.e-8 ) THEN
8469 qx(mgs,il) = 0.0
8470 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
8471 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
8472 ELSE
8473! write(0,*) 'alpha = ',alpha(mgs,il)
8474 ! set values according to dBZ of -10
8475! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
8476 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
8477 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8478
8479 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8480 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
8481 z = zx(mgs,il)
8482 qr = qx(mgs,il)
8483 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(z*(pi*xdn(mgs,il))**2)
8484 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
8485 ENDIF
8486 ENDIF
8487 ENDIF
8488
8489 IF ( qx(mgs,il) .gt. qxmin(il) .and. cx(mgs,il) .gt. cxmin ) THEN
8490 chw = cx(mgs,il)
8491 qr = qx(mgs,il)
8492 z = zx(mgs,il)
8493
8494 IF ( zx(mgs,il) .gt. 0. ) THEN
8495
8496! rd = z*(pi/6.*1000.)**2*chw/(0.224*(dn(igs(mgs),jy,kgs(mgs))*qr)**2)
8497 rd = z*(pi/6.*xdn(mgs,il))**2*chw/((dn(igs(mgs),jy,kgs(mgs))*qr)**2)
8498
8499 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
8500 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd) - 1.0
8501 DO i = 1,10
8502 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
8503 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
8504 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
8505 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd) - 1.0
8506! write(0,*) 'i,alp = ',i,alp
8507 alp = max( alphamin, min( alphamax, alp ) )
8508 ENDDO
8509
8510
8511
8512! check for artificial breakup (graupel/hail larger than allowed max size)
8513
8514 IF ( imaxdiaopt == 1 .or. il /= lr ) THEN
8515 xvbarmax = xvmx(il)
8516 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
8517 xvbarmax = xvmx(il) /((3. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
8518 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
8519 xvbarmax = xvmx(il) /((4. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
8520 ENDIF
8521
8522 IF ( xv(mgs,il) .gt. xvbarmax ) THEN
8523 tmp = cx(mgs,il)
8524 xv(mgs,il) = min( xvbarmax, max( xvmn(il),xv(mgs,il) ) )
8525 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
8526 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
8527 IF ( tmp < cx(mgs,il) ) THEN ! breakup
8528 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8529 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
8530 ! check if incoming zx is consistent
8531 ! Z from incoming cx, qx, and alpha
8532 tmpz = g1/(pi/6.*xdn(mgs,il))**2 * ((rho0(mgs)*qx(mgs,il))**2)/tmp
8533 IF ( tmpz > zx(mgs,il) ) THEN
8534 ! find cx that gives zx
8535 tmpc = g1/(pi/6.*xdn(mgs,il))**2 * ((rho0(mgs)*qx(mgs,il))**2)/zx(mgs,il)
8536 cx(mgs,il) = max(cx(mgs,il), tmpc)
8537 ENDIF
8538 zx(mgs,il) = g1/(pi/6.*xdn(mgs,il))**2 * ((rho0(mgs)*qx(mgs,il))**2)/cx(mgs,il)
8539! zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
8540 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
8541
8542 chw = cx(mgs,il)
8543 qr = qx(mgs,il)
8544 z = zx(mgs,il)
8545
8546 rd = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
8547 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
8548 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd) - 1.0
8549 DO i = 1,10
8550 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
8551 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
8552 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
8553 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd) - 1.0
8554 alp = max( alphamin, min( alphamax, alp ) )
8555 ENDDO
8556
8557
8558 ENDIF
8559 ENDIF
8560
8561!
8562! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
8563! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
8564!
8565 IF ( (rescale_low_alpha .or. rescale_high_alpha ) .and. &
8566 & ( alpha(mgs,il) <= alphamin .or. alp == alphamin .or. alp == alphamax ) ) THEN
8567
8568 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
8569 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
8570
8571 IF ( rescale_high_alpha .and. alp >= alphamax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
8572 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(6./(pi*xdn(mgs,il)))**2
8573 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
8574
8575 ELSEIF ( rescale_low_alpha .and. alp <= alphamin .and. .not. (il == lh .and. icvhl2h > 0 ) ) THEN
8576
8577!! z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*( 0.224*qr)*qr/chw
8578 z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
8579 z = z1*(6./(pi*xdn(mgs,il)))**2
8580 zx(mgs,il) = z
8581 an(igs(mgs),jy,kgs(mgs),lz(il)) = z
8582 ENDIF
8583 ENDIF
8584 ELSE
8585 ENDIF
8586 ENDIF
8587 ENDDO ! mgs
8588
8589 ENDIF ! lz(il) .gt. 1
8590
8591 ENDDO ! il
8592
8593! CALL cld_cpu('Z-MOMENT-ZFAll')
8594
8595 ENDIF
8596
8597 IF ( lzhl > 1 ) THEN
8598 IF ( lhl .gt. 1 ) THEN
8599
8600 ENDIF
8601 ENDIF
8602
8603
8604
8605!
8606! Set density
8607!
8608 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: call setvtz'
8609!
8610
8611 call setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno,cnostmp, &
8612 & xmas,vtxbar,xdn,xvmn,xvmx,xv,cdx,cdxgs, &
8613 & ipconc,ndebugzf,ngs,nz,igs,kgs,fadvisc, &
8614 & cwmasn,cwmasx,cwradn,cnina,cimn,cimx, &
8615 & itype1,itype2,temcg,infdo,alpha,axx,bxx,ildo)
8616! & itype1,itype2,temcg,infdo,alpha,ildo,axh,bxh,axhl,bxhl)
8617
8618
8619
8620!
8621! put fall speeds into the x-z arrays
8622!
8623 DO il = l1,l2
8624 do mgs = 1,ngscnt
8625
8626 vtmax = 150.0
8627
8628
8629 IF ( vtxbar(mgs,il,2) .gt. vtxbar(mgs,il,1) .or. &
8630 & ( vtxbar(mgs,il,1) .gt. vtxbar(mgs,il,3) .and. vtxbar(mgs,il,3) > 0.0) ) THEN
8631
8632
8633! IF ( qx(mgs,il) > 1.e-4 .and. &
8634! & .not. ( il == lr .and. 1.e3*xdia(mgs,il,3) > 5.0 ) ) THEN
8635! write(0,*) 'infdo,mgs = ',infdo,lzr,mgs
8636! write(0,*) 'Moment problem with vtxbar for il at i,j,k = ',il,igs(mgs),jy,kgs(mgs)
8637! write(0,*) 'nx,ny,nz,ng = ',nx,ny,nz,nor
8638! write(0,*) 'cwmasn,cwmasx = ',cwmasn,cwmasx
8639! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,il,1),vtxbar(mgs,il,2),vtxbar(mgs,il,3)
8640! write(0,*) 'q,n,d = ', 1.e3*qx(mgs,il),cx(mgs,il),1.e3*xdia(mgs,il,3)
8641! IF ( il .ge. lr .and. lz(il) > 1 ) write(0,*) 'z = ', zx(mgs,il)
8642! IF ( il .ge. lg .or. il == lr ) THEN
8643! write(0,*) 'alpha = ',alpha(mgs,il)
8644! ENDIF
8645! ENDIF
8646
8647 vtxbar(mgs,il,1) = max( vtxbar(mgs,il,1), vtxbar(mgs,il,2) )
8648 vtxbar(mgs,il,3) = max( vtxbar(mgs,il,3), vtxbar(mgs,il,1) )
8649
8650 ENDIF
8651
8652
8653 IF ( vtxbar(mgs,il,1) .gt. vtmax .or. vtxbar(mgs,il,2) .gt. vtmax .or. &
8654 & vtxbar(mgs,il,3) .gt. vtmax ) THEN
8655
8656! IF ( ndebugzf >= 0 .and. 1.e3*qx(mgs,il) > 0.1 ) THEN
8657! write(0,*) 'infdo = ',infdo
8658! write(0,*) 'Problem with vtxbar for il at i,j,k = ',il,igs(mgs),jy,kgs(mgs)
8659! write(0,*) 'nx,ny,nz,ng = ',nx,ny,nz,nor
8660! write(0,*) 'cwmasn,cwmasx = ',cwmasn,cwmasx
8661! write(0,*) 'vt1,2,3 = ',vtxbar(mgs,il,1),vtxbar(mgs,il,2),vtxbar(mgs,il,3)
8662! write(0,*) 'q,n,d = ', 1.e3*qx(mgs,il),cx(mgs,il),1.e3*xdia(mgs,il,3)
8663! IF ( il .ge. lr .and. lz(il) > 1 ) write(0,*) 'z = ', zx(mgs,il)
8664! IF ( il .ge. lg ) THEN
8665! write(0,*) 'alpha = ',alpha(mgs,il)
8666! ENDIF
8667! ENDIF
8668 vtxbar(mgs,il,1) = min(vtmax,vtxbar(mgs,il,1) )
8669 vtxbar(mgs,il,2) = min(vtmax,vtxbar(mgs,il,2) )
8670 vtxbar(mgs,il,3) = min(vtmax,vtxbar(mgs,il,3) )
8671
8672! call commasmpi_abort()
8673 ENDIF
8674
8675
8676 xvt(kgs(mgs),igs(mgs),1,il) = vtxbar(mgs,il,1)
8677 xvt(kgs(mgs),igs(mgs),2,il) = vtxbar(mgs,il,2)
8678 IF ( infdo .ge. 2 ) THEN
8679 xvt(kgs(mgs),igs(mgs),3,il) = vtxbar(mgs,il,3)
8680 ELSE
8681 xvt(kgs(mgs),igs(mgs),3,il) = 0.0
8682 ENDIF
8683
8684! xvt(kgs(mgs),igs(mgs),2,il) = xvt(kgs(mgs),igs(mgs),1,il)
8685
8686 enddo
8687 ENDDO
8688
8689
8690 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: COPIED FALL SPEEDS'
8691
8692
8693
8694 9998 continue
8695
8696 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: DONE WITH LOOP'
8697
8698 if ( kz .gt. nz-1 ) then
8699 go to 1200
8700 else
8701 nzmpb = kz
8702 end if
8703
8704 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: SET NZMPB'
8705
8706 end do !! inumgs
8707
8708 if (ndebugzf .gt. 0 ) write(0,*) 'ZIEGFALL: SET NXMPB'
8709
8710 1200 continue
8711
8712
8713! ENDDO ! ix
8714! ENDDO ! kz
8715
8716
8717 if (ndebugzf .gt. 0 ) write(0,*) "ZIEGFALL: EXITING SUBROUTINE"
8718
8719
8720 RETURN
8721 END subroutine ziegfall1d
8722
8723! #####################################################################
8724! #####################################################################
8725
8726
8727! #####################################################################
8728! #####################################################################
8729
8730! ##############################################################################
8733 subroutine radardd02(nx,ny,nz,nor,na,an,temk, &
8734 & dbz,db,nzdbz,cnoh0t,hwdn1t,ipconc,ke_diag, iunit)
8735!
8736! 11.13.2005: Changed values of indices for reordering of lip
8737!
8738! 07.13.2005: Fixed an error where cnoh was being used for graupel and frozen drops
8739!
8740! 01.24.2005: add ice crystal reflectivity using parameterization of
8741! Heymsfield (JAS, 1977). Could also try Ferrier for this, too.
8742!
8743! 09.28.2002 Test alterations for dry ice following Ferrier (1994)
8744! for equivalent melted diameter reflectivity.
8745! Converted to Fortran by ERM.
8746!
8747!Date: Tue, 21 Nov 2000 10:13:36 -0600 (CST)
8748!From: Matthew Gilmore <gilmore@hesston.met.tamu.edu>
8749!
8750!PRO RF_SPEC ; Computes Radar Reflectivity
8751!COMMON MAINB, data, x1d, y1d, z1d, iconst, rconst, labels, nx, ny, nz, dshft
8752!
8753!;MODIFICATION HISTORY
8754!; 5/99 -Svelta Veleva introduces variable dielf (const_ki_x) as a (weak)
8755!; function of density. This leads to slight modification of dielf such
8756!; that the snow reflectivity is slightly increased - not a big effect.
8757!; This is believed to be more accurate than assuming the dielectric
8758!; constant for snow is the same as for hail in previous versions.
8759!
8760!;On 6/13/99 I added the VIL computation (k=0 in vil array)
8761!;On 6/15/99 I removed the number concentration dependencies as a function
8762!; of temperature (only use for ferrier!)
8763!;On 6/15/99 I added the Composite reflectivity (k=1 in VIL array)
8764!;On 6/15/99 I added the Severe Hail Index computation (k=2 in vil array)
8765!;
8766!; 6/99 - Veleva and Seo argue that since graupel is more similar to
8767!; snow (in number conc and size density) than it is to hail, we
8768!; should not weight wetted graupel with the .95 exponent correction
8769!; factor as in the case of hail. An if-statement checks the size
8770!; density for wet hail/graupel and treats them appropriately.
8771!;
8772!; 6/22/99 - Added function to compute height of max rf and 40 dbz echo top
8773!; Also added vilqr which is the model vertical integrated liquid only
8774!; using qr. Will need to check...does not seem consistent with vilZ
8775!;
8776
8777
8778 implicit none
8779
8780 character(LEN=15), parameter :: microp = 'ZVD'
8781 integer nx,ny,nz,nor,na,ngt
8782 integer nzdbz ! how many levels actually to process
8783
8784 integer ng1,n10
8785 integer iunit
8786 integer, parameter :: printyn = 0
8787
8788 parameter( ng1 = 1 )
8789
8790 real cnoh0t,hwdn1t
8791 integer ke_diag
8792 integer ipconc
8793 real vr
8794
8795
8796 integer imapz,mzdist
8797
8798 integer vzflag
8799 integer, parameter :: norz = 3
8800 real an(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,na)
8801 real db(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor) ! air density
8802! real gt(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor,ngt)
8803 real temk(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor) ! air temperature (kelvin)
8804 real dbz(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-nor+ng1:nz+nor) ! reflectivity
8805 real gz(-nor+1:nz+nor) ! ,z1d(-nor+1:nz+nor,4)
8806
8807! real g,rgas,eta,inveta
8808 real cr1, cr2 , hwdnsq,swdnsq
8809 real rwdnsq, dhmin, qrmin, qsmin, qhmin, qhlmin, tfr, tfrh, zrc
8810 real reflectmin, kw_sq
8811 real const_ki_sn, const_ki_h, ki_sq_sn
8812 real ki_sq_h, dielf_sn, dielf_h
8813 real pi
8814 logical ltest
8815
8816! Other data arrays
8817 real gtmp (nx,nz)
8818 real dtmp (nx,nz)
8819 real tmp
8820
8821 double precision :: dtmps, dtmpr, dtmph, dtmphl, g1, zx, ze, x
8822
8823 integer i,j,k,ix,jy,kz,ihcnt
8824
8825 double precision :: xcnoh, xcnos, dadh, dads, zhdryc, zsdryc, zhwetc,zswetc
8826 double precision :: dadr
8827 real dbzmax,dbzmin
8828 parameter( dbzmin = 0 )
8829
8830 real cnow,cnoi,cnoip,cnoir,cnor,cnos
8831 real cnogl,cnogm,cnogh,cnof,cnoh,cnohl
8832
8833 real swdn, rwdn ,hwdn,gldn,gmdn,ghdn,fwdn,hldn
8834 real swdn0
8835
8836 real rwdnmx,cwdnmx,cidnmx,xidnmx,swdnmx,gldnmx,gmdnmx
8837 real ghdnmx,fwdnmx,hwdnmx,hldnmx
8838 real rwdnmn,cwdnmn,cidnmn,xidnmn,swdnmn,gldnmn,gmdnmn
8839 real ghdnmn,fwdnmn,hwdnmn,hldnmn
8840
8841 real gldnsq,gmdnsq,ghdnsq,fwdnsq,hldnsq
8842
8843 real dadgl,dadgm,dadgh,dadhl,dadf
8844 real zgldryc,zglwetc,zgmdryc, zgmwetc,zghdryc,zghwetc
8845 real zhldryc,zhlwetc,zfdryc,zfwetc
8846
8847 real dielf_gl,dielf_gm,dielf_gh,dielf_hl,dielf_fw
8848
8849 integer imx,jmx,kmx
8850
8851 real swdia,gldia,gmdia,ghdia,fwdia,hwdia,hldia
8852
8853 real csw,cgl,cgm,cgh,cfw,chw,chl
8854 real xvs,xvgl,xvgm,xvgh,xvf,xvh,xvhl
8855
8856 real cwc0
8857 integer izieg
8858 integer ice10
8859 real rhos
8860 parameter( rhos = 0.1 )
8861
8862 real qxw,qxw1 ! temp value for liquid water on ice mixing ratio
8863 real :: dnsnow
8864 real qh
8865
8866 real, parameter :: cwmasn = 5.23e-13 ! minimum mass, defined by radius of 5.0e-6
8867 real, parameter :: cwmasx = 5.25e-10 ! maximum mass, defined by radius of 50.0e-6
8868 real, parameter :: cwradn = 5.0e-6 ! minimum radius
8869
8870 real cwnccn(nz)
8871
8872 real :: vzsnow, vzrain, vzgraupel, vzhail
8873 real :: ksq
8874 real :: dtp
8875
8876
8877! #########################################################################
8878
8879 vzflag = 0
8880
8881 izieg = 0
8882 ice10 = 0
8883! g=9.806 ! g: gravity constant
8884! rgas=287.04 ! rgas: gas constant for dry air
8885! rcp=rgas/cp ! rcp: gamma constant
8886! eta=0.622
8887! inveta = 1./eta
8888! rcpinv = 1./rcp
8889! cpr=cp/rgas
8890! cvr=cv/rgas
8891 pi = 4.0*atan(1.)
8892 cwc0 = piinv ! 1./pi ! 6.0/pi
8893
8894 cnoh = cnoh0t
8895 hwdn = hwdn1t
8896
8897 rwdn = 1000.0
8898 swdn = 100.0
8899
8900 qrmin = 1.0e-05
8901 qsmin = 1.0e-06
8902 qhmin = 1.0e-05
8903
8904!
8905! default slope intercepts
8906!
8907 cnow = 1.0e+08
8908 cnoi = 1.0e+08
8909 cnoip = 1.0e+08
8910 cnoir = 1.0e+08
8911 cnor = 8.0e+06
8912 cnos = 8.0e+06
8913 cnogl = 4.0e+05
8914 cnogm = 4.0e+05
8915 cnogh = 4.0e+05
8916 cnof = 4.0e+05
8917 cnohl = 1.0e+03
8918
8919
8920 imx = 1
8921 jmx = 1
8922 kmx = 1
8923 i = 1
8924
8925
8926 IF ( microp(1:4) .eq. 'ZIEG' ) THEN ! na .ge. 14 .and. ipconc .ge. 3 ) THEN
8927
8928! write(0,*) 'Set reflectivity for ZIEG'
8929 izieg = 1
8930
8931 hwdn = hwdn1t ! 500.
8932
8933
8934 cnor = cno(lr)
8935 cnos = cno(ls)
8936 cnoh = cno(lh)
8937 qrmin = qxmin(lr)
8938 qsmin = qxmin(ls)
8939 qhmin = qxmin(lh)
8940 IF ( lhl .gt. 1 ) THEN
8941 cnohl = cno(lhl)
8942 qhlmin = qxmin(lhl)
8943 ENDIF
8944
8945 ELSEIF ( microp(1:3) .eq. 'ZVD' ) THEN ! na .ge. 14 .and. ipconc .ge. 3 ) THEN
8946
8947 izieg = 1
8948
8949 swdn0 = swdn
8950
8951 cnor = cno(lr)
8952 cnos = cno(ls)
8953 cnoh = cno(lh)
8954
8955 qrmin = qxmin(lr)
8956 qsmin = qxmin(ls)
8957 qhmin = qxmin(lh)
8958 IF ( lhl .gt. 1 ) THEN
8959 cnohl = cno(lhl)
8960 qhlmin = qxmin(lhl)
8961 ENDIF
8962! 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)
8963
8964
8965 ENDIF
8966
8967
8968! cdx(lr) = 0.60
8969!
8970! IF ( lh > 1 ) THEN
8971! cdx(lh) = 0.8 ! 1.0 ! 0.45
8972! cdx(ls) = 2.00
8973! ENDIF
8974!
8975! IF ( lhl .gt. 1 ) cdx(lhl) = 0.45
8976!
8977! xvmn(lc) = xvcmn
8978! xvmn(lr) = xvrmn
8979!
8980! xvmx(lc) = xvcmx
8981! xvmx(lr) = xvrmx
8982!
8983! IF ( lh > 1 ) THEN
8984! xvmn(ls) = xvsmn
8985! xvmn(lh) = xvhmn
8986! xvmx(ls) = xvsmx
8987! xvmx(lh) = xvhmx
8988! ENDIF
8989!
8990! IF ( lhl .gt. 1 ) THEN
8991! xvmn(lhl) = xvhlmn
8992! xvmx(lhl) = xvhlmx
8993! ENDIF
8994!
8995! xdnmx(lr) = 1000.0
8996! xdnmx(lc) = 1000.0
8997! IF ( lh > 1 ) THEN
8998! xdnmx(li) = 917.0
8999! xdnmx(ls) = 300.0
9000! xdnmx(lh) = 900.0
9001! ENDIF
9002! IF ( lhl .gt. 1 ) xdnmx(lhl) = 900.0
9003!!
9004! xdnmn(:) = 900.0
9005!
9006! xdnmn(lr) = 1000.0
9007! xdnmn(lc) = 1000.0
9008! IF ( lh > 1 ) THEN
9009! xdnmn(li) = 100.0
9010! xdnmn(ls) = 100.0
9011! xdnmn(lh) = hdnmn
9012! ENDIF
9013! IF ( lhl .gt. 1 ) xdnmn(lhl) = 500.0
9014!
9015! xdn0(:) = 900.0
9016!
9017! xdn0(lc) = 1000.0
9018! xdn0(lr) = 1000.0
9019! IF ( lh > 1 ) THEN
9020! xdn0(li) = 900.0
9021! xdn0(ls) = 100.0 ! 100.0
9022! xdn0(lh) = hwdn1t ! (0.5)*(xdnmn(lh)+xdnmx(lh))
9023! ENDIF
9024! IF ( lhl .gt. 1 ) xdn0(lhl) = 800.0
9025
9026!
9027! slope intercepts
9028!
9029! cnow = 1.0e+08
9030! cnoi = 1.0e+08
9031! cnoip = 1.0e+08
9032! cnoir = 1.0e+08
9033! cnor = 8.0e+06
9034! cnos = 8.0e+06
9035! cnogl = 4.0e+05
9036! cnogm = 4.0e+05
9037! cnogh = 4.0e+05
9038! cnof = 4.0e+05
9039!c cnoh = 4.0e+04
9040! cnohl = 1.0e+03
9041!
9042!
9043! density maximums and minimums
9044!
9045 rwdnmx = 1000.0
9046 cwdnmx = 1000.0
9047 cidnmx = 917.0
9048 xidnmx = 917.0
9049 swdnmx = 200.0
9050 gldnmx = 400.0
9051 gmdnmx = 600.0
9052 ghdnmx = 800.0
9053 fwdnmx = 900.0
9054 hwdnmx = 900.0
9055 hldnmx = 900.0
9056!
9057 rwdnmn = 1000.0
9058 cwdnmn = 1000.0
9059 xidnmn = 001.0
9060 cidnmn = 001.0
9061 swdnmn = 001.0
9062 gldnmn = 200.0
9063 gmdnmn = 400.0
9064 ghdnmn = 600.0
9065 fwdnmn = 700.0
9066 hwdnmn = 700.0
9067 hldnmn = 900.0
9068
9069
9070 gldn = (0.5)*(gldnmn+gldnmx) ! 300.
9071 gmdn = (0.5)*(gmdnmn+gmdnmx) ! 500.
9072 ghdn = (0.5)*(ghdnmn+ghdnmx) ! 700.
9073 fwdn = (0.5)*(fwdnmn+fwdnmx) ! 800.
9074 hldn = (0.5)*(hldnmn+hldnmx) ! 900.
9075
9076
9077 cr1 = 7.2e+20
9078 cr2 = 7.295e+19
9079 hwdnsq = hwdn**2
9080 swdnsq = swdn**2
9081 rwdnsq = rwdn**2
9082
9083 gldnsq = gldn**2
9084 gmdnsq = gmdn**2
9085 ghdnsq = ghdn**2
9086 fwdnsq = fwdn**2
9087 hldnsq = hldn**2
9088
9089 dhmin = 0.005
9090 tfr = 273.16
9091 tfrh = tfr - 8.0
9092 zrc = cr1*cnor
9093 reflectmin = 0.0
9094 kw_sq = 0.93
9095 dbzmax = dbzmin
9096
9097 ihcnt=0
9098
9099
9100!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9101! Dielectric Factor - Formulas implemented by Svetla Veleva
9102! following Battan, "Radar Meteorology" - p. 40
9103! The result of these calculations is that the dielf numerator (ki_sq) without
9104! the density ratio is .2116 for hail if using 917 density and .25 for
9105! snow if using 220 density.
9106!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9107 const_ki_sn = 0.5 - (0.5-0.46)/(917.-220.)*(swdn-220.)
9108 const_ki_h = 0.5 - (0.5-0.46)/(917.-220.)*(hwdn-220.)
9109 ki_sq_sn = (swdnsq/rwdnsq) * const_ki_sn**2
9110 ki_sq_h = (hwdnsq/rwdnsq) * const_ki_h**2
9111 dielf_sn = ki_sq_sn / kw_sq
9112 dielf_h = ki_sq_h / kw_sq
9113
9114!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9115! Use the next line if you want to hardwire dielf for dry hail for both dry
9116! snow and dry hail.
9117! This would be equivalent to what Straka had originally. (i.e, .21/.93)
9118!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9119 dielf_sn = (swdnsq/rwdnsq)*.21/ kw_sq
9120 dielf_h = (hwdnsq/rwdnsq)*.21/ kw_sq
9121
9122 dielf_gl = (gldnsq/rwdnsq)*.21/ kw_sq
9123 dielf_gm = (gmdnsq/rwdnsq)*.21/ kw_sq
9124 dielf_gh = (ghdnsq/rwdnsq)*.21/ kw_sq
9125 dielf_hl = (hldnsq/rwdnsq)*.21/ kw_sq
9126 dielf_fw = (fwdnsq/rwdnsq)*.21/ kw_sq
9127
9128!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9129! Notes on dielectric factors - from Eun-Kyoung Seo
9130!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9131! constants for both snow and hail would be (x=s,h).....
9132! xwdnsq/rwdnsq *0.21/kw_sq ! Straka/Smith - the original
9133! xwdnsq/rwdnsq *0.224 ! Ferrier - for particle sizes in equiv. drop diam
9134! xwdnsq/rwdnsq *0.176/kw_sq ! =0.189 in Smith - for particle sizes in equiv
9135! ice spheres
9136! xwdnsq/rwdnsq *0.208/kw_sq ! Smith 1984 - for particle sizes in equiv melted drop diameter
9137!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9138
9139
9140! VIL algorithm constants
9141! Ztop = 10.**(56./10) !56 dbz is the max rf used by WATADS in cell vil
9142
9143
9144! Hail detection algorithm constants
9145! ZL = 40.
9146! ZU = 50.
9147! Ho = 3400. !WATADS Defaults
9148! Hm20 = 6200. !WATADS Defaults
9149
9150! DO kz = 1,Min(nzdbz,nz-1)
9151
9152 DO jy=1,1
9153
9154 DO kz = 1,ke_diag ! nz
9155
9156 DO ix=1,nx
9157 dbz(ix,jy,kz) = 0.0
9158
9159 vzsnow = 0.0
9160 vzrain = 0.0
9161 vzgraupel = 0.0
9162 vzhail = 0.0
9163
9164 dtmph = 0.0
9165 dtmps = 0.0
9166 dtmphl = 0.0
9167 dtmpr = 0.0
9168 dadr = (db(ix,jy,kz)/(pi*rwdn*cnor))**(0.25)
9169!-----------------------------------------------------------------------
9170! Compute Rain Radar Reflectivity
9171!-----------------------------------------------------------------------
9172
9173 dtmp(ix,kz) = 0.0
9174 gtmp(ix,kz) = 0.0
9175 IF ( an(ix,jy,kz,lr) .ge. qrmin ) THEN
9176 IF ( ipconc .le. 2 ) THEN
9177 gtmp(ix,kz) = dadr*an(ix,jy,kz,lr)**(0.25)
9178 dtmp(ix,kz) = zrc*gtmp(ix,kz)**7
9179 ELSEIF ( lzr .gt. 1 ) THEN
9180 dtmp(ix,kz) = 1e18*an(ix,jy,kz,lzr)
9181 ELSEIF ( an(ix,jy,kz,lnr) .gt. 1.e-3 ) THEN
9182 IF ( imurain == 3 ) THEN
9183 vr = db(ix,jy,kz)*an(ix,jy,kz,lr)/(1000.*an(ix,jy,kz,lnr))
9184 dtmp(ix,kz) = 3.6e18*(rnu+2.)*an(ix,jy,kz,lnr)*vr**2/(rnu+1.)
9185 ELSE ! imurain == 1
9186 g1 = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
9187 zx = g1*(db(ix,jy,kz)*an(ix,jy,kz,lr))**2/an(ix,jy,kz,lnr)
9188 ze =1.e18*zx*(6./(pi*1000.))**2 ! note: using 1000. here for water density
9189 dtmp(ix,kz) = ze
9190 ENDIF
9191 ENDIF
9192 dtmpr = dtmp(ix,kz)
9193 ENDIF
9194
9195!-----------------------------------------------------------------------
9196! Compute snow and graupel reflectivity
9197!
9198! Lou modified to look at parcel temperature rather than base state
9199!-----------------------------------------------------------------------
9200
9201 IF( lhab .gt. lr ) THEN
9202
9203! qs2d = reform(data[*,*,k,10],[nx*ny])
9204! qh2d = reform(data[*,*,k,11],[nx*ny])
9205
9206!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9207! Only use the following lines if running Straka GEMS microphysics
9208! (Sam 1-d version modified by L Wicker does not use this)
9209!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9210! ;xcnoh = cnoh*exp(-0.025*(temp-tfr))
9211! ;xcnos = cnos*exp(-0.038*(temp-tfr))
9212! ;good = where(temp GT tfr, n_elements)
9213! ;IF n_elements NE 0 THEN xcnoh(good) = cnoh*exp(-0.075*(temp(good)-tfr))
9214! ;IF n_elements NE 0 THEN xcnos(good) = cnos*exp(-0.088*(temp(good)-tfr))
9215
9216!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9217! Only use the following lines if running Ferrier micro with No=No(T)
9218!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9219! ; NOSE = -.15
9220! ; NOGE = .0
9221! ; xcnoh = cnoh*(1.>exp(NOGE*(temp-tfr)) )
9222! ; xcnos = cnos*(1.>exp(NOSE*(temp-tfr)) )
9223
9224!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9225! Use the following lines if Nos and Noh are constant
9226! (As in Svetla version of Ferrier, GCE Tao, and SAM 1-d)
9227!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9228 xcnoh = cnoh
9229 xcnos = cnos
9230
9231!
9232! Temporary fix for predicted number concentration -- need a
9233! more appropriate reflectivity equation!
9234!
9235! IF ( an(ix,jy,kz,lns) .lt. 0.1 ) THEN
9236! swdia = (xvrmn*cwc0)**(1./3.)
9237! xcnos = an(ix,jy,kz,ls)*db(ix,jy,kz)/(xvrmn*swdn*swdia)
9238! ELSE
9239! ! changed back to diameter of mean volume!!!
9240! swdia =
9241! > (an(ix,jy,kz,ls)*db(ix,jy,kz)
9242! > /(pi*swdn*an(ix,jy,kz,lns)))**(1./3.)
9243!
9244! xcnos = an(ix,jy,kz,lns)/swdia
9245! ENDIF
9246
9247 IF ( ls .gt. 1 ) THEN ! {
9248
9249 IF ( lvs .gt. 1 ) THEN
9250 IF ( an(ix,jy,kz,lvs) .gt. 0.0 ) THEN
9251 swdn = db(ix,jy,kz)*an(ix,jy,kz,ls)/an(ix,jy,kz,lvs)
9252 swdn = min( 300., max( 100., swdn ) )
9253 ELSE
9254 swdn = swdn0
9255 ENDIF
9256
9257 ENDIF
9258
9259 IF ( ipconc .ge. 5 ) THEN ! {
9260
9261 xvs = db(ix,jy,kz)*an(ix,jy,kz,ls)/ &
9262 & (swdn*max(1.0e-3,an(ix,jy,kz,lns)))
9263 IF ( xvs .lt. xvsmn .or. xvs .gt. xvsmx ) THEN
9264 xvs = min( xvsmx, max( xvsmn,xvs ) )
9265 csw = db(ix,jy,kz)*an(ix,jy,kz,ls)/(xvs*swdn)
9266 ENDIF
9267
9268 swdia = (xvs*cwc0)**(1./3.)
9269 xcnos = an(ix,jy,kz,ls)*db(ix,jy,kz)/(xvs*swdn*swdia)
9270
9271 ENDIF ! }
9272 ENDIF ! }
9273
9274! IF ( an(ix,jy,kz,lnh) .lt. 0.1 ) THEN
9275! hwdia = (xvrmn*cwc0)**(1./3.)
9276! xcnoh = an(ix,jy,kz,lh)*db(ix,jy,kz)/(xvrmn*hwdn*hwdia)
9277! ELSE
9278! ! changed back to diameter of mean volume!!!
9279! hwdia =
9280! > (an(ix,jy,kz,lh)*db(ix,jy,kz)
9281! > /(pi*hwdn*an(ix,jy,kz,lnh)))**(1./3.)
9282!
9283! xcnoh = an(ix,jy,kz,lnh)/hwdia
9284! ENDIF
9285
9286 IF ( lh .gt. 1 ) THEN ! {
9287
9288 IF ( lvh .gt. 1 ) THEN
9289 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
9290 hwdn = db(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
9291 hwdn = min( 900., max( hdnmn, hwdn ) )
9292 ELSE
9293 hwdn = 500. ! hwdn1t
9294 ENDIF
9295 ELSE
9296 hwdn = hwdn1t
9297 ENDIF
9298
9299 IF ( ipconc .ge. 5 ) THEN ! {
9300
9301 xvh = db(ix,jy,kz)*an(ix,jy,kz,lh)/ &
9302 & (hwdn*max(1.0e-3,an(ix,jy,kz,lnh)))
9303 IF ( xvh .lt. xvhmn .or. xvh .gt. xvhmx ) THEN
9304 xvh = min( xvhmx, max( xvhmn,xvh ) )
9305 chw = db(ix,jy,kz)*an(ix,jy,kz,lh)/(xvh*hwdn)
9306 ENDIF
9307
9308 hwdia = (xvh*cwc0)**(1./3.)
9309 xcnoh = an(ix,jy,kz,lh)*db(ix,jy,kz)/(xvh*hwdn*hwdia)
9310
9311 ENDIF ! } ipconc .ge. 5
9312
9313 ENDIF ! }
9314
9315 dadh = 0.0
9316 dadhl = 0.0
9317 dads = 0.0
9318 IF ( xcnoh .gt. 0.0 ) THEN
9319 dadh = ( db(ix,jy,kz) /(pi*hwdn*xcnoh) )**(.25)
9320 zhdryc = 0.224*cr2*(db(ix,jy,kz)/rwdn)**2/xcnoh ! dielf_h*cr1*xcnoh ! SV - equiv formula as before but
9321 ! ratio of densities included in
9322 ! dielf_h rather than here following
9323 ! Battan.
9324 ELSE
9325 dadh = 0.0
9326 zhdryc = 0.0
9327 ENDIF
9328
9329 IF ( xcnos .gt. 0.0 ) THEN
9330 dads = ( db(ix,jy,kz) /(pi*swdn*xcnos) )**(.25)
9331 zsdryc = 0.224*cr2*(db(ix,jy,kz)/rwdn)**2/xcnos ! dielf_sn*cr1*xcnos ! SV - similar change as above
9332 ELSE
9333 dads = 0.0
9334 zsdryc = 0.0
9335 ENDIF
9336 zhwetc = zhdryc ! cr1*xcnoh !Hail/graupel version with .95 power bug removed
9337 zswetc = zsdryc ! cr1*xcnos
9338!
9339! snow contribution
9340!
9341 IF ( ls .gt. 1 ) THEN
9342
9343 gtmp(ix,kz) = 0.0
9344 qxw = 0.0
9345 qxw1 = 0.0
9346 dtmps = 0.0
9347 IF ( an(ix,jy,kz,ls) .ge. qsmin ) THEN !{
9348 IF ( ipconc .ge. 4 ) THEN ! (Ferrier 94) !{
9349
9350 if (lsw .gt. 1) THEN
9351 qxw = an(ix,jy,kz,lsw)
9352 qxw1 = 0.0
9353 ELSEIF ( ( iusewetsnow == 1 .or. iusewetsnow == 3) .and. temk(ix,jy,kz) .gt. tfr+1. &
9354 & .and. an(ix,jy,kz,ls) > an(ix,jy,kz,lr) .and. an(ix,jy,kz,lr) > qsmin) THEN
9355 qxw = min(0.5*an(ix,jy,kz,ls), an(ix,jy,kz,lr))
9356 qxw1 = qxw
9357 ENDIF
9358
9359 vr = xvs ! db(ix,jy,kz)*an(ix,jy,kz,lr)/(1000.*an(ix,jy,kz,lnr))
9360! gtmp(ix,kz) = 3.6e18*(0.243*rhos**2/0.93)*(snu+2.)*an(ix,jy,kz,lns)*vr**2/(snu+1.)
9361
9362 ksq = 0.189 ! Smith (1984, JAMC) for equiv. ice sphere
9363 IF ( an(ix,jy,kz,lns) .gt. 1.e-7 ) THEN
9364 ! IF ( .true. ) THEN
9365 IF ( qxw > qsmin .or. iusewetsnow >= 2 ) THEN ! old version
9366! gtmp(ix,kz) = 3.6e18*(snu+2.)*( 0.224*an(ix,jy,kz,ls) + 0.776*qxw)*an(ix,jy,kz,ls)/ &
9367! & (an(ix,jy,kz,lns)*(snu+1.)*rwdn**2)*db(ix,jy,kz)**2
9368 gtmp(ix,kz) = 3.6e18*(snu+2.)*( 0.224*(an(ix,jy,kz,ls)+qxw1) + 0.776*qxw)*(an(ix,jy,kz,ls)+qxw1)/ &
9369 & (an(ix,jy,kz,lns)*(snu+1.)*rwdn**2)*db(ix,jy,kz)**2
9370
9371 ELSE ! new form using a mass relationship m = p d^2 (instead of d^3 -- Cox 1988 QJRMS) so that density depends on size
9372 ! p = 0.106214 for m = p v^(2/3)
9373 dnsnow = 0.0346159*sqrt(an(ix,jy,kz,lns)/(an(ix,jy,kz,ls)*db(ix,jy,kz)) )
9374 IF ( .true. .or. dnsnow < 900. ) THEN
9375 gtmp(ix,kz) = 1.e18*323.3226* 0.106214**2*(ksq*an(ix,jy,kz,ls) + &
9376 & (1.-ksq)*qxw)*an(ix,jy,kz,ls)*db(ix,jy,kz)**2*gsnow73/ &
9377 & (an(ix,jy,kz,lns)*(917.)**2* gsnow1*(1.0+snu)**(4./3.))
9378 ELSE ! otherwise small enough to assume ice spheres?
9379 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)/ &
9380 & (an(ix,jy,kz,lns)*(snu+1.)*rwdn**2)*db(ix,jy,kz)**2
9381 ENDIF
9382
9383 ENDIF
9384
9385 ENDIF
9386
9387! tmp = Min(1.0,1.e3*(an(ix,jy,kz,ls))*db(ix,jy,kz))
9388! gtmp(ix,kz) = Max( 1.0*gtmp(ix,kz), 750.0*(tmp)**1.98)
9389 dtmps = gtmp(ix,kz)
9390 dtmp(ix,kz) = dtmp(ix,kz) + gtmp(ix,kz)
9391 ELSE ! }{ single-moment snow:
9392 gtmp(ix,kz) = dads*an(ix,jy,kz,ls)**(0.25)
9393
9394 IF ( gtmp(ix,kz) .gt. 0.0 ) THEN !{
9395 dtmps = zsdryc*an(ix,jy,kz,ls)**2/gtmp(ix,kz)
9396 IF ( temk(ix,jy,kz) .lt. tfr ) THEN
9397 dtmp(ix,kz) = dtmp(ix,kz) + &
9398 & zsdryc*an(ix,jy,kz,ls)**2/gtmp(ix,kz)
9399 ELSE
9400 dtmp(ix,kz) = dtmp(ix,kz) + &
9401 & zswetc*an(ix,jy,kz,ls)**2/gtmp(ix,kz)
9402 ENDIF
9403 ENDIF !}
9404 ENDIF !}
9405
9406 ENDIF !}
9407
9408 ENDIF
9409
9410
9411!
9412! ice crystal contribution (Heymsfield, 1977, JAS)
9413!
9414 IF ( li .gt. 1 .and. idbzci .ne. 0 ) THEN
9415
9416 IF ( idbzci == 1 .and. lni > 0 ) THEN
9417 ! assume spherical ice with density of 900 for dbz calc
9418 IF ( an(ix,jy,kz,li) > qxmin(li) .and. an(ix,jy,kz,lni) > 1.0 ) THEN
9419 vr = db(ix,jy,kz)*an(ix,jy,kz,li)/(900.*an(ix,jy,kz,lni))
9420 dtmp(ix,kz) = dtmp(ix,kz) + &
9421 & 0.224*3.6e18*(cinu+2.)*an(ix,jy,kz,lni)*vr**2/(cinu+1.)*(900./1000.)**2
9422 ENDIF
9423
9424 ELSEIF ( idbzci == 2 ) THEN
9425!
9426! ice crystal contribution (Heymsfield, 1977, JAS)
9427!
9428 gtmp(ix,kz) = 0.0
9429 IF ( an(ix,jy,kz,li) .ge. 0.1e-3 ) THEN
9430 gtmp(ix,kz) = min(1.0,1.e3*(an(ix,jy,kz,li))*db(ix,jy,kz))
9431 dtmp(ix,kz) = dtmp(ix,kz) + 750.0*(gtmp(ix,kz))**1.98
9432 ENDIF
9433
9434 ENDIF
9435
9436 ENDIF
9437
9438!
9439! graupel/hail contribution
9440!
9441 IF ( lh .gt. 1 ) THEN ! {
9442 gtmp(ix,kz) = 0.0
9443 dtmph = 0.0
9444 qxw = 0.0
9445
9446 IF ( izieg .ge. 1 .and. ipconc .ge. 5 ) THEN
9447
9448 ltest = .false.
9449 IF ( lzh > 1 ) THEN
9450 IF ( an(ix,jy,kz,lzh) > 0.0 .and. an(ix,jy,kz,lh) > qhmin .and. &
9451 an(ix,jy,kz,lnh) >= cxmin ) ltest = .true.
9452 ENDIF
9453
9454 IF ( ltest .or. (an(ix,jy,kz,lh) .ge. qhmin .and. an(ix,jy,kz,lnh) .ge. cxmin )) THEN
9455
9456 IF ( lvh .gt. 1 ) THEN
9457
9458 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
9459 hwdn = db(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
9460 hwdn = min( 900., max( 100., hwdn ) )
9461 ELSE
9462 hwdn = 500. ! hwdn1t
9463 ENDIF
9464
9465 ENDIF
9466
9467 chw = an(ix,jy,kz,lnh)
9468 IF ( chw .gt. 0.0 ) THEN ! (Ferrier 94)
9469 xvh = db(ix,jy,kz)*an(ix,jy,kz,lh)/(hwdn*max(1.0e-3,chw))
9470 IF ( xvh .lt. xvhmn .or. xvh .gt. xvhmx ) THEN
9471 xvh = min( xvhmx, max( xvhmn,xvh ) )
9472 chw = db(ix,jy,kz)*an(ix,jy,kz,lh)/(xvh*hwdn)
9473 ENDIF
9474
9475 qh = an(ix,jy,kz,lh)
9476
9477 IF ( lhw .gt. 1 ) THEN
9478 IF ( iusewetgraupel .eq. 1 ) THEN
9479 qxw = an(ix,jy,kz,lhw)
9480 ELSEIF ( iusewetgraupel .eq. 2 ) THEN
9481 IF ( hwdn .lt. 300. ) THEN
9482 qxw = an(ix,jy,kz,lhw)
9483 ENDIF
9484 ENDIF
9485 ELSEIF ( iusewetgraupel .eq. 3 ) THEN
9486 IF ( hwdn .lt. 300. .and. temk(ix,jy,kz) > tfr .and. an(ix,jy,kz,lr) > qhmin ) THEN
9487 qxw = min( an(ix,jy,kz,lh), an(ix,jy,kz,lr))
9488 qh = qh + qxw
9489 ENDIF
9490 ELSEIF ( iusewetgraupel == 4 .and. temk(ix,jy,kz) .gt. tfr+0.25 .and. an(ix,jy,kz,lh) > an(ix,jy,kz,lr) &
9491 & .and. an(ix,jy,kz,lr) > qhmin) THEN
9492 qxw = min(0.5*an(ix,jy,kz,lh), an(ix,jy,kz,lr))
9493 qh = qh + qxw
9494
9495 ENDIF
9496
9497 IF ( lzh .gt. 1 ) THEN
9498 x = (0.224*qh + 0.776*qxw)/an(ix,jy,kz,lh) ! weighted average of dielectric const
9499 dtmph = 1.e18*x*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
9500 dtmp(ix,kz) = dtmp(ix,kz) + dtmph
9501 ELSE
9502 g1 = (6.0 + alphah)*(5.0 + alphah)*(4.0 + alphah)/((3.0 + alphah)*(2.0 + alphah)*(1.0 + alphah))
9503! zx = g1*(db(ix,jy,kz)*an(ix,jy,kz,lh))**2/chw
9504! ze = 0.224*1.e18*zx*(6./(pi*1000.))**2
9505 zx = g1*db(ix,jy,kz)**2*( 0.224*qh + 0.776*qxw)*qh/chw
9506 ze =1.e18*zx*(6./(pi*1000.))**2
9507 dtmp(ix,kz) = dtmp(ix,kz) + ze
9508 dtmph = ze
9509 ENDIF
9510
9511 ENDIF
9512
9513 ! IF ( an(ix,jy,kz,lh) .gt. 1.0e-3 ) write(0,*) 'Graupel Z : ',dtmph,ze
9514 ENDIF
9515
9516 ELSE
9517
9518 dtmph = 0.0
9519
9520 IF ( an(ix,jy,kz,lh) .ge. qhmin ) THEN
9521 gtmp(ix,kz) = dadh*an(ix,jy,kz,lh)**(0.25)
9522 IF ( gtmp(ix,kz) .gt. 0.0 ) THEN
9523 dtmph = zhdryc*an(ix,jy,kz,lh)**2/gtmp(ix,kz)
9524 IF ( temk(ix,jy,kz) .lt. tfr ) THEN
9525 dtmp(ix,kz) = dtmp(ix,kz) + &
9526 & zhdryc*an(ix,jy,kz,lh)**2/gtmp(ix,kz)
9527 ELSE
9528! IF ( hwdn .gt. 700.0 ) THEN
9529 dtmp(ix,kz) = dtmp(ix,kz) + &
9530 & zhdryc*an(ix,jy,kz,lh)**2/gtmp(ix,kz)
9531!
9532! & (zhwetc*gtmp(ix,kz)**7)**0.95
9533! ELSE
9534! dtmp(ix,kz) = dtmp(ix,kz) + zhwetc*gtmp(ix,kz)**7
9535! ENDIF
9536 ENDIF
9537 ENDIF
9538 ENDIF
9539
9540
9541
9542 ENDIF
9543
9544
9545 ENDIF ! }
9546
9547 ENDIF ! na .gt. 5
9548
9549
9550 IF ( izieg .ge. 1 .and. lhl .gt. 1 ) THEN
9551
9552 hldn = 900.0
9553 gtmp(ix,kz) = 0.0
9554 dtmphl = 0.0
9555 qxw = 0.0
9556
9557
9558 IF ( lvhl .gt. 1 ) THEN
9559 IF ( an(ix,jy,kz,lvhl) .gt. 0.0 ) THEN
9560 hldn = db(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
9561 hldn = min( 900., max( 300., hldn ) )
9562 ELSE
9563 hldn = 900.
9564 ENDIF
9565 ELSE
9566 hldn = rho_qhl
9567 ENDIF
9568
9569
9570 IF ( ipconc .ge. 5 ) THEN
9571
9572 ltest = .false.
9573 IF ( lzhl > 1 ) THEN
9574 IF ( an(ix,jy,kz,lzhl) > 0.0 .and. an(ix,jy,kz,lhl) > qhlmin .and. &
9575 an(ix,jy,kz,lnhl) > 0.0 ) ltest = .true.
9576 ENDIF
9577
9578 IF ( ltest .or. ( an(ix,jy,kz,lhl) .ge. qhlmin .and. an(ix,jy,kz,lnhl) .gt. 0.) ) THEN !{
9579 chl = an(ix,jy,kz,lnhl)
9580 IF ( chl .gt. 0.0 ) THEN !{
9581 xvhl = db(ix,jy,kz)*an(ix,jy,kz,lhl)/ &
9582 & (hldn*max(1.0e-9,an(ix,jy,kz,lnhl)))
9583 IF ( xvhl .lt. xvhlmn .or. xvhl .gt. xvhlmx ) THEN ! {
9584 xvhl = min( xvhlmx, max( xvhlmn,xvhl ) )
9585 chl = db(ix,jy,kz)*an(ix,jy,kz,lhl)/(xvhl*hldn)
9586 ! do not update state in dbz calc. ! an(ix,jy,kz,lnhl) = chl
9587 ENDIF ! }
9588
9589 IF ( lhlw .gt. 1 ) THEN
9590 IF ( iusewethail .eq. 1 ) THEN
9591 qxw = an(ix,jy,kz,lhlw)
9592 ELSEIF ( iusewethail .eq. 2 ) THEN
9593 IF ( hldn .lt. 300. ) THEN
9594 qxw = an(ix,jy,kz,lhlw)
9595 ENDIF
9596 ENDIF
9597 ENDIF
9598
9599 IF ( lzhl .gt. 1 ) THEN !{
9600 x = (0.224*an(ix,jy,kz,lhl) + 0.776*qxw)/an(ix,jy,kz,lhl) ! weighted average of dielectric const
9601 dtmphl = 1.e18*x*an(ix,jy,kz,lzhl)*(hldn/rwdn)**2
9602 dtmp(ix,kz) = dtmp(ix,kz) + dtmphl
9603 ELSE !}
9604
9605 g1 = (6.0 + alphahl)*(5.0 + alphahl)*(4.0 + alphahl)/((3.0 + alphahl)*(2.0 + alphahl)*(1.0 + alphahl))
9606 zx = g1*db(ix,jy,kz)**2*( 0.224*an(ix,jy,kz,lhl) + 0.776*qxw)*an(ix,jy,kz,lhl)/chl
9607! zx = g1*(db(ix,jy,kz)*an(ix,jy,kz,lhl))**2/chl
9608 ze = 1.e18*zx*(6./(pi*1000.))**2 ! 3/28/2016 removed extra factor of 0.224
9609 dtmp(ix,kz) = dtmp(ix,kz) + ze
9610 dtmphl = ze
9611
9612 ENDIF !}
9613 endif!}
9614 ! IF ( an(ix,jy,kz,lh) .gt. 1.0e-3 ) write(0,*) 'Graupel Z : ',dtmph,ze
9615 ENDIF
9616
9617
9618 ELSE
9619
9620
9621 IF ( an(ix,jy,kz,lhl) .ge. qhlmin ) THEN ! {
9622 dadhl = ( db(ix,jy,kz) /(pi*hldn*cnohl) )**(.25)
9623 gtmp(ix,kz) = dadhl*an(ix,jy,kz,lhl)**(0.25)
9624 IF ( gtmp(ix,kz) .gt. 0.0 ) THEN ! {
9625
9626 zhldryc = 0.224*cr2*( db(ix,jy,kz)/rwdn)**2/cnohl
9627
9628 dtmphl = zhldryc*an(ix,jy,kz,lhl)**2/gtmp(ix,kz)
9629
9630 IF ( temk(ix,jy,kz) .lt. tfr ) THEN
9631 dtmp(ix,kz) = dtmp(ix,kz) + &
9632 & zhldryc*an(ix,jy,kz,lhl)**2/gtmp(ix,kz)
9633 ELSE
9634! IF ( hwdn .gt. 700.0 ) THEN
9635 dtmp(ix,kz) = dtmp(ix,kz) + &
9636 & zhldryc*an(ix,jy,kz,lhl)**2/gtmp(ix,kz)
9637!
9638! : (zhwetc*gtmp(ix,kz)**7)**0.95
9639! ELSE
9640! dtmp(ix,kz) = dtmp(ix,kz) + zhwetc*gtmp(ix,kz)**7
9641! ENDIF
9642 ENDIF
9643 ENDIF ! }
9644
9645 ENDIF ! }
9646
9647 ENDIF ! ipconc .ge. 5
9648
9649
9650 ENDIF ! izieg .ge. 1 .and. lhl .gt. 1
9651
9652
9653
9654 IF ( dtmp(ix,kz) .gt. 0.0 ) THEN
9655 dbz(ix,jy,kz) = max(dbzmin, 10.0*log10(dtmp(ix,kz)) )
9656
9657 IF ( dbz(ix,jy,kz) .gt. dbzmax ) THEN
9658 dbzmax = max(dbzmax,dbz(ix,jy,kz))
9659 imx = ix
9660 jmx = jy
9661 kmx = kz
9662 ENDIF
9663 ELSE
9664 dbz(ix,jy,kz) = dbzmin
9665 IF ( lh > 1 .and. lhl > 1) THEN
9666 IF ( an(ix,jy,kz,lh) > 1.0e-3 ) THEN
9667 write(0,*) 'radardbz: qr,qh,qhl = ',an(ix,jy,kz,lr), an(ix,jy,kz,lh),an(ix,jy,kz,lhl)
9668 write(0,*) 'radardbz: dtmps,dtmph,dadh,dadhl,dtmphl = ',dtmps,dtmph,dadh,dadhl,dtmphl
9669
9670 IF ( lzh>1 .and. lzhl>1 ) write(0,*) 'radardbz: zh, zhl = ',an(ix,jy,kz,lzh),an(ix,jy,kz,lzhl)
9671 ENDIF
9672 ENDIF
9673 ENDIF
9674
9675! IF ( an(ix,jy,kz,lh) .gt. 1.e-4 .and.
9676! & dbz(ix,jy,kz) .le. 0.0 ) THEN
9677! write(0,*) 'dbz = ',dbz(ix,jy,kz)
9678! write(0,*) 'Hail intercept: ',xcnoh,ix,kz
9679! write(0,*) 'Hail,snow q: ',an(ix,jy,kz,lh),an(ix,jy,kz,ls)
9680! write(0,*) 'Hail,snow c: ',an(ix,jy,kz,lnh),an(ix,jy,kz,lns)
9681! write(0,*) 'dtmps,dtmph = ',dtmps,dtmph
9682! ENDIF
9683 IF ( .not. dtmp(ix,kz) .lt. 1.e30 .or. dbz(ix,jy,kz) > 190.0 ) THEN
9684! IF ( ix == 31 .and. kz == 20 .and. jy == 23 ) THEN
9685! write(0,*) 'my_rank = ',my_rank
9686 write(0,*) 'ix,jy,kz = ',ix,jy,kz
9687 write(0,*) 'dbz = ',dbz(ix,jy,kz)
9688 write(0,*) 'db, zhdryc = ',db(ix,jy,kz),zhdryc
9689 write(0,*) 'Hail intercept: ',xcnoh,ix,kz
9690 write(0,*) 'Hail,snow q: ',an(ix,jy,kz,lh),an(ix,jy,kz,ls)
9691 write(0,*) 'graupel density hwdn = ',hwdn
9692 write(0,*) 'rain q: ',an(ix,jy,kz,lr)
9693 write(0,*) 'ice q: ',an(ix,jy,kz,li)
9694 IF ( lhl .gt. 1 ) write(0,*) 'Hail (lhl): ',an(ix,jy,kz,lhl)
9695 IF (ipconc .ge. 3 ) write(0,*) 'rain c: ',an(ix,jy,kz,lnr)
9696 IF ( lzr > 1 ) write(0,*) 'rain Z: ',an(ix,jy,kz,lzr)
9697 IF ( ipconc .ge. 5 ) THEN
9698 write(0,*) 'Hail,snow c: ',an(ix,jy,kz,lnh),an(ix,jy,kz,lns)
9699 IF ( lhl .gt. 1 ) write(0,*) 'Hail (lnhl): ',an(ix,jy,kz,lnhl)
9700 IF ( lzhl .gt. 1 ) THEN
9701 write(0,*) 'Hail (lzhl): ',an(ix,jy,kz,lzhl)
9702 write(0,*) 'chl,xvhl,dhl = ',chl,xvhl,(xvhl*6./3.14159)**(1./3.)
9703 write(0,*) 'xvhlmn,xvhlmx = ',xvhlmn,xvhlmx
9704 ENDIF
9705 ENDIF
9706 write(0,*) 'chw,xvh = ', chw,xvh
9707 write(0,*) 'dtmps,dtmph,dadh,dadhl,dtmphl = ',dtmps,dtmph,dadh,dadhl,dtmphl
9708 write(0,*) 'dtmpr = ',dtmpr
9709 write(0,*) 'gtmp = ',gtmp(ix,kz),dtmp(ix,kz)
9710 IF ( .not. (dbz(ix,jy,kz) .gt. -100 .and. dbz(ix,jy,kz) .lt. 200 ) ) THEN
9711 write(0,*) 'dbz out of bounds!'
9712 ENDIF
9713 ENDIF
9714
9715
9716 ENDDO ! ix
9717 ENDDO ! kz
9718 ENDDO ! jy
9719
9720
9721
9722
9723! write(0,*) 'na,lr = ',na,lr
9724 IF ( printyn .eq. 1 ) THEN
9725! IF ( dbzmax .gt. dbzmin ) THEN
9726 write(iunit,*) 'maxdbz,ijk = ',dbzmax,imx,jmx,kmx
9727 write(iunit,*) 'qrw = ',an(imx,jmx,kmx,lr)
9728
9729 IF ( lh .gt. 1 ) THEN
9730 write(iunit,*) 'qi = ',an(imx,jmx,kmx,li)
9731 write(iunit,*) 'qsw = ',an(imx,jmx,kmx,ls)
9732 write(iunit,*) 'qhw = ',an(imx,jmx,kmx,lh)
9733 IF ( lhl .gt. 1 ) write(iunit,*) 'qhl = ',an(imx,jmx,kmx,lhl)
9734 ENDIF
9735
9736
9737 ENDIF
9738
9739
9740 RETURN
9741 END subroutine radardd02
9742
9743
9744! ##############################################################################
9745! ##############################################################################
9746
9747
9750! #####################################################################
9751! #####################################################################
9752!
9753! Subroutine for explicit cloud condensation and droplet nucleation
9754!
9755! 11/30/2022: Fixed droplet evaporation heating term for CM1 eqtset=2 (was only doing eqtset=1)
9756!
9757 SUBROUTINE nucond &
9758 & (nx,ny,nz,na,jyslab &
9759 & ,nor,norz,dtp,nxi &
9760 & ,dz3d &
9761 & ,t0,t9 &
9762 & ,an,dn,p2 &
9763 & ,pn,w &
9764 & ,ngs &
9765 & ,axtra,io_flag &
9766 & ,ssfilt,t00,t77,flag_qndrop &
9767 & )
9768
9769
9770 implicit none
9771
9772! real :: cwmasn = 1000.*0.523599*(2.*2.e-6)**3
9773 integer :: nx,ny,nz,na,nxi
9774 integer :: nor,norz, jyslab ! ,nht,ngt,igsr
9775 real :: dtp ! time step
9776 logical :: flag_qndrop
9777
9778 integer, parameter :: ng1 = 1
9779
9780
9781!
9782! external temporary arrays
9783!
9784 real t00(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9785 real t77(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9786
9787 real t0(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9788! real t1(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9789! real t2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9790! real t3(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9791! real t4(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9792! real t5(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9793! real t6(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9794! real t7(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9795! real t8(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9796 real t9(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9797
9798
9799 real p2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz) ! perturbation Pi
9800 real pn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9801 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
9802 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9803
9804 real w(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9805! real qv(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9806
9807 real ssfilt(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9808
9809
9810 real pb(-norz+ng1:nz+norz)
9811 real pinit(-norz+ng1:nz+norz)
9812
9813 real dz3d(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
9814
9815
9816 ! local
9817
9818
9819 real axtra(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz,nxtra)
9820 logical :: io_flag
9821
9822 real :: dv
9823 real :: ccnefactwo, sstmp, cn1, cnuctmp
9824
9825!
9826! declarations microphysics and for gather/scatter
9827!
9828 real, parameter :: cwmas30 = 1000.*0.523599*(2.*30.e-6)**3 ! mass of 30-micron radius droplet, for sat. adj.
9829 real, parameter :: cwmas20 = 1000.*0.523599*(2.*20.e-6)**3 ! mass of 20-micron radius droplet, for sat. adj.
9830 integer nxmpb,nzmpb,nxz
9831 integer mgs,ngs,numgs,inumgs
9832 integer ngscnt,igs(ngs),kgs(ngs)
9833 integer kgsp(ngs),kgsm(ngs)
9834 integer nsvcnt
9835
9836 integer ix,kz,i,n, kp1, km1
9837 integer :: jy, jgs
9838 integer ixb,ixe,jyb,jye,kzb,kze
9839
9840 integer itile,jtile,ktile
9841 integer ixend,jyend,kzend,kzbeg
9842 integer nxend,nyend,nzend,nzbeg
9843
9844!
9845! Variables for Ziegler warm rain microphysics
9846!
9847
9848
9849 real ccnc(ngs), ccna(ngs), cnuc(ngs), cwnccn(ngs), ccnaco(ngs), ccnanu(ngs)
9850 real :: ccnc_nu(ngs), ccnc_ac(ngs), ccnc_co(ngs)
9851 real ccncuf(ngs)
9852 real sscb ! 'cloud base' SS threshold
9853 parameter( sscb = 2.0 )
9854 integer idecss ! flag to turn on (=1) decay of ssmax when no cloud or ice crystals
9855 parameter( idecss = 1 )
9856 integer iba ! flag to do condensation/nucleation in 1st or 2nd loop
9857 ! =0 to use ad to calculate SS
9858 ! =1 to use an at end of main jy loop to calculate SS
9859 parameter(iba = 1)
9860 integer ifilt ! =1 to filter ssat, =0 to set ssfilt=ssat
9861 parameter( ifilt = 0 )
9862 real temp1,temp2 ! ,ssold
9863 real :: ssmax(ngs) ! maximum SS experienced by a parcel
9864 real ssmx
9865 real dnnet,dqnet
9866! real cnu,rnu,snu,cinu
9867! parameter ( cnu = 0.0, rnu = -0.8, snu = -0.8, cinu = 0.0 )
9868 real ventrx(ngs)
9869 real ventrxn(ngs)
9870 real volb, t2s
9871 real, parameter :: aa1 = 9.44e15, aa2 = 5.78e3 ! a1 in Ziegler
9872
9873 real rhoinv(ngs)
9874
9875 real chw, g1, rd1
9876
9877 real ac1,bc, taus, c1,d1,e1,f1,p380,tmp,tmp2 ! , sstdy, super
9878 real tmpmx, fw, qctmp
9879 real x,y,del,r,alpr
9880 double precision :: vent1,vent2
9881 real g1palp
9882 real bs
9883 real v1, v2
9884 real d1r, d1i, d1s, e1i
9885 integer nc ! condensation step
9886 real dtcon,dtcon1,dtcon2 ! condensation time step (dtcon*nc = dtp)
9887 real delta
9888 integer ltemq1,ltemq1m ! ,ltemq1m2
9889 real dqv,qv1,ss1,ss2,qvs1,dqvs,dtemp,dt1 ! temporaries for condensation
9890
9891 real ssi1, ssi2, dqvi, dqvis, dqvii,qis1
9892 real dqvr, dqc, dqr, dqi, dqs
9893 real qv1m,qvs1m,ss1m,ssi1m,qis1m
9894 real cwmastmp
9895 real dcloud,dcloud2 ! ,as, bs
9896 real dcrit
9897 real cn(ngs), cnuf(ngs)
9898 real :: ccwmax
9899
9900
9901 integer ltemq
9902
9903 integer il
9904
9905 real es(ngs) ! ss(ngs),
9906! real eis(ngs)
9907 real ssf(ngs),ssfkp1(ngs),ssfkm1(ngs),ssat0(ngs)
9908 real, parameter :: ssfcut = 4.0
9909 real ssfjp1(ngs),ssfjm1(ngs)
9910 real ssfip1(ngs),ssfim1(ngs)
9911
9912 real supcb, supmx
9913 parameter(supcb=0.5,supmx=238.0)
9914 real r2dxm, r2dym, r2dzm
9915 real dssdz, dssdy, dssdx
9916! real tqvcon
9917 real epsi,d
9918 parameter(epsi = 0.622, d = 0.266)
9919 real r1,qevap ! ,slv
9920
9921 real vr,nrx,qr,z1,z2,rdi,alp,xnutmp,xnuc
9922 real ctmp, ccwtmp
9923 real f5, qvs0 ! Kessler condensation factor
9924 real :: t0p1, t0p3
9925 real qvex
9926
9927! real, dimension(ngs) :: temp, tempc, elv, elf, els, pqs, theta, temg, temcg
9928 real dqvcnd(ngs),dqwv(ngs),dqcw(ngs),dqci(ngs)
9929 real temp(ngs),tempc(ngs)
9930 real temg(ngs),temcg(ngs),theta(ngs),qvap(ngs) ! ,tembzg(ngs)
9931 real temgx(ngs),temcgx(ngs)
9932 real qvs(ngs),qis(ngs),qss(ngs),pqs(ngs)
9933 real felv(ngs),felf(ngs),fels(ngs)
9934 real felvcp(ngs),felvpi(ngs)
9935 real gamw(ngs),gams(ngs) ! qciavl(ngs),
9936 real tsqr(ngs),ssi(ngs),ssw(ngs)
9937 real cc3(ngs),cqv1(ngs),cqv2(ngs)
9938 real qcwtmp(ngs),qtmp
9939
9940 real fvent(ngs) !,fraci(ngs),fracl(ngs)
9941 real fwvdf(ngs),ftka(ngs),fthdf(ngs)
9942 real fadvisc(ngs),fakvisc(ngs)
9943 real fci(ngs),fcw(ngs)
9944 real fschm(ngs),fpndl(ngs)
9945
9946 real pres(ngs),pipert(ngs)
9947 real pk(ngs)
9948 real rho0(ngs),pi0(ngs)
9949 real rhovt(ngs)
9950 real thetap(ngs),theta0(ngs),qwvp(ngs),qv0(ngs)
9951 real thsave(ngs)
9952 real qss0(ngs)
9953 real fcqv1(ngs)
9954 real wvel(ngs),wvelkm1(ngs)
9955
9956 real wvdf(ngs),tka(ngs)
9957 real advisc(ngs)
9958
9959 real rwvent(ngs)
9960
9961
9962 real :: qx(ngs,lv:lhab)
9963 real :: cx(ngs,lc:lhab)
9964 real :: xv(ngs,lc:lhab)
9965 real :: xmas(ngs,lc:lhab)
9966 real :: xdn(ngs,lc:lhab)
9967 real :: xdia(ngs,lc:lhab,3)
9968 real :: alpha(ngs,lc:lhab)
9969 real :: zx(ngs,lr:lhab)
9970
9971
9972 logical zerocx(lc:lqmx)
9973
9974 logical :: lprint
9975
9976 integer, parameter :: iunit = 0
9977
9978 real :: frac, hwdn, tmpg, xdia1, xdia3, cwch,xvol
9979
9980 real :: cvm,cpm,rmm
9981
9982 real, parameter :: cpv = 1885.0 ! specific heat of water vapor at constant pressure
9983 real, parameter :: Mair = 0.0284 ! MOLECULAR WEIGHT OF 'AIR' (KG/MOL)
9984
9985
9986 integer :: kstag
9987
9988 integer :: count
9989
9990! Addtion T.Iguchi Y2021 Update
9991 real, parameter :: mwwater = 0.01801528 ! Molecular weight of water (kg/mol)
9992 real, parameter :: rhowater = 997.0 ! Density of liquid water (kg/m3)
9993 real, parameter :: gasconst = 8.3144598 ! Gas constant (m2 kg s-2 K-1 mol-1)
9994 real :: sswater ! unit change supersaturation from percentage to n/a
9995 real :: sigvl, aact
9996
9997 real :: alpha_ar, gamma_ar, G_ar, evs, zeta, smax
9998 real :: f_ac, g_ac, eta_ac
9999 real :: f_nu, g_nu, eta_nu
10000 real :: f_co, g_co, eta_co
10001
10002 real :: sm_nu, sm_ac, sm_co, ss_ac, ss_nu, ss_co
10003 real :: uu_nu, uu_ac, uu_co
10004
10005 real :: cn_ac, cn_co, cn_nu
10006
10007! -------------------------------------------------------------------------------
10008 itile = nxi
10009 jtile = ny
10010 ktile = nz
10011 ixend = nxi
10012 jyend = ny
10013 kzend = nz
10014 nxend = nxi + 1
10015 nyend = ny + 1
10016 nzend = nz
10017 kzbeg = 1
10018 nzbeg = 1
10019
10020 IF ( ac_opt > 0 ) ccnefactwo = (1.63e-3/(cck * beta(3./2., cck/2.)))**(1.0/(cck + 2.0))
10021 f5 = 237.3 * 17.27 * 2.5e6 / cp ! combined constants for rain condensation (Soong and Ogura 73)
10022
10023 jy = 1
10024 kstag = 0
10025 pb(:) = 0.0
10026 pinit(:) = 0.0
10027
10028 IF ( ipconc <= 1 .or. isedonly == 2 ) GOTO 2200
10029
10030!
10031! Ziegler nucleation
10032!
10033
10034! ssfilt(:,:,:) = 0.0
10035 ssmx = 0
10036 count = 0
10037
10038 do kz = 1,nz-kstag
10039 do ix = 1,nxi
10040
10041 temp1 = an(ix,jy,kz,lt)*t77(ix,jy,kz)
10042 t0(ix,jy,kz) = temp1
10043 ltemq = int( (temp1-163.15)/fqsat+1.5 )
10044 ltemq = min( nqsat, max(1,ltemq) )
10045
10046! c1 = t00(ix,jy,kz)*tabqvs(ltemq)
10047 IF ( iqvsopt == 0 ) THEN
10048 c1 = t00(ix,jy,kz)*tabqvs(ltemq)
10049 ELSEIF ( iqvsopt == 1 ) THEN
10050 c1 = rdorv*esbolton*tabqvs(ltemq)/(pn(ix,jy,kz) + pb(kz) - esbolton*tabqvs(ltemq))
10051 ENDIF
10052
10053 IF ( c1 > 0. ) THEN
10054 ssfilt(ix,jy,kz) = 100.*(an(ix,jy,kz,lv)/c1 - 1.0) ! from "new" values
10055 ELSE
10056 ssfilt(ix,jy,kz) = -100.
10057 ENDIF
10058
10059 ENDDO
10060 ENDDO
10061
10062
10063!
10064! jy = 1 ! working on a 2d slab
10065!! VERY IMPORTANT: SET jgs = jy
10066
10067 jgs = jy
10068
10069!
10070!..Gather microphysics
10071!
10072 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: Gather stage'
10073
10074 nxmpb = 1
10075 nzmpb = 1
10076 nxz = nxi*nz
10077 numgs = nxz/ngs + 1
10078
10079
10080 do 2000 inumgs = 1,numgs
10081
10082 ngscnt = 0
10083
10084
10085 kzb = nzmpb
10086 kze = nz-kstag
10087 ! if (kzbeg .le. nzmpb .and. kzend .gt. nzmpb) kzb = nzmpb
10088
10089 ixb = nxmpb
10090 ixe = itile
10091
10092 do kz = kzb,kze
10093 do ix = nxmpb,nxi
10094
10095 pres(1) = pn(ix,jy,kz) + pb(kz)
10096 pqs(1) = 380.0/(pn(ix,jy,kz) + pb(kz))
10097 theta(1) = an(ix,jy,kz,lt)
10098 temg(1) = t0(ix,jy,kz)
10099
10100 temcg(1) = temg(1) - tfr
10101 ltemq = (temg(1)-163.15)/fqsat+1.5
10102 ltemq = min( nqsat, max(1,ltemq) )
10103 ! qvs(1) = pqs(1)*tabqvs(ltemq)
10104 IF ( iqvsopt == 0 ) THEN
10105 qvs(1) = pqs(1)*tabqvs(ltemq)
10106 ELSEIF ( iqvsopt == 1 ) THEN
10107 qvs(1) = rdorv*esbolton*tabqvs(ltemq)/(pres(1) - esbolton*tabqvs(ltemq))
10108 ENDIF
10109 qis(1) = pqs(1)*tabqis(ltemq)
10110
10111 qss(1) = qvs(1)
10112
10113
10114 if ( temg(1) .lt. tfr ) then
10115 end if
10116!
10117 if ( (temg(1) .gt. tfrh .or. an(ix,jy,kz,lv)/qvs(1) > maxlowtempss ) .and. &
10118 & ( an(ix,jy,kz,lv) .gt. qss(1) .or. &
10119 & an(ix,jy,kz,lc) .gt. qxmin(lc) .or. &
10120 & ( an(ix,jy,kz,lr) .gt. qxmin(lr) .and. rcond == 2 ) &
10121 & )) then
10122 ngscnt = ngscnt + 1
10123 igs(ngscnt) = ix
10124 kgs(ngscnt) = kz
10125 if ( ngscnt .eq. ngs ) goto 2100
10126 end if
10127
10128 end do !ix
10129
10130 nxmpb = 1
10131 end do !kz
10132! if ( jy .eq. (ny-jstag) ) iend = 1
10133 2100 continue
10134
10135 if ( ngscnt .eq. 0 ) go to 29998
10136
10137 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: dbg = 8'
10138
10139! write(0,*) 'NUCOND: dbg = 8, ngscnt,ssmx = ',ngscnt,ssmx
10140
10141
10142 qx(:,:) = 0.0
10143 cx(:,:) = 0.0
10144 zx(:,:) = 0.0
10145
10146 xv(:,:) = 0.0
10147 xmas(:,:) = 0.0
10148
10149 IF ( imurain == 1 ) THEN
10150 alpha(:,lr) = alphar
10151 ELSEIF ( imurain == 3 ) THEN
10152 alpha(:,lr) = xnu(lr)
10153 ENDIF
10154
10155!
10156! define temporaries for state variables to be used in calculations
10157!
10158 DO mgs = 1,ngscnt
10159 qx(mgs,lv) = an(igs(mgs),jy,kgs(mgs),lv)
10160 DO il = lc,lhab
10161 qx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),il), 0.0)
10162 ENDDO
10163
10164 qcwtmp(mgs) = qx(mgs,lc)
10165
10166
10167 theta0(mgs) = an(igs(mgs),jy,kgs(mgs),lt) !
10168 thetap(mgs) = 0.0
10169 theta(mgs) = an(igs(mgs),jy,kgs(mgs),lt)
10170 qv0(mgs) = qx(mgs,lv)
10171 qwvp(mgs) = qx(mgs,lv) - qv0(mgs)
10172
10173 pres(mgs) = pn(igs(mgs),jy,kgs(mgs)) + pb(kgs(mgs))
10174 pipert(mgs) = p2(igs(mgs),jy,kgs(mgs))
10175 rho0(mgs) = dn(igs(mgs),jy,kgs(mgs))
10176 rhoinv(mgs) = 1.0/rho0(mgs)
10177 rhovt(mgs) = sqrt(rho00/rho0(mgs))
10178 pi0(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs))
10179 temg(mgs) = t0(igs(mgs),jy,kgs(mgs))
10180! pk(mgs) = t77(igs(mgs),jy,kgs(mgs)) ! ( pres(mgs) / poo ) ** cap
10181 pk(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs)) ! t77(igs(mgs),jy,kgs(mgs))
10182 temcg(mgs) = temg(mgs) - tfr
10183 qss0(mgs) = (380.0)/(pres(mgs))
10184 pqs(mgs) = (380.0)/(pres(mgs))
10185 ltemq = (temg(mgs)-163.15)/fqsat+1.5
10186 ltemq = min( nqsat, max(1,ltemq) )
10187! qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
10188 IF ( iqvsopt == 0 ) THEN
10189 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
10190 ELSEIF ( iqvsopt == 1 ) THEN
10191 qvs(mgs) = rdorv*esbolton*tabqvs(ltemq)/(pres(mgs) - esbolton*tabqvs(ltemq))
10192 ENDIF
10193 qis(mgs) = pqs(mgs)*tabqis(ltemq)
10194!
10195 qvap(mgs) = max( (qwvp(mgs) + qv0(mgs)), 0.0 )
10196 IF ( iqvsopt == 0 ) THEN
10197 es(mgs) = 6.1078e2*tabqvs(ltemq)
10198 ELSEIF ( iqvsopt == 1 ) THEN
10199 es(mgs) = esbolton*tabqvs(ltemq)
10200 ENDIF
10201! es(mgs) = 6.1078e2*tabqvs(ltemq)
10202 qss(mgs) = qvs(mgs)
10203
10204
10205 temgx(mgs) = min(temg(mgs),313.15)
10206 temgx(mgs) = max(temgx(mgs),233.15)
10207 felv(mgs) = 2500837.367 * (273.15/temgx(mgs))**((0.167)+(3.67e-4)*temgx(mgs))
10208!
10209 IF ( eqtset <= 1 ) THEN
10210 felvcp(mgs) = felv(mgs)*cpi
10211 ELSE ! equation set 2 in cm1
10212 tmp = qx(mgs,li)+qx(mgs,ls)+qx(mgs,lh)
10213 IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
10214 IF ( lf > 1 ) tmp = tmp + qx(mgs,lf)
10215 cvm = cv+cvv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
10216 +cpigb*(tmp)
10217 cpm = cp+cpv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
10218 +cpigb*(tmp)
10219 rmm=rd+rw*qx(mgs,lv)
10220
10221 IF ( eqtset == 2 ) THEN
10222
10223 felvcp(mgs) = (felv(mgs)-rw*temg(mgs))/cvm
10224
10225 ELSE
10226 felvcp(mgs) = (felv(mgs)*cv/(cp) - rw*temg(mgs)*(1.0-rovcp*cpm/rmm))/cvm
10227 felvpi(mgs) = pi0(mgs)*rovcp*(felv(mgs)/(temg(mgs)) - rw*cpm/rmm)/cvm
10228 ENDIF
10229
10230 ENDIF
10231
10232 temcgx(mgs) = min(temg(mgs),273.15)
10233 temcgx(mgs) = max(temcgx(mgs),223.15)
10234 temcgx(mgs) = temcgx(mgs)-273.15
10235 felf(mgs) = 333690.6098 + (2030.61425)*temcgx(mgs) - (10.46708312)*temcgx(mgs)**2
10236!
10237 fels(mgs) = felv(mgs) + felf(mgs)
10238 fcqv1(mgs) = 4098.0258*felv(mgs)*cpi
10239
10240 wvdf(mgs) = (2.11e-05)*((temg(mgs)/tfr)**1.94)* &
10241 & (101325.0/(pb(kgs(mgs)) + pn(igs(mgs),jgs,kgs(mgs)))) ! diffusivity of water vapor, Hall and Pruppacher (76)
10242 advisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))* &
10243 & (temg(mgs)/296.0)**(1.5) ! dynamic viscosity (SMT; see Beard & Pruppacher 71)
10244 tka(mgs) = tka0*advisc(mgs)/advisc1 ! thermal conductivity
10245
10246
10247 ENDDO
10248
10249
10250
10251!
10252! load concentrations
10253!
10254 if ( ipconc .ge. 1 ) then
10255 do mgs = 1,ngscnt
10256 cx(mgs,li) = max(an(igs(mgs),jy,kgs(mgs),lni), 0.0)
10257 end do
10258 end if
10259 if ( ipconc .ge. 2 ) then
10260 do mgs = 1,ngscnt
10261 cx(mgs,lc) = max(an(igs(mgs),jy,kgs(mgs),lnc), 0.0)
10262 cwnccn(mgs) = cwccn*rho0(mgs)/rho00 ! background ccn count
10263 cn(mgs) = 0.0
10264 IF ( lss > 1 ) THEN
10265 ssmax(mgs) = an(igs(mgs),jy,kgs(mgs),lss)
10266 ELSE
10267 ssmax(mgs) = 0.0
10268 ENDIF
10269 IF ( lccn .gt. 1 .and. ac_opt == 0 ) THEN
10270 IF ( lccnuf .gt. 1 .and. i_uf_or_ccn > 0 ) THEN
10271 ccnc(mgs) = an(igs(mgs),jy,kgs(mgs),lccn) + an(igs(mgs),jy,kgs(mgs),lccnuf)
10272 ELSE
10273 ccnc(mgs) = an(igs(mgs),jy,kgs(mgs),lccn)
10274 IF ( lccna > 1 ) THEN
10275 cnuc(mgs) = ccnc(mgs)
10276 ENDIF
10277 ENDIF
10278 IF ( lcn_nu > 1 ) THEN
10279 ccnc_nu(mgs) = an(igs(mgs),jy,kgs(mgs),lcn_nu)
10280 ENDIF
10281 IF ( lcn_co > 1 ) THEN
10282 ccnc_co(mgs) = an(igs(mgs),jy,kgs(mgs),lcn_co)
10283 ENDIF
10284 IF ( lccnaco > 1 ) THEN
10285 ccnaco(mgs) = an(igs(mgs),jy,kgs(mgs),lccnaco)
10286 ELSE
10287 ccnaco(mgs) = 0.0
10288 ENDIF
10289 IF ( lccnanu > 1 ) THEN
10290 ccnanu(mgs) = an(igs(mgs),jy,kgs(mgs),lccnanu)
10291 ELSE
10292 ccnanu(mgs) = 0.0
10293 ENDIF
10294 ELSEIF ( lccn > 1 .and. ( ac_opt == 1 .or. ac_opt == 11 ) ) THEN
10295 ccnc(mgs) = an(igs(mgs),jy,kgs(mgs),lccn)
10296 ! ccnc(mgs) = ccnc_ac(mgs)
10297 cnuc(mgs) = ccnc(mgs)
10298 cwnccn(mgs) = cnuc(mgs)
10299 ! write(0,*) 'ccnc_ac,mgs = ', ccnc_ac(mgs),mgs,igs(mgs),jy,kgs(mgs)
10300 ELSEIF ( lccn > 1 .and. ( ac_opt == 2 .or. ac_opt == 22 ) ) THEN
10301 ccnc_nu(mgs) = an(igs(mgs),jy,kgs(mgs),lcn_nu)
10302 ccnc(mgs) = an(igs(mgs),jy,kgs(mgs),lccn)
10303 ! ccnc(mgs) = ccnc_ac(mgs)
10304 ccnc_co(mgs) = an(igs(mgs),jy,kgs(mgs),lcn_co)
10305 ELSE
10306 ccnc(mgs) = cwnccn(mgs)
10307 ENDIF
10308 IF ( lccnuf .gt. 1 .and. i_uf_or_ccn == 0 ) THEN
10309 ccncuf(mgs) = an(igs(mgs),jy,kgs(mgs),lccnuf)
10310 ELSE
10311 ccncuf(mgs) = 0.0
10312 ENDIF
10313 cnuf(mgs) = 0.0
10314 IF ( lccna > 1 ) THEN
10315 ccna(mgs) = an(igs(mgs),jy,kgs(mgs),lccna) ! predicted count of activated ccn
10316 IF ( ac_opt == 22 ) THEN
10317 IF ( lccnaco > 1 ) THEN
10318 ccnaco(mgs) = an(igs(mgs),jy,kgs(mgs),lccnaco)
10319 ELSE
10320 ccnaco(mgs) = 0.0
10321 ENDIF
10322 IF ( lccnanu > 1 ) THEN
10323 ccnanu(mgs) = an(igs(mgs),jy,kgs(mgs),lccnanu)
10324 ELSE
10325 ccnanu(mgs) = 0.0
10326 ENDIF
10327 ENDIF
10328 ELSE
10329 IF ( lccn > 1 ) THEN
10330 ccna(mgs) = 0.0 ! WRF driver interface already has ccw subtracted from ccnc
10331 ELSE
10332 ccna(mgs) = cx(mgs,lc) ! approximation of number of activated ccn
10333 ENDIF
10334 ENDIF
10335 end do
10336 end if
10337 if ( ipconc .ge. 3 ) then
10338 do mgs = 1,ngscnt
10339 cx(mgs,lr) = max(an(igs(mgs),jy,kgs(mgs),lnr), 0.0)
10340 end do
10341 end if
10342
10343! cnuc(1:ngscnt) = cwccn*rho0(mgs)/rho00*(1. - renucfrac) + ccnc(1:ngscnt)*renucfrac
10344 DO mgs = 1,ngscnt
10345 ! default value of renucfrac is 0.0
10346 IF ( irenuc /= 6 ) THEN
10347 IF ( irenuc == 2 ) THEN
10348 cnuc(mgs) = max(ccnc(mgs),cwnccn(mgs))*(1. - renucfrac) + ccnc(mgs)*renucfrac
10349 ELSE
10350 cnuc(mgs) = ccnc(mgs)*(1. - renucfrac) + ccnc(mgs)*renucfrac
10351 ENDIF
10352 ELSE
10353 cnuc(mgs) = ccnc(mgs)*(1. - renucfrac) + max(0.0,ccnc(mgs) - ccna(mgs))*renucfrac
10354 ENDIF
10355 IF ( renucfrac >= 0.999 ) THEN
10356 IF ( temg(mgs) < 265. ) THEN
10357 IF ( qx(mgs,lc) > 10.*qxmin(lc) .and. w(igs(mgs),jgs,kgs(mgs)) > 2.0 ) THEN
10358 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
10359 ELSE
10360 cnuc(mgs) = 0.1*cnuc(mgs)
10361 ENDIF
10362 ENDIF
10363 ENDIF
10364 ENDDO
10365
10366! Set density
10367!
10368 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: Set density'
10369
10370 do mgs = 1,ngscnt
10371 xdn(mgs,lc) = xdn0(lc)
10372 xdn(mgs,lr) = xdn0(lr)
10373 end do
10374
10375 ventrx(:) = ventr
10376 ventrxn(:) = ventrn
10377
10378
10379! Find shape parameter rain
10380
10381 IF ( lzr > 1 .and. rcond == 2 ) THEN ! { RAIN SHAPE PARAM
10382 DO mgs = 1,ngscnt
10383 zx(mgs,lr) = max(an(igs(mgs),jy,kgs(mgs),lzr), 0.0)
10384 ENDDO
10385
10386! CALL cld_cpu('Z-MOMENT-1r2')
10387 il = lr
10388 DO mgs = 1,ngscnt
10389
10390 IF ( zx(mgs,il) <= zxmin ) THEN
10391 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
10392 qx(mgs,il) = 0.0
10393 cx(mgs,il) = 0.0
10394 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
10395 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
10396 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
10397 ELSEIF ( cx(mgs,il) <= 0.0 ) THEN
10398 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
10399 zx(mgs,il) = 0.0
10400 qx(mgs,il) = 0.0
10401 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
10402 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
10403 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
10404 ENDIF
10405
10406 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
10407
10408 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*max(1.0e-11,cx(mgs,lr)))
10409 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
10410 xv(mgs,lr) = xvmx(lr)
10411 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
10412 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
10413 xv(mgs,lr) = xvmn(lr)
10414 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
10415 ENDIF
10416
10417 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
10418! have mass and reflectivity but no concentration, so set concentration, using default alpha
10419 IF ( imurain == 3 ) THEN
10420 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10421 z1 = zx(mgs,il)
10422 qr = qx(mgs,il)
10423 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z1*1000.*1000)
10424 ELSE
10425 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10426 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
10427 z1 = zx(mgs,il)
10428 qr = qx(mgs,il)
10429 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z1*1000.*1000)
10430
10431 ENDIF
10432! an(igs(mgs),jgs,kgs(mgs),ln(il)) = zx(mgs,il)
10433 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > 0.0 ) THEN
10434! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
10435 IF ( imurain == 3 ) THEN
10436 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10437 chw = cx(mgs,il)
10438 qr = qx(mgs,il)
10439 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(chw*1000.*1000)
10440 ELSE
10441 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10442 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
10443 chw = cx(mgs,il)
10444 qr = qx(mgs,il)
10445 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(chw*1000.*1000)
10446
10447 ENDIF
10448
10449 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
10450! How did this happen?
10451 ! set values according to dBZ of -10, or Z = 0.1
10452! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
10453 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
10454 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
10455
10456 IF ( imurain == 3 ) THEN
10457 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10458 z1 = zx(mgs,il)
10459 qr = qx(mgs,il)
10460 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z1*1000.*1000)
10461 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
10462 ELSEIF ( imurain == 1 ) THEN
10463 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10464 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
10465 z1 = zx(mgs,il)
10466 qr = qx(mgs,il)
10467 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(z1*(pi*xdn(mgs,il))**2)
10468 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
10469
10470 ENDIF
10471 ENDIF
10472
10473 IF ( zx(mgs,lr) > 0.0 ) THEN
10474 vr = rho0(mgs)*qx(mgs,lr)/(1000.*cx(mgs,lr))
10475! z1 = 36.*(alpha(kz)+2.0)*a(ix,jy,kz,lnr)*vr**2/((alpha(kz)+1.0)*pi**2)
10476 qr = qx(mgs,lr)
10477 nrx = cx(mgs,lr)
10478 z1 = zx(mgs,lr)
10479
10480! xv = (db(1,kz)*a(1,1,kz,lr))**2/(a(1,1,kz,lnr))
10481! rd = z1*(pi/6.*1000.)**2/xv
10482
10483
10484! determine shape parameter alpha by iteration
10485 IF ( z1 .gt. 0.0 ) THEN
10486
10487 IF ( imurain == 3 ) THEN
10488 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z1*pi**2) - 1.
10489! write(0,*) 'kz, alp, alpha(kz) = ',kz,alp,alpha(kz),rd,z1,xv
10490 DO i = 1,20
10491 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
10492 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
10493 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z1*pi**2) - 1.
10494! write(0,*) 'i,alp = ',i,alp
10495 alp = max( rnumin, min( rnumax, alp ) )
10496 ENDDO
10497
10498 ELSE ! imurain == 1
10499 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10500 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
10501
10502 rd1 = z1*(pi/6.*xdn(mgs,il))**2*nrx/(rho0(mgs)*qr)**2
10503
10504 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
10505 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd1) - 1.0
10506
10507 DO i = 1,10
10508 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
10509 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
10510
10511 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
10512 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rd1) - 1.0
10513
10514 alp = max( alphamin, min( alphamax, alp ) )
10515 ENDDO
10516
10517
10518 ENDIF
10519! ENDIF
10520
10521!
10522! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
10523! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
10524!
10525 IF ( imurain == 3 ) THEN
10526 IF ( .true. .and. (alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax) ) THEN
10527
10528 IF ( rescale_high_alpha .and. alp >= rnumax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
10529 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
10530 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z1*(1./(xdn(mgs,il)))**2
10531 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
10532
10533 ELSEIF ( rescale_low_alphar .and. alp <= rnumin ) THEN
10534
10535 z1 = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
10536 zx(mgs,il) = z1
10537 ENDIF
10538 ENDIF
10539
10540 ELSEIF ( imurain == 1 ) THEN
10541
10542 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
10543 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
10544
10545 IF ( (rescale_low_alpha .or. rescale_high_alpha ) .and. &
10546 & ( alpha(mgs,il) <= alphamin .or. alp == alphamin .or. alp == alphamax ) ) THEN
10547
10548
10549
10550 IF ( rescale_high_alpha .and. alp >= alphamax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
10551 cx(mgs,il) = g1*rho0(mgs)**2*(qr)*qr/zx(mgs,lr)*(6./(pi*xdn(mgs,il)))**2
10552 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
10553
10554 ELSEIF ( rescale_low_alpha .and. alp <= alphamin ) THEN ! alpha = alphamin, so reset Z to prevent growth in C
10555 z1 = g1*rho0(mgs)**2*(qr)*qr/nrx
10556 z2 = z1*(6./(pi*xdn(mgs,il)))**2
10557 zx(mgs,il) = z2
10558 an(igs(mgs),jy,kgs(mgs),lz(il)) = z2
10559 ENDIF
10560 ENDIF ! imurain
10561
10562 ENDIF ! z > 0
10563
10564 tmp = alpha(mgs,lr) + 4./3.
10565 i = int(dgami*(tmp))
10566 del = tmp - dgam*i
10567 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10568
10569 tmp = alpha(mgs,lr) + 1.
10570 i = int(dgami*(tmp))
10571 del = tmp - dgam*i
10572 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10573
10574! ventrx(mgs) = Gamma(alpha(mgs,lr) + 4./3.)/(alpha(mgs,lr) + 1.)**(1./3.)/Gamma(alpha(mgs,lr) + 1.)
10575 ventrx(mgs) = x/(y*(alpha(mgs,lr) + 1.)**(1./3.))
10576
10577 IF ( imurain == 3 .and. izwisventr == 2 ) THEN
10578
10579 tmp = alpha(mgs,lr) + 1.5 + br/6.
10580 i = int(dgami*(tmp))
10581 del = tmp - dgam*i
10582 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10583
10584! ventrx(mgs) = Gamma(alpha(mgs,lr) + 1.5 + br/6.)/Gamma(alpha(mgs,lr) + 1.)
10585 ventrxn(mgs) = x/(y*(alpha(mgs,lr) + 1.)**((1.+br)/6. + 1./3.))
10586
10587 ELSEIF ( imurain == 1 .and. iferwisventr == 2 ) THEN
10588
10589 tmp = alpha(mgs,lr) + 2.5 + br/2.
10590 i = int(dgami*(tmp))
10591 del = tmp - dgam*i
10592 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10593
10594! ventrx(mgs) = Gamma(alpha(mgs,lr) + 1.5 + br/6.)/Gamma(alpha(mgs,lr) + 1.)
10595 ventrxn(mgs) = x/y
10596
10597
10598 ENDIF
10599
10600
10601 ENDIF
10602 ENDIF
10603
10604 ENDIF
10605
10606 ENDDO
10607! CALL cld_cpu('Z-MOMENT-1r2')
10608 ENDIF ! }
10609
10610
10611! write(0,*) 'NUCOND: Set ssf variables, ssmxinit =',ssmxinit
10612 ssmx = 0.0
10613 DO mgs = 1,ngscnt
10614
10615 kp1 = min(nz, kgs(mgs)+1 )
10616 wvel(mgs) = (0.5)*(w(igs(mgs),jgs,kp1) &
10617 & +w(igs(mgs),jgs,kgs(mgs)))
10618 wvelkm1(mgs) = (0.5)*(w(igs(mgs),jgs,kgs(mgs)) &
10619 & +w(igs(mgs),jgs,max(1,kgs(mgs)-1)))
10620
10621 ssat0(mgs) = ssfilt(igs(mgs),jgs,kgs(mgs))
10622 ssf(mgs) = ssfilt(igs(mgs),jgs,kgs(mgs))
10623! ssmx = Max( ssmx, ssf(mgs) )
10624
10625
10626 ssfkp1(mgs) = ssfilt(igs(mgs),jgs,min(nz-1,kgs(mgs)+1))
10627 ssfkm1(mgs) = ssfilt(igs(mgs),jgs,max(1,kgs(mgs)-1))
10628
10629! IF ( wvel(mgs) /= 0.0 ) write(0,*) 'mgs,wvel1,ssf = ',mgs,wvel(mgs),ssf(mgs)
10630
10631
10632 ENDDO
10633
10634
10635
10636!
10637! cloud water variables
10638!
10639
10640 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_DR: Set cloud water variables'
10641
10642 do mgs = 1,ngscnt
10643 xv(mgs,lc) = 0.0
10644 IF ( ipconc .ge. 2 .and. cx(mgs,lc) .gt. 1.0e6 ) THEN
10645 xmas(mgs,lc) = &
10646 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
10647 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
10648 ELSE
10649 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. cxmin ) THEN
10650 xmas(mgs,lc) = &
10651 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),xdn(mgs,lc)*xvmn(lc)), &
10652 & xdn(mgs,lc)*xvmx(lc) )
10653
10654 cx(mgs,lc) = qx(mgs,lc)*rho0(mgs)/xmas(mgs,lc)
10655
10656 ELSEIF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .le. cxmin ) THEN
10657! xmas(mgs,lc) = xdn(mgs,lc)*4.*pi/3.*(5.0e-6)**3
10658! cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc)
10659 cx(mgs,lc) = max( cxmin, rho0(mgs)*qx(mgs,lc)/cwmasx )
10660 xmas(mgs,lc) = &
10661 & min( max(qx(mgs,lc)*rho0(mgs)/cx(mgs,lc),cwmasn),cwmasx )
10662 xv(mgs,lc) = xmas(mgs,lc)/xdn(mgs,lc)
10663
10664 ELSE
10665 xmas(mgs,lc) = cwmasn
10666 ENDIF
10667 ENDIF
10668 xdia(mgs,lc,1) = (xmas(mgs,lc)*cwc1)**c1f3
10669
10670
10671 end do
10672!
10673! rain
10674!
10675 do mgs = 1,ngscnt
10676 if ( qx(mgs,lr) .gt. qxmin(lr) ) then
10677
10678 if ( ipconc .ge. 3 ) then
10679 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*max(1.0e-9,cx(mgs,lr)))
10680! parameter( xvmn(lr)=2.8866e-13, xvmx(lr)=4.1887e-9 ) ! mks
10681 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
10682 xv(mgs,lr) = xvmx(lr)
10683 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
10684 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
10685 xv(mgs,lr) = xvmn(lr)
10686 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
10687 ENDIF
10688
10689 xmas(mgs,lr) = xv(mgs,lr)*xdn(mgs,lr)
10690 xdia(mgs,lr,3) = (xmas(mgs,lr)*cwc1)**(1./3.) ! xdia(mgs,lr,1)
10691 IF ( imurain == 3 ) THEN
10692! xdia(mgs,lr,1) = (6.*pii*xv(mgs,lr)/(alpha(mgs,lr)+1.))**(1./3.)
10693 xdia(mgs,lr,1) = xdia(mgs,lr,3) ! formulae for Ziegler (1985) use mean volume diameter, not lambda**(-1)
10694 ELSE ! imurain == 1, Characteristic diameter (1/lambda)
10695 xdia(mgs,lr,1) = (6.*piinv*xv(mgs,lr)/((alpha(mgs,lr)+3.)*(alpha(mgs,lr)+2.)*(alpha(mgs,lr)+1.)))**(1./3.)
10696 ENDIF
10697! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
10698
10699! Inverse exponential version:
10700! xdia(mgs,lr,1) =
10701! > (qx(mgs,lr)*rho0(mgs)
10702! > /(pi*xdn(mgs,lr)*cx(mgs,lr)))**(0.333333)
10703 ELSE
10704 xdia(mgs,lr,1) = &
10705 & (qx(mgs,lr)*rho0(mgs)/(pi*xdn(mgs,lr)*cno(lr)))**(0.25)
10706 end if
10707 else
10708 xdia(mgs,lr,1) = 1.e-9
10709! rwrad(mgs) = 0.5*xdia(mgs,lr,1)
10710 end if
10711
10712 end do
10713
10714
10715!
10716! Ventilation coefficients
10717
10718 do mgs = 1,ngscnt
10719
10720
10721 fadvisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))* &
10722 & (temg(mgs)/296.0)**(1.5)
10723
10724 fakvisc(mgs) = fadvisc(mgs)*rhoinv(mgs)
10725
10726 fwvdf(mgs) = (2.11e-05)*((temg(mgs)/tfr)**1.94)* &
10727 & (101325.0/(pres(mgs)))
10728
10729 fschm(mgs) = (fakvisc(mgs)/fwvdf(mgs))
10730
10731 fvent(mgs) = (fschm(mgs)**(1./3.)) * (fakvisc(mgs)**(-0.5))
10732
10733 end do
10734!
10735!
10736! Ziegler nucleation
10737!
10738!
10739! cloud evaporation, condensation, and nucleation
10740! sqsat -> qss(mgs)
10741
10742 DO mgs=1,ngscnt
10743 dcloud = 0.0
10744 ! Skip points at low temperature if SS stays less than 1.08,
10745 ! otherwise allow nucleation at low temp (will freeze at next time step)
10746 IF ( temg(mgs) .le. tfrh .and. qx(mgs,lv)/qvs(mgs) < maxlowtempss ) THEN
10747 cycle
10748 ENDIF
10749
10750 IF( ssat0(mgs) .GT. 0. .OR. ssf(mgs) .GT. 0. ) GO TO 620
10751!6/4 IF( qvap(mgs) .EQ. qss(mgs) ) GO TO 631
10752!
10753!.... EVAPORATION. QV IS LESS THAN qss(mgs).
10754!.... EVAPORATE CLOUD FIRST
10755!
10756 IF ( qx(mgs,lc) .LE. 0. ) GO TO 631
10757!.... CLOUD EVAPORATION.
10758! convert input 'cp' to cgs
10759 r1=1./(1. + caw*(273.15 - cbw)*qss(mgs)*felv(mgs)/ &
10760 & (cp*(temg(mgs) - cbw)**2))
10761 qevap= min( qx(mgs,lc), r1*(qss(mgs)-qvap(mgs)) )
10762
10763
10764 IF ( qx(mgs,lc) <= qevap ) THEN !{ GO TO 63
10765 qwvp(mgs) = qwvp(mgs) + qx(mgs,lc)
10766 thetap(mgs) = thetap(mgs) - felvcp(mgs)*qx(mgs,lc)/(pi0(mgs))
10767 IF ( io_flag .and. nxtra > 1 ) THEN
10768 axtra(igs(mgs),jy,kgs(mgs),1) = -qx(mgs,lc)/dtp
10769 ENDIF
10770 qx(mgs,lc) = 0.
10771 IF ( restoreccn ) THEN !{
10772 IF ( lccna > 1 ) THEN
10773 tmp = restoreccnfrac*cx(mgs,lc)
10774 IF ( lccnaco > 1 .and. lccnanu > 1 ) THEN
10775 ! restore CCN proportionally to each type, although coarse are presumably already lost to rain
10776 tmp2 = ccna(mgs) + ccnaco(mgs) + ccnanu(mgs)
10777 IF ( tmp2 > 0.0 ) THEN
10778 ccna(mgs) = ccna(mgs) - tmp*ccna(mgs)/tmp2
10779 ccnaco(mgs) = ccnaco(mgs) - tmp*ccnaco(mgs)/tmp2
10780 ccnanu(mgs) = ccnanu(mgs) - tmp*ccnanu(mgs)/tmp2
10781 ENDIF
10782 ELSE
10783 ccna(mgs) = ccna(mgs) - tmp
10784 ENDIF
10785 ELSEIF ( irenuc <= 2 ) THEN
10786 IF ( .not. invertccn ) THEN
10787 ccnc(mgs) = max( ccnc(mgs), min( qccn*rho0(mgs), ccnc(mgs) + restoreccnfrac*cx(mgs,lc) ) )
10788 ELSE
10789 ccnc(mgs) = ccnc(mgs) + restoreccnfrac*cx(mgs,lc)
10790 ENDIF
10791 ENDIF
10792 ENDIF !}
10793 cx(mgs,lc) = 0.
10794 ELSE !} {
10795 qctmp = qx(mgs,lc)
10796 qwvp(mgs) = qwvp(mgs) + qevap
10797 qx(mgs,lc) = qx(mgs,lc) - qevap
10798 IF ( qx(mgs,lc) .le. 0. ) THEN
10799 IF ( restoreccn ) THEN
10800 IF ( lccna > 1 ) THEN
10801 tmp = restoreccnfrac*cx(mgs,lc)
10802 IF ( lccnaco > 1 .and. lccnanu > 1 ) THEN
10803 ! restore CCN proportionally to each type, although coarse are presumably already lost to rain
10804 tmp2 = ccna(mgs) + ccnaco(mgs) + ccnanu(mgs)
10805 IF ( tmp2 > 0.0 ) THEN
10806 ccna(mgs) = ccna(mgs) - tmp*ccna(mgs)/tmp2
10807 ccnaco(mgs) = ccnaco(mgs) - tmp*ccnaco(mgs)/tmp2
10808 ccnanu(mgs) = ccnanu(mgs) - tmp*ccnanu(mgs)/tmp2
10809 ENDIF
10810 ELSE
10811 ccna(mgs) = ccna(mgs) - tmp
10812 ENDIF
10813 ELSEIF ( irenuc <= 2 ) THEN
10814! ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + cx(mgs,lc) ) )
10815! ccnc(mgs) = ccnc(mgs) + cx(mgs,lc)
10816 IF ( .not. invertccn ) THEN
10817 ccnc(mgs) = max( ccnc(mgs), min( qccn*rho0(mgs), ccnc(mgs) + restoreccnfrac*cx(mgs,lc) ) )
10818 ELSE
10819 ccnc(mgs) = ccnc(mgs) + restoreccnfrac*cx(mgs,lc)
10820 ENDIF
10821 ENDIF
10822 ENDIF
10823 cx(mgs,lc) = 0.
10824 ELSE
10825 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
10826 IF ( restoreccn ) THEN
10827 IF ( lccna > 1 ) THEN
10828 tmp = restoreccnfrac*tmp
10829 IF ( lccnaco > 1 .and. lccnanu > 1 ) THEN
10830 ! restore CCN proportionally to each type, although coarse are presumably already lost to rain
10831 tmp2 = ccna(mgs) + ccnaco(mgs) + ccnanu(mgs)
10832 IF ( tmp2 > 0.0 ) THEN
10833 ccna(mgs) = ccna(mgs) - tmp*ccna(mgs)/tmp2
10834 ccnaco(mgs) = ccnaco(mgs) - tmp*ccnaco(mgs)/tmp2
10835 ccnanu(mgs) = ccnanu(mgs) - tmp*ccnanu(mgs)/tmp2
10836 ENDIF
10837 ELSE
10838 ccna(mgs) = ccna(mgs) - tmp
10839 ENDIF
10840 ! ccna(mgs) = ccna(mgs) - restoreccnfrac*tmp
10841 ELSEIF ( irenuc <= 2 ) THEN
10842 ! ccnc(mgs) = Max( ccnc(mgs), Min( qccn*rho0(mgs), ccnc(mgs) + tmp ) )
10843! ccnc(mgs) = ccnc(mgs) + tmp
10844 IF ( .not. invertccn ) THEN
10845 ccnc(mgs) = max( ccnc(mgs), min( qccn*rho0(mgs), ccnc(mgs) + restoreccnfrac*tmp ) )
10846 ELSE
10847 ccnc(mgs) = ccnc(mgs) + restoreccnfrac*tmp
10848 ENDIF
10849 ENDIF
10850 ENDIF
10851 cx(mgs,lc) = cx(mgs,lc) - tmp
10852 ENDIF
10853 thetap(mgs) = thetap(mgs) - felvcp(mgs)*qevap/(pi0(mgs))
10854 IF ( io_flag .and. nxtra > 1 ) THEN
10855 axtra(igs(mgs),jy,kgs(mgs),1) = -qevap/dtp
10856 ENDIF
10857
10858 ENDIF !}
10859
10860 GO TO 631
10861
10862
10863 620 CONTINUE
10864
10865!.... CLOUD CONDENSATION
10866
10867 IF ( qx(mgs,lc) .GT. qxmin(lc) .and. cx(mgs,lc) .ge. 1. ) THEN
10868
10869
10870
10871! ac1 = xdn(mgs,lc)*elv(kgs(mgs))**2*epsi/
10872! : (tka(kgs(mgs))*rw*temg(mgs)**2)
10873! took out xdn factor because it cancels later...
10874 ac1 = felv(mgs)**2/(tka(mgs)*rw*temg(mgs)**2)
10875
10876
10877! bc = xdn(mgs,lc)*rw*temg(mgs)/
10878! : (epsi*wvdf(kgs(mgs))*es(mgs))
10879! took out xdn factor because it cancels later...
10880 bc = rw*temg(mgs)/(wvdf(mgs)*es(mgs))
10881
10882! bs = rho0(mgs)*((rd*temg(mgs)/(epsi*es(mgs)))+
10883! : (epsi*elv(kgs(mgs))**2/(pres(mgs)*temg(mgs)*cp)))
10884
10885! taus = Min(dtp, xdn(mgs,lc)*rho0(mgs)*(ac1+bc)/
10886! : (4*pi*0.89298*BS*0.5*xdia(mgs,lc,1)*cx(mgs,lc)*xdn(mgs,lc)))
10887
10888!
10889 IF ( ssf(mgs) .gt. 0.0 .or. ssat0(mgs) .gt. 0.0 ) THEN
10890 IF ( ny .le. 2 ) THEN
10891! write(0,*) 'undershoot: ',ssf(mgs),
10892! : ( (qx(mgs,lv) - dcloud)/c1 - 1.0)*100.
10893 ENDIF
10894
10895
10896
10897 IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN
10898
10899 IF ( xdia(mgs,lc,1) .le. 0.0 ) THEN
10900 xmas(mgs,lc) = cwmasn
10901 xdia(mgs,lc,1) = (xmas(mgs,lc)*cwc1)**c1f3
10902 ENDIF
10903 d1 = (1./(ac1 + bc))*4.0*pi*ventc &
10904 & *0.5*xdia(mgs,lc,1)*cx(mgs,lc)*rhoinv(mgs)
10905
10906 ELSE
10907 d1 = 0.0
10908 ENDIF
10909
10910 IF ( rcond .eq. 2 .and. qx(mgs,lr) .gt. qxmin(lr) .and. cx(mgs,lr) > 1.e-9 ) THEN
10911 IF ( imurain == 3 ) THEN
10912 IF ( izwisventr == 1 ) THEN
10913 rwvent(mgs) = ventrx(mgs)*(1.6 + 124.9*(1.e-3*rho0(mgs)*qx(mgs,lr))**.2046)
10914 ELSE ! izwisventr = 2
10915! 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
10916 rwvent(mgs) = &
10917 & (0.78*ventrx(mgs) + 0.308*ventrxn(mgs)*fvent(mgs) &
10918 & *sqrt((ar*rhovt(mgs))) &
10919 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
10920 ENDIF
10921
10922 ELSE ! imurain == 1
10923
10924 IF ( iferwisventr == 1 ) THEN
10925 alpr = min(alpharmax,alpha(mgs,lr) )
10926! alpr = alpha(mgs,lr)
10927 x = 1. + alpr
10928
10929 tmp = 1 + alpr
10930 i = int(dgami*(tmp))
10931 del = tmp - dgam*i
10932 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
10933
10934 tmp = 2.5 + alpr + 0.5*bx(lr)
10935 i = int(dgami*(tmp))
10936 del = tmp - dgam*i
10937 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp ! ratio of gamma functions
10938
10939! vent1 = dble(xdia(mgs,lr,1))**(-2. - alpr) ! Actually OK
10940! vent2 = dble(1./xdia(mgs,lr,1) + 0.5*fx(lr))**dble(2.5+alpr+0.5*bx(lr)) ! Actually OK
10941 vent1 = dble(xdia(mgs,lr,1))**(0.5 + 0.5*bx(lr)) ! 2016.2.26 Changed for consistency with derivation (recast formula)
10942 vent2 = dble(1. + 0.5*fx(lr)*xdia(mgs,lr,1))**dble(2.5+alpr+0.5*bx(lr))
10943
10944
10945 rwvent(mgs) = &
10946 & 0.78*x + &
10947 & 0.308*fvent(mgs)*y* &
10948 & sqrt(ax(lr)*rhovt(mgs))*(vent1/vent2)
10949
10950 ELSEIF ( iferwisventr == 2 ) THEN
10951
10952! 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
10953 x = 1. + alpha(mgs,lr)
10954
10955 rwvent(mgs) = &
10956 & (0.78*x + 0.308*ventrxn(mgs)*fvent(mgs) &
10957 & *sqrt((ar*rhovt(mgs))) &
10958 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
10959
10960
10961 ENDIF ! iferwisventr
10962
10963 ENDIF ! imurain
10964
10965 d1r = (1./(ac1 + bc))*4.0*pi*rwvent(mgs) &
10966 & *0.5*xdia(mgs,lr,1)*cx(mgs,lr)*rhoinv(mgs)
10967 ELSE
10968 d1r = 0.0
10969 ENDIF
10970
10971
10972 e1 = felvcp(mgs)/(pi0(mgs))
10973 f1 = pk(mgs) ! (pres(mgs)/poo)**cap
10974
10975!
10976! fifth trial to see what happens:
10977!
10978 ltemq = (temg(mgs)-163.15)/fqsat+1.5
10979 ltemq = min( nqsat, max(1,ltemq) )
10980 ltemq1 = ltemq
10981 temp1 = temg(mgs)
10982 IF ( iqvsopt == 0 ) THEN
10983 p380 = 380.0/pres(mgs)
10984 ELSE
10985 p380 = esbolton*rdorv/(pres(mgs) - es(mgs))
10986 ENDIF
10987
10988! taus = Max( 0.05*dtp, Min(taus, 0.25*dtp ) )
10989! nc = NInt(dtp/Min(1.0,0.5*taus))
10990! dtcon = dtp/float(nc)
10991 ss1 = qx(mgs,lv)/qvs(mgs)
10992 ss2 = ss1
10993 temp2 = temp1
10994 qv1 = qx(mgs,lv)
10995 qvs1 = qvs(mgs)
10996 qis1 = qis(mgs)
10997 dt1 = 0.0
10998
10999
11000! dtcon = Max(dtcon,0.2)
11001! nc = Nint(dtp/dtcon)
11002
11003 ltemq1 = ltemq
11004! want to start out with a small time step to handle the steep slope
11005! and fast changes, then can switch to a larger step (dtcon2) for the
11006! rest of the big time step.
11007! base the initial time step (dtcon1) on the slope (delta)
11008 IF ( abs(ss1 - 1.0) .gt. 1.e-5 ) THEN
11009 delta = 0.5*(qv1-qvs1)/(d1*(ss1 - 1.0))
11010 ELSE
11011 delta = 0.1*dtp
11012 ENDIF
11013! delta is the extrapolated time to get halfway from qv1 to qvs1
11014! want at least 5 time steps to the halfway point, so multiply by 0.2
11015! for the initial time step
11016 dtcon1 = min(0.05,0.2*delta)
11017 nc = max(5,2*nint( (dtp-4.0*dtcon1)/delta))
11018 dtcon2 = (dtp-4.0*dtcon1)/nc
11019
11020 n = 1
11021 dt1 = 0.0
11022 nc = 0
11023 dqc = 0.0
11024 dqr = 0.0
11025 dqi = 0.0
11026 dqs = 0.0
11027 dqvii = 0.0
11028 dqvis = 0.0
11029
11030 rk2c: DO WHILE ( dt1 .lt. dtp )
11031 nc = 0
11032 IF ( n .le. 4 ) THEN
11033 dtcon = dtcon1
11034 ELSE
11035 dtcon = dtcon2
11036 ENDIF
11037 609 dqv = -(ss1 - 1.)*d1*dtcon
11038 dqvr = -(ss1 - 1.)*d1r*dtcon
11039 dtemp = -0.5*e1*f1*(dqv + dqvr)
11040! write(0,*) 'RK2c dqv1 = ',dqv
11041! calculate midpoint values:
11042 ! ltemq1m = ltemq1 + Nint(dtemp*fqsat + 0.5)
11043
11044 ! 7.6.2016: Test full calc of ltemq
11045 ltemq1m = (temp1+dtemp-163.15)*fqsati+1.5
11046 ltemq1m = min( nqsat, max(1,ltemq1m) )
11047
11048 IF ( ltemq1m .lt. 1 .or. ltemq1m .gt. nqsat ) THEN
11049 write(0,*) 'STOP in nucond line 1192 '
11050 write(0,*) ' ltemq1m,icond = ',ltemq1m,icond
11051 write(0,*) ' dtemp,e1,f1,dqv,dqvr = ', dtemp,e1,f1,dqv,dqvr
11052 write(0,*) ' d1,d1r,dtcon,ss1 = ',d1,d1r,dtcon,ss1
11053 write(0,*) ' dqc, dqr = ',dqc,dqr
11054 write(0,*) ' qv,qc,qr = ',qx(mgs,lv)*1000.,qx(mgs,lc)*1000.,qx(mgs,lr)*1000.
11055 write(0,*) ' i, j, k = ',igs(mgs),jy,kgs(mgs)
11056 write(0,*) ' dtcon1,dtcon2,delta = ',dtcon1,dtcon2,delta
11057 write(0,*) ' nc,dtp = ',nc,dtp
11058 write(0,*) ' rwvent,xdia,crw,ccw = ', rwvent(mgs),xdia(mgs,lr,1),cx(mgs,lr),cx(mgs,lc)
11059 write(0,*) ' fvent,alphar = ',fvent(mgs),alpha(mgs,lr)
11060 write(0,*) ' xvr,xmasr,xdnr,cwc1 = ',xv(mgs,lr),xmas(mgs,lr),xdn(mgs,lr),cwc1
11061 ENDIF
11062 dqvs = dtemp*p380*dtabqvs(ltemq1m)
11063 qv1m = qv1 + dqv + dqvr
11064! qv1mr = qv1r + dqvr
11065
11066 qvs1m = qvs1 + dqvs
11067 ss1m = qv1m/qvs1m
11068
11069 ! check for undersaturation when no ice is present, if so, then reduce time step
11070 IF ( ss1m .lt. 1. .and. (dqvii + dqvis) .eq. 0.0 ) THEN
11071 dtcon = (0.5*dtcon)
11072 IF ( dtcon .ge. dtcon1 ) THEN
11073 GOTO 609
11074 ELSE
11075 EXIT
11076 ENDIF
11077 ENDIF
11078! calculate full step:
11079 dqv = -(ss1m - 1.)*d1*dtcon
11080 dqvr = -(ss1m - 1.)*d1r*dtcon
11081
11082
11083! write(0,*) 'RK2a dqv1m = ',dqv
11084 dtemp = -e1*f1*(dqv + dqvr)
11085
11086 ! ltemq1 = ltemq1 + Nint(dtemp*fqsat + 0.5)
11087
11088 ! 7.6.2016: Test full calc of ltemq
11089 ltemq1 = (temp1+dtemp-163.15)*fqsati+1.5
11090 ltemq1 = min( nqsat, max(1,ltemq1) )
11091
11092 IF ( ltemq1 .lt. 1 .or. ltemq1 .gt. nqsat ) THEN
11093 write(0,*) 'STOP in nucond line 1230 '
11094 write(0,*) ' ltemq1m,icond = ',ltemq1m,icond
11095 write(0,*) ' dtemp,e1,dqv,dqvr = ', dtemp,e1,dqv,dqvr
11096 ENDIF
11097 dqvs = dtemp*p380*dtabqvs(ltemq1)
11098
11099 qv1 = qv1 + dqv + dqvr
11100
11101 dqc = dqc - dqv
11102 dqr = dqr - dqvr
11103
11104 qvs1 = qvs1 + dqvs
11105 ss1 = qv1/qvs1
11106 temp1 = temp1 + dtemp
11107 IF ( temp2 .eq. temp1 .or. ss2 .eq. ss1 .or. &
11108 & ss1 .eq. 1.00 .or. &
11109 & ( n .gt. 10 .and. ss1 .lt. 1.0005 ) ) THEN
11110! write(0,*) 'RK2c break'
11111 EXIT
11112 ELSE
11113 ss2 = ss1
11114 temp2 = temp1
11115 dt1 = dt1 + dtcon
11116 n = n + 1
11117 ENDIF
11118 ENDDO rk2c
11119
11120
11121 dcloud = dqc ! qx(mgs,lv) - qv1
11122 thetap(mgs) = thetap(mgs) + e1*(dcloud + dqr)
11123
11124
11125 IF ( eqtset > 2 ) THEN
11126 pipert(mgs) = pipert(mgs) + felvpi(mgs)*(dcloud + dqr)
11127 ENDIF
11128 IF ( io_flag .and. nxtra > 1 ) THEN
11129 axtra(igs(mgs),jy,kgs(mgs),1) = dcloud/dtp
11130 axtra(igs(mgs),jy,kgs(mgs),2) = axtra(igs(mgs),jy,kgs(mgs),2) + dqr/dtp
11131 ENDIF
11132 qwvp(mgs) = qwvp(mgs) - (dcloud + dqr)
11133 qx(mgs,lc) = qx(mgs,lc) + dcloud
11134 qx(mgs,lr) = qx(mgs,lr) + dqr
11135! t9(igs(mgs),jy,kgs(mgs)) = t9(igs(mgs),jy,kgs(mgs)) + (DCLOUD + dqr)/dtp*felv(mgs)/(cp*pi0(mgs)) !* &
11136!! & dx*dy*dz3d(igs(mgs),jy,kgs(mgs))
11137
11138
11139 IF ( lzr > 1 .and. rcond == 2 .and. qx(mgs,lr) .gt. qxmin(lr) &
11140 & .and. cx(mgs,lr) .gt. 1.e-9 ) THEN
11141 tmp = qx(mgs,lr)/cx(mgs,lr)
11142 IF ( imurain == 3 ) THEN
11143 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
11144 ELSE
11145 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
11146 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
11147
11148 ENDIF
11149 zx(mgs,lr) = zx(mgs,lr) + g1*(rho0(mgs)/(xdn(mgs,lr)))**2*( 2.*( tmp ) * dqr )
11150 ENDIF
11151
11152 theta(mgs) = thetap(mgs) + theta0(mgs)
11153 temg(mgs) = theta(mgs)*f1
11154 ltemq = (temg(mgs)-163.15)/fqsat+1.5
11155 ltemq = min( nqsat, max(1,ltemq) )
11156 IF ( iqvsopt == 0 ) THEN
11157 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
11158 ELSEIF ( iqvsopt == 1 ) THEN
11159 qvs(mgs) = rdorv*esbolton*tabqvs(ltemq)/(pres(mgs) - esbolton*tabqvs(ltemq))
11160 ENDIF
11161! es(mgs) = 6.1078e2*tabqvs(ltemq)
11162
11163!
11164
11165 ENDIF ! dcloud .gt. 0.
11166
11167
11168 ELSE ! qc .le. qxmin(lc)
11169
11170! IF ( ssf(mgs) .gt. 0.0 .and. .not. flag_qndrop ) THEN ! flag_qndrop turns off primary nucleation when using wrf-chem with progn=1
11171 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
11172
11173 IF ( iqcinit == 1 ) THEN
11174
11175 qvs0 = 380.*exp(17.27*(temg(mgs)-273.)/(temg(mgs)- 36.))/pk(mgs)
11176
11177 dcloud = max(0.0, (qx(mgs,lv)-qvs0) / (1.+qvs0*f5/(temg(mgs)-36.)**2) )
11178
11179 ELSEIF ( iqcinit == 3 ) THEN
11180 r1=1./(1. + caw*(273.15 - cbw)*qss(mgs)*felvcp(mgs)/ &
11181 & ((temg(mgs) - cbw)**2))
11182 dcloud=r1*(qvap(mgs) - qvs(mgs)) ! KW model adjustment;
11183 ! this will put mass into qc if qv > sqsat exists
11184
11185 ELSEIF ( iqcinit == 2 ) THEN
11186! R1=1./(1. + caw*(273.15 - cbw)*qss(mgs)*felv(mgs)/
11187! : (cp*(temg(mgs) - cbw)**2))
11188! DCLOUD=R1*(qvap(mgs) - qvs(mgs)) ! KW model adjustment;
11189 ! this will put mass into qc if qv > sqsat exists
11190 ssmx = ssmxinit
11191
11192! IF ( ssf(mgs) > ssmx .and. ssmax(mgs) < 3.0 ) THEN
11193! IF ( ssf(mgs) > ssmx .and. ccnc(mgs) > 1.0 ) THEN
11194! IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 5.0 .and. ccnc(mgs) > 0.1*cwnccn(mgs) ) THEN ! this one works
11195! IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 20.0 ) THEN ! test -- fails
11196! IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 20.0 .and. ccnc(mgs) > 0.1*cwnccn(mgs)) THEN ! test -- is OK
11197 IF ( ssf(mgs) > ssmx .and. ssf(mgs) < 20.0 .and. &
11198 ( ccnc(mgs) > 0.05*cwnccn(mgs) .or. ( ac_opt > 0 .and. ccnc(mgs) - cx(mgs,lc) > 0.0 ) ) ) THEN ! test
11199! IF ( ssf(mgs) > ssmx ) THEN ! original condition
11200 CALL qvexcess(ngs,mgs,qwvp,qv0,qx(1,lc),pres,thetap,theta0,dcloud, &
11201 & pi0,tabqvs,nqsat,fqsat,cbw,fcqv1,felvcp,ssmx,pk,ngscnt)
11202 ELSE
11203 dcloud = 0.0
11204 ENDIF
11205 ENDIF
11206 ELSE
11207 dcloud = 0.0
11208 ENDIF
11209
11210 thetap(mgs) = thetap(mgs) + felvcp(mgs)*dcloud/(pi0(mgs))
11211 qwvp(mgs) = qwvp(mgs) - dcloud
11212 qx(mgs,lc) = qx(mgs,lc) + dcloud
11213 IF ( io_flag .and. nxtra > 1 ) THEN
11214 axtra(igs(mgs),jy,kgs(mgs),1) = dcloud/dtp
11215 ENDIF
11216 theta(mgs) = thetap(mgs) + theta0(mgs)
11217 temg(mgs) = theta(mgs)*pk(mgs) !( pres(mgs) / poo ) ** cap
11218! temg(mgs) = theta2temp( theta(mgs), pres(mgs) )
11219 ltemq = (temg(mgs)-163.15)/fqsat+1.5
11220 ltemq = min( nqsat, max(1,ltemq) )
11221 ! qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
11222 IF ( iqvsopt == 0 ) THEN
11223 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
11224 ELSEIF ( iqvsopt == 1 ) THEN
11225 qvs(mgs) = rdorv*esbolton*tabqvs(ltemq)/(pres(mgs) - esbolton*tabqvs(ltemq))
11226 ENDIF
11227! es(mgs) = 6.1078e2*tabqvs(ltemq)
11228
11229!.... S. TWOMEY (1959)
11230! Note: get here if there is no previous cloud water and w > 0.
11231 cn(mgs) = 0.0
11232
11233 IF ( ncdebug .ge. 1 ) THEN
11234 write(iunit,*) 'at 613: ',qx(mgs,lc),cx(mgs,lc),wvel(mgs),ssmax(mgs),kgs(mgs)
11235 ENDIF
11236
11237 IF ( .not. flag_qndrop ) THEN ! { do not calculate number of droplets if using wrf-chem
11238
11239 ! IF ( ac_opt == 0 ) THEN
11240 cnuctmp = cnuc(mgs)
11241 ! ELSE
11242 ! cnuctmp = ccnc(mgs)
11243 ! ENDIF
11244
11245! IF ( ssmax(mgs) .lt. sscb .and. qx(mgs,lc) .gt. qxmin(lc)) THEN
11246 IF ( dcloud .gt. qxmin(lc) .and. wvel(mgs) > 0.0) THEN
11247! CN(mgs) = CCNE*wvel(mgs)**cnexp ! *Min(1.0,1./dtp) ! 0.3465
11248 cn(mgs) = ccne0*cnuctmp**(2./(2.+cck))*wvel(mgs)**cnexp ! *Min(1.0,1./dtp) ! 0.3465
11249 IF ( ny .le. 2 .and. cn(mgs) .gt. 0.0 &
11250 & .and. ncdebug .ge. 1 ) THEN
11251 write(iunit,*) 'CN: ',cn(mgs)*1.e-6, cx(mgs,lc)*1.e-6, qx(mgs,lc)*1.e3, &
11252 & wvel(mgs), dcloud*1.e3
11253 IF ( cn(mgs) .gt. 1.0 ) write(iunit,*) 'cwrad = ', &
11254 & 1.e6*(rho0(mgs)*qx(mgs,lc)/cn(mgs)*cwc1)**c1f3, &
11255 & igs(mgs),kgs(mgs),temcg(mgs), &
11256 & 1.e3*an(igs(mgs),jgs,kgs(mgs)-1,lc)
11257 ENDIF
11258 IF ( iccwflg .eq. 1 ) THEN
11259 cn(mgs) = min(cwccn*rho0(mgs)/rho00, max(cn(mgs), &
11260 & rho0(mgs)*qx(mgs,lc)/(xdn(mgs,lc)*(4.*pi/3.)*(4.e-6)**3)))
11261 ENDIF
11262 ELSE
11263 cn(mgs) = 0.0
11264 dcloud = 0.0
11265! cn(mgs) = Min(cwccn, &
11266! & rho0(mgs)*dcloud/(xdn(mgs,lc)*(4.*pi/3.)*(4.e-6)**3) )
11267 ENDIF
11268
11269 IF ( cn(mgs) .gt. 0.0 ) THEN
11270 IF ( ac_opt == 0 ) THEN
11271 IF ( cn(mgs) .gt. ccnc(mgs) ) THEN
11272 cn(mgs) = ccnc(mgs)
11273! ccnc(mgs) = 0.0
11274 ENDIF
11275 ELSE
11276 cn(mgs) = min( cn(mgs), ccnc(mgs) )
11277 ENDIF
11278! cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11279 IF ( irenuc <= 2 .and. lccna < 1 ) ccnc(mgs) = max(0.0, ccnc(mgs) - cn(mgs))
11280 ccna(mgs) = ccna(mgs) + cn(mgs)
11281 ENDIF
11282
11283! write(91,*) 'nuc1: cn, ix, kz = ',cn(mgs),igs(mgs),kgs(mgs),wvel(mgs),cnexp,ccnc(mgs)
11284
11285 IF( cn(mgs) .GT. cx(mgs,lc) ) cx(mgs,lc) = cn(mgs)
11286 IF( cx(mgs,lc) .GT. 0. .AND. qx(mgs,lc) .le. qxmin(lc) ) THEN
11287 cx(mgs,lc) = 0.
11288 ELSE
11289 cx(mgs,lc) = min(cx(mgs,lc),rho0(mgs)*max(0.0,qx(mgs,lc))/cwmasn)
11290 ENDIF
11291
11292 ENDIF ! }.not. flag_qndrop
11293
11294 GOTO 613
11295
11296 END IF ! qc .gt. 0.
11297
11298! ES=EES(PIB(K)*PT)
11299! SQSAT=EPSI*ES/(PB(K)*1000.-ES)
11300
11301!.... CLOUD NUCLEATION
11302! T=PIB(K)*PT
11303! ES=1.E3*PB(K)*QV/EPSI
11304
11305 IF ( wvel(mgs) .le. 0. ) GO TO 616
11306 IF ( cx(mgs,lc) .le. 0. ) GO TO 613 !TWOMEY (1959) Nucleation
11307 IF ( kzbeg-1+kgs(mgs) .GT. 1 .and. qx(mgs,lc) .le. qxmin(lc)) GO TO 613 !TWOMEY (1959) Nucleation
11308 IF ( kzbeg-1+kgs(mgs) .eq. 1 .and. wvel(mgs) .gt. 0. ) GO TO 613 !TWOMEY (1959) Nucleation
11309!.... ATTEMPT ZIEGLER CLOUD NUCLEATION IN CLOUD INTERIOR UNLESS...
11310 616 IF ( ssf(mgs) .LE. supcb .AND. wvel(mgs) .GT. 0. ) GO TO 631 !... weakly saturated updraft
11311 IF ( kzbeg-1+kgs(mgs) .GT. 1 .AND. kzbeg-1+kgs(mgs) .LT. nzend-1 .AND. &
11312 & (ssfkp1(mgs) .GE. supmx .OR. &
11313 & ssf(mgs) .GE. supmx .OR. &
11314 & ssfkm1(mgs) .GE. supmx)) GO TO 631 !... too much vapour
11315 IF (ssf(mgs) .LT. 1.e-10 .OR. ssf(mgs) .GE. supmx) GO TO 631 !... at the extremes for ss
11316
11317!
11318! get here if ( qc > 0 and ss > supcb) or (w < 0)
11319!
11320
11321 if (ndebug .gt. 0) write(0,*) "ICEZVD_DR: Entered Ziegler Cloud Nucleation" !mpidebug
11322
11323 dssdz=0.
11324 r2dzm=0.50/dz3d(igs(mgs),jy,kgs(mgs))
11325
11326 IF ( irenuc >= 0 .and. ac_opt == 0 .and. .not. flag_qndrop ) THEN ! turn off nucleation when flag_qndrop (using WRF-CHEM for activation)
11327
11328 IF ( irenuc < 2 ) THEN !{
11329
11330 IF ( kzend == nzend ) THEN
11331 t0p3 = t0(igs(mgs),jgs,min(kze,kgs(mgs)+3))
11332 t0p1 = t0(igs(mgs),jgs,min(kze,kgs(mgs)+1))
11333 ELSE
11334 t0p3 = t0(igs(mgs),jgs,kgs(mgs)+3)
11335 t0p1 = t0(igs(mgs),jgs,kgs(mgs)+1)
11336 ENDIF
11337
11338 IF ( ( ssf(mgs) .gt. ssmax(mgs) .or. irenuc .eq. 1 ) &
11339 & .and. ( ( lccn .lt. 1 .and. &
11340 & cx(mgs,lc) .lt. cwccn*(min(1.0,rho0(mgs)))) .or. &
11341 & ( lccn .gt. 1 .and. ccnc(mgs) .gt. 0. ) ) &
11342 & ) THEN
11343 IF( kzbeg-1+kgs(mgs) .GT. 1 .AND. kzbeg-1+kgs(mgs) .LT. nzend-1 &
11344 & .and. ssf(mgs) .gt. 0.0 &
11345 & .and. ssfkp1(mgs) .LT. supmx .and. ssfkp1(mgs) .ge. 0.0 &
11346 & .AND. ssfkm1(mgs) .LT. supmx .AND. ssfkm1(mgs) .ge. 0.0 &
11347 & .AND. ssfkp1(mgs) .gt. ssfkm1(mgs) &
11348 & .and. t0p3 .gt. 233.2) THEN
11349 dssdz = (ssfkp1(mgs) - ssfkm1(mgs))*r2dzm
11350!
11351! otherwise check for cloud base condition with updraft:
11352!
11353 ELSEIF( kzbeg-1+kgs(mgs) .GT. 1 .AND. kzbeg-1+kgs(mgs) .LT. nzend-1 &
11354! IF( kgs(mgs) .GT. 1 .AND. kgs(mgs) .LT. NZ-1 & !)
11355 & .and. ssf(mgs) .gt. 0.0 .and. wvel(mgs) .gt. 0.0 &
11356 & .and. ssfkp1(mgs) .gt. 0.0 &
11357 & .AND. ssfkm1(mgs) .le. 0.0 .and. wvelkm1(mgs) .gt. 0.0 &
11358 & .AND. ssf(mgs) .gt. ssfkm1(mgs) &
11359 & .and. t0p1 .gt. 233.2) THEN
11360 dssdz = 2.*(ssf(mgs) - ssfkm1(mgs))*r2dzm ! 1-sided difference
11361 ENDIF
11362
11363 ENDIF
11364!
11365!CLZ IF(wijk.LE.0.) CN=CCN*ssfilt(ix,jy,kz)**CCK
11366! note: CCN -> cwccn, DELT -> dtp
11367 c1 = max(0.0, rho0(mgs)*(qx(mgs,lv) - qss(mgs))/ &
11368 & (xdn(mgs,lc)*(4.*pi/3.)*(4.e-6)**3))
11369 IF ( lccn .lt. 1 ) THEN
11370 cn(mgs) = cwccn*rho0(mgs)/rho00*cck*ssf(mgs)**cckm*dtp* &
11371 & max(0.0, &
11372 & (wvel(mgs)*dssdz) ) ! probably the vertical gradient dominates
11373 ELSE
11374 cn(mgs) = &
11375 & min(ccnc(mgs), cnuc(mgs)*cck*ssf(mgs)**cckm*dtp* &
11376 & max(0.0, &
11377 & ( wvel(mgs)*dssdz) ) )
11378! IF ( cn(mgs) .gt. 0 ) ccnc(mgs) = ccnc(mgs) - cn(mgs)
11379 ENDIF
11380
11381 IF ( cn(mgs) .gt. 0.0 ) THEN
11382 IF ( ccnc(mgs) .lt. 5.e7 .and. cn(mgs) .ge. 5.e7 ) THEN
11383 cn(mgs) = 5.e7
11384 ccnc(mgs) = 0.0
11385 ELSEIF ( cn(mgs) .gt. ccnc(mgs) ) THEN
11386 cn(mgs) = ccnc(mgs)
11387 ccnc(mgs) = 0.0
11388 ENDIF
11389 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11390 ccnc(mgs) = max(0.0, ccnc(mgs) - cn(mgs))
11391 ENDIF
11392
11393 ELSEIF ( irenuc == 2 ) THEN !} {
11394 ! simple Twomey scheme
11395! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11396 cn(mgs) = ccne0*cnuc(mgs)**(2./(2.+cck))*max(0.0,wvel(mgs))**cnexp ! *Min(1.0,1./dtp) ! 0.3465
11397! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
11398!!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11399 ! Philips, Donner et al. 2007, but results in too much limitation of
11400 ! nucleation
11401 cn(mgs) = min(cn(mgs), ccnc(mgs))
11402 cn(mgs) = min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11403 cn(mgs) = min( cn(mgs), max(0.0, (cnuc(mgs) - ccna(mgs) )) )
11404
11405 IF ( .false. .and. ny <= 2 ) THEN
11406 write(0,*) 'i,k, cwmasn = ',igs(mgs),kgs(mgs),cwmasn
11407 write(0,*) 'wvel, cnuc, cn = ',wvel(mgs),cnuc(mgs),cn(mgs)
11408 write(0,*) 'ccne0,cnexp,cck = ',ccne0,cnexp,cck
11409 write(0,*) 'part1, part2 = ',ccne0*cnuc(mgs)**(2./(2.+cck)), max(0.0,wvel(mgs))**cnexp
11410 write(0,*) 'ccnc, dqc, dqc/cwmasn = ',ccnc(mgs), dqc, 0.5*dqc/cwmasn
11411 ENDIF
11412
11413 IF ( icnuclimit > 0 ) THEN
11414 tmp = ccnc(mgs) + cx(mgs,lc)
11415 IF ( tmp < 330.34e6 ) THEN
11416 ccwmax = 1.1173e6 * (1.e-6*tmp)**0.9504
11417 ELSE
11418 ccwmax = 21.57e6 * (1.e-6*tmp)**0.44
11419 ENDIF
11420
11421! IF ( cn(mgs) > 0. ) THEN
11422! write(0,*) 'cn,tmp,ccwmax,cx,c-cx = ',cn(mgs),tmp,ccwmax,cx(mgs,lc),ccwmax - cx(mgs,lc)
11423! ENDIF
11424
11425 cn(mgs) = max( 0.0, min( cn(mgs), ccwmax - cx(mgs,lc) ) )
11426
11427 ENDIF
11428
11429 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11430
11431 IF ( lccna < 1 ) ccnc(mgs) = max(0.0, ccnc(mgs) - cn(mgs))
11432
11433 ELSEIF ( irenuc == 3 ) THEN !} {
11434 ! Phillips Donner Garner 2007
11435! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11436! CN(mgs) = cwccn*Min(ssf(mgs),ssfcut)**cck
11437
11438! Need to calculate new ssf since condensation has happened:
11439 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11440 ltemq = int( (temp1-163.15)/fqsat+1.5 )
11441 ltemq = min( nqsat, max(1,ltemq) )
11442
11443 c1= pqs(mgs)*tabqvs(ltemq)
11444
11445 ssf(mgs) = 0.0
11446 IF ( c1 > 0. ) THEN
11447 ssf(mgs) = 100.*(qx(mgs,lv)/c1 - 1.0) ! from "new" values
11448 ENDIF
11449 cn(mgs) = cnuc(mgs)*min(1.0, (ssf(mgs))**cck ) !
11450
11451 cn(mgs) = max( 0.0, cn(mgs) - ccna(mgs) ) ! this was from
11452 ! Philips, Donner et al. 2007, but results in too much limitation of
11453 ! nucleation
11454 cn(mgs) = min(cn(mgs), ccnc(mgs))
11455 cn(mgs) = min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11456
11457 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11458
11459 ! 6/13/2016: Phillips et al. appears not to decrement CCN, but only increments CCNa.
11460 ! This would allow an initially non-homogeneous (vertically, e.g.) initial value of CCN/rho_air
11461 ccnc(mgs) = max(0.0, ccnc(mgs) - cn(mgs))
11462
11463 ELSEIF ( irenuc == 4 ) THEN !} {
11464 ! modification of Phillips Donner Garner 2007
11465! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11466! CN(mgs) = CCNE0*cnuc(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp
11467! cn(mgs) = Min( cn(mgs), cnuc(mgs) )
11468! Need to calculate new ssf since condensation has happened:
11469 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11470 ltemq = int( (temp1-163.15)/fqsat+1.5 )
11471 ltemq = min( nqsat, max(1,ltemq) )
11472
11473 c1= pqs(mgs)*tabqvs(ltemq)
11474 IF ( c1 > 0. ) THEN
11475 ssf(mgs) = max(0.0, 100.*((qv0(mgs) + qwvp(mgs))/c1 - 1.0) ) ! from "new" values
11476 ELSE
11477 ssf(mgs) = 0.0
11478 ENDIF
11479 cn(mgs) = cnuc(mgs)*min(ssf2kmax, ssf(mgs)**cck) ! this allows cn(mgs) > cnuc(mgs)
11480
11481 cn(mgs) = max( 0.0, cn(mgs) - ccna(mgs) ) ! this was from
11482 ! Philips, Donner et al. 2007, but results in too much limitation of
11483 ! nucleation
11484! CN(mgs) = Min(cn(mgs), ccnc(mgs))
11485 cn(mgs) = min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11486
11487 IF ( cn(mgs) > 0.0 ) THEN
11488 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11489 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11490
11491 dcrit = 2.0*2.5e-7
11492
11493 dcloud = 1000.*dcrit**3*pi/6.*cn(mgs)
11494 qx(mgs,lc) = qx(mgs,lc) + dcloud
11495 thetap(mgs) = thetap(mgs) + felvcp(mgs)*dcloud/(pi0(mgs))
11496 qwvp(mgs) = qwvp(mgs) - dcloud
11497 ENDIF
11498 ! 6/13/2016: Phillips et al. appears not to decrement CCN, but only increments CCNa.
11499 ! This would allow an initially non-homogeneous (vertically, e.g.) initial value of CCN/rho_air
11500! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11501
11502
11503
11504 ELSEIF ( irenuc == 6 ) THEN !} {
11505
11506 ! simple Twomey scheme but limit activation to try to do most activation near cloud base, but keep some CCN available for renuclation
11507! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11508 cn(mgs) = 0.0
11509! 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
11510 IF ( ccna(mgs) < 0.7*cnuc(mgs) ) THEN ! here, assume we are near cloud base and use Twomey formulation
11511 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
11512! IF ( cn(mgs) + ccna(mgs) > 0.71*cnuc ) THEN
11513 ! prevent this branch from activating more than 70% of CCN
11514 cn(mgs) = min( cn(mgs), max(0.0, (0.7*cnuc(mgs) - ccna(mgs) )) )
11515! CN(mgs) = Min( CN(mgs), Max(0.0, 0.71*ccnc(mgs) - ccna(mgs) ) )
11516
11517 ELSE
11518 ! 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.
11519
11520 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11521! t0(ix,jy,kz) = temp1
11522 ltemq = int( (temp1-163.15)/fqsat+1.5 )
11523 ltemq = min( nqsat, max(1,ltemq) )
11524
11525! c1 = t00(igs(mgs),jy,kgs(mgs))*tabqvs(ltemq)
11526 c1= pqs(mgs)*tabqvs(ltemq)
11527 IF ( c1 > 0. ) THEN
11528 ssf(mgs) = max(0.0, 100.*((qv0(mgs) + qwvp(mgs))/c1 - 1.0) ) ! from "new" values
11529 ELSE
11530 ssf(mgs) = 0.0
11531 ENDIF
11532
11533! CN(mgs) = cnuc(mgs)*Min(0.99, Min(ssf(mgs),ssfcut)**cck ) !
11534 cn(mgs) = cnuc(mgs)*min(2.0, max(0.0,ssf(mgs))**cck ) !
11535! CN(mgs) = cnuc(mgs)*Min(ssf(mgs),ssfcut)**cck !
11536
11537
11538 cn(mgs) = min(0.01*cnuc(mgs), max( 0.0, cn(mgs) - ccna(mgs) ) ) ! this was from
11539! cn(mgs) = 0.0
11540 ENDIF
11541! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
11542!!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11543 ! Philips, Donner et al. 2007, but results in too much limitation of
11544 ! nucleation
11545! CN(mgs) = Min(cn(mgs), ccnc(mgs))
11546! cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11547
11548 IF ( cn(mgs) > 0.0 ) THEN
11549 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11550
11551 ! create some small droplets at minimum size (CP 2000), although it adds very little liquid
11552
11553 dcrit = 2.0*2.5e-7
11554
11555 dcloud = 1000.*dcrit**3*pi/6.*cn(mgs)
11556 qx(mgs,lc) = qx(mgs,lc) + dcloud
11557 thetap(mgs) = thetap(mgs) + felvcp(mgs)*dcloud/(pi0(mgs))
11558 qwvp(mgs) = qwvp(mgs) - dcloud
11559 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11560 ENDIF
11561 ELSEIF ( irenuc == 5 ) THEN !} {
11562
11563 ! modification of Phillips Donner Garner 2007
11564! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11565! 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
11566 cn(mgs) = min( cnuc(mgs), ccne0*cnuc(mgs)**(2./(2.+cck))*max(0.0,wvel(mgs))**cnexp )
11567
11568
11569 IF ( ccna(mgs) >= cnuc(mgs) ) THEN ! apply limit after all "base" CCN have been depleted
11570 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11571 ltemq = int( (temp1-163.15)/fqsat+1.5 )
11572 ltemq = min( nqsat, max(1,ltemq) )
11573
11574 IF ( iqvsopt == 0 ) THEN
11575 c1 = pqs(mgs)*tabqvs(ltemq)
11576 ELSEIF ( iqvsopt == 1 ) THEN
11577 c1 = rdorv*esbolton*tabqvs(ltemq)/(pres(mgs) - esbolton*tabqvs(ltemq))
11578 ENDIF
11579 IF ( c1 > 0. ) THEN
11580 ssf(mgs) = max(0.0, 100.*((qv0(mgs) + qwvp(mgs))/c1 - 1.0) ) ! from "new" values
11581 ELSE
11582 ssf(mgs) = 0.0
11583 ENDIF
11584
11585
11586 cn(mgs) = max( cn(mgs), cnuc(mgs)*min(ssf2kmax, ssf(mgs)**cck) ) ! this allows cn(mgs) > cnuc(mgs)
11587
11588 ! cn(mgs) = Min( cn(mgs), cnuc(mgs) )
11589
11590! IF ( ccna(mgs) >= cnuc(mgs) ) THEN ! apply limit after all "base" CCN have been depleted
11591 cn(mgs) = max( 0.0, cn(mgs) - ccna(mgs) ) ! this was from
11592
11593 ELSE
11594 cn(mgs) = min( cn(mgs), cnuc(mgs) - ccna(mgs) ) ! no more than remaining "base" CCN
11595 ENDIF
11596 ! Philips, Donner et al. 2007, but results in too much limitation of
11597 ! nucleation
11598! CN(mgs) = Min(cn(mgs), ccnc(mgs))
11599! cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11600 dcrit = 2.0*2.0e-6
11601 dcloud = 1000.*dcrit**3*pi/6.
11602 ! cn(mgs) = Min(cn(mgs), 0.5*dqc/dcloud) ! limit the nucleation mass to half of the condensation mass
11603 ! check new droplet size:
11604 ! tmp is number of droplets at diameter dcrit
11605 tmp = max(0.0, rho0(mgs)*qx(mgs,lc)/dcloud - cx(mgs,lc)) ! (cx(mgs,lc) + cn(mgs))
11606 cn(mgs) = min(tmp, cn(mgs) )
11607
11608
11609 IF ( cn(mgs) > 0.0 ) THEN
11610 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11611
11612 dcrit = 2.5e-7
11613
11614 dcloud = 1000.*dcrit**3*pi/6.*cn(mgs)
11615 qx(mgs,lc) = qx(mgs,lc) + dcloud
11616 thetap(mgs) = thetap(mgs) + felvcp(mgs)*dcloud/(pi0(mgs))
11617 qwvp(mgs) = qwvp(mgs) - dcloud
11618 ENDIF
11619 ! 6/13/2016: Phillips et al. appears not to decrement CCN, but only increments CCNa.
11620 ! This would allow an initially non-homogeneous (vertically, e.g.) initial value of CCN/rho_air
11621 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11622 ELSEIF ( irenuc == 7 .or. irenuc == 17 ) THEN !} {
11623
11624 ! simple Twomey scheme but limit activation to try to do most activation near cloud base, but keep some CCN available for renuclation
11625! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11626 cn(mgs) = 0.0
11627 IF ( irenuc == 7 ) THEN
11628 frac = 0.9
11629 ELSE
11630 frac = 0.98
11631 ENDIF
11632! 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
11633 IF ( ccna(mgs) < frac*cnuc(mgs) ) THEN ! { here, assume we are near cloud base and use Twomey formulation
11634 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
11635! IF ( cn(mgs) + ccna(mgs) > 0.71*cnuc ) THEN
11636 ! prevent this branch from activating more than 70% of CCN
11637 cn(mgs) = min( cn(mgs), max(0.0, (frac*cnuc(mgs) - ccna(mgs) )) )
11638! CN(mgs) = Min( CN(mgs), Max(0.0, 0.71*ccnc(mgs) - ccna(mgs) ) )
11639 ! write(0,*) '1: k,cn = ',kgs(mgs),cn(mgs),ssf(mgs)
11640!! IF ( ccncuf(mgs) > 0.0 .and. cn(mgs) < 1.e-3 .and. ssmax(mgs) > 1.0 ) THEN
11641! IF ( ccncuf(mgs) > 0.0 .and. ssf(mgs) > ssmxuf .and. ssmax(mgs) > ssmxuf ) THEN
11642! CNuf(mgs) = Min( ccncuf(mgs), CCNE0*ccncuf(mgs)**(2./(2.+cck))*Max(0.0,wvel(mgs))**cnexp )! *Min(1.0,1./dtp) ! 0.3465
11643 ! IF ( cnuf(mgs) >= 0.0 ) write(0,*) '1: cnuf, k = ',cnuf(mgs),ccncuf(mgs),kgs(mgs)
11644! ENDIF
11645
11646
11647 ELSE ! }{
11648 ! 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.
11649
11650 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11651! t0(ix,jy,kz) = temp1
11652 ltemq = int( (temp1-163.15)/fqsat+1.5 )
11653 ltemq = min( nqsat, max(1,ltemq) )
11654
11655 ! c1 = t00(igs(mgs),jy,kgs(mgs))*tabqvs(ltemq)
11656 IF ( iqvsopt == 0 ) THEN
11657 c1 = pqs(mgs)*tabqvs(ltemq)
11658 ELSEIF ( iqvsopt == 1 ) THEN
11659 c1 = rdorv*esbolton*tabqvs(ltemq)/(pres(mgs) - esbolton*tabqvs(ltemq))
11660 ENDIF
11661
11662 ssf(mgs) = 0.0
11663 IF ( c1 > 0. ) THEN
11664 ssf(mgs) = 100.*(qx(mgs,lv)/c1 - 1.0) ! from "new" values
11665 ENDIF
11666
11667! IF ( ssf(mgs) <= 1.0 .or. cnuc(mgs) > ccna(mgs) ) THEN
11668 IF ( ssf(mgs) <= 1.0 ) THEN
11669 cn(mgs) = cnuc(mgs)*min(1.0, max(0.0,ssf(mgs))**cck ) !
11670 ELSE
11671 cn(mgs) = cnuc(mgs)*min(2.0, max(0.0,0.03*(ssf(mgs)-1.0)+1.)**cck ) !
11672! write(0,*) 'iren7: ssf,ssmx = ',ssf(mgs),ssmax(mgs),cn(mgs),ccna(mgs),cnuc(mgs)
11673! write(0,*) 'c1,qv = ',c1,qx(mgs,lv),temp1,ltemq
11674 ENDIF
11675
11676 ! write(0,*) 'k,cn = ',kgs(mgs),cn(mgs),ssf(mgs)
11677 ! write(0,*) 'ccn-ccna = ',cnuc(mgs) - ccna(mgs),ccnc(mgs) - ccna(mgs)
11678! IF ( ccncuf(mgs) > 0.0 .and. cn(mgs) < 1.e-3 .and. ssmax(mgs) > 1.0 ) THEN
11679 IF ( ccncuf(mgs) > 0.0 .and. ssf(mgs) > ssmxuf .and. ( ssmax(mgs) > ssmxuf .or. lss < 1 ) ) THEN
11680 cnuf(mgs) = min( ccncuf(mgs), ccne0*ccncuf(mgs)**(2./(2.+cck))*max(0.0,wvel(mgs))**cnexp )! *Min(1.0,1./dtp) ! 0.3465
11681 ! IF ( cnuf(mgs) >= 0.0 ) write(0,*) 'cnuf, k = ',cnuf(mgs),ccncuf(mgs),kgs(mgs)
11682 ENDIF
11683
11684
11685! CN(mgs) = Min( Min(0.1,ssf(mgs)-1.)*cnuc(mgs), Max( 0.0, CN(mgs) - ccna(mgs) ) ) ! this was from
11686! 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
11687
11688 cn(mgs) = min(0.01*cnuc(mgs), max( 0.0, cn(mgs) - ccna(mgs) ) ) ! this was from
11689
11690 ENDIF ! }
11691! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
11692!!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11693 ! Philips, Donner et al. 2007, but results in too much limitation of
11694 ! nucleation
11695! CN(mgs) = Min(cn(mgs), ccnc(mgs))
11696! cn(mgs) = Min(cn(mgs), 0.5*dqc/cwmasn) ! limit the nucleation mass to half of the condensation mass
11697
11698
11699 IF ( icnuclimit > 0 ) THEN
11700! max droplet conc. based on Chandrakar et al. (2016) and Konwar et al. (2012)
11701 tmp = ccnc(mgs) - ccna(mgs) + cx(mgs,lc)
11702 IF ( tmp < 330.34e6 ) THEN
11703 ccwmax = 1.1173e6 * (1.e-6*tmp)**0.9504
11704 ELSE
11705 ccwmax = 21.57e6 * (1.e-6*tmp)**0.44
11706 ENDIF
11707
11708 cn(mgs) = max( 0.0, min( cn(mgs), ccwmax - cx(mgs,lc) ) )
11709
11710 ENDIF
11711
11712 IF ( cn(mgs) + cnuf(mgs) > 0.0 ) THEN
11713
11714 dcrit = 2.0*2.0e-6
11715 dcloud = 1000.*dcrit**3*pi/6.
11716 ! cn(mgs) = Min(cn(mgs), 0.5*dqc/dcloud) ! limit the nucleation mass to half of the condensation mass
11717 ! check new droplet size:
11718 ! tmp is number of droplets at diameter dcrit
11719 tmp = max(0.0, rho0(mgs)*qx(mgs,lc)/dcloud - cx(mgs,lc)) ! (cx(mgs,lc) + cn(mgs))
11720 cn(mgs) = min(tmp, cn(mgs) )
11721
11722 cx(mgs,lc) = cx(mgs,lc) + cn(mgs) + cnuf(mgs)
11723
11724
11725 ! create some small droplets at minimum size (CP 2000), although it adds very little liquid
11726
11727
11728 dcrit = 2.0*2.5e-7
11729 dcloud = 1000.*dcrit**3*pi/6.*(cn(mgs) + cnuf(mgs) )
11730 qx(mgs,lc) = qx(mgs,lc) + dcloud
11731 thetap(mgs) = thetap(mgs) + felvcp(mgs)*dcloud/(pi0(mgs))
11732 qwvp(mgs) = qwvp(mgs) - dcloud
11733 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11734 ccncuf(mgs) = max(0.0, ccncuf(mgs) - cnuf(mgs))
11735 ENDIF
11736
11737 ELSEIF ( irenuc == 8 ) THEN !} {
11738 ! simple Twomey scheme
11739! if (ndebug .gt. 0) write(0,*) 'ICEZVD_DR: Cloud reNucleation, wvel = ',wvel(mgs)
11740
11741 cn(mgs) = 0.0
11742
11743 IF ( ccnc(mgs) > 0. ) THEN
11744 cn(mgs) = ccne0*ccnc(mgs)**(2./(2.+cck))*max(0.0,wvel(mgs))**cnexp ! *Min(1.0,1./dtp) ! 0.3465
11745! ccne = ccnefac*1.e6*(1.e-6*Abs(cwccn))**(2./(2.+cck))
11746!!! CN(mgs) = Max( 0.0, CN(mgs) - ccna(mgs) ) ! this was from
11747 ! Philips, Donner et al. 2007, but results in too much limitation of
11748 ! nucleation
11749 cn(mgs) = min(cn(mgs), ccnc(mgs))
11750
11751 ELSEIF ( cx(mgs,lc) < 0.01e9 ) THEN
11752
11753 ! 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.
11754
11755 temp1 = (theta0(mgs)+thetap(mgs))*pk(mgs) ! t77(ix,jy,kz)
11756! t0(ix,jy,kz) = temp1
11757 ltemq = int( (temp1-163.15)/fqsat+1.5 )
11758 ltemq = min( nqsat, max(1,ltemq) )
11759
11760 ! c1 = t00(igs(mgs),jy,kgs(mgs))*tabqvs(ltemq)
11761 IF ( iqvsopt == 0 ) THEN
11762 c1 = pqs(mgs)*tabqvs(ltemq)
11763 ELSEIF ( iqvsopt == 1 ) THEN
11764 c1 = rdorv*esbolton*tabqvs(ltemq)/(pres(mgs) - esbolton*tabqvs(ltemq))
11765 ENDIF
11766
11767 ssf(mgs) = 0.0
11768 IF ( c1 > 0. ) THEN
11769 ssf(mgs) = 100.*(qx(mgs,lv)/c1 - 1.0) ! from "new" values
11770 ENDIF
11771
11772! IF ( ssf(mgs) <= 1.0 .or. cnuc(mgs) > ccna(mgs) ) THEN
11773 IF ( ssf(mgs) <= 1.0 ) THEN
11774 cn(mgs) = 0.0
11775 ELSE
11776! CN(mgs) = 0.01e9*rho0(mgs)/rho00*Min(2.0, Max(0.0,0.03*(ssf(mgs)-1.0)+1.)**cck ) - cx(mgs,lc) !
11777 cn(mgs) = 0.01e9*min(2.0, max(0.0,0.03*(ssf(mgs)-1.0)+1.)**cck ) - cx(mgs,lc) !
11778 ENDIF
11779
11780 ENDIF
11781
11782 IF ( cn(mgs) > 0.0 ) THEN
11783 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11784
11785 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11786
11787 ! create some small droplets at minimum size (CP 2000), although it adds very little liquid
11788
11789 dcrit = 2.0*2.5e-7
11790
11791 dcloud = 1000.*dcrit**3*pi/6.*cn(mgs)
11792 qx(mgs,lc) = qx(mgs,lc) + dcloud
11793 thetap(mgs) = thetap(mgs) + felvcp(mgs)*dcloud/(pi0(mgs))
11794 qwvp(mgs) = qwvp(mgs) - dcloud
11795 ! ccnc(mgs) = Max(0.0, ccnc(mgs) - cn(mgs))
11796 ENDIF
11797
11798
11799 ELSEIF ( irenuc == 9 .or. irenuc == 10 ) THEN ! } {
11800
11801 write(0,*) 'irenuc=9 requires nuwrfmods=1'
11802
11803
11804 ELSEIF ( irenuc == 11 ) THEN ! } {
11805
11806 write(0,*) 'irenuc=11 requires nuwrfmods=1'
11807 ENDIF ! }
11808
11809
11810 ccna(mgs) = ccna(mgs) + cn(mgs)
11811
11812
11813
11814 ENDIF ! irenuc >= 0 .and. .not. flag_qndrop
11815
11816 ! IF( cx(mgs,lc) .GT. 0. .AND. qx(mgs,lc) .LE. qxmin(lc)) cx(mgs,lc)=0.
11817 GO TO 631
11818!.... NUCLEATION ON CLOUD INFLOW BOUNDARY POINT
11819
11820 613 CONTINUE
11821
11822 631 CONTINUE
11823
11824!
11825! Check for supersaturation greater than ssmx and adjust down
11826!
11827 ssmx = maxsupersat
11828 qv1 = qv0(mgs) + qwvp(mgs)
11829 qvs1 = qvs(mgs)
11830
11831! IF ( flag_qndrop .and. do_satadj_for_wrfchem ) ssmx = 1.04 ! set lower threshold for progn=1 when using WRF-CHEM
11832
11833 IF ( qv1 .gt. (ssmx*qvs1) ) THEN
11834! use line below to disable saturation adjustment when flag_qndrop is true
11835! IF ( qv1 .gt. (ssmx*qvs1) .and. .not. flag_qndrop ) THEN
11836
11837 ss1 = qv1/qvs1
11838
11839 ssmx = 100.*(ssmx - 1.0)
11840
11841 qvex = 0.0
11842
11843 CALL qvexcess(ngs,mgs,qwvp,qv0,qx(1,lc),pres,thetap,theta0,qvex, &
11844 & pi0,tabqvs,nqsat,fqsat,cbw,fcqv1,felvcp,ssmx,pk,ngscnt)
11845
11846
11847
11848 IF ( qvex .gt. 0.0 ) THEN
11849 thetap(mgs) = thetap(mgs) + felvcp(mgs)*qvex/(pi0(mgs))
11850 IF ( io_flag .and. nxtra > 1 ) THEN
11851 axtra(igs(mgs),jy,kgs(mgs),1) = axtra(igs(mgs),jy,kgs(mgs),1) + qvex/dtp
11852 ENDIF
11853 qwvp(mgs) = qwvp(mgs) - qvex
11854 qx(mgs,lc) = qx(mgs,lc) + qvex
11855 IF ( .not. flag_qndrop) THEN
11856 IF ( imaxsupopt == 1 ) THEN
11857 cn(mgs) = min( max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/max( cwmasn5, xmas(mgs,lc) ) )
11858 ELSEIF ( imaxsupopt == 2 ) THEN
11859 cn(mgs) = min( max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/max( cwmasn5, max(cwmas30,xmas(mgs,lc)) ) )
11860 ELSEIF ( imaxsupopt == 3 ) THEN
11861 cn(mgs) = min( max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/max( cwmasn5, max(cwmasx,xmas(mgs,lc)) ) )
11862! cn(mgs) = 1.5*cxmin
11863 ELSEIF ( imaxsupopt == 4 ) THEN
11864 cn(mgs) = min( max(ccnc(mgs),cwnccn(mgs)), rho0(mgs)*qvex/max( cwmasn5, max(cwmas20,xmas(mgs,lc)) ) )
11865 ENDIF
11866
11867 IF ( lccna > 1 ) THEN
11868 !IF ( ac_opt == 0 ) THEN
11869 ccna(mgs) = ccna(mgs) + cn(mgs)
11870 !ENDIF
11871 ELSE
11872 ccnc(mgs) = max( 0.0, ccnc(mgs) - cn(mgs) )
11873 ENDIF
11874
11875 cx(mgs,lc) = cx(mgs,lc) + cn(mgs)
11876
11877 ENDIF ! flag_qndrop
11878
11879 ENDIF ! ( qvex .gt. 0.0 )
11880
11881 ENDIF ! ( qv1 .gt. (ssmx*qvs1) )
11882
11883!
11884! Calculate droplet volume and check if it is within bounds.
11885! Adjust if necessary
11886!
11887! if (ndebug .gt. 0) write(0,*) "ICEZVD_DR: check droplet volume"
11888
11889
11890! cx(mgs,lc) = Min( cwnccn(mgs), cx(mgs,lc) )
11891 IF( cx(mgs,lc) > cxmin .AND. qx(mgs,lc) .GT. qxmin(lc)) THEN
11892! SVC(mgs) = rho0(mgs)*qx(mgs,lc)/(cx(mgs,lc)*xdn(mgs,lc))
11893 xmas(mgs,lc) = rho0(mgs)*qx(mgs,lc)/(cx(mgs,lc))
11894
11895 IF ( xmas(mgs,lc) < cwmasn .or. xmas(mgs,lc) > cwmasx ) THEN
11896 tmp = cx(mgs,lc)
11897 xmas(mgs,lc) = min( xmas(mgs,lc), cwmasx )
11898 xmas(mgs,lc) = max( xmas(mgs,lc), cwmasn )
11899 cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc)
11900! IF ( cx(mgs,lc) > tmp*1.1 ) THEN
11901! ENDIF
11902 ENDIF
11903 ENDIF
11904
11905
11906! IF( cx(mgs,lc) .GT. 10.e6 .AND. qx(mgs,lc) .GT. qxmin(lc) ) GO TO 681
11907! ccwtmp = cx(mgs,lc)
11908! cwmastmp = xmas(mgs,lc)
11909! xmas(mgs,lc) = Max(xmas(mgs,lc), cwmasn)
11910! IF (qx(mgs,lc) .GT. qxmin(lc) .AND. cx(mgs,lc) .le. 0.) THEN
11911! cx(mgs,lc) = Min(0.5*cwccn,rho0(mgs)*qx(mgs,lc)/xmas(mgs,lc))
11912! xmas(mgs,lc) = rho0(mgs)*qx(mgs,lc)/cx(mgs,lc)
11913! ENDIF
11914! IF (cx(mgs,lc) .GT. 0. .AND. qx(mgs,lc) .GT. qxmin(lc)) &
11915! & xmas(mgs,lc) = rho0(mgs)*qx(mgs,lc)/cx(mgs,lc)
11916! IF (qx(mgs,lc) .GT. qxmin(lc) .AND. xmas(mgs,lc) .LT. cwmasn) &
11917! & xmas(mgs,lc) = cwmasn
11918! IF (qx(mgs,lc) .GT. qxmin(lc) .AND. xmas(mgs,lc) .GT. cwmasx) &
11919! & xmas(mgs,lc) = cwmasx
11920! IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN
11921! cx(mgs,lc) = rho0(mgs)*qx(mgs,lc)/Max(cwmasn,xmas(mgs,lc))
11922! ENDIF
11923!
11924!
11925! 681 CONTINUE
11926
11927
11928 IF ( ipconc .ge. 3 .and. rcond == 2 ) THEN
11929
11930
11931 IF (cx(mgs,lr) .GT. 0. .AND. qx(mgs,lr) .GT. qxmin(lr)) &
11932 & xv(mgs,lr)=rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr))
11933 IF (xv(mgs,lr) .GT. xvmx(lr)) xv(mgs,lr) = xvmx(lr)
11934 IF (xv(mgs,lr) .LT. xvmn(lr)) xv(mgs,lr) = xvmn(lr)
11935
11936 ENDIF
11937
11938
11939
11940 ENDDO ! mgs
11941
11942
11943! ################################################################
11944 DO mgs=1,ngscnt
11945 IF ( lss > 1 .and. ssf(mgs) .gt. ssmax(mgs) &
11946 & .and. ( idecss .eq. 0 .or. qx(mgs,lc) .gt. qxmin(lc)) ) THEN
11947 ssmax(mgs) = ssf(mgs)
11948 ENDIF
11949 ENDDO
11950!
11951
11952 do mgs = 1,ngscnt
11953 an(igs(mgs),jy,kgs(mgs),lt) = theta0(mgs) + thetap(mgs)
11954 an(igs(mgs),jy,kgs(mgs),lv) = qv0(mgs) + qwvp(mgs)
11955! 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)
11956!
11957 IF ( eqtset > 2 ) THEN
11958 p2(igs(mgs),jy,kgs(mgs)) = pipert(mgs)
11959 ENDIF
11960
11961 if ( ido(lc) .eq. 1 ) then
11962 an(igs(mgs),jy,kgs(mgs),lc) = qx(mgs,lc) + &
11963 & min( an(igs(mgs),jy,kgs(mgs),lc), 0.0 )
11964! qx(mgs,lc) = an(igs(mgs),jy,kgs(mgs),lc)
11965 end if
11966!
11967
11968 if ( ido(lr) .eq. 1 .and. rcond == 2 ) then
11969 an(igs(mgs),jy,kgs(mgs),lr) = qx(mgs,lr) + &
11970 & min( an(igs(mgs),jy,kgs(mgs),lr), 0.0 )
11971! qx(mgs,lr) = an(igs(mgs),jy,kgs(mgs),lr)
11972 end if
11973
11974 IF ( lzr > 1 .and. rcond == 2 ) THEN
11975 an(igs(mgs),jy,kgs(mgs),lzr) = zx(mgs,lr) + &
11976 & min( an(igs(mgs),jy,kgs(mgs),lzr), 0.0 )
11977 ENDIF
11978
11979
11980 IF ( ipconc .ge. 2 ) THEN
11981 an(igs(mgs),jy,kgs(mgs),lnc) = max(cx(mgs,lc) , 0.0)
11982 ! IF ( ac_opt > 10 .and. (cx(mgs,lc) > 0. .or. ccna(mgs) > 0. ) ) THEN
11983 ! write(0,*) 'i,k final cx/cna = ',igs(mgs),kgs(mgs),cx(mgs,lc),ccna(mgs)
11984 ! ENDIF
11985
11986 IF ( lss > 1 ) an(igs(mgs),jy,kgs(mgs),lss) = max( 0.0, ssmax(mgs) )
11987 IF ( ac_opt == 0 ) THEN
11988 IF ( lccn .gt. 1 .and. lccna .lt. 1 ) THEN
11989 an(igs(mgs),jy,kgs(mgs),lccn) = max(0.0, ccnc(mgs) )
11990 ENDIF
11991 ELSEIF ( ac_opt == 1 .and. lccn > 1) THEN
11992 an(igs(mgs),jy,kgs(mgs),lccn) = max( 0.0, ccnc(mgs) ) ! cn are depleted for ac_opt=1 or 2
11993 ELSEIF ( ac_opt == 11 .and. lccna > 1) THEN
11994 ! an(igs(mgs),jy,kgs(mgs),lccna) = Max( 0.0, ccna(mgs) ) ! done below
11995 ELSEIF ( ac_opt == 2 .and. lccn > 1) THEN
11996 an(igs(mgs),jy,kgs(mgs),lccn) = max( 0.0, ccnc(mgs) )
11997 an(igs(mgs),jy,kgs(mgs),lcn_nu) = max( 0.0, ccnc_nu(mgs) )
11998 an(igs(mgs),jy,kgs(mgs),lcn_co) = max( 0.0, ccnc_co(mgs) )
11999 ELSEIF ( ac_opt == 22 .and. lccna > 1) THEN
12000 ! an(igs(mgs),jy,kgs(mgs),lccna) = Max( 0.0, ccna(mgs) ) ! done below
12001 an(igs(mgs),jy,kgs(mgs),lccnanu) = max( 0.0, ccnanu(mgs) )
12002 an(igs(mgs),jy,kgs(mgs),lccnaco) = max( 0.0, ccnaco(mgs) )
12003 ENDIF
12004 IF ( lccnuf .gt. 1 .and. .not. ( lccna .gt. 1 .and. i_uf_or_ccn > 0 ) ) THEN
12005 an(igs(mgs),jy,kgs(mgs),lccnuf) = max(0.0, ccncuf(mgs) )
12006 ENDIF
12007 IF ( lccna .gt. 1 ) THEN
12008 an(igs(mgs),jy,kgs(mgs),lccna) = max(0.0, ccna(mgs) )
12009 ENDIF
12010 ENDIF ! ipconc >= 2
12011 IF ( ipconc .ge. 3 .and. rcond == 2 ) THEN
12012 an(igs(mgs),jy,kgs(mgs),lnr) = max(cx(mgs,lr) , 0.0)
12013 ENDIF
12014 end do
12015
12016
1201729998 continue
12018
12019
12020 if ( kz .gt. nz-1 .and. ix .ge. nxi) then
12021 if ( ix .ge. nxi ) then
12022 go to 2200 ! exit gather scatter
12023 else
12024 nzmpb = kz
12025 endif
12026 else
12027 nzmpb = kz
12028 end if
12029
12030 if ( ix .ge. nxi ) then
12031 nxmpb = 1
12032 nzmpb = kz+1
12033 else
12034 nxmpb = ix+1
12035 end if
12036
12037 2000 continue ! inumgs
12038 2200 continue
12039!
12040! end of gather scatter (for this jy slice)
12041
12042
12043! Redistribute inappreciable cloud particles and charge
12044!
12045! Redistribution everywhere in the domain...
12046!
12047! moved to separate subroutine (below)
12048!
12049
12050
12051
12052 9999 RETURN
12053
12054 END SUBROUTINE nucond
12055
12056
12057! #####################################################################
12058! #####################################################################
12059! Clean up tiny values of mixing ratio
12060! Redistribute inappreciable cloud particles and charge
12061!
12062! Redistribution everywhere in the domain...
12063!
12064 subroutine smallvalues &
12065 & (nx,ny,nz,na,jyslab &
12066 & ,nor,norz,dtp,nxi &
12067 & ,t0 &
12068 & ,an,dn, w &
12069 & ,t77,flag_qndrop &
12070 & )
12071
12072
12073 implicit none
12074
12075 integer :: nx,ny,nz,na,nxi
12076 integer :: nor,norz, jyslab ! ,nht,ngt,igsr
12077 real :: dtp ! time step
12078 logical,intent(in) :: flag_qndrop
12079
12080!
12081! external temporary arrays
12082!
12083 real t77(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
12084 real t0(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
12085 real an(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz,na)
12086 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
12087 real w(-nor+1:nx+nor,-nor+1:ny+nor,-norz+1:nz+norz)
12088
12089 ! local
12090
12091
12092 logical zerocx(lc:lqmx)
12093
12094 real :: frac, hwdn, tmpg, xdia1, xdia3, cwch,xvol
12095
12096 integer ix,kz,i,n, km1
12097 integer :: il
12098 integer :: jy, jgs
12099 real :: chw, g1, z1, tmp, tmp2, fw, tmpmx, qr
12100
12101
12102! Redistribute inappreciable cloud particles and charge
12103!
12104! Redistribution everywhere in the domain...
12105!
12106 jy = 1
12107
12108 frac = 1.0 ! 0.25 ! 1.0 ! 0.2
12109
12110 cwch = ((3. + alphah)*(2. + alphah)*(1.0 + alphah))**(-1./3.)
12111!
12112! alternate test version for ipconc .ge. 3
12113! just vaporize stuff to prevent noise in the number concentrations
12114
12115
12116 do kz = 1,nz
12117! do jy = 1,1
12118 do ix = 1,nxi
12119
12120 t0(ix,jy,kz) = an(ix,jy,kz,lt)*t77(ix,jy,kz)
12121
12122 zerocx(:) = .false.
12123 DO il = lc,lhab
12124 IF ( iresetmoments == 1 .or. iresetmoments == il ) THEN
12125 IF ( ln(il) > 1 ) zerocx(il) = ( an(ix,jy,kz,ln(il)) < cxmin )
12126 IF ( lz(il) > 1 ) zerocx(il) = ( zerocx(il) .or. (an(ix,jy,kz,lz(il)) < zxmin) )
12127 ELSE
12128 IF ( il == lc ) THEN
12129 IF ( ln(il) > 1 ) THEN
12130 zerocx(il) = ( an(ix,jy,kz,ln(il)) <= 0.0 ) .and. .not. flag_qndrop ! do not reset if progn=1 (WRF-CHEM)
12131 ENDIF
12132 ELSE
12133 IF ( ln(il) > 1 ) zerocx(il) = ( an(ix,jy,kz,ln(il)) <= 0.0 )
12134 ENDIF
12135 ENDIF
12136 ENDDO
12137
12138 IF ( lhl .gt. 1 ) THEN
12139
12140 IF ( lzhl .gt. 1 ) THEN
12141
12142 an(ix,jy,kz,lzhl) = max(0.0, an(ix,jy,kz,lzhl) )
12143
12144 IF ( an(ix,jy,kz,lhl) .ge. frac*qxmin(lhl) .and. rescale_low_alpha ) THEN ! check 6th moment
12145
12146 IF ( an(ix,jy,kz,lnhl) .gt. 0.0 ) THEN
12147
12148 IF ( lvhl .gt. 1 ) THEN
12149 IF ( an(ix,jy,kz,lvhl) .gt. 0.0 ) THEN
12150 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
12151 ELSE
12152 hwdn = xdn0(lhl)
12153 ENDIF
12154 hwdn = max( xdnmn(lhl), hwdn )
12155 ELSE
12156 hwdn = xdn0(lhl)
12157 ENDIF
12158
12159 chw = an(ix,jy,kz,lnhl)
12160 g1 = (6.0+alphamin)*(5.0+alphamin)*(4.0+alphamin)/ &
12161 & ((3.0+alphamin)*(2.0+alphamin)*(1.0+alphamin))
12162 z1 = g1*dn(ix,jy,kz)**2*( an(ix,jy,kz,lhl) )*an(ix,jy,kz,lhl)/chw
12163 z1 = z1*(6./(pi*hwdn))**2
12164 ELSE
12165 z1 = 0.0
12166 ENDIF
12167
12168 an(ix,jy,kz,lzhl) = min( z1, an(ix,jy,kz,lzhl) )
12169
12170 IF ( an(ix,jy,kz,lnhl) .lt. 1.e-5 ) THEN
12171! an(ix,jy,kz,lzhl) = 0.9*an(ix,jy,kz,lzhl)
12172 ENDIF
12173 ENDIF
12174
12175 ENDIF !lzhl
12176
12177 if ( (an(ix,jy,kz,lhl) .lt. frac*qxmin(lhl)) .or. zerocx(lhl) ) then
12178
12179! IF ( an(ix,jy,kz,lhl) .gt. 0 ) THEN
12180 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lhl)
12181 an(ix,jy,kz,lhl) = 0.0
12182! ENDIF
12183
12184 IF ( ipconc .ge. 5 ) THEN ! .and. an(ix,jy,kz,lnh) .gt. 0.0 ) THEN
12185 an(ix,jy,kz,lnhl) = 0.0
12186 ENDIF
12187
12188 IF ( lvhl .gt. 1 ) THEN
12189 an(ix,jy,kz,lvhl) = 0.0
12190 ENDIF
12191
12192 IF ( lhlw .gt. 1 ) THEN
12193 an(ix,jy,kz,lhlw) = 0.0
12194 ENDIF
12195
12196 IF ( lnhlf .gt. 1 ) THEN
12197 an(ix,jy,kz,lnhlf) = 0.0
12198 ENDIF
12199
12200 IF ( lzhl .gt. 1 ) THEN
12201 an(ix,jy,kz,lzhl) = 0.0
12202 ENDIF
12203
12204 ELSE
12205 IF ( lvol(lhl) .gt. 1 ) THEN ! check density
12206 IF ( an(ix,jy,kz,lvhl) .gt. 0.0 ) THEN
12207 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
12208 ELSE ! in case volume is zero but mass is above threshold (should not happen, of course)
12209 tmp = rho_qhl
12210 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
12211 ENDIF
12212
12213 IF ( tmp .lt. xdnmn(lhl) ) THEN
12214 tmp = max( xdnmn(lhl), tmp )
12215 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
12216 ENDIF
12217
12218 IF ( tmp .gt. xdnmx(lhl) .and. lhlw .le. 0 ) THEN ! no liquid allowed on hail
12219 tmp = min( xdnmx(lhl), tmp )
12220 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
12221 ELSEIF ( tmp .gt. xdnmx(lhl) .and. lhlw .gt. 1 ) THEN ! allow for liquid on hail
12222 fw = an(ix,jy,kz,lhlw)/an(ix,jy,kz,lhl)
12223! tmpmx = xdnmx(lhl) + fw*(xdnmx(lr) - xdnmx(lhl)) ! maximum possible average density
12224 ! it is not exactly linear, but approx. is close enough for this
12225! tmpmx = 1./( (1. - fw)/900. + fw/1000. ) is exact max, where 900 is xdnmx
12226
12227 tmpmx = xdnmx(lhl)/( 1. - fw*(1. - xdnmx(lhl)/xdnmx(lr) ))
12228
12229 IF ( tmp .gt. tmpmx ) THEN
12230 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmpmx
12231 ENDIF
12232
12233! IF ( tmp .gt. xdnmx(lhl) .and. an(ix,jy,kz,lhlw) .lt. qxmin(lhl) ) THEN
12234! tmp = Min( xdnmx(lhl), tmp )
12235! an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
12236! ELSEIF ( tmp .gt. xdnmx(lr) ) THEN
12237! tmp = xdnmx(lr)
12238! an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
12239! ENDIF
12240 ENDIF
12241
12242 IF ( lhlw .gt. 1 ) THEN ! check if basically pure water
12243 IF ( an(ix,jy,kz,lhlw) .gt. 0.98*an(ix,jy,kz,lhl) ) THEN
12244 tmp = xdnmx(lr)
12245 an(ix,jy,kz,lvhl) = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/tmp
12246 ENDIF
12247 ENDIF
12248
12249 ENDIF
12250
12251 IF ( lvhl .gt. 1 ) THEN
12252 IF ( an(ix,jy,kz,lvhl) .gt. 0.0 ) THEN
12253 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
12254 ELSE
12255 hwdn = xdn0(lhl)
12256 ENDIF
12257 hwdn = max( xdnmn(lhl), hwdn )
12258 ELSE
12259 hwdn = xdn0(lhl)
12260 ENDIF
12261
12262 IF ( ipconc >= 5 .and. an(ix,jy,kz,lhl) .gt. qxmin(lhl) ) THEN
12263 qr = an(ix,jy,kz,lhl)
12264 xvol = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/(hwdn*an(ix,jy,kz,lnhl))
12265 chw = an(ix,jy,kz,lnhl)
12266
12267 IF ( xvol .lt. xvmn(lhl) .or. xvol .gt. xvmx(lhl) ) THEN
12268 xvol = min( xvmx(lhl), max( xvmn(lhl),xvol ) )
12269 chw = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/(xvol*hwdn)
12270 an(ix,jy,kz,lnhl) = chw
12271 ENDIF
12272 ENDIF
12273
12274! CHECK INTERCEPT
12275 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
12276
12277 IF ( lvhl .gt. 1 ) THEN
12278 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lhl)/an(ix,jy,kz,lvhl)
12279 ELSE
12280 hwdn = xdn0(lhl)
12281 ENDIF
12282 tmp = (hwdn*an(ix,jy,kz,lnhl))/(dn(ix,jy,kz)*an(ix,jy,kz,lhl))
12283 tmpg = an(ix,jy,kz,lnhl)*(tmp*pi)**(1./3.)
12284 IF ( tmpg .lt. cnohlmn ) THEN
12285 tmp = ( (hwdn)/(dn(ix,jy,kz)*an(ix,jy,kz,lhl))*pi)**(1./3.)
12286 an(ix,jy,kz,lnhl) = (cnohlmn/tmp)**(3./4.)
12287 ENDIF
12288
12289 ENDIF
12290! ELSE ! check mean size here?
12291
12292 end if
12293
12294 ENDIF !lhl
12295
12296
12297
12298 IF ( lzh .gt. 1 ) THEN
12299
12300 an(ix,jy,kz,lzh) = max(0.0, an(ix,jy,kz,lzh) )
12301
12302 IF ( .false. .and. an(ix,jy,kz,lh) .ge. frac*qxmin(lh) .and. rescale_low_alpha ) THEN
12303
12304 IF ( an(ix,jy,kz,lnh) .gt. 0.0 ) THEN
12305
12306 IF ( lvh .gt. 1 ) THEN
12307 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
12308 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
12309 ELSE
12310 hwdn = xdn0(lh)
12311 ENDIF
12312 hwdn = max( xdnmn(lh), hwdn )
12313 ELSE
12314 hwdn = xdn0(lh)
12315 ENDIF
12316
12317 chw = an(ix,jy,kz,lnh)
12318 g1 = (6.0+alphamin)*(5.0+alphamin)*(4.0+alphamin)/ &
12319 & ((3.0+alphamin)*(2.0+alphamin)*(1.0+alphamin))
12320 z1 = g1*dn(ix,jy,kz)**2*( an(ix,jy,kz,lh) )*an(ix,jy,kz,lh)/chw
12321 z1 = z1*(6./(pi*hwdn))**2
12322 ELSE
12323 z1 = 0.0
12324 ENDIF
12325
12326 an(ix,jy,kz,lzh) = min( z1, an(ix,jy,kz,lzh) )
12327
12328 IF ( an(ix,jy,kz,lnh) .lt. 1.e-5 ) THEN
12329! an(ix,jy,kz,lzh) = 0.9*an(ix,jy,kz,lzh)
12330 ENDIF
12331 ENDIF
12332
12333 ENDIF
12334
12335 if ( (an(ix,jy,kz,lh) .lt. frac*qxmin(lh)) .or. zerocx(lh) ) then
12336
12337! IF ( an(ix,jy,kz,lh) .gt. 0 ) THEN
12338 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lh)
12339 an(ix,jy,kz,lh) = 0.0
12340! ENDIF
12341
12342 IF ( ipconc .ge. 5 ) THEN ! .and. an(ix,jy,kz,lnh) .gt. 0.0 ) THEN
12343 an(ix,jy,kz,lnh) = 0.0
12344 ENDIF
12345
12346 IF ( lvh .gt. 1 ) THEN
12347 an(ix,jy,kz,lvh) = 0.0
12348 ENDIF
12349
12350 IF ( lhw .gt. 1 ) THEN
12351 an(ix,jy,kz,lhw) = 0.0
12352 ENDIF
12353
12354 IF ( lnhf .gt. 1 ) THEN
12355 an(ix,jy,kz,lnhf) = 0.0
12356 ENDIF
12357
12358 IF ( lzh .gt. 1 ) THEN
12359 an(ix,jy,kz,lzh) = 0.0
12360 ENDIF
12361
12362 ELSE
12363 IF ( lvol(lh) .gt. 1 ) THEN ! check density
12364 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
12365 tmp = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
12366 ELSE
12367 tmp = rho_qh
12368 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
12369 ENDIF
12370
12371 IF ( tmp .lt. xdnmn(lh) ) THEN
12372 tmp = max( xdnmn(lh), tmp )
12373 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
12374 ENDIF
12375
12376 IF ( tmp .gt. xdnmx(lh) .and. lhw .le. 0 ) THEN ! no liquid allowed on graupel
12377 tmp = min( xdnmx(lh), tmp )
12378 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
12379 ELSEIF ( tmp .gt. xdnmx(lh) .and. lhw .gt. 1 ) THEN ! allow for liquid on graupel
12380 fw = an(ix,jy,kz,lhw)/an(ix,jy,kz,lh)
12381! tmpmx = xdnmx(lh) + fw*(xdnmx(lr) - xdnmx(lh)) ! maximum possible average density
12382 ! it is not exactly linear, but approx. is close enough for this
12383! tmpmx = 1./( (1. - fw)/900. + fw/1000. ) is exact max, where 900 is xdnmx
12384 tmpmx = xdnmx(lh)/( 1. - fw*(1. - xdnmx(lh)/xdnmx(lr) ))
12385
12386 IF ( tmp .gt. tmpmx ) THEN
12387 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmpmx
12388 ENDIF
12389
12390! IF ( tmp .gt. xdnmx(lh) .and. an(ix,jy,kz,lhw) .lt. qxmin(lh) ) THEN
12391! tmp = Min( xdnmx(lh), tmp )
12392! an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
12393! ELSEIF ( tmp .gt. xdnmx(lr) ) THEN
12394! tmp = xdnmx(lr)
12395! an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
12396! ENDIF
12397
12398 ENDIF
12399
12400 IF ( lhw .gt. 1 ) THEN ! check if basically pure water
12401 IF ( an(ix,jy,kz,lhw) .gt. 0.98*an(ix,jy,kz,lh) ) THEN
12402 tmp = xdnmx(lr)
12403 an(ix,jy,kz,lvh) = dn(ix,jy,kz)*an(ix,jy,kz,lh)/tmp
12404 ENDIF
12405 ENDIF
12406
12407 ENDIF
12408
12409 IF ( lvh .gt. 1 ) THEN
12410 IF ( an(ix,jy,kz,lvh) .gt. 0.0 ) THEN
12411 hwdn = dn(ix,jy,kz)*an(ix,jy,kz,lh)/an(ix,jy,kz,lvh)
12412 ELSE
12413 hwdn = xdn0(lh)
12414 ENDIF
12415 hwdn = max( xdnmn(lh), hwdn )
12416 ELSE
12417 hwdn = xdn0(lh)
12418 ENDIF
12419
12420 IF ( ipconc >= 5 .and. an(ix,jy,kz,lh) .gt. qxmin(lh) ) THEN
12421 qr = an(ix,jy,kz,lh)
12422 xvol = dn(ix,jy,kz)*an(ix,jy,kz,lh)/(hwdn*an(ix,jy,kz,lnh))
12423 chw = an(ix,jy,kz,lnh)
12424
12425 IF ( xvol .lt. xvmn(lh) .or. xvol .gt. xvmx(lh) ) THEN
12426 xvol = min( xvmx(lh), max( xvmn(lh),xvol ) )
12427 chw = dn(ix,jy,kz)*an(ix,jy,kz,lh)/(xvol*hwdn)
12428 an(ix,jy,kz,lnh) = chw
12429 ENDIF
12430 ENDIF
12431
12432! CHECK INTERCEPT
12433 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
12434
12435 tmp = (hwdn*an(ix,jy,kz,lnh))/(dn(ix,jy,kz)*an(ix,jy,kz,lh))
12436 tmpg = an(ix,jy,kz,lnh)*(tmp*pi)**(1./3.)
12437 IF ( tmpg .lt. cnohmn ) THEN
12438! 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.)
12439! tmpg = an(ix,jy,kz,lnh)**(4./3.)*( (hwdn)/(dn(ix,jy,kz)*an(ix,jy,kz,lh))*(3.14159))**(1./3.)
12440 tmp = ( (hwdn)/(dn(ix,jy,kz)*an(ix,jy,kz,lh))*pi)**(1./3.)
12441 an(ix,jy,kz,lnh) = (cnohmn/tmp)**(3./4.)
12442 ENDIF
12443
12444 ENDIF
12445
12446 IF ( ipconc == 5 .and. imorrgdnglimit == 1 ) THEN
12447 ! limit on characteristic diameter (i.e., 1/slope)
12448 xdia3 = (xvol*6.*piinv)**(1./3.)
12449 xdia1 = cwch*xdia3
12450 IF ( xdia1 > morrdnglimit ) THEN
12451 xdia1 = morrdnglimit
12452 xvol = pi/6.0*(xdia1/cwch)**3
12453 chw = dn(ix,jy,kz)*qr/(xvol*hwdn)
12454 an(ix,jy,kz,lnh) = chw
12455 xdia3 = (xvol*6.*piinv)**(1./3.)
12456 ENDIF
12457
12458 ENDIF
12459
12460 end if
12461
12462
12463 if ( (an(ix,jy,kz,ls) .lt. frac*qxmin(ls)) .or. zerocx(ls) ) then
12464 IF ( t0(ix,jy,kz) .lt. 273.15 ) THEN
12465! IF ( an(ix,jy,kz,ls) .gt. 0 ) THEN
12466 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,ls)
12467 an(ix,jy,kz,ls) = 0.0
12468! ENDIF
12469
12470 IF ( ipconc .ge. 4 ) THEN ! .and. an(ix,jy,kz,lns) .gt. 0.0 ) THEN !
12471! an(ix,jy,kz,lni) = an(ix,jy,kz,lni) + an(ix,jy,kz,lns)
12472 an(ix,jy,kz,lns) = 0.0
12473 ENDIF
12474
12475 IF ( lvs .gt. 1 ) THEN
12476 an(ix,jy,kz,lvs) = 0.0
12477 ENDIF
12478
12479 IF ( lsw .gt. 1 ) THEN
12480 an(ix,jy,kz,lsw) = 0.0
12481 ENDIF
12482
12483 ELSE
12484! IF ( an(ix,jy,kz,ls) .gt. 0 ) THEN
12485 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,ls)
12486 an(ix,jy,kz,ls) = 0.0
12487! ENDIF
12488
12489 IF ( lvs .gt. 1 ) THEN
12490 an(ix,jy,kz,lvs) = 0.0
12491 ENDIF
12492
12493 IF ( lsw .gt. 1 ) THEN
12494 an(ix,jy,kz,lsw) = 0.0
12495 ENDIF
12496
12497 IF ( ipconc .ge. 4 ) THEN ! .and. an(ix,jy,kz,lns) .gt. 0.0 ) THEN !
12498! an(ix,jy,kz,lnr) = an(ix,jy,kz,lnr) + an(ix,jy,kz,lns)
12499 an(ix,jy,kz,lns) = 0.0
12500 ENDIF
12501
12502 ENDIF
12503
12504
12505 ELSEIF ( lvol(ls) .gt. 1 ) THEN ! check density
12506 IF ( an(ix,jy,kz,lvs) .gt. 0.0 ) THEN
12507 tmp = dn(ix,jy,kz)*an(ix,jy,kz,ls)/an(ix,jy,kz,lvs)
12508 IF ( tmp .gt. xdnmx(ls) .or. tmp .lt. xdnmn(ls) ) THEN
12509 tmp = min( xdnmx(ls), max( xdnmn(ls), tmp ) )
12510 an(ix,jy,kz,lvs) = dn(ix,jy,kz)*an(ix,jy,kz,ls)/tmp
12511 ENDIF
12512 ELSE
12513 tmp = rho_qs
12514 an(ix,jy,kz,lvs) = dn(ix,jy,kz)*an(ix,jy,kz,ls)/tmp
12515 ENDIF
12516
12517
12518 end if
12519
12520 IF ( lzr > 1 ) THEN
12521 an(ix,jy,kz,lzr) = max(0.0, an(ix,jy,kz,lzr) )
12522 ENDIF
12523
12524 if ( (an(ix,jy,kz,lr) .lt. frac*qxmin(lr)) .or. zerocx(lr) ) then
12525 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lr)
12526 an(ix,jy,kz,lr) = 0.0
12527 IF ( ipconc .ge. 3 ) THEN
12528! an(ix,jy,kz,lnc) = an(ix,jy,kz,lnc) + an(ix,jy,kz,lnr)
12529 an(ix,jy,kz,lnr) = 0.0
12530 ENDIF
12531
12532 IF ( lzr > 1 ) THEN
12533 an(ix,jy,kz,lzr) = 0.0
12534 ENDIF
12535
12536 end if
12537
12538!
12539! for qci
12540!
12541 IF ( (an(ix,jy,kz,li) .le. frac*qxmin(li)) .or. zerocx(li) ) THEN
12542 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,li)
12543 an(ix,jy,kz,li)= 0.0
12544 IF ( ipconc .ge. 1 ) THEN
12545 an(ix,jy,kz,lni) = 0.0
12546 ENDIF
12547 ENDIF
12548
12549!
12550! for qcw
12551!
12552
12553 IF ( (an(ix,jy,kz,lc) .le. frac*qxmin(lc)) .or. zerocx(lc) ) THEN
12554 an(ix,jy,kz,lv) = an(ix,jy,kz,lv) + an(ix,jy,kz,lc)
12555 an(ix,jy,kz,lc)= 0.0
12556 IF ( ipconc .ge. 2 ) THEN
12557 IF ( lccn .gt. 1 .or. ac_opt == 1 ) THEN
12558 IF ( irenuc < 5 .and. lccna <= 1 ) THEN
12559 IF ( ac_opt == 0 ) THEN
12560 an(ix,jy,kz,lccn) = an(ix,jy,kz,lccn) + max(0.0,an(ix,jy,kz,lnc))
12561 ELSEIF ( lccn > 1 ) THEN
12562 an(ix,jy,kz,lccn) = an(ix,jy,kz,lccn) + max(0.0,an(ix,jy,kz,lnc))
12563 ENDIF
12564 ELSEIF ( lccna > 1 ) THEN
12565 tmp = max(0.0,an(ix,jy,kz,lnc))
12566 IF ( lccnaco > 1 .and. lccnanu > 1 ) THEN
12567 ! restore CCN proportionally to each type, although coarse are presumably already lost to rain
12568 tmp2 = an(ix,jy,kz,lccna) + an(ix,jy,kz,lccnaco) + an(ix,jy,kz,lccnanu)
12569 IF ( tmp2 > 0.0 .and. tmp > 0.0 ) THEN
12570 an(ix,jy,kz,lccna) = max( 0.0, an(ix,jy,kz,lccna) - tmp*an(ix,jy,kz,lccna)/tmp2 )
12571 an(ix,jy,kz,lccnaco) = max( 0.0, an(ix,jy,kz,lccnaco) - tmp*an(ix,jy,kz,lccnaco)/tmp2 )
12572 an(ix,jy,kz,lccnanu) = max( 0.0, an(ix,jy,kz,lccnanu) - tmp*an(ix,jy,kz,lccnanu)/tmp2 )
12573 ENDIF
12574 ELSE
12575 an(ix,jy,kz,lccna) = max( 0.0, an(ix,jy,kz,lccna) - tmp )
12576 ENDIF
12577 ENDIF
12578 ENDIF
12579 an(ix,jy,kz,lnc) = 0.0
12580 IF ( lccn > 1 ) an(ix,jy,kz,lccn) = max( 0.0, an(ix,jy,kz,lccn) )
12581
12582! IF ( lccna > 0 .and. ac_opt == 0 ) THEN ! apply exponential decay to activated CCN to restore to environmental value
12583 IF ( lccna > 0 ) THEN ! apply exponential decay to activated CCN to restore to environmental value
12584 IF ( restoreccn ) THEN
12585 tmp = an(ix,jy,kz,li) + an(ix,jy,kz,ls)
12586 IF ( tmp < qxmin(li) ) THEN
12587 IF ( an(ix,jy,kz,lccna) > 1. .and. tmp < qxmin(li) ) an(ix,jy,kz,lccna) = an(ix,jy,kz,lccna)*exp(-dtp/ccntimeconst)
12588 IF ( lccnaco > 1 ) an(ix,jy,kz,lccnaco) = an(ix,jy,kz,lccnaco)*exp(-dtp/ccntimeconst)
12589 IF ( lccnanu > 1 ) an(ix,jy,kz,lccnanu) = an(ix,jy,kz,lccnanu)*exp(-dtp/ccntimeconst)
12590 ENDIF
12591 ENDIF
12592 ELSEIF ( lccn > 1 .and. restoreccn .and. ac_opt == 0 ) THEN
12593 ! in this case, we are treating the ccn field as ccna
12594 tmp = an(ix,jy,kz,li) + an(ix,jy,kz,ls)
12595! IF ( ny == 2 .and. ix == nx/2 ) THEN
12596! write(0,*) 'restore: k, qccn,exp = ',kz,qccn,dn(ix,jy,kz)*qccn,Exp(-dtp/ccntimeconst)
12597! 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)
12598! ENDIF
12599 IF ( an(ix,jy,kz,lccn) > 1. .and. tmp < qxmin(li) .and. &
12600 ( an(ix,jy,kz,lccn) < dn(ix,jy,kz)*qccn .or. .not. invertccn ) ) THEN
12601 ! an(ix,jy,kz,lccn) = &
12602 ! an(ix,jy,kz,lccn) + Max(0.0 , dn(ix,jy,kz)*qccn - an(ix,jy,kz,lccn))*(1.0 - Exp(-dtp/ccntimeconst))
12603 ! Equivalent form after expanding last term:
12604 an(ix,jy,kz,lccn) = &
12605 dn(ix,jy,kz)*qccn - max(0.0 , dn(ix,jy,kz)*qccn - an(ix,jy,kz,lccn))*exp(-dtp/ccntimeconst)
12606 ENDIF
12607
12608 ENDIF
12609
12610 ENDIF
12611
12612 ENDIF
12613
12614 end do
12615! end do
12616 end do
12617
12618
12619 end subroutine smallvalues
12622
12623
12624
12625
12626!c--------------------------------------------------------------------------
12627!
12628!
12629!--------------------------------------------------------------------------
12630!
12631
12632 subroutine nssl_2mom_gs &
12633 & (nx,ny,nz,na,jyslab &
12634 & ,nor,norz &
12635 & ,dtp,gz &
12636 & ,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9 &
12637 & ,an,dn,p2 &
12638 & ,pn,w,iunit &
12639 & ,t00,t77, &
12640 & ventr,ventc,c1sw,jgs,ido, &
12641 & xdnmx,xdnmn, &
12642! & ln,ipc,lvol,lz,lliq, &
12643 & cdx, &
12644 & xdn0,tmp3d,tkediss &
12645 & ,thproc,numproc,dx1,dy1,ngs &
12646 & ,timevtcalc,axtra,io_flag &
12647 & , has_wetscav,rainprod2d, evapprod2d, alpha2d &
12648 & ,errmsg,errflg &
12649 & ,elec,its,ids,ide,jds,jde &
12650 & )
12651
12652
12653!
12654!--------------------------------------------------------------------------
12655!
12656! Ziegler 1985 parameterized microphysics (also Zrnic et al. 1993)
12657! 1) cloud water
12658! 2) rain
12659! 3) column ice
12660! 6) snow
12661! 11) graupel/hail
12662!
12663!--------------------------------------------------------------------------
12664!
12665! Notes:
12666!
12667! 4/27/2009: allows for liquid water to be advected on snow and graupel particles using flag "mixedphase"
12668!
12669! 3/14/2007: (APS) added qproc temp to make microphysic process timeseries
12670!
12671! 10/17/2006: added flag (iehw) to select how to calculate ehw
12672!
12673! 10/5/2006: switched chacr to integrated version rather than assuming that average rain
12674! drop mass does not change. This acts to reduce rain size somewhat via graupel
12675! collection.
12676! Use Mason data for ehw, with scaling toward ehw=1 as air density decreases.
12677!
12678! 10/3/2006: Turned off Meyers nucleation for T > -5 (can turn on with imeyers5 flag)
12679! Turned off contact nucleation in updrafts
12680!
12681! 7/24/2006: Turned on Meyers nucleation for -5 < T < 0
12682!
12683! 5/12/2006: Converted qsacw/csacw and qsaci/csaci to Z93
12684!
12685! 5/12/2006: Put a threshold on Bigg rain freezing. If the frozen drops
12686! have an average volume less than xvhmn, then the drops are put
12687! into snow instead of graupel/hail.
12688!
12689! Fixed bug when vapor deposition was limited.
12690!
12691! 5/13/2006: Note that qhacr has a large effect, but Z85 did not include it.
12692! Turned off qsacr (set to zero).
12693!
12694! 9/14/2007: erm: recalculate vx(lh) after setting xdn(lh) in case xdn was out of allowed range.
12695! added parameter rimc3 for minimum rime density. Default value set at 170. kg/m**3
12696! instead of previous use of 100. (Farley, 1987)
12697!
12698!--------------------------------------------------------------------------
12699!
12700! general declarations
12701!
12702!--------------------------------------------------------------------------
12703!
12704!
12705!
12706
12707
12708 implicit none
12709!
12710! integer icond
12711! parameter ( icond = 2 )
12712
12713 integer, parameter :: ng1 = 1
12714
12715 integer nx,ny,nz,na,nba,nv
12716 integer nor,norz,istag,jstag,kstag ! ,nht,ngt,igsr
12717 integer iwrite
12718 real dtp,dx,dy,dz
12719
12720 logical, intent(in) :: io_flag
12721
12722 integer itile,jtile,ktile
12723 integer ixbeg,jybeg
12724 integer ixend,jyend,kzend,kzbeg
12725 integer nxend,nyend,nzend,nzbeg
12726 integer :: my_rank = 0
12727 integer, parameter :: myprock = 1, nprock = 1
12728 logical, intent(in) :: has_wetscav
12729 integer, intent(in) :: numproc
12730 real, intent(inout) :: thproc(nz,numproc)
12731 real, intent(in) :: dx1,dy1
12732 real rainprod2d(-nor+1:nx+nor,-norz+ng1:nz+norz)
12733 real evapprod2d(-nor+1:nx+nor,-norz+ng1:nz+norz)
12734
12735
12736 real :: alpha2d(-nor+1:nx+nor,-norz+ng1:nz+norz,3)
12737
12738 real, parameter :: tfrdry = 243.15
12739
12740 logical lrescalelow(lc:lhab)
12741 real tkediss(-nor+1:nx+nor,-norz+ng1:nz+norz)
12742 real axtra(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz,nxtra)
12743
12744 real :: galpharaut
12745 real :: xvbarmax
12746
12747 integer jyslab,its,ids,ide,jds,jde ! domain boundaries
12748 integer, intent(in) :: iunit !,iunit0
12749 real qvex
12750 integer iraincv, icgxconv
12751 parameter( iraincv = 1, icgxconv = 1)
12752 real ffrz
12753 real :: ffrzh = 1.0
12754
12755 real qcitmp,cirdiatmp ! ,qiptmp,qirtmp
12756 real ccwtmp,ccitmp ! ,ciptmp,cirtmp
12757 real cpqc,cpci ! ,cpip,cpir
12758 real cpqc0,cpci0 ! ,cpip0,cpir0
12759 real scfac ! ,cpip1
12760
12761 double precision dp1
12762
12763 double precision frac, frach, xvfrz, xvbiggsnow
12764
12765 double precision :: timevtcalc
12766 double precision :: dpt1,dpt2
12767
12768 logical, parameter :: gammacheck = .false.
12769 integer :: luindex
12770 double precision :: tmpgam
12771 logical, parameter :: usegamxinfcnu = .false.
12772 logical, parameter :: usegamxinf = .false.
12773 logical, parameter :: usegamxinf2 = .false.
12774 logical, parameter :: usegamxinf3 = .false.
12775! real rar ! rime accretion rate as calculated from qxacw
12776
12777 ! CCPP error handling
12778 character(len=*), intent( out) :: errmsg
12779 integer, intent( out) :: errflg
12780! a few vars for time-split fallout
12781 real vtmax
12782 integer n,ndfall
12783
12784 double precision chgneg,chgpos,sctot
12785
12786 real temgtmp
12787
12788 real pb(-norz+ng1:nz+norz)
12789 real pinit(-norz+ng1:nz+norz)
12790
12791 real gz(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz) ! dz
12792
12793 real qimax,xni0,roqi0
12794
12795
12796 real dv
12797
12798 real dtptmp
12799 integer itest,nidx,id1,jd1,kd1
12800 parameter(itest=1)
12801 parameter(nidx=10)
12802 parameter(id1=1,jd1=1,kd1=1)
12803 integer ierr
12804 integer iend
12805
12806 integer ix,kz, il, ic, ir, icp1, irp1, ip1,jp1,kp1
12807 integer :: jy
12808 integer i,j,k,i1
12809 integer kzb,kze
12810 real slope1, slope2
12811 real x1, x2, x3, y1
12812 real eps,eps2
12813 parameter(eps=1.e-20,eps2=1.e-5)
12814!
12815! Other elec. vars
12816!
12817 real temele
12818 real trev
12819
12820 logical ldovol, ishail, ltest, wtest
12821 logical , parameter :: alp0flag = .false.
12822!
12823!
12824! wind indicies
12825!
12826 integer mu,mv,mw
12827 parameter(mu=1,mv=2,mw=3)
12828!
12829! conversion parameters
12830!
12831 integer mqcw,mqxw,mtem,mrho,mtim
12832 parameter(mqcw=21,mqxw=21,mtem=21,mrho=5,mtim=6)
12833
12834 real xftim,xftimi,yftim, xftem,yftem, xfqcw,yfqcw, xfqxw,yfqxw
12835 parameter(xftim=0.05,xftimi = 1./xftim,yftim=1.)
12836 parameter(xftem=0.5,yftem=1.)
12837 parameter(xfqcw=2000.,yfqcw=1.)
12838 parameter(xfqxw=2000.,yfqxw=1.)
12839 real dtfac
12840 parameter( dtfac = 1.0 )
12841 integer ido(lc:lqmx)
12842
12843! integer iexy(lc:lqmx,lc:lqmx)
12844! integer ieswi, ieswir, ieswip, ieswc, ieswr
12845! integer ieglsw, iegli, ieglir, ieglip, ieglc, ieglr
12846! integer iegmsw, iegmi, iegmir, iegmip, iegmc, iegmr
12847! integer ieghsw, ieghi, ieghir, ieghip, ieghc, ieghr
12848! integer iefwsw, iefwi, iefwir, iefwip, iefwc, iefwr
12849! integer iehwsw, iehwi, iehwir, iehwip, iehwc, iehwr
12850! integer iehlsw, iehli, iehlir, iehlip, iehlc, iehlr
12851! real delqnsa, delqxsa, delqnsb, delqxsb, delqnia, delqxia
12852! real delqnra, delqxra
12853
12854 real delqnxa(lc:lqmx)
12855 real delqxxa(lc:lqmx)
12856!
12857! external temporary arrays
12858!
12859 real t00(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12860 real t77(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12861
12862 real t0(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12863 real t1(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12864 real t2(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12865 real t3(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12866 real t4(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12867 real t5(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12868 real t6(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12869 real t7(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12870 real t8(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12871 real t9(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12872
12873 real p2(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz) ! perturbation Pi
12874 real pn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz)
12875 real an(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz,na)
12876 real dn(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz)
12877 real w(-nor+1:nx+nor,-nor+1:ny+nor,-norz+ng1:nz+norz)
12878
12879 real tmp3d(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz)
12880
12881!
12882! declarations microphyscs and for gather/scatter
12883!
12884 integer nxmpb,nzmpb,nxz
12885 integer jgs,mgs,ngs,numgs
12886 integer, parameter :: ngsz = 500
12887 integer ntt
12888 parameter(ntt=300)
12889
12890 real dvmgs(ngs)
12891
12892 integer ngscnt,igs(ngs),kgs(ngs)
12893 integer kgsp(ngs),kgsm(ngs),kgsm2(ngs)
12894 integer ncuse
12895 parameter(ncuse=0)
12896 integer il0(ngs),il5(ngs),il2(ngs),il3(ngs)
12897! integer il1m(ngs),il2m(ngs),il3m(ngs),il4m(ngs),il5m(ngs)
12898!
12899 real tdtol,temsav,tfrcbw,tfrcbi
12900 real, parameter :: thnuc = 235.15
12901!
12902! Ice Multiplication Arrays.
12903!
12904 real fimt1(ngs),fimta(ngs),fimt2(ngs) !,qmul1(ngs),qmul2(ngs)
12905 real xcwmas
12906!
12907!
12908! Variables for Ziegler warm rain microphysics
12909!
12910
12911
12912 real ccnc(ngs),ccin(ngs),cina(ngs),ccna(ngs)
12913 real cwnccn(ngs)
12914 real sscb ! 'cloud base' SS threshold
12915 parameter( sscb = 2.0 )
12916 integer idecss ! flag to turn on (=1) decay of ssmax when no cloud or ice crystals
12917 parameter( idecss = 1 )
12918 integer iba ! flag to do condensation/nucleation in 1st or 2nd loop
12919 ! =0 to use ad to calculate SS
12920 ! =1 to use an at end of main jy loop to calculate SS
12921 parameter(iba = 1)
12922 integer ifilt ! =1 to filter ssat, =0 to set ssfilt=ssat
12923 parameter( ifilt = 0 )
12924 real temp1,temp2 ! ,ssold
12925 real :: mwat, mice, dice, mwshed, fwmax, fw, mwcrit, massfactor, tmpdiam
12926 real, parameter :: shedalp = 3. ! set 3 for maximum mass diameter (same as area-weighted diameter), 4 for mass-weighted diameter
12927 real ssmax(ngs) ! maximum SS experienced by a parcel
12928 real ssmx
12929 real dnnet,dqnet
12930! real cnu,rnu,snu,cinu
12931! parameter ( cnu = 0.0, rnu = -0.8, snu = -0.8, cinu = 0.0 )
12932 real bfnu, bfnu0, bfnu1
12933 parameter( bfnu0 = (rnu + 2.0)/(rnu + 1.0) )
12934 real ventr, ventc
12935 real volb
12936 double precision t2s, xdp
12937 double precision xl2p(ngs),rb(ngs)
12938 real, parameter :: aa1 = 9.44e15, aa2 = 5.78e3 ! a1 in Ziegler
12939! snow parameters:
12940 real, parameter :: cexs = 0.1, cecs = 0.5
12941 real, parameter :: rvt = 0.104 ! ratio of collection kernels (Zrnic et al, 1993)
12942 real, parameter :: kfrag = 1.0e-6 ! rate coefficent for collisional splintering (Schuur & Rutledge 00b)
12943 real, parameter :: mfrag = 1.0e-10 ! assumed ice fragment mass for collisional splintering (Schuur & Rutledge 00b)
12944 double precision cautn(ngs), rh(ngs), nh(ngs)
12945 real ex1, ft, rhoinv(ngs)
12946 real :: ec0(ngs)
12947
12948 real ac1,bc, c1,d1,e1,f1,p380,tmp,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,temp3 ! , sstdy, super
12949 real :: flim, xmass
12950 real dw,dwr
12951 double precision :: tmpz, tmpzmlt
12952 real :: tmpc
12953 real ratio, delx, dely
12954 real dbigg,volt
12955 real chgtmp,fac,mixedphasefac
12956 real x,y,y2,del,r,rtmp,alpr
12957 double precision :: vent1,vent2
12958 double precision :: g1palp,g4palp
12959 double precision :: g1palpinf,g4palpinf
12960 real fqt !charge separation as fn of temperature from Dong and Hallett 1992
12961 real bs
12962 real v1, v2
12963 real d1r, d1i, d1s, e1i
12964 real c1sw ! integration factor for snow melting with snu = -0.8
12965 real, parameter :: vr1mm = 5.23599e-10 ! volume of 1mm diameter sphere (m**3)
12966 real, parameter :: vr3mm = 5.23599e-10*(3.0/1.)**3 ! volume of a 3 mm diameter sphere (m**3) (Rasmussen et al. 1984b, JAS)
12967 real, parameter :: vr4p5mm = 5.23599e-10*(4.5/1.)**3 ! volume of 4.5mm diameter sphere (m**3) (Rasmussen et al. 1984b, JAS)
12968 real vmlt,vshd, vshdgs(ngs,lh:lhab), maxmassfac(lc:lhab)
12969 real rhosm
12970 parameter( rhosm = 500. )
12971 integer nc ! condensation step
12972 real dtcon,dtcon1,dtcon2 ! condensation time step (dtcon*nc = dtp)
12973 real delta
12974 integer ltemq1,ltemq1m ! ,ltemq1m2
12975 real dqv,qv1,ss1,ss2,qvs1,dqvs,dtemp,dt1 ! temporaries for condensation
12976 real ssi1, ssi2, dqvi, dqvis, dqvii,qis1
12977 real dqvr, dqc, dqr, dqi, dqs
12978 real qv1m,qvs1m,ss1m,ssi1m,qis1m
12979 real cwmastmp
12980 real dcloud,dcloud2 ! ,as, bs
12981 real cn(ngs)
12982 double precision xvc, xvr
12983 real mwfac
12984! real es(ngs) ! ss(ngs),
12985! real eis(ngs)
12986
12987 real rwmasn,rwmasx
12988
12989 real vgra,vfrz
12990 parameter( vgra = 0.523599*(1.0e-3)**3 )
12991
12992! real, parameter :: epsi = 0.622
12993! real, parameter :: d = 0.266
12994 real :: d, dold, denom,denominv,vth
12995 double precision :: h1, h2, h3, h4,denomdp, denominvdp
12996 real r1,qevap ! ,slv
12997
12998 real vr,nrx,chw,g1,qr,z,z1,rdi,alp,xnutmp,xnuc,g1r,rd1,rdia,rmas
12999 real :: snowmeltmass = 0
13000
13001! real, parameter :: rhofrz = 900. ! density of graupel from newly-frozen rain
13002 real, parameter :: rimedens = 500. ! default rime density
13003
13004! real svc(ngs) ! droplet volume
13005!
13006! contact freezing nucleation
13007!
13008 real raero,kaero !assumd aerosol radius, thermal conductivity
13009 parameter( raero = 3.e-7, kaero = 5.39e-3 )
13010 real kb ! Boltzman constant J K-1
13011 parameter(kb = 1.3807e-23)
13012
13013 real knud(ngs),knuda(ngs) !knudsen number and correction factor
13014 real gtp(ngs) !G(T,p) = 1/(a' + b') Cotton 72b
13015 real dfar(ngs) !aerosol diffusivity
13016 real fn1(ngs),fn2(ngs),fnft(ngs)
13017
13018 real ccia(ngs)
13019 real ctfzbd(ngs),ctfzth(ngs),ctfzdi(ngs)
13020!
13021! misc
13022!
13023 real ni,nis,nr,d0
13024 real dqvcnd(ngs),dqwv(ngs),dqcw(ngs),dqci(ngs),dqcitmp(ngs),dqwvtmp(ngs)
13025 real tempc(ngs)
13026 real temg(ngs),temcg(ngs),theta(ngs),qvap(ngs)
13027 real temgkm1(ngs), temgkm2(ngs)
13028 real temgx(ngs),temcgx(ngs)
13029 real qvs(ngs),qis(ngs),qss(ngs),pqs(ngs)
13030 real elv(ngs),elf(ngs),els(ngs)
13031 real tsqr(ngs),ssi(ngs),ssw(ngs),ssi0(ngs)
13032 real qcwtmp(ngs),qtmp,qtot(ngs)
13033 real qcond(ngs)
13034 real ctmp, sctmp
13035 real cimasn,cimasx,ccimx
13036 real pid4
13037 real cs,ds,gf7,gf6,gf5,gf4,gf3,gf2,gf1
13038 real gcnup1,gcnup2
13039 real gf73rds, gf83rds
13040 real gamice73fac, gamsnow73fac
13041 real gf43rds, gf53rds
13042 real aradcw,bradcw,cradcw,dradcw,cwrad,rwrad,rwradmn
13043 parameter( rwradmn = 50.e-6 )
13044 real dh0
13045 real dg0(ngs),df0(ngs)
13046 real dhwet(ngs),dhlwet(ngs),dfwet(ngs)
13047
13048 real clionpmx,clionnmx
13049 parameter(clionpmx=1.e9,clionnmx=1.e9) ! Takahashi 84
13050!
13051! other arrays
13052
13053 real fwet1(ngs),fwet2(ngs)
13054 real fmlt1(ngs),fmlt2(ngs),fmlt1e(ngs)
13055 real fvds(ngs),fvce(ngs),fiinit(ngs)
13056 real fvent(ngs),fraci(ngs),fracl(ngs)
13057!
13058 real fai(ngs),fav(ngs),fbi(ngs),fbv(ngs)
13059 real felv(ngs),fels(ngs),felf(ngs)
13060 real felvcp(ngs),felscp(ngs),felfcp(ngs)
13061 real felvpi(ngs),felspi(ngs),felfpi(ngs)
13062 real felvs(ngs),felss(ngs) ! ,felfs(ngs)
13063 real fwvdf(ngs),ftka(ngs),fthdf(ngs)
13064 real fadvisc(ngs),fakvisc(ngs)
13065 real fci(ngs),fcw(ngs) ! heat capacities of ice and liquid
13066 real fschm(ngs),fpndl(ngs)
13067 real fgamw(ngs),fgams(ngs)
13068 real fcqv1(ngs),fcqv2(ngs),fcc3(ngs)
13069
13070 real cvm,cpm,rmm
13071
13072 real, parameter :: cpv = 1885.0 ! specific heat of water vapor at constant pressure
13073!
13074 real fcci(ngs), fcip(ngs)
13075!
13076 real :: sfm1(ngs),sfm2(ngs)
13077 real :: gfm1(ngs),gfm2(ngs)
13078 real :: ffm1(ngs),ffm2(ngs)
13079 real :: hfm1(ngs),hfm2(ngs)
13080
13081 logical :: wetsfc(ngs),wetsfchl(ngs),wetsfcf(ngs)
13082 logical :: wetgrowth(ngs), wetgrowthhl(ngs), wetgrowthf(ngs)
13083
13084 real qitmp(ngs),qistmp(ngs)
13085
13086 real rzxh(ngs), rzxhl(ngs), rzxhlh(ngs), rzxhlf(ngs)
13087 real rzxs(ngs), rzxf(ngs)
13088! real axh(ngs),bxh(ngs),axhl(ngs),bxhl(ngs)
13089 real cdh(ngs),cdhl(ngs)
13090 real :: axx(ngs,lh:lhab),bxx(ngs,lh:lhab)
13091 real vt2ave(ngs)
13092
13093 real :: qcwresv(ngs), ccwresv(ngs) ! "reserved" droplet mass and number that are too small for accretion
13094
13095 real :: lfsave(ngs,6)
13096 real :: qx(ngs,lv:lhab)
13097 real :: qxw(ngs,ls:lhab)
13098 real :: qxwlg(ngs,lh:lhab)
13099 real :: chxf(ngs,lh:lhab)
13100 real :: cx(ngs,lc:lhab)
13101 real :: cxmxd(ngs,lc:lhab)
13102 real :: qxmxd(ngs,lv:lhab)
13103 real :: scx(ngs,lc:lhab)
13104 real :: xv(ngs,lc:lhab)
13105 real :: vtxbar(ngs,lc:lhab,3)
13106 real :: xmas(ngs,lc:lhab)
13107 real :: xdn(ngs,lc:lhab)
13108 real :: xdntmp(ngs,lc:lhab)
13109 real :: cdxgs(ngs,lc:lhab)
13110 real :: xdia(ngs,lc:lhab,3)
13111 real :: vtwtdia(ngs,lr:lhab) ! sweep-out volume weighted diameter
13112 real :: rarx(ngs,ls:lhab)
13113 real :: vx(ngs,li:lhab)
13114 real :: rimdn(ngs,li:lhab)
13115 real :: raindn(ngs,li:lhab)
13116 real :: alpha(ngs,lc:lhab)
13117 real :: dab0lh(ngs,lc:lhab,lc:lhab)
13118 real :: dab1lh(ngs,lc:lhab,lc:lhab)
13119 real :: zx(ngs,lr:lhab)
13120 real :: zxmxd(ngs,lr:lhab)
13121 real :: g1x(ngs,lr:lhab)
13122
13123 real :: g1xmax,g1xmin
13124 real :: qsimxdep(ngs) ! max sublimation of qi+qs+qis
13125 real :: qsimxsub(ngs) ! max depositionof qi+qs+qis
13126 logical,parameter :: DoSublimationFix = .true.
13127 real :: qrtmp(ngs),qvtmp(ngs),qctmp(ngs)
13128 real :: felvcptmp,felscptmp,qsstmp
13129 real :: thetatmp, thetaptmp, temcgtmp,qvaptmp
13130 real :: qvstmp, qisstmp, qvptmp, qitmp1, qctmp1
13131
13132 real :: galphrout
13133
13134 real ventrx(ngs)
13135 real ventrxn(ngs)
13136 real g1shr, alphashr
13137 real g1mlr, alphamlr
13138 real g1smlr, alphasmlr
13139 real massfacshr, massfacmlr
13140
13141 real :: qhgt8mm ! ice mass greater than 8mm
13142 real :: qhwgt8mm ! ice + max water mass greater than 8mm
13143 real :: qhgt10mm ! mass greater than 10mm
13144 real :: qhgt20mm ! mass greater than 20mm
13145 real :: fwmhtmp
13146! real, parameter :: fwmhtmptem = -15. ! temperature at which fwmhtmp fully switches to liquid water only being on large particles
13147 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
13148 real, parameter :: srasheym = 0.1389 ! slope fraction from Rasmussen and Heymsfield
13149 real :: dtmp
13150!
13151 real swvent(ngs),hwvent(ngs),rwvent(ngs),hlvent(ngs),hwventy(ngs),hlventy(ngs),rwventz(ngs)
13152 real hxventtmp
13153 real hlventinc(ngs),hwventinc(ngs)
13154 integer, parameter :: ndiam = 10
13155 integer :: numdiam
13156 real hwvent0(ndiam+4),hlvent0 ! 0 to d1
13157 real hwvent1,hlvent1 ! d1 to infinity
13158 real hwvent2,hlvent2 ! d2 to infinity
13159 real gama0,gamb0
13160 real gama1,gamb1
13161 real gama2,gamb2
13162! real, parameter :: mltdiam1 = 9.0e-3, mltdiam1p5 = 16.0e-3, mltdiam2 = 19.0e-3, mltdiam3 = 200.0e-3, mltdiam05 = 4.5e-3
13163 real :: mltdiam(ndiam+4)
13164 real mltmass0inv,mltmass1inv,mltmass2inv, mltmass1cgs, mltmass2cgs,mltmass3inv, mltmass3cgs
13165 real qhmlr0, qhmlr05, qhmlr1, qhmlr2,qhmlr3, qhmlr12, qhmlr23
13166 real qhlmlr0, qhlmlr05, qhlmlr1, qhlmlr2,qhlmlr3, qhlmlr12, qhlmlr23
13167 real qxd1, cxd1, zxd1 ! mass and number up to mltdiam1
13168 real qxd05, cxd05 ! mass and number up to mltdiam1/2
13169 real :: qrbreak, crbreaksmall, crbreak, zrbreak, breakbin
13170
13171 real :: qxd(ndiam+4), cxd(ndiam+4), qhml(ndiam+4), qhml0(ndiam+4)
13172 real :: dqxd(ndiam+4), dcxd(ndiam+4), dqhml(ndiam+4)
13173
13174
13175 real civent(ngs)
13176 real isvent(ngs)
13177!
13178 real xmascw(ngs)
13179 real xdnmx(lc:lhab), xdnmn(lc:lhab)
13180 real dnmx
13181 real :: xdiamxmas(ngs,lc:lhab)
13182!
13183 real cilen(ngs) ! ,ciplen(ngs)
13184!
13185!
13186 real rwcap(ngs),swcap(ngs)
13187 real hwcap(ngs)
13188 real hlcap(ngs)
13189 real cicap(ngs)
13190 real iscap(ngs)
13191
13192 real qvimxd(ngs)
13193 real qimxd(ngs),qismxd(ngs),qcmxd(ngs),qrmxd(ngs),qsmxd(ngs),qhmxd(ngs),qhlmxd(ngs)
13194 real cimxd(ngs),ccmxd(ngs),crmxd(ngs),csmxd(ngs),chmxd(ngs)
13195 real cionpmxd(ngs),cionnmxd(ngs)
13196 real clionpmxd(ngs),clionnmxd(ngs)
13197
13198
13199 real elec(-nor+ng1:nx+nor,-nor+ng1:ny+nor,-norz+ng1:nz+norz) ! Ez (elecsave)
13200
13201!
13202!
13203 ! Hallett-Mossop arrays
13204 real chmul1(ngs),chlmul1(ngs),csmul1(ngs),csmul(ngs)
13205 real qhmul1(ngs),qhlmul1(ngs),qsmul1(ngs),qsmul(ngs)
13206
13207 ! splinters from drop freezing
13208 real csplinter(ngs),qsplinter(ngs)
13209 real csplinter2(ngs),qsplinter2(ngs)
13210!
13211!
13212! concentration arrays...
13213!
13214 real :: chlcnh(ngs), vhlcnh(ngs), vhlcnhl(ngs)
13215 real :: chlcnhhl(ngs) ! number of new hail particles (may be different from number of lost graupel)
13216 real cracif(ngs), ciacrf(ngs)
13217 real cracr(ngs)
13218
13219!
13220 real ciint(ngs), crfrz(ngs), crfrzf(ngs), crfrzs(ngs)
13221 real cicint(ngs)
13222 real cipint(ngs)
13223 real ciacw(ngs), cwacii(ngs)
13224 real ciacr(ngs), craci(ngs)
13225 real csacw(ngs)
13226 real csacr(ngs)
13227 real csaci(ngs), csacs(ngs)
13228 real cracw(ngs)
13229 real chacw(ngs), chacr(ngs)
13230 real :: chlacw(ngs)
13231 real chaci(ngs), chacs(ngs)
13232!
13233 real :: chlacr(ngs)
13234 real :: chlaci(ngs), chlacs(ngs)
13235 real crcnw(ngs)
13236 real cidpv(ngs),cisbv(ngs)
13237 real cisdpv(ngs),cissbv(ngs)
13238 real cimlr(ngs),cismlr(ngs)
13239
13240 real chlsbv(ngs), chldpv(ngs)
13241 real chlmlr(ngs), chlmlrr(ngs)
13242 real chlfmlr(ngs)
13243! real chlmlrsave(ngs),chlsave(ngs),qhlsave(ngs)
13244 real chlshr(ngs), chlshrr(ngs)
13245
13246
13247 real chdpv(ngs),chsbv(ngs)
13248 real chmlr(ngs),chcev(ngs)
13249 real chmlrr(ngs)
13250 real chshr(ngs), chshrr(ngs)
13251
13252 real csdpv(ngs),cssbv(ngs)
13253 real csmlr(ngs),csmlrr(ngs),cscev(ngs)
13254 real csshr(ngs), csshrr(ngs)
13255
13256 real crcev(ngs)
13257 real crshr(ngs)
13258 real cwshw(ngs), qwshw(ngs)
13259!
13260!
13261! arrays for w-ac-x ; x-ac-w
13262!
13263!
13264!
13265 real qrcnw(ngs), qwcnr(ngs)
13266 real zrcnw(ngs),zracr(ngs),zracw(ngs),zrcev(ngs)
13267
13268 real qracw(ngs) ! qwacr(ngs),
13269 real qiacw(ngs) !, qwaci(ngs)
13270
13271 real qsacw(ngs) ! ,qwacs(ngs),
13272 real qhacw(ngs) ! qwach(ngs),
13273 real :: qhlacw(ngs), qxacwtmp, qxacrtmp, qxacitmp, qxacstmp !
13274 real vhacw(ngs), vsacw(ngs), vhlacw(ngs), vhlacr(ngs)
13275
13276 real qfcev(ngs)
13277 real qfmul1(ngs),cfmul1(ngs)
13278!
13279 real qsacws(ngs)
13280
13281!
13282! arrays for x-ac-r and r-ac-x;
13283!
13284 real qsacr(ngs),qracs(ngs)
13285 real qhacr(ngs),qhacrmlr(ngs),qhacwmlr(ngs) ! ,qrach(ngs)
13286 real vhacr(ngs), zhacr(ngs), zhacrf(ngs), zrach(ngs), zrachl(ngs)
13287 real qiacr(ngs),qraci(ngs)
13288
13289 real ziacr(ngs)
13290
13291 real qracif(ngs),qiacrf(ngs),qiacrs(ngs),ciacrs(ngs)
13292
13293 real :: qhlacr(ngs),qhlacrmlr(ngs), qhlacwmlr(ngs)
13294 real qsacrs(ngs) !,qracss(ngs)
13295!
13296! ice - ice interactions
13297!
13298 real qsaci(ngs)
13299 real qsacis(ngs)
13300 real csacis(ngs)
13301 real qhaci(ngs)
13302 real qhacs(ngs)
13303
13304 real :: qhacis(ngs)
13305 real :: chacis(ngs)
13306 real :: chacis0(ngs)
13307
13308 real :: csaci0(ngs) ! collision rate only
13309 real :: csacis0(ngs) ! collision rate only
13310 real :: chaci0(ngs) ! collision rate only
13311 real :: chacs0(ngs) ! collision rate only
13312 real :: chlaci0(ngs)
13313 real :: chlacis(ngs)
13314 real :: chlacis0(ngs)
13315 real :: chlacs0(ngs)
13316
13317 real :: qsaci0(ngs) ! collision rate only
13318 real :: qsacis0(ngs) ! collision rate only
13319 real :: qhaci0(ngs) ! collision rate only
13320 real :: qhacis0(ngs) ! collision rate only
13321 real :: qhacs0(ngs) ! collision rate only
13322 real :: qhlaci0(ngs)
13323 real :: qhlacis0(ngs)
13324 real :: qhlacs0(ngs)
13325
13326 real :: qhlaci(ngs)
13327 real :: qhlacis(ngs)
13328 real :: qhlacs(ngs)
13329!
13330! conversions
13331!
13332 real qrfrz(ngs) ! , qirirhr(ngs)
13333 real zrfrz(ngs), zrfrzf(ngs), zrfrzs(ngs)
13334 real ziacrf(ngs), zhcnsh(ngs), zhcnih(ngs)
13335 real zhacw(ngs), zhacs(ngs), zhaci(ngs)
13336 real zhmlr(ngs), zhdsv(ngs), zhsbv(ngs), zhlcnh(ngs), zhshr(ngs)
13337 real zfacw(ngs), zfacs(ngs), zfaci(ngs)
13338 real zfmlr(ngs), zfdsv(ngs), zfsbv(ngs), zhlcnf(ngs), zfshr(ngs), zfshrr(ngs)
13339 real zhmlrtmp,zhmlr0inf,zhlmlr0inf
13340 real zhmlrr(ngs),zhlmlrr(ngs),zhshrr(ngs),zhlshrr(ngs),zfmlrr(ngs)
13341! real zsmlr(ngs)
13342 real zsmlrr(ngs), zsshr(ngs), zsshrr(ngs)
13343 real zhcns(ngs), zhcni(ngs)
13344 real zhwdn(ngs), zfwdn(ngs) ! change in Z due to density changes
13345 real zhldn(ngs) ! change in Z due to density changes
13346
13347 real zhlacw(ngs), zhlacs(ngs), zhlacr(ngs)
13348 real zhlmlr(ngs), zhldsv(ngs), zhlsbv(ngs), zhlshr(ngs)
13349
13350
13351 real vrfrzf(ngs), viacrf(ngs)
13352 real qrfrzs(ngs), qrfrzf(ngs)
13353 real qwfrz(ngs), qwctfz(ngs)
13354 real cwfrz(ngs), cwctfz(ngs)
13355 real qwfrzis(ngs), qwctfzis(ngs) ! droplet freezing to ice spheres
13356 real cwfrzis(ngs), cwctfzis(ngs)
13357 real qwfrzc(ngs), qwctfzc(ngs) ! droplet freezing to columns
13358 real cwfrzc(ngs), cwctfzc(ngs)
13359 real qwfrzp(ngs), qwctfzp(ngs) ! droplet freezing to plates
13360 real cwfrzp(ngs), cwctfzp(ngs)
13361 real xcolmn(ngs), xplate(ngs)
13362 real ciihr(ngs), qiihr(ngs)
13363 real cicichr(ngs), qicichr(ngs)
13364 real cipiphr(ngs), qipiphr(ngs)
13365 real qscni(ngs), cscni(ngs), cscnis(ngs)
13366 real qscnvi(ngs), cscnvi(ngs), cscnvis(ngs)
13367 real qhcns(ngs), chcns(ngs), chcnsh(ngs), vhcns(ngs)
13368 real qscnh(ngs), cscnh(ngs), vscnh(ngs)
13369 real qhcni(ngs), chcni(ngs), chcnih(ngs), vhcni(ngs)
13370 real qiint(ngs),qipipnt(ngs),qicicnt(ngs)
13371 real cninm(ngs),cnina(ngs),cninp(ngs),wvel(ngs),wvelkm1(ngs)
13372 real tke(ngs)
13373 real uvel(ngs),vvel(ngs)
13374!
13375 real qidpv(ngs),qisbv(ngs) ! qicnv(ngs),qievv(ngs),
13376 real qimlr(ngs),qidsv(ngs),qisdsv(ngs),qidsvp(ngs) ! ,qicev(ngs)
13377 real qismlr(ngs)
13378
13379!
13380!
13381 real :: qhldpv(ngs), qhlsbv(ngs) ! qhlcnv(ngs),qhlevv(ngs),
13382 real :: qhlmlr(ngs), qhldsv(ngs), qhlmlrsave(ngs)
13383 real :: qhlwet(ngs), qhldry(ngs), qhlshr(ngs), qxwettmp
13384!
13385 real :: qrfz(ngs),qsfz(ngs),qhfz(ngs),qhlfz(ngs)
13386 real :: qffz(ngs)
13387!
13388 real qhdpv(ngs),qhsbv(ngs) ! qhcnv(ngs),qhevv(ngs),
13389 real qhmlr(ngs),qhdsv(ngs),qhcev(ngs),qhcndv(ngs),qhevv(ngs)
13390 real qhlcev(ngs), chlcev(ngs)
13391 real qhwet(ngs),qhdry(ngs),qhshr(ngs)
13392 real qhshrp(ngs)
13393 real qhshh(ngs) !accreted water that remains on graupel
13394 real qhmlh(ngs) !melt water that remains on graupel
13395 real qhfzh(ngs) !water that freezes on mixed-phase graupel
13396 real qffzf(ngs) !water that freezes on mixed-phase FD
13397 real qhlfzhl(ngs) !water that freezes on mixed-phase hail
13398
13399 real qhmlrlg(ngs),qhlmlrlg(ngs) ! melting from the larger diameters
13400 real qhfzhlg(ngs) !water that freezes on mixed-phase graupel (large sizes)
13401 real qhlfzhllg(ngs) !water that freezes on mixed-phase hail (large sizes)
13402 real qhlcevlg(ngs), chlcevlg(ngs)
13403 real qhcevlg(ngs), chcevlg(ngs)
13404
13405 real vhfzh(ngs), vffzf(ngs) ! change in volume from water that freezes on mixed-phase graupel, frozen drops
13406 real vhlfzhl(ngs) ! change in volume from water that freezes on mixed-phase hail
13407
13408 real vhshdr(ngs) !accreted water that leaves on graupel (mixedphase)
13409 real vhlshdr(ngs) !accreted water that leaves on hail (mixedphase)
13410 real vhmlr(ngs) !melt water that leaves graupel (single phase)
13411 real vhlmlr(ngs) !melt water that leaves hail (single phase)
13412 real vhsoak(ngs) ! aquired water that seeps into graupel.
13413 real vhlsoak(ngs) ! aquired water that seeps into hail.
13414
13415!
13416 real qsdpv(ngs),qssbv(ngs) ! qscnv(ngs),qsevv(ngs),
13417 real qsmlr(ngs),qsdsv(ngs),qscev(ngs),qscndv(ngs),qsevv(ngs)
13418 real qswet(ngs),qsdry(ngs),qsshr(ngs)
13419 real qsshrp(ngs)
13420 real qsfzs(ngs)
13421!
13422!
13423 real qipdpv(ngs),qipsbv(ngs)
13424 real qipmlr(ngs),qipdsv(ngs)
13425!
13426 real qirdpv(ngs),qirsbv(ngs)
13427 real qirmlr(ngs),qirdsv(ngs),qirmlw(ngs)
13428!
13429 real qgldpv(ngs),qglsbv(ngs)
13430 real qglmlr(ngs),qgldsv(ngs)
13431 real qglwet(ngs),qgldry(ngs),qglshr(ngs)
13432 real qglshrp(ngs)
13433!
13434 real qgmdpv(ngs),qgmsbv(ngs)
13435 real qgmmlr(ngs),qgmdsv(ngs)
13436 real qgmwet(ngs),qgmdry(ngs),qgmshr(ngs)
13437 real qgmshrp(ngs)
13438 real qghdpv(ngs),qghsbv(ngs)
13439 real qghmlr(ngs),qghdsv(ngs)
13440 real qghwet(ngs),qghdry(ngs),qghshr(ngs)
13441 real qghshrp(ngs)
13442!
13443 real qrztot(ngs),qrzmax(ngs),qrzfac(ngs)
13444 real qrcev(ngs)
13445 real qrshr(ngs)
13446 real fsw(ngs),fhw(ngs),fhlw(ngs),ffw(ngs) !liquid water fractions
13447 real fswmax(ngs),fhwmax(ngs),fhlwmax(ngs) !liquid water fractions
13448 real ffwmax(ngs)
13449 real qhcnf(ngs)
13450 real :: qhlcnh(ngs)
13451 real qhcngh(ngs),qhcngm(ngs),qhcngl(ngs)
13452
13453 real :: qhcnhl(ngs), chcnhl(ngs), zhcnhl(ngs), vhcnhl(ngs) ! conversion of low-density hail back to graupel
13454
13455 real eiw(ngs),eii(ngs),eiri(ngs),eipir(ngs),eisw(ngs)
13456 real erw(ngs),esw(ngs),eglw(ngs),eghw(ngs),efw(ngs)
13457 real ehxw(ngs),ehlw(ngs),egmw(ngs),ehw(ngs)
13458 real err(ngs),esr(ngs),eglr(ngs),eghr(ngs),efr(ngs)
13459 real ehxr(ngs),ehlr(ngs),egmr(ngs)
13460 real eri(ngs),esi(ngs),esis(ngs),egli(ngs),eghi(ngs),efi(ngs),efis(ngs)
13461 real ehxi(ngs),ehli(ngs),egmi(ngs),ehi(ngs),ehis(ngs),ehlis(ngs)
13462 real ers(ngs),ess(ngs),egls(ngs),eghs(ngs),efs(ngs),ehs(ngs),ehsfac(ngs)
13463 real ehscnv(ngs)
13464 real ehxs(ngs),ehls(ngs),egms(ngs),egmip(ngs)
13465
13466 real ehsclsn(ngs),ehiclsn(ngs),ehisclsn(ngs)
13467 real efsclsn(ngs),eficlsn(ngs),efisclsn(ngs)
13468 real ehlsclsn(ngs),ehliclsn(ngs),ehlisclsn(ngs)
13469 real esiclsn(ngs),esisclsn(ngs)
13470
13471 real :: ehs_collsn = 0.5, ehi_collsn = 1.0
13472 real :: efs_collsn = 0.5, efi_collsn = 1.0
13473 real :: ehls_collsn = 1.0, ehli_collsn = 1.0
13474 real :: esi_collsn = 1.0
13475
13476 real ew(8,6)
13477 real cwr(8,2) ! radius and inverse of interval
13478 data cwr / 2.0, 3.0, 4.0, 6.0, 8.0, 10.0, 15.0, 20.0 , & ! radius
13479 & 1.0, 1.0, 0.5, 0.5, 0.5, 0.2, 0.2, 1. / ! inverse of interval
13480 integer icwr(ngs), igwr(ngs), irwr(ngs), ihlr(ngs), ifwr(ngs)
13481 real grad(6,2) ! graupel radius and inverse of interval
13482 data grad / 100., 200., 300., 400., 600., 1000., &
13483 & 1.e-2,1.e-2,1.e-2,5.e-3,2.5e-3, 1. /
13484!droplet radius: 2 3 4 6 8 10 15 20
13485 data ew /0.03, 0.07, 0.17, 0.41, 0.58, 0.69, 0.82, 0.88, & ! 100
13486! : 0.07, 0.13, 0.27, 0.48, 0.65, 0.73, 0.84, 0.91, ! 150
13487 & 0.10, 0.20, 0.34, 0.58, 0.70, 0.78, 0.88, 0.92, & ! 200
13488 & 0.15, 0.31, 0.44, 0.65, 0.75, 0.83, 0.96, 0.91, & ! 300
13489 & 0.17, 0.37, 0.50, 0.70, 0.81, 0.87, 0.93, 0.96, & ! 400
13490 & 0.17, 0.40, 0.54, 0.71, 0.83, 0.88, 0.94, 0.98, & ! 600
13491 & 0.15, 0.37, 0.52, 0.74, 0.82, 0.88, 0.94, 0.98 / ! 1000
13492! : 0.11, 0.34, 0.49, 0.71, 0.83, 0.88, 0.94, 0.95 / ! 1400
13493
13494
13495 real da0lr(ngs),da1lr(ngs)
13496 real da0lc(ngs),da1lc(ngs)
13497 real da0lh(ngs)
13498 real da0lhl(ngs)
13499 real da0lf(ngs)
13500 real :: da0lx(ngs,lr:lhab)
13501
13502 real va0 (lc:lqmx) ! collection coefficients from Seifert 2005
13503 real vab0(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
13504 real vab1(lc:lqmx,lc:lqmx) ! collection coefficients from Seifert 2005
13505 real va1 (lc:lqmx) ! collection coefficients from Seifert 2005
13506 real ehip(ngs),ehlip(ngs),ehlir(ngs)
13507 real erir(ngs),esir(ngs),eglir(ngs),egmir(ngs),eghir(ngs)
13508 real efir(ngs),ehir(ngs),eirw(ngs),eirir(ngs),ehr(ngs)
13509 real erip(ngs),esip(ngs),eglip(ngs),eghip(ngs)
13510 real efip(ngs),eipi(ngs),eipw(ngs),eipip(ngs)
13511!
13512! arrays for production terms
13513!
13514 real ptotal(ngs) ! , pqtot(ngs)
13515!
13516 real pqcwi(ngs),pqcii(ngs),pqrwi(ngs),pqisi(ngs)
13517 real pqswi(ngs),pqhwi(ngs),pqwvi(ngs)
13518 real pqgli(ngs),pqghi(ngs),pqfwi(ngs)
13519 real pqgmi(ngs),pqhli(ngs) ! ,pqhxi(ngs)
13520 real pqiri(ngs),pqipi(ngs) ! pqwai(ngs),
13521 real pqlwsi(ngs),pqlwhi(ngs),pqlwhli(ngs),pqlwfi(ngs)
13522
13523 real pqlwlghi(ngs),pqlwlghli(ngs)
13524 real pqlwlghd(ngs),pqlwlghld(ngs)
13525
13526
13527
13528
13529 real pvhwi(ngs), pvhwd(ngs)
13530 real pvfwi(ngs), pvfwd(ngs)
13531 real pvhli(ngs), pvhld(ngs)
13532 real pvswi(ngs), pvswd(ngs)
13533!
13534 real pqcwd(ngs),pqcid(ngs),pqrwd(ngs),pqisd(ngs), pqcwdacc(ngs)
13535 real pqswd(ngs),pqhwd(ngs),pqwvd(ngs)
13536 real pqgld(ngs),pqghd(ngs),pqfwd(ngs)
13537 real pqgmd(ngs),pqhld(ngs) ! ,pqhxd(ngs)
13538 real pqird(ngs),pqipd(ngs) ! pqwad(ngs),
13539 real pqlwsd(ngs),pqlwhd(ngs),pqlwhld(ngs),pqlwfd(ngs)
13540!
13541! real pqxii(ngs,nhab),pqxid(ngs,nhab)
13542!
13543 real pctot(ngs)
13544 real pcipi(ngs), pcipd(ngs)
13545 real pciri(ngs), pcird(ngs)
13546 real pccwi(ngs), pccwd(ngs), pccwdacc(ngs)
13547 real pccii(ngs), pccid(ngs)
13548 real pcisi(ngs), pcisd(ngs)
13549 real pccin(ngs)
13550 real pcrwi(ngs), pcrwd(ngs)
13551 real pcswi(ngs), pcswd(ngs)
13552 real pchwi(ngs), pchwd(ngs)
13553 real pchli(ngs), pchld(ngs)
13554 real pcfwi(ngs), pcfwd(ngs)
13555 real pcgli(ngs), pcgld(ngs)
13556 real pcgmi(ngs), pcgmd(ngs)
13557 real pcghi(ngs), pcghd(ngs)
13558
13559 real pzrwi(ngs), pzrwd(ngs)
13560 real pzhwi(ngs), pzhwd(ngs)
13561 real pzfwi(ngs), pzfwd(ngs)
13562 real pzhli(ngs), pzhld(ngs)
13563 real pzswi(ngs), pzswd(ngs)
13564
13565!
13566! other arrays
13567!
13568 real dqisdt(ngs) !,advisc(ngs) !dqwsdt(ngs), ,schm(ngs),pndl(ngs)
13569
13570 real qss0(ngs)
13571
13572 real qsacip(ngs)
13573 real pres(ngs),pipert(ngs)
13574 real pk(ngs)
13575 real rho0(ngs),pi0(ngs)
13576 real rhovt(ngs),sqrtrhovt
13577 real thetap(ngs),theta0(ngs),qwvp(ngs),qv0(ngs)
13578 real thsave(ngs)
13579 real ptwfzi(ngs),ptimlw(ngs)
13580 real psub(ngs),pvap(ngs),pfrz(ngs),ptem(ngs),pmlt(ngs),pevap(ngs),pdep(ngs),ptem2(ngs)
13581
13582 real cnostmp(ngs) ! for diagnosed snow intercept
13583!
13584! iholef = 1 to do hole filling technique version 1
13585! which uses all hydrometerors to do hole filling of all hydrometeors
13586! iholef = 2 to do hole filling technique version 2
13587! which uses an individual hydrometeror species to do hole
13588! filling of a species of a hydrometeor
13589!
13590! iholen = interval that hole filling is done
13591!
13592 integer iholef
13593 integer iholen
13594 parameter(iholef = 1)
13595 parameter(iholen = 1)
13596 real cqtotn,cqtotn1
13597 real cctotn
13598 real citotn
13599 real crtotn
13600 real cstotn
13601 real cvtotn
13602 real cftotn
13603 real cgltotn
13604 real cghtotn
13605 real chtotn
13606 real cqtotp,cqtotp1
13607 real cctotp
13608 real citotp
13609 real ciptotp
13610 real crtotp
13611 real cstotp
13612 real cvtotp
13613 real cftotp
13614 real chltotp
13615 real cgltotp
13616 real cgmtotp
13617 real cghtotp
13618 real chtotp
13619 real cqfac
13620 real ccfac
13621 real cifac
13622 real cipfac
13623 real crfac
13624 real csfac
13625 real cvfac
13626 real cffac
13627 real cglfac
13628 real cghfac
13629 real chfac
13630
13631 real ssifac, qvapor
13632!
13633! Miscellaneous variables
13634!
13635 real, parameter :: cwmas30 = 1000.*0.523599*(2.*30.e-6)**3 ! mass of 30-micron radius droplet, for sat. adj.
13636 real, parameter :: cwmas20 = 1000.*0.523599*(2.*20.e-6)**3 ! mass of 20-micron radius droplet, for sat. adj.
13637 integer ireadqf,lrho,lqsw,lqgl,lqgm ,lqgh
13638 integer lqrw
13639 real vt
13640 real arg ! gamma is a function
13641 real erbnd1, fdgt1, costhe1
13642 real qeps
13643 real dyi2,dzi2,bta1,cnit,dragh,dnz00,pii ! ,cp608
13644 real qccrit,gf4br,gf4ds,gf4p5, gf3ds, gf1ds
13645 real gf1palp(ngs) ! for storing Gamma[1.0 + alphar]
13646
13647
13648 real xdn0(lc:lhab)
13649 real xdn_new,drhodt
13650
13651 integer l ,ltemq,inumgs, idelq
13652
13653 real brz,arz,temq
13654
13655 real ssival,tqvcon
13656 real cdx(lc:lhab)
13657 real cnox
13658 real cval,aval,eval,fval,gval ,qsign,ftelwc,qconkq,elecfac,altelecfac
13659 real qconm,qconn,cfce15,gf8,gf4i,gf3p5,gf1a,gf1p5,qdiff,argrcnw
13660 real c4,bradp,bl2,bt2,dthr,hrifac, hdia0,hdia1,civenta,civentb
13661 real civentc,civentd,civente,civentf,civentg,cireyn,xcivent
13662 real cipventa,cipventb,cipventc,cipventd,cipreyn,cirventa
13663 real cirventb
13664 integer igmrwa,igmrwb,igmswa, igmswb,igmfwa,igmfwb,igmhwa,igmhwb
13665 real rwventa ,rwventb,swventa,swventb,fwventa,fwventb,fwventc
13666 real hwventa,hwventb
13667 real hwventc, hlventa, hlventb, hlventc
13668 real glventa, glventb, glventc
13669 real gmventa, gmventb, gmventc, ghventa, ghventb, ghventc
13670 real dzfacp, dzfacm, cmassin, cwdiar
13671 real rimmas, rhobar
13672 real argtim, argqcw, argqxw, argtem
13673 real frcswsw, frcswgl, frcswgm, frcswgh, frcswfw, frcswsw1
13674 real frcglgl, frcglgm, frcglgh, frcglfw, frcglgl1
13675 real frcgmgl, frcgmgm, frcgmgh, frcgmfw, frcgmgm1
13676 real frcghgl, frcghgm, frcghgh, frcghfw, frcghgh1
13677 real frcfwgl, frcfwgm, frcfwgh, frcfwfw, frcfwfw1
13678 real frcswrsw, frcswrgl, frcswrgm, frcswrgh, frcswrfw
13679 real frcswrsw1
13680 real frcrswsw, frcrswgl, frcrswgm, frcrswgh, frcrswfw
13681 real frcrswsw1
13682 real frcglrgl, frcglrgm, frcglrgh, frcglrfw, frcglrgl1
13683 real frcrglgl
13684 real frcrglgm, frcrglgh, frcrglfw, frcrglgl1
13685 real frcgmrgl, frcgmrgm, frcgmrgh, frcgmrfw, frcgmrgm1
13686 real frcrgmgl, frcrgmgm, frcrgmgh, frcrgmfw, frcrgmgm1
13687 real total, qweps, gf2a, gf4a, dqldt, dqidt, dqdt
13688 real frcghrgl, frcghrgm, frcghrgh, frcghrfw, frcghrgh1, frcrghgl
13689 real frcrghgm, frcrghgh, frcrghfw, frcrghgh1
13690 real a1,a2,a3,a4,a5,a6
13691 real gamss
13692 real cdw, cdi, denom1, denom2, delqci1, delqip1
13693 real cirtotn, ciptotn, cgmtotn, chltotn, cirtotp
13694 real cgmfac, chlfac, cirfac
13695 integer igmhla, igmhlb, igmgla, igmglb, igmgma, igmgmb
13696 integer igmgha, igmghb
13697 integer idqis, item, itim0
13698 integer iqgl, iqgm, iqgh, iqrw, iqsw
13699 integer itertd, ia
13700
13701 integer :: infdo
13702
13703 real tau, ewtmp
13704
13705 integer cntnic_noliq
13706 real q_noliqmn, q_noliqmx
13707 real scsacimn, scsacimx
13708
13709 real :: dtpinv
13710
13711! arrays for temporary bin space
13712
13713 real :: xden,xmlt,cmlt,cmlttot,fventm,fventh,am,ah,felfinv,dmwdt
13714
13715 real :: qhmlrtmp,qhmlrtmp2, chmlrtmp, chmlrtmpd1inf, chlmlrtmp, zhlmlrtmp, zhlmlrrtmp, qvs0,tmpcmlt
13716
13717 real :: term1,term2,term3,term4
13718 real :: qaacw ! combined qsacw-qhacw for WSM6 variation
13719 real :: cwchtmp
13720
13721 real, parameter :: c1r=19.0, c2r=0.6, c3r=1.8, c4r=17.0 ! rain
13722 real, parameter :: c1h=5.5, c2h=0.7, c3h=4.5, c4h=8.5 ! Graupel
13723 real, parameter :: c1hl=3.7, c2hl=0.3, c3hl=9.0, c4hl=6.5, c5hl=1.0, c6hl=6.5 ! Hail
13724
13725
13726! inline functions for Newton method
13727 real :: galpha, dgalpha
13728 real :: a_in
13729 logical, parameter :: newton = .false.
13730
13731
13732 galpha(a_in) = ((4. + a_in)*(5. + a_in)*(6. + a_in))/((1. + a_in)*(2. + a_in)*(3. + a_in))
13733 dgalpha(a_in) = (876. + 1260.*a_in + 621.*a_in**2 + 126.*a_in**3 + 9.*a_in**4)/ &
13734 & (36. + 132.*a_in + 193.*a_in**2 + 144.*a_in**3 + 58.*a_in**4 + 12.*a_in**5 + a_in**6)
13735!
13736! ####################################################################
13737!
13738! Start routine
13739!
13740! ####################################################################
13741
13742
13743
13744!
13745
13746 pb(:) = 0.0
13747 pinit(:) = 0.0
13748 itile = nx
13749 jtile = ny
13750 ktile = nz
13751 ixend = nx
13752 jyend = ny
13753 kzend = nz
13754 nxend = nx + 1
13755 nyend = ny + 1
13756 nzend = nz
13757 kzbeg = 1
13758 nzbeg = 1
13759
13760 istag = 0
13761 jstag = 0
13762 kstag = 1
13763
13764 lrescalelow(:) = rescale_low_alpha
13765 lrescalelow(lr) = rescale_low_alphar .and. rescale_low_alpha
13766 lrescalelow(lh) = rescale_low_alphah .and. rescale_low_alpha
13767 IF ( lf > 1 ) lrescalelow(lf) = rescale_low_alphah .and. rescale_low_alpha
13768 IF ( lhl > 1 ) lrescalelow(lhl) = rescale_low_alphahl .and. rescale_low_alpha
13769
13770
13771!
13772! slope intercepts
13773!
13774
13775 IF ( ngs .lt. nz ) THEN
13776! write(0,*) 'Error in ICEZVD: Must have ngs .ge. nz!'
13777! STOP
13778 ENDIF
13779
13780 cntnic_noliq = 0
13781 q_noliqmn = 0.0
13782 q_noliqmx = 0.0
13783 scsacimn = 0.0
13784 scsacimx = 0.0
13785
13786 ldovol = .false.
13787
13788 DO il = lc,lhab
13789 ldovol = ldovol .or. ( lvol(il) .gt. 1 )
13790 ENDDO
13791
13792
13793 ffrzh = 1
13794! DO il = lc,lhab
13795! write(iunit,*) 'delqnxa(',il,') = ',delqnxa(il)
13796! ENDDO
13797
13798!
13799! density maximums and minimums
13800!
13801
13802!
13803! Set terminal velocities...
13804! also set drag coefficients
13805!
13806
13807 dtpinv = 1.d0/dtp
13808
13809!
13810
13811!
13812! electricity constants
13813!
13814! mixing ratio epsilon
13815!
13816 qeps = 1.0e-20
13817
13818! rebound efficiency (erbnd)
13819!
13820!
13821!
13822! constants
13823!
13824
13825! cp608 = 0.608
13826 aradcw = -0.27544
13827 bradcw = 0.26249e+06
13828 cradcw = -1.8896e+10
13829 dradcw = 4.4626e+14
13830 bta1 = 0.6
13831 cnit = 1.0e-02
13832 dragh = 0.60
13833 dnz00 = 1.225
13834! cs = 4.83607122
13835! ds = 0.25
13836! new values for cs and ds
13837 cs = 12.42
13838 ds = 0.42
13839 pii = piinv ! 1./pi
13840 pid4 = pi/4.0
13841! qscrit = 6.0e-04
13842 gf1 = 1.0 ! gamma(1.0)
13843 gf1p5 = 0.8862269255 ! gamma(1.5)
13844 gf2 = 1.0 ! gamma(2.0)
13845 gf3 = 2.0 ! gamma(3.0)
13846 gf3p5 = 3.32335097 ! gamma(3.5)
13847 gf4 = 6.00 ! gamma(4.0)
13848 gf5 = 24.0 ! gamma(5.0)
13849 gf6 = 120.0 ! gamma(6.0)
13850 gf7 = 720.0 ! gamma(7.0)
13851 gf4br = 17.837861981813607 ! gamma(4.0+br)
13852 gf4ds = 10.41688578110938 ! gamma(4.0+ds)
13853 gf4p5 = 11.63172839656745 ! gamma(4.0+0.5)
13854 gf3ds = 3.0458730354120997 ! gamma(3.0+ds)
13855 gf1ds = 0.8863557896089221 ! gamma(1.0+ds)
13856
13857 gf43rds = 0.8929795116 ! gamma(4./3.)
13858 gf53rds = 0.9027452930 ! gamma(5./3.)
13859 gf73rds = 1.190639349 ! gamma(7./3.)
13860 gf83rds = 1.504575488 ! gamma(8./3.)
13861
13862 gamice73fac = (gamma_sp(7./3. + cinu))**3/ (gamma_sp(1. + cinu)**3 * (1. + cinu)**4)
13863 gamsnow73fac = (gamma_sp(7./3. + snu))**3/ (gamma_sp(1. + snu)**3 * (1. + snu)**4)
13864
13865! gcnup1 = Gamma_sp(cnu + 1.)
13866! gcnup2 = Gamma_sp(cnu + 2.)
13867!
13868! constants
13869!
13870!
13871! general constants for microphysics
13872!
13873 brz = 100.0
13874 arz = 0.66
13875
13876 bfnu1 = (4. + alphar)*(5. + alphar)*(6. + alphar)/ &
13877 & ((1. + alphar)*(2. + alphar)*(3. + alphar))
13878
13879 galpharaut = (6.+alpharaut)*(5.+alpharaut)*(4.+alpharaut)/ &
13880 & ((3.+alpharaut)*(2.+alpharaut)*(1.+alpharaut))
13881
13882 vfrz = 0.523599*(dfrz)**3
13883 vmlt = min(xvmx(lr), 0.523599*(dmlt)**3 )
13884 vshd = min(xvmx(lr), 0.523599*(dshd)**3 )
13885
13886 IF ( snowmeltdia > 0.0 ) THEN
13887 snowmeltmass = pi/6.0 * 1000. * snowmeltdia**3 ! maximum rain particle mass from melting snow (if snowmeltdia > 0)
13888 ENDIF
13889
13890 tdtol = 1.0e-05
13891 tfrcbw = tfr - cbw
13892 tfrcbi = tfr - cbi
13893
13894 IF ( mixedphase ) THEN
13895 ibinhmlr = 0
13896 ibinhlmlr = 0
13897 ENDIF
13898!
13899!
13900! #ifdef COMMAS
13901! print*,'ventr,ventc = ',ventr,ventc
13902
13903!
13904! Set up look up tables for supersaturation w.r.t. liq and ice
13905!
13906!VD$L SKIP
13907! do l = 1,nqsat
13908! temq = 163.15 + (l-1)*fqsat
13909! tabqvs(l) = exp(caw*(temq-273.15)/(temq-cbw))
13910! tabqis(l) = exp(cai*(temq-273.15)/(temq-cbi))
13911! end do
13912
13913 mltmass0inv = 1.0/( 1000.0* xvmx(lr) ) ! for drops melting from ice with diameter > 1.9cm
13914 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
13915 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)
13916 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
13917 mltmass1cgs = 1.0*(4.0*pi/3.0)*((0.5*takshedsize1)**3)
13918 mltmass2cgs = 1.0*(4.0*pi/3.0)*((0.5*takshedsize2)**3)
13919 mltmass3cgs = 1.0*(4.0*pi/3.0)*((0.5*takshedsize3)**3)
13920
13921! real, parameter :: mltdiam1 = 9.0e-3, mltdiam2 = 19.0e-3, mltdiam05 = 4.5e-3
13922
13923 IF ( ibinnum == 1 ) THEN
13924 numdiam = 1 ! must have numdiam < ndiam because numdiam+1 holds values for the interval of mltdiam(numdiam) to mltdiam(ndiam+1)
13925 mltdiam(1) = 4.5e-3
13926 ELSEIF ( ibinnum == 2 ) THEN
13927 numdiam = 2 ! must have numdiam < ndiam because numdiam+1 holds values for the interval of mltdiam(numdiam) to mltdiam(ndiam+1)
13928 mltdiam(1) = mltdiam1/6. ! 1.5e-3
13929 mltdiam(2) = mltdiam1/2. ! 4.5e-3
13930 ELSEIF ( ibinnum > 2 ) THEN
13931 numdiam = min(ibinnum, ndiam)
13932 DO k = 1,numdiam
13933 mltdiam(k) = (k - 0.5)*mltdiam1/float(numdiam)
13934 ENDDO
13935
13936 ELSE
13937 numdiam = 5 ! must have numdiam < ndiam because numdiam+1 holds values for the interval of mltdiam(numdiam) to mltdiam(ndiam+1)
13938 mltdiam(1) = 0.5e-3
13939 mltdiam(2) = 1.0e-3
13940 mltdiam(3) = 2.0e-3
13941 mltdiam(4) = 4.0e-3
13942 mltdiam(5) = 6.0e-3
13943 ENDIF
13944
13945
13946 IF ( numshedregimes == 2 ) THEN
13947 mltdiam(ndiam+1) = mltdiam1 ! 9.0e-3
13948 mltdiam(ndiam+2) = mltdiam3 ! 19.0e-3
13949 mltdiam(ndiam+3) = mltdiam4 !100.0e-3
13950 ELSEIF ( numshedregimes == 3 ) THEN
13951 mltdiam(ndiam+1) = mltdiam1 ! 9.0e-3
13952 mltdiam(ndiam+2) = mltdiam2 ! 16.0e-3
13953 mltdiam(ndiam+3) = mltdiam3 ! 19.0e-3
13954 mltdiam(ndiam+4) = mltdiam4 !200.0e-3
13955 ENDIF
13956
13957 kzb = 1
13958 kze = ktile
13959! if (kzend .eq. nzend) kze = kzend-kzbeg+1-kstag
13960
13961!
13962! cw constants in mks units
13963!
13964! cwmasn = 4.25e-15 ! radius of 1.0e-6
13965 mwfac = 6.0**(1./3.)
13966 IF ( ipconc .ge. 2 ) THEN
13967! cwmasn = xvmn(lc)*1000.
13968! cwradn = 1.0e-6
13969! cwmasx = xvmx(lc)*1000.
13970 ENDIF
13971 rwmasn = xvmn(lr)*1000.
13972 rwmasx = xvmx(lr)*1000.
13973
13974 IF ( biggsnowdiam > 0.0 ) THEN
13975 xvbiggsnow = (pi/6.0)*biggsnowdiam**3
13976 ELSE
13977 xvbiggsnow = xvmn(lh)
13978 ENDIF
13979
13980!
13981! ci constants in mks units
13982!
13983 cimasn = min(cimas0, cimas1) ! 12 microns for 0.1871*(xmas(mgs,li)**(0.3429))
13984 cimasx = 1.0e-8 ! 338 microns
13985 ccimx = 5000.0e3 ! max of 5000 per liter
13986
13987!
13988! constants for paramerization
13989!
13990!
13991! set save counter (number of saves): nsvcnt
13992!
13993! nsvcnt = 0
13994 iend = 0
13995
13996
13997! timetd1 = etime(tarray)
13998! timetd1 = tarray(1)
13999
14000!
14001!***********************************************************
14002! start jy loop
14003!***********************************************************
14004!
14005
14006! do 9999 jy = 1,ny-jstag
14007!
14008! VERY IMPORTANT: SET jy = jgs
14009!
14010 jy = jgs
14011
14012
14013! t1(:,:,:) = 0
14014! t2(:,:,:) = 0
14015! t3(:,:,:) = 0
14016! t4(:,:,:) = 0
14017! t5(:,:,:) = 0
14018! t6(:,:,:) = 0
14019! t8(:,:,:) = 0
14020
14021 IF ( ipconc < 2 ) THEN ! Make a copy of cloud droplet mixing ratio to use for homogeneous freezing
14022 DO kz = 1,kze
14023 DO ix = 1,itile
14024 t9(ix,jy,kz) = an(ix,jy,kz,lc)
14025 ENDDO
14026 ENDDO
14027 ENDIF
14028
14029!
14030!..Gather microphysics
14031!
14032 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: ENTER GATHER STAGE'
14033
14034
14035
14036 nxmpb = 1
14037 nzmpb = 1
14038 nxz = itile*nz
14039 numgs = nxz/ngs + 1
14040! write(0,*) 'ICEZVD_GS: ENTER GATHER STAGE: nx,nz,nxz,numgs,ngs = ',nx,nz,nxz,numgs,ngs
14041
14042 do 1000 inumgs = 1,numgs
14043 ngscnt = 0
14044
14045 do kz = nzmpb,kze
14046 do ix = nxmpb,itile
14047
14048 pqs(1) = t00(ix,jy,kz)
14049 pres(1) = pn(ix,jy,kz) + pb(kz)
14050
14051 theta(1) = an(ix,jy,kz,lt)
14052 temg(1) = t0(ix,jy,kz)
14053 temcg(1) = temg(1) - tfr
14054 tqvcon = temg(1)-cbw
14055 ltemq = (temg(1)-163.15)/fqsat + 1.5
14056 ltemq = min( nqsat, max(1,ltemq) )
14057 IF ( iqvsopt == 0 ) THEN
14058 qvs(1) = pqs(1)*tabqvs(ltemq)
14059 ELSEIF ( iqvsopt == 1 ) THEN
14060 qvs(1) = rdorv*esbolton*tabqvs(ltemq)/(pres(1) - esbolton*tabqvs(ltemq))
14061 ENDIF
14062
14063 IF ( iqis0 == 1 .or. temg(1) <= tfr+0.5 ) THEN
14064 qis(1) = pqs(1)*tabqis(ltemq)
14065 ELSE
14066 ltemq = (tfr - 163.15)/fqsat + 1.5
14067 qis(1) = pqs(1)*tabqis(ltemq)
14068 ENDIF
14069
14070 qss(1) = qvs(1)
14071
14072 if ( temg(1) .lt. tfr ) then
14073 qss(1) = qis(1)
14074 end if
14075!
14076 ishail = .false.
14077 IF ( lhl > 1 ) THEN
14078 IF ( an(ix,jy,kz,lhl) .gt. qxmin(lhl) ) ishail = .true.
14079 ENDIF
14080
14081
14082
14083 if ( an(ix,jy,kz,lv) .gt. qss(1) .or. &
14084 & an(ix,jy,kz,lc) .gt. qxmin(lc) .or. &
14085 & an(ix,jy,kz,li) .gt. qxmin(li) .or. &
14086 & an(ix,jy,kz,lr) .gt. qxmin(lr) .or. &
14087 & an(ix,jy,kz,ls) .gt. qxmin(ls) .or. &
14088 & an(ix,jy,kz,lh) .gt. qxmin(lh) .or. ishail ) then
14089 ngscnt = ngscnt + 1
14090 igs(ngscnt) = ix
14091 kgs(ngscnt) = kz
14092 if ( ngscnt .eq. ngs ) goto 1100
14093 end if
14094 enddo !ix
14095 nxmpb = 1
14096 enddo !kz
14097 1100 continue
14098
14099 if ( ngscnt .eq. 0 ) go to 9998
14100
14101 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: dbg = 5, ngscnt = ',ngscnt
14102
14103! write(0,*) 'allocating qc'
14104
14105
14106 xv(:,:) = 0.0
14107 xmas(:,:) = 0.0
14108 vtxbar(:,:,:) = 0.0
14109 xdia(:,:,:) = 0.0
14110 raindn(:,:) = 900.
14111 cx(:,:) = 0.0
14112 IF ( lnhf > 1 .or. lnhlf > 1 ) chxf(:,:) = 0.0
14113 alpha(:,:) = 0.0
14114 DO il = li,lhab
14115 DO mgs = 1,ngscnt
14116 rimdn(mgs,il) = rimedens ! xdn0(il)
14117 ENDDO
14118 ENDDO
14119!
14120! define temporaries for state variables to be used in calculations
14121!
14122 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: dbg = def temps'
14123 do mgs = 1,ngscnt
14124 kgsm(mgs) = max(kgs(mgs)-1,1)
14125 kgsp(mgs) = min(kgs(mgs)+1,nz-1)
14126 kgsm2(mgs) = max(kgs(mgs)-2,1)
14127 theta0(mgs) = an(igs(mgs),jy,kgs(mgs),lt)
14128 thetap(mgs) = an(igs(mgs),jy,kgs(mgs),lt) - theta0(mgs)
14129 theta(mgs) = an(igs(mgs),jy,kgs(mgs),lt)
14130 qv0(mgs) = an(igs(mgs),jy,kgs(mgs),lv)
14131 qwvp(mgs) = an(igs(mgs),jy,kgs(mgs),lv) - qv0(mgs) ! qv0(mgs) is full qv, so qwvp starts as zero!
14132
14133 pres(mgs) = pn(igs(mgs),jy,kgs(mgs)) + pb(kgs(mgs))
14134 pipert(mgs) = p2(igs(mgs),jy,kgs(mgs))
14135 rho0(mgs) = dn(igs(mgs),jy,kgs(mgs))
14136 rhoinv(mgs) = 1.0/rho0(mgs)
14137 rhovt(mgs) = sqrt(rho00/max(0.05,rho0(mgs))) ! prevent excessive rhovt
14138 pi0(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs))
14139 temg(mgs) = t0(igs(mgs),jy,kgs(mgs))
14140 temgkm1(mgs) = t0(igs(mgs),jy,kgsm(mgs))
14141 temgkm2(mgs) = t0(igs(mgs),jy,kgsm2(mgs))
14142 pk(mgs) = p2(igs(mgs),jy,kgs(mgs)) + pinit(kgs(mgs)) ! t77(igs(mgs),jy,kgs(mgs))
14143 temcg(mgs) = temg(mgs) - tfr
14144 qss0(mgs) = (380.0)/(pres(mgs))
14145 pqs(mgs) = (380.0)/(pres(mgs))
14146 ltemq = (temg(mgs)-163.15)/fqsat+1.5
14147 ltemq = min( nqsat, max(1,ltemq) )
14148
14149 IF ( iqvsopt == 0 ) THEN
14150 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
14151 ELSEIF ( iqvsopt == 1 ) THEN
14152 qvs(mgs) = rdorv*esbolton*tabqvs(ltemq)/(pres(mgs) - esbolton*tabqvs(ltemq))
14153 ENDIF
14154
14155 IF ( iqis0 == 1 .or. temg(mgs) <= tfr+0.5 ) THEN
14156 qis(mgs) = pqs(mgs)*tabqis(ltemq)
14157 ELSE
14158 ltemq = (tfr - 163.15)/fqsat + 1.5
14159 qis(mgs) = pqs(mgs)*tabqis(ltemq)
14160 ENDIF
14161 qss(mgs) = qvs(mgs)
14162! es(mgs) = 6.1078e2*tabqvs(ltemq)
14163! eis(mgs) = 6.1078e2*tabqis(ltemq)
14164 cnostmp(mgs) = cno(ls)
14165!
14166
14167 il5(mgs) = 0
14168 if ( temg(mgs) .lt. tfr ) then
14169 il5(mgs) = 1
14170 end if
14171 enddo !mgs
14172
14173 IF ( ipconc < 1 .and. lwsm6 ) THEN
14174 DO mgs = 1,ngscnt
14175 tmp = min( 0.0, temcg(mgs) )
14176 cnostmp(mgs) = min( 2.e8, 2.e6*exp(0.12*tmp) )
14177 ENDDO
14178 ENDIF
14179
14180
14181!
14182! zero arrays that are used but not otherwise set (tm)
14183!
14184 do mgs = 1,ngscnt
14185 qhshr(mgs) = 0.0
14186 end do
14187!
14188! set temporaries for microphysics variables
14189!
14190 DO il = lv,lhab
14191 do mgs = 1,ngscnt
14192 qx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),il), 0.0)
14193 ENDDO
14194 end do
14195
14196 qxw(:,:) = 0.0
14197 qxwlg(:,:) = 0.0
14198
14199
14200
14201
14202!
14203! set concentrations
14204!
14205! ssmax = 0.0
14206
14207
14208 if ( ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) 'ICEZVD_GS: dbg = 5b'
14209
14210 if ( ipconc .ge. 1 ) then
14211 do mgs = 1,ngscnt
14212 cx(mgs,li) = max(an(igs(mgs),jy,kgs(mgs),lni), 0.0)
14213 IF ( qx(mgs,li) .le. qxmin(li) ) THEN
14214 cx(mgs,li) = 0.0
14215 ENDIF
14216
14217 IF ( lcina .gt. 1 ) THEN
14218 cina(mgs) = an(igs(mgs),jy,kgs(mgs),lcina)
14219 ELSE
14220 cina(mgs) = cx(mgs,li)
14221 ENDIF
14222 IF ( lcin > 1 ) THEN
14223 ccin(mgs) = an(igs(mgs),jy,kgs(mgs),lcin)
14224 ENDIF
14225 end do
14226 end if
14227 if ( ipconc .ge. 2 ) then
14228 do mgs = 1,ngscnt
14229 cx(mgs,lc) = max(an(igs(mgs),jy,kgs(mgs),lnc), 0.0)
14230! cx(mgs,lc) = Min( ccwmx, cx(mgs,lc) )
14231 IF ( qx(mgs,lc) .le. qxmin(lc) ) THEN
14232 cx(mgs,lc) = 0.0
14233 ENDIF
14234 IF ( lss > 1 ) THEN
14235 ssmax(mgs) = an(igs(mgs),jy,kgs(mgs),lss)
14236 ENDIF
14237 IF ( lccn .gt. 1 ) THEN
14238 ccnc(mgs) = an(igs(mgs),jy,kgs(mgs),lccn)
14239 ELSE
14240 ccnc(mgs) = 0.0
14241 ENDIF
14242 IF ( lccna .gt. 1 ) THEN
14243 ccna(mgs) = an(igs(mgs),jy,kgs(mgs),lccna)
14244 ELSE
14245 ccna(mgs) = cx(mgs,lc)
14246 ENDIF
14247 end do
14248! ELSE
14249! cx(mgs,lc) = Abs(ccn)
14250 end if
14251 if ( ipconc .ge. 3 ) then
14252 do mgs = 1,ngscnt
14253 cx(mgs,lr) = max(an(igs(mgs),jy,kgs(mgs),lnr), 0.0)
14254 IF ( qx(mgs,lr) .le. qxmin(lr) ) THEN
14255! cx(mgs,lr) = 0.0
14256 ELSEIF ( cx(mgs,lr) .eq. 0.0 .and. qx(mgs,lr) .lt. 3.0*qxmin(lr) ) THEN
14257 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,lr)
14258 qx(mgs,lr) = 0.0
14259 ELSE
14260 cx(mgs,lr) = max( 1.e-9, cx(mgs,lr) )
14261 ENDIF
14262 end do
14263 end if
14264 if ( ipconc .ge. 4 ) then
14265 do mgs = 1,ngscnt
14266 cx(mgs,ls) = max(an(igs(mgs),jy,kgs(mgs),lns), 0.0)
14267 IF ( qx(mgs,ls) .le. qxmin(ls) ) THEN
14268! cx(mgs,ls) = 0.0
14269 ELSEIF ( cx(mgs,ls) .eq. 0.0 .and. qx(mgs,ls) .lt. 3.0*qxmin(ls) ) THEN
14270 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,ls)
14271 qx(mgs,ls) = 0.0
14272 ELSE
14273 cx(mgs,ls) = max( 1.e-9, cx(mgs,ls) )
14274
14275 IF ( ilimit .ge. ipc(ls) ) THEN
14276 tmp = (xdn0(ls)*cx(mgs,ls))/(rho0(mgs)*qx(mgs,ls))
14277 tmp2 = (tmp*(3.14159))**(1./3.)
14278 cnox = cx(mgs,ls)*(tmp2)
14279 IF ( cnox .gt. 3.0*cno(ls) ) THEN
14280 cx(mgs,ls) = 3.0*cno(ls)/tmp2
14281 ENDIF
14282 ENDIF
14283 ENDIF
14284 end do
14285 end if
14286 if ( ipconc .ge. 5 ) then
14287 do mgs = 1,ngscnt
14288
14289 cx(mgs,lh) = max(an(igs(mgs),jy,kgs(mgs),lnh), 0.0)
14290 IF ( qx(mgs,lh) .le. qxmin(lh) ) THEN
14291! cx(mgs,lh) = 0.0
14292 ELSEIF ( cx(mgs,lh) .eq. 0.0 .and. qx(mgs,lh) .lt. 3.0*qxmin(lh) ) THEN
14293 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,lh)
14294 qx(mgs,lh) = 0.0
14295 ELSE
14296 cx(mgs,lh) = max( 1.e-9, cx(mgs,lh) )
14297 IF ( ilimit .ge. ipc(lh) ) THEN
14298 tmp = (xdn0(lh)*cx(mgs,lh))/(rho0(mgs)*qx(mgs,lh))
14299 tmp2 = (tmp*(3.14159))**(1./3.)
14300 cnox = cx(mgs,lh)*(tmp2)
14301 IF ( cnox .gt. 3.0*cno(lh) ) THEN
14302 cx(mgs,lh) = 3.0*cno(lh)/tmp2
14303 ENDIF
14304 ENDIF
14305 ENDIF
14306
14307
14308 end do
14309
14310
14311 end if
14312
14313 if ( lhl .gt. 1 .and. ipconc .ge. 5 ) then
14314 do mgs = 1,ngscnt
14315
14316 cx(mgs,lhl) = max(an(igs(mgs),jy,kgs(mgs),lnhl), 0.0)
14317 IF ( qx(mgs,lhl) .le. qxmin(lhl) ) THEN
14318 cx(mgs,lhl) = 0.0
14319 ELSEIF ( cx(mgs,lhl) .eq. 0.0 .and. qx(mgs,lhl) .lt. 3.0*qxmin(lhl) ) THEN
14320 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,lhl)
14321 qx(mgs,lhl) = 0.0
14322 ELSE
14323 cx(mgs,lhl) = max( 1.e-9, cx(mgs,lhl) )
14324 IF ( ilimit .ge. ipc(lhl) ) THEN
14325 tmp = (xdn0(lhl)*cx(mgs,lhl))/(rho0(mgs)*qx(mgs,lhl))
14326 tmp2 = (tmp*(3.14159))**(1./3.)
14327 cnox = cx(mgs,lhl)*(tmp2)
14328 IF ( cnox .gt. 3.0*cno(lhl) ) THEN
14329 cx(mgs,lhl) = 3.0*cno(lhl)/tmp2
14330 ENDIF
14331 ENDIF
14332 ENDIF
14333
14334
14335 end do
14336 end if
14337
14338!
14339! Set mean particle volume
14340!
14341 IF ( ldovol ) THEN
14342
14343 vx(:,:) = 0.0
14344
14345 DO il = li,lhab
14346
14347 IF ( lvol(il) .ge. 1 ) THEN
14348
14349 DO mgs = 1,ngscnt
14350 vx(mgs,il) = max(an(igs(mgs),jy,kgs(mgs),lvol(il)), 0.0)
14351 ENDDO
14352
14353 ENDIF
14354
14355 ENDDO
14356
14357 ENDIF
14358
14359
14360!
14361! Set liquid water fraction
14362!
14363 fhw(:) = 0.0
14364 fsw(:) = 0.0
14365 fhlw(:) = 0.0
14366
14367
14368
14369!
14370! 6th moments
14371!
14372
14373 IF ( ipconc .ge. 6 ) THEN
14374 zx(:,:) = 0.0
14375 DO il = lr,lhab
14376 IF ( lz(il) .gt. 1 ) THEN
14377 DO mgs = 1,ngscnt
14378 zx(mgs,il) = max( an(igs(mgs),jy,kgs(mgs),lz(il)), 0.0 )
14379 ENDDO
14380 ENDIF
14381 ENDDO
14382
14383 ENDIF
14384
14385 IF ( ipconc .ge. 6 ) THEN
14386
14387 tmp = alphamax - 1.0
14388 g1xmax = (6.0 + tmp)*(5.0 + tmp)*(4.0 + tmp)/ &
14389 & ((3.0 + tmp)*(2.0 + tmp)*(1.0 + tmp))
14390 g1xmin = (6.0 + alphamin)*(5.0 + alphamin)*(4.0 + alphamin)/ &
14391 & ((3.0 + alphamin)*(2.0 + alphamin)*(1.0 + alphamin))
14392
14393 IF ( lz(lr) .lt. 1 ) THEN
14394 g1x(:,lr) = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/ &
14395 & ((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
14396
14397
14398 DO mgs = 1,ngscnt
14399 IF ( cx(mgs,lr) .gt. 0.0 .and. qx(mgs,lr) .gt. qxmin(lr) ) THEN
14400
14401 vr = rho0(mgs)*qx(mgs,lr)/(1000.*cx(mgs,lr))
14402 IF ( lzr < 1 ) THEN
14403 IF ( imurain == 3 ) THEN
14404 zx(mgs,lr) = 3.6476*(rnu+2.0)*cx(mgs,lr)*vr**2/(rnu+1.0)
14405 ELSE ! imurain == 1
14406 zx(mgs,lr) = 3.6476*g1x(mgs,lr)*cx(mgs,lr)*vr**2
14407 ENDIF
14408 ENDIF
14409
14410 ENDIF
14411 ENDDO
14412 ENDIF
14413
14414 ENDIF
14415
14416
14417 IF ( ipconc == 5 ) THEN
14418 ! set up factors for ihlcnh=3 conversion
14419 g1x(:,lr) = (6.0 + alphar)*(5.0 + alphar)*(4.0 + alphar)/ &
14420 & ((3.0 + alphar)*(2.0 + alphar)*(1.0 + alphar))
14421 g1x(:,lh) = (6.0 + alphah)*(5.0 + alphah)*(4.0 + alphah)/ &
14422 & ((3.0 + alphah)*(2.0 + alphah)*(1.0 + alphah))
14423 IF ( lhl > 0 ) THEN
14424 g1x(:,lhl) = (6.0 + alphahl)*(5.0 + alphahl)*(4.0 + alphahl)/ &
14425 & ((3.0 + alphahl)*(2.0 + alphahl)*(1.0 + alphahl))
14426 ENDIF
14427 ENDIF
14428
14429 scx(:,:) = 0.0
14430!
14431! set shape parameters
14432!
14433 if ( ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'ICEZVD_GS: dbg = set alpha'
14434 IF ( imurain == 1 ) THEN
14435 alpha(:,lr) = alphar
14436 ELSEIF ( imurain == 3 ) THEN
14437 alpha(:,lr) = xnu(lr)
14438 ENDIF
14439
14440 alpha(:,li) = xnu(li)
14441 alpha(:,lc) = xnu(lc)
14442
14443 IF ( imusnow == 1 ) THEN
14444 alpha(:,ls) = alphas
14445 ELSEIF ( imusnow == 3 ) THEN
14446 alpha(:,ls) = xnu(ls)
14447 ENDIF
14448
14449 if ( ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'ICEZVD_GS: dbg = set dab'
14450
14451 DO il = lr,lhab
14452 do mgs = 1,ngscnt
14453 IF ( il .ge. lg ) alpha(mgs,il) = dnu(il)
14454
14455
14456 DO ic = lc,lhab
14457 dab0lh(mgs,il,ic) = dab0(il,ic) ! dab0(ic,il)
14458 dab1lh(mgs,il,ic) = dab1(il,ic) ! dab1(ic,il)
14459 ENDDO
14460 end do
14461 ENDDO
14462
14463
14464! DO mgs = 1,ngscnt
14465 DO il = lr,lhab
14466 da0lx(:,il) = da0(il)
14467 ENDDO
14468 da0lh(:) = da0(lh)
14469 da0lr(:) = da0(lr)
14470 da1lr(:) = da1(lr)
14471 da0lc(:) = da0(lc)
14472 da1lc(:) = da1(lc)
14473
14474 if ( ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'ICEZVD_GS: dbg = set rz'
14475
14476 IF ( lzh < 1 .or. lzhl < 1 ) THEN
14477 rzxhlh(:) = rzhl/rz
14478 ELSEIF ( lzh > 1 .and. lzhl > 1 ) THEN
14479 rzxhlh(:) = 1.
14480 ENDIF
14481 IF ( lzr > 1 ) THEN
14482 rzxh(:) = 1.
14483 rzxhl(:) = 1.
14484 ELSE
14485 rzxh(:) = rz
14486 rzxhl(:) = rzhl
14487 ENDIF
14488
14489 IF ( imurain == 1 .and. imusnow == 3 .and. lzr < 1 ) THEN
14490 rzxs(:) = rzs
14491 ELSEIF ( imurain == imusnow .or. lzr > 1 ) THEN
14492 rzxs(:) = 1.
14493 ENDIF
14494 ! ENDDO
14495
14496 IF ( lhl .gt. 1 ) THEN
14497 DO mgs = 1,ngscnt
14498 da0lhl(mgs) = da0(lhl)
14499 ENDDO
14500 ENDIF
14501
14502 ventrx(:) = ventr
14503 ventrxn(:) = ventrn
14504 gf1palp(:) = gamma_sp(1.0 + alphar)
14505
14506!
14507! set factors
14508!
14509 do mgs = 1,ngscnt
14510!
14511 ssi(mgs) = qx(mgs,lv)/qis(mgs)
14512 ssw(mgs) = qx(mgs,lv)/qvs(mgs)
14513!
14514 tsqr(mgs) = temg(mgs)**2
14515!
14516 temgx(mgs) = min(temg(mgs),313.15)
14517 temgx(mgs) = max(temgx(mgs),233.15)
14518 felv(mgs) = 2500837.367 * (273.15/temgx(mgs))**((0.167)+(3.67e-4)*temgx(mgs))
14519!
14520 temcgx(mgs) = min(temg(mgs),273.15)
14521 temcgx(mgs) = max(temcgx(mgs),223.15)
14522 temcgx(mgs) = temcgx(mgs)-273.15
14523
14524! felf = latent heat of fusion, fels = LH of sublimation, felv = LH of vaporization
14525 felf(mgs) = 333690.6098 + (2030.61425)*temcgx(mgs) - (10.46708312)*temcgx(mgs)**2
14526!
14527 fels(mgs) = felv(mgs) + felf(mgs)
14528!
14529 felvs(mgs) = felv(mgs)*felv(mgs)
14530 felss(mgs) = fels(mgs)*fels(mgs)
14531
14532 IF ( eqtset <= 1 ) THEN
14533 felvcp(mgs) = felv(mgs)*cpi
14534 felscp(mgs) = fels(mgs)*cpi
14535 felfcp(mgs) = felf(mgs)*cpi
14536 ELSE
14537
14538 ! equations from appendix in Bryan and Morrison (2012, MWR)
14539 ! note that rw is Rv in the paper, and rd is R.
14540
14541 tmp = qx(mgs,li)+qx(mgs,ls)+qx(mgs,lh)
14542 IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
14543 cvm = cv+cvv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
14544 +cpigb*(tmp)
14545
14546 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
14547 felvcp(mgs) = (felv(mgs)-rw*temg(mgs))/cvm
14548 felscp(mgs) = (fels(mgs)-rw*temg(mgs))/cvm
14549 felfcp(mgs) = felf(mgs)/cvm
14550
14551 ELSE
14552 ! equivalent version that applies separate updates of latent heating to theta and pi, when both are returned.
14553
14554 cpm = cp+cpv*qx(mgs,lv)+cpl*(qx(mgs,lc)+qx(mgs,lr)) &
14555 +cpigb*(tmp)
14556 rmm=rd+rw*qx(mgs,lv)
14557
14558 felvcp(mgs) = (felv(mgs)*cv/(cp) - rw*temg(mgs)*(1.0-rovcp*cpm/rmm))/cvm
14559 felscp(mgs) = (fels(mgs)*cv/(cp) - rw*temg(mgs)*(1.0-rovcp*cpm/rmm))/cvm
14560 felfcp(mgs) = felf(mgs)*cv/(cp*cvm)
14561
14562 felvpi(mgs) = pi0(mgs)*rovcp*(felv(mgs)/(temg(mgs)) - rw*cpm/rmm)/cvm
14563 felspi(mgs) = pi0(mgs)*rovcp*(fels(mgs)/(temg(mgs)) - rw*cpm/rmm)/cvm
14564 felfpi(mgs) = pi0(mgs)*rovcp*(felf(mgs)/(cvm*temg(mgs)))
14565
14566 ENDIF
14567
14568 ENDIF
14569!
14570 fgamw(mgs) = felvcp(mgs)/pi0(mgs)
14571 fgams(mgs) = felscp(mgs)/pi0(mgs)
14572!
14573 fcqv1(mgs) = 4098.0258*pi0(mgs)*fgamw(mgs)
14574 fcqv2(mgs) = 5807.6953*pi0(mgs)*fgams(mgs)
14575 fcc3(mgs) = felfcp(mgs)/pi0(mgs)
14576!
14577! fwvdf = water vapor diffusivity
14578 fwvdf(mgs) = (2.11e-05)*((temg(mgs)/tfr)**1.94)*(101325.0/(pres(mgs)))
14579!
14580! fadvisc = 'd' for dynamic viscosity
14581! fakvisc = 'k' for kinematic viscosity
14582 fadvisc(mgs) = advisc0*(416.16/(temg(mgs)+120.0))*(temg(mgs)/296.0)**(1.5) ! dynamic visc.
14583!
14584 fakvisc(mgs) = fadvisc(mgs)*rhoinv(mgs) ! divide by rho_air to get kinematic visc. (note the 'k' vs. 'd')
14585!
14586 temcgx(mgs) = min(temg(mgs),273.15)
14587 temcgx(mgs) = max(temcgx(mgs),233.15)
14588 temcgx(mgs) = temcgx(mgs)-273.15
14589 fci(mgs) = (2.118636 + 0.007371*(temcgx(mgs)))*(1.0e+03)
14590!
14591 if ( temg(mgs) .lt. 273.15 ) then
14592 temcgx(mgs) = min(temg(mgs),273.15)
14593 temcgx(mgs) = max(temcgx(mgs),233.15)
14594 temcgx(mgs) = temcgx(mgs)-273.15
14595 fcw(mgs) = 4203.1548 + (1.30572e-2)*((temcgx(mgs)-35.)**2) &
14596 & + (1.60056e-5)*((temcgx(mgs)-35.)**4)
14597 end if
14598 if ( temg(mgs) .ge. 273.15 ) then
14599 temcgx(mgs) = min(temg(mgs),308.15)
14600 temcgx(mgs) = max(temcgx(mgs),273.15)
14601 temcgx(mgs) = temcgx(mgs)-273.15
14602 fcw(mgs) = 4243.1688 + (3.47104e-1)*(temcgx(mgs)**2)
14603 end if
14604!
14605 ftka(mgs) = tka0*fadvisc(mgs)/advisc1 ! thermal conductivity: proportional to dynamic viscosity
14606 fthdf(mgs) = ftka(mgs)*cpi*rhoinv(mgs)
14607!
14608 fschm(mgs) = (fakvisc(mgs)/fwvdf(mgs)) ! Schmidt number
14609 fpndl(mgs) = (fakvisc(mgs)/fthdf(mgs)) ! Prandl number (only used for bin melting)
14610!
14611 fai(mgs) = (fels(mgs)**2)/(ftka(mgs)*rw*temg(mgs)**2)
14612 fbi(mgs) = (1.0/(rho0(mgs)*fwvdf(mgs)*qis(mgs)))
14613 fav(mgs) = (felv(mgs)**2)/(ftka(mgs)*rw*temg(mgs)**2)
14614 fbv(mgs) = (1.0/(rho0(mgs)*fwvdf(mgs)*qvs(mgs)))
14615
14616 kp1 = min(nz, kgs(mgs)+1 )
14617 wvel(mgs) = (0.5)*(w(igs(mgs),jgs,kp1) &
14618 & +w(igs(mgs),jgs,kgs(mgs)))
14619
14620!
14621 end do
14622!
14623!
14624! ice habit fractions
14625!
14626!
14627!
14628! Set density
14629!
14630 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: Set density'
14631!
14632
14633 do mgs = 1,ngscnt
14634 xdn(mgs,li) = xdn0(li)
14635 xdn(mgs,lc) = xdn0(lc)
14636 xdn(mgs,lr) = xdn0(lr)
14637 xdn(mgs,ls) = xdn0(ls)
14638 xdn(mgs,lh) = xdn0(lh)
14639 IF ( lvol(ls) .gt. 1 ) THEN
14640 IF ( vx(mgs,ls) .gt. 0.0 .and. qx(mgs,ls) .gt. qxmin(ls) ) THEN
14641 xdn(mgs,ls) = min( xdnmx(ls), max( xdnmn(ls), rho0(mgs)*qx(mgs,ls)/vx(mgs,ls) ) )
14642 ENDIF
14643 ENDIF
14644
14645 IF ( lvol(lh) .gt. 1 ) THEN
14646 IF ( vx(mgs,lh) .gt. 0.0 .and. qx(mgs,lh) .gt. qxmin(lh) ) THEN
14647 IF ( mixedphase ) THEN
14648 ELSE
14649 dnmx = xdnmx(lh)
14650 ENDIF
14651 xdn(mgs,lh) = min( dnmx, max( xdnmn(lh), rho0(mgs)*qx(mgs,lh)/vx(mgs,lh) ) )
14652 vx(mgs,lh) = rho0(mgs)*qx(mgs,lh)/xdn(mgs,lh)
14653
14654 ELSEIF ( vx(mgs,lh) == 0.0 .and. qx(mgs,lh) .gt. qxmin(lh) ) THEN ! if volume is zero, need to initialize the default value
14655
14656 vx(mgs,lh) = rho0(mgs)*qx(mgs,lh)/xdn(mgs,lh)
14657
14658 ENDIF
14659 ENDIF
14660
14661
14662 IF ( lhl .gt. 1 ) THEN
14663
14664 xdn(mgs,lhl) = xdn0(lhl)
14665 xdntmp(mgs,lhl) = xdn0(lhl)
14666
14667 IF ( lvol(lhl) .gt. 1 ) THEN
14668 IF ( vx(mgs,lhl) .gt. 0.0 .and. qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
14669
14670 IF ( mixedphase .and. lhlw > 1 ) THEN
14671 ELSE
14672 dnmx = xdnmx(lhl)
14673 ENDIF
14674
14675 xdn(mgs,lhl) = min( dnmx, max( xdnmn(lhl), rho0(mgs)*qx(mgs,lhl)/vx(mgs,lhl) ) )
14676 vx(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/xdn(mgs,lhl)
14677 xdntmp(mgs,lhl) = xdn(mgs,lhl)
14678
14679 ELSEIF ( vx(mgs,lhl) == 0.0 .and. qx(mgs,lhl) .gt. qxmin(lhl) ) THEN ! if volume is zero, need to initialize the default value
14680
14681 vx(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/xdn(mgs,lhl)
14682
14683 ENDIF
14684 ENDIF
14685
14686 ENDIF
14687
14688
14689 end do
14690
14691 IF ( ipconc == 5 .and. imydiagalpha == 2 ) THEN
14692
14693 cwchtmp = ((3. + dnu(lh))*(2. + dnu(lh))*(1.0 + dnu(lh)))**(-1./3.)
14694
14695 DO mgs = 1,ngscnt
14696 !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)
14697 IF ( qx(mgs,lr) .gt. qxmin(lr) .and. cx(mgs,lr) > cxmin ) THEN
14698 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr)) !
14699 xdia(mgs,lr,3) = (xv(mgs,lr)*6.0*cwc1)**(1./3.)
14700 ! alpha(mgs,lr) = Min(alphamax, c1r*tanh(c2r*(xdia(mgs,lr,3)*1000. - c3r)) + c4r)
14701 ! IF ( igs(mgs) == 19 ) write(0,*) 'imy: i,k,alpr,xdia = ',igs(mgs),kgs(mgs),alpha(mgs,lr),xdia(mgs,lr,3)*1000.
14702
14703 ! Milbrandt & M-C 2010:
14704 tmp = 4. + alphar
14705 i = int(dgami*(tmp))
14706 del = tmp - dgam*i
14707 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14708
14709 tmp = 1. + alphar
14710 i = int(dgami*(tmp))
14711 del = tmp - dgam*i
14712 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14713
14714 tmp = (x/y)**(1./3.)*xdia(mgs,lr,3)*cwchtmp
14715
14716 alpha(mgs,lr) = min(15., 11.8*(1000.*tmp - 0.7)**2 + 2.)
14717 ENDIF
14718 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. cx(mgs,lh) > cxmin ) THEN
14719! MY 2005:
14720 xv(mgs,lh) = rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) !
14721 xdia(mgs,lh,3) = (xv(mgs,lh)*6.*piinv)**(1./3.) ! mwfac*xdia(mgs,lh,1) ! (xv(mgs,lh)*cwc0*6.0)**(1./3.)
14722! alpha(mgs,lh) = Min(alphamax, c1h*tanh(c2h*(xdia(mgs,lh,3)*1000. - c3h)) + c4h)
14723
14724 ! Milbrandt & M-C 2010:
14725 tmp = 4. + dnu(lh)
14726 i = int(dgami*(tmp))
14727 del = tmp - dgam*i
14728 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14729
14730 tmp = 1. + dnu(lh)
14731 i = int(dgami*(tmp))
14732 del = tmp - dgam*i
14733 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
14734
14735 tmp = (x/y)**(1./3.)*xdia(mgs,lh,3)*cwchtmp
14736
14737 alpha(mgs,lh) = min(15., 11.8*(1000.*tmp - 0.7)**2 + 2.)
14738 ! alphan(mgs,lh) = alpha(mgs,lh)
14739
14740 ! IF ( igs(mgs) == 19 ) write(0,*) 'imy: i,k,alph,xdia = ',igs(mgs),kgs(mgs),alpha(mgs,lh),xdia(mgs,lh,3)*1000.
14741 il = lh
14742 DO ic = lc,lh-1 ! lhab
14743 i = nint( alpha(mgs,il)*dqiacralphainv )
14744 IF ( ic == lc .or. ic == li .or. ic == ls .or. (ic == lr .and. imurain == 3) ) THEN
14745 alp = (3.*alpha(mgs,ic) + 2.)
14746 j = nint( (3.*alpha(mgs,ic) + 2.)*dqiacralphainv )
14747 ELSE ! IF ( ic == lr .and. imurain == 1 ) ! rain
14748 alp = alpha(mgs,ic)
14749 j = nint( alpha(mgs,ic)*dqiacralphainv )
14750 ENDIF
14751
14752 dab0lh(mgs,ic,il) = dab0lu(j,i,ic,il)
14753 dab1lh(mgs,ic,il) = dab1lu(j,i,ic,il)
14754 dab0lh(mgs,il,ic) = dab0lu(i,j,il,ic)
14755 dab1lh(mgs,il,ic) = dab1lu(i,j,il,ic)
14756 ENDDO
14757 ENDIF
14758! alpha(:,lr) = 0. ! 10.
14759! alpha(:,lh) = 0. ! 10.
14760 IF ( lhl > 0 ) THEN
14761 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. cx(mgs,lhl) > cxmin ) THEN
14762 xv(mgs,lhl) = rho0(mgs)*qx(mgs,lhl)/(xdn(mgs,lhl)*cx(mgs,lhl)) !
14763 xdia(mgs,lhl,3) = (xv(mgs,lhl)*6.*piinv)**(1./3.)
14764 IF ( xdia(mgs,lhl,3) < 0.008 ) THEN
14765 alpha(mgs,lhl) = min(alphamax, c1hl*tanh(c2hl*(xdia(mgs,lhl,3)*1000. - c3hl)) + c4hl)
14766 ELSE
14767 alpha(mgs,lhl) = min(alphamax, c5hl*xdia(mgs,lhl,3)*1000. + c6hl)
14768 ENDIF
14769
14770 il = lhl
14771 DO ic = lc,lh-1 ! lhab
14772 i = nint( alpha(mgs,il)*dqiacralphainv )
14773 IF ( ic == lc .or. ic == li .or. ic == ls .or. (ic == lr .and. imurain == 3) ) THEN
14774 alp = (3.*alpha(mgs,ic) + 2.)
14775 j = nint( (3.*alpha(mgs,ic) + 2.)*dqiacralphainv )
14776 ELSE ! IF ( ic == lr .and. imurain == 1 ) ! rain
14777 alp = alpha(mgs,ic)
14778 j = nint( alpha(mgs,ic)*dqiacralphainv )
14779 ENDIF
14780
14781 dab0lh(mgs,ic,il) = dab0lu(j,i,ic,il)
14782 dab1lh(mgs,ic,il) = dab1lu(j,i,ic,il)
14783 dab0lh(mgs,il,ic) = dab0lu(i,j,il,ic)
14784 dab1lh(mgs,il,ic) = dab1lu(i,j,il,ic)
14785 ENDDO
14786
14787 ENDIF
14788 ENDIF
14789
14790
14791
14792 ENDDO
14793 ENDIF
14794
14795
14796 IF ( imurain == 3 ) THEN
14797 IF ( lzr > 1 ) THEN
14798 alphashr = 0.0
14799 alphamlr = -2.0/3.0
14800 alphasmlr = -2.0/3.0
14801 ELSE
14802 alphashr = xnu(lr)
14803 alphamlr = xnu(lr)
14804 alphasmlr = xnu(lr)
14805 ENDIF
14806! massfacshr = ( (2. + 3.*(1. +alphashr) )/( 3.*(1. + alphashr) ) )**(1./3.) ! this is the diameter factor
14807! massfacmlr = ( (2. + 3.*(1. +alphamlr) )/( 3.*(1. + alphamlr) ) )**(1./3.)
14808 massfacshr = ( (2. + 3.*(1. +alphashr) )**3/( 3.*(1. + alphashr) ) ) ! this is the mass or volume factor
14809 massfacmlr = ( (2. + 3.*(1. +alphamlr) )**3/( 3.*(1. + alphamlr) ) )
14810 ELSEIF ( imurain == 1 ) THEN
14811 IF ( lzr > 1 ) THEN
14812 alphashr = 4.0
14813 alphamlr = 4.0
14814 alphasmlr = alphasmlr0
14815 ELSE
14816 alphashr = alphar
14817 alphamlr = alphar
14818 alphasmlr = alphar
14819 ENDIF
14820! massfacshr = (3.0 + alphashr)*((3.+alphashr)*(2.+alphashr)*(1. + alphashr) )**(-1./3.) ! this is the diameter factor
14821! massfacmlr = (3.0 + alphamlr)*((3.+alphamlr)*(2.+alphamlr)*(1. + alphamlr) )**(-1./3.)
14822 massfacshr = (3.0 + alphashr)**3/((3.+alphashr)*(2.+alphashr)*(1. + alphashr) ) ! this is the mass or volume factor
14823 massfacmlr = (3.0 + alphamlr)**3/((3.+alphamlr)*(2.+alphamlr)*(1. + alphamlr) )
14824 ENDIF
14825
14826! Find shape parameter rain
14827
14828 g1shr = 1.0
14829 g1mlr = 1.0
14830 g1smlr = 1.0
14831
14832! CALL cld_cpu('Z-MOMENT-1')
14833
14834 IF ( ipconc >= 6 ) THEN
14835
14836 ! set base g1x in case rain is not 3-moment
14837 IF ( ipconc >= 6 .and. imurain == 3 ) THEN
14838 il = lr
14839 DO mgs = 1,ngscnt
14840! g1x(mgs,il) = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14841 g1x(mgs,il) = (alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0))
14842 ENDDO
14843 ENDIF
14844
14845 IF (lzr > 1 ) THEN
14846 IF ( imurain == 3 ) THEN
14847 g1shr = (alphashr+2.0)/((alphashr+1.0))
14848 g1mlr = (alphamlr+2.0)/((alphamlr+1.0))
14849 g1smlr = (alphasmlr+2.0)/((alphasmlr+1.0))
14850 ELSEIF ( imurain == 1 ) THEN
14851! g1shr = 36.*(6.0 + alphashr)*(5.0 + alphashr)*(4.0 + alphashr)/ &
14852! & (pi**2*(3.0 + alphashr)*(2.0 + alphashr)*(1.0 + alphashr))
14853 g1shr = (6.0 + alphashr)*(5.0 + alphashr)*(4.0 + alphashr)/ &
14854 & ((3.0 + alphashr)*(2.0 + alphashr)*(1.0 + alphashr))
14855! g1mlr = 36.*(6.0 + alphamlr)*(5.0 + alphamlr)*(4.0 + alphamlr)/ &
14856! & (pi**2*(3.0 + alphamlr)*(2.0 + alphamlr)*(1.0 + alphamlr))
14857 g1mlr = (6.0 + alphamlr)*(5.0 + alphamlr)*(4.0 + alphamlr)/ &
14858 & ((3.0 + alphamlr)*(2.0 + alphamlr)*(1.0 + alphamlr))
14859 g1smlr = (6.0 + alphasmlr)*(5.0 + alphasmlr)*(4.0 + alphasmlr)/ &
14860 & ((3.0 + alphasmlr)*(2.0 + alphasmlr)*(1.0 + alphasmlr))
14861 ENDIF
14862 ENDIF
14863
14864 IF ( lzr > 1 .and. imurain == 3 ) THEN ! { RAIN SHAPE PARAM
14865
14866
14867! CALL cld_cpu('Z-MOMENT-1r')
14868 il = lr
14869 DO mgs = 1,ngscnt
14870
14871
14872 IF ( iresetmoments == 1 .or. iresetmoments == il .or. iresetmoments == -1 ) THEN ! .or. qx(mgs,il) <= qxmin(il) THEN
14873 IF ( zx(mgs,il) <= zxmin ) THEN ! .and. qx(mgs,il) > 0.05e-3 THEN
14874!! write(91,*) 'zx=0; qx,cx = ',1000.*qx(mgs,il),cx(mgs,il)
14875 qx(mgs,il) = 0.0
14876 cx(mgs,il) = 0.0
14877 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14878 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14879 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14880 ELSEIF ( iresetmoments == -1 .and. qx(mgs,il) < qxmin(il) ) THEN
14881 zx(mgs,il) = 0.0
14882 cx(mgs,il) = 0.0
14883 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14884
14885 qx(mgs,il) = 0.0
14886 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14887 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14888 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14889
14890 ELSEIF ( cx(mgs,il) <= cxmin .and. iresetmoments /= -1 ) THEN ! .and. qx(mgs,il) > 0.05e-3 THEN
14891
14892 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
14893 zx(mgs,lr) = 0.0
14894 qx(mgs,lr) = 0.0
14895 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
14896 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
14897 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
14898 ENDIF
14899 ENDIF
14900
14901 IF ( .false. .and. zx(mgs,il) <= zxmin .and. cx(mgs,il) <= cxmin ) THEN
14902 zx(mgs,il) = 0.0
14903 cx(mgs,il) = 0.0
14904 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
14905
14906 qx(mgs,il) = 0.0
14907 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
14908 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14909 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14910 ENDIF
14911
14912 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
14913
14914 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*max(1.0e-11,cx(mgs,lr)))
14915 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
14916! xv(mgs,lr) = xvmx(lr)
14917! cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
14918 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
14919 xv(mgs,lr) = xvmn(lr)
14920 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
14921 ENDIF
14922
14923 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
14924! have mass and reflectivity but no concentration, so set concentration, using default alpha
14925 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14926 z = zx(mgs,il)
14927 qr = qx(mgs,il)
14928 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*xdn(mgs,lr)**2)
14929! an(igs(mgs),jgs,kgs(mgs),ln(il)) = zx(mgs,il)
14930 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > 0.0 ) THEN
14931! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
14932 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14933 chw = cx(mgs,il)
14934 qr = qx(mgs,il)
14935 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(xdn(mgs,lr)**2*chw)
14936 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
14937
14938 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
14939! How did this happen?
14940 ! set values according to dBZ of -10, or Z = 0.1
14941! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
14942 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
14943 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14944
14945 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14946 z = zx(mgs,il)
14947 qr = qx(mgs,il)
14948 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*1000.*1000)
14949 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
14950 ENDIF
14951
14952 IF ( zx(mgs,lr) > 0.0 ) THEN
14953 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(1000.*cx(mgs,lr))
14954 vr = xv(mgs,lr)
14955 qr = qx(mgs,lr)
14956 nrx = cx(mgs,lr)
14957 z = zx(mgs,lr)
14958
14959! xv = (db(1,kz)*a(1,1,kz,lr))**2/(a(1,1,kz,lnr))
14960! rd = z*(pi/6.*1000.)**2/xv
14961
14962! determine shape parameter alpha by iteration
14963 IF ( z .gt. 0.0 ) THEN
14964! alpha(mgs,lr) = 3.
14965 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
14966 DO i = 1,20
14967 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
14968 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
14969 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
14970 alp = max( rnumin, min( rnumax, alp ) )
14971 ENDDO
14972
14973! check for artificial breakup (rain larger than allowed max size)
14974 IF ( (xv(mgs,il) .gt. xvmx(il) .or. (ioldlimiter >= 2 .and. xv(mgs,il) .gt. xvmx(il)/8.) )) THEN
14975 tmp = cx(mgs,il)
14976 IF ( ioldlimiter >= 2 ) THEN ! MY-style active breakup
14977 x = (6.*rho0(mgs)*qx(mgs,il)/(pi*xdn(mgs,il)*cx(mgs,il)))**(1./3.)
14978 x1 = max(0.0e-3, x - 3.0e-3)
14979 x2 = max(0.5, x/6.0e-3)
14980 x3 = x2**3
14981 cx(mgs,il) = cx(mgs,il)*max((1.+2.222e3*x1**2), x3)
14982 xv(mgs,il) = xv(mgs,il)/max((1.+2.222e3*x1**2), x3)
14983 ELSE ! simple cutoff
14984 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
14985 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
14986 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
14987 ENDIF
14988 !xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
14989 !cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
14990
14991 IF ( tmp < cx(mgs,il) ) THEN ! breakup
14992
14993 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
14994 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
14995 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
14996
14997 vr = xv(mgs,lr)
14998 qr = qx(mgs,lr)
14999 nrx = cx(mgs,lr)
15000 z = zx(mgs,lr)
15001
15002
15003! determine shape parameter alpha by iteration
15004 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
15005 DO i = 1,20
15006 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
15007 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
15008 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
15009 alp = max( rnumin, min( rnumax, alp ) )
15010 ENDDO
15011
15012
15013 ENDIF
15014 ENDIF
15015
15016!
15017! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
15018! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
15019!
15020 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
15021 IF ( .true. .and. (alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax) ) THEN
15022
15023 IF ( rescale_high_alpha .and. alp >= rnumax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
15024 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(1./(xdn(mgs,il)))**2
15025 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
15026
15027 ELSEIF ( rescale_low_alphar .and. alp <= rnumin ) THEN
15028 z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
15029 zx(mgs,il) = z
15030 an(igs(mgs),jy,kgs(mgs),lz(il)) = zx(mgs,il)
15031 ENDIF
15032 ENDIF
15033
15034 ! set g1x to use as G factor later. If alpha is in the range ( rnumin < alpha < rnumax ), then
15035 ! this will be the same as computing G from alpha. If alpha = rnumax, however, it probably means that
15036 ! the moments are not matched correctly, so we compute G from the moments instead so that the dZ/dt rates
15037 ! stay consistent with dN/dt and dq/dt.
15038 IF ( alp >= rnumax - 0.01 ) THEN
15039! g1x(mgs,il) = 6**2*zx(mgs,il)/(cx(mgs,il)*(pi*xv(mgs,lr))**2)
15040! g1x(mgs,il) = xdn(mgs,il)*zx(mgs,il)*cx(mgs,il)/((rho0(mgs)*qx(mgs,lr))**2)
15041 g1x(mgs,il) = (pi*xdn(mgs,il))**2*zx(mgs,il)*cx(mgs,il)/((6.*rho0(mgs)*qx(mgs,il))**2)
15042 ELSE
15043 g1x(mgs,il) = g1
15044 ENDIF
15045
15046 tmp = alpha(mgs,lr) + 4./3.
15047 i = int(dgami*(tmp))
15048 del = tmp - dgam*i
15049 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15050
15051 tmp = alpha(mgs,lr) + 1.
15052 i = int(dgami*(tmp))
15053 del = tmp - dgam*i
15054 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15055
15056 gf1palp(mgs) = y
15057
15058! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 4./3.)/(alpha(mgs,lr) + 1.)**(1./3.)/Gamma_sp(alpha(mgs,lr) + 1.)
15059 ventrx(mgs) = x/(y*(alpha(mgs,lr) + 1.)**(1./3.))
15060
15061 IF ( imurain == 3 .and. izwisventr == 2 ) THEN
15062
15063 tmp = alpha(mgs,lr) + 1.5 + br/6.
15064 i = int(dgami*(tmp))
15065 del = tmp - dgam*i
15066 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15067
15068! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 1.5 + br/6.)/Gamma_sp(alpha(mgs,lr) + 1.)
15069 ventrxn(mgs) = x/(y*(alpha(mgs,lr) + 1.)**((1.+br)/6. + 1./3.))
15070
15071! This whole section is imurain == 3, so this branch never runs
15072! ELSEIF ( imurain == 1 .and. iferwisventr == 2 ) THEN
15073!
15074! tmp = alpha(mgs,lr) + 2.5 + br/2.
15075! i = Int(dgami*(tmp))
15076! del = tmp - dgam*i
15077! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15078!
15079!! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 1.5 + br/6.)/Gamma_sp(alpha(mgs,lr) + 1.)
15080! ventrxn(mgs) = x/y
15081
15082
15083 ENDIF
15084
15085 ENDIF
15086 ENDIF
15087
15088 ENDIF
15089
15090 ENDDO
15091! CALL cld_cpu('Z-MOMENT-1r')
15092 ENDIF ! }
15093
15094 ENDIF ! ipconc >= 6
15095
15096! Find shape parameters for graupel and hail
15097 IF ( ipconc .ge. 6 ) THEN
15098
15099 DO il = lr,lhab
15100
15101 ! set base values of g1x
15102 IF ( (.not. ( il == lr .and. imurain == 3 )) .and. ( il == lr .or. il == lh .or. il == lhl .or. il == lf ) ) THEN
15103 DO mgs = 1,ngscnt
15104 g1x(mgs,il) = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
15105 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
15106 ENDDO
15107 ENDIF
15108
15109 IF ( lz(il) .gt. 1 .and. ( .not. ( il == lr .and. imurain == 3 )) ) THEN
15110
15111 DO mgs = 1,ngscnt
15112
15113
15114 IF ( iresetmoments == 1 .or. iresetmoments == il .or. iresetmoments == -1 ) THEN ! .or. qx(mgs,il) <= qxmin(il) ) THEN
15115 IF ( zx(mgs,il) <= zxmin ) THEN ! .and. qx(mgs,il) > 0.05e-3 ) THEN
15116!! write(91,*) 'zx=0; qx,cx = ',1000.*qx(mgs,il),cx(mgs,il)
15117 qx(mgs,il) = 0.0
15118 cx(mgs,il) = 0.0
15119 zx(mgs,il) = 0.0
15120 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
15121 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
15122 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
15123 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
15124 ELSEIF ( iresetmoments == -1 .and. qx(mgs,il) < qxmin(il) ) THEN
15125 zx(mgs,il) = 0.0
15126 cx(mgs,il) = 0.0
15127 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
15128
15129 qx(mgs,il) = 0.0
15130 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
15131 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
15132 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
15133
15134 ELSEIF ( cx(mgs,il) <= cxmin .and. iresetmoments /= -1 ) THEN ! .and. qx(mgs,il) > 0.05e-3 ) THEN
15135 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
15136 zx(mgs,il) = 0.0
15137 cx(mgs,il) = 0.0
15138 qx(mgs,il) = 0.0
15139 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
15140 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
15141 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
15142 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
15143 ENDIF
15144 ENDIF
15145
15146 IF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= cxmin ) THEN
15147 zx(mgs,il) = 0.0
15148 cx(mgs,il) = 0.0
15149 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
15150
15151 qx(mgs,il) = 0.0
15152 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
15153 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
15154 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
15155 ENDIF
15156
15157 IF ( qx(mgs,il) .gt. qxmin(il) ) THEN
15158
15159 xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*max(1.0e-9,cx(mgs,il)))
15160 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
15161
15162 IF ( xv(mgs,il) .lt. xvmn(il) ) THEN
15163 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
15164 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
15165 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
15166 ENDIF
15167
15168 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
15169! have mass and reflectivity but no concentration, so set concentration, using default alpha
15170 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
15171 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
15172 z = zx(mgs,il)
15173 qr = qx(mgs,il)
15174! cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z
15175 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(z*(pi*xdn(mgs,il))**2)
15176
15177 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > cxmin ) THEN
15178! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
15179! g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
15180! & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
15181 chw = cx(mgs,il)
15182 qr = qx(mgs,il)
15183! zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
15184! zx(mgs,il) = Min(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
15185 g1 = (6.0 + alphamax)*(5.0 + alphamax)*(4.0 + alphamax)/ &
15186 & ((3.0 + alphamax)*(2.0 + alphamax)*(1.0 + alphamax))
15187 zx(mgs,il) = max(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
15188 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
15189
15190 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
15191! How did this happen?
15192 ! set values according to dBZ of -10, or Z = 0.1
15193! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
15194 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
15195 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
15196
15197 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
15198 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
15199 z = zx(mgs,il)
15200 qr = qx(mgs,il)
15201! cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z
15202 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(z*(pi*xdn(mgs,il))**2)
15203 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
15204 ELSE
15205
15206 chw = cx(mgs,il)
15207 qr = qx(mgs,il)
15208 z = zx(mgs,il)
15209
15210 IF ( zx(mgs,il) .gt. 0. ) THEN
15211
15212! rdi = z*(pi/6.*1000.)**2*chw/((rho0(mgs)*qr)**2)
15213 rdi = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
15214
15215! alp = 1.e18*(6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/
15216! : ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
15217 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
15218 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
15219! print*,'kz, alp, alpha(mgs,il) = ',kz,alp,alpha(mgs,il),rdi,z,xv
15220 alp = max( alphamin, min( alphamax, alp ) )
15221
15222 IF ( newton ) THEN
15223 DO i = 1,10
15224 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
15225 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
15226 alp = alp + ( galpha(alp) - rdi )/dgalpha(alp)
15227 alp = max( alphamin, min( alphamax, alp ) )
15228 ENDDO
15229
15230 ELSE
15231 DO i = 1,10
15232! IF ( 100.*Abs(alp - alpha(mgs,il))/(Abs(alpha(mgs,il))+1.e-5) .lt. 1. ) EXIT
15233 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
15234 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
15235! alp = 1.e18*(6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/
15236! : ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
15237 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
15238 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
15239! print*,'i,alp = ',i,alp
15240 alp = max( alphamin, min( alphamax, alp ) )
15241 ENDDO
15242 ENDIF
15243
15244
15245! check for artificial breakup (graupel/hail larger than allowed max size)
15246 IF ( imaxdiaopt == 1 .or. il /= lr ) THEN
15247 xvbarmax = xvmx(il)
15248 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
15249 xvbarmax = xvmx(il) /((3. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
15250 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
15251 xvbarmax = xvmx(il) /((4. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
15252 ELSE
15253 xvbarmax = xvmx(il)
15254 ENDIF
15255
15256 IF ( xv(mgs,il) .gt. xvbarmax .or. (il == lr .and. ioldlimiter >= 2 .and. xv(mgs,il) .gt. xvmx(il)/8.)) THEN
15257 tmp = cx(mgs,il)
15258 IF( ioldlimiter >= 2 .and. il == lr) THEN ! MY-style drop limiter for rain
15259 x = (6.*rho0(mgs)*qx(mgs,il)/(pi*xdn(mgs,il)*cx(mgs,il)))**(1./3.)
15260 x1 = max(0.0e-3, x - 3.0e-3)
15261 x2 = max(0.5, x/6.0e-3)
15262 x3 = x2**3
15263 cx(mgs,il) = cx(mgs,il)*max((1.+2.222e3*x1**2), x3)
15264 xv(mgs,il) = xv(mgs,il)/max((1.+2.222e3*x1**2), x3)
15265 ELSE
15266 xv(mgs,il) = min( xvbarmax, max( xvmn(il),xv(mgs,il) ) )
15267 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
15268 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
15269 ENDIF
15270 IF ( tmp < cx(mgs,il) ) THEN ! artificial breakup has happened, so need to adjust reflectivity and find new shape parameter
15271 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
15272 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
15273! zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
15274 ! check if incoming zx is consistent
15275 ! Z from incoming cx, qx, and alpha
15276 tmpz = g1/(pi/6.*xdn(mgs,il))**2 * ((rho0(mgs)*qx(mgs,il))**2)/tmp
15277 IF ( tmpz > zx(mgs,il) ) THEN
15278 tmpc = g1/(pi/6.*xdn(mgs,il))**2 * ((rho0(mgs)*qx(mgs,il))**2)/zx(mgs,il)
15279 cx(mgs,il) = max(cx(mgs,il), tmpc)
15280 ! find cx that gives zx
15281 ENDIF
15282 zx(mgs,il) = g1/(pi/6.*xdn(mgs,il))**2 * ((rho0(mgs)*qx(mgs,il))**2)/cx(mgs,il)
15283 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
15284
15285 qr = qx(mgs,il)
15286 chw = cx(mgs,il)
15287 z = zx(mgs,il)
15288
15289 rdi = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
15290 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
15291 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
15292 DO i = 1,10
15293 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
15294 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
15295 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
15296 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
15297 alp = max( alphamin, min( alphamax, alp ) )
15298 ENDDO
15299
15300
15301 ENDIF
15302 ENDIF
15303
15304!
15305! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
15306! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
15307!
15308 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
15309 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
15310
15311 IF ( ( lrescalelow(il) .or. rescale_high_alpha ) .and. &
15312 & ( alpha(mgs,il) <= alphamin .or. alp == alphamin .or. alp == alphamax ) ) THEN
15313
15314
15315
15316 IF ( rescale_high_alpha .and. alp >= alphamax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
15317 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(6./(pi*xdn(mgs,il)))**2
15318 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
15319
15320 ELSEIF ( lrescalelow(il) .and. alp <= alphamin .and. .not. (il == lh .and. icvhl2h > 0 ) .and. &
15321 .not. ( il == lr .and. .not. rescale_low_alphar ) ) THEN ! alpha = alphamin, so reset Z to prevent growth in C
15322 wtest = .false.
15323 IF ( irescalerainopt == 0 ) THEN
15324 wtest = .false.
15325 ELSEIF ( irescalerainopt == 1 ) THEN
15326 wtest = qx(mgs,lc) > qxmin(lc)
15327 ELSEIF ( irescalerainopt == 2 ) THEN
15328 wtest = qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < rescale_wthresh
15329 ELSEIF ( irescalerainopt == 3 ) THEN
15330 wtest = temcg(mgs) > rescale_tempthresh .and. qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < rescale_wthresh
15331 ENDIF
15332
15333 IF ( il == lr .and. ( wtest ) ) THEN
15334! IF ( temcg(mgs) > 0.0 .and. il == lr .and. qx(mgs,lc) > qxmin(lc) ) THEN
15335 ! certain situations where rain number is adjusted instead of Z. Helps avoid rain being 'zapped' by autoconverted
15336 ! drops (i.e., favor preserving Z when alpha tries to go negative)
15337 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
15338 cx(mgs,il) = chw
15339 an(igs(mgs),jy,kgs(mgs),ln(il)) = chw
15340 ELSE
15341
15342 ! Usual resetting of reflectivity moment to force consisntency between Q, N, Z, and alpha when alpha = alphamin
15343 z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
15344 z = z1*(6./(pi*xdn(mgs,il)))**2
15345 zx(mgs,il) = z
15346 an(igs(mgs),jy,kgs(mgs),lz(il)) = z
15347 ENDIF
15348 ENDIF
15349 ENDIF
15350
15351
15352 ! set g1x to use as G factor later. If alpha is in the range ( rnumin < alpha < rnumax ), then
15353 ! this will be the same as computing G from alpha. If alpha = rnumax, however, it probably means that
15354 ! the moments are not matched correctly, so we compute G from the moments instead so that the dZ/dt rates
15355 ! stay consistent with dN/dt and dq/dt.
15356! g1x(mgs,il) = zx(mgs,il)*chw*(pi*xdn(mgs,il))**2/(6.*qr*dn(igs(mgs),jy,kgs(mgs)))**2
15357! g1x(mgs,il) = g1 ! zx(mgs,il)*cx(mgs,il)/(qr)**2
15358 IF ( alp >= alphamax - 0.5 ) THEN
15359! g1x(mgs,il) = 6**2*zx(mgs,il)/(cx(mgs,il)*(pi*xv(mgs,lr))**2)
15360! g1x(mgs,il) = (xdn(mgs,il))**2*zx(mgs,il)*cx(mgs,il)/((rho0(mgs)*qx(mgs,il))**2)
15361 g1x(mgs,il) = (pi*xdn(mgs,il))**2*zx(mgs,il)*cx(mgs,il)/((6.*rho0(mgs)*qx(mgs,il))**2)
15362 ELSE
15363 g1x(mgs,il) = g1
15364 ENDIF
15365
15366 ENDIF
15367
15368! IF ( ny .eq. 2 ) THEN
15369! IF ( qr .gt. 1.e-3 ) THEN
15370! write(0,*) 'alphah at nstep,i,k = ',dtp*(nstep-1),igs(mgs),kgs(mgs),alpha(mgs,il),qr*1000.
15371! ENDIF
15372! ENDIF
15373
15374
15375 ENDIF ! .true.
15376
15377 IF ( il == lr ) THEN
15378
15379! tmp = alpha(mgs,lr) + 4./3.
15380! i = Int(dgami*(tmp))
15381! del = tmp - dgam*i
15382! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15383!
15384! tmp = alpha(mgs,lr) + 1.
15385! i = Int(dgami*(tmp))
15386! del = tmp - dgam*i
15387! y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15388!
15389!! ventrx(mgs) = Gamma_sp(alpha(mgs,lr) + 4./3.)/(alpha(mgs,lr) + 1.)**(1./3.)/Gamma_sp(alpha(mgs,lr) + 1.)
15390! ventrx(mgs) = x/(y*(alpha(mgs,lr) + 1.)**(1./3.))
15391
15392
15393 tmp = alpha(mgs,lr) + 1.
15394 i = int(dgami*(tmp))
15395 del = tmp - dgam*i
15396 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15397
15398 gf1palp(mgs) = y
15399
15400 IF ( iferwisventr == 2 ) THEN
15401! ventrn = Gamma(alphar + 2.5 + br/2.)/Gamma(alphar + 1.) ! adapted from Wisner et al. 1972
15402 tmp = alpha(mgs,lr) + 2.5 + br/2.
15403 i = int(dgami*(tmp))
15404 del = tmp - dgam*i
15405 x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
15406
15407
15408 ventrxn(mgs) = x/y
15409
15410 ENDIF
15411
15412 ENDIF ! il==lr
15413
15414
15415 ELSE ! below mass threshold
15416! g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/
15417! & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
15418! z1 = g1*rho0(mgs)**2*(qr)*qr/chw
15419! z = 1.e18*z1*(6./(pi*1000.))**2
15420! z = z1*(6./(pi*1000.))**2
15421! zx(mgs,il) = z
15422! an(igs(mgs),jy,kgs(mgs),lz(il)) = z
15423 ENDIF ! ( qx(mgs,il) .gt. qxmin(il) )
15424
15425
15426
15427! ENDIF
15428 ENDDO ! mgs
15429
15430! CALL cld_cpu('Z-DELABK')
15431
15432! IF ( il == lr ) THEN
15433! xnutmp = (alpha(mgs,il) - 2.)/3.
15434! da0lr(mgs) = delbk(bb(il), xnutmp, xmu(il), 0)
15435! ENDIF
15436
15437 IF ( .not. ( il == lr .and. imurain == 3 ) ) THEN
15438! CALL cld_cpu('Z-DELABK')
15439 DO mgs = 1,ngscnt
15440 IF ( qx(mgs,il) > qxmin(il) ) THEN
15441 xnutmp = (alpha(mgs,il) - 2.)/3.
15442
15443! IF ( .true. ) THEN
15444 DO ic = lc,lh-1 ! lhab
15445 IF ( il .ne. ic .and. qx(mgs,ic) .gt. qxmin(ic)) THEN
15446 xnuc = xnu(ic)
15447 IF ( ic == lc .and. idiagnosecnu > 0 ) xnuc = alpha(mgs,lc) ! alpha for droplets is actually nu
15448 IF ( il /= lr .and. ic == lr .and. lzr > 1 ) THEN
15449 IF ( imurain == 3 ) THEN
15450 xnuc = alpha(mgs,lr) ! alpha is nu already
15451 ELSE
15452 xnuc = ( alpha(mgs,lr) - 2. )/3. ! convert alpha to nu
15453 ENDIF
15454 ENDIF
15455 ! delabk(ba,bb,nua,nub,mua,mub,k), where a (il) is collector and b (ic) is collected
15456 IF ( .false. ) THEN
15457 dab0lh(mgs,ic,il) = delabk(bb(ic), bb(il), xnuc, xnutmp, xmu(ic), xmu(il), 0) !dab0(il,ic)
15458 dab1lh(mgs,ic,il) = delabk(bb(ic), bb(il), xnuc, xnutmp, xmu(ic), xmu(il), 1) !dab1(il,ic)
15459 dab0lh(mgs,il,ic) = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic), 0) !dab0(il,ic)
15460 dab1lh(mgs,il,ic) = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic), 1) !dab1(il,ic)
15461 ELSE ! use lookup table -- not interpolating yet because table resolution of 0.05 is good enough
15462 i = nint( alpha(mgs,il)*dqiacralphainv )
15463 IF ( ic == lc .or. ic == li .or. ic == ls .or. (ic == lr .and. imurain == 3) ) THEN
15464 alp = (3.*alpha(mgs,ic) + 2.)
15465 j = nint( (3.*alpha(mgs,ic) + 2.)*dqiacralphainv )
15466 ELSE ! IF ( ic == lr .and. imurain == 1 ) ! rain
15467 alp = alpha(mgs,ic)
15468 j = nint( alpha(mgs,ic)*dqiacralphainv )
15469 ENDIF
15470
15471 dab0lh(mgs,ic,il) = dab0lu(j,i,ic,il)
15472 dab1lh(mgs,ic,il) = dab1lu(j,i,ic,il)
15473 dab0lh(mgs,il,ic) = dab0lu(i,j,il,ic)
15474 dab1lh(mgs,il,ic) = dab1lu(i,j,il,ic)
15475
15476! tmp1 = dab0lu(j,i,ic,il)
15477! tmp2 = dab1lu(j,i,ic,il)
15478! tmp3 = dab0lu(i,j,il,ic)
15479! tmp4 = dab1lu(i,j,il,ic)
15480! tmp5 = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(ic), xmu(il), 0) !dab0(il,ic)
15481! tmp6 = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(ic), xmu(il), 1) !dab1(il,ic)
15482! tmp5 = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic), 0) !dab0(il,ic)
15483! tmp6 = delabk(bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic), 1) !dab1(il,ic)
15484
15485 IF ( .false. .and. ny <= 2 ) THEN
15486 write(0,*)
15487 write(0,*) 'bb: ', bb(il), bb(ic), xnutmp, xnuc, xmu(il), xmu(ic)
15488 write(0,*) 'il,ic = ',il,ic,alpha(mgs,il),i,xnuc,alp,j
15489 write(0,*) 'dab0lh,tmp1 = ',dab0lh(mgs,ic,il),tmp1
15490 write(0,*) 'dab1lh,tmp2 = ',dab1lh(mgs,ic,il),tmp2
15491 write(0,*) 'dab0lh,tmp3 = ',dab0lh(mgs,il,ic),tmp3,tmp5
15492 write(0,*) 'dab1lh,tmp4 = ',dab1lh(mgs,il,ic),tmp4,tmp6
15493
15494 ENDIF
15495
15496 ENDIF
15497
15498 ENDIF
15499 ENDDO
15500
15501! ENDIF
15502
15503 da0lx(mgs,il) = delbk(bb(il), xnutmp, xmu(il), 0)
15504 IF ( il .eq. lh ) THEN
15505 da0lh(mgs) = delbk(bb(il), xnutmp, xmu(il), 0)
15506 IF ( lzr > 1 ) THEN
15507 rzxh(mgs) = 1.
15508 ELSE
15509 rzxh(mgs) = ((4. + alpha(mgs,il))*(5. + alpha(mgs,il))*(6. + alpha(mgs,il))*(1. + xnu(lr)))/ &
15510 & ((1. + alpha(mgs,il))*(2. + alpha(mgs,il))*(3. + alpha(mgs,il))*(2. + xnu(lr)))
15511 ENDIF
15512
15513 IF ( lzhl < 1 ) THEN
15514 rzxhlh(mgs) = rzxhl(mgs)/(((4. + alpha(mgs,il))*(5. + alpha(mgs,il))*(6. + alpha(mgs,il))*(1. + xnu(lr)))/ &
15515 & ((1. + alpha(mgs,il))*(2. + alpha(mgs,il))*(3. + alpha(mgs,il))*(2. + xnu(lr))))
15516 ENDIF
15517 ELSEIF ( il .eq. lhl ) THEN
15518 da0lhl(mgs) = delbk(bb(il), xnutmp, xmu(il), 0)
15519 IF ( lzr > 1 ) THEN
15520 rzxhl(mgs) = 1.
15521 ELSE
15522 rzxhl(mgs) = ((4.0 + alpha(mgs,il))*(5. + alpha(mgs,il))*(6. + alpha(mgs,il))*(1. + xnu(lr)))/ &
15523 & ((1. + alpha(mgs,il))*(2. + alpha(mgs,il))*(3. + alpha(mgs,il))*(2. + xnu(lr)))
15524 ENDIF
15525 ELSEIF ( il == lr ) THEN
15526 xnutmp = (alpha(mgs,il) - 2.)/3.
15527 da0lr(mgs) = delbk(bb(il), xnutmp, xmu(il), 0)
15528 da1lr(mgs) = delbk(bb(il), xnutmp, xmu(il), 1)
15529 ENDIF
15530
15531 ENDIF ! ( qx(mgs,il) > qxmin(il) )
15532 ENDDO ! mgs
15533! CALL cld_cpu('Z-DELABK')
15534 ENDIF ! il /= lr
15535
15536! CALL cld_cpu('Z-DELABK')
15537
15538 ENDIF ! lz(il) .gt. 1
15539
15540 ENDDO ! il
15541
15542 ENDIF ! ipconc .ge. 6
15543
15544! CALL cld_cpu('Z-MOMENT-1')
15545
15546!
15547! set some values for ice nucleation
15548!
15549 do mgs = 1,ngscnt
15550 kp1 = min(nz, kgs(mgs)+1 )
15551! wvel(mgs) = (0.5)*(w(igs(mgs),jgs,kp1) &
15552! & +w(igs(mgs),jgs,kgs(mgs)))
15553
15554
15555 wvelkm1(mgs) = (0.5)*(w(igs(mgs),jgs,kgs(mgs)) &
15556 & +w(igs(mgs),jgs,kgsm(mgs)))
15557 cninm(mgs) = t7(igs(mgs),jgs,kgsm(mgs))
15558 cnina(mgs) = t7(igs(mgs),jgs,kgs(mgs))
15559 cninp(mgs) = t7(igs(mgs),jgs,kgsp(mgs))
15560 end do
15561
15562!
15563! Set a couple of cloud variables...
15564!
15565
15566! SUBROUTINE setvt(ngscnt,qx,qxmin,cx,rho0,rhovt,xdia,cno,
15567! : xmas,xdn,xvmn,xvmx,xv,cdx,
15568! : ipconc,ndebug)
15569! SUBROUTINE setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno, &
15570! & xmas,vtxbar,xdn,xvmn,xvmx,xv,cdx, &
15571! & ipconc1,ndebug1,ngs,nz,kgs,cwnccn,fadvisc, &
15572! & cwmasn,cwmasx,cwradn,cnina,cimna,cimxa, &
15573! & itype1a,itype2a,temcg,infdo,alpha)
15574
15575
15576 infdo = 1
15577 IF ( rimdenvwgt > 0 ) infdo = 1
15578
15579 call setvtz(ngscnt,qx,qxmin,qxw,cx,rho0,rhovt,xdia,cno,cnostmp, &
15580 & xmas,vtxbar,xdn,xvmn,xvmx,xv,cdx,cdxgs, &
15581 & ipconc,ndebug,ngs,nz,igs,kgs,fadvisc, &
15582 & cwmasn,cwmasx,cwradn,cnina,cimn,cimx, &
15583 & itype1,itype2,temcg,infdo,alpha,axx,bxx,0) ! ,cdh,cdhl)
15584! & itype1,itype2,temcg,infdo,alpha,0,axh,bxh,axhl,bxhl) ! ,cdh,cdhl)
15585
15586
15587 IF ( lwsm6 .and. ipconc == 0 ) THEN
15588 tmp = max(qxmin(lh), qxmin(ls))
15589 DO mgs = 1,ngscnt
15590 total = qx(mgs,lh) + qx(mgs,ls)
15591 IF ( total > tmp ) THEN
15592 vt2ave(mgs) = (qx(mgs,lh)*vtxbar(mgs,lh,1) + qx(mgs,ls)*vtxbar(mgs,ls,1))/total
15593 ELSE
15594 vt2ave(mgs) = 0.0
15595 ENDIF
15596 ENDDO
15597 ENDIF
15598
15599
15600!
15601! Set number concentrations (need xdia from setvt)
15602!
15603 if ( ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: Set concentration'
15604 IF ( ipconc .lt. 1 ) THEN
15605 cina(1:ngscnt) = cx(1:ngscnt,li)
15606 ENDIF
15607 if ( ipconc .lt. 5 ) then
15608 do mgs = 1,ngscnt
15609
15610
15611 IF ( ipconc .lt. 3 ) THEN
15612! cx(mgs,lr) = 0.0
15613 if ( qx(mgs,lr) .gt. qxmin(lh) ) then
15614! cx(mgs,lr) = cno(lr)*xdia(mgs,lr,1)
15615! xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*cx(mgs,lr))
15616 end if
15617 ENDIF
15618
15619 IF ( ipconc .lt. 4 ) THEN
15620! tmp = cx(mgs,ls)
15621! cx(mgs,ls) = 0.0
15622 if ( qx(mgs,ls) .gt. qxmin(ls) ) then
15623! cx(mgs,ls) = cno(ls)*xdia(mgs,ls,1)
15624! xv(mgs,ls) = rho0(mgs)*qx(mgs,ls)/(xdn(mgs,ls)*cx(mgs,ls))
15625 end if
15626 ENDIF ! ( ipconc .lt. 4 )
15627
15628 IF ( ipconc .lt. 5 ) THEN
15629
15630
15631! cx(mgs,lh) = 0.0
15632 if ( qx(mgs,lh) .gt. qxmin(lh) ) then
15633! cx(mgs,lh) = cno(lh)*xdia(mgs,lh,1)
15634! xv(mgs,lh) = Max(xvmn(lh), rho0(mgs)*qx(mgs,lh)/(xdn(mgs,lh)*cx(mgs,lh)) )
15635! xdia(mgs,lh,3) = (xv(mgs,lh)*6./pi)**(1./3.)
15636 end if
15637
15638 ENDIF ! ( ipconc .lt. 5 )
15639
15640 end do
15641 end if
15642
15643 IF ( ipconc .ge. 2 ) THEN
15644 DO mgs = 1,ngscnt
15645
15646 rb(mgs) = 0.5*xdia(mgs,lc,1)*(1./(1.+alpha(mgs,lc)))**(1./6.)
15647 xl2p(mgs) = max(0.0d0, 2.7e-2*xdn(mgs,lc)*cx(mgs,lc)*xv(mgs,lc)* &
15648 & ((0.5e20*rb(mgs)**3*xdia(mgs,lc,1))-0.4) )
15649 IF ( rb(mgs) .gt. 3.51e-6 ) THEN
15650! rh(mgs) = Max( 0.5d0*xdia(mgs,lc,1), 6.3d-4/(1.d6*(rb(mgs) - 3.5d-6)) )
15651 rh(mgs) = max( 41.d-6, 6.3d-4/(1.d6*(rb(mgs) - 3.5d-6)) )
15652 ELSE
15653 rh(mgs) = 41.d-6
15654 ENDIF
15655 IF ( xl2p(mgs) .gt. 0.0 ) THEN
15656 nh(mgs) = 4.2d9*xl2p(mgs)
15657 ELSE
15658 nh(mgs) = 1.e30
15659 ENDIF
15660 ENDDO
15661 ENDIF
15662
15663!
15664!
15665!
15666!
15667! maximum depletion tendency by any one source
15668!
15669!
15670 if( ndebug .ge. 0 ) THEN
15671!mpi! write(0,*) 'Set depletion max/min1'
15672 endif
15673 do mgs = 1,ngscnt
15674 qvimxd(mgs) = 0.70*(qx(mgs,lv)-qis(mgs))*dtpinv ! depletion by all vap. dep to ice.
15675
15676 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
15677
15678 qvimxd(mgs) = max(qvimxd(mgs), 0.0)
15679
15680 frac = 0.1d0
15681 qimxd(mgs) = frac*qx(mgs,li)*dtpinv
15682 qcmxd(mgs) = frac*qx(mgs,lc)*dtpinv
15683 qrmxd(mgs) = frac*qx(mgs,lr)*dtpinv
15684 qsmxd(mgs) = frac*qx(mgs,ls)*dtpinv
15685 qhmxd(mgs) = frac*qx(mgs,lh)*dtpinv
15686 IF ( lhl > 1 ) qhlmxd(mgs) = frac*qx(mgs,lhl)*dtpinv
15687 end do
15688!
15689 if( ndebug .ge. 0 ) THEN
15690!mpi! write(0,*) 'Set depletion max/min2'
15691 endif
15692
15693 do mgs = 1,ngscnt
15694!
15695 if ( qx(mgs,lc) .le. qxmin(lc) ) then
15696 ccmxd(mgs) = 0.20*cx(mgs,lc)*dtpinv
15697 else
15698 IF ( ipconc .ge. 2 ) THEN
15699 ccmxd(mgs) = frac*cx(mgs,lc)*dtpinv
15700 ELSE
15701 ccmxd(mgs) = frac*qx(mgs,lc)/(xmas(mgs,lc)*rho0(mgs)*dtp)
15702 ENDIF
15703 end if
15704!
15705 if ( qx(mgs,li) .le. qxmin(li) ) then
15706 cimxd(mgs) = frac*cx(mgs,li)*dtpinv
15707 else
15708 IF ( ipconc .ge. 1 ) THEN
15709 cimxd(mgs) = frac*cx(mgs,li)*dtpinv
15710 ELSE
15711 cimxd(mgs) = frac*qx(mgs,li)/(xmas(mgs,li)*rho0(mgs)*dtp)
15712 ENDIF
15713 end if
15714!
15715!
15716 crmxd(mgs) = 0.10*cx(mgs,lr)*dtpinv
15717 csmxd(mgs) = frac*cx(mgs,ls)*dtpinv
15718 chmxd(mgs) = frac*cx(mgs,lh)*dtpinv
15719
15720 ccmxd(mgs) = frac*cx(mgs,lc)*dtpinv
15721 cimxd(mgs) = frac*cx(mgs,li)*dtpinv
15722 crmxd(mgs) = frac*cx(mgs,lr)*dtpinv
15723 csmxd(mgs) = frac*cx(mgs,ls)*dtpinv
15724 chmxd(mgs) = frac*cx(mgs,lh)*dtpinv
15725
15726 qxmxd(mgs,lv) = max(0.0, 0.1*(qx(mgs,lv) - qvs(mgs))*dtpinv)
15727
15728 DO il = lc,lhab
15729 qxmxd(mgs,il) = frac*qx(mgs,il)*dtpinv
15730 cxmxd(mgs,il) = frac*cx(mgs,il)*dtpinv
15731 ENDDO
15732
15733 end do
15734
15735
15736
15737
15738 IF ( ipconc >= 6 ) THEN
15739 frac = 0.4d0
15740 zxmxd(:,:) = 0.0
15741 DO il = lr,lhab
15742 IF ( lz(il) > 0 .or. ( il == lr ) ) THEN
15743 DO mgs = 1,ngscnt
15744 zxmxd(mgs,il) = frac*zx(mgs,il)*dtpinv
15745 ENDDO
15746 ENDIF
15747 ENDDO
15748 ENDIF
15749
15750
15751
15752
15753 ! default factors between mean volume and maximum mass volume
15754 maxmassfac(lc) = ( (2. + 3.*(1. + xnu(lc)) )**3/( 3.*(1. + xnu(lc)) ) )
15755 maxmassfac(li) = ( (2. + 3.*(1. + xnu(li)) )**3/( 3.*(1. + xnu(li)) ) )
15756
15757 IF ( imurain == 3 ) THEN
15758 maxmassfac(lr) = ( (2. + 3.*(1. + xnu(lr)) )**3/( 3.*(1. + xnu(lr)) ) )
15759 ELSE
15760 maxmassfac(lr) = (3.0 + alphar)**3/ &
15761 & ((3.+alphar)*(2.+alphar)*(1. + alphar) )
15762 ENDIF
15763
15764 IF ( imusnow == 3 ) THEN
15765 maxmassfac(ls) = ( (2. + 3.*(1. + alphas) )**3/( 3.*(1. + alphas) ) )
15766 ELSE
15767 maxmassfac(ls) = (3.0 + alphas)**3/ &
15768 & ((3.+alphas)*(2.+alphas)*(1. + alphas) )
15769 ENDIF
15770
15771 maxmassfac(lh) = (3.0 + alphah)**3/ &
15772 & ((3.+alphah)*(2.+alphah)*(1. + alphah) )
15773
15774 IF ( lhl > 1 ) THEN
15775 maxmassfac(lhl) = (3.0 + alphahl)**3/ &
15776 & ((3.+alphahl)*(2.+alphahl)*(1. + alphahl) )
15777 ENDIF
15778
15779
15780
15781 DO mgs = 1,ngscnt
15782 DO il = lh,lhab ! graupel and hail only (and frozen drops)
15783
15784 vshdgs(mgs,il) = vshd ! base value
15785
15786 IF ( qx(mgs,il) > qxmin(il) .and. ivshdgs > 0 ) THEN
15787
15788 ! tmpdiam is weighted diameter of d^(shedalp-1), so for shedalp=3, this is the area-weighted diameter or maximum mass diameter.
15789 ! 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
15790 tmpdiam = (shedalp+0.0)*xdia(mgs,il,1) ! *( xdn(mgs,il)/917. )**(1./3.) ! erm added density factor for equiv. solid ice sphere 10.12.2015
15791 ! imltshddmr
15792 IF ( tmpdiam > sheddiam0 ) THEN
15793 vshdgs(mgs,il) = 0.523599*(1.5e-3)**3/massfacshr ! 1.5mm drops from very large ice
15794 ELSEIF ( tmpdiam > sheddiam ) THEN ! intermediate size
15795 vshdgs(mgs,il) = 0.523599*(3.0e-3)**3/massfacshr ! 3.0mm drops from medium-large ice
15796 ELSE
15797! vshdgs(mgs,il) = Min( xvmx(lr), xv(mgs,il)*xdn(mgs,il)*0.001 ) ! size of drop from melted mean ice particle
15798 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
15799 ENDIF
15800 ENDIF
15801 ENDDO
15802 ENDDO
15803
15804!
15805!
15806! microphysics source terms (1/s) for mixing ratios
15807!
15808!
15809!
15810! Collection efficiencies:
15811!
15812 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: Set collection efficiencies'
15813!
15814 do mgs = 1,ngscnt
15815!
15816!
15817!
15818 qcwresv(mgs) = 0.0
15819 ccwresv(mgs) = 0.0
15820
15821 erw(mgs) = 0.0
15822 esw(mgs) = 0.0
15823 ehw(mgs) = 0.0
15824 efw(mgs) = 0.0
15825 ehlw(mgs) = 0.0
15826! ehxw(mgs) = 0.0
15827!
15828 err(mgs) = 0.0
15829 esr(mgs) = 0.0
15830 il2(mgs) = 0
15831 il3(mgs) = 0
15832 ehr(mgs) = 0.0
15833 ehlr(mgs) = 0.0
15834! ehxr(mgs) = 0.0
15835!
15836 eri(mgs) = 0.0
15837 esi(mgs) = 0.0
15838 ehi(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehi*ehiclsn
15839 ehis(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehi*ehiclsn
15840 ehli(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehli*ehliclsn
15841 ehlis(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehli*ehliclsn
15842! ehxi(mgs) = 0.0
15843!
15844 ers(mgs) = 0.0
15845 ess(mgs) = 0.0
15846 ehs(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehs*ehsclsn
15847 ehsfac(mgs) = 1.0 ! factor based on ice saturation
15848 ehls(mgs) = 0.0 ! used as sticking efficiency, so collection efficiency is ehls*ehlsclsn
15849 ehscnv(mgs) = 0.0
15850! ehxs(mgs) = 0.0
15851!
15852 eiw(mgs) = 0.0
15853 eii(mgs) = 0.0
15854 ehsclsn(mgs) = 0.0
15855 ehiclsn(mgs) = 0.0
15856 ehlsclsn(mgs) = 0.0
15857 ehliclsn(mgs) = 0.0
15858 esiclsn(mgs) = 0.0
15859
15860
15861! reserve droplets
15862 IF ( exwmindiam > 0 .and. qx(mgs,lc) > qxmin(lc) ) THEN
15863 tmp = cx(mgs,lc)*exp(- (exwmindiam/xdia(mgs,lc,1))**3 )
15864 ccwresv(mgs) = min( cx(mgs,lc), max( 2.e6, cx(mgs,lc) - tmp ) )
15865
15866 tmp = cx(mgs,lc) - ccwresv(mgs)
15867
15868 volt = pi/6.*(exwmindiam)**3
15869 qcwresv(mgs) = qx(mgs,lc) - tmp*xdn0(lc)*rhoinv(mgs)*(volt + xv(mgs,lc))
15870
15871
15872 IF ( .false. .and. qx(mgs,lc) > 0.1e-3 ) THEN
15873
15874 write(0,*) 'cx,qx,crsv,qrsv = ',cx(mgs,lc),qx(mgs,lc),ccwresv(mgs),qcwresv(mgs)
15875
15876 ENDIF
15877
15878 ENDIF
15879
15880
15881 icwr(mgs) = 1
15882 IF ( qx(mgs,lc) .gt. qxmin(lc) ) THEN
15883 cwrad = 0.5*xdia(mgs,lc,1)
15884 DO il = 1,8
15885 IF ( cwrad .ge. 1.e-6*cwr(il,1) ) icwr(mgs) = il
15886 ENDDO
15887 ENDIF
15888
15889
15890 irwr(mgs) = 1
15891 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
15892 rwrad = 0.5*xdia(mgs,lr,3) ! changed to mean volume diameter (10/6/06)
15893 DO il = 1,6
15894 IF ( rwrad .ge. 1.e-6*grad(il,1) ) irwr(mgs) = il
15895 ENDDO
15896 ENDIF
15897
15898
15899 igwr(mgs) = 1
15900! IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
15901! rwrad = 0.5*xdia(mgs,lr,1)
15902! setting erw = 1 always, so now use igwr for graupel
15903 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
15904 rwrad = 0.5*xdia(mgs,lh,3) ! changed to mean volume diameter (10/6/06)
15905 DO il = 1,6
15906 IF ( rwrad .ge. 1.e-6*grad(il,1) ) igwr(mgs) = il
15907 ENDDO
15908 ENDIF
15909
15910
15911 IF ( lhl .gt. 1 ) THEN ! hail is turned on
15912 ihlr(mgs) = 1
15913 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
15914 rwrad = 0.5*xdia(mgs,lhl,3) ! changed to mean volume diameter (10/6/06)
15915 DO il = 1,6
15916 IF ( rwrad .ge. 1.e-6*grad(il,1) ) ihlr(mgs) = il
15917 ENDDO
15918 ENDIF
15919 ENDIF
15920
15921!
15922!
15923! Ice-Ice: Collection (cxc) efficiencies
15924!
15925!
15926 if ( qx(mgs,li) .gt. qxmin(li) ) then
15927! IF ( ipconc .ge. 14 ) THEN
15928! eii(mgs)=0.1*exp(0.1*temcg(mgs))
15929! if ( temg(mgs) .lt. 243.15 .and. qx(mgs,lc) .gt. 1.e-6 ) then
15930! eii(mgs)=0.1
15931! end if
15932!
15933! ELSE
15934 eii(mgs) = exp(0.025*min(temcg(mgs),0.0)) ! alpha1 from LFO83 (21)
15935! ENDIF
15936 if ( temg(mgs) .gt. 273.15 ) eii(mgs) = 1.0
15937 end if
15938!
15939!
15940!
15941! Ice-cloud water: Collection (cxc) efficiencies
15942!
15943!
15944 eiw(mgs) = 0.0
15945 if ( qx(mgs,li).gt.qxmin(li) .and. qx(mgs,lc).gt.qxmin(lc) ) then
15946
15947
15948 if (xdia(mgs,lc,1).gt.ewi_dcmin .and. xdia(mgs,li,1).gt.ewi_dimin) then
15949! erm 5/10/2007 test following change:
15950! if (xdia(mgs,lc,1).gt.12.0e-06 .and. xdia(mgs,li,1).gt.50.0e-06) then
15951 eiw(mgs) = eiw0
15952 end if
15953 if ( temg(mgs) .ge. 273.15 ) eiw(mgs) = 0.0
15954 end if
15955
15956!
15957!
15958!
15959! Rain: Collection (cxc) efficiencies
15960!
15961!
15962 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,lc).gt.qxmin(lc) ) then
15963
15964 IF ( lnr .gt. 1 ) THEN
15965 erw(mgs) = 1.0
15966
15967 ELSE
15968
15969! cwrad = 0.5*xdia(mgs,lc,1)
15970! erw(mgs) =
15971! > min((aradcw + cwrad*(bradcw + cwrad*
15972! < (cradcw + cwrad*(dradcw)))), 1.0)
15973! IF ( xdia(mgs,lc,1) .lt. 2.4e-06 .or. xdia(mgs,lr,1) .le. 50.0e-6 ) THEN
15974! erw(mgs)=0.0
15975! ENDIF
15976! erw(mgs) = ew(icwr(mgs),igwr(mgs))
15977! interpolate along droplet radius
15978 ic = icwr(mgs)
15979 icp1 = min( 8, ic+1 )
15980 ir = irwr(mgs)
15981 irp1 = min( 6, ir+1 )
15982 cwrad = 0.5*xdia(mgs,lc,3)
15983 rwrad = 0.5*xdia(mgs,lr,3)
15984
15985 slope1 = (ew(icp1, ir ) - ew(ic,ir ))*cwr(ic,2)
15986 slope2 = (ew(icp1, irp1) - ew(ic,irp1))*cwr(ic,2)
15987
15988! write(iunit,*) 'slop1: ',slope1,slope2,ew(ic,ir),cwr(ic,2)
15989
15990 x1 = ew(ic, ir) + slope1*max(0.0, (cwrad - cwr(ic,1)) )
15991 x2 = ew(icp1,ir) + slope2*max(0.0, (cwrad - cwr(ic,1)) )
15992
15993 slope1 = (x2 - x1)*grad(ir,2)
15994
15995 erw(mgs) = max(0.0, x1 + slope1*max(0.0, (rwrad - grad(ir,1)) ))
15996
15997! write(iunit,*) 'erw: ',erw(mgs),1.e6*cwrad,1.e6*rwrad,ic,ir,x1,x2
15998! write(iunit,*)
15999
16000 erw(mgs) = max(0.0, erw(mgs) )
16001 IF ( rwrad .lt. 50.e-6 ) THEN
16002 erw(mgs) = 0.0
16003 ELSEIF ( rwrad .lt. 100.e-6 ) THEN ! linear change from zero at 50 to erw at 100 microns
16004 erw(mgs) = erw(mgs)*(rwrad - 50.e-6)/50.e-6
16005 ENDIF
16006
16007 ENDIF
16008 end if
16009 IF ( cx(mgs,lc) .le. 0.0 ) erw(mgs) = 0.0
16010!
16011 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,lr).gt.qxmin(lr) ) then
16012 err(mgs)=1.0
16013 end if
16014!
16015 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,ls).gt.qxmin(ls) ) then
16016 ers(mgs)=1.0
16017 end if
16018!
16019 if ( qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,li).gt.qxmin(li) ) then
16020! IF ( vtxbar(mgs,lr,1) .gt. vtxbar(mgs,li,1) .and.
16021! : xdia(mgs,lr,3) .gt. 200.e-6 .and. xdia(mgs,li,3) .gt. 100.e-6 ) THEN
16022 eri(mgs) = eri0
16023! cwrad = 0.5*xdia(mgs,li,3)
16024! eri(mgs) =
16025! > 1.0*min((aradcw + cwrad*(bradcw + cwrad*
16026! < (cradcw + cwrad*(dradcw)))), 1.0)
16027! ENDIF
16028! if ( xdia(mgs,li,1) .lt. 10.e-6 ) eri(mgs)=0.0
16029 if ( xdia(mgs,li,3) .lt. eri_cimin ) eri(mgs)=0.0
16030 end if
16031!
16032!
16033! Snow aggregates: Collection (cxc) efficiencies
16034!
16035! Modified by ERM with a linear function for small droplets and large
16036! snow agg. based numerical data from Wang and Ji (1992) in P&K 1997 (Fig. 14-13), which
16037! allows collection of very small droplets, albeit at low efficiency. But slow
16038! fall speeds of snow make up for the efficiency.
16039!
16040 esw(mgs) = 0.0
16041 if ( qx(mgs,ls).gt.qxmin(ls) .and. qx(mgs,lc).gt.qxmin(lc) ) then
16042 esw(mgs) = 0.5
16043 if ( xdia(mgs,lc,1) .gt. 15.e-6 .and. xdia(mgs,ls,1) .gt. 100.e-6) then
16044 esw(mgs) = 0.5
16045 ELSEIF ( xdia(mgs,ls,1) .ge. 500.e-6 ) THEN
16046 esw(mgs) = min(0.5, 0.05 + (0.8-0.05)/(40.e-6)*xdia(mgs,lc,1) )
16047 ENDIF
16048 end if
16049!
16050 if ( qx(mgs,ls).gt.qxmin(ls) .and. qx(mgs,lr).gt.qxmin(lr) &
16051 & .and. temg(mgs) .lt. tfr - 1. &
16052 & ) then
16053 esr(mgs)=exp(-(40.e-6)**3/xv(mgs,lr))*exp(-40.e-6/xdia(mgs,ls,1))
16054 IF ( qx(mgs,ls) < 1.e-4 .and. qx(mgs,lr) < 1.e-4 ) il2(mgs) = 1
16055 end if
16056
16057 IF ( ipconc < 3 .and. temg(mgs) < tfr .and. qx(mgs,lr).gt.qxmin(lr) .and. qx(mgs,lr) < 1.e-4 ) THEN
16058 il3(mgs) = 1
16059 ENDIF
16060!
16061! if ( qx(mgs,ls).gt.qxmin(ls) ) then
16062 if ( temcg(mgs) < 0.0 ) then
16063
16064 IF ( ipconc .lt. 4 .or. temcg(mgs) < esstem1 ) THEN
16065 ess(mgs) = 0.0
16066! ess(mgs)=0.1*exp(0.1*min(temcg(mgs),0.0))
16067! ess(mgs)=min(0.1,ess(mgs))
16068
16069 ELSE
16070
16071 fac = abs(ess0)
16072 IF ( iessopt == 2 ) THEN ! experimental code
16073! IF ( wvel(mgs) > 2.0 .or. wvel(mgs) < -0.5 .or. ssi(mgs) < 1.0 ) THEN
16074 IF ( wvel(mgs) > 2.0 ) THEN
16075 ! assume convective cell or downdraft
16076 fac = 0.0
16077 ELSEIF ( wvel(mgs) > 1.0 ) THEN ! transition to stratiform range of values
16078 fac = max(0.0, 2.0 - wvel(mgs))*fac
16079 ENDIF
16080 ELSEIF ( iessopt == 3 ) THEN ! factor based on ice supersat
16081 IF ( ssi(mgs) <= 1.0 ) THEN
16082 fac = 0.0
16083 ehsfac(mgs) = 0.0
16084 ELSEIF ( ssi(mgs) <= 1.02 ) THEN
16085 fac = fac*(ssi(mgs) - 1.0)/0.02
16086 ehsfac(mgs) = (ssi(mgs) - 1.0)/0.02
16087 ENDIF
16088 ELSEIF ( iessopt == 4 ) THEN ! factor based on ice supersat; very roughly based on Hosler et al. 1957 (J. Met.)
16089 IF ( ssi(mgs) <= 1.0 ) THEN
16090 fac = 0.1
16091 ehsfac(mgs) = 0.1
16092 ELSEIF ( ssi(mgs) <= 1.005 ) THEN
16093 fac = max(0.1, fac*(ssi(mgs) - 1.0)/0.005)
16094 ehsfac(mgs) = max(0.1, (ssi(mgs) - 1.0)/0.005)
16095 ENDIF
16096 ENDIF
16097
16098 IF ( temcg(mgs) > esstem1 .and. temcg(mgs) < esstem2 ) THEN ! only nonzero for T > esstem1
16099 ess(mgs) = fac*exp(ess1*(esstem2) )*(temcg(mgs) - esstem1)/(esstem2 - esstem1) ! linear ramp up from zero at esstem1 to value at esstem2
16100 ELSEIF ( temcg(mgs) >= esstem2 ) THEN
16101 ess(mgs) = fac*exp(ess1*min( temcg(mgs), 0.0 ) )
16102 ENDIF
16103
16104 ENDIF
16105 end if
16106!
16107 if ( qx(mgs,ls).gt.qxmin(ls) .and. qx(mgs,li).gt.qxmin(li) ) then
16108 esiclsn(mgs) = esi_collsn
16109! IF ( ipconc .lt. 4 ) THEN
16110 IF ( ipconc < 1 .and. lwsm6 ) THEN
16111 esi(mgs) = exp(0.7*min(temcg(mgs),0.0))
16112 ELSE
16113 esi(mgs) = esi0*exp(0.1*min(temcg(mgs),0.0))
16114 esi(mgs) = min(0.1,esi(mgs))
16115 ENDIF
16116 IF ( ipconc .le. 3 ) THEN
16117 esi(mgs) = exp(0.025*min(temcg(mgs),0.0)) ! LFO
16118! esi(mgs) = Min(0.5, exp(0.025*min(temcg(mgs),0.0)) ) ! LFO
16119! esi(mgs)=0.5*exp(0.1*min(temcg(mgs),0.0)) ! 10ice
16120 ENDIF
16121! ELSE ! zrnic/ziegler 1993
16122! esi(mgs)= 0.1 ! 0.5*exp(0.1*min(temcg(mgs),0.0))
16123! ENDIF
16124 if ( temg(mgs) .gt. 273.15 ) esi(mgs) = 0.0
16125 end if
16126
16127!
16128!
16129!
16130!
16131! Graupel: Collection (cxc) efficiencies
16132!
16133!
16134 xmascw(mgs) = xmas(mgs,lc)
16135 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lc).gt.qxmin(lc) ) then !{
16136 ehw(mgs) = 1.0
16137 IF ( iehw .eq. 0 ) THEN
16138 ehw(mgs) = ehw0 ! default value is 1.0
16139 ELSEIF ( iehw .eq. 1 .or. iehw .eq. 10 ) THEN
16140 cwrad = 0.5*xdia(mgs,lc,1)
16141 ehw(mgs) = min( ehw0, &
16142 & ewfac*min((aradcw + cwrad*(bradcw + cwrad* &
16143 & (cradcw + cwrad*(dradcw)))), 1.0) )
16144
16145 ELSEIF ( iehw .eq. 2 .or. iehw .eq. 10 ) THEN
16146 ic = icwr(mgs)
16147 icp1 = min( 8, ic+1 )
16148 ir = igwr(mgs)
16149 irp1 = min( 6, ir+1 )
16150 cwrad = 0.5*xdia(mgs,lc,1)
16151 rwrad = 0.5*xdia(mgs,lh,3) ! changed to mean volume diameter
16152
16153 slope1 = (ew(icp1, ir ) - ew(ic,ir ))*cwr(ic,2)
16154 slope2 = (ew(icp1, irp1) - ew(ic,irp1))*cwr(ic,2)
16155
16156! write(iunit,*) 'slop1: ',slope1,slope2,ew(ic,ir),cwr(ic,2)
16157
16158 x1 = ew(ic, ir) + slope1*max(0.0, (cwrad - cwr(ic,1)) )
16159 x2 = ew(icp1,ir) + slope2*max(0.0, (cwrad - cwr(ic,1)) )
16160
16161 slope1 = (x2 - x1)*grad(ir,2)
16162
16163 tmp = max( 0.0, min( 1.0, x1 + slope1*max(0.0, (rwrad - grad(ir,1)) ) ) )
16164 ehw(mgs) = min( ehw(mgs), tmp )
16165
16166! write(iunit,*) 'ehw: ',ehw(mgs),1.e6*cwrad,1.e6*rwrad,ic,ir,x1,x2
16167! write(iunit,*)
16168
16169! ehw(mgs) = Max( 0.2, ehw(mgs) )
16170! assume that ehw = 1 for zero air resistance (rho0 = 0.0) and extrapolate toward that
16171! ehw(mgs) = ehw(mgs) + (ehw(mgs) - 1.0)*(rho0(mgs) - rho00)/rho00
16172! ehw(mgs) = ehw(mgs) + (1.0 - ehw(mgs))*((Max(0.0,rho00 - rho0(mgs)))/rho00)**2
16173
16174 ELSEIF ( iehw .eq. 3 .or. iehw .eq. 10 ) THEN ! use fraction of droplets greater than dmincw diameter
16175 tmp = exp(- (dmincw/xdia(mgs,lc,1))**3)
16176 xmascw(mgs) = xmas(mgs,lc) + xdn0(lc)*(pi*dmincw**3/6.0) ! this is the average mass of the droplets with d > dmincw
16177 ehw(mgs) = min( ehw(mgs), tmp )
16178 ELSEIF ( iehw .eq. 4 .or. iehw .eq. 10 ) THEN ! Cober and List 1993, eq. 19-20
16179 tmp = &
16180 & 2.0*xdn(mgs,lc)*vtxbar(mgs,lh,1)*(0.5*xdia(mgs,lc,1))**2 &
16181 & /(9.0*fadvisc(mgs)*0.5*xdia(mgs,lh,3))
16182 tmp = max( 1.5, min(10.0, tmp) )
16183 ehw(mgs) = min( ehw(mgs), 0.55*log10(2.51*tmp) )
16184 ENDIF
16185 if ( xdia(mgs,lc,1) .lt. 2.4e-06 ) ehw(mgs)=0.0
16186
16187 ehw(mgs) = min( ehw0, ehw(mgs) )
16188
16189 IF ( ibfc == -1 .and. temcg(mgs) < -41.0 ) THEN
16190 ehw(mgs) = 0.0
16191 ENDIF
16192
16193 end if !}
16194!
16195 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lr).gt.qxmin(lr) &
16196! & .and. temg(mgs) .lt. tfr &
16197 & ) then
16198! ehr(mgs) = Exp(-(40.e-6)**3/xv(mgs,lr))*Exp(-40.e-6/xdia(mgs,lh,1))
16199! ehr(mgs) = 1.0
16200 ehr(mgs) = exp(-(40.e-6)/xdia(mgs,lr,3))*exp(-40.e-6/xdia(mgs,lh,3))
16201 ehr(mgs) = min( ehr0, ehr(mgs) )
16202 end if
16203!
16204 IF ( qx(mgs,ls).gt.qxmin(ls) ) THEN
16205 IF ( ipconc .ge. 4 ) THEN
16206 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
16207 ELSE
16208 ehscnv(mgs) = exp(0.09*min(temcg(mgs),0.0))
16209 ENDIF
16210
16211 IF ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lc) >= qxmin(lc) ) THEN
16212! ehsclsn(mgs) = ehs_collsn
16213! ehs(mgs) = ehscnv(mgs)*ehsfac(mgs)*Min(1.0, Max(0.0,xdn(mgs,lh) - 300.)/300. )
16214! ELSEIF ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lc) >= qxmin(lc) ) then
16215 ehsclsn(mgs) = ehs_collsn
16216 IF ( xdia(mgs,ls,3) < 40.e-6 ) THEN
16217 ehsclsn(mgs) = 0.0
16218 ELSEIF ( xdia(mgs,ls,3) < 150.e-6 ) THEN
16219 ehsclsn(mgs) = ehs_collsn*(xdia(mgs,ls,3) - 40.e-6)/(150.e-6 - 40.e-6)
16220 ELSE
16221 ehsclsn(mgs) = ehs_collsn
16222 ENDIF
16223! 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
16224 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
16225! ehs(mgs) = ehscnv(mgs) ! *Min(1.0, Max(0.0,xdn(mgs,lh) - 300.)/300. ) ! shut off qhacs as graupel goes to low density
16226 ehs(mgs) = min(ehs(mgs),ehsmax)
16227 end if
16228 ENDIF
16229!
16230 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,li).gt.qxmin(li) ) then
16231 ehiclsn(mgs) = ehi_collsn
16232 ehi(mgs)=eii0*exp(eii1*min(temcg(mgs),0.0))
16233 ehi(mgs) = min( ehimax, max( ehi(mgs), ehimin ) )
16234! if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehi(mgs) = 0.0
16235 end if
16236
16237 IF ( lis > 1 ) THEN
16238 if ( qx(mgs,lh).gt.qxmin(lh) .and. qx(mgs,lis).gt.qxmin(lis) ) then
16239 ehisclsn(mgs) = ehi_collsn
16240 ehis(mgs)=eii0*exp(eii1*min(temcg(mgs),0.0))
16241 ehis(mgs) = min( ehimax, max( ehis(mgs), ehimin ) )
16242! if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehis(mgs) = 0.0
16243 end if
16244 ENDIF
16245
16246
16247!
16248!
16249! Hail: Collection (cxc) efficiencies
16250!
16251!
16252 IF ( lhl .gt. 1 ) THEN
16253
16254 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,lc).gt.qxmin(lc) ) then
16255 IF ( iehw == 3 ) iehlw = 3
16256 IF ( iehw == 4 ) iehlw = 4
16257 ehlw(mgs) = ehlw0
16258 IF ( iehlw .eq. 0 ) THEN
16259 ehlw(mgs) = ehlw0 ! default value is 1.0
16260 ELSEIF ( iehlw .eq. 1 .or. iehlw .eq. 10 ) THEN
16261 cwrad = 0.5*xdia(mgs,lc,1)
16262 ehlw(mgs) = min( ehlw0, &
16263 & ewfac*min((aradcw + cwrad*(bradcw + cwrad* &
16264 & (cradcw + cwrad*(dradcw)))), 1.0) )
16265
16266 ELSEIF ( iehlw .eq. 2 .or. iehlw .eq. 10 ) THEN
16267 ic = icwr(mgs)
16268 icp1 = min( 8, ic+1 )
16269 ir = ihlr(mgs)
16270 irp1 = min( 6, ir+1 )
16271 cwrad = 0.5*xdia(mgs,lc,1)
16272 rwrad = 0.5*xdia(mgs,lhl,3) ! changed to mean volume diameter
16273
16274 slope1 = (ew(icp1, ir ) - ew(ic,ir ))*cwr(ic,2)
16275 slope2 = (ew(icp1, irp1) - ew(ic,irp1))*cwr(ic,2)
16276
16277 x1 = ew(ic, ir) + slope1*(cwrad - cwr(ic,1))
16278 x2 = ew(icp1,ir) + slope2*(cwrad - cwr(ic,1))
16279
16280 slope1 = (x2 - x1)*grad(ir,2)
16281
16282 tmp = max( 0.0, min( 1.0, x1 + slope1*(rwrad - grad(ir,1)) ) )
16283 ehlw(mgs) = min( ehlw(mgs), tmp )
16284 ehlw(mgs) = min( ehlw0, ehlw(mgs) )
16285! ehw(mgs) = Max( 0.2, ehw(mgs) )
16286! assume that ehw = 1 for zero air resistance (rho0 = 0.0) and extrapolate toward that
16287! ehw(mgs) = ehw(mgs) + (ehw(mgs) - 1.0)*(rho0(mgs) - rho00)/rho00
16288! ehlw(mgs) = ehlw(mgs) + (1.0 - ehlw(mgs))*((Max(0.0,rho00 - rho0(mgs)))/rho00)**2
16289
16290 ELSEIF ( iehlw .eq. 3 .or. iehlw .eq. 10 ) THEN ! use fraction of droplets greater than 15 micron diameter
16291 tmp = exp(- (dmincw/xdia(mgs,lc,1))**3)
16292 ehlw(mgs) = min( ehlw(mgs), tmp )
16293 ELSEIF ( iehlw .eq. 4 .or. iehlw .eq. 10 ) THEN ! Cober and List 1993
16294 tmp = &
16295 & 2.0*xdn(mgs,lc)*vtxbar(mgs,lhl,1)*(0.5*xdia(mgs,lc,1))**2 &
16296 & /(9.0*fadvisc(mgs)*0.5*xdia(mgs,lhl,3))
16297 tmp = max( 1.5, min(10.0, tmp) )
16298 ehlw(mgs) = min( ehlw(mgs), 0.55*log10(2.51*tmp) )
16299 ENDIF
16300 if ( xdia(mgs,lc,1) .lt. 2.4e-06 ) ehlw(mgs)=0.0
16301 ehlw(mgs) = min( ehlw0, ehlw(mgs) )
16302
16303 IF ( ibfc == -1 .and. temcg(mgs) < -41.0 ) THEN
16304 ehlw(mgs) = 0.0
16305 ENDIF
16306
16307 end if
16308!
16309 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,lr).gt.qxmin(lr) &
16310! & .and. temg(mgs) .lt. tfr &
16311 & ) then
16312 ehlr(mgs) = 1.0
16313 ehlr(mgs) = min( ehlr0, ehlr(mgs) )
16314 end if
16315!
16316 IF ( qx(mgs,ls).gt.qxmin(ls) ) THEN
16317 if ( qx(mgs,lhl).gt.qxmin(lhl) ) then
16318 ehlsclsn(mgs) = ehls_collsn
16319 ehls(mgs) = ehscnv(mgs)
16320 ehls(mgs) = min(ehls(mgs),ehsmax)
16321 end if
16322 ENDIF
16323!
16324 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,li).gt.qxmin(li) ) then
16325 ehliclsn(mgs) = ehli_collsn
16326 ehli(mgs)=eii0hl*exp(eii1hl*min(temcg(mgs),0.0))
16327 ehli(mgs) = min( ehimax, max( ehli(mgs), ehimin ) )
16328 if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehli(mgs) = 0.0
16329 end if
16330
16331 IF ( lis > 1 ) THEN
16332 if ( qx(mgs,lhl).gt.qxmin(lhl) .and. qx(mgs,lis).gt.qxmin(lis) ) then
16333 ehlisclsn(mgs) = ehli_collsn
16334 ehlis(mgs)=eii0*exp(eii1*min(temcg(mgs),0.0))
16335 ehlis(mgs) = min( ehimax, max( ehlis(mgs), ehimin ) )
16336 if ( temg(mgs) .gt. 273.15 .or. ( qx(mgs,lc) < qxmin(lc)) ) ehlis(mgs) = 0.0
16337 end if
16338 ENDIF
16339
16340
16341 ENDIF ! lhl .gt. 1
16342
16343 ENDDO ! mgs loop for collection efficiencies
16344
16345!
16346!
16347!
16348! Set flags for plates vs. columns
16349!
16350!
16351 do mgs = 1,ngscnt
16352!
16353 xplate(mgs) = 0.0
16354 xcolmn(mgs) = 1.0
16355!
16356! if ( temcg(mgs) .lt. 0. .and. temcg(mgs) .ge. -4. ) then
16357! xplate(mgs) = 1.0
16358! xcolmn(mgs) = 0.0
16359! end if
16360!c
16361! if ( temcg(mgs) .lt. -4. .and. temcg(mgs) .ge. -9. ) then
16362! xplate(mgs) = 0.0
16363! xcolmn(mgs) = 1.0
16364! end if
16365!c
16366! if ( temcg(mgs) .lt. -9. .and. temcg(mgs) .ge. -22.5 ) then
16367! xplate(mgs) = 1.0
16368! xcolmn(mgs) = 0.0
16369! end if
16370!c
16371! if ( temcg(mgs) .lt. -22.5 .and. temcg(mgs) .ge. -90. ) then
16372! xplate(mgs) = 0.0
16373! xcolmn(mgs) = 1.0
16374! end if
16375!
16376 end do
16377
16378
16379
16380!
16381!
16382!
16383! Collection growth equations....
16384!
16385!
16386 if (ndebug .gt. 0 ) write(0,*) 'Collection: rain collects xxxxx'
16387!
16388 do mgs = 1,ngscnt
16389 qracw(mgs) = 0.0
16390 IF ( qx(mgs,lr) .gt. qxmin(lr) .and. erw(mgs) .gt. 0.0 ) THEN
16391 IF ( ipconc .lt. 3 ) THEN
16392 IF ( erw(mgs) .gt. 0.0 .and. qx(mgs,lr) .gt. 1.e-7 ) THEN
16393 vt = (ar*(xdia(mgs,lc,1)**br))*rhovt(mgs)
16394 qracw(mgs) = &
16395 & (0.25)*pi*erw(mgs)*(qx(mgs,lc)-qcwresv(mgs))*cx(mgs,lr) &
16396! > *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,lc,1)) &
16397 & *max(0.0, vtxbar(mgs,lr,1)-vt) &
16398 & *( gf3*xdia(mgs,lr,2) &
16399 & + 2.0*gf2*xdia(mgs,lr,1)*xdia(mgs,lc,1) &
16400 & + gf1*xdia(mgs,lc,2) )
16401! qracw(mgs) = 0.0
16402! write(iunit,*) 'qracw,cx =',qracw(mgs),1.e6*xdia(mgs,lr,1),erw(mgs)
16403! 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
16404! write(iunit,*) 'vtr: ',vtxbar(mgs,lr,1), ar*gf4br/6.0*xdia(mgs,lr,1)**br, rhovt(mgs),
16405! : ar*gf4br/6.0*xdia(mgs,lr,1)**br * rhovt(mgs)
16406 ENDIF
16407 ELSE
16408
16409 IF ( dmrauto <= 0 .or. rho0(mgs)*qx(mgs,lr) > 1.2*xl2p(mgs) ) THEN
16410 rwrad = 0.5*xdia(mgs,lr,3)
16411 IF ( rwrad .gt. rh(mgs) ) THEN ! .or. cx(mgs,lr) .gt. nh(mgs) ) THEN
16412 IF ( rwrad .gt. rwradmn ) THEN
16413! DM1CCC=A2*XNC*XNR*XVC*(((CNU+2.)/(CNU+1.))*XVC+XVR) ! (A12)
16414! NOTE: Result is independent of imurain, assumes mucloud = 3
16415 qracw(mgs) = erw(mgs)*aa2*cx(mgs,lr)*cx(mgs,lc)*xmas(mgs,lc)* &
16416 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)/(alpha(mgs,lc) + 1.) + xv(mgs,lr))/rho0(mgs) !*rhoinv(mgs)
16417 ELSE
16418
16419 IF ( imurain == 3 ) THEN
16420
16421! DM1CCC=A1*XNC*XNR*(((CNU+3.)*(CNU+2.)/(CNU+1.)**2)*XVC**3+ ! (A14)
16422! 1 ((RNU+2.)/(RNU+1.))*XVC*XVR**2)
16423
16424! qracw(mgs) = aa1*cx(mgs,lr)*cx(mgs,lc)*xdn(mgs,lc)* &
16425! & ((cnu + 3.)*(cnu + 2.)*xv(mgs,lc)**3/(cnu + 1.)**2 + &
16426! & (alpha(mgs,lr) + 2.)*xv(mgs,lc)*xv(mgs,lr)**2/(alpha(mgs,lr) + 1.))/rho0(mgs) !*rhoinv(mgs)
16427! save multiplies by converting cx*xdn*xv/rho0 to qx
16428 qracw(mgs) = aa1*cx(mgs,lr)*(qx(mgs,lc)-qcwresv(mgs))* &
16429 & ((alpha(mgs,lc) + 3.)*(alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.)**2 + &
16430 & (alpha(mgs,lr) + 2.)*xv(mgs,lr)**2/(alpha(mgs,lr) + 1.))
16431
16432 ELSE ! imurain == 1
16433
16434 qracw(mgs) = aa1*cx(mgs,lr)*(qx(mgs,lc)-qcwresv(mgs))* &
16435 & ((alpha(mgs,lc) + 3.)*(alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.)**2 + &
16436 & (alpha(mgs,lr) + 6.)*(alpha(mgs,lr) + 5.)*(alpha(mgs,lr) + 4.)*xv(mgs,lr)**2/ &
16437 & ((alpha(mgs,lr) + 3.)*(alpha(mgs,lr) + 2.)*(alpha(mgs,lr) + 1.)))
16438
16439 ENDIF
16440
16441 ENDIF
16442 ENDIF
16443 ENDIF
16444 ENDIF
16445! qracw(mgs) = Min(qracw(mgs), qx(mgs,lc))
16446 qracw(mgs) = min(qracw(mgs), qcmxd(mgs))
16447 ENDIF
16448 end do
16449!
16450 do mgs = 1,ngscnt
16451 qraci(mgs) = 0.0
16452 craci(mgs) = 0.0
16453 qracs(mgs) = 0.0
16454 IF ( eri(mgs) .gt. 0.0 .and. iacr .ge. 1 .and. xdia(mgs,lr,3) .gt. 2.*rwradmn ) THEN
16455 IF ( ipconc .ge. 3 ) THEN
16456
16457 tmp = eri(mgs)*aa2*cx(mgs,lr)*cx(mgs,li)* &
16458 & ((cinu + 2.)*xv(mgs,li)/(cinu + 1.) + xv(mgs,lr))
16459
16460 qraci(mgs) = min( qxmxd(mgs,li), tmp*xmas(mgs,li)*rhoinv(mgs) )
16461 craci(mgs) = min( cxmxd(mgs,li), tmp )
16462
16463! vt = Sqrt((vtxbar(mgs,lr,1)-vtxbar(mgs,li,1))**2 +
16464! : 0.04*vtxbar(mgs,lr,1)*vtxbar(mgs,li,1) )
16465!
16466! qraci(mgs) = 0.25*pi*eri(mgs)*cx(mgs,lr)*qx(mgs,li)*vt*
16467! : ( da0(lr)*xdia(mgs,lr,3)**2 +
16468! : dab1(lr,li)*xdia(mgs,lr,3)*xdia(mgs,li,3) +
16469! : da1(li)*xdia(mgs,li,3)**2 )
16470!
16471!
16472! vt = Sqrt((vtxbar(mgs,lr,1)-vtxbar(mgs,li,1))**2 +
16473! : 0.04*vtxbar(mgs,lr,1)*vtxbar(mgs,li,1) )
16474!
16475! craci(mgs) = 0.25*pi*eri(mgs)*cx(mgs,lr)*cx(mgs,li)*vt*
16476! : ( da0(lr)*xdia(mgs,lr,3)**2 +
16477! : dab0(lr,li)*xdia(mgs,lr,3)*xdia(mgs,li,3) +
16478! : da0(li)*xdia(mgs,li,3)**2 )
16479!
16480! qraci(mgs) = Min( qraci(mgs), qxmxd(mgs,li) )
16481! craci(mgs) = Min( craci(mgs), cxmxd(mgs,li) )
16482
16483 ELSE
16484 qraci(mgs) = &
16485 & min( &
16486 & (0.25)*pi*eri(mgs)*qx(mgs,li)*cx(mgs,lr) &
16487 & *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,li,1)) &
16488 & *( gf3*xdia(mgs,lr,2) &
16489 & + 2.0*gf2*xdia(mgs,lr,1)*xdia(mgs,li,1) &
16490 & + gf1*xdia(mgs,li,2) ) &
16491 & , qimxd(mgs))
16492 ENDIF
16493 if ( temg(mgs) .gt. 268.15 ) then
16494 qraci(mgs) = 0.0
16495 end if
16496 ENDIF
16497 end do
16498!
16499 IF ( ipconc < 3 ) THEN
16500 do mgs = 1,ngscnt
16501 qracs(mgs) = 0.0
16502 IF ( ers(mgs) .gt. 0.0 .and. ipconc < 3 ) THEN
16503 IF ( lwsm6 .and. ipconc == 0 ) THEN
16504 vt = vt2ave(mgs)
16505 ELSE
16506 vt = vtxbar(mgs,ls,1)
16507 ENDIF
16508 qracs(mgs) = &
16509 & min( &
16510 & ((0.25)*pi/gf4)*ers(mgs)*qx(mgs,ls)*cx(mgs,lr) &
16511 & *abs(vtxbar(mgs,lr,1)-vt) &
16512 & *( gf6*gf1*xdia(mgs,ls,2) &
16513 & + 2.0*gf5*gf2*xdia(mgs,ls,1)*xdia(mgs,lr,1) &
16514 & + gf4*gf3*xdia(mgs,lr,2) ) &
16515 & , qsmxd(mgs))
16516 ENDIF
16517 end do
16518 ENDIF
16519
16520!
16521!
16522 if (ndebug .gt. 0 ) write(0,*) 'Collection: snow collects xxxxx'
16523!
16524 do mgs = 1,ngscnt
16525 qsacw(mgs) = 0.0
16526 csacw(mgs) = 0.0
16527 vsacw(mgs) = 0.0
16528 IF ( esw(mgs) .gt. 0.0 ) THEN
16529
16530 IF ( ipconc .ge. 4 ) THEN
16531! QSACC=CECS*RVT*A2*XNC*XNS*XVC*ROS*
16532! * (((CNU+2.)/(CNU+1.))*XVC+XVS)/RO
16533
16534! tmp = esw(mgs)*rvt*aa2*cx(mgs,ls)*cx(mgs,lc)*
16535! : ((cnu + 2.)*xv(mgs,lc)/(cnu + 1.) + xv(mgs,ls))
16536 tmp = 1.0*rvt*aa2*cx(mgs,ls)*cx(mgs,lc)* &
16537 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)/(alpha(mgs,lc) + 1.) + xv(mgs,ls))
16538
16539 qsacw(mgs) = min( qxmxd(mgs,lc), tmp*xmas(mgs,lc)*rhoinv(mgs) )
16540 csacw(mgs) = min( cxmxd(mgs,lc), tmp )
16541
16542 IF ( lvol(ls) .gt. 1 ) THEN
16543 IF ( temg(mgs) .lt. 273.15) THEN
16544 rimdn(mgs,ls) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16545 & *((0.60)*vtxbar(mgs,ls,1)) &
16546 & /(temg(mgs)-273.15))**(rimc2)
16547 rimdn(mgs,ls) = min( max( rimc3, rimdn(mgs,ls) ), rimc4 )
16548 ELSE
16549 rimdn(mgs,ls) = 1000.
16550 ENDIF
16551
16552 vsacw(mgs) = rho0(mgs)*qsacw(mgs)/rimdn(mgs,ls)
16553
16554 ENDIF
16555
16556
16557! qsacw(mgs) = cecs*aa2*cx(mgs,ls)*cx(mgs,lc)*xmas(mgs,lc)*
16558! : ((alpha(mgs,lc) + 2.)*xv(mgs,lc)/(alpha(mgs,lc) + 1.) + xv(mgs,ls))*rhoinv(mgs)
16559 ELSE
16560! qsacw(mgs) =
16561! > min(
16562! > ((0.25)*pi)*esw(mgs)*qx(mgs,lc)*cx(mgs,ls)
16563! > *abs(vtxbar(mgs,ls,1)-vtxbar(mgs,lc,1))
16564! > *( gf3*xdia(mgs,ls,2)
16565! > + 2.0*gf2*xdia(mgs,ls,1)*xdia(mgs,lc,1)
16566! > + gf1*xdia(mgs,lc,2) )
16567! < , qcmxd(mgs))
16568
16569 vt = abs(vtxbar(mgs,ls,1)-vtxbar(mgs,lc,1))
16570
16571 qsacw(mgs) = 0.25*pi*esw(mgs)*cx(mgs,ls)*qx(mgs,lc)*vt* &
16572 & ( da0(ls)*xdia(mgs,ls,3)**2 + &
16573 & dab1(ls,lc)*xdia(mgs,ls,3)*xdia(mgs,lc,3) + &
16574 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
16575 qsacw(mgs) = min( qsacw(mgs), qxmxd(mgs,ls) )
16576 csacw(mgs) = rho0(mgs)*qsacw(mgs)/xmas(mgs,lc)
16577 ENDIF
16578 ENDIF
16579 end do
16580!
16581!
16582 do mgs = 1,ngscnt
16583 qsaci(mgs) = 0.0
16584 csaci(mgs) = 0.0
16585 csaci0(mgs) = 0.0
16586 IF ( ipconc .ge. 4 ) THEN
16587 IF ( esi(mgs) .gt. 0.0 .or. ( ipelec > 0 .and. esiclsn(mgs) > 0.0 )) THEN
16588! QSCOI=CEXS*RVT*A2*XNCI*XNS*XVCI*ROS*
16589! * (((CINU+2.)/(CINU+1.))*VCIP+XVS)/RO
16590
16591 tmp = esiclsn(mgs)*rvt*aa2*cx(mgs,ls)*cx(mgs,li)* &
16592 & ((cinu + 2.)*xv(mgs,li)/(cinu + 1.) + xv(mgs,ls))
16593
16594 qsaci(mgs) = min( qxmxd(mgs,li), esi(mgs)*tmp*xmas(mgs,li)*rhoinv(mgs) )
16595 csaci0(mgs) = tmp
16596 csaci(mgs) = min(cxmxd(mgs,li), esi(mgs)*tmp )
16597
16598! qsaci(mgs) =
16599! > min(
16600! > ((0.25)*pi)*esi(mgs)*qx(mgs,li)*cx(mgs,ls)
16601! > *abs(vtxbar(mgs,ls,1)-vtxbar(mgs,li,1))
16602! > *( gf3*xdia(mgs,ls,2)
16603! > + 2.0*gf2*xdia(mgs,ls,1)*xdia(mgs,li,1)
16604! > + gf1*xdia(mgs,li,2) )
16605! < , qimxd(mgs))
16606 ENDIF
16607 ELSE !
16608 IF ( esi(mgs) .gt. 0.0 ) THEN
16609 qsaci(mgs) = &
16610 & min( &
16611 & ((0.25)*pi)*esi(mgs)*qx(mgs,li)*cx(mgs,ls) &
16612 & *abs(vtxbar(mgs,ls,1)-vtxbar(mgs,li,1)) &
16613 & *( gf3*xdia(mgs,ls,2) &
16614 & + 2.0*gf2*xdia(mgs,ls,1)*xdia(mgs,li,1) &
16615 & + gf1*xdia(mgs,li,2) ) &
16616 & , qimxd(mgs))
16617 ENDIF
16618 ENDIF
16619 end do
16620!
16621!
16622!
16623 do mgs = 1,ngscnt
16624 qsacr(mgs) = 0.0
16625 qsacrs(mgs) = 0.0
16626 csacr(mgs) = 0.0
16627 IF ( esr(mgs) .gt. 0.0 ) THEN
16628 IF ( ipconc .ge. 3 ) THEN
16629! vt = Sqrt((vtxbar(mgs,ls,1)-vtxbar(mgs,lr,1))**2 +
16630! : 0.04*vtxbar(mgs,ls,1)*vtxbar(mgs,lr,1) )
16631! qsacr(mgs) = esr(mgs)*cx(mgs,ls)*vt*
16632! : qx(mgs,lr)*0.25*pi*
16633! : (3.02787*xdia(mgs,lr,2) +
16634! : 3.30669*xdia(mgs,ls,1)*xdia(mgs,lr,1) +
16635! : 2.*xdia(mgs,ls,2))
16636! qsacr(mgs) = Min( qsacr(mgs), qrmxd(mgs) )
16637! csacr(mgs) = qsacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
16638! csacr(mgs) = min(csacr(mgs),crmxd(mgs))
16639 ELSE
16640 IF ( lwsm6 .and. ipconc == 0 ) THEN
16641 vt = vt2ave(mgs)
16642 ELSE
16643 vt = vtxbar(mgs,ls,1)
16644 ENDIF
16645
16646 qsacr(mgs) = &
16647 & min( &
16648 & ((0.25)*pi/gf4)*esr(mgs)*qx(mgs,lr)*cx(mgs,ls) &
16649 & *abs(vtxbar(mgs,lr,1)-vt) &
16650 & *( gf6*gf1*xdia(mgs,lr,2) &
16651 & + 2.0*gf5*gf2*xdia(mgs,lr,1)*xdia(mgs,ls,1) &
16652 & + gf4*gf3*xdia(mgs,ls,2) ) &
16653 & , qrmxd(mgs))
16654 ENDIF
16655 ENDIF
16656 end do
16657!
16658!
16659!
16660
16661 if (ndebug .gt. 0 ) write(0,*) 'Collection: graupel collects xxxxx'
16662!
16663 do mgs = 1,ngscnt
16664 qhacw(mgs) = 0.0
16665 qhacwmlr(mgs) = 0.0
16666 rarx(mgs,lh) = 0.0
16667 vhacw(mgs) = 0.0
16668 vhsoak(mgs) = 0.0
16669 zhacw(mgs) = 0.0
16670
16671 IF ( .false. ) THEN
16672 vtmax = (gz(igs(mgs),jgs,kgs(mgs))*dtpinv)
16673 vtxbar(mgs,lh,1) = min( vtmax, vtxbar(mgs,lh,1))
16674 vtxbar(mgs,lh,2) = min( vtmax, vtxbar(mgs,lh,2))
16675 vtxbar(mgs,lh,3) = min( vtmax, vtxbar(mgs,lh,3))
16676 ENDIF
16677 IF ( ehw(mgs) .gt. 0.0 ) THEN
16678
16679 IF ( ipconc .ge. 2 ) THEN
16680
16681 IF ( .false. ) THEN
16682 qhacw(mgs) = (ehw(mgs)*(qx(mgs,lc)-qcwresv(mgs))*cx(mgs,lh)*pi* &
16683 & abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1))* &
16684 & (2.0*xdia(mgs,lh,1)*(xdia(mgs,lh,1) + &
16685 & xdia(mgs,lc,1)*gf73rds) + &
16686 & xdia(mgs,lc,2)*gf83rds))/4.
16687
16688 ELSE ! using Seifert coefficients
16689 vt = abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1))
16690
16691 qhacw(mgs) = 0.25*pi*ehw(mgs)*cx(mgs,lh)*(qx(mgs,lc)-qcwresv(mgs))*vt* &
16692 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16693 & dab1lh(mgs,lh,lc)*xdia(mgs,lh,3)*xdia(mgs,lc,3) + &
16694 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
16695
16696 ENDIF
16697 qhacw(mgs) = min( qhacw(mgs), 0.5*qx(mgs,lc)*dtpinv )
16698
16699 IF ( lzh .gt. 1 ) THEN
16700 tmp = qx(mgs,lh)/cx(mgs,lh)
16701
16702!! g1 = (6.0 + alpha(mgs,lh))*(5.0 + alpha(mgs,lh))*(4.0 + alpha(mgs,lh))/
16703!! : ((3.0 + alpha(mgs,lh))*(2.0 + alpha(mgs,lh))*(1.0 + alpha(mgs,lh)))
16704! alp = Max( 1.0, alpha(mgs,lh)+1. )
16705! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/
16706! : ((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
16707! zhacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacw(mgs) )
16708 ENDIF
16709
16710 ELSE
16711 qhacw(mgs) = &
16712 & min( &
16713 & ((0.25)*pi)*ehw(mgs)*(qx(mgs,lc)-qcwresv(mgs))*cx(mgs,lh) &
16714 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1)) &
16715 & *( gf3*xdia(mgs,lh,2) &
16716 & + 2.0*gf2*xdia(mgs,lh,1)*xdia(mgs,lc,1) &
16717 & + gf1*xdia(mgs,lc,2) ) &
16718 & , 0.5*(qx(mgs,lc)-qcwresv(mgs))*dtpinv)
16719! < , qxmxd(mgs,lc))
16720! < , qcmxd(mgs))
16721
16722
16723 IF ( lwsm6 .and. qsacw(mgs) > 0.0 .and. qhacw(mgs) > 0.0) THEN
16724 qaacw = ( qx(mgs,ls)*qsacw(mgs) + qx(mgs,lh)*qhacw(mgs) )/(qx(mgs,ls) + qx(mgs,lh))
16725! qaacw = Min( qaacw, 0.5*(qsacw(mgs) + qhacw(mgs) ) )
16726 qsacw(mgs) = qaacw
16727 qhacw(mgs) = qaacw
16728 ENDIF
16729
16730 ENDIF
16731
16732 qhacwmlr(mgs) = qhacw(mgs)
16733 IF ( temg(mgs) > tfr .and. iqhacwshr == 0 ) THEN
16734 qhacw(mgs) = 0.0
16735 ENDIF
16736
16737 IF ( lvol(lh) .gt. 1 .or. lhl .gt. 1 ) THEN ! calculate rime density for graupel volume and/or for graupel conversion to hail
16738
16739 IF ( temg(mgs) .lt. 273.15) THEN
16740 IF ( irimdenopt == 1 ) THEN ! Heymsfield and Pflaum (1985)
16741 vt = ( (1.0-rimdenvwgt)*vtxbar(mgs,lh,1) + rimdenvwgt*vtxbar(mgs,lh,2) )
16742
16743 rimdn(mgs,lh) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16744 & *((0.60)*vt ) &
16745 & /(temg(mgs)-273.15))**(rimc2)
16746! rimdn(mgs,lh) = Min( Max( hdnmn, rimc3, rimdn(mgs,lh) ), rimc4 )
16747 rimdn(mgs,lh) = min( max( rimc3, rimdn(mgs,lh) ), rimc4 )
16748
16749! IF ( igs(mgs) == 30 ) THEN
16750! 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)
16751! write(0,*) 'diam: char, mean, maxmass = ',xdia(mgs,lh,1),xdia(mgs,lh,3),(alpha(mgs,lh)+3.)*xdia(mgs,lh,1)
16752! write(0,*) 'ax,bx,cd,xdn = ',axx(mgs,lh),bxx(mgs,lh),cdxgs(mgs,lh),xdn(mgs,lh)
16753! 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)
16754! write(0,*) 'rimdn,alpha = ',rimdn(mgs,lh),alpha(mgs,lh)
16755! ENDIF
16756
16757 ELSEIF ( irimdenopt == 2 ) THEN ! Cober and List (1993)
16758
16759 tmp = (-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16760 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lh,1) + rimdenvwgt*vtxbar(mgs,lh,2) ) &
16761 & /(temg(mgs)-273.15))
16762 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
16763
16764 rimdn(mgs,lh) = 1000.*(0.051 + 0.114*tmp - 0.0055*tmp**2)
16765
16766 ELSEIF ( irimdenopt == 3 .or. irimdenopt == 4) THEN ! Macklin (3) or Saunders and Hosseini 2001
16767
16768 tmp = (-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
16769 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lh,1) + rimdenvwgt*vtxbar(mgs,lh,2) ) &
16770 & /(temg(mgs)-273.15))
16771 ! tmp = Min( 5.5/0.6, Max( 0.3/0.6, tmp ) )
16772
16773 IF ( irimdenopt == 3 ) THEN
16774 rimdn(mgs,lh) = min(900., max( 170., 110.*tmp**0.76 ) )
16775 ELSEIF ( irimdenopt == 4 ) THEN ! Saunders and Hosseini
16776 rimdn(mgs,lh) = min(917., max( 10., 900.0*(1.0 - 0.905**tmp ) ) )
16777 ENDIF
16778
16779 ENDIF
16780 ELSE
16781 rimdn(mgs,lh) = 1000.
16782 ENDIF
16783
16784 IF ( lvol(lh) > 1 ) vhacw(mgs) = rho0(mgs)*qhacw(mgs)/rimdn(mgs,lh)
16785
16786 ENDIF
16787
16788 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. ipelec .ge. 1 ) THEN
16789 rarx(mgs,lh) = &
16790 & qhacw(mgs)*1.0e3*rho0(mgs)/((pi/2.0)*xdia(mgs,lh,2)*cx(mgs,lh))
16791 ENDIF
16792
16793 ENDIF
16794 end do
16795!
16796!
16797 do mgs = 1,ngscnt
16798 qhaci(mgs) = 0.0
16799 qhaci0(mgs) = 0.0
16800 IF ( ehi(mgs) .gt. 0.0 ) THEN
16801 IF ( ipconc .ge. 5 ) THEN
16802
16803 vt = sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,li,1))**2 + &
16804 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,li,1) )
16805
16806 qhaci0(mgs) = 0.25*pi*ehiclsn(mgs)*cx(mgs,lh)*qx(mgs,li)*vt* &
16807 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16808 & dab1lh(mgs,lh,li)*xdia(mgs,lh,3)*xdia(mgs,li,3) + &
16809 & da1(li)*xdia(mgs,li,3)**2 )
16810 qhaci(mgs) = min( ehi(mgs)*qhaci0(mgs), qimxd(mgs) )
16811 ELSE
16812 qhaci(mgs) = &
16813 & min( &
16814 & ((0.25)*pi)*ehi(mgs)*ehiclsn(mgs)*qx(mgs,li)*cx(mgs,lh) &
16815 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,li,1)) &
16816 & *( gf3*xdia(mgs,lh,2) &
16817 & + 2.0*gf2*xdia(mgs,lh,1)*xdia(mgs,li,1) &
16818 & + gf1*xdia(mgs,li,2) ) &
16819 & , qimxd(mgs))
16820 ENDIF
16821 ENDIF
16822 end do
16823
16824
16825!
16826!
16827 do mgs = 1,ngscnt
16828 qhacs(mgs) = 0.0
16829 qhacs0(mgs) = 0.0
16830 IF ( ehs(mgs) .gt. 0.0 ) THEN
16831 IF ( ipconc .ge. 5 ) THEN
16832
16833 vt = sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1))**2 + &
16834 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,ls,1) )
16835
16836 qhacs0(mgs) = 0.25*pi*ehsclsn(mgs)*cx(mgs,lh)*qx(mgs,ls)*vt* &
16837 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16838 & dab1lh(mgs,lh,ls)*xdia(mgs,lh,3)*xdia(mgs,ls,3) + &
16839 & da1(ls)*xdia(mgs,ls,3)**2 )
16840
16841 qhacs(mgs) = min( ehs(mgs)*qhacs0(mgs), qsmxd(mgs) )
16842
16843 ELSE
16844 qhacs(mgs) = &
16845 & min( &
16846 & ((0.25)*pi/gf4)*ehs(mgs)*ehsclsn(mgs)*qx(mgs,ls)*cx(mgs,lh) &
16847 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1)) &
16848 & *( gf6*gf1*xdia(mgs,ls,2) &
16849 & + 2.0*gf5*gf2*xdia(mgs,ls,1)*xdia(mgs,lh,1) &
16850 & + gf4*gf3*xdia(mgs,lh,2) ) &
16851 & , qsmxd(mgs))
16852 ENDIF
16853 ENDIF
16854 end do
16855!
16856 do mgs = 1,ngscnt
16857 qhacr(mgs) = 0.0
16858 qhacrmlr(mgs) = 0.0
16859 vhacr(mgs) = 0.0
16860 chacr(mgs) = 0.0
16861 zhacr(mgs) = 0.0
16862 IF ( temg(mgs) .gt. tfr ) raindn(mgs,lh) = 1000.0
16863
16864 IF ( ehr(mgs) .gt. 0.0 ) THEN
16865 IF ( ipconc .ge. 3 ) THEN
16866 vt = sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,lr,1))**2 + &
16867 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,lr,1) )
16868! qhacr(mgs) = ehr(mgs)*cx(mgs,lh)*vt*
16869! : qx(mgs,lr)*0.25*pi*
16870! : (3.02787*xdia(mgs,lr,2) +
16871! : 3.30669*xdia(mgs,lh,1)*xdia(mgs,lr,1) +
16872! : 2.*xdia(mgs,lh,2))
16873
16874 qhacr(mgs) = 0.25*pi*ehr(mgs)*cx(mgs,lh)*qx(mgs,lr)*vt* &
16875 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16876 & dab1lh(mgs,lh,lr)*xdia(mgs,lh,3)*xdia(mgs,lr,3) + &
16877 & da1lr(mgs)*xdia(mgs,lr,3)**2 )
16878! & da1(lr)*xdia(mgs,lr,3)**2 )
16879! IF ( qhacr(mgs) .gt. 0. .or. tmp .gt. 0.0 ) write(0,*) 'qhacr= ',qhacr(mgs),tmp
16880!! qhacr(mgs) = Min( qhacr(mgs), qrmxd(mgs) )
16881!! chacr(mgs) = qhacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
16882!! chacr(mgs) = min(chacr(mgs),crmxd(mgs))
16883
16884 qhacr(mgs) = min( qhacr(mgs), qxmxd(mgs,lr) )
16885
16886 qhacrmlr(mgs) = qhacr(mgs)
16887
16888 IF ( temg(mgs) > tfr .and. iehr0c == 0 ) THEN
16889 qhacr(mgs) = 0.0
16890
16891 IF ( iqhacrmlr == 0 ) THEN
16892 qhacrmlr(mgs) = -qhacw(mgs)
16893 ENDIF
16894
16895 ELSE
16896! chacr(mgs) = Min( qhacr(mgs)*rho0(mgs)/xmas(mgs,lr), cxmxd(mgs,lr) )
16897
16898! chacr(mgs) = ehr(mgs)*cx(mgs,lh)*vt*
16899! : cx(mgs,lr)*0.25*pi*
16900! : (0.69874*xdia(mgs,lr,2) +
16901! : 1.24001*xdia(mgs,lh,1)*xdia(mgs,lr,1) +
16902! : 2.*xdia(mgs,lh,2))
16903
16904 chacr(mgs) = 0.25*pi*ehr(mgs)*cx(mgs,lh)*cx(mgs,lr)*vt* &
16905 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
16906 & dab0lh(mgs,lh,lr)*xdia(mgs,lh,3)*xdia(mgs,lr,3) + &
16907 & da0lr(mgs)*xdia(mgs,lr,3)**2 )
16908
16909! IF ( qhacr(mgs) .gt. 0. .or. tmp .gt. 0.0 ) write(0,*) 'chacr= ',chacr(mgs),tmp
16910
16911! chacr(mgs) = qhacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
16912 chacr(mgs) = min(chacr(mgs),crmxd(mgs))
16913
16914 IF ( lzh .gt. 1 ) THEN
16915 tmp = qx(mgs,lh)/cx(mgs,lh)
16916
16917! g1 = (6.0 + alpha(mgs,lh))*(5.0 + alpha(mgs,lh))*(4.0 + alpha(mgs,lh))/
16918! : ((3.0 + alpha(mgs,lh))*(2.0 + alpha(mgs,lh))*(1.0 + alpha(mgs,lh)))
16919! alp = Max( 1.0, alpha(mgs,lh)+1. )
16920! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/
16921! : ((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
16922! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) - tmp**2 * chacr(mgs) )
16923! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qhacr(mgs) )
16924 ENDIF
16925 ENDIF ! temg > tfr
16926
16927 ELSE
16928 IF ( lwsm6 .and. ipconc == 0 ) THEN
16929 vt = vt2ave(mgs)
16930 ELSE
16931 vt = vtxbar(mgs,lh,1)
16932 ENDIF
16933
16934 qhacr(mgs) = &
16935 & min( &
16936 & ((0.25)*pi/gf4)*ehr(mgs)*qx(mgs,lr)*cx(mgs,lh) &
16937 & *abs(vt-vtxbar(mgs,lr,1)) &
16938 & *( gf6*gf1*xdia(mgs,lr,2) &
16939 & + 2.0*gf5*gf2*xdia(mgs,lr,1)*xdia(mgs,lh,1) &
16940 & + gf4*gf3*xdia(mgs,lh,2) ) &
16941 & , qrmxd(mgs))
16942
16943 IF ( temg(mgs) > tfr ) THEN
16944 IF ( iqhacrmlr >= 1 ) qhacrmlr(mgs) = qhacr(mgs)
16945 qhacr(mgs) = 0.0
16946 ENDIF
16947
16948 ENDIF
16949 IF ( lvol(lh) .gt. 1 .or. lhl .gt. 1 ) THEN ! calculate rime density for graupel volume and/or for graupel conversion to hail
16950
16951 IF ( temg(mgs) .lt. 273.15) THEN
16952 raindn(mgs,lh) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lr,3)) &
16953 & *((0.60)*vt) &
16954 & /(temg(mgs)-273.15))**(rimc2)
16955
16956 raindn(mgs,lh) = min( max( rimc3, rimdn(mgs,lh) ), rimc4 )
16957 ELSE
16958 raindn(mgs,lh) = 1000.
16959 ENDIF
16960
16961 IF ( lvol(lh) > 1 ) vhacr(mgs) = rho0(mgs)*qhacr(mgs)/raindn(mgs,lh)
16962 ENDIF
16963 ENDIF
16964 end do
16965
16966!
16967!
16968 if (ndebug .gt. 0 ) write(0,*) 'Collection: hail collects xxxxx'
16969!
16970
16971 do mgs = 1,ngscnt
16972 qhlacw(mgs) = 0.0
16973 qhlacwmlr(mgs) = 0.0
16974 vhlacw(mgs) = 0.0
16975 vhlsoak(mgs) = 0.0
16976 IF ( lhl > 1 .and. .true.) THEN
16977 vtmax = (gz(igs(mgs),jgs,kgs(mgs))*dtpinv)
16978 vtxbar(mgs,lhl,1) = min( vtmax, vtxbar(mgs,lhl,1))
16979 vtxbar(mgs,lhl,2) = min( vtmax, vtxbar(mgs,lhl,2))
16980 vtxbar(mgs,lhl,3) = min( vtmax, vtxbar(mgs,lhl,3))
16981 ENDIF
16982
16983 IF ( lhl > 0 ) THEN
16984 rarx(mgs,lhl) = 0.0
16985 ENDIF
16986
16987 IF ( lhl .gt. 1 .and. ehlw(mgs) .gt. 0.0 ) THEN
16988
16989
16990! IF ( ipconc .ge. 2 ) THEN
16991
16992 vt = abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,lc,1))
16993
16994 qhlacw(mgs) = 0.25*pi*ehlw(mgs)*cx(mgs,lhl)*(qx(mgs,lc)-qcwresv(mgs))*vt* &
16995 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
16996 & dab1lh(mgs,lhl,lc)*xdia(mgs,lhl,3)*xdia(mgs,lc,3) + &
16997 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
16998
16999
17000 qhlacw(mgs) = min( qhlacw(mgs), 0.5*qx(mgs,lc)*dtpinv )
17001
17002 qhlacwmlr(mgs) = qhlacw(mgs)
17003 IF ( temg(mgs) > tfr .and. iqhlacwshr == 0 ) THEN
17004 qhlacw(mgs) = 0.0
17005 ENDIF
17006
17007 IF ( lvol(lhl) .gt. 1 ) THEN
17008
17009 IF ( temg(mgs) .lt. 273.15) THEN
17010 IF ( irimdenopt == 1 ) THEN ! Heymsfeld and Pflaum (1985)
17011 rimdn(mgs,lhl) = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
17012 & *((0.60)*( (1.0-rimdenvwgt)*vtxbar(mgs,lhl,1) + rimdenvwgt*vtxbar(mgs,lhl,2) )) &
17013 & /(temg(mgs)-273.15))**(rimc2)
17014 rimdn(mgs,lhl) = min( max( hldnmn, rimc3, rimdn(mgs,lhl) ), rimc4 )
17015
17016 ELSEIF ( irimdenopt == 2 ) THEN ! Cober and List (1993)
17017 tmp = -0.5*(1.e+06)*xdia(mgs,lc,1) &
17018 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lhl,1) + rimdenvwgt*vtxbar(mgs,lhl,2) ) &
17019 & /(temg(mgs)-273.15)
17020 tmp = min( 5.5/0.6, max( 0.3/0.6, tmp ) )
17021
17022 rimdn(mgs,lhl) = 1000.*(0.051 + 0.114*tmp - 0.005*tmp**2)
17023
17024 ELSEIF ( irimdenopt == 3 .or. irimdenopt == 4) THEN ! Macklin (3) or Saunders and Hosseini 2001
17025 tmp = -0.5*(1.e+06)*xdia(mgs,lc,1) &
17026 & *( (1.0-rimdenvwgt)*vtxbar(mgs,lhl,1) + rimdenvwgt*vtxbar(mgs,lhl,2) ) &
17027 & /(temg(mgs)-273.15)
17028 ! tmp = Min( 5.5/0.6, Max( 0.3/0.6, tmp ) )
17029
17030 IF ( irimdenopt == 3 ) THEN
17031 rimdn(mgs,lhl) = min(900., max( 170., 110.*tmp**0.76 ) )
17032 ELSEIF ( irimdenopt == 4 ) THEN ! Saunders and Hosseini
17033 rimdn(mgs,lhl) = min(917., max( 10., 900.0*(1.0 - 0.905**tmp ) ) )
17034 ENDIF
17035
17036 ENDIF
17037 ELSE
17038 rimdn(mgs,lhl) = 1000.
17039 ENDIF
17040
17041 vhlacw(mgs) = rho0(mgs)*qhlacw(mgs)/rimdn(mgs,lhl)
17042
17043 ENDIF
17044
17045
17046 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. ipelec .ge. 1 ) THEN
17047 rarx(mgs,lhl) = &
17048 & qhlacw(mgs)*1.0e3*rho0(mgs)/((pi/2.0)*xdia(mgs,lhl,2)*cx(mgs,lhl))
17049 ENDIF
17050
17051 ENDIF
17052 end do
17053
17054 qhlaci(:) = 0.0
17055 qhlaci0(:) = 0.0
17056 IF ( lhl .gt. 1 ) THEN
17057 do mgs = 1,ngscnt
17058 IF ( ehli(mgs) .gt. 0.0 ) THEN
17059 IF ( ipconc .ge. 5 ) THEN
17060
17061 vt = sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,li,1))**2 + &
17062 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,li,1) )
17063
17064 qhlaci0(mgs) = 0.25*pi*ehliclsn(mgs)*cx(mgs,lhl)*qx(mgs,li)*vt* &
17065 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
17066 & dab1lh(mgs,lhl,li)*xdia(mgs,lhl,3)*xdia(mgs,li,3) + &
17067 & da1(li)*xdia(mgs,li,3)**2 )
17068 ! qhlaci(mgs) = Min( qhlaci(mgs), qimxd(mgs) )
17069 qhlaci(mgs) = min( ehli(mgs)*qhlaci0(mgs), qimxd(mgs) )
17070 ENDIF
17071 ENDIF
17072 end do
17073 ENDIF
17074!
17075 qhlacis(:) = 0.0
17076 qhlacis0(:) = 0.0
17077
17078 qhlacs(:) = 0.0
17079 qhlacs0(:) = 0.0
17080 IF ( lhl .gt. 1 ) THEN
17081 do mgs = 1,ngscnt
17082 IF ( ehls(mgs) .gt. 0.0) THEN
17083 IF ( ipconc .ge. 5 ) THEN
17084
17085 vt = sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,ls,1))**2 + &
17086 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,ls,1) )
17087
17088 qhlacs0(mgs) = 0.25*pi*ehlsclsn(mgs)*cx(mgs,lhl)*qx(mgs,ls)*vt* &
17089 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
17090 & dab1lh(mgs,lhl,ls)*xdia(mgs,lhl,3)*xdia(mgs,ls,3) + &
17091 & da1(ls)*xdia(mgs,ls,3)**2 )
17092
17093 qhlacs(mgs) = min( ehls(mgs)*qhlacs0(mgs), qsmxd(mgs) )
17094 ENDIF
17095 ENDIF
17096 end do
17097 ENDIF
17098
17099
17100 do mgs = 1,ngscnt
17101 qhlacr(mgs) = 0.0
17102 qhlacrmlr(mgs) = 0.0
17103 chlacr(mgs) = 0.0
17104 vhlacr(mgs) = 0.0
17105 IF ( lhl .gt. 1 .and. temg(mgs) .gt. tfr ) raindn(mgs,lhl) = 1000.0
17106
17107 IF ( lhl .gt. 1 .and. ehlr(mgs) .gt. 0.0 ) THEN
17108 IF ( ipconc .ge. 3 ) THEN
17109 vt = sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,lr,1))**2 + &
17110 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,lr,1) )
17111
17112 qhlacr(mgs) = 0.25*pi*ehlr(mgs)*cx(mgs,lhl)*qx(mgs,lr)*vt* &
17113 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
17114 & dab1lh(mgs,lhl,lr)*xdia(mgs,lhl,3)*xdia(mgs,lr,3) + &
17115 & da1lr(mgs)*xdia(mgs,lr,3)**2 )
17116! & da1(lr)*xdia(mgs,lr,3)**2 )
17117! IF ( qhacr(mgs) .gt. 0. .or. tmp .gt. 0.0 ) write(0,*) 'qhacr= ',qhacr(mgs),tmp
17118!! qhacr(mgs) = Min( qhacr(mgs), qrmxd(mgs) )
17119!! chacr(mgs) = qhacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
17120!! chacr(mgs) = min(chacr(mgs),crmxd(mgs))
17121
17122 qhlacr(mgs) = min( qhlacr(mgs), qxmxd(mgs,lr) )
17123
17124
17125 IF ( iqhlacrmlr >= 1 ) qhlacrmlr(mgs) = qhlacr(mgs)
17126
17127 IF ( temg(mgs) > tfr .and. iehlr0c == 0) THEN
17128 qhlacr(mgs) = 0.0
17129 IF ( iqhlacrmlr == 0 ) THEN
17130 qhlacrmlr(mgs) = -qhlacw(mgs)
17131 ENDIF
17132 ELSE
17133 chlacr(mgs) = 0.25*pi*ehlr(mgs)*cx(mgs,lhl)*cx(mgs,lr)*vt* &
17134 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
17135 & dab0lh(mgs,lhl,lr)*xdia(mgs,lhl,3)*xdia(mgs,lr,3) + &
17136 & da0lr(mgs)*xdia(mgs,lr,3)**2 )
17137
17138 chlacr(mgs) = min(chlacr(mgs),crmxd(mgs))
17139
17140 IF ( lvol(lhl) .gt. 1 ) THEN
17141 vhlacr(mgs) = rho0(mgs)*qhlacr(mgs)/raindn(mgs,lhl)
17142 ENDIF
17143 ENDIF
17144 ENDIF
17145 ENDIF
17146 end do
17147
17148
17149
17150!
17151!
17152!
17153!
17154! if (ndebug .gt. 0 ) write(0,*) 'Collection: Cloud collects xxxxx'
17155
17156 if (ndebug .gt. 0 ) write(0,*) 'Collection: cloud ice collects xxxx2'
17157!
17158 do mgs = 1,ngscnt
17159 qiacw(mgs) = 0.0
17160 IF ( eiw(mgs) .gt. 0.0 ) THEN
17161
17162 vt = sqrt((vtxbar(mgs,li,1)-vtxbar(mgs,lc,1))**2 + &
17163 & 0.04*vtxbar(mgs,li,1)*vtxbar(mgs,lc,1) )
17164
17165 qiacw(mgs) = 0.25*pi*eiw(mgs)*cx(mgs,li)*qx(mgs,lc)*vt* &
17166 & ( da0(li)*xdia(mgs,li,3)**2 + &
17167 & dab1(li,lc)*xdia(mgs,li,3)*xdia(mgs,lc,3) + &
17168 & da1lc(mgs)*xdia(mgs,lc,3)**2 )
17169
17170 qiacw(mgs) = min( qiacw(mgs), qxmxd(mgs,lc) )
17171 ENDIF
17172 end do
17173
17174
17175!
17176!
17177 if (ndebug .gt. 0 ) write(0,*) 'Collection: cloud ice collects xxxx8'
17178!
17179 do mgs = 1,ngscnt
17180 qiacr(mgs) = 0.0
17181 qiacrf(mgs) = 0.0
17182 qiacrs(mgs) = 0.0
17183 ciacrs(mgs) = 0.0
17184 ciacr(mgs) = 0.0
17185 ciacrf(mgs) = 0.0
17186 viacrf(mgs) = 0.0
17187 csplinter(mgs) = 0.0
17188 qsplinter(mgs) = 0.0
17189 csplinter2(mgs) = 0.0
17190 qsplinter2(mgs) = 0.0
17191 IF ( iacr .ge. 1 .and. eri(mgs) .gt. 0.0 &
17192 & .and. temg(mgs) .le. 270.15 ) THEN
17193 IF ( ipconc .ge. 3 ) THEN
17194 ni = 0.0
17195 IF ( xdia(mgs,li,1) .ge. 10.e-6 ) THEN
17196 ni = ni + cx(mgs,li)*exp(- (40.e-6/xdia(mgs,li,1))**3 )
17197 ENDIF
17198 IF ( imurain == 1 ) THEN ! gamma of diameter
17199 IF ( iacrsize /= 4 ) THEN
17200 IF ( iacrsize .eq. 1 ) THEN
17201 ratio = 500.e-6/xdia(mgs,lr,1)
17202 ELSEIF ( iacrsize .eq. 2 ) THEN
17203 ratio = 300.e-6/xdia(mgs,lr,1)
17204 ELSEIF ( iacrsize .eq. 3 ) THEN
17205 ratio = 40.e-6/xdia(mgs,lr,1)
17206 ELSEIF ( iacrsize .eq. 5 ) THEN
17207 ratio = 150.e-6/xdia(mgs,lr,1)
17208 ENDIF
17209 i = min(nqiacrratio,int(ratio*dqiacrratioinv))
17210 j = int(max(0.0,min(15.,alpha(mgs,lr)))*dqiacralphainv)
17211! j = Int(Max(minalphalu,Min(maxalphalu,alpha(mgs,lr)))*dqiacralphainv)
17212 delx = ratio - float(i)*dqiacrratio
17213 dely = alpha(mgs,lr) - float(j)*dqiacralpha
17214 ip1 = min( i+1, nqiacrratio )
17215 jp1 = min( j+1, nqiacralpha )
17216
17217 ! interpolate along x, i.e., ratio
17218 tmp1 = ciacrratio(i,j) + delx*dqiacrratioinv*(ciacrratio(ip1,j) - ciacrratio(i,j))
17219 tmp2 = ciacrratio(i,jp1) + delx*dqiacrratioinv*(ciacrratio(ip1,jp1) - ciacrratio(i,jp1))
17220
17221 ! interpolate along alpha
17222
17223 nr = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*cx(mgs,lr)
17224
17225 ! interpolate along x, i.e., ratio;
17226 tmp1 = qiacrratio(i,j) + delx*dqiacrratioinv*(qiacrratio(ip1,j) - qiacrratio(i,j))
17227 tmp2 = qiacrratio(i,jp1) + delx*dqiacrratioinv*(qiacrratio(ip1,jp1) - qiacrratio(i,jp1))
17228
17229 ! interpolate along alpha;
17230
17231 qr = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*qx(mgs,lr)
17232
17233 ELSE ! iacrsize == 4 : use all
17234 nr = cx(mgs,lr)
17235 qr = qx(mgs,lr)
17236 ENDIF
17237
17238 vt = sqrt((vtxbar(mgs,lr,1)-vtxbar(mgs,li,1))**2 + &
17239 & 0.04*vtxbar(mgs,lr,1)*vtxbar(mgs,li,1) )
17240
17241 qiacr(mgs) = 0.25*pi*eri(mgs)*ni*qr*vt* &
17242 & ( da0(li)*xdia(mgs,li,3)**2 + &
17243 & dab1lh(mgs,li,lr)*xdia(mgs,lh,3)*xdia(mgs,li,3) + &
17244 & da1(lr)*xdia(mgs,lr,3)**2 )
17245
17246 qiacr(mgs) = min( qrmxd(mgs), qiacr(mgs) )
17247
17248
17249 ciacr(mgs) = 0.25*pi*eri(mgs)*ni*nr*vt* &
17250 & ( da0(li)*xdia(mgs,li,3)**2 + &
17251 & dab0lh(mgs,li,lr)*xdia(mgs,lr,3)*xdia(mgs,li,3) + &
17252 & da0(lr)*xdia(mgs,lr,3)**2 )
17253
17254 ciacr(mgs) = min( crmxd(mgs), ciacr(mgs) )
17255
17256! write(iunit,*) 'qiacr: ',cx(mgs,lr),nr,qx(mgs,lr),qr,qiacr(mgs),ciacr(mgs)
17257! write(iunit,*) 'xdia r li = ',xdia(mgs,lr,3),xdia(mgs,li,3),xdia(mgs,lr,1),xdia(mgs,li,1)
17258! write(iunit,*) 'i,j,ratio = ',i,j,ciacrratio(i,j),qiacrratio(i,j)
17259! write(iunit,*) 'ni,ci = ',ni,cx(mgs,li),qx(mgs,li)
17260
17261 ELSEIF ( imurain == 3 ) THEN ! gamma of volume
17262! Set nr to the number of drops greater than 40 microns.
17263 arg = 1000.*xdia(mgs,lr,3)
17264! nr = cx(mgs,lr)*gaml02( arg )
17265! IF ( iacr .eq. 1 ) THEN
17266 IF ( ipconc .ge. 3 ) THEN
17267 IF ( iacrsize .eq. 1 ) THEN
17268 nr = cx(mgs,lr)*gaml02d500( arg ) ! number greater than 500 microns in diameter
17269 ELSEIF ( iacrsize .eq. 2 .or. iacrsize .eq. 5 ) THEN
17270 nr = cx(mgs,lr)*gaml02d300( arg ) ! number greater than 300 microns in diameter
17271 ELSEIF ( iacrsize .eq. 3 ) THEN
17272 nr = cx(mgs,lr)*gaml02( arg ) ! number greater than 40 microns in diameter
17273 ELSEIF ( iacrsize .eq. 4 ) THEN
17274 nr = cx(mgs,lr) ! all raindrops
17275 ENDIF
17276 ELSE
17277 nr = cx(mgs,lr)*gaml02( arg )
17278 ENDIF
17279! ELSEIF ( iacr .eq. 2 ) THEN
17280! nr = cx(mgs,lr)*gaml02d300( arg ) ! number greater than 300 microns in diameter
17281! ENDIF
17282 IF ( ni .gt. 0.0 .and. nr .gt. 0.0 ) THEN
17283 d0 = xdia(mgs,lr,3)
17284 qiacr(mgs) = xdn(mgs,lr)*rhoinv(mgs)* &
17285 & (0.217239*(0.522295*(d0**5) + &
17286 & 49711.81*(d0**6) - &
17287 & 1.673016e7*(d0**7)+ &
17288 & 2.404471e9*(d0**8) - &
17289 & 1.22872e11*(d0**9))*ni*nr)
17290 qiacr(mgs) = min( qrmxd(mgs), qiacr(mgs) )
17291 ciacr(mgs) = &
17292 & (0.217239*(0.2301947*(d0**2) + &
17293 & 15823.76*(d0**3) - &
17294 & 4.167685e6*(d0**4) + &
17295 & 4.920215e8*(d0**5) - &
17296 & 2.133344e10*(d0**6))*ni*nr)
17297 ciacr(mgs) = min( crmxd(mgs), ciacr(mgs) )
17298! ciacr(mgs) = qiacr(mgs)*cx(mgs,lr)/qx(mgs,lr)
17299 ENDIF
17300 ENDIF
17301 IF ( iacr .eq. 1 .or. iacr .eq. 3 ) THEN
17302 ciacrf(mgs) = min(ciacr(mgs), qiacr(mgs)/(1.0*vr1mm*1000.0)*rho0(mgs) ) ! *rzxh(mgs)
17303 ELSEIF ( iacr .eq. 2 ) THEN
17304 ciacrf(mgs) = ciacr(mgs) ! *rzxh(mgs)
17305 ELSEIF ( iacr .eq. 4 ) THEN
17306 ciacrf(mgs) = min(ciacr(mgs), qiacr(mgs)/(1.0*vfrz*1000.0)*rho0(mgs) ) ! *rzxh(mgs)
17307 ELSEIF ( iacr .eq. 5 ) THEN
17308 ciacrf(mgs) = ciacr(mgs)*rzxh(mgs)
17309 ENDIF
17310! crfrzf(mgs) = Min(crfrz(mgs), qrfrz(mgs)/(bfnu*27.0*vr1mm*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
17311 ENDIF
17312
17313
17314 ELSE ! single-moment rain
17315 qiacr(mgs) = &
17316 & min( &
17317 & ((0.25/gf4)*pi)*eri(mgs)*cx(mgs,li)*qx(mgs,lr) &
17318 & *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,li,1)) &
17319 & *( gf6*gf1*xdia(mgs,lr,2) &
17320 & + 2.0*gf5*gf2*xdia(mgs,lr,1)*xdia(mgs,li,1) &
17321 & + gf4*gf3*xdia(mgs,li,2) ) &
17322 & , qrmxd(mgs))
17323 ENDIF
17324! if ( temg(mgs) .gt. 268.15 ) then
17325! qiacr(mgs) = 0.0
17326! ciacr(mgs) = 0.0
17327! end if
17328
17329 IF ( ipconc .ge. 1 ) THEN
17330 IF ( nsplinter .ge. 1000 ) THEN
17331 ! Lawson et al. 2015 JAS
17332 ! ave. diam of freezing drops in microns
17333 IF ( qiacr(mgs)*dtp > qxmin(lh) .and. ciacr(mgs) > 1.e-3 ) THEN
17334 tmpdiam = 1.e6*( 6.*qiacr(mgs)/(1000.*pi*ciacr(mgs) ) )**(1./3.) ! avg. diameter of newly frozen drops in microns
17335 fac = 1.0
17336 IF ( nsplinter .eq. 1001 ) THEN
17337 ! fac = 0.2/sqrt(2.0*pi*10.**2)*Exp(-0.5*((258.-temg(mgs))/10.)**2 ) ! temperature dependence from Sullivan et al. 2018 ACP
17338 ! ELSE
17339 fac = 0.2*exp(-0.5*((258.-temg(mgs))/10.)**2 ) ! temperature dependence from Sullivan et al. 2018 ACP
17340 ENDIF
17341 csplinter(mgs) = fac*lawson_splinter_fac*tmpdiam**4*ciacr(mgs)
17342 ENDIF
17343 ELSEIF ( nsplinter .ge. 0 ) THEN
17344 csplinter(mgs) = nsplinter*ciacr(mgs)
17345 ELSE
17346 csplinter(mgs) = -nsplinter*ciacrf(mgs)
17347 ENDIF
17348 qsplinter(mgs) = min(0.1*qiacr(mgs), csplinter(mgs)*splintermass/rho0(mgs) ) ! makes splinters smaller if too much mass is taken from graupel
17349 ENDIF
17350
17351 frach = 1.0
17352 IF ( ibiggsnow == 2 .or. ibiggsnow == 3 ) THEN
17353 IF ( ciacr(mgs) > qxmin(lh) ) THEN
17354 xvfrz = rho0(mgs)*qiacr(mgs)/(ciacr(mgs)*900.) ! mean volume of frozen drops; 900. for frozen drop density
17355 frach = 0.5 *(1. + tanh(0.2e12 *( xvfrz - 1.15*xvbiggsnow)))
17356
17357 qiacrs(mgs) = (1.-frach)*qiacr(mgs)
17358 ciacrs(mgs) = (1.-frach)*ciacrf(mgs) ! *rzxh(mgs)
17359
17360 ENDIF
17361 ENDIF
17362
17363 qiacrf(mgs) = frach*qiacr(mgs)
17364 ciacrf(mgs) = frach*ciacrf(mgs)
17365
17366 IF ( lvol(lh) > 1 ) THEN
17367 viacrf(mgs) = rho0(mgs)*qiacrf(mgs)/rhofrz
17368 ENDIF
17369
17370 end do
17371!
17372!
17373!
17374!
17375
17376! snow aggregation here
17377 if ( ipconc .ge. 4 ) then !
17378 do mgs = 1,ngscnt
17379 csacs(mgs) = 0.0
17380 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
17381
17382 IF ( iessec0flag == 0 ) THEN
17383 ec0(mgs) = 1.0
17384 ELSE
17385 tmp = xv(mgs,ls)/(xvmx(ls)*max(1.,100./min(100.,xdn(mgs,ls)))) ! fraction of max snow mass
17386 IF ( tmp .lt. essfrac1 ) THEN
17387 ec0(mgs) = 1.0
17388 ELSEIF ( tmp .ge. essfrac2 ) THEN
17389 ec0(mgs) = 0.0
17390 ELSE
17391 ec0(mgs) = (essfrac2 - tmp)/(essfrac2 - essfrac1)
17392 ENDIF
17393 ENDIF
17394
17395 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
17396! 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
17397 csacs(mgs) = min(csacs(mgs),csmxd(mgs))
17398 ENDIF
17399 end do
17400 end if
17401!
17402!
17403 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 11'
17404 if ( ipconc .ge. 2 .or. ipelec .ge. 9 ) then
17405 do mgs = 1,ngscnt
17406 ciacw(mgs) = 0.0
17407 IF ( eiw(mgs) .gt. 0.0 .and. xmas(mgs,lc) > 0.0 ) THEN
17408 ciacw(mgs) = qiacw(mgs)*rho0(mgs)/xmas(mgs,lc)
17409 ciacw(mgs) = min(ciacw(mgs),ccmxd(mgs))
17410 ENDIF
17411 end do
17412
17413 end if
17414
17415 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 18'
17416 if ( ipconc .ge. 2 .or. ipelec .ge. 1 ) then
17417 do mgs = 1,ngscnt
17418 tmp1 = 0.0
17419 cracw(mgs) = 0.0
17420 cracr(mgs) = 0.0
17421 ec0(mgs) = 1.e9
17422 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. qx(mgs,lr) .gt. qxmin(lr) &
17423 & .and. qracw(mgs) .gt. 0.0 ) THEN
17424
17425 IF ( ipconc .lt. 3 ) THEN
17426 IF ( erw(mgs) .gt. 0.0 ) THEN
17427 cracw(mgs) = &
17428 & ((0.25)*pi)*erw(mgs)*(cx(mgs,lc) - ccwresv(mgs))*cx(mgs,lr) &
17429 & *abs(vtxbar(mgs,lr,1)-vtxbar(mgs,lc,1)) &
17430 & *( gf1*xdia(mgs,lc,2) &
17431 & + 2.0*gf2*xdia(mgs,lc,1)*xdia(mgs,lr,1) &
17432 & + gf3*xdia(mgs,lr,2) )
17433 ENDIF
17434 ELSE ! IF ( ipconc .ge. 3 .and. )
17435 IF ( dmrauto <= 0 .or. rho0(mgs)*qx(mgs,lr) > 1.2*xl2p(mgs) ) THEN !{
17436 IF ( 0.5*xdia(mgs,lr,3) .gt. rh(mgs) ) THEN ! { .or. cx(mgs,lr) .gt. nh(mgs)
17437! IF ( qx(mgs,lc) .gt. qxmin(lc) .and. qx(mgs,lr) .gt. qxmin(lr) ) THEN
17438 IF ( 0.5*xdia(mgs,lr,3) .gt. rwradmn ) THEN ! r > 50.e-6
17439! DM0CCC=A2*XNC*XNR*(XVC+XVR) ! (A11)
17440! NOTE: murain drops out, so same result for imurain = 1 and 3
17441 cracw(mgs) = aa2*cx(mgs,lr)*(cx(mgs,lc) - ccwresv(mgs))*(xv(mgs,lc) + xv(mgs,lr))
17442 ELSE
17443 IF ( imurain == 3 ) THEN
17444! DM0CCC=A1*XNC*XNR*(((CNU+2.)/(CNU+1.))*XVC**2+((RNU+2.)/(RNU+1.))*XVR**2) ! (A13)
17445 cracw(mgs) = aa1*cx(mgs,lr)*(cx(mgs,lc) - ccwresv(mgs))* &
17446 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.) + &
17447 & (alpha(mgs,lr) + 2.)*xv(mgs,lr)**2/(alpha(mgs,lr) + 1.))
17448 ELSE ! imurain == 1 USE CP00 for rain DSD in diameter
17449 cracw(mgs) = aa1*cx(mgs,lr)*(cx(mgs,lc) - ccwresv(mgs))* &
17450 & ((alpha(mgs,lc) + 2.)*xv(mgs,lc)**2/(alpha(mgs,lc) + 1.) + &
17451 & (alpha(mgs,lr) + 6.)*(alpha(mgs,lr) + 5.)*(alpha(mgs,lr) + 4.)*xv(mgs,lr)**2/ &
17452 & ((alpha(mgs,lr) + 3.)*(alpha(mgs,lr) + 2.)*(alpha(mgs,lr) + 1.)) )
17453 ENDIF ! imurain
17454 ENDIF
17455 ENDIF ! } rh
17456 ENDIF ! } dmrauto
17457 ENDIF ! ipconc
17458 ENDIF ! qc > qcmin & qr > qrmin
17459
17460! Rain self collection (cracr) and break-up (factor of ec0)
17461!
17462!
17463 ec0(mgs) = 1.0 ! 2.e9
17464 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
17465 rwrad = 0.5*xdia(mgs,lr,3)
17466
17467
17468 ! check median volume diameter
17469 IF ( icracrthresh > 1 ) THEN
17470 IF ( imurain == 1 ) THEN
17471 tmp = (3.67+alpha(mgs,lr))*xdia(mgs,lr,1) ! median volume diameter; units of mm (Ulbrich 1983, JCAM)
17472 ELSE ! imurain == 3,
17473 tmp = (1.678+alpha(mgs,lr))**(1./3.)*xdia(mgs,lr,1) ! units of mm (using method of Ulbrich 1983. See ventillation_stuff.nb)
17474 ENDIF
17475 ELSE
17476 tmp = xdia(mgs,lr,3) - 0.1e-3
17477 ENDIF
17478
17479! Using collection efficiency factor ec0 to simulate break-up that off-sets self-collection (Zieger 1985; Cohard & Pinty 2000)
17480! ec0 is 1 for rain diameter < 600 microns and then drop off toward zero until diameter of 2mm to represent passive breakup
17481! ec0 does not go negative here (i.e., does not follow other versions that create extra breakup at large rain diameter)
17482 IF ( ( tmp .gt. 1.9e-3 .and. irainbreak /= 10 .and. irainbreak /= 20 ) .or. icracr <= 0 ) THEN
17483 ec0(mgs) = 0.0
17484 cracr(mgs) = 0.0
17485 IF ( ibincracr == 3 ) THEN
17486 tmp1 = aa1*(cx(mgs,lr)*xv(mgs,lr))**2* &
17487 & (alpha(mgs,lr) + 6.)*(alpha(mgs,lr) + 5.)*(alpha(mgs,lr) + 4.)/ &
17488 & ((alpha(mgs,lr) + 3.)*(alpha(mgs,lr) + 2.)*(alpha(mgs,lr) + 1.))
17489 ENDIF
17490 ELSE
17491 IF ( dmrauto <= 0 .or. rho0(mgs)*qx(mgs,lr) > 1.2*xl2p(mgs) ) THEN
17492
17493 IF ( xdia(mgs,lr,3) .lt. 6.1e-4 .or. irainbreak == 10 ) THEN
17494 ec0(mgs) = 1.0
17495 ELSE
17496 ec0(mgs) = exp( -2500.0*(xdia(mgs,lr,3) - 6.0e-4) )
17497 ENDIF
17498
17499
17500
17501 IF ( rwrad .ge. 50.e-6 ) THEN
17502 tmp1 = aa2*cx(mgs,lr)**2*xv(mgs,lr)
17503 cracr(mgs) = ec0(mgs)*tmp1
17504 IF ( irainbreak == 20 ) THEN
17505 cracr(mgs) = tmp1
17506 ENDIF
17507 ELSE
17508 IF ( imurain == 3 ) THEN
17509 cracr(mgs) = ec0(mgs)*aa1*(cx(mgs,lr)*xv(mgs,lr))**2* &
17510 & (alpha(mgs,lr) + 2.)/(alpha(mgs,lr) + 1.)
17511 ELSE ! imurain == 1
17512 tmp1 = aa1*(cx(mgs,lr)*xv(mgs,lr))**2* &
17513 & (alpha(mgs,lr) + 6.)*(alpha(mgs,lr) + 5.)*(alpha(mgs,lr) + 4.)/ &
17514 & ((alpha(mgs,lr) + 3.)*(alpha(mgs,lr) + 2.)*(alpha(mgs,lr) + 1.))
17515 cracr(mgs) = ec0(mgs)*tmp1
17516 IF ( irainbreak == 20 ) THEN
17517 cracr(mgs) = tmp1
17518 ENDIF
17519 ENDIF
17520 ENDIF ! rwrad > 50
17521! cracr(mgs) = Min(cracr(mgs),crmxd(mgs))
17522 ENDIF ! dmrauto <= 0
17523 ENDIF ! tmp > 1.9e-3
17524
17525 IF ( irainbreak == 100 ) THEN ! Morrison breakup
17526 ec0(mgs) = 1.0
17527 IF ( xdia(mgs,lr,1) > 300.e-6 ) THEN
17528 ec0(mgs) = 2. - exp(2300.*(xdia(mgs,lr,1)-300.e-6))
17529 ENDIF
17530 cracr(mgs) = 5.78*ec0(mgs)*cx(mgs,lr)*qx(mgs,lr)
17531 ENDIF
17532
17533 ENDIF ! ( qx(mgs,lr) .gt. qxmin(lr) )
17534
17535 ! active breakup option
17536 crbreak = 0.0
17537 IF ( irainbreak == 1 .or. irainbreak == 10 ) THEN
17538 crbreak = max( 0.0, rainbreakfac* (rho0(mgs)*qx(mgs,lr))**2 ) ! hand fit to lower range of wkqss output
17539 cracr(mgs) = cracr(mgs) - crbreak ! cracr is subtracted, so negative value for breakup
17540 ELSEIF ( irainbreak == 2 .or. irainbreak == 20 ) THEN
17541 ! irainbreak == 20 does not work as intended
17542 crbreak = max( 0.0, rainbreakfac*(1. - ec0(mgs))*(rho0(mgs)*qx(mgs,lr))**2 ) ! hand fit to lower range of wkqss output
17543! crbreak = Max(0.0, -0.18 + 1.139e6 * (rho0(mgs)*qx(mgs,lr) + 0.00038106)**2)
17544 cracr(mgs) = cracr(mgs) - crbreak ! cracr is subtracted, so negative value for breakup
17545 ELSEIF ( irainbreak == 11 .and. rho0(mgs)*qx(mgs,lr) > qrbrthresh1 .and. ipconc >= 5 ) THEN
17546
17547 ! Ad hoc method to break up drops in the DSD tail (D > draintail)
17548
17549 ratio = min( maxratiolu, draintail/xdia(mgs,lr,1) )
17550 ! mass
17551 tmp2 = gaminterp(ratio,alpha(mgs,lr),4,1)
17552 qxd1 = qx(mgs,lr)*(tmp2)
17553 qrbreak = dtpinv*qxd1
17554
17555 crbreaksmall = rho0(mgs)*qrbreak/(xdn(mgs,lr)*pi/6.*drsmall**3)
17556 IF ( ( qxd1 > qxmin(lr)) ) THEN
17557
17558 ! number
17559 tmp = gaminterp(ratio,alpha(mgs,lr),1,1)
17560 IF ( ipconc == 5 ) THEN
17561 ! tmp = Min( 0.2, tmp )
17562 ENDIF
17563 cxd1 = cx(mgs,lr)*( tmp)
17564 IF ( rho0(mgs)*qx(mgs,lr) > qrbrthresh2 ) THEN
17565 flim = 1.0
17566 ELSE
17567 flim = (rho0(mgs)*qx(mgs,lr) - qrbrthresh1)/(qrbrthresh2 - qrbrthresh1)
17568 ENDIF
17569 crbreak = flim*(crbreaksmall - dtpinv*cxd1)
17570
17571! IF ( kgs(mgs) == 1 .and. qx(mgs,lr) > 0.1e-3 ) THEN
17572! write(0,*) 'crbreak: ',crbreak,crbreaksmall,dtpinv*cxd1,cx(mgs,lr),cracr(mgs) - crbreak
17573! ENDIF
17574 cracr(mgs) = cracr(mgs) - crbreak ! cracr is subtracted, so negative value for breakup
17575
17576 ! reflectivity -- not used yet: goes into zracr
17577! IF ( ipconc >= 6 .and. lzr > 1 ) THEN
17578! tmp3 = gaminterp(ratio,alpha(mgs,lr),11,1)
17579! zxd1 = zx(mgs,lr)*(tmp3)
17580! zrbreak = dtpinv*zxd1
17581! ELSE
17582! zxd1 = 0
17583! ENDIF
17584! zrbreak = Max(0.0, zrbreak - crbreaksmall*drsmall**6)
17585 ELSEIF ( irainbreak == 12 ) THEN
17586 crbreak = max( 0.0, 3.8098 * (rho0(mgs)*qx(mgs,lr))**1.9416 ) ! best fit to lower range of wkqss (collision only) output
17587 cracr(mgs) = cracr(mgs) - crbreak ! cracr is subtracted, so negative value for breakup
17588 ENDIF
17589 ENDIF
17590
17591! cracw(mgs) = min(cracw(mgs),cxmxd(mgs,lc))
17592
17593 end do
17594 end if
17595
17596!
17597!
17598!
17599! Graupel
17600!
17601 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22ii'
17602 chacw(:) = 0.0
17603 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17604 do mgs = 1,ngscnt
17605
17606 IF ( ipconc .ge. 5 ) THEN
17607 IF ( qhacw(mgs) .gt. 0.0 .and. xmas(mgs,lc) .gt. 0.0 ) THEN
17608
17609! This is the explict version of chacw, which turns out to be very close to the
17610! approximation that the droplet size does not change, to within a few percent.
17611! This may _not_ be the case for cnu other than zero!
17612! chacw(mgs) = (ehw(mgs)*cx(mgs,lc)*cx(mgs,lh)*(pi/4.)*
17613! : abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1))*
17614! : (2.0*xdia(mgs,lh,1)*(xdia(mgs,lh,1) +
17615! : xdia(mgs,lc,1)*gf43rds) +
17616! : xdia(mgs,lc,2)*gf53rds))
17617
17618! chacw(mgs) = Min( chacw(mgs), 0.6*cx(mgs,lc)*dtpinv )
17619
17620! chacw(mgs) = qhacw(mgs)*rho0(mgs)/xmas(mgs,lc)
17621 chacw(mgs) = qhacw(mgs)*rho0(mgs)/xmascw(mgs)
17622! chacw(mgs) = min(chacw(mgs),cxmxd(mgs,lc))
17623 chacw(mgs) = min( chacw(mgs), 0.5*(cx(mgs,lc) - ccwresv(mgs))*dtpinv )
17624 ELSE
17625 qhacw(mgs) = 0.0
17626 ENDIF
17627 ELSE
17628 ! single-moment
17629 chacw(mgs) = &
17630 & ((0.25)*pi)*ehw(mgs)*cx(mgs,lc)*cx(mgs,lh) &
17631 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1)) &
17632 & *( gf1*xdia(mgs,lc,2) &
17633 & + 2.0*gf2*xdia(mgs,lc,1)*xdia(mgs,lh,1) &
17634 & + gf3*xdia(mgs,lh,2) )
17635 chacw(mgs) = min(chacw(mgs),0.5*cx(mgs,lc)*dtpinv)
17636! chacw(mgs) = min(chacw(mgs),cxmxd(mgs,lc))
17637! chacw(mgs) = min(chacw(mgs),ccmxd(mgs))
17638 ENDIF
17639 end do
17640 end if
17641!
17642 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22kk'
17643 chaci(:) = 0.0
17644 chaci0(:) = 0.0
17645 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17646 do mgs = 1,ngscnt
17647 IF ( ehi(mgs) .gt. 0.0 .or. ( ehiclsn(mgs) > 0.0 .and. ipelec > 0 )) THEN
17648 IF ( ipconc .ge. 5 ) THEN
17649
17650 vt = sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,li,1))**2 + &
17651 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,li,1) )
17652
17653 chaci0(mgs) = 0.25*pi*ehiclsn(mgs)*cx(mgs,lh)*cx(mgs,li)*vt* &
17654 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
17655 & dab0lh(mgs,lh,li)*xdia(mgs,lh,3)*xdia(mgs,li,3) + &
17656 & da0(li)*xdia(mgs,li,3)**2 )
17657
17658 ELSE
17659 chaci0(mgs) = &
17660 & ((0.25)*pi)*ehiclsn(mgs)*cx(mgs,li)*cx(mgs,lh) &
17661 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,li,1)) &
17662 & *( gf1*xdia(mgs,li,2) &
17663 & + 2.0*gf2*xdia(mgs,li,1)*xdia(mgs,lh,1) &
17664 & + gf3*xdia(mgs,lh,2) )
17665 ENDIF
17666
17667 chaci(mgs) = min(ehi(mgs)*chaci0(mgs),cimxd(mgs))
17668 ENDIF
17669 end do
17670 end if
17671
17672
17673!
17674!
17675 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22nn'
17676 chacs(:) = 0.0
17677 chacs0(:) = 0.0
17678 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17679 do mgs = 1,ngscnt
17680 IF ( ehs(mgs) .gt. 0 ) THEN
17681 IF ( ipconc .ge. 5 .or. ( ehsclsn(mgs) > 0.0 .and. ipelec > 0 ) ) THEN
17682
17683 vt = sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1))**2 + &
17684 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,ls,1) )
17685
17686 chacs0(mgs) = 0.25*pi*ehsclsn(mgs)*cx(mgs,lh)*cx(mgs,ls)*vt* &
17687 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
17688 & dab0lh(mgs,lh,ls)*xdia(mgs,lh,3)*xdia(mgs,ls,3) + &
17689 & da0(ls)*xdia(mgs,ls,3)**2 )
17690
17691 ELSE
17692 chacs0(mgs) = &
17693 & ((0.25)*pi)*ehsclsn(mgs)*cx(mgs,ls)*cx(mgs,lh) &
17694 & *abs(vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1)) &
17695 & *( gf3*gf1*xdia(mgs,ls,2) &
17696 & + 2.0*gf2*gf2*xdia(mgs,ls,1)*xdia(mgs,lh,1) &
17697 & + gf1*gf3*xdia(mgs,lh,2) )
17698 ENDIF
17699 chacs(mgs) = min(ehs(mgs)*chacs0(mgs),csmxd(mgs))
17700 ENDIF
17701 end do
17702 end if
17703
17704
17705!
17706!
17707! Hail
17708!
17709 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22ii'
17710 chlacw(:) = 0.0
17711 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17712 do mgs = 1,ngscnt
17713
17714 IF ( lhl .gt. 1 .and. ipconc .ge. 5 ) THEN
17715 IF ( qhlacw(mgs) .gt. 0.0 .and. xmas(mgs,lc) .gt. 0.0 ) THEN
17716
17717! This is the explict version of chacw, which turns out to be very close to the
17718! approximation that the droplet size does not change, to within a few percent.
17719! This may _not_ be the case for cnu other than zero!
17720! chlacw(mgs) = (ehlw(mgs)*cx(mgs,lc)*cx(mgs,lhl)*(pi/4.)*
17721! : abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,lc,1))*
17722! : (2.0*xdia(mgs,lhl,1)*(xdia(mgs,lhl,1) +
17723! : xdia(mgs,lc,1)*gf43rds) +
17724! : xdia(mgs,lc,2)*gf53rds))
17725
17726! chlacw(mgs) = Min( chlacw(mgs), 0.6*cx(mgs,lc)*dtpinv )
17727
17728! chlacw(mgs) = qhlacw(mgs)*rho0(mgs)/xmas(mgs,lc)
17729 chlacw(mgs) = qhlacw(mgs)*rho0(mgs)/xmascw(mgs)
17730! chlacw(mgs) = min(chlacw(mgs),cxmxd(mgs,lc))
17731 chlacw(mgs) = min( chlacw(mgs), 0.5*cx(mgs,lc)*dtpinv )
17732 ELSE
17733 qhlacw(mgs) = 0.0
17734 ENDIF
17735! ELSE
17736! chlacw(mgs) =
17737! > ((0.25)*pi)*ehlw(mgs)*cx(mgs,lc)*cx(mgs,lhl)
17738! > *abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,lc,1))
17739! > *( gf1*xdia(mgs,lc,2)
17740! > + 2.0*gf2*xdia(mgs,lc,1)*xdia(mgs,lhl,1)
17741! > + gf3*xdia(mgs,lhl,2) )
17742! chlacw(mgs) = min(chlacw(mgs),0.5*cx(mgs,lc)*dtpinv)
17743! chlacw(mgs) = min(chlacw(mgs),cxmxd(mgs,lc))
17744! chlacw(mgs) = min(chlacw(mgs),ccmxd(mgs))
17745 ENDIF
17746 end do
17747 end if
17748!
17749 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22kk'
17750 chlaci(:) = 0.0
17751 chlaci0(:) = 0.0
17752 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17753 do mgs = 1,ngscnt
17754 IF ( lhl .gt. 1 .and. ( ehli(mgs) .gt. 0.0 .or. (ipelec > 0 .and. ehliclsn(mgs) > 0.0) ) ) THEN
17755 IF ( ipconc .ge. 5 ) THEN
17756
17757 vt = sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,li,1))**2 + &
17758 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,li,1) )
17759
17760 chlaci0(mgs) = 0.25*pi*ehliclsn(mgs)*cx(mgs,lhl)*cx(mgs,li)*vt* &
17761 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
17762 & dab0(lhl,li)*xdia(mgs,lhl,3)*xdia(mgs,li,3) + &
17763 & da0(li)*xdia(mgs,li,3)**2 )
17764
17765! ELSE
17766! chlaci(mgs) =
17767! > ((0.25)*pi)*ehli(mgs)*cx(mgs,li)*cx(mgs,lhl)
17768! > *abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,li,1))
17769! > *( gf1*xdia(mgs,li,2)
17770! > + 2.0*gf2*xdia(mgs,li,1)*xdia(mgs,lhl,1)
17771! > + gf3*xdia(mgs,lhl,2) )
17772 ENDIF
17773
17774 chlaci(mgs) = min(ehli(mgs)*chlaci0(mgs),cimxd(mgs))
17775 ENDIF
17776 end do
17777 end if
17778
17779
17780!
17781!
17782 if (ndebug .gt. 0 ) write(0,*) 'ICEZVD_GS: conc 22jj'
17783 chlacs(:) = 0.0
17784 chlacs0(:) = 0.0
17785 if ( ipconc .ge. 1 .or. ipelec .ge. 1 ) then
17786 do mgs = 1,ngscnt
17787 IF ( lhl .gt. 1 .and. ( ehls(mgs) .gt. 0.0 .or. (ipelec > 0 .and. ehlsclsn(mgs) > 0.0) ) ) THEN
17788 IF ( ipconc .ge. 5 ) THEN
17789
17790 vt = sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,ls,1))**2 + &
17791 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,ls,1) )
17792
17793 chlacs0(mgs) = 0.25*pi*ehlsclsn(mgs)*cx(mgs,lhl)*cx(mgs,ls)*vt* &
17794 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
17795 & dab0(lhl,ls)*xdia(mgs,lhl,3)*xdia(mgs,ls,3) + &
17796 & da0(ls)*xdia(mgs,ls,3)**2 )
17797
17798! ELSE
17799! chlacs(mgs) =
17800! > ((0.25)*pi)*ehls(mgs)*cx(mgs,ls)*cx(mgs,lhl)
17801! > *abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,ls,1))
17802! > *( gf3*gf1*xdia(mgs,ls,2)
17803! > + 2.0*gf2*gf2*xdia(mgs,ls,1)*xdia(mgs,lhl,1)
17804! > + gf1*gf3*xdia(mgs,lhl,2) )
17805 ENDIF
17806 chlacs(mgs) = min(ehls(mgs)*chlacs0(mgs),csmxd(mgs))
17807 ENDIF
17808 end do
17809 end if
17810
17811!
17812! Ziegler (1985) autoconversion
17813!
17814!
17815 IF ( ipconc .ge. 2 ) THEN
17816 if (ndebug .gt. 0 ) write(0,*) 'conc 26a'
17817
17818 DO mgs = 1,ngscnt
17819 zrcnw(mgs) = 0.0
17820 qrcnw(mgs) = 0.0
17821 crcnw(mgs) = 0.0
17822 cautn(mgs) = 0.0
17823 ENDDO
17824
17825 IF ( dmrauto >= -1 ) THEN !{
17826 DO mgs = 1,ngscnt
17827! qracw(mgs) = 0.0
17828! cracw(mgs) = 0.0
17829 IF ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. 1000. .and. temg(mgs) .gt. tfrh+4.) THEN
17830 !( .and. w(igs(mgs),jgs,kgs(mgs)) > 5.0) THEN ! DTD: added w threshold for testing
17831 volb = xv(mgs,lc)*(1./(1.+alpha(mgs,lc)))**(1./2.)
17832 cautn(mgs) = min(ccmxd(mgs), &
17833 & ((alpha(mgs,lc)+2.)/(alpha(mgs,lc)+1.))*aa1*cx(mgs,lc)**2*xv(mgs,lc)**2)
17834 cautn(mgs) = max( 0.0d0, cautn(mgs) )
17835 IF ( rb(mgs) .le. 7.51d-6 .or. dmrauto == -1) THEN
17836 t2s = 1.d30
17837! cautn(mgs) = 0.0
17838 ELSE
17839! XL2P=2.7E-2*XNC*XVC*((1.E12*RB**3*RC)-0.4)
17840
17841! T2S=3.72E-3/(((1.E4*RB)-7.5)*XNC*XVC)
17842! t2s = 3.72E-3/(((1.e6*rb)-7.5)*cx(mgs,lc)*xv(mgs,lc))
17843! t2s = 3.72/(((1.e6*rb(mgs))-7.5)*rho0(mgs)*qx(mgs,lc))
17844 t2s = 3.72/(1.e6*(rb(mgs)-7.500d-6)*rho0(mgs)*qx(mgs,lc))
17845
17846 qrcnw(mgs) = max( 0.0d0, xl2p(mgs)/(t2s*rho0(mgs)) )
17847 crcnw(mgs) = max( 0.0d0, min(3.5e9*xl2p(mgs)/t2s,0.5*cautn(mgs)) )
17848
17849 IF ( dmrauto == 0 ) THEN
17850 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)
17851 crcnw(mgs) = cx(mgs,lr)/qx(mgs,lr)*qrcnw(mgs)
17852 ELSEIF ( ( dmropt == 1 .or. dmropt == 3 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17853 tmp = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17854 crcnw(mgs) = min(tmp,crcnw(mgs) )
17855 ELSEIF ( ( dmropt == 4 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17856 tmp = crcnw(mgs)
17857 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17858 ! try mass-weighted average of old and new Dmr using converted qc mass
17859 crcnw(mgs) = (tmp*qrcnw(mgs)+tmp2*qx(mgs,lr))/(qrcnw(mgs)+qx(mgs,lr))
17860 ELSEIF ( ( dmropt == 5 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17861 tmp = crcnw(mgs)
17862 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17863 ! try mass-weighted average of old and new Dmr using full qc mass
17864 crcnw(mgs) = (tmp*qx(mgs,lc)+tmp2*qx(mgs,lr))/(qx(mgs,lc)+qx(mgs,lr))
17865 ELSEIF ( ( dmropt == 6 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17866 tmp = crcnw(mgs)
17867 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17868 ! try mass*diameter-weighted average of old and new Dmr (using full qc mass)
17869 crcnw(mgs) = (tmp*xdia(mgs,lc,3)*qx(mgs,lc)+tmp2*xdia(mgs,lr,3)*qx(mgs,lr))/ &
17870 (xdia(mgs,lc,3)*qx(mgs,lc)+xdia(mgs,lr,3)*qx(mgs,lr))
17871 ELSEIF ( ( dmropt == 7 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17872 tmp = crcnw(mgs)
17873 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17874 ! try diameter-weighted average of old and new Dmr
17875 crcnw(mgs) = (tmp*xdia(mgs,lc,3)+tmp2*xdia(mgs,lr,3))/(xdia(mgs,lc,3)+xdia(mgs,lr,3))
17876 ELSEIF ( ( dmropt == 8 ) .and. qx(mgs,lr) > qxmin(lr) ) THEN
17877 tmp = crcnw(mgs)
17878 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17879 ! try sqrt(diameter)-weighted average of old and new Dmr
17880 crcnw(mgs) = (tmp*sqrt(xdia(mgs,lc,3))+tmp2*sqrt(xdia(mgs,lr,3)))/ &
17881 (sqrt(xdia(mgs,lc,3))+sqrt(xdia(mgs,lr,3)))
17882 ENDIF
17883 ELSEIF ( dmrauto == 1 .and. cx(mgs,lr) > cxmin) THEN
17884 IF ( qx(mgs,lr) > qxmin(lr) ) THEN
17885 tmp = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17886 crcnw(mgs) = min(tmp,crcnw(mgs) )
17887 ENDIF
17888 ELSEIF ( dmrauto == 2 .and. cx(mgs,lr) > cxmin) THEN
17889 tmp = crcnw(mgs)
17890 tmp2 = qrcnw(mgs)*cx(mgs,lr)/qx(mgs,lr)
17891 ! try mass-weighted average of old and new Dmr
17892 crcnw(mgs) = (tmp*qrcnw(mgs)+tmp2*qx(mgs,lr))/(qrcnw(mgs)+qx(mgs,lr))
17893 ELSEIF ( dmrauto == 3 .and. cx(mgs,lr) > cxmin) THEN ! adapted from MY/CP code
17894 tmp = max( 2.d0*rh(mgs), dble( xdia(mgs,lr,3) ) )
17895 crcnw(mgs) = rho0(mgs)*qrcnw(mgs)/(pi/6.*1000.*tmp**3)
17896 ENDIF
17897
17898 IF ( crcnw(mgs) < 1.e-30 ) qrcnw(mgs) = 0.0
17899
17900 IF ( ipconc >= 6 ) THEN
17901 IF ( lzr > 1 .and. qrcnw(mgs) > 0.0 ) THEN
17902! vr = rho0(mgs)*qrcnw(mgs)/(1000.*crcnw(mgs))
17903! zrcnw(mgs) = 36.*(xnu(lr)+2.0)*crcnw(mgs)*vr**2/((xnu(lr)+1.0)*pi**2)
17904 ! DTD: If rain exists at a grid point already either use the alpha-preserving Z-rate eqn. (dmrauto == 1)
17905 ! or a mass-weighted average of the alpha-preserving Z-rate eqn. and the init. rate eqn. (dmrauto == 2)
17906 ! or the original initiation rate equation (dmrauto == 0). Not sure if this is the correct way to go but seems to work ok.
17907 IF (qx(mgs,lr) .gt. qxmin(lr) .and. ( dmrauto == 1 .or. dmrauto ==2 ) ) THEN
17908 tmp3 = qx(mgs,lr)/cx(mgs,lr)
17909 tmp4 = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2* &
17910 & ( 2.*tmp3 * qrcnw(mgs) - tmp3**2 * crcnw(mgs) )
17911 if (imurain == 3) then
17912 vr = rho0(mgs)*qrcnw(mgs)/(1000.)
17913 tmp3 = 36.*(xnu(lc)+2.0)*vr**2/(crcnw(mgs)*(xnu(lc)+1.0)*pi**2)
17914 else
17915 tmp3 = galpharaut*(6.*rho0(mgs)*qrcnw(mgs)/(pi*xdn0(lr)))**2/crcnw(mgs)
17916 endif
17917 IF ( dmrauto == 1 ) THEN ! Preserve alpha
17918 zrcnw(mgs) = tmp4
17919 ELSEIF ( dmrauto == 2 ) THEN ! Mass-weighted average
17920 zrcnw(mgs) = (tmp3*qrcnw(mgs)+tmp4*qx(mgs,lr))/(qrcnw(mgs)+qx(mgs,lr))
17921 ENDIF
17922 else ! original formulation
17923 IF ( imurain == 3 ) THEN
17924 vr = rho0(mgs)*qrcnw(mgs)/(1000.) ! crcnw(mgs) not divided here but is in next line, cancels one factor in the numerator
17925 zrcnw(mgs) = 36.*(xnu(lc)+2.0)*vr**2/(crcnw(mgs)*(xnu(lc)+1.0)*pi**2)
17926 ELSE ! rain in gamma of diameter
17927 IF ( dmropt <= 1 .or. dmropt >= 4 .or. ( qx(mgs,lr) < qxmin(lr) .and. cx(mgs,lr) < cxmin ) ) THEN
17928 zrcnw(mgs) = galpharaut*(6.*rho0(mgs)*qrcnw(mgs)/(pi*xdn0(lr)))**2/crcnw(mgs)
17929 ELSE
17930 tmp3 = qx(mgs,lr)/cx(mgs,lr)
17931 zrcnw(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2* &
17932 & ( 2.*tmp3 * qrcnw(mgs) - tmp3**2 * crcnw(mgs) )
17933 ENDIF
17934! vr = rho0(mgs)*qrcnw(mgs)/(1000.) ! crcnw(mgs) not divided here but is in next line, cancels one factor in the numerator
17935! zrcnw(mgs) = 36.*(xnu(lc)+2.0)*vr**2/(crcnw(mgs)*(xnu(lc)+1.0)*pi**2)
17936 ENDIF
17937 endif
17938! z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
17939 ENDIF
17940 ENDIF ! ipconc >= 6
17941! IF ( crcnw(mgs) .gt. cautn(mgs) .and. crcnw(mgs) .gt. 1.0 )
17942! : THEN
17943! write(0,*) 'crcnw,cautn ',crcnw(mgs)/cautn(mgs),
17944! : crcnw(mgs),cautn(mgs),igs(mgs),kgs(mgs),t2s,qx(mgs,lr)
17945! write(0,*) ' ',qx(mgs,lc),cx(mgs,lc),0.5e6*xdia(mgs,lc,1)
17946! write(0,*) ' ',rho0(mgs)*qrcnw(mgs)/crcnw(mgs),
17947! : 1.e6*(( 3/(4.*pi))*rho0(mgs)*qrcnw(mgs)/
17948! : (crcnw(mgs)*xdn(mgs,lr)))**(1./3.),rh(mgs)*1.e6,rwrad(mgs)
17949! ELSEIF ( crcnw(mgs) .gt. 1.0 .and. cautn(mgs) .gt. 0.) THEN
17950! write(0,*) 'crcnw,cautn ',crcnw(mgs)/cautn(mgs),
17951! : crcnw(mgs),cautn(mgs),igs(mgs),kgs(mgs),t2s
17952! write(0,*) ' ',rho0(mgs)*qrcnw(mgs)/crcnw(mgs),
17953! : 1.e6*(( 3*pi/4.)*rho0(mgs)*qrcnw(mgs)/
17954! : (crcnw(mgs)*xdn(mgs,lr)))**(1./3.)
17955! ENDIF
17956! crcnw(mgs) = Min(cautn(mgs),3.5e9*xl2p(mgs)/t2s)
17957
17958! IF ( qrcnw(mgs) .gt. 0.3e-2 ) THEN
17959! write(0,*) 'QRCNW'
17960! write(0,*) qrcnw(mgs),crcnw(mgs),cautn(mgs)
17961! write(0,*) xl2p,t2s,rho0(mgs),xv(mgs,lc),cx(mgs,lc),qx(mgs,lc)
17962! write(0,*) rb,0.5*xdia(mgs,lc,1),mgs,igs(mgs),kgs(mgs)
17963! ENDIF
17964! qrcnw(mgs) = Min(qrcnw(mgs),qcmxd(mgs))
17965 ENDIF
17966
17967
17968 ENDIF
17969 ENDDO
17970
17971 ENDIF !} dmrauto >= 0
17972
17973
17974
17975 ELSE
17976
17977!
17978! Berry 1968 auto conversion for rain (Orville & Kopp 1977)
17979!
17980!
17981 if ( ircnw .eq. 4 ) then
17982 do mgs = 1,ngscnt
17983! sconvmix(lcw,mgs) = 0.0
17984 qrcnw(mgs) = 0.0
17985 qdiff = max((qx(mgs,lc)-qminrncw),0.0)
17986 if ( qdiff .gt. 0.0 .and. xdia(mgs,lc,1) .gt. 20.0e-6 ) then
17987 argrcnw = &
17988 & ((1.2e-4)+(1.596e-12)*(cx(mgs,lc)*1.0e-6) &
17989 & /(cwdisp*qdiff*1.0e-3*rho0(mgs)))
17990 qrcnw(mgs) = (rho0(mgs)*1e-3)*(qdiff**2)/argrcnw
17991! sconvmix(lcw,mgs) = max(sconvmix(lcw,mgs),0.0)
17992 qrcnw(mgs) = (max(qrcnw(mgs),0.0))
17993 end if
17994 end do
17995
17996 ENDIF
17997!
17998!
17999!
18000! Berry 1968 auto conversion for rain (Ferrier 1994)
18001!
18002!
18003 if ( ircnw .eq. 5 ) then
18004 do mgs = 1,ngscnt
18005 qrcnw(mgs) = 0.0
18006 qrcnw(mgs) = 0.0
18007 qccrit = (pi/6.)*(cx(mgs,lc)*cwdiap**3)*xdn(mgs,lc)/rho0(mgs)
18008 qdiff = max((qx(mgs,lc)-qccrit),0.)
18009 if ( qdiff .gt. 0.0 .and. cx(mgs,lc) .gt. 1.0 ) then
18010 argrcnw = &
18011! > ((1.2e-4)+(1.596e-12)*cx(mgs,lc)/(cwdisp*rho0(mgs)*qdiff)) &
18012 & ((1.2e-4)+(1.596e-12)*cx(mgs,lc)*1.0e-3/(cwdisp*rho0(mgs)*qdiff))
18013 qrcnw(mgs) = &
18014! > timflg(mgs)*rho0(mgs)*(qdiff**2)/argrcnw &
18015 & 1.0e-3*rho0(mgs)*(qdiff**2)/argrcnw
18016 qrcnw(mgs) = min(qxmxd(mgs,lc), (max(qrcnw(mgs),0.0)) )
18017
18018! write(iunit,*) 'qrcnw,cx =',qrcnw(mgs),cx(mgs,lc),mgs,1.e3*qx(mgs,lc),cno(lr)
18019 end if
18020 end do
18021 end if
18022
18023!
18024!
18025! kessler auto conversion for rain.
18026!
18027 if ( ircnw .eq. 2 ) then
18028 do mgs = 1,ngscnt
18029 qrcnw(mgs) = 0.0
18030 qrcnw(mgs) = (0.001)*max((qx(mgs,lc)-qminrncw),0.0)
18031 end do
18032 end if
18033!
18034! c4 = pi/6
18035! c1 = 0.12-0.32 for colorado storms...typically 0.3-0.4
18036! berry reinhart type conversion (proctor 1988)
18037!
18038 if ( ircnw .eq. 1 ) then
18039 do mgs = 1,ngscnt
18040 qrcnw(mgs) = 0.0
18041 c1 = 0.2
18042 c4 = pi/(6.0)
18043 bradp = &
18044 & (1.e+06) * ((c1/(0.38))**(1./3.)) * (xdia(mgs,lc,1)*(0.5))
18045 bl2 = &
18046 & (0.027) * ((100.0)*(bradp**3)*(xdia(mgs,lc,1)*(0.5)) - (0.4))
18047 bt2 = (bradp -7.5) / (3.72)
18048 qrcnw(mgs) = 0.0
18049 if ( bl2 .gt. 0.0 .and. bt2 .gt. 0.0 ) then
18050 qrcnw(mgs) = bl2 * bt2 * rho0(mgs) &
18051 & * qx(mgs,lc) * qx(mgs,lc)
18052 end if
18053 end do
18054 end if
18055
18056
18057
18058 ENDIF ! ( ipconc .ge. 2 )
18059
18060!
18061!
18062!
18063! Bigg Freezing of Rain
18064!
18065 if (ndebug .gt. 0 ) write(0,*) 'conc 27a'
18066 qrfrz(:) = 0.0
18067 qrfrzs(:) = 0.0
18068 qrfrzf(:) = 0.0
18069 vrfrzf(:) = 0.0
18070 crfrz(:) = 0.0
18071 crfrzs(:) = 0.0
18072 crfrzf(:) = 0.0
18073 zrfrz(:) = 0.0
18074 zrfrzs(:) = 0.0
18075 zrfrzf(:) = 0.0
18076 qwcnr(:) = 0.0
18077
18078 IF ( .not. ( ipconc == 0 .and. lwsm6 ) ) THEN
18079
18080 do mgs = 1,ngscnt
18081 if ( qx(mgs,lr) .gt. qxmin(lr) .and. temcg(mgs) .lt. -5. .and. ibiggopt > 0 ) then
18082! brz = 100.0
18083! arz = 0.66
18084 IF ( ipconc .lt. 3 ) THEN
18085 qrfrz(mgs) = &
18086 & min( &
18087 & (20.0)*(pi**2)*brz*(xdn(mgs,lr)/rho0(mgs)) &
18088 & *cx(mgs,lr)*(xdia(mgs,lr,1)**6) &
18089 & *(exp(max(-arz*temcg(mgs), 0.0))-1.0) &
18090 & , qrmxd(mgs))
18091 qrfrzf(mgs) = qrfrz(mgs)
18092
18093! ELSEIF ( ipconc .ge. 3 .and. xv(mgs,lr) .gt. 1.1*xvmn(lr) ) THEN
18094 ELSEIF ( ipconc .ge. 3 ) THEN
18095! tmp = brz*cx(mgs,lr)*(Exp(Max( -arz*temcg(mgs), 0.0 )) - 1.0)
18096! crfrz(mgs) = xv(mgs,lr)*tmp
18097
18098 frach = 1.0d0
18099
18100! IF ( ibiggopt == 2 .and. imurain == 1 .and. lzr < 1 ) THEN ! lzr check because results are weird for 3-moment
18101 IF ( ibiggopt == 2 .and. imurain == 1 ) THEN !
18102 ! integrate from Bigg diameter (for given supercooling Ts) to infinity
18103
18104 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)
18105 ! 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
18106 ! volt is given in cm**3, so convert to m**3
18107 dbigg = (6./pi* volt )**(1./3.)
18108
18109 ! perhaps should also test that W > V_t_dbigg, i.e., that drops the size of dbigg are being lifted and cooled.
18110 IF ( dbigg < 8.e-3 ) THEN !{ only bother if freezing diameter is reasonable
18111
18112 ratio = min(maxratiolu, dbigg/xdia(mgs,lr,1) )
18113
18114 i = min(nqiacrratio,int(ratio*dqiacrratioinv))
18115 IF ( alp0flag ) THEN
18116 j = int(max(0.0,min(15.,alpha(mgs,lr)))*dqiacralphainv)
18117 ELSE
18118 j = int(max(minalphalu,min(maxalphalu,alpha(mgs,lr)))*dqiacralphainv)
18119 ENDIF
18120 delx = ratio - float(i)*dqiacrratio
18121 dely = alpha(mgs,lr) - float(j)*dqiacralpha
18122 ip1 = min( i+1, nqiacrratio )
18123 jp1 = min( j+1, nqiacralpha )
18124
18125 ! interpolate along x, i.e., ratio;
18126 tmp1 = ciacrratio(i,j) + delx*dqiacrratioinv*(ciacrratio(ip1,j) - ciacrratio(i,j))
18127 tmp2 = ciacrratio(i,jp1) + delx*dqiacrratioinv*(ciacrratio(ip1,jp1) - ciacrratio(i,jp1))
18128
18129 ! interpolate along alpha;
18130
18131 crfrz(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*cx(mgs,lr)*dtpinv
18132 crfrzf(mgs) = crfrz(mgs)
18133 ! interpolate along x, i.e., ratio;
18134 tmp1 = qiacrratio(i,j) + delx*dqiacrratioinv*(qiacrratio(ip1,j) - qiacrratio(i,j))
18135 tmp2 = qiacrratio(i,jp1) + delx*dqiacrratioinv*(qiacrratio(ip1,jp1) - qiacrratio(i,jp1))
18136
18137 ! interpolate along alpha;
18138
18139 qrfrz(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*qx(mgs,lr)*dtpinv
18140 qrfrzf(mgs) = qrfrz(mgs)
18141
18142 IF ( qrfrz(mgs)*dtp < qxmin(lh) .or. crfrz(mgs)*dtp < cxmin ) THEN
18143
18144 crfrz(mgs) = 0.0
18145 qrfrz(mgs) = 0.0
18146 qrfrzf(mgs) = 0.0
18147
18148 ELSE !{
18149
18150
18151 IF ( ipconc >= 5 .or. lzr > 1 ) THEN
18152
18153 cxd1 = crfrz(mgs)*dtp
18154 qxd1 = qrfrz(mgs)*dtp
18155
18156 ! interpolate along x, i.e., ratio;
18157 tmp1 = ziacrratio(i,j) + delx*dqiacrratioinv*(ziacrratio(ip1,j) - ziacrratio(i,j))
18158 tmp2 = ziacrratio(i,jp1) + delx*dqiacrratioinv*(ziacrratio(ip1,jp1) - ziacrratio(i,jp1))
18159
18160 ! interpolate along alpha;
18161
18162 IF ( ipconc >= 6 .and. lzr > 1 ) THEN
18163 zxd1 = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*zx(mgs,lr)
18164 ! Do the correction for alphamax
18165 zrfrz(mgs) = zxd1*dtpinv
18166 ! tmp4 is the Z from the converted particles assuming shape of alphamax
18167 tmp3 = g1xmax*(rho0(mgs)*qxd1)**2/((pi*xdn(mgs,lh)/6.0)**2)
18168 tmp4 = tmp3/cxd1
18169 IF ( tmp4 > zxd1 ) THEN ! calculate new graupel/fd number to match zxd1
18170 ! increase cxd1 to make z,q,c rates consistent
18171 ! cxd1 = g1xmax*(rho0(mgs)*qxd1)**2/(zxd1*(pi*xdn(mgs,lh)/6.0)**2)
18172 cxd1 = tmp3/zxd1
18173 crfrzf(mgs) = dtpinv*cxd1
18174 ENDIF
18175 ELSE
18176 ! tmp5 is rain reflectivity moment
18177 tmp5 = g1x(mgs,lr)*(rho0(mgs)*qx(mgs,lr))**2/((pi*xdn(mgs,lr)/6.)**2*cx(mgs,lr))
18178 zxd1 = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*tmp5
18179 ! tmp4 is the reflectivity of the newly-converted graupel particles (use g1x(lh) for loss term)
18180 ! which we want to match zxd1 to prevent spurious increase in total reflectivity
18181 tmp3 = g1x(mgs,lr)*(rho0(mgs)*qxd1)**2/((pi*xdn(mgs,lr)/6.0)**2)
18182 tmp4 = tmp3/cxd1
18183 IF ( tmp4 > zxd1 ) THEN ! calculate new FD number to match zxd1
18184 crfrzf(mgs) = tmp3/zxd1*dtpinv
18185 ENDIF
18186 ENDIF
18187 ENDIF
18188
18189
18190 IF ( ibiggsmallrain > 0 .and. xv(mgs,lr) < 2.*xvmn(lr) .and. ( ibiggsnow == 1 .or. ibiggsnow == 3 ) ) THEN
18191! IF ( ibiggsmallrain > 0 .and. xv(mgs,lr) < xvbiggsnow .and. ( ibiggsnow == 1 .or. ibiggsnow == 3 ) ) THEN
18192 ! rain drops are so small that they cannot be pushed smaller, so put into snow (or cloud ice, depending on ifrzs)
18193 crfrzf(mgs) = 0.0
18194 qrfrzf(mgs) = 0.0
18195 crfrzs(mgs) = crfrz(mgs)
18196 qrfrzs(mgs) = qrfrz(mgs)
18197
18198 IF ( ipconc >= 6 .and. lzr > 1 ) THEN
18199 zrfrzs(mgs) = zrfrz(mgs)
18200 zrfrzf(mgs) = 0.
18201 ENDIF
18202 ELSEIF ( dbigg < max( biggsnowdiam, max(dfrz,dhmn)) .and. ( ibiggsnow == 1 .or. ibiggsnow == 3 ) ) THEN ! { convert some to snow or ice crystals
18203 ! temporarily store qrfrz and crfrz in snow terms and caclulate new crfrzf, qrfrzf, and zrfrzf. Leave crfrz etc. alone!
18204
18205 crfrzs(mgs) = crfrz(mgs)
18206 qrfrzs(mgs) = qrfrz(mgs)
18207
18208 IF ( ibiggsmallrain > 0 .and. xv(mgs,lr) < 1.2*xvmn(lr) ) THEN
18209 ! rain drops are so small that they cannot be pushed smaller, so put into snow (or cloud ice, depending on ifrzs)
18210 crfrzf(mgs) = 0.0
18211 qrfrzf(mgs) = 0.0
18212
18213 IF (ipconc >= 6 .and. lzr > 1 ) THEN
18214 zrfrzs(mgs) = zrfrz(mgs)
18215 zrfrzf(mgs) = 0.
18216 ENDIF
18217 ELSE !{
18218
18219 ! recalculate using dhmn for ratio
18220 ratio = min( maxratiolu, max(dfrz,dhmn)/xdia(mgs,lr,1) )
18221
18222 i = min(nqiacrratio,int(ratio*dqiacrratioinv))
18223! j = Int(Max(0.0,Min(15.,alpha(mgs,lr)))*dqiacralphainv)
18224! j = Int(Max(alphamin,Min(alphamax,alpha(mgs,lr)))*dqiacralphainv)
18225 IF ( alp0flag ) THEN
18226 j = int(max(0.0,min(alphamax,alpha(mgs,lr)))*dqiacralphainv)
18227 ELSE
18228 j = int(max(minalphalu,min(maxalphalu,alpha(mgs,lr)))*dqiacralphainv)
18229 ENDIF
18230 delx = ratio - float(i)*dqiacrratio
18231 dely = alpha(mgs,lr) - float(j)*dqiacralpha
18232 ip1 = min( i+1, nqiacrratio )
18233 jp1 = min( j+1, nqiacralpha )
18234
18235 ! interpolate along x, i.e., ratio;
18236 tmp1 = ciacrratio(i,j) + delx*dqiacrratioinv*(ciacrratio(ip1,j) - ciacrratio(i,j))
18237 tmp2 = ciacrratio(i,jp1) + delx*dqiacrratioinv*(ciacrratio(ip1,jp1) - ciacrratio(i,jp1))
18238
18239
18240 ! interpolate along alpha;
18241
18242 crfrzf(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*cx(mgs,lr)*dtpinv
18243
18244 ! interpolate along x, i.e., ratio;
18245 tmp1 = qiacrratio(i,j) + delx*dqiacrratioinv*(qiacrratio(ip1,j) - qiacrratio(i,j))
18246 tmp2 = qiacrratio(i,jp1) + delx*dqiacrratioinv*(qiacrratio(ip1,jp1) - qiacrratio(i,jp1))
18247
18248 ! interpolate along alpha;
18249
18250 qrfrzf(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*qx(mgs,lr)*dtpinv
18251
18252 ! now subtract off the difference
18253 crfrzs(mgs) = crfrzs(mgs) - crfrzf(mgs)
18254 qrfrzs(mgs) = qrfrzs(mgs) - qrfrzf(mgs)
18255
18256 IF ( ipconc >= 6 .and. lzr > 1 ) THEN
18257 zrfrzs(mgs) = zrfrz(mgs)
18258 ! interpolate along x, i.e., ratio;
18259 tmp1 = ziacrratio(i,j) + delx*dqiacrratioinv*(ziacrratio(ip1,j) - ziacrratio(i,j))
18260 tmp2 = ziacrratio(i,jp1) + delx*dqiacrratioinv*(ziacrratio(ip1,jp1) - ziacrratio(i,jp1))
18261
18262 ! interpolate along alpha;
18263
18264 zrfrzf(mgs) = (tmp1 + dely*dqiacralphainv*(tmp2 - tmp1))*zx(mgs,lr)*dtpinv
18265 zrfrzs(mgs) = zrfrzs(mgs) - zrfrzf(mgs)
18266 zrfrzf(mgs) = (1000./900.)**2*zrfrzf(mgs)
18267 ENDIF
18268 ENDIF ! }
18269 ELSE
18270 crfrzs(mgs) = 0.0
18271 qrfrzs(mgs) = 0.0
18272 zrfrzs(mgs) = 0.0
18273 ENDIF ! }
18274
18275 ENDIF !}
18276
18277 IF ( (qrfrz(mgs))*dtp > qx(mgs,lr) ) THEN
18278 fac = ( qrfrz(mgs) )*dtp/qx(mgs,lr)
18279 qrfrz(mgs) = fac*qrfrz(mgs)
18280 qrfrzs(mgs) = fac*qrfrzs(mgs)
18281 qrfrzf(mgs) = fac*qrfrzf(mgs)
18282 crfrz(mgs) = fac*crfrz(mgs)
18283 crfrzs(mgs) = fac*crfrzs(mgs)
18284 crfrzf(mgs) = fac*crfrzf(mgs)
18285 IF ( ipconc >= 6 .and. lzr > 1 ) THEN
18286 zrfrz(mgs) = fac*zrfrz(mgs)
18287 zrfrzf(mgs) = fac*zrfrzf(mgs)
18288 ENDIF
18289 ENDIF
18290
18291 ENDIF !}
18292
18293! IF ( (crfrzs(mgs) + crfrz(mgs))*dtp > cx(mgs,lr) ) THEN
18294! fac = ( crfrzs(mgs) + crfrz(mgs) )*dtp/cx(mgs,lr)
18295! crfrz(mgs) = fac*crfrz(mgs)
18296! crfrzs(mgs) = fac*crfrzs(mgs)
18297! ENDIF
18298
18299! qrfrzf(mgs) = qrfrz(mgs)
18300! crfrzf(mgs) = crfrz(mgs)
18301
18302 ! qrfrz(mgs) = qrfrzf(mgs) + qrfrzs(mgs)
18303 ! crfrz(mgs) = crfrzf(mgs) + crfrzs(mgs)
18304
18305
18306 ELSEIF ( ibiggopt == 1 ) THEN
18307 ! Z85, eq. A34
18308 tmp = xv(mgs,lr)*brz*cx(mgs,lr)*(exp(max( -arz*temcg(mgs), 0.0 )) - 1.0)
18309 IF ( .false. .and. tmp .gt. cxmxd(mgs,lr) ) THEN ! {
18310! write(iunit,*) 'Bigg Freezing problem!',mgs,igs(mgs),kgs(mgs)
18311! write(iunit,*) 'tmp, cx(lr), xv = ',tmp, cx(mgs,lr), xv(mgs,lr), (Exp(Max( -arz*temcg(mgs), 0.0 )) - 1.0)
18312! write(iunit,*) 'qr,temcg = ',qx(mgs,lr)*1000.,temcg(mgs)
18313 crfrz(mgs) = cxmxd(mgs,lr) ! cx(mgs,lr)*dtpinv
18314 qrfrz(mgs) = qxmxd(mgs,lr) ! qx(mgs,lr)*dtpinv
18315! STOP
18316 ELSE ! } {
18317 crfrz(mgs) = tmp
18318 ! crfrzfmx = cx(mgs,lr)*Exp(-4./3.*pi*(40.e-6)**3/xv(mgs,lr))
18319 ! IF ( crfrz(mgs) .gt. crfrzmx ) THEN
18320 ! crfrz(mgs) = crfrzmx
18321 ! qrfrz(mgs) = bfnu*xmas(mgs,lr)*rhoinv(mgs)*crfrzmx
18322 ! qwcnr(mgs) = cx(mgs,lr) - crfrzmx
18323 ! ELSE
18324 IF ( lzr < 1 ) THEN
18325 IF ( imurain == 3 ) THEN
18326 bfnu = bfnu0
18327 ELSE !imurain == 1
18328 bfnu = bfnu1
18329 ENDIF
18330 ELSE
18331 ! bfnu = 1.0 ! (alpha(mgs,lr)+2.0)/(alpha(mgs,lr)+1.)
18332 IF ( imurain == 3 ) THEN
18333 bfnu = (alpha(mgs,lr)+2.0)/(alpha(mgs,lr)+1.)
18334 ELSE !imurain == 1
18335! bfnu = bfnu1
18336 bfnu = (4. + alpha(mgs,lr))*(5. + alpha(mgs,lr))*(6. + alpha(mgs,lr))/ &
18337 & ((1. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(3. + alpha(mgs,lr)))
18338! bfnu = 1.
18339 ENDIF
18340 ENDIF
18341 qrfrz(mgs) = bfnu*xmas(mgs,lr)*rhoinv(mgs)*crfrz(mgs)
18342
18343 qrfrz(mgs) = min( qrfrz(mgs), 1.*qx(mgs,lr)*dtpinv ) ! qxmxd(mgs,lr)
18344 crfrz(mgs) = min( crfrz(mgs), 1.*cx(mgs,lr)*dtpinv ) !cxmxd(mgs,lr)
18345 qrfrz(mgs) = min( qrfrz(mgs), qx(mgs,lr) )
18346 qrfrzf(mgs) = qrfrz(mgs)
18347 ENDIF !}
18348
18349
18350
18351
18352 IF ( crfrz(mgs) .gt. qxmin(lh) ) THEN !{ Yes, it compares cx and qxmin, but this is just to be sure that
18353 ! crfrz is greater than zero in the division
18354! IF ( xdia(mgs,lr,1) .lt. 200.e-6 ) THEN
18355! IF ( xv(mgs,lr) .lt. xvmn(lh) ) THEN
18356
18357 IF ( (ibiggsnow == 1 .or. ibiggsnow == 3 ) .and. ibiggopt /= 2 ) THEN
18358 xvfrz = rho0(mgs)*qrfrz(mgs)/(crfrz(mgs)*900.) ! mean volume of frozen drops; 900. for frozen drop density
18359 frach = 0.5 *(1. + tanh(0.2e12 *( xvfrz - 1.15*xvmn(lh))))
18360
18361 qrfrzs(mgs) = (1.-frach)*qrfrz(mgs)
18362 crfrzs(mgs) = (1.-frach)*crfrz(mgs) ! *rzxh(mgs)
18363! qrfrzf(mgs) = frach*qrfrz(mgs)
18364
18365 ENDIF
18366
18367 IF ( ipconc .ge. 14 .and. 1.e-3*rho0(mgs)*qrfrz(mgs)/crfrz(mgs) .lt. xvmn(lh) ) THEN
18368 qrfrzs(mgs) = qrfrz(mgs)
18369 crfrzs(mgs) = crfrz(mgs) ! *rzxh(mgs)
18370 ELSE
18371! crfrz(mgs) = Min( crfrz(mgs), 0.1*cx(mgs,lr)*dtpinv ) ! cxmxd(mgs,lr)
18372! qrfrz(mgs) = Min( qrfrz(mgs), 0.1*qx(mgs,lr)*dtpinv ) ! qxmxd(mgs,lr)
18373 qrfrzf(mgs) = frach*qrfrz(mgs)
18374! crfrzf(mgs) = Min( qrfrz(mgs)*rho0(mgs)/(xdn(mgs,lh)*vgra), crfrz(mgs) )
18375 IF ( ibfr .le. 1 ) THEN
18376 crfrzf(mgs) = frach*min(crfrz(mgs), qrfrz(mgs)/(bfnu*1.0*vr1mm*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
18377 ELSEIF ( ibfr .eq. 5 ) THEN
18378 crfrzf(mgs) = frach*min(crfrz(mgs), qrfrz(mgs)/(bfnu*vfrz*1000.0)*rho0(mgs) )*rzxh(mgs) !*crfrz(mgs)
18379 ELSEIF ( ibfr .eq. 2 ) THEN
18380 crfrzf(mgs) = frach*min(crfrz(mgs), qrfrz(mgs)/(bfnu*vfrz*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
18381 ELSEIF ( ibfr .eq. 6 ) THEN
18382 crfrzf(mgs) = frach*max(crfrz(mgs), qrfrz(mgs)/(bfnu*9.*xv(mgs,lr)*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
18383 ELSE
18384 crfrzf(mgs) = frach*crfrz(mgs)
18385 ENDIF
18386! crfrzf(mgs) = Min(crfrz(mgs), qrfrz(mgs)/(bfnu*xvmn(lh)*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
18387! IF ( lz(lr) > 1 .and. lz(lh) > 1 ) THEN
18388! crfrzf(mgs) = crfrz(mgs)
18389! ENDIF
18390
18391 ENDIF
18392! crfrz(mgs) = Min( cxmxd(mgs,lr), rho0(mgs)*qrfrz(mgs)/xmas(mgs,lr) )
18393 ELSE
18394 crfrz(mgs) = 0.0
18395 qrfrz(mgs) = 0.0
18396 ENDIF !}
18397
18398 ENDIF ! ibiggopt
18399
18400 IF ( lvol(lh) .gt. 1 ) THEN
18401 vrfrzf(mgs) = rho0(mgs)*qrfrzf(mgs)/rhofrz
18402 ENDIF
18403
18404
18405 IF ( nsplinter .ne. 0 ) THEN
18406 IF ( nsplinter .ge. 1000 ) THEN
18407 ! Lawson et al. 2015 JAS
18408 ! ave. diam of freezing drops in microns
18409 tmp = 0
18410 IF ( qrfrz(mgs)*dtp > qxmin(lh) .and. crfrz(mgs) > 1.e-3 ) THEN
18411 tmpdiam = 1.e6*( 6.*qrfrz(mgs)/(1000.*pi*crfrz(mgs) ))**(1./3.) ! avg. diameter of newly frozen drops in microns
18412 fac = 1.0
18413 IF ( nsplinter .eq. 1001 ) THEN
18414 ! fac = 0.2/sqrt(2.0*pi*10.**2)*Exp(-0.5*((258.-temg(mgs))/10.)**2 ) ! temperature dependence from Sullivan et al. 2018 ACP
18415 ! ELSE
18416 fac = 0.2*exp(-0.5*((258.-temg(mgs))/10.)**2 ) ! temperature dependence from Sullivan et al. 2018 ACP
18417 ENDIF
18418 tmp = fac*lawson_splinter_fac*tmpdiam**4*crfrz(mgs)
18419 ENDIF
18420 ELSEIF ( nsplinter .gt. 0 ) THEN
18421 tmp = nsplinter*crfrz(mgs)
18422 ELSE
18423 tmp = -nsplinter*crfrzf(mgs)
18424 ENDIF
18425 csplinter2(mgs) = tmp
18426 qsplinter2(mgs) = min(0.1*qrfrz(mgs), tmp*splintermass/rho0(mgs) ) ! makes splinters smaller if too much mass is taken from graupel
18427
18428! csplinter(mgs) = csplinter(mgs) + tmp
18429! qsplinter(mgs) = qsplinter(mgs) + Min(0.1*qrfrz(mgs), tmp*splintermass/rho0(mgs) ) ! makes splinters smaller if too much mass is taken from graupel
18430 ENDIF
18431! IF ( temcg(mgs) .lt. -31.0 ) THEN
18432! qrfrz(mgs) = qx(mgs,lr)*dtpinv + qrcnw(mgs)
18433! qrfrzf(mgs) = qrfrz(mgs)
18434! crfrz(mgs) = cx(mgs,lr)*dtpinv + crcnw(mgs)
18435! crfrzf(mgs) = Min(crfrz(mgs), qrfrz(mgs)/(bfnu*1.0*vr1mm*1000.0)*rho0(mgs) ) ! rzxh(mgs)*crfrz(mgs)
18436! ENDIF
18437! qrfrz(mgs) = 6.0*xdn(mgs,lr)*xv(mgs,lr)**2*tmp*rhoinv(mgs)
18438! qrfrz(mgs) = Min( qrfrz(mgs), ffrz*qrmxd(mgs) )
18439! crfrz(mgs) = Min( crmxd(mgs), ffrz*crfrz(mgs))
18440! crfrz(mgs) = Min(crmxd(mgs),qrfrz(mgs)*rho0(mgs)/xmas(mgs,lr))
18441 ENDIF
18442! if ( temg(mgs) .gt. 268.15 ) then
18443 else
18444! end if
18445 end if
18446 end do
18447
18448 ENDIF
18449!
18450! Homogeneous freezing of cloud drops to ice crystals
18451! following Bigg (1953) and Ferrier (1994).
18452!
18453 if (ndebug .gt. 0 ) write(0,*) 'conc 25b'
18454 do mgs = 1,ngscnt
18455 qwfrz(mgs) = 0.0
18456 cwfrz(mgs) = 0.0
18457 qwfrzc(mgs) = 0.0
18458 cwfrzc(mgs) = 0.0
18459 qwfrzp(mgs) = 0.0
18460 cwfrzp(mgs) = 0.0
18461 IF ( ibfc .ge. 1 .and. ibfc /= 3 .and. temg(mgs) < 268.15 ) THEN
18462! if ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. 1. .and. &
18463! & .not. (ipconc .ge. 2 .and. xdia(mgs,lc,1) .lt. 10.e-6) ) then
18464 if ( qx(mgs,lc) .gt. qxmin(lc) .and. cx(mgs,lc) .gt. cxmin ) THEN
18465 IF ( ipconc < 2 ) THEN
18466 qwfrz(mgs) = ((2.0)*(brz)/(xdn(mgs,lc)*cx(mgs,lc))) &
18467 & *(exp(max(-arz*temcg(mgs), 0.0))-1.0) &
18468 & *rho0(mgs)*(qx(mgs,lc)**2)
18469 qwfrz(mgs) = max(qwfrz(mgs), 0.0)
18470 qwfrz(mgs) = min(qwfrz(mgs),qcmxd(mgs))
18471 cwfrz(mgs) = qwfrz(mgs)*rho0(mgs)/xmas(mgs,li)
18472 ELSEIF ( ipconc .ge. 2 ) THEN
18473 IF ( xdia(mgs,lc,3) > 0.e-6 ) THEN
18474 volt = exp( 16.2 + 1.0*temcg(mgs) )* 1.0e-6 ! Ts == -temcg ; volt comes from the fit in Fig. 1 in Bigg 1953
18475 ! for mean temperature for freezing: -ln (V) = a*Ts - b
18476 ! volt is given in cm**3, so factor of 1.e-6 to convert to m**3
18477! dbigg = (6./pi* volt )**(1./3.)
18478
18479 IF ( alpha(mgs,lc) == 0.0 ) THEN
18480 cwfrz(mgs) = cx(mgs,lc)*exp(-volt/xv(mgs,lc))*dtpinv ! number of droplets with volume greater than volt
18481!turn off limit so that all can freeze at low temp
18482!!! cwfrz(mgs) = Min(cwfrz(mgs),ccmxd(mgs))
18483
18484 qwfrz(mgs) = cwfrz(mgs)*xdn0(lc)*rhoinv(mgs)*(volt + xv(mgs,lc))
18485 ELSE
18486 ratio = (1. + alpha(mgs,lc))*volt/xv(mgs,lc)
18487
18488 IF ( .false. .and. usegamxinfcnu ) THEN
18489 i = nint(dgami*(1. + alpha(mgs,lc)))
18490 gcnup1 = gmoi(i)
18491 i = nint(dgami*(2. + alpha(mgs,lc)))
18492 gcnup2 = gmoi(i)
18493
18494 cwfrz(mgs) = cx(mgs,lc)*gamxinf(1.+alpha(mgs,lc), ratio)/(dtp*gcnup1) ! gamxinflu(i,j,1,1)
18495
18496 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)
18497
18498 ELSE
18499
18500 ratio = min( maxratiolu, ratio )
18501! write(0,*) 'cwfrz: temp,ratio = ',temcg(mgs),ratio
18502! write(0,*) 'cwfrz: xv,volt,qx = ',xv(mgs,lc),volt,qx(mgs,lc)
18503! write(0,*) 'cwfrz: i,j,k = ',igs(mgs),jgs,kgs(mgs)
18504 tmp = gaminterp(ratio,alpha(mgs,lc),1,1)
18505! write(0,*) 'cwfrz: tmp1 = ',tmp
18506 cwfrz(mgs) = cx(mgs,lc)*tmp*dtpinv ! Gamxinf(1.+alpha(mgs,lc), ratio)/(dtp*gcnup1) ! gamxinflu(i,j,1,1)
18507
18508 tmp = gaminterp(ratio,alpha(mgs,lc),12,1)
18509! write(0,*) 'cwfrz: tmp2 = ',tmp
18510 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)
18511
18512 ENDIF
18513
18514 ENDIF
18515
18516 ENDIF
18517 ENDIF
18518 if ( temg(mgs) .gt. 268.15 ) then
18519 qwfrz(mgs) = 0.0
18520 cwfrz(mgs) = 0.0
18521 end if
18522 end if
18523 ENDIF
18524!
18525 if ( xplate(mgs) .eq. 1 ) then
18526 qwfrzp(mgs) = qwfrz(mgs)
18527 cwfrzp(mgs) = cwfrz(mgs)
18528 end if
18529!
18530 if ( xcolmn(mgs) .eq. 1 ) then
18531 qwfrzc(mgs) = qwfrz(mgs)
18532 cwfrzc(mgs) = cwfrz(mgs)
18533 end if
18534
18535!
18536! qwfrzp(mgs) = 0.0
18537! qwfrzc(mgs) = qwfrz(mgs)
18538!
18539 end do
18540!
18541!
18542! Contact freezing nucleation: factor is to convert from L-1
18543! T < -2C: via Meyers et al. JAM July, 1992 (31, 708-721)
18544!
18545 if (ndebug .gt. 0 ) write(0,*) 'conc 25a'
18546 do mgs = 1,ngscnt
18547
18548 ccia(mgs) = 0.0
18549
18550 cwctfz(mgs) = 0.0
18551 qwctfz(mgs) = 0.0
18552 ctfzbd(mgs) = 0.0
18553 ctfzth(mgs) = 0.0
18554 ctfzdi(mgs) = 0.0
18555
18556 cwctfzc(mgs) = 0.0
18557 qwctfzc(mgs) = 0.0
18558 cwctfzp(mgs) = 0.0
18559 qwctfzp(mgs) = 0.0
18560 IF ( icfn .ge. 1 ) THEN
18561
18562 IF ( temg(mgs) .lt. 271.15 .and. qx(mgs,lc) .gt. qxmin(lc)) THEN
18563
18564! find available # of ice nuclei & limit value to max depletion of cloud water
18565
18566 IF ( icfn .ge. 2 ) THEN
18567 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)
18568 !ccia(mgs) = Min(cwctfz(mgs), ccmxd(mgs) )
18569
18570! now find how many of these collect cloud water to form IN
18571! Cotton et al 1986
18572
18573 knud(mgs) = 2.28e-5 * temg(mgs) / ( pres(mgs)*raero ) !Walko et al. 1995
18574 knuda(mgs) = 1.257 + 0.4*exp(-1.1/knud(mgs)) !Pruppacher & Klett 1997 eqn 11-16
18575 gtp(mgs) = 1. / ( fai(mgs) + fbi(mgs) ) !Byers 65 / Cotton 72b
18576 dfar(mgs) = kb*temg(mgs)*(1.+knuda(mgs)*knud(mgs))/(6.*pi*fadvisc(mgs)*raero) !P&K 1997 eqn 11-15
18577 fn1(mgs) = 2.*pi*xdia(mgs,lc,1)*cx(mgs,lc)*ccia(mgs)
18578 fn2(mgs) = -gtp(mgs)*(ssw(mgs)-1.)*felv(mgs)/pres(mgs)
18579 fnft(mgs) = 0.4*(1.+1.45*knud(mgs)+0.4*knud(mgs)*exp(-1./knud(mgs)))*(ftka(mgs)+2.5*knud(mgs)*kaero) &
18580 & / ( (1.+3.*knud(mgs))*(2*ftka(mgs)+5.*knud(mgs)*kaero+kaero) )
18581
18582
18583! Brownian diffusion
18584 ctfzbd(mgs) = fn1(mgs)*dfar(mgs)
18585
18586! Thermophoretic contact nucleation
18587 ctfzth(mgs) = fn1(mgs)*fn2(mgs)*fnft(mgs)/rho0(mgs)
18588
18589! Diffusiophoretic contact nucleation
18590 ctfzdi(mgs) = fn1(mgs)*fn2(mgs)*rw*temg(mgs)/(felv(mgs)*rho0(mgs))
18591
18592 cwctfz(mgs) = max( ctfzbd(mgs) + ctfzth(mgs) + ctfzdi(mgs) , 0.)
18593
18594! Sum of the contact nucleation processes
18595! IF ( cx(mgs,lc) .gt. 1.e6) write(0,*) 'ctfzbd,etc = ',cwctfz(mgs),ctfzbd(mgs),ctfzth(mgs),ctfzdi(mgs)
18596! IF ( wvel(mgs) .lt. -0.05 ) write(6,*) 'ctfzbd,etc = ',ctfzbd(mgs),ctfzth(mgs),ctfzdi(mgs),cx(mgs,lc)*1e-6,wvel(mgs)
18597! IF ( ssw(mgs) .lt. 1.0 .and. cx(mgs,lc) .gt. 1.e6 .and. cwctfz(mgs) .gt. 1. ) THEN
18598! write(6,*) 'ctfzbd,etc = ',ctfzbd(mgs),ctfzth(mgs),ctfzdi(mgs),cx(mgs,lc)*1e-6,wvel(mgs),fn1(mgs),fn2(mgs)
18599! write(6,*) 'more = ',nstep,ssw(mgs),dfar(mgs),gtp(mgs),felv(mgs),pres(mgs)
18600! ENDIF
18601
18602 ELSEIF ( icfn .eq. 1 ) THEN
18603 IF ( wvel(mgs) .lt. -0.05 ) THEN ! older kludgy version
18604 cwctfz(mgs) = cfnfac*exp( (-2.80) - (0.262)*temcg(mgs) )
18605 cwctfz(mgs) = min((1.0e3)*cwctfz(mgs), ccmxd(mgs) ) !convert to m-3
18606 ENDIF
18607 ENDIF ! icfn
18608
18609 IF ( ipconc .ge. 2 ) THEN
18610 cwctfz(mgs) = min( cwctfz(mgs)*dtpinv, ccmxd(mgs) )
18611 qwctfz(mgs) = xmas(mgs,lc)*cwctfz(mgs)/rho0(mgs)
18612 ELSE
18613 qwctfz(mgs) = (cimasn)*cwctfz(mgs)/(dtp*rho0(mgs))
18614 qwctfz(mgs) = max(qwctfz(mgs), 0.0)
18615 qwctfz(mgs) = min(qwctfz(mgs),qcmxd(mgs))
18616 ENDIF
18617
18618!
18619 if ( xplate(mgs) .eq. 1 ) then
18620 qwctfzp(mgs) = qwctfz(mgs)
18621 cwctfzp(mgs) = cwctfz(mgs)
18622 end if
18623!
18624 if ( xcolmn(mgs) .eq. 1 ) then
18625 qwctfzc(mgs) = qwctfz(mgs)
18626 cwctfzc(mgs) = cwctfz(mgs)
18627 end if
18628
18629! IF ( cwctfz(mgs)*dtp > 0.5 .and. dtp*qwctfz(mgs) > qxmin(li) ) THEN
18630! write(91,*) 'cwctfz: ',cwctfz(mgs),qwctfz(mgs) ! ,cwctfzc(mgs),qwctfzc(mgs)
18631! ENDIF
18632
18633!
18634! qwctfzc(mgs) = qwctfz(mgs)
18635! qwctfzp(mgs) = 0.0
18636!
18637 end if
18638
18639 ENDIF ! icfn
18640
18641 end do
18642!
18643!
18644!
18645! Hobbs-Rangno ice enhancement (Ferrier, 1994)
18646!
18647 if (ndebug .gt. 0 ) write(0,*) 'conc 23a'
18648 dthr = 300.0
18649 hrifac = (1.e-3)*((0.044)*(0.01**3))
18650 do mgs = 1,ngscnt
18651 ciihr(mgs) = 0.0
18652 qiihr(mgs) = 0.0
18653 cicichr(mgs) = 0.0
18654 qicichr(mgs) = 0.0
18655 cipiphr(mgs) = 0.0
18656 qipiphr(mgs) = 0.0
18657 IF ( ihrn .ge. 1 ) THEN
18658 if ( qx(mgs,lc) .gt. qxmin(lc) ) then
18659 if ( temg(mgs) .lt. 273.15 ) then
18660! write(iunit,'(3(1x,i3),3(1x,1pe12.5))')
18661! : igs(mgs),jgs,kgs(mgs),cx(mgs,lc),rho0(mgs),qx(mgs,lc)
18662! write(iunit,'(1pe15.6)')
18663! : log(cx(mgs,lc)*(1.e-6)/(3.0)),
18664! : ((1.e-3)*rho0(mgs)*qx(mgs,lc)),
18665! : (cx(mgs,lc)*(1.e-6)),
18666! : ((1.e-3)*rho0(mgs)*qx(mgs,lc))/(cx(mgs,lc)*(1.e-6)),
18667! : (alog(cx(mgs,lc)*(1.e-6)/(3.0)) *
18668! > ((1.e-3)*rho0(mgs)*qx(mgs,lc))/(cx(mgs,lc)*(1.e-6)))
18669
18670 IF ( log(cx(mgs,lc)*(1.e-6)/(3.0)) .gt. 0.0 ) THEN
18671 ciihr(mgs) = ((1.69e17)/dthr) &
18672 & *(log(cx(mgs,lc)*(1.e-6)/(3.0)) * &
18673 & ((1.e-3)*rho0(mgs)*qx(mgs,lc))/(cx(mgs,lc)*(1.e-6)))**(7./3.)
18674 ciihr(mgs) = ciihr(mgs)*(1.0e6)
18675 qiihr(mgs) = hrifac*ciihr(mgs)/rho0(mgs)
18676 qiihr(mgs) = max(qiihr(mgs), 0.0)
18677 qiihr(mgs) = min(qiihr(mgs),qcmxd(mgs))
18678 ENDIF
18679!
18680 if ( xplate(mgs) .eq. 1 ) then
18681 qipiphr(mgs) = qiihr(mgs)
18682 cipiphr(mgs) = ciihr(mgs)
18683 end if
18684!
18685 if ( xcolmn(mgs) .eq. 1 ) then
18686 qicichr(mgs) = qiihr(mgs)
18687 cicichr(mgs) = ciihr(mgs)
18688 end if
18689!
18690! qipiphr(mgs) = 0.0
18691! qicichr(mgs) = qiihr(mgs)
18692!
18693 end if
18694 end if
18695 ENDIF ! ihrn
18696 end do
18697!
18698!
18699!
18700! simple frozen rain to hail conversion. All of the
18701! frozen rain larger than 5.0e-3 m in diameter are converted
18702! to hail. This is done by considering the equation for
18703! frozen rain mixing ratio:
18704!
18705!
18706! qfw = [ cno(lf) * pi * fwdn / (6 rhoair) ]
18707!
18708! /inf
18709! * | fwdia*3 exp(-dia/fwdia) d(dia)
18710! /Do
18711!
18712! The amount to be reclassified as hail is the integral above from
18713! Do to inf where Do is 5.0e-3 m.
18714!
18715!
18716! qfauh = [ cno(lf) * pi * fwdn / (6 rhoair) ]
18717!
18718!
18719
18720
18721 hdia0 = 300.0e-6
18722 do mgs = 1,ngscnt
18723 qscnvi(mgs) = 0.0
18724 cscnvi(mgs) = 0.0
18725 cscnvis(mgs) = 0.0
18726! IF ( .false. ) THEN
18727! IF ( temg(mgs) .lt. tfr .and. ssi(mgs) .gt. 1.01 .and. qx(mgs,li) .gt. qxmin(li) ) THEN
18728 IF ( temg(mgs) .lt. tfr .and. qx(mgs,li) .gt. qxmin(li) ) THEN
18729 IF ( ipconc .ge. 4 .and. .false. ) THEN
18730 if ( cx(mgs,li) .gt. 10. .and. xdia(mgs,li,1) .gt. 50.e-6 ) then !{
18731 cirdiatmp = &
18732 & (qx(mgs,li)*rho0(mgs) &
18733 & /(pi*xdn(mgs,li)*cx(mgs,li)))**(1./3.)
18734 IF ( cirdiatmp .gt. 100.e-6 ) THEN !{
18735 qscnvi(mgs) = &
18736 & ((pi*xdn(mgs,li)*cx(mgs,li)) / (6.0*rho0(mgs)*dtp)) &
18737 & *exp(-hdia0/cirdiatmp) &
18738 & *( (hdia0**3) + 3.0*(hdia0**2)*cirdiatmp &
18739 & + 6.0*(hdia0)*(cirdiatmp**2) + 6.0*(cirdiatmp**3) )
18740 qscnvi(mgs) = &
18741 & min(qscnvi(mgs),qimxd(mgs))
18742 IF ( ipconc .ge. 4 ) THEN
18743 cscnvi(mgs) = min( cimxd(mgs), cx(mgs,li)*exp(-hdia0/cirdiatmp))
18744 ENDIF
18745 ENDIF ! }
18746 end if ! }
18747
18748 ELSEIF ( ipconc .lt. 4 ) THEN
18749
18750 qscnvi(mgs) = 0.001*eii(mgs)*max((qx(mgs,li)-1.e-3),0.0)
18751 qscnvi(mgs) = min(qscnvi(mgs),qxmxd(mgs,li))
18752 cscnvi(mgs) = qscnvi(mgs)*rho0(mgs)/xmas(mgs,li)
18753 cscnvis(mgs) = 0.5*cscnvi(mgs)
18754
18755 ENDIF
18756 ENDIF
18757! ENDIF
18758 end do
18759
18760
18761
18762!
18763! Ventilation coeficients
18764!
18765 do mgs = 1,ngscnt
18766 fvent(mgs) = (fschm(mgs)**(1./3.)) * (fakvisc(mgs)**(-0.5))
18767 end do
18768!
18769!
18770 if ( ndebug .gt. 0 ) write(0,*) 'civent'
18771!
18772 civenta = 1.258e4
18773 civentb = 2.331
18774 civentc = 5.662e4
18775 civentd = 2.373
18776 civente = 0.8241
18777 civentf = -0.042
18778 civentg = 1.70
18779
18780 do mgs = 1,ngscnt
18781 IF ( icond .eq. 1 .or. temg(mgs) .le. tfrh &
18782 & .or. (qx(mgs,lr) .le. qxmin(lr) .and. qx(mgs,lc) .le. qxmin(lc)) ) THEN
18783 IF ( qx(mgs,li) .gt. qxmin(li) ) THEN
18784 cireyn = &
18785 & (civenta*xdia(mgs,li,1)**civentb &
18786 & +civentc*xdia(mgs,li,1)**civentd) &
18787 & / &
18788 & (civente*xdia(mgs,li,1)**civentf+civentg)
18789 xcivent = (fschm(mgs)**(1./3.))*((cireyn/fakvisc(mgs))**0.5)
18790 if ( xcivent .lt. 1.0 ) then
18791 civent(mgs) = 1.0 + 0.14*xcivent**2
18792 end if
18793 if ( xcivent .ge. 1.0 ) then
18794 civent(mgs) = 0.86 + 0.28*xcivent
18795 end if
18796 ELSE
18797 civent(mgs) = 0.0
18798 ENDIF
18799
18800
18801 ENDIF ! icond .eq. 1
18802 end do
18803
18804!
18805!
18806 igmrwa = 100.0*2.0
18807 igmrwb = 100.*((5.0+br)/2.0)
18808 rwventa = (0.78)*gmoi(igmrwa) ! 0.78
18809 rwventb = (0.308)*gmoi(igmrwb) ! 0.562825
18810 do mgs = 1,ngscnt
18811 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
18812 IF ( ipconc .ge. 3 ) THEN
18813 IF ( imurain == 3 ) THEN
18814 IF ( izwisventr == 1 ) THEN
18815 rwvent(mgs) = ventrx(mgs)*(1.6 + 124.9*(1.e-3*rho0(mgs)*qx(mgs,lr))**.2046)
18816 ELSE ! izwisventr = 2
18817! 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
18818 rwvent(mgs) = &
18819 & (0.78*ventrx(mgs) + 0.308*ventrxn(mgs)*fvent(mgs) &
18820 & *sqrt((ar*rhovt(mgs))) &
18821 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
18822 ENDIF
18823
18824 ELSE ! imurain == 1
18825 ! linear interpolation of complete gamma function
18826! tmp = 2. + alpha(mgs,lr)
18827! i = Int(dgami*(tmp))
18828! del = tmp - dgam*i
18829! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18830
18831 IF ( iferwisventr == 1 ) THEN
18832
18833 ! Ferrier fall speed in the ventillation term [uses fx(lr) ]
18834
18835 alpr = min(alpharmax,alpha(mgs,lr) )
18836
18837 x = 1. + alpha(mgs,lr)
18838
18839 IF ( ipconc >= 6 .and. lzr > 1 ) THEN ! 3 moment
18840 tmp = 1. + alpr ! alpha(mgs,lr)
18841 i = int(dgami*(tmp))
18842 del = tmp - dgam*i
18843 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18844
18845 tmp = 2.5 + alpha(mgs,lr) + 0.5*bx(lr)
18846 i = int(dgami*(tmp))
18847 del = tmp - dgam*i
18848 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp ! ratio of gamma functions
18849 ELSE
18850 y = ventrxn(mgs)
18851 ENDIF
18852
18853! vent1 = dble(xdia(mgs,lr,1))**(-2. - alpr) ! Actually OK
18854! vent2 = dble(1./xdia(mgs,lr,1) + 0.5*fx(lr))**dble(2.5+alpr+0.5*bx(lr)) ! Actually OK
18855 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)
18856 vent2 = dble(1. + 0.5*fx(lr)*xdia(mgs,lr,1))**dble(2.5+alpr+0.5*bx(lr))
18857
18858
18859 rwvent(mgs) = &
18860 & 0.78*x + &
18861 & 0.308*fvent(mgs)*y* &
18862 & sqrt(ax(lr)*rhovt(mgs))*(vent1/vent2)
18863
18864 rwventz(mgs) = 0.0
18865
18866! rwventz(mgs) = &
18867! & 0.78*x + &
18868! & 0.308*fvent(mgs)*y* &
18869! & Sqrt(ax(lr)*rhovt(mgs))*(vent1/vent2)
18870
18871
18872 ELSEIF ( iferwisventr == 2 ) THEN
18873
18874! 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
18875 x = 1. + alpha(mgs,lr)
18876
18877 rwvent(mgs) = &
18878 & (0.78*x + 0.308*ventrxn(mgs)*fvent(mgs) &
18879 & *sqrt((ar*rhovt(mgs))) &
18880 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
18881
18882
18883 IF ( ipconc >= 7 ) THEN
18884 ! vent coeff. for reflectivity rate from evaporation
18885 alpr = min(alpharmax,alpha(mgs,lr) )
18886
18887 tmp = alpr + 5.5 + br/2.
18888 i = int(dgami*(tmp))
18889 del = tmp - dgam*i
18890 y = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18891
18892! rwventz(mgs) = &
18893! & 0.78*(4. + alpha(mgs,lr))*(3. + alpha(mgs,lr))*(2. + alpha(mgs,lr))*(1. + alpha(mgs,lr)) + &
18894 rwventz(mgs) = &
18895 & 0.78*(4. + alpr)*(3. + alpr)*(2. + alpr)*(1. + alpr) + &
18896 & 0.308*fvent(mgs)* &
18897 & sqrt(ax(lr)*rhovt(mgs))*(y/gf1palp(mgs))*(xdia(mgs,lr,1)**((1.0+br)/2.0))
18898
18899 ENDIF
18900
18901
18902 ENDIF ! iferwisventr
18903
18904 ENDIF ! imurain
18905 ELSE
18906 rwvent(mgs) = &
18907 & (rwventa + rwventb*fvent(mgs) &
18908 & *sqrt((ar*rhovt(mgs))) &
18909 & *(xdia(mgs,lr,1)**((1.0+br)/2.0)) )
18910 ENDIF
18911 ELSE
18912 rwvent(mgs) = 0.0
18913 ENDIF
18914 end do
18915!
18916 igmswa = 100.0*2.0
18917 igmswb = 100.*((5.0+ds)/2.0)
18918 swventa = (0.78)*gmoi(igmswa)
18919 swventb = (0.308)*gmoi(igmswb)
18920 do mgs = 1,ngscnt
18921 IF ( qx(mgs,ls) .gt. qxmin(ls) ) THEN
18922 IF ( ipconc .ge. 4 ) THEN
18923 swvent(mgs) = 0.65 + 0.44*fvent(mgs)*sqrt(vtxbar(mgs,ls,1)*xdia(mgs,ls,1))
18924 ELSE
18925! 10-ice version:
18926 swvent(mgs) = &
18927 & (swventa + swventb*fvent(mgs) &
18928 & *sqrt((cs*rhovt(mgs))) &
18929 & *(xdia(mgs,ls,1)**((1.0+ds)/2.0)) )
18930 ENDIF
18931 ELSE
18932 swvent(mgs) = 0.0
18933 ENDIF
18934 end do
18935!
18936!
18937
18938 igmhwa = 100.0*2.0
18939 igmhwb = 100.0*2.75
18940 hwventa = (0.78)*gmoi(igmhwa)
18941 hwventb = (0.308)*gmoi(igmhwb)
18942! hwventc = (4.0*gr/(3.0*cdx(lh)))**(0.25)
18943 hwvent(:) = 0.0
18944 hwventy(:) = 0.0
18945
18946 do mgs = 1,ngscnt
18947 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
18948 hwventc = (4.0*gr/(3.0*cdxgs(mgs,lh)))**(0.25)
18949 IF ( .false. .or. alpha(mgs,lh) .eq. 0.0 ) THEN
18950 hwvent(mgs) = &
18951 & ( hwventa + hwventb*hwventc*fvent(mgs) &
18952 & *((xdn(mgs,lh)/rho0(mgs))**(0.25)) &
18953 & *(xdia(mgs,lh,1)**(0.75)))
18954 ELSE ! Ferrier 1994, eq. B.36
18955 ! linear interpolation of complete gamma function
18956! tmp = 2. + alpha(mgs,lh)
18957! i = Int(dgami*(tmp))
18958! del = tmp - dgam*i
18959! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18960
18961! note that hwvent includes a division by Gamma(1+alpha), so Gamma(2+alpha)/Gamma(1+alpha) = 1 + alpha
18962! and g1palp = Gamma(1+alpha) divides into y
18963 x = 1. + alpha(mgs,lh)
18964
18965 tmp = 1 + alpha(mgs,lh)
18966 i = int(dgami*(tmp))
18967 del = tmp - dgam*i
18968 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
18969
18970 tmp = 2.5 + alpha(mgs,lh) + 0.5*bxx(mgs,lh)
18971 i = int(dgami*(tmp))
18972 del = tmp - dgam*i
18973 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp
18974
18975
18976 hwventy(mgs) = 0.308*fvent(mgs)*(xdia(mgs,lh,1)**(0.5 + 0.5*bxx(mgs,lh)))*sqrt(axx(mgs,lh)*rhovt(mgs))
18977 hwvent(mgs) = &
18978 & ( 0.78*x + y*hwventy(mgs) ) ! &
18979! & 0.308*fvent(mgs)*y*(xdia(mgs,lh,1)**(0.5 + 0.5*bxx(mgs,lh)))* &
18980! & Sqrt(axx(mgs,lh)*rhovt(mgs)) )
18981
18982 ENDIF
18983 ELSE
18984 hwvent(mgs) = 0.0
18985 hwventy(mgs) = 0.0
18986 ENDIF
18987 end do
18988
18989
18990 hlvent(:) = 0.0
18991 hlventy(:) = 0.0
18992
18993 IF ( lhl .gt. 1 ) THEN
18994 igmhwa = 100.0*2.0
18995 igmhwb = 100.0*2.75
18996 hwventa = (0.78)*gmoi(igmhwa)
18997 hwventb = (0.308)*gmoi(igmhwb)
18998! hwventc = (4.0*gr/(3.0*cdx(lhl)))**(0.25)
18999 do mgs = 1,ngscnt
19000 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
19001 hwventc = (4.0*gr/(3.0*cdxgs(mgs,lhl)))**(0.25)
19002
19003 IF ( .false. .or. alpha(mgs,lhl) .eq. 0.0 ) THEN
19004 hlvent(mgs) = &
19005 & ( hwventa + hwventb*hwventc*fvent(mgs) &
19006 & *((xdn(mgs,lhl)/rho0(mgs))**(0.25)) &
19007 & *(xdia(mgs,lhl,1)**(0.75)))
19008 ELSE ! Ferrier 1994, eq. B.36
19009 ! linear interpolation of complete gamma function
19010! tmp = 2. + alpha(mgs,lhl)
19011! i = Int(dgami*(tmp))
19012! del = tmp - dgam*i
19013! x = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
19014
19015! note that hlvent includes a division by Gamma(1+alpha), so x = Gamma(2+alpha)/Gamma(1+alpha) = 1 + alpha
19016! and g1palp = Gamma(1+alpha) divides into y
19017
19018 x = 1. + alpha(mgs,lhl)
19019
19020 tmp = 1 + alpha(mgs,lhl)
19021 i = int(dgami*(tmp))
19022 del = tmp - dgam*i
19023 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
19024
19025 tmp = 2.5 + alpha(mgs,lhl) + 0.5*bxx(mgs,lhl)
19026 i = int(dgami*(tmp))
19027 del = tmp - dgam*i
19028 y = (gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami)/g1palp ! ratio of gamma functions
19029
19030 hlventy(mgs) = 0.308*fvent(mgs)*(xdia(mgs,lhl,1)**(0.5 + 0.5*bxx(mgs,lhl)))*sqrt(axx(mgs,lhl)*rhovt(mgs))
19031
19032 hlvent(mgs) = 0.78*x + y*hlventy(mgs) ! &
19033! & 0.308*fvent(mgs)*y*(xdia(mgs,lhl,1)**(0.5 + 0.5*bxx(mgs,lhl)))* &
19034! & Sqrt(axx(mgs,lhl)*rhovt(mgs)))
19035! : Sqrt(xdn(mgs,lhl)*ax(lhl)*rhovt(mgs)/rg0))/tmp
19036
19037 ENDIF
19038 ENDIF
19039 end do
19040 ENDIF
19041
19042!
19043!
19044!
19045! Wet growth constants
19046!
19047 do mgs = 1,ngscnt
19048 fwet1(mgs) = &
19049 & (2.0*pi)* &
19050 & ( felv(mgs)*fwvdf(mgs)*rho0(mgs)*(qss0(mgs)-qx(mgs,lv)) &
19051 & -ftka(mgs)*temcg(mgs) ) &
19052 & / ( rho0(mgs)*(felf(mgs)+fcw(mgs)*temcg(mgs)) )
19053 fwet2(mgs) = &
19054 & (1.0)-fci(mgs)*temcg(mgs) &
19055 & / ( felf(mgs)+fcw(mgs)*temcg(mgs) )
19056 end do
19057!
19058! Melting constants
19059!
19060 do mgs = 1,ngscnt
19061 fmlt1(mgs) = (2.0*pi)* &
19062 & ( felv(mgs)*fwvdf(mgs)*(qss0(mgs)-qx(mgs,lv)) &
19063 & -ftka(mgs)*temcg(mgs)/rho0(mgs) ) &
19064 & / (felf(mgs))
19065 fmlt2(mgs) = -fcw(mgs)*temcg(mgs)/felf(mgs)
19066 fmlt1e(mgs) = (2.0*pi)* &
19067 & ( felv(mgs)*fwvdf(mgs)*(qss0(mgs)-qx(mgs,lv)) ) / (felf(mgs))
19068 end do
19069!
19070! Vapor Deposition constants
19071!
19072 do mgs = 1,ngscnt
19073 fvds(mgs) = &
19074 & (4.0*pi/rho0(mgs))*(ssi(mgs)-1.0)* &
19075 & (1.0/(fai(mgs)+fbi(mgs)))
19076 end do
19077 do mgs = 1,ngscnt
19078 fvce(mgs) = &
19079 & (4.0*pi/rho0(mgs))*(ssw(mgs)-1.0)* &
19080 & (1.0/(fav(mgs)+fbv(mgs)))
19081 end do
19082
19083!
19084! deposition, sublimation, and melting of snow, graupel and hail
19085!
19086 qsmlr(:) = 0.0
19087 qimlr(:) = 0.0 ! this is not used. qi melts to qc way down in the code.
19088 qhmlr(:) = 0.0
19089 qhlmlr(:) = 0.0
19090 IF ( lhwlg > 1 ) THEN
19091 qhmlrlg(:) = 0.0
19092 qhlmlrlg(:) = 0.0
19093 ENDIF
19094 qhfzh(:) = 0.0
19095 qffzf(:) = 0.0
19096 qhlfzhl(:) = 0.0
19097 qhfzhlg(:) = 0.0
19098 qhlfzhllg(:) = 0.0
19099 vhfzh(:) = 0.0
19100 vffzf(:) = 0.0
19101 vhlfzhl(:) = 0.0
19102 qsfzs(:) = 0.0
19103! zsmlr(:) = 0.0
19104 zhmlr(:) = 0.0
19105 zhmlrr(:) = 0.0
19106 zsmlrr(:) = 0.0
19107 zhshr(:) = 0.0
19108 zhlmlr(:) = 0.0
19109 zhlshr(:) = 0.0
19110
19111 zhshrr(:) = 0.0
19112 zhlmlrr(:) = 0.0
19113 zhlshrr(:) = 0.0
19114
19115 csmlr(:) = 0.0
19116 csmlrr(:) = 0.0
19117 chmlr(:) = 0.0
19118 chmlrr(:) = 0.0
19119 chlmlr(:) = 0.0
19120 chlfmlr(:) = 0.0
19121! chlmlrsave(:) = 0.0
19122! qhlmlrsave(:) = 0.0
19123! chlsave(:) = 0.0
19124! qhlsave(:) = 0.0
19125 chlmlrr(:) = 0.0
19126
19127
19128 if ( .not. mixedphase ) then !{
19129 do mgs = 1,ngscnt
19130!
19131 IF ( temg(mgs) .gt. tfr ) THEN
19132
19133 IF ( qx(mgs,ls) .gt. qxmin(ls) ) THEN
19134 qsmlr(mgs) = &
19135 & min( &
19136 & (c1sw*fmlt1(mgs)*cx(mgs,ls)*swvent(mgs)*xdia(mgs,ls,1) ) & ! /rhosm &
19137 & , 0.0 )
19138 ENDIF
19139
19140
19141! IF ( qx(mgs,ls) .gt. 0.1e-4 ) write(0,*) 'qsmlr: ',qsmlr(mgs),qx(mgs,ls),cx(mgs,ls),fmlt1(mgs),
19142! : temcg(mgs),swvent(mgs),xdia(mgs,ls,1),qss0(mgs)-qx(mgs,lv)
19143! ELSE
19144! qsmlr(mgs) = 0.0
19145! ENDIF
19146! 10ice version:
19147! > min(
19148! > (fmlt1(mgs)*cx(mgs,ls)*swvent(mgs)*xdia(mgs,ls,1) +
19149! > fmlt2(mgs)*(qsacr(mgs)+qsacw(mgs)) )
19150! < , 0.0 )
19151
19152 IF ( qx(mgs,lh) .gt. qxmin(lh) ) THEN
19153
19154 IF ( ibinhmlr == 0 .or. lzh < 1 ) THEN
19155 qhmlr(mgs) = &
19156 & meltfac*min( &
19157 & fmlt1(mgs)*cx(mgs,lh)*hwvent(mgs)*xdia(mgs,lh,1) &
19158 & + fmlt2(mgs)*(qhacrmlr(mgs)+qhacwmlr(mgs)) &
19159 & , 0.0 )
19160 ELSEIF ( ibinhmlr == 1 ) THEN ! use incomplete gamma functions to approximate the bin results
19161
19162 errmsg = 'ibinhmlr = 1 not available for 2-moment'
19163 errflg = 1
19164 RETURN
19165
19166 ELSEIF ( ibinhmlr == 2 .or. ibinhmlr == 3 ) THEN
19167
19168 ENDIF
19169
19170
19171 IF ( ivhmltsoak > 0 .and. qhmlr(mgs) < 0.0 .and. lvol(lh) > 1 .and. xdn(mgs,lh) .lt. xdnmx(lh) ) THEN
19172 ! act as if 100% of the meltwater were soaked into the graupel
19173 v1 = (1. - xdn(mgs,lh)/xdnmx(lh))*(vx(mgs,lh) + rho0(mgs)*qhmlr(mgs)/xdn(mgs,lh) )/(dtp) ! volume available for filling
19174 v2 = -1.0*rho0(mgs)*qhmlr(mgs)/xdnmx(lh) ! volume of melted ice if it were refrozen in the matrix
19175
19176 vhsoak(mgs) = min(v1,v2)
19177
19178 ENDIF
19179
19180 ENDIF ! qx(mgs,lh) .gt. qxmin(lh)
19181
19182
19183 IF ( lhl .gt. 1 .and. lhlw < 1 ) THEN
19184
19185 IF ( qx(mgs,lhl) .gt. qxmin(lhl) ) THEN
19186 IF ( ibinhlmlr == 0 .or. lzhl < 1) THEN
19187 qhlmlr(mgs) = &
19188 & meltfac*min( &
19189 & fmlt1(mgs)*cx(mgs,lhl)*hlvent(mgs)*xdia(mgs,lhl,1) &
19190 & + fmlt2(mgs)*(qhlacrmlr(mgs)+qhlacwmlr(mgs)) &
19191 & , 0.0 )
19192
19193 ELSEIF ( ibinhlmlr == 1 ) THEN ! use incomplete gamma functions to approximate the bin results
19194
19195
19196 ELSEIF ( ibinhlmlr == -1 ) THEN ! OLD VERSION use incomplete gamma functions to approximate the bin results
19197
19198 ENDIF ! ibinhlmlr
19199
19200
19201 IF ( ivhmltsoak > 0 .and. qhlmlr(mgs) < 0.0 .and. lvol(lhl) > 1 .and. xdn(mgs,lhl) .lt. xdnmx(lhl) ) THEN
19202 ! act as if 50% of the meltwater were soaked into the graupel
19203 v1 = (1. - xdn(mgs,lhl)/xdnmx(lhl))*(vx(mgs,lhl) + rho0(mgs)*qhlmlr(mgs)/xdn(mgs,lhl) )/(dtp) ! volume available for filling
19204 v2 = -1.0*rho0(mgs)*qhlmlr(mgs)/xdnmx(lhl) ! volume of melted ice if it were refrozen in the matrix
19205
19206 vhlsoak(mgs) = min(v1,v2)
19207
19208 ENDIF
19209
19210 ENDIF
19211 ENDIF
19212
19213 ENDIF
19214
19215!
19216! qimlr(mgs) = max( qimlr(mgs), -qimxd(mgs) )
19217! qsmlr(mgs) = max( qsmlr(mgs), -qsmxd(mgs) )
19218! erm 5/10/2007 changed to next line:
19219 if ( .not. mixedphase ) qsmlr(mgs) = max( qsmlr(mgs), min( -qsmxd(mgs), -0.7*qx(mgs,ls)*dtpinv ) )
19220 IF ( .not. mixedphase ) THEN
19221 qhmlr(mgs) = max( qhmlr(mgs), min( -qhmxd(mgs), -0.95*qx(mgs,lh)*dtpinv ) )
19222 chmlr(mgs) = max( chmlr(mgs), min( -chmxd(mgs), -0.95*cx(mgs,lh)*dtpinv ) )
19223 ENDIF
19224! qhmlr(mgs) = max( max( qhmlr(mgs), -qhmxd(mgs) ) , -0.5*qx(mgs,lh)*dtpinv ) !limits to 1/2 qh or max depletion
19225 qhmlh(mgs) = 0. ! not used
19226
19227
19228 ! Rasmussen and Heymsfield say melt water remains on graupel up to 9 mm before shedding
19229
19230
19231 IF ( lhl .gt. 1 .and. lhlw < 1 ) THEN
19232 qhlmlr(mgs) = max( qhlmlr(mgs), min( -qxmxd(mgs,lhl), -0.95*qx(mgs,lhl)*dtpinv ) )
19233 chlmlr(mgs) = max( chlmlr(mgs), min( -cxmxd(mgs,lhl), -0.95*cx(mgs,lhl)*dtpinv ) )
19234 ENDIF
19235
19236!
19237 end do
19238
19239 endif ! } not mixedphase
19240!
19241 if ( ipconc .ge. 1 ) then
19242 do mgs = 1,ngscnt
19243 cimlr(mgs) = (cx(mgs,li)/(qx(mgs,li)+1.e-20))*qimlr(mgs)
19244 IF ( .not. mixedphase ) THEN !{
19245 IF ( xdia(mgs,ls,1) .gt. 1.e-6 .and. -qsmlr(mgs) .ge. 0.5*qxmin(ls) .and. ipconc .ge. 4 ) THEN
19246! csmlr(mgs) = rho0(mgs)*qsmlr(mgs)/(xv(mgs,ls)*rhosm)
19247 csmlr(mgs) = (cx(mgs,ls)/(qx(mgs,ls)))*qsmlr(mgs)
19248 ELSEIF ( qx(mgs,ls) > qxmin(ls) ) THEN
19249 csmlr(mgs) = (cx(mgs,ls)/(qx(mgs,ls)))*qsmlr(mgs)
19250 ENDIF
19251
19252 csmlrr(mgs) = csmlr(mgs)/rzxs(mgs)
19253 IF ( -csmlrr(mgs)*dtp > cxmin .and. -qsmlr(mgs)*dtp > qxmin(lr) .and. snowmeltdia > 0.0 ) THEN
19254 rmas = rho0(mgs)*qsmlr(mgs)/csmlrr(mgs)
19255 IF ( rmas > snowmeltmass ) THEN
19256 csmlrr(mgs) = rho0(mgs)*qsmlr(mgs)/snowmeltmass
19257 ENDIF
19258 ENDIF
19259
19260
19261
19262! IF ( xdia(mgs,lh,1) .gt. 1.e-6 .and. Abs(qhmlr(mgs)) .ge. qxmin(lh) ) THEN
19263! chmlr(mgs) = rho0(mgs)*qhmlr(mgs)/(pi*xdn(mgs,lh)*xdia(mgs,lh,1)**3) ! out of hail
19264! chmlr(mgs) = Max( chmlr(mgs), -chmxd(mgs) )
19265! ELSE
19266 IF ( ibinhmlr == 0 .or. lzh < 1 ) THEN
19267 chmlr(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhmlr(mgs)
19268 IF ( imltshddmr == 3 .and. qhmlr(mgs) < -qxmin(lh) ) THEN
19269 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
19270 !
19271 ! IF ( tmpdiam > sheddiam ) THEN ! let size get smaller until it reaches sheddiam
19272 ! chmlr(mgs) = 0.0
19273 ! ENDIF
19274
19275 ! test to remove the part of the melting associated with large ice particles so they get smaller
19276
19277 tmp = 1. + alpha(mgs,lh)
19278 i = int(dgami*(tmp))
19279 del = tmp - dgam*i
19280 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
19281
19282 ratio = min( maxratiolu, mltdiam1/xdia(mgs,lh,1) )
19283
19284 x = gamxinfdp(2. + alpha(mgs,lh), ratio)/g1palp
19285 y = gamxinfdp(2.5 + alpha(mgs,lh) + 0.5*bxx(mgs,lh), ratio)/g1palp
19286
19287 hwvent1 = 0.78*x + y*hwventy(mgs)
19288
19289 qhlmlr1 = min( fmlt1(mgs)*cx(mgs,lh)*hwvent1*xdia(mgs,lh,1), 0.0 )
19290
19291 chmlr(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*(qhmlr(mgs) - qhlmlr1)
19292
19293
19294 ENDIF
19295! IF ( igs(mgs) == 40 ) THEN
19296! write(0,*) 'is this running? chmlr = ',kgs(mgs), chmlr(mgs)
19297! ENDIF
19298 ENDIF
19299! ENDIF
19300
19301
19302 IF ( chmlr(mgs) < 0.0 .and. (ibinhmlr < 1 .or. lzh < 1) ) THEN ! { already done if ibinhmlr > 0
19303 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
19304 tmp = qx(mgs,lh)/cx(mgs,lh)
19305 alp = alpha(mgs,lh)
19306 g1 = g1x(mgs,lh) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
19307
19308 zhmlr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*tmp * qhmlr(mgs) - tmp**2 * chmlr(mgs) )
19309
19310 ENDIF
19311
19312 IF ( ibinhmlr == 0 .or. lzh < 1 ) THEN
19313 IF ( ihmlt .eq. 1 ) THEN
19314 chmlrr(mgs) = min( chmlr(mgs), rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*vmlt) ) ! into rain
19315 ELSEIF ( ihmlt .eq. 2 ) THEN
19316 IF ( xv(mgs,lh) .gt. 0.0 .and. chmlr(mgs) .lt. 0.0 ) THEN
19317! chmlrr(mgs) = Min( chmlr(mgs), rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lh)*xv(mgs,lh)) ) ! into rain
19318! guess what, this is the same as chmlr: rho0*qhmlr/xmas(lh) --> cx/qx = rho0/xmas
19319 IF(imltshddmr == 1) THEN
19320 ! DTD: If Dmg < sheddiam, then assume complete melting into
19321 ! maximal raindrop. Between sheddiam and sheddiam0 mm, linearly ramp down to a 3 mm shed drop
19322 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
19323 tmp2 = -rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*vr3mm) ! conc. change for a 3 mm mean drop diameter
19324
19325 chmlrr(mgs) = tmp*(sheddiam0-xdia(mgs,lh,3))/(sheddiam0-sheddiam)+tmp2*(xdia(mgs,lh,3)-sheddiam)/(sheddiam0-sheddiam) ! old version
19326 chmlrr(mgs) = -max(tmp,min(tmp2,chmlrr(mgs)))
19327 ELSEIF ( imltshddmr == 2 .or. imltshddmr == 3 ) THEN
19328 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
19329 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
19330 chmlrr(mgs) = rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lh)) ! into rain
19331 ELSE ! Old method
19332 chmlrr(mgs) = rho0(mgs)*qhmlr(mgs)/(min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lh)*xv(mgs,lh))) ! into rain
19333 ENDIF
19334 ELSE
19335 chmlrr(mgs) = chmlr(mgs)
19336 ENDIF
19337 ELSEIF ( ihmlt .eq. 0 ) THEN
19338 chmlrr(mgs) = chmlr(mgs)
19339 ENDIF
19340
19341 ELSE ! ibinhmlr < 0? Already have an outer IF test for ibinhmlr < 1
19342 chmlrr(mgs) = min( chmlrr(mgs), rho0(mgs)*qhmlr(mgs)/(xdn(mgs,lr)*xvmx(lr)) ) ! into rain
19343 ENDIF
19344
19345 ENDIF ! } ( chmlr(mgs) < 0.0 .and. ibinhmlr < 1)
19346
19347 IF ( lhl .gt. 1 .and. lhlw < 1 .and. .not. mixedphase .and. qhlmlr(mgs) < 0.0 ) THEN ! {
19348
19349 IF ( ibinhlmlr == 0 .or. lzhl < 1 ) THEN
19350! IF ( xdia(mgs,lhl,1) .gt. 1.e-6 .and. Abs(qhlmlr(mgs)) .ge. qxmin(lhl) ) THEN
19351! chlmlr(mgs) = rho0(mgs)*qhlmlr(mgs)/(pi*xdn(mgs,lhl)*xdia(mgs,lhl,1)**3) ! out of hail
19352! chlmlr(mgs) = Max( chlmlr(mgs), -cxmxd(mgs,lhl) )
19353! ELSE
19354 chlmlr(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlmlr(mgs)
19355 IF ( imltshddmr == 3 .and. qhlmlr(mgs) < -qxmin(lhl) ) THEN
19356! IF ( .false. .and. imltshddmr == 3 ) THEN
19357! tmpdiam = (shedalp+alpha(mgs,lhl))*xdia(mgs,lhl,1)
19358!
19359! IF ( tmpdiam > sheddiam ) THEN ! let size get smaller until it reaches sheddiam
19360! chlmlr(mgs) = 0.0
19361! ENDIF
19362
19363 ! test to remove the part of the melting associated with large ice particles so they get smaller
19364!
19365 tmp = 1. + alpha(mgs,lhl)
19366 i = int(dgami*(tmp))
19367 del = tmp - dgam*i
19368 g1palp = gmoi(i) + (gmoi(i+1) - gmoi(i))*del*dgami
19369
19370 ratio = min( maxratiolu, mltdiam1/xdia(mgs,lhl,1) )
19371
19372 x = gamxinfdp(2. + alpha(mgs,lhl), ratio)/g1palp
19373 y = gamxinfdp(2.5 + alpha(mgs,lhl) + 0.5*bxx(mgs,lhl), ratio)/g1palp
19374
19375 hwvent1 = 0.78*x + y*hlventy(mgs)
19376
19377 qhlmlr1 = min( fmlt1(mgs)*cx(mgs,lhl)*hwvent1*xdia(mgs,lhl,1), 0.0 )
19378
19379 chlmlr(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*min(0.0, qhlmlr(mgs) - qhlmlr1)
19380
19381 ENDIF
19382! ENDIF
19383 ENDIF
19384
19385 IF ( ibinhlmlr == 0 .or. lzhl < 1 ) THEN !{
19386 IF ( ihmlt .eq. 1 ) THEN
19387 chlmlrr(mgs) = min( chlmlr(mgs), rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*vmlt) ) ! into rain
19388 ELSEIF ( ihmlt .eq. 2 ) THEN
19389 IF ( xv(mgs,lhl) .gt. 0.0 .and. chlmlr(mgs) .lt. 0.0 ) THEN
19390! chlmlrr(mgs) = rho0(mgs)*qhlmlr(mgs)/(Min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lhl)*xv(mgs,lhl))) ! into rain
19391! chlmlrr(mgs) = Min( chlmlr(mgs), rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lhl)*xv(mgs,lhl)) ) ! into rain
19392 IF(imltshddmr == 1 ) THEN
19393 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
19394 tmp2 = -rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*vr3mm) ! conc. change for a 3 mm mean drop diameter
19395 chlmlrr(mgs) = tmp*(20.e-3-xdia(mgs,lhl,3))/(20.e-3-sheddiam)+tmp2*(xdia(mgs,lhl,3)-sheddiam)/(20.e-3-sheddiam)
19396 chlmlrr(mgs) = -max(tmp,min(tmp2,chlmlrr(mgs)))
19397 ELSEIF ( imltshddmr == 2 .or. imltshddmr == 3 ) THEN
19398 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
19399 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
19400 chlmlrr(mgs) = rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lhl)) ! into rain
19401 ELSE ! old method
19402 chlmlrr(mgs) = rho0(mgs)*qhlmlr(mgs)/(min(xdn(mgs,lr)*xvmx(lr), xdn(mgs,lhl)*xv(mgs,lhl))) ! into rain
19403 ENDIF
19404 ELSE
19405 chlmlrr(mgs) = chlmlr(mgs)
19406 ENDIF
19407 ELSEIF ( ihmlt .eq. 0 ) THEN
19408 chlmlrr(mgs) = chlmlr(mgs)
19409 ENDIF
19410
19411 ELSE ! } { ibinhlmlr > 0
19412 chlmlrr(mgs) = min( chlmlrr(mgs), rho0(mgs)*qhlmlr(mgs)/(xdn(mgs,lr)*xvmx(lr)) ) ! into rain
19413 ENDIF !}
19414
19415
19416 IF ( ipconc >= 8 .and. lzhl .gt. 1 .and. ibinhlmlr <= 0 ) THEN
19417 IF ( cx(mgs,lhl) > 0.0 ) THEN
19418
19419 tmp = qx(mgs,lhl)/cx(mgs,lhl)
19420 alp = alpha(mgs,lhl)
19421! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
19422 g1 = g1x(mgs,lhl) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
19423
19424 zhlmlr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( tmp * qhlmlr(mgs) )
19425 ENDIF
19426 ENDIF
19427 ENDIF ! }
19428
19429 ENDIF ! }.not. mixedphase
19430
19431! 10ice versions:
19432! chmlr(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhmlr(mgs)
19433! chmlrr(mgs) = chmlr(mgs)
19434 end do
19435 end if
19436
19437!
19438! deposition/sublimation of ice
19439!
19440 DO mgs = 1,ngscnt
19441
19442 rwcap(mgs) = (0.5)*xdia(mgs,lr,1)
19443 swcap(mgs) = (0.5)*xdia(mgs,ls,1)
19444 hwcap(mgs) = (0.5)*xdia(mgs,lh,1)
19445 IF ( lhl .gt. 1 ) hlcap(mgs) = (0.5)*xdia(mgs,lhl,1)
19446
19447 if ( qx(mgs,li).gt.qxmin(li) .and. xdia(mgs,li,1) .gt. 0.0 ) then
19448!
19449! from Cotton, 1972 (Part II)
19450!
19451 cilen(mgs) = 0.4764*(xdia(mgs,li,1))**(0.958)
19452 cval = xdia(mgs,li,1)
19453 aval = cilen(mgs)
19454 eval = sqrt(1.0-(aval**2)/(cval**2))
19455 fval = min(0.99,eval)
19456 gval = alog( abs( (1.+fval)/(1.-fval) ) )
19457 cicap(mgs) = cval*fval / gval
19458 ELSE
19459 cicap(mgs) = 0.0
19460 end if
19461 ENDDO
19462!
19463!
19464 qhdsv(:) = 0.0
19465 qhldsv(:) = 0.0
19466
19467 do mgs = 1,ngscnt
19468 IF ( icond .eq. 1 .or. temg(mgs) .le. tfrh &
19469 & .or. (qx(mgs,lr) .le. qxmin(lr) .and. qx(mgs,lc) .le. qxmin(lc)) ) THEN
19470 qidsv(mgs) = &
19471 & fvds(mgs)*cx(mgs,li)*civent(mgs)*cicap(mgs)*depfac
19472 qsdsv(mgs) = &
19473 & fvds(mgs)*cx(mgs,ls)*swvent(mgs)*swcap(mgs)*depfac
19474
19475! IF ( ny .eq. 2 .and. igs(mgs) .eq. 302 .and. temg(mgs) .le. tfrh+10 .and. qx(mgs,lv) .gt. qis(mgs)
19476! : .and. qx(mgs,li) .gt. qxmin(li) ) THEN
19477! write(0,*) 'qidsv = ',nstep,kgs(mgs),qidsv(mgs),temg(mgs)-tfrh,100.*(qx(mgs,lv)/qis(mgs) - 1.),1.e6*xdia(mgs,li,1),
19478! : fvds(mgs),civent(mgs),cicap(mgs)
19479! ENDIF
19480 ELSE
19481 qidsv(mgs) = 0.0
19482 qsdsv(mgs) = 0.0
19483 ENDIF
19484 qhdsv(mgs) = &
19485 & fvds(mgs)*cx(mgs,lh)*hwvent(mgs)*hwcap(mgs)*depfac
19486
19487 IF ( lhl .gt. 1 ) qhldsv(mgs) = fvds(mgs)*cx(mgs,lhl)*hlvent(mgs)*hlcap(mgs)*depfac
19488!
19489!
19490 end do
19491!
19492
19493
19494! #include "nssl.qlimit.F"
19495
19496!
19497! Use a test saturation adjustment to set limits on ice deposition/sublimation
19498! and rain evaporation
19499!
19500!
19501 IF ( dosublimationfix ) THEN
19502
19503 do mgs = 1,ngscnt
19504
19505 qitmp(mgs) = qx(mgs,li) + qx(mgs,ls) + qx(mgs,lh)
19506 IF ( lis > 1 ) qitmp(mgs) = qitmp(mgs) + qx(mgs,lis)
19507 IF ( lhl > 1 ) qitmp(mgs) = qitmp(mgs) + qx(mgs,lhl)
19508 qrtmp(mgs) = qx(mgs,lr)
19509 qctmp(mgs) = qx(mgs,lc)
19510 qsimxdep(mgs) = 0.0
19511 qsimxsub(mgs) = 0.0
19512 dqcitmp(mgs) = 0.0
19513
19514
19515! IF ( ( qitmp(mgs) > qxmin(li) .or. qrtmp(mgs) > qxmin(lr) ) ) THEN
19516 IF ( qitmp(mgs) > qxmin(li) ) THEN
19517
19518 qitmp1 = qitmp(mgs)
19519 qctmp1 = qctmp(mgs)
19520 felvcptmp = felvcp(mgs)
19521 felscptmp = felscp(mgs)
19522 qvtmp(mgs) = qx(mgs,lv)
19523 qss(mgs) = qvs(mgs)
19524 qsstmp = qvs(mgs)
19525 qvstmp = qvs(mgs)
19526 qisstmp = qis(mgs)
19527 thetatmp = theta(mgs)
19528 thetaptmp = thetap(mgs)
19529 temgtmp = temg(mgs)
19530 temcgtmp = temcg(mgs)
19531 qvaptmp = qx(mgs,lv) ! qwvp(mgs) + qv0(mgs)
19532 qvptmp = 0.0 ! qwvp(mgs) ! qv pertubation
19533
19534 qsstmp = qisstmp
19535
19536
19537 dqwvtmp(mgs) = ( qvtmp(mgs) - qsstmp )
19538
19539 do itertd = 1,2
19540
19541!
19542! calculate super-saturation
19543!
19544 IF ( itertd == 1 ) THEN
19545
19546 ELSE
19547 dqcitmp(mgs) = dqci(mgs)
19548 ! dqwvtmp(mgs) = dqwv(mgs)
19549 ENDIF
19550
19551 dqcw(mgs) = 0.0
19552 dqci(mgs) = 0.0
19553 dqwv(mgs) = ( qvtmp(mgs) - qsstmp )
19554!
19555! evaporation and sublimation adjustment
19556!
19557 if( dqwv(mgs) .lt. 0. ) then ! { subsaturated
19558 if( qitmp(mgs) .gt. -dqwv(mgs) ) then ! check if qi can make up all the deficit
19559 dqci(mgs) = dqwv(mgs)
19560 dqwv(mgs) = 0.
19561 else ! otherwise make all ice available for sublimation
19562 dqci(mgs) = -qitmp(mgs)
19563 dqwv(mgs) = dqwv(mgs) + qitmp(mgs)
19564 end if
19565!
19566 qvptmp = qvptmp - ( dqcw(mgs) + dqci(mgs) ) ! add to perturbation vapor
19567
19568 IF ( itertd == 2 .and. eqtset > 1 ) THEN
19569 ! if eqtset == 2, then need to update the latent heats for change in hydrometeor content
19570 tmp = qitmp(mgs) !+ qx(mgs,lh)
19571! IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
19572 cvm = cv+cvv*qvtmp(mgs)+cpl*(qx(mgs,lc)+qrtmp(mgs)) &
19573 +cpigb*(tmp)
19574
19575 felvcptmp = (felv(mgs)-rw*temg(mgs))/cvm
19576 felscptmp = (fels(mgs)-rw*temg(mgs))/cvm
19577 ENDIF
19578
19579
19580! qitmp(mgs) = qx(mgs,li)
19581 qctmp(mgs) = qctmp(mgs) + dqcw(mgs) ! dqcw is zero
19582 qitmp(mgs) = qitmp(mgs) + dqci(mgs)
19583 thetaptmp = thetaptmp + &
19584 & 1./pi0(mgs)* &
19585 & (felvcp(mgs)*dqcw(mgs) +felscp(mgs)*dqci(mgs))
19586
19587
19588 end if ! } dqwv(mgs) .lt. 0. (end of evap/sublim)
19589!
19590! condensation/deposition
19591!
19592 IF ( dqwv(mgs) .ge. 0. ) THEN ! {
19593
19594! write(iunit,*) 'satadj: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qx(mgs,lv),qx(mgs,lc)
19595!
19596! qitmp(mgs) = qx(mgs,li)
19597 fracl(mgs) = 0.0
19598 fraci(mgs) = 1.0
19599 if ( temg(mgs) .lt. tfr .and. temg(mgs) .gt. thnuc ) then
19600! fracl(mgs) = max(min(1.,(temg(mgs)-233.15)/(20.)),0.0)
19601! fraci(mgs) = 1.0-fracl(mgs)
19602 end if
19603 if ( temg(mgs) .le. thnuc ) then
19604 fraci(mgs) = 1.0
19605 fracl(mgs) = 0.0
19606 end if
19607! fraci(mgs) = 1.0-fracl(mgs)
19608
19609 gamss = (felvcp(mgs)*fracl(mgs) + felscp(mgs)*fraci(mgs)) &
19610 & / (pi0(mgs))
19611
19612 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv2(mgs)*qsstmp/ &
19613 & ((temg(mgs)-cbi)**2))
19614
19615 if ( temg(mgs) .ge. tfr ) then
19616 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qsstmp/ &
19617 & ((temg(mgs)-cbw)**2))
19618 end if
19619
19620 delqci1=qx(mgs,li)
19621
19622
19623 dqcw(mgs) = dqvcnd(mgs)*fracl(mgs) ! is zero
19624 dqci(mgs) = dqvcnd(mgs)*fraci(mgs)
19625
19626 thetaptmp = thetaptmp + &
19627 & (felvcp(mgs)*dqcw(mgs) + felscp(mgs)*dqci(mgs)) &
19628 & / (pi0(mgs))
19629
19630 qvptmp = qvptmp - ( dqvcnd(mgs) )
19631 qctmp(mgs) = qctmp(mgs) + dqcw(mgs)
19632 qitmp(mgs) = qitmp(mgs) + dqci(mgs)
19633
19634 IF ( itertd == 2 .and. eqtset > 1 ) THEN
19635 ! if eqtset == 2, then need to update the latent heats for change in hydrometeor content
19636 tmp = qitmp(mgs) ! + qx(mgs,lh)
19637! IF ( lhl > 1 ) tmp = tmp + qx(mgs,lhl)
19638 cvm = cv+cvv*qvtmp(mgs)+cpl*(qctmp(mgs) +qrtmp(mgs)) &
19639 +cpigb*(tmp)
19640
19641 felvcptmp = (felv(mgs)-rw*temg(mgs))/cvm
19642 felscptmp = (fels(mgs)-rw*temg(mgs))/cvm
19643 ENDIF
19644
19645! IF ( eqtset > 2 ) THEN
19646! pipert(mgs) = pipert(mgs) + (0 &
19647! & +felspi(mgs)*dqci(mgs) &
19648! & +felvpi(mgs)*dqcw(mgs)) ! *dtp
19649! ENDIF
19650
19651!
19652!
19653 END IF ! } dqwv(mgs) .ge. 0.
19654
19655
19656!
19657 IF ( itertd == 1 ) THEN
19658 ! update temporary saturation values
19659
19660 thetatmp = thetaptmp + theta0(mgs)
19661 temgtmp = thetatmp*pk(mgs) ! ( pres(mgs) / poo ) ** cap
19662 qvaptmp = max((qvptmp + qv0(mgs)), 0.0)
19663 temcgtmp = temgtmp - tfr
19664 tqvcon = temgtmp-cbw
19665 ltemq = (temgtmp-163.15)/fqsat+1.5
19666 ltemq = min( nqsat, max(1,ltemq) )
19667
19668 IF ( iqvsopt == 0 ) THEN
19669 qvstmp = pqs(mgs)*tabqvs(ltemq)
19670 ELSEIF ( iqvsopt == 1 ) THEN
19671 qvstmp = rdorv*esbolton*tabqvs(ltemq)/(pres(mgs) - esbolton*tabqvs(ltemq))
19672 ENDIF
19673
19674 qisstmp = pqs(mgs)*tabqis(ltemq)
19675 qctmp(mgs) = max( 0.0, qctmp(mgs) )
19676 qitmp(mgs) = max( 0.0, qitmp(mgs) )
19677 qvtmp(mgs) = max( 0.0, qvaptmp )
19678
19679! qsstmp = qvstmp
19680 qsstmp = qisstmp
19681
19682 ELSE
19683 ! set max depletion
19684 qctmp(mgs) = max( 0.0, qctmp(mgs) )
19685 qitmp(mgs) = max( 0.0, qitmp(mgs) )
19686
19687 IF ( qitmp(mgs) < qitmp1 ) THEN
19688 qsimxsub(mgs) = (qitmp1 - qitmp(mgs))*dtpinv
19689 ELSEIF ( qitmp(mgs) > qitmp1 ) THEN
19690 qsimxdep(mgs) = (qitmp(mgs) - qitmp1)*dtpinv
19691 ENDIF
19692
19693
19694 ENDIF
19695! pceds(mgs) = (thetap(mgs) - thsave(mgs))*dtpinv
19696! write(iunit,*) 'satadj2: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qxtmp,qctmp(mgs)
19697!
19698! end the saturation adjustment iteration loop
19699!
19700 end do ! itertd
19701
19702 ENDIF
19703
19704 end do ! mgs
19705
19706 ELSE
19707
19708 DO mgs = 1,ngscnt
19709 qsimxdep(mgs) = qvimxd(mgs)
19710 qsimxsub(mgs) = 1.e20
19711 ENDDO
19712
19713 ENDIF
19714
19715! end of qlimit
19716
19717 qhcev(:) = 0.0
19718 chcev(:) = 0.0
19719 qhlcev(:) = 0.0
19720 chlcev(:) = 0.0
19721 qfcev(:) = 0.0
19722
19723 do mgs = 1,ngscnt
19724 qisbv(mgs) = 0.0
19725 qssbv(mgs) = 0.0
19726 qidpv(mgs) = 0.0
19727 qsdpv(mgs) = 0.0
19728 qhsbv(mgs) = 0.0
19729 qscev(mgs) = 0.0
19730 cscev(mgs) = 0.0
19731 IF ( icond .eq. 1 .or. temg(mgs) .le. tfrh &
19732 & .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
19733! qisbv(mgs) = max( min(qidsv(mgs), 0.0), -qimxd(mgs) )
19734! qssbv(mgs) = max( min(qsdsv(mgs), 0.0), -qsmxd(mgs) )
19735! erm 5/10/2007:
19736 qisbv(mgs) = max( min(qidsv(mgs), 0.0), min( -qimxd(mgs), -0.5*qx(mgs,li)*dtpinv ) )
19737 IF ( temg(mgs) < tfr .or. .not. qsmlr(mgs) < 0.0 ) THEN
19738 qssbv(mgs) = max( min(qsdsv(mgs), 0.0), min( -qsmxd(mgs), -0.5*qx(mgs,ls)*dtpinv ) )
19739 ENDIF
19740 qidpv(mgs) = max(qidsv(mgs), 0.0)
19741 qsdpv(mgs) = max(qsdsv(mgs), 0.0)
19742
19743 IF ( qsmlr(mgs) < 0.0 .and. .not. mixedphase ) THEN ! switch snow sublimation to evaporation if there is melting
19744
19745 qscev(mgs) = evapfac* &
19746 & 4.0*pi*(qx(mgs,lv)-qss0(mgs))*cx(mgs,ls)*swcap(mgs)*swvent(mgs)/(qss0(mgs)*(fav(mgs)+fbv(mgs)))
19747 qscev(mgs) = max( min(0.0,qscev(mgs)), min( -qsmxd(mgs), -0.5*qx(mgs,ls)*dtpinv ) )
19748 ELSE
19749
19750 ENDIF
19751
19752
19753
19754 ELSE
19755 qisbv(mgs) = 0.0
19756 qssbv(mgs) = 0.0
19757 qidpv(mgs) = 0.0
19758 qsdpv(mgs) = 0.0
19759 ENDIF
19760
19761 qhsbv(mgs) = 0.0
19762 qhdpv(mgs) = 0.0
19763 IF ( qx(mgs,lh) > qxmin(lh) ) THEN
19764 IF ( temg(mgs) < tfr .or. .not. qhmlr(mgs) < 0.0 ) THEN
19765 ! no liquid from melting, so evaporation is greater. Thus can calculate sublimation rate
19766 qhsbv(mgs) = max( min(qhdsv(mgs), 0.0), -qhmxd(mgs) )
19767 qhdpv(mgs) = max(qhdsv(mgs), 0.0)
19768 ENDIF
19769
19770 IF ( .true. .and. qhmlr(mgs) < 0.0 .and. .not. mixedphase ) THEN
19771 ! Liquid is forming, so find the evaporation that was subtracted from melting (if it is not condensing)
19772! qhcev(mgs) = &
19773! & evapfac*min( &
19774! & fmlt1e(mgs)*cx(mgs,lh)*hwvent(mgs)*xdia(mgs,lh,1), 0.0 )
19775
19776 qhcev(mgs) = evapfac*2.0*pi*(qx(mgs,lv)-qss0(mgs))* &
19777 & cx(mgs,lh)*xdia(mgs,lh,1)*hwvent(mgs)/(qss0(mgs)*(fav(mgs)+fbv(mgs)))
19778
19779 qhcev(mgs) = max(qhcev(mgs), -qhmxd(mgs))
19780 IF ( temg(mgs) > tfr ) qhcev(mgs) = min(0.0, qhcev(mgs) )
19781
19782 ENDIF
19783 ENDIF
19784
19785
19786 qhlsbv(mgs) = 0.0
19787 qhldpv(mgs) = 0.0
19788 IF ( lhl .gt. 1 ) THEN
19789 IF ( qx(mgs,lhl) > qxmin(lhl) ) THEN
19790 IF ( temg(mgs) < tfr .or. .not. qhlmlr(mgs) < 0.0 ) THEN
19791 qhlsbv(mgs) = max( min(qhldsv(mgs), 0.0), -qxmxd(mgs,lhl) )
19792 qhldpv(mgs) = max(qhldsv(mgs), 0.0)
19793 ENDIF
19794 IF ( qhlmlr(mgs) < 0.0 .and. .not. mixedphase ) THEN
19795 ! Liquid is forming, so find the evaporation that was subtracted from melting (if it is not condensing)
19796 qhlcev(mgs) = evapfac*2.0*pi*(qx(mgs,lv)-qss0(mgs))* &
19797 & cx(mgs,lhl)*xdia(mgs,lhl,1)*hlvent(mgs)/(qss0(mgs)*(fav(mgs)+fbv(mgs)))
19798
19799 qhlcev(mgs) = max(qhlcev(mgs), -qhlmxd(mgs))
19800 IF ( temg(mgs) > tfr ) qhlcev(mgs) = min(0.0, qhlcev(mgs) )
19801
19802 ENDIF
19803 ENDIF
19804 ENDIF
19805
19806 temp1 = qidpv(mgs) + qsdpv(mgs) + qhdpv(mgs) + qhldpv(mgs)
19807
19808! IF ( temp1 .gt. qvimxd(mgs) ) THEN
19809
19810! frac = qvimxd(mgs)/temp1
19811
19812 IF ( temp1 .gt. qsimxdep(mgs) ) THEN
19813 frac = qsimxdep(mgs)/temp1
19814
19815 qidpv(mgs) = frac*qidpv(mgs)
19816 qsdpv(mgs) = frac*qsdpv(mgs)
19817 qhdpv(mgs) = frac*qhdpv(mgs)
19818 qhldpv(mgs) = frac*qhldpv(mgs)
19819
19820! IF ( ny .eq. 2 .and. igs(mgs) .eq. 302 .and. temg(mgs) .le. tfrh+10 .and. qx(mgs,lv) .gt. qis(mgs)
19821! : .and. qx(mgs,li) .gt. qxmin(li) ) THEN
19822! write(0,*) 'qidpv,frac = ',kgs(mgs),qidpv(mgs),frac
19823! ENDIF
19824
19825 ENDIF
19826
19827 temp1 = qisbv(mgs) + qssbv(mgs) + qhsbv(mgs) + qhlsbv(mgs)
19828
19829
19830 IF ( temp1 < -qsimxsub(mgs) ) THEN
19831 frac = -qsimxsub(mgs)/temp1
19832
19833 qisbv(mgs) = frac*qisbv(mgs)
19834 qssbv(mgs) = frac*qssbv(mgs)
19835 qhsbv(mgs) = frac*qhsbv(mgs)
19836 qhlsbv(mgs) = frac*qhlsbv(mgs)
19837
19838! IF ( ny .eq. 2 .and. igs(mgs) .eq. 302 .and. temg(mgs) .le. tfrh+10 .and. qx(mgs,lv) .gt. qis(mgs)
19839! : .and. qx(mgs,li) .gt. qxmin(li) ) THEN
19840! write(0,*) 'qidpv,frac = ',kgs(mgs),qidpv(mgs),frac
19841! ENDIF
19842
19843 ENDIF
19844
19845
19846 end do
19847!
19848!
19849 if ( ipconc .ge. 1 ) then
19850 do mgs = 1,ngscnt
19851 cssbv(mgs) = (cx(mgs,ls)/(qx(mgs,ls)+1.e-20))*qssbv(mgs)
19852 cisbv(mgs) = (cx(mgs,li)/(qx(mgs,li)+1.e-20))*qisbv(mgs)
19853 chsbv(mgs) = (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhsbv(mgs)
19854 IF ( lhl .gt. 1 ) chlsbv(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlsbv(mgs)
19855 csdpv(mgs) = 0.0 ! (cx(mgs,ls)/(qx(mgs,ls)+1.e-20))*qsdpv(mgs)
19856 cidpv(mgs) = 0.0 ! (cx(mgs,li)/(qx(mgs,li)+1.e-20))*qidpv(mgs)
19857 cisdpv(mgs) = 0.0
19858 chdpv(mgs) = 0.0 ! (cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhdpv(mgs)
19859 chldpv(mgs) = 0.0
19860 end do
19861 end if
19862
19863!
19864! Aggregation or size conversion of small crystals to snow
19865!
19866 if (ndebug .gt. 0 ) write(0,*) 'conc 29a'
19867 do mgs = 1,ngscnt
19868 qscni(mgs) = 0.0
19869 cscni(mgs) = 0.0
19870 cscnis(mgs) = 0.0
19871 if ( ipconc .ge. 4 .and. iscni .ge. 1 .and. qx(mgs,li) .gt. qxmin(li) ) then
19872 IF ( iscni .eq. 1 ) THEN
19873 qscni(mgs) = &
19874 & pi*rho0(mgs)*((0.25)/(6.0)) &
19875 & *eii(mgs)*(qx(mgs,li)**2)*(xdia(mgs,li,2)) &
19876 & *vtxbar(mgs,li,1)/xmas(mgs,li)
19877 cscni(mgs) = min(cimxd(mgs),qscni(mgs)*rho0(mgs)/xmas(mgs,li))
19878 cscnis(mgs) = 0.5*cscni(mgs)
19879 ELSEIF ( iscni .eq. 2 .or. iscni .eq. 4 .or. iscni .eq. 5 ) THEN ! Zeigler 1985/Zrnic 1993, sort of
19880 IF ( iscni .ne. 5 .and. qidpv(mgs) .gt. 0.0 .and. xdia(mgs,li,3) .ge. 100.e-6 ) THEN
19881 ! convert larger crystals to snow
19882! IF ( xdia(mgs,ls,3) .gt. xdia(mgs,li,3) ) THEN
19883! qscni(mgs) = Max(0.1,xdia(mgs,li,3)/xdia(mgs,ls,3))*qidpv(mgs)
19884! erm 9/5/08 changed max to min
19885 qscni(mgs) = min(0.5, xdia(mgs,li,3)/200.e-6)*qidpv(mgs)
19886! ELSE
19887! qscni(mgs) = 0.1*qidpv(mgs)
19888! ENDIF
19889 cscni(mgs) = fscni*qscni(mgs)*rho0(mgs)/max(rho_qs*xvmn(ls),xmas(mgs,li))
19890! cscni(mgs) = fscni*Min(cimxd(mgs),qscni(mgs)*rho0(mgs)/Max(xdn(mgs,ls)*xvmn(ls),xmas(mgs,li)))
19891! cscni(mgs) = Min(cimxd(mgs),qscni(mgs)*rho0(mgs)/xmas(mgs,li) )
19892! IF ( xdia(mgs,ls,3) .le. 200.e-6 ) THEN
19893 cscnis(mgs) = cscni(mgs)
19894! ELSE
19895! cscnis(mgs) = 0.0
19896! ENDIF
19897 ! write(91,*) 'qi,qscni = ',igs(mgs),kgs(mgs),qx(mgs,li),qscni(mgs),cscnis(mgs),qidpv(mgs)
19898 ENDIF
19899 IF ( iscni .ne. 4 ) THEN
19900 ! crystal aggregation to become snow
19901! erm 9/5/08 commented second line and added xv to 1st line (zrnic et al 1993)
19902 tmp = ess(mgs)*rvt*aa2*cx(mgs,li)*cx(mgs,li)*xv(mgs,li)
19903! : ((cinu + 2.)*xv(mgs,li)/(cinu + 1.) + xv(mgs,li))
19904
19905! csacs(mgs) = rvt*aa2*ess(mgs)*cx(mgs,ls)**2*xv(mgs,ls)
19906
19907 qscni(mgs) = qscni(mgs) + min( qxmxd(mgs,li), 2.0*tmp*xmas(mgs,li)*rhoinv(mgs) )
19908 cscni(mgs) = cscni(mgs) + min( cxmxd(mgs,li), 2.0*tmp )
19909 cscnis(mgs) = cscnis(mgs) + min( cxmxd(mgs,li), tmp )
19910 ENDIF
19911 ELSEIF ( iscni .eq. 3 ) THEN ! LFO
19912 qscni(mgs) = 0.001*eii(mgs)*max((qx(mgs,li)-1.e-3),0.0)
19913 qscni(mgs) = min(qscni(mgs),qxmxd(mgs,li))
19914 cscni(mgs) = qscni(mgs)*rho0(mgs)/xmas(mgs,li)
19915 cscnis(mgs) = 0.5*cscni(mgs)
19916! write(iunit,*) 'qscni, qi = ',qscni(mgs),qx(mgs,li),igs(mgs),kgs(mgs)
19917 ENDIF
19918
19919 ELSEIF ( ipconc < 4 ) THEN ! LFO
19920 IF ( lwsm6 ) THEN
19921 qimax = rhoinv(mgs)*roqimax
19922 qscni(mgs) = min(0.90*qx(mgs,li), max( 0.0, (qx(mgs,li) - qimax)*dtpinv ) )
19923 ELSE
19924 qscni(mgs) = 0.001*eii(mgs)*max((qx(mgs,li)-1.e-3),0.0)
19925 qscni(mgs) = min(qscni(mgs),qxmxd(mgs,li))
19926 ENDIF
19927 else ! 10-ice version
19928 if ( iscni > 0 .and. qx(mgs,li) .gt. qxmin(li) ) then
19929 qscni(mgs) = &
19930 & pi*rho0(mgs)*((0.25)/(6.0)) &
19931 & *eii(mgs)*(qx(mgs,li)**2)*(xdia(mgs,li,2)) &
19932 & *vtxbar(mgs,li,1)/xmas(mgs,li)
19933 cscni(mgs) = min(cimxd(mgs),qscni(mgs)*rho0(mgs)/xmas(mgs,li))
19934 end if
19935
19936 end if
19937 end do
19938
19939 IF ( incwet < 1 ) THEN
19940 dhwet(:) = d1t
19941 dhlwet(:) = d1t
19942 dfwet(:) = d1t
19943 ENDIF
19944
19945 IF ( incwet >= 1 ) THEN
19946 ! 'incwet' = incomplete gamma for wet growth
19947 ! Find diameter where wet growth starts, then compute dry and wet growth
19948 ! over [dwet,infinity]. Subtract dry growth from qxacw etc. to get total
19949 ! dry growth part
19950 dhwet(:) = dg0thresh + 0.0001
19951 dhlwet(:) = dg0thresh + 0.0001
19952 dfwet(:) = dg0thresh + 0.0001
19953
19954 DO mgs = 1,ngscnt
19955
19956 sqrtrhovt = sqrt( rhovt(mgs) )
19957 fventh = sqrtrhovt*(fpndl(mgs)**(1./3.)) * (fakvisc(mgs))**(-0.5)
19958 fventm = sqrtrhovt*(fschm(mgs)**(1./3.)) * (fakvisc(mgs))**(-0.5)
19959 ltemq = (tfr-163.15)/fqsat+1.5
19960 qvs0 = pqs(mgs)*tabqvs(ltemq)
19961 denomdp = felf(mgs) + fcw(mgs)*temcg(mgs)
19962 denominvdp = 1.d0/(felf(mgs) + fcw(mgs)*temcg(mgs))
19963
19964 IF (((qhacw(mgs) + qhacr(mgs))*dtp > qxmin(lh) .and. qx(mgs,lh) > hlcnhqmin .and. &
19965 temg(mgs) .le. tfr + wetgrthtoffset .and. temg(mgs) .ge. 243.15 ) ) THEN
19966! 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 )
19967! dwr = 0.01*( Exp( -temcg(mgs)/( 1.1e4 * rho0(mgs)*(ehw(mgs)*qx(mgs,lc)+ehr(mgs)*qx(mgs,lr)) - &
19968! 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0 ) ) - 1.0 )
19969 x = 1.1e4 * rho0(mgs)*(ehw(mgs)*qx(mgs,lc)+ehr(mgs)*qx(mgs,lr)) - &
19970 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0
19971 IF ( x > 1.e-20 ) THEN
19972 arg = min(70.0, (-temcg(mgs)/x )) ! prevent overflow of the exp function in 32 bit
19973 dwr = 0.01*(exp(arg) - 1.0)
19974 ELSE
19975 dwr = 1.e30
19976 ENDIF
19977 d = dwr
19978
19979 IF ( dwr < 0.2 .and. dwr > 0.0 .and. rho0(mgs)*(qx(mgs,lc)+qx(mgs,lr)) > 1.e-4 ) THEN
19980
19981 h1 = ( -ftka(mgs)*temcg(mgs) - felv(mgs)*fwvdf(mgs)*rho0(mgs)*(qx(mgs,lv) - qvs0) )
19982 h2 = ehi(mgs)*qx(mgs,li)*rho0(mgs)*fci(mgs)*temcg(mgs)
19983 h3 = max(dwehwmin, ehw(mgs))*qx(mgs,lc)
19984 h4 = ehr(mgs)* qx(mgs,lr)
19985 ! iterate to find minimum diameter for wet growth. Start with value of dwr
19986 DO n = 1,10
19987 d = max(d, 1.e-4)
19988 dold = d
19989 vth = axx(mgs,lh)*d**bxx(mgs,lh)
19990 x2 = fventh*sqrtrhovt*sqrt(d*vth)
19991 IF ( x2 > 1.4 ) THEN
19992 ah = 0.78 + 0.308*x2 ! heat ventillation
19993 ELSE
19994 ah = 1.0 + 0.108*x2**2 ! mass ventillation (Beard and Pruppacher 1971, eq. 9)
19995 ENDIF
19996
19997
19998 d = 8.*ah*h1/ &
19999 ( ( max(0.001,vth - vtxbar(mgs,lc,1))*h3 + &
20000 max(0.001,vth - vtxbar(mgs,lr,1))*h4) *rho0(mgs)*denomdp + &
20001 max(0.001,vth - vtxbar(mgs,li,1))*h2)
20002
20003 IF ( abs(dold - d)/dold < 0.05 .or. ( n > 3 .and. d > dg0thresh ) ) EXIT
20004
20005 ENDDO
20006 ENDIF
20007
20008 dhwet(mgs) = min(dg0thresh + 0.0001, max( d, dwetmin ))
20009 ELSE
20010 dhwet(mgs) = dg0thresh + 0.0001
20011 ENDIF
20012
20013 IF (((qhlacw(mgs) + qhlacr(mgs))*dtp > qxmin(lhl) .and. qx(mgs,lhl) > 0.01e-3 &
20014 .and. temg(mgs) .le. tfr + wetgrthtoffset .and. temg(mgs) .ge. 243.15 ) ) THEN
20015! dw = 0.01*( Exp( -temcg(mgs)/( 1.1e4 * rho0(mgs)*ehlw(mgs)*qx(mgs,lc) - 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0 ) ) - 1.0 )
20016! dwr = 0.01*( Exp( -temcg(mgs)/( 1.1e4 * rho0(mgs)*(ehlw(mgs)*qx(mgs,lc)+ehlr(mgs)*qx(mgs,lr)) - &
20017! 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0 ) ) - 1.0 )
20018 x = 1.1e4 * rho0(mgs)*(ehlw(mgs)*qx(mgs,lc)+ehlr(mgs)*qx(mgs,lr)) - &
20019 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0
20020 IF ( x > 1.e-20 ) THEN
20021 arg = min(70.0, (-temcg(mgs)/x )) ! prevent overflow of the exp function in 32 bit
20022 dwr = 0.01*(exp(arg) - 1.0)
20023 ELSE
20024 dwr = 1.e30
20025 ENDIF
20026 d = dwr
20027 IF ( dwr < 0.2 .and. dwr > 0.0 .and. rho0(mgs)*(qx(mgs,lc)+qx(mgs,lr)) > 1.e-4 ) THEN
20028
20029! write(91,*) 'dw,dwr,temcg = ',100.*dw,100.*dwr,temcg(mgs)
20030 h1 = ( -ftka(mgs)*temcg(mgs) - felv(mgs)*fwvdf(mgs)*rho0(mgs)*(qx(mgs,lv) - qvs0) )
20031 h2 = ehi(mgs)*qx(mgs,li)*rho0(mgs)*fci(mgs)*temcg(mgs)
20032 h3 = max(dwehwmin, ehlw(mgs))*qx(mgs,lc)
20033 h4 = ehlr(mgs)* qx(mgs,lr)
20034 ! iterate to find minimum diameter for wet growth. Start with value of dwr
20035 DO n = 1,10
20036 d = max(d, 1.e-4)
20037 dold = d
20038 vth = axx(mgs,lhl)*d**bxx(mgs,lhl)
20039 x2 = fventh*sqrtrhovt*sqrt(d*vth)
20040 IF ( x2 > 1.4 ) THEN
20041 ah = 0.78 + 0.308*x2 ! heat ventillation
20042 ELSE
20043 ah = 1.0 + 0.108*x2**2 ! mass ventillation (Beard and Pruppacher 1971, eq. 9)
20044 ENDIF
20045
20046
20047 d = 8.*ah*h1/ &
20048 ( ( max(0.001,vth - vtxbar(mgs,lc,1))*h3 + &
20049 max(0.001,vth - vtxbar(mgs,lr,1))*h4) *rho0(mgs)*denomdp + &
20050 max(0.001,vth - vtxbar(mgs,li,1))*h2)
20051
20052 IF ( abs(dold - d)/dold < 0.05 .or. ( n > 3 .and. d > dg0thresh ) ) EXIT
20053
20054 ENDDO
20055 ENDIF
20056
20057 dhlwet(mgs) = min(dg0thresh + 0.0001, max( d, dwetmin ) )
20058 ELSE
20059 dhlwet(mgs) = dg0thresh + 0.0001
20060 ENDIF
20061
20062
20063 ENDDO
20064
20065 ENDIF ! incwet
20066
20067
20068
20069!
20070!
20071! compute dry growth rate of snow, graupel, and hail
20072!
20073 do mgs = 1,ngscnt
20074!
20075 qsdry(mgs) = qsacr(mgs) + qsacw(mgs) &
20076 & + qsaci(mgs)
20077!
20078 qhdry(mgs) = qhaci(mgs) + qhacs(mgs) &
20079 & + qhacr(mgs) &
20080 & + qhacw(mgs)
20081!
20082
20083 qhldry(mgs) = 0.0
20084 IF ( lhl .gt. 1 ) THEN
20085 qhldry(mgs) = qhlaci(mgs) + qhlacs(mgs) &
20086 & + qhlacr(mgs) &
20087 & + qhlacw(mgs)
20088 ENDIF
20089 end do
20090!
20091! set wet growth and shedding
20092!
20093 do mgs = 1,ngscnt
20094
20095 IF ( tfrdry < temg(mgs) .and. temg(mgs) < tfr ) THEN
20096!
20097! qswet(mgs) =
20098! > ( xdia(mgs,ls,1)*swvent(mgs)*cx(mgs,ls)*fwet1(mgs)
20099! > + fwet2(mgs)*(qsaci(mgs)+qsacir(mgs)
20100! > +qsacip(mgs)) )
20101! qswet(mgs) = max( 0.0, qswet(mgs))
20102!
20103! IF ( dnu(lh) .ne. 0. ) THEN
20104! qhwet(mgs) = qhdry(mgs)
20105! ELSE
20106 ! IF ( incwet == 0 ) THEN
20107 qhwet(mgs) = &
20108 & ( xdia(mgs,lh,1)*hwvent(mgs)*cx(mgs,lh)*fwet1(mgs) &
20109 & + fwet2(mgs)*(qhaci(mgs) + qhacs(mgs)) )
20110 qhwet(mgs) = max( 0.0, qhwet(mgs))
20111
20112 IF ( incwet == 1 .and. qhwet(mgs) < qhdry(mgs) .and. dhwet(mgs) < dg0thresh ) THEN
20113 ! ELSE
20114 ! IF ( dhwet(mgs) < dg0thresh ) THEN
20115 ! find portion of qc and qr collection that are dry/wet growth for d > dwet
20116
20117 ratio = min( maxratiolu, dhwet(mgs)/xdia(mgs,lh,1) )
20118
20119 tmp1 = gaminterp(ratio,alpha(mgs,lh),13,1) ! alpha + 3
20120 tmp2 = gaminterp(ratio,alpha(mgs,lh),12,1) ! alpha + 2
20121 tmp3 = gaminterp(ratio,alpha(mgs,lh), 9,1) ! alpha + 1
20122
20123 IF ( qhacw(mgs)*dtp > qxmin(lh) ) THEN
20124 vt = abs(vtxbar(mgs,lh,1)-vtxbar(mgs,lc,1))
20125
20126 qxacwtmp = 0.25*pi*ehw(mgs)*cx(mgs,lh)*(qx(mgs,lc)-qcwresv(mgs))*vt* &
20127 & ( tmp1*da0lh(mgs)*xdia(mgs,lh,3)**2 + &
20128 & tmp2*dab1lh(mgs,lh,lc)*xdia(mgs,lh,3)*xdia(mgs,lc,3) + &
20129 & tmp3*da1lc(mgs)*xdia(mgs,lc,3)**2 )
20130 ELSE
20131 qxacwtmp = 0.0
20132 ENDIF
20133
20134 IF ( qhacr(mgs)*dtp > qxmin(lh) ) THEN
20135
20136 vt = sqrt((vtxbar(mgs,lh,1)-vtxbar(mgs,lr,1))**2 + &
20137 & 0.04*vtxbar(mgs,lh,1)*vtxbar(mgs,lr,1) )
20138
20139 qxacrtmp = 0.25*pi*ehr(mgs)*cx(mgs,lh)*qx(mgs,lr)*vt* &
20140 & ( tmp1*da0lh(mgs)*xdia(mgs,lh,3)**2 + &
20141 & tmp2*dab1lh(mgs,lh,lr)*xdia(mgs,lh,3)*xdia(mgs,lr,3) + &
20142 & tmp3*da1lr(mgs)*xdia(mgs,lr,3)**2 )
20143 ELSE
20144 qxacrtmp = 0.0
20145 ENDIF
20146
20147 ! hwvent is where the size dependency is, so hxventtmp gives the portion for d > dwet
20148 x = gaminterp(ratio,alpha(mgs,lh),9,1) ! alpha + 1
20149 y = gaminterp(ratio,alpha(mgs,lh),3,1) ! alpha + b/2 + 5/2
20150
20151 hxventtmp = 0.78*x + y*hwventy(mgs) ! &
20152
20153 ! find the ice and snow collection for d > dwet
20154 qxacitmp = 0.0
20155 IF ( qhaci(mgs)*dtp > qxmin(lh) ) THEN
20156 vt = abs(vtxbar(mgs,lh,1)-vtxbar(mgs,li,1))
20157
20158 qxacitmp = 0.25*pi*ehiclsn(mgs)*cx(mgs,lh)*qx(mgs,li)*vt* &
20159 & ( tmp1*da0lh(mgs)*xdia(mgs,lh,3)**2 + &
20160 & tmp2*dab1lh(mgs,lh,li)*xdia(mgs,lh,3)*xdia(mgs,li,3) + &
20161 & tmp3*da1(li)*xdia(mgs,li,3)**2 )
20162 ENDIF
20163
20164 qxacstmp = 0.0
20165 IF ( qhacs(mgs)*dtp > qxmin(lh) ) THEN
20166 vt = abs(vtxbar(mgs,lh,1)-vtxbar(mgs,ls,1))
20167
20168 qxacstmp = 0.25*pi*ehsclsn(mgs)*cx(mgs,lh)*qx(mgs,ls)*vt* &
20169 & ( da0lh(mgs)*xdia(mgs,lh,3)**2 + &
20170 & dab1lh(mgs,lh,ls)*xdia(mgs,lh,3)*xdia(mgs,ls,3) + &
20171 & da1(ls)*xdia(mgs,ls,3)**2 )
20172 ENDIF
20173
20174 qxwettmp = &
20175 & xdia(mgs,lh,1)*hxventtmp*cx(mgs,lh)*fwet1(mgs) &
20176 & + fwet2(mgs)*(qxacitmp + qxacstmp)
20177
20178 ! as dry growth but subtract part for D > Dw and add wet growth for D > Dw
20179 qhwet(mgs) = qhacw(mgs) + qhacr(mgs) + qhaci(mgs) + qhacs(mgs) &
20180 - ehi(mgs)*qxacitmp - ehs(mgs)*qxacstmp &
20181 - qxacwtmp - qxacrtmp + qxwettmp
20182
20183 ! qhacw(mgs) = Min( qhacw(mgs), 0.5*qx(mgs,lc)*dtpinv )
20184
20185 ! ELSE ! for dwet > 15cm, just assume dry growth
20186 ! qhwet(mgs) = qhdry(mgs)
20187 ! ENDIF
20188 ENDIF
20189
20190! ENDIF
20191
20192
20193 qhlwet(mgs) = 0.0
20194 IF ( lhl .gt. 1 ) THEN
20195 !IF ( incwet == 0 ) THEN
20196 qhlwet(mgs) = &
20197 & ( xdia(mgs,lhl,1)*hlvent(mgs)*cx(mgs,lhl)*fwet1(mgs) &
20198 & + fwet2(mgs)*(qhlaci(mgs) + qhlacs(mgs)) )
20199 qhlwet(mgs) = max( 0.0, qhlwet(mgs))
20200
20201 IF ( incwet == 1 .and. qhlwet(mgs) < qhldry(mgs) .and. dhlwet(mgs) < dg0thresh ) THEN
20202 !ELSE
20203!! || defined (WRFEXTRAS)
20204 ! IF ( dhlwet(mgs) < dg0thresh ) THEN
20205 ! find portion of qc and qr collection that are dry/wet growth for d > dwet
20206
20207 ratio = min( maxratiolu, dhlwet(mgs)/xdia(mgs,lhl,1) )
20208
20209 tmp1 = gaminterp(ratio,alpha(mgs,lhl),13,2) ! alpha + 3
20210 tmp2 = gaminterp(ratio,alpha(mgs,lhl),12,2) ! alpha + 2
20211 tmp3 = gaminterp(ratio,alpha(mgs,lhl), 9,2) ! alpha + 1
20212
20213 IF ( qhlacw(mgs)*dtp > qxmin(lhl) ) THEN
20214 vt = abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,lc,1))
20215
20216 qxacwtmp = 0.25*pi*ehlw(mgs)*cx(mgs,lhl)*(qx(mgs,lc)-qcwresv(mgs))*vt* &
20217 & ( tmp1*da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
20218 & tmp2*dab1lh(mgs,lhl,lc)*xdia(mgs,lhl,3)*xdia(mgs,lc,3) + &
20219 & tmp3*da1lc(mgs)*xdia(mgs,lc,3)**2 )
20220 ELSE
20221 qxacwtmp = 0.0
20222 ENDIF
20223
20224 IF ( qhlacr(mgs)*dtp > qxmin(lhl) ) THEN
20225
20226 vt = sqrt((vtxbar(mgs,lhl,1)-vtxbar(mgs,lr,1))**2 + &
20227 & 0.04*vtxbar(mgs,lhl,1)*vtxbar(mgs,lr,1) )
20228
20229 qxacrtmp = 0.25*pi*ehlr(mgs)*cx(mgs,lhl)*qx(mgs,lr)*vt* &
20230 & ( tmp1*da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
20231 & tmp2*dab1lh(mgs,lhl,lr)*xdia(mgs,lhl,3)*xdia(mgs,lr,3) + &
20232 & tmp3*da1lr(mgs)*xdia(mgs,lr,3)**2 )
20233 ELSE
20234 qxacrtmp = 0.0
20235 ENDIF
20236
20237 x = gaminterp(ratio,alpha(mgs,lhl),9,2) ! alpha + 1
20238 y = gaminterp(ratio,alpha(mgs,lhl),3,2) ! alpha + b/2 + 5/2
20239
20240 hxventtmp = 0.78*x + y*hlventy(mgs) ! &
20241
20242 qxacitmp = 0.0
20243 IF ( qhlaci(mgs)*dtp > qxmin(lhl) ) THEN
20244 vt = abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,li,1))
20245
20246 qxacitmp = 0.25*pi*ehliclsn(mgs)*cx(mgs,lhl)*qx(mgs,li)*vt* &
20247 & ( tmp1*da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
20248 & tmp2*dab1lh(mgs,lhl,li)*xdia(mgs,lhl,3)*xdia(mgs,li,3) + &
20249 & tmp3*da1(li)*xdia(mgs,li,3)**2 )
20250 ENDIF
20251
20252 qxacstmp = 0.0
20253 IF ( qhlacs(mgs)*dtp > qxmin(lhl) ) THEN
20254 vt = abs(vtxbar(mgs,lhl,1)-vtxbar(mgs,ls,1))
20255
20256 qxacstmp = 0.25*pi*ehlsclsn(mgs)*cx(mgs,lhl)*qx(mgs,ls)*vt* &
20257 & ( da0lhl(mgs)*xdia(mgs,lhl,3)**2 + &
20258 & dab1lh(mgs,lhl,ls)*xdia(mgs,lhl,3)*xdia(mgs,ls,3) + &
20259 & da1(ls)*xdia(mgs,ls,3)**2 )
20260 ENDIF
20261
20262 qxwettmp = &
20263 & xdia(mgs,lhl,1)*hxventtmp*cx(mgs,lhl)*fwet1(mgs) &
20264 & + fwet2(mgs)*(qxacitmp + qxacstmp)
20265
20266 ! qhlacw(mgs) + qhlacr(mgs) - qxacwtmp - qxacrtmp is the 'dry' growth
20267 ! at smaller diameters
20268! qhlwet(mgs) = qhlacw(mgs) + qhlacr(mgs) - qxacwtmp - qxacrtmp + qxwettmp
20269 ! as dry growth but subtract part for D > Dw and add wet growth for D > Dw
20270 qhlwet(mgs) = qhlacw(mgs) + qhlacr(mgs) + qhlaci(mgs) + qhlacs(mgs) &
20271 - ehli(mgs)*qxacitmp - ehls(mgs)*qxacstmp &
20272 - qxacwtmp - qxacrtmp + qxwettmp
20273
20274 ! ELSE
20275 ! qhlwet(mgs) = qhldry(mgs)
20276 ! ENDIF
20277 ENDIF ! incwet
20278 ENDIF
20279
20280 ELSE
20281
20282 qhwet(mgs) = qhdry(mgs)
20283 qhlwet(mgs) = qhldry(mgs)
20284 ENDIF
20285!
20286! qhlwet(mgs) = qhldry(mgs)
20287
20288 end do
20289
20290!
20291! shedding rate
20292!
20293 qsshr(:) = 0.0
20294 qhshr(:) = 0.0
20295 qhlshr(:) = 0.0
20296 qhshh(:) = 0.0
20297 csshr(:) = 0.0
20298 csshrr(:) = 0.0
20299 chshr(:) = 0.0
20300 chlshr(:) = 0.0
20301 chshrr(:) = 0.0
20302 chlshrr(:) = 0.0
20303 vhshdr(:) = 0.0
20304 vhlshdr(:) = 0.0
20305 wetsfc(:) = .false.
20306 wetgrowth(:) = .false.
20307 wetsfchl(:) = .false.
20308 wetgrowthhl(:) = .false.
20309
20310 do mgs = 1,ngscnt
20311!
20312!
20313!
20314 qhshr(mgs) = min( 0.0, qhwet(mgs) - qhdry(mgs) ) ! water that freezes should never be more than what sheds
20315
20316
20317
20318 qhlshr(mgs) = min( 0.0, qhlwet(mgs) - qhldry(mgs) )
20319
20320!
20321! limit wet growth to only higher density particles
20322!
20323 qsshr(mgs) = 0.0
20324!
20325!
20326! no shedding for temperatures < 243.15
20327!
20328 if ( temg(mgs) .lt. 243.15 ) then
20329 qsshr(mgs) = 0.0
20330 qhshr(mgs) = 0.0
20331 qhlshr(mgs) = 0.0
20332 vhshdr(mgs) = 0.0
20333 vhlshdr(mgs) = 0.0
20334 wetsfc(mgs) = .false.
20335 wetgrowth(mgs) = .false.
20336 wetsfchl(mgs) = .false.
20337 wetgrowthhl(mgs) = .false.
20338 end if
20339!
20340! shed all at temperatures > 273.15
20341!
20342 if ( temg(mgs) .gt. tfr ) then
20343
20344 IF ( .false. ) THEN ! old and incorrect -- Thanks to Shaofeng Hua for noticing this error (9/17/2017)
20345 qsshr(mgs) = -qsdry(mgs)
20346 qhshr(mgs) = -qhdry(mgs)
20347 qhlshr(mgs) = -qhldry(mgs)
20348 ELSE ! new and correct
20349 ! note that the qxacr terms should be zero here, so shedding at T > 0 is all from the droplets
20350 qsshr(mgs) = - qsacr(mgs) - qsacw(mgs) ! -qsdry(mgs)
20351 qhlshr(mgs) = - qhlacw(mgs) - qhlacr(mgs) ! -qhldry(mgs)
20352 qhshr(mgs) = - qhacw(mgs) - qhacr(mgs) ! -qhdry(mgs)
20353
20354 ENDIF
20355
20356 vhshdr(mgs) = -vhacw(mgs) - vhacr(mgs)
20357 vhlshdr(mgs) = -vhlacw(mgs) - vhlacr(mgs)
20358 qhwet(mgs) = 0.0
20359 qhlwet(mgs) = 0.0
20360 end if
20361!
20362! if (qhshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) THEN
20363 wetsfc(mgs) = (qhshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) .or. ( qhmlr(mgs) < -qxmin(lh) .and. temg(mgs) > tfr )
20364 wetgrowth(mgs) = (qhshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr )
20365! ENDIF
20366 if (qhlshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) THEN
20367 wetsfchl(mgs) = (qhlshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr ) .or. ( qhlmlr(mgs) < -qxmin(lhl) .and. temg(mgs) > tfr )
20368 wetgrowthhl(mgs) = (qhlshr(mgs) .lt. 0.0 .and. temg(mgs) < tfr )
20369 ENDIF
20370
20371 end do
20372!
20373 if ( ipconc .ge. 1 ) then
20374 do mgs = 1,ngscnt
20375 csshr(mgs) = 0.0 ! (cx(mgs,ls)/(qx(mgs,ls)+1.e-20))*Min(0.0,qsshr(mgs))
20376
20377 chshr(mgs) = 0.0 ! no change to graupel number concentration for wet-growth shedding
20378
20379 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
20380 ! Base the drop size on the shedding regime
20381 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
20382 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
20383 chshrr(mgs) = rho0(mgs)*qhshr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lh)) ! into rain
20384
20385
20386
20387 chlshr(mgs) = 0.0
20388 chlshrr(mgs) = 0.0
20389 IF ( lhl .gt. 1 ) THEN
20390! chlshr(mgs) = (cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlshr(mgs)
20391
20392
20393 chlshr(mgs) = 0.0 ! no change to hail number concentration for wet-growth shedding
20394
20395 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
20396 ! Base the drop size on the shedding regime
20397 ! 8/26/2015 ERM updated to use shedalp and tmpdiam
20398 ! tmpdiam = (shedalp+alpha(mgs,lh))*xdia(mgs,lh,1)
20399 chlshrr(mgs) = rho0(mgs)*qhlshr(mgs)/(xdn(mgs,lr)*vshdgs(mgs,lhl)) ! into rain
20400
20401 ENDIF ! ( lhl > 1 )
20402
20403
20404 end do
20405 end if
20406
20407
20408
20409!
20410! final decisions
20411!
20412 do mgs = 1,ngscnt
20413!
20414! Snow
20415!
20416 if ( qsshr(mgs) .lt. 0.0 ) then
20417 qsdpv(mgs) = 0.0
20418 qssbv(mgs) = 0.0
20419 else
20420 qsshr(mgs) = 0.0
20421 end if
20422!
20423! if ( qsdry(mgs) .lt. qswet(mgs) ) then
20424! qswet(mgs) = 0.0
20425! else
20426! qsdry(mgs) = 0.0
20427! end if
20428!
20429
20430! graupel
20431!
20432!
20433 if ( wetgrowth(mgs) .or. (mixedphase .and. fhw(mgs) .gt. 0.05 .and. temg(mgs) .gt. 243.15) ) then
20434
20435
20436! soaking (when not advected liquid water film with graupel)
20437
20438 IF ( lvol(lh) .gt. 1 .and. .not. mixedphase) THEN
20439 ! rescale volumes to maximum density
20440 IF ( iwetsoak ) THEN
20441
20442 rimdn(mgs,lh) = xdnmx(lh)
20443 raindn(mgs,lh) = xdnmx(lh)
20444 vhacw(mgs) = qhacw(mgs)*rho0(mgs)/rimdn(mgs,lh)
20445 vhacr(mgs) = qhacr(mgs)*rho0(mgs)/raindn(mgs,lh)
20446! IF ( lvol(lh) .gt. 1 .and. wetgrowth(mgs) ) THEN
20447 IF ( xdn(mgs,lh) .lt. xdnmx(lh) ) THEN
20448 ! soak some liquid into the graupel
20449! v1 = xdnmx(lh)*vx(mgs,lh)/(xdn(mgs,lh)*dtp) ! volume available for filling
20450 v1 = (1. - xdn(mgs,lh)/xdnmx(lh))*vx(mgs,lh)/(dtp) ! volume available for filling
20451! tmp = (vx(mgs,lh)/rho0(mgs))*(xdnmx(lh) - xdn(mgs,lh)) ! max mixing ratio of liquid water that can be added
20452 v2 = rho0(mgs)*qhwet(mgs)/xdnmx(lh) ! volume of frozen accretion
20453
20454 vhsoak(mgs) = min(v1,v2)
20455
20456
20457 ENDIF
20458
20459 ENDIF
20460
20461 vhshdr(mgs) = min(0.0, rho0(mgs)*qhwet(mgs)/xdnmx(lh) - vhacw(mgs) - vhacr(mgs) )
20462
20463 ELSEIF ( lvol(lh) .gt. 1 .and. mixedphase ) THEN
20464! vhacw(mgs) = rho0(mgs)*qhacw(mgs)/xdn0(lr)
20465! vhacr(mgs) = rho0(mgs)*qhacr(mgs)/xdn0(lr)
20466 ENDIF
20467
20468
20469 qhdpv(mgs) = 0.0
20470! qhsbv(mgs) = 0.0
20471 chdpv(mgs) = 0.0
20472! chsbv(mgs) = 0.0
20473
20474! collection efficiency modification
20475
20476 IF ( ehi(mgs) .gt. 0.0 ) THEN
20477 qhaci(mgs) = min(qimxd(mgs),qhaci0(mgs)) ! effectively sets collection eff to 1
20478 chaci(mgs) = min(cimxd(mgs),chaci0(mgs)) ! effectively sets collection eff to 1
20479 ENDIF
20480 IF ( ehs(mgs) .gt. 0.0 ) THEN
20481! qhacs(mgs) = Min(qsmxd(mgs),qhacs(mgs)/ehs(mgs)) ! effectively sets collection eff to 1
20482 qhacs(mgs) = min(qsmxd(mgs),qhacs0(mgs)) !/ehs(mgs) ! divide out the collection efficiency
20483 chacs(mgs) = min(csmxd(mgs),chacs0(mgs)) !/ehs(mgs) ! divide out the collection efficiency
20484 ehs(mgs) = ehsmax ! 1.0 ! min(ehsfrac*ehs(mgs),ehsmax) ! modify it
20485 qhacs(mgs) = min(qsmxd(mgs),qhacs(mgs)) ! plug it back in
20486 ENDIF
20487
20488! be sure to catch particles with wet surfaces but not in wet growth to turn off Hallett-Mossop
20489 wetsfc(mgs) = .true.
20490
20491 else
20492! qhshr(mgs) = 0.0
20493 end if
20494!
20495!
20496! hail
20497!
20498! if ( lhl .gt. 1 .and. qhlshr(mgs) .lt. 0.0 ) then
20499 if ( lhl > 1 .and. ( wetgrowthhl(mgs) .or. (mixedphase .and. fhlw(mgs) .gt. 0.05 .and. temg(mgs) .gt. 243.15) ) ) then
20500! if ( wetgrowthhl(mgs) ) then
20501
20502
20503 qhldpv(mgs) = 0.0
20504! qhlsbv(mgs) = 0.0
20505 chldpv(mgs) = 0.0
20506! chlsbv(mgs) = 0.0
20507
20508
20509
20510
20511 IF ( lvol(lhl) .gt. 1 .and. .not. mixedphase ) THEN
20512! IF ( lvol(lhl) .gt. 1 .and. wetgrowthhl(mgs) ) THEN
20513
20514 IF ( iwetsoak ) THEN
20515
20516 rimdn(mgs,lhl) = xdnmx(lhl)
20517 raindn(mgs,lhl) = xdnmx(lhl)
20518 vhlacw(mgs) = qhlacw(mgs)*rho0(mgs)/rimdn(mgs,lhl)
20519 vhlacr(mgs) = qhlacr(mgs)*rho0(mgs)/raindn(mgs,lhl)
20520
20521 IF ( xdn(mgs,lhl) .lt. xdnmx(lhl) ) THEN
20522 ! soak some liquid into the hail
20523! v1 = xdnmx(lhl)*vx(mgs,lhl)/(xdn(mgs,lhl)*dtp) ! volume available for filling
20524 v1 = (1. - xdn(mgs,lhl)/xdnmx(lhl))*vx(mgs,lhl)/(dtp) ! volume available for filling
20525! tmp = (vx(mgs,lhl)/rho0(mgs))*(xdnmx(lhl) - xdn(mgs,lhl)) ! max mixing ratio of liquid water that can be added
20526 v2 = rho0(mgs)*qhlwet(mgs)/xdnmx(lhl) ! volume of frozen accretion
20527 IF ( v1 > v2 ) THEN ! all the frozen stuff fits in
20528 vhlsoak(mgs) = v2
20529 ELSE ! fill up the available space
20530 vhlsoak(mgs) = v1
20531 ENDIF
20532! vhlacw(mgs) = 0.0
20533! vhlacr(mgs) = Max( 0.0, v2 - v1 )
20534 ELSE
20535 vhlsoak(mgs) = 0.0
20536! vhlacw(mgs) = 0.0
20537! vhlacr(mgs) = rho0(mgs)*qhlwet(mgs)/raindn(mgs,lhl)
20538
20539 ENDIF
20540
20541 ENDIF
20542
20543 vhlshdr(mgs) = min(0.0, rho0(mgs)*qhlwet(mgs)/xdnmx(lhl) - vhlacw(mgs) - vhlacr(mgs) )
20544
20545
20546 ELSEIF ( lvol(lhl) .gt. 1 .and. mixedphase ) THEN
20547! vhlacw(mgs) = rho0(mgs)*qhlacw(mgs)/xdn0(lr)
20548! vhlacr(mgs) = rho0(mgs)*qhlacr(mgs)/xdn0(lr)
20549 ENDIF
20550
20551 IF ( ehli(mgs) .gt. 0.0 ) THEN
20552 qhlaci(mgs) = min(qimxd(mgs),qhlaci0(mgs)) ! effectively sets collection eff to 1
20553 chlaci(mgs) = min(cimxd(mgs),chlaci0(mgs)) ! effectively sets collection eff to 1
20554 ENDIF
20555
20556! IF ( ehls(mgs) .gt. 0.0 ) THEN
20557! qhlacs(mgs) = Min(qsmxd(mgs),qhlacs(mgs)/ehls(mgs))
20558! ENDIF
20559 IF ( ehls(mgs) .gt. 0.0 ) THEN
20560 qhlacs(mgs) = min(qsmxd(mgs),qhlacs0(mgs)) !/ehls(mgs) ! divide out the collection efficiency
20561 chlacs(mgs) = min(csmxd(mgs),chlacs0(mgs)) !/ehls(mgs) ! divide out the collection efficiency
20562 ehls(mgs) = ehsmax ! 1.0 ! min(ehsfrac*ehs(mgs),ehsmax) ! modify it
20563! qhlacs(mgs) = Min(qsmxd(mgs),qhlacs(mgs)) ! plug it back in
20564 ENDIF
20565
20566
20567! qhlwet(mgs) = 1.0
20568
20569! be sure to catch particles with wet surfaces but not in wet growth to turn off Hallett-Mossop
20570 wetsfchl(mgs) = .true.
20571
20572
20573 else
20574! qhlshr(mgs) = 0.0
20575! qhlwet(mgs) = 0.0
20576 end if
20577
20578 end do
20579!
20580! Ice -> graupel conversion
20581!
20582 DO mgs = 1,ngscnt
20583
20584 qhcni(mgs) = 0.0
20585 chcni(mgs) = 0.0
20586 chcnih(mgs) = 0.0
20587 vhcni(mgs) = 0.0
20588
20589 IF ( iglcnvi .ge. 1 ) THEN
20590 IF ( temg(mgs) .lt. 273.0 .and. qiacw(mgs) - qidpv(mgs) .gt. 0.0 ) THEN
20591
20592
20593 tmp = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
20594 & *((0.60)*vtxbar(mgs,li,1)) &
20595 & /(temg(mgs)-273.15))**(rimc2)
20596 tmp = min( max( rimc3, tmp ), 900.0 )
20597
20598 ! Assume that half the volume of the embryo is rime with density 'tmp'
20599 ! m = rhoi*(V/2) + rhorime*(V/2) = (rhoi + rhorime)*V/2
20600 ! V = 2*m/(rhoi + rhorime)
20601
20602! write(0,*) 'rime dens = ',tmp
20603
20604 IF ( tmp .ge. 200.0 .or. iglcnvi >= 2 ) THEN
20605 r = max( 0.5*(xdn(mgs,li) + tmp), xdnmn(lh) )
20606! r = Max( r, 400. )
20607 qhcni(mgs) = (qiacw(mgs) - qidpv(mgs)) ! *float(iglcnvi)
20608 chcni(mgs) = cx(mgs,li)*qhcni(mgs)/qx(mgs,li)
20609! chcnih(mgs) = rho0(mgs)*qhcni(mgs)/(1.6e-10)
20610 chcnih(mgs) = min(chcni(mgs), rho0(mgs)*qhcni(mgs)/(r*xvmn(lh)) )
20611! vhcni(mgs) = rho0(mgs)*2.0*qhcni(mgs)/(xdn(mgs,li) + tmp)
20612 vhcni(mgs) = rho0(mgs)*qhcni(mgs)/r
20613 ENDIF
20614
20615 ELSEIF ( iglcnvi == 3 ) THEN
20616
20617 IF ( temg(mgs) .lt. 273.0 .and. qiacw(mgs)*dtp > 2.*qxmin(lh) .and. gamice73fac*xmas(mgs,li) > xdnmn(lh)*xvmn(lh) ) THEN
20618
20619
20620 tmp = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
20621 & *((0.60)*vtxbar(mgs,li,1)) &
20622 & /(temg(mgs)-273.15))**(rimc2)
20623 tmp = min( max( rimc3, tmp ), 900.0 )
20624
20625 ! Assume that half the volume of the embryo is rime with density 'tmp'
20626 ! m = rhoi*(V/2) + rhorime*(V/2) = (rhoi + rhorime)*V/2
20627 ! V = 2*m/(rhoi + rhorime)
20628
20629! write(0,*) 'rime dens = ',tmp
20630 ! convert to particles with the mass of the mass-weighted diameter
20631 ! massofmwr = gamice73fac*xmas(mgs,li)
20632
20633 IF ( tmp .ge. xdnmn(lh) ) THEN
20634 r = max( 0.5*(xdn(mgs,li) + tmp), xdnmn(lh) )
20635! r = Max( r, 400. )
20636 qhcni(mgs) = 0.5*qiacw(mgs)
20637 chcni(mgs) = qhcni(mgs)/(gamice73fac*xmas(mgs,li))
20638 chcnih(mgs) = min(chcni(mgs), rho0(mgs)*qhcni(mgs)/(r*xvmn(lh)) )
20639! vhcni(mgs) = rho0(mgs)*2.0*qhcni(mgs)/(xdn(mgs,li) + tmp)
20640 vhcni(mgs) = rho0(mgs)*qhcni(mgs)/r
20641 ENDIF
20642
20643 ENDIF
20644
20645
20646 ENDIF
20647 ENDIF
20648
20649
20650 ENDDO
20651
20652
20653 qhlcnh(:) = 0.0
20654 chlcnh(:) = 0.0
20655 chlcnhhl(:) = 0.0
20656 vhlcnh(:) = 0.0
20657 vhlcnhl(:) = 0.0
20658 zhlcnh(:) = 0.0
20659
20660 qhcnhl(:) = 0.0
20661 chcnhl(:) = 0.0
20662 vhcnhl(:) = 0.0
20663 zhcnhl(:) = 0.0
20664
20665
20666 IF ( lhl .gt. 1 ) THEN
20667
20668 IF ( ihlcnh == 1 .or. ihlcnh == 3 ) THEN
20669
20670!
20671! Graupel (h) conversion to hail (hl) based on Milbrandt and Yau 2005b
20672!
20673 DO mgs = 1,ngscnt
20674
20675! IF ( lhl .gt. 1 .and. ipconc .ge. 5 .and. qx(mgs,lh) .gt. 1.0e-3 .and.
20676! : xdn(mgs,lh) .gt. 750. .and. qhshr(mgs) .lt. 0.0 .and.
20677! : xdia(mgs,lh,3) .gt. 1.e-3 ) THEN
20678 IF ( hlcnhdia > 0 ) THEN
20679 ltest = xdia(mgs,lh,3) .gt. hlcnhdia ! test on mean volume diameter
20680 ELSE
20681! ltest = xdia(mgs,lh,1)*(3. + alpha(mgs,lh)) > Abs( hlcnhdia ) ! test on maximum mass diameter
20682 ltest = xdia(mgs,lh,1)*(4. + alpha(mgs,lh)) > abs( hlcnhdia ) ! test on mass-weighted diameter
20683 ENDIF
20684
20685 ! if incwet > 0, then should use dhwet here to avoid calculating again
20686 IF ( iusedw == 0 .and. ihlcnh == 1 ) THEN
20687 dg0(mgs) = -1.
20688 ELSE
20689 IF ( temg(mgs) .le. tfr+hailcnvtoffset .and. &
20690 (( (qhacw(mgs) + qhacr(mgs))*dtp > qxmin(lh) .and. qx(mgs,lh) > hlcnhqmin &
20691 .and. temg(mgs) .gt. dwtempmin ) .or. ( wetgrowth(mgs) .and. qx(mgs,lh) > hlcnhqmin )) ) THEN
20692! 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 )
20693! dwr = 0.01*( Exp( -temcg(mgs)/( 1.1e4 * rho0(mgs)*(ehw(mgs)*qx(mgs,lc)+ehr(mgs)*qx(mgs,lr)) - &
20694! 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0 ) ) - 1.0 )
20695 IF ( incwet > 0 ) THEN
20696 d = dhwet(mgs)
20697 ELSE
20698 ! First guess for dwet (not that good, but it is something)
20699 x = 1.1e4 * rho0(mgs)*(ehw(mgs)*qx(mgs,lc)+ehr(mgs)*qx(mgs,lr)) - &
20700 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0
20701 IF ( x > 1.e-20 ) THEN
20702 arg = min(70.0, (-temcg(mgs)/x )) ! prevent overflow of the exp function in 32 bit
20703 dwr = 0.01*(exp(arg) - 1.0)
20704 ELSE
20705 dwr = 1.e30
20706 ENDIF
20707 d = min(dwr, dg0thresh + 0.0001)
20708 IF ( dwr < 0.2 .and. dwr > 0.0 .and. rho0(mgs)*(qx(mgs,lc)+qx(mgs,lr)) > 1.e-4 ) THEN
20709 sqrtrhovt = sqrt( rhovt(mgs) )
20710 fventh = sqrtrhovt*(fpndl(mgs)**(1./3.)) * (fakvisc(mgs))**(-0.5)
20711 fventm = sqrtrhovt*(fschm(mgs)**(1./3.)) * (fakvisc(mgs))**(-0.5)
20712 ltemq = (tfr-163.15)/fqsat+1.5
20713 qvs0 = pqs(mgs)*tabqvs(ltemq)
20714 denomdp = felf(mgs) + fcw(mgs)*temcg(mgs)
20715 denominvdp = 1.d0/(felf(mgs) + fcw(mgs)*temcg(mgs))
20716
20717! write(91,*) 'dw,dwr,temcg = ',100.*dw,100.*dwr,temcg(mgs)
20718 h1 = ( -ftka(mgs)*temcg(mgs) - felv(mgs)*fwvdf(mgs)*rho0(mgs)*(qx(mgs,lv) - qvs0) )
20719 h2 = ehi(mgs)*qx(mgs,li)*rho0(mgs)*fci(mgs)*temcg(mgs)
20720 h3 = max(dwehwmin, ehw(mgs))*qx(mgs,lc)
20721 h4 = ehr(mgs)* qx(mgs,lr)
20722 ! iterate to find minimum diameter for wet growth. Start with value of dwr
20723 DO n = 1,10
20724 d = max(d, 1.e-4)
20725 dold = d
20726 vth = axx(mgs,lh)*d**bxx(mgs,lh)
20727 x2 = fventh*sqrtrhovt*sqrt(d*vth)
20728 IF ( x2 > 1.4 ) THEN
20729 ah = 0.78 + 0.308*x2 ! heat ventillation
20730 ELSE
20731 ah = 1.0 + 0.108*x2**2 ! mass ventillation (Beard and Pruppacher 1971, eq. 9)
20732 ENDIF
20733
20734 IF ( .false. ) THEN ! this option includes 'am' separate from ah, which makes only small differences. Otherwise equivalent to second option
20735 x1 = fventm*sqrtrhovt*sqrt(d*vth)
20736 IF ( x1 > 1.4 ) THEN
20737 am = 0.78 + 0.308*x1 ! mass ventillation (Beard and Pruppacher 1971, eq. 8)
20738 ELSE
20739 am = 1.0 + 0.108*x1**2 ! mass ventillation (Beard and Pruppacher 1971, eq. 9)
20740 ENDIF
20741
20742 d = 8.*denominvdp*( am*felv(mgs)*fwvdf(mgs)*rho0(mgs)*(qvs0 - qx(mgs,lv)) - ah*ftka(mgs)*temcg(mgs) )/ &
20743 (dtp* ( ( max(0.001,vth - vtxbar(mgs,lc,1))*h3 + &
20744 max(0.001,vth - vtxbar(mgs,lr,1))*h4) *rho0(mgs) + &
20745 max(0.001,vth - vtxbar(mgs,li,1))*h2*denominvdp))
20746
20747 ELSE
20748
20749 ! Based on Farley and Orville (1986), eq. 5-9 but neglecting the Ci*(T0-Ts) term in (8) since we want Ts=T0
20750 ! Simplified mass rates as dm_w/dt = pi/4*d**2*(Vh - Vc)*rhoair*qc*ehw, etc.
20751 d = 8.*ah*h1/ &
20752 ( ( max(0.001,vth - vtxbar(mgs,lc,1))*h3 + &
20753 max(0.001,vth - vtxbar(mgs,lr,1))*h4) *rho0(mgs)*denomdp + &
20754 max(0.001,vth - vtxbar(mgs,li,1))*h2)
20755
20756 ENDIF
20757 IF ( abs(dold - d)/dold < 0.05 .or. ( n > 3 .and. d > dg0thresh ) ) EXIT
20758
20759 ENDDO
20760
20761 d = min( d, dg0thresh + 0.0001 )
20762 ENDIF ! dwr < 0.2 .and. dwr > 0.0
20763 ENDIF ! incwet
20764
20765 ! dg0(mgs) = Min( dwmax, Max( d, dwmin ) )
20766 dg0(mgs) = max( d, dwmin )
20767 ELSE
20768 ! IF ( qx(mgs,lh) > qxmin(lh) .and. qx(mgs,lh) > hlcnhqmin .and. temg(mgs) .le. tfr+hailcnvtoffset ) THEN
20769 ! dg0(mgs) = dwmax
20770 ! ELSE
20771 dg0(mgs) = dg0thresh + 0.0001
20772 ! ENDIF
20773 ENDIF
20774
20775 IF ( ihlcnh == 3 .and. (qhacw(mgs) + qhacr(mgs))*dtp > qxmin(lh) .and. qx(mgs,lh) > hlcnhqmin &
20776 .and. temg(mgs) .le. tfr+hailcnvtoffset .and. temg(mgs) > 238.0 ) THEN
20777 ! set a secondary condition on to capture large graupel that is riming but not in wet growth
20778! dg0(mgs) = Min( dg0(mgs), dg0thresh - 0.0001 )
20779 dg0(mgs) = min( dg0(mgs), dwmax )
20780 ENDIF
20781
20782 ENDIF
20783
20784 wtest = (dg0(mgs) > 0.0 .and. dg0(mgs) < dg0thresh )
20785
20786 IF ( ihlcnh == 1 ) THEN ! .or. iusedw == 0 THEN
20787
20788 IF ( ( wetgrowth(mgs) .and. (xdn(mgs,lh) .gt. hldnmn .or. lvh < 1 ) .and. & ! correct this when hail gets turned on
20789 & rimdn(mgs,lh) .gt. 800. .and. &
20790 & ltest .and. qx(mgs,lh) .gt. hlcnhqmin ) .or. wtest ) THEN ! {
20791! : xdia(mgs,lh,3) .gt. 2.e-3 .and. qx(mgs,lh) .gt. 1.0e-3 THEN ! 0823.2008 erm test
20792! IF ( xdia(mgs,lh,3) .gt. 1.e-3 ) THEN
20793 IF ( qhacw(mgs) .gt. 0.0 .and. qhacw(mgs) .gt. qhaci(mgs) .and. temg(mgs) .le. tfr+hailcnvtoffset ) THEN ! {
20794 ! dh0 is the diameter dividing wet growth from dry growth (Ziegler 1985), modified by MY05
20795! dh0 = 0.01*(exp(temcg(mgs)/(1.1e4*(qx(mgs,lc)+qx(mgs,lr)) -
20796! : 1.3e3*qx(mgs,li) + 1.0e-3 ) ) - 1.0)
20797 IF ( wtest ) THEN
20798 dh0 = dg0(mgs)
20799 ELSE
20800 x = (1.1e4*(rho0(mgs)*qx(mgs,lc)) - 1.3e3*rho0(mgs)*qx(mgs,li) + 1.0e-3 )
20801 IF ( x > 1.e-20 ) THEN
20802 arg = min(70.0, (-temcg(mgs)/x )) ! prevent overflow of the exp function in 32 bit
20803 dh0 = 0.01*(exp(arg) - 1.0)
20804 ELSE
20805 dh0 = 1.e30
20806 ENDIF
20807 dg0(mgs) = min(dh0, dg0thresh + 0.0001)
20808 ENDIF ! wtest
20809! dh0 = Max( dh0, 5.e-3 )
20810
20811! IF ( dh0 .gt. 0.0 ) write(0,*) 'dh0 = ',dh0
20812! IF ( dh0 .gt. 1.0e-4 ) THEN
20813 IF ( xdia(mgs,lh,3)/dh0 .gt. 0.1 ) THEN !{
20814! IF ( xdia(mgs,lh,3) .lt. 20.*dh0 .and. dh0 .lt. 2.0*xdia(mgs,lh,3) ) THEN
20815 tmp = qhacw(mgs) + qhacr(mgs) + qhaci(mgs) + qhacs(mgs)
20816! qtmp = Min( 1.0, xdia(mgs,lh,3)/(2.0*dh0) )*(tmp)
20817 qtmp = min( 100.0, xdia(mgs,lh,3)/(2.0*dh0) )*(tmp)
20818 qhlcnh(mgs) = min( qxmxd(mgs,lh), qtmp )
20819
20820 IF ( ipconc .ge. 5 ) THEN !{
20821! dh0 = Max( xdia(mgs,lh,3), Min( dh0, 5.e-3 ) ) ! do not create hail greater than 5mm diam. unless the graupel is larger
20822 IF ( .not. wtest ) dh0 = min( dh0, 10.e-3 ) ! do not create hail greater than 10mm diam., which is the max graupel size
20823 IF ( qx(mgs,lhl) > 0.1e-3 ) dh0 = max( dh0, xdia(mgs,lhl,3) ) ! when enough hail is established, do not dilute the size
20824 chlcnhhl(mgs) = min( cxmxd(mgs,lh), rho0(mgs)*qhlcnh(mgs)/(pi*xdn(mgs,lh)*dh0**3/6.0) )
20825
20826 r = rho0(mgs)*qhlcnh(mgs)/(xdn(mgs,lh)*xv(mgs,lh)) ! number of graupel particles at mean volume diameter
20827 chlcnh(mgs) = max( chlcnhhl(mgs), r )
20828 ENDIF !}
20829
20830 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
20831 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/max(xdnmn(lhl), xdn(mgs,lh))
20832
20833 ENDIF !}
20834
20835 ENDIF ! }
20836 ENDIF ! }
20837
20838 ELSEIF ( ihlcnh == 3 ) THEN !{
20839
20840
20841 IF ( wtest .and. &
20842 ( qhacw(mgs)*dtp > qxmin(lh) .and. temg(mgs) .lt. tfr+hailcnvtoffset .and. qx(mgs,lh) > hlcnhqmin ) ) THEN
20843 ! convert number, mass, and reflectivity for d > dw
20844 IF ( ipconc == 5 ) THEN
20845 ! dg0(mgs) = Min( dg0(mgs), hldia1 )
20846 !dg0(mgs) = hldia1
20847 ENDIF
20848
20849 ratio = min( maxratiolu, dg0(mgs)/xdia(mgs,lh,1) )
20850
20851
20852 ! mass
20853 tmp2 = gaminterp(ratio,alpha(mgs,lh),4,1)
20854 IF ( ipconc == 5 ) THEN
20855 ! tmp2 = Min( 0.25, tmp2 )
20856 ENDIF
20857 qxd1 = qx(mgs,lh)*(tmp2)
20858 qhlcnh(mgs) = dtpinv*qxd1
20859 flim = 1.0
20860 tmp3 = qxmxd(mgs,lh)
20861 IF (qxd1 > tmp3 ) THEN
20862! flim = tmp3/(qxd1)
20863! qhlcnh(mgs) = flim*qhlcnh(mgs)
20864 ENDIF
20865
20866
20867
20868 IF ( ( qxd1 > qxmin(lhl) .and. ipconc > 5 ) .or. ( qxd1 > 10.*qxmin(lhl) .and. ipconc == 5) ) THEN
20869
20870 ! number
20871 tmp = gaminterp(ratio,alpha(mgs,lh),1,1)
20872 IF ( ipconc == 5 ) THEN
20873 ! tmp = Min( 0.2, tmp )
20874 ENDIF
20875 cxd1 = flim*cx(mgs,lh)*( tmp)
20876 chlcnh(mgs) = dtpinv*cxd1
20877 chlcnhhl(mgs) = chlcnh(mgs)
20878
20879 IF ( qx(mgs,lhl) > qxmin(lhl) .and. dmhlopt > 0 ) THEN
20880 tmp = rho0(mgs)*qhlcnh(mgs)/chlcnhhl(mgs)
20881 IF ( tmp < xmas(mgs,lhl) ) THEN
20882 ! dh0 = ( qxd1*dh0 + qx(mgs,lhl)*xmas(mgs,lhl))/( qxd1 + qx(mgs,lhl)) ! weighted average
20883 dh0 = (( qxd1*tmp**(1./3.) + qx(mgs,lhl)*xmas(mgs,lhl)**(1./3.))/( qxd1 + qx(mgs,lhl)))**3 ! weighted average
20884 chlcnhhl(mgs) = min( chlcnhhl(mgs), rho0(mgs)*qhlcnh(mgs)/dh0 )
20885 ELSE
20886! dh0 = Max( dh0, xmas(mgs,lhl) ) ! when enough hail is established, do not dilute the size
20887 ENDIF
20888 ENDIF
20889
20890
20891 ! reflectivity
20892 IF ( ipconc >= 6 .and. lzh > 1 .and. lzhl > 1 ) THEN
20893 tmp3 = gaminterp(ratio,alpha(mgs,lh),11,1)
20894 zxd1 = flim*zx(mgs,lh)*(tmp3)
20895 zhlcnh(mgs) = dtpinv*zxd1
20896
20897 ! tmp4 is the Z from the converted particles assuming shape of alphamax
20898 tmp3 = g1xmax*(rho0(mgs)*qxd1)**2/((pi*xdn(mgs,lh)/6.0)**2)
20899 tmp4 = tmp3/cxd1
20900 IF ( tmp4 > zxd1 ) THEN ! calculate new hail number to match zxd1
20901 ! increase cxd1 to make z,q,c rates consistent
20902 ! cxd1 = g1xmax*(rho0(mgs)*qxd1)**2/(zxd1*(pi*xdn(mgs,lh)/6.0)**2)
20903 cxd1 = tmp3/zxd1
20904 chlcnhhl(mgs) = dtpinv*cxd1
20905 ENDIF
20906 ELSE
20907 zxd1 = 0
20908 ENDIF
20909 IF ( ipconc == 5 ) THEN ! Adjust cxd1 by reflectivity removed from graupel
20910 tmp3 = gaminterp(ratio,alpha(mgs,lh),11,1)
20911 ! tmp5 is graupel reflectivity moment
20912 tmp5 = g1x(mgs,lh)*(rho0(mgs)*qx(mgs,lh))**2/((pi*xdn(mgs,lh)/6.)**2*cx(mgs,lh))
20913 zxd1 = flim*(tmp3)*tmp5
20914 ! tmp4 is the reflectivity of the newly-converted graupel particles (use g1x(lh) for loss term)
20915 ! which we want to match zxd1 to prevent spurious increase in total reflectivity
20916 tmp3 = g1x(mgs,lh)*(rho0(mgs)*qxd1)**2/((pi*xdn(mgs,lh)/6.0)**2)
20917 tmp4 = tmp3/cxd1
20918 IF ( tmp4 > zxd1 ) THEN ! calculate new hail number to match zxd1
20919 ! cxd1 = g1x(mgs,lhl)*(rho0(mgs)*qxd1)**2/(zxd1*pi*xdn(mgs,lh)/6.0) ! trial form results in tiny hail
20920 ! want the adjust size of the new hail so that Z is conserved, so increase number of
20921 ! particles to make qxd1,zxd1, and C consistent.
20922 ! want zxd1 = g1x(mgs,lh)*(rho0(mgs)*qxd1)**2/(c*(pi*xdn(mgs,lh)/6.0)**2)
20923 ! Use g1x(mgs,lh) here instead of g1x(mgs,lhl) because rzxhlh will then multiply
20924 ! by g1x(mgs,lhl)/g1x(mgs,lh)
20925 ! cxd1 = g1x(mgs,lh)*(rho0(mgs)*qxd1)**2/(zxd1*(pi*xdn(mgs,lh)/6.0)**2)
20926 cxd1 = tmp3/zxd1
20927 chlcnhhl(mgs) = dtpinv*cxd1 ! multiplied later by rzxhlh(mgs)
20928 ENDIF
20929 ENDIF
20930
20931
20932 ELSE
20933 qhlcnh(mgs) = 0.0
20934 ENDIF
20935
20936 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
20937 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/max(xdnmn(lhl), xdn(mgs,lh))
20938
20939 ENDIF
20940
20941
20942 ENDIF !}
20943
20944 ENDDO
20945
20946 ELSEIF ( ihlcnh == 2 ) THEN ! 10-ice type conversion
20947
20948!
20949! Staka and Mansell (2005) type conversion
20950!
20951! hldia1 is set in micro_module and namelist
20952! IF ( .true. ) THEN
20953
20954 ! convert number, mass, and reflectivity for d > hldia1,
20955 ! regardless of wet growth status, but as long as riming > 0
20956 DO mgs = 1,ngscnt
20957 IF ( qhacw(mgs)*dtp > qxmin(lh) .and. temg(mgs) .lt. tfr+hailcnvtoffset .and. qx(mgs,lh) > qxmin(lh) ) THEN
20958 ratio = min( maxratiolu, hldia1/xdia(mgs,lh,1) )
20959
20960 ! number
20961 tmp = gaminterp(ratio,alpha(mgs,lh),1,1)
20962 cxd1 = cx(mgs,lh)*( tmp)
20963 chlcnh(mgs) = dtpinv*cxd1
20964 chlcnhhl(mgs) = chlcnh(mgs)
20965
20966 ! mass
20967 tmp2 = gaminterp(ratio,alpha(mgs,lh),4,1)
20968 qxd1 = qx(mgs,lh)*(tmp2)
20969 qhlcnh(mgs) = dtpinv*qxd1
20970
20971 ! reflectivity
20972 IF ( lzh > 1 .and. lzhl > 1 ) THEN
20973 tmp3 = gaminterp(ratio,alpha(mgs,lh),11,1)
20974 zxd1 = zx(mgs,lh)*(tmp3)
20975 zhlcnh(mgs) = dtpinv*zxd1
20976 ELSE
20977 zxd1 = 0
20978 ENDIF
20979 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
20980 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/max(xdnmn(lhl), xdn(mgs,lh))
20981
20982 ENDIF
20983
20984 ENDDO
20985! ENDIF
20986 ELSEIF ( ihlcnh == 0 ) THEN
20987
20988 do mgs = 1,ngscnt
20989! qhlcnh(mgs) = 0.0
20990! chlcnh(mgs) = 0.0
20991 if ( wetgrowth(mgs) .and. temg(mgs) .lt. tfr-5. .and. qx(mgs,lh) > qxmin(lh) ) then
20992 if ( qhacw(mgs).gt.1.e-6 .and. ( xdn(mgs,lh) > 700. .or. lvh == 0 ) ) then
20993 qhlcnh(mgs) = &
20994 ((pi*xdn(mgs,lh)*cx(mgs,lh)) / (6.0*rho0(mgs)*dtp)) &
20995 *exp(-hldia1/xdia(mgs,lh,1)) &
20996 *( (hldia1**3) + 3.0*(hldia1**2)*xdia(mgs,lh,1) &
20997 + 6.0*(hldia1)*(xdia(mgs,lh,1)**2) + 6.0*(xdia(mgs,lh,1)**3) )
20998 qhlcnh(mgs) = min(qhlcnh(mgs),qhmxd(mgs))
20999 IF ( ipconc .ge. 5 ) THEN
21000 chlcnh(mgs) = min( cxmxd(mgs,lh), cx(mgs,lh)*exp(-hldia1/xdia(mgs,lh,1)))
21001 chlcnhhl(mgs) = chlcnh(mgs)
21002! chlcnh(mgs) = Min( cxmxd(mgs,lh), rho0(mgs)*qhlcnh(mgs)/(2.0*xmas(mgs,lh) ))
21003 ENDIF
21004 vhlcnh(mgs) = rho0(mgs)*qhlcnh(mgs)/xdn(mgs,lh)
21005 vhlcnhl(mgs) = rho0(mgs)*qhlcnh(mgs)/max(xdnmn(lhl), xdn(mgs,lh))
21006 end if
21007 end if
21008 end do
21009
21010! ENDIF ! true
21011
21012 ENDIF ! ihlcnh options
21013
21014 ! convert low-density hail to graupel
21015 IF ( icvhl2h >= 1 ) THEN
21016 DO mgs = 1,ngscnt
21017 IF ( qx(mgs,lhl) > qxmin(lhl) .and. xdn(mgs,lhl) < 0.5*(xdnmn(lhl) + xdnmx(lhl)) ) THEN
21018 tmp = min(0.95, 1. - 0.5*(1. + tanh(0.125*(xdn(mgs,lhl) - 1.01*xdnmn(lhl) )) ))
21019 qhcnhl(mgs) = tmp*qx(mgs,lhl)*dtpinv
21020 chcnhl(mgs) = cx(mgs,lhl)*qhcnhl(mgs)/qx(mgs,lhl)
21021 vhcnhl(mgs) = vx(mgs,lhl)*qhcnhl(mgs)/qx(mgs,lhl)
21022
21023 ENDIF
21024 ENDDO
21025
21026 ENDIF
21027
21028 ENDIF ! lhl > 1
21029
21030
21031
21032
21033!
21034! Ziegler snow conversion to graupel
21035!
21036 DO mgs = 1,ngscnt
21037
21038 qhcns(mgs) = 0.0
21039 chcns(mgs) = 0.0
21040 chcnsh(mgs) = 0.0
21041 vhcns(mgs) = 0.0
21042
21043 qscnh(mgs) = 0.0
21044 cscnh(mgs) = 0.0
21045 vscnh(mgs) = 0.0
21046
21047 IF ( ipconc .ge. 5 ) THEN
21048
21049 ! test attempt at converting graupel to snow when not riming but growing by deposition
21050 IF ( temg(mgs) < tfr .and. qx(mgs,lh) .gt. qxmin(lh) .and. qhdpv(mgs) > qxmin(lh)*dtpinv &
21051 & .and. qhacw(mgs) < qxmin(lh)*dtpinv ) THEN
21052 IF ( xdn(mgs,lh) < 290. ) THEN
21053! qscnh(mgs) = 2.*qhdpv(mgs)
21054! cscnh(mgs) = cx(mgs,lh)*qscnh(mgs)/qx(mgs,lh)
21055! vscnh(mgs) = rho0(mgs)*qscnh(mgs)/xdn(mgs,lh)
21056 ENDIF
21057 ENDIF
21058
21059
21060 IF ( qx(mgs,ls) .gt. qxmin(ls) .and. qsacw(mgs) .gt. 0.0 ) THEN
21061
21062! DATA VGRA/1.413E-2/ ! this is the volume (cm**3) of a 3mm diam. sphere
21063! vgra = 1.4137e-8 m**3
21064
21065! DNNET=DNCNV-DNAGG
21066! DQNET=QXCON+QSACC+SDEP
21067!
21068! DNSCNV=EXP(-(ROS*XNS*VGRA/(RO*QI)))*((1.-(XNS*VGRA*ROS/
21069! / (RO*QI)))*DNNET + (XNS**2*VGRA*ROS/(RO*QI**2))*DQNET)
21070! IF(DNSCNV.LT.0.) DNSCNV=0.
21071!
21072! QIHC=(ROS*VGRA/RO)*DNSCNV
21073!
21074! QH=QH+DT*QIHC
21075! QI=QI-DT*QIHC
21076! XNH=XNH+DT*DNSCNV
21077! XNS=XNS-DT*DNSCNV
21078
21079 IF ( iglcnvs .eq. 1 ) THEN ! Zrnic, Ziegler et al (1993)
21080
21081 dnnet = cscnvis(mgs) + cscnis(mgs) - csacs(mgs)
21082 dqnet = qscnvi(mgs) + qscni(mgs) + qsacw(mgs) + qsdpv(mgs) + qssbv(mgs)
21083
21084 a3 = 1./(rho0(mgs)*qx(mgs,ls))
21085 a1 = exp( - xdn(mgs,ls)*cx(mgs,ls)*vgra*a3 ) !! EXP(-(ROS*XNS*VGRA/(RO*QI)))
21086! (1.-(XNS*VGRA*ROS/(RO*QI)))*DNNET
21087 a2 = (1.-(cx(mgs,ls)*vgra*xdn(mgs,ls)*a3))*dnnet
21088! (XNS**2*VGRA*ROS/(RO*QI**2))*DQNET
21089 a4 = cx(mgs,ls)**2*vgra*xdn(mgs,ls)*a3/qx(mgs,ls)*dqnet
21090
21091 chcns(mgs) = max( 0.0, a1*(a2 + a4) )
21092 chcns(mgs) = min( chcns(mgs), cxmxd(mgs,ls) )
21093 chcnsh(mgs) = chcns(mgs)
21094
21095 qhcns(mgs) = min( xdn(mgs,ls)*vgra*rhoinv(mgs)*chcns(mgs), qxmxd(mgs,ls) )
21096 vhcns(mgs) = rho0(mgs)*qhcns(mgs)/max(xdn(mgs,ls),xdnmn(lh))
21097! vhcns(mgs) = rho0(mgs)*qhcns(mgs)/Max(xdn(mgs,ls),400.)
21098
21099 ELSEIF ( iglcnvs .ge. 2 ) THEN ! treat like ice crystals, i.e., check for rime density (ERM)
21100
21101 IF ( temg(mgs) .lt. 273.0 .and. ( qsacw(mgs) - qsdpv(mgs) .gt. 0.0 .or. &
21102 ( iglcnvs >= 3 .and. qsacw(mgs)*dtp > 2.*qxmin(lh) .and. gamsnow73fac*xmas(mgs,ls) > xdnmn(lh)*xvmn(lh) ) ) ) THEN !{
21103
21104
21105 tmp = rimc1*(-((0.5)*(1.e+06)*xdia(mgs,lc,1)) &
21106 & *((0.60)*vtxbar(mgs,ls,1)) &
21107 & /(temg(mgs)-273.15))**(rimc2)
21108! tmp = Min( Max( rimc3, tmp ), 900.0 )
21109 tmp = min( tmp , 900.0 )
21110
21111 ! Assume that half the volume of the embryo is rime with density 'tmp'
21112 ! m = rhoi*(V/2) + rhorime*(V/2) = (rhoi + rhorime)*V/2
21113 ! V = 2*m/(rhoi + rhorime)
21114
21115! write(0,*) 'rime dens = ',tmp
21116
21117 IF ( iglcnvs == 2 ) THEN !{
21118 IF ( tmp .ge. 200.0 ) THEN
21119 r = max( 0.5*(xdn(mgs,ls) + tmp), xdnmn(lh) )
21120! r = Max( r, 400. )
21121 qhcns(mgs) = (qsacw(mgs) - qsdpv(mgs))
21122 chcns(mgs) = cx(mgs,ls)*qhcns(mgs)/qx(mgs,ls)
21123! chcnih(mgs) = rho0(mgs)*qhcni(mgs)/(1.6e-10)
21124 chcnsh(mgs) = min(chcns(mgs), rho0(mgs)*qhcns(mgs)/(r*xvmn(lh)) )
21125! vhcni(mgs) = rho0(mgs)*2.0*qhcni(mgs)/(xdn(mgs,li) + tmp)
21126 vhcns(mgs) = rho0(mgs)*qhcns(mgs)/r
21127 ENDIF
21128
21129 ELSEIF ( iglcnvs == 3 ) THEN
21130
21131 ! convert to particles with the mass of the mass-weighted diameter
21132 ! massofmwr = gamice73fac*xmas(mgs,li)
21133
21134 IF ( tmp > xdnmn(lh) ) THEN
21135 r = max( 0.5*(xdn(mgs,ls) + tmp), xdnmn(lh) )
21136! r = Max( r, 400. )
21137 qhcns(mgs) = 0.5*qsacw(mgs)
21138 chcns(mgs) = qhcns(mgs)/(gamsnow73fac*xmas(mgs,ls))
21139 chcns(mgs) = min( chcns(mgs), cx(mgs,ls)*qhcns(mgs)/qx(mgs,ls))
21140 chcnsh(mgs) = min(chcns(mgs), rho0(mgs)*qhcns(mgs)/(r*xvmn(lh)) )
21141 vhcns(mgs) = rho0(mgs)*qhcns(mgs)/r
21142 ENDIF
21143
21144 ENDIF !}
21145
21146 ENDIF !}
21147
21148 ENDIF
21149
21150
21151 ENDIF
21152
21153 ELSE ! single moment lfo
21154
21155 qhcns(mgs) = 0.001*ehscnv(mgs)*max((qx(mgs,ls)-6.e-4),0.0)
21156 qhcns(mgs) = min(qhcns(mgs),qxmxd(mgs,ls))
21157 IF ( lvol(lh) .ge. 1 ) vhcns(mgs) = rho0(mgs)*qhcns(mgs)/max(xdn(mgs,ls),400.)
21158
21159 ENDIF
21160 ENDDO
21161!
21162!
21163! heat budget for rain---not all rain that collects ice can freeze
21164!
21165!
21166!
21167 if ( irwfrz .gt. 0 .and. .not. mixedphase) then
21168!
21169 do mgs = 1,ngscnt
21170!
21171! compute total rain that freeze when it interacts with cloud ice
21172!
21173 qrztot(mgs) = qrfrz(mgs) + qiacr(mgs) + qsacr(mgs)
21174!
21175! compute the maximum amount of rain that can freeze
21176! Used to limit freezing to 4*qrmxd, but now allow all rain to freeze if possible
21177!
21178 qrzmax(mgs) = &
21179 & ( xdia(mgs,lr,1)*rwvent(mgs)*cx(mgs,lr)*fwet1(mgs) )
21180 qrzmax(mgs) = max(qrzmax(mgs), 0.0)
21181 qrzmax(mgs) = min(qrztot(mgs), qrzmax(mgs))
21182 qrzmax(mgs) = min(qx(mgs,lr)*dtpinv, qrzmax(mgs))
21183
21184 IF ( temcg(mgs) < -30. ) THEN ! allow all to freeze if T < -30 because fwet becomes invalid (negative)
21185 qrzmax(mgs) = qx(mgs,lr)*dtpinv
21186 ENDIF
21187! qrzmax(mgs) = min(4.*qrmxd(mgs), qrzmax(mgs))
21188!
21189! compute the correction factor
21190!
21191! IF ( qrztot(mgs) .gt. qxmin(lr) ) THEN
21192 IF ( qrztot(mgs) .gt. qrzmax(mgs) .and. qrztot(mgs) .gt. qxmin(lr) ) THEN
21193 qrzfac(mgs) = qrzmax(mgs)/(qrztot(mgs))
21194 ELSE
21195 qrzfac(mgs) = 1.0
21196 ENDIF
21197 qrzfac(mgs) = min(1.0, qrzfac(mgs))
21198!
21199 end do
21200!
21201!
21202! now correct the above sources
21203!
21204!
21205 do mgs = 1,ngscnt
21206 if ( temg(mgs) .le. 273.15 .and. qrzfac(mgs) .lt. 1.0 ) then
21207 qrfrz(mgs) = qrzfac(mgs)*qrfrz(mgs)
21208 qrfrzs(mgs) = qrzfac(mgs)*qrfrzs(mgs)
21209 qrfrzf(mgs) = qrzfac(mgs)*qrfrzf(mgs)
21210 qiacr(mgs) = qrzfac(mgs)*qiacr(mgs)
21211 qsacr(mgs) = qrzfac(mgs)*qsacr(mgs)
21212 qiacrf(mgs) = qrzfac(mgs)*qiacrf(mgs)
21213 qiacrs(mgs) = qrzfac(mgs)*qiacrs(mgs)
21214 crfrz(mgs) = qrzfac(mgs)*crfrz(mgs)
21215 crfrzf(mgs) = qrzfac(mgs)*crfrzf(mgs)
21216 crfrzs(mgs) = qrzfac(mgs)*crfrzs(mgs)
21217 ciacr(mgs) = qrzfac(mgs)*ciacr(mgs)
21218 ciacrf(mgs) = qrzfac(mgs)*ciacrf(mgs)
21219 ciacrs(mgs) = qrzfac(mgs)*ciacrs(mgs)
21220
21221! IF ( lzh .gt. 1 ) THEN
21222! zrfrzf(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,lr)+2.)/(xdn0(lr)**2*(alpha(mgs,lr)+1.)) * &
21223! ( 2.*tmp * qrfrzf(mgs) - tmp**2 * crfrzf(mgs) )
21224! ENDIF
21225
21226 vrfrzf(mgs) = qrzfac(mgs)*vrfrzf(mgs)
21227 viacrf(mgs) = qrzfac(mgs)*viacrf(mgs)
21228 end if
21229 end do
21230!
21231!
21232!
21233 end if
21234!
21235!
21236!
21237! evaporation of rain
21238!
21239!
21240!
21241 qrcev(:) = 0.0
21242 crcev(:) = 0.0
21243
21244
21245 do mgs = 1,ngscnt
21246!
21247 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
21248
21249 qrcev(mgs) = &
21250 & fvce(mgs)*cx(mgs,lr)*rwvent(mgs)*rwcap(mgs)*evapfac
21251! this line to allow condensation on rain:
21252 IF ( rcond .eq. 1 ) THEN
21253 qrcev(mgs) = min(qrcev(mgs), qxmxd(mgs,lv))
21254! this line to have evaporation only:
21255 ELSE
21256 qrcev(mgs) = min(qrcev(mgs), 0.0)
21257 ENDIF
21258
21259 qrcev(mgs) = max(qrcev(mgs), -qrmxd(mgs))
21260! if ( temg(mgs) .lt. 273.15 ) qrcev(mgs) = 0.0
21261 IF ( qrcev(mgs) .lt. 0. .and. lnr > 1 ) THEN
21262! qrcev(mgs) = -qrmxd(mgs)
21263! crcev(mgs) = (rho0(mgs)/(xmas(mgs,lr)+1.e-20))*qrcev(mgs)
21264 IF ( icrcev == 1 ) THEN
21265 crcev(mgs) = (cx(mgs,lr)/(qx(mgs,lr)))*qrcev(mgs)
21266 ELSEIF ( icrcev == 2 ) THEN
21267 crcev(mgs) = (cx(mgs,lr)/(qx(mgs,lr)))*qrcev(mgs)*vtxbar(mgs,lr,2)/vtxbar(mgs,lr,1)
21268 ELSE
21269 crcev(mgs) = 0.0
21270 ENDIF
21271 ELSE
21272 crcev(mgs) = 0.0
21273 ENDIF
21274! if ( temg(mgs) .lt. 273.15 ) crcev(mgs) = 0.0
21275!
21276 ENDIF
21277
21278 end do
21279!
21280! evaporation/condensation of wet graupel and snow
21281!
21282 IF ( lhwlg > 1 ) THEN
21283 qhcevlg(:) = 0.0
21284 chcevlg(:) = 0.0
21285 ENDIF
21286 IF ( lhlwlg > 1 ) THEN
21287 qhlcevlg(:) = 0.0
21288 chlcevlg(:) = 0.0
21289 ENDIF
21290
21291
21292!
21293!
21294!
21295! ICE MULTIPLICATION: Two modes (rimpa, and rimpb)
21296! (following Cotton et al. 1986)
21297!
21298
21299 chmul1(:) = 0.0
21300 chlmul1(:) = 0.0
21301 csmul1(:) = 0.0
21302!
21303 qhmul1(:) = 0.0
21304 qhlmul1(:) = 0.0
21305 qsmul1(:) = 0.0
21306 do mgs = 1,ngscnt
21307
21308 ltest = qx(mgs,lh) .gt. qxmin(lh)
21309 IF ( lhl > 1 ) ltest = ltest .or. qx(mgs,lhl) .gt. qxmin(lhl)
21310
21311 IF ( (itype1 .ge. 1 .or. itype2 .ge. 1 ) &
21312 & .and. qx(mgs,lc) .gt. qxmin(lc)) THEN
21313 if ( temg(mgs) .ge. 265.15 .and. temg(mgs) .le. 271.15 ) then
21314 IF ( ipconc .ge. 2 ) THEN
21315 IF ( xv(mgs,lc) .gt. 0.0 &
21316 & .and. ltest &
21317! .and. itype2 .ge. 2 &
21318 & ) THEN
21319!
21320! Ziegler et al. 1986 Hallett-Mossop process. VSTAR = 7.23e-15 (vol of 12micron radius)
21321!
21322 IF ( alpha(mgs,lc) == 0.0 ) THEN
21323 ex1 = (1./250.)*exp(-7.23e-15/xv(mgs,lc))
21324 ELSE
21325
21326 ratio = (1. + alpha(mgs,lc))*(7.23e-15)/xv(mgs,lc)
21327
21328 IF ( usegamxinfcnu ) THEN
21329 i = nint(dgami*(1. + alpha(mgs,lc)))
21330 gcnup1 = gmoi(i)
21331 ex1 = (1./250.)*gamxinf(1.+alpha(mgs,lc), ratio)/(gcnup1)
21332 ELSE
21333 ratio = min( maxratiolu, ratio )
21334 tmp = gaminterp(ratio,alpha(mgs,lc),1,1)
21335 ex1 = (1./250.)*tmp
21336 ENDIF
21337 ENDIF
21338 IF ( itype2 .le. 2 ) THEN
21339 ft = max(0.0,min(1.0,-0.11*temcg(mgs)**2 - 1.1*temcg(mgs)-1.7))
21340 ELSE
21341 IF ( temg(mgs) .ge. 265.15 .and. temg(mgs) .le. 267.15 ) THEN
21342 ft = 0.5
21343 ELSEIF (temg(mgs) .ge. 267.15 .and. temg(mgs) .le. 269.15 ) THEN
21344 ft = 1.0
21345 ELSEIF (temg(mgs) .ge. 269.15 .and. temg(mgs) .le. 271.15 ) THEN
21346 ft = 0.5
21347 ELSE
21348 ft = 0.0
21349 ENDIF
21350 ENDIF
21351! rhoinv = 1./rho0(mgs)
21352! DNSTAR = ex1*cglacw(mgs)
21353
21354 IF ( ft > 0.0 ) THEN
21355
21356 IF ( itype2 > 0 ) THEN
21357 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. (.not. wetsfc(mgs)) ) THEN
21358 chmul1(mgs) = ft*ex1*chacw(mgs)
21359! 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
21360 qhmul1(mgs) = cimas0*chmul1(mgs)*rhoinv(mgs)
21361 ENDIF
21362 IF ( lhl .gt. 1 ) THEN
21363 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. (.not. wetsfchl(mgs)) ) THEN
21364 chlmul1(mgs) = (ft*ex1*chlacw(mgs))
21365 qhlmul1(mgs) = cimas0*chlmul1(mgs)*rhoinv(mgs)
21366 ENDIF
21367 ENDIF
21368 ENDIF ! itype2
21369
21370 IF ( itype1 > 0 ) THEN
21371 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. (.not. wetsfc(mgs)) ) THEN
21372 tmp = ft*(3.5e+08)*rho0(mgs)*qhacw(mgs)
21373 chmul1(mgs) = chmul1(mgs) + tmp
21374 qhmul1(mgs) = qhmul1(mgs) + cimas0*tmp*rhoinv(mgs)
21375 ENDIF
21376 IF ( lhl .gt. 1 ) THEN
21377 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. (.not. wetsfchl(mgs)) ) THEN
21378 tmp = ft*(3.5e+08)*rho0(mgs)*qhlacw(mgs)
21379 chlmul1(mgs) = chlmul1(mgs) + tmp
21380 qhlmul1(mgs) = qhlmul1(mgs) + cimas0*tmp*rhoinv(mgs)
21381 ENDIF
21382 ENDIF
21383 ENDIF ! itype1
21384
21385
21386 ENDIF ! ft
21387
21388 ENDIF ! xv(mgs,lc) .gt. 0.0 .and.
21389
21390 ELSE ! ipconc .lt. 2
21391!
21392! define the temperature function
21393!
21394 fimt1(mgs) = 0.0
21395!
21396! Cotton et al. (1986) version
21397!
21398 if ( temg(mgs) .ge. 268.15 .and. temg(mgs) .le. 270.15 ) then
21399 fimt1(mgs) = 1.0 -(temg(mgs)-268.15)/2.0
21400 elseif (temg(mgs) .le. 268.15 .and. temg(mgs) .ge. 265.15 ) then
21401 fimt1(mgs) = 1.0 +(temg(mgs)-268.15)/3.0
21402 ELSE
21403 fimt1(mgs) = 0.0
21404 end if
21405!
21406! Ferrier (1994) version
21407!
21408 if ( temg(mgs) .ge. 265.15 .and. temg(mgs) .le. 267.15 ) then
21409 fimt1(mgs) = 0.5
21410 elseif (temg(mgs) .ge. 267.15 .and. temg(mgs) .le. 269.15 ) then
21411 fimt1(mgs) = 1.0
21412 elseif (temg(mgs) .ge. 269.15 .and. temg(mgs) .le. 271.15 ) then
21413 fimt1(mgs) = 0.5
21414 ELSE
21415 fimt1(mgs) = 0.0
21416 end if
21417!
21418!
21419! type I: 350 splinters are formed for every 1e-3 grams of cloud
21420! water accreted by graupel/hail (note converted to MKS units)
21421! 3.5e+8 has units of 1/kg
21422!
21423 IF ( itype1 .ge. 1 ) THEN
21424 fimta(mgs) = (3.5e+08)*rho0(mgs)
21425 ELSE
21426 fimta(mgs) = 0.0
21427 ENDIF
21428
21429!
21430!
21431! type II: 1 splinter formed for every 250 cloud droplets larger than
21432! 24 micons in diameter (12 microns in radius) accreted by
21433! graupel/hail
21434!
21435!
21436 fimt2(mgs) = 0.0
21437 xcwmas = xmas(mgs,lc) * 1000.
21438!
21439 IF ( itype2 .ge. 1 ) THEN
21440 if ( xcwmas.lt.1.26e-9 ) then
21441 fimt2(mgs) = 0.0
21442 end if
21443 if ( xcwmas .le. 3.55e-9 .and. xcwmas .ge. 1.26e-9 ) then
21444 fimt2(mgs) = (2.27)*alog(xcwmas) + 13.39
21445 end if
21446 if ( xcwmas .gt. 3.55e-9 ) then
21447 fimt2(mgs) = 1.0
21448 end if
21449
21450 fimt2(mgs) = min(fimt2(mgs),1.0)
21451 fimt2(mgs) = max(fimt2(mgs),0.0)
21452
21453 ENDIF
21454!
21455! qhmul2 = 0.0
21456! qsmul2 = 0.0
21457!
21458! qhmul2 =
21459! > (4.0e-03)*fimt1(mgs)*fimt2(mgs)*qhacw(mgs)
21460! qsmul2 =
21461! > (4.0e-03)*fimt1(mgs)*fimt2(mgs)*qsacw(mgs)
21462!
21463! cimas0 = (1.0e-12)
21464! cimas0 = 2.5e-10
21465 IF ( .not. wetsfc(mgs) ) THEN
21466 chmul1(mgs) = fimt1(mgs)*(fimta(mgs) + &
21467 & (4.0e-03)*fimt2(mgs))*qhacw(mgs)
21468 ENDIF
21469!
21470 qhmul1(mgs) = chmul1(mgs)*(cimas0/rho0(mgs))
21471
21472 IF ( lhl .gt. 1 ) THEN
21473 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. (.not. wetsfchl(mgs)) ) THEN
21474 tmp = fimt1(mgs)*(fimta(mgs) + &
21475 & (4.0e-03)*fimt2(mgs))*qhlacw(mgs)
21476 chlmul1(mgs) = tmp
21477 qhlmul1(mgs) = cimas0*tmp*rhoinv(mgs)
21478 ENDIF
21479 ENDIF
21480
21481! qsmul1(mgs) = csmul1(mgs)*(cimas0/rho0(mgs))
21482!
21483 ENDIF ! ( ipconc .ge. 2 )
21484
21485 end if ! (in temperature range)
21486
21487 ENDIF ! ( itype1 .eq. 1 .or. itype2 .eq. 1)
21488!
21489 end do
21490!
21491!
21492!
21493! end if
21494!
21495! end do
21496!
21497!
21498! ICE MULTIPLICATION FROM SNOW
21499! Lo and Passarelli 82 / Willis and Heymsfield 89 / Schuur and Rutledge 00b
21500! using kfrag as fragmentation rate (s-1) / 500 microns as char mean diam for max snow mix ratio
21501!
21502 csmul(:) = 0.0
21503 qsmul(:) = 0.0
21504
21505 IF ( isnwfrac /= 0 ) THEN
21506 do mgs = 1,ngscnt
21507 IF (temg(mgs) .gt. 265.0) THEN !{
21508 if (xdia(mgs,ls,1) .gt. 100.e-6 .and. xdia(mgs,ls,1) .lt. 2.0e-3) then ! equiv diameter 100microns to 2mm
21509
21510 tmp = rhoinv(mgs)*pi*xdn(mgs,ls)*cx(mgs,ls)*(500.e-6)**3
21511 qsmul(mgs) = max( kfrag*( qx(mgs,ls) - tmp ) , 0.0 )
21512
21513 qsmul(mgs) = min( qxmxd(mgs,li), qsmul(mgs) )
21514 csmul(mgs) = min( cxmxd(mgs,li), rho0(mgs)*qsmul(mgs)/mfrag )
21515
21516 endif
21517 ENDIF !}
21518 enddo
21519 ENDIF
21520
21521!
21522! frozen rain-rain interaction....
21523!
21524!
21525!
21526!
21527! rain-ice interaction
21528!
21529!
21530 do mgs = 1,ngscnt
21531 qracif(mgs) = qraci(mgs)
21532 cracif(mgs) = craci(mgs)
21533! ciacrf(mgs) = ciacr(mgs)
21534 end do
21535!
21536!
21537! vapor to pristine ice crystals UP
21538!
21539!
21540!
21541! compute the nucleation rate
21542!
21543! do mgs = 1,ngscnt
21544! idqis = 0
21545! if ( ssi(mgs) .gt. 1.0 ) idqis = 1
21546! fiinit(mgs) = (felv(mgs)**2)/(cp*rw)
21547! dqisdt(mgs) = (qx(mgs,lv)-qis(mgs))/
21548! > (1.0 + fiinit(mgs)*qis(mgs)/tsqr(mgs))
21549! qidsvp(mgs) = dqisdt(mgs)
21550! cnnt = min(cnit*exp(-temcg(mgs)*bta1),1.0e+09)
21551! qiint(mgs) =
21552! > il5(mgs)*idqis*(1.0*dtpinv)
21553! < *min((6.88e-13)*cnnt/rho0(mgs), 0.25*dqisdt(mgs))
21554! end do
21555!
21556! Meyers et al. (1992; JAS) and Ferrier (1994) primary ice nucleation
21557!
21558 cmassin = cimasn ! 6.88e-13
21559 do mgs = 1,ngscnt
21560 qiint(mgs) = 0.0
21561 ciint(mgs) = 0.0
21562 qicicnt(mgs) = 0.0
21563 cicint(mgs) = 0.0
21564 qipipnt(mgs) = 0.0
21565 cipint(mgs) = 0.0
21566 ccitmp = 0.0
21567 IF ( icenucopt == 1 .or. icenucopt == -10 .or. icenucopt == -11 ) THEN
21568 if ( ( temg(mgs) .lt. 268.15 .or. &
21569! : ( imeyers5 .and. temg(mgs) .lt. 273.0) ) .and. &
21570 & ( imeyers5 .and. temg(mgs) .lt. 272.0 .and. temgkm2(mgs) .lt. tfr) ) .and. &
21571 & ciintmx .gt. (cx(mgs,li)+ccitmp) &
21572! : .and. cninm(mgs) .gt. 0. &
21573 & ) then
21574 fiinit(mgs) = (felv(mgs)**2)/(cp*rw)
21575 dqisdt(mgs) = (qx(mgs,lv)-qis(mgs))/ &
21576 & (1.0 + fiinit(mgs)*qis(mgs)/tsqr(mgs))
21577! qidsvp(mgs) = dqisdt(mgs)
21578 idqis = 0
21579 if ( ssi(mgs) .gt. 1.0 ) THEN
21580 idqis = 1
21581 dzfacp = max( float(kgsp(mgs)-kgs(mgs)), 0.0 )
21582 dzfacm = max( float(kgs(mgs)-kgsm(mgs)), 0.0 )
21583 qiint(mgs) = &
21584 & idqis*il5(mgs) &
21585 & *(cmassin/rho0(mgs)) &
21586 & *max(0.0,wvel(mgs)) &
21587 & *max((cninp(mgs)-cninm(mgs)),0.0)/gz(igs(mgs),jgs,kgs(mgs)) &
21588 & /((dzfacp+dzfacm))
21589
21590 qiint(mgs) = min(qiint(mgs), max(0.25*dqisdt(mgs),0.0))
21591 ciint(mgs) = qiint(mgs)*rho0(mgs)/cmassin
21592
21593!
21594! limit new crystals so it does not increase the current concentration
21595! above ciintmx 20,000 per liter (2.e7 per m**3)
21596!
21597! ciintmx = 1.e9
21598! ciintmx = 1.e9
21599 IF ( icenucopt /= -10 ) THEN
21600
21601 IF ( lcin > 1 ) THEN
21602 ciint(mgs) = min(ciint(mgs), ccin(mgs)*dtpinv) ! because ciint is a *rate*
21603 ccin(mgs) = ccin(mgs) - ciint(mgs)*dtp
21604 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
21605 ELSEIF ( lcina > 1 ) THEN
21606 ciint(mgs) = max(0.0, min( ciint(mgs), min( cnina(mgs), ciintmx ) - cina(mgs) ))
21607 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
21608
21609 ELSEIF ( icenucopt == 1 .and. ciint(mgs) .gt. max(0.0, ciintmx - cx(mgs,li) - ccitmp )*dtpinv ) THEN
21610 ciint(mgs) = max(0.0, ciintmx - (cx(mgs,li)) )*dtpinv
21611 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
21612
21613 ELSEIF ( icenucopt == -11 .and. dtp*ciint(mgs) .gt. ( cnina(mgs) - (cx(mgs,li) - ccitmp))) THEN
21614 ciint(mgs) = max(0.0, cnina(mgs) - (cx(mgs,li)+ccitmp)*dtpinv )
21615 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
21616
21617 ENDIF
21618 ENDIF
21619
21620 end if
21621 endif
21622
21623 ELSEIF ( icenucopt == 2 .or. icenucopt == -1 .or. icenucopt == -2 ) THEN
21624
21625 IF ( ( temg(mgs) .lt. 268.15 .and. ssw(mgs) > 1.0 ) .or. ssi(mgs) > 1.25 ) THEN
21626 IF ( lcin > 1 ) THEN
21627 ciint(mgs) = min(cnina(mgs), ccin(mgs))
21628 ciint(mgs) = min( ciint(mgs), max(0.0, ciintmx - (cx(mgs,li) - ccitmp) ) ) ! do not initiate ice beyond concentration of ciintmx
21629 ccin(mgs) = ccin(mgs) - ciint(mgs)
21630 ciint(mgs) = ciint(mgs)*dtpinv ! convert total initiation to a rate
21631 ELSE
21632 ciint(mgs) = max( 0.0, cnina(mgs) - cina(mgs) )*dtpinv
21633 ENDIF
21634 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
21635
21636 fiinit(mgs) = (felv(mgs)**2)/(cp*rw)
21637 dqisdt(mgs) = (qx(mgs,lv)-qis(mgs))/(1.0 + fiinit(mgs)*qis(mgs)/tsqr(mgs))
21638 qiint(mgs) = min(qiint(mgs), max(0.25*dqisdt(mgs),0.0))
21639 ciint(mgs) = qiint(mgs)*rho0(mgs)/cmassin
21640 ENDIF
21641
21642
21643
21644 ELSEIF ( icenucopt == 3 .or. icenucopt == 4 .or. icenucopt == 10 ) THEN
21645 IF ( temg(mgs) .lt. 268.15 ) THEN
21646 IF ( lcin > 1 ) THEN
21647 ciint(mgs) = min(cnina(mgs), ccin(mgs))
21648 ciint(mgs) = min( ciint(mgs), max(0.0, ciintmx - (cx(mgs,li) + ccitmp) ) ) ! do not initiate ice beyond concentration of ciintmx
21649 ccin(mgs) = ccin(mgs) - ciint(mgs)
21650 ciint(mgs) = ciint(mgs)*dtpinv ! convert total initiation to a rate
21651 ELSE
21652 ciint(mgs) = max( 0.0, cnina(mgs) - cina(mgs) )*dtpinv
21653 ENDIF
21654 qiint(mgs) = ciint(mgs)*cmassin/rho0(mgs)
21655 ENDIF
21656
21657 ENDIF
21658!
21659 if ( xplate(mgs) .eq. 1 ) then
21660 qipipnt(mgs) = qiint(mgs)
21661 cipint(mgs) = ciint(mgs)
21662 end if
21663!
21664 if ( xcolmn(mgs) .eq. 1 ) then
21665 qicicnt(mgs) = qiint(mgs)
21666 cicint(mgs) = ciint(mgs)
21667 end if
21668!
21669! qipipnt(mgs) = 0.0
21670! qicicnt(mgs) = qiint(mgs)
21671!
21672 end do
21673!
21674!
21675
21676!
21677! vapor to cloud droplets UP
21678!
21679 if (ndebug .gt. 0 ) write(0,*) 'dbg = 8'
21680!
21681!
21682 if (ndebug .gt. 0 ) write(0,*) 'Collection: set 3-component'
21683!
21684! time for riming....
21685!
21686! rimtim = 240.0
21687! dtrim = rimtim
21688! xacrtim = 120.0
21689! tranfr = 0.50
21690! tranfw = 0.50
21691!
21692! coefficients for riming
21693!
21694! rimc1 = 300.00
21695! rimc2 = 0.44
21696!
21697!
21698! zero some arrays
21699!
21700!
21701 do mgs = 1,ngscnt
21702 qrshr(mgs) = 0.0
21703 qwshw(mgs) = 0.0
21704 cwshw(mgs) = 0.0
21705 qsshrp(mgs) = 0.0
21706 qhshrp(mgs) = 0.0
21707 end do
21708!
21709!
21710! first sum all of the shed rain
21711!
21712!
21713 do mgs = 1,ngscnt
21714 qrshr(mgs) = qsshr(mgs) + qhshr(mgs) + qhlshr(mgs)
21715 crshr(mgs) = chshrr(mgs)/rzxh(mgs) + chlshrr(mgs)/rzxhl(mgs)
21716
21717
21718 IF ( ipconc .ge. 3 ) THEN
21719! crshr(mgs) = Max(crshr(mgs), rho0(mgs)*qrshr(mgs)/(xdn(mgs,lr)*vr1mm) )
21720 ENDIF
21721 end do
21722!
21723!
21724!
21725 if (ndebug .gt. 0 ) write(0,*) 'dbg = 8a'
21726
21727!
21728!
21729!
21730!
21731 IF ( ipconc .ge. 1 ) THEN
21732!
21733!
21734! concentration production terms
21735!
21736! YYY
21737!
21738!
21739! DO mgs = 1,ngscnt
21740 pccwi(:) = 0.0
21741 pccwd(:) = 0.0
21742 pccwdacc(:) = 0.0
21743 pccii(:) = 0.0
21744 pccin(:) = 0.0
21745 pccid(:) = 0.0
21746 pcisi(:) = 0.0
21747 pcisd(:) = 0.0
21748 pcrwi(:) = 0.0
21749 pcrwd(:) = 0.0
21750 pcswi(:) = 0.0
21751 pcswd(:) = 0.0
21752 pchwi(:) = 0.0
21753 pchwd(:) = 0.0
21754 pchli(:) = 0.0
21755 pchld(:) = 0.0
21756! ENDDO
21757!
21758! Cloud ice
21759!
21760! IF ( ipconc .ge. 1 ) THEN
21761 if (ndebug .gt. 0 ) write(0,*) 'cloud ice sum'
21762
21763 IF ( warmonly < 0.5 ) THEN
21764 IF ( ffrzs < 1.0 ) THEN
21765 do mgs = 1,ngscnt
21766 pccii(mgs) = &
21767 & il5(mgs)*cicint(mgs) &
21768 & +il5(mgs)*((1.0-cwfrz2snowfrac)*cwfrzc(mgs)+cwctfzc(mgs) &
21769 & +cicichr(mgs)) &
21770 & +chmul1(mgs) &
21771 & +chlmul1(mgs) &
21772 & + csplinter(mgs) + csplinter2(mgs) &
21773 & +csmul(mgs)
21774
21775 pccii(mgs) = pccii(mgs)*(1.0 - ffrzs)
21776
21777! > + nsplinter*(crfrzf(mgs) + crfrz(mgs))
21778 pccid(mgs) = &
21779 & il5(mgs)*(-cscni(mgs) - cscnvi(mgs) & ! - cwaci(mgs) &
21780 & -craci(mgs) &
21781 & -csaci(mgs) &
21782 & -chaci(mgs) - chlaci(mgs) &
21783 & -chcni(mgs)) &
21784 & +il5(mgs)*cisbv(mgs) &
21785 & -(1.-il5(mgs))*cimlr(mgs)
21786
21787 pccin(mgs) = ciint(mgs)
21788
21789
21790 end do
21791 ENDIF ! ffrzs
21792 ELSEIF ( warmonly < 0.8 ) THEN
21793 do mgs = 1,ngscnt
21794
21795! qiint(mgs) = 0.0
21796! cicint(mgs) = 0.0
21797! qicicnt(mgs) = 0.0
21798
21799 pccii(mgs) = &
21800 & il5(mgs)*cicint(mgs) &
21801 & +il5(mgs)*((1.0-cwfrz2snowfrac)*cwfrzc(mgs)+cwctfzc(mgs) &
21802 & +cicichr(mgs)) &
21803 & +chmul1(mgs) &
21804 & +chlmul1(mgs) &
21805 & + csplinter(mgs) + csplinter2(mgs) &
21806 & +csmul(mgs)
21807
21808 pccii(mgs) = pccii(mgs)*(1. - ffrzs)
21809 pccid(mgs) = &
21810! & il5(mgs)*(-cscni(mgs) - cscnvi(mgs) & ! - cwaci(mgs) &
21811! & -craci(mgs) &
21812! & -csaci(mgs) &
21813! & -chaci(mgs) - chlaci(mgs) &
21814! & -chcni(mgs)) &
21815 & +il5(mgs)*cisbv(mgs) &
21816 & -(1.-il5(mgs))*cimlr(mgs)
21817
21818 pccin(mgs) = ciint(mgs)
21819
21820 end do
21821 ENDIF ! warmonly
21822
21823
21824! ENDIF ! ( ipconc .ge. 1 )
21825!
21826! Cloud water
21827!
21828 IF ( ipconc .ge. 2 ) THEN
21829
21830 do mgs = 1,ngscnt
21831 pccwi(mgs) = (0.0) - cwshw(mgs) ! + (1-il5(mgs))*(-cirmlw(mgs))
21832
21833 IF ( warmonly < 0.5 ) THEN
21834 pccwd(mgs) = &
21835 & - cautn(mgs) + &
21836 & il5(mgs)*(-ciacw(mgs)-cwfrz(mgs)-cwctfzp(mgs) &
21837 & -cwctfzc(mgs) &
21838 & ) &
21839 & -cracw(mgs) -csacw(mgs) -chacw(mgs) - chlacw(mgs)
21840
21841
21842 ELSEIF ( warmonly < 0.8 ) THEN
21843 pccwd(mgs) = &
21844 & - cautn(mgs) + &
21845 & il5(mgs)*( &
21846 & -ciacw(mgs)-cwfrz(mgs)-cwctfzp(mgs) &
21847 & -cwctfzc(mgs) &
21848 & ) &
21849 & -cracw(mgs) -chacw(mgs) -chlacw(mgs)
21850 ELSE
21851
21852! tmp3d(igs(mgs),jy,kgs(mgs)) = crcnw(mgs)
21853
21854! cracw(mgs) = 0.0 ! turn off accretion
21855! qracw(mgs) = 0.0
21856! crcev(mgs) = 0.0 ! turn off evap
21857! qrcev(mgs) = 0.0 ! turn off evap
21858! cracr(mgs) = 0.0 ! turn off self collection
21859
21860
21861! cautn(mgs) = 0.0
21862! crcnw(mgs) = 0.0
21863! qrcnw(mgs) = 0.0
21864
21865 pccwd(mgs) = &
21866 & - cautn(mgs) -cracw(mgs)
21867 ENDIF
21868
21869
21870 IF ( .false. .and. exwmindiam > 0.0 .and. ccwresv(mgs) > 0.0 ) THEN
21871 pccwdacc(mgs) = &
21872 & il5(mgs)*(-ciacw(mgs) &
21873 & ) &
21874 & -cracw(mgs) -csacw(mgs) -chacw(mgs) - chlacw(mgs)
21875
21876 IF ( -pccwdacc(mgs)*dtp .gt. cx(mgs,lc) - ccwresv(mgs) ) THEN
21877
21878 frac = -(cx(mgs,lc) - ccwresv(mgs) )/(pccwdacc(mgs)*dtp)
21879 pccwdacc(mgs) = -(cx(mgs,lc) - ccwresv(mgs) )*dtpinv
21880
21881 ciacw(mgs) = frac*ciacw(mgs)
21882 cracw(mgs) = frac*cracw(mgs)
21883 csacw(mgs) = frac*csacw(mgs)
21884 chacw(mgs) = frac*chacw(mgs)
21885 cautn(mgs) = frac*cautn(mgs)
21886
21887 IF ( lhl .gt. 1 ) chlacw(mgs) = frac*chlacw(mgs)
21888
21889! resum
21890 pccwd(mgs) = &
21891 & - cautn(mgs) + &
21892 & il5(mgs)*(-ciacw(mgs)-cwfrzp(mgs)-cwctfzp(mgs) &
21893 & -cwfrzc(mgs)-cwctfzc(mgs) &
21894 & -il5(mgs)*(ciihr(mgs)) &
21895 & ) &
21896 & -cracw(mgs) -csacw(mgs) -chacw(mgs) - chlacw(mgs)
21897
21898 ENDIF
21899
21900 ENDIF
21901
21902
21903 IF ( -pccwd(mgs)*dtp .gt. cx(mgs,lc) ) THEN
21904! write(0,*) 'OUCH! pccwd(mgs)*dtp .gt. ccw(mgs) ',pccwd(mgs),cx(mgs,lc)
21905! write(0,*) 'qc = ',qx(mgs,lc)
21906! write(0,*) -ciacw(mgs)-cwfrzp(mgs)-cwctfzp(mgs)-cwfrzc(mgs)-cwctfzc(mgs)
21907! write(0,*) -cracw(mgs) -csacw(mgs) -chacw(mgs)
21908! write(0,*) - cautn(mgs)
21909
21910 frac = -cx(mgs,lc)/(pccwd(mgs)*dtp)
21911 pccwd(mgs) = -cx(mgs,lc)*dtpinv
21912
21913 ciacw(mgs) = frac*ciacw(mgs)
21914 cwfrz(mgs) = frac*cwfrz(mgs)
21915 cwfrzp(mgs) = frac*cwfrzp(mgs)
21916 cwctfzp(mgs) = frac*cwctfzp(mgs)
21917 cwfrzc(mgs) = frac*cwfrzc(mgs)
21918 cwctfzc(mgs) = frac*cwctfzc(mgs)
21919 cwctfz(mgs) = frac*cwctfz(mgs)
21920 cracw(mgs) = frac*cracw(mgs)
21921 csacw(mgs) = frac*csacw(mgs)
21922 chacw(mgs) = frac*chacw(mgs)
21923 cautn(mgs) = frac*cautn(mgs)
21924
21925 pccii(mgs) = pccii(mgs) - (1.-frac)*il5(mgs)*(cwfrzc(mgs)+cwctfzc(mgs))*(1. - ffrzs)
21926 IF ( lhl .gt. 1 ) chlacw(mgs) = frac*chlacw(mgs)
21927
21928
21929! STOP
21930 ENDIF
21931
21932 end do
21933
21934 ENDIF ! ipconc
21935
21936!
21937! Rain
21938!
21939 IF ( ipconc .ge. 3 ) THEN
21940
21941 do mgs = 1,ngscnt
21942
21943 IF ( warmonly < 0.5 ) THEN
21944 pcrwi(mgs) = &
21945! > cracw(mgs) + &
21946 & crcnw(mgs) &
21947 & +(1-il5(mgs))*( &
21948 & -chmlrr(mgs)/rzxh(mgs) &
21949 & -chlmlrr(mgs)/rzxhl(mgs) &
21950! & -csmlr(mgs)/rzxs(mgs) &
21951 & -csmlrr(mgs) &
21952 & - cimlr(mgs) ) &
21953 & - min(0.0,cracr(mgs)) & ! cracr is negative if there is enough breakup
21954 & -crshr(mgs) !null at this point when wet snow/graupel included
21955 pcrwd(mgs) = &
21956 & il5(mgs)*(-ciacr(mgs) - crfrz(mgs) ) & ! - cipacr(mgs))
21957! > -csacr(mgs) &
21958 & - chacr(mgs) - chlacr(mgs) &
21959 & +crcev(mgs) &
21960 & - max(0.0,cracr(mgs))
21961! > -il5(mgs)*ciracr(mgs)
21962
21963 ELSEIF ( warmonly < 0.8 ) THEN
21964 pcrwi(mgs) = &
21965 & crcnw(mgs) &
21966 & +(1-il5(mgs))*( &
21967 & -chmlrr(mgs)/rzxh(mgs) &
21968 & -chlmlrr(mgs)/rzxhl(mgs) &
21969! & -csmlr(mgs) &
21970 & -csmlrr(mgs) &
21971 & - cimlr(mgs) ) &
21972 & -crshr(mgs) !null at this point when wet snow/graupel included
21973 pcrwd(mgs) = &
21974 & il5(mgs)*( - crfrz(mgs) ) & ! - cipacr(mgs))
21975 & - chacr(mgs) &
21976 & - chlacr(mgs) &
21977 & +crcev(mgs) &
21978 & - cracr(mgs)
21979 ELSE
21980 pcrwi(mgs) = &
21981 & crcnw(mgs)
21982 pcrwd(mgs) = &
21983 & +crcev(mgs) &
21984 & - cracr(mgs)
21985
21986! tmp3d(igs(mgs),jy,kgs(mgs)) = vtxbar(mgs,lr,1) ! crcnw(mgs) ! (pcrwi(mgs) + pcrwd(mgs))
21987! pcrwi(mgs) = 0.0
21988! pcrwd(mgs) = 0.0
21989! qrcnw(mgs) = 0.0
21990
21991 ENDIF
21992
21993
21994 frac = 0.0
21995 IF ( -pcrwd(mgs)*dtp .gt. cx(mgs,lr) ) THEN
21996! write(0,*) 'OUCH! pcrwd(mgs)*dtp .gt. crw(mgs) ',pcrwd(mgs)*dtp,cx(mgs,lr),mgs,igs(mgs),kgs(mgs)
21997! write(0,*) -ciacr(mgs)
21998! write(0,*) -crfrz(mgs)
21999! write(0,*) -chacr(mgs)
22000! write(0,*) crcev(mgs)
22001! write(0,*) -cracr(mgs)
22002
22003 frac = -cx(mgs,lr)/(pcrwd(mgs)*dtp)
22004 pcrwd(mgs) = -cx(mgs,lr)*dtpinv
22005
22006 ciacr(mgs) = frac*ciacr(mgs)
22007 ciacrf(mgs) = frac*ciacrf(mgs)
22008 ciacrs(mgs) = frac*ciacrs(mgs)
22009 crfrz(mgs) = frac*crfrz(mgs)
22010 crfrzf(mgs) = frac*crfrzf(mgs)
22011 crfrzs(mgs) = frac*crfrzs(mgs)
22012 chacr(mgs) = frac*chacr(mgs)
22013 chlacr(mgs) = frac*chlacr(mgs)
22014 crcev(mgs) = frac*crcev(mgs)
22015 cracr(mgs) = frac*cracr(mgs)
22016
22017! STOP
22018 ENDIF
22019
22020 end do
22021
22022 ENDIF
22023
22024
22025 IF ( warmonly < 0.5 ) THEN
22026
22027!
22028! Snow
22029!
22030 IF ( ipconc .ge. 4 ) THEN !
22031
22032 do mgs = 1,ngscnt
22033 pcswi(mgs) = &
22034 & il5(mgs)*(cscnis(mgs) + cscnvis(mgs) ) &
22035 & + cwfrz2snowfrac*cwfrz(mgs)/cwfrz2snowratio &
22036 & + cscnh(mgs)
22037
22038 IF ( ffrzs > 0.0 ) THEN
22039 pcswi(mgs) = pcswi(mgs) + ffrzs* ( &
22040 & il5(mgs)*cicint(mgs) &
22041 & +il5(mgs)*(cwfrzc(mgs)+cwctfzc(mgs) &
22042 & +cicichr(mgs)) &
22043 & +chmul1(mgs) &
22044 & +chlmul1(mgs) &
22045 & + csplinter(mgs) + csplinter2(mgs) &
22046 & +csmul(mgs) )
22047 ENDIF
22048
22049
22050 IF ( ess0 < 0.0 ) THEN
22051 csacs(mgs) = max(0.0, csacs(mgs) - (ifrzs)*(crfrzs(mgs) + ciacrs(mgs)))
22052 ENDIF
22053
22054 pcswd(mgs) = &
22055! : cracs(mgs) &
22056 & -chacs(mgs) - chlacs(mgs) &
22057 & -chcns(mgs) &
22058 & +(1-il5(mgs))*csmlr(mgs) + csshr(mgs) & ! + csshrp(mgs)
22059! > +il5(mgs)*(cssbv(mgs)) &
22060 & + cssbv(mgs) &
22061 & - csacs(mgs)
22062
22063 frac = 0.0
22064 IF ( imixedphase == 0 ) THEN
22065 IF ( cx(mgs,ls) + dtp*(pcswi(mgs) + pcswd(mgs)) < 0.0 ) THEN
22066 frac = (-cx(mgs,ls) + pcswi(mgs)*dtp)/(pcswd(mgs)*dtp)
22067
22068 pcswd(mgs) = frac*pcswd(mgs)
22069
22070 chacs(mgs) = frac*chacs(mgs)
22071 chlacs(mgs) = frac*chlacs(mgs)
22072 chcns(mgs) = frac*chcns(mgs)
22073 csmlr(mgs) = frac*csmlr(mgs)
22074 csshr(mgs) = frac*csshr(mgs)
22075 cssbv(mgs) = frac*cssbv(mgs)
22076 csacs(mgs) = frac*csacs(mgs)
22077
22078 ENDIF
22079 ENDIF
22080
22081
22082
22083 pccii(mgs) = pccii(mgs) &
22084 & + (1. - ifrzs)*crfrzs(mgs) &
22085 & + (1. - ifrzs)*ciacrs(mgs)
22086
22087 pcswi(mgs) = pcswi(mgs) &
22088 & + (ifrzs)*crfrzs(mgs) &
22089 & + (ifrzs)*ciacrs(mgs)
22090
22091 end do
22092
22093 ENDIF
22094
22095!
22096! Graupel
22097!
22098 IF ( ipconc .ge. 5 ) THEN !
22099 do mgs = 1,ngscnt
22100 pchwi(mgs) = &
22101 & +(ffrzh*ifrzg*crfrzf(mgs) &
22102 & +il5(mgs)*ffrzh*ifiacrg*(ciacrf(mgs) )) &
22103 & + f2h*chcnsh(mgs) + f2h*chcnih(mgs) + chcnhl(mgs)
22104
22105 pchwd(mgs) = &
22106 & (1-il5(mgs))*chmlr(mgs) &
22107! > + il5(mgs)*chsbv(mgs) &
22108 & + chsbv(mgs) &
22109 & - il5(mgs)*chlcnh(mgs) &
22110 & - cscnh(mgs)
22111
22112 end do
22113
22114
22115
22116!
22117
22118!
22119! Hail
22120!
22121 IF ( lhl .gt. 1 .and. lnhl > 1 ) THEN !
22122 do mgs = 1,ngscnt
22123 pchli(mgs) = (ffrzh*(1.0-ifrzg)*crfrzf(mgs) +il5(mgs)*ffrzh*(1.0-ifiacrg)*(ciacrf(mgs) )) &
22124 & + chlcnhhl(mgs) *rzxhlh(mgs)
22125
22126 pchld(mgs) = &
22127 & (1-il5(mgs))*chlmlr(mgs) &
22128! > + il5(mgs)*chlsbv(mgs) &
22129 & + chlsbv(mgs) - chcnhl(mgs)
22130
22131 IF ( imixedphase == 0 ) THEN
22132 frac = 0.0
22133 IF ( cx(mgs,lhl) + dtp*(pchli(mgs) + pchld(mgs)) < 0.0 ) THEN
22134 ! rescale depletion
22135
22136 frac = (-cx(mgs,lhl) + pchli(mgs)*dtp)/(pchld(mgs)*dtp)
22137
22138 chlmlr(mgs) = frac*chlmlr(mgs)
22139 chlsbv(mgs) = frac*chlsbv(mgs)
22140 chcnhl(mgs) = frac*chcnhl(mgs)
22141
22142 pchld(mgs) = frac*pchld(mgs)
22143
22144 ENDIF
22145 ENDIF
22146
22147 end do
22148
22149 ENDIF
22150!
22151
22152 ENDIF ! (ipconc .ge. 5 )
22153
22154 ELSEIF ( warmonly < 0.8 ) THEN
22155
22156!
22157! Graupel
22158!
22159 IF ( ipconc .ge. 5 ) THEN !
22160 do mgs = 1,ngscnt
22161 pchwi(mgs) = &
22162 & +ifrzg*(crfrzf(mgs) ) ! +il5(mgs)*(ciacrf(mgs) ))
22163
22164 pchwd(mgs) = &
22165 & (1-il5(mgs))*chmlr(mgs) &
22166 & - il5(mgs)*chlcnh(mgs)
22167 end do
22168!
22169! Hail
22170!
22171 IF ( lhl .gt. 1 ) THEN !
22172 do mgs = 1,ngscnt
22173 pchli(mgs) = (1.0-ifrzg)*(crfrzf(mgs)) & ! +il5(mgs)*(ciacrf(mgs) )) &
22174 & + chlcnhhl(mgs) *rzxhl(mgs)/rzxh(mgs)
22175
22176 pchld(mgs) = &
22177 & (1-il5(mgs))*chlmlr(mgs) ! &
22178! > + il5(mgs)*chlsbv(mgs) &
22179! & + chlsbv(mgs)
22180
22181! IF ( pchli(mgs) .ne. 0. .or. pchld(mgs) .ne. 0 ) THEN
22182! write(0,*) 'dr: pchli,pchld = ', pchli(mgs),pchld(mgs), igs(mgs),kgs(mgs)
22183! ENDIF
22184 end do
22185
22186 ENDIF
22187
22188 ENDIF ! ipconc >= 5
22189
22190 ENDIF ! warmonly
22191
22192!
22193
22194!
22195! Balance and checks for continuity.....within machine precision...
22196!
22197 do mgs = 1,ngscnt
22198 pctot(mgs) = pccwi(mgs) +pccwd(mgs) + &
22199 & pccii(mgs) +pccid(mgs) + &
22200 & pcrwi(mgs) +pcrwd(mgs) + &
22201 & pcswi(mgs) +pcswd(mgs) + &
22202 & pchwi(mgs) +pchwd(mgs) + &
22203 & pchli(mgs) +pchld(mgs)
22204 end do
22205!
22206!
22207 ENDIF ! ( ipconc .ge. 1 )
22208!
22209!
22210!
22211!
22212!
22213! GOGO
22214! production terms for mass
22215!
22216!
22217 pqwvi(:) = 0.0
22218 pqwvd(:) = 0.0
22219 pqcwi(:) = 0.0
22220 pqcwd(:) = 0.0
22221 pqcwdacc(:) = 0.0
22222 pqcii(:) = 0.0
22223 pqcid(:) = 0.0
22224 pqrwi(:) = 0.0
22225 pqrwd(:) = 0.0
22226 pqswi(:) = 0.0
22227 pqswd(:) = 0.0
22228 pqhwi(:) = 0.0
22229 pqhwd(:) = 0.0
22230 pqhli(:) = 0.0
22231 pqhld(:) = 0.0
22232 pqlwsi(:) = 0.0
22233 pqlwsd(:) = 0.0
22234 pqlwhi(:) = 0.0
22235 pqlwhd(:) = 0.0
22236 pqlwlghi(:) = 0.0
22237 pqlwlghd(:) = 0.0
22238 pqlwlghli(:) = 0.0
22239 pqlwlghld(:) = 0.0
22240 pqlwhli(:) = 0.0
22241 pqlwhld(:) = 0.0
22242 IF ( ipconc > 5 ) THEN
22243 pzhwi(:) = 0.0
22244 pzhwd(:) = 0.0
22245 pzrwi(:) = 0.0
22246 pzrwd(:) = 0.0
22247 pzhli(:) = 0.0
22248 pzhld(:) = 0.0
22249 ENDIF
22250
22251
22252!
22253! Vapor
22254!
22255 IF ( warmonly < 0.5 ) THEN
22256 do mgs = 1,ngscnt
22257
22258! NOTE: ANY CHANGES HERE ALSO NEED TO GO INTO THE RESUM FARTHER DOWN!
22259 pqwvi(mgs) = &
22260 & -min(0.0, qrcev(mgs)) &
22261 & -min(0.0, qhcev(mgs)) &
22262 & -min(0.0, qhlcev(mgs)) &
22263 & -min(0.0, qscev(mgs)) &
22264! > +il5(mgs)*(-qhsbv(mgs) - qhlsbv(mgs) ) &
22265 & -qhsbv(mgs) - qhlsbv(mgs) &
22266 & -qssbv(mgs) &
22267 & -il5(mgs)*qisbv(mgs)
22268
22269 pqwvd(mgs) = &
22270 & -max(0.0, qrcev(mgs)) &
22271 & -max(0.0, qhcev(mgs)) &
22272 & -max(0.0, qhlcev(mgs)) &
22273 & -max(0.0, qscev(mgs)) &
22274 & +il5(mgs)*(-qiint(mgs) &
22275 & -qhdpv(mgs) -qsdpv(mgs) - qhldpv(mgs)) &
22276 & -il5(mgs)*qidpv(mgs)
22277
22278 end do
22279
22280 ELSEIF ( warmonly < 0.8 ) THEN
22281 do mgs = 1,ngscnt
22282 pqwvi(mgs) = &
22283 & -min(0.0, qrcev(mgs)) &
22284 & -il5(mgs)*qisbv(mgs)
22285 pqwvd(mgs) = &
22286 & +il5(mgs)*(-qiint(mgs) &
22287! & -qhdpv(mgs) ) & !- qhldpv(mgs)) &
22288 & -qhdpv(mgs) - qhldpv(mgs)) &
22289! & -qhdpv(mgs) -qsdpv(mgs) - qhldpv(mgs)) &
22290 & -max(0.0, qrcev(mgs)) &
22291 & -il5(mgs)*qidpv(mgs)
22292 end do
22293
22294 ELSE
22295 do mgs = 1,ngscnt
22296 pqwvi(mgs) = &
22297 & -min(0.0, qrcev(mgs))
22298 pqwvd(mgs) = &
22299 & -max(0.0, qrcev(mgs))
22300 end do
22301
22302 ENDIF ! warmonly
22303!
22304! Cloud water
22305!
22306 do mgs = 1,ngscnt
22307
22308 pqcwi(mgs) = (0.0) + qwcnr(mgs) - qwshw(mgs)
22309
22310 IF ( warmonly < 0.5 ) THEN
22311 pqcwd(mgs) = &
22312 & il5(mgs)*(-qiacw(mgs)-qwfrz(mgs)-qwctfz(mgs)) &
22313 & -il5(mgs)*(qiihr(mgs)) &
22314 & -qracw(mgs) -qsacw(mgs) -qrcnw(mgs) -qhacw(mgs) - qhlacw(mgs) !&
22315! & -il5(mgs)*(qwfrzp(mgs))
22316 ELSEIF ( warmonly < 0.8 ) THEN
22317 pqcwd(mgs) = &
22318 & il5(mgs)*(-qiacw(mgs)-qwfrz(mgs)-qwctfz(mgs)) &
22319 & -il5(mgs)*(qiihr(mgs)) &
22320 & -qracw(mgs) -qrcnw(mgs) -qhacw(mgs) -qhlacw(mgs)
22321 ELSE
22322 pqcwd(mgs) = &
22323 & -qracw(mgs) - qrcnw(mgs)
22324 ENDIF
22325
22326
22327 IF ( pqcwd(mgs) .lt. 0.0 .and. -pqcwd(mgs)*dtp .gt. qx(mgs,lc) ) THEN
22328
22329 frac = -max(0.0,qx(mgs,lc))/(pqcwd(mgs)*dtp)
22330 pqcwd(mgs) = -qx(mgs,lc)*dtpinv
22331
22332 qiacw(mgs) = frac*qiacw(mgs)
22333! qwfrzp(mgs) = frac*qwfrzp(mgs)
22334! qwctfzp(mgs) = frac*qwctfzp(mgs)
22335 qwfrzc(mgs) = frac*qwfrzc(mgs)
22336 qwfrz(mgs) = frac*qwfrz(mgs)
22337 qwctfzc(mgs) = frac*qwctfzc(mgs)
22338 qwctfz(mgs) = frac*qwctfz(mgs)
22339 qracw(mgs) = frac*qracw(mgs)
22340 qsacw(mgs) = frac*qsacw(mgs)
22341 qhacw(mgs) = frac*qhacw(mgs)
22342 vhacw(mgs) = frac*vhacw(mgs)
22343 qrcnw(mgs) = frac*qrcnw(mgs)
22344 qwfrzp(mgs) = frac*qwfrzp(mgs)
22345 IF ( lhl .gt. 1 ) THEN
22346 qhlacw(mgs) = frac*qhlacw(mgs)
22347 vhlacw(mgs) = frac*vhlacw(mgs)
22348 ENDIF
22349! IF ( lzh .gt. 1 ) zhacw(mgs) = frac*zhacw(mgs)
22350
22351! STOP
22352 ENDIF
22353
22354
22355 end do
22356!
22357! Cloud ice
22358!
22359 IF ( warmonly < 0.5 ) THEN
22360
22361 do mgs = 1,ngscnt
22362 IF ( ffrzs < 1.0 ) THEN
22363 pqcii(mgs) = &
22364 & il5(mgs)*qicicnt(mgs) &
22365 & +il5(mgs)*((1.0-cwfrz2snowfrac)*qwfrzc(mgs)+qwctfzc(mgs)) &
22366 & +il5(mgs)*(qicichr(mgs)) &
22367 & +qsmul(mgs) &
22368 & +qhmul1(mgs) + qhlmul1(mgs) &
22369 & + qsplinter(mgs) + qsplinter2(mgs)
22370! > + cimas0*nsplinter*(crfrzf(mgs) + crfrz(mgs))/rho0(mgs)
22371 ENDIF
22372
22373 pqcii(mgs) = pqcii(mgs)*(1.0 - ffrzs) &
22374 & +il5(mgs)*qidpv(mgs) &
22375 & +il5(mgs)*qiacw(mgs)
22376
22377 pqcid(mgs) = &
22378 & il5(mgs)*(-qscni(mgs) - qscnvi(mgs) & ! -qwaci(mgs) &
22379 & -qraci(mgs) &
22380 & -qsaci(mgs) ) &
22381 & -qhaci(mgs) &
22382 & -qhlaci(mgs) &
22383 & +il5(mgs)*qisbv(mgs) &
22384 & +(1.-il5(mgs))*qimlr(mgs) &
22385 & - qhcni(mgs)
22386 end do
22387
22388
22389 ELSEIF ( warmonly < 0.8 ) THEN
22390
22391 do mgs = 1,ngscnt
22392 pqcii(mgs) = &
22393 & il5(mgs)*qicicnt(mgs)*(1. - ffrzs) &
22394 & +il5(mgs)*((1.0-cwfrz2snowfrac)*qwfrzc(mgs)+qwctfzc(mgs))*(1. - ffrzs) &
22395 & +il5(mgs)*(qicichr(mgs))*(1. - ffrzs) &
22396! & +il5(mgs)*(qicichr(mgs)) &
22397! & +qsmul(mgs) &
22398 & +qhmul1(mgs) + qhlmul1(mgs) &
22399 & + qsplinter(mgs) + qsplinter2(mgs) &
22400 & +il5(mgs)*qidpv(mgs) &
22401 & +il5(mgs)*qiacw(mgs) ! & ! (qiacwi(mgs)+qwacii(mgs)) &
22402! & +il5(mgs)*(qwfrzc(mgs)+qwctfzc(mgs)) &
22403! & +il5(mgs)*(qicichr(mgs)) &
22404! & +qsmul(mgs) &
22405! & +qhmul1(mgs) + qhlmul1(mgs) &
22406! & + qsplinter(mgs) + qsplinter2(mgs)
22407
22408 pqcid(mgs) = &
22409! & il5(mgs)*(-qscni(mgs) - qscnvi(mgs) & ! -qwaci(mgs) &
22410! & -qraci(mgs) &
22411! & -qsaci(mgs) ) &
22412! & -qhaci(mgs) &
22413! & -qhlaci(mgs) &
22414 & +il5(mgs)*qisbv(mgs) &
22415 & +(1.-il5(mgs))*qimlr(mgs) ! &
22416! & - qhcni(mgs)
22417 end do
22418
22419 ENDIF
22420!
22421! Rain
22422!
22423
22424 do mgs = 1,ngscnt
22425 IF ( warmonly < 0.5 ) THEN
22426 pqrwi(mgs) = &
22427 & qracw(mgs) + qrcnw(mgs) + max(0.0, qrcev(mgs)) &
22428 & +(1-il5(mgs))*( &
22429 & -qhmlr(mgs) & !null at this point when wet snow/graupel included
22430 & -qsmlr(mgs) - qhlmlr(mgs) &
22431 & -qimlr(mgs)) &
22432! & -qsshr(mgs) & !null at this point when wet snow/graupel included
22433! & -qhshr(mgs) & !null at this point when wet snow/graupel included
22434! & -qhlshr(mgs) &
22435 & - qrshr(mgs)
22436
22437 pqrwd(mgs) = &
22438 & il5(mgs)*(-qiacr(mgs)-qrfrz(mgs)) &
22439 & - qsacr(mgs) - qhacr(mgs) - qhlacr(mgs) - qwcnr(mgs) &
22440 & + min(0.0,qrcev(mgs))
22441 ELSEIF ( warmonly < 0.8 ) THEN
22442 pqrwi(mgs) = &
22443 & qracw(mgs) + qrcnw(mgs) + max(0.0, qrcev(mgs)) &
22444 & +(1-il5(mgs))*( &
22445 & -qhlmlr(mgs) & !null at this point when wet snow/graupel included
22446 & -qhmlr(mgs) ) & !null at this point when wet snow/graupel included
22447 & -qhshr(mgs) & !null at this point when wet snow/graupel included
22448 & -qhlshr(mgs) !null at this point when wet snow/graupel included
22449 pqrwd(mgs) = &
22450 & il5(mgs)*(-qrfrz(mgs)) &
22451 & - qhacr(mgs) &
22452 & - qhlacr(mgs) &
22453 & + min(0.0,qrcev(mgs))
22454 ELSE
22455 pqrwi(mgs) = &
22456 & qracw(mgs) + qrcnw(mgs) + max(0.0, qrcev(mgs))
22457 pqrwd(mgs) = min(0.0,qrcev(mgs))
22458 ENDIF ! warmonly
22459
22460
22461 ! IF ( pqrwd(mgs) .lt. 0.0 .and. -(pqrwd(mgs) + pqrwi(mgs))*dtp .gt. qx(mgs,lr) ) THEN
22462 IF ( pqrwd(mgs) .lt. 0.0 .and. -(pqrwd(mgs) + pqrwi(mgs))*dtp .gt. qx(mgs,lr) ) THEN
22463
22464 frac = (-qx(mgs,lr) + pqrwi(mgs)*dtp)/(pqrwd(mgs)*dtp)
22465! pqrwd(mgs) = -qx(mgs,lr)*dtpinv + pqrwi(mgs)
22466
22467 pqwvi(mgs) = pqwvi(mgs) &
22468 & + min(0.0, qrcev(mgs)) &
22469 & - frac*min(0.0, qrcev(mgs))
22470 pqwvd(mgs) = pqwvd(mgs) &
22471 & + max(0.0, qrcev(mgs)) &
22472 & - frac*max(0.0, qrcev(mgs))
22473
22474 qiacr(mgs) = frac*qiacr(mgs)
22475 qiacrf(mgs) = frac*qiacrf(mgs)
22476 qiacrs(mgs) = frac*qiacrs(mgs)
22477 viacrf(mgs) = frac*viacrf(mgs)
22478 qrfrz(mgs) = frac*qrfrz(mgs)
22479 qrfrzs(mgs) = frac*qrfrzs(mgs)
22480 qrfrzf(mgs) = frac*qrfrzf(mgs)
22481 vrfrzf(mgs) = frac*vrfrzf(mgs)
22482 qsacr(mgs) = frac*qsacr(mgs)
22483 qhacr(mgs) = frac*qhacr(mgs)
22484 vhacr(mgs) = frac*vhacr(mgs)
22485 qrcev(mgs) = frac*qrcev(mgs)
22486 qhlacr(mgs) = frac*qhlacr(mgs)
22487 vhlacr(mgs) = frac*vhlacr(mgs)
22488 qhcev(mgs) = frac*qhcev(mgs)
22489 qhlcev(mgs) = frac*qhlcev(mgs)
22490
22491
22492 IF ( warmonly < 0.5 ) THEN
22493 pqrwd(mgs) = &
22494 & il5(mgs)*(-qiacr(mgs)-qrfrz(mgs) - qsacr(mgs)) &
22495 & - qhacr(mgs) - qhlacr(mgs) - qwcnr(mgs) &
22496 & + min(0.0,qrcev(mgs))
22497 ELSEIF ( warmonly < 0.8 ) THEN
22498 pqrwd(mgs) = &
22499 & il5(mgs)*(-qrfrz(mgs)) &
22500 & - qhacr(mgs) &
22501 & - qhlacr(mgs) &
22502 & + min(0.0,qrcev(mgs))
22503 ELSE
22504 pqrwd(mgs) = min(0.0,qrcev(mgs))
22505 ENDIF ! warmonly
22506
22507!
22508! Resum for vapor since qrcev has changed
22509!
22510 IF ( qrcev(mgs) .ne. 0.0 ) THEN
22511 pqwvi(mgs) = &
22512 & -min(0.0, qrcev(mgs)) &
22513 & -min(0.0, qhcev(mgs)) &
22514 & -min(0.0, qhlcev(mgs)) &
22515 & -min(0.0, qscev(mgs)) &
22516! > +il5(mgs)*(-qhsbv(mgs) - qhlsbv(mgs) ) &
22517 & -qhsbv(mgs) - qhlsbv(mgs) &
22518 & -qssbv(mgs) &
22519 & -il5(mgs)*qisbv(mgs)
22520
22521 pqwvd(mgs) = &
22522 & -max(0.0, qrcev(mgs)) &
22523 & -max(0.0, qhcev(mgs)) &
22524 & -max(0.0, qhlcev(mgs)) &
22525 & -max(0.0, qscev(mgs)) &
22526 & +il5(mgs)*(-qiint(mgs) &
22527 & -qhdpv(mgs) -qsdpv(mgs) - qhldpv(mgs)) &
22528 & -il5(mgs)*qidpv(mgs)
22529
22530 ENDIF
22531
22532
22533! STOP
22534 ENDIF
22535
22536
22537 end do
22538
22539 IF ( warmonly < 0.5 ) THEN
22540
22541!
22542! Snow
22543!
22544 do mgs = 1,ngscnt
22545 pqswi(mgs) = &
22546 & il5(mgs)*(qscni(mgs)+qsaci(mgs)+qsdpv(mgs) &
22547 & + qscnvi(mgs) &
22548 & + ifrzs*(qiacrs(mgs) + qrfrzs(mgs)) &
22549 & + il5(mgs)*(( qwfrzc(mgs) + qwctfzc(mgs) + qicichr(mgs) )*ffrzs &
22550 & + (1.0 - ffrzs)*cwfrz2snowfrac*qwfrz(mgs) ) &
22551 & + il2(mgs)*qsacr(mgs)) &
22552 & + il5(mgs)*qicicnt(mgs)*ffrzs &
22553 & + il3(mgs)*(qiacrf(mgs)+qracif(mgs)) & ! only applies for ipconc <= 3
22554 & + max(0.0, qscev(mgs)) &
22555 & + qsacw(mgs) + qscnh(mgs) &
22556 & + ffrzs*(qsmul(mgs) &
22557 & +qhmul1(mgs) + qhlmul1(mgs) &
22558 & + qsplinter(mgs) + qsplinter2(mgs))
22559 pqswd(mgs) = &
22560! > -qfacs(mgs) ! -qwacs(mgs) &
22561 & -qracs(mgs)*(1-il2(mgs)) -qhacs(mgs) - qhlacs(mgs) &
22562 & -qhcns(mgs) &
22563 & +(1-il5(mgs))*qsmlr(mgs) + qsshr(mgs) & !null at this point when wet snow included
22564! > +il5(mgs)*(qssbv(mgs)) &
22565 & + qssbv(mgs) &
22566 & + min(0.0, qscev(mgs)) &
22567 & -qsmul(mgs)
22568
22569
22570 IF ( imixedphase == 0 .and. pqswd(mgs) .lt. 0.0 ) THEN
22571 IF ( qx(mgs,ls) + dtp*(pqswi(mgs) + pqswd(mgs)) < 0.0 ) THEN
22572 frac = (-qx(mgs,ls) + pqswi(mgs)*dtp)/(pqswd(mgs)*dtp)
22573
22574 pqswd(mgs) = frac*pqswd(mgs)
22575
22576 qracs(mgs) = frac*qracs(mgs) ! only used for single moment at this time
22577 qhacs(mgs) = frac*qhacs(mgs)
22578 qhlacs(mgs) = frac*qhlacs(mgs)
22579 qhcns(mgs) = frac*qhcns(mgs)
22580 qsmlr(mgs) = frac*qsmlr(mgs)
22581 qsshr(mgs) = frac*qsshr(mgs)
22582 qssbv(mgs) = frac*qssbv(mgs)
22583 qsmul(mgs) = frac*qsmul(mgs)
22584 IF ( qscev(mgs) < 0.0 ) qscev(mgs) = frac*qscev(mgs)
22585
22586 ENDIF
22587 ENDIF
22588
22589 pqcii(mgs) = pqcii(mgs) &
22590 & + (1. - ifrzs)*qrfrzs(mgs) &
22591 & + (1. - ifrzs)*qiacrs(mgs)
22592
22593 end do
22594
22595!
22596! Graupel
22597!
22598 do mgs = 1,ngscnt
22599 pqhwi(mgs) = &
22600 & +il5(mgs)*(ffrzh*ifrzg*qrfrzf(mgs) + (1-il3(mgs))*ffrzh*ifiacrg*(qiacrf(mgs)+qracif(mgs))) &
22601 & + (1-il2(mgs))*(qracs(mgs) + qsacr(mgs)) & ! only used for ipconc < 3
22602 & +il5(mgs)*(qhdpv(mgs)) &
22603 & +max(0.0, qhcev(mgs)) &
22604 & +qhacr(mgs)+qhacw(mgs) &
22605 & +qhacs(mgs)+qhaci(mgs) &
22606 & + f2h*qhcns(mgs) + f2h*qhcni(mgs) + qhcnhl(mgs)
22607 pqhwd(mgs) = &
22608 & qhshr(mgs) & !null at this point when wet graupel included
22609 & +(1-il5(mgs))*qhmlr(mgs) & !null at this point when wet graupel included
22610! > +il5(mgs)*qhsbv(mgs) &
22611 & + qhsbv(mgs) &
22612 & + min(0.0, qhcev(mgs)) &
22613 & -qhmul1(mgs) - qhlcnh(mgs) - qscnh(mgs) &
22614 & - ffrzh*(qsplinter(mgs) + qsplinter2(mgs))
22615! > - cimas0*nsplinter*(crfrzf(mgs) + crfrz(mgs))/rho0(mgs)
22616
22617 end do
22618
22619
22620!
22621! Hail
22622!
22623 IF ( lhl .gt. 1 ) THEN
22624
22625 do mgs = 1,ngscnt
22626 pqhli(mgs) = &
22627 & +il5(mgs)*(qhldpv(mgs) + ((1.0-ifrzg)*qrfrzf(mgs) + (1.0-ifiacrg)*(qiacrf(mgs)+ qracif(mgs)))) &
22628 & +max(0.0, qhlcev(mgs)) &
22629 & +qhlacr(mgs)+qhlacw(mgs) &
22630 & +qhlacs(mgs)+qhlaci(mgs) &
22631 & + qhlcnh(mgs)
22632 pqhld(mgs) = &
22633 & qhlshr(mgs) &
22634 & +(1-il5(mgs))*qhlmlr(mgs) &
22635! > +il5(mgs)*qhlsbv(mgs) &
22636 & + qhlsbv(mgs) &
22637 & + min(0.0, qhlcev(mgs)) &
22638 & -qhlmul1(mgs) - qhcnhl(mgs)
22639
22640 IF ( imixedphase == 0 ) THEN
22641 frac = 0.0
22642 IF ( qx(mgs,lhl) + dtp*(pqhli(mgs) + pqhld(mgs)) < 0.0 ) THEN
22643 ! rescale depletion
22644
22645 frac = (-qx(mgs,lhl) + pqhli(mgs)*dtp)/(pqhld(mgs)*dtp)
22646
22647 qhlmlr(mgs) = frac*qhlmlr(mgs)
22648 qhlsbv(mgs) = frac*qhlsbv(mgs)
22649 qhcnhl(mgs) = frac*qhcnhl(mgs)
22650 qhlmul1(mgs) = frac*qhlmul1(mgs)
22651 IF ( qhlcev(mgs) < 0.0 ) qhlcev(mgs) = frac*qhlcev(mgs)
22652
22653 pqhld(mgs) = frac*pqhld(mgs)
22654
22655 ENDIF
22656 ENDIF
22657
22658
22659 end do
22660
22661 ENDIF ! lhl
22662
22663 ELSEIF ( warmonly < 0.8 ) THEN
22664!
22665! Graupel
22666!
22667 do mgs = 1,ngscnt
22668 pqhwi(mgs) = &
22669 & +il5(mgs)*ifrzg*(qrfrzf(mgs) ) &
22670 & +il5(mgs)*(qhdpv(mgs)) &
22671 & +qhacr(mgs)+qhacw(mgs)
22672 pqhwd(mgs) = &
22673 & qhshr(mgs) & !null at this point when wet graupel included
22674 & - qhlcnh(mgs) &
22675 & - qhmul1(mgs) &
22676 & - qsplinter(mgs) - qsplinter2(mgs) &
22677 & +(1-il5(mgs))*qhmlr(mgs) !null at this point when wet graupel included
22678 end do
22679
22680!
22681! Hail
22682!
22683 IF ( lhl .gt. 1 ) THEN
22684
22685 do mgs = 1,ngscnt
22686 pqhli(mgs) = &
22687 & +il5(mgs)*(qhldpv(mgs) ) & ! + (1.0-ifrzg)*(qiacrf(mgs)+qrfrzf(mgs) + qracif(mgs))) &
22688 & +il5(mgs)*(1.0-ifrzg)*(qrfrzf(mgs) ) &
22689 & +qhlacr(mgs)+qhlacw(mgs) &
22690! & +qhlacs(mgs)+qhlaci(mgs) &
22691 & + qhlcnh(mgs)
22692 pqhld(mgs) = &
22693 & qhlshr(mgs) &
22694 & +(1-il5(mgs))*qhlmlr(mgs) &
22695! > +il5(mgs)*qhlsbv(mgs) &
22696 & + qhlsbv(mgs) &
22697 & -qhlmul1(mgs) - qhcnhl(mgs)
22698
22699 end do
22700
22701 ENDIF ! lhl
22702
22703 ENDIF ! warmonly
22704
22705!
22706! Liquid water on snow and graupel
22707!
22708
22709 vhmlr(:) = 0.0
22710 vhlmlr(:) = 0.0
22711 vhfzh(:) = 0.0
22712 vhlfzhl(:) = 0.0
22713
22714 IF ( mixedphase ) THEN
22715 ELSE ! set arrays for non-mixedphase graupel
22716
22717! vhshdr(:) = 0.0
22718 vhmlr(:) = qhmlr(:) ! not actually volume, but treated as q in rate equation
22719! vhsoak(:) = 0.0
22720
22721! vhlshdr(:) = 0.0
22722 vhlmlr(:) = qhlmlr(:) ! not actually volume, but treated as q in rate equation
22723! vhlmlr(:) = rho0(:)*qhlmlr(:)/xdn(:,lhl)
22724! vhlsoak(:) = 0.0
22725
22726 ENDIF ! mixedphase
22727
22728
22729
22730!
22731! Graupel reflectivity
22732!
22733 if (ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'graupel reflectivity'
22734
22735 do mgs = 1,ngscnt
22736
22737! zhmlr(mgs) = 0.0
22738! zhshr(mgs) = 0.0
22739! zhmlrr(mgs) = 0.0
22740! zhshrr(mgs) = 0.0
22741 zhdsv(mgs) = 0.0
22742! IF ( lf < 1 ) THEN
22743 IF ( ffrzh > 0.0 ) THEN
22744 ziacr(mgs) = 0.0
22745 ziacrf(mgs) = 0.0
22746 ENDIF
22747! ENDIF
22748 zhcns(mgs) = 0.0
22749 zhcni(mgs) = 0.0
22750 zhacs(mgs) = 0.0
22751 zhaci(mgs) = 0.0
22752
22753 ENDDO
22754
22755 IF ( lzh .gt. 1 ) THEN !
22756 do mgs = 1,ngscnt
22757
22758
22759 IF ( qx(mgs,lh) .gt. qxmin(lh) .and. cx(mgs,lh) .gt. 0.0 ) THEN
22760 tmp = qx(mgs,lh)/cx(mgs,lh)
22761 alp = max( alphamin, alpha(mgs,lh) )
22762! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22763 g1 = g1x(mgs,lh) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22764! g1r = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
22765
22766 zhaci(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qhaci(mgs) )
22767 zhacs(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qhacs(mgs) )
22768
22769 IF ( .not. mixedphase .and. ibinhmlr < 1 ) THEN
22770 zhmlr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*tmp * qhmlr(mgs) - tmp**2 * chmlr(mgs) )
22771 ENDIF
22772
22773 zhshr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshr(mgs) )
22774
22775! IF ( lzr > 0 .and. qhshr(mgs) /= 0.0 .and. chshrr(mgs) /= 0.0 .and. ibinhmlr < 1 ) THEN
22776 IF ( lzr > 0 .and. qhshr(mgs) /= 0.0 .and. chshrr(mgs) /= 0.0 ) THEN
22777! IF ( temg(mgs) > tfr + 2.0 ) THEN
22778! zhshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshrr(mgs) )
22779! IF ( zhshrr(mgs) > 0. ) THEN
22780! zhshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshr(mgs) )
22781! ENDIF
22782! z1 = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) ) ! should this be g1shr?
22783! zhshrr(mgs) = Max( z1, zhshrr(mgs))
22784! ELSE
22785! zhshrr(mgs) = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) )
22786
22787
22788 IF ( temg(mgs) >= tfr ) THEN
22789 ! zhshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn0(lr)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshrr(mgs) )
22790 ! IF ( zhshrr(mgs) > 0.0 ) THEN
22791 ! zhshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn0(lr)))**2*( 2.*tmp * qhshr(mgs) - tmp**2 * chshr(mgs) )
22792 ! ENDIF
22793 IF ( (shedalp + alpha(mgs,lh))*xdia(mgs,lh,1) < sheddiam ) THEN ! if not shedding small drops, then use alpha of hail
22794 z1 = g1*(6.0*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) )
22795 ELSE
22796 z1 = g1shr*(6.0*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) ) ! should this be g1shr?
22797 ENDIF
22798 zhshrr(mgs) = z1
22799! z1 = g1mlr*(rho0(mgs)/(xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) ) ! should this be g1shr?
22800! zhshrr(mgs) = Max( z1, zhshrr(mgs))
22801 ELSE
22802 zhshrr(mgs) = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhshr(mgs)**2/ chshrr(mgs) )
22803 ENDIF
22804
22805 zhshrr(mgs) = min( 0.0, zhshrr(mgs) )
22806 ENDIF
22807
22808 IF ( zhshr(mgs) > 0.0 ) THEN
22809 write(0,*) 'Problem with zhshr! zhshr,qhshr,chshr = ',zhshr(mgs),qhshr(mgs),chshr(mgs)
22810 write(0,*) 'g1,tmp, qx,cx,zx = ',g1,tmp,qx(mgs,lh),cx(mgs,lh),zx(mgs,lh)
22811 write(0,*) ( 2.*tmp * qhshr(mgs) - tmp**2 * chshr(mgs) ), 2.*tmp * qhshr(mgs), - tmp**2 * chshr(mgs)
22812 write(0,*) 'temcg = ',temcg(mgs),'chshr recalc = ',(cx(mgs,lh)/(qx(mgs,lh)+1.e-20))*qhshr(mgs)
22813
22814 stop
22815 ENDIF
22816
22817
22818! zhshr(mgs) = (xdn0(lr)/(xdn(mgs,lh)))**2*( zx(mgs,lh) * qhshr(mgs) )
22819
22820 qtmp = qhdpv(mgs) + qhcev(mgs) + qhsbv(mgs)
22821 ctmp = chdpv(mgs) + chcev(mgs) + chsbv(mgs)
22822
22823 zhdsv(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qtmp - tmp**2 * ctmp )
22824
22825 alp = max( alphahacx, alpha(mgs,lh) )
22826! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22827 g1 = g1x(mgs,lh) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22828
22829 IF ( .true. ) THEN ! {
22830 IF ( qhacr(mgs) .gt. 0.0 ) THEN
22831! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacr(mgs) )
22832
22833! g1r = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
22834! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacr(mgs) )
22835 zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacr(mgs) )
22836! zhacrf(mgs) = g1*zhacr
22837
22838 ENDIF
22839
22840! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) )
22841! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) - tmp**2 * chacr(mgs) )
22842
22843! alp = Max( 1.0, alpha(mgs,lh)+1. )
22844! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/
22845! : ((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22846 IF ( qhacw(mgs) .gt. 0.0 ) THEN
22847! zhacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacw(mgs) )
22848 zhacw(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacw(mgs) )
22849 ENDIF
22850
22851 ELSE ! } { ! this is not used because of the 'true' above
22852
22853 IF ( qhacw(mgs) .gt. 0.0 .or. qhacr(mgs) .gt. 0.0 ) THEN
22854 z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lh)+dtp*(qhacr(mgs) + qhacw(mgs)-qhmul1(mgs)))**2)/(cx(mgs,lh))
22855! zhacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lh)/cx(mgs,lh)) * qhacw(mgs) )
22856 IF ( z > zx(mgs,lh) ) THEN
22857 zhacw(mgs) = (z - zx(mgs,lh))*dtpinv
22858 ENDIF
22859 ENDIF
22860
22861 ENDIF ! }
22862
22863 IF ( qhlcnh(mgs) .gt. 0.0 .and. ihlcnh < 2 ) THEN
22864 zhlcnh(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*( tmp ) * qhlcnh(mgs) - tmp**2 * chlcnh(mgs) )
22865 ENDIF
22866 ENDIF
22867! qsplinter(mgs)
22868 IF ( ffrzh*qiacrf(mgs) .gt. 0.0 .and. cx(mgs,lr) .gt. 0.0 .and. qx(mgs,lr) .gt. qxmin(lr) ) THEN
22869 tmp = qx(mgs,lr)/cx(mgs,lr)
22870! alp = 3.0
22871! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22872 IF ( imurain == 3 ) THEN
22873 ! note that 3.6476 = (6/pi)**2
22874 ziacr(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,lr)+2.)/(xdn0(lr)**2*(alpha(mgs,lr)+1.))* &
22875 & ( 2.*tmp * qiacrf(mgs) - tmp**2 * ciacrf(mgs) )
22876 ELSE ! imurain == 1
22877 ziacr(mgs) = 3.6476*rho0(mgs)**2*g1x(mgs,lr)/(xdn0(lr)**2)* &
22878 & ( 2.*tmp * qiacrf(mgs) - tmp**2 * ciacrf(mgs) )
22879 ENDIF
22880 ziacr(mgs) = min( ziacr(mgs), zxmxd(mgs,lr) )
22881! ziacrf(mgs) = (xdn(mgs,lr)/xdn(mgs,lh))**2 * ziacr(mgs)
22882 ziacrf(mgs) = (xdn(mgs,lr)/xdnmx(lh))**2 * ziacr(mgs)
22883! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*tmp * (qiacrf(mgs) - qsplinter(mgs)) - tmp**2 * ciacrf(mgs) )
22884! ziacrf(mgs) = Min( ziacrf(mgs), z )
22885 ENDIF
22886
22887
22888
22889 IF ( ffrzh*qrfrzf(mgs) .gt. 0.0 .and. cx(mgs,lr) .gt. 0.0 ) THEN
22890 tmp = qx(mgs,lr)/cx(mgs,lr)
22891! alp = 3.0
22892! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22893 IF ( imurain == 3 ) THEN
22894 zrfrz(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,lr)+2.)/(xdn0(lr)**2*(alpha(mgs,lr)+1.)) * &
22895 & ( 2.*tmp * qrfrzf(mgs) - tmp**2 * crfrzf(mgs) )
22896 zrfrzf(mgs) = (xdn(mgs,lr)/xdn(mgs,lh))**2 * zrfrz(mgs)
22897 ELSEIF ( imurain == 1 .and. ibiggopt /= 2 ) THEN
22898! zrfrz(mgs) = 3.6476*rho0(mgs)**2*g1x(mgs,lr)/(xdn0(lr)**2) * &
22899! & ( 2.*tmp * qrfrzf(mgs) - tmp**2 * crfrz(mgs) )
22900 zrfrz(mgs) = 3.6476*rho0(mgs)**2*g1x(mgs,lr)/(xdn0(lr)**2) * &
22901 & ( 2.*tmp * qrfrz(mgs) - tmp**2 * crfrz(mgs) )
22902 zrfrzf(mgs) = 3.6476*rho0(mgs)**2*g1x(mgs,lr)/(rhofrz**2) * &
22903 & ( 2.*tmp * qrfrzf(mgs) - tmp**2 * crfrzf(mgs) )
22904 ENDIF
22905 zrfrz(mgs) = min( zrfrz(mgs), max(0.4,qrfrz(mgs)/qx(mgs,lr))*zx(mgs,lr)*dtpinv )
22906! zrfrzf(mgs) = (xdn(mgs,lr)/xdn(mgs,lh))**2 * zrfrz(mgs)
22907! zrfrzf(mgs) = (xdn(mgs,lr)/xdnmx(lh))**2 * zrfrz(mgs)
22908! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*tmp * (qrfrzf(mgs)-qsplinter2(mgs)) - tmp**2 * crfrzf(mgs) )
22909! zrfrzf(mgs) = Min( zrfrzf(mgs), z )
22910 ! change this to be alpha=0?
22911 ENDIF
22912
22913 IF ( lhl > 1 .and. qhcnhl(mgs) .gt. 0.0 ) THEN
22914 tmp = qx(mgs,lhl)/cx(mgs,lhl)
22915 zhcnhl(mgs) = g1x(mgs,lhl)*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*( tmp ) * qhcnhl(mgs) - tmp**2 * chcnhl(mgs) )
22916
22917 ENDIF
22918
22919 IF ( qhcns(mgs) > 0.0 .and. chcns(mgs) > 0.0 .and. cx(mgs,ls) > cxmin .and. vhcns(mgs) > 0 ) THEN
22920 tmp = qx(mgs,ls)/cx(mgs,ls)
22921 r = rho0(mgs)*qhcns(mgs)/vhcns(mgs) ! density of new graupel particles
22922 IF ( imusnow == 3 ) THEN
22923 zhcns(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,ls)+2.)/(r**2*(alpha(mgs,ls)+1.)) * &
22924 & ( 2.*tmp * qhcns(mgs) - tmp**2 * chcnsh(mgs) )
22925 ELSE
22926 write(0,*) 'Value of imusnow not valid. Must be 3 (fix me for =1). imusnow = ',imusnow
22927 stop
22928 ENDIF
22929 ENDIF
22930
22931 IF ( qhcni(mgs) > 0.0 .and. chcnih(mgs) > 0.0 .and. cx(mgs,li) > cxmin .and. vhcni(mgs) > 0 ) THEN
22932 tmp = qx(mgs,li)/cx(mgs,li)
22933 r = rho0(mgs)*qhcni(mgs)/vhcni(mgs) ! density of new graupel particles
22934 zhcni(mgs) = 3.6476*rho0(mgs)**2*(alpha(mgs,li)+2.)/(r**2*(alpha(mgs,li)+1.)) * &
22935 & ( 2.*tmp * qhcni(mgs) - tmp**2 * chcnih(mgs) )
22936 ENDIF
22937
22938
22939 pzhwi(mgs) = &
22940 & +ifrzg*ffrzh*(zrfrzf(mgs) &
22941 & +il5(mgs)*ifiacrg*(ziacrf(mgs) ) ) &
22942! : + zhcnsh(mgs) + zhcnih(mgs) &
22943 & + zhacw(mgs) &
22944 & + zhacr(mgs) &
22945 & + zhcnhl(mgs) &
22946 & + zhacs(mgs) &
22947 & + zhaci(mgs) &
22948 & + f2h*zhcni(mgs) + f2h*zhcns(mgs) &
22949 & + max( 0.0, zhdsv(mgs) )
22950
22951 pzhwd(mgs) = 0.0 &
22952 & + (1-il5(mgs))*zhmlr(mgs) &
22953 & + zhshr(mgs) &
22954 & + min( 0.0, zhdsv(mgs) ) &
22955 & - il5(mgs)*zhlcnh(mgs)
22956
22957
22958! IF ( zhcnhl(mgs) < 0.0 ) THEN
22959! write(0,*) 'Problem with zhcnhl! zhcnhl,qhcnhl,chcnhl = ',zhcnhl(mgs),qhcnhl(mgs),chcnhl(mgs)
22960! write(0,*) 'g1,tmp = ',g1x(mgs,lhl),tmp
22961! write(0,*) ( 2.*( tmp ) * qhcnhl(mgs) - tmp**2 * chcnhl(mgs) )
22962!
22963!! STOP
22964! ENDIF
22965 end do
22966
22967 if (ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'end graupel reflectivity'
22968
22969 ENDIF
22970
22971!
22972! Hail reflectivity
22973!
22974
22975 do mgs = 1,ngscnt
22976
22977 zhldsv(mgs) = 0.0
22978 zhlacr(mgs) = 0.0
22979 zhlacw(mgs) = 0.0
22980
22981 ENDDO
22982
22983 IF ( lzhl .gt. 1 .or. ( lzr > 1 .and. lnhl > 1 ) ) THEN ! also run for 2-moment hail for 3-moment rain sources
22984
22985 if (ndebug .gt. 0 .and. my_rank>=0 ) write(0,*) my_rank, 'hail reflectivity'
22986
22987 do mgs = 1,ngscnt
22988
22989 IF ( qx(mgs,lhl) .gt. qxmin(lhl) .and. cx(mgs,lhl) .gt. 0.0 ) THEN
22990 tmp = qx(mgs,lhl)/cx(mgs,lhl)
22991 alp = max( alphamin, alpha(mgs,lhl) )
22992! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22993 g1 = g1x(mgs,lhl) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
22994
22995 IF ( .not. mixedphase .and. qhlmlr(mgs) /= 0.0 .and. chlmlr(mgs) /= 0.0 .and. ibinhlmlr < 1 ) THEN
22996 zhlmlr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*tmp * qhlmlr(mgs) - tmp**2 * chlmlr(mgs) )
22997 ENDIF
22998
22999 zhlshr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*tmp * qhlshr(mgs) - tmp**2 * chlshr(mgs) )
23000 IF ( lzr > 1 .and. qhlshr(mgs) /= 0.0 .and. chlshrr(mgs) /= 0.0 ) THEN
23001 IF ( temg(mgs) >= tfr ) THEN
23002 ! zhlshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn0(lr)))**2*( 2.*tmp * qhlshr(mgs) - tmp**2 * chlshrr(mgs) )
23003 ! IF ( zhlshrr(mgs) > 0.0 ) THEN
23004 ! zhlshrr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn0(lr)))**2*( 2.*tmp * qhlshr(mgs) - tmp**2 * chlshr(mgs) )
23005 ! ENDIF
23006 IF ( (shedalp + alpha(mgs,lhl))*xdia(mgs,lhl,1) < sheddiam ) THEN ! if not shedding small drops, then use alpha of hail
23007 z1 = g1*(6.0*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlshr(mgs)**2/ chlshrr(mgs) )
23008 ELSE
23009 z1 = g1shr*(6.0*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlshr(mgs)**2/ chlshrr(mgs) ) ! should this be g1shr?
23010 ENDIF
23011 zhlshrr(mgs) = z1
23012! z1 = g1mlr*(rho0(mgs)/(xdn(mgs,lr)))**2*( qhlshr(mgs)**2/ chlshrr(mgs) ) ! should this be g1shr?
23013! zhlshrr(mgs) = Max( z1, zhlshrr(mgs))
23014 ELSE
23015 zhlshrr(mgs) = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlshr(mgs)**2/ chlshrr(mgs) )
23016 ENDIF
23017
23018 zhlshrr(mgs) = min( 0.0, zhlshrr(mgs) )
23019 ENDIF
23020
23021 IF ( zhlshr(mgs) > 0.0 ) THEN
23022 write(0,*) 'Problem with zhlshr! zhlshr,qhlshr,chlshr = ',zhlshr(mgs),qhlshr(mgs),chlshr(mgs)
23023 write(0,*) 'g1,tmp, qx,cx,zx = ',g1,tmp,qx(mgs,lhl),cx(mgs,lhl),zx(mgs,lhl)
23024 write(0,*) ( 2.*tmp * qhlshr(mgs) - tmp**2 * chlshr(mgs) ), 2.*tmp * qhlshr(mgs), - tmp**2 * chlshr(mgs)
23025 write(0,*) 'temcg = ',temcg(mgs),'chlshr recalc = ',(cx(mgs,lhl)/(qx(mgs,lhl)+1.e-20))*qhlshr(mgs)
23026
23027 stop
23028 ENDIF
23029! zhlshr(mgs) = Min( 0.0, zhlshr(mgs) )
23030
23031! zhlshr(mgs) = (xdn0(lr)/(xdn(mgs,lhl)))**2*( zx(mgs,lhl) * qhlshr(mgs) )
23032
23033 qtmp = qhldpv(mgs) + qhlcev(mgs)
23034 ctmp = chldpv(mgs) + chlcev(mgs)
23035
23036 zhldsv(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*( tmp ) * qtmp - tmp**2 * ctmp )
23037
23038 alp = max( alphahacx, alpha(mgs,lhl) )
23039! g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
23040 g1 = g1x(mgs,lhl) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
23041
23042 IF ( .true. ) THEN ! {
23043 IF ( qhlacr(mgs) .gt. 0.0 ) THEN
23044! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lhl)+dtp*qhlacr(mgs))**2)/(cx(mgs,lhl))
23045 zhlacr(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*( tmp ) * qhlacr(mgs) )
23046! zhlacr(mgs) = Min( zxmxd(mgs,lr), zhlacr(mgs) )
23047
23048! IF ( z > zx(mgs,lhl) ) THEN
23049! zhlacr(mgs) = (z - zx(mgs,lhl))*dtpinv
23050! ELSE
23051! zhlacr(mgs) = 0.0
23052! ENDIF
23053 ENDIF
23054
23055! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) )
23056! zhacr(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( tmp ) * qhacr(mgs) - tmp**2 * chacr(mgs) )
23057
23058 IF ( qhlacw(mgs) .gt. 0.0 ) THEN
23059 alp = max( 3.0, alpha(mgs,lhl)+1. )
23060 g1 = (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
23061
23062! z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lhl)+dtp*(qhlacw(mgs)-qhlmul1(mgs)))**2)/(cx(mgs,lhl))
23063! zhlacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lhl)/cx(mgs,lhl)) * qhlacw(mgs) )
23064 zhlacw(mgs) = g1*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*tmp * qhlacw(mgs) )
23065
23066! IF ( z > zx(mgs,lhl) ) THEN
23067! zhlacw(mgs) = (z - zx(mgs,lhl))*dtpinv
23068! ENDIF
23069 g1 = g1x(mgs,lhl) ! (6.0 + alp)*(5.0 + alp)*(4.0 + alp)/((3.0 + alp)*(2.0 + alp)*(1.0 + alp))
23070 ENDIF
23071
23072 ELSE ! } .false. {
23073
23074 IF ( qhlacw(mgs) .gt. 0.0 .or. qhlacr(mgs) .gt. 0.0 ) THEN
23075 z = g1*(6.*rho0(mgs)/(pi*1000.))**2*( (qx(mgs,lhl)+dtp*(qhlacr(mgs) + qhlacw(mgs)-qhlmul1(mgs)))**2)/(cx(mgs,lhl))
23076! zhlacw(mgs) = g1*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*( qx(mgs,lhl)/cx(mgs,lhl)) * qhlacw(mgs) )
23077 IF ( z > zx(mgs,lhl) ) THEN
23078 zhlacw(mgs) = (z - zx(mgs,lhl))*dtpinv
23079 ENDIF
23080 ENDIF
23081
23082 ENDIF ! }
23083
23084 ENDIF
23085! qsplinter(mgs)
23086
23087 IF ( lzhl > 1 ) THEN
23088 pzhli(mgs) = ffrzh*(((1.0-ifrzg)*zrfrzf(mgs) &
23089 & +il5(mgs)*(1.0-ifiacrg)*ziacrf(mgs) )) &
23090 & + il5(mgs)*zhlcnh(mgs) &
23091 & + zhlacw(mgs) &
23092 & + zhlacr(mgs) &
23093! : + zhlacs(mgs) &
23094 & + max( 0.0, zhldsv(mgs) )
23095
23096 pzhld(mgs) = 0.0 &
23097 & + (1-il5(mgs))*zhlmlr(mgs) &
23098 & + zhlshr(mgs) &
23099 & - zhcnhl(mgs) &
23100 & + min( 0.0, zhldsv(mgs) )
23101
23102
23103 IF ( .not. ( -1.0 < pzhli(mgs) .and. pzhli(mgs) < 1.e20 ) ) THEN
23104 write(iunit,*) 'Problem with pzhli!'
23105 write(iunit,*) 'zhlcnh,zhlacw,zhlacr,zhldsv = ',zhlcnh(mgs),zhlacw(mgs),zhlacr(mgs),zhldsv(mgs)
23106 ENDIF
23107
23108 IF ( .not. ( -1.0e20 < pzhld(mgs) .and. pzhld(mgs) < 1. ) ) THEN
23109 write(iunit,*) 'Problem with pzhld!'
23110 write(iunit,*) 'zhlmlr,zhlshr,zhldsv = ',zhlmlr(mgs),zhlshr(mgs),zhldsv(mgs)
23111 ENDIF
23112
23113 ENDIF ! lzhl > 1
23114
23115 end do
23116
23117 ENDIF
23118
23119!
23120! rain reflectivity
23121!
23122 if (ndebug .gt. 0 ) write(0,*) 'WARMZIEG: dbg = 11'
23123
23124 IF ( lzr .gt. 1 ) THEN !
23125
23126 DO mgs = 1,ngscnt
23127
23128 zracw(mgs) = 0.0
23129 zracr(mgs) = 0.0
23130 zrcev(mgs) = 0.0
23131 zrach(mgs) = 0.0
23132 zrachl(mgs) = 0.0
23133 zsshr(mgs) = 0.0
23134 zsshrr(mgs) = 0.0
23135! zsmlr(mgs) = 0.0
23136 zsmlrr(mgs) = 0.0
23137
23138 IF ( qx(mgs,ls) .gt. qxmin(ls) .and. ( csmlr(mgs) /= 0.0 .or. csshr(mgs) /= 0.0 .or. &
23139 csmlrr(mgs) /= 0.0 .or. csshrr(mgs) /= 0.0) ) THEN !{
23140 tmp = qx(mgs,ls)/cx(mgs,ls)
23141 g1 = 36.*(xnu(ls)+2.0)/((xnu(ls)+1.0)*pi**2)
23142 IF ( .not. mixedphase ) THEN
23143! zsmlr(mgs) = (xdn(mgs,ls)/xdn(mgs,lr))**2*g1*(rho0(mgs)/(xdn(mgs,ls)))**2* &
23144! & ( 2.*tmp * qsmlr(mgs) - tmp**2 * csmlr(mgs) )
23145
23146 IF ( csmlrr(mgs) /= 0.0 ) THEN
23147 z1 = g1smlr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qsmlr(mgs)**2/ csmlrr(mgs) )
23148 zsmlrr(mgs) = z1
23149 ENDIF
23150 ENDIF
23151
23152! zsshr(mgs) = (xdn(mgs,ls)/xdn(mgs,lr))**2*g1*(rho0(mgs)/(xdn(mgs,ls)))**2* &
23153! & ( 2.*tmp * qsshr(mgs) - tmp**2 * csshr(mgs) )
23154
23155 IF ( csshrr(mgs) /= 0.0 ) THEN
23156 z1 = g1smlr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qsshr(mgs)**2/ csshrr(mgs) )
23157 zsshrr(mgs) = z1
23158 ENDIF
23159
23160 ENDIF !}
23161
23162 IF ( .not. mixedphase ) THEN !{
23163 IF ( zhmlr(mgs) < 0.0 .and. chmlrr(mgs) /= 0.0 .and. ibinhmlr == 0 ) THEN !{
23164 tmp = qx(mgs,lh)/cx(mgs,lh)
23165! zhmlrr(mgs) = Min(0.0, (xdn(mgs,lh)/xdn(mgs,lr))**2 * &
23166! & g1x(mgs,lh)*(6.*rho0(mgs)/(pi*xdn(mgs,lh)))**2*( 2.*tmp * qhmlr(mgs) - tmp**2 * chmlrr(mgs) ) )
23167
23168! IF ( zhmlrr(mgs) >= 0. ) THEN
23169! zhmlrr(mgs) = (xdn(mgs,lh)/xdn(mgs,lr))**2 * zhmlr(mgs)
23170! ENDIF
23171 IF ( (shedalp + alpha(mgs,lh))*xdia(mgs,lh,1) < sheddiam ) THEN ! if not shedding small drops, then use alpha of graupel
23172 z1 = g1x(mgs,lh)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhmlr(mgs)**2/ chmlrr(mgs) )
23173 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)
23174 z1 = min(g1x(mgs,lh),g1shr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhmlr(mgs)**2/ chmlrr(mgs) )
23175 ENDIF
23176 zhmlrr(mgs) = z1
23177! z1 = g1mlr*(rho0(mgs)/(xdn(mgs,lr)))**2*( qhmlr(mgs)**2/ chmlrr(mgs) )
23178! zhmlrr(mgs) = Max( z1, zhmlrr(mgs))
23179 ENDIF !}
23180
23181
23182! zhshrr(mgs) = (xdn(mgs,lh)/xdn(mgs,lr))**2 * zhshr(mgs)
23183
23184 IF ( lhl > 1 .and. qhlmlr(mgs) /= 0 .and. ibinhlmlr == 0) THEN
23185 tmp = qx(mgs,lhl)/cx(mgs,lhl)
23186! zhlmlrr(mgs) = Min(0.0, (xdn(mgs,lhl)/xdn(mgs,lr))**2 * &
23187! & g1x(mgs,lhl)*(6.*rho0(mgs)/(pi*xdn(mgs,lhl)))**2*( 2.*tmp * qhlmlr(mgs) - tmp**2 * chlmlrr(mgs) ) )
23188
23189! IF ( zhlmlrr(mgs) >= 0. ) THEN ! should be negative, if not, then use alternate calculation
23190! zhlmlrr(mgs) = (xdn(mgs,lhl)/xdn(mgs,lr))**2 * zhlmlr(mgs)
23191! ENDIF
23192
23193 IF ( (shedalp + alpha(mgs,lhl))*xdia(mgs,lhl,1) < sheddiam ) THEN ! if not shedding small drops, then use alpha of hail
23194 z1 = g1x(mgs,lhl)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlmlr(mgs)**2/ chlmlrr(mgs) )
23195 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)
23196 z1 = min(g1x(mgs,lhl),g1shr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlmlr(mgs)**2/ chlmlrr(mgs) )
23197! z1 = g1shr*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( qhlmlr(mgs)**2/ chlmlrr(mgs) )
23198 ENDIF
23199 zhlmlrr(mgs) = z1
23200
23201! z1 = g1mlr*(rho0(mgs)/(xdn(mgs,lr)))**2*( qhlmlr(mgs)**2/ chlmlrr(mgs) )
23202! zhlmlrr(mgs) = Max( z1, zhlmlrr(mgs))
23203! zhlmlr(mgs) =
23204! zhlshrr(mgs) = (xdn(mgs,lhl)/xdn(mgs,lr))**2 * zhlshr(mgs)
23205 ENDIF
23206
23207 ENDIF ! }
23208
23209 IF ( qx(mgs,lr) .gt. qxmin(lr) .and. cx(mgs,lr) .gt. 0.0 ) THEN
23210
23211 tmp = qx(mgs,lr)/cx(mgs,lr)
23212 g1 = g1x(mgs,lr) ! 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
23213
23214
23215 IF ( qracw(mgs) > 0.0 .and. cx(mgs,lr) > 0.0 ) THEN
23216 zracw(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*1000.))**2*( 2.*tmp * qracw(mgs) )
23217 ENDIF
23218
23219 IF ( cracr(mgs) /= 0.0 .and. cx(mgs,lr) > 0.0 ) THEN
23220 zracr(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*1000.))**2*( tmp**2 * cracr(mgs) )
23221 ENDIF
23222
23223 qtmp = qrcev(mgs)
23224 ctmp = crcev(mgs)
23225
23226! IF ( .false. .or. iferwisventr == 2 ) THEN
23227! zrcev(mgs) = Min(0.0, (12./(pii*xdn(mgs,lr)))*xdia(mgs,lr,1)**3*fvce(mgs)*rwcap(mgs)*rwventz(mgs) )
23228! ELSE
23229 zrcev(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2*( 2.*( tmp ) * qtmp - tmp**2 * ctmp )
23230
23231
23232 IF ( iferwisventr == 2 ) THEN
23233 vent1 = min(0.0, (12./(pii*xdn(mgs,lr)))*xdia(mgs,lr,1)**3*fvce(mgs)*rwcap(mgs)*rwventz(mgs))
23234 zrcev(mgs) = max( dble(zrcev(mgs)), vent1 )
23235 ENDIF
23236! IF ( ny == 2 .and. igs(mgs) == 20 ) THEN
23237! write(0,*) 'k,zrcevold,new,maxdep : ',kgs(mgs),zrcev(mgs),vent1,-zxmxd(mgs,lr),alpha(mgs,lr),cx(mgs,lr)
23238! ENDIF
23239
23240
23241! ENDIF
23242 zrcev(mgs) = max( zrcev(mgs), -zxmxd(mgs,lr) )
23243
23244 IF ( qhacr(mgs) > 0.0 ) THEN
23245 zrach(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2* &
23246 & ( 2.*( qx(mgs,lr)/cx(mgs,lr)) * qhacr(mgs) - tmp**2 * chacr(mgs) )
23247 zrach(mgs) = min( zrach(mgs), zxmxd(mgs,lr) )
23248
23249 ENDIF
23250
23251 IF ( lhl > 1 .and. qhlacr(mgs) > 0.0 ) THEN
23252 zrachl(mgs) = g1x(mgs,lr)*(6.*rho0(mgs)/(pi*xdn(mgs,lr)))**2* &
23253 & ( 2.*( qx(mgs,lr)/cx(mgs,lr)) * qhlacr(mgs) - tmp**2 * chlacr(mgs) )
23254 zrachl(mgs) = min( zrachl(mgs), zxmxd(mgs,lr) )
23255 ENDIF
23256
23257
23258
23259 ENDIF
23260
23261 pzrwi(mgs) = zrcnw(mgs) + zracw(mgs) + zracr(mgs) &
23262 & + max( 0.,zrcev(mgs) ) &
23263 & - (1-il5(mgs))*zsmlrr(mgs) &
23264 & - zsshrr(mgs) &
23265 & - (1-il5(mgs))*zhmlrr(mgs) &
23266 & - zhshrr(mgs) &
23267 & - (1-il5(mgs))*zhlmlrr(mgs) &
23268 & - zhlshrr(mgs)
23269
23270
23271 pzrwd(mgs) = 0.0 &
23272 & + min(0.,zrcev(mgs) ) &
23273 & - zrach(mgs) &
23274 & - zrachl(mgs) &
23275 & - zrfrz(mgs) &
23276 & - il5(mgs)*(ziacr(mgs) )
23277
23278
23279 IF ( zx(mgs,lr) + dtp*(pzrwi(mgs)+pzrwd(mgs)) <= 0.0 &
23280 .and. qx(mgs,lr) > qxmin(lr) ) THEN
23281 pzrwd(mgs) = -zx(mgs,lr)*dtpinv - pzrwi(mgs)
23282 ENDIF
23283
23284 ENDDO
23285
23286 ENDIF
23287
23288
23289
23290!
23291! Snow volume
23292!
23293 IF ( lvol(ls) .gt. 1 ) THEN
23294 do mgs = 1,ngscnt
23295! pvswi(mgs) = rho0(mgs)*( pqswi(mgs) )/xdn0(ls)
23296
23297 pvswi(mgs) = rho0(mgs)*( &
23298!aps > il5*qsfzs(mgs)/xdn(mgs,ls) &
23299!aps > -il5*qsfzs(mgs)/xdn(mgs,lr) &
23300 & +il5(mgs)*(qscni(mgs)+qsaci(mgs)+qsdpv(mgs) &
23301 & + qscnvi(mgs) + (1. - ifrzs)*qiacrs(mgs) &
23302 & + (1. - ifrzs)*qrfrzs(mgs) &
23303 & )/xdn0(ls) &
23304 & + (qsacr(mgs))/rimdn(mgs,ls) ) + vsacw(mgs)
23305! > + (qsacw(mgs) + qsacr(mgs))/rimdn(mgs,ls) )
23306 pvswd(mgs) = rho0(mgs)*( pqswd(mgs) )/xdn0(ls) &
23307! > -qhacs(mgs)
23308! > -qhcns(mgs)
23309! > +(1-il5(mgs))*qsmlr(mgs) + qsshr(mgs)
23310! > +il5(mgs)*(qssbv(mgs))
23311 & -rho0(mgs)*qsmul(mgs)/xdn0(ls)
23312!aps > +rho0(mgs)*(1-il5(mgs))*(
23313!aps > qsmlr(mgs)/xdn(mgs,ls)
23314!aps > +(qscev-qsmlr(mgs))/xdn(mgs,lr) )
23315 end do
23316
23317!aps IF (mixedphase) THEN
23318!aps pvswd(mgs) = pvswd(mgs)
23319!aps > + rho0(mgs)*qsshr(mgs)/xdn(mgs,lr)
23320!aps ENDIF
23321
23322 ENDIF
23323!
23324! Graupel volume
23325!
23326 IF ( lvol(lh) .gt. 1 ) THEN
23327 DO mgs = 1,ngscnt
23328! pvhwi(mgs) = rho0(mgs)*( (pqhwi(mgs) )/xdn0(lh) )
23329
23330! pvhwi(mgs) = rho0(mgs)*( (pqhwi(mgs) - il5(mgs)*qrfrzf(mgs) )/xdn0(lh) !
23331! : + il5(mgs)*qrfrzf(mgs)/rhofrz )
23332
23333 pvhwi(mgs) = rho0(mgs)*( &
23334 & +il5(mgs)*( ifiacrg*ffrzh*qracif(mgs))/rhofrz &
23335!erm > + il5(mgs)*qhfzh(mgs)/rhofrz !aps: or use xdnmx(lh)? &
23336 & + ( il5(mgs)*qhdpv(mgs)/qhdpvdn &
23337 & + (qhacs(mgs) + qhaci(mgs))/qhacidn ) ) &
23338 & + rho0(mgs)*max(0.0, qhcev(mgs))/1000. & ! only used in mixed phase: evaporation/condensation of liquid water coating
23339! > + qhacs(mgs) + qhaci(mgs) )/xdn0(ls) ) &
23340 & + f2h*vhcns(mgs) &
23341 & + vhacr(mgs) + vhacw(mgs) + vhfzh(mgs) & ! qhacw(mgs)/rimdn(mgs,lh)
23342! > + vhfrh(mgs) &
23343 & + f2h*vhcni(mgs) + (ifiacrg*viacrf(mgs) + ifrzg*vrfrzf(mgs))*ffrzh
23344! > +qhacr(mgs)/raindn(mgs,lh) + qhacw(mgs)/rimdn(mgs,lh)
23345
23346! pvhwd(mgs) = rho0(mgs)*(pqhwd(mgs) )/xdn0(lh)
23347
23348 pvhwd(mgs) = rho0(mgs)*( &
23349! > qhshr(mgs)/xdn0(lr) &
23350! > - il5(mgs)*qhfzh(mgs)/xdn(mgs,lr) &
23351 & +( (1-il5(mgs))*vhmlr(mgs) &
23352! > +il5(mgs)*qhsbv(mgs) &
23353 & + qhsbv(mgs) &
23354 & + min(0.0, qhcev(mgs)) &
23355 & -qhmul1(mgs) )/xdn(mgs,lh) ) &
23356 & - vhlcnh(mgs) + vhshdr(mgs) - vhsoak(mgs) - vscnh(mgs)
23357
23358! IF (mixedphase) THEN
23359! pvhwd(mgs) = pvhwd(mgs)
23360! > + rho0(mgs)*qhshr(mgs)/xdn(mgs,lh) !xdn(mgs,lr)
23361! ENDIF
23362
23363 IF ( lzh > 1 .and. qx(mgs,lh) > qxmin(lh) .and. &
23364 vx(mgs,lh) + dtp*(pvhwi(mgs) + pvhwd(mgs)) > rho0(mgs)*qxmin(lh)/900. ) THEN
23365! Calculate change in reflectivity due to density changes
23366
23367 xdn_new = rho0(mgs)*(qx(mgs,lh) + dtp*(pqhwi(mgs) + pqhwd(mgs) ))/ &
23368 & (vx(mgs,lh) + dtp*(pvhwi(mgs) + pvhwd(mgs)) )
23369
23370 IF ( mixedphase ) THEN
23371 IF ( qxw(mgs,lh) .gt. 0.0 ) THEN
23372 dnmx = xdnmx(lr)
23373 ELSE
23374 dnmx = xdnmx(lh)
23375 ENDIF
23376 ELSE
23377 dnmx = xdnmx(lh)
23378 ENDIF
23379
23380 xdn_new = max( min( xdn_new, dnmx ), xdnmn(lh) )
23381
23382 drhodt = (xdn_new - xdn(mgs,lh))*dtpinv
23383
23384 zhwdn(mgs) = -2.*g1x(mgs,lh)*(rho0(mgs)*qx(mgs,lh)*6.*pii )**2/(cx(mgs,lh)*xdn(mgs,lh)**3)*drhodt
23385
23386 pzhwi(mgs) = pzhwi(mgs) + max(0.0, zhwdn(mgs))
23387 pzhwd(mgs) = pzhwd(mgs) + min(0.0, zhwdn(mgs))
23388
23389
23390 ENDIF
23391 IF ( .false. .and. ny .eq. 2 .and. kgs(mgs) .eq. 9 .and. igs(mgs) .eq. 19 ) THEN
23392
23393 write(iunit,*)
23394 write(iunit,*) 'Graupel at ',igs(mgs),kgs(mgs)
23395!
23396 write(iunit,*) il5(mgs)*qrfrzf(mgs), qrfrzf(mgs) - qrfrz(mgs)
23397 write(iunit,*) il5(mgs)*qiacrf(mgs)
23398 write(iunit,*) il5(mgs)*qracif(mgs)
23399 write(iunit,*) 'qhcns',qhcns(mgs)
23400 write(iunit,*) 'qhcni',qhcni(mgs)
23401 write(iunit,*) il5(mgs)*(qhdpv(mgs))
23402 write(iunit,*) 'qhacr ',qhacr(mgs)
23403 write(iunit,*) 'qhacw', qhacw(mgs)
23404 write(iunit,*) 'qhacs', qhacs(mgs)
23405 write(iunit,*) 'qhaci', qhaci(mgs)
23406 write(iunit,*) 'pqhwi = ',pqhwi(mgs)
23407 write(iunit,*)
23408 write(iunit,*) 'qhcev',qhcev(mgs)
23409 write(iunit,*)
23410 write(iunit,*) 'qhshr',qhshr(mgs)
23411 write(iunit,*) 'qhmlr', (1-il5(mgs))*qhmlr(mgs)
23412 write(iunit,*) 'qhsbv', qhsbv(mgs)
23413 write(iunit,*) 'qhlcnh',-qhlcnh(mgs)
23414 write(iunit,*) 'qhmul1',-qhmul1(mgs)
23415 write(iunit,*) 'pqhwd = ', pqhwd(mgs)
23416 write(iunit,*)
23417 write(iunit,*) 'Volume'
23418 write(iunit,*)
23419 write(iunit,*) 'pvhwi',pvhwi(mgs)
23420 write(iunit,*) 'vhcns', vhcns(mgs)
23421 write(iunit,*) 'vhacr,vhacw',vhacr(mgs), vhacw(mgs) ! qhacw(mgs)/rimdn(mgs,lh)
23422 write(iunit,*) 'vhcni',vhcni(mgs)
23423 write(iunit,*)
23424 write(iunit,*) 'pvhwd',pvhwd(mgs)
23425 write(iunit,*) 'vhlcnh,vhshdr,vhsoak ', vhlcnh(mgs), vhshdr(mgs), vhsoak(mgs)
23426 write(iunit,*) 'vhmlr', vhmlr(mgs)
23427 write(iunit,*)
23428! write(iunit,*)
23429! write(iunit,*)
23430! write(iunit,*)
23431 write(iunit,*) 'Concentration'
23432 write(iunit,*) pchwi(mgs),pchwd(mgs)
23433 write(iunit,*) crfrzf(mgs)
23434 write(iunit,*) chcns(mgs)
23435 write(iunit,*) ciacrf(mgs)
23436
23437
23438 ENDIF
23439
23440
23441 ENDDO
23442
23443 ENDIF
23444!
23445!
23446!
23447
23448!
23449! Hail volume
23450!
23451 IF ( lhl .gt. 1 ) THEN
23452 IF ( lvol(lhl) .gt. 1 ) THEN
23453 DO mgs = 1,ngscnt
23454
23455 pvhli(mgs) = rho0(mgs)*( &
23456 & + ( il5(mgs)*(((1.0-ifiacrg)*ffrzh*qracif(mgs))/rhofrz + qhldpv(mgs) ) &
23457! & + Max(0.0, qhlcev(mgs)) &
23458! & + qhlacs(mgs) + qhlaci(mgs) )/xdnmn(lhl) ) & ! xdn0(ls) ) &
23459! & + qhlacs(mgs) + qhlaci(mgs) )/xdnmn(lh) ) & ! yes, this is 'lh' on purpose
23460 & + qhlacs(mgs) + qhlaci(mgs) )/500. ) & ! changed to 500 instead of min graupel density to keep hail density from dropping too much
23461 & + rho0(mgs)*max(0.0, qhlcev(mgs))/1000. &
23462 & + vhlcnhl(mgs) + ((1.0-ifiacrg)*ffrzh*viacrf(mgs) + (1.0-ifrzg)*ffrzh*vrfrzf(mgs)) &
23463 & + vhlacr(mgs) + vhlacw(mgs) + vhlfzhl(mgs) ! qhlacw(mgs)/rimdn(mgs,lhl)
23464
23465 pvhld(mgs) = rho0(mgs)*( &
23466 & +( qhlsbv(mgs) &
23467 & + min(0.0, qhlcev(mgs)) &
23468 & -qhlmul1(mgs) )/xdn(mgs,lhl) ) &
23469! & + vhlmlr(mgs) &
23470 & + rho0(mgs)*(1-il5(mgs))*vhlmlr(mgs)/xdn(mgs,lhl) &
23471 & + vhlshdr(mgs) - vhlsoak(mgs)
23472
23473 IF ( lzhl > 1 .and. qx(mgs,lhl) > qxmin(lhl) .and. &
23474 vx(mgs,lhl) + dtp*(pvhli(mgs) + pvhld(mgs)) > rho0(mgs)*qxmin(lhl)/900. ) THEN
23475! Calculate change in reflectivity due to density changes
23476
23477 xdn_new = rho0(mgs)*(qx(mgs,lhl) + dtp*(pqhli(mgs) + pqhld(mgs) ))/ &
23478 & (vx(mgs,lhl) + dtp*(pvhli(mgs) + pvhld(mgs)) )
23479
23480 IF ( mixedphase ) THEN
23481 IF ( qxw(mgs,lhl) .gt. 0.0 ) THEN
23482 dnmx = xdnmx(lr)
23483 ELSE
23484 dnmx = xdnmx(lhl)
23485 ENDIF
23486 ELSE
23487 dnmx = xdnmx(lhl)
23488 ENDIF
23489 xdn_new = max( min( xdn_new, dnmx ), xdnmn(lhl) )
23490
23491 drhodt = (xdn_new - xdn(mgs,lhl))*dtpinv
23492
23493 zhldn(mgs) = -2.*g1x(mgs,lhl)*(rho0(mgs)*qx(mgs,lhl)*6.*pii )**2/(cx(mgs,lhl)*xdn(mgs,lhl)**3)*drhodt
23494
23495 pzhli(mgs) = pzhli(mgs) + max(0.0, zhldn(mgs))
23496 pzhld(mgs) = pzhld(mgs) + min(0.0, zhldn(mgs))
23497
23498
23499 ENDIF
23500
23501 ENDDO
23502
23503 ENDIF
23504 ENDIF
23505
23506
23507 if ( ndebug .ge. 1 ) then
23508 do mgs = 1,ngscnt
23509!
23510 ptotal(mgs) = 0.
23511 ptotal(mgs) = ptotal(mgs) &
23512 & + pqwvi(mgs) + pqwvd(mgs) &
23513 & + pqcwi(mgs) + pqcwd(mgs) &
23514 & + pqcii(mgs) + pqcid(mgs) &
23515 & + pqrwi(mgs) + pqrwd(mgs) &
23516 & + pqswi(mgs) + pqswd(mgs) &
23517 & + pqhwi(mgs) + pqhwd(mgs) &
23518 & + pqhli(mgs) + pqhld(mgs)
23519!
23520
23521
23522
23523 ENDDO
23524
23525 do mgs = 1,ngscnt
23526
23527 if ( ( (ndebug .ge. 0 ) .and. abs(ptotal(mgs)) .gt. eqtot ) &
23528! if ( ( abs(ptotal(mgs)) .gt. eqtot )
23529! : .or. pqswi(mgs)*dtp .gt. 1.e-3
23530! : .or. pqhwi(mgs)*dtp .gt. 1.e-3
23531! : .or. dtp*(pqrwi(mgs)+pqrwd(mgs)) .gt. 10.0e-3
23532! : .or. dtp*(pccii(mgs)+pccid(mgs)) .gt. 1.e7
23533! : .or. dtp*(pcipi(mgs)+pcipd(mgs)) .gt. 1.e7 &
23534 & .or. .not. (ptotal(mgs) .lt. 1.0 .and. ptotal(mgs) .gt. -1.0) & ! this line is basically checking for NaNs
23535 & ) then
23536 write(iunit,*) 'YIKES! ','ptotal1',mgs,igs(mgs),jgs, &
23537 & kgs(mgs),ptotal(mgs)
23538
23539 write(iunit,*) 't7: ', t7(igs(mgs),jgs,kgs(mgs))
23540 write(iunit,*) 'cci,ccw,crw,rdia: ',cx(mgs,li),cx(mgs,lc),cx(mgs,lr),0.5*xdia(mgs,lr,1)
23541 write(iunit,*) 'qc,qi,qr : ',qx(mgs,lc),qx(mgs,li),qx(mgs,lr)
23542 write(iunit,*) 'rmas, qrcalc : ',xmas(mgs,lr),xmas(mgs,lr)*cx(mgs,lr)/rho0(mgs)
23543 write(iunit,*) 'vti,vtc,eiw,vtr: ',vtxbar(mgs,li,1),vtxbar(mgs,lc,1),eiw(mgs),vtxbar(mgs,lr,1)
23544 write(iunit,*) 'cidia,cwdia,qcmxd: ', xdia(mgs,li,1),xdia(mgs,lc,1),qcmxd(mgs)
23545 write(iunit,*) 'snow: ',qx(mgs,ls),cx(mgs,ls),swvent(mgs),vtxbar(mgs,ls,1),xdia(mgs,ls,1)
23546 write(iunit,*) 'graupel: ',qx(mgs,lh),cx(mgs,lh),hwvent(mgs),vtxbar(mgs,lh,1),xdia(mgs,lh,1)
23547 IF ( lhl .gt. 1 ) write(iunit,*) 'hail: ',qx(mgs,lhl),cx(mgs,lhl),hlvent(mgs),vtxbar(mgs,lhl,1),xdia(mgs,lhl,1)
23548
23549
23550 write(iunit,*) 'li: ',xdia(mgs,li,1),xdia(mgs,li,2),xmas(mgs,li),qx(mgs,li), &
23551 & vtxbar(mgs,li,1)
23552
23553
23554 write(iunit,*) 'rain cx,xv : ',cx(mgs,lr),xv(mgs,lr)
23555 write(iunit,*) 'temcg = ', temcg(mgs)
23556
23557 write(iunit,*) 'v ', pqwvi(mgs) ,pqwvd(mgs)
23558 write(iunit,*) 'c ', pqcwi(mgs) ,pqcwd(mgs)
23559 write(iunit,*) 'ci', pqcii(mgs) ,pqcid(mgs)
23560 write(iunit,*) 'r ', pqrwi(mgs) ,pqrwd(mgs)
23561 write(iunit,*) 's ', pqswi(mgs) ,pqswd(mgs)
23562 write(iunit,*) 'h ', pqhwi(mgs) ,pqhwd(mgs)
23563 write(iunit,*) 'hl', pqhli(mgs) ,pqhld(mgs)
23564 tmp = pqwvi(mgs) + pqwvd(mgs) &
23565 & + pqcwi(mgs) + pqcwd(mgs) &
23566 & + pqcii(mgs) + pqcid(mgs) &
23567 & + pqrwi(mgs) + pqrwd(mgs) &
23568 & + pqswi(mgs) + pqswd(mgs) &
23569 & + pqhwi(mgs) + pqhwd(mgs) &
23570 & + pqhli(mgs) + pqhld(mgs)
23571
23572 write(iunit,*) 'total = ',tmp
23573 write(iunit,*) 'END OF OUTPUT OF SOURCE AND SINK'
23574
23575!
23576! print production terms
23577!
23578 write(iunit,*)
23579 write(iunit,*) 'Vapor'
23580!
23581 write(iunit,*) -min(0.0,qrcev(mgs))
23582 write(iunit,*) -il5(mgs)*qhsbv(mgs)
23583 write(iunit,*) -il5(mgs)*qhlsbv(mgs)
23584 write(iunit,*) -il5(mgs)*qssbv(mgs)
23585 write(iunit,*) -il5(mgs)*qisbv(mgs)
23586 write(iunit,*) 'pqwvi= ', pqwvi(mgs)
23587 write(iunit,*) -max(0.0,qrcev(mgs))
23588 write(iunit,*) -max(0.0,qhcev(mgs))
23589 write(iunit,*) -max(0.0,qhlcev(mgs))
23590 write(iunit,*) -max(0.0,qscev(mgs))
23591 write(iunit,*) -il5(mgs)*qiint(mgs)
23592 write(iunit,*) -il5(mgs)*qhdpv(mgs)
23593 write(iunit,*) -il5(mgs)*qhldpv(mgs)
23594 write(iunit,*) -il5(mgs)*qsdpv(mgs)
23595 write(iunit,*) -il5(mgs)*qidpv(mgs)
23596 write(iunit,*) 'pqwvd = ', pqwvd(mgs)
23597!
23598 write(iunit,*)
23599 write(iunit,*) 'Cloud ice'
23600!
23601 write(iunit,*) il5(mgs)*qicicnt(mgs)
23602 write(iunit,*) il5(mgs)*qidpv(mgs)
23603 write(iunit,*) il5(mgs)*qiacw(mgs)
23604 write(iunit,*) il5(mgs)*qwfrzc(mgs)
23605 write(iunit,*) il5(mgs)*qwctfzc(mgs)
23606 write(iunit,*) il5(mgs)*qicichr(mgs)
23607 write(iunit,*) qhmul1(mgs)
23608 write(iunit,*) qhlmul1(mgs)
23609 write(iunit,*) 'pqcii = ', pqcii(mgs)
23610 write(iunit,*) -il5(mgs)*qscni(mgs)
23611 write(iunit,*) -il5(mgs)*qscnvi(mgs)
23612 write(iunit,*) -il5(mgs)*qraci(mgs)
23613 write(iunit,*) -il5(mgs)*qsaci(mgs)
23614 write(iunit,*) -il5(mgs)*qhaci(mgs)
23615 write(iunit,*) -il5(mgs)*qhlaci(mgs)
23616 write(iunit,*) il5(mgs)*qisbv(mgs)
23617 write(iunit,*) (1.-il5(mgs))*qimlr(mgs)
23618 write(iunit,*) -il5(mgs)*qhcni(mgs)
23619 write(iunit,*) 'pqcid = ', pqcid(mgs)
23620 write(iunit,*) ' Conc:'
23621 write(iunit,*) pccii(mgs),pccid(mgs)
23622 write(iunit,*) il5(mgs),cicint(mgs)
23623 write(iunit,*) cwfrzc(mgs),cwctfzc(mgs)
23624 write(iunit,*) cicichr(mgs)
23625 write(iunit,*) chmul1(mgs)
23626 write(iunit,*) chlmul1(mgs)
23627 write(iunit,*) csmul(mgs)
23628!
23629!
23630!
23631!
23632 write(iunit,*)
23633 write(iunit,*) 'Cloud water'
23634!
23635 write(iunit,*) 'pqcwi =', pqcwi(mgs)
23636 write(iunit,*) -il5(mgs)*qiacw(mgs)
23637 write(iunit,*) -il5(mgs)*qwfrzc(mgs)
23638 write(iunit,*) -il5(mgs)*qwctfzc(mgs)
23639! write(iunit,*) -il5(mgs)*qwfrzp(mgs)
23640! write(iunit,*) -il5(mgs)*qwctfzp(mgs)
23641 write(iunit,*) -il5(mgs)*qiihr(mgs)
23642 write(iunit,*) -il5(mgs)*qicichr(mgs)
23643 write(iunit,*) -il5(mgs)*qipiphr(mgs)
23644 write(iunit,*) -qracw(mgs)
23645 write(iunit,*) -qsacw(mgs)
23646 write(iunit,*) -qrcnw(mgs)
23647 write(iunit,*) -qhacw(mgs)
23648 write(iunit,*) -qhlacw(mgs)
23649 write(iunit,*) 'pqcwd = ', pqcwd(mgs)
23650
23651
23652 write(iunit,*)
23653 write(iunit,*) 'Concentration:'
23654 write(iunit,*) -cautn(mgs)
23655 write(iunit,*) -cracw(mgs)
23656 write(iunit,*) -csacw(mgs)
23657 write(iunit,*) -chacw(mgs)
23658 write(iunit,*) -ciacw(mgs)
23659 write(iunit,*) -cwfrzp(mgs)
23660 write(iunit,*) -cwctfzp(mgs)
23661 write(iunit,*) -cwfrzc(mgs)
23662 write(iunit,*) -cwctfzc(mgs)
23663 write(iunit,*) pccwd(mgs)
23664!
23665 write(iunit,*)
23666 write(iunit,*) 'Rain '
23667!
23668 write(iunit,*) qracw(mgs)
23669 write(iunit,*) qrcnw(mgs)
23670 write(iunit,*) max(0.0, qrcev(mgs))
23671 write(iunit,*) -(1-il5(mgs))*qhmlr(mgs)
23672 write(iunit,*) -(1-il5(mgs))*qhlmlr(mgs)
23673 write(iunit,*) -(1-il5(mgs))*qsmlr(mgs)
23674 write(iunit,*) -(1-il5(mgs))*qimlr(mgs)
23675 write(iunit,*) -qrshr(mgs)
23676 write(iunit,*) 'pqrwi = ', pqrwi(mgs)
23677 write(iunit,*) -qsshr(mgs)
23678 write(iunit,*) -qhshr(mgs)
23679 write(iunit,*) -qhlshr(mgs)
23680 write(iunit,*) -il5(mgs)*qiacr(mgs),qiacr(mgs), qiacrf(mgs)
23681 write(iunit,*) -il5(mgs)*qrfrz(mgs)
23682 write(iunit,*) -qsacr(mgs)
23683 write(iunit,*) -qhacr(mgs)
23684 write(iunit,*) -qhlacr(mgs)
23685 write(iunit,*) qrcev(mgs)
23686 write(iunit,*) 'pqrwd = ', pqrwd(mgs)
23687 write(iunit,*) 'qrzfac = ', qrzfac(mgs)
23688!
23689
23690 write(iunit,*)
23691 write(iunit,*) 'Rain concentration'
23692 write(iunit,*) pcrwi(mgs)
23693 write(iunit,*) crcnw(mgs)
23694 write(iunit,*) 1-il5(mgs)
23695 write(iunit,*) -chmlr(mgs),-csmlr(mgs)
23696 write(iunit,*) -crshr(mgs)
23697 write(iunit,*) pcrwd(mgs)
23698 write(iunit,*) il5(mgs)
23699 write(iunit,*) -ciacr(mgs),-crfrz(mgs)
23700 write(iunit,*) -csacr(mgs),-chacr(mgs)
23701 write(iunit,*) +crcev(mgs)
23702 write(iunit,*) cracr(mgs)
23703! write(iunit,*) -il5(mgs)*ciracr(mgs)
23704
23705
23706 write(iunit,*)
23707 write(iunit,*) 'Snow'
23708!
23709 write(iunit,*) il5(mgs)*qscni(mgs), qscnvi(mgs)
23710 write(iunit,*) il5(mgs)*qsaci(mgs)
23711 write(iunit,*) il5(mgs)*qrfrzs(mgs), qiacrs(mgs)
23712 write(iunit,*) il5(mgs)*qiacrs(mgs),il3(mgs)*(qiacrf(mgs)+qracif(mgs)),il3(mgs),qiacrf(mgs),qracif(mgs)
23713 write(iunit,*) il5(mgs)*qsdpv(mgs), qscev(mgs)
23714 write(iunit,*) qsacw(mgs),qwfrzc(mgs), qwctfzc(mgs), qicichr(mgs)
23715 write(iunit,*) qsacr(mgs), qscnh(mgs)
23716 write(iunit,*) il2(mgs)*qsacr(mgs)
23717 write(iunit,*) il5(mgs)*qicicnt(mgs)*ffrzs
23718 write(iunit,*) il3(mgs)*(qiacrf(mgs)+qracif(mgs)) ! only applies for ipconc <= 3
23719 write(iunit,*) max(0.0, qscev(mgs))
23720 write(iunit,*) qsacw(mgs) + qscnh(mgs)
23721 write(iunit,*) 'pqswi = ',pqswi(mgs)
23722 write(iunit,*) -qhcns(mgs)
23723 write(iunit,*) -qracs(mgs)
23724 write(iunit,*) -qhacs(mgs)
23725 write(iunit,*) -qhlacs(mgs)
23726 write(iunit,*) (1-il5(mgs))*qsmlr(mgs)
23727 write(iunit,*) qsshr(mgs)
23728! write(iunit,*) qsshrp(mgs)
23729 write(iunit,*) il5(mgs)*(qssbv(mgs))
23730 write(iunit,*) 'pqswd = ', pqswd(mgs)
23731 write(iunit,*) -qracs(mgs)*(1-il2(mgs)) , qhacs(mgs) , qhlacs(mgs)
23732 write(iunit,*) -qhcns(mgs)
23733 write(iunit,*) +(1-il5(mgs))*qsmlr(mgs) , qsshr(mgs)
23734 write(iunit,*) qssbv(mgs)
23735 write(iunit,*) min(0.0, qscev(mgs))
23736 write(iunit,*) -qsmul(mgs)
23737!
23738!
23739 write(iunit,*)
23740 write(iunit,*) 'Graupel'
23741!
23742 write(iunit,*) il5(mgs)*qrfrzf(mgs), qrfrzf(mgs) - qrfrz(mgs)
23743 write(iunit,*) il5(mgs)*qiacrf(mgs)
23744 write(iunit,*) il5(mgs)*qracif(mgs)
23745 write(iunit,*) qhcns(mgs)
23746 write(iunit,*) qhcni(mgs)
23747 write(iunit,*) il5(mgs)*(qhdpv(mgs))
23748 write(iunit,*) qhacr(mgs)
23749 write(iunit,*) qhacw(mgs)
23750 write(iunit,*) qhacs(mgs)
23751 write(iunit,*) qhaci(mgs)
23752 write(iunit,*) 'pqhwi = ',pqhwi(mgs)
23753 write(iunit,*)
23754 write(iunit,*) qhshr(mgs)
23755 write(iunit,*) (1-il5(mgs))*qhmlr(mgs)
23756 write(iunit,*) il5(mgs),qhsbv(mgs)
23757 write(iunit,*) -qhlcnh(mgs)
23758 write(iunit,*) -qhmul1(mgs)
23759 write(iunit,*) 'pqhwd = ', pqhwd(mgs)
23760 write(iunit,*) 'Concentration'
23761 write(iunit,*) pchwi(mgs),pchwd(mgs)
23762 write(iunit,*) crfrzf(mgs)
23763 write(iunit,*) chcns(mgs)
23764 write(iunit,*) ciacrf(mgs)
23765
23766!
23767 write(iunit,*)
23768 write(iunit,*) 'Hail'
23769!
23770 write(iunit,*) qhlcnh(mgs)
23771 write(iunit,*) il5(mgs)*(qhldpv(mgs))
23772 write(iunit,*) qhlacr(mgs)
23773 write(iunit,*) qhlacw(mgs)
23774 write(iunit,*) qhlacs(mgs)
23775 write(iunit,*) qhlaci(mgs)
23776 write(iunit,*) pqhli(mgs)
23777 write(iunit,*)
23778 write(iunit,*) qhlshr(mgs)
23779 write(iunit,*) (1-il5(mgs))*qhlmlr(mgs)
23780 write(iunit,*) il5(mgs)*qhlsbv(mgs)
23781 write(iunit,*) pqhld(mgs)
23782 write(iunit,*) 'Concentration'
23783 write(iunit,*) pchli(mgs),pchld(mgs)
23784 write(iunit,*) chlcnh(mgs)
23785!
23786! Balance and checks for continuity.....within machine precision...
23787!
23788!
23789 write(iunit,*) 'END OF OUTPUT OF SOURCE AND SINK'
23790 write(iunit,*) 'PTOTAL',ptotal(mgs)
23791!
23792 end if ! ptotal out of bounds or NaN
23793!
23794 end do
23795!
23796
23797 end if ! ( nstep/12*12 .eq. nstep )
23798
23799!
23800! latent heating from phase changes (except qcw, qci cond, and evap)
23801!
23802 do mgs = 1,ngscnt
23803 IF ( warmonly < 0.5 ) THEN
23804 pfrz(mgs) = &
23805 & (1-il5(mgs))* &
23806 & (qhmlr(mgs)+ &
23807 & qsmlr(mgs)+qhlmlr(mgs)) & !+qhmlh(mgs)) &
23808 & +il5(mgs)*(1-imixedphase)*( &
23809 & qsacw(mgs)+qhacw(mgs) + qhlacw(mgs) &
23810 & +qsacr(mgs)+qhacr(mgs) + qhlacr(mgs) &
23811 & +qsshr(mgs) &
23812 & +qhshr(mgs) &
23813 & +qhlshr(mgs) &
23814 & +qrfrz(mgs)+qiacr(mgs) &
23815 & ) &
23816 & +il5(mgs)*(qwfrz(mgs) &
23817 & +qwctfz(mgs)+qiihr(mgs) &
23818 & +qiacw(mgs))
23819 pmlt(mgs) = &
23820 & (1-il5(mgs))* &
23821 & (qhmlr(mgs)+qsmlr(mgs)+ &
23822 & qhlmlr(mgs)) !+qhmlh(mgs))
23823 ! NOTE: psub is sum of sublimation and deposition
23824 psub(mgs) = &
23825 & il5(mgs)*( &
23826 & + qsdpv(mgs) + qhdpv(mgs) &
23827 & + qhldpv(mgs) &
23828 & + qidpv(mgs) + qisbv(mgs) ) &
23829 & + qssbv(mgs) + qhsbv(mgs) &
23830 & + qhlsbv(mgs) &
23831 & +il5(mgs)*(qiint(mgs))
23832 pvap(mgs) = &
23833 & qrcev(mgs) + qhcev(mgs) + qscev(mgs) + qhlcev(mgs) + qfcev(mgs)
23834 pevap(mgs) = &
23835 & min(0.0,qrcev(mgs)) + min(0.0,qhcev(mgs)) + min(0.0,qscev(mgs)) + min(0.0,qhlcev(mgs)) &
23836 + min(0.0,qfcev(mgs))
23837 ! NOTE: pdep is the deposition part only
23838 pdep(mgs) = &
23839 & il5(mgs)*( &
23840 & + qsdpv(mgs) + qhdpv(mgs) &
23841 & + qhldpv(mgs) &
23842 & + qidpv(mgs) ) &
23843 & +il5(mgs)*(qiint(mgs))
23844 ELSEIF ( warmonly < 0.8 ) THEN
23845 pfrz(mgs) = &
23846 & (1-il5(mgs))* &
23847 & (qhmlr(mgs)+qhlmlr(mgs)) & !+qhmlh(mgs)) &
23848 & +il5(mgs)*(qhfzh(mgs)+qhlfzhl(mgs)) &
23849 & +il5(mgs)*( &
23850 & +qhshr(mgs) &
23851 & +qhlshr(mgs) &
23852 & +qrfrz(mgs)+qwfrz(mgs) &
23853 & +qwctfz(mgs)+qiihr(mgs) &
23854 & +qiacw(mgs) &
23855 & +qhacw(mgs) + qhlacw(mgs) &
23856 & +qhacr(mgs) + qhlacr(mgs) )
23857 psub(mgs) = 0.0 + &
23858 & il5(mgs)*( &
23859 & + qhdpv(mgs) &
23860 & + qhldpv(mgs) &
23861 & + qidpv(mgs) + qisbv(mgs) ) &
23862 & +il5(mgs)*(qiint(mgs))
23863 pvap(mgs) = &
23864 & qrcev(mgs) + qhcev(mgs) + qhlcev(mgs) + qfcev(mgs)
23865 ELSE
23866 pfrz(mgs) = 0.0
23867 psub(mgs) = 0.0
23868 pvap(mgs) = qrcev(mgs)
23869 ENDIF ! warmonly
23870 ptem(mgs) = &
23871 & (1./pi0(mgs))* &
23872 & (felfcp(mgs)*pfrz(mgs) &
23873 & +felscp(mgs)*psub(mgs) &
23874 & +felvcp(mgs)*pvap(mgs))
23875 thetap(mgs) = thetap(mgs) + dtp*ptem(mgs)
23876 ptem2(mgs) = ptem(mgs)
23877 IF ( eqtset > 2 ) THEN
23878 pipert(mgs) = pipert(mgs) + (felfpi(mgs)*pfrz(mgs) &
23879 & +felspi(mgs)*psub(mgs) &
23880 & +felvpi(mgs)*pvap(mgs))*dtp
23881 ENDIF
23882 end do
23883
23884
23885
23886
23887!
23888! sum the sources and sinks for qwvp, qcw, qci, qrw, qsw
23889!
23890!
23891 do mgs = 1,ngscnt
23892
23893
23894 qwvp(mgs) = qwvp(mgs) + &
23895 & dtp*(pqwvi(mgs)+pqwvd(mgs))
23896 ! qcwresv(mgs) = qx(mgs,lc) ! temporary save of old qc value
23897 qx(mgs,lc) = qx(mgs,lc) + &
23898 & dtp*(pqcwi(mgs)+pqcwd(mgs))
23899 qx(mgs,lr) = qx(mgs,lr) + &
23900 & dtp*(pqrwi(mgs)+pqrwd(mgs))
23901 qx(mgs,li) = qx(mgs,li) + &
23902 & dtp*(pqcii(mgs)+pqcid(mgs))
23903 qx(mgs,ls) = qx(mgs,ls) + &
23904 & dtp*(pqswi(mgs)+pqswd(mgs))
23905 qx(mgs,lh) = qx(mgs,lh) + &
23906 & dtp*(pqhwi(mgs)+pqhwd(mgs))
23907
23908 IF ( lhl .gt. 1 ) THEN
23909 qx(mgs,lhl) = qx(mgs,lhl) + &
23910 & dtp*(pqhli(mgs)+pqhld(mgs))
23911 ENDIF
23912
23913
23914 end do
23915
23916! sum sources for particle volume
23917
23918 IF ( ldovol ) THEN
23919
23920 do mgs = 1,ngscnt
23921
23922 IF ( lvol(ls) .gt. 1 ) THEN
23923 vx(mgs,ls) = vx(mgs,ls) + &
23924 & dtp*(pvswi(mgs)+pvswd(mgs))
23925 ENDIF
23926
23927 IF ( lvol(lh) .gt. 1 ) THEN
23928 vx(mgs,lh) = vx(mgs,lh) + &
23929 & dtp*(pvhwi(mgs)+pvhwd(mgs))
23930! > rho0(mgs)*dtp*(pqhwi(mgs)+pqhwd(mgs))/xdn0(lh)
23931 ENDIF
23932
23933 IF ( lhl .gt. 1 ) THEN
23934 IF ( lvol(lhl) .gt. 1 ) THEN
23935 vx(mgs,lhl) = vx(mgs,lhl) + &
23936 & dtp*(pvhli(mgs)+pvhld(mgs))
23937! > rho0(mgs)*dtp*(pqhwi(mgs)+pqhwd(mgs))/xdn0(lh)
23938 ENDIF
23939 ENDIF
23940
23941 ENDDO
23942
23943 ENDIF ! ldovol
23944
23945!
23946!
23947!
23948! concentrations
23949!
23950 if ( ipconc .ge. 1 ) then
23951 do mgs = 1,ngscnt
23952 cx(mgs,li) = cx(mgs,li) + &
23953 & dtp*(pccii(mgs)+pccid(mgs))
23954 cina(mgs) = cina(mgs) + pccin(mgs)*dtp
23955 IF ( ipconc .ge. 2 ) THEN
23956 cx(mgs,lc) = cx(mgs,lc) + &
23957 & dtp*(pccwi(mgs)+pccwd(mgs))
23958 ENDIF
23959 IF ( ipconc .ge. 3 ) THEN
23960 cx(mgs,lr) = cx(mgs,lr) + &
23961 & dtp*(pcrwi(mgs)+pcrwd(mgs))
23962 ENDIF
23963 IF ( ipconc .ge. 4 ) THEN
23964 cx(mgs,ls) = cx(mgs,ls) + &
23965 & dtp*(pcswi(mgs)+pcswd(mgs))
23966 ENDIF
23967 IF ( ipconc .ge. 5 ) THEN
23968 cx(mgs,lh) = cx(mgs,lh) + &
23969 & dtp*(pchwi(mgs)+pchwd(mgs))
23970 IF ( lhl .gt. 1 ) THEN
23971 cx(mgs,lhl) = cx(mgs,lhl) + &
23972 & dtp*(pchli(mgs)+pchld(mgs))
23973
23974
23975
23976
23977 ENDIF
23978 ENDIF
23979 IF ( ipconc .ge. 6 ) THEN
23980 IF ( lzr .gt. 1 ) THEN
23981 zx(mgs,lr) = zx(mgs,lr) + &
23982 & dtp*(pzrwi(mgs)+pzrwd(mgs))
23983 ENDIF
23984 IF ( lzs .gt. 1 ) THEN
23985 zx(mgs,ls) = zx(mgs,ls) + &
23986 & dtp*(pzswi(mgs)+pzswd(mgs))
23987 ENDIF
23988 IF ( lzh .gt. 1 ) THEN
23989 zx(mgs,lh) = zx(mgs,lh) + &
23990 & dtp*(pzhwi(mgs)+pzhwd(mgs))
23991 ENDIF
23992 IF ( lzhl .gt. 1 ) THEN
23993 zx(mgs,lhl) = zx(mgs,lhl) + &
23994 & dtp*(pzhli(mgs)+pzhld(mgs))
23995! IF ( pchli(mgs) .ne. 0. .or. pchld(mgs) .ne. 0 ) THEN
23996! write(0,*) 'dr: cx,pchli,pchld = ', cx(mgs,lhl),pchli(mgs),pchld(mgs), igs(mgs),kgs(mgs)
23997! ENDIF
23998 ENDIF
23999 ENDIF
24000 end do
24001 end if
24002
24003 IF ( has_wetscav ) THEN
24004 DO mgs = 1,ngscnt
24005 evapprod2d(igs(mgs),kgs(mgs)) = -(qrcev(mgs) + qssbv(mgs) + qhsbv(mgs) + qhlsbv(mgs))
24006 rainprod2d(igs(mgs),kgs(mgs)) = qrcnw(mgs) + qracw(mgs) + qsacw(mgs) + qhacw(mgs) + qhlacw(mgs) + &
24007 qraci(mgs) + qsaci(mgs) + qhaci(mgs) + qhlaci(mgs) + qscni(mgs)
24008 ENDDO
24009 ENDIF
24010!
24011!
24012!
24013! start saturation adjustment
24014!
24015 if (ndebug .gt. 0 ) write(0,*) 'conc 30a'
24016! include 'sam.jms.satadj.sgi'
24017!
24018!
24019!
24020! Modified Straka adjustment (nearly identical to Tao et al. 1989 MWR)
24021!
24022!
24023!
24024! set up temperature and vapor arrays
24025!
24026 do mgs = 1,ngscnt
24027 pqs(mgs) = (380.0)/(pres(mgs))
24028 theta(mgs) = thetap(mgs) + theta0(mgs)
24029 qvap(mgs) = max( (qwvp(mgs) + qv0(mgs)), 0.0 )
24030 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
24031 end do
24032!
24033! melting of cloud ice
24034!
24035 do mgs = 1,ngscnt
24036 qcwtmp(mgs) = qx(mgs,lc)
24037 ptimlw(mgs) = 0.0
24038 end do
24039!
24040 do mgs = 1,ngscnt
24041 qitmp(mgs) = qx(mgs,li)
24042 if( temg(mgs) .gt. tfr .and. &
24043 & qitmp(mgs) .gt. 0.0 ) then
24044 qx(mgs,lc) = qx(mgs,lc) + qitmp(mgs)
24045! pfrz(mgs) = pfrz(mgs) - qitmp(mgs)*dtpinv
24046 ptem(mgs) = ptem(mgs) + &
24047 & (1./pi0(mgs))* &
24048 & felfcp(mgs)*(- qitmp(mgs)*dtpinv)
24049 IF ( eqtset > 2 ) THEN
24050 pipert(mgs) = pipert(mgs) - (felfpi(mgs)*qitmp(mgs))
24051 ENDIF
24052 pmlt(mgs) = pmlt(mgs) - qitmp(mgs)*dtpinv
24053 scx(mgs,lc) = scx(mgs,lc) + scx(mgs,li)
24054 thetap(mgs) = thetap(mgs) - &
24055 & fcc3(mgs)*qitmp(mgs)
24056 ptimlw(mgs) = -fcc3(mgs)*qitmp(mgs)*dtpinv
24057 cx(mgs,lc) = cx(mgs,lc) + cx(mgs,li)
24058 qx(mgs,li) = 0.0
24059 cx(mgs,li) = 0.0
24060 scx(mgs,li) = 0.0
24061 vx(mgs,li) = 0.0
24062 qitmp(mgs) = 0.0
24063 end if
24064 end do
24065
24066!
24067!
24068
24069
24070! do mgs = 1,ngscnt
24071! qimlw(mgs) = (qcwtmp(mgs)-qx(mgs,lc))*dtpinv
24072! end do
24073!
24074! homogeneous freezing of cloud water
24075!
24076 IF ( warmonly < 0.8 ) THEN
24077
24078 do mgs = 1,ngscnt
24079 qcwtmp(mgs) = qx(mgs,lc)
24080 ptwfzi(mgs) = 0.0
24081 end do
24082!
24083 do mgs = 1,ngscnt
24084
24085! if( temg(mgs) .lt. tfrh ) THEN
24086! write(0,*) 'GS: mgs,temp,qc,qi = ',mgs,temg(mgs),temcg(mgs),qx(mgs,lc),qx(mgs,li)
24087! ENDIF
24088
24089 ctmp = 0.0
24090 frac = 0.0
24091 qtmp = 0.0
24092
24093! if( ( temg(mgs) .lt. thnuc + 2. .or. (ibfc == 2 .and. temg(mgs) < thnuc + 10. ) ) .and. &
24094! & qx(mgs,lc) .gt. qxmin(lc) .and. (ipconc < 2 .or. ibfc == 0 .or. ibfc == 2 )) then
24095! commented for test (12/01/2015):
24096! if( temg(mgs) .lt. thnuc + 0. .and. &
24097! & qx(mgs,lc) .gt. 0.0 .and. (ipconc < 2 .or. ibfc == 0 )) then
24098 if( ( ( temg(mgs) .lt. thnuc + 0.) .or. (temg(mgs) .lt. thnuc + 2. .and. ibfc >= 3) ) .and. &
24099 & qx(mgs,lc) .gt. 0.0 .and. (ipconc < 2 .or. ibfc == 0 .or. ibfc == 2)) then
24100
24101 IF ( ibfc >= 3 ) THEN
24102 frac = max( 0.25, min( 1., ((thnuc + 2.) - temg(mgs) )/4.0 ) )
24103 ELSEIF ( ibfc /= 2 .or. ipconc < 2 ) THEN
24104 frac = max( 0.25, min( 1., ((thnuc + 1.) - temg(mgs) )/4.0 ) )
24105 ELSE
24106 volt = exp( 16.2 + 1.0*temcg(mgs) )* 1.0e-6 ! Ts == -temcg ; volt comes from the fit in Fig. 1 in Bigg 1953
24107 ! for mean temperature for freezing: -ln (V) = a*Ts - b
24108 ! volt is given in cm**3, so factor of 1.e-6 to convert to m**3
24109
24110 cwfrz(mgs) = cx(mgs,lc)*exp(-volt/xv(mgs,lc)) ! number of droplets with volume greater than volt
24111
24112 qtmp = cwfrz(mgs)*xdn0(lc)*rhoinv(mgs)*(volt + xv(mgs,lc))
24113 frac = qtmp/qx(mgs,lc) ! reset number frozen to same fraction as mass. This makes
24114 ! sure that cwfrz and qwfrz are consistent and prevents
24115 ! spurious creation of ice crystals.
24116
24117 ENDIF
24118 qtmp = frac*qx(mgs,lc)
24119
24120 IF ( ibfc == 4 .and. lis >= 1 ) THEN
24121 qx(mgs,lis) = qx(mgs,lis) + qtmp
24122 ELSE
24123 qx(mgs,li) = qx(mgs,li) + qtmp ! qx(mgs,lc)
24124 ENDIF
24125 pfrz(mgs) = pfrz(mgs) + qtmp*dtpinv
24126 ptem(mgs) = ptem(mgs) + &
24127 & (1./pi0(mgs))* &
24128 & felfcp(mgs)*(qtmp*dtpinv)
24129
24130 IF ( eqtset > 2 ) THEN
24131 pipert(mgs) = pipert(mgs) + felfpi(mgs)*qtmp
24132 ENDIF
24133
24134! IF ( lvol(li) .gt. 1 ) vx(mgs,li) = vx(mgs,li) + rho0(mgs)*qx(mgs,lc)/xdn0(li)
24135 IF ( lvol(li) .gt. 1 ) vx(mgs,li) = vx(mgs,li) + rho0(mgs)*qtmp/xdn0(li)
24136
24137 IF ( ipconc .ge. 2 ) THEN
24138 ctmp = frac*cx(mgs,lc)
24139! cx(mgs,li) = cx(mgs,li) + cx(mgs,lc)
24140 IF ( ibfc == 4 .and. lis >= 1 ) THEN
24141 cx(mgs,lis) = cx(mgs,lis) + ctmp
24142 ELSE
24143 cx(mgs,li) = cx(mgs,li) + ctmp
24144 ENDIF
24145 ELSE ! (ipconc .lt. 2 )
24146 ctmp = 0.0
24147 IF ( t9(igs(mgs),jgs,kgs(mgs)-1) .gt. qx(mgs,lc) ) THEN
24148 qtmp = frac*t9(igs(mgs),jgs,kgs(mgs)-1)
24149
24150! cx(mgs,lc) = cx(mgs,lc)*qx(mgs,lc)*rho0(mgs)/qtmp
24151 ctmp = cx(mgs,lc)*qx(mgs,lc)*rho0(mgs)/qtmp
24152 ELSE
24153 cx(mgs,lc) = max(0.0,wvel(mgs))*dtp*cwccn &
24154 & /gz(igs(mgs),jgs,kgs(mgs))
24155 cx(mgs,lc) = cwccn
24156 ENDIF
24157
24158 IF ( ipconc .ge. 1 ) cx(mgs,li) = min(ccimx, cx(mgs,li) + cx(mgs,lc))
24159 ENDIF
24160
24161 sctmp = frac*scx(mgs,lc)
24162! scx(mgs,li) = scx(mgs,li) + scx(mgs,lc)
24163 scx(mgs,li) = scx(mgs,li) + sctmp
24164! thetap(mgs) = thetap(mgs) + fcc3(mgs)*qx(mgs,lc)
24165! ptwfzi(mgs) = fcc3(mgs)*qx(mgs,lc)*dtpinv
24166! qx(mgs,lc) = 0.0
24167! cx(mgs,lc) = 0.0
24168! scx(mgs,lc) = 0.0
24169 thetap(mgs) = thetap(mgs) + fcc3(mgs)*qtmp
24170 ptwfzi(mgs) = fcc3(mgs)*qtmp*dtpinv
24171 qx(mgs,lc) = qx(mgs,lc) - qtmp
24172 cx(mgs,lc) = cx(mgs,lc) - ctmp
24173 scx(mgs,lc) = scx(mgs,lc) - sctmp
24174 end if
24175 end do
24176
24177 ENDIF ! warmonly
24178!
24179! do mgs = 1,ngscnt
24180! qwfzi(mgs) = (qcwtmp(mgs)-qx(mgs,lc))*dtpinv ! Not used?? (ERM)
24181! end do
24182!
24183! reset temporaries for cloud particles and vapor
24184!
24185 qcond(:) = 0.0
24186
24187 IF ( ipconc .le. 1 .and. lwsm6 ) THEN ! Explicit cloud condensation/evaporation (Rutledge and Hobbs 1983)
24188 DO mgs = 1,ngscnt
24189
24190 qcwtmp(mgs) = qx(mgs,lc)
24191 theta(mgs) = thetap(mgs) + theta0(mgs)
24192 temgtmp = temg(mgs)
24193! temg(mgs) = theta(mgs)*(p2(igs(mgs),jgs,kgs(mgs)) ) ! *pk(mgs) ! ( pres(mgs) / poo ) ** cap
24194! temsav = temg(mgs)
24195! thsave(mgs) = thetap(mgs)
24196 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
24197 temcg(mgs) = temg(mgs) - tfr
24198 ltemq = (temg(mgs)-163.15)/fqsat+1.5
24199 ltemq = min( nqsat, max(1,ltemq) )
24200
24201 IF ( iqvsopt == 0 ) THEN
24202 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
24203 ELSEIF ( iqvsopt == 1 ) THEN
24204 qvs(mgs) = rdorv*esbolton*tabqvs(ltemq)/(pres(mgs) - esbolton*tabqvs(ltemq))
24205 ENDIF
24206
24207 IF ( ( qvap(mgs) > qvs(mgs) .or. qx(mgs,lc) > qxmin(lc) ) .and. temg(mgs) > tfrh ) THEN
24208 tmp = (qvap(mgs) - qvs(mgs))/(1. + qvs(mgs)*felv(mgs)**2/(cp*rw*temg(mgs)**2) )
24209 qcond(mgs) = min( max( 0.0, tmp ), (qvap(mgs)-qvs(mgs)) )
24210 IF ( qx(mgs,lc) > qxmin(lc) .and. tmp < 0.0 ) THEN ! evaporation
24211 qcond(mgs) = max( tmp, -qx(mgs,lc) )
24212 ENDIF
24213 qwvp(mgs) = qwvp(mgs) - qcond(mgs)
24214 qvap(mgs) = qvap(mgs) - qcond(mgs)
24215 qx(mgs,lc) = max( 0.0, qx(mgs,lc) + qcond(mgs) )
24216 thetap(mgs) = thetap(mgs) + felvcp(mgs)*qcond(mgs)/(pi0(mgs))
24217
24218 ENDIF
24219
24220 ENDDO
24221
24222 ENDIF
24223
24224
24225 IF ( ipconc .le. 1 .and. .not. lwsm6 ) THEN
24226! IF ( ipconc .le. 1 ) THEN
24227
24228 do mgs = 1,ngscnt
24229 qx(mgs,lv) = max( 0.0, qvap(mgs) )
24230 qx(mgs,lc) = max( 0.0, qx(mgs,lc) )
24231 qx(mgs,li) = max( 0.0, qx(mgs,li) )
24232 qitmp(mgs) = qx(mgs,li)
24233 end do
24234!
24235!
24236 do mgs = 1,ngscnt
24237 qcwtmp(mgs) = qx(mgs,lc)
24238 qitmp(mgs) = qx(mgs,li)
24239 theta(mgs) = thetap(mgs) + theta0(mgs)
24240 temgtmp = temg(mgs)
24241 temg(mgs) = theta(mgs)*(pinit(kgs(mgs)) + p2(igs(mgs),jgs,kgs(mgs)) ) ! *pk(mgs) ! ( pres(mgs) / poo ) ** cap
24242 temsav = temg(mgs)
24243 thsave(mgs) = thetap(mgs)
24244 temcg(mgs) = temg(mgs) - tfr
24245 tqvcon = temg(mgs)-cbw
24246 ltemq = (temg(mgs)-163.15)/fqsat+1.5
24247 ltemq = min( nqsat, max(1,ltemq) )
24248
24249 IF ( iqvsopt == 0 ) THEN
24250 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
24251 ELSEIF ( iqvsopt == 1 ) THEN
24252 qvs(mgs) = rdorv*esbolton*tabqvs(ltemq)/(pres(mgs) - esbolton*tabqvs(ltemq))
24253 ENDIF
24254 qis(mgs) = pqs(mgs)*tabqis(ltemq)
24255 qss(mgs) = qvs(mgs)
24256 if ( temg(mgs) .lt. tfr ) then
24257 if( qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) ) &
24258 & qss(mgs) = qvs(mgs)
24259 if( qx(mgs,lc) .le. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
24260 & qss(mgs) = qis(mgs)
24261 if( qx(mgs,lc) .gt. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
24262 & qss(mgs) = (qx(mgs,lc)*qvs(mgs) + qitmp(mgs)*qis(mgs)) / &
24263 & (qx(mgs,lc) + qitmp(mgs))
24264 end if
24265 end do
24266!
24267! iterate adjustment
24268!
24269 do itertd = 1,2
24270!
24271 do mgs = 1,ngscnt
24272!
24273! calculate super-saturation
24274!
24275 qitmp(mgs) = qx(mgs,li)
24276 fcci(mgs) = 0.0
24277 fcip(mgs) = 0.0
24278 dqcw(mgs) = 0.0
24279 dqci(mgs) = 0.0
24280 dqwv(mgs) = ( qx(mgs,lv) - qss(mgs) )
24281!
24282! evaporation and sublimation adjustment
24283!
24284 if( dqwv(mgs) .lt. 0. ) then ! subsaturated
24285 if( qx(mgs,lc) .gt. -dqwv(mgs) ) then ! check if qc can make up all of the deficit
24286 dqcw(mgs) = dqwv(mgs)
24287 dqwv(mgs) = 0.
24288 else ! otherwise make all qc available for evap
24289 dqcw(mgs) = -qx(mgs,lc)
24290 dqwv(mgs) = dqwv(mgs) + qx(mgs,lc)
24291 end if
24292!
24293 if( qitmp(mgs) .gt. -dqwv(mgs) ) then ! check if qi can make up all the deficit
24294 dqci(mgs) = dqwv(mgs)
24295 dqwv(mgs) = 0.
24296 else ! otherwise make all ice available for sublimation
24297 dqci(mgs) = -qitmp(mgs)
24298 dqwv(mgs) = dqwv(mgs) + qitmp(mgs)
24299 end if
24300!
24301 qwvp(mgs) = qwvp(mgs) - ( dqcw(mgs) + dqci(mgs) ) ! add to perturbation vapor
24302!
24303! This next line removed 3/19/2003 thanks to Adam Houston,
24304! who found the bug in the 3-ICE code
24305! qwvp(mgs) = max(qwvp(mgs), 0.0)
24306 qitmp(mgs) = qx(mgs,li)
24307 IF ( qitmp(mgs) .ge. qxmin(li) ) THEN
24308 fcci(mgs) = qx(mgs,li)/(qitmp(mgs))
24309 ELSE
24310 fcci(mgs) = 1.0
24311 ENDIF
24312 qx(mgs,lc) = qx(mgs,lc) + dqcw(mgs)
24313 qx(mgs,li) = qx(mgs,li) + dqci(mgs) * fcci(mgs)
24314 thetap(mgs) = thetap(mgs) + &
24315 & 1./pi0(mgs)* &
24316 & (felvcp(mgs)*dqcw(mgs) +felscp(mgs)*dqci(mgs))
24317
24318 IF ( eqtset > 2 ) THEN
24319 pipert(mgs) = pipert(mgs) &
24320 & +(felspi(mgs)*dqci(mgs) &
24321 & +felvpi(mgs)*dqcw(mgs)) ! *dtp (remove dtp since dqxx are not rates)
24322 ENDIF
24323
24324 end if ! dqwv(mgs) .lt. 0. (end of evap/sublim)
24325!
24326! condensation/deposition
24327!
24328 IF ( dqwv(mgs) .ge. 0. ) THEN
24329
24330! write(iunit,*) 'satadj: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qx(mgs,lv),qx(mgs,lc)
24331!
24332 qitmp(mgs) = qx(mgs,li)
24333 fracl(mgs) = 1.0
24334 fraci(mgs) = 0.0
24335 if ( temg(mgs) .lt. tfr .and. temg(mgs) .gt. thnuc ) then
24336 fracl(mgs) = max(min(1.,(temg(mgs)-233.15)/(20.)),0.0)
24337 fraci(mgs) = 1.0-fracl(mgs)
24338 end if
24339 if ( temg(mgs) .le. thnuc ) then
24340 fraci(mgs) = 1.0
24341 fracl(mgs) = 0.0
24342 end if
24343 fraci(mgs) = 1.0-fracl(mgs)
24344!
24345 gamss = (felvcp(mgs)*fracl(mgs) + felscp(mgs)*fraci(mgs)) &
24346 & / (pi0(mgs))
24347!
24348 IF ( temg(mgs) .lt. tfr ) then
24349 IF (qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) ) then
24350 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qss(mgs)/ &
24351 & ((temg(mgs)-cbw)**2))
24352 END IF
24353 IF ( qx(mgs,lc) .eq. 0.0 .and. qitmp(mgs) .gt. qxmin(li) ) then
24354 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv2(mgs)*qss(mgs)/ &
24355 & ((temg(mgs)-cbi)**2))
24356 END IF
24357 IF ( qx(mgs,lc) .gt. 0.0 .and. qitmp(mgs) .gt. qxmin(li) ) then
24358 cdw = caw*pi0(mgs)*tfrcbw/((temg(mgs)-cbw)**2)
24359 cdi = cai*pi0(mgs)*tfrcbi/((temg(mgs)-cbi)**2)
24360 denom1 = qx(mgs,lc) + qitmp(mgs)
24361 denom2 = 1.0 + gamss* &
24362 & (qx(mgs,lc)*qvs(mgs)*cdw + qitmp(mgs)*qis(mgs)*cdi) / denom1
24363 dqvcnd(mgs) = dqwv(mgs) / denom2
24364 END IF
24365
24366 ENDIF ! temg(mgs) .lt. tfr
24367!
24368 if ( temg(mgs) .ge. tfr ) then
24369 dqvcnd(mgs) = dqwv(mgs)/(1. + fcqv1(mgs)*qss(mgs)/ &
24370 & ((temg(mgs)-cbw)**2))
24371 end if
24372!
24373 delqci1=qx(mgs,li)
24374!
24375 IF ( qitmp(mgs) .gt. qxmin(li) ) THEN
24376 fcci(mgs) = qx(mgs,li)/(qitmp(mgs))
24377 ELSE
24378 fcci(mgs) = 1.0
24379 ENDIF
24380!
24381 dqcw(mgs) = dqvcnd(mgs)*fracl(mgs)
24382 dqci(mgs) = dqvcnd(mgs)*fraci(mgs)
24383!
24384 thetap(mgs) = thetap(mgs) + &
24385 & (felvcp(mgs)*dqcw(mgs) + felscp(mgs)*dqci(mgs)) &
24386 & / (pi0(mgs))
24387
24388 IF ( eqtset > 2 ) THEN
24389 pipert(mgs) = pipert(mgs) + (0 &
24390 & +felspi(mgs)*dqci(mgs) &
24391 & +felvpi(mgs)*dqcw(mgs)) ! *dtp (remove dtp since dqxx are not rates)
24392 ENDIF
24393
24394 qwvp(mgs) = qwvp(mgs) - ( dqvcnd(mgs) )
24395 qx(mgs,lc) = qx(mgs,lc) + dqcw(mgs)
24396! IF ( qitmp(mgs) .gt. qxmin(li) ) THEN
24397 qx(mgs,li) = qx(mgs,li) + dqci(mgs)*fcci(mgs)
24398 qitmp(mgs) = qx(mgs,li)
24399! ENDIF
24400!
24401! delqci(mgs) = dqci(mgs)*fcci(mgs)
24402!
24403 END IF ! dqwv(mgs) .ge. 0.
24404 end do
24405!
24406 do mgs = 1,ngscnt
24407 qitmp(mgs) = qx(mgs,li)
24408 theta(mgs) = thetap(mgs) + theta0(mgs)
24409 temg(mgs) = theta(mgs)*pk(mgs) ! ( pres(mgs) / poo ) ** cap
24410 qvap(mgs) = max((qwvp(mgs) + qv0(mgs)), 0.0)
24411 temcg(mgs) = temg(mgs) - tfr
24412 tqvcon = temg(mgs)-cbw
24413 ltemq = (temg(mgs)-163.15)/fqsat+1.5
24414 ltemq = min( nqsat, max(1,ltemq) )
24415
24416 IF ( iqvsopt == 0 ) THEN
24417 qvs(mgs) = pqs(mgs)*tabqvs(ltemq)
24418 ELSEIF ( iqvsopt == 1 ) THEN
24419 qvs(mgs) = rdorv*esbolton*tabqvs(ltemq)/(pres(mgs) - esbolton*tabqvs(ltemq))
24420 ENDIF
24421 qis(mgs) = pqs(mgs)*tabqis(ltemq)
24422 qx(mgs,lc) = max( 0.0, qx(mgs,lc) )
24423 qitmp(mgs) = max( 0.0, qitmp(mgs) )
24424 qx(mgs,lv) = max( 0.0, qvap(mgs))
24425! if ( temg(mgs) .lt. tfr ) then
24426! if( qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) )
24427! > qss(mgs) = qvs(mgs)
24428!c if( qx(mgs,lc) .le. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li))
24429! if( qx(mgs,lc) .eq. 0.0 .and. qitmp(mgs) .gt. qxmin(li))
24430! > qss(mgs) = qis(mgs)
24431!c if( qx(mgs,lc) .gt. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li))
24432! if( qx(mgs,lc) .gt. 0.0 .and. qitmp(mgs) .gt. qxmin(li))
24433! > qss(mgs) = (qx(mgs,lc)*qvs(mgs) + qitmp(mgs)*qis(mgs)) /
24434! > (qx(mgs,lc) + qitmp(mgs))
24435! else
24436! qss(mgs) = qvs(mgs)
24437! end if
24438 qss(mgs) = qvs(mgs)
24439 if ( temg(mgs) .lt. tfr ) then
24440 if( qx(mgs,lc) .ge. 0.0 .and. qitmp(mgs) .le. qxmin(li) ) &
24441 & qss(mgs) = qvs(mgs)
24442 if( qx(mgs,lc) .le. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
24443 & qss(mgs) = qis(mgs)
24444 if( qx(mgs,lc) .gt. qxmin(lc) .and. qitmp(mgs) .gt. qxmin(li)) &
24445 & qss(mgs) = (qx(mgs,lc)*qvs(mgs) + qitmp(mgs)*qis(mgs)) / &
24446 & (qx(mgs,lc) + qitmp(mgs))
24447 end if
24448! pceds(mgs) = (thetap(mgs) - thsave(mgs))*dtpinv
24449! write(iunit,*) 'satadj2: mgs,iter = ',mgs,itertd,dqwv(mgs),qss(mgs),qx(mgs,lv),qx(mgs,lc)
24450 end do
24451!
24452! end the saturation adjustment iteration loop
24453!
24454 end do
24455
24456 ENDIF ! ( ipconc .le. 1 )
24457
24458!
24459! spread the growth owing to vapor diffusion onto the
24460! ice crystal categories using the
24461!
24462! END OF SATURATION ADJUSTMENT
24463!
24464
24465 if (ndebug .gt. 0 ) write(0,*) 'conc 30b'
24466!
24467!
24468! end of saturation adjustment
24469
24470!
24471!
24472! !DIR$ IVDEP
24473 do mgs = 1,ngscnt
24474 t0(igs(mgs),jy,kgs(mgs)) = temg(mgs)
24475 end do
24476!
24477! Load the save arrays
24478!
24479
24480
24481! Sample code for using the axtra array to load microphysical rates or quantities for output
24482!
24483! Note that indices 1 and 2 are used in the nucond subroutine for condensation/evap of droplets (1) and
24484! condensation of rain (2)
24485!
24486! IF ( io_flag .and. nxtra > 1 ) THEN
24487! DO mgs = 1,ngscnt
24488! axtra(igs(mgs),jy,kgs(mgs),3) = pfrz(mgs) !
24489! axtra(igs(mgs),jy,kgs(mgs),4) = qrcev(mgs) ! pre2
24490! axtra(igs(mgs),jy,kgs(mgs),5) = psub(mgs) ! depsubr
24491! axtra(igs(mgs),jy,kgs(mgs),6) = qrfrz(mgs) ! rain freezing (Bigg)
24492! axtra(igs(mgs),jy,kgs(mgs),7) = pmlt(mgs) ! melr2
24493! ENDDO
24494! ENDIF
24495
24496
24497
24498 if (ndebug .gt. 0 ) write(0,*) 'gs 11'
24499
24500 do mgs = 1,ngscnt
24501!
24502 an(igs(mgs),jy,kgs(mgs),lt) = &
24503 & theta0(mgs) + thetap(mgs)
24504 an(igs(mgs),jy,kgs(mgs),lv) = qwvp(mgs) + qv0(mgs) !
24505
24506 IF ( eqtset > 2 ) THEN
24507 p2(igs(mgs),jy,kgs(mgs)) = pipert(mgs)
24508 ENDIF
24509!
24510
24511 DO il = lc,lhab
24512 IF ( ido(il) .eq. 1 ) THEN
24513 IF ( lf > 1 .and. il == lf ) THEN
24514 lfsave(mgs,1) = an(igs(mgs),jy,kgs(mgs),il)
24515 lfsave(mgs,2) = qx(mgs,il)
24516 ENDIF
24517 an(igs(mgs),jy,kgs(mgs),il) = qx(mgs,il) + &
24518 & min( an(igs(mgs),jy,kgs(mgs),il), 0.0 )
24519 qx(mgs,il) = an(igs(mgs),jy,kgs(mgs),il)
24520 ENDIF
24521 ENDDO
24522
24523 IF ( lcina > 1 ) THEN
24524 an(igs(mgs),jy,kgs(mgs),lcina) = cina(mgs)
24525 ENDIF
24526
24527
24528
24529
24530
24531!
24532! 6th moments
24533!
24534
24535 IF ( ipconc .ge. 6 ) THEN
24536 DO il = lr,lhab
24537 IF ( lz(il) .gt. 1 ) THEN
24538 IF ( lf > 1 .and. il == lf ) THEN
24539 lfsave(mgs,3) = an(igs(mgs),jy,kgs(mgs),lz(il))
24540 lfsave(mgs,4) = zx(mgs,il)
24541 ENDIF
24542
24543 an(igs(mgs),jy,kgs(mgs),lz(il)) = zx(mgs,il) + &
24544 & min( an(igs(mgs),jy,kgs(mgs),lz(il)), 0.0 )
24545 zx(mgs,il) = an(igs(mgs),jy,kgs(mgs),lz(il))
24546
24547 ENDIF
24548 ENDDO
24549
24550 ENDIF
24551!
24552 end do
24553!
24554
24555 if ( ipconc .ge. 1 ) then
24556 DO il = lc,lhab !{
24557
24558! write(0,*) 'limiter loop: il,ipc,lz: ',il,ipc(il),lz(il),ipconc
24559
24560 IF ( ipconc .ge. ipc(il) .and. ido(il) > 0 ) THEN ! {
24561
24562 IF ( ipconc .ge. 4 .and. ipc(il) .ge. 1 ) THEN ! {
24563
24564! write(0,*) 'MY limiter: il,ipc,lz: ',il,ipc(il),lz(il),lr,lzr
24565! STOP
24566
24567 IF ( lz(il) <= 1 .or. ioldlimiter == 1 ) THEN ! { { is a two-moment category so dont worry about reflectivity
24568
24569
24570 DO mgs = 1,ngscnt
24571 IF ( qx(mgs,il) .le. 0.0 ) THEN
24572 cx(mgs,il) = 0.0
24573 ELSE !{
24574 IF ( cx(mgs,il) .gt. cxmin .and. qx(mgs,il) > qxmin(il) ) THEN !{ only do this if mass is sufficient
24575! xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*Max(1.0e-9,cx(mgs,il)))
24576! xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*Max(cxmin,cx(mgs,il)))
24577 xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*cx(mgs,il))
24578
24579! IF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
24580! write(0,*) 'dr: xv,cx,qx,xdn,ln = ',xv(mgs,il),cx(mgs,il),qx(mgs,il),xdn(mgs,il),ln(il)
24581! ENDIF
24582
24583 ! 8/26/2015 erm: apply imaxdiaopt for 2-moment also
24584 IF ( imaxdiaopt == 1 .or. il == lc .or. il == li .or. (il == lr .and. imurain == 3) .or. &
24585 & (il == ls .and. imusnow == 3 ) .or. ( il >= lh .and. lh > 0 ) ) THEN
24586! IF ( imaxdiaopt == 1 .or. (il == lr .and. imurain == 3) .or. .not. (il == lr .and. imurain == 1) ) THEN
24587 xvbarmax = xvmx(il)
24588 ELSEIF ( imaxdiaopt == 2 ) THEN ! test against maximum mass diameter
24589 xvbarmax = xvmx(il) /((3. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
24590 ELSEIF ( imaxdiaopt == 3 ) THEN ! test against mass-weighted diameter
24591 xvbarmax = xvmx(il) /((4. + alpha(mgs,il))**3/((3. + alpha(mgs,il))*(2. + alpha(mgs,il))*(1. + alpha(mgs,il))))
24592 ELSE
24593 xvbarmax = xvmx(il)
24594 ENDIF
24595
24596 tmp = 1.0
24597 IF ( il == ls ) THEN
24598 xvbarmax = xvbarmax*max(1.,100./min(100.,xdn(mgs,ls)))
24599 ENDIF
24600
24601 IF ( xv(mgs,il) .lt. xvmn(il) .or. xv(mgs,il) .gt. xvbarmax ) THEN
24602 xv(mgs,il) = min( xvbarmax, xv(mgs,il) )
24603 xv(mgs,il) = max( xvmn(il), xv(mgs,il) )
24604 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xv(mgs,il)*xdn(mgs,il))
24605 ENDIF
24606
24607 ENDIF !}
24608
24609! IF ( lhl .gt. 1 .and. il .eq. lhl ) THEN
24610! write(0,*) 'dr: xv,cx,= ',xv(mgs,il),cx(mgs,il)
24611! ENDIF
24612
24613 ENDIF !}
24614 ENDDO ! mgs
24615
24616 ELSE ! } { is three-moment, so have to adjust Z if size is too large
24617 IF ( il == lr .and. imurain == 3 ) THEN ! { { RAIN
24618
24619! rdmx =
24620! rdmn =
24621
24622 DO mgs = 1,ngscnt
24623
24624
24625 IF ( iresetmoments == 1 .or. iresetmoments == il ) THEN
24626 IF ( zx(mgs,lr) <= zxmin ) THEN
24627 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
24628 qx(mgs,lr) = 0.0
24629 cx(mgs,lr) = 0.0
24630 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
24631 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
24632 an(igs(mgs),jgs,kgs(mgs),ln(lr)) = cx(mgs,lr)
24633 ELSEIF ( cx(mgs,lr) <= cxmin ) THEN
24634 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
24635 zx(mgs,lr) = 0.0
24636 qx(mgs,lr) = 0.0
24637 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),lr)
24638 an(igs(mgs),jgs,kgs(mgs),lr) = qx(mgs,lr)
24639 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
24640 ENDIF
24641 ENDIF
24642
24643 IF ( qx(mgs,lr) .gt. qxmin(lr) ) THEN
24644
24645 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xdn(mgs,lr)*max(1.0e-11,cx(mgs,lr)))
24646 IF ( xv(mgs,lr) .gt. xvmx(lr) ) THEN
24647! xv(mgs,lr) = xvmx(lr)
24648! cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmx(lr)*xdn(mgs,lr))
24649 ELSEIF ( xv(mgs,lr) .lt. xvmn(lr) ) THEN
24650 xv(mgs,lr) = xvmn(lr)
24651 cx(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(xvmn(lr)*xdn(mgs,lr))
24652 ENDIF
24653
24654 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN
24655! have mass and reflectivity but no concentration, so set concentration, using default alpha
24656 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
24657 z = zx(mgs,il)
24658 qr = qx(mgs,il)
24659 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*xdn(mgs,lr)**2)
24660! an(igs(mgs),jgs,kgs(mgs),ln(il)) = zx(mgs,il)
24661 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > 0.0 ) THEN
24662! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
24663 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
24664 chw = cx(mgs,il)
24665 qr = qx(mgs,il)
24666 zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(xdn(mgs,lr)**2*chw)
24667 an(igs(mgs),jgs,kgs(mgs),lz(lr)) = zx(mgs,lr)
24668
24669 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
24670! How did this happen?
24671 ! set values according to dBZ of -10, or Z = 0.1
24672! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
24673 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
24674 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
24675
24676 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
24677 z = zx(mgs,il)
24678 qr = qx(mgs,il)
24679 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/(z*1000.*1000)
24680 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
24681 ENDIF
24682
24683 IF ( zx(mgs,lr) > 0.0 ) THEN
24684 xv(mgs,lr) = rho0(mgs)*qx(mgs,lr)/(1000.*cx(mgs,lr))
24685 vr = xv(mgs,lr)
24686 qr = qx(mgs,lr)
24687 nrx = cx(mgs,lr)
24688 z = zx(mgs,lr)
24689
24690! xv = (db(1,kz)*a(1,1,kz,lr))**2/(a(1,1,kz,lnr))
24691! rd = z*(pi/6.*1000.)**2/xv
24692
24693! determine shape parameter alpha by iteration
24694 IF ( z .gt. 0.0 ) THEN
24695 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
24696 DO i = 1,20
24697 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
24698 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
24699 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
24700 alp = max( rnumin, min( rnumax, alp ) )
24701 ENDDO
24702
24703! check for artificial breakup (rain larger than allowed max size)
24704 IF ( xv(mgs,il) .gt. xvmx(il) .or. (ioldlimiter == 2 .and. xv(mgs,il) .gt. xvmx(il)/8.) ) THEN
24705 tmp = cx(mgs,il)
24706! write(0,*) 'MY limiter: xv: ',xv(mgs,il), xv(mgs,il)/(xvmx(il)/8.)
24707! STOP
24708 IF ( ioldlimiter == 2 ) THEN ! MY-style active breakup
24709 x = (6.*rho0(mgs)*qx(mgs,il)/(pi*xdn(mgs,il)*cx(mgs,il)))**(1./3.)
24710 x1 = max(0.0e-3, x - 3.0e-3)
24711 x2 = max(0.5, x/6.0e-3)
24712 x3 = x2**3
24713 cx(mgs,il) = cx(mgs,il)*max((1.+2.222e3*x1**2), x3)
24714 xv(mgs,il) = xv(mgs,il)/max((1.+2.222e3*x1**2), x3)
24715 ELSE ! simple cutoff
24716 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
24717 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
24718 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
24719 ENDIF
24720 !xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
24721 !cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
24722
24723
24724 IF ( tmp < cx(mgs,il) ) THEN ! breakup
24725
24726 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
24727 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
24728 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
24729
24730 vr = xv(mgs,lr)
24731 qr = qx(mgs,lr)
24732 nrx = cx(mgs,lr)
24733 z = zx(mgs,lr)
24734
24735
24736! determine shape parameter alpha by iteration
24737 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
24738 DO i = 1,20
24739 IF ( abs(alp - alpha(mgs,lr)) .lt. 0.01 ) EXIT
24740 alpha(mgs,lr) = max( rnumin, min( rnumax, alp ) )
24741 alp = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/(z*pi**2) - 1.
24742 alp = max( rnumin, min( rnumax, alp ) )
24743 ENDDO
24744
24745
24746 ENDIF
24747 ENDIF
24748
24749!
24750! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
24751! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
24752!
24753 g1 = 36.*(alpha(mgs,lr)+2.0)/((alpha(mgs,lr)+1.0)*pi**2)
24754 IF ( .true. .and. (alpha(mgs,il) <= rnumin .or. alp == rnumin .or. alp == rnumax) ) THEN
24755
24756 IF ( rescale_high_alpha .and. alp >= rnumax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
24757 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(1./(xdn(mgs,il)))**2
24758 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
24759
24760 ELSEIF ( rescale_low_alphar .and. alp <= rnumin ) THEN
24761 z = 36.*(alpha(mgs,lr)+2.0)*nrx*vr**2/((alpha(mgs,lr)+1.0)*pi**2)
24762 zx(mgs,il) = z
24763 an(igs(mgs),jy,kgs(mgs),lz(il)) = zx(mgs,il)
24764 ENDIF
24765 ENDIF
24766
24767
24768
24769 ENDIF
24770 ENDIF
24771
24772 ENDIF
24773
24774 ENDDO
24775! CALL cld_cpu('Z-MOMENT-1r')
24776
24777
24778 ELSEIF ( il == lh .or. il == lhl .or. il == lf .or. (il == lr .and. imurain == 1 )) THEN ! } { Rain, GRAUPEL OR HAIL
24779
24780
24781
24782 DO mgs = 1,ngscnt
24783
24784 IF ( lf > 1 .and. il == lf ) THEN
24785 lfsave(mgs,5) = an(igs(mgs),jy,kgs(mgs),ln(il))
24786 lfsave(mgs,6) = cx(mgs,il)
24787 ENDIF
24788
24789 IF ( il == lhl .and. lnhlf > 1 ) THEN
24790 IF ( cx(mgs,lhl) > cxmin ) THEN
24791 frac = chxf(mgs,lhl)/cx(mgs,lhl)
24792 ELSE
24793 frac = 0.0
24794 ENDIF
24795 ENDIF
24796
24797 IF ( il == lh .and. lnhf > 1 ) THEN
24798 IF ( cx(mgs,lh) > cxmin ) THEN
24799 frach = chxf(mgs,lh)/cx(mgs,lh)
24800 ELSE
24801 frach = 0.0
24802 ENDIF
24803 ENDIF
24804
24805
24806
24807 IF ( iresetmoments == 1 .or. iresetmoments == il .or. iresetmoments == -1 ) THEN ! { .or. qx(mgs,il) <= qxmin(il)
24808 IF ( zx(mgs,il) <= zxmin ) THEN ! .and. qx(mgs,il) > 0.05e-3
24809!! write(91,*) 'zx=0; qx,cx = ',1000.*qx(mgs,il),cx(mgs,il)
24810 qx(mgs,il) = 0.0
24811 cx(mgs,il) = 0.0
24812 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
24813 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
24814 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
24815 ELSEIF ( iresetmoments == -1 .and. qx(mgs,il) < qxmin(il) ) THEN
24816 zx(mgs,il) = 0.0
24817 cx(mgs,il) = 0.0
24818 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
24819
24820 qx(mgs,il) = 0.0
24821 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
24822 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
24823 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
24824
24825 ELSEIF ( cx(mgs,il) <= cxmin .and. iresetmoments /= -1 ) THEN ! .and. qx(mgs,il) > 0.05e-3
24826 qx(mgs,lv) = qx(mgs,lv) + qx(mgs,il)
24827 zx(mgs,il) = 0.0
24828 qx(mgs,il) = 0.0
24829 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
24830 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
24831 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
24832 ENDIF
24833 ELSE
24834 IF ( zx(mgs,il) < 0.0 ) THEN ! .and. qx(mgs,il) > 0.05e-3
24835 zx(mgs,il) = 0.0
24836 ENDIF
24837 ENDIF !}
24838
24839
24840 IF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= cxmin ) THEN
24841 zx(mgs,il) = 0.0
24842 cx(mgs,il) = 0.0
24843 an(igs(mgs),jgs,kgs(mgs),lv) = an(igs(mgs),jgs,kgs(mgs),lv) + an(igs(mgs),jgs,kgs(mgs),il)
24844 qx(mgs,il) = 0.0
24845 an(igs(mgs),jgs,kgs(mgs),il) = qx(mgs,il)
24846 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
24847 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
24848 ENDIF
24849
24850 IF ( qx(mgs,il) .gt. qxmin(il) ) THEN !{
24851
24852 xv(mgs,il) = rho0(mgs)*qx(mgs,il)/(xdn(mgs,il)*max(1.0e-9,cx(mgs,il)))
24853 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
24854
24855 IF ( xv(mgs,il) .lt. xvmn(il) ) THEN
24856 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
24857 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
24858 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
24859 ENDIF
24860
24861 IF ( zx(mgs,il) > 0.0 .and. cx(mgs,il) <= 0.0 ) THEN !{
24862! have mass and reflectivity but no concentration, so set concentration, using default alpha
24863 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
24864 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
24865 z = zx(mgs,il)
24866 qr = qx(mgs,il)
24867! cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z
24868 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(z*(pi*xdn(mgs,il))**2)
24869
24870
24871 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) > 0.0 ) THEN
24872! have mass and concentration but no reflectivity, so set reflectivity, using default alpha
24873! g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
24874! & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
24875 chw = cx(mgs,il)
24876 qr = qx(mgs,il)
24877! zx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
24878! zx(mgs,il) = Min(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
24879 g1 = (6.0 + alphamax)*(5.0 + alphamax)*(4.0 + alphamax)/ &
24880 & ((3.0 + alphamax)*(2.0 + alphamax)*(1.0 + alphamax))
24881 zx(mgs,il) = max(zxmin*1.1, g1*dn(igs(mgs),jy,kgs(mgs))**2*(6*qr)**2/(chw*(pi*xdn(mgs,il))**2) )
24882 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
24883
24884 ELSEIF ( zx(mgs,il) <= zxmin .and. cx(mgs,il) <= 0.0 ) THEN
24885! How did this happen?
24886 ! set values according to dBZ of -10, or Z = 0.1
24887! 0.1 = 1.e18*0.224*an(ix,jy,kz,lzh)*(hwdn/rwdn)**2
24888
24889! write(0,*) 'GS: moment problem! il,c,z,q = ',il,cx(mgs,il),zx(mgs,il),qx(mgs,il)
24890
24891 zx(mgs,il) = 1.e-19/0.224*(xdn0(lr)/xdn0(il))**2
24892 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
24893
24894 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
24895 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
24896 z = zx(mgs,il)
24897 qr = qx(mgs,il)
24898! cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z
24899 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(6.*qr)**2/(z*(pi*xdn(mgs,il))**2)
24900 an(igs(mgs),jgs,kgs(mgs),ln(il)) = cx(mgs,il)
24901
24902! write(0,*) 'GS: moment problem! reset il,c,z,q = ',il,cx(mgs,il),zx(mgs,il),qx(mgs,il)
24903
24904 ELSE
24905 ! have all valid moments, so find shape parameter
24906 chw = cx(mgs,il)
24907 qr = qx(mgs,il)
24908 z = zx(mgs,il)
24909
24910 IF ( zx(mgs,il) .gt. zxmin .and. qr > qxmin(il) .and. chw > cxmin ) THEN !{
24911
24912! rdi = z*(pi/6.*1000.)**2*chw/((rho0(mgs)*qr)**2)
24913 rdi = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
24914
24915! alp = 1.e18*(6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/
24916! : ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24917 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
24918 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24919! print*,'kz, alp, alpha(mgs,il) = ',kz,alp,alpha(mgs,il),rdi,z,xv
24920 DO i = 1,10
24921! IF ( 100.*Abs(alp - alpha(mgs,il))/(Abs(alpha(mgs,il))+1.e-5) .lt. 1. ) EXIT
24922 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
24923 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
24924! alp = 1.e18*(6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/
24925! : ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24926 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
24927 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24928! print*,'i,alp = ',i,alp
24929 alp = max( alphamin, min( alphamax, alp ) )
24930 ENDDO
24931
24932
24933! check for artificial breakup (graupel/hail larger than allowed max size)
24934 IF ( xv(mgs,il) .gt. xvmx(il) ) THEN !{
24935 tmp = cx(mgs,il)
24936
24937
24938 xv(mgs,il) = min( xvmx(il), max( xvmn(il),xv(mgs,il) ) )
24939 xmas(mgs,il) = xv(mgs,il)*xdn(mgs,il)
24940 cx(mgs,il) = rho0(mgs)*qx(mgs,il)/(xmas(mgs,il))
24941 IF ( tmp < cx(mgs,il) ) THEN ! breakup
24942 g1 = 36.*(6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
24943 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il))*pi**2)
24944 zx(mgs,il) = zx(mgs,il) + g1*(rho0(mgs)/xdn(mgs,il))**2*( (qx(mgs,il)/tmp)**2 * (tmp-cx(mgs,il)) )
24945 an(igs(mgs),jgs,kgs(mgs),lz(il)) = zx(mgs,il)
24946
24947 chw = cx(mgs,il)
24948 qr = qx(mgs,il)
24949 z = zx(mgs,il)
24950
24951 rdi = z*(pi/6.*xdn(mgs,il))**2*chw/((rho0(mgs)*qr)**2)
24952 alp = (6.0+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
24953 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24954 DO i = 1,10
24955 IF ( abs(alp - alpha(mgs,il)) .lt. 0.01 ) EXIT
24956 alpha(mgs,il) = max( alphamin, min( alphamax, alp ) )
24957 alp = (6.+alpha(mgs,il))*(5.0+alpha(mgs,il))*(4.0+alpha(mgs,il))/ &
24958 & ((3.0+alpha(mgs,il))*(2.0+alpha(mgs,il))*rdi) - 1.0
24959 alp = max( alphamin, min( alphamax, alp ) )
24960 ENDDO
24961
24962
24963 ENDIF
24964 ENDIF !}
24965
24966!
24967! Check whether the shape parameter is at or less than the minimum, and if it is, reset the
24968! concentration or reflectivity to match (prevents reflectivity from being out of balance with Q and N)
24969!
24970 g1 = (6.0 + alpha(mgs,il))*(5.0 + alpha(mgs,il))*(4.0 + alpha(mgs,il))/ &
24971 & ((3.0 + alpha(mgs,il))*(2.0 + alpha(mgs,il))*(1.0 + alpha(mgs,il)))
24972
24973 IF ( ( lrescalelow(il) .or. rescale_high_alpha ) .and. &
24974 & ( alpha(mgs,il) <= alphamin .or. alp == alphamin .or. alp == alphamax ) ) THEN !{
24975
24976 IF ( rescale_high_alpha .and. alp >= alphamax - 0.01 ) THEN ! reset c at high alpha to prevent growth in Z
24977 cx(mgs,il) = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/z*(6./(pi*xdn(mgs,il)))**2
24978 an(igs(mgs),jy,kgs(mgs),ln(il)) = cx(mgs,il)
24979
24980 ELSEIF ( lrescalelow(il) .and. alp <= alphamin .and. .not. (il == lh .and. icvhl2h > 0 ) .and. &
24981 .not. ( il == lr .and. .not. rescale_low_alphar ) ) THEN ! alpha = alphamin, so reset Z to prevent growth in C
24982
24983 wtest = .false.
24984 IF ( irescalerainopt == 0 ) THEN
24985 wtest = .false.
24986 ELSEIF ( irescalerainopt == 1 ) THEN
24987 wtest = qx(mgs,lc) > qxmin(lc)
24988 ELSEIF ( irescalerainopt == 2 ) THEN
24989 wtest = qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < rescale_wthresh
24990 ELSEIF ( irescalerainopt == 3 ) THEN
24991 wtest = temcg(mgs) > rescale_tempthresh .and. qx(mgs,lc) > qxmin(lc) .and. wvel(mgs) < rescale_wthresh
24992 ENDIF
24993
24994 IF ( il == lr .and. ( wtest .or. .not. rescale_low_alphar ) ) THEN
24995 ! certain situations where rain number is adjusted instead of Z. Helps avoid rain being 'zapped' by autoconverted
24996 ! drops (i.e., favor preserving Z when alpha tries to go negative)
24997 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
24998 cx(mgs,il) = chw
24999 an(igs(mgs),jy,kgs(mgs),ln(il)) = chw
25000 ELSE
25001 ! Usual resetting of reflectivity moment to force consisntency between Q, N, Z, and alpha when alpha = alphamin
25002 z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
25003 z = z1*(6./(pi*xdn(mgs,il)))**2
25004 zx(mgs,il) = z
25005 an(igs(mgs),jy,kgs(mgs),lz(il)) = z
25006 ENDIF
25007
25008! z1 = g1*dn(igs(mgs),jy,kgs(mgs))**2*(qr)*qr/chw
25009! z = z1*(6./(pi*xdn(mgs,il)))**2
25010! zx(mgs,il) = z
25011! an(igs(mgs),jy,kgs(mgs),lz(il)) = z
25012 ENDIF
25013
25014 ENDIF !}
25015
25016
25017 ENDIF !}
25018
25019
25020 ENDIF ! !}
25021
25022
25023
25024 ENDIF !}
25025
25026 IF ( lzr > 1 ) THEN
25027 alpha2d(igs(mgs),kgs(mgs),1) = max(alphamin, min(alphamax, alpha(mgs,lr) ))
25028 ENDIF
25029 IF ( lzh > 1 ) THEN
25030 alpha2d(igs(mgs),kgs(mgs),2) = max(alphamin, min(alphamax, alpha(mgs,lh) ))
25031 ENDIF
25032 IF ( lzhl > 1 ) THEN
25033 alpha2d(igs(mgs),kgs(mgs),3) = max(alphamin, min(alphamax, alpha(mgs,lhl) ))
25034 ENDIF
25035
25036 IF ( il == lhl .and. lnhlf > 1 ) THEN
25037 ! update chxf in case cx has changed
25038 chxf(mgs,lhl) = frac*cx(mgs,lhl)
25039 ENDIF
25040 IF ( il == lh .and. lnhf > 1 ) THEN
25041 ! update chxf in case cx has changed
25042 chxf(mgs,lh) = frach*cx(mgs,lh)
25043 ENDIF
25044
25045
25046! 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
25047! 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)
25048! write(0,*) 'qold,qxold,zold,zxold = ',lfsave(mgs,1),lfsave(mgs,2),lfsave(mgs,3),lfsave(mgs,4)
25049! write(0,*) 'cf_new,pcfwi,pcfwd = ',cx(mgs,lf),cx(mgs,lf) + dtp*( pcfwi(mgs) + pcfwd(mgs) ),pcfwi(mgs) + pcfwd(mgs)
25050!
25051! ENDIF
25052
25053 ENDDO ! mgs
25054
25055! CALL cld_cpu('Z-DELABK')
25056
25057
25058! CALL cld_cpu('Z-DELABK')
25059
25060
25061
25062
25063 ENDIF ! } }
25064
25065 ENDIF ! }}
25066 ENDIF ! }
25067
25068 DO mgs = 1,ngscnt
25069
25070 IF ( il == lh ) THEN
25071 IF ( lnhf > 1 ) THEN ! number of graupel from frozen drops
25072 an(igs(mgs),jy,kgs(mgs),lnhf) = max( chxf(mgs,lh), 0.0)
25073 ENDIF
25074 ENDIF
25075
25076 IF ( il == lhl ) THEN
25077
25078 IF ( lnhlf > 1 ) THEN ! number of hail from frozen drops
25079! an(igs(mgs),jy,kgs(mgs),lnhlf) = Min( cx(mgs,lhl), Max( chxf(mgs,lhl), 0.0) )
25080 an(igs(mgs),jy,kgs(mgs),lnhlf) = max( chxf(mgs,lhl), 0.0)
25081 ENDIF
25082 ENDIF
25083 an(igs(mgs),jy,kgs(mgs),ln(il)) = max(cx(mgs,il), 0.0)
25084 ENDDO
25085 ENDIF ! }
25086 ENDDO ! il }
25087
25088 IF ( lcin > 1 ) THEN
25089 do mgs = 1,ngscnt
25090 an(igs(mgs),jy,kgs(mgs),lcin) = max(0.0, ccin(mgs))
25091 end do
25092 ENDIF
25093
25094 IF ( ipconc .ge. 2 ) THEN
25095 do mgs = 1,ngscnt
25096 IF ( lss > 1 ) THEN
25097 an(igs(mgs),jy,kgs(mgs),lss) = max(0.0, ssmax(mgs) )
25098 ENDIF
25099
25100 IF ( lccn > 1 ) THEN
25101 an(igs(mgs),jy,kgs(mgs),lccn) = max(0.0, ccnc(mgs) )
25102 ENDIF
25103 end do
25104 ENDIF
25105
25106 ELSEIF ( ipconc .eq. 0 .and. lni .gt. 1 ) THEN
25107
25108 DO mgs = 1,ngscnt
25109 an(igs(mgs),jy,kgs(mgs),lni) = max(cx(mgs,li), 0.0)
25110 ENDDO
25111
25112
25113 end if
25114
25115 IF ( ldovol ) THEN
25116
25117 DO il = li,lhab
25118
25119 IF ( lvol(il) .ge. 1 ) THEN
25120
25121 DO mgs = 1,ngscnt
25122
25123 an(igs(mgs),jy,kgs(mgs),lvol(il)) = max( 0.0, vx(mgs,il) )
25124 ENDDO
25125
25126 ENDIF
25127
25128 ENDDO
25129
25130 ENDIF
25131!
25132!
25133!
25134!
25135!
25136 if (ndebug .gt. 0 ) write(0,*) 'gs 12'
25137
25138
25139
25140 if (ndebug .gt. 0 ) write(0,*) 'gs 13'
25141
25142 9998 continue
25143
25144 if ( kz .gt. nz-1 .and. ix .ge. itile) then
25145 if ( ix .ge. itile ) then
25146 go to 1200 ! exit gather scatter
25147 else
25148 nzmpb = kz
25149 endif
25150 else
25151 nzmpb = kz
25152 end if
25153
25154 if ( ix .ge. itile ) then
25155 nxmpb = 1
25156 nzmpb = kz+1
25157 else
25158 nxmpb = ix+1
25159 end if
25160
25161 1000 continue
25162 1200 continue
25163!
25164! end of gather scatter (for this jy slice)
25165!
25166!
25167
25168 return
25169 end subroutine nssl_2mom_gs
25170!
25171!--------------------------------------------------------------------------
25172!
25173
25174
25175
25176!
25177!--------------------------------------------------------------------------
25178!
25179
25180
25181END 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...
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 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 setvtz(ngscnt, qx, qxmin, qxw, cx, rho0, rhovt, xdia, cno, cnostmp, xmas, vtxbar, xdn, xvmn0, xvmx0, xv, cdx, cdxgs, ipconc1, ndebug1, ngs, nz, igs, kgs, fadvisc, cwmasn, cwmasx, cwradn, cnina, cimna, cimxa, itype1a, itype2a, temcg, infdo, alpha, axx, bxx, ildo)
Mean hydrometeor size and fall speed calculations.
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.
subroutine, public nssl_2mom_init(ims, ime, jms, jme, kms, kme, nssl_params, ipctmp, mixphase, ihvol, idoniconlytmp, namelist_filename, internal_nml, 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, nssl_ccn_opt, errmsg, errflg, infileunit, myrank, mpiroot)
NSSL MP setup routine (sets local options and array indices)
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 calc_eff_radius(nx, ny, nz, na, jyslab, nor, norz, t1, t2, t3, t4, t5, t6, f_t4, f_t5, f_t6, qcw, qci, qsw, qrw, ccw, cci, csw, crw, an, dn)
Subroutine to calculate effective radii for use by radiation routines.
subroutine fallout1d(nx, ny, nz, nor, na, dtp, dtfrac, jgs, vt, a, db1, ia, id, xfall, dtz1, ixcol)
Column sedimentation fallout subroutine.
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, cn_nu, cn_co, cinp, f_cnnu, f_cnco, f_cinp, cna_co, cna_nu, f_cnaco, f_cnanu, cnuf, f_cnuf, cn_ac, f_cnac, 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, f_scion, f_sciona, noninduc, noninducp, noninducn, ssat3d, ssati, nssl_ssat_output, 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, isedonly_in, 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.
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...