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

Last change on this file since 1523 was 1503, checked in by flefevre, 10 years ago

Nettoyage du solveur chimique ASIS

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