Merge pull request #22 from wirc-sjsu/develop-w21
[WRF-Fire-merge.git] / chem / photolysis_driver.F
bloba1a4be1d52b99b7d0f1e5eb9424da415bfc7e948
1 !WRF:MODEL_LAYER:CHEMISTRY
3       SUBROUTINE photolysis_driver (id,curr_secs,ktau,dtstep,            &
4                config_flags,haveaer,                                     &
5                dt_cld,af_dir,af_dn,af_up,par,erythema,                   &
6                gmt,julday,t_phy,moist,aerwrf,p8w,t8w,p_phy,              &
7                chem,rho_phy,dz8w,xlat,xlong,z,z_at_w,gd_cloud,gd_cloud2, &
8                bl_cld,bl_cld2,                                           &
9                ph_macr,ph_o31d,ph_o33p,ph_no2,                           &
10                ph_clno2,                                                 &
11                ph_no3o2,                                                 &
12                ph_no3o,ph_hno2,ph_hno3,ph_hno4,ph_h2o2,                  &
13                ph_ch2or,ph_ch2om,ph_ch3cho,ph_ch3coch3,                  &
14                ph_ch3coc2h5,ph_hcocho,ph_ch3cocho,                       &
15                ph_hcochest,ph_ch3o2h,ph_ch3coo2h,ph_ch3ono2,             &
16                ph_hcochob, ph_n2o5,ph_o2,ph_n2o,                         &
17                ph_pan,ph_mpan,ph_acetol,ph_gly,                          &
18                ph_bigald,ph_mek,ph_c2h5ooh,ph_c3h7ooh,ph_pooh,           &
19                ph_rooh,ph_xooh,ph_isopooh,ph_alkooh,                     &
20                ph_mekooh,ph_tolooh,ph_terpooh,ph_mvk,                    &
21                ph_glyald,ph_hyac,                                        &
22                ph_cl2,ph_hocl,ph_fmcl,                                   &
23                nref0, nw0, tuv_jmax0,                                    &
24                ph_radfld, ph_adjcoe, ph_prate,                           &
25                wc, zref,                                                 &
26                tauaer1,tauaer2,tauaer3,tauaer4,                          &
27                gaer1,gaer2,gaer3,gaer4,                                  &
28                waer1,waer2,waer3,waer4,                                  &
29                bscoef1,bscoef2,bscoef3,bscoef4,                          &
30                l2aer,l3aer,l4aer,l5aer,l6aer,l7aer,                      &
31                pm2_5_dry,pm2_5_water,uvrad,ivgtyp,                       &
32                ids,ide, jds,jde, kds,kde,                                &
33                ims,ime, jms,jme, kms,kme,                                &
34                its,ite, jts,jte, kts,kte                                 )
36 !------------------------------------------------------------------------
37    USE module_configure
38    USE module_state_description
39    USE module_model_constants
40    USE module_phot_mad
41    USE module_phot_fastj
42    USE module_ftuv_driver
43    USE module_phot_tuv, only : tuv_driver
45    INTEGER,      INTENT(IN   ) :: id,julday,                           &
46                                   ids,ide, jds,jde, kds,kde,           &
47                                   ims,ime, jms,jme, kms,kme,           &
48                                   its,ite, jts,jte, kts,kte
49    INTEGER,      INTENT(IN   ) :: ktau
50    REAL(KIND=8), INTENT(IN   ) :: curr_secs
51    REAL,         INTENT(IN   ) :: dtstep,gmt
53 ! advected moisture variables
55    REAL, DIMENSION( ims:ime, kms:kme, jms:jme, num_moist ),            &
56          INTENT(IN ) ::                                   moist
58 !  aerosol interaction
60    REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                       & 
61          INTENT(INOUT ) ::                                             &
62                pm2_5_dry,pm2_5_water, aerwrf
64 ! arrays that hold the photolysis rates
67    REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                       &  
68          INTENT(INOUT ) ::                                             &
69            ph_macr,ph_o31d,ph_o33p,ph_no2,                             &
70            ph_clno2,                                                   &
71            ph_no3o2,ph_no3o,ph_hno2,                                   &
72            ph_hno3,ph_hno4,ph_h2o2,ph_ch2or,ph_ch2om,ph_ch3cho,        &  
73            ph_ch3coch3,ph_ch3coc2h5,ph_hcocho,ph_ch3cocho,             &  
74            ph_hcochest,ph_ch3o2h,ph_ch3coo2h,ph_ch3ono2,ph_hcochob,    &
75            ph_n2o5,ph_o2,ph_n2o,ph_pan,ph_mpan,ph_acetol,ph_gly,       &
76            ph_bigald,ph_mek,ph_c2h5ooh,ph_c3h7ooh,ph_pooh,ph_rooh,     &
77            ph_xooh,ph_isopooh,ph_alkooh,ph_mekooh,ph_tolooh,           &
78            ph_terpooh,ph_mvk,ph_glyald,ph_hyac,                        &
79            ph_cl2,ph_hocl,ph_fmcl
81    REAL, INTENT(INOUT)  ::                                             &
82            dt_cld(ims:ime,kms:kme,jms:jme),                            &
83            af_dir(ims:ime,kms:kme,jms:jme),                            &
84            af_dn(ims:ime,kms:kme,jms:jme),                             &
85            af_up(ims:ime,kms:kme,jms:jme),                             &
86            par(ims:ime,kms:kme,jms:jme),                               &
87            erythema(ims:ime,kms:kme,jms:jme)
89    INTEGER,      INTENT(IN   ) :: nref0, nw0, tuv_jmax0 
90    real, dimension( ims:ime, nref0, jms:jme, nw0 ),                    &
91             intent(out  ) :: ph_radfld
92    real, dimension( ims:ime, nref0, jms:jme, tuv_jmax0 ),              &
93             intent(out  ) :: ph_adjcoe
94    real, dimension( ims:ime, nref0, jms:jme, tuv_jmax0 ),              &
95             intent(out  ) :: ph_prate
96    real, dimension(nw0),                                               &
97             intent(out  ) :: wc
98    real, dimension(nref0),                                             &
99             intent(out  ) :: zref
100    REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                       &  
101          OPTIONAL,                                                     &
102          INTENT(INOUT ) ::                                             &
103            gd_cloud,gd_cloud2,bl_cld,bl_cld2
105 ! arrays that hold the aerosol optical properties
107    REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                       &  
108          INTENT(IN ) ::                                                &
109            tauaer1,tauaer2,tauaer3,tauaer4,                            &
110            gaer1,gaer2,gaer3,gaer4,                                    &
111            waer1,waer2,waer3,waer4,                                    &
112            bscoef1,bscoef2,bscoef3,bscoef4                              
113    REAL, DIMENSION( ims:ime, kms:kme, jms:jme, 1:4 ),                  &  
114          INTENT(IN ) ::                                                &
115            l2aer,l3aer,l4aer,l5aer,l6aer,l7aer
117 ! array that holds all advected chemical species
119    REAL, DIMENSION( ims:ime, kms:kme, jms:jme, num_chem ),             &
120          INTENT(INOUT ) ::                                   chem
122 ! on input from meteorological part of model
124    REAL,  DIMENSION( ims:ime , kms:kme , jms:jme )         ,           &
125           INTENT(IN   ) ::                                             &
126                                                       t_phy,           &
127                                                       p_phy,           &
128                                                       dz8w,            &
129                                           t8w,p8w,z,z_at_w,            &
130                                                     rho_phy
131    REAL,  DIMENSION( ims:ime , jms:jme )                   ,           &
132           INTENT(INOUT   ) ::  uvrad
133    REAL,  DIMENSION( ims:ime , jms:jme )                   ,           &
134           INTENT(IN   ) ::                                             &
135                                                      xlat,             &
136                                                      xlong
137    TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
139    LOGICAL, INTENT(IN)  :: haveaer
140    integer, INTENT(IN ) :: ivgtyp(ims:ime,jms:jme)
141    character(len=132)   :: dbg_msg
142 !         
143 !                                                    
144 ! LOCAL  VAR
147 !-----------------------------------------------------------------
149    IF (config_flags%phot_opt .eq. 0) return
151    write(dbg_msg,*) 'photolysis_driver: called for domain ',id
152    CALL wrf_message( trim(dbg_msg) )
154 ! select photolysis option
156    chem_phot_select: SELECT CASE(config_flags%phot_opt)
158      CASE (PHOTMAD)
159        CALL wrf_debug(15,'calling madronich1_driver')
160        call madronich1_driver(id,curr_secs,ktau,config_flags,haveaer,  &
161                gmt,julday,t_phy,moist,aerwrf,p8w,t8w,p_phy,            &
162                chem,rho_phy,dz8w,xlat,xlong,z_at_w,gd_cloud,gd_cloud2, &
163                ph_macr,ph_o31d,ph_o33p,ph_no2,                  &
164 !liqy
165                 ph_cl2,ph_hocl,ph_clno2,ph_fmcl,        &
166 !liqy-20140911 
167                 ph_no3o2,ph_no3o,ph_hno2,&
168                ph_hno3,ph_hno4,ph_h2o2,ph_ch2or,ph_ch2om,ph_ch3cho,    &
169                ph_ch3coch3,ph_ch3coc2h5,ph_hcocho,ph_ch3cocho,         &
170                ph_hcochest,ph_ch3o2h,ph_ch3coo2h,ph_ch3ono2,ph_hcochob,&
171                pm2_5_dry,pm2_5_water,uvrad,                            &
172                ids,ide, jds,jde, kds,kde,                              &
173                ims,ime, jms,jme, kms,kme,                              &
174                its,ite, jts,jte, kts,kte                               )
175      CASE (PHOTFASTJ)
176        call wrf_debug(15,'calling fastj_driver')
177        call fastj_driver(id,curr_secs,dtstep,config_flags,             &
178                gmt,julday,t_phy,moist,p8w,p_phy,                       &
179                chem,rho_phy,dz8w,xlat,xlong,z_at_w,                    &
180                ph_o2,ph_o31d,ph_o33p,ph_no2,ph_no3o2,ph_no3o,ph_hno2,  &
181                ph_hno3,ph_hno4,ph_h2o2,ph_ch2or,ph_ch2om,ph_ch3cho,    &
182                ph_ch3coch3,ph_ch3coc2h5,ph_hcocho,ph_ch3cocho,         &
183                ph_hcochest,ph_ch3o2h,ph_ch3coo2h,ph_ch3ono2,ph_hcochob,&
184                ph_n2o5,                                                &
185                tauaer1,tauaer2,tauaer3,tauaer4,                        &
186                gaer1,gaer2,gaer3,gaer4,                                &
187                waer1,waer2,waer3,waer4,                                &
188                bscoef1,bscoef2,bscoef3,bscoef4,                        &
189                l2aer,l3aer,l4aer,l5aer,l6aer,l7aer,                    &
190                ids,ide, jds,jde, kds,kde,                              &
191                ims,ime, jms,jme, kms,kme,                              &
192                its,ite, jts,jte, kts,kte                               )
193      CASE (FTUV)
194        call wrf_debug(15,'calling ftuv_driver')
195        call ftuv_driver(      id, curr_secs, dtstep, config_flags,     &
196                               gmt, julday,                             &
197                               p_phy, t_phy, rho_phy, p8w, t8w,         &
198                               xlat, xlong,    z_at_w,                  &
199                               moist, chem, gd_cloud,gd_cloud2,         &
200                               ph_no2,ph_o31d,ph_o33p,ph_hno2,          &
201                               ph_hno3,ph_hno4,ph_no3o2,ph_no3o,        &
202                               ph_h2o2,ph_ch2om,ph_ch2or,ph_ch3cho,     &
203                               ph_ch3o2h,ph_o2,ph_ch3coo2h,ph_ch3coch3,ph_hcocho, &
204                               ph_hcochob,ph_ch3cocho,ph_hcochest,ph_ch3ono2,     &
205                               ph_macr,ph_ch3coc2h5,ph_n2o,             &
206                               ph_pan,ph_mpan,ph_acetol,ph_gly,         &
207                               ph_bigald,ph_mek,ph_c2h5ooh,ph_c3h7ooh,  &
208                               ph_pooh,ph_rooh,ph_xooh,ph_isopooh,      &
209                               ph_alkooh,ph_mekooh,ph_tolooh,ph_terpooh,&
210                               ph_n2o5,ph_mvk,ph_glyald,ph_hyac,        &
211                               ph_cl2,ph_hocl,ph_fmcl,                  &
212                               ivgtyp,                                  &
213                               nref0, nw0, tuv_jmax0,                   &
214                               ph_radfld, ph_adjcoe, ph_prate,          &
215                               wc,zref,                                 &
216                               tauaer1, tauaer2, tauaer3, tauaer4,      &    !rajesh
217                               waer1, waer2, waer3, waer4,              &    !rajesh
218                               gaer1, gaer2, gaer3, gaer4,              &    !rajesh
219                               ids,ide, jds,jde, kds,kde,               &
220                               ims,ime, jms,jme, kms,kme,               &
221                               its,ite, jts,jte, kts,kte                )
222      CASE (TUV)
223        CALL wrf_debug(15,'calling tuv driver')
224        call tuv_driver(                                                &
225                id, curr_secs, ktau, config_flags, haveaer,             &
226                gmt, julday, t_phy, moist, aerwrf,                      &
227                p8w, t8w, p_phy, chem, rho_phy,                         &
228                dz8w, xlat, xlong, z, z_at_w, gd_cloud, gd_cloud2,      &
229                bl_cld,bl_cld2,                                         &
230                tauaer1,tauaer2,tauaer3,tauaer4,                        &
231                gaer1,gaer2,gaer3,gaer4,                                &
232                waer1,waer2,waer3,waer4,                                &
233                ph_macr,ph_o31d,ph_o33p,ph_no2,ph_no3o2,ph_no3o,ph_hno2,&
234                ph_hno3,ph_hno4,ph_h2o2,ph_ch2or,ph_ch2om,ph_ch3cho,    &
235                ph_ch3coch3,ph_ch3coc2h5,ph_hcocho,ph_ch3cocho,         &
236                ph_hcochest,ph_ch3o2h,ph_ch3coo2h,ph_ch3ono2,ph_hcochob,&
237                ph_n2o5,ph_o2,ph_n2o,ph_pooh,ph_pan,ph_mvk,ph_hyac,     &
238                ph_glyald,ph_mek,ph_gly,                                &
239                pm2_5_dry, pm2_5_water, uvrad,                          &
240                dt_cld,af_dir,af_dn,af_up,par,erythema,                 &
241                ids,ide, jds,jde, kds,kde,                              &
242                ims,ime, jms,jme, kms,kme,                              &
243                its,ite, jts,jte, kts,kte                               )
244      CASE DEFAULT
246    END SELECT chem_phot_select
248 END SUBROUTINE photolysis_driver