[2158] | 1 | subroutine calchim(ngrid,nlayer,nq, & |
---|
[1495] | 2 | ptimestep,pplay,pplev,pt,pdt,dist_sol,mu0, & |
---|
| 3 | zzlev,zzlay,zday,pq,pdq,dqchim,dqschim,dqcloud, & |
---|
[2031] | 4 | dqscloud,tau,co2ice, & |
---|
[1495] | 5 | pu,pdu,pv,pdv,surfdust,surfice) |
---|
| 6 | |
---|
| 7 | use tracer_mod, only: igcm_co2, igcm_co, igcm_o, igcm_o1d, igcm_o2, & |
---|
| 8 | igcm_o3, igcm_h, igcm_h2, igcm_oh, igcm_ho2, & |
---|
| 9 | igcm_h2o2, igcm_ch4, igcm_n2, igcm_h2o_vap, & |
---|
| 10 | igcm_no, igcm_n, igcm_no2, igcm_n2d, & |
---|
| 11 | igcm_o2plus, igcm_co2plus, igcm_oplus, & |
---|
| 12 | igcm_coplus, igcm_cplus, igcm_nplus, & |
---|
| 13 | igcm_noplus, igcm_n2plus, igcm_hplus, & |
---|
| 14 | igcm_hco2plus, igcm_elec, mmol |
---|
| 15 | |
---|
| 16 | use conc_mod, only: mmean ! mean molecular mass of the atmosphere |
---|
[2029] | 17 | use comcstfi_h |
---|
| 18 | use photolysis_mod |
---|
[2158] | 19 | use iono_h, only: temp_elect |
---|
[1495] | 20 | |
---|
| 21 | implicit none |
---|
| 22 | |
---|
| 23 | !======================================================================= |
---|
| 24 | ! |
---|
| 25 | ! subject: |
---|
| 26 | ! -------- |
---|
| 27 | ! |
---|
| 28 | ! Prepare the call for the photochemical module, and send back the |
---|
| 29 | ! tendencies from photochemistry in the chemical species mass mixing ratios |
---|
| 30 | ! |
---|
| 31 | ! Author: Sebastien Lebonnois (08/11/2002) |
---|
| 32 | ! ------- |
---|
| 33 | ! update 12/06/2003 for water ice clouds and compatibility with dust |
---|
| 34 | ! update 07/2003 for coupling with thermosphere (Monica Angelats-i-Coll) |
---|
| 35 | ! update 03/05/2005 cosmetic changes (Franck Lefevre) |
---|
| 36 | ! update sept. 2008 identify tracers by their names (Ehouarn Millour) |
---|
| 37 | ! update 05/12/2011 synchronize with latest version of chemistry (Franck Lefevre) |
---|
| 38 | ! update 16/03/2012 optimization (Franck Lefevre) |
---|
| 39 | ! update 11/12/2013 optimization (Franck Lefevre) |
---|
| 40 | ! |
---|
| 41 | ! Arguments: |
---|
| 42 | ! ---------- |
---|
| 43 | ! |
---|
| 44 | ! Input: |
---|
| 45 | ! |
---|
[2031] | 46 | ! ptimestep timestep (s) |
---|
[1495] | 47 | ! pplay(ngrid,nlayer) Pressure at the middle of the layers (Pa) |
---|
| 48 | ! pplev(ngrid,nlayer+1) Intermediate pressure levels (Pa) |
---|
| 49 | ! pt(ngrid,nlayer) Temperature (K) |
---|
| 50 | ! pdt(ngrid,nlayer) Temperature tendency (K) |
---|
| 51 | ! pu(ngrid,nlayer) u component of the wind (ms-1) |
---|
| 52 | ! pdu(ngrid,nlayer) u component tendency (K) |
---|
| 53 | ! pv(ngrid,nlayer) v component of the wind (ms-1) |
---|
| 54 | ! pdv(ngrid,nlayer) v component tendency (K) |
---|
[2031] | 55 | ! dist_sol distance of the sun (AU) |
---|
| 56 | ! mu0(ngrid) cos of solar zenith angle (=1 when sun at zenith) |
---|
| 57 | ! pq(ngrid,nlayer,nq) advected fields, ie chemical species here |
---|
| 58 | ! pdq(ngrid,nlayer,nq) previous tendencies on pq |
---|
| 59 | ! tau(ngrid) dust optical depth |
---|
| 60 | ! co2ice(ngrid) co2 ice surface layer (kg.m-2) |
---|
[1495] | 61 | ! surfdust(ngrid,nlayer) dust surface area (m2/m3) |
---|
| 62 | ! surfice(ngrid,nlayer) ice surface area (m2/m3) |
---|
| 63 | ! |
---|
| 64 | ! Output: |
---|
| 65 | ! |
---|
[2031] | 66 | ! dqchim(ngrid,nlayer,nq) tendencies on pq due to chemistry |
---|
| 67 | ! dqschim(ngrid,nq) tendencies on qsurf |
---|
[1495] | 68 | ! |
---|
| 69 | !======================================================================= |
---|
| 70 | |
---|
| 71 | #include "callkeys.h" |
---|
| 72 | |
---|
| 73 | ! input: |
---|
| 74 | |
---|
| 75 | integer,intent(in) :: ngrid ! number of atmospheric columns |
---|
| 76 | integer,intent(in) :: nlayer ! number of atmospheric layers |
---|
| 77 | integer,intent(in) :: nq ! number of tracers |
---|
| 78 | real :: ptimestep |
---|
| 79 | real :: pplay(ngrid,nlayer) ! pressure at the middle of the layers |
---|
| 80 | real :: zzlay(ngrid,nlayer) ! pressure at the middle of the layers |
---|
| 81 | real :: pplev(ngrid,nlayer+1) ! intermediate pressure levels |
---|
| 82 | real :: zzlev(ngrid,nlayer+1) ! altitude at layer boundaries |
---|
| 83 | real :: pt(ngrid,nlayer) ! temperature |
---|
| 84 | real :: pdt(ngrid,nlayer) ! temperature tendency |
---|
| 85 | real :: pu(ngrid,nlayer) ! u component of the wind (m.s-1) |
---|
| 86 | real :: pdu(ngrid,nlayer) ! u component tendency |
---|
| 87 | real :: pv(ngrid,nlayer) ! v component of the wind (m.s-1) |
---|
| 88 | real :: pdv(ngrid,nlayer) ! v component tendency |
---|
| 89 | real :: dist_sol ! distance of the sun (AU) |
---|
| 90 | real :: mu0(ngrid) ! cos of solar zenith angle (=1 when sun at zenith) |
---|
| 91 | real :: pq(ngrid,nlayer,nq) ! tracers mass mixing ratio |
---|
| 92 | real :: pdq(ngrid,nlayer,nq) ! previous tendencies |
---|
| 93 | real :: zday ! date (time since Ls=0, in martian days) |
---|
[2031] | 94 | real :: tau(ngrid) ! dust optical depth |
---|
[1495] | 95 | real :: co2ice(ngrid) ! co2 ice surface layer (kg.m-2) |
---|
| 96 | real :: surfdust(ngrid,nlayer) ! dust surface area (m2/m3) |
---|
[2031] | 97 | real :: surfice(ngrid,nlayer) ! ice surface area (m2/m3) |
---|
[1495] | 98 | |
---|
| 99 | ! output: |
---|
| 100 | |
---|
| 101 | real :: dqchim(ngrid,nlayer,nq) ! tendencies on pq due to chemistry |
---|
| 102 | real :: dqschim(ngrid,nq) ! tendencies on qsurf |
---|
| 103 | real :: dqcloud(ngrid,nlayer,nq) ! tendencies on pq due to condensation |
---|
| 104 | real :: dqscloud(ngrid,nq) ! tendencies on qsurf |
---|
| 105 | |
---|
| 106 | ! local variables: |
---|
| 107 | |
---|
| 108 | integer,save :: nbq ! number of tracers used in the chemistry |
---|
| 109 | integer,allocatable,save :: niq(:) ! array storing the indexes of the tracers |
---|
| 110 | integer :: iloc(1) ! index of major species |
---|
| 111 | integer :: ig,l,i,iq,iqmax |
---|
| 112 | integer :: foundswitch, lswitch |
---|
| 113 | integer,save :: chemthermod |
---|
| 114 | |
---|
| 115 | integer,save :: i_co2 = 0 |
---|
| 116 | integer,save :: i_co = 0 |
---|
| 117 | integer,save :: i_o = 0 |
---|
| 118 | integer,save :: i_o1d = 0 |
---|
| 119 | integer,save :: i_o2 = 0 |
---|
| 120 | integer,save :: i_o3 = 0 |
---|
| 121 | integer,save :: i_h = 0 |
---|
| 122 | integer,save :: i_h2 = 0 |
---|
| 123 | integer,save :: i_oh = 0 |
---|
| 124 | integer,save :: i_ho2 = 0 |
---|
| 125 | integer,save :: i_h2o2 = 0 |
---|
| 126 | integer,save :: i_ch4 = 0 |
---|
| 127 | integer,save :: i_n2 = 0 |
---|
| 128 | integer,save :: i_h2o = 0 |
---|
| 129 | integer,save :: i_n = 0 |
---|
| 130 | integer,save :: i_no = 0 |
---|
| 131 | integer,save :: i_no2 = 0 |
---|
| 132 | integer,save :: i_n2d = 0 |
---|
| 133 | integer,save :: i_co2plus=0 |
---|
| 134 | integer,save :: i_oplus=0 |
---|
| 135 | integer,save :: i_o2plus=0 |
---|
| 136 | integer,save :: i_coplus=0 |
---|
| 137 | integer,save :: i_cplus=0 |
---|
| 138 | integer,save :: i_nplus=0 |
---|
| 139 | integer,save :: i_noplus=0 |
---|
| 140 | integer,save :: i_n2plus=0 |
---|
| 141 | integer,save :: i_hplus=0 |
---|
| 142 | integer,save :: i_hco2plus=0 |
---|
| 143 | integer,save :: i_elec=0 |
---|
| 144 | |
---|
| 145 | integer :: ig_vl1 |
---|
| 146 | |
---|
| 147 | real :: latvl1, lonvl1 |
---|
| 148 | real :: zq(ngrid,nlayer,nq) ! pq+pdq*ptimestep before chemistry |
---|
| 149 | ! new mole fraction after |
---|
| 150 | real :: zt(ngrid,nlayer) ! temperature |
---|
| 151 | real :: zu(ngrid,nlayer) ! u component of the wind |
---|
| 152 | real :: zv(ngrid,nlayer) ! v component of the wind |
---|
[2027] | 153 | real :: taucol ! dust optical depth at the surface |
---|
[2030] | 154 | real :: kb ! boltzmann constant |
---|
[1495] | 155 | |
---|
| 156 | logical,save :: firstcall = .true. |
---|
| 157 | logical,save :: depos = .false. ! switch for dry deposition |
---|
| 158 | |
---|
| 159 | ! for each column of atmosphere: |
---|
| 160 | |
---|
| 161 | real :: zpress(nlayer) ! Pressure (mbar) |
---|
| 162 | real :: zdens(nlayer) ! Density (cm-3) |
---|
| 163 | real :: ztemp(nlayer) ! Temperature (K) |
---|
[2158] | 164 | real :: ztelec(nlayer) ! Electronic temperature (K) |
---|
[1495] | 165 | real :: zlocal(nlayer) ! Altitude (km) |
---|
| 166 | real :: zycol(nlayer,nq) ! Composition (mole fractions) |
---|
| 167 | real :: zmmean(nlayer) ! Mean molecular mass (g.mole-1) |
---|
| 168 | real :: szacol ! Solar zenith angle |
---|
| 169 | real :: surfice1d(nlayer) ! Ice surface area (cm2/cm3) |
---|
| 170 | real :: surfdust1d(nlayer) ! Dust surface area (cm2/cm3) |
---|
| 171 | real :: jo3(nlayer) ! Photodissociation rate O3->O1D (s-1) |
---|
[2030] | 172 | real :: jh2o(nlayer) ! Photodissociation rate H2O->H+OH (s-1) |
---|
[1888] | 173 | real :: em_no(nlayer) ! NO nightglow emission rate |
---|
| 174 | real :: em_o2(nlayer) ! O2 nightglow emission rate |
---|
[1495] | 175 | |
---|
| 176 | integer :: iter(nlayer) ! Number of chemical iterations |
---|
| 177 | ! within one physical timestep |
---|
| 178 | |
---|
| 179 | ! for output: |
---|
| 180 | |
---|
| 181 | logical :: output ! to issue calls to writediagfi and stats |
---|
| 182 | parameter (output = .true.) |
---|
| 183 | real :: jo3_3d(ngrid,nlayer) ! Photodissociation rate O3->O1D (s-1) |
---|
[2030] | 184 | real :: jh2o_3d(ngrid,nlayer) ! Photodissociation rate H2O->H+OH (s-1) |
---|
[1888] | 185 | real :: emission_no(ngrid,nlayer) !NO emission rate |
---|
| 186 | real :: emission_o2(ngrid,nlayer) !O2 emission rate |
---|
[1495] | 187 | real :: iter_3d(ngrid,nlayer) ! Number of chemical iterations |
---|
| 188 | ! within one physical timestep |
---|
| 189 | |
---|
[2158] | 190 | logical :: unichim ! only one, unified chemical scheme at all |
---|
| 191 | ! layers (default), or upper atmospheric |
---|
| 192 | ! scheme in the thermosphere? |
---|
| 193 | |
---|
[1495] | 194 | !======================================================================= |
---|
| 195 | ! initialization of the chemistry (first call only) |
---|
| 196 | !======================================================================= |
---|
| 197 | |
---|
[2158] | 198 | !call only unified chemistry (default), or also upper atmospheric model |
---|
| 199 | !unichim = .true. unified chemistry |
---|
| 200 | !unichim = .false. 2 different models |
---|
| 201 | unichim = .true. |
---|
| 202 | |
---|
[1495] | 203 | if (firstcall) then |
---|
| 204 | |
---|
| 205 | if (photochem) then |
---|
[2044] | 206 | if (jonline) then |
---|
| 207 | print*,'calchim: Read UV absorption cross-sections' |
---|
| 208 | call init_photolysis ! on-line photolysis |
---|
| 209 | else |
---|
| 210 | print*,'calchim: Read photolysis lookup table' |
---|
| 211 | call read_phototable ! off-line photolysis |
---|
| 212 | end if |
---|
[1495] | 213 | end if |
---|
[2158] | 214 | |
---|
| 215 | if(.not.unichim) then |
---|
| 216 | !Read reaction rates from external file if the upper atmospheric |
---|
| 217 | !chemistry is called |
---|
| 218 | call chemthermos_readini |
---|
| 219 | endif |
---|
| 220 | |
---|
[1495] | 221 | ! find index of chemical tracers to use |
---|
| 222 | allocate(niq(nq)) |
---|
| 223 | ! Listed here are all tracers that can go into photochemistry |
---|
| 224 | nbq = 0 ! to count number of tracers |
---|
[2158] | 225 | ! Species ALWAYS present if photochem=.T. |
---|
[1495] | 226 | i_co2 = igcm_co2 |
---|
| 227 | if (i_co2 == 0) then |
---|
| 228 | write(*,*) "calchim: Error; no CO2 tracer !!!" |
---|
| 229 | stop |
---|
| 230 | else |
---|
| 231 | nbq = nbq + 1 |
---|
| 232 | niq(nbq) = i_co2 |
---|
| 233 | end if |
---|
| 234 | i_co = igcm_co |
---|
| 235 | if (i_co == 0) then |
---|
| 236 | write(*,*) "calchim: Error; no CO tracer !!!" |
---|
| 237 | stop |
---|
| 238 | else |
---|
| 239 | nbq = nbq + 1 |
---|
| 240 | niq(nbq) = i_co |
---|
| 241 | end if |
---|
| 242 | i_o = igcm_o |
---|
| 243 | if (i_o == 0) then |
---|
| 244 | write(*,*) "calchim: Error; no O tracer !!!" |
---|
| 245 | stop |
---|
| 246 | else |
---|
| 247 | nbq = nbq + 1 |
---|
| 248 | niq(nbq) = i_o |
---|
| 249 | end if |
---|
| 250 | i_o1d = igcm_o1d |
---|
| 251 | if (i_o1d == 0) then |
---|
| 252 | write(*,*) "calchim: Error; no O1D tracer !!!" |
---|
| 253 | stop |
---|
| 254 | else |
---|
| 255 | nbq = nbq + 1 |
---|
| 256 | niq(nbq) = i_o1d |
---|
| 257 | end if |
---|
| 258 | i_o2 = igcm_o2 |
---|
| 259 | if (i_o2 == 0) then |
---|
| 260 | write(*,*) "calchim: Error; no O2 tracer !!!" |
---|
| 261 | stop |
---|
| 262 | else |
---|
| 263 | nbq = nbq + 1 |
---|
| 264 | niq(nbq) = i_o2 |
---|
| 265 | end if |
---|
| 266 | i_o3 = igcm_o3 |
---|
| 267 | if (i_o3 == 0) then |
---|
| 268 | write(*,*) "calchim: Error; no O3 tracer !!!" |
---|
| 269 | stop |
---|
| 270 | else |
---|
| 271 | nbq = nbq + 1 |
---|
| 272 | niq(nbq) = i_o3 |
---|
| 273 | end if |
---|
| 274 | i_h = igcm_h |
---|
| 275 | if (i_h == 0) then |
---|
| 276 | write(*,*) "calchim: Error; no H tracer !!!" |
---|
| 277 | stop |
---|
| 278 | else |
---|
| 279 | nbq = nbq + 1 |
---|
| 280 | niq(nbq) = i_h |
---|
| 281 | end if |
---|
| 282 | i_h2 = igcm_h2 |
---|
| 283 | if (i_h2 == 0) then |
---|
| 284 | write(*,*) "calchim: Error; no H2 tracer !!!" |
---|
| 285 | stop |
---|
| 286 | else |
---|
| 287 | nbq = nbq + 1 |
---|
| 288 | niq(nbq) = i_h2 |
---|
| 289 | end if |
---|
| 290 | i_oh = igcm_oh |
---|
| 291 | if (i_oh == 0) then |
---|
| 292 | write(*,*) "calchim: Error; no OH tracer !!!" |
---|
| 293 | stop |
---|
| 294 | else |
---|
| 295 | nbq = nbq + 1 |
---|
| 296 | niq(nbq) = i_oh |
---|
| 297 | end if |
---|
| 298 | i_ho2 = igcm_ho2 |
---|
| 299 | if (i_ho2 == 0) then |
---|
| 300 | write(*,*) "calchim: Error; no HO2 tracer !!!" |
---|
| 301 | stop |
---|
| 302 | else |
---|
| 303 | nbq = nbq + 1 |
---|
| 304 | niq(nbq) = i_ho2 |
---|
| 305 | end if |
---|
| 306 | i_h2o2 = igcm_h2o2 |
---|
| 307 | if (i_h2o2 == 0) then |
---|
| 308 | write(*,*) "calchim: Error; no H2O2 tracer !!!" |
---|
| 309 | stop |
---|
| 310 | else |
---|
| 311 | nbq = nbq + 1 |
---|
| 312 | niq(nbq) = i_h2o2 |
---|
| 313 | end if |
---|
| 314 | i_ch4 = igcm_ch4 |
---|
| 315 | if (i_ch4 == 0) then |
---|
| 316 | write(*,*) "calchim: Error; no CH4 tracer !!!" |
---|
| 317 | write(*,*) "CH4 will be ignored in the chemistry" |
---|
| 318 | else |
---|
| 319 | nbq = nbq + 1 |
---|
| 320 | niq(nbq) = i_ch4 |
---|
| 321 | end if |
---|
| 322 | i_n2 = igcm_n2 |
---|
| 323 | if (i_n2 == 0) then |
---|
| 324 | write(*,*) "calchim: Error; no N2 tracer !!!" |
---|
| 325 | stop |
---|
| 326 | else |
---|
| 327 | nbq = nbq + 1 |
---|
| 328 | niq(nbq) = i_n2 |
---|
| 329 | end if |
---|
| 330 | i_n = igcm_n |
---|
| 331 | if (i_n == 0) then |
---|
| 332 | if (photochem) then |
---|
| 333 | write(*,*) "calchim: Error; no N tracer !!!" |
---|
| 334 | stop |
---|
| 335 | end if |
---|
| 336 | else |
---|
| 337 | nbq = nbq + 1 |
---|
| 338 | niq(nbq) = i_n |
---|
| 339 | end if |
---|
| 340 | i_n2d = igcm_n2d |
---|
| 341 | if (i_n2d == 0) then |
---|
| 342 | if (photochem) then |
---|
| 343 | write(*,*) "calchim: Error; no N2D tracer !!!" |
---|
| 344 | stop |
---|
| 345 | end if |
---|
| 346 | else |
---|
| 347 | nbq = nbq + 1 |
---|
| 348 | niq(nbq) = i_n2d |
---|
| 349 | end if |
---|
| 350 | i_no = igcm_no |
---|
| 351 | if (i_no == 0) then |
---|
| 352 | if (photochem) then |
---|
| 353 | write(*,*) "calchim: Error; no NO tracer !!!" |
---|
| 354 | stop |
---|
| 355 | end if |
---|
| 356 | else |
---|
| 357 | nbq = nbq + 1 |
---|
| 358 | niq(nbq) = i_no |
---|
| 359 | end if |
---|
| 360 | i_no2 = igcm_no2 |
---|
| 361 | if (i_no2 == 0) then |
---|
| 362 | if (photochem) then |
---|
| 363 | write(*,*) "calchim: Error; no NO2 tracer !!!" |
---|
| 364 | stop |
---|
| 365 | end if |
---|
| 366 | else |
---|
| 367 | nbq = nbq + 1 |
---|
| 368 | niq(nbq) = i_no2 |
---|
| 369 | end if |
---|
| 370 | i_h2o = igcm_h2o_vap |
---|
| 371 | if (i_h2o == 0) then |
---|
| 372 | write(*,*) "calchim: Error; no water vapor tracer !!!" |
---|
| 373 | stop |
---|
| 374 | else |
---|
| 375 | nbq = nbq + 1 |
---|
| 376 | niq(nbq) = i_h2o |
---|
| 377 | end if |
---|
[2158] | 378 | i_o2plus = igcm_o2plus |
---|
| 379 | if (i_o2plus == 0) then |
---|
| 380 | write(*,*) "calchim: Error, no O2+ tracer !!!" |
---|
| 381 | stop |
---|
| 382 | else |
---|
| 383 | nbq = nbq + 1 |
---|
| 384 | niq(nbq) = i_o2plus |
---|
| 385 | end if |
---|
| 386 | i_co2plus = igcm_co2plus |
---|
| 387 | if (i_co2plus == 0) then |
---|
| 388 | write(*,*) "calchim: Error, no CO2+ tracer !!!" |
---|
| 389 | stop |
---|
| 390 | else |
---|
| 391 | nbq = nbq + 1 |
---|
| 392 | niq(nbq) = i_co2plus |
---|
| 393 | end if |
---|
| 394 | i_oplus=igcm_oplus |
---|
| 395 | if (i_oplus == 0) then |
---|
| 396 | write(*,*) "calchim: Error, no O+ tracer !!!" |
---|
| 397 | stop |
---|
| 398 | else |
---|
| 399 | nbq = nbq + 1 |
---|
| 400 | niq(nbq) = i_oplus |
---|
| 401 | end if |
---|
| 402 | i_noplus=igcm_noplus |
---|
| 403 | if (i_noplus == 0) then |
---|
| 404 | write(*,*) "calchim: Error, no NO+ tracer !!!" |
---|
| 405 | stop |
---|
| 406 | else |
---|
| 407 | nbq = nbq + 1 |
---|
| 408 | niq(nbq) = i_noplus |
---|
| 409 | end if |
---|
| 410 | i_coplus=igcm_coplus |
---|
| 411 | if (i_coplus == 0) then |
---|
| 412 | write(*,*) "calchim: Error, no CO+ tracer !!!" |
---|
| 413 | stop |
---|
| 414 | else |
---|
| 415 | nbq = nbq + 1 |
---|
| 416 | niq(nbq) = i_coplus |
---|
| 417 | end if |
---|
| 418 | i_cplus=igcm_cplus |
---|
| 419 | if (i_cplus == 0) then |
---|
| 420 | write(*,*) "calchim: Error, no C+ tracer !!!" |
---|
| 421 | stop |
---|
| 422 | else |
---|
| 423 | nbq = nbq + 1 |
---|
| 424 | niq(nbq) = i_cplus |
---|
| 425 | end if |
---|
| 426 | i_n2plus=igcm_n2plus |
---|
| 427 | if (i_n2plus == 0) then |
---|
| 428 | write(*,*) "calchim: Error, no N2+ tracer !!!" |
---|
| 429 | stop |
---|
| 430 | else |
---|
| 431 | nbq = nbq + 1 |
---|
| 432 | niq(nbq) = i_n2plus |
---|
| 433 | end if |
---|
| 434 | i_nplus=igcm_nplus |
---|
| 435 | if (i_nplus == 0) then |
---|
| 436 | write(*,*) "calchim: Error, no N+ tracer !!!" |
---|
| 437 | stop |
---|
| 438 | else |
---|
| 439 | nbq = nbq + 1 |
---|
| 440 | niq(nbq) = i_nplus |
---|
| 441 | end if |
---|
| 442 | i_hplus=igcm_hplus |
---|
| 443 | if (i_hplus == 0) then |
---|
| 444 | write(*,*) "calchim: Error, no H+ tracer !!!" |
---|
| 445 | stop |
---|
| 446 | else |
---|
| 447 | nbq = nbq + 1 |
---|
| 448 | niq(nbq) = i_hplus |
---|
| 449 | end if |
---|
| 450 | i_hco2plus=igcm_hco2plus |
---|
| 451 | if (i_hco2plus == 0) then |
---|
| 452 | write(*,*) "calchim: Error, no HCO2+ tracer !!!" |
---|
| 453 | stop |
---|
| 454 | else |
---|
| 455 | nbq = nbq + 1 |
---|
| 456 | niq(nbq) = i_hco2plus |
---|
| 457 | end if |
---|
| 458 | i_elec = igcm_elec |
---|
| 459 | if (i_elec == 0) then |
---|
| 460 | write(*,*) "calchim: Error, no e- tracer !!!" |
---|
| 461 | stop |
---|
| 462 | else |
---|
| 463 | nbq = nbq + 1 |
---|
| 464 | niq(nbq) = i_elec |
---|
| 465 | end if |
---|
| 466 | |
---|
[1495] | 467 | write(*,*) 'calchim: found nbq = ',nbq,' tracers' |
---|
| 468 | |
---|
| 469 | firstcall = .false. |
---|
| 470 | end if ! if (firstcall) |
---|
| 471 | |
---|
| 472 | ! Initializations |
---|
| 473 | |
---|
| 474 | zycol(:,:) = 0. |
---|
| 475 | dqchim(:,:,:) = 0. |
---|
| 476 | dqschim(:,:) = 0. |
---|
| 477 | |
---|
[2030] | 478 | kb = 1.3806e-23 |
---|
| 479 | |
---|
[1495] | 480 | ! latvl1= 22.27 |
---|
| 481 | ! lonvl1= -47.94 |
---|
[2029] | 482 | ! ig_vl1= 1+ int( (1.5-(latvl1-90.)*48./180.) -2 )*64. + & |
---|
| 483 | ! int(1.5+(lonvl1+180)*64./360.) |
---|
[1495] | 484 | |
---|
| 485 | !======================================================================= |
---|
| 486 | ! loop over grid |
---|
| 487 | !======================================================================= |
---|
| 488 | |
---|
| 489 | do ig = 1,ngrid |
---|
| 490 | |
---|
| 491 | foundswitch = 0 |
---|
| 492 | do l = 1,nlayer |
---|
| 493 | do i = 1,nbq |
---|
| 494 | iq = niq(i) ! get tracer index |
---|
| 495 | zq(ig,l,iq) = pq(ig,l,iq) + pdq(ig,l,iq)*ptimestep |
---|
| 496 | zycol(l,iq) = zq(ig,l,iq)*mmean(ig,l)/mmol(iq) |
---|
| 497 | end do |
---|
| 498 | zt(ig,l) = pt(ig,l) + pdt(ig,l)*ptimestep |
---|
| 499 | zu(ig,l) = pu(ig,l) + pdu(ig,l)*ptimestep |
---|
| 500 | zv(ig,l) = pv(ig,l) + pdv(ig,l)*ptimestep |
---|
| 501 | zpress(l) = pplay(ig,l)/100. |
---|
| 502 | ztemp(l) = zt(ig,l) |
---|
| 503 | zdens(l) = zpress(l)/(kb*1.e4*ztemp(l)) |
---|
| 504 | zlocal(l) = zzlay(ig,l)/1000. |
---|
| 505 | zmmean(l) = mmean(ig,l) |
---|
[2158] | 506 | ztelec(l) = temp_elect(zlocal(l),ztemp(l),1) |
---|
| 507 | !Electronic temperature. Index 1 -> Viking; Index 2-> MAVEN |
---|
[1495] | 508 | |
---|
| 509 | ! surfdust1d and surfice1d: conversion from m2/m3 to cm2/cm3 |
---|
| 510 | |
---|
| 511 | surfdust1d(l) = surfdust(ig,l)*1.e-2 |
---|
| 512 | surfice1d(l) = surfice(ig,l)*1.e-2 |
---|
| 513 | |
---|
[2158] | 514 | ! search for switch index between regions |
---|
| 515 | if(unichim) then |
---|
| 516 | lswitch=nlayer+1 |
---|
| 517 | else |
---|
[1495] | 518 | if (foundswitch == 0 .and. pplay(ig,l) < 1.e-1) then |
---|
| 519 | lswitch = l |
---|
| 520 | foundswitch = 1 |
---|
| 521 | end if |
---|
[2158] | 522 | endif |
---|
[1495] | 523 | end do ! of do l=1,nlayer |
---|
| 524 | |
---|
| 525 | szacol = acos(mu0(ig))*180./pi |
---|
[2031] | 526 | taucol = tau(ig) |
---|
[1495] | 527 | |
---|
| 528 | !======================================================================= |
---|
| 529 | ! call chemical subroutines |
---|
| 530 | !======================================================================= |
---|
| 531 | |
---|
[2158] | 532 | ! chemistry: only one scheme at all layers |
---|
| 533 | |
---|
[1495] | 534 | if (photochem) then |
---|
[2007] | 535 | call photochemistry(nlayer,nq, & |
---|
[2027] | 536 | ig,lswitch,zycol,szacol,ptimestep, & |
---|
[2158] | 537 | zpress,zlocal,ztemp,ztelec,zdens,zmmean, & |
---|
| 538 | dist_sol,zday,surfdust1d,surfice1d, & |
---|
| 539 | jo3,jh2o,taucol,iter) |
---|
[1495] | 540 | |
---|
| 541 | ! ozone photolysis, for output |
---|
| 542 | |
---|
| 543 | do l = 1,nlayer |
---|
| 544 | jo3_3d(ig,l) = jo3(l) |
---|
[2030] | 545 | jh2o_3d(ig,l) = jh2o(l) |
---|
[1495] | 546 | iter_3d(ig,l) = iter(l) |
---|
| 547 | end do |
---|
| 548 | ! condensation of h2o2 |
---|
| 549 | |
---|
| 550 | call perosat(ngrid, nlayer, nq, & |
---|
| 551 | ig,ptimestep,pplev,pplay, & |
---|
| 552 | ztemp,zycol,dqcloud,dqscloud) |
---|
| 553 | |
---|
[2158] | 554 | if(.not.unichim) then |
---|
| 555 | chemthermod=3 !C/O/H/N/ions |
---|
| 556 | call chemthermos(ig,nlayer,lswitch,chemthermod,zycol,ztemp,& |
---|
| 557 | zdens,zpress,zlocal,szacol,ptimestep,zday,& |
---|
| 558 | em_no,em_o2) |
---|
| 559 | do l=1,nlayer |
---|
| 560 | emission_no(ig,l)=em_no(l) |
---|
| 561 | emission_o2(ig,l)=em_o2(l) |
---|
| 562 | enddo |
---|
| 563 | end if |
---|
[1495] | 564 | end if |
---|
| 565 | |
---|
| 566 | ! dry deposition |
---|
| 567 | |
---|
| 568 | if (depos) then |
---|
| 569 | call deposition(ngrid, nlayer, nq, & |
---|
| 570 | ig, ig_vl1, pplay, pplev, zzlay, zzlev, & |
---|
| 571 | zu, zv, zt, zycol, ptimestep, co2ice) |
---|
| 572 | end if |
---|
| 573 | |
---|
| 574 | !======================================================================= |
---|
| 575 | ! tendencies |
---|
| 576 | !======================================================================= |
---|
| 577 | |
---|
| 578 | ! index of the most abundant species at each level |
---|
| 579 | |
---|
| 580 | ! major(:) = maxloc(zycol, dim = 2) |
---|
| 581 | |
---|
| 582 | ! tendency for the most abundant species = - sum of others |
---|
| 583 | |
---|
| 584 | do l = 1,nlayer |
---|
| 585 | iloc=maxloc(zycol(l,:)) |
---|
| 586 | iqmax=iloc(1) |
---|
| 587 | do i = 1,nbq |
---|
| 588 | iq = niq(i) ! get tracer index |
---|
| 589 | if (iq /= iqmax) then |
---|
| 590 | dqchim(ig,l,iq) = (zycol(l,iq)*mmol(iq)/mmean(ig,l) & |
---|
| 591 | - zq(ig,l,iq))/ptimestep |
---|
| 592 | dqchim(ig,l,iqmax) = dqchim(ig,l,iqmax) & |
---|
| 593 | - dqchim(ig,l,iq) |
---|
| 594 | end if |
---|
| 595 | end do |
---|
| 596 | end do ! of do l = 1,nlayer |
---|
| 597 | |
---|
| 598 | !======================================================================= |
---|
| 599 | ! end of loop over grid |
---|
| 600 | !======================================================================= |
---|
| 601 | |
---|
| 602 | end do ! of do ig=1,ngrid |
---|
| 603 | |
---|
| 604 | !======================================================================= |
---|
| 605 | ! write outputs |
---|
| 606 | !======================================================================= |
---|
| 607 | |
---|
| 608 | ! value of parameter 'output' to trigger writting of outputs |
---|
| 609 | ! is set above at the declaration of the variable. |
---|
| 610 | |
---|
| 611 | if (photochem .and. output) then |
---|
| 612 | if (ngrid > 1) then |
---|
| 613 | call writediagfi(ngrid,'jo3','j o3->o1d', & |
---|
| 614 | 's-1',3,jo3_3d(1,1)) |
---|
[2030] | 615 | call writediagfi(ngrid,'jh2o','jh2o', & |
---|
| 616 | 's-1',3,jh2o_3d(1,1)) |
---|
[1495] | 617 | call writediagfi(ngrid,'iter','iterations', & |
---|
| 618 | ' ',3,iter_3d(1,1)) |
---|
[2158] | 619 | if(.not.unichim) then |
---|
| 620 | call writediagfi(ngrid,'emission_no', & |
---|
| 621 | 'NO nightglow emission rate','cm-3 s-1',3,emission_no) |
---|
| 622 | call writediagfi(ngrid,'emission_o2', & |
---|
| 623 | 'O2 nightglow emission rate','cm-3 s-1',3,emission_o2) |
---|
| 624 | endif |
---|
[2042] | 625 | |
---|
[1495] | 626 | if (callstats) then |
---|
| 627 | call wstats(ngrid,'jo3','j o3->o1d', & |
---|
| 628 | 's-1',3,jo3_3d(1,1)) |
---|
[1888] | 629 | call wstats(ngrid,'emission_no', & |
---|
| 630 | 'NO nightglow emission rate','cm-3 s-1',3,emission_no) |
---|
| 631 | call wstats(ngrid,'emission_o2', & |
---|
| 632 | 'O2 nightglow emission rate','cm-3 s-1',3,emission_o2) |
---|
[1495] | 633 | call wstats(ngrid,'mmean','mean molecular mass', & |
---|
| 634 | 'g.mole-1',3,mmean(1,1)) |
---|
| 635 | endif |
---|
| 636 | end if ! of if (ngrid.gt.1) |
---|
| 637 | end if ! of if (output) |
---|
| 638 | |
---|
| 639 | return |
---|
| 640 | end |
---|