1 | subroutine moldiffcoeff_red(dij,indic,gcmind,ncompdiff2) |
---|
2 | |
---|
3 | use tracer_mod, only: nqmx, noms, mmol |
---|
4 | IMPLICIT NONE |
---|
5 | c======================================================================= |
---|
6 | c subject: |
---|
7 | c -------- |
---|
8 | c Computing molecular diffusion coefficients |
---|
9 | c following Nair 94 (pg 131) |
---|
10 | c author: MAC 2002 |
---|
11 | c ------ |
---|
12 | c |
---|
13 | c======================================================================= |
---|
14 | #include "callkeys.h" |
---|
15 | #include "diffusion.h" |
---|
16 | |
---|
17 | c----------------------------------------------------------------------- |
---|
18 | c Input/Output |
---|
19 | c ------------ |
---|
20 | c integer,parameter :: ncompmoldiff = 12 |
---|
21 | integer ncompdiff2 |
---|
22 | integer gcmind(ncompdiff2) |
---|
23 | real dij(ncompdiff2,ncompdiff2) |
---|
24 | integer indic(nqmx) |
---|
25 | |
---|
26 | c Local variables: |
---|
27 | c --------------- |
---|
28 | INTEGER nq, n, nn, i,iq |
---|
29 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
30 | c tracer numbering in the molecular diffusion |
---|
31 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
32 | |
---|
33 | real :: dijh2co,dijh2n2,dijh2co2,dijh2o2,dijho,dijref |
---|
34 | ! integer :: i_h2,i_h,i_o |
---|
35 | integer :: g_h2,g_h,g_o |
---|
36 | ! integer,parameter :: i_o = 1 |
---|
37 | ! integer,parameter :: i_n2 = 2 |
---|
38 | ! integer,parameter :: i_co = 3 |
---|
39 | ! integer,parameter :: i_ar = 4 |
---|
40 | ! integer,parameter :: i_h2 = 5 |
---|
41 | ! integer,parameter :: i_h = 6 |
---|
42 | ! integer,parameter :: i_o2 = 7 |
---|
43 | ! integer,parameter :: i_oh = 8 |
---|
44 | ! integer,parameter :: i_ho2 = 9 |
---|
45 | ! integer,parameter :: i_h2o = 10 |
---|
46 | ! integer,parameter :: i_h2o2 = 11 |
---|
47 | ! integer,parameter :: i_o1d = 12 |
---|
48 | ! integer,parameter :: i_o3 = 13 |
---|
49 | ! integer,parameter :: i_n = 13 |
---|
50 | ! integer,parameter :: i_no = 14 |
---|
51 | ! integer,parameter :: i_no2 = 15 |
---|
52 | ! integer,parameter :: i_n2d = 17 |
---|
53 | ! integer,parameter :: i_oplus = 18 |
---|
54 | ! integer,parameter :: i_co2 = 16 |
---|
55 | ! integer,parameter :: i_oplus = 17 |
---|
56 | ! integer,parameter :: i_hplus = 18 |
---|
57 | |
---|
58 | ! Tracer indexes in the GCM: |
---|
59 | ! integer,save :: g_co2=0 |
---|
60 | ! integer,save :: g_co=0 |
---|
61 | ! integer,save :: g_o=0 |
---|
62 | ! integer,save :: g_o1d=0 |
---|
63 | ! integer,save :: g_o2=0 |
---|
64 | ! integer,save :: g_o3=0 |
---|
65 | ! integer,save :: g_h=0 |
---|
66 | ! integer,save :: g_h2=0 |
---|
67 | ! integer,save :: g_oh=0 |
---|
68 | ! integer,save :: g_ho2=0 |
---|
69 | ! integer,save :: g_h2o2=0 |
---|
70 | ! integer,save :: g_n2=0 |
---|
71 | ! integer,save :: g_ar=0 |
---|
72 | ! integer,save :: g_h2o=0 |
---|
73 | ! integer,save :: g_n=0 |
---|
74 | ! integer,save :: g_no=0 |
---|
75 | ! integer,save :: g_no2=0 |
---|
76 | ! integer,save :: g_n2d=0 |
---|
77 | ! integer,save :: g_oplus=0 |
---|
78 | ! integer,save :: g_hplus=0 |
---|
79 | |
---|
80 | ! integer,save :: gcmind(ncompdiff) |
---|
81 | |
---|
82 | real dnh |
---|
83 | logical,save :: firstcall=.true. |
---|
84 | logical,parameter :: outputcoeffs=.false. ! to output 'coeffs.dat' file, |
---|
85 | ! set outputcoeffs=.true. |
---|
86 | |
---|
87 | ! Initializations at first call (and some sanity checks) |
---|
88 | if (firstcall) then |
---|
89 | ! identify the indexes of the tracers we'll need |
---|
90 | ! g_co2=igcm_co2 |
---|
91 | ! if (g_co2.eq.0) then |
---|
92 | ! write(*,*) "moldiffcoeff: Error; no CO2 tracer !!!" |
---|
93 | ! stop |
---|
94 | ! endif |
---|
95 | ! g_n2=igcm_n2 |
---|
96 | ! if (g_n2.eq.0) then |
---|
97 | ! write(*,*) "moldiffcoeff: Error; no N2 tracer !!!" |
---|
98 | ! stop |
---|
99 | ! endif |
---|
100 | ! g_ar=igcm_ar |
---|
101 | ! if (g_ar.eq.0) then |
---|
102 | ! write(*,*) "moldiffcoeff: Error; no Ar tracer !!!" |
---|
103 | ! stop |
---|
104 | ! endif |
---|
105 | ! g_h2=igcm_h2 |
---|
106 | ! if (g_h2.eq.0) then |
---|
107 | ! write(*,*) "moldiffcoeff: Error; no H2 tracer !!!" |
---|
108 | ! stop |
---|
109 | ! endif |
---|
110 | ! g_h=igcm_h |
---|
111 | ! if (g_h.eq.0) then |
---|
112 | ! write(*,*) "moldiffcoeff: Error; no H tracer !!!" |
---|
113 | ! stop |
---|
114 | ! endif |
---|
115 | ! g_co=igcm_co |
---|
116 | ! if (g_co.eq.0) then |
---|
117 | ! write(*,*) "moldiffcoeff: Error; no CO tracer !!!" |
---|
118 | ! stop |
---|
119 | ! endif |
---|
120 | ! g_o2=igcm_o2 |
---|
121 | ! if (g_o2.eq.0) then |
---|
122 | ! write(*,*) "moldiffcoeff: Error; no O2 tracer !!!" |
---|
123 | ! stop |
---|
124 | ! endif |
---|
125 | ! g_oh=igcm_oh |
---|
126 | ! if (g_oh.eq.0) then |
---|
127 | ! write(*,*) "moldiffcoeff: Error; no OH tracer !!!" |
---|
128 | ! stop |
---|
129 | ! endif |
---|
130 | ! g_ho2=igcm_ho2 |
---|
131 | ! if (g_ho2.eq.0) then |
---|
132 | ! write(*,*) "moldiffcoeff: Error; no HO2 tracer !!!" |
---|
133 | ! stop |
---|
134 | ! endif |
---|
135 | ! g_h2o=igcm_h2o_vap |
---|
136 | ! if (g_h2o.eq.0) then |
---|
137 | ! write(*,*) "moldiffcoeff: Error; no H2O tracer !!!" |
---|
138 | ! stop |
---|
139 | ! endif |
---|
140 | ! g_h2o2=igcm_h2o2 |
---|
141 | ! if (g_h2o2.eq.0) then |
---|
142 | ! write(*,*) "moldiffcoeff: Error; no H2O2 tracer !!!" |
---|
143 | ! stop |
---|
144 | ! endif |
---|
145 | ! g_o1d=igcm_o1d |
---|
146 | ! if (g_h.eq.0) then |
---|
147 | ! write(*,*) "moldiffcoeff: Error; no O1d tracer !!!" |
---|
148 | ! stop |
---|
149 | ! endif |
---|
150 | ! g_o3=igcm_o3 |
---|
151 | ! if (g_o3.eq.0) then |
---|
152 | ! write(*,*) "moldiffcoeff: Error; no O3 tracer !!!" |
---|
153 | ! stop |
---|
154 | ! endif |
---|
155 | ! g_n=igcm_n |
---|
156 | ! if (g_n.eq.0) then |
---|
157 | ! write(*,*) "moldiffcoeff: Error; no N tracer !!!" |
---|
158 | ! stop |
---|
159 | ! endif |
---|
160 | ! g_no=igcm_no |
---|
161 | ! if (g_no.eq.0) then |
---|
162 | ! write(*,*) "moldiffcoeff: Error; no NO tracer !!!" |
---|
163 | ! stop |
---|
164 | ! endif |
---|
165 | ! g_no2=igcm_no2 |
---|
166 | ! if (g_no2.eq.0) then |
---|
167 | ! write(*,*) "moldiffcoeff: Error; no NO2 tracer !!!" |
---|
168 | ! stop |
---|
169 | ! endif |
---|
170 | ! g_n2d=igcm_n2d |
---|
171 | ! if (g_n2d.eq.0) then |
---|
172 | ! write(*,*) "moldiffcoeff: Error; no N2(D) tracer !!!" |
---|
173 | ! stop |
---|
174 | ! endif |
---|
175 | ! g_oplus=igcm_oplus |
---|
176 | ! if (g_oplus .eq. 0) then |
---|
177 | ! write(*,*) "moldiffcoeff: Error; no Oplus tracer !!!" |
---|
178 | ! stop |
---|
179 | ! endif |
---|
180 | ! g_hplus=igcm_hplus |
---|
181 | ! if (g_hplus .eq. 0) then |
---|
182 | ! write(*,*) "moldiffcoeff: Error; no Hplus tracer !!!" |
---|
183 | ! stop |
---|
184 | ! endif |
---|
185 | ! g_o=igcm_o |
---|
186 | ! if (g_o.eq.0) then |
---|
187 | ! write(*,*) "moldiffcoeff: Error; no O tracer !!!" |
---|
188 | ! stop |
---|
189 | ! endif |
---|
190 | |
---|
191 | c |
---|
192 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
193 | c fill array to relate local indexes to gcm indexes |
---|
194 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
195 | |
---|
196 | ! gcmind(i_co2) = g_co2 |
---|
197 | ! gcmind(i_n2) = g_n2 |
---|
198 | ! gcmind(i_ar) = g_ar |
---|
199 | ! gcmind(i_h2) = g_h2 |
---|
200 | ! gcmind(i_h) = g_h |
---|
201 | ! gcmind(i_co) = g_co |
---|
202 | ! gcmind(i_o2) = g_o2 |
---|
203 | ! gcmind(i_oh)= g_oh |
---|
204 | ! gcmind(i_ho2) = g_ho2 |
---|
205 | ! gcmind(i_h2o) = g_h2o |
---|
206 | ! gcmind(i_h2o2)= g_h2o2 |
---|
207 | ! gcmind(i_o1d) = g_o1d |
---|
208 | ! gcmind(i_o3) = g_o3 |
---|
209 | ! gcmind(i_n)= g_n |
---|
210 | ! gcmind(i_no) = g_no |
---|
211 | ! gcmind(i_no2) = g_no2 |
---|
212 | ! gcmind(i_n2d) = g_n2d |
---|
213 | ! gcmind(i_oplus) = g_oplus |
---|
214 | ! gcmind(i_hplus) = g_hplus |
---|
215 | ! gcmind(i_o) = g_o |
---|
216 | |
---|
217 | c |
---|
218 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
219 | firstcall= .false. |
---|
220 | endif ! of if (firstcall) |
---|
221 | |
---|
222 | dijh2co = 0.0000651 |
---|
223 | dijh2n2 = 0.0000674 |
---|
224 | dijh2o2 = 0.0000697 |
---|
225 | dijh2co2 = 0.0000550 |
---|
226 | dijho = 0.000114 |
---|
227 | |
---|
228 | ! dij(i_h2,i_co) = 0.0000651 |
---|
229 | ! dij(i_h2,i_n2) = 0.0000674 |
---|
230 | ! dij(i_h2,i_o2) = 0.0000697 |
---|
231 | ! dij(i_h2,i_co2) = 0.0000550 |
---|
232 | ! dij(i_h2,i_h2) = 0.0 |
---|
233 | ! dij(i_h2,i_h) = 0.0 |
---|
234 | ! dij(i_h2,i_h2o) = 0.0 !0003 |
---|
235 | ! dij(i_h2,i_h2o2) = 0.0 !0003 |
---|
236 | ! dij(i_h2,i_o3) = 0.0 !0003 |
---|
237 | ! dij(i_h2,i_o) = 0.0 |
---|
238 | ! dij(i_h2,i_ar) = 0.0 |
---|
239 | ! dij(i_h2,i_n) = 0.0 |
---|
240 | |
---|
241 | !c dij(i_h,i_o) = 0.0000144 |
---|
242 | ! dij(i_h,i_o) = 0.000114 |
---|
243 | |
---|
244 | ! find h2, h and o index in gcm |
---|
245 | ! these species are used to define the diffusion coefficients |
---|
246 | |
---|
247 | do n=1,nqmx |
---|
248 | if (noms(n) .eq. 'h2') g_h2=n |
---|
249 | if (noms(n) .eq. 'h') g_h=n |
---|
250 | if (noms(n) .eq. 'o') g_o=n |
---|
251 | enddo |
---|
252 | print*,'moldiffcoeff_red: gh2',g_h2,g_h,g_o |
---|
253 | |
---|
254 | print*,'moldiffcoeff_red: COEFF CALC' |
---|
255 | |
---|
256 | do n=1,ncompdiff2 |
---|
257 | dijref=0. |
---|
258 | if (noms(gcmind(n)) .eq. 'co') dijref=dijh2co |
---|
259 | if (noms(gcmind(n)) .eq. 'n2') dijref=dijh2n2 |
---|
260 | if (noms(gcmind(n)) .eq. 'o2') dijref=dijh2o2 |
---|
261 | if (noms(gcmind(n)) .eq. 'co2') dijref=dijh2co2 |
---|
262 | ! print*,'test',n,dijref |
---|
263 | if (dijref .gt. 0.0) then |
---|
264 | do nn=n,ncompdiff2 |
---|
265 | dij(nn,n)=dijref |
---|
266 | & *sqrt(mmol(g_h2)/mmol(gcmind(nn))) |
---|
267 | if(n.eq.nn) dij(nn,n)=1.0 |
---|
268 | dij(n,nn)=dij(nn,n) |
---|
269 | enddo |
---|
270 | endif |
---|
271 | if (dijref .eq. 0.0) then |
---|
272 | dijref=dijho |
---|
273 | dnh=dijref*sqrt(mmol(g_o)/mmol(gcmind(n))) |
---|
274 | do nn=n,ncompdiff2 |
---|
275 | dij(nn,n)=dnh*sqrt(mmol(g_h)/mmol(gcmind(nn))) |
---|
276 | if(n.eq.nn) dij(nn,n)=1.0 |
---|
277 | dij(n,nn)=dij(nn,n) |
---|
278 | enddo |
---|
279 | endif |
---|
280 | enddo |
---|
281 | |
---|
282 | if (outputcoeffs) then |
---|
283 | ! output coefficients in 'coeffs.dat' file |
---|
284 | open(56,file='coeffs.dat',status='unknown') |
---|
285 | do n=1,ncompdiff2 |
---|
286 | do nn=n,ncompdiff2 |
---|
287 | write(56,*) n,nn,dij(n,nn) !*1.e5/1.381e-23/(273**1.75) |
---|
288 | enddo |
---|
289 | enddo |
---|
290 | close(56) |
---|
291 | endif |
---|
292 | |
---|
293 | |
---|
294 | return |
---|
295 | end |
---|
296 | |
---|