source: trunk/LMDZ.MARS/libf/aeronomars/photochemistry.F90 @ 2042

Last change on this file since 2042 was 2042, checked in by emillour, 7 years ago

Mars GCM:
Modifications to use the parametrized photoabsorbtion coefficients;
a first step towards implementing ionospheric chemistry in the new
chemical solver:

  • change in species indexes in chemthermos.F90, paramfoto_compact.F, hrtherm.F and euvheat.F90
  • calchim.F90: added a variable in call to photochemistry
  • photochemistry.F90: added calls to jthermcalc_e107 and phdisrate, with an additionlal flag, jparam (.false. by default). The computed photodissociation coefficents are sent to v_phot, which is used in the chemistry. Thus concentrations computed in chimtogcm are now done over all atmospheric layers.

FGG

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