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