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 | |
---|
85 | !$OMP THREADPRIVATE(firstcall) |
---|
86 | |
---|
87 | logical,parameter :: outputcoeffs=.false. ! to output 'coeffs.dat' file, |
---|
88 | ! set outputcoeffs=.true. |
---|
89 | |
---|
90 | ! Initializations at first call (and some sanity checks) |
---|
91 | if (firstcall) then |
---|
92 | ! identify the indexes of the tracers we'll need |
---|
93 | ! g_co2=igcm_co2 |
---|
94 | ! if (g_co2.eq.0) then |
---|
95 | ! write(*,*) "moldiffcoeff: Error; no CO2 tracer !!!" |
---|
96 | ! stop |
---|
97 | ! endif |
---|
98 | ! g_n2=igcm_n2 |
---|
99 | ! if (g_n2.eq.0) then |
---|
100 | ! write(*,*) "moldiffcoeff: Error; no N2 tracer !!!" |
---|
101 | ! stop |
---|
102 | ! endif |
---|
103 | ! g_ar=igcm_ar |
---|
104 | ! if (g_ar.eq.0) then |
---|
105 | ! write(*,*) "moldiffcoeff: Error; no Ar tracer !!!" |
---|
106 | ! stop |
---|
107 | ! endif |
---|
108 | ! g_h2=igcm_h2 |
---|
109 | ! if (g_h2.eq.0) then |
---|
110 | ! write(*,*) "moldiffcoeff: Error; no H2 tracer !!!" |
---|
111 | ! stop |
---|
112 | ! endif |
---|
113 | ! g_h=igcm_h |
---|
114 | ! if (g_h.eq.0) then |
---|
115 | ! write(*,*) "moldiffcoeff: Error; no H tracer !!!" |
---|
116 | ! stop |
---|
117 | ! endif |
---|
118 | ! g_co=igcm_co |
---|
119 | ! if (g_co.eq.0) then |
---|
120 | ! write(*,*) "moldiffcoeff: Error; no CO tracer !!!" |
---|
121 | ! stop |
---|
122 | ! endif |
---|
123 | ! g_o2=igcm_o2 |
---|
124 | ! if (g_o2.eq.0) then |
---|
125 | ! write(*,*) "moldiffcoeff: Error; no O2 tracer !!!" |
---|
126 | ! stop |
---|
127 | ! endif |
---|
128 | ! g_oh=igcm_oh |
---|
129 | ! if (g_oh.eq.0) then |
---|
130 | ! write(*,*) "moldiffcoeff: Error; no OH tracer !!!" |
---|
131 | ! stop |
---|
132 | ! endif |
---|
133 | ! g_ho2=igcm_ho2 |
---|
134 | ! if (g_ho2.eq.0) then |
---|
135 | ! write(*,*) "moldiffcoeff: Error; no HO2 tracer !!!" |
---|
136 | ! stop |
---|
137 | ! endif |
---|
138 | ! g_h2o=igcm_h2o_vap |
---|
139 | ! if (g_h2o.eq.0) then |
---|
140 | ! write(*,*) "moldiffcoeff: Error; no H2O tracer !!!" |
---|
141 | ! stop |
---|
142 | ! endif |
---|
143 | ! g_h2o2=igcm_h2o2 |
---|
144 | ! if (g_h2o2.eq.0) then |
---|
145 | ! write(*,*) "moldiffcoeff: Error; no H2O2 tracer !!!" |
---|
146 | ! stop |
---|
147 | ! endif |
---|
148 | ! g_o1d=igcm_o1d |
---|
149 | ! if (g_h.eq.0) then |
---|
150 | ! write(*,*) "moldiffcoeff: Error; no O1d tracer !!!" |
---|
151 | ! stop |
---|
152 | ! endif |
---|
153 | ! g_o3=igcm_o3 |
---|
154 | ! if (g_o3.eq.0) then |
---|
155 | ! write(*,*) "moldiffcoeff: Error; no O3 tracer !!!" |
---|
156 | ! stop |
---|
157 | ! endif |
---|
158 | ! g_n=igcm_n |
---|
159 | ! if (g_n.eq.0) then |
---|
160 | ! write(*,*) "moldiffcoeff: Error; no N tracer !!!" |
---|
161 | ! stop |
---|
162 | ! endif |
---|
163 | ! g_no=igcm_no |
---|
164 | ! if (g_no.eq.0) then |
---|
165 | ! write(*,*) "moldiffcoeff: Error; no NO tracer !!!" |
---|
166 | ! stop |
---|
167 | ! endif |
---|
168 | ! g_no2=igcm_no2 |
---|
169 | ! if (g_no2.eq.0) then |
---|
170 | ! write(*,*) "moldiffcoeff: Error; no NO2 tracer !!!" |
---|
171 | ! stop |
---|
172 | ! endif |
---|
173 | ! g_n2d=igcm_n2d |
---|
174 | ! if (g_n2d.eq.0) then |
---|
175 | ! write(*,*) "moldiffcoeff: Error; no N2(D) tracer !!!" |
---|
176 | ! stop |
---|
177 | ! endif |
---|
178 | ! g_oplus=igcm_oplus |
---|
179 | ! if (g_oplus .eq. 0) then |
---|
180 | ! write(*,*) "moldiffcoeff: Error; no Oplus tracer !!!" |
---|
181 | ! stop |
---|
182 | ! endif |
---|
183 | ! g_hplus=igcm_hplus |
---|
184 | ! if (g_hplus .eq. 0) then |
---|
185 | ! write(*,*) "moldiffcoeff: Error; no Hplus tracer !!!" |
---|
186 | ! stop |
---|
187 | ! endif |
---|
188 | ! g_o=igcm_o |
---|
189 | ! if (g_o.eq.0) then |
---|
190 | ! write(*,*) "moldiffcoeff: Error; no O tracer !!!" |
---|
191 | ! stop |
---|
192 | ! endif |
---|
193 | |
---|
194 | c |
---|
195 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
196 | c fill array to relate local indexes to gcm indexes |
---|
197 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
198 | |
---|
199 | ! gcmind(i_co2) = g_co2 |
---|
200 | ! gcmind(i_n2) = g_n2 |
---|
201 | ! gcmind(i_ar) = g_ar |
---|
202 | ! gcmind(i_h2) = g_h2 |
---|
203 | ! gcmind(i_h) = g_h |
---|
204 | ! gcmind(i_co) = g_co |
---|
205 | ! gcmind(i_o2) = g_o2 |
---|
206 | ! gcmind(i_oh)= g_oh |
---|
207 | ! gcmind(i_ho2) = g_ho2 |
---|
208 | ! gcmind(i_h2o) = g_h2o |
---|
209 | ! gcmind(i_h2o2)= g_h2o2 |
---|
210 | ! gcmind(i_o1d) = g_o1d |
---|
211 | ! gcmind(i_o3) = g_o3 |
---|
212 | ! gcmind(i_n)= g_n |
---|
213 | ! gcmind(i_no) = g_no |
---|
214 | ! gcmind(i_no2) = g_no2 |
---|
215 | ! gcmind(i_n2d) = g_n2d |
---|
216 | ! gcmind(i_oplus) = g_oplus |
---|
217 | ! gcmind(i_hplus) = g_hplus |
---|
218 | ! gcmind(i_o) = g_o |
---|
219 | |
---|
220 | c |
---|
221 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
222 | firstcall= .false. |
---|
223 | endif ! of if (firstcall) |
---|
224 | |
---|
225 | dijh2co = 0.0000651 |
---|
226 | dijh2n2 = 0.0000674 |
---|
227 | dijh2o2 = 0.0000697 |
---|
228 | dijh2co2 = 0.0000550 |
---|
229 | dijho = 0.000114 |
---|
230 | |
---|
231 | ! dij(i_h2,i_co) = 0.0000651 |
---|
232 | ! dij(i_h2,i_n2) = 0.0000674 |
---|
233 | ! dij(i_h2,i_o2) = 0.0000697 |
---|
234 | ! dij(i_h2,i_co2) = 0.0000550 |
---|
235 | ! dij(i_h2,i_h2) = 0.0 |
---|
236 | ! dij(i_h2,i_h) = 0.0 |
---|
237 | ! dij(i_h2,i_h2o) = 0.0 !0003 |
---|
238 | ! dij(i_h2,i_h2o2) = 0.0 !0003 |
---|
239 | ! dij(i_h2,i_o3) = 0.0 !0003 |
---|
240 | ! dij(i_h2,i_o) = 0.0 |
---|
241 | ! dij(i_h2,i_ar) = 0.0 |
---|
242 | ! dij(i_h2,i_n) = 0.0 |
---|
243 | |
---|
244 | !c dij(i_h,i_o) = 0.0000144 |
---|
245 | ! dij(i_h,i_o) = 0.000114 |
---|
246 | |
---|
247 | ! find h2, h and o index in gcm |
---|
248 | ! these species are used to define the diffusion coefficients |
---|
249 | |
---|
250 | do n=1,nqmx |
---|
251 | if (noms(n) .eq. 'h2') g_h2=n |
---|
252 | if (noms(n) .eq. 'h') g_h=n |
---|
253 | if (noms(n) .eq. 'o') g_o=n |
---|
254 | enddo |
---|
255 | print*,'moldiffcoeff_red: gh2',g_h2,g_h,g_o |
---|
256 | |
---|
257 | print*,'moldiffcoeff_red: COEFF CALC' |
---|
258 | |
---|
259 | do n=1,ncompdiff2 |
---|
260 | dijref=0. |
---|
261 | if (noms(gcmind(n)) .eq. 'co') dijref=dijh2co |
---|
262 | if (noms(gcmind(n)) .eq. 'n2') dijref=dijh2n2 |
---|
263 | if (noms(gcmind(n)) .eq. 'o2') dijref=dijh2o2 |
---|
264 | if (noms(gcmind(n)) .eq. 'co2') dijref=dijh2co2 |
---|
265 | ! print*,'test',n,dijref |
---|
266 | if (dijref .gt. 0.0) then |
---|
267 | do nn=n,ncompdiff2 |
---|
268 | dij(nn,n)=dijref |
---|
269 | & *sqrt(mmol(g_h2)/mmol(gcmind(nn))) |
---|
270 | if(n.eq.nn) dij(nn,n)=1.0 |
---|
271 | dij(n,nn)=dij(nn,n) |
---|
272 | enddo |
---|
273 | endif |
---|
274 | if (dijref .eq. 0.0) then |
---|
275 | dijref=dijho |
---|
276 | dnh=dijref*sqrt(mmol(g_o)/mmol(gcmind(n))) |
---|
277 | do nn=n,ncompdiff2 |
---|
278 | dij(nn,n)=dnh*sqrt(mmol(g_h)/mmol(gcmind(nn))) |
---|
279 | if(n.eq.nn) dij(nn,n)=1.0 |
---|
280 | dij(n,nn)=dij(nn,n) |
---|
281 | enddo |
---|
282 | endif |
---|
283 | enddo |
---|
284 | |
---|
285 | if (outputcoeffs) then |
---|
286 | ! output coefficients in 'coeffs.dat' file |
---|
287 | open(56,file='coeffs.dat',status='unknown') |
---|
288 | do n=1,ncompdiff2 |
---|
289 | do nn=n,ncompdiff2 |
---|
290 | write(56,*) n,nn,dij(n,nn) !*1.e5/1.381e-23/(273**1.75) |
---|
291 | enddo |
---|
292 | enddo |
---|
293 | close(56) |
---|
294 | endif |
---|
295 | |
---|
296 | |
---|
297 | return |
---|
298 | end |
---|
299 | |
---|