updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / phys / module_microphysics_driver.F
blob7bfcaf901b038d9d48c9c761e68254c31bc434c6
1 !WRF:MEDIATION_LAYER:PHYSICS
2 ! *** add new modules of schemes here
4 MODULE module_microphysics_driver
5   real, private, parameter :: QX_MIN = 1.E-12
6   real, private, parameter :: NI_MIN = 1.E-6
7 CONTAINS
9 SUBROUTINE microphysics_driver(                                          &
10                        th, rho, pi_phy, p                                &
11                       ,ht, dz8w, p8w, dt,dx,dy                           &
12                       ,mp_physics, spec_zone                             &
13                       ,specified, channel_switch                         &
14                       ,warm_rain                                         &
15                       ,t8w                                               &
16                       ,chem_opt, progn                                   &
17                       ,cldfra, cldfra_old, exch_h, nsource               &
18                       ,qlsink, precr, preci, precs, precg                &
19                       ,xland,snowh,itimestep                             &
20                       ,f_ice_phy,f_rain_phy,f_rimef_phy                  &
21                       ,lowlyr,sr, id                                     &
22                       ,ids,ide, jds,jde, kds,kde                         &
23                       ,ims,ime, jms,jme, kms,kme                         &
24                       ,ips,ipe, jps,jpe, kps,kpe                         &
25                       ,i_start,i_end,j_start,j_end,kts,kte               &
26                       ,num_tiles, naer                                   &
27                       ,irrigation,sf_surf_irr_scheme, irr_daily_amount   &   
28                       ,irr_start_hour,irr_num_hours,julian_in            &
29                       ,irr_start_julianday,irr_end_julianday             &
30                       ,irr_freq,irr_ph,irr_rand_field                    &
31                       ,gmt,xtime                                         &
32 !======================
33                       !Variables required for CAMMGMP Scheme
34                       ,dlf,dlf2,t_phy,p_hyd,p8w_hyd,tke_pbl,pblh         &
35                       ,z_at_mass,z_at_w,qfx                              &
36                       ,rliq,turbtype3d,smaw3d,wsedl3d,cldfra_old_mp      &
37                       ,cldfra_mp,cldfra_mp_all,lradius,iradius           &
38                       ,cldfrai,cldfral,cldfra_conv                       &
39                       ,alt                                               &
40                       ,accum_mode,aitken_mode,coarse_mode                &
41                       ,icwmrsh3d,icwmrdp3d,shfrc3d,cmfmc3d,cmfmc2_3d     &
42                       ,config_flags,fnm,fnp,rh_old_mp,lcd_old_mp         &
43 #if ( WRF_CHEM == 1 )
44                       ,chem                                              &! For CAMMGMP scheme Prognostic aerosols
45                       ,qme3d,prain3d,nevapr3d,rate1ord_cw2pr_st3d        &
46                       ,dgnum4D,dgnumwet4D                                &
47 #endif
48 !======================                                   
49                       ,qv_curr,qc_curr,qr_curr,qi_curr,qs_curr,qg_curr   &
50                       ,qic_curr,qip_curr,qid_curr &
51                       ,qnic_curr,qnip_curr,qnid_curr &
52                       ,qndrop_curr,qni_curr,qh_curr,qnh_curr             &
53                       ,qzr_curr,qzi_curr,qzs_curr,qzg_curr,qzh_curr      &
54                       ,qns_curr,qnr_curr,qng_curr,qnn_curr,qnc_curr      &
55                       ,qnwfa_curr,qnifa_curr,qnbca_curr                  & ! for water/ice-friendly/black carbon aerosols
56                       ,f_qnwfa,f_qnifa,f_qnbca                           & ! for water/ice-friendly/black carbon aerosols
57                       ,qvolg_curr,qvolh_curr                             &
58                       ,qdcn_curr,qtcn_curr,qccn_curr,qrcn_curr           & ! for ntu3m
59                       ,qnin_curr,fi_curr,fs_curr,vi_curr,vs_curr         & ! for ntu3m
60                       ,vg_curr,ai_curr,as_curr,ag_curr,ah_curr,i3m_curr  & ! for ntu3m
61                       ,f_qdcn,f_qtcn,f_qccn,f_qrcn,f_qnin,f_fi,f_fs      & ! for ntu3m
62                       ,f_vi,f_vs,f_vg,f_ai,f_as,f_ag,f_ah,f_i3m          & ! for ntu3m
63                       ,qir_curr,qib_curr                                 & ! for P3
64                       ,qi2_curr,qni2_curr,qir2_curr,qib2_curr            & ! for P3
65                       ,qvoli_curr,qaoli_curr                             & ! for Jensen ISHMAEL
66                       ,qvoli2_curr,qaoli2_curr                           & ! for Jensen ISHMAEL
67                       ,qi3_curr,qni3_curr,qvoli3_curr,qaoli3_curr        & ! for Jensen ISHMAEL
68                       ,effr_curr,ice_effr_curr,tot_effr_curr             &
69                       ,qic_effr_curr,qip_effr_curr,qid_effr_curr         &             
70                       ,f_qv,f_qc,f_qr,f_qi,f_qs,f_qg,f_qndrop,f_qni      &
71                       ,f_qns,f_qnr,f_qng,f_qnc,f_qnn,f_qh,f_qnh          &
72                       ,            f_qzr,f_qzi,f_qzs,f_qzg,f_qzh         &
73                       ,f_qvolg,f_qvolh                                   &
74                       ,f_qic,f_qip,f_qid &
75                       ,f_qnic,f_qnip,f_qnid &
76                       ,f_qir,f_qib                                       & ! for P3
77                       ,f_qi2,f_qni2,f_qir2,f_qib2                        & ! for P3
78                       ,f_qvoli,f_qaoli                                   & ! for Jensen ISHMAEL
79                       ,f_qvoli2,f_qaoli2                                 & ! for Jensen ISHMAEL
80                       ,f_qi3,f_qni3,f_qvoli3,f_qaoli3                    & ! for Jensen ISHMAEL
81                       ,f_effr,f_ice_effr,f_tot_effr                      &
82                       ,f_qic_effr,f_qip_effr,f_qid_effr                  &                 
83                       ,cu_used                                           &
84                       ,qrcuten, qscuten, qicuten, qccuten                &
85                       ,qt_curr,f_qt                                      &
86                       ,mp_restart_state,tbpvs_state,tbpvs0_state         & ! for etampnew or fer_mp_hires
87                       ,hail,ice2                                         & ! for mp_gsfcgce
88 !NUWRF JJS 20110525 vvvvv
89                       ,phys_tot, physc, physe, physd, physs, physm, physf& ! for gsfcgce
90                       ,acphys_tot, acphysc, acphyse, acphysd  & ! for gsfcgce
91                       ,acphyss, acphysm, acphysf              & ! for gsfcgce
93                       ,re_cloud_gsfc, re_rain_gsfc, re_ice_gsfc          &
94                       ,re_snow_gsfc, re_graupel_gsfc, re_hail_gsfc       & ! cloud effective radius
95                       ,precr3d, preci3d, precs3d, precg3d, prech3d       &
96 #if ( WRF_CHEM == 1 )
97                       ,icn_diag, nc_diag                           &  ! inline gocart
98                       ,gsfcgce_gocart_coupling                           &
99 #endif
100 !NUWRF JJS 20110525 ^^^^^
101 !                     ,ccntype                                           & ! for mp_milbrandt2mom
102                       ,u,v,w,z                                          &   
103                       ,rainnc,    rainncv                                &
104                       ,snownc,    snowncv                                &
105                       ,hailnc,    hailncv                                &
106                       ,graupelnc, graupelncv                             &
107 #if ( WRF_CHEM == 1 )
108                       ,rainprod, evapprod                                &
109                       ,qv_b4mp, qc_b4mp, qi_b4mp, qs_b4mp                &
110 #endif
111                       ,qnwfa2d, qnifa2d, qnbca2d                         & ! for water/ice-friendly/black carbon aerosols
112                       ,qnocbb2d, qnbcbb2d                                & ! for biomass burning aerosols
113                       ,refl_10cm                                         & ! HM, 9/22/09, add for refl
114                       ,vmi3d                                             & ! for P3 
115                       ,di3d                                              & ! for P3 
116                       ,rhopo3d                                           & ! for P3 
117                       ,phii3d                                            & ! for Jensen ISHMAEL
118                       ,vmi3d_2                                           & ! for P3 
119                       ,di3d_2                                            & ! for P3 
120                       ,rhopo3d_2                                         & ! for P3 
121                       ,phii3d_2                                          & ! for Jensen ISHMAEL
122                       ,vmi3d_3                                           & ! for Jensen ISHMAEL
123                       ,di3d_3                                            & ! for Jensen ISHMAEL
124                       ,rhopo3d_3                                         & ! for Jensen ISHMAEL
125                       ,phii3d_3                                          & ! for Jensen ISHMAEL
126                       ,itype                                             & ! for Jensen ISHMAEL
127                       ,itype_2                                           & ! for Jensen ISHMAEL
128                       ,itype_3                                           & ! for Jensen ISHMAEL
130 ! YLIN
131 ! Added the RI_CURR array to the call
132                       ,ri_curr                                           &
133                       ,diagflag,   do_radar_ref                          &
134                       ,ke_diag                                           &
135                       ,re_cloud, re_ice, re_snow                         & ! G. Thompson
136                       ,has_reqc, has_reqi, has_reqs                      & ! G. Thompson
137                       ,ccn_conc                                          & ! RAS
138                       ,scalar,num_scalar                                   &
139                       ,kext_ql,kext_qs,kext_qg            &
140                       ,kext_qh,kext_qa                         &
141                       ,kext_qic,kext_qid,kext_qip         &
142                       ,kext_ft_qic,kext_ft_qid,kext_ft_qip         &
143                       ,kext_ft_qs,kext_ft_qg            &
144                       ,height,tempc &
145                       ,TH_OLD                                            &
146                       ,QV_OLD                                            &
147                       ,xlat,xlong,ivgtyp                                 &
148                       ,qrimef_curr,f_qrimef                              &
149                       ,aercu_opt                                         &
150 # if( EM_CORE==1 )
151                       ,sbmradar,num_sbmradar                             &
152                       ,sbm_diagnostics                                   &
153                       ,aerocu,aercu_fct,no_src_types_cu                  &
154                       ,PBL,EFCG,EFIG,EFSG,WACT,CCN1_GS,CCN2_GS           &
155                       ,CCN3_GS,CCN4_GS,CCN5_GS,CCN6_GS,CCN7_GS           &
156                       ,NR_CU,QR_CU,NS_CU,QS_CU,CU_UAF,mskf_refl_10cm     &
157 # endif
158                       ,multi_perturb                                     &
159                       ,pert_thom, perts_qvapor, perts_qcloud, perts_qice &
160                       ,perts_qsnow, perts_ni                             &
161                       ,pert_thom_qv,pert_thom_qc,pert_thom_qi            &
162                       ,pert_thom_qs,pert_thom_ni                         &
163                                                                          )
165 ! Framework
166    USE module_state_description, ONLY :                                  &
167                      KESSLERSCHEME, LINSCHEME, SBU_YLINSCHEME, WSM3SCHEME, WSM5SCHEME    &
168                     ,WSM6SCHEME, ETAMPNEW, FER_MP_HIRES, THOMPSON, THOMPSONAERO, THOMPSONGH, FAST_KHAIN_LYNN_SHPUND, MORR_TWO_MOMENT     &
169                     ,GSFCGCESCHEME, WDM5SCHEME, WDM6SCHEME, NSSL_2MOM, NSSL_2MOMCCN, NSSL_2MOMG, MADWRF_MP  &
170                     ,NSSL_1MOM,NSSL_1MOMLFO, FER_MP_HIRES_ADVECT & ! ,NSSL_3MOM       &
171                     ,WSM7SCHEME, WDM7SCHEME &
172                     ,NUWRF4ICESCHEME &
173                     ,MILBRANDT2MOM , CAMMGMPSCHEME,FULL_KHAIN_LYNN, P3_1CATEGORY, P3_1CATEGORY_NC, P3_2CATEGORY, P3_1CAT_3MOM &
174                     ,MORR_TM_AERO, JENSEN_ISHMAEL, SPRINKLER, NTU !,MILBRANDT3MOM
175    USE module_state_description, ONLY : WSM6RSCHEME
176 #if ( WRFPLUS == 1 )
177    USE module_state_description, ONLY : LSCONDSCHEME, MKESSLERSCHEME
178 #endif
179 #if ( WRF_CHEM == 1 )
180 ! NUWRF
181    USE module_state_description, ONLY :                                 &
182                      num_chem                                           & !inline gocart
183                     ,p_bc1, p_bc2, p_oc1, p_oc2                         & !inline gocart
184                     ,p_dust_1, p_dust_2, p_dust_3                       & !inline gocart
185                     ,p_dust_4, p_dust_5                                 & !inline gocart
186                     ,p_sulf, p_seas_1, p_seas_2                         & !inline gocart
187                     ,p_seas_3, p_seas_4 
189 #endif
191 #ifdef DM_PARALLEL
192   USE module_dm, ONLY : &
193                  local_communicator, mytask,  wrf_dm_min_real, wrf_dm_max_real
194 #endif
196 ! Model Layer
197    USE module_model_constants
198    USE module_wrf_error
199    USE module_configure, only: grid_config_rec_type
200 #if ( WRF_CHEM == 1 )   
201 !mchen   USE module_state_description, only: num_scalar               ! For CAMMGMP scheme Prognostic aerosols
202    USE module_state_description, only: num_chem               ! mchen 
203    USE modal_aero_data, only:  ntot_amode_cam_mam => ntot_amode ! For CAMMGMP scheme Prognostic aerosols
204 #endif
206 ! *** add new modules of schemes here
208    USE module_mp_kessler
209 #if ( WRFPLUS == 1 )
210    USE module_mp_mkessler
211    USE module_mp_nconvp    !  added by Zhuxiao
212 #endif
213    USE module_mp_lin
214    USE module_mp_sbu_ylin
215    USE module_mp_wsm3
216    USE module_mp_wsm5
217    USE module_mp_wsm6
218    USE module_mp_wsm6r, ONLY:wsm6r
219    USE module_mp_wsm7
220    USE module_mp_etanew
221    USE module_mp_fer_hires
222    USE module_mp_thompson
223    USE module_mp_full_sbm
224 #if ( BUILD_SBM_FAST == 1 )
225    USE module_mp_fast_sbm
226 #endif
227    USE module_mp_gsfcgce
228    USE module_mp_gsfcgce_4ice_nuwrf, only: gsfcgce_4ice_nuwrf
229    USE module_mp_morr_two_moment
230    USE microphy_p3
231    USE module_mp_jensen_ishmael
232 # if (EM_CORE == 1)
233    USE module_mp_morr_two_moment_aero
234    USE module_mp_ntu
235 # endif
236    USE module_mp_wdm5
237    USE module_mp_wdm6
238    USE module_mp_wdm7
239    USE module_mp_milbrandt2mom
240 # if (EM_CORE == 1)
241    USE module_mp_cammgmp_driver, ONLY: CAMMGMP ! CAM5's microphysics driver
242 # endif
243 !  USE module_mp_milbrandt3mom
244    USE module_mp_nssl_2mom
246    USE module_mixactivate, only: prescribe_aerosol_mixactivate
248 ! For checking model timestep is history time (for radar reflectivity)
249    USE module_utility, ONLY: WRFU_Clock, WRFU_Alarm
250    USE module_domain, ONLY : HISTORY_ALARM, Is_alarm_tstep
251    USE module_irrigation
253    USE module_fire_emis
255 !----------------------------------------------------------------------
256    ! This driver calls subroutines for the microphys.
257    !
258    ! Schemes
259    !
260    ! Kessler scheme
261    ! Lin et al. (1983), Rutledge and Hobbs (1984)
262    ! WRF Single-Moment 3-class, Hong, Dudhia and Chen (2004)
263    ! WRF Single-Moment 5-class, Hong, Dudhia and Chen (2004)
264    ! WRF Single-Moment 6-class, Lim and Hong (2003 WRF workshop)
265    ! Eta Grid-scale Cloud and Precipitation scheme (EGCP01, Ferrier)
266    !   * etampnew - what's in the operational 4-km High-Resolution Window Runs
267    ! Goddard 4-ice scheme (2016)
268    ! Thompson (2008)
269    ! Milbrandt and Yau (2005)
270    ! Morrison (2009)
271    ! CAM
272    ! SBU-YLin (2011)
273    ! WRF Double-Moment 5-class
274    ! WRF Double-Moment 6-class
276 !----------------------------------------------------------------------
277    IMPLICIT NONE
278 !======================================================================
279 ! Grid structure in physics part of WRF
280 !----------------------------------------------------------------------
281 ! The horizontal velocities used in the physics are unstaggered
282 ! relative to temperature/moisture variables. All predicted
283 ! variables are carried at half levels except w, which is at full
284 ! levels. Some arrays with names (*8w) are at w (full) levels.
286 !----------------------------------------------------------------------
287 ! In WRF, kms (smallest number) is the bottom level and kme (largest
288 ! number) is the top level.  In your scheme, if 1 is at the top level,
289 ! then you have to reverse the order in the k direction.
291 !         kme      -   half level (no data at this level)
292 !         kme    ----- full level
293 !         kme-1    -   half level
294 !         kme-1  ----- full level
295 !         .
296 !         .
297 !         .
298 !         kms+2    -   half level
299 !         kms+2  ----- full level
300 !         kms+1    -   half level
301 !         kms+1  ----- full level
302 !         kms      -   half level
303 !         kms    ----- full level
305 !======================================================================
306 ! Definitions
307 !-----------
308 ! Rho_d      dry density (kg/m^3)
309 ! Theta_m    moist potential temperature (K)
310 ! Qv         water vapor    mixing ratio (kg/kg)
311 ! Qc         cloud water    mixing ratio (kg/kg)
312 ! Qr         rain water     mixing ratio (kg/kg)
313 ! Qi         cloud ice      mixing ratio (kg/kg)
314 ! Qs         snow           mixing ratio (kg/kg)
315 ! Qg         graupel        mixing ratio (kg/kg)
316 ! Qh         hail           mixing ratio (kg/kg)
317 ! Qndrop     droplet number mixing ratio (#/kg)
318 ! Qni        cloud ice number concentration (#/kg)
319 ! Qns        snow      number concentration (#/kg)
320 ! Qnr        rain      number concentration (#/kg)
321 ! Qng        graupel   number concentration (#/kg)
322 ! Qnh        hail      number concentration (#/kg)
324 ! Qzr        rain             reflectivity (m6/kg)
325 ! Qzi        ice              reflectivity (m6/kg)
326 ! Qzs        snow             reflectivity (m6/kg)
327 ! Qzg        graupel          reflectivity (m6/kg)
328 ! Qzh        hail             reflectivity (m6/kg)
330 ! Qvolg        graupel   particle volume (m3/kg)
333 !----------------------------------------------------------------------
334 !-- th        potential temperature    (K)
335 !-- moist_new     updated moisture array   (kg/kg)
336 !-- moist_old     Old moisture array       (kg/kg)
337 !-- rho           density of air           (kg/m^3)
338 !-- pi_phy        exner function           (dimensionless)
339 !-- p             pressure                 (Pa)
340 !-- RAINNC        grid scale precipitation (mm)
341 !-- RAINNCV       one time step grid scale precipitation (mm/step)
342 !-- SNOWNC        grid scale snow and ice (mm)
343 !-- SNOWNCV       one time step grid scale snow and ice (mm/step)
344 !-- GRAUPELNC     grid scale graupel (mm)
345 !-- GRAUPELNCV    one time step grid scale graupel (mm/step)
346 !-- HAILNC        grid scale hail (mm)
347 !-- HAILNCV       one time step grid scale hail (mm/step)
348 !-- SR            one time step mass ratio of snow to total precip
349 !-- z             Height above sea level   (m)
350 !-- dt            Time step              (s)
351 !-- G             acceleration due to gravity  (m/s^2)
352 !-- CP            heat capacity at constant pressure for dry air (J/kg/K)
353 !-- R_d           gas constant for dry air (J/kg/K)
354 !-- R_v           gas constant for water vapor (J/kg/K)
355 !-- XLS           latent heat of sublimation   (J/kg)
356 !-- XLV           latent heat of vaporization  (J/kg)
357 !-- XLF           latent heat of melting       (J/kg)
358 !-- rhowater      water density                      (kg/m^3)
359 !-- rhosnow       snow density               (kg/m^3)
360 !-- F_ICE_PHY     Fraction of ice.
361 !-- F_RAIN_PHY    Fraction of rain.
362 !-- F_RIMEF_PHY   Mass ratio of rimed ice (rime factor)
363 !-- t8w           temperature at layer interfaces
364 !-- cldfra, cldfra_old, current, previous cloud fraction
365 !-- exch_h        vertical diffusivity (m2/s)
366 !-- qlsink        Fractional cloud water sink (/s)
367 !-- precr         rain precipitation rate at all levels (kg/m2/s)
368 !-- preci         ice precipitation rate at all levels (kg/m2/s)
369 !-- precs         snow precipitation rate at all levels (kg/m2/s)
370 !-- precg         graupel precipitation rate at all levels (kg/m2/s)                             &
371 !-- P_QV          species index for water vapor
372 !-- P_QC          species index for cloud water
373 !-- P_QR          species index for rain water
374 !-- P_QI          species index for cloud ice
375 !-- P_QS          species index for snow
376 !-- P_QG          species index for graupel
377 !-- P_QH          species index for hail
378 !-- P_QNDROP      species index for cloud drop mixing ratio
379 !-- P_QNR         species index for rain number concentration,
380 !-- P_QNI         species index for cloud ice number concentration
381 !-- P_QNS         species index for snow number concentration,
382 !-- P_QNG         species index for graupel number concentration,
383 !-- P_QNH         species index for hail number concentration,
384 !-- P_QZR         species index for rain    reflectivity
385 !-- P_QZI         species index for ice     reflectivity
386 !-- P_QZS         species index for snow    reflectivity
387 !-- P_QZG         species index for graupel reflectivity
388 !-- P_QZH         species index for hail    reflectivity
389 !-- P_QVOLG       species index for graupel particle volume,
390 !-- id            grid id number
391 !-- ids           start index for i in domain
392 !-- ide           end index for i in domain
393 !-- jds           start index for j in domain
394 !-- jde           end index for j in domain
395 !-- kds           start index for k in domain
396 !-- kde           end index for k in domain
397 !-- ims           start index for i in memory
398 !-- ime           end index for i in memory
399 !-- jms           start index for j in memory
400 !-- jme           end index for j in memory
401 !-- kms           start index for k in memory
402 !-- kme           end index for k in memory
403 !-- i_start       start indices for i in tile
404 !-- i_end         end indices for i in tile
405 !-- j_start       start indices for j in tile
406 !-- j_end         end indices for j in tile
407 !-- its           start index for i in tile
408 !-- ite           end index for i in tile
409 !-- jts           start index for j in tile
410 !-- jte           end index for j in tile
411 !-- kts           start index for k in tile
412 !-- kte           end index for k in tile
413 !-- num_tiles     number of tiles
414 !-- diagflag      Logical to tell us when to produce diagnostics for history or restart
416 !======================================================================
417   INTEGER,parameter :: iunit=6
418   INTEGER :: mpi_error_code=1
420    TYPE(grid_config_rec_type),  INTENT(IN   ) , OPTIONAL   :: config_flags
421    INTEGER,    INTENT(IN   )    :: mp_physics
422    LOGICAL,    INTENT(IN   )    :: specified
423    INTEGER, OPTIONAL, INTENT(IN   )    :: chem_opt, progn
424    INTEGER, OPTIONAL, INTENT(IN   )    :: hail, ice2 !, ccntype
426    INTEGER,      INTENT(IN   )    ::       ids,ide, jds,jde, kds,kde
427    INTEGER,      INTENT(IN   )    ::       ims,ime, jms,jme, kms,kme,num_scalar
428 #if (EM_CORE == 1)
429    INTEGER,      INTENT(IN   )    ::     num_sbmradar
430    INTEGER,      INTENT(IN   )    ::     sbm_diagnostics
431 #endif
432    INTEGER, OPTIONAL, INTENT(IN   )    ::       ips,ipe, jps,jpe, kps,kpe
433    INTEGER,      INTENT(IN   )    ::                         kts,kte
434    INTEGER,      INTENT(IN   )    ::     itimestep,num_tiles,spec_zone
435    INTEGER, DIMENSION(num_tiles), INTENT(IN) ::                       &
436      &           i_start,i_end,j_start,j_end
438    LOGICAL,      INTENT(IN   )    ::   warm_rain
440    REAL, DIMENSION( ims:ime , kms:kme , jms:jme ),                    &
441          INTENT(INOUT) ::                                         th
445    REAL, DIMENSION( ims:ime , kms:kme , jms:jme ),                    &
446          INTENT(IN   ) ::                                             &
447                                                                  rho, &
448                                                                 dz8w, &
449                                                                  p8w, &
450                                                               pi_phy, &
451                                                                    p
452 !NUWRF JJS 20101021   vvvvv
453    REAL, DIMENSION( ims:ime , kms:kme , jms:jme ),                    &
454          INTENT(INOUT), OPTIONAL ::                        phys_tot,  &
455                                                            physc,     &
456                                                            physe,     &
457                                                            physd,     &
458                                                            physs,     &
459                                                            physm,     &
460                                                            physf,     &
461                                                            acphys_tot,  &
462                                                            acphysc,     &
463                                                            acphyse,     &
464                                                            acphysd,     &
465                                                            acphyss,     &
466                                                            acphysm,     &
467                                                            acphysf
469 !NUWRF JJS 20101021   ^^^^^
470 !NUWRF JJS 20140225  vvvvv
471   REAL, DIMENSION( ims:ime , kms:kme , jms:jme ),                 &
472         INTENT(INOUT), OPTIONAL ::                     re_cloud_gsfc,   &
473                                                        re_rain_gsfc,    &
474                                                        re_ice_gsfc,     &
475                                                        re_snow_gsfc,    &
476                                                        re_graupel_gsfc, &
477                                                        re_hail_gsfc
478    REAL, DIMENSION( ims:ime , kms:kme , jms:jme ),                    &
479          OPTIONAL,          &
480          INTENT(INOUT) ::   &
481          precr3d, & ! rain precipitation rate at all levels (kg/m2/s)
482          preci3d, & ! ice precipitation rate at all levels (kg/m2/s)
483          precs3d, & ! snow precipitation rate at all levels (kg/m2/s)
484          precg3d, & ! graupel precipitation rate at all levels (kg/m2/s)
485          prech3d    ! graupel precipitation rate at all levels (kg/m2/s)
486 !NUWRF JJS 20140225  ^^^^^
488     REAL, DIMENSION( ims:ime , kms:kme , jms:jme ),INTENT(INOUT), OPTIONAL :: th_old,qv_old
489     REAL,DIMENSION(ims:ime,kms:kme,jms:jme,num_scalar),INTENT(INOUT), OPTIONAL   :: scalar
490 #if (EM_CORE == 1)
491     REAL, DIMENSION(ims:ime,kms:kme,jms:jme,num_sbmradar),INTENT(INOUT) :: sbmradar
492 #endif
493     INTEGER, DIMENSION( ims:ime , jms:jme ), INTENT(IN), OPTIONAL::   IVGTYP
494     REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN), OPTIONAL    :: XLAT, XLONG
496 !=================
497 !Data for CAMMGMP scheme
498    REAL,INTENT(IN), OPTIONAL ::accum_mode,aitken_mode,coarse_mode  
499 !1D variables required for CAMMGMP scheme
500    REAL , DIMENSION( kms:kme ) ,                                      &
501         INTENT(IN   ) , OPTIONAL ::                                        fnm,  & !Factors for interpolation at "w" grid (interfaces)
502                                                                 fnp     
503 !2D variables required for CAMMGMP scheme
504    REAL, DIMENSION( ims:ime, jms:jme ),                               &
505         INTENT(IN), OPTIONAL ::                                                 &
506                                                                  qfx, &    !Moisture flux at surface (kg m-2 s-1)
507                                                                  rliq      !Vertically-integrated reserved cloud condensate(m/s)
509 ! WRF-Solar EPS
510    integer, intent (in), optional :: multi_perturb 
511    logical, intent (in), optional :: pert_thom
512    real, intent (in), optional :: pert_thom_qv, pert_thom_qc, pert_thom_qi, pert_thom_qs, pert_thom_ni
513    real, dimension(ims:ime, kms:kme, jms:jme ), intent (in), optional :: perts_qvapor, perts_qcloud, perts_qice, &
514        perts_qsnow, perts_ni 
515   real, dimension(:, :, :), allocatable :: qv_tmp, qc_tmp, qi_tmp, qs_tmp, qni_tmp
517  !3D variables required for CAMMGMP scheme
518  REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                        &
519       INTENT(IN), OPTIONAL ::                                                   &
520                                                                  dlf, &    !Detraining cloud water tendendcy
521                                                                 dlf2, &    !dq/dt due to export of cloud water into env by shal conv (kg/kg/s)
522                                                                t_phy, &    !Temprature at the mid points (K)
523                                                                p_hyd, &    !Hydrostatic pressure(Pa)
524                                                              p8w_hyd, &    !Hydrostatic Pressure at level interface (Pa)
525                                                            z_at_mass, &    !Height above sea level at grid cell center (m)
526                                                               z_at_w, &    !Height above sea level at layer interfaces (m) 
527                                                              tke_pbl, &    !Turbulence kinetic energy
528                                                                 pblh, &    !Planetary boundary layer height (m)
529                                                           turbtype3d, &    !Turbulent interface types [ no unit ]
530                                                               smaw3d, &    !Normalized Galperin instability function for momentum [no units]
531                                                                  alt, &    !inverse density(m3/kg)
532                                                            icwmrsh3d, &    !Shallow cumulus in-cloud water mixing ratio (kg/m2)
533                                                            icwmrdp3d, &    !Deep Convection in-cloud water mixing ratio (kg/m2)
534                                                              shfrc3d, &    !Shallow cloud fraction
535                                                              cmfmc3d, &    !Deep + Shallow Convective mass flux [ kg /s/m^2 ]
536                                                            cmfmc2_3d       !Shallow convective mass flux [ kg/s/m^2 ]
537 #if ( WRF_CHEM == 1 )
538 !4D variables required for CAMMGMP scheme
539  REAL, OPTIONAL, DIMENSION( ims:ime, kms:kme, jms:jme,ntot_amode_cam_mam ),     &
540         INTENT(IN) ::                                                 &
541                                                              dgnum4D, &
542                                                           dgnumwet4D 
543 #endif
544 !In-outs
545  REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                        &
546       INTENT(INOUT) , OPTIONAL ::                                                &
547                                                        cldfra_old_mp, &    !Old Cloud fraction for CAMMGMP microphysics only
548                                                            rh_old_mp, &    !Old RH
549                                                           lcd_old_mp       !Old liquid cloud fraction
550 !In-outs -optional
551 #if ( WRF_CHEM == 1 )
552  REAL, OPTIONAL, DIMENSION( ims:ime, kms:kme, jms:jme, num_chem),     &
553       INTENT(INOUT) ::                                                &
554                                                                  chem      !Chem array for CAMMGMP scheme Prognostic aerosols      
555 #endif
556 !outs
557 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                        &
558       INTENT(INOUT) , OPTIONAL::                                                 &
559                                                             wsedl3d, &    !Sedimentation velocity of stratiform liquid cloud droplet (m/s) 
560                                                           cldfra_mp, &    !Old Cloud fraction for CAMMGMP microphysics only
561                                                       cldfra_mp_all, &    !Old Cloud fraction for CAMMGMP microphysics only
562                                                             cldfrai, &    !Old Cloud fraction for CAMMGMP microphysics only
563                                                             cldfral, &    !Old Cloud fraction for CAMMGMP microphysics only
564                                                             lradius, &    !Old Cloud fraction for CAMMGMP microphysics only
565                                                             iradius, &    !Old Cloud fraction for CAMMGMP microphysics only                                                            
566                                                         cldfra_conv 
570 #if ( WRF_CHEM == 1 )
571 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                        &
572       INTENT(INOUT), OPTIONAL ::                                                 &
573                                                               qme3d, &     !Net condensation rate (kg/kg/s)
574                                                             prain3d, &     !Rate of conversion of condensate to precipitation (kg/kg/s)
575                                                            nevapr3d, &     !Evaporation rate of rain + snow (kg/kg/s)
576                                                 rate1ord_cw2pr_st3d        !1st order rate for direct conversion of strat. cloud water to precip (1/s)
577 #endif
579    REAL, INTENT(INOUT),  DIMENSION(ims:ime, kms:kme, jms:jme ) ::     &
580                                      F_ICE_PHY,F_RAIN_PHY,F_RIMEF_PHY
581 !!$#if ( WRF_CHEM == 1 )
582 !  REAL, INTENT(OUT), DIMENSION(ims:ime, kms:kme, jms:jme ) ::     &
583    REAL, OPTIONAL, INTENT(OUT), DIMENSION(ims:ime, kms:kme, jms:jme ) ::     &
584 !!$#else
585 !!$  REAL, DIMENSION(ims:ime, kms:kme, jms:jme ) ::     &
586 !!$#endif
587          qlsink, & ! cloud water sink (/s)
588          precr, & ! rain precipitation rate at all levels (kg/m2/s)
589          preci, & ! ice precipitation rate at all levels (kg/m2/s)
590          precs, & ! snow precipitation rate at all levels (kg/m2/s)
591          precg    ! graupel precipitation rate at all levels (kg/m2/s)
595    REAL , DIMENSION( ims:ime , jms:jme ) , INTENT(IN)   :: XLAND
596    REAL , DIMENSION( ims:ime , jms:jme ) , INTENT(IN), OPTIONAL   :: SNOWH
598    REAL , DIMENSION( ims:ime , jms:jme ) , INTENT(OUT)   :: SR
600    REAL, INTENT(IN   ) :: dt,dx,dy
602    INTEGER, DIMENSION( ims:ime , jms:jme ), INTENT(INOUT) :: LOWLYR
605 ! Optional
607    REAL, OPTIONAL, DIMENSION( ims:ime , kms:kme, jms:jme ) , INTENT(OUT) :: refl_10cm
608    REAL, OPTIONAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: &  ! for ntu3m
609                    qdcn_curr,qtcn_curr,qccn_curr,qrcn_curr,qnin_curr,   &  ! for ntu3m
610                    fi_curr,fs_curr,vi_curr,vs_curr,vg_curr,ai_curr,     &  ! for ntu3m
611                    as_curr,ag_curr,ah_curr,i3m_curr                        ! for ntu3m
612    LOGICAL, OPTIONAL :: f_qdcn,f_qtcn,f_qccn,f_qrcn,f_qnin,f_fi,f_fs,   &  ! for ntu3m
613                         f_vi,f_vs,f_vg,f_ai,f_as,f_ag,f_ah,f_i3m           ! for ntu3m
614    REAL, OPTIONAL, DIMENSION( ims:ime , kms:kme, jms:jme ) , INTENT(OUT) :: vmi3d,di3d,rhopo3d,    & ! for P3
615                                                                          vmi3d_2,di3d_2,rhopo3d_2,  & ! for P3
616                                                                          phii3d,         & ! for Jensen ISHMAEL
617                                                                          phii3d_2,       & ! for Jensen ISHMAEL
618                                                                          vmi3d_3,di3d_3,rhopo3d_3,  & ! for Jensen ISHMAEL
619                                                                          phii3d_3,       & ! for Jensen ISHMAEL
620                                                                          itype,itype_2,itype_3             ! for Jensen ISHMAEL
621    LOGICAL,  OPTIONAL,   INTENT(IN   )    :: channel_switch
622    REAL, OPTIONAL,  INTENT(INOUT   ) :: naer  ! aerosol number concentration (/kg)
623    REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) , OPTIONAL :: qnwfa2d, qnifa2d, qnbca2d, &
624                                                                     qnocbb2d, qnbcbb2d
625    REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                  &
626          OPTIONAL,                                                &
627          INTENT(INOUT ) ::                                        &
628                   u,v,w, z, t8w                                       &
629                  ,cldfra, cldfra_old, exch_h                      &
630                  ,qv_curr,qc_curr,qr_curr,qi_curr,qs_curr,qg_curr &
631                  ,qt_curr,qndrop_curr,qni_curr,qh_curr,qnh_curr   &
632                  ,qns_curr,qnr_curr,qng_curr,qnn_curr,qnc_curr    &
633                  ,qic_curr,qip_curr,qid_curr &
634                  ,qnic_curr,qnip_curr,qnid_curr &
635                  ,qzr_curr,qzi_curr,qzs_curr,qzg_curr,qzh_curr    &
636                  ,qir_curr,qib_curr                               & ! for P3
637                  ,qi2_curr,qni2_curr,qir2_curr,qib2_curr          & ! for P3
638                  ,qvoli_curr,qaoli_curr                           & ! for Jensen ISHMAEL
639                  ,qvoli2_curr,qaoli2_curr                         & ! for Jensen ISHMAEL
640                  ,qi3_curr,qni3_curr,qvoli3_curr,qaoli3_curr      & ! for Jensen ISHMAEL
641                  ,effr_curr,ice_effr_curr,tot_effr_curr           &
642                  ,qic_effr_curr,qip_effr_curr,qid_effr_curr           &
643                  ,kext_ql,kext_qs,kext_qg          &
644                  ,kext_qh,kext_qa                       &
645                  ,kext_qic,kext_qip,kext_qid,tempc,height      &
646                  ,kext_ft_qic,kext_ft_qip,kext_ft_qid &
647                  ,kext_ft_qs,kext_ft_qg                           &
648                  ,qnwfa_curr,qnifa_curr,qnbca_curr                & ! Added by G. Thompson
649                  ,qvolg_curr,qvolh_curr, qrimef_curr
651    REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                  &
652          OPTIONAL,                                                &
653          INTENT(IN) :: qrcuten, qscuten, qicuten, qccuten
654    INTEGER, INTENT(IN), optional ::     cu_used
655 #if ( WRF_CHEM == 1 )
656    REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                  &
657          INTENT(INOUT) :: rainprod, evapprod
658    REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                  &
659          INTENT(INOUT) :: qv_b4mp, qc_b4mp, qi_b4mp, qs_b4mp
660 #endif
661 ! YLIN
662 ! Added RI_CURR similar to microphysics fields above
663    REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                  &
664          OPTIONAL,                                                &
665          INTENT(INOUT) :: ri_curr
668    REAL, DIMENSION(ims:ime, kms:kme, jms:jme ),                   &
669          OPTIONAL,                                                &
670          INTENT(OUT ) ::                                          &
671                   nsource
674    REAL, DIMENSION( ims:ime , jms:jme ),                          &
675          INTENT(INOUT),                                           &
676          OPTIONAL   ::                                            &
677                                                            RAINNC &
678                                                          ,RAINNCV &
679                                                           ,SNOWNC &
680                                                          ,SNOWNCV &
681                                                        ,GRAUPELNC &
682                                                       ,GRAUPELNCV &
683                                                           ,HAILNC &
684                                                           ,HAILNCV
685                                                           
686 #if ( WRF_CHEM == 1)
687 ! NUWRF JJS 20110525 vvvvv
688 ! for inline Gocart coupling
689  integer :: i24h
690  INTEGER, PARAMETER :: num_go = 14  ! number of the gocart aerosol species
691  REAL, DIMENSION( ims:ime, kms:kme, jms:jme, num_go) :: aero
692  REAL, DIMENSION( ims:ime, kms:kme, jms:jme), INTENT(OUT) :: icn_diag
693  REAL, DIMENSION( ims:ime, kms:kme, jms:jme), INTENT(OUT) :: nc_diag
694  integer, intent(in) :: gsfcgce_gocart_coupling ! EMK
695  REAL, PARAMETER :: frac(4)=(/ 0.01053,0.08421,0.25263,0.65263 /) !fraction for fine dust
697 ! NUWRF JJS 20110525 ^^^^^
698 #endif
702    INTEGER,OPTIONAL,INTENT(IN   )    ::                        id
704    REAL , DIMENSION( ims:ime , jms:jme ) , OPTIONAL ,             &
705          INTENT(IN)   ::                                       ht
707    REAL, DIMENSION (:), OPTIONAL, INTENT(INOUT) :: mp_restart_state &
708                                          ,tbpvs_state,tbpvs0_state
711    LOGICAL, OPTIONAL :: f_qv,f_qc,f_qr,f_qi,f_qs,f_qg,f_qndrop,f_qni,f_qt    &
712                        ,f_qns,f_qnr,f_qng,f_qnn,f_qnc,f_qh,f_qnh,f_qzr       &
713                       ,f_effr,f_ice_effr,f_tot_effr &
714                        ,f_qic_effr,f_qip_effr,f_qid_effr &
715                       ,f_qic,f_qip,f_qid &
716                       ,f_qnic,f_qnip,f_qnid                                  &
717                        ,f_qzi,f_qzs,f_qzg,f_qzh,f_qvolg,f_qvolh              &
718                        ,f_qrimef                                             &
719                        ,f_qir,f_qib                                          & ! for P3
720                        ,f_qi2,f_qni2,f_qir2,f_qib2                           & ! for P3
721                        ,f_qvoli,f_qaoli                                      & ! for Jensen ISHMAEL
722                        ,f_qvoli2,f_qaoli2                                    & ! for Jensen ISHMAEL
723                        ,f_qi3,f_qni3,f_qvoli3,f_qaoli3                       & ! for Jensen ISHMAEL
724                        ,f_qnwfa, f_qnifa, f_qnbca                         ! Added by G. Thompson
727    LOGICAL, OPTIONAL, INTENT(IN) :: diagflag
728    INTEGER, OPTIONAL, INTENT(IN) :: ke_diag ! tells reflectivity calculation whether to do full depth or only k=1
729    REAL, INTENT(IN) :: ccn_conc ! RAS
730    INTEGER, OPTIONAL, INTENT(IN) :: do_radar_ref
731    REAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) ::  & ! G. Thompson
732                  re_cloud, re_ice, re_snow
733    INTEGER, INTENT(IN):: has_reqc, has_reqi, has_reqs
735   INTEGER,           INTENT(IN   )    :: aercu_opt
736 # if (EM_CORE == 1)
737   INTEGER, OPTIONAL, INTENT(IN   )    :: PBL
738   INTEGER,           INTENT(IN   )    :: no_src_types_cu
739   REAL,              INTENT(IN   )    :: aercu_fct
740   REAL,    OPTIONAL, DIMENSION( ims:ime, kms:kme, jms:jme, no_src_types_cu), INTENT(INOUT) & 
741                                       :: aerocu
742   REAL,    OPTIONAL, DIMENSION( ims:ime, kms:kme, jms:jme), INTENT(INOUT) &
743                                       :: EFCG,           &
744                                          EFIG,           &
745                                          EFSG,           &
746                                          WACT,           &
747                                          CCN1_GS,        &
748                                          CCN2_GS,        &
749                                          CCN3_GS,        &
750                                          CCN4_GS,        &
751                                          CCN5_GS,        &
752                                          CCN6_GS,        &
753                                          CCN7_GS,        &
754                                          NR_CU,          &
755                                          QR_CU,          &
756                                          NS_CU,          &
757                                          QS_CU
758    REAL,   OPTIONAL, DIMENSION( ims:ime, jms:jme), INTENT(INOUT) &
759                                       :: CU_UAF
760    REAL, OPTIONAL, DIMENSION( ims:ime , kms:kme, jms:jme ) , INTENT(OUT) :: mskf_refl_10cm
761 # endif
763 !  REAL , DIMENSION( ims:ime , jms:jme ), OPTIONAL, INTENT(INOUT) :: lwp
765 ! LOCAL  VAR
767    INTEGER :: i,j,k,its,ite,jts,jte,ij,sz,n
768    LOGICAL :: channel
769    LOGICAL :: nssl_progn = .false.
770    REAL    :: z0, z1, z2, w1, w2
772    integer, parameter :: ntot = 50
773    real :: wmin, wmax
774    integer :: ierr
775 ! IRRIGATION
777    REAL, DIMENSION( ims:ime , jms:jme ), OPTIONAL, INTENT(IN):: IRRIGATION !ARI
778    REAL,  OPTIONAL, INTENT(IN)::  irr_daily_amount, julian_in, xtime, gmt
779    INTEGER, OPTIONAL, INTENT(IN ):: sf_surf_irr_scheme, irr_start_hour, irr_num_hours, &
780                                     irr_start_julianday,irr_end_julianday,irr_freq,irr_ph
781    REAL, PARAMETER    :: PI_GRECO=3.14159
782    INTEGER  :: end_hour,a,b,xt24,irr_day,timing
783    REAL :: constants_irrigation,tloc,irr_start,phase
784    INTEGER, OPTIONAL, DIMENSION( ims:ime , jms:jme ), INTENT(INOUT) :: irr_rand_field
786 !---------------------------------------------------------------------
787 !  check for microphysics type.  We need a clean way to
788 !  specify these things!
789 !---------------------------------------------------------------------
791    channel = .FALSE.
792    IF ( PRESENT ( channel_switch ) ) channel = channel_switch
794    if (mp_physics .eq. 0) return
795    IF( specified ) THEN
796      sz = spec_zone
797    ELSE
798      sz = 0
799    ENDIF
801 ! set this to true to print out the global max/min for W on each time step.
802    IF ( .false. ) THEN
803       wmax = maxval( w(ips:ipe,kps:kpe,jps:jpe) )
804       wmin = minval( w(ips:ipe,kps:kpe,jps:jpe) )
805 #if ( defined(DM_PARALLEL)  &&   ! defined(STUBMPI) )
806       wmax = wrf_dm_max_real ( wmax )
807       wmin = wrf_dm_min_real ( wmin )
808 #endif
809       WRITE( wrf_err_message , * ) 'microphysics_driver: GLOBAL w max/min = ', wmax, wmin
810       CALL wrf_message ( wrf_err_message )
811    ENDIF
813 #ifdef XEON_OPTIMIZED_WSM5
814    ! the OpenMP loops are inside the scheme when running on MIC
815    IF ( mp_physics .EQ. WSM5SCHEME ) THEN
816        IF (channel) THEN
817          its = max(ips,ids)
818          ite = min(ipe,ide-1)
819        ELSE
820          its = max(ips,ids+sz)
821          ite = min(ipe,ide-1-sz)
822        ENDIF
823        jts = max(jps,jds+sz)
824        jte = min(jpe,jde-1-sz)
826        CALL wsm5(                                              &
827              TH=th                                             &
828             ,Q=qv_curr                                         &
829             ,QC=qc_curr                                        &
830             ,QR=qr_curr                                        &
831             ,QI=qi_curr                                        &
832             ,QS=qs_curr                                        &
833             ,DEN=rho,PII=pi_phy,P=p,DELZ=dz8w                  &
834             ,DELT=dt,G=g,CPD=cp,CPV=cpv                        &
835             ,RD=r_d,RV=r_v,T0C=svpt0                           &
836             ,EP1=ep_1, EP2=ep_2, QMIN=epsilon                  &
837             ,XLS=xls, XLV0=xlv, XLF0=xlf                       &
838             ,DEN0=rhoair0, DENR=rhowater                       &
839             ,CLIQ=cliq,CICE=cice,PSAT=psat                     &
840             ,RAIN=rainnc ,RAINNCV=rainncv                      &
841             ,SNOW=snownc ,SNOWNCV=snowncv                      &
842             ,SR=sr                                             &
843             ,REFL_10CM=refl_10cm                               &
844             ,diagflag=diagflag                                 &
845             ,do_radar_ref=do_radar_ref                         &
846             ,has_reqc=has_reqc                                 &  ! for radiation +
847             ,has_reqi=has_reqi                                 &
848             ,has_reqs=has_reqs                                 &
849             ,re_cloud=re_cloud                                 &
850             ,re_ice=re_ice                                     &
851             ,re_snow=re_snow                                   &  ! for radiation -  
852             ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
853             ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
854             ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
855             )
857    ELSE
858 #endif
860    !$OMP PARALLEL DO   &
861    !$OMP PRIVATE ( ij, its, ite, jts, jte, i,j,k,n )
863    DO ij = 1 , num_tiles
864        IF (channel) THEN
865          its = max(i_start(ij),ids)
866          ite = min(i_end(ij),ide-1)
867        ELSE
868          its = max(i_start(ij),ids+sz)
869          ite = min(i_end(ij),ide-1-sz)
870        ENDIF
871        jts = max(j_start(ij),jds+sz)
872        jte = min(j_end(ij),jde-1-sz)
874 # if( EM_CORE==1 )
875        sf_surf_irr: SELECT CASE(sf_surf_irr_scheme)
876             CASE(SPRINKLER)
877              CALL sprinkler_irrigation(  julian_in                    & 
878      &          ,irrigation, irr_daily_amount,rho,dz8w                & 
879      &          ,irr_start_hour,irr_num_hours,irr_start_julianday     & 
880      &          ,irr_end_julianday,irr_freq,irr_ph,qr_curr            &
881      &          ,gmt,xtime,dt,irr_rand_field                          &
882      &          ,ids,ide, jds,jde                                     & ! domain dims
883      &          ,ims,ime, jms,jme, kms,kme                            & ! memory dims
884      &          ,its,ite, jts,jte               )
885        END SELECT sf_surf_irr
886 #endif
890 ! 2009-06009 rce - zero all these for safety
891        IF( PRESENT(qlsink) ) qlsink(its:ite,kts:kte,jts:jte) = 0.
892        IF( PRESENT(precr ) ) precr(its:ite,kts:kte,jts:jte)  = 0.
893        IF( PRESENT(preci ) ) preci(its:ite,kts:kte,jts:jte)  = 0.
894        IF( PRESENT(precs ) ) precs(its:ite,kts:kte,jts:jte)  = 0.
895        IF( PRESENT(precg ) ) precg(its:ite,kts:kte,jts:jte)  = 0.
897 !-----------
898        IF( PRESENT(chem_opt) .AND. PRESENT(progn) ) THEN
899        
900        ! ERM: check whether to use built-in droplet nucleation or use qndrop from CHEM
901        IF ( mp_physics==NSSL_2MOMCCN .or. mp_physics==NSSL_2MOM .or. mp_physics==NSSL_2MOMG ) THEN
902          IF ( progn > 0 ) THEN
903           IF ( .not. (chem_opt == 0 .or. chem_opt == 401) ) nssl_progn = .true.
904          ELSE
905            nssl_progn = .false. ! use NUCOND for droplet nucleation
906          ENDIF
907        ENDIF
908        
909        !Add pass for dust-only wrf-chem option - RAS
910        IF( (chem_opt==0 .OR. chem_opt==401) .AND. progn==1 .AND. (mp_physics==LINSCHEME  .OR. mp_physics==MORR_TWO_MOMENT)) THEN
911           IF( PRESENT( QNDROP_CURR ) ) THEN
912              CALL wrf_debug ( 100 , 'microphysics_driver: calling prescribe_aerosol_mixactivate' )
913 ! 06-nov-2005 rce - id  & itimestep added to arg list
914              call prescribe_aerosol_mixactivate (               &
915                   id, itimestep, dt, naer,                      &
916                   ccn_conc, chem_opt,                           & !RAS13.1
917                   rho, th, pi_phy, w, cldfra, cldfra_old,       &
918                   z, dz8w, p8w, t8w, exch_h,                    &
919                   qv_curr, qc_curr, qi_curr, qndrop_curr,       &
920                   nsource,                                      &
921                   ids,ide, jds,jde, kds,kde,                    &
922                   ims,ime, jms,jme, kms,kme,                    &
923                   its,ite, jts,jte, kts,kte,                    &
924                   F_QC=f_qc, F_QI=f_qi                          )
925           END IF
926        ELSEIF ( (chem_opt==0 .OR. chem_opt==401) .AND. progn==1 .AND. (mp_physics==NSSL_2MOMCCN .or.      &
927                  mp_physics==NSSL_2MOM .or. mp_physics==NSSL_2MOMG)) THEN
928 !          Do nothing here for the moment. Use activation of CCN within the NSSL_2MOM scheme instead, based on nssl_cccn namelist value.
929        ELSEIF ( progn==1 .AND. mp_physics/=LINSCHEME .AND. mp_physics/=MORR_TWO_MOMENT &
930                 .AND. mp_physics/=NSSL_2MOM .AND. mp_physics/=NSSL_2MOMCCN .AND. mp_physics/=NSSL_2MOMG ) THEN
931              call wrf_error_fatal( &
932              "SETTINGS ERROR: Prognostic cloud droplet number can only be used with the mp_physics=LINSCHEME or MORRISON or NSSL_2MOM.")
933        END IF
934        END IF
936 #if ( WRF_CHEM == 1)
937 !NUWRF JJS 20110525 vvvvv
938 ! Pack gocart aerosol species
939 ! All aerosol species in chem are in "ug/kg-dryair"
940 !  and conerted to (g/m**3)
942    aero(:,:,:,:) = 0.
943    do k = kts, kte
944       do j = jts, jte
945          do i = its, ite
946          aero(i,k,j, 1) = max(0.0, chem(i,k,j,p_sulf)*1.0e-6*p(i,k,j)*    &
947                           96.0/(8.314*th(i,k,j)*pi_phy(i,k,j)))  ! 1 = SO4
948          aero(i,k,j, 2) = max(0.0, (chem(i,k,j,p_bc1)+chem(i,k,j,p_bc2))*1.0e-6*rho(i,k,j))  ! 2 = BC1+BC2
949          aero(i,k,j, 3) = max(0.0, chem(i,k,j,p_oc1)*1.0e-6*rho(i,k,j)*1.4e0)          !  3 = OC1
950          aero(i,k,j, 4) = max(0.0, chem(i,k,j,p_oc2)*1.0e-6*rho(i,k,j)*1.4e0)          !  4 = OC2
951          aero(i,k,j, 5) = max(0.0, chem(i,k,j,p_seas_1)*1.0e-6*rho(i,k,j))           !  5 = SS1
952          aero(i,k,j, 6) = max(0.0, (chem(i,k,j,p_seas_2)+chem(i,k,j,p_seas_3)+  &
953                                    chem(i,k,j,p_seas_4))*1.0e-6*rho(i,k,j))          !  6 = SS2+SS3+SS4
954          aero(i,k,j, 7) = max(0.0, chem(i,k,j,p_dust_1)*1.0e-6*rho(i,k,j)*frac(1))   !  7 = DU1 dust mode 1
955          aero(i,k,j, 8) = max(0.0, chem(i,k,j,p_dust_1)*1.0e-6*rho(i,k,j)*frac(2))   !  8 = DU1 dust mode 2
956          aero(i,k,j, 9) = max(0.0, chem(i,k,j,p_dust_1)*1.0e-6*rho(i,k,j)*frac(3))   !  9 = DU1 dust mode 3
957          aero(i,k,j,10) = max(0.0, chem(i,k,j,p_dust_1)*1.0e-6*rho(i,k,j)*frac(4))   ! 10 = DU1 dust mode 4
958          aero(i,k,j,11) = max(0.0, chem(i,k,j,p_dust_2)*1.0e-6*rho(i,k,j))           ! 11 = DU2 dust mode 5
959          aero(i,k,j,12) = max(0.0, chem(i,k,j,p_dust_3)*1.0e-6*rho(i,k,j))           ! 11 = DU3 dust mode 6
960          aero(i,k,j,13) = max(0.0, chem(i,k,j,p_dust_4)*1.0e-6*rho(i,k,j))           ! 11 = DU4 dust mode 7
961          aero(i,k,j,14) = max(0.0, chem(i,k,j,p_dust_5)*1.0e-6*rho(i,k,j))           ! 11 = DU5 dust mode 8
962          enddo ! !
963       enddo ! j
964    enddo ! k
965 !NUWRF JJS 20110525 ^^^^^
966 #endif
968      micro_select: SELECT CASE(mp_physics)
970         CASE (KESSLERSCHEME)
971              CALL wrf_debug ( 100 , 'microphysics_driver: calling kessler' )
972              IF ( PRESENT( QV_CURR ) .AND. PRESENT( QC_CURR ) .AND.  &
973                                            PRESENT( QR_CURR ) .AND.  &
974                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV ) .AND.  &
975                                            PRESENT( Z       ))  THEN
976                CALL kessler(                                        &
977                   T=th                                              &
978                  ,QV=qv_curr                                        &
979                  ,QC=qc_curr                                        &
980                  ,QR=qr_curr                                        &
981                  ,RHO=rho, PII=pi_phy,DT_IN=dt, Z=z, XLV=xlv, CP=cp &
982                  ,EP2=ep_2,SVP1=svp1,SVP2=svp2                      &
983                  ,SVP3=svp3,SVPT0=svpt0,RHOWATER=rhowater           &
984                  ,DZ8W=dz8w                                         &
985                  ,RAINNC=rainnc,RAINNCV=rainncv                     &
986                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
987                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
988                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
989                                                                     )
990              ELSE
991                 CALL wrf_error_fatal ( 'arguments not present for calling kessler' )
992              ENDIF
993 #if ( WRFPLUS == 1 )
994         CASE (MKESSLERSCHEME)
995              CALL wrf_debug ( 100 , 'microphysics_driver: calling mkessler' )
996              IF ( PRESENT( QV_CURR ) .AND. PRESENT( QC_CURR ) .AND.  &
997                                            PRESENT( QR_CURR ) .AND.  &
998                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV ) .AND.  &
999                                            PRESENT( Z       ))  THEN
1000                CALL mkessler(                                        &
1001                   T=th                                              &
1002                  ,QV=qv_curr                                        &
1003                  ,QC=qc_curr                                        &
1004                  ,QR=qr_curr                                        &
1005 !whl P is not recomputed in the HL' Kessler; need be added here
1006                  ,P=p                                               &
1007 !end whl
1008                  ,RHO=rho, PII=pi_phy,DT_IN=dt, Z=z, XLV=xlv, CP=cp &
1009                  ,EP2=ep_2,SVP1=svp1,SVP2=svp2                      &
1010                  ,SVP3=svp3,SVPT0=svpt0,RHOWATER=rhowater           &
1011                  ,DZ8W=dz8w                                         &
1012                  ,RAINNC=rainnc,RAINNCV=rainncv                     &
1013                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
1014                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
1015                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
1016                                                                     )
1017              ELSE
1018                 CALL wrf_error_fatal ( 'arguments not present for calling mkessler' )
1019              ENDIF
1020 #endif
1022         CASE (THOMPSONAERO)
1023               if (pert_thom .and. multi_perturb == 1) then
1024                 allocate (qv_tmp(its:ite, kts:kte, jts:jte))
1025                 allocate (qc_tmp(its:ite, kts:kte, jts:jte))
1026                 allocate (qi_tmp(its:ite, kts:kte, jts:jte))
1027                 allocate (qs_tmp(its:ite, kts:kte, jts:jte))
1028                 allocate (qni_tmp(its:ite, kts:kte, jts:jte))
1030                 call Add_multi_perturb_mp_perturbations (perts_qvapor, perts_qcloud, perts_qice, &
1031                   perts_qsnow, perts_ni, pert_thom_qv, pert_thom_qc, pert_thom_qi, pert_thom_qs, &
1032                   pert_thom_ni, qv_curr, qc_curr, qi_curr, qs_curr, qni_curr, qv_tmp, qc_tmp, qi_tmp, &
1033                   qs_tmp, qni_tmp, its, ite, jts, jte, ims, ime, jms, jme, kms, kme, kts, kte)
1034               end if
1036              CALL wrf_debug ( 100 , 'microphysics_driver: calling thompson' )
1037              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR )   .AND.  &
1038                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR )   .AND.  &
1039                   PRESENT( QS_CURR ) .AND. PRESENT ( QG_CURR )   .AND.  &
1040                   PRESENT( QNR_CURR) .AND. PRESENT ( QNI_CURR)   .AND.  &
1041                   PRESENT( QNC_CURR) .AND. PRESENT ( QNWFA_CURR) .AND.  &
1042                   PRESENT( QNIFA_CURR).AND.PRESENT ( QNWFA2D)    .AND.  &
1043                   PRESENT( QNIFA2D)                              .AND.  &
1044                   PRESENT( SNOWNC)   .AND. PRESENT ( SNOWNCV)    .AND.  &
1045                   PRESENT( GRAUPELNC).AND. PRESENT ( GRAUPELNCV) .AND.  &
1046                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV ) ) THEN
1047 #if ( WRF_CHEM == 1 )
1048                  qv_b4mp(its:ite,kts:kte,jts:jte) = qv_curr(its:ite,kts:kte,jts:jte)
1049                  qc_b4mp(its:ite,kts:kte,jts:jte) = qc_curr(its:ite,kts:kte,jts:jte)
1050                  qi_b4mp(its:ite,kts:kte,jts:jte) = qi_curr(its:ite,kts:kte,jts:jte)
1051                  qs_b4mp(its:ite,kts:kte,jts:jte) = qs_curr(its:ite,kts:kte,jts:jte)
1052 #endif
1053              CALL mp_gt_driver(                          &
1054                      QV=qv_curr,                         &
1055                      QC=qc_curr,                         &
1056                      QR=qr_curr,                         &
1057                      QI=qi_curr,                         &
1058                      QS=qs_curr,                         &
1059                      QG=qg_curr,                         &
1060                      NI=qni_curr,                        &
1061                      NR=qnr_curr,                        &
1062                      NC=qnc_curr,                        &
1063                      NWFA=qnwfa_curr,                    &
1064                      NIFA=qnifa_curr,                    &
1065                      NBCA=qnbca_curr,                    &
1066                      NWFA2D=qnwfa2d,                     &
1067                      NIFA2D=qnifa2d,                     &
1068                      NBCA2D=qnbca2d,                     &
1069                      aer_init_opt=config_flags%aer_init_opt,   &
1070                      wif_input_opt=config_flags%wif_input_opt, &
1071                      TH=th,                              &
1072                      PII=pi_phy,                         &
1073                      P=p,                                &
1074                      W=w,                                &
1075                      DZ=dz8w,                            &
1076                      DT_IN=dt,                           &
1077                      ITIMESTEP=itimestep,                &
1078                      RAINNC=RAINNC,                      &
1079                      RAINNCV=RAINNCV,                    &
1080                      SNOWNC=SNOWNC,                      &
1081                      SNOWNCV=SNOWNCV,                    &
1082                      GRAUPELNC=GRAUPELNC,                &
1083                      GRAUPELNCV=GRAUPELNCV,              &
1084                      SR=SR,                              &
1085 #if ( WRF_CHEM == 1 )
1086                      WETSCAV_ON=config_flags%wetscav_onoff == 1, &
1087                      RAINPROD=rainprod,                  &
1088                      EVAPPROD=evapprod,                  &
1089 #endif
1090                      REFL_10CM=refl_10cm,                &
1091                      diagflag=diagflag,                  &
1092                      ke_diag = ke_diag,                  &
1093                      do_radar_ref=do_radar_ref,          &
1094                      re_cloud=re_cloud,                  &
1095                      re_ice=re_ice,                      &
1096                      re_snow=re_snow,                    &
1097                      has_reqc=has_reqc,                  & ! G. Thompson
1098                      has_reqi=has_reqi,                  & ! G. Thompson
1099                      has_reqs=has_reqs,                  & ! G. Thompson
1100                  IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde, &
1101                  IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme, &
1102                  ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte)
1104               if (pert_thom .and. multi_perturb == 1) then
1105                 call Remove_multi_perturb_mp_perturbations (perts_qvapor, perts_qcloud, perts_qice, &
1106                   perts_qsnow, perts_ni, pert_thom_qv, pert_thom_qc, pert_thom_qi, pert_thom_qs, &
1107                   pert_thom_ni, qv_curr, qc_curr, qi_curr, qs_curr, qni_curr, qv_tmp, qc_tmp, qi_tmp, &
1108                   qs_tmp, qni_tmp, its, ite, jts, jte, ims, ime, jms, jme, kms, kme, kts, kte)
1109                 deallocate (qv_tmp)
1110                 deallocate (qc_tmp)
1111                 deallocate (qi_tmp)
1112                 deallocate (qs_tmp)
1113                 deallocate (qni_tmp)
1114               end if
1116               IF (config_flags%aer_fire_emit_opt.gt.0)  then
1117                 CALL wrf_debug ( 200 , ' call fire_emis_simple_plumerise' )
1118                 CALL fire_emis_simple_plumerise (config_flags%wif_fire_inj, config_flags%aer_fire_emit_opt  &
1119                     ,z_at_mass, pblh, qnwfa_curr, qnbca_curr   &
1120                     ,qnocbb2d, qnbcbb2d, dt, ids, ide, jds, jde, kds, kde                    &
1121                     ,ims, ime, jms, jme, kms, kme, its, ite, jts, jte, kts, kte                       )
1122               ENDIF
1123              ELSE
1124                 CALL wrf_error_fatal ( 'arguments not present for calling thompson_et_al' )
1125              ENDIF
1127         CASE (THOMPSONGH)
1128              CALL wrf_debug ( 100 , 'microphysics_driver: calling thompsongh' )
1129              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR )   .AND.  &
1130                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR )   .AND.  &
1131                   PRESENT( QS_CURR ) .AND. PRESENT ( QG_CURR )   .AND.  &
1132                   PRESENT( QNR_CURR) .AND. PRESENT ( QNI_CURR)   .AND.  &
1133                   PRESENT( QNG_CURR) .AND. PRESENT ( QVOLG_CURR) .AND.  &
1134                   PRESENT( QNC_CURR) .AND. PRESENT ( QNWFA_CURR) .AND.  &
1135                   PRESENT( QNIFA_CURR).AND.PRESENT ( QNWFA2D)    .AND.  &
1136                   PRESENT( QNIFA2D)                              .AND.  &
1137                   PRESENT( SNOWNC)   .AND. PRESENT ( SNOWNCV)    .AND.  &
1138                   PRESENT( GRAUPELNC).AND. PRESENT ( GRAUPELNCV) .AND.  &
1139                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV ) ) THEN
1140 #if ( WRF_CHEM == 1 )
1141                  qv_b4mp(its:ite,kts:kte,jts:jte) = qv_curr(its:ite,kts:kte,jts:jte)
1142                  qc_b4mp(its:ite,kts:kte,jts:jte) = qc_curr(its:ite,kts:kte,jts:jte)
1143                  qi_b4mp(its:ite,kts:kte,jts:jte) = qi_curr(its:ite,kts:kte,jts:jte)
1144                  qs_b4mp(its:ite,kts:kte,jts:jte) = qs_curr(its:ite,kts:kte,jts:jte)
1145 #endif
1146              CALL mp_gt_driver(                          &
1147                      QV=qv_curr,                         &
1148                      QC=qc_curr,                         &
1149                      QR=qr_curr,                         &
1150                      QI=qi_curr,                         &
1151                      QS=qs_curr,                         &
1152                      QG=qg_curr,                         &
1153                      QB=qvolg_curr,                      &
1154                      NI=qni_curr,                        &
1155                      NR=qnr_curr,                        &
1156                      NC=qnc_curr,                        &
1157                      NG=qng_curr,                        &
1158                      NWFA=qnwfa_curr,                    &
1159                      NIFA=qnifa_curr,                    &
1160                      NBCA=qnbca_curr,                    &
1161                      NWFA2D=qnwfa2d,                     &
1162                      NIFA2D=qnifa2d,                     &
1163                      NBCA2D=qnbca2d,                     &
1164                      aer_init_opt=config_flags%aer_init_opt,   &
1165                      wif_input_opt=config_flags%wif_input_opt, &
1166                      TH=th,                              &
1167                      PII=pi_phy,                         &
1168                      P=p,                                &
1169                      W=w,                                &
1170                      DZ=dz8w,                            &
1171                      DT_IN=dt,                           &
1172                      ITIMESTEP=itimestep,                &
1173                      RAINNC=RAINNC,                      &
1174                      RAINNCV=RAINNCV,                    &
1175                      SNOWNC=SNOWNC,                      &
1176                      SNOWNCV=SNOWNCV,                    &
1177                      GRAUPELNC=GRAUPELNC,                &
1178                      GRAUPELNCV=GRAUPELNCV,              &
1179                      SR=SR,                              &
1180 #if ( WRF_CHEM == 1 )
1181                      WETSCAV_ON=config_flags%wetscav_onoff == 1, &
1182                      RAINPROD=rainprod,                  &
1183                      EVAPPROD=evapprod,                  &
1184 #endif
1185                      REFL_10CM=refl_10cm,                &
1186                      diagflag=diagflag,                  &
1187                      ke_diag = ke_diag,                  &
1188                      do_radar_ref=do_radar_ref,          &
1189                      re_cloud=re_cloud,                  &
1190                      re_ice=re_ice,                      &
1191                      re_snow=re_snow,                    &
1192                      has_reqc=has_reqc,                  & ! G. Thompson 
1193                      has_reqi=has_reqi,                  & ! G. Thompson 
1194                      has_reqs=has_reqs,                  & ! G. Thompson 
1195                  IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde, &
1196                  IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme, &
1197                  ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte)
1198              ELSE
1199                 CALL wrf_error_fatal ( 'arguments not present for calling thompson_et_al' )
1200              ENDIF
1202         CASE (THOMPSON)
1203              CALL wrf_debug ( 100 , 'microphysics_driver: calling thompson' )
1204              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR ) .AND.  &
1205                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR ) .AND.  &
1206                   PRESENT( QS_CURR ) .AND. PRESENT ( QG_CURR ) .AND.  &
1207                   PRESENT( QNR_CURR) .AND. PRESENT ( QNI_CURR) .AND.  &
1208 !                  PRESENT( SNOWNC) .AND. PRESENT ( SNOWNCV) .AND.        &
1209 !                  PRESENT( GRAUPELNC) .AND. PRESENT ( GRAUPELNCV) .AND.  &
1210                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV ) ) THEN
1211 #if ( WRF_CHEM == 1 )
1212                  qv_b4mp(its:ite,kts:kte,jts:jte) = qv_curr(its:ite,kts:kte,jts:jte)
1213                  qc_b4mp(its:ite,kts:kte,jts:jte) = qc_curr(its:ite,kts:kte,jts:jte)
1214                  qi_b4mp(its:ite,kts:kte,jts:jte) = qi_curr(its:ite,kts:kte,jts:jte)
1215                  qs_b4mp(its:ite,kts:kte,jts:jte) = qs_curr(its:ite,kts:kte,jts:jte)
1216 #endif
1217               if (pert_thom .and. multi_perturb == 1) then
1218                 allocate (qv_tmp(its:ite, kts:kte, jts:jte))
1219                 allocate (qc_tmp(its:ite, kts:kte, jts:jte))
1220                 allocate (qi_tmp(its:ite, kts:kte, jts:jte))
1221                 allocate (qs_tmp(its:ite, kts:kte, jts:jte))
1222                 allocate (qni_tmp(its:ite, kts:kte, jts:jte))
1224                 call Add_multi_perturb_mp_perturbations (perts_qvapor, perts_qcloud, perts_qice, &
1225                   perts_qsnow, perts_ni, pert_thom_qv, pert_thom_qc, pert_thom_qi, pert_thom_qs, &
1226                   pert_thom_ni, qv_curr, qc_curr, qi_curr, qs_curr, qni_curr, qv_tmp, qc_tmp, qi_tmp, &
1227                   qs_tmp, qni_tmp, its, ite, jts, jte, ims, ime, jms, jme, kms, kme, kts, kte)
1228               end if
1230              CALL mp_gt_driver(                          &
1231                      QV=qv_curr,                         &
1232                      QC=qc_curr,                         &
1233                      QR=qr_curr,                         &
1234                      QI=qi_curr,                         &
1235                      QS=qs_curr,                         &
1236                      QG=qg_curr,                         &
1237                      NI=qni_curr,                        &
1238                      NR=qnr_curr,                        &
1239                      TH=th,                              &
1240                      PII=pi_phy,                         &
1241                      P=p,                                &
1242                      W=w,                                &
1243                      DZ=dz8w,                            &
1244                      DT_IN=dt,                           &
1245                      ITIMESTEP=itimestep,                &
1246                      RAINNC=RAINNC,                      &
1247                      RAINNCV=RAINNCV,                    &
1248                      SNOWNC=SNOWNC,                      &
1249                      SNOWNCV=SNOWNCV,                    &
1250                      GRAUPELNC=GRAUPELNC,                &
1251                      GRAUPELNCV=GRAUPELNCV,              &
1252                      SR=SR,                              &
1253 #if ( WRF_CHEM == 1 )
1254                      WETSCAV_ON=config_flags%wetscav_onoff == 1, &
1255                      RAINPROD=rainprod,                  &
1256                      EVAPPROD=evapprod,                  &
1257 #endif
1258                      REFL_10CM=refl_10cm,                &
1259                      diagflag=diagflag,                  &
1260                      ke_diag = ke_diag,                  &
1261                      do_radar_ref=do_radar_ref,          &
1262                      re_cloud=re_cloud,                  & ! G. Thompson
1263                      re_ice=re_ice,                      & ! G. Thompson
1264                      re_snow=re_snow,                    & ! G. Thompson
1265                      has_reqc=has_reqc,                  & ! G. Thompson
1266                      has_reqi=has_reqi,                  & ! G. Thompson
1267                      has_reqs=has_reqs,                  & ! G. Thompson
1268                  IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde, &
1269                  IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme, &
1270                  ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte)
1272               if (pert_thom .and. multi_perturb == 1) then
1273                 call Remove_multi_perturb_mp_perturbations (perts_qvapor, perts_qcloud, perts_qice, & 
1274                   perts_qsnow, perts_ni, pert_thom_qv, pert_thom_qc, pert_thom_qi, pert_thom_qs, &
1275                   pert_thom_ni, qv_curr, qc_curr, qi_curr, qs_curr, qni_curr, qv_tmp, qc_tmp, qi_tmp, &
1276                   qs_tmp, qni_tmp, its, ite, jts, jte, ims, ime, jms, jme, kms, kme, kts, kte)
1277                 deallocate (qv_tmp)
1278                 deallocate (qc_tmp)
1279                 deallocate (qi_tmp)
1280                 deallocate (qs_tmp)
1281                 deallocate (qni_tmp)
1282               end if
1284              ELSE
1285                 CALL wrf_error_fatal ( 'arguments not present for calling thompson_et_al' )
1286              ENDIF
1287 #if (EM_CORE==1)
1288         CASE (NTU)
1289              CALL wrf_debug(100, 'microphysics_driver: calling ntu')
1290              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR ) .AND.    &
1291                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR ) .AND.    &
1292                   PRESENT( QS_CURR ) .AND. PRESENT ( QG_CURR ) .AND.    &
1293                   PRESENT( RAINNC )  .AND. PRESENT ( RAINNCV )) THEN   ! ....
1294                 CALL mp_ntu(ITIMESTEP=itimestep,TH=th,P=p,DZ=dz8w,      &
1295                      W=w,PII=pi_phy,DT_MP=dt,SR=sr,QV=qv_curr,          &
1296                      QC=qc_curr,QR=qr_curr,QI=qi_curr,QS=qs_curr,       &
1297                      QG=qg_curr,QH=qh_curr,NC=qnc_curr,NR=qnr_curr,     &
1298                      NI=qni_curr,NS=qns_curr,NG=qng_curr,               &
1299                      NH=qnh_curr,QDCN=qdcn_curr,QTCN=qtcn_curr,         &
1300                      QCCN=qccn_curr,QRCN=qrcn_curr,QNIN=qnin_curr,      &
1301                      FI=fi_curr,FS=fs_curr,VI=vi_curr,VS=vs_curr,       &
1302                      VG=vg_curr,AI=ai_curr,AS=as_curr,AG=ag_curr,       &
1303                      AH=ah_curr,I3M=i3m_curr,RAINNC=rainnc,             &
1304                      RAINNCV=rainncv,SNOWNC=snownc,SNOWNCV=snowncv,     &
1305                      GRAPNC=graupelnc,GRAPNCV=graupelncv,               &
1306                      HAILNC=hailnc,HAILNCV=hailncv,                     &
1307                      IDS=ids,IDE=ide,JDS=jds,JDE=jde,KDS=kds,KDE=kde,   &
1308                      IMS=ims,IME=ime,JMS=jms,JME=jme,KMS=kms,KME=kme,   &
1309                      ITS=its,ITE=ite,JTS=jts,JTE=jte,KTS=kts,KTE=kte)
1310              ELSE
1311                 Call wrf_error_fatal( 'arguments not present for calling ntu')
1312              ENDIF
1313 #endif
1314 #if (EM_CORE==1)
1315 # if ( BUILD_SBM_FAST == 1 )
1316        CASE (FAST_KHAIN_LYNN_SHPUND)
1317              CALL wrf_debug ( 100 , 'microphysics_driver: calling sbm' )
1318                CALL fast_sbm(W=w,U=u,V=v,TH_OLD=th_old              &
1319                  ,CHEM_new=scalar,N_CHEM=num_scalar                 &
1320                  ,ITIMESTEP=itimestep,DT=dt,DX=dx,DY=dy             &
1321                  ,DZ8W=dz8w,RHO_PHY=rho,P_PHY=p                     &
1322                  ,PI_PHY=pi_phy,TH_PHY=th                           &
1323                  ,xland=xland,domain_id=id                          &
1324                  ,ivgtyp=ivgtyp                                     &
1325                  ,xlat=xlat                                         &
1326                  ,xlong=xlong                                       &
1327                  ,QV=qv_curr                                        &
1328                  ,QC=qc_curr                                        &
1329                  ,QR=qr_curr                                        &
1330                  ,QI=qi_curr                                        &
1331                  ,QS=qs_curr                                        &
1332                  ,QG=qg_curr                                        &
1333                  ,QV_OLD=qv_old                                     &
1334                  ,QNC=qnc_curr                                      &
1335                  ,QNR=qnr_curr                                      &
1336                  ,QNI=qni_curr                                      &
1337                  ,QNS=qns_curr                                      &
1338                  ,QNG=qng_curr                                      &
1339                  ,QNA=qnn_curr                                      &
1340                  ,sbmradar=sbmradar,num_sbmradar=num_sbmradar       &
1341                  ,sbm_diagnostics=sbm_diagnostics                   &
1342                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
1343                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
1344                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
1345                  ,diagflag=diagflag                                 &  ! added for radar reflectivity
1346                  ,RAINNC=rainnc                                     &
1347                  ,RAINNCV=rainncv                                   &
1348                  ,SNOWNC=snownc                                     &
1349                  ,SNOWNCV=snowncv                                   &
1350                  ,GRAUPELNC=graupelnc                               &
1351                  ,GRAUPELNCV=graupelncv                             &
1352                  ,SR=sr                                             &
1353                                                                     )
1354 # endif
1357        CASE (FULL_KHAIN_LYNN)
1358              CALL wrf_debug ( 100 , 'microphysics_driver: calling sbm' )
1359                CALL sbm(W=w,U=u,V=v,TH_OLD=th_old          &
1360                  ,CHEM_new=scalar,N_CHEM=num_scalar                     &
1361                  ,ITIMESTEP=itimestep,DT=dt,DX=dx,DY=dy             &
1362                  ,DZ8W=dz8w,RHO_PHY=rho,P_PHY=p,PI_PHY=pi_phy,TH_PHY=th &
1363                  ,xland=xland                                       &
1364                  ,ivgtyp=ivgtyp                                      &
1365                  ,xlat=xlat                                        &
1366                  ,xlong=xlong                                        &
1367                  ,QV=qv_curr                                        &
1368                  ,QC=qc_curr                                        &
1369                  ,QR=qr_curr                                        &
1370                  ,QIP=qip_curr                                        &
1371                  ,QIC=qic_curr                                        &
1372                  ,QID=qid_curr                                        &
1373                  ,QS=qs_curr                                        &
1374                  ,QG=qg_curr                                        &
1375                  ,QH=qh_curr                                        &
1376                  ,QV_OLD=qv_old                                     &
1377                  ,QNC=qnc_curr                                      &
1378                  ,QNR=qnr_curr                                      &
1379                  ,QNIP=qnip_curr                                      &
1380                  ,QNIC=qnic_curr                                      &
1381                  ,QNID=qnid_curr                                      &
1382                  ,QNS=qns_curr                                      &
1383                  ,QNG=qng_curr                                      &
1384                  ,QNH=qng_curr                                      &
1385                  ,QNA=qnn_curr                                      &
1386                  ,EFFR=effr_curr                                  &
1387                  ,ICE_EFFR=ice_effr_curr                                  &
1388                  ,TOT_EFFR=tot_effr_curr                                  &
1389                  ,QIC_EFFR=qic_effr_curr                                  &
1390                  ,QIP_EFFR=qip_effr_curr                                  &
1391                  ,QID_EFFR=qid_effr_curr                                  &
1392                  ,height=height                                        &
1393                  ,tempc=tempc                                         &
1394                  ,kext_ql=kext_ql                                       &
1395                  ,kext_qs=kext_qs                                       &
1396                  ,kext_qg=kext_qg                                       &
1397                  ,kext_qh=kext_qh                                       &
1398                  ,kext_qa=kext_qa                                       &
1399                  ,kext_qic=kext_qic                                       &
1400                  ,kext_qip=kext_qip                                       &
1401                  ,kext_qid=kext_qid                                       &
1402                  ,kext_ft_qic=kext_ft_qic                                       &
1403                  ,kext_ft_qip=kext_ft_qip                                       &
1404                  ,kext_ft_qid=kext_ft_qid                                       &
1405                  ,kext_ft_qs=kext_ft_qs                                       &
1406                  ,kext_ft_qg=kext_ft_qg                                       &
1407                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
1408                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
1409                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
1410                  ,REFL_10CM=refl_10cm                 &  ! added for radar reflectivity
1411                  ,diagflag=diagflag                   &  ! added for radar reflectivity
1412                  ,do_radar_ref=do_radar_ref           &  ! added for radar reflectivity
1413                  ,RAINNC=rainnc                       &
1414                  ,RAINNCV=rainncv                     &
1415                  ,SNOWNC=snownc                       &
1416                  ,SNOWNCV=snowncv                     &
1417                  ,GRAUPELNC=graupelnc                 &
1418                  ,GRAUPELNCV=graupelncv               &
1419                  ,HAILNC=hailnc                       &
1420                  ,HAILNCV=hailncv                     &
1421                  ,SR=sr                               &
1422                                                       )
1423 #endif
1426      CASE (JENSEN_ISHMAEL)
1427         CALL wrf_debug(100, 'microphysics_driver: jensen_ishmael ')
1428         IF (PRESENT (QV_CURR) .AND. PRESENT (QC_CURR) .AND. &
1429              PRESENT (QR_CURR) .AND. PRESENT (QNR_CURR) .AND. &
1430              PRESENT (QI_CURR).AND. PRESENT (QNI_CURR) .AND. &
1431              PRESENT (QVOLI_CURR) .AND. PRESENT (QAOLI_CURR) .AND. &
1432              PRESENT (QI2_CURR).AND. PRESENT (QNI2_CURR) .AND. &
1433              PRESENT (QVOLI2_CURR) .AND. PRESENT (QAOLI2_CURR) .AND. &
1434              PRESENT (QI3_CURR).AND. PRESENT (QNI3_CURR) .AND. &
1435              PRESENT (QVOLI3_CURR).AND. PRESENT (QAOLI3_CURR)) THEN
1436              CALL mp_jensen_ishmael(             &
1437              ITIMESTEP=itimestep,                &  !*                                                                         
1438              DT_IN=dt,                           &  !*
1439              P=p,                                &  !*                                                                         
1440              DZ=dz8w,                            &  !* !
1441              TH=th,                              &  !*                                                                         
1442              QV=qv_curr,                         &  !*                                                                         
1443              QC=qc_curr,                         &  !*                                                                         
1444              QR=qr_curr,                         &  !*                                                                         
1445              NR=qnr_curr,                        &  !* !
1446              QI1=qi_curr,                        &  !*                                                                         
1447              NI1=qni_curr,                       &  !*                                                                         
1448              AI1=qvoli_curr,                     &  !*
1449              CI1=qaoli_curr,                     &  !*
1450              QI2=qi2_curr,                       &  !*                                                                         
1451              NI2=qni2_curr,                      &  !*                                                                         
1452              AI2=qvoli2_curr,                    &  !*
1453              CI2=qaoli2_curr,                    &  !*
1454              QI3=qi3_curr,                       &  !*                                                                         
1455              NI3=qni3_curr,                      &  !*                                                                         
1456              AI3=qvoli3_curr,                    &  !*
1457              CI3=qaoli3_curr,                    &  !*
1458              IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde, &
1459              IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme, &
1460              ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte, &
1461              RAINNC=RAINNC,                      &
1462              RAINNCV=RAINNCV,                    &
1463              SNOWNC=SNOWNC,                      &
1464              SNOWNCV=SNOWNCV,                    &
1465              diag_effc3d=re_cloud,               &
1466              diag_effi3d=re_ice,                 &
1467              diag_dbz3d=refl_10cm,               &
1468              diag_vmi3d_1=vmi3d,                 &
1469              diag_di3d_1=di3d,                   &
1470              diag_rhopo3d_1=rhopo3d,             &
1471              diag_phii3d_1=phii3d,               &
1472              diag_vmi3d_2=vmi3d_2,               &
1473              diag_di3d_2=di3d_2,                 &
1474              diag_rhopo3d_2=rhopo3d_2,           &
1475              diag_phii3d_2=phii3d_2,             &
1476              diag_vmi3d_3=vmi3d_3,               &
1477              diag_di3d_3=di3d_3,                 &
1478              diag_rhopo3d_3=rhopo3d_3,           &
1479              diag_phii3d_3=phii3d_3,             &
1480              diag_itype_1=itype,                 &
1481              diag_itype_2=itype_2,               &
1482              diag_itype_3=itype_3                &
1483              )
1484         ELSE
1485            Call wrf_error_fatal( 'arguments not present for calling jensen_ishamel')
1486         ENDIF
1488     CASE (MORR_TWO_MOMENT)
1489          CALL wrf_debug(100, 'microphysics_driver: calling morrison two moment')
1490          IF (PRESENT (QV_CURR) .AND. PRESENT (QC_CURR) .AND. &
1491              PRESENT (QR_CURR) .AND. PRESENT (QI_CURR) .AND. &
1492          PRESENT (QS_CURR) .AND. PRESENT (QG_CURR) .AND. &
1493          PRESENT (QR_CURR) .AND. PRESENT (QI_CURR) .AND. &
1494          PRESENT (QNS_CURR) .AND. PRESENT (QNI_CURR).AND. &
1495          PRESENT (QNR_CURR) .AND. PRESENT (QNG_CURR).AND. &
1496          PRESENT (QSCUTEN).AND. &
1497          PRESENT (QRCUTEN) .AND. PRESENT (QICUTEN).AND. &
1498          PRESENT (RAINNC ) .AND. PRESENT (RAINNCV) .AND. &
1499          PRESENT ( W      )  ) THEN
1500          CALL mp_morr_two_moment(                            &
1501                      ITIMESTEP=itimestep,                &  !*
1502                      TH=th,                              &  !*
1503                      QV=qv_curr,                         &  !*
1504                      QC=qc_curr,                         &  !*
1505                      QR=qr_curr,                         &  !*
1506                      QI=qi_curr,                         &  !*
1507                      QS=qs_curr,                         &  !*
1508                      QG=qg_curr,                         &  !*
1509                      NI=qni_curr,                        &  !*
1510                      NS=qns_curr,                        &  !* ! VVT
1511                      NR=qnr_curr,                        &  !* ! VVT
1512                      NG=qng_curr,                        &  !* ! VVT
1513                      RHO=rho,                            &  !*
1514                      PII=pi_phy,                         &  !*
1515                      P=p,                                &  !*
1516                      DT_IN=dt,                           &  !*
1517                      DZ=dz8w,                            &  !* !hm
1518                      HT=ht,                              &  !*
1519                      W=w                                 &  !*
1520                     ,RAINNC=RAINNC                       &  !*
1521                     ,RAINNCV=RAINNCV                     &  !*
1522                     ,SNOWNC=SNOWNC                       &  !*
1523                     ,SNOWNCV=SNOWNCV                     &  !*
1524                     ,GRAUPELNC=GRAUPELNC                 &  !*
1525                     ,GRAUPELNCV=GRAUPELNCV               &  !*
1526                     ,SR=SR                               &  !* !hm
1527                     ,REFL_10CM=refl_10cm                 &  ! added for radar reflectivity
1528                     ,diagflag=diagflag                   &  ! added for radar reflectivity
1529                     ,do_radar_ref=do_radar_ref           &  ! added for radar reflectivity
1530                     ,qrcuten=qrcuten                     &  ! hm
1531                     ,qscuten=qscuten                     &  ! hm
1532                     ,qicuten=qicuten                     &  ! hm
1533                     ,F_QNDROP=f_qndrop                   &  ! hm for wrf-chem
1534                  ,QNDROP=qndrop_curr                     &  ! hm for wrf-chem
1535                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
1536                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
1537                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
1538                  ,QLSINK=qlsink                                     & ! jdf for wrf-chem
1539 #if ( WRF_CHEM == 1 )
1540                  ,WETSCAV_ON=config_flags%wetscav_onoff == 1 &
1541                  ,EVAPPROD=evapprod,RAINPROD=rainprod          &
1542 #endif
1543                  ,PRECR=precr,PRECI=preci,PRECS=precs,PRECG=precg   & ! jdf for wrf-chem
1544                                                                     )
1545         ELSE
1546            Call wrf_error_fatal( 'arguments not present for calling morrison two moment')
1547         ENDIF
1549 #if (EM_CORE==1)
1550     CASE (P3_1CATEGORY)
1551          CALL wrf_debug(100, 'microphysics_driver: calling p3 one category')
1552 !         IF (PRESENT (QV_CURR) .AND. PRESENT (QC_CURR) .AND. &
1553 !             PRESENT (QR_CURR) .AND. PRESENT (QI_CURR) .AND. &
1554 !         PRESENT (QNG_CURR) .AND. &
1555 !         PRESENT (QNC_CURR) .AND. PRESENT (QNI_CURR).AND. &
1556 !         PRESENT (QNR_CURR) .AND. &
1557 !         PRESENT (QSCUTEN).AND. &
1558 !         PRESENT (QRCUTEN) .AND. PRESENT (QICUTEN).AND. &
1559 !         PRESENT (RAINNC ) .AND. PRESENT (RAINNCV) .AND. &
1560 !         PRESENT (Z      ) .AND.PRESENT ( W      )  ) THEN
1562          CALL mp_p3_wrapper_wrf(                         &
1563                      ITIMESTEP=itimestep,                &
1564                      TH_3d=th,                            &
1565                      QV_3d=qv_curr,                       &
1566                      QC_3d=qc_curr,                       &
1567                      QR_3d=qr_curr,                       &
1568                      QNR_3d=qnr_curr,                     &
1569                      QI1_3d=qi_curr,                     &
1570                      QIR1_3d=qir_curr,                    &
1571                      QNI1_3d=qni_curr,                   &
1572                      QIB1_3d=qib_curr,                 &
1573                      th_old_3d=th_old,                 &
1574                      qv_old_3d=qv_old,                 &
1575                      PII=pi_phy,                         &
1576                      P=p,                                &
1577                      DT=dt,                           &
1578                      DZ=dz8w,                            &
1579                      W=w                                 &
1580                     ,RAINNC=RAINNC                       &
1581                     ,RAINNCV=RAINNCV                     &
1582                     ,SR=SR                               &
1583                     ,SNOWNC=SNOWNC                       &
1584                     ,SNOWNCV=SNOWNCV                     &
1585                     ,N_ICECAT=1                     &
1586                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
1587                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
1588                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
1589                  ,diag_zdbz_3d=refl_10cm,                                 &
1590                      diag_effc_3d=re_cloud,                    &
1591                      diag_effi_3d=re_ice                       &
1592                  ,diag_vmi_3d=vmi3d                                       &
1593                  ,diag_di_3d=di3d                                         &
1594                  ,diag_rhopo_3d=rhopo3d                                   &
1595                                                                     )
1596 !        ELSE
1597 !           Call wrf_error_fatal( 'arguments not present for calling p3 one category')
1598 !        ENDIF
1600     CASE (P3_1CATEGORY_NC)
1601          CALL wrf_debug(100, 'microphysics_driver: calling p3 one category')
1602 !         IF (PRESENT (QV_CURR) .AND. PRESENT (QC_CURR) .AND. &
1603 !             PRESENT (QR_CURR) .AND. PRESENT (QI_CURR) .AND. &
1604 !         PRESENT (QNG_CURR) .AND. &
1605 !         PRESENT (QNC_CURR) .AND. PRESENT (QNI_CURR).AND. &
1606 !         PRESENT (QNR_CURR) .AND. &
1607 !         PRESENT (QSCUTEN).AND. &
1608 !         PRESENT (QRCUTEN) .AND. PRESENT (QICUTEN).AND. &
1609 !         PRESENT (RAINNC ) .AND. PRESENT (RAINNCV) .AND. &
1610 !         PRESENT (Z      ) .AND.PRESENT ( W      )  ) THEN
1612          CALL mp_p3_wrapper_wrf(                         &
1613                      ITIMESTEP=itimestep,                &
1614                      TH_3d=th,                            &
1615                      QV_3d=qv_curr,                       &
1616                      QC_3d=qc_curr,                       &
1617                      QR_3d=qr_curr,                       &
1618                      QNR_3d=qnr_curr,                     &
1619                      QI1_3d=qi_curr,                     &
1620                      QIR1_3d=qir_curr,                    &
1621                      QNI1_3d=qni_curr,                   &
1622                      QIB1_3d=qib_curr,                 &
1623                      th_old_3d=th_old,                 &
1624                      qv_old_3d=qv_old,                 &
1625                      nc_3d=qnc_curr,                   &
1626                      PII=pi_phy,                         &
1627                      P=p,                                &
1628                      DT=dt,                           &
1629                      DZ=dz8w,                            &
1630                      W=w                                 &
1631                     ,RAINNC=RAINNC                       &
1632                     ,RAINNCV=RAINNCV                     &
1633                     ,SR=SR                               &
1634                     ,SNOWNC=SNOWNC                       &
1635                     ,SNOWNCV=SNOWNCV                     &
1636                     ,N_ICECAT=1                     &
1637                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
1638                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
1639                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
1640                  ,diag_zdbz_3d=refl_10cm,                                 &
1641                      diag_effc_3d=re_cloud,                    &
1642                      diag_effi_3d=re_ice                       &
1643                  ,diag_vmi_3d=vmi3d                                       &
1644                  ,diag_di_3d=di3d                                         &
1645                  ,diag_rhopo_3d=rhopo3d                                   &
1646                                                                     )
1647     CASE (P3_2CATEGORY)
1648          CALL wrf_debug(100, 'microphysics_driver: calling p3 one category')
1649 !         IF (PRESENT (QV_CURR) .AND. PRESENT (QC_CURR) .AND. &
1650 !             PRESENT (QR_CURR) .AND. PRESENT (QI_CURR) .AND. &
1651 !         PRESENT (QNG_CURR) .AND. &
1652 !         PRESENT (QNC_CURR) .AND. PRESENT (QNI_CURR).AND. &
1653 !         PRESENT (QNR_CURR) .AND. &
1654 !         PRESENT (QSCUTEN).AND. &
1655 !         PRESENT (QRCUTEN) .AND. PRESENT (QICUTEN).AND. &
1656 !         PRESENT (RAINNC ) .AND. PRESENT (RAINNCV) .AND. &
1657 !         PRESENT (Z      ) .AND.PRESENT ( W      )  ) THEN
1659          CALL mp_p3_wrapper_wrf_2cat(                         &
1660                      ITIMESTEP=itimestep,                &
1661                      TH_3d=th,                            &
1662                      QV_3d=qv_curr,                       &
1663                      QC_3d=qc_curr,                       &
1664                      QR_3d=qr_curr,                       &
1665                      QNR_3d=qnr_curr,                     &
1666                      QI1_3d=qi_curr,                     &
1667                      QIR1_3d=qir_curr,                    &
1668                      QNI1_3d=qni_curr,                   &
1669                      QIB1_3d=qib_curr,                 &
1670                      QI2_3d=qi2_curr,                     &
1671                      QIR2_3d=qir2_curr,                    &
1672                      QNI2_3d=qni2_curr,                   &
1673                      QIB2_3d=qib2_curr,                 &
1674                      th_old_3d=th_old,                 &
1675                      qv_old_3d=qv_old,                 &
1676                      nc_3d=qnc_curr,                   &
1677                      PII=pi_phy,                         &
1678                      P=p,                                &
1679                      DT=dt,                           &
1680                      DZ=dz8w,                            &
1681                      W=w                                 &
1682                     ,RAINNC=RAINNC                       &
1683                     ,RAINNCV=RAINNCV                     &
1684                     ,SR=SR                               &
1685                     ,SNOWNC=SNOWNC                       &
1686                     ,SNOWNCV=SNOWNCV                     &
1687                     ,N_ICECAT=2                     &
1688                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
1689                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
1690                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
1691                  ,diag_zdbz_3d=refl_10cm,                                 &
1692                      diag_effc_3d=re_cloud,                    &
1693                      diag_effi_3d=re_ice                       &
1694                  ,diag_vmi_3d=vmi3d                                       &
1695                  ,diag_di_3d=di3d                                         &
1696                  ,diag_rhopo_3d=rhopo3d                                   &
1697                  ,diag_vmi2_3d=vmi3d_2                                       &
1698                  ,diag_di2_3d=di3d_2                                         &
1699                  ,diag_rhopo2_3d=rhopo3d_2                                   &
1700                                                                     )
1702     CASE (P3_1CAT_3MOM)                                                                                          
1703          CALL wrf_debug(100, 'microphysics_driver: calling p3 one category 3 moment')
1705          CALL mp_p3_wrapper_wrf(                         &                           
1706                      ITIMESTEP=itimestep,                &                           
1707                      TH_3d=th,                            &                          
1708                      QV_3d=qv_curr,                       &                          
1709                      QC_3d=qc_curr,                       &                          
1710                      QR_3d=qr_curr,                       &                          
1711                      QNR_3d=qnr_curr,                     &                          
1712                      QI1_3d=qi_curr,                     &                           
1713                      QIR1_3d=qir_curr,                    &                          
1714                      QNI1_3d=qni_curr,                   &                           
1715                      QIB1_3d=qib_curr,                 &                             
1716                      th_old_3d=th_old,                 &                             
1717                      qv_old_3d=qv_old,                 &                             
1718                      nc_3d=qnc_curr,                   & 
1719                      PII=pi_phy,                         &                           
1720                      P=p,                                &                           
1721                      DT=dt,                           &                              
1722                      DZ=dz8w,                            &                           
1723                      W=w                                 &                           
1724                     ,RAINNC=RAINNC                       &                           
1725                     ,RAINNCV=RAINNCV                     &                           
1726                     ,SR=SR                               &                           
1727                     ,SNOWNC=SNOWNC                       &                           
1728                     ,SNOWNCV=SNOWNCV                     &                           
1729                     ,N_ICECAT=1                     &                                
1730                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &                
1731                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &                
1732                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &                
1733                  ,diag_zdbz_3d=refl_10cm,                                 &          
1734                      diag_effc_3d=re_cloud,                    &                     
1735                      diag_effi_3d=re_ice                       &                     
1736                  ,diag_vmi_3d=vmi3d                                       &          
1737                  ,diag_di_3d=di3d                                         &          
1738                  ,diag_rhopo_3d=rhopo3d                                   &          
1739                  ,QZI1_3d=qzi_curr                                   &               
1740 ! not currently output
1741 !                 ,diag_dhmax_3d=dhmax3d                                       &      
1742 !                 ,diag_lami_3d=lami3d                                         &      
1743 !                 ,diag_mui_3d=mui3d                                   &              
1744                                                                     )
1746 #endif
1749 # if (EM_CORE == 1)
1750     CASE (MORR_TM_AERO)
1751          CALL wrf_debug(100, 'microphysics_driver: calling morrison two moment')
1752          CALL mp_morr_two_moment_aero(                            &
1753                      ITIMESTEP=itimestep,                &  !*
1754                      TH=th,                              &  !*
1755                      QV=qv_curr,                         &  !*
1756                      QC=qc_curr,                         &  !*
1757                      QR=qr_curr,                         &  !*
1758                      QI=qi_curr,                         &  !*
1759                      QS=qs_curr,                         &  !*
1760                      QG=qg_curr,                         &  !*
1761                      NI=qni_curr,                        &  !*
1762                      NS=qns_curr,                        &  !* ! VVT
1763                      NR=qnr_curr,                        &  !* ! VVT
1764                      NG=qng_curr,                        &  !* ! VVT
1765                      NC=qnc_curr,                        &  ! TWG/amy added nc
1766                      KZH=exch_h,                         &  ! TWG/amy add
1767                      RHO=rho,                            &  !*
1768                      PII=pi_phy,                         &  !*
1769                      P=p,                                &  !*
1770                      DT_IN=dt,                           &  !*
1771                      DZ=dz8w,                            &  !* !hm
1772                      HT=ht,                              &  !*
1773                      W=w                                 &  !*
1774                     ,RAINNC=RAINNC                       &  !*
1775                     ,RAINNCV=RAINNCV                     &  !*
1776                     ,SNOWNC=SNOWNC                       &  !*
1777                     ,SNOWNCV=SNOWNCV                     &  !*
1778                     ,GRAUPELNC=GRAUPELNC                 &  !*
1779                     ,GRAUPELNCV=GRAUPELNCV               &  !*
1780                     ,SR=SR                               &  !* !hm
1781                     ,REFL_10CM=refl_10cm                 &  ! added for radar reflectivity
1782                     ,MSKF_REFL_10CM=MSKF_REFL_10CM       &  ! addef for radar reflectivity TWG 2017
1783                     ,diagflag=diagflag                   &  ! added for radar reflectivity
1784                     ,do_radar_ref=do_radar_ref           &  ! added for radar reflectivity
1785                     ,qrcuten=qrcuten                     &  ! hm
1786                     ,qscuten=qscuten                     &  ! hm
1787                     ,qicuten=qicuten                     &  ! hm
1788                     ,F_QNDROP=f_qndrop                   &  ! hm for wrf-chem
1789                  ,QNDROP=qndrop_curr                     &  ! hm for wrf-chem
1790                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
1791                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
1792                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
1793                  ,PBL=PBL                                & ! TWG/amy add
1794                  ,aerocu=aerocu                          & ! TWG add
1795                  ,aercu_opt=aercu_opt                    & ! TWG add
1796                  ,aercu_fct=aercu_fct                    & ! TWG add
1797                  ,no_src_types_cu=no_src_types_cu        & ! TWG add
1798                  ,EFCG=EFCG                              & ! TWG add
1799                  ,EFIG=EFIG                              & ! TWG add
1800                  ,EFSG=EFSG                              & ! TWG add
1801                  ,WACT=WACT                              & ! TWG add
1802                  ,CCN1_GS=CCN1_GS                        & ! TWG add
1803                  ,CCN2_GS=CCN2_GS                        & ! TWG add
1804                  ,CCN3_GS=CCN3_GS                        & ! TWG add
1805                  ,CCN4_GS=CCN4_GS                        & ! TWG add
1806                  ,CCN5_GS=CCN5_GS                        & ! TWG add
1807                  ,CCN6_GS=CCN6_GS                        & ! TWG add
1808                  ,CCN7_GS=CCN7_GS                        & ! TWG add
1809                  ,NR_CU=NR_CU                            & ! TWG add
1810                  ,QR_CU=QR_CU                            & ! TWG add
1811                  ,NS_CU=NS_CU                            & ! TWG add
1812                  ,QS_CU=QS_CU                            & ! TWG add
1813                  ,CU_UAF=CU_UAF                          & ! TWG add
1814                  ,QLSINK=qlsink                                     & ! jdf for wrf-chem
1815 #if ( WRF_CHEM == 1 )
1816                  ,WETSCAV_ON=config_flags%wetscav_onoff == 1 &
1817                  ,EVAPPROD=evapprod,RAINPROD=rainprod          &
1818 #endif
1819                  ,PRECR=precr,PRECI=preci,PRECS=precs,PRECG=precg   & ! jdf for wrf-chem
1820                                                                     )
1821 #endif
1823     CASE (MILBRANDT2MOM)
1824          CALL wrf_debug(100, 'microphysics_driver: calling milbrandt2mom')
1825          IF (PRESENT (QV_CURR) .AND.                           &
1826              PRESENT (QC_CURR) .AND. PRESENT (QNC_CURR)  .AND. &
1827              PRESENT (QR_CURR) .AND. PRESENT (QNR_CURR)  .AND. &
1828              PRESENT (QI_CURR) .AND. PRESENT (QNI_CURR)  .AND. &
1829              PRESENT (QS_CURR) .AND. PRESENT (QNS_CURR)  .AND. &
1830              PRESENT (QG_CURR) .AND. PRESENT (QNG_CURR)  .AND. &
1831              PRESENT (QH_CURR) .AND. PRESENT (QNH_CURR)  .AND. &
1832              PRESENT (RAINNC ) .AND. PRESENT (RAINNCV)   .AND. &
1833              PRESENT (SNOWNC ) .AND. PRESENT (SNOWNCV)   .AND. &
1834              PRESENT (HAILNC ) .AND. PRESENT (HAILNCV)   .AND. &
1835              PRESENT (GRAUPELNC).AND.PRESENT (GRAUPELNCV).AND. &
1836              PRESENT ( W      )  ) THEN
1837 !            PRESENT (ccntype)                                 &
1839          CALL mp_milbrandt2mom_driver(                   &
1840                      ITIMESTEP=itimestep,                &
1841                      p8w=p8w,                              &
1842                      TH=th,                              &
1843                      QV=qv_curr,                         &
1844                      QC=qc_curr,                         &
1845                      QR=qr_curr,                         &
1846                      QI=qi_curr,                         &
1847                      QS=qs_curr,                         &
1848                      QG=qg_curr,                         &
1849                      QH=qh_curr,                         &
1850                      NC=qnc_curr,                        &
1851                      NR=qnr_curr,                        &
1852                      NI=qni_curr,                        &
1853                      NS=qns_curr,                        &
1854                      NG=qng_curr,                        &
1855                      NH=qnh_curr,                        &
1856                      PII=pi_phy,                         &
1857                      P=p,                                &
1858                      DT_IN=dt,                           &
1859                      DZ=dz8w,                            &
1860                      W=w,                                &
1861                      RAINNC   = RAINNC,                  &
1862                      RAINNCV  = RAINNCV,                 &
1863                      SNOWNC   = SNOWNC,                  &
1864                      SNOWNCV  = SNOWNCV,                 &
1865                      HAILNC   = HAILNC,                  &
1866                      HAILNCV  = HAILNCV,                 &
1867                      GRPLNC   = GRAUPELNC,               &
1868                      GRPLNCV  = GRAUPELNCV,              &
1869                      SR=SR,                              &
1870 !                    ccntype  = ccntype,                 &
1871                      Zet      = refl_10cm,               & ! HM, 9/22/09 for refl
1872                   IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde, &
1873                   IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme, &
1874                   ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte  &
1875                                                                     )
1876         ELSE
1877            Call wrf_error_fatal( 'arguments not present for calling milbrandt2mom')
1878         ENDIF
1881 !     CASE (MILBRANDT3MOM)
1882 !          CALL wrf_debug(100, 'microphysics_driver: calling milbrandt3mom')
1883 !          IF (PRESENT (QV_CURR) .AND.                          &
1884 !              PRESENT (QC_CURR) .AND. PRESENT (QNC_CURR) .AND. &
1885 !              PRESENT (QR_CURR) .AND. PRESENT (QNR_CURR) .AND. PRESENT (QZR_CURR) .AND.  &
1886 !              PRESENT (QI_CURR) .AND. PRESENT (QNI_CURR) .AND. PRESENT (QZI_CURR) .AND.  &
1887 !              PRESENT (QS_CURR) .AND. PRESENT (QNS_CURR) .AND. PRESENT (QZS_CURR) .AND.  &
1888 !              PRESENT (QG_CURR) .AND. PRESENT (QNG_CURR) .AND. PRESENT (QZG_CURR) .AND.  &
1889 !              PRESENT (QH_CURR) .AND. PRESENT (QNH_CURR) .AND. PRESENT (QZH_CURR) .AND.  &
1890 !              PRESENT (RAINNC ) .AND. PRESENT (RAINNCV)  .AND. &
1891 !              PRESENT ( W      )  ) THEN
1892 !          CALL mp_milbrandt3mom_driver(                   &
1893 !                      ITIMESTEP=itimestep,                &  !*
1894 !                      TH=th,                              &  !*
1895 !                      QV=qv_curr,                         &  !*
1896 !                      QC=qc_curr,                         &  !*
1897 !                      QR=qr_curr,                         &  !*
1898 !                      QI=qi_curr,                         &  !*
1899 !                      QS=qs_curr,                         &  !*
1900 !                      QG=qg_curr,                         &  !*
1901 !                      QH=qh_curr,                         &  !*
1902 !                      NC=qnc_curr,                        &  !*
1903 !                      NR=qnr_curr,                        &  !*
1904 !                      NI=qni_curr,                        &  !*
1905 !                      NS=qns_curr,                        &  !*
1906 !                      NG=qng_curr,                        &  !*
1907 !                      NH=qnh_curr,                        &  !*
1908 !                      ZR=qzr_curr,                        &  !*
1909 !                      ZI=qzi_curr,                        &  !*
1910 !                      ZS=qzs_curr,                        &  !*
1911 !                      ZG=qzg_curr,                        &  !*
1912 !                      ZH=qzh_curr,                        &  !*
1913 !                      PII=pi_phy,                         &  !*
1914 !                      P=p,                                &  !*
1915 !                      DT_IN=dt,                           &  !*
1916 !                      DZ=dz8w,                            &  !* ! h
1917 !                      W=w                                 &  !*
1918 !                     ,RAINNC=RAINNC                       &  !*
1919 !                     ,RAINNCV=RAINNCV                     &  !*
1920 !                     ,SR=SR                               &  !* !hm
1921 !                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
1922 !                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
1923 !                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
1924 !                                                                     )
1925 !         ELSE
1926 !            Call wrf_error_fatal( 'arguments not present for calling milbrandt3mom')
1927 !         ENDIF
1929     CASE (NSSL_1MOM)
1930          CALL wrf_debug(100, 'microphysics_driver: calling nssl1mom')
1931          IF (PRESENT (QV_CURR) .AND.                           &
1932              PRESENT (QC_CURR) .AND.  &
1933              PRESENT (QR_CURR) .AND.  &
1934              PRESENT (QI_CURR) .AND.  &
1935              PRESENT (QS_CURR) .AND.  &
1936              PRESENT (QG_CURR) .AND.  &
1937              PRESENT (QH_CURR) .AND.  &
1938              PRESENT (RAINNC ) .AND. PRESENT (RAINNCV)   .AND. &
1939 #if (EM_CORE==1)
1940              PRESENT (SNOWNC ) .AND. PRESENT (SNOWNCV)   .AND. &
1941              PRESENT (HAILNC ) .AND. PRESENT (HAILNCV)   .AND. &
1942              PRESENT (GRAUPELNC).AND.PRESENT (GRAUPELNCV).AND. &
1943 #endif
1944              PRESENT ( W      )  .AND. &
1945              PRESENT (QVOLG_CURR) ) THEN
1946              
1948          CALL nssl_2mom_driver(                          &
1949                      ITIMESTEP=itimestep,                &
1950                      TH=th,                              &
1951                      QV=qv_curr,                         &
1952                      QC=qc_curr,                         &
1953                      QR=qr_curr,                         &
1954                      QI=qi_curr,                         &
1955                      QS=qs_curr,                         &
1956                      QH=qg_curr,                         &
1957                      QHL=qh_curr,                        &
1958 !                     CCW=qnc_curr,                       &
1959 !                     CRW=qnr_curr,                       &
1960 !                     CCI=qni_curr,                       &
1961 !                     CSW=qns_curr,                       &
1962 !                     CHW=qng_curr,                       &
1963 !                     CHL=qnh_curr,                       &
1964                      VHW=qvolg_curr,                     &
1965                      PII=pi_phy,                         &
1966                      P=p,                                &
1967                      W=w,                                &
1968                      DZ=dz8w,                            &
1969                      DTP=dt,                             &
1970                      DN=rho,                             &
1971                      RAINNC   = RAINNC,                  &
1972                      RAINNCV  = RAINNCV,                 &
1973                      SNOWNC   = SNOWNC,                  &
1974                      SNOWNCV  = SNOWNCV,                 &
1975                      HAILNC   = HAILNC,                  &
1976                      HAILNCV  = HAILNCV,                 &
1977                      GRPLNC   = GRAUPELNC,               &
1978                      GRPLNCV  = GRAUPELNCV,              &
1979                      SR=SR,                              &
1980                      dbz      = refl_10cm,               &
1981                      diagflag = diagflag,                &
1982                      ke_diag = ke_diag,                &
1983                   IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde, &
1984                   IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme, &
1985                   ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte  &
1986                                                                     )
1987         ELSE
1988            Call wrf_error_fatal( 'arguments not present for calling nssl_1mom')
1989         ENDIF
1992     CASE (NSSL_1MOMLFO)
1993          CALL wrf_debug(100, 'microphysics_driver: calling nssl1mom')
1994          IF (PRESENT (QV_CURR) .AND.                           &
1995              PRESENT (QC_CURR) .AND.  &
1996              PRESENT (QR_CURR) .AND.  &
1997              PRESENT (QI_CURR) .AND.  &
1998              PRESENT (QS_CURR) .AND.  &
1999              PRESENT (QG_CURR) .AND.  &
2000              PRESENT (RAINNC ) .AND. PRESENT (RAINNCV)   .AND. &
2001 #if (EM_CORE==1)
2002              PRESENT (SNOWNC ) .AND. PRESENT (SNOWNCV)   .AND. &
2003              PRESENT (GRAUPELNC).AND.PRESENT (GRAUPELNCV).AND. &
2004 #endif
2005              PRESENT ( W      )  ) THEN
2006              
2008          CALL nssl_2mom_driver(                          &
2009                      ITIMESTEP=itimestep,                &
2010                      TH=th,                              &
2011                      QV=qv_curr,                         &
2012                      QC=qc_curr,                         &
2013                      QR=qr_curr,                         &
2014                      QI=qi_curr,                         &
2015                      QS=qs_curr,                         &
2016                      QH=qg_curr,                         &
2017                      PII=pi_phy,                         &
2018                      P=p,                                &
2019                      W=w,                                &
2020                      DZ=dz8w,                            &
2021                      DTP=dt,                             &
2022                      DN=rho,                             &
2023                      RAINNC   = RAINNC,                  &
2024                      RAINNCV  = RAINNCV,                 &
2025                      SNOWNC   = SNOWNC,                  &
2026                      SNOWNCV  = SNOWNCV,                 &
2027                      GRPLNC   = GRAUPELNC,               &
2028                      GRPLNCV  = GRAUPELNCV,              &
2029                      SR=SR,                              &
2030                      dbz      = refl_10cm,               &
2031                      diagflag = diagflag,                &
2032                      ke_diag = ke_diag,                &
2033                   IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde, &
2034                   IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme, &
2035                   ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte  &
2036                                                                     )
2037         ELSE
2038            Call wrf_error_fatal( 'arguments not present for calling nssl_1momlfo')
2039         ENDIF
2041     CASE (NSSL_2MOM)
2042          CALL wrf_debug(100, 'microphysics_driver: calling nssl2mom')
2043          IF (PRESENT (QV_CURR) .AND.                           &
2044              PRESENT (QC_CURR) .AND. PRESENT (QNdrop_CURR)  .AND. &
2045              PRESENT (QR_CURR) .AND. PRESENT (QNR_CURR)  .AND. &
2046              PRESENT (QI_CURR) .AND. PRESENT (QNI_CURR)  .AND. &
2047              PRESENT (QS_CURR) .AND. PRESENT (QNS_CURR)  .AND. &
2048              PRESENT (QG_CURR) .AND. PRESENT (QNG_CURR)  .AND. &
2049              PRESENT (QH_CURR) .AND. PRESENT (QNH_CURR)  .AND. &
2050              PRESENT (RAINNC ) .AND. PRESENT (RAINNCV)   .AND. &
2051 #if (EM_CORE==1)
2052              PRESENT (SNOWNC ) .AND. PRESENT (SNOWNCV)   .AND. &
2053              PRESENT (HAILNC ) .AND. PRESENT (HAILNCV)   .AND. &
2054              PRESENT (GRAUPELNC).AND.PRESENT (GRAUPELNCV).AND. &
2055 #endif
2056              PRESENT ( W      )  .AND. &
2057              PRESENT (QVOLG_CURR) .AND. F_QVOLG  .AND.         &
2058              PRESENT (QVOLH_CURR) .AND. F_QVOLH ) THEN
2059              
2061          CALL nssl_2mom_driver(                          &
2062                      ITIMESTEP=itimestep,                &
2063                      TH=th,                              &
2064                      QV=qv_curr,                         &
2065                      QC=qc_curr,                         &
2066                      QR=qr_curr,                         &
2067                      QI=qi_curr,                         &
2068                      QS=qs_curr,                         &
2069                      QH=qg_curr,                         &
2070                      QHL=qh_curr,                        &
2071  !                    CCW=qnc_curr,                       &
2072                      CCW=qndrop_curr,                    &
2073                      CRW=qnr_curr,                       &
2074                      CCI=qni_curr,                       &
2075                      CSW=qns_curr,                       &
2076                      CHW=qng_curr,                       &
2077                      CHL=qnh_curr,                       &
2078                      VHW=qvolg_curr,                     &
2079                      VHL=qvolh_curr,                     &
2080                      PII=pi_phy,                         &
2081                      P=p,                                &
2082                      W=w,                                &
2083                      DZ=dz8w,                            &
2084                      DTP=dt,                             &
2085                      DN=rho,                             &
2086                      RAINNC   = RAINNC,                  &
2087                      RAINNCV  = RAINNCV,                 &
2088                      SNOWNC   = SNOWNC,                  &
2089                      SNOWNCV  = SNOWNCV,                 &
2090                      HAILNC   = HAILNC,                  &
2091                      HAILNCV  = HAILNCV,                 &
2092                      GRPLNC   = GRAUPELNC,               &
2093                      GRPLNCV  = GRAUPELNCV,              &
2094                      SR=SR,                              &
2095                      dbz      = refl_10cm,               &
2096 #if ( WRF_CHEM == 1 )
2097                     WETSCAV_ON = config_flags%wetscav_onoff == 1, &
2098                     EVAPPROD=evapprod,RAINPROD=rainprod, &
2099 #endif
2100                      nssl_progn=nssl_progn,              &
2101                      diagflag = diagflag,                &
2102                      ke_diag = ke_diag,                &
2103                      cu_used=cu_used,                    &
2104                      qrcuten=qrcuten,                    &  ! hm
2105                      qscuten=qscuten,                    &  ! hm
2106                      qicuten=qicuten,                    &  ! hm
2107                      qccuten=qccuten,                    &  ! hm
2108                      re_cloud=re_cloud,                  &
2109                      re_ice=re_ice,                      &
2110                      re_snow=re_snow,                    &
2111                      has_reqc=has_reqc,                  & ! ala G. Thompson
2112                      has_reqi=has_reqi,                  & ! ala G. Thompson
2113                      has_reqs=has_reqs,                  & ! ala G. Thompson
2114                   IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde, &
2115                   IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme, &
2116                   ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte  &
2117                                                                     )
2119         ELSE
2120            Call wrf_error_fatal( 'arguments not present for calling nssl_2mom')
2121         ENDIF
2123     CASE (NSSL_2MOMG)
2124          CALL wrf_debug(100, 'microphysics_driver: calling nssl2mom')
2125          IF (PRESENT (QV_CURR) .AND.                           &
2126              PRESENT (QC_CURR) .AND. PRESENT (QNdrop_CURR)  .AND. &
2127              PRESENT (QR_CURR) .AND. PRESENT (QNR_CURR)  .AND. &
2128              PRESENT (QI_CURR) .AND. PRESENT (QNI_CURR)  .AND. &
2129              PRESENT (QS_CURR) .AND. PRESENT (QNS_CURR)  .AND. &
2130              PRESENT (QG_CURR) .AND. PRESENT (QNG_CURR)  .AND. &
2131              PRESENT (RAINNC ) .AND. PRESENT (RAINNCV)   .AND. &
2132 #if (EM_CORE==1)
2133              PRESENT (SNOWNC ) .AND. PRESENT (SNOWNCV)   .AND. &
2134              PRESENT (HAILNC ) .AND. PRESENT (HAILNCV)   .AND. &
2135              PRESENT (GRAUPELNC).AND.PRESENT (GRAUPELNCV).AND. &
2136 #endif
2137              PRESENT ( W      )  .AND. &
2138              PRESENT (QVOLG_CURR) .AND. F_QVOLG  ) THEN
2139              
2141          CALL nssl_2mom_driver(                          &
2142                      ITIMESTEP=itimestep,                &
2143                      TH=th,                              &
2144                      QV=qv_curr,                         &
2145                      QC=qc_curr,                         &
2146                      QR=qr_curr,                         &
2147                      QI=qi_curr,                         &
2148                      QS=qs_curr,                         &
2149                      QH=qg_curr,                         &
2150  !                    CCW=qnc_curr,                       &
2151                      CCW=qndrop_curr,                    &
2152                      CRW=qnr_curr,                       &
2153                      CCI=qni_curr,                       &
2154                      CSW=qns_curr,                       &
2155                      CHW=qng_curr,                       &
2156                      VHW=qvolg_curr,                     &
2157                      PII=pi_phy,                         &
2158                      P=p,                                &
2159                      W=w,                                &
2160                      DZ=dz8w,                            &
2161                      DTP=dt,                             &
2162                      DN=rho,                             &
2163                      RAINNC   = RAINNC,                  &
2164                      RAINNCV  = RAINNCV,                 &
2165                      SNOWNC   = SNOWNC,                  &
2166                      SNOWNCV  = SNOWNCV,                 &
2167                      HAILNC   = HAILNC,                  &
2168                      HAILNCV  = HAILNCV,                 &
2169                      GRPLNC   = GRAUPELNC,               &
2170                      GRPLNCV  = GRAUPELNCV,              &
2171                      SR=SR,                              &
2172                      dbz      = refl_10cm,               &
2173 #if ( WRF_CHEM == 1 )
2174                     WETSCAV_ON = config_flags%wetscav_onoff == 1, &
2175                     EVAPPROD=evapprod,RAINPROD=rainprod, &
2176 #endif
2177                      nssl_progn=nssl_progn,              &
2178                       diagflag = diagflag,               &
2179                      cu_used=cu_used,                    &
2180                      qrcuten=qrcuten,                    &  ! hm
2181                      qscuten=qscuten,                    &  ! hm
2182                      qicuten=qicuten,                    &  ! hm
2183                      qccuten=qccuten,                    &  ! hm
2184                      re_cloud=re_cloud,                  &
2185                      re_ice=re_ice,                      &
2186                      re_snow=re_snow,                    &
2187                      has_reqc=has_reqc,                  & ! ala G. Thompson
2188                      has_reqi=has_reqi,                  & ! ala G. Thompson
2189                      has_reqs=has_reqs,                  & ! ala G. Thompson
2190                   IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde, &
2191                   IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme, &
2192                   ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte  &
2193                                                                     )
2195         ELSE
2196            Call wrf_error_fatal( 'arguments not present for calling nssl_2momg')
2197         ENDIF
2199     CASE (NSSL_2MOMCCN)
2200          CALL wrf_debug(100, 'microphysics_driver: calling nssl_2momccn')
2201          IF (PRESENT (QV_CURR) .AND.                           &
2202              PRESENT (QC_CURR) .AND. PRESENT (QNDROP_CURR)  .AND. &
2203              PRESENT (QR_CURR) .AND. PRESENT (QNR_CURR)  .AND. &
2204              PRESENT (QI_CURR) .AND. PRESENT (QNI_CURR)  .AND. &
2205              PRESENT (QS_CURR) .AND. PRESENT (QNS_CURR)  .AND. &
2206              PRESENT (QG_CURR) .AND. PRESENT (QNG_CURR)  .AND. &
2207              PRESENT (QH_CURR) .AND. PRESENT (QNH_CURR)  .AND. &
2208              PRESENT (RAINNC ) .AND. PRESENT (RAINNCV)   .AND. &
2209 #if (EM_CORE==1)
2210              PRESENT (SNOWNC ) .AND. PRESENT (SNOWNCV)   .AND. &
2211              PRESENT (HAILNC ) .AND. PRESENT (HAILNCV)   .AND. &
2212              PRESENT (GRAUPELNC).AND.PRESENT (GRAUPELNCV).AND. &
2213 #endif
2214              PRESENT ( W      )  .AND. &
2215              PRESENT (QVOLG_CURR) .AND. F_QVOLG  .AND.         &
2216              PRESENT (QVOLH_CURR) .AND. F_QVOLH  .AND.         &
2217              PRESENT( QNN_CURR )                          ) THEN
2218              
2220          CALL nssl_2mom_driver(                          &
2221                      ITIMESTEP=itimestep,                &
2222                      TH=th,                              &
2223                      QV=qv_curr,                         &
2224                      QC=qc_curr,                         &
2225                      QR=qr_curr,                         &
2226                      QI=qi_curr,                         &
2227                      QS=qs_curr,                         &
2228                      QH=qg_curr,                         &
2229                      QHL=qh_curr,                        &
2230 !                     CCW=qnc_curr,                       &
2231                      CCW=qndrop_curr,                    &
2232                      CRW=qnr_curr,                       &
2233                      CCI=qni_curr,                       &
2234                      CSW=qns_curr,                       &
2235                      CHW=qng_curr,                       &
2236                      CHL=qnh_curr,                       &
2237                      VHW=qvolg_curr,                     &
2238                      VHL=qvolh_curr,                     &
2239                      cn=qnn_curr,                        &
2240                      PII=pi_phy,                         &
2241                      P=p,                                &
2242                      W=w,                                &
2243                      DZ=dz8w,                            &
2244                      DTP=dt,                             &
2245                      DN=rho,                             &
2246                      RAINNC   = RAINNC,                  &
2247                      RAINNCV  = RAINNCV,                 &
2248                      SNOWNC   = SNOWNC,                  &
2249                      SNOWNCV  = SNOWNCV,                 &
2250                      HAILNC   = HAILNC,                  &
2251                      HAILNCV  = HAILNCV,                 &
2252                      GRPLNC   = GRAUPELNC,               &
2253                      GRPLNCV  = GRAUPELNCV,              &
2254                      SR=SR,                              &
2255                      dbz      = refl_10cm,               &
2256 #if ( WRF_CHEM == 1 )
2257                      WETSCAV_ON = config_flags%wetscav_onoff == 1, &
2258                      EVAPPROD=evapprod,RAINPROD=rainprod,&
2259 #endif
2260                      nssl_progn=nssl_progn,              &
2261                      diagflag = diagflag,                &
2262                      ke_diag = ke_diag,                &
2263                      cu_used=cu_used,                    &
2264                      qrcuten=qrcuten,                    &  ! hm
2265                      qscuten=qscuten,                    &  ! hm
2266                      qicuten=qicuten,                    &  ! hm
2267                      qccuten=qccuten,                    &  ! hm
2268                      re_cloud=re_cloud,                  &
2269                      re_ice=re_ice,                      &
2270                      re_snow=re_snow,                    &
2271                      has_reqc=has_reqc,                  & ! ala G. Thompson
2272                      has_reqi=has_reqi,                  & ! ala G. Thompson
2273                      has_reqs=has_reqs,                  & ! ala G. Thompson
2274                   IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde, &
2275                   IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme, &
2276                   ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte  &
2277                                                                     )
2278         ELSE
2279            Call wrf_error_fatal( 'arguments not present for calling nssl_2momccn')
2280         ENDIF
2282         CASE (GSFCGCESCHEME)
2283              CALL wrf_debug ( 100 , 'microphysics_driver: calling GSFCGCE' )
2284              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR ) .AND.  &
2285                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR ) .AND.  &
2286                   PRESENT( QS_CURR )                           .AND.  &
2287                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV ) .AND.  &
2288                   PRESENT( HAIL    ) .AND. PRESENT ( ICE2    ) .AND.  &
2289                   PRESENT( Z       ) .AND. PRESENT ( W       )  ) THEN
2290                CALL gsfcgce(                                        &
2291                   TH=th                                             &
2292                  ,QV=qv_curr                                        &
2293                  ,QL=qc_curr                                        &
2294                  ,QR=qr_curr                                        &
2295                  ,QI=qi_curr                                        &
2296                  ,QS=qs_curr                                        &
2297                  ,RHO=rho, PII=pi_phy, P=p, DT_IN=dt, Z=z           &
2298                  ,HT=ht, DZ8W=dz8w, GRAV=G                          &
2299                  ,RHOWATER=rhowater, RHOSNOW=rhosnow                &
2300                  ,ITIMESTEP=itimestep                               &
2301                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2302                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2303                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2304                  ,RAINNC=rainnc, RAINNCV=rainncv                    &
2305                  ,SNOWNC=snownc, SNOWNCV=snowncv ,SR=sr             &
2306                  ,GRAUPELNC=graupelnc ,GRAUPELNCV=graupelncv        &
2307                  ,REFL_10CM=refl_10cm                               &  ! added for radar reflectivity
2308                  ,diagflag=diagflag                                 &  ! added for radar reflectivity
2309                  ,do_radar_ref=do_radar_ref                         &  ! added for radar reflectivity
2310                  ,F_QG=f_qg                                         &
2311                  ,QG=qg_curr                                        &
2312                  ,IHAIL=hail, ICE2=ice2                             &
2313                                                                     )
2314 ! HAIL = 1,  run gsfcgce with hail option
2315 !        0,  run gsfcgce with graupel option   <---- default
2316 !        note: no effect if ice2 = 1
2317 ! ICE2 = 1,  run gsfcgce with only snow, ice
2318 !        2,  run gsfcgce with only graupel, ice
2319 !        0,  run gsfcgce with snow, ice and hail/graupel   <---- default
2321              ELSE
2322                 CALL wrf_error_fatal ( 'arguments not present for calling GSFCGCE' )
2323              ENDIF
2325         CASE (NUWRF4ICESCHEME)
2326              CALL wrf_debug ( 100 , 'microphysics_driver: calling NUWRF4ICE' )
2327              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR ) .AND.  &
2328                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR ) .AND.  &
2329                   PRESENT( QS_CURR ) .AND. PRESENT ( QG_CURR ) .AND.  &
2330                   PRESENT( QH_CURR )                           .AND.  &
2331                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV ) .AND.  &
2332                   PRESENT( HAIL    ) .AND. PRESENT ( ICE2    ) .AND.  &
2333                   PRESENT( Z       ) .AND. PRESENT ( W       )  ) THEN
2334                CALL gsfcgce_4ice_nuwrf(                             &
2335                   TH=th                                             &
2336                  ,QV=qv_curr                                        &
2337                  ,QL=qc_curr                                        &
2338                  ,QR=qr_curr                                        &
2339                  ,QI=qi_curr                                        &
2340                  ,QS=qs_curr                                        &
2341                  ,QH=qh_curr                                        &
2342                  ,RHO=rho, PII=pi_phy, P=p, DT_IN=dt, Z=z           &
2343                  ,HT=ht, DZ8W=dz8w, GRAV=G, W=w                     &
2344                  ,RHOWATER=rhowater, RHOSNOW=rhosnow                &
2345                  ,ITIMESTEP=itimestep, XLAND=xland, DX=dx           &
2346                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2347                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2348                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2349                  ,RAINNC=rainnc, RAINNCV=rainncv                    &
2350                  ,SNOWNC=snownc, SNOWNCV=snowncv ,SR=sr             &
2351                  ,GRAUPELNC=graupelnc ,GRAUPELNCV=graupelncv        &
2352                  ,HAILNC=hailnc, HAILNCV=hailncv                    &
2353                  ,REFL_10CM=refl_10cm                               &  ! added for radar reflectivity
2354                  ,diagflag=diagflag                                 &  ! added for radar reflectivity
2355                  ,do_radar_ref=do_radar_ref                         &  ! added for radar reflectivity
2356                  ,F_QG=f_qg                                         &
2357                  ,QG=qg_curr                                        &
2358 !                 ,IHAIL=hail, ICE4=ice2                             & ! hardcoded in the 4ice scheme
2359                                                                        ! ihail = 0, ice4=4 
2360 !NUWRF JJS 20110525 vvvvv
2361                  ,PHYSC=physc, PHYSE=physe, PHYSD=physd             &
2362                  ,PHYSS=physs, PHYSM=physm, PHYSF=physf             &
2363                  ,ACPHYSC=acphysc, ACPHYSE=acphyse, ACPHYSD=acphysd  &
2364                  ,ACPHYSS=acphyss, ACPHYSM=acphysm, ACPHYSF=acphysf  &
2365                  ,RE_CLOUD_GSFC=re_cloud_gsfc                       &
2366                  ,RE_RAIN_GSFC=re_rain_gsfc                         &
2367                  ,RE_ICE_GSFC=re_ice_gsfc                           &
2368                  ,RE_SNOW_GSFC=re_snow_gsfc                         &
2369                  ,RE_GRAUPEL_GSFC=re_graupel_gsfc                   &
2370                  ,RE_HAIL_GSFC=re_hail_gsfc                         &
2371                  ,PRECR3D=precr3d,PRECI3D=preci3d,PRECS3D=precs3d   &
2372                  ,PRECG3D=precg3d,PRECH3D=prech3d                   &
2373 #if ( WRF_CHEM == 1)
2374                  ,AERO=aero                                         &
2375                  ,ICN_DIAG=icn_diag, NC_DIAG=nc_diag, GID=ID        &
2376                  ,CHEM_OPT=chem_opt                                 &
2377                  ,GSFCGCE_GOCART_COUPLING=gsfcgce_gocart_coupling   &
2378 #endif
2379 !NUWRF JJS 20110525 ^^^^^
2380                                                                     )
2382                do j=jts,jte
2383                   do k=kts,kte
2384                      do i=its,ite
2385                         ! Snapshot total latent heating rate [K/s]
2386                         phys_tot(i,k,j) = physc(i,k,j) + physe(i,k,j) + &
2387                              physd(i,k,j) + physs(i,k,j) + physm(i,k,j) + &
2388                              physf(i,k,j)
2389                         ! Accumulated total latent heating [K]
2390                         acphys_tot(i,k,j) = acphysc(i,k,j) + acphyse(i,k,j) + &
2391                              acphysd(i,k,j) + acphyss(i,k,j) + acphysm(i,k,j) + &
2392                              acphysf(i,k,j)
2393                         
2394                      end do
2395                   end do
2396                end do
2398              ELSE
2399                 CALL wrf_error_fatal ( 'arguments not present for calling NUWRF4ICESFCGCE' )
2400              ENDIF
2402         CASE (LINSCHEME)
2403              CALL wrf_debug ( 100 , 'microphysics_driver: calling lin_et_al' )
2404              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR ) .AND.  &
2405                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR ) .AND.  &
2406                   PRESENT( QS_CURR )                           .AND.  &
2407                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV ) .AND.  &
2408                   PRESENT( Z       ) ) THEN
2409                CALL lin_et_al(                                      &
2410                   TH=th                                             &
2411                  ,QV=qv_curr                                        &
2412                  ,QL=qc_curr                                        &
2413                  ,QR=qr_curr                                        &
2414                  ,QI=qi_curr                                        &
2415                  ,QS=qs_curr                                        &
2416                  ,QLSINK=qlsink                                     &
2417                  ,RHO=rho, PII=pi_phy, P=p, DT_IN=dt, Z=z           &
2418                  ,HT=ht, DZ8W=dz8w, GRAV=G,  CP=cp                  &
2419                  ,RAIR=r_d, RVAPOR=R_v                              &
2420                  ,XLS=xls, XLV=xlv, XLF=xlf                         &
2421                  ,RHOWATER=rhowater, RHOSNOW=rhosnow                &
2422                  ,EP2=ep_2,SVP1=svp1,SVP2=svp2                      &
2423                  ,SVP3=svp3,SVPT0=svpt0                             &
2424                  ,RAINNC=rainnc, RAINNCV=rainncv                    &
2425                  ,SNOWNC=snownc, SNOWNCV=snowncv                    &
2426                  ,GRAUPELNC=graupelnc, GRAUPELNCV=graupelncv, SR=sr &
2427                  ,REFL_10CM=refl_10cm                               &  ! added for radar reflectivity
2428                  ,diagflag=diagflag                                 &  ! added for radar reflectivity
2429                  ,do_radar_ref=do_radar_ref                         &  ! added for radar reflectivity
2430                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2431                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2432                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2433                  ,PRECR=precr,PRECI=preci,PRECS=precs,PRECG=precg   &
2434                  ,F_QG=f_qg, F_QNDROP=f_qndrop                      &
2435                  ,QG=qg_curr                                        &
2436                  ,QNDROP=qndrop_curr                                &
2437                                                                     )
2438              ELSE
2439                 CALL wrf_error_fatal ( 'arguments not present for calling lin_et_al' )
2440              ENDIF
2442        CASE (SBU_YLINSCHEME)
2443              CALL wrf_debug ( 100 , 'microphysics_driver: calling sbu_ylin' )
2444              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR ) .AND.  &
2445                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR ) .AND.  &
2446                   PRESENT( QS_CURR )                           .AND.  &
2447                   PRESENT( RI_CURR )                           .AND.  &
2448                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV ) .AND.  &
2449                   PRESENT( Z       ) ) THEN
2450                CALL sbu_ylin(                                       &
2451                   TH=th                                             &
2452                  ,QV=qv_curr                                        &
2453                  ,QL=qc_curr                                        &
2454                  ,QR=qr_curr                                        &
2455                  ,QI=qi_curr                                        &
2456                  ,QS=qs_curr                                        &
2457                  ,RI3D=ri_curr                                      &
2458 !                 ,QLSINK=qlsink                                     &
2459                  ,RHO=rho, PII=pi_phy, P=p, DT_IN=dt, Z=z           &
2460                  ,HT=ht, DZ8W=dz8w                                  &
2461 !                 , GRAV=G,  CP=cp                  &
2462 !                 ,RAIR=r_d, RVAPOR=R_v                              &
2463 !                 ,XLS=xls, XLV=xlv, XLF=xlf                         &
2464 !                 ,RHOWATER=rhowater, RHOSNOW=rhosnow                &
2465 !                 ,EP2=ep_2,SVP1=svp1,SVP2=svp2                      &
2466 !                 ,SVP3=svp3,SVPT0=svpt0                             &
2467                  ,RAINNC=rainnc, RAINNCV=rainncv                    &
2468 !                 ,SNOWNC=snownc, SNOWNCV=snowncv                    &
2469 !                 ,GRAUPELNC=graupelnc, GRAUPELNCV=graupelncv, SR=sr &
2470                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2471                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2472                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2473 !                 ,PRECR=precr,PRECI=preci,PRECS=precs,PRECG=precg   &
2474 !                 ,F_QG=f_qg                                         &
2475 !                 ,F_QNDROP=f_qndrop                      &
2476 !                 ,QG=qg_curr                                        &
2477 !                 ,QNDROP=qndrop_curr                                &
2478                                                                      )
2479              ELSE
2480                 CALL wrf_error_fatal ( 'arguments not present for calling sbu_ylin' )
2481              ENDIF
2484         CASE (WSM3SCHEME)
2485              CALL wrf_debug ( 100 , 'microphysics_driver: calling wsm3' )
2486              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR ) .AND.  &
2487                   PRESENT( QR_CURR ) .AND.                            &
2488                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV ) .AND.  &
2489                   PRESENT( W       )                            ) THEN
2490              CALL wsm3(                                             &
2491                   TH=th                                             &
2492                  ,Q=qv_curr                                         &
2493                  ,QCI=qc_curr                                       &
2494                  ,QRS=qr_curr                                       &
2495                  ,W=w,DEN=rho,PII=pi_phy,P=p,DELZ=dz8w              &
2496                  ,DELT=dt,G=g,CPD=cp,CPV=cpv                        &
2497                  ,RD=r_d,RV=r_v,T0C=svpt0                           &
2498                  ,EP1=ep_1, EP2=ep_2, QMIN=epsilon                  &
2499                  ,XLS=xls, XLV0=xlv, XLF0=xlf                       &
2500                  ,DEN0=rhoair0, DENR=rhowater                       &
2501                  ,CLIQ=cliq,CICE=cice,PSAT=psat                     &
2502                  ,RAIN=rainnc ,RAINNCV=rainncv                      &
2503                  ,SNOW=snownc ,SNOWNCV=snowncv                      &
2504                  ,SR=sr                                             &
2505 # ifndef _ACCEL
2506                  ,has_reqc=has_reqc                                 &  ! for radiation +
2507                  ,has_reqi=has_reqi                                 &
2508                  ,has_reqs=has_reqs                                 &
2509                  ,re_cloud=re_cloud                                 &
2510                  ,re_ice=re_ice                                     &
2511                  ,re_snow=re_snow                                   &  ! for radiation -  
2512 # endif
2513                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2514                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2515                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2516                                                                     )
2517              ELSE
2518                 CALL wrf_error_fatal ( 'arguments not present for calling wsm3' )
2519              ENDIF
2521 #ifndef XEON_OPTIMIZED_WSM5
2522         CASE (WSM5SCHEME)
2523              CALL wrf_debug ( 100 , 'microphysics_driver: calling wsm5' )
2524              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR ) .AND.  &
2525                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR ) .AND.  &
2526                   PRESENT( QS_CURR ) .AND.                            &
2527                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV )  ) THEN
2528              CALL wsm5(                                             &
2529                   TH=th                                             &
2530                  ,Q=qv_curr                                         &
2531                  ,QC=qc_curr                                        &
2532                  ,QR=qr_curr                                        &
2533                  ,QI=qi_curr                                        &
2534                  ,QS=qs_curr                                        &
2535                  ,DEN=rho,PII=pi_phy,P=p,DELZ=dz8w                  &
2536                  ,DELT=dt,G=g,CPD=cp,CPV=cpv                        &
2537                  ,RD=r_d,RV=r_v,T0C=svpt0                           &
2538                  ,EP1=ep_1, EP2=ep_2, QMIN=epsilon                  &
2539                  ,XLS=xls, XLV0=xlv, XLF0=xlf                       &
2540                  ,DEN0=rhoair0, DENR=rhowater                       &
2541                  ,CLIQ=cliq,CICE=cice,PSAT=psat                     &
2542                  ,RAIN=rainnc ,RAINNCV=rainncv                      &
2543                  ,SNOW=snownc ,SNOWNCV=snowncv                      &
2544                  ,SR=sr                                             &
2545 # ifndef _ACCEL
2546                  ,REFL_10CM=refl_10cm                               &  ! added for radar reflectivity
2547                  ,diagflag=diagflag                                 &  ! added for radar reflectivity
2548                  ,do_radar_ref=do_radar_ref                         &  ! added for radar reflectivity
2549                  ,has_reqc=has_reqc                                 &  ! for radiation +
2550                  ,has_reqi=has_reqi                                 &
2551                  ,has_reqs=has_reqs                                 &
2552                  ,re_cloud=re_cloud                                 &
2553                  ,re_ice=re_ice                                     &
2554                  ,re_snow=re_snow                                   &  ! for radiation -  
2555 # endif
2556                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2557                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2558                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2559                                                                     )
2560              ELSE
2561                 CALL wrf_error_fatal ( 'arguments not present for calling wsm5' )
2562              ENDIF
2563 #endif
2565         CASE (WSM6SCHEME)
2566              CALL wrf_debug ( 100 , 'microphysics_driver: calling wsm6' )
2567              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR ) .AND.  &
2568                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR ) .AND.  &
2569                   PRESENT( QS_CURR ) .AND. PRESENT ( QG_CURR ) .AND.  &
2570                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV )  ) THEN
2571              CALL wsm6(                                             &
2572                   TH=th                                             &
2573                  ,Q=qv_curr                                         &
2574                  ,QC=qc_curr                                        &
2575                  ,QR=qr_curr                                        &
2576                  ,QI=qi_curr                                        &
2577                  ,QS=qs_curr                                        &
2578                  ,QG=qg_curr                                        &
2579                  ,DEN=rho,PII=pi_phy,P=p,DELZ=dz8w                  &
2580                  ,DELT=dt,G=g,CPD=cp,CPV=cpv                        &
2581                  ,RD=r_d,RV=r_v,T0C=svpt0                           &
2582                  ,EP1=ep_1, EP2=ep_2, QMIN=epsilon                  &
2583                  ,XLS=xls, XLV0=xlv, XLF0=xlf                       &
2584                  ,DEN0=rhoair0, DENR=rhowater                       &
2585                  ,CLIQ=cliq,CICE=cice,PSAT=psat                     &
2586                  ,RAIN=rainnc ,RAINNCV=rainncv                      &
2587                  ,SNOW=snownc ,SNOWNCV=snowncv                      &
2588                  ,SR=sr                                             &
2589                  ,REFL_10CM=refl_10cm                               &  ! added for radar reflectivity
2590                  ,diagflag=diagflag                                 &  ! added for radar reflectivity
2591                  ,do_radar_ref=do_radar_ref                         &  ! added for radar reflectivity
2592                  ,GRAUPEL=graupelnc ,GRAUPELNCV=graupelncv          &
2593                  ,has_reqc=has_reqc                                 &  ! for radiation +
2594                  ,has_reqi=has_reqi                                 &
2595                  ,has_reqs=has_reqs                                 &
2596                  ,re_cloud=re_cloud                                 &
2597                  ,re_ice=re_ice                                     &
2598                  ,re_snow=re_snow                                   &  ! for radiation -  
2599                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2600                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2601                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2602 #if ( WRF_CHEM == 1 )
2603                  ,WETSCAV_ON=config_flags%wetscav_onoff==1          &
2604                  ,EVAPPROD=evapprod,RAINPROD=rainprod               &
2605 #endif
2606                                                                     )
2607              ELSE
2608                 CALL wrf_error_fatal ( 'arguments not present for calling wsm6' )
2609              ENDIF
2611         CASE (WSM6RSCHEME)
2612              CALL wrf_debug ( 100 , 'microphysics_driver: calling wsm6r' )
2613              IF ( PRESENT( QV_CURR ) .AND. PRESENT( QR_CURR ) .AND. &
2614                   PRESENT( QC_CURR ) .AND. PRESENT( QS_CURR ) .AND. &
2615                   PRESENT( QI_CURR ) .AND. PRESENT( QG_CURR ) .AND. &
2616                   PRESENT( RAINNC  ) .AND. PRESENT( RAINNCV )) THEN
2617                CALL wsm6r(                                          &
2618                   TH=th                                             &
2619                  ,Q =qv_curr,Qc=qc_curr,Qi=qi_curr                   &
2620                  ,Qr=qr_curr,Qs=qs_curr,Qg=qg_curr                   &
2621                  ,DEN=rho, PII=pi_phy                               &
2622                  ,P=p                                               &
2623                  ,DELZ=dz8w, DELT=dt &
2624                  ,RAIN=rainnc,RAINNCV=rainncv                     &
2625                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2626                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2627                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2628                                                                     )
2629              ELSE
2630                 CALL wrf_error_fatal ( 'arguments not present for calling wsm6r' )
2631              ENDIF
2633         CASE (WSM7SCHEME)
2634              CALL wrf_debug ( 100 , 'microphysics_driver: calling wsm7' )
2635              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR ) .AND.  &
2636                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR ) .AND.  &
2637                   PRESENT( QS_CURR ) .AND. PRESENT ( QG_CURR ) .AND.  &
2638                   PRESENT( QH_CURR ) .AND.                            &
2639                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV )  ) THEN
2640              CALL wsm7(                                             &
2641                   TH=th                                             &
2642                  ,Q=qv_curr                                         &
2643                  ,QC=qc_curr                                        &
2644                  ,QR=qr_curr                                        &
2645                  ,QI=qi_curr                                        &
2646                  ,QS=qs_curr                                        &
2647                  ,QG=qg_curr                                        &
2648                  ,QH=qh_curr                                        &
2649                  ,DEN=rho,PII=pi_phy,P=p,DELZ=dz8w                  &
2650                  ,DELT=dt,G=g,CPD=cp,CPV=cpv                        &
2651                  ,RD=r_d,RV=r_v,T0C=svpt0                           &
2652                  ,EP1=ep_1, EP2=ep_2, QMIN=epsilon                  &
2653                  ,XLS=xls, XLV0=xlv, XLF0=xlf                       &
2654                  ,DEN0=rhoair0, DENR=rhowater                       &
2655                  ,CLIQ=cliq,CICE=cice,PSAT=psat                     &
2656                  ,RAIN=rainnc ,RAINNCV=rainncv                      &
2657                  ,SNOW=snownc ,SNOWNCV=snowncv                      &
2658                  ,SR=sr                                             &
2659                  ,REFL_10CM=refl_10cm                               &  ! added for radar reflectivity
2660                  ,diagflag=diagflag                                 &  ! added for radar reflectivity
2661                  ,do_radar_ref=do_radar_ref                         &  ! added for radar reflectivity
2662                  ,GRAUPEL=graupelnc ,GRAUPELNCV=graupelncv          &
2663                  ,HAIL=hailnc ,HAILNCV=hailncv                      &
2664                  ,has_reqc=has_reqc                                 &  ! for radiation +
2665                  ,has_reqi=has_reqi                                 &
2666                  ,has_reqs=has_reqs                                 &
2667                  ,re_cloud=re_cloud                                 &
2668                  ,re_ice=re_ice                                     &
2669                  ,re_snow=re_snow                                   &  ! for radiation -
2670                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2671                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2672                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2673                                                                     )
2674              ELSE
2675                 CALL wrf_error_fatal ( 'arguments not present for calling wsm7' )
2676              ENDIF
2678         CASE (WDM5SCHEME)
2679              CALL wrf_debug ( 100 , 'microphysics_driver: calling wdm5' )
2680              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR ) .AND.  &
2681                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR ) .AND.  &
2682                   PRESENT( QS_CURR ) .AND. PRESENT( QNN_CURR ) .AND.  &
2683                   PRESENT ( QNC_CURR ) .AND. PRESENT( QNR_CURR ).AND.  &
2684                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV )  ) THEN
2685              CALL wdm5(                                             &
2686                   TH=th                                             &
2687                  ,Q=qv_curr                                         &
2688                  ,QC=qc_curr                                        &
2689                  ,QR=qr_curr                                        &
2690                  ,QI=qi_curr                                        &
2691                  ,QS=qs_curr                                        &
2692                  ,NN=qnn_curr                                       &
2693                  ,NC=qnc_curr                                       &
2694                  ,NR=qnr_curr                                       &
2695                  ,DEN=rho,PII=pi_phy,P=p,DELZ=dz8w                  &
2696                  ,DELT=dt,G=g,CPD=cp,CPV=cpv,CCN0=ccn_conc          & ! RAS
2697                  ,RD=r_d,RV=r_v,T0C=svpt0                           &
2698                  ,EP1=ep_1, EP2=ep_2, QMIN=epsilon                  &
2699                  ,XLS=xls, XLV0=xlv, XLF0=xlf                       &
2700                  ,DEN0=rhoair0, DENR=rhowater                       &
2701                  ,CLIQ=cliq,CICE=cice,PSAT=psat                     &
2702                  ,RAIN=rainnc ,RAINNCV=rainncv                      &
2703                  ,SNOW=snownc ,SNOWNCV=snowncv                      &
2704                  ,SR=sr                                             &
2705                  ,REFL_10CM=refl_10cm                               &  ! added for radar reflectivity
2706                  ,diagflag=diagflag                                 &  ! added for radar reflectivity
2707                  ,do_radar_ref=do_radar_ref                         &  ! added for radar reflectivity
2708                  ,has_reqc=has_reqc                                 &  ! for radiation +
2709                  ,has_reqi=has_reqi                                 &
2710                  ,has_reqs=has_reqs                                 &
2711                  ,re_cloud=re_cloud                                 &
2712                  ,re_ice=re_ice                                     &
2713                  ,re_snow=re_snow                                   &  ! for radiation -       
2714                  ,ITIMESTEP=itimestep                               & 
2715                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2716                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2717                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2718                                                                     )
2719              ELSE
2720                 CALL wrf_error_fatal ( 'arguments not present for calling wdm5')
2721              ENDIF
2723        CASE (WDM6SCHEME)
2724              CALL wrf_debug ( 100 , 'microphysics_driver: calling wdm6' )
2725              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR ) .AND.  &
2726                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR ) .AND.  &
2727                   PRESENT( QS_CURR ) .AND. PRESENT ( QG_CURR ) .AND.  &
2728                   PRESENT( QNN_CURR ) .AND. PRESENT ( QNC_CURR ) .AND. &
2729                   PRESENT( QNR_CURR ).AND.                            &
2730                  PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV )  ) THEN
2731              CALL wdm6(                                             &
2732                   TH=th                                             &
2733                  ,Q=qv_curr                                         &
2734                  ,QC=qc_curr                                        &
2735                  ,QR=qr_curr                                        &
2736                  ,QI=qi_curr                                        &
2737                  ,QS=qs_curr                                        &
2738                  ,QG=qg_curr                                        &
2739                  ,NN=qnn_curr                                       &
2740                  ,NC=qnc_curr                                       &
2741                  ,NR=qnr_curr                                       &
2742                  ,DEN=rho,PII=pi_phy,P=p,DELZ=dz8w                  &
2743                  ,DELT=dt,G=g,CPD=cp,CPV=cpv,CCN0=ccn_conc          & ! RAS
2744                  ,RD=r_d,RV=r_v,T0C=svpt0                           &
2745                  ,EP1=ep_1, EP2=ep_2, QMIN=epsilon                  &
2746                  ,XLS=xls, XLV0=xlv, XLF0=xlf                       &
2747                  ,DEN0=rhoair0, DENR=rhowater                       &
2748                  ,CLIQ=cliq,CICE=cice,PSAT=psat                     &
2749                  ,xland=xland                                       &  ! land mask, 1: land, 2: water
2750                  ,RAIN=rainnc ,RAINNCV=rainncv                      &
2751                  ,SNOW=snownc ,SNOWNCV=snowncv                      &
2752                  ,SR=sr                                             &
2753                  ,REFL_10CM=refl_10cm                               &  ! added for radar reflectivity
2754                  ,diagflag=diagflag                                 &  ! added for radar reflectivity
2755                  ,do_radar_ref=do_radar_ref                         &  ! added for radar reflectivity
2756                  ,GRAUPEL=graupelnc ,GRAUPELNCV=graupelncv          &
2757                  ,ITIMESTEP=itimestep                               & 
2758                  ,has_reqc=has_reqc                                 &  ! for radiation +
2759                  ,has_reqi=has_reqi                                 &
2760                  ,has_reqs=has_reqs                                 &
2761                  ,re_cloud=re_cloud                                 &
2762                  ,re_ice=re_ice                                     & 
2763                  ,re_snow=re_snow                                   &  ! for radiation -  
2764                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2765                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2766                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2767                                                                     )
2768              ELSE
2769                CALL wrf_error_fatal ( 'arguments not present for calling wdm6')
2770              ENDIF
2772         CASE (WDM7SCHEME)
2773              CALL wrf_debug ( 100 , 'microphysics_driver: calling wdm7' )
2774              IF ( PRESENT( QV_CURR ) .AND. PRESENT ( QC_CURR ) .AND.  &
2775                   PRESENT( QR_CURR ) .AND. PRESENT ( QI_CURR ) .AND.  &
2776                   PRESENT( QS_CURR ) .AND. PRESENT ( QG_CURR ) .AND.  &
2777                   PRESENT( QH_CURR ) .AND.                            &
2778                   PRESENT( QNN_CURR ) .AND. PRESENT ( QNC_CURR ) .AND. &
2779                   PRESENT( QNR_CURR ).AND.                            &
2780                  PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV )  ) THEN
2781              CALL wdm7(                                             &
2782                   TH=th                                             &
2783                  ,Q=qv_curr                                         &
2784                  ,QC=qc_curr                                        &
2785                  ,QR=qr_curr                                        &
2786                  ,QI=qi_curr                                        &
2787                  ,QS=qs_curr                                        &
2788                  ,QG=qg_curr                                        &
2789                  ,QH=qh_curr                                        &
2790                  ,NN=qnn_curr                                       &
2791                  ,NC=qnc_curr                                       &
2792                  ,NR=qnr_curr                                       &
2793                  ,DEN=rho,PII=pi_phy,P=p,DELZ=dz8w                  &
2794                  ,DELT=dt,G=g,CPD=cp,CPV=cpv,CCN0=ccn_conc          & ! RAS
2795                  ,RD=r_d,RV=r_v,T0C=svpt0                           &
2796                  ,EP1=ep_1, EP2=ep_2, QMIN=epsilon                  &
2797                  ,XLS=xls, XLV0=xlv, XLF0=xlf                       &
2798                  ,DEN0=rhoair0, DENR=rhowater                       &
2799                  ,CLIQ=cliq,CICE=cice,PSAT=psat                     &
2800                  ,xland=xland                                       &  ! land mask, 1: land, 2: water
2801                  ,RAIN=rainnc ,RAINNCV=rainncv                      &
2802                  ,SNOW=snownc ,SNOWNCV=snowncv                      &
2803                  ,SR=sr                                             &
2804                  ,REFL_10CM=refl_10cm                               &  ! added for radar reflectivity
2805                  ,diagflag=diagflag                                 &  ! added for radar reflectivity
2806                  ,do_radar_ref=do_radar_ref                         &  ! added for radar reflectivity
2807                  ,GRAUPEL=graupelnc ,GRAUPELNCV=graupelncv          &
2808                  ,HAIL=hailnc ,HAILNCV=hailncv                      &
2809                  ,ITIMESTEP=itimestep                               &
2810                  ,has_reqc=has_reqc                                 &  ! for radiation +
2811                  ,has_reqi=has_reqi                                 &
2812                  ,has_reqs=has_reqs                                 &
2813                  ,re_cloud=re_cloud                                 &
2814                  ,re_ice=re_ice                                     &
2815                  ,re_snow=re_snow                                   &  ! for radiation -
2816                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2817                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2818                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2819                                                                     )
2820              ELSE
2821                CALL wrf_error_fatal ( 'arguments not present for calling wdm7')
2822              ENDIF
2824         CASE (ETAMPNEW)    !-- Operational 4-km High-Resolution Window (HRW) version
2825              CALL wrf_debug ( 100 , 'microphysics_driver: calling etampnew')
2827              IF ( PRESENT( qv_curr ) .AND. PRESENT( qt_curr ) .AND. &
2828                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV ) .AND.  &
2829                   PRESENT( mp_restart_state )                  .AND. &
2830                   PRESENT( tbpvs_state )                      .AND. &
2831                   PRESENT( tbpvs0_state )                       ) THEN
2832                CALL ETAMP_NEW(                                      &
2833                   ITIMESTEP=itimestep,DT=dt,DX=dx,DY=dy             &
2834                  ,DZ8W=dz8w,RHO_PHY=rho,P_PHY=p,PI_PHY=pi_phy,TH_PHY=th &
2835                  ,QV=qv_curr                                        &
2836                  ,QC=qc_curr                                        &
2837                  ,QS=qs_curr                                        &
2838                  ,QR=qr_curr                                        &
2839                  ,QT=qt_curr                                        &
2840                  ,LOWLYR=LOWLYR,SR=SR                               &
2841                  ,F_ICE_PHY=F_ICE_PHY,F_RAIN_PHY=F_RAIN_PHY         &
2842                  ,F_RIMEF_PHY=F_RIMEF_PHY                           &
2843                  ,RAINNC=rainnc,RAINNCV=rainncv                     &
2844                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2845                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2846                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2847                  ,MP_RESTART_STATE=mp_restart_state                 &
2848                  ,TBPVS_STATE=tbpvs_state,TBPVS0_STATE=tbpvs0_state &
2849                                                                     )
2850              ELSE
2851                 CALL wrf_error_fatal ( 'arguments not present for calling etampnew' )
2852              ENDIF
2853         CASE (FER_MP_HIRES)    !-- Operational Ferrier-Aligo High-Resolution Window(HRW) version
2854                             !   (2014/2 version) added by Weiguo Wang on
2855                             !   2014-11-19
2856              CALL wrf_debug ( 100 , 'microphysics_driver: calling etampnew')
2858              IF ( PRESENT( qv_curr ) .AND. PRESENT( qt_curr ) .AND. &
2859                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV ) .AND.  &
2860                   PRESENT( mp_restart_state )                  .AND. &
2861                   PRESENT( tbpvs_state )                      .AND. &
2862                   PRESENT( tbpvs0_state )                       ) THEN
2864              !  write(0,*)',f_qv,f_qc,f_qr,f_qi,f_qs,f_qg',f_qv,f_qc,f_qr,f_qi,f_qs,f_qg
2865              !  write(0,*)'max qi=',maxval(qi_curr(its:ite,kts:kte,jts:jte))
2866              !  write(0,*)'max qs=',maxval(qs_curr(its:ite,kts:kte,jts:jte))
2868                 CALL FER_HIRES(                                      &
2869                    ITIMESTEP=itimestep,DT=dt,DX=dx,DY=dy, GID=id &
2870                   ,RAINNC=rainnc,RAINNCV=rainncv                     &
2871                   ,DZ8W=dz8w,RHO_PHY=rho,P_PHY=p,PI_PHY=pi_phy,TH_PHY=th &
2872                   ,QV=qv_curr                                        &
2873                   ,QT=qt_curr                                        &
2874                   ,LOWLYR=LOWLYR,SR=SR                               &
2875                   ,F_ICE_PHY=F_ICE_PHY,F_RAIN_PHY=F_RAIN_PHY         &
2876                   ,F_RIMEF_PHY=F_RIMEF_PHY                           &
2877                   ,QC=qc_curr,QR=Qr_curr,QI=Qi_curr                  &
2878                   ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2879                   ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2880                   ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2881                                                                      )
2882              ELSE
2883                 CALL wrf_error_fatal ( 'arguments not present for calling fer_hires' )
2884              ENDIF
2886         CASE (FER_MP_HIRES_ADVECT)    !-- Operational Ferrier-Aligo High-Resolution Window(HRW) version
2887                             !   (2014/2 version) added by Weiguo Wang on
2888                             !   2014-11-19
2889                             !   Modified for advection, Sam Trahan, August 2015
2890              CALL wrf_debug ( 100 , 'microphysics_driver: calling etampnew')
2892              IF ( PRESENT( qv_curr ) .AND. PRESENT( qi_curr ) .AND. &
2893                   PRESENT( qc_curr ) .and. PRESENT(qrimef_curr) .AND.  &
2894                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV ) .AND.  &
2895                   PRESENT( mp_restart_state )                  .AND. &
2896                   PRESENT( tbpvs_state )                      .AND. &
2897                   PRESENT( tbpvs0_state )                       ) THEN
2899              !  write(0,*)',f_qv,f_qc,f_qr,f_qi,f_qs,f_qg',f_qv,f_qc,f_qr,f_qi,f_qs,f_qg
2900              !  write(0,*)'max qi=',maxval(qi_curr(its:ite,kts:kte,jts:jte))
2901              !  write(0,*)'max qs=',maxval(qs_curr(its:ite,kts:kte,jts:jte))
2903                 CALL FER_HIRES_ADVECT(                               &
2904                    ITIMESTEP=itimestep,DT=dt,DX=dx,DY=dy, GID=id &
2905                   ,RAINNC=rainnc,RAINNCV=rainncv                     &
2906                   ,DZ8W=dz8w,RHO_PHY=rho,P_PHY=p,PI_PHY=pi_phy,TH_PHY=th &
2907                   ,QV=qv_curr                                        &
2908                   ,LOWLYR=LOWLYR,SR=SR                               &
2909                   ,QC=qc_curr,QR=Qr_curr,QI=Qi_curr,QRIMEF=qrimef_curr    &
2910                   ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2911                   ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2912                   ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2913                                                                      )
2914              ELSE
2915                 CALL wrf_error_fatal ( 'arguments not present for calling fer_hires' )
2916              ENDIF
2918 #if(EM_CORE==1)
2919           CASE (CAMMGMPSCHEME)
2920              CALL wrf_debug ( 100 , 'microphysics_driver: calling CAMMGMPSCHEME')
2921              IF ( PRESENT( z          ) .AND. PRESENT( ht          ) .AND. &
2922                   PRESENT( qs_curr    ) .AND.                              &
2923                   PRESENT( qv_curr    ) .AND. PRESENT( qc_curr     ) .AND. &
2924                   PRESENT( qi_curr    ) .AND. PRESENT( f_qc        ) .AND. &
2925                   PRESENT( qr_curr    ) .AND. PRESENT( qndrop_curr ) .AND. &                  
2926                   PRESENT( f_qi       ) .AND. PRESENT( qnc_curr    ) .AND. &
2927                   PRESENT( RAINNCV    ) .AND. PRESENT( SNOWNCV     ) .AND. &
2928                   PRESENT( qns_curr   ) .AND. PRESENT( qnr_curr    ) .AND. &
2929 #if ( WRF_CHEM == 1 )
2930                   PRESENT( chem       ) .AND. PRESENT(dgnum4D      )  .AND. &
2931                   PRESENT( dgnumwet4D ) .AND.                           &
2932 #endif
2933                   PRESENT( qni_curr   ) .AND. PRESENT( RAINNC      ) ) THEN
2934 #if ( WRF_CHEM == 1 )
2935                 qv_b4mp(its:ite,kts:kte,jts:jte) = qv_curr(its:ite,kts:kte,jts:jte)
2936                 qc_b4mp(its:ite,kts:kte,jts:jte) = qc_curr(its:ite,kts:kte,jts:jte)
2937                 qi_b4mp(its:ite,kts:kte,jts:jte) = qi_curr(its:ite,kts:kte,jts:jte)
2938                 qs_b4mp(its:ite,kts:kte,jts:jte) = qs_curr(its:ite,kts:kte,jts:jte)
2939 #endif
2940                   
2941                 CALL CAMMGMP(ITIMESTEP=itimestep,DT=dt,P8W=p8w_hyd,P_HYD=p_hyd    &
2942                      ,T_PHY=t_phy,PI_PHY=pi_phy,Z_AT_W=z_at_w,QFX=qfx             &
2943                      ,TKE_PBL=tke_pbl,TURBTYPE3D=turbtype3d,SMAW3D=smaw3d     &
2944                      ,DLF3D=dlf,DLF2_3D=dlf2,RLIQ2D=rliq,Z_SEA_LEVEL=z            &
2945                      ,KVH3D=exch_h,HT=ht,ALT=alt,ACCUM_MODE=accum_mode            &
2946                      ,AITKEN_MODE=aitken_mode,COARSE_MODE=coarse_mode             &
2947                      ,ICWMRSH3D=icwmrsh3d,ICWMRDP3D=icwmrdp3d,SHFRC3D=shfrc3d     &
2948                      ,CMFMC3D=cmfmc3d,CMFMC2_3D=cmfmc2_3d                         &
2949                      ,CONFIG_FLAGS=config_flags,F_ICE_PHY=f_ice_phy               &
2950                      ,F_RAIN_PHY=f_rain_phy                                       &
2951 #if ( WRF_CHEM == 1 )
2952                      ,DGNUM4D=dgnum4D,DGNUMWET4D=dgnumwet4D                       &
2953 #endif
2954                      ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde           &
2955                      ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme           &
2956                      ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte           &
2957 !Output variables from CAMMGMP
2958                      ,TH=th,CLDFRA_OLD_MP=cldfra_old_mp,CLDFRA_MP=cldfra_mp       &
2959                      ,CLDFRA_MP_ALL=cldfra_mp_all,lradius=lradius,iradius=iradius &
2960                      ,CLDFRAI=cldfrai,CLDFRAL=cldfral                             &
2961                      ,CLDFRA_CONV=cldfra_conv,WSEDL3D=wsedl3d                     &
2962                      ,RAINNC=rainnc,RAINNCV=rainncv,SNOWNC=snownc,SNOWNCV=snowncv &
2963                      ,SR=sr,QV_CURR=qv_curr,QC_CURR=qc_curr,QI_CURR=qi_curr       &
2964                      ,QS_CURR=qs_curr,QR_CURR=qr_curr,NC3D=qnc_curr               &
2965                      ,NI3D=qni_curr,NS3D=qns_curr,NR3D=qnr_curr,QNDROP=qndrop_curr&
2966                      ,RH_OLD_MP=rh_old_mp,LCD_OLD_MP=lcd_old_mp                   &
2967 #if ( WRF_CHEM == 1 )
2968                      ,CHEM=chem                                                   &
2969                      ,QME3D=qme3d,PRAIN3D=prain3d,NEVAPR3D=nevapr3d               &
2970                      ,RATE1ORD_CW2PR_ST3D=rate1ord_cw2pr_st3d                     &
2971 #endif
2972                      ,XLAND=XLAND,SNOWH=SNOWH                                     &
2973                      )
2974              ELSE
2975                 CALL wrf_error_fatal ( 'arguments not present for calling CAMMGMP SCHEME' )
2976              ENDIF
2978 !    Added by Zhuxiao,  lscond (simplified Large-scale condensation scheme by Jimy )
2979 #if ( WRFPLUS == 1 )
2980         CASE (LSCONDSCHEME)
2981              CALL wrf_debug ( 100 , 'microphysics_driver: calling lscond' )
2982              IF ( PRESENT( QV_CURR ) .AND.                          &
2983                   PRESENT( RAINNC  ) .AND. PRESENT ( RAINNCV )) THEN
2984                                           
2985                CALL lscond(                                         &
2986                   TH=th                                              &
2987                  ,P=p                                               & 
2988                  ,QV=qv_curr                                        &
2989                  ,RHO=rho, PII=pi_phy, XLV=xlv, CP=cp               &  
2990                  ,EP2=ep_2,SVP1=svp1,SVP2=svp2                      &
2991                  ,SVP3=svp3,SVPT0=svpt0                             & 
2992                  ,R_V= R_v                                          & ! added
2993                  ,DZ8W=dz8w                                         &
2994                  ,RAINNC=rainnc,RAINNCV=rainncv                     &
2995                  ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
2996                  ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
2997                  ,ITS=its,ITE=ite, JTS=jts,JTE=jte, KTS=kts,KTE=kte &
2998                                                                     )
2999              ELSE
3000                 CALL wrf_error_fatal ( 'arguments not present for calling lscond' )
3001              ENDIF
3002 #endif
3003 #endif
3005           CASE (MADWRF_MP)
3006              CALL wrf_debug ( 100 , 'microphysics_driver: case MADWRF_MP')
3008       CASE DEFAULT
3010          WRITE( wrf_err_message , * ) 'The microphysics option does not exist: mp_physics = ', mp_physics
3011          CALL wrf_error_fatal ( wrf_err_message )
3013       END SELECT micro_select
3015    ENDDO
3016    !$OMP END PARALLEL DO
3018 #ifdef XEON_OPTIMIZED_WSM5
3019    ENDIF
3020 #endif
3022 ! by ZCX
3023 ! IF ( PRESENT (LWP) ) THEN
3024 !   DO ij = 1 , num_tiles
3025 !      its = i_start(ij)
3026 !      ite = i_end(ij)
3027 !      jts = j_start(ij)
3028 !      jte = j_end(ij)
3029 !      DO j=jts,jte
3030 !      DO i=its,ite
3031 !         lwp(i,j) = 0.0
3032 !         do k=kts,kte
3033 !           lwp(i,j)=lwp(i,j)+qc_curr(i,k,j)*rho(i,k,j)*dz8w(i,k,j)
3034 !         end do
3035 !      ENDDO
3036 !      ENDDO
3037 !   ENDDO
3038 ! ENDIF
3039 ! ZCX
3041    CALL wrf_debug ( 200 , 'microphysics_driver: returning from' )
3043    RETURN
3045    END SUBROUTINE microphysics_driver
3047    subroutine Add_multi_perturb_mp_perturbations (perts_qvapor, perts_qcloud, perts_qice, &
3048        perts_qsnow, perts_ni, pert_thom_qv, pert_thom_qc, pert_thom_qi, pert_thom_qs, &
3049        pert_thom_ni, qv_curr, qc_curr, qi_curr, qs_curr, qni_curr, qv_tmp, qc_tmp, qi_tmp, &
3050        qs_tmp, qni_tmp, its, ite, jts, jte, ims, ime, jms, jme, kms, kme, kts, kte)
3052      implicit none
3054      integer, intent(in) :: its, ite, jts, jte, ims, ime, jms, jme, kms, kme, kts, kte
3055      real, intent(in) :: pert_thom_qv, pert_thom_qc, pert_thom_qi, pert_thom_qs, pert_thom_ni
3056      real, dimension(ims:ime, kms:kme, jms:jme), optional, intent (in) :: perts_qvapor, perts_qcloud, perts_qice, &
3057          perts_qsnow, perts_ni
3058      real, dimension(ims:ime, kms:kme, jms:jme), intent (inout) :: qv_curr, qc_curr, qi_curr, qs_curr, qni_curr
3059      real, dimension (its:ite, kts:kte, jts:jte), intent (out) :: qv_tmp, qc_tmp, qi_tmp, qs_tmp, qni_tmp
3061      integer :: i, j, k
3064      do j = jts, jte
3065        do k = kts, kte
3066          do i = its, ite
3067            qv_tmp(i, k, j) = qv_curr(i, k, j)
3068            qv_curr(i, k, j) = max (QX_MIN, (1.0 + perts_qvapor(i, k, j) * pert_thom_qv) * qv_curr(i, k, j))
3069            qc_tmp(i, k, j) = qc_curr(i, k, j)
3070            qc_curr(i, k, j) = max (QX_MIN, (1.0 + perts_qcloud(i, k, j) * pert_thom_qc) * qc_curr(i, k, j))
3071            qi_tmp(i, k, j) = qi_curr(i, k, j)
3072            qi_curr(i, k, j) = max (QX_MIN, (1.0 + perts_qice(i, k, j) * pert_thom_qi) * qi_curr(i, k, j))
3073            qs_tmp(i, k, j) = qs_curr(i, k, j)
3074            qs_curr(i, k, j) = max (QX_MIN, (1.0 + perts_qsnow(i, k, j) * pert_thom_qs) * qs_curr(i, k, j))
3075            qni_tmp(i, k, j) = qni_curr(i, k, j)
3076            qni_curr(i, k, j) = max (NI_MIN, (1.0 + perts_ni(i, k, j) * pert_thom_ni) * qni_curr(i, k, j))
3077          end do
3078        end do
3079      end do
3081    end subroutine Add_multi_perturb_mp_perturbations
3083    subroutine Remove_multi_perturb_mp_perturbations (perts_qvapor, perts_qcloud, perts_qice, &
3084        perts_qsnow, perts_ni, pert_thom_qv, pert_thom_qc, pert_thom_qi, pert_thom_qs, &
3085        pert_thom_ni, qv_curr, qc_curr, qi_curr, qs_curr, qni_curr, qv_tmp, qc_tmp, qi_tmp, &
3086        qs_tmp, qni_tmp, its, ite, jts, jte, ims, ime, jms, jme, kms, kme, kts, kte)
3088      implicit none
3090      integer, intent(in) :: its, ite, jts, jte, ims, ime, jms, jme, kms, kme, kts, kte
3091      real, intent(in) :: pert_thom_qv, pert_thom_qc, pert_thom_qi, pert_thom_qs, pert_thom_ni
3092      real, dimension(ims:ime, kms:kme, jms:jme), optional, intent (in) :: perts_qvapor, perts_qcloud, perts_qice, &
3093          perts_qsnow, perts_ni
3094      real, dimension(ims:ime, kms:kme, jms:jme), intent (inout) :: qv_curr, qc_curr, qi_curr, qs_curr, qni_curr
3095      real, dimension (its:ite, kts:kte, jts:jte), intent (in) :: qv_tmp, qc_tmp, qi_tmp, qs_tmp, qni_tmp
3097      integer :: i, j, k
3100      do j = jts, jte
3101        do k = kts, kte
3102          do i = its, ite
3103            qv_curr(i, k, j) = max (QX_MIN, qv_curr(i, k, j) - perts_qvapor(i, k, j) * pert_thom_qv * qv_tmp(i, k, j))
3104            qc_curr(i, k, j) = max (QX_MIN, qc_curr(i, k, j) - perts_qcloud(i, k, j) * pert_thom_qc * qc_tmp(i, k, j))
3105            qi_curr(i, k, j) = max (QX_MIN, qi_curr(i, k, j) - perts_qice(i, k, j) * pert_thom_qi * qi_tmp(i, k, j))
3106            qs_curr(i, k, j) = max (QX_MIN, qs_curr(i, k, j) - perts_qsnow(i, k, j) * pert_thom_qs * qs_tmp(i, k, j))
3107            qni_curr(i, k, j) = max (NI_MIN, qni_curr(i, k, j) - perts_ni(i, k, j) * pert_thom_ni * qni_tmp(i, k, j))
3108          end do
3109        end do
3110      end do
3112    end subroutine Remove_multi_perturb_mp_perturbations
3114 END MODULE module_microphysics_driver