1 | module moldiffcoeff_mod |
---|
2 | |
---|
3 | implicit none |
---|
4 | |
---|
5 | contains |
---|
6 | |
---|
7 | subroutine moldiffcoeff(dij) |
---|
8 | |
---|
9 | use tracer_mod, only: igcm_co2, igcm_co, igcm_o, igcm_o1d, |
---|
10 | & igcm_o2, igcm_o3, igcm_h, igcm_h2, igcm_oh, |
---|
11 | & igcm_ho2, igcm_h2o2, igcm_n2, igcm_ar, |
---|
12 | & igcm_h2o_vap, mmol |
---|
13 | |
---|
14 | IMPLICIT NONE |
---|
15 | c======================================================================= |
---|
16 | c subject: |
---|
17 | c -------- |
---|
18 | c Computing molecular diffusion coefficients |
---|
19 | c following Nair 94 (pg 131) |
---|
20 | c author: MAC 2002 |
---|
21 | c ------ |
---|
22 | c |
---|
23 | c======================================================================= |
---|
24 | #include "callkeys.h" |
---|
25 | |
---|
26 | c----------------------------------------------------------------------- |
---|
27 | c Input/Output |
---|
28 | c ------------ |
---|
29 | integer,parameter :: ncompmoldiff = 14 |
---|
30 | real dij(ncompmoldiff,ncompmoldiff) |
---|
31 | |
---|
32 | c Local variables: |
---|
33 | c --------------- |
---|
34 | INTEGER nq, n, nn, i,iq |
---|
35 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
36 | c tracer numbering in the molecular diffusion |
---|
37 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
38 | c Atomic oxygen must always be the LAST species of the list as |
---|
39 | c it is the dominant species at high altitudes. |
---|
40 | integer,parameter :: i_co = 1 |
---|
41 | integer,parameter :: i_n2 = 2 |
---|
42 | integer,parameter :: i_o2 = 3 |
---|
43 | integer,parameter :: i_co2 = 4 |
---|
44 | integer,parameter :: i_h2 = 5 |
---|
45 | integer,parameter :: i_h = 6 |
---|
46 | integer,parameter :: i_oh = 7 |
---|
47 | integer,parameter :: i_ho2 = 8 |
---|
48 | integer,parameter :: i_h2o = 9 |
---|
49 | integer,parameter :: i_h2o2 = 10 |
---|
50 | integer,parameter :: i_o1d = 11 |
---|
51 | integer,parameter :: i_o3 = 12 |
---|
52 | integer,parameter :: i_ar = 13 |
---|
53 | integer,parameter :: i_o = 14 |
---|
54 | |
---|
55 | ! Tracer indexes in the GCM: |
---|
56 | integer,save :: g_co2=0 |
---|
57 | integer,save :: g_co=0 |
---|
58 | integer,save :: g_o=0 |
---|
59 | integer,save :: g_o1d=0 |
---|
60 | integer,save :: g_o2=0 |
---|
61 | integer,save :: g_o3=0 |
---|
62 | integer,save :: g_h=0 |
---|
63 | integer,save :: g_h2=0 |
---|
64 | integer,save :: g_oh=0 |
---|
65 | integer,save :: g_ho2=0 |
---|
66 | integer,save :: g_h2o2=0 |
---|
67 | integer,save :: g_n2=0 |
---|
68 | integer,save :: g_ar=0 |
---|
69 | integer,save :: g_h2o=0 |
---|
70 | |
---|
71 | !$OMP THREADPRIVATE(g_co2,g_co,g_o,g_o1d,g_o2,g_o3,g_h,g_h2,g_oh) |
---|
72 | !$OMP THREADPRIVATE(g_ho2,g_h2o2,g_n2,g_ar,g_h2o) |
---|
73 | |
---|
74 | integer,save :: gcmind(ncompmoldiff) |
---|
75 | |
---|
76 | real dnh |
---|
77 | logical,save :: firstcall=.true. |
---|
78 | |
---|
79 | !$OMP THREADPRIVATE(gcmind,firstcall) |
---|
80 | |
---|
81 | ! Initializations at first call (and some sanity checks) |
---|
82 | if (firstcall) then |
---|
83 | ! identify the indexes of the tracers we'll need |
---|
84 | g_co2=igcm_co2 |
---|
85 | if (g_co2.eq.0) then |
---|
86 | write(*,*) "moldiffcoeff: Error; no CO2 tracer !!!" |
---|
87 | stop |
---|
88 | endif |
---|
89 | g_co=igcm_co |
---|
90 | if (g_co.eq.0) then |
---|
91 | write(*,*) "moldiffcoeff: Error; no CO tracer !!!" |
---|
92 | stop |
---|
93 | endif |
---|
94 | g_o=igcm_o |
---|
95 | if (g_o.eq.0) then |
---|
96 | write(*,*) "moldiffcoeff: Error; no O tracer !!!" |
---|
97 | stop |
---|
98 | endif |
---|
99 | g_o1d=igcm_o1d |
---|
100 | if (g_o1d.eq.0) then |
---|
101 | write(*,*) "moldiffcoeff: Error; no O1D tracer !!!" |
---|
102 | stop |
---|
103 | endif |
---|
104 | g_o2=igcm_o2 |
---|
105 | if (g_o2.eq.0) then |
---|
106 | write(*,*) "moldiffcoeff: Error; no O2 tracer !!!" |
---|
107 | stop |
---|
108 | endif |
---|
109 | g_o3=igcm_o3 |
---|
110 | if (g_o3.eq.0) then |
---|
111 | write(*,*) "moldiffcoeff: Error; no O3 tracer !!!" |
---|
112 | stop |
---|
113 | endif |
---|
114 | g_h=igcm_h |
---|
115 | if (g_h.eq.0) then |
---|
116 | write(*,*) "moldiffcoeff: Error; no H tracer !!!" |
---|
117 | stop |
---|
118 | endif |
---|
119 | g_h2=igcm_h2 |
---|
120 | if (g_h2.eq.0) then |
---|
121 | write(*,*) "moldiffcoeff: Error; no H2 tracer !!!" |
---|
122 | stop |
---|
123 | endif |
---|
124 | g_oh=igcm_oh |
---|
125 | if (g_oh.eq.0) then |
---|
126 | write(*,*) "moldiffcoeff: Error; no OH tracer !!!" |
---|
127 | stop |
---|
128 | endif |
---|
129 | g_ho2=igcm_ho2 |
---|
130 | if (g_ho2.eq.0) then |
---|
131 | write(*,*) "moldiffcoeff: Error; no HO2 tracer !!!" |
---|
132 | stop |
---|
133 | endif |
---|
134 | g_h2o2=igcm_h2o2 |
---|
135 | if (g_h2o2.eq.0) then |
---|
136 | write(*,*) "moldiffcoeff: Error; no H2O2 tracer !!!" |
---|
137 | stop |
---|
138 | endif |
---|
139 | g_n2=igcm_n2 |
---|
140 | if (g_n2.eq.0) then |
---|
141 | write(*,*) "moldiffcoeff: Error; no N2 tracer !!!" |
---|
142 | stop |
---|
143 | endif |
---|
144 | g_ar=igcm_ar |
---|
145 | if (g_ar.eq.0) then |
---|
146 | write(*,*) "moldiffcoeff: Error; no AR tracer !!!" |
---|
147 | stop |
---|
148 | endif |
---|
149 | g_h2o=igcm_h2o_vap |
---|
150 | if (g_h2o.eq.0) then |
---|
151 | write(*,*) "moldiffcoeff: Error; no water vapor tracer !!!" |
---|
152 | stop |
---|
153 | endif |
---|
154 | |
---|
155 | c |
---|
156 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
157 | c fill array to relate local indexes to gcm indexes |
---|
158 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
159 | |
---|
160 | gcmind(i_co) = g_co |
---|
161 | gcmind(i_n2) = g_n2 |
---|
162 | gcmind(i_o2) = g_o2 |
---|
163 | gcmind(i_co2) = g_co2 |
---|
164 | gcmind(i_h2) = g_h2 |
---|
165 | gcmind(i_h) = g_h |
---|
166 | gcmind(i_oh) = g_oh |
---|
167 | gcmind(i_ho2) = g_ho2 |
---|
168 | gcmind(i_h2o) = g_h2o |
---|
169 | gcmind(i_h2o2)= g_h2o2 |
---|
170 | gcmind(i_o1d) = g_o1d |
---|
171 | gcmind(i_o3) = g_o3 |
---|
172 | gcmind(i_o) = g_o |
---|
173 | gcmind(i_ar) = g_ar |
---|
174 | c |
---|
175 | cccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
176 | firstcall= .false. |
---|
177 | endif ! of if (firstcall) |
---|
178 | |
---|
179 | |
---|
180 | dij(i_h2,i_co) = 0.0000651 |
---|
181 | dij(i_h2,i_n2) = 0.0000674 |
---|
182 | dij(i_h2,i_o2) = 0.0000697 |
---|
183 | dij(i_h2,i_co2) = 0.0000550 |
---|
184 | dij(i_h2,i_h2) = 0.0 |
---|
185 | dij(i_h2,i_h) = 0.0 |
---|
186 | dij(i_h2,i_oh) = 0.0 !0003 |
---|
187 | dij(i_h2,i_ho2) = 0.0 !0003 |
---|
188 | dij(i_h2,i_h2o) = 0.0 !0003 |
---|
189 | dij(i_h2,i_h2o2) = 0.0 !0003 |
---|
190 | dij(i_h2,i_o1d) = 0.0 |
---|
191 | dij(i_h2,i_o3) = 0.0 !0003 |
---|
192 | dij(i_h2,i_o) = 0.0 |
---|
193 | dij(i_h2,i_ar) = 0.0 |
---|
194 | |
---|
195 | c dij(i_h,i_o) = 0.0000144 |
---|
196 | dij(i_h,i_o) = 0.000114 |
---|
197 | |
---|
198 | print*,'moldiffcoef: COEFF CALC' |
---|
199 | open(56,file='coeffs.dat',status='unknown') |
---|
200 | do n=1,ncompmoldiff |
---|
201 | if (dij(i_h2,n).gt.0.0) then |
---|
202 | do nn=n,ncompmoldiff |
---|
203 | dij(nn,n)=dij(i_h2,n) |
---|
204 | & *sqrt(mmol(g_h2)/mmol(gcmind(nn))) |
---|
205 | if(n.eq.nn) dij(nn,n)=1.0 |
---|
206 | dij(n,nn)=dij(nn,n) |
---|
207 | enddo |
---|
208 | endif |
---|
209 | if (dij(i_h2,n).eq.0.0) then |
---|
210 | dnh=dij(i_h,i_o)*sqrt(mmol(g_o)/mmol(gcmind(n))) |
---|
211 | do nn=n,ncompmoldiff |
---|
212 | dij(nn,n)=dnh*sqrt(mmol(g_h)/mmol(gcmind(nn))) |
---|
213 | if(n.eq.nn) dij(nn,n)=1.0 |
---|
214 | dij(n,nn)=dij(nn,n) |
---|
215 | enddo |
---|
216 | endif |
---|
217 | enddo |
---|
218 | |
---|
219 | do n=1,ncompmoldiff |
---|
220 | do nn=n,ncompmoldiff |
---|
221 | write(56,*) n,nn,dij(n,nn) !*1.e5/1.381e-23/(273**1.75) |
---|
222 | enddo |
---|
223 | enddo |
---|
224 | close(56) |
---|
225 | |
---|
226 | end subroutine moldiffcoeff |
---|
227 | |
---|
228 | end module moldiffcoeff_mod |
---|