I believe this was a bug, no idea how it was even working before
[WRF.git] / chem / module_wetscav_driver.F
blob43cd5de5c267f67212e30aae9b4d3c576964613b
1 !**********************************************************************************  
2 ! This computer software was prepared by Battelle Memorial Institute, hereinafter
3 ! the Contractor, under Contract No. DE-AC05-76RL0 1830 with the Department of 
4 ! Energy (DOE). NEITHER THE GOVERNMENT NOR THE CONTRACTOR MAKES ANY WARRANTY,
5 ! EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE.
7 ! MOSAIC module: see module_mosaic_driver.F for references and terms of use
8 !**********************************************************************************  
10 MODULE module_wetscav_driver
12   REAL, PARAMETER :: mwso4 = 96.00   ! Molecular mass of SO4-- (g/mol)
13   REAL, PARAMETER :: mwno3 = 62.0    ! Molecular mass of NO3- (g/mol)
15 CONTAINS
18 !===========================================================================
19 !===========================================================================
20       subroutine wetscav_driver( id, ktau, dtstep, ktauc, config_flags,    &
21                dtstepc, alt, t_phy, moist, p8w,                            &
22                t8w, dx, dy, p_phy, chem,                                   &
23                rho_phy, cldfra, cldfra2, rainprod, evapprod,               &
24                hno3_col_mdel, qlsink, precr, preci, precs, precg,          &
25                wdflx, &
26                gas_aqfrac, numgas_aqfrac, dz8w,                            &
27                h2oaj,h2oai,nu3,ac3,cor3,asulf,ahno3,anh3,cvaro1,           &
28                cvaro2,cvalk1,cvole1,cvapi1,cvapi2,cvlim1,cvlim2,           &
29                wd_no3,wd_so4,wd_nh4,wd_oa,                                 &
30                wd_so2, wd_sulf, wd_hno3, wd_nh3,                           &
31                wd_cvasoa, wd_cvbsoa, wd_asoa, wd_bsoa,                     &
32                qv_b4mp, qc_b4mp, qi_b4mp, qs_b4mp,                         &
33 !======================================================================================
34 !Variables required for CAM_MAM_WETSCAV
35                p_hyd,scalar,dgnum4d,dgnumwet4d,dlf3d,dlf2_3d,qme3d,prain3d,&
36                nevapr3d,rate1ord_cw2pr_st3d,shfrc3d,cmfmc,cmfmc2,evapcsh,  &
37                icwmrsh,rprdsh,evapcdp3d,icwmrdp3d,rprddp3d,fracis3d,       &
38                f_ice_phy,f_rain_phy,cldfrai,cldfral,cldfra_mp_all,         &
39                is_CAMMGMP_used,                                            &
40 !======================================================================================
41                ids,ide, jds,jde, kds,kde,                                  &
42                ims,ime, jms,jme, kms,kme,                                  &
43                its,ite, jts,jte, kts,kte                                   )
45 !----------------------------------------------------------------------
47 !  wet removal by grid-resolved precipitation
48 !  scavenging of cloud-phase aerosols and gases by collection, freezing, ...
49 !  scavenging of interstitial-phase aerosols by impaction
50 !  scavenging of gas-phase gases by mass transfer and reaction
52 !  This driver calls subroutines for wet scavenging.
54 !  1. MADE-SORGAM
55 !  2. MOSAIC
56 !  3. CAM5's Wet scavenging
58 !----------------------------------------------------------------------
60    USE module_configure
61    USE module_state_description
62    USE module_model_constants
63    USE modal_aero_data,        only:  ntot_amode               ! For cam_mam_wetscav variables
64    USE module_mozcart_wetscav, only:  wetscav_mozcart
65    USE module_mosaic_wetscav, only:  wetscav_cbmz_mosaic, wetscav_mozart_mosaic
66 !!! TUCCELLA (BUG, the line below is commented now)
67    !USE module_aerosols_sorgam, only:  wetscav_sorgam_driver
68    USE module_aerosols_sorgam_vbs, only:  wetscav_sorgam_vbs_driver
69    USE module_cam_mam_wetscav, only:  wetscav_cam_mam_driver
70    USE module_cam_support,     only:  pcnst =>pcnst_runtime
71 !!! TUCCELLA (BUG, the line below is commented now)
72    !USE module_aerosols_soa_vbs,         only: wetscav_soa_vbs_driver
73 !!! TUCCELLA (BUG, the drivers for wet scavenging of SORGAM and VBS now are in
74 !             module_prep_wetscav_sorgam.F)
75    USE module_prep_wetscav_sorgam, only: wetscav_sorgam_driver, wetscav_soa_vbs_driver
76    USE module_data_mosaic_asect, only: mw_so4_aer, mw_no3_aer, mw_nh4_aer, &
77                                        mw_smpa_aer, mw_smpbb_aer, mw_oc_aer, &
78                                        mw_glysoa_r1_aer, mw_glysoa_r2_aer, &
79                                        mw_glysoa_sfc_aer, mw_glysoa_nh4_aer, &
80                                        mw_glysoa_oh_aer,&
81                          mw_asoaX_aer, mw_asoa1_aer, mw_asoa2_aer, mw_asoa3_aer, mw_asoa4_aer, &
82                          mw_bsoaX_aer, mw_bsoa1_aer, mw_bsoa2_aer, mw_bsoa3_aer, mw_bsoa4_aer, &
83                                        mw_biog1_c_aer, mw_biog1_o_aer
85    IMPLICIT NONE
87 !======================================================================
88 ! Grid structure in physics part of WRF
89 !----------------------------------------------------------------------
90 ! The horizontal velocities used in the physics are unstaggered
91 ! relative to temperature/moisture variables. All predicted
92 ! variables are carried at half levels except w, which is at full
93 ! levels. Some arrays with names (*8w) are at w (full) levels.
95 !----------------------------------------------------------------------
96 ! In WRF, kms (smallest number) is the bottom level and kme (largest
97 ! number) is the top level.  In your scheme, if 1 is at the top level,
98 ! then you have to reverse the order in the k direction.
100 !         kme      -   half level (no data at this level)
101 !         kme    ----- full level
102 !         kme-1    -   half level
103 !         kme-1  ----- full level
104 !         .
105 !         .
106 !         .
107 !         kms+2    -   half level
108 !         kms+2  ----- full level
109 !         kms+1    -   half level
110 !         kms+1  ----- full level
111 !         kms      -   half level
112 !         kms    ----- full level
114 !======================================================================
115 ! Definitions
116 !-----------
117 !-- alt       inverse density
118 !-- t_phy         temperature (K)
119 !-- w             vertical velocity (m/s)
120 !-- moist         moisture array (4D - last index is species) (kg/kg)
121 !-- dz8w          dz between full levels (m)
122 !-- p8w           pressure at full levels (Pa)  
123 !-- p_phy         pressure (Pa)
124 !                 points (dimensionless)
125 !-- z             3D height with lowest level being the terrain
126 !-- rho_phy       density (kg/m^3)
127 !-- qlsink        Fractional cloud water sink (/s)
128 !-- precr         rain precipitation rate at all levels (kg/m2/s)
129 !-- preci         ice precipitation rate at all levels (kg/m2/s)
130 !-- precs         snow precipitation rate at all levels (kg/m2/s)
131 !-- precg         graupel precipitation rate at all levels (kg/m2/s)                             &
132 !-- R_d           gas constant for dry air ( 287. J/kg/K)
133 !-- R_v           gas constant for water vapor (461 J/k/kg)
134 !-- Cp            specific heat at constant pressure (1004 J/k/kg)
135 !-- rvovrd        R_v divided by R_d (dimensionless)
136 !-- G             acceleration due to gravity (m/s^2)
137 !-- p_hyd         Hydrostatic pressure(Pa)
138 !-- z_sea_level   Height above sea level at mid-level (m) 
139 !-- dlf3d         Detrainment of convective condensate (kg/kg/s)
140 !-- dlf2_3d       dq/dt due to export of cloud water into environment by shallow convection(kg/kg/s)
141 !-- qme3d         Net condensation rate (kg/kg/s)
142 !-- prain3d       Rate of conversion of condensate to precipitation (kg/kg/s)
143 !-- nevapr3d      Evaporation rate of rain + snow (kg/kg/s)
144 !-- rate1ord_cw2pr_st3d   1st order rate for direct conversion of strat. cloud water to precip (1/s)
145 !-- shfrc3d       Shallow cloud fraction
146 !-- cmfmc         Deep + Shallow Convective mass flux [ kg /s/m^2 ]
147 !-- cmfmc2        Shallow convective mass flux [ kg/s/m^2 ]
148 !-- evapcsh       Evaporation of shallow convection precipitation (kg/kg/s)
149 !-- icwmrsh       shallow cumulus in-cloud water mixing ratio (kg/m2)
150 !-- rprdsh        dq/dt due to deep and shallow convective rainout(kg/kg/s)
151 !-- evapcdp3d     Evaporation of deep convective precipitation (kg/kg/s)
152 !-- icwmrdp3d     Deep Convection in-cloud water mixing ratio (kg/m2)
153 !-- rprddp3d      dq/dt due to deep convective rainout (kg/kg/s)
154 !-- fracis3d      fraction of transported species that are insoluble
155 !-- ids           start index for i in domain
156 !-- ide           end index for i in domain
157 !-- jds           start index for j in domain
158 !-- jde           end index for j in domain
159 !-- kds           start index for k in domain
160 !-- kde           end index for k in domain
161 !-- ims           start index for i in memory
162 !-- ime           end index for i in memory
163 !-- jms           start index for j in memory
164 !-- jme           end index for j in memory
165 !-- kms           start index for k in memory
166 !-- kme           end index for k in memory
167 !-- its           start index for i in tile
168 !-- ite           end index for i in tile
169 !-- jts           start index for j in tile
170 !-- jte           end index for j in tile
171 !-- kts           start index for k in tile
172 !-- kte           end index for k in tile
173 !-- config_flags%kemit  end index for k for emissions arrays
175 !======================================================================
177    TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
178    LOGICAL,      INTENT(IN)       :: is_CAMMGMP_used
179    INTEGER,      INTENT(IN   )    ::                                &
180                                       ids,ide, jds,jde, kds,kde,    &
181                                       ims,ime, jms,jme, kms,kme,    &
182                                       its,ite, jts,jte, kts,kte,    &
183                                       id, ktau, ktauc, numgas_aqfrac
185       REAL,      INTENT(IN   ) :: dtstep,dtstepc
186       REAL,      INTENT(IN   ) :: dx, dy
188 ! moisture variables
190    REAL, DIMENSION( ims:ime, kms:kme, jms:jme, num_moist ),         &
191          INTENT(INOUT ) ::                                   moist
193 ! scalar variables
195    REAL, DIMENSION( ims:ime, kms:kme, jms:jme, num_scalar ),         &
196          INTENT(INOUT) ::                                   scalar
199 ! all advected chemical species
201    REAL, DIMENSION( ims:ime, kms:kme, jms:jme, num_chem ),          &
202          INTENT(INOUT ) ::                                chem
204 ! fraction of gas species in cloud water
205    REAL, DIMENSION( ims:ime, kms:kme, jms:jme, numgas_aqfrac ),     &
206          INTENT(IN ) ::                                   gas_aqfrac
209 ! following are aerosol arrays that are not advected
211    REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                    &
212          INTENT(INOUT ) ::                                          &
213            h2oaj,h2oai,nu3,ac3,cor3,asulf,ahno3,anh3,cvaro1,cvaro2, &
214            cvalk1,cvole1,cvapi1,cvapi2,cvlim1,cvlim2
216 ! Accumulated wet deposition
218    REAL, DIMENSION( ims:ime , jms:jme ), INTENT(INOUT) :: wd_no3,wd_so4, &
219                                                           wd_nh4, wd_oa, &
220                                                           wd_so2, wd_sulf, &
221                                                           wd_hno3, wd_nh3
222    REAL, DIMENSION( ims:ime , jms:jme ), INTENT(INOUT) :: &
223                    wd_cvasoa, wd_cvbsoa, wd_asoa, wd_bsoa
225 ! input from meteorology(3D)
226    REAL,  DIMENSION( ims:ime , kms:kme , jms:jme )         ,        &
227           INTENT(IN   ) ::                                          &
228                                                       alt,          &
229                                                       t_phy,        &
230                                                       p_phy,        &
231                                                       t8w,          &
232                                                       p8w,          &
233                                                       dz8w,         &
234                                     qlsink,precr,preci,precs,precg, &
235                                                     rho_phy,cldfra, &
236 !variables needed for cam_mam_wetscav
237                                      cldfrai,cldfral,cldfra_mp_all, &
238                                                p_hyd,dlf3d,dlf2_3d, & 
239                                             qme3d,prain3d,nevapr3d, & 
240                                        rate1ord_cw2pr_st3d,shfrc3d, &
241                                     cmfmc,cmfmc2,evapcsh,icwmrsh,   &
242                                         rprdsh,evapcdp3d,icwmrdp3d, &
243                                      rprddp3d,f_ice_phy,f_rain_phy 
244    REAL,  DIMENSION( ims:ime , kms:kme , jms:jme )         ,        &
245          INTENT(INOUT ) ::                             cldfra2,     &
246                                                        rainprod,    &
247                                                        evapprod
248    REAL,  DIMENSION( ims:ime , kms:kme , jms:jme )         ,        &
249          INTENT(IN) ::                                 qc_b4mp,     &
250                                                        qv_b4mp,     &
251                                                        qi_b4mp,     &
252                                                        qs_b4mp
253    REAL,  DIMENSION( ims:ime , jms:jme )         ,                  &
254          INTENT(INOUT ) ::                             hno3_col_mdel
256    REAL, DIMENSION( ims:ime, jms:jme, num_chem )            ,       &
257           INTENT(INOUT) ::                                          &
258                                                        wdflx !wet deposition mol/m^2 or #/m^2 or ug/m^2
260 !input (4D)
261 REAL,  DIMENSION( ims:ime , kms:kme , jms:jme , ntot_amode ),       &
262           INTENT(IN   ) ::                       dgnum4d,dgnumwet4d   !variables needed for cam_mam_wetscav   
265 ! output variables (3D)
266    REAL,  DIMENSION( ims:ime , kms:kme , jms:jme, pcnst )         ,        &
267           INTENT(OUT  ) ::                                          &
268                                                         fracis3d
270 ! LOCAL  VAR
271    integer :: ii,jj,kk
272    REAL, DIMENSION( ims:ime, jms:jme, num_chem ) :: qsrflx, delta_mass_col ! column change due to scavening
273    REAL ::  tmp_minval = 1.0e7
274    REAL,  DIMENSION( ims:ime , kms:kme , jms:jme ) :: rainrate, evaprate
277 ! Wet deposition over the current time step
279   REAL, DIMENSION( ims:ime , jms:jme ) :: wdi_no3,wdi_so4,wdi_nh4,wdi_oa, &
280                                           wdi_so2, wdi_sulf, wdi_hno3, wdi_nh3
281   REAL, DIMENSION( ims:ime , jms:jme ) :: wdi_cvasoa,wdi_cvbsoa,wdi_asoa,wdi_bsoa
283 !-----------------------------------------------------------------
285 ! These are unneeded, since the default behavior is to do nothing.
286 ! If the default changes, then lines need to be added for CBMZ and
287 ! CBMZ_BB.
288 !   IF (config_flags%chem_opt .eq. 0) return
289 !   IF (config_flags%chem_opt .eq. 1) return
292 ! select which aerosol scheme to take
294    cps_select: SELECT CASE(config_flags%chem_opt)
296    CASE ( RADM2SORG_AQ, RADM2SORG_AQCHEM, RACMSORG_AQ, RACMSORG_AQCHEM_KPP, RACM_ESRLSORG_AQCHEM_KPP, CBMZSORG_AQ, &
297           CB05_SORG_AQ_KPP)
298        CALL wrf_debug(15,'wetscav_driver calling sorgam_wetscav_driver' )
299        call wetscav_sorgam_driver (id,ktau,dtstep,ktauc,config_flags,      &
300                dtstepc,alt,t_phy,p8w,t8w,p_phy,chem,rho_phy,cldfra,        &
301                qlsink,precr,preci,precs,precg, qsrflx,                     &
302                gas_aqfrac, numgas_aqfrac,                                  &
303                ids,ide, jds,jde, kds,kde,                                  &
304                ims,ime, jms,jme, kms,kme,                                  &
305                its,ite, jts,jte, kts,kte                                   )
306 ! not clear if the following is necessary or appropriate
307        tmp_minval = 1.0e7
308        do jj=jts,jte
309        do kk=kts,kte
310        do ii=its,ite
311           if (chem(ii,kk,jj,p_nu0) .lt. tmp_minval) then
312              chem(ii,kk,jj,p_nu0) = tmp_minval
313           endif
314        enddo
315        enddo
316        enddo
318 !!! TUCCELLA
319      CASE ( RACM_SOA_VBS_AQCHEM_KPP )
320        CALL wrf_debug(15,'wetscav_driver calling soa_vbs_wetscav_driver' )
321        call wetscav_soa_vbs_driver (id,ktau,dtstep,ktauc,config_flags,     &
322                dtstepc,alt,t_phy,p8w,t8w,p_phy,chem,rho_phy,cldfra,        &
323                qlsink,precr,preci,precs,precg, qsrflx,                     &
324                gas_aqfrac, numgas_aqfrac,                                  &
325                ids,ide, jds,jde, kds,kde,                                  &
326                ims,ime, jms,jme, kms,kme,                                  &
327                its,ite, jts,jte, kts,kte                                   )
328 ! not clear if the following is necessary or appropriate
329        tmp_minval = 1.0e7
330        do jj=jts,jte
331        do kk=kts,kte
332        do ii=its,ite
333           if (chem(ii,kk,jj,p_nu0) .lt. tmp_minval) then
334              chem(ii,kk,jj,p_nu0) = tmp_minval
335           endif
336        enddo
337        enddo
338        enddo
340    CASE (CB05_SORG_VBS_AQ_KPP )
341        CALL wrf_debug(15,'wetscav_driver calling sorgam_wetscav_driver' )
342        call wetscav_sorgam_vbs_driver (id,ktau,dtstep,ktauc,config_flags,      &
343                dtstepc,alt,t_phy,p8w,t8w,p_phy,chem,rho_phy,cldfra,        &
344                qlsink,precr,preci,precs,precg, qsrflx,                     &
345                gas_aqfrac, numgas_aqfrac,                                  &
346                ids,ide, jds,jde, kds,kde,                                  &
347                ims,ime, jms,jme, kms,kme,                                  &
348                its,ite, jts,jte, kts,kte                                   )
349 ! not clear if the following is necessary or appropriate
350        tmp_minval = 1.0e7
351        do jj=jts,jte
352        do kk=kts,kte
353        do ii=its,ite
354           if (chem(ii,kk,jj,p_nu0) .lt. tmp_minval) then
355              chem(ii,kk,jj,p_nu0) = tmp_minval
356           endif
357        enddo
358        enddo
359        enddo
361    CASE (CBMZ_MOSAIC_4BIN, CBMZ_MOSAIC_8BIN, CBMZ_MOSAIC_DMS_4BIN, CBMZ_MOSAIC_DMS_8BIN)
362        CALL wrf_error_fatal('Wet scavenging is currently not possible with MOSAIC unless aqueous aerosols are turned on.')
364    CASE (CBMZ_MOSAIC_4BIN_AQ, CBMZ_MOSAIC_8BIN_AQ, CBMZ_MOSAIC_DMS_4BIN_AQ, CBMZ_MOSAIC_DMS_8BIN_AQ, &
365          CRI_MOSAIC_8BIN_AQ_KPP, CRI_MOSAIC_4BIN_AQ_KPP,SAPRC99_MOSAIC_8BIN_VBS2_AQ_KPP )!BSINGH(12/05/2013): Added for SAPRC 8 bin vbs )
366        CALL wrf_debug(15,'wetscav_driver calling mosaic_wetscav_driver')
367        call wetscav_cbmz_mosaic (id,ktau,dtstep,ktauc,config_flags,        &
368                dtstepc,alt,t_phy,p8w,t8w,p_phy,chem,rho_phy,cldfra,        &
369                qlsink,precr,preci,precs,precg, qsrflx,                     &
370                gas_aqfrac, numgas_aqfrac,                                  &
371                ids,ide, jds,jde, kds,kde,                                  &
372                ims,ime, jms,jme, kms,kme,                                  &
373                its,ite, jts,jte, kts,kte                                   )
374    CASE (MOZART_KPP,MOZCART_KPP,T1_MOZCART_KPP,MOZART_MOSAIC_4BIN_KPP)
375        CALL wrf_debug(15,'wetscav_driver calling wetscav_mozcart')
376        if( config_flags%mp_physics == THOMPSON ) then
377          rainrate(:,:,:) = rainprod(:,:,:)
378          evaprate(:,:,:) = evapprod(:,:,:)
379        elseif( config_flags%mp_physics == WSM6SCHEME ) then
380          rainrate(:,:,:) = rainprod(:,:,:)
381          evaprate(:,:,:) = evapprod(:,:,:)
382        elseif( config_flags%mp_physics == CAMMGMPSCHEME ) then
383          rainrate(:,:,:) = prain3d(:,:,:)
384          evaprate(:,:,:) = nevapr3d(:,:,:)
385        elseif( config_flags%mp_physics == MORR_TWO_MOMENT ) then
386          rainrate(:,:,:) = rainprod(:,:,:)
387          evaprate(:,:,:) = evapprod(:,:,:)
388        else
389          rainrate(:,:,:) = 0.
390          evaprate(:,:,:) = 0.
391        endif
392        call wetscav_mozcart( id, ktau, dtstep, ktauc, config_flags,             &
393                              dtstepc, t_phy, p8w, t8w, p_phy,                   &
394                              chem, rho_phy, cldfra2, rainrate, evaprate,        &
395                              qv_b4mp, qc_b4mp, qi_b4mp, qs_b4mp,                &
396                              gas_aqfrac, numgas_aqfrac, dz8w, dx, dy,           &
397                              moist(ims,kms,jms,p_qv), moist(ims,kms,jms,p_qc),  &
398                              moist(ims,kms,jms,p_qi), moist(ims,kms,jms,p_qs),  &
399 !                             hno3_col_mdel,                                     &
400                              delta_mass_col,                                    &
401                              ids,ide, jds,jde, kds,kde,                         &
402                              ims,ime, jms,jme, kms,kme,                         &
403                              its,ite, jts,jte, kts,kte                          )
405         hno3_col_mdel = delta_mass_col(:,:,p_hno3)
406    ! STUPID - cases have to be unique. We repeat both calls done above
407    ! (mosaic_wetscav for aerosols, mozcart for gases)
408    CASE (MOZART_MOSAIC_4BIN_AQ_KPP)
409        CALL wrf_debug(15,'wetscav_driver calling mosaic_wetscav_driver')
410        if( config_flags%mp_physics == THOMPSON ) then
411          rainrate(:,:,:) = rainprod(:,:,:)
412          evaprate(:,:,:) = evapprod(:,:,:)
413        elseif( config_flags%mp_physics == WSM6SCHEME ) then
414          rainrate(:,:,:) = rainprod(:,:,:)
415          evaprate(:,:,:) = evapprod(:,:,:)
416        elseif( config_flags%mp_physics == CAMMGMPSCHEME ) then
417          rainrate(:,:,:) = prain3d(:,:,:)
418          evaprate(:,:,:) = nevapr3d(:,:,:)
419        elseif( config_flags%mp_physics == MORR_TWO_MOMENT ) then
420          rainrate(:,:,:) = rainprod(:,:,:)
421          evaprate(:,:,:) = evapprod(:,:,:)
422        else
423          rainrate(:,:,:) = 0.
424          evaprate(:,:,:) = 0.
425        endif
426        call wetscav_mozart_mosaic (id,ktau,dtstep,ktauc,config_flags,        &
427                dtstepc,alt,t_phy,p8w,t8w,p_phy,chem,rho_phy,cldfra,        &
428                qlsink,precr,preci,precs,precg, qsrflx,                     &
429                gas_aqfrac, numgas_aqfrac,                                  &
430                ids,ide, jds,jde, kds,kde,                                  &
431                ims,ime, jms,jme, kms,kme,                                  &
432                its,ite, jts,jte, kts,kte                                   )
433        CALL wrf_debug(15,'wetscav_driver calling wetscav_mozcart')
434        call wetscav_mozcart( id, ktau, dtstep, ktauc, config_flags,             &
435                              dtstepc, t_phy, p8w, t8w, p_phy,                   &
436                              chem, rho_phy, cldfra2, rainrate, evaprate,        &
437                              qv_b4mp, qc_b4mp, qi_b4mp, qs_b4mp,                &
438                              gas_aqfrac, numgas_aqfrac, dz8w, dx, dy,           &
439                              moist(ims,kms,jms,p_qv), moist(ims,kms,jms,p_qc),  &
440                              moist(ims,kms,jms,p_qi), moist(ims,kms,jms,p_qs),  &
441 !                             hno3_col_mdel,                                     &
442                              delta_mass_col,                                    &
443                              ids,ide, jds,jde, kds,kde,                         &
444                              ims,ime, jms,jme, kms,kme,                         &
445                              its,ite, jts,jte, kts,kte                          )
446         hno3_col_mdel = delta_mass_col(:,:,p_hno3)
448 CASE (CBMZ_CAM_MAM3_NOAQ,CBMZ_CAM_MAM3_AQ,CBMZ_CAM_MAM7_NOAQ,CBMZ_CAM_MAM7_AQ)       
449        CALL wrf_debug(15,'wetscav_driver calling wetscav_cam_mam_driver')
450        call wetscav_cam_mam_driver (ktau,p_hyd,p8w,t_phy,dgnum4d,          &
451             dgnumwet4d,dlf3d,dlf2_3d,dtstep,qme3d,prain3d,nevapr3d,        &
452             rate1ord_cw2pr_st3d,shfrc3d,cmfmc,cmfmc2,evapcsh,icwmrsh,      &
453             rprdsh,evapcdp3d,icwmrdp3d,rprddp3d,moist(ims,kms,jms,P_QS),   &
454             f_ice_phy,f_rain_phy,config_flags,cldfra_mp_all,cldfrai,       &
455             cldfral,cldfra,is_CAMMGMP_used,                                &                             
456             ids,ide, jds,jde, kds,kde,                                     &
457             ims,ime, jms,jme, kms,kme,                                     &
458             its,ite, jts,jte, kts,kte,                                     &
459             !intent-inout
460             moist(ims,kms,jms,P_QV),moist(ims,kms,jms,P_QC),               &
461             moist(ims,kms,jms,P_QI),scalar(ims,kms,jms,P_QNI),             &
462             scalar(ims,kms,jms,P_QNC),chem,                                &
463             !intent-out            
464             fracis3D                                                       )
465    CASE DEFAULT
467    END SELECT cps_select
469    ! Calculate wet deposition of the species by accumulating their (negative)
470    ! column change. It is assumed that all precipitation reaches the ground.
471    
472     SELECT CASE(config_flags%chem_opt)
473       
474       CASE ( RADM2SORG_AQCHEM,RACMSORG_AQCHEM_KPP,RACM_ESRLSORG_AQCHEM_KPP )
475       
476       do jj=jts,jte
477         do ii=its,ite
478           
479           ! Nitrate wet deposition over the current time step:
480           wdi_no3(ii,jj) = - 0.001*qsrflx(ii,jj,p_no3cwj)/mwno3 &
481                            - 0.001*qsrflx(ii,jj,p_no3cwi)/mwno3  ! mmol/m2
482           
483           ! Accumulated nitrate wet deposition:
484           wd_no3(ii,jj) = wd_no3(ii,jj) + wdi_no3(ii,jj)         ! mmol/m2
485           
486           ! Sulfate wet deposition over the current time step:
487           wdi_so4(ii,jj) = - 0.001*qsrflx(ii,jj,p_so4cwj)/mwso4 &
488                            - 0.001*qsrflx(ii,jj,p_so4cwi)/mwso4 &
489                            - qsrflx(ii,jj,p_sulf) &
490                            - qsrflx(ii,jj,p_so2)                 ! mmol/m2
491           
492           ! Accumulated sulfate wet deposition:
493           wd_so4(ii,jj) = wd_so4(ii,jj) + wdi_so4(ii,jj)         ! mmol/m2
494           
495         enddo
496       enddo
497     
498       CASE ( MOZART_MOSAIC_4BIN_AQ_KPP)
500       do jj=jts,jte
501         do ii=its,ite
503           ! Nitrate wet deposition over the current time step:
504           wdi_no3(ii,jj) = - 0.001*qsrflx(ii,jj,p_no3_cw01)/mw_no3_aer &
505                            - 0.001*qsrflx(ii,jj,p_no3_cw02)/mw_no3_aer &
506                            - 0.001*qsrflx(ii,jj,p_no3_cw03)/mw_no3_aer &
507                            - 0.001*qsrflx(ii,jj,p_no3_cw04)/mw_no3_aer ! mmol/m2
509           ! Accumulated nitrate wet deposition:
510           wd_no3(ii,jj) = wd_no3(ii,jj) + wdi_no3(ii,jj)         ! mmol/m2
512           ! Sulfate wet deposition over the current time step:
513           wdi_so4(ii,jj) = - 0.001*qsrflx(ii,jj,p_so4_cw01)/mw_so4_aer &
514                            - 0.001*qsrflx(ii,jj,p_so4_cw02)/mw_so4_aer &
515                            - 0.001*qsrflx(ii,jj,p_so4_cw03)/mw_so4_aer &
516                            - 0.001*qsrflx(ii,jj,p_so4_cw04)/mw_so4_aer ! mmol/m2
518           ! Accumulated sulfate wet deposition:
519           wd_so4(ii,jj) = wd_so4(ii,jj) + wdi_so4(ii,jj)         ! mmol/m2
521           ! Ammoni* wet deposition over the current time step:
522           wdi_nh4(ii,jj) = - 0.001*qsrflx(ii,jj,p_nh4_cw01)/mw_nh4_aer &
523                            - 0.001*qsrflx(ii,jj,p_nh4_cw02)/mw_nh4_aer &
524                            - 0.001*qsrflx(ii,jj,p_nh4_cw03)/mw_nh4_aer &
525                            - 0.001*qsrflx(ii,jj,p_nh4_cw04)/mw_nh4_aer ! mmol/m2
527           ! Accumulated ammoni* wet deposition:
528           wd_nh4(ii,jj) = wd_nh4(ii,jj) + wdi_nh4(ii,jj)         ! mmol/m2
530           ! Total organics wet deposition over the current time step:
531           wdi_oa(ii,jj)  = - 0.001*qsrflx(ii,jj,p_oc_cw01)/mw_oc_aer &
532                            - 0.001*qsrflx(ii,jj,p_oc_cw02)/mw_oc_aer &
533                            - 0.001*qsrflx(ii,jj,p_oc_cw03)/mw_oc_aer &
534                            - 0.001*qsrflx(ii,jj,p_oc_cw04)/mw_oc_aer &
535                            - 0.001*qsrflx(ii,jj,p_asoaX_cw01)/mw_asoaX_aer &
536                            - 0.001*qsrflx(ii,jj,p_asoaX_cw02)/mw_asoaX_aer &
537                            - 0.001*qsrflx(ii,jj,p_asoaX_cw03)/mw_asoaX_aer &
538                            - 0.001*qsrflx(ii,jj,p_asoaX_cw04)/mw_asoaX_aer &
539                            - 0.001*qsrflx(ii,jj,p_asoa1_cw01)/mw_asoa1_aer &
540                            - 0.001*qsrflx(ii,jj,p_asoa1_cw02)/mw_asoa1_aer &
541                            - 0.001*qsrflx(ii,jj,p_asoa1_cw03)/mw_asoa1_aer &
542                            - 0.001*qsrflx(ii,jj,p_asoa1_cw04)/mw_asoa1_aer &
543                            - 0.001*qsrflx(ii,jj,p_asoa2_cw01)/mw_asoa2_aer &
544                            - 0.001*qsrflx(ii,jj,p_asoa2_cw02)/mw_asoa2_aer &
545                            - 0.001*qsrflx(ii,jj,p_asoa2_cw03)/mw_asoa2_aer &
546                            - 0.001*qsrflx(ii,jj,p_asoa2_cw04)/mw_asoa2_aer &
547                            - 0.001*qsrflx(ii,jj,p_asoa3_cw01)/mw_asoa3_aer &
548                            - 0.001*qsrflx(ii,jj,p_asoa3_cw02)/mw_asoa3_aer &
549                            - 0.001*qsrflx(ii,jj,p_asoa3_cw03)/mw_asoa3_aer &
550                            - 0.001*qsrflx(ii,jj,p_asoa3_cw04)/mw_asoa3_aer &
551                            - 0.001*qsrflx(ii,jj,p_asoa4_cw01)/mw_asoa4_aer &
552                            - 0.001*qsrflx(ii,jj,p_asoa4_cw02)/mw_asoa4_aer &
553                            - 0.001*qsrflx(ii,jj,p_asoa4_cw03)/mw_asoa4_aer &
554                            - 0.001*qsrflx(ii,jj,p_asoa4_cw04)/mw_asoa4_aer &
555                            - 0.001*qsrflx(ii,jj,p_bsoaX_cw01)/mw_bsoaX_aer &
556                            - 0.001*qsrflx(ii,jj,p_bsoaX_cw02)/mw_bsoaX_aer &
557                            - 0.001*qsrflx(ii,jj,p_bsoaX_cw03)/mw_bsoaX_aer &
558                            - 0.001*qsrflx(ii,jj,p_bsoaX_cw04)/mw_bsoaX_aer &
559                            - 0.001*qsrflx(ii,jj,p_bsoa1_cw01)/mw_bsoa1_aer &
560                            - 0.001*qsrflx(ii,jj,p_bsoa1_cw02)/mw_bsoa1_aer &
561                            - 0.001*qsrflx(ii,jj,p_bsoa1_cw03)/mw_bsoa1_aer &
562                            - 0.001*qsrflx(ii,jj,p_bsoa1_cw04)/mw_bsoa1_aer &
563                            - 0.001*qsrflx(ii,jj,p_bsoa2_cw01)/mw_bsoa2_aer &
564                            - 0.001*qsrflx(ii,jj,p_bsoa2_cw02)/mw_bsoa2_aer &
565                            - 0.001*qsrflx(ii,jj,p_bsoa2_cw03)/mw_bsoa2_aer &
566                            - 0.001*qsrflx(ii,jj,p_bsoa2_cw04)/mw_bsoa2_aer &
567                            - 0.001*qsrflx(ii,jj,p_bsoa3_cw01)/mw_bsoa3_aer &
568                            - 0.001*qsrflx(ii,jj,p_bsoa3_cw02)/mw_bsoa3_aer &
569                            - 0.001*qsrflx(ii,jj,p_bsoa3_cw03)/mw_bsoa3_aer &
570                            - 0.001*qsrflx(ii,jj,p_bsoa3_cw04)/mw_bsoa3_aer &
571                            - 0.001*qsrflx(ii,jj,p_bsoa4_cw01)/mw_bsoa4_aer &
572                            - 0.001*qsrflx(ii,jj,p_bsoa4_cw02)/mw_bsoa4_aer &
573                            - 0.001*qsrflx(ii,jj,p_bsoa4_cw03)/mw_bsoa4_aer &
574                            - 0.001*qsrflx(ii,jj,p_bsoa4_cw04)/mw_bsoa4_aer &
575                            - 0.001*qsrflx(ii,jj,p_glysoa_r1_cw01)/mw_glysoa_r1_aer &
576                            - 0.001*qsrflx(ii,jj,p_glysoa_r1_cw02)/mw_glysoa_r1_aer &
577                            - 0.001*qsrflx(ii,jj,p_glysoa_r1_cw03)/mw_glysoa_r1_aer &
578                            - 0.001*qsrflx(ii,jj,p_glysoa_r1_cw04)/mw_glysoa_r1_aer &
579                            - 0.001*qsrflx(ii,jj,p_glysoa_r2_cw01)/mw_glysoa_r2_aer &
580                            - 0.001*qsrflx(ii,jj,p_glysoa_r2_cw02)/mw_glysoa_r2_aer &
581                            - 0.001*qsrflx(ii,jj,p_glysoa_r2_cw03)/mw_glysoa_r2_aer &
582                            - 0.001*qsrflx(ii,jj,p_glysoa_r2_cw04)/mw_glysoa_r2_aer &
583                            - 0.001*qsrflx(ii,jj,p_glysoa_sfc_cw01)/mw_glysoa_sfc_aer &
584                            - 0.001*qsrflx(ii,jj,p_glysoa_sfc_cw02)/mw_glysoa_sfc_aer &
585                            - 0.001*qsrflx(ii,jj,p_glysoa_sfc_cw03)/mw_glysoa_sfc_aer &
586                            - 0.001*qsrflx(ii,jj,p_glysoa_sfc_cw04)/mw_glysoa_sfc_aer &
587                            - 0.001*qsrflx(ii,jj,p_glysoa_nh4_cw01)/mw_glysoa_nh4_aer &
588                            - 0.001*qsrflx(ii,jj,p_glysoa_nh4_cw02)/mw_glysoa_nh4_aer &
589                            - 0.001*qsrflx(ii,jj,p_glysoa_nh4_cw03)/mw_glysoa_nh4_aer &
590                            - 0.001*qsrflx(ii,jj,p_glysoa_nh4_cw04)/mw_glysoa_nh4_aer &
591                            - 0.001*qsrflx(ii,jj,p_glysoa_oh_cw01)/mw_glysoa_oh_aer &
592                            - 0.001*qsrflx(ii,jj,p_glysoa_oh_cw02)/mw_glysoa_oh_aer &
593                            - 0.001*qsrflx(ii,jj,p_glysoa_oh_cw03)/mw_glysoa_oh_aer &
594                            - 0.001*qsrflx(ii,jj,p_glysoa_oh_cw04)/mw_glysoa_oh_aer  ! mmol/m2
596           ! Accumulated total organics wet deposition:
597           wd_oa(ii,jj) = wd_oa(ii,jj) + wdi_oa(ii,jj)         ! mmol/m2
599           wdi_asoa(ii,jj)= - 0.001*qsrflx(ii,jj,p_asoaX_cw01)/mw_asoaX_aer &
600                            - 0.001*qsrflx(ii,jj,p_asoaX_cw02)/mw_asoaX_aer &
601                            - 0.001*qsrflx(ii,jj,p_asoaX_cw03)/mw_asoaX_aer &
602                            - 0.001*qsrflx(ii,jj,p_asoaX_cw04)/mw_asoaX_aer &
603                            - 0.001*qsrflx(ii,jj,p_asoa1_cw01)/mw_asoa1_aer &
604                            - 0.001*qsrflx(ii,jj,p_asoa1_cw02)/mw_asoa1_aer &
605                            - 0.001*qsrflx(ii,jj,p_asoa1_cw03)/mw_asoa1_aer &
606                            - 0.001*qsrflx(ii,jj,p_asoa1_cw04)/mw_asoa1_aer &
607                            - 0.001*qsrflx(ii,jj,p_asoa2_cw01)/mw_asoa2_aer &
608                            - 0.001*qsrflx(ii,jj,p_asoa2_cw02)/mw_asoa2_aer &
609                            - 0.001*qsrflx(ii,jj,p_asoa2_cw03)/mw_asoa2_aer &
610                            - 0.001*qsrflx(ii,jj,p_asoa2_cw04)/mw_asoa2_aer &
611                            - 0.001*qsrflx(ii,jj,p_asoa3_cw01)/mw_asoa3_aer &
612                            - 0.001*qsrflx(ii,jj,p_asoa3_cw02)/mw_asoa3_aer &
613                            - 0.001*qsrflx(ii,jj,p_asoa3_cw03)/mw_asoa3_aer &
614                            - 0.001*qsrflx(ii,jj,p_asoa3_cw04)/mw_asoa3_aer &
615                            - 0.001*qsrflx(ii,jj,p_asoa4_cw01)/mw_asoa4_aer &
616                            - 0.001*qsrflx(ii,jj,p_asoa4_cw02)/mw_asoa4_aer &
617                            - 0.001*qsrflx(ii,jj,p_asoa4_cw03)/mw_asoa4_aer &
618                            - 0.001*qsrflx(ii,jj,p_asoa4_cw04)/mw_asoa4_aer ! mmol/m2
620           ! Accumulated total organics wet deposition:
621           wd_asoa(ii,jj) = wd_asoa(ii,jj) + wdi_asoa(ii,jj)         ! mmol/m2
623           wdi_bsoa(ii,jj)= - 0.001*qsrflx(ii,jj,p_bsoaX_cw01)/mw_bsoaX_aer &
624                            - 0.001*qsrflx(ii,jj,p_bsoaX_cw02)/mw_bsoaX_aer &
625                            - 0.001*qsrflx(ii,jj,p_bsoaX_cw03)/mw_bsoaX_aer &
626                            - 0.001*qsrflx(ii,jj,p_bsoaX_cw04)/mw_bsoaX_aer &
627                            - 0.001*qsrflx(ii,jj,p_bsoa1_cw01)/mw_bsoa1_aer &
628                            - 0.001*qsrflx(ii,jj,p_bsoa1_cw02)/mw_bsoa1_aer &
629                            - 0.001*qsrflx(ii,jj,p_bsoa1_cw03)/mw_bsoa1_aer &
630                            - 0.001*qsrflx(ii,jj,p_bsoa1_cw04)/mw_bsoa1_aer &
631                            - 0.001*qsrflx(ii,jj,p_bsoa2_cw01)/mw_bsoa2_aer &
632                            - 0.001*qsrflx(ii,jj,p_bsoa2_cw02)/mw_bsoa2_aer &
633                            - 0.001*qsrflx(ii,jj,p_bsoa2_cw03)/mw_bsoa2_aer &
634                            - 0.001*qsrflx(ii,jj,p_bsoa2_cw04)/mw_bsoa2_aer &
635                            - 0.001*qsrflx(ii,jj,p_bsoa3_cw01)/mw_bsoa3_aer &
636                            - 0.001*qsrflx(ii,jj,p_bsoa3_cw02)/mw_bsoa3_aer &
637                            - 0.001*qsrflx(ii,jj,p_bsoa3_cw03)/mw_bsoa3_aer &
638                            - 0.001*qsrflx(ii,jj,p_bsoa3_cw04)/mw_bsoa3_aer &
639                            - 0.001*qsrflx(ii,jj,p_bsoa4_cw01)/mw_bsoa4_aer &
640                            - 0.001*qsrflx(ii,jj,p_bsoa4_cw02)/mw_bsoa4_aer &
641                            - 0.001*qsrflx(ii,jj,p_bsoa4_cw03)/mw_bsoa4_aer &
642                            - 0.001*qsrflx(ii,jj,p_bsoa4_cw04)/mw_bsoa4_aer ! mmol/m2
644           ! Accumulated total organics wet deposition:
645           wd_bsoa(ii,jj) = wd_bsoa(ii,jj) + wdi_bsoa(ii,jj)         ! mmol/m2
647           wdi_cvasoa(ii,jj) = - delta_mass_col(ii,jj,p_cvasoaX) &
648                               - delta_mass_col(ii,jj,p_cvasoa1) &
649                               - delta_mass_col(ii,jj,p_cvasoa2) &
650                               - delta_mass_col(ii,jj,p_cvasoa3) &
651                               - delta_mass_col(ii,jj,p_cvasoa4) ! kg
653           wdi_cvasoa(ii,jj) = wdi_cvasoa(ii,jj) / (dx * dy) / (150.0 * 1e-3) * 1e3 ! mmol/m2
655           ! Accumulated CVASOA wet deposition:
656           wd_cvasoa(ii,jj)  = wd_cvasoa(ii,jj) + wdi_cvasoa(ii,jj)         ! mmol/m2
658           wdi_cvbsoa(ii,jj) = - delta_mass_col(ii,jj,p_cvbsoaX) &
659                               - delta_mass_col(ii,jj,p_cvbsoa1) &
660                               - delta_mass_col(ii,jj,p_cvbsoa2) &
661                               - delta_mass_col(ii,jj,p_cvbsoa3) &
662                               - delta_mass_col(ii,jj,p_cvbsoa4) ! kg
664           wdi_cvbsoa(ii,jj) = wdi_cvbsoa(ii,jj) / (dx * dy) / (180.0 * 1e-3) * 1e3 ! mmol/m2
666           ! Accumulated CVbsoa wet deposition:
667           wd_cvbsoa(ii,jj)  = wd_cvbsoa(ii,jj) + wdi_cvbsoa(ii,jj)         ! mmol/m2
669           ! add inorganic gas washout
671           wdi_hno3(ii,jj)    = - delta_mass_col(ii,jj,p_hno3) / (63.0123405 * 1e-3) ! kg
672           wdi_hno3(ii,jj)    = wdi_hno3(ii,jj) / (dx * dy) * 1e3 ! mmol/m2
673           wd_hno3(ii,jj)     = wd_hno3(ii,jj) + wdi_hno3(ii,jj)               ! mmol/m2
675           wdi_so2(ii,jj)    = - delta_mass_col(ii,jj,p_so2) / (63.961901 * 1e-3) ! kg
676           wdi_so2(ii,jj)    = wdi_so2(ii,jj) / (dx * dy) * 1e3 ! mmol/m2
677           wd_so2(ii,jj)     = wd_so2(ii,jj) + wdi_so2(ii,jj)               ! mmol/m2
679           wdi_sulf(ii,jj)    = - delta_mass_col(ii,jj,p_sulf) / (98.078 * 1e-3) ! kg
680           wdi_sulf(ii,jj)    = wdi_sulf(ii,jj) / (dx * dy) * 1e3 ! mmol/m2
681           wd_sulf(ii,jj)     = wd_sulf(ii,jj) + wdi_sulf(ii,jj)               ! mmol/m2
683           wdi_nh3(ii,jj)    = - delta_mass_col(ii,jj,p_nh3) / (17.0289402 * 1e-3) ! kg
684           wdi_nh3(ii,jj)    = wdi_nh3(ii,jj) / (dx * dy) * 1e3 ! mmol/m2
685           wd_nh3(ii,jj)     = wd_nh3(ii,jj) + wdi_nh3(ii,jj)               ! mmol/m2
687         enddo
688       enddo
689     
691     CASE DEFAULT
692       
693     END SELECT
695     if( config_flags%diagnostic_dep == 1 ) then
696        wdflx(its:ite,jts:jte,:)=wdflx(its:ite,jts:jte,:)-qsrflx(its:ite,jts:jte,:)
697     end if
699    end subroutine wetscav_driver
702 END MODULE module_wetscav_driver