source: trunk/LMDZ.MARS/libf/aeronomars/photochemistry_asis.F90 @ 1717

Last change on this file since 1717 was 1708, checked in by flefevre, 8 years ago

Photochimie : le solveur chimique ASIS est desormais solveur par defaut.
Pour plus de details sur la methode voir Cariolle et al, Geosci. Model Dev., 10, 1467-1485, 2017.
(avec des vrais bouts de Mars dedans!)

File size: 55.7 KB
Line 
1!*****************************************************************
2!
3!     Photochemical routine
4!
5!     Author: Franck Lefevre
6!     ------
7!
8!     Version: 27/04/2017
9!
10!     ASIS scheme : for details on the method see
11!     Cariolle et al., Geosci. Model Dev., 10, 1467-1485, 2017.
12!
13!*****************************************************************
14
15subroutine photochemistry_asis(nlayer, nq,                            &
16                          ig, lswitch, zycol, sza, ptimestep, press,  &
17                          temp, dens, zmmean, dist_sol, surfdust1d,   &
18                          surfice1d, jo3, tau, iter)
19
20implicit none
21
22#include "chimiedata.h"
23#include "callkeys.h"
24
25!===================================================================
26!     inputs:
27!===================================================================
28
29integer, intent(in) :: nlayer ! number of atmospheric layers
30integer, intent(in) :: nq     ! number of tracers
31integer :: ig                 ! grid point index
32     
33real :: sza                   ! solar zenith angle (deg)
34real :: ptimestep             ! physics timestep (s)
35real :: press(nlayer)         ! pressure (hpa)
36real :: temp(nlayer)          ! temperature (k)
37real :: dens(nlayer)          ! density (cm-3)
38real :: zmmean(nlayer)        ! mean molar mass (g/mole)
39real :: dist_sol              ! sun distance (au)
40real :: surfdust1d(nlayer)    ! dust surface area (cm2/cm3)
41real :: surfice1d(nlayer)     ! ice surface area (cm2/cm3)
42real :: tau                   ! optical depth at 7 hpa
43
44!===================================================================
45!     input/output:
46!===================================================================
47     
48real :: zycol(nlayer,nq)       ! chemical species volume mixing ratio
49
50!===================================================================
51!     output:
52!===================================================================
53     
54integer :: iter(nlayer)        ! iteration counter
55real    :: jo3(nlayer)         ! photodissociation rate o3 -> o1d
56
57!===================================================================
58!     local:
59!===================================================================
60
61integer :: phychemrat         ! (physical timestep)/(nominal chemical timestep)
62integer :: j_o3_o1d, ilev
63integer :: iesp, nesp
64integer :: lswitch
65
66logical, save :: firstcall = .true.
67
68parameter (nesp = 17)         ! number of species in the chemistry
69
70! tracer indexes in the chemistry:
71
72integer,parameter :: i_co2  =  1
73integer,parameter :: i_co   =  2
74integer,parameter :: i_o    =  3
75integer,parameter :: i_o1d  =  4
76integer,parameter :: i_o2   =  5
77integer,parameter :: i_o3   =  6
78integer,parameter :: i_h    =  7
79integer,parameter :: i_h2   =  8
80integer,parameter :: i_oh   =  9
81integer,parameter :: i_ho2  = 10
82integer,parameter :: i_h2o2 = 11
83integer,parameter :: i_h2o  = 12
84integer,parameter :: i_n    = 13
85integer,parameter :: i_n2d  = 14
86integer,parameter :: i_no   = 15
87integer,parameter :: i_no2  = 16
88integer,parameter :: i_n2   = 17
89
90real :: ctimestep           ! standard timestep for the chemistry (s)
91real :: dt_guess            ! first-guess timestep (s)
92real :: dt_corrected        ! corrected timestep (s)
93real :: j(nlayer,nd)        ! interpolated photolysis rates (s-1)
94real :: time                ! internal time (between 0 and ptimestep, in s)
95
96real, dimension(nlayer,nesp)            :: rm   ! mixing ratios
97real (kind = 8), dimension(nesp)        :: cold ! number densities at previous timestep (molecule.cm-3)
98real (kind = 8), dimension(nlayer,nesp) :: c    ! number densities at current timestep (molecule.cm-3)
99real (kind = 8), dimension(nesp)        :: cnew ! number densities at next timestep (molecule.cm-3)
100 
101! reaction rates
102 
103real (kind = 8), dimension(nlayer,      nb_phot_max) :: v_phot
104real (kind = 8), dimension(nlayer,nb_reaction_3_max) :: v_3
105real (kind = 8), dimension(nlayer,nb_reaction_4_max) :: v_4
106logical :: hetero_dust, hetero_ice
107
108! matrix
109
110real (kind = 8), dimension(nesp,nesp) :: mat, mat1
111integer, dimension(nesp)              :: indx
112integer                               :: code
113
114! production and loss terms (for first-guess solution only)
115
116real (kind = 8), dimension(nesp) :: prod, loss
117
118!===================================================================
119!     initialisation of the reaction indexes
120!===================================================================
121
122if (firstcall) then
123   print*,'photochemistry: initialize indexes'
124   call indice(i_co2, i_co, i_o, i_o1d, i_o2, i_o3, i_h,       &
125               i_h2, i_oh, i_ho2, i_h2o2, i_h2o,               &
126               i_n, i_n2d, i_no, i_no2, i_n2)
127   firstcall = .false.
128end if
129
130!===================================================================
131!     initialisation of mixing ratios and densities       
132!===================================================================
133
134call gcmtochim(nlayer, nq, zycol, lswitch, nesp,               &
135               i_co2, i_co, i_o, i_o1d, i_o2, i_o3, i_h,       &
136               i_h2, i_oh, i_ho2, i_h2o2, i_h2o,               &
137               i_n, i_n2d, i_no, i_no2, i_n2, dens, rm, c)
138
139!===================================================================
140!     interpolation of photolysis rates in the lookup table     
141!===================================================================
142
143call photolysis_asis(nlayer, lswitch, press, temp, sza, tau, zmmean, dist_sol, &
144                     rm(:,i_co2), rm(:,i_o3), v_phot)
145
146! save o3 photolysis for output
147
148j_o3_o1d = 5
149jo3(:) = v_phot(:,j_o3_o1d)
150
151!===================================================================
152!     reaction rates                                     
153!===================================================================
154!     switches for heterogeneous chemistry
155!     hetero_ice  : reactions on ice clouds
156!     hetero_dust : reactions on dust   
157!===================================================================
158
159hetero_dust = .false.
160hetero_ice  = .true.
161
162call reactionrates(nlayer, lswitch, dens, c(:,i_co2), c(:,i_o2), &
163                   press, temp, hetero_dust, hetero_ice,         &
164                   surfdust1d, surfice1d, v_phot, v_3, v_4)
165
166!===================================================================
167!     ctimestep : standard chemical timestep (s), defined as
168!                 the fraction phychemrat of the physical timestep                           
169!===================================================================
170
171phychemrat = 1
172
173ctimestep = ptimestep/real(phychemrat)
174
175!print*, "ptimestep  = ", ptimestep
176!print*, "phychemrat = ", phychemrat
177!print*, "ctimestep  = ", ctimestep
178!stop
179
180!===================================================================
181!     loop over levels         
182!===================================================================
183
184do ilev = 1,lswitch - 1
185
186!  initializations
187
188   time = 0.
189   iter(ilev) = 0
190   dt_guess = ctimestep
191   cold(:) = c(ilev,:)
192
193!  internal loop for the chemistry
194
195   do while (time < ptimestep)
196
197   iter(ilev) = iter(ilev) + 1    ! iteration counter
198 
199!  first-guess: fill matrix
200
201   call fill_matrix(ilev, mat1, prod, loss, c, nesp, nlayer, v_phot, v_3, v_4)
202
203!  adaptative evaluation of the sub time step
204
205   call define_dt(nesp, dt_corrected, dt_guess, ctimestep, cold(:), c(ilev,:),  &
206                  mat1, prod, loss, dens(ilev))
207
208   if (time + dt_corrected > ptimestep) then
209      dt_corrected = ptimestep - time
210   end if
211
212!  if (dt_corrected /= dt_guess) then  ! the timestep has been modified
213
214!  form the matrix identity + mat*dt_corrected
215
216   mat(:,:) = mat1(:,:)*dt_corrected
217   do iesp = 1,nesp
218      mat(iesp,iesp) = 1. + mat(iesp,iesp)
219   end do
220
221!  solve the linear system  M*Cn+1 = Cn (RHS in cnew, then replaced by solution)
222     
223   cnew(:) = c(ilev,:)
224
225#ifdef LAPACK
226   call dgesv(nesp,1,mat,nesp,indx,cnew,nesp,code)
227#else
228   write(*,*) "photochemistry_asis error, missing LAPACK routine dgesv"
229   stop
230#endif
231
232!  end if
233
234!  eliminate small values
235
236   where (cnew(:)/dens(ilev) < 1.e-30)
237      cnew(:) = 0.
238   end where
239
240!  update concentrations
241
242   cold(:)   = c(ilev,:)
243   c(ilev,:) = cnew(:)
244   cnew(:)   = 0.
245
246!  increment internal time
247
248   time = time + dt_corrected
249   dt_guess = dt_corrected     ! first-guess timestep for next iteration
250
251   end do ! while (time < ptimestep)
252
253end do ! ilev
254
255!===================================================================
256!     save chemical species for the gcm       
257!===================================================================
258
259call chimtogcm(nlayer, nq, zycol, lswitch, nesp,              &
260               i_co2, i_co, i_o, i_o1d, i_o2, i_o3, i_h,      &
261               i_h2, i_oh, i_ho2, i_h2o2, i_h2o,              &
262               i_n, i_n2d, i_no, i_no2, i_n2, dens, c)
263
264contains
265
266!================================================================
267
268 subroutine define_dt(nesp, dtnew, dtold, ctimestep, cold, ccur, mat1, &
269                      prod, loss, dens)
270
271!================================================================
272! iterative evaluation of the appropriate time step dtnew
273! according to curvature criterion based on
274! e = 2 Rtol [r Cn+1 -(1-r) Cn + Cn-1 ]/[(1+r) Cn]
275! with r = (tn - tn-1)/(tn+1 - tn)
276!================================================================
277
278implicit none
279
280! input
281
282integer :: nesp  ! number of species in the chemistry
283
284real :: dtold, ctimestep
285real (kind = 8), dimension(nesp)      :: cold, ccur
286real (kind = 8), dimension(nesp,nesp) :: mat1
287real (kind = 8), dimension(nesp)      :: prod, loss
288real                                  :: dens
289
290! output
291
292real :: dtnew
293
294! local
295
296real (kind = 8), dimension(nesp)      :: cnew
297real (kind = 8), dimension(nesp,nesp) :: mat
298real (kind = 8) :: atol, ratio, e, es, coef
299
300integer                  :: code, iesp, iter
301integer, dimension(nesp) :: indx
302
303real :: dttest
304
305! parameters
306
307real (kind = 8), parameter :: dtmin   = 10.      ! minimum time step (s)
308real (kind = 8), parameter :: vmrtol  = 1.e-11   ! absolute tolerance on vmr
309real (kind = 8), parameter :: rtol    = 1./0.05   ! 1/rtol recommended value : 0.1-0.02
310integer,         parameter :: niter   = 3        ! number of iterations
311real (kind = 8), parameter :: coefmax = 2.
312real (kind = 8), parameter :: coefmin = 0.1
313logical                    :: fast_guess = .true.
314
315dttest = dtold   ! dttest = dtold = dt_guess
316
317atol = vmrtol*dens ! absolute tolerance in molecule.cm-3
318
319do iter = 1,niter
320
321if (fast_guess) then
322
323! first guess : fast semi-implicit method
324
325   do iesp = 1, nesp
326      cnew(iesp) = (ccur(iesp) + prod(iesp)*dttest)/(1. + loss(iesp)*dttest)
327   end do
328
329else
330
331! first guess : form the matrix identity + mat*dt_guess
332
333   mat(:,:) = mat1(:,:)*dttest
334   do iesp = 1,nesp
335      mat(iesp,iesp) = 1. + mat(iesp,iesp)
336   end do
337
338! form right-hand side (RHS) of the system
339
340   cnew(:) = ccur(:)
341
342! solve the linear system  M*Cn+1 = Cn (RHS in cnew, then replaced by solution)
343
344#ifdef LAPACK
345      call dgesv(nesp,1,mat,nesp,indx,cnew,nesp,code)
346#else
347   write(*,*) "photochemistry_asis error, missing LAPACK routine dgesv"
348   stop
349#endif
350
351end if
352
353! ratio old/new subtimestep
354
355ratio = dtold/dttest
356
357! e : local error indicatocitr
358
359e = 0.
360
361do iesp = 1,nesp
362   es = 2.*abs((ratio*cnew(iesp) - (1. + ratio)*ccur(iesp) + cold(iesp))   &
363         /(1. + ratio)/max(ccur(iesp),atol))
364
365   if (es > e) then
366      e = es
367   end if
368end do
369e = rtol*e
370
371! timestep correction
372
373coef = max(coefmin, min(coefmax,0.8/sqrt(e)))
374
375dttest = max(dtmin,dttest*coef)
376dttest = min(ctimestep,dttest)
377
378end do ! iter
379
380! new timestep
381
382dtnew = dttest
383
384end subroutine define_dt
385
386!======================================================================
387
388 subroutine reactionrates(nlayer,                               &
389                          lswitch, dens, co2, o2, press, t,     &
390                          hetero_dust, hetero_ice,              &
391                          surfdust1d, surfice1d,                &
392                          v_phot, v_3, v_4)
393 
394!================================================================
395! compute reaction rates                                        !
396!----------------------------------------------------------------
397! reaction               type                array              !
398!----------------------------------------------------------------
399! A + B    --> C + D     bimolecular         v_4                !
400! A + A    --> B + C     quadratic           v_3                !
401! A + C    --> B + C     quenching           v_phot             !
402! A + ice  --> B + C     heterogeneous       v_phot             !
403!================================================================
404
405use comcstfi_h
406
407implicit none
408
409#include "chimiedata.h"
410
411!----------------------------------------------------------------------
412!     input
413!----------------------------------------------------------------------
414
415integer, intent(in)     :: nlayer            ! number of atmospheric layers
416integer                 :: lswitch           ! interface level between lower
417                                             ! atmosphere and thermosphere chemistries
418real, dimension(nlayer) :: dens              ! total number density (molecule.cm-3)
419real, dimension(nlayer) :: press             ! pressure (hPa)
420real, dimension(nlayer) :: t                 ! temperature (K)
421real, dimension(nlayer) :: surfdust1d        ! dust surface area (cm2.cm-3)
422real, dimension(nlayer) :: surfice1d         ! ice surface area (cm2.cm-3)
423real (kind = 8), dimension(nlayer) :: co2    ! co2 number density (molecule.cm-3)
424real (kind = 8), dimension(nlayer) :: o2     ! o2 number density (molecule.cm-3)
425logical :: hetero_dust, hetero_ice           ! switches for heterogeneous chemistry
426
427!----------------------------------------------------------------------
428!     output
429!----------------------------------------------------------------------
430
431real (kind = 8), dimension(nlayer,      nb_phot_max) :: v_phot
432real (kind = 8), dimension(nlayer,nb_reaction_3_max) :: v_3
433real (kind = 8), dimension(nlayer,nb_reaction_4_max) :: v_4
434
435!----------------------------------------------------------------------
436!     local
437!----------------------------------------------------------------------
438
439integer          :: ilev
440integer          :: nb_phot, nb_reaction_3, nb_reaction_4
441real :: ak0, ak1, xpo, rate
442real :: k1a0, k1b0, k1ainf, k1a, k1b, fc, fx, x, y, gam
443real, dimension(nlayer) :: deq
444real, dimension(nlayer) :: a001, a002, a003,                           &
445                             b001, b002, b003, b004, b005, b006, b007,   &
446                             b008, b009,                                 &
447                             c001, c002, c003, c004, c005, c006, c007,   &
448                             c008, c009, c010, c011, c012, c013, c014,   &
449                             c015, c016, c017, c018,                     &
450                             d001, d002, d003, d004, d005, d006, d007,   &
451                             d008, d009,                                 &
452                             e001, e002,                                 &
453                             h001, h002, h003, h004, h005
454
455!----------------------------------------------------------------------
456!     initialisation
457!----------------------------------------------------------------------
458
459      nb_phot       = 11       ! jmars.20140930 reduit de 13 a 11
460      nb_reaction_3 = 0
461      nb_reaction_4 = 0
462
463!----------------------------------------------------------------------
464!     oxygen reactions
465!----------------------------------------------------------------------
466
467!---  a001: o + o2 + co2 -> o3 + co2
468
469!     jpl 2003
470!
471!     co2 efficiency as a third body (2.075)
472!     from sehested et al., j. geophys. res., 100, 1995.
473
474      a001(:) = 2.075*6.0e-34*(t(:)/300.)**(-2.4)*dens(:)
475
476      nb_reaction_4 = nb_reaction_4 + 1
477      v_4(:,nb_reaction_4) = a001(:)
478
479!---  a002: o + o + co2 -> o2 + co2
480
481!     Tsang and Hampson, J. Chem. Phys. Ref. Data, 15, 1087, 1986
482
483!     a002(:) = 2.5*5.2e-35*exp(900./t(:))*dens(:)
484
485!     Campbell and Gray, Chem. Phys. Lett., 18, 607, 1973
486
487!     a002(:) = 1.2e-32*(300./t(:))**(2.0)*dens(:)  ! yung expression
488      a002(:) = 2.5*9.46e-34*exp(485./t(:))*dens(:) ! nist expression
489
490      nb_reaction_3 = nb_reaction_3 + 1
491      v_3(:,nb_reaction_3) = a002(:)
492
493!---  a003: o + o3 -> o2 + o2
494
495!     jpl 2003
496
497      a003(:) = 8.0e-12*exp(-2060./t(:))
498
499      nb_reaction_4 = nb_reaction_4 + 1
500      v_4(:,nb_reaction_4) = a003(:)
501
502!----------------------------------------------------------------------
503!     o(1d) reactions
504!----------------------------------------------------------------------
505
506!---  b001: o(1d) + co2  -> o + co2
507
508!     jpl 2006
509
510      b001(:) = 7.5e-11*exp(115./t(:))
511   
512      nb_phot = nb_phot + 1
513      v_phot(:,nb_phot) = b001(:)*co2(:)
514
515!---  b002: o(1d) + h2o  -> oh + oh
516
517!     jpl 2006
518 
519      b002(:) = 1.63e-10*exp(60./t(:))
520
521      nb_reaction_4 = nb_reaction_4 + 1
522      v_4(:,nb_reaction_4) = b002(:)
523
524!---  b003: o(1d) + h2  -> oh + h
525
526!     jpl 2011
527
528      b003(:) = 1.2e-10
529
530      nb_reaction_4 = nb_reaction_4 + 1
531      v_4(:,nb_reaction_4) = b003(:)
532
533!---  b004: o(1d) + o2  -> o + o2
534
535!     jpl 2006
536
537      b004(:) = 3.3e-11*exp(55./t(:))
538
539      nb_phot = nb_phot + 1
540      v_phot(:,nb_phot) = b004(:)*o2(:)
541   
542!---  b005: o(1d) + o3  -> o2 + o2
543
544!     jpl 2003
545
546      b005(:) = 1.2e-10
547
548      nb_reaction_4 = nb_reaction_4 + 1
549      v_4(:,nb_reaction_4) = b005(:)
550   
551!---  b006: o(1d) + o3  -> o2 + o + o
552
553!     jpl 2003
554
555      b006(:) = 1.2e-10
556
557      nb_reaction_4 = nb_reaction_4 + 1
558      v_4(:,nb_reaction_4) = b006(:)
559   
560!---  b007: o(1d) + ch4 -> ch3 + oh
561
562!     jpl 2003
563
564      b007(:) = 1.5e-10*0.75
565
566!---  b008: o(1d) + ch4 -> ch3o + h
567
568!     jpl 2003
569
570      b008(:) = 1.5e-10*0.20
571!
572!---  b009: o(1d) + ch4 -> ch2o + h2
573
574!     jpl 2003
575
576      b009(:) = 1.5e-10*0.05
577
578!----------------------------------------------------------------------
579!     hydrogen reactions
580!----------------------------------------------------------------------
581
582!---  c001: o + ho2 -> oh + o2
583
584!     jpl 2003
585
586      c001(:) = 3.0e-11*exp(200./t(:))
587
588      nb_reaction_4 = nb_reaction_4 + 1
589      v_4(:,nb_reaction_4) = c001(:)
590
591!---  c002: o + oh -> o2 + h
592
593!     jpl 2011
594
595      c002(:) = 1.8e-11*exp(180./t(:))
596
597!     robertson and smith, j. chem. phys. a 110, 6673, 2006
598
599!     c002(:) = 11.2e-11*t(:)**(-0.32)*exp(177./t(:))
600
601      nb_reaction_4 = nb_reaction_4 + 1
602      v_4(:,nb_reaction_4) = c002(:)
603
604!---  c003: h + o3 -> oh + o2
605
606!     jpl 2003
607
608      c003(:) = 1.4e-10*exp(-470./t(:))
609
610      nb_reaction_4 = nb_reaction_4 + 1
611      v_4(:,nb_reaction_4) = c003(:)
612
613!---  c004: h + ho2 -> oh + oh
614
615!     jpl 2006
616
617      c004(:) = 7.2e-11
618
619      nb_reaction_4 = nb_reaction_4 + 1
620      v_4(:,nb_reaction_4) = c004(:)
621
622!---  c005: h + ho2 -> h2 + o2
623
624!     jpl 2006
625
626      c005(:) = 6.9e-12
627
628      nb_reaction_4 = nb_reaction_4 + 1
629      v_4(:,nb_reaction_4) = c005(:)
630
631!---  c006: h + ho2 -> h2o + o
632
633!     jpl 2006
634
635      c006(:) = 1.6e-12
636
637      nb_reaction_4 = nb_reaction_4 + 1
638      v_4(:,nb_reaction_4) = c006(:)
639
640!---  c007: oh + ho2 -> h2o + o2
641
642!     jpl 2003
643
644!     canty et al., grl, 2006 suggest to increase this rate
645!     by 20%. not done here.
646
647      c007(:) = 4.8e-11*exp(250./t(:))
648
649      nb_reaction_4 = nb_reaction_4 + 1
650      v_4(:,nb_reaction_4) = c007(:)
651
652!---  c008: ho2 + ho2 -> h2o2 + o2
653
654!     jpl 2006
655
656!     c008(:) = 3.5e-13*exp(430./t(:))
657
658!     christensen et al., grl, 13, 2002
659
660      c008(:) = 1.5e-12*exp(19./t(:))
661
662      nb_reaction_3 = nb_reaction_3 + 1
663      v_3(:,nb_reaction_3) = c008(:)
664
665!---  c009: oh + h2o2 -> h2o + ho2
666
667!     jpl 2006
668
669      c009(:) = 1.8e-12
670
671      nb_reaction_4 = nb_reaction_4 + 1
672      v_4(:,nb_reaction_4) = c009(:)
673
674!---  c010: oh + h2 -> h2o + h
675
676!     jpl 2006
677
678      c010(:) = 2.8e-12*exp(-1800./t(:))
679
680      nb_reaction_4 = nb_reaction_4 + 1
681      v_4(:,nb_reaction_4) = c010(:)
682
683!---  c011: h + o2 + co2 -> ho2 + co2
684
685!     jpl 2011
686
687      do ilev = 1,lswitch-1
688         ak0 = 2.5*4.4e-32*(t(ilev)/300.)**(-1.3)
689         ak1 = 7.5e-11*(t(ilev)/300.)**(0.2)
690
691         rate = (ak0*dens(ilev))/(1. + ak0*dens(ilev)/ak1)
692         xpo = 1./(1. + alog10((ak0*dens(ilev))/ak1)**2)
693         c011(ilev) = rate*0.6**xpo
694      end do
695
696      nb_reaction_4 = nb_reaction_4 + 1
697      v_4(:,nb_reaction_4) = c011(:)
698
699!---  c012: o + h2o2 -> oh + ho2
700
701!     jpl 2003
702
703      c012(:) = 1.4e-12*exp(-2000./t(:))
704
705      nb_reaction_4 = nb_reaction_4 + 1
706      v_4(:,nb_reaction_4) = c012(:)
707
708!---  c013: oh + oh -> h2o + o
709
710!     jpl 2006
711
712      c013(:) = 1.8e-12
713
714      nb_reaction_3 = nb_reaction_3 + 1
715      v_3(:,nb_reaction_3) = c013(:)
716
717!---  c014: oh + o3 -> ho2 + o2
718
719!     jpl 2003
720
721      c014(:) = 1.7e-12*exp(-940./t(:))
722
723      nb_reaction_4 = nb_reaction_4 + 1
724      v_4(:,nb_reaction_4) = c014(:)
725
726!---  c015: ho2 + o3 -> oh + o2 + o2
727
728!     jpl 2003
729
730      c015(:) = 1.0e-14*exp(-490./t(:))
731
732      nb_reaction_4 = nb_reaction_4 + 1
733      v_4(:,nb_reaction_4) = c015(:)
734
735!---  c016: ho2 + ho2 + co2 -> h2o2 + o2 + co2
736
737!     jpl 2011
738
739      c016(:) = 2.5*2.1e-33*exp(920./t(:))*dens(:)
740
741      nb_reaction_3 = nb_reaction_3 + 1
742      v_3(:,nb_reaction_3) = c016(:)
743
744!---  c017: oh + oh + co2 -> h2o2 + co2
745
746!     jpl 2003
747
748      do ilev = 1,lswitch-1
749         ak0 = 2.5*6.9e-31*(t(ilev)/300.)**(-1.0)
750         ak1 = 2.6e-11*(t(ilev)/300.)**(0.0)
751
752         rate = (ak0*dens(ilev))/(1. + ak0*dens(ilev)/ak1)
753         xpo = 1./(1. + alog10((ak0*dens(ilev))/ak1)**2)
754         c017(ilev) = rate*0.6**xpo
755      end do
756
757      nb_reaction_3 = nb_reaction_3 + 1
758      v_3(:,nb_reaction_3) = c017(:)
759
760!---  c018: h + h + co2 -> h2 + co2
761
762!     baulch et al., 2005
763
764      c018(:) = 2.5*1.8e-30*(t(:)**(-1.0))*dens(:)
765
766      nb_reaction_3 = nb_reaction_3 + 1
767      v_3(:,nb_reaction_3) = c018(:)
768
769!----------------------------------------------------------------------
770!     nitrogen reactions
771!----------------------------------------------------------------------
772
773!---  d001: no2 + o -> no + o2
774
775!     jpl 2006
776
777      d001(:) = 5.1e-12*exp(210./t(:))
778
779      nb_reaction_4 = nb_reaction_4 + 1
780      v_4(:,nb_reaction_4) = d001(:)
781
782!---  d002: no + o3 -> no2 + o2
783
784!     jpl 2006
785
786      d002(:) = 3.0e-12*exp(-1500./t(:))
787
788      nb_reaction_4 = nb_reaction_4 + 1
789      v_4(:,nb_reaction_4) = d002(:)
790
791!---  d003: no + ho2 -> no2 + oh
792
793!     jpl 2011
794
795      d003(:) = 3.3e-12*exp(270./t(:))
796
797      nb_reaction_4 = nb_reaction_4 + 1
798      v_4(:,nb_reaction_4) = d003(:)
799
800!---  d004: n + no -> n2 + o
801
802!     jpl 2011
803
804      d004(:) = 2.1e-11*exp(100./t(:))
805
806      nb_reaction_4 = nb_reaction_4 + 1
807      v_4(:,nb_reaction_4) = d004(:)
808
809!---  d005: n + o2 -> no + o
810
811!     jpl 2011
812
813      d005(:) = 1.5e-11*exp(-3600./t(:))
814
815      nb_reaction_4 = nb_reaction_4 + 1
816      v_4(:,nb_reaction_4) = d005(:)
817
818!---  d006: no2 + h -> no + oh
819
820!     jpl 2011
821
822      d006(:) = 4.0e-10*exp(-340./t(:))
823
824      nb_reaction_4 = nb_reaction_4 + 1
825      v_4(:,nb_reaction_4) = d006(:)
826
827!---  d007: n + o -> no
828 
829      d007(:) = 2.8e-17*(300./t(:))**0.5
830
831      nb_reaction_4 = nb_reaction_4 + 1
832      v_4(:,nb_reaction_4) = d007(:)
833
834!---  d008: n + ho2 -> no + oh
835
836!     brune et al., j. chem. phys., 87, 1983
837
838      d008(:) = 2.19e-11
839
840      nb_reaction_4 = nb_reaction_4 + 1
841      v_4(:,nb_reaction_4) = d008(:)
842
843!---  d009: n + oh -> no + h
844
845!     atkinson et al., j. phys. chem. ref. data, 18, 881, 1989
846
847      d009(:) = 3.8e-11*exp(85./t(:))
848
849      nb_reaction_4 = nb_reaction_4 + 1
850      v_4(:,nb_reaction_4) = d009(:)
851
852!----------------------------------------------------------------------
853!     carbon reactions
854!----------------------------------------------------------------------
855
856!---  e001: oh + co -> co2 + h
857
858!     jpl 2003
859
860!     e001(:) = 1.5e-13*(1 + 0.6*press(:)/1013.)
861
862!     mccabe et al., grl, 28, 3135, 2001
863
864!     e001(:) = 1.57e-13 + 3.54e-33*dens(:)
865
866!     jpl 2006
867
868!     ak0 = 1.5e-13*(t(:)/300.)**(0.6)
869!     ak1 = 2.1e-9*(t(:)/300.)**(6.1)
870!     rate1 = ak0/(1. + ak0/(ak1/dens(:)))
871!     xpo1 = 1./(1. + alog10(ak0/(ak1/dens(:)))**2)
872
873!     ak0 = 5.9e-33*(t(:)/300.)**(-1.4)
874!     ak1 = 1.1e-12*(t(:)/300.)**(1.3)
875!     rate2 = (ak0*dens(:))/(1. + ak0*dens(:)/ak1)
876!     xpo2 = 1./(1. + alog10((ak0*dens(:))/ak1)**2)
877
878!     e001(:) = rate1*0.6**xpo1 + rate2*0.6**xpo2
879
880!     joshi et al., 2006
881
882      do ilev = 1,lswitch-1
883         k1a0 = 1.34*2.5*dens(ilev)                                  &
884               *1/(1/(3.62e-26*t(ilev)**(-2.739)*exp(-20./t(ilev)))  &
885               + 1/(6.48e-33*t(ilev)**(0.14)*exp(-57./t(ilev))))     ! typo in paper corrected
886         k1b0 = 1.17e-19*t(ilev)**(2.053)*exp(139./t(ilev))          &
887              + 9.56e-12*t(ilev)**(-0.664)*exp(-167./t(ilev))
888         k1ainf = 1.52e-17*t(ilev)**(1.858)*exp(28.8/t(ilev))        &
889                + 4.78e-8*t(ilev)**(-1.851)*exp(-318./t(ilev))
890         x = k1a0/(k1ainf - k1b0)
891         y = k1b0/(k1ainf - k1b0)
892         fc = 0.628*exp(-1223./t(ilev)) + (1. - 0.628)*exp(-39./t(ilev))  &
893            + exp(-t(ilev)/255.)
894         fx = fc**(1./(1. + (alog(x))**2))                           ! typo in paper corrected
895         k1a = k1a0*((1. + y)/(1. + x))*fx
896         k1b = k1b0*(1./(1.+x))*fx
897
898         e001(ilev) = k1a + k1b
899      end do
900
901      nb_reaction_4 = nb_reaction_4 + 1
902      v_4(:,nb_reaction_4) = e001(:)
903
904!---  e002: o + co + m -> co2 + m
905
906!     tsang and hampson, 1986.
907
908      e002(:) = 2.5*6.5e-33*exp(-2184./t(:))*dens(:)
909
910      nb_reaction_4 = nb_reaction_4 + 1
911      v_4(:,nb_reaction_4) = e002(:)
912
913!----------------------------------------------------------------------
914!     heterogeneous chemistry
915!----------------------------------------------------------------------
916
917      if (hetero_ice) then
918
919!        k = (surface*v*gamma)/4 (s-1)
920!        v = 100*sqrt(8rt/(pi*m))  (cm s-1)
921 
922!---     h001: ho2 + ice -> products
923 
924!        cooper and abbatt, 1996: gamma = 0.025
925     
926         gam = 0.025
927         h001(:) = surfice1d(:)       &
928                   *100.*sqrt(8.*8.31*t(:)/(33.e-3*pi))*gam/4.
929 
930!        h002: oh + ice -> products
931 
932!        cooper and abbatt, 1996: gamma = 0.03
933 
934         gam = 0.03
935         h002(:) = surfice1d(:)       &
936                   *100.*sqrt(8.*8.31*t(:)/(17.e-3*pi))*gam/4.
937
938!---     h003: h2o2 + ice -> products
939 
940!        gamma = 0.    test value
941 
942         gam = 0.
943         h003(:) = surfice1d(:)       &
944                   *100.*sqrt(8.*8.31*t(:)/(34.e-3*pi))*gam/4.
945      else
946         h001(:) = 0.
947         h002(:) = 0.
948         h003(:) = 0.
949      end if
950
951      nb_phot = nb_phot + 1
952      v_phot(:,nb_phot) = h001(:)
953
954      nb_phot = nb_phot + 1
955      v_phot(:,nb_phot) = h002(:)
956
957      nb_phot = nb_phot + 1
958      v_phot(:,nb_phot) = h003(:)
959
960      if (hetero_dust) then
961 
962!---     h004: ho2 + dust -> products
963 
964!        jacob, 2000: gamma = 0.2
965!        see dereus et al., atm. chem. phys., 2005
966 
967         gam = 0.2
968         h004(:) = surfdust1d(:)  &
969                   *100.*sqrt(8.*8.31*t(:)/(33.e-3*pi))*gam/4.
970 
971!---     h005: h2o2 + dust -> products
972 
973!        gamma = 5.e-4
974!        see dereus et al., atm. chem. phys., 2005
975 
976         gam = 5.e-4
977         h005(:) = surfdust1d(:)  &
978                   *100.*sqrt(8.*8.31*t(:)/(34.e-3*pi))*gam/4.
979      else
980         h004(:) = 0.
981         h005(:) = 0.
982      end if
983 
984      nb_phot = nb_phot + 1
985      v_phot(:,nb_phot) = h004(:)
986
987      nb_phot = nb_phot + 1
988      v_phot(:,nb_phot) = h005(:)
989
990end subroutine reactionrates
991
992!======================================================================
993
994 subroutine fill_matrix(ilev, mat, prod, loss, c, nesp, nlayer, v_phot, v_3, v_4)
995
996!======================================================================
997! filling of the jacobian matrix
998!======================================================================
999
1000use types_asis
1001
1002implicit none
1003
1004#include "chimiedata.h"
1005
1006! input
1007
1008integer             :: ilev    ! level index
1009integer             :: nesp    ! number of species in the chemistry
1010integer, intent(in) :: nlayer  ! number of atmospheric layers
1011
1012real (kind = 8), dimension(nlayer,nesp)              :: c    ! number densities
1013real (kind = 8), dimension(nlayer,      nb_phot_max) :: v_phot
1014real (kind = 8), dimension(nlayer,nb_reaction_3_max) :: v_3
1015real (kind = 8), dimension(nlayer,nb_reaction_4_max) :: v_4
1016
1017! output
1018
1019real (kind = 8), dimension(nesp,nesp), intent(out) :: mat  ! matrix
1020real (kind = 8), dimension(nesp), intent(out)      :: prod, loss
1021
1022! local
1023
1024integer :: iesp
1025integer :: ind_phot_2,ind_phot_4,ind_phot_6
1026integer :: ind_3_2,ind_3_4,ind_3_6
1027integer :: ind_4_2,ind_4_4,ind_4_6,ind_4_8
1028integer :: iphot,i3,i4
1029
1030real(kind = 8) :: eps, eps_4  ! implicit/explicit coefficient
1031
1032! initialisations
1033
1034mat(:,:) = 0.
1035prod(:)  = 0.
1036loss(:)  = 0.
1037
1038! photodissociations
1039! or reactions a + c -> b + c
1040! or reactions a + ice -> b + c
1041
1042do iphot = 1,nb_phot_max
1043
1044  ind_phot_2 = indice_phot(iphot)%z2
1045  ind_phot_4 = indice_phot(iphot)%z4
1046  ind_phot_6 = indice_phot(iphot)%z6
1047
1048  mat(ind_phot_2,ind_phot_2) = mat(ind_phot_2,ind_phot_2) + indice_phot(iphot)%z1*v_phot(ilev,iphot)
1049  mat(ind_phot_4,ind_phot_2) = mat(ind_phot_4,ind_phot_2) - indice_phot(iphot)%z3*v_phot(ilev,iphot)
1050  mat(ind_phot_6,ind_phot_2) = mat(ind_phot_6,ind_phot_2) - indice_phot(iphot)%z5*v_phot(ilev,iphot)
1051
1052  loss(ind_phot_2) = loss(ind_phot_2) + indice_phot(iphot)%z1*v_phot(ilev,iphot)
1053  prod(ind_phot_4) = prod(ind_phot_4) + indice_phot(iphot)%z3*v_phot(ilev,iphot)*c(ilev,ind_phot_2)
1054  prod(ind_phot_6) = prod(ind_phot_6) + indice_phot(iphot)%z5*v_phot(ilev,iphot)*c(ilev,ind_phot_2)
1055
1056end do
1057
1058! reactions a + a -> b + c
1059
1060do i3 = 1,nb_reaction_3_max
1061
1062  ind_3_2 = indice_3(i3)%z2
1063  ind_3_4 = indice_3(i3)%z4
1064  ind_3_6 = indice_3(i3)%z6
1065
1066  mat(ind_3_2,ind_3_2) = mat(ind_3_2,ind_3_2) + indice_3(i3)%z1*v_3(ilev,i3)*c(ilev,ind_3_2)
1067  mat(ind_3_4,ind_3_2) = mat(ind_3_4,ind_3_2) - indice_3(i3)%z3*v_3(ilev,i3)*c(ilev,ind_3_2)
1068  mat(ind_3_6,ind_3_2) = mat(ind_3_6,ind_3_2) - indice_3(i3)%z5*v_3(ilev,i3)*c(ilev,ind_3_2)
1069
1070  loss(ind_3_2) = loss(ind_3_2) + indice_3(i3)%z1*v_3(ilev,i3)*c(ilev,ind_3_2)
1071  prod(ind_3_4) = prod(ind_3_4) + indice_3(i3)%z3*v_3(ilev,i3)*c(ilev,ind_3_2)*c(ilev,ind_3_2)
1072  prod(ind_3_6) = prod(ind_3_6) + indice_3(i3)%z5*v_3(ilev,i3)*c(ilev,ind_3_2)*c(ilev,ind_3_2)
1073
1074end do
1075
1076! reactions a + b -> c + d
1077
1078eps = 1.d-10
1079
1080do i4 = 1,nb_reaction_4_max
1081
1082  ind_4_2 = indice_4(i4)%z2
1083  ind_4_4 = indice_4(i4)%z4
1084  ind_4_6 = indice_4(i4)%z6
1085  ind_4_8 = indice_4(i4)%z8
1086
1087  eps_4 = abs(c(ilev,ind_4_2))/(abs(c(ilev,ind_4_2)) + abs(c(ilev,ind_4_4)) + eps)
1088  eps_4 = min(eps_4,1.0)
1089
1090  mat(ind_4_2,ind_4_2) = mat(ind_4_2,ind_4_2) + indice_4(i4)%z1*v_4(ilev,i4)*(1. - eps_4)*c(ilev,ind_4_4)
1091  mat(ind_4_2,ind_4_4) = mat(ind_4_2,ind_4_4) + indice_4(i4)%z1*v_4(ilev,i4)*eps_4*c(ilev,ind_4_2)
1092  mat(ind_4_4,ind_4_2) = mat(ind_4_4,ind_4_2) + indice_4(i4)%z3*v_4(ilev,i4)*(1. - eps_4)*c(ilev,ind_4_4)
1093  mat(ind_4_4,ind_4_4) = mat(ind_4_4,ind_4_4) + indice_4(i4)%z3*v_4(ilev,i4)*eps_4*c(ilev,ind_4_2)   
1094  mat(ind_4_6,ind_4_2) = mat(ind_4_6,ind_4_2) - indice_4(i4)%z5*v_4(ilev,i4)*(1. - eps_4)*c(ilev,ind_4_4)
1095  mat(ind_4_6,ind_4_4) = mat(ind_4_6,ind_4_4) - indice_4(i4)%z5*v_4(ilev,i4)*eps_4*c(ilev,ind_4_2)
1096  mat(ind_4_8,ind_4_2) = mat(ind_4_8,ind_4_2) - indice_4(i4)%z7*v_4(ilev,i4)*(1. - eps_4)*c(ilev,ind_4_4)
1097  mat(ind_4_8,ind_4_4) = mat(ind_4_8,ind_4_4) - indice_4(i4)%z7*v_4(ilev,i4)*eps_4*c(ilev,ind_4_2)
1098
1099  loss(ind_4_2) = loss(ind_4_2) + indice_4(i4)%z1*v_4(ilev,i4)*c(ilev,ind_4_4)
1100  loss(ind_4_4) = loss(ind_4_4) + indice_4(i4)%z3*v_4(ilev,i4)*c(ilev,ind_4_2)
1101  prod(ind_4_6) = prod(ind_4_6) + indice_4(i4)%z5*v_4(ilev,i4)*c(ilev,ind_4_2)*c(ilev,ind_4_4)
1102  prod(ind_4_8) = prod(ind_4_8) + indice_4(i4)%z7*v_4(ilev,i4)*c(ilev,ind_4_2)*c(ilev,ind_4_4)
1103
1104end do
1105
1106end subroutine fill_matrix
1107
1108!================================================================
1109
1110 subroutine indice(i_co2, i_co, i_o, i_o1d, i_o2, i_o3, i_h,       &
1111                   i_h2, i_oh, i_ho2, i_h2o2, i_h2o,               &
1112                   i_n, i_n2d, i_no, i_no2, i_n2)
1113
1114!================================================================
1115! set the "indice" arrays used to fill the jacobian matrix      !
1116!----------------------------------------------------------------
1117! reaction                                   type               !
1118!----------------------------------------------------------------
1119! A + hv   --> B + C     photolysis          indice_phot        !
1120! A + B    --> C + D     bimolecular         indice_4           !
1121! A + A    --> B + C     quadratic           indice_3           !
1122! A + C    --> B + C     quenching           indice_phot        !
1123! A + ice  --> B + C     heterogeneous       indice_phot        !
1124!================================================================
1125
1126use types_asis
1127
1128implicit none
1129
1130#include "chimiedata.h"
1131
1132! input
1133
1134integer :: i_co2, i_co, i_o, i_o1d, i_o2, i_o3, i_h,       &
1135           i_h2, i_oh, i_ho2, i_h2o2, i_h2o,               &
1136           i_n, i_n2d, i_no, i_no2, i_n2
1137
1138! local
1139
1140integer :: nb_phot, nb_reaction_3, nb_reaction_4
1141integer :: i_dummy
1142
1143allocate (indice_phot(nb_phot_max))
1144allocate (indice_3(nb_reaction_3_max))
1145allocate (indice_4(nb_reaction_4_max))
1146
1147i_dummy = 1
1148
1149nb_phot       = 0
1150nb_reaction_3 = 0
1151nb_reaction_4 = 0
1152
1153!===========================================================
1154!      O2 + hv -> O + O
1155!===========================================================
1156
1157nb_phot = nb_phot + 1
1158
1159indice_phot(nb_phot) = z3spec(1.0, i_o2, 2.0, i_o, 0.0, i_dummy)
1160
1161!===========================================================
1162!      O2 + hv -> O + O(1D)
1163!===========================================================
1164
1165nb_phot = nb_phot + 1
1166
1167indice_phot(nb_phot) = z3spec(1.0, i_o2, 1.0, i_o, 1.0, i_o1d)
1168
1169!===========================================================
1170!      CO2 + hv -> CO + O
1171!===========================================================
1172
1173nb_phot = nb_phot + 1
1174
1175indice_phot(nb_phot) = z3spec(1.0, i_co2, 1.0, i_co, 1.0, i_o)
1176
1177!===========================================================
1178!      CO2 + hv -> CO + O(1D)
1179!===========================================================
1180
1181nb_phot = nb_phot + 1
1182
1183indice_phot(nb_phot) = z3spec(1.0, i_co2, 1.0, i_co, 1.0, i_o1d)
1184
1185!===========================================================
1186!      O3 + hv -> O2 + O(1D)
1187!===========================================================
1188
1189nb_phot = nb_phot + 1
1190
1191indice_phot(nb_phot) = z3spec(1.0, i_o3, 1.0, i_o2, 1.0, i_o1d)
1192
1193!===========================================================
1194!      O3 + hv -> O2 + O
1195!===========================================================
1196
1197nb_phot = nb_phot + 1
1198
1199indice_phot(nb_phot) = z3spec(1.0, i_o3, 1.0, i_o2, 1.0, i_o)
1200
1201!===========================================================
1202!      H2O + hv -> H + OH
1203!===========================================================
1204
1205nb_phot = nb_phot + 1
1206
1207indice_phot(nb_phot) = z3spec(1.0, i_h2o, 1.0, i_h, 1.0, i_oh)
1208
1209!===========================================================
1210!      H2O2 + hv -> OH + OH
1211!===========================================================
1212
1213nb_phot = nb_phot + 1
1214
1215indice_phot(nb_phot) = z3spec(1.0, i_h2o2, 2.0, i_oh, 0.0, i_dummy)
1216
1217!===========================================================
1218!      HO2 + hv -> OH + O
1219!===========================================================
1220
1221nb_phot = nb_phot + 1
1222
1223indice_phot(nb_phot) = z3spec(1.0, i_ho2, 1.0, i_oh, 1.0, i_o)
1224
1225!===========================================================
1226!      NO + hv -> N + O
1227!===========================================================
1228
1229nb_phot = nb_phot + 1
1230
1231indice_phot(nb_phot) = z3spec(1.0, i_no, 1.0, i_n, 1.0, i_o)
1232
1233!===========================================================
1234!      NO2 + hv -> NO + O
1235!===========================================================
1236
1237nb_phot = nb_phot + 1
1238
1239indice_phot(nb_phot) = z3spec(1.0, i_no2, 1.0, i_no, 1.0, i_o)
1240
1241!===========================================================
1242!      a001 : O + O2 + CO2 -> O3 + CO2
1243!===========================================================
1244
1245nb_reaction_4 = nb_reaction_4 + 1
1246
1247indice_4(nb_reaction_4) = z4spec(1.0, i_o, 1.0, i_o2, 1.0, i_o3, 0.0, i_dummy)
1248
1249!===========================================================
1250!      a002 : O + O + CO2 -> O2 + CO2
1251!===========================================================
1252
1253nb_reaction_3 = nb_reaction_3 + 1
1254
1255indice_3(nb_reaction_3) = z3spec(2.0, i_o, 1.0, i_o2, 0.0, i_dummy)
1256
1257!===========================================================
1258!      a003 : O + O3 -> O2 + O2
1259!===========================================================
1260
1261nb_reaction_4 = nb_reaction_4 + 1
1262
1263indice_4(nb_reaction_4) = z4spec(1.0, i_o, 1.0, i_o3, 2.0, i_o2, 0.0, i_dummy)
1264
1265!===========================================================
1266!      b001 : O(1D) + CO2 -> O + CO2
1267!===========================================================
1268
1269nb_phot = nb_phot + 1
1270
1271indice_phot(nb_phot) = z3spec(1.0, i_o1d, 1.0, i_o, 0.0, i_dummy)
1272
1273!===========================================================
1274!      b002 : O(1D) + H2O -> OH + OH
1275!===========================================================
1276
1277nb_reaction_4 = nb_reaction_4 + 1
1278
1279indice_4(nb_reaction_4) = z4spec(1.0, i_o1d, 1.0, i_h2o, 2.0, i_oh, 0.0, i_dummy)
1280
1281!===========================================================
1282!      b003 : O(1D) + H2 -> OH + H
1283!===========================================================
1284
1285nb_reaction_4 = nb_reaction_4 + 1
1286
1287indice_4(nb_reaction_4) = z4spec(1.0, i_o1d, 1.0, i_h2, 1.0, i_oh, 1.0, i_h)
1288
1289!===========================================================
1290!      b004 : O(1D) + O2 -> O + O2
1291!===========================================================
1292
1293nb_phot = nb_phot + 1
1294
1295indice_phot(nb_phot) = z3spec(1.0, i_o1d, 1.0, i_o, 0.0, i_dummy)
1296
1297!===========================================================
1298!      b005 : O(1D) + O3 -> O2 + O2
1299!===========================================================
1300
1301nb_reaction_4 = nb_reaction_4 + 1
1302
1303indice_4(nb_reaction_4) = z4spec(1.0, i_o1d, 1.0, i_o3, 2.0, i_o2, 0.0, i_dummy)
1304
1305!===========================================================
1306!      b006 : O(1D) + O3 -> O2 + O + O
1307!===========================================================
1308
1309nb_reaction_4 = nb_reaction_4 + 1
1310
1311indice_4(nb_reaction_4) = z4spec(1.0, i_o1d, 1.0, i_o3, 1.0, i_o2, 2.0, i_o)
1312
1313!===========================================================
1314!      c001 : O + HO2 -> OH + O2
1315!===========================================================
1316
1317nb_reaction_4 = nb_reaction_4 + 1
1318
1319indice_4(nb_reaction_4) = z4spec(1.0, i_o, 1.0, i_ho2, 1.0, i_oh, 1.0, i_o2)
1320
1321!===========================================================
1322!      c002 : O + OH -> O2 + H
1323!===========================================================
1324
1325nb_reaction_4 = nb_reaction_4 + 1
1326
1327indice_4(nb_reaction_4) = z4spec(1.0, i_o, 1.0, i_oh, 1.0, i_o2, 1.0, i_h)
1328
1329!===========================================================
1330!      c003 : H + O3 -> OH + O2
1331!===========================================================
1332
1333nb_reaction_4 = nb_reaction_4 + 1
1334
1335indice_4(nb_reaction_4) = z4spec(1.0, i_h, 1.0, i_o3, 1.0, i_oh, 1.0, i_o2)
1336
1337!===========================================================
1338!      c004 : H + HO2 -> OH + OH
1339!===========================================================
1340
1341nb_reaction_4 = nb_reaction_4 + 1
1342
1343indice_4(nb_reaction_4) = z4spec(1.0, i_h, 1.0, i_ho2, 2.0, i_oh, 0.0, i_dummy)
1344
1345!===========================================================
1346!      c005 : H + HO2 -> H2 + O2
1347!===========================================================
1348
1349nb_reaction_4 = nb_reaction_4 + 1
1350
1351indice_4(nb_reaction_4) = z4spec(1.0, i_h, 1.0, i_ho2, 1.0, i_h2, 1.0, i_o2)
1352
1353!===========================================================
1354!      c006 : H + HO2 -> H2O + O
1355!===========================================================
1356
1357nb_reaction_4 = nb_reaction_4 + 1
1358
1359indice_4(nb_reaction_4) = z4spec(1.0, i_h, 1.0, i_ho2, 1.0, i_h2o, 1.0, i_o)
1360
1361!===========================================================
1362!      c007 : OH + HO2 -> H2O + O2
1363!===========================================================
1364
1365nb_reaction_4 = nb_reaction_4 + 1
1366
1367indice_4(nb_reaction_4) = z4spec(1.0, i_oh, 1.0, i_ho2, 1.0, i_h2o, 1.0, i_o2)
1368
1369!===========================================================
1370!      c008 : HO2 + HO2 -> H2O2 + O2
1371!===========================================================
1372
1373nb_reaction_3 = nb_reaction_3 + 1
1374
1375indice_3(nb_reaction_3) = z3spec(2.0, i_ho2, 1.0, i_h2o2, 1.0, i_o2)
1376
1377!===========================================================
1378!      c009 : OH + H2O2 -> H2O + HO2
1379!===========================================================
1380
1381nb_reaction_4 = nb_reaction_4 + 1
1382
1383indice_4(nb_reaction_4) = z4spec(1.0, i_oh, 1.0, i_h2o2, 1.0, i_h2o, 1.0, i_ho2)
1384
1385!===========================================================
1386!      c010 : OH + H2 -> H2O + H
1387!===========================================================
1388
1389nb_reaction_4 = nb_reaction_4 + 1
1390
1391indice_4(nb_reaction_4) = z4spec(1.0, i_oh, 1.0, i_h2, 1.0, i_h2o, 1.0, i_h)
1392
1393!===========================================================
1394!      c011 : H + O2 + CO2 -> HO2 + CO2
1395!===========================================================
1396
1397nb_reaction_4 = nb_reaction_4 + 1
1398
1399indice_4(nb_reaction_4) = z4spec(1.0, i_h, 1.0, i_o2, 1.0, i_ho2, 0.0, i_dummy)
1400
1401!===========================================================
1402!      c012 : O + H2O2 -> OH + HO2
1403!===========================================================
1404
1405nb_reaction_4 = nb_reaction_4 + 1
1406
1407indice_4(nb_reaction_4) = z4spec(1.0, i_o, 1.0, i_h2o2, 1.0, i_oh, 1.0, i_ho2)
1408
1409!===========================================================
1410!      c013 : OH + OH -> H2O + O
1411!===========================================================
1412
1413nb_reaction_3 = nb_reaction_3 + 1
1414
1415indice_3(nb_reaction_3) = z3spec(2.0, i_oh, 1.0, i_h2o, 1.0, i_o)
1416
1417!===========================================================
1418!      c014 : OH + O3 -> HO2 + O2
1419!===========================================================
1420
1421nb_reaction_4 = nb_reaction_4 + 1
1422
1423indice_4(nb_reaction_4) = z4spec(1.0, i_oh, 1.0, i_o3, 1.0, i_ho2, 1.0, i_o2)
1424
1425!===========================================================
1426!      c015 : HO2 + O3 -> OH + O2 + O2
1427!===========================================================
1428
1429nb_reaction_4 = nb_reaction_4 + 1
1430
1431indice_4(nb_reaction_4) = z4spec(1.0, i_ho2, 1.0, i_o3, 1.0, i_oh, 2.0, i_o2)
1432
1433!===========================================================
1434!      c016 : HO2 + HO2 + CO2 -> H2O2 + O2 + CO2
1435!===========================================================
1436
1437nb_reaction_3 = nb_reaction_3 + 1
1438
1439indice_3(nb_reaction_3) = z3spec(2.0, i_ho2, 1.0, i_h2o2, 1.0, i_o2)
1440
1441!===========================================================
1442!      c017 : OH + OH + CO2 -> H2O2 + CO2
1443!===========================================================
1444
1445nb_reaction_3 = nb_reaction_3 + 1
1446
1447indice_3(nb_reaction_3) = z3spec(2.0, i_oh, 1.0, i_h2o2, 0.0, i_dummy)
1448
1449!===========================================================
1450!      c018 : H + H + CO2 -> H2 + CO2
1451!===========================================================
1452
1453nb_reaction_3 = nb_reaction_3 + 1
1454
1455indice_3(nb_reaction_3) = z3spec(2.0, i_h, 1.0, i_h2, 0.0, i_dummy)
1456
1457!===========================================================
1458!      d001 : NO2 + O -> NO + O2
1459!===========================================================
1460
1461nb_reaction_4 = nb_reaction_4 + 1
1462
1463indice_4(nb_reaction_4) = z4spec(1.0, i_no2, 1.0, i_o, 1.0, i_no, 1.0, i_o2)
1464
1465!===========================================================
1466!      d002 : NO + O3 -> NO2 + O2
1467!===========================================================
1468
1469nb_reaction_4 = nb_reaction_4 + 1
1470
1471indice_4(nb_reaction_4) = z4spec(1.0, i_no, 1.0, i_o3, 1.0, i_no2, 1.0, i_o2)
1472
1473!===========================================================
1474!      d003 : NO + HO2 -> NO2 + OH
1475!===========================================================
1476
1477nb_reaction_4 = nb_reaction_4 + 1
1478
1479indice_4(nb_reaction_4) = z4spec(1.0, i_no, 1.0, i_ho2, 1.0, i_no2, 1.0, i_oh)
1480
1481!===========================================================
1482!      d004 : N + NO -> N2 + O
1483!===========================================================
1484
1485nb_reaction_4 = nb_reaction_4 + 1
1486
1487indice_4(nb_reaction_4) = z4spec(1.0, i_n, 1.0, i_no, 1.0, i_n2, 1.0, i_o)
1488
1489!===========================================================
1490!      d005 : N + O2 -> NO + O
1491!===========================================================
1492
1493nb_reaction_4 = nb_reaction_4 + 1
1494
1495indice_4(nb_reaction_4) = z4spec(1.0, i_n, 1.0, i_o2, 1.0, i_no, 1.0, i_o)
1496
1497!===========================================================
1498!      d006 : NO2 + H -> NO + OH
1499!===========================================================
1500
1501nb_reaction_4 = nb_reaction_4 + 1
1502
1503indice_4(nb_reaction_4) = z4spec(1.0, i_no2, 1.0, i_h, 1.0, i_no, 1.0, i_oh)
1504
1505!===========================================================
1506!      d007 : N + O -> NO
1507!===========================================================
1508
1509nb_reaction_4 = nb_reaction_4 + 1
1510
1511indice_4(nb_reaction_4) = z4spec(1.0, i_n, 1.0, i_o, 1.0, i_no, 0.0, i_dummy)
1512
1513!===========================================================
1514!      d008 : N + HO2 -> NO + OH
1515!===========================================================
1516
1517nb_reaction_4 = nb_reaction_4 + 1
1518
1519indice_4(nb_reaction_4) = z4spec(1.0, i_n, 1.0, i_ho2, 1.0, i_no, 1.0, i_oh)
1520
1521!===========================================================
1522!      d009 : N + OH -> NO + H
1523!===========================================================
1524
1525nb_reaction_4 = nb_reaction_4 + 1
1526
1527indice_4(nb_reaction_4) = z4spec(1.0, i_n, 1.0, i_oh, 1.0, i_no, 1.0, i_h)
1528
1529!===========================================================
1530!      e001 : CO + OH -> CO2 + H
1531!===========================================================
1532
1533nb_reaction_4 = nb_reaction_4 + 1
1534
1535indice_4(nb_reaction_4) = z4spec(1.0, i_co, 1.0, i_oh, 1.0, i_co2, 1.0, i_h)
1536
1537!===========================================================
1538!      e002 : CO + O + M -> CO2 + M
1539!===========================================================
1540
1541nb_reaction_4 = nb_reaction_4 + 1
1542
1543indice_4(nb_reaction_4) = z4spec(1.0, i_co, 1.0, i_o, 1.0, i_co2, 0.0, i_dummy)
1544
1545!===========================================================
1546!      h001: HO2 + ice -> products
1547!            treated as
1548!            HO2 -> 0.5 H2O + 0.75 O2
1549!===========================================================
1550
1551nb_phot = nb_phot + 1
1552
1553indice_phot(nb_phot) = z3spec(1.0, i_ho2, 0.5, i_h2o, 0.75, i_o2)
1554
1555!===========================================================
1556!      h002: OH + ice -> products
1557!            treated as
1558!            OH -> 0.5 H2O + 0.25 O2
1559!===========================================================
1560
1561nb_phot = nb_phot + 1
1562
1563indice_phot(nb_phot) = z3spec(1.0, i_oh, 0.5, i_h2o, 0.25, i_o2)
1564
1565!===========================================================
1566!      h003: H2O2 + ice -> products
1567!            treated as
1568!            H2O2 -> H2O + 0.5 O2
1569!===========================================================
1570
1571nb_phot = nb_phot + 1
1572
1573indice_phot(nb_phot) = z3spec(1.0, i_h2o2, 1.0, i_h2o, 0.5, i_o2)
1574
1575!===========================================================
1576!      h004: HO2 + dust -> products
1577!            treated as
1578!            HO2 -> 0.5 H2O + 0.75 O2
1579!===========================================================
1580
1581nb_phot = nb_phot + 1
1582
1583indice_phot(nb_phot) = z3spec(1.0, i_ho2, 0.5, i_h2o, 0.75, i_o2)
1584
1585!===========================================================
1586!      h005: H2O2 + dust -> products
1587!            treated as
1588!            H2O2 -> H2O + 0.5 O2
1589!===========================================================
1590
1591nb_phot = nb_phot + 1
1592
1593indice_phot(nb_phot) = z3spec(1.0, i_h2o2, 1.0, i_h2o, 0.5, i_o2)
1594
1595!===========================================================
1596!  check dimensions
1597!===========================================================
1598
1599print*, 'nb_phot       = ', nb_phot
1600print*, 'nb_reaction_4 = ', nb_reaction_4
1601print*, 'nb_reaction_3 = ', nb_reaction_3
1602
1603if ((nb_phot /= nb_phot_max)             .or.  &
1604    (nb_reaction_3 /= nb_reaction_3_max) .or.  &
1605    (nb_reaction_4 /= nb_reaction_4_max)) then
1606   print*, 'wrong dimensions in indice'
1607   stop
1608end if 
1609
1610end subroutine indice
1611
1612!*****************************************************************
1613
1614      subroutine gcmtochim(nlayer, nq, zycol, lswitch, nesp,         &
1615                           i_co2, i_co, i_o, i_o1d, i_o2, i_o3, i_h, &
1616                           i_h2, i_oh, i_ho2, i_h2o2, i_h2o,         &
1617                           i_n, i_n2d, i_no, i_no2, i_n2,            &
1618                           dens, rm, c)
1619
1620!*****************************************************************
1621
1622      use tracer_mod, only: igcm_co2, igcm_co, igcm_o, igcm_o1d,         &
1623     &                      igcm_o2, igcm_o3, igcm_h, igcm_h2, igcm_oh,  &
1624     &                      igcm_ho2, igcm_h2o2, igcm_h2o_vap,           &
1625     &                      igcm_n, igcm_n2d, igcm_no, igcm_no2, igcm_n2
1626
1627      implicit none
1628
1629#include "callkeys.h"
1630
1631!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1632!     input:
1633!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1634     
1635      integer, intent(in) :: nlayer ! number of atmospheric layers
1636      integer, intent(in) :: nq     ! number of tracers in the gcm
1637      integer :: nesp               ! number of species in the chemistry
1638      integer :: lswitch            ! interface level between chemistries
1639
1640      integer :: i_co2, i_co, i_o, i_o1d, i_o2, i_o3, i_h,           &
1641                 i_h2, i_oh, i_ho2, i_h2o2, i_h2o,                   &
1642                 i_n, i_n2d, i_no, i_no2, i_n2
1643
1644      real :: zycol(nlayer,nq)      ! volume mixing ratios in the gcm
1645      real :: dens(nlayer)          ! total number density (molecule.cm-3)
1646
1647!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1648!     output:
1649!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1650
1651      real, dimension(nlayer,nesp)            :: rm ! volume mixing ratios
1652      real (kind = 8), dimension(nlayer,nesp) :: c  ! number densities (molecule.cm-3)
1653     
1654!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1655!     local:
1656!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1657
1658      integer      :: l, iesp
1659      logical,save :: firstcall = .true.
1660     
1661     
1662!     first call initializations
1663
1664      if (firstcall) then
1665
1666!       identify the indexes of the tracers we need
1667
1668         if (igcm_co2 == 0) then
1669            write(*,*) "gcmtochim: Error; no CO2 tracer !!!"
1670            stop
1671         endif
1672         if (igcm_co == 0) then
1673            write(*,*) "gcmtochim: Error; no CO tracer !!!"
1674            stop
1675         end if
1676         if (igcm_o == 0) then
1677            write(*,*) "gcmtochim: Error; no O tracer !!!"
1678            stop
1679         end if
1680         if (igcm_o1d == 0) then
1681            write(*,*) "gcmtochim: Error; no O1D tracer !!!"
1682            stop
1683         end if
1684         if (igcm_o2 == 0) then
1685            write(*,*) "gcmtochim: Error; no O2 tracer !!!"
1686            stop
1687         end if
1688         if (igcm_o3 == 0) then
1689            write(*,*) "gcmtochim: Error; no O3 tracer !!!"
1690            stop
1691         end if
1692         if (igcm_h == 0) then
1693            write(*,*) "gcmtochim: Error; no H tracer !!!"
1694            stop
1695         end if
1696         if (igcm_h2 == 0) then
1697            write(*,*) "gcmtochim: Error; no H2 tracer !!!"
1698            stop
1699         end if
1700         if (igcm_oh == 0) then
1701            write(*,*) "gcmtochim: Error; no OH tracer !!!"
1702            stop
1703         end if
1704         if (igcm_ho2 == 0) then
1705            write(*,*) "gcmtochim: Error; no HO2 tracer !!!"
1706            stop
1707         end if
1708         if (igcm_h2o2 == 0) then
1709            write(*,*) "gcmtochim: Error; no H2O2 tracer !!!"
1710            stop
1711         end if
1712         if (igcm_n == 0) then
1713            write(*,*) "gcmtochim: Error; no N tracer !!!"
1714            stop
1715         end if
1716         if (igcm_n2d == 0) then
1717            write(*,*) "gcmtochim: Error; no N2D tracer !!!"
1718            stop
1719         end if
1720         if (igcm_no == 0) then
1721            write(*,*) "gcmtochim: Error; no NO tracer !!!"
1722            stop
1723         end if
1724         if (igcm_no2 == 0) then
1725            write(*,*) "gcmtochim: Error; no NO2 tracer !!!"
1726            stop
1727         end if
1728         if (igcm_n2 == 0) then
1729            write(*,*) "gcmtochim: Error; no N2 tracer !!!"
1730            stop
1731         end if
1732         if (igcm_h2o_vap == 0) then
1733            write(*,*) "gcmtochim: Error; no water vapor tracer !!!"
1734            stop
1735         end if
1736         firstcall = .false.
1737      end if ! of if (firstcall)
1738
1739!ccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1740!     initialise mixing ratios
1741!ccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1742
1743      do l = 1,lswitch-1
1744         rm(l,i_co2)  = zycol(l, igcm_co2)
1745         rm(l,i_co)   = zycol(l, igcm_co)
1746         rm(l,i_o)    = zycol(l, igcm_o)
1747         rm(l,i_o1d)  = zycol(l, igcm_o1d)
1748         rm(l,i_o2)   = zycol(l, igcm_o2)
1749         rm(l,i_o3)   = zycol(l, igcm_o3)
1750         rm(l,i_h)    = zycol(l, igcm_h)
1751         rm(l,i_h2)   = zycol(l, igcm_h2)
1752         rm(l,i_oh)   = zycol(l, igcm_oh)
1753         rm(l,i_ho2)  = zycol(l, igcm_ho2)
1754         rm(l,i_h2o2) = zycol(l, igcm_h2o2)
1755         rm(l,i_h2o)  = zycol(l, igcm_h2o_vap)
1756         rm(l,i_n)    = zycol(l, igcm_n)
1757         rm(l,i_n2d)  = zycol(l, igcm_n2d)
1758         rm(l,i_no)   = zycol(l, igcm_no)
1759         rm(l,i_no2)  = zycol(l, igcm_no2)
1760         rm(l,i_n2)   = zycol(l, igcm_n2)
1761      end do
1762
1763      where (rm(:,:) < 1.e-30)
1764         rm(:,:) = 0.
1765      end where
1766
1767!ccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1768!     initialise number densities
1769!ccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1770
1771      do iesp = 1,nesp
1772         do l = 1,lswitch-1
1773            c(l,iesp) = rm(l,iesp)*dens(l)
1774         end do
1775      end do
1776
1777      end subroutine gcmtochim
1778
1779!*****************************************************************
1780 
1781      subroutine chimtogcm(nlayer, nq, zycol, lswitch, nesp,         &
1782                           i_co2, i_co, i_o, i_o1d, i_o2, i_o3, i_h, &
1783                           i_h2, i_oh, i_ho2, i_h2o2, i_h2o,         &
1784                           i_n, i_n2d, i_no, i_no2, i_n2, dens, c)
1785 
1786!*****************************************************************
1787 
1788      use tracer_mod, only: igcm_co2, igcm_co, igcm_o, igcm_o1d,          &
1789                            igcm_o2, igcm_o3, igcm_h, igcm_h2, igcm_oh,   &
1790                            igcm_ho2, igcm_h2o2, igcm_h2o_vap,            &
1791                            igcm_n, igcm_n2d, igcm_no, igcm_no2, igcm_n2
1792
1793      implicit none
1794
1795#include "callkeys.h"
1796
1797!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1798!     inputs:
1799!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1800 
1801      integer, intent(in) :: nlayer  ! number of atmospheric layers
1802      integer, intent(in) :: nq      ! number of tracers in the gcm
1803      integer :: nesp                ! number of species in the chemistry
1804      integer :: lswitch             ! interface level between chemistries
1805      integer :: i_co2, i_co, i_o, i_o1d, i_o2, i_o3, i_h,       &
1806                 i_h2, i_oh, i_ho2, i_h2o2, i_h2o,               &
1807                 i_n, i_n2d, i_no, i_no2, i_n2
1808
1809      real :: dens(nlayer)     ! total number density (molecule.cm-3)
1810      real (kind = 8), dimension(nlayer,nesp) :: c  ! number densities (molecule.cm-3)
1811
1812!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1813!     output:
1814!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1815       
1816      real zycol(nlayer,nq)  ! volume mixing ratios in the gcm
1817
1818!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1819!     local:
1820!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1821
1822      integer l
1823     
1824!ccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1825!     save mixing ratios for the gcm
1826!ccccccccccccccccccccccccccccccccccccccccccccccccccccccc
1827
1828      do l = 1,lswitch-1
1829         zycol(l, igcm_co2)     = c(l,i_co2)/dens(l)
1830         zycol(l, igcm_co)      = c(l,i_co)/dens(l)
1831         zycol(l, igcm_o)       = c(l,i_o)/dens(l)
1832         zycol(l, igcm_o1d)     = c(l,i_o1d)/dens(l)
1833         zycol(l, igcm_o2)      = c(l,i_o2)/dens(l)
1834         zycol(l, igcm_o3)      = c(l,i_o3)/dens(l)
1835         zycol(l, igcm_h)       = c(l,i_h)/dens(l) 
1836         zycol(l, igcm_h2)      = c(l,i_h2)/dens(l)
1837         zycol(l, igcm_oh)      = c(l,i_oh)/dens(l)
1838         zycol(l, igcm_ho2)     = c(l,i_ho2)/dens(l)
1839         zycol(l, igcm_h2o2)    = c(l,i_h2o2)/dens(l)
1840         zycol(l, igcm_h2o_vap) = c(l,i_h2o)/dens(l)
1841         zycol(l, igcm_n)       = c(l,i_n)/dens(l)
1842         zycol(l, igcm_n2d)     = c(l,i_n2d)/dens(l)
1843         zycol(l, igcm_no)      = c(l,i_no)/dens(l)
1844         zycol(l, igcm_no2)     = c(l,i_no2)/dens(l)
1845         zycol(l, igcm_n2)      = c(l,i_n2)/dens(l)
1846      end do
1847
1848      end subroutine chimtogcm
1849
1850end subroutine photochemistry_asis
1851
Note: See TracBrowser for help on using the repository browser.