1 | !*********************************************************************** |
---|
2 | !* Copyright 2012,2013 * |
---|
3 | !* Jerome Brioude, Jerome Fast, |
---|
4 | !* Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa * |
---|
5 | !* Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann * |
---|
6 | !* * |
---|
7 | !* This file is part of FLEXPART WRF * |
---|
8 | !* * |
---|
9 | !* FLEXPART is free software: you can redistribute it and/or modify * |
---|
10 | !* it under the terms of the GNU General Public License as published by* |
---|
11 | !* the Free Software Foundation, either version 3 of the License, or * |
---|
12 | !* (at your option) any later version. * |
---|
13 | !* * |
---|
14 | !* FLEXPART is distributed in the hope that it will be useful, * |
---|
15 | !* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
16 | !* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
17 | !* GNU General Public License for more details. * |
---|
18 | !* * |
---|
19 | !* You should have received a copy of the GNU General Public License * |
---|
20 | !* along with FLEXPART. If not, see <http://www.gnu.org/licenses/>. * |
---|
21 | !*********************************************************************** |
---|
22 | subroutine concoutput_irreg(itime,outnum,gridtotalunc,wetgridtotalunc, & |
---|
23 | drygridtotalunc) |
---|
24 | ! i i o o |
---|
25 | ! o |
---|
26 | !******************************************************************************* |
---|
27 | ! * |
---|
28 | ! Note: This is the FLEXPART_WRF version of subroutine concoutput * |
---|
29 | ! * |
---|
30 | ! Output of the concentration grid and the receptor concentrations. * |
---|
31 | ! * |
---|
32 | ! Author: A. Stohl * |
---|
33 | ! * |
---|
34 | ! 24 May 1995 * |
---|
35 | ! * |
---|
36 | ! 13 April 1999, Major update: if output size is smaller, dump output * |
---|
37 | ! in sparse matrix format; additional output of uncertainty * |
---|
38 | ! * |
---|
39 | ! 05 April 2000, Major update: output of age classes; output for backward * |
---|
40 | ! runs is time spent in grid cell times total mass of * |
---|
41 | ! species. * |
---|
42 | ! * |
---|
43 | ! 17 February 2002, Appropriate dimensions for backward and forward runs * |
---|
44 | ! are now specified in file includepar * |
---|
45 | ! * |
---|
46 | ! Dec 2005, J. Fast - Output files can be either binary or ascii. * |
---|
47 | ! Sparse output option is turned off. * |
---|
48 | ! Dec 2005, R. Easter - changed names of "*lon0*" & "*lat0*" variables * |
---|
49 | ! 2012, J. Brioude- modify output format to flexpart 8*, latlon output * |
---|
50 | ! 2014-05-07 A. Dingwell: Suppressed output of receptor points to separate* |
---|
51 | ! files when netcdf output is set (bug reported by Barbosa) * |
---|
52 | !******************************************************************************* |
---|
53 | ! * |
---|
54 | ! Variables: * |
---|
55 | ! outnum number of samples * |
---|
56 | ! ncells number of cells with non-zero concentrations * |
---|
57 | ! sparse .true. if in sparse matrix format, else .false. * |
---|
58 | ! nspeciesdim either nspec (forward runs), or numpoint (backward runs) * |
---|
59 | ! tot_mu 1 for forward, initial mass mixing ration for backw. runs * |
---|
60 | ! maxpointspec maxspec for forward runs, maxpoint for backward runs * |
---|
61 | ! * |
---|
62 | !******************************************************************************* |
---|
63 | |
---|
64 | ! include 'includepar' |
---|
65 | ! include 'includecom' |
---|
66 | ! |
---|
67 | ! double precision jul |
---|
68 | ! integer itime,i,ix,jy,kz,k,l,iix,jjy,kzz,nage,jjjjmmdd,ihmmss |
---|
69 | ! integer ncells(maxpointspec,maxageclass) |
---|
70 | ! integer ncellsd(maxpointspec,maxageclass) |
---|
71 | ! integer ncellsw(maxpointspec,maxageclass),nspeciesdim |
---|
72 | ! real outnum,weightair,densityoutrecept(maxreceptor),xl,yl |
---|
73 | ! real densityoutgrid(0:maxxgrid-1,0:maxygrid-1,maxzgrid), |
---|
74 | ! +grid(0:maxxgrid-1,0:maxygrid-1,maxzgrid,maxpointspec,maxageclass) |
---|
75 | ! real wetgrid(0:maxxgrid-1,0:maxygrid-1,maxpointspec,maxageclass) |
---|
76 | ! real drygrid(0:maxxgrid-1,0:maxygrid-1,maxpointspec,maxageclass) |
---|
77 | ! real gridsigma(0:maxxgrid-1,0:maxygrid-1,maxzgrid,maxpointspec, |
---|
78 | ! +maxageclass), |
---|
79 | ! +drygridsigma(0:maxxgrid-1,0:maxygrid-1,maxpointspec,maxageclass), |
---|
80 | ! +wetgridsigma(0:maxxgrid-1,0:maxygrid-1,maxpointspec,maxageclass) |
---|
81 | ! real auxgrid(nclassunc),gridtotal,gridsigmatotal,gridtotalunc |
---|
82 | ! real wetgridtotal,wetgridsigmatotal,wetgridtotalunc |
---|
83 | ! real drygridtotal,drygridsigmatotal,drygridtotalunc |
---|
84 | ! real factor(0:maxxgrid-1,0:maxygrid-1,maxzgrid) |
---|
85 | ! real halfheight,dz,dz1,dz2,tot_mu(maxpointspec) |
---|
86 | ! real xnelat,xnelon |
---|
87 | ! real xsw,xne,ysw,yne,tmpx,tmpy,tmplon,tmplat |
---|
88 | ! parameter(weightair=28.97) |
---|
89 | ! logical sparse(maxpointspec,maxageclass) |
---|
90 | ! logical sparsed(maxpointspec,maxageclass) |
---|
91 | ! logical sparsew(maxpointspec,maxageclass) |
---|
92 | ! character adate*8,atime*6 |
---|
93 | use unc_mod |
---|
94 | use point_mod |
---|
95 | use outg_mod |
---|
96 | use par_mod |
---|
97 | use com_mod |
---|
98 | use netcdf_output_mod |
---|
99 | |
---|
100 | implicit none |
---|
101 | |
---|
102 | real(kind=dp) :: jul |
---|
103 | integer :: itime,i,ix,jy,kz,ks,kp,l,iix,jjy,kzz,nage,jjjjmmdd,ihmmss |
---|
104 | integer :: sp_count_i,sp_count_r |
---|
105 | real :: sp_fact |
---|
106 | real :: outnum,densityoutrecept(maxreceptor),xl,yl |
---|
107 | real :: auxgrid(nclassunc),gridtotal,gridsigmatotal,gridtotalunc |
---|
108 | real :: wetgridtotal,wetgridsigmatotal,wetgridtotalunc |
---|
109 | real :: drygridtotal,drygridsigmatotal,drygridtotalunc |
---|
110 | real :: halfheight,dz,dz1,dz2,tot_mu(maxspec,maxpointspec_act) |
---|
111 | real :: xsw,xne,ysw,yne,tmpx,tmpy,tmplon,tmplat |
---|
112 | real :: start, finish |
---|
113 | |
---|
114 | real,parameter :: smallnum = tiny(0.0) ! smallest number that can be handled |
---|
115 | ! real,parameter :: weightair=28.97 !AD: moved this to par_mod.f90 |
---|
116 | logical :: sp_zer |
---|
117 | character :: adate*8,atime*6 |
---|
118 | character(len=3) :: anspec |
---|
119 | |
---|
120 | |
---|
121 | ! Determine current calendar date, needed for the file name |
---|
122 | !********************************************************** |
---|
123 | |
---|
124 | jul=bdate+real(itime,kind=dp)/86400._dp |
---|
125 | |
---|
126 | call caldate(jul,jjjjmmdd,ihmmss) |
---|
127 | write(adate,'(i8.8)') jjjjmmdd |
---|
128 | write(atime,'(i6.6)') ihmmss |
---|
129 | write(unitdates,'(a)') adate//atime |
---|
130 | |
---|
131 | |
---|
132 | ! For forward simulations, output fields have dimension MAXSPEC, |
---|
133 | ! for backward simulations, output fields have dimension MAXPOINT. |
---|
134 | ! Thus, make loops either about nspec, or about numpoint |
---|
135 | !***************************************************************** |
---|
136 | |
---|
137 | if (ldirect.eq.1) then |
---|
138 | do ks=1,nspec |
---|
139 | do kp=1,maxpointspec_act |
---|
140 | tot_mu(ks,kp)=1 |
---|
141 | end do |
---|
142 | end do |
---|
143 | else |
---|
144 | do ks=1,nspec |
---|
145 | do kp=1,maxpointspec_act |
---|
146 | tot_mu(ks,kp)=xmass(kp,ks) |
---|
147 | end do |
---|
148 | end do |
---|
149 | endif |
---|
150 | |
---|
151 | !******************************************************************* |
---|
152 | ! Compute air density: sufficiently accurate to take it |
---|
153 | ! from coarse grid at some time |
---|
154 | ! Determine center altitude of output layer, and interpolate density |
---|
155 | ! data to that altitude |
---|
156 | !******************************************************************* |
---|
157 | |
---|
158 | do kz=1,numzgrid |
---|
159 | if (kz.eq.1) then |
---|
160 | halfheight=outheight(1)/2. |
---|
161 | else |
---|
162 | halfheight=(outheight(kz)+outheight(kz-1))/2. |
---|
163 | endif |
---|
164 | do kzz=2,nz |
---|
165 | if ((height(kzz-1).lt.halfheight).and. & |
---|
166 | (height(kzz).gt.halfheight)) goto 46 |
---|
167 | end do |
---|
168 | 46 kzz=max(min(kzz,nz),2) |
---|
169 | dz1=halfheight-height(kzz-1) |
---|
170 | dz2=height(kzz)-halfheight |
---|
171 | dz=dz1+dz2 |
---|
172 | do jy=0,numygrid-1 |
---|
173 | do ix=0,numxgrid-1 |
---|
174 | ! xl=outlon0+real(ix)*dxout |
---|
175 | ! yl=outlat0+real(jy)*dyout |
---|
176 | xl=out_xm0+float(ix)*dxout |
---|
177 | yl=out_ym0+float(jy)*dyout |
---|
178 | ! xl=(xl-xlon0)/dx |
---|
179 | ! yl=(yl-ylat0)/dx |
---|
180 | xl=(xl-xmet0)/dx |
---|
181 | yl=(yl-ymet0)/dy |
---|
182 | iix=max(min(nint(xl),nxmin1),0) |
---|
183 | jjy=max(min(nint(yl),nymin1),0) |
---|
184 | densityoutgrid(ix,jy,kz)=(rho(iix,jjy,kzz,2)*dz1+ & |
---|
185 | rho(iix,jjy,kzz-1,2)*dz2)/dz |
---|
186 | end do |
---|
187 | end do |
---|
188 | end do |
---|
189 | |
---|
190 | do i=1,numreceptor |
---|
191 | xl=xreceptor(i) |
---|
192 | yl=yreceptor(i) |
---|
193 | iix=max(min(nint(xl),nxmin1),0) |
---|
194 | jjy=max(min(nint(yl),nymin1),0) |
---|
195 | densityoutrecept(i)=rho(iix,jjy,1,2) |
---|
196 | end do |
---|
197 | |
---|
198 | ! Output is different for forward and backward simulations |
---|
199 | do kz=1,numzgrid |
---|
200 | do jy=0,numygrid-1 |
---|
201 | do ix=0,numxgrid-1 |
---|
202 | if (ldirect.eq.1) then |
---|
203 | factor3d(ix,jy,kz)=1.e12/volume(ix,jy,kz)/outnum |
---|
204 | else |
---|
205 | factor3d(ix,jy,kz)=real(abs(loutaver))/outnum |
---|
206 | endif |
---|
207 | end do |
---|
208 | end do |
---|
209 | end do |
---|
210 | |
---|
211 | !********************************************************************* |
---|
212 | ! Determine the standard deviation of the mean concentration or mixing |
---|
213 | ! ratio (uncertainty of the output) and the dry and wet deposition |
---|
214 | !********************************************************************* |
---|
215 | |
---|
216 | gridtotal=0. |
---|
217 | gridsigmatotal=0. |
---|
218 | gridtotalunc=0. |
---|
219 | wetgridtotal=0. |
---|
220 | wetgridsigmatotal=0. |
---|
221 | wetgridtotalunc=0. |
---|
222 | drygridtotal=0. |
---|
223 | drygridsigmatotal=0. |
---|
224 | drygridtotalunc=0. |
---|
225 | |
---|
226 | !******************************************************************* |
---|
227 | ! Generate output: may be in concentration (ng/m3) or in mixing |
---|
228 | ! ratio (ppt) or both |
---|
229 | ! Output either in full grid dump or sparse matrix format |
---|
230 | ! For backward simulations, the unit is seconds, stored in grid_conc |
---|
231 | !******************************************************************* |
---|
232 | |
---|
233 | ! Concentration output |
---|
234 | !********************* |
---|
235 | |
---|
236 | ! open(53,file=path(1)(1:length(1))//'latlon.txt',form='formatted') |
---|
237 | ! open(54,file=path(1)(1:length(1))//'latlon_corner.txt' & |
---|
238 | ! ,form='formatted') |
---|
239 | ! |
---|
240 | !! xnelat=outgrid_nelat |
---|
241 | !! xnelon=outgrid_nelon |
---|
242 | ! print*,'before ll_to',outgrid_swlon,outgrid_swlat,outgrid_nelon,outgrid_nelat |
---|
243 | ! call ll_to_xymeter_wrf(outgrid_swlon,outgrid_swlat,xsw,ysw) |
---|
244 | ! call ll_to_xymeter_wrf(outgrid_nelon,outgrid_nelat,xne,yne) |
---|
245 | ! print*,'after ll_to' |
---|
246 | ! do jy=1,numygrid |
---|
247 | ! do ix=1,numxgrid |
---|
248 | !! tmpx=out_xm0+(ix-1)*dxout |
---|
249 | !! tmpy=out_ym0+(jy-1)*dyout |
---|
250 | ! tmpx=out_xm0+(float(ix)-0.5)*dxout |
---|
251 | ! tmpy=out_ym0+(float(jy)-0.5)*dyout |
---|
252 | !! print*,'jb','tmpx','tmpy',dxout,dyout,ix,jy |
---|
253 | ! call xymeter_to_ll_wrf(tmpx,tmpy,tmplon,tmplat) |
---|
254 | !!jb if(iouttype.eq.0) write(unitoutgrid) tmplon,tmplat |
---|
255 | !! if(iouttype.eq.1) write(unitoutgrid,*) tmplon,tmplat |
---|
256 | ! write(53,*) tmplon,tmplat |
---|
257 | !! tmpx=out_xm0+(ix-1-0.5)*dxout |
---|
258 | !! tmpy=out_ym0+(jy-1-0.5)*dyout |
---|
259 | ! tmpx=out_xm0+(float(ix)-1.)*dxout |
---|
260 | ! tmpy=out_ym0+(float(jy)-1.)*dyout |
---|
261 | !! tmpx=xsw+(xne-xsw)*float(ix-1)/float(numxgrid-1) |
---|
262 | !! tmpy=ysw+(yne-ysw)*float(jy-1)/float(numygrid-1) |
---|
263 | !! print*,'jb2','tmpx','tmpy',dxout,dyout,ix,jy |
---|
264 | !! call xymeter_to_ll_wrf(tmpx,tmpy,tmplon,tmplat) |
---|
265 | ! call xymeter_to_ll_wrf_out(tmpx,tmpy,tmplon,tmplat) |
---|
266 | ! write(54,*) tmplon,tmplat |
---|
267 | ! enddo |
---|
268 | ! enddo |
---|
269 | ! close(53) |
---|
270 | ! close(54) |
---|
271 | |
---|
272 | ! print*,'in grid conc',nspec,iout,adate,atime |
---|
273 | do ks=1,nspec |
---|
274 | if (iouttype.ne.2) then ! Not netcdf output, open the standard files |
---|
275 | ! AD: I don't think this is right, there is no distinction between ascii |
---|
276 | ! or binary files as there is in concoutput_reg... |
---|
277 | write(anspec,'(i3.3)') ks |
---|
278 | if ((iout.eq.1).or.(iout.eq.3).or.(iout.eq.5)) then |
---|
279 | if (ldirect.eq.1) then |
---|
280 | if (iouttype.eq.0) then |
---|
281 | open(unitoutgrid,file=path(1)(1:length(1))//'grid_conc_'//adate// & |
---|
282 | atime//'_'//anspec,form='unformatted') |
---|
283 | else if (iouttype.eq.1) then |
---|
284 | open(unitoutgrid,file=path(1)(1:length(1))//'grid_conc_'//adate// & |
---|
285 | atime//'_'//anspec) |
---|
286 | endif |
---|
287 | else |
---|
288 | if (iouttype.eq.0) then |
---|
289 | open(unitoutgrid,file=path(1)(1:length(1))//'grid_time_'//adate// & |
---|
290 | atime//'_'//anspec,form='unformatted') |
---|
291 | else if (iouttype.eq.1) then |
---|
292 | open(unitoutgrid,file=path(1)(1:length(1))//'grid_time_'//adate// & |
---|
293 | atime//'_'//anspec) |
---|
294 | end if |
---|
295 | |
---|
296 | endif |
---|
297 | if (iouttype.eq.0) write(unitoutgrid) itime |
---|
298 | if (iouttype.eq.1) write(unitoutgrid,*) itime |
---|
299 | endif |
---|
300 | endif ! iouttype.ne.2 |
---|
301 | |
---|
302 | if ((iout.eq.2).or.(iout.eq.3)) then ! mixing ratio |
---|
303 | if(iouttype.ne.2) then ! Not netcdf output, open standard file |
---|
304 | ! AD: still the same issue as my previous comment... |
---|
305 | open(unitoutgridppt,file=path(1)(1:length(1))//'grid_pptv_'//adate// & |
---|
306 | atime//'_'//anspec,form='unformatted') |
---|
307 | if (iouttype.eq.0) write(unitoutgridppt) itime |
---|
308 | if (iouttype.eq.1) write(unitoutgridppt,*) itime |
---|
309 | endif |
---|
310 | endif |
---|
311 | |
---|
312 | |
---|
313 | ! print*,'in grid conc step 2',maxpointspec_act,nageclass,numygrid,numxgrid,numzgrid |
---|
314 | do kp=1,maxpointspec_act |
---|
315 | do nage=1,nageclass |
---|
316 | |
---|
317 | do jy=0,numygrid-1 |
---|
318 | do ix=0,numxgrid-1 |
---|
319 | |
---|
320 | ! WET DEPOSITION |
---|
321 | if ((WETDEP).and.(ldirect.gt.0)) then |
---|
322 | do l=1,nclassunc |
---|
323 | auxgrid(l)=wetgridunc(ix,jy,ks,kp,l,nage) |
---|
324 | end do |
---|
325 | call mean(auxgrid,wetgrid(ix,jy), & |
---|
326 | wetgridsigma(ix,jy),nclassunc) |
---|
327 | ! Multiply by number of classes to get total concentration |
---|
328 | wetgrid(ix,jy)=wetgrid(ix,jy) & |
---|
329 | *nclassunc |
---|
330 | wetgridtotal=wetgridtotal+wetgrid(ix,jy) |
---|
331 | ! Calculate standard deviation of the mean |
---|
332 | wetgridsigma(ix,jy)= & |
---|
333 | wetgridsigma(ix,jy)* & |
---|
334 | sqrt(real(nclassunc)) |
---|
335 | wetgridsigmatotal=wetgridsigmatotal+ & |
---|
336 | wetgridsigma(ix,jy) |
---|
337 | endif |
---|
338 | |
---|
339 | ! DRY DEPOSITION |
---|
340 | if ((DRYDEP).and.(ldirect.gt.0)) then |
---|
341 | do l=1,nclassunc |
---|
342 | auxgrid(l)=drygridunc(ix,jy,ks,kp,l,nage) |
---|
343 | end do |
---|
344 | call mean(auxgrid,drygrid(ix,jy), & |
---|
345 | drygridsigma(ix,jy),nclassunc) |
---|
346 | ! Multiply by number of classes to get total concentration |
---|
347 | drygrid(ix,jy)=drygrid(ix,jy)* & |
---|
348 | nclassunc |
---|
349 | drygridtotal=drygridtotal+drygrid(ix,jy) |
---|
350 | ! Calculate standard deviation of the mean |
---|
351 | drygridsigma(ix,jy)= & |
---|
352 | drygridsigma(ix,jy)* & |
---|
353 | sqrt(real(nclassunc)) |
---|
354 | 125 drygridsigmatotal=drygridsigmatotal+ & |
---|
355 | drygridsigma(ix,jy) |
---|
356 | endif |
---|
357 | ! CONCENTRATION OR MIXING RATIO |
---|
358 | do kz=1,numzgrid |
---|
359 | do l=1,nclassunc |
---|
360 | auxgrid(l)=gridunc(ix,jy,kz,ks,kp,l,nage) |
---|
361 | end do |
---|
362 | call mean(auxgrid,grid(ix,jy,kz), & |
---|
363 | gridsigma(ix,jy,kz),nclassunc) |
---|
364 | ! Multiply by number of classes to get total concentration |
---|
365 | grid(ix,jy,kz)= & |
---|
366 | grid(ix,jy,kz)*nclassunc |
---|
367 | ! if (grid(ix,jy,kz).gt.0. ) print*,grid(ix,jy,kz) |
---|
368 | gridtotal=gridtotal+grid(ix,jy,kz) |
---|
369 | ! Calculate standard deviation of the mean |
---|
370 | gridsigma(ix,jy,kz)= & |
---|
371 | gridsigma(ix,jy,kz)* & |
---|
372 | sqrt(real(nclassunc)) |
---|
373 | gridsigmatotal=gridsigmatotal+ & |
---|
374 | gridsigma(ix,jy,kz) |
---|
375 | end do |
---|
376 | end do |
---|
377 | end do |
---|
378 | |
---|
379 | !******************************************************************* |
---|
380 | ! Generate output: may be in concentration (ng/m3) or in mixing |
---|
381 | ! ratio (ppt) or both |
---|
382 | ! Output the position and the values alternated multiplied by |
---|
383 | ! 1 or -1, first line is number of values, number of positions |
---|
384 | ! For backward simulations, the unit is seconds, stored in grid_time |
---|
385 | !******************************************************************* |
---|
386 | |
---|
387 | if (iouttype.eq.2) then ! netcdf output |
---|
388 | if (option_verbose.ge.1) then |
---|
389 | write(*,*) 'concoutput_irreg: Calling write_ncconc for main outgrid' |
---|
390 | endif |
---|
391 | call nc_write_output(itime,outnum,ks,kp,nage,tot_mu(ks,kp),densityoutrecept,volume,0) ! 0= nest level |
---|
392 | else ! binary or ascii output |
---|
393 | |
---|
394 | ! Concentration output |
---|
395 | !********************* |
---|
396 | if ((iout.eq.1).or.(iout.eq.3).or.(iout.eq.5)) then |
---|
397 | |
---|
398 | ! Wet deposition |
---|
399 | sp_count_i=0 |
---|
400 | sp_count_r=0 |
---|
401 | sp_fact=-1. |
---|
402 | sp_zer=.true. |
---|
403 | if ((ldirect.eq.1).and.(WETDEP)) then |
---|
404 | do jy=0,numygrid-1 |
---|
405 | do ix=0,numxgrid-1 |
---|
406 | !oncentraion greater zero |
---|
407 | if (wetgrid(ix,jy).gt.smallnum) then |
---|
408 | if (sp_zer.eqv..true.) then ! first non zero value |
---|
409 | sp_count_i=sp_count_i+1 |
---|
410 | sparse_dump_i(sp_count_i)=ix+jy*numxgrid |
---|
411 | sp_zer=.false. |
---|
412 | sp_fact=sp_fact*(-1.) |
---|
413 | endif |
---|
414 | sp_count_r=sp_count_r+1 |
---|
415 | sparse_dump_r(sp_count_r)= & |
---|
416 | sp_fact*1.e12*wetgrid(ix,jy)/area(ix,jy) |
---|
417 | ! sparse_dump_u(sp_count_r)= |
---|
418 | !+ 1.e12*wetgridsigma(ix,jy,ks,kp,nage)/area(ix,jy) |
---|
419 | else ! concentration is zero |
---|
420 | sp_zer=.true. |
---|
421 | endif |
---|
422 | end do |
---|
423 | end do |
---|
424 | else |
---|
425 | sp_count_i=0 |
---|
426 | sp_count_r=0 |
---|
427 | endif |
---|
428 | if (iouttype.eq.0) then |
---|
429 | write(unitoutgrid) sp_count_i |
---|
430 | write(unitoutgrid) (sparse_dump_i(i),i=1,sp_count_i) |
---|
431 | write(unitoutgrid) sp_count_r |
---|
432 | write(unitoutgrid) (sparse_dump_r(i),i=1,sp_count_r) |
---|
433 | endif |
---|
434 | if (iouttype.eq.1) then |
---|
435 | write(unitoutgrid,*) sp_count_i |
---|
436 | write(unitoutgrid,*) (sparse_dump_i(i),i=1,sp_count_i) |
---|
437 | write(unitoutgrid,*) sp_count_r |
---|
438 | write(unitoutgrid,*) (sparse_dump_r(i),i=1,sp_count_r) |
---|
439 | endif |
---|
440 | ! write(unitoutgrid) sp_count_u |
---|
441 | ! write(unitoutgrid) (sparse_dump_u(i),i=1,sp_count_r) |
---|
442 | |
---|
443 | ! Dry deposition |
---|
444 | sp_count_i=0 |
---|
445 | sp_count_r=0 |
---|
446 | sp_fact=-1. |
---|
447 | sp_zer=.true. |
---|
448 | if ((ldirect.eq.1).and.(DRYDEP)) then |
---|
449 | do jy=0,numygrid-1 |
---|
450 | do ix=0,numxgrid-1 |
---|
451 | if (drygrid(ix,jy).gt.smallnum) then |
---|
452 | if (sp_zer.eqv..true.) then ! first non zero value |
---|
453 | sp_count_i=sp_count_i+1 |
---|
454 | sparse_dump_i(sp_count_i)=ix+jy*numxgrid |
---|
455 | sp_zer=.false. |
---|
456 | sp_fact=sp_fact*(-1.) |
---|
457 | endif |
---|
458 | sp_count_r=sp_count_r+1 |
---|
459 | sparse_dump_r(sp_count_r)= & |
---|
460 | sp_fact* & |
---|
461 | 1.e12*drygrid(ix,jy)/area(ix,jy) |
---|
462 | ! sparse_dump_u(sp_count_r)= |
---|
463 | !+ 1.e12*drygridsigma(ix,jy,ks,kp,nage)/area(ix,jy) |
---|
464 | else ! concentration is zero |
---|
465 | sp_zer=.true. |
---|
466 | endif |
---|
467 | end do |
---|
468 | end do |
---|
469 | else |
---|
470 | sp_count_i=0 |
---|
471 | sp_count_r=0 |
---|
472 | endif |
---|
473 | if (iouttype.eq.0) then |
---|
474 | write(unitoutgrid) sp_count_i |
---|
475 | write(unitoutgrid) (sparse_dump_i(i),i=1,sp_count_i) |
---|
476 | write(unitoutgrid) sp_count_r |
---|
477 | write(unitoutgrid) (sparse_dump_r(i),i=1,sp_count_r) |
---|
478 | endif |
---|
479 | if (iouttype.eq.1) then |
---|
480 | write(unitoutgrid,*) sp_count_i |
---|
481 | write(unitoutgrid,*) (sparse_dump_i(i),i=1,sp_count_i) |
---|
482 | write(unitoutgrid,*) sp_count_r |
---|
483 | write(unitoutgrid,*) (sparse_dump_r(i),i=1,sp_count_r) |
---|
484 | endif |
---|
485 | |
---|
486 | ! write(*,*) sp_count_u |
---|
487 | ! write(unitoutgrid) (sparse_dump_u(i),i=1,sp_count_r) |
---|
488 | |
---|
489 | ! Concentrations |
---|
490 | sp_count_i=0 |
---|
491 | sp_count_r=0 |
---|
492 | sp_fact=-1. |
---|
493 | sp_zer=.true. |
---|
494 | do kz=1,numzgrid |
---|
495 | do jy=0,numygrid-1 |
---|
496 | do ix=0,numxgrid-1 |
---|
497 | if (grid(ix,jy,kz).gt.smallnum) then |
---|
498 | if (sp_zer.eqv..true.) then ! first non zero value |
---|
499 | sp_count_i=sp_count_i+1 |
---|
500 | sparse_dump_i(sp_count_i)= & |
---|
501 | ix+jy*numxgrid+kz*numxgrid*numygrid |
---|
502 | sp_zer=.false. |
---|
503 | sp_fact=sp_fact*(-1.) |
---|
504 | endif |
---|
505 | sp_count_r=sp_count_r+1 |
---|
506 | sparse_dump_r(sp_count_r)= & |
---|
507 | sp_fact* & |
---|
508 | grid(ix,jy,kz)* & |
---|
509 | factor3d(ix,jy,kz)/tot_mu(ks,kp) |
---|
510 | ! if ((factor(ix,jy,kz)/tot_mu(ks,kp)).eq.0) |
---|
511 | ! + write (*,*) factor(ix,jy,kz),tot_mu(ks,kp),ks,kp |
---|
512 | ! sparse_dump_u(sp_count_r)= |
---|
513 | !+ ,gridsigma(ix,jy,kz,ks,kp,nage)* |
---|
514 | !+ factor(ix,jy,kz)/tot_mu(ks,kp) |
---|
515 | else ! concentration is zero |
---|
516 | sp_zer=.true. |
---|
517 | endif |
---|
518 | end do |
---|
519 | end do |
---|
520 | end do |
---|
521 | if (iouttype.eq.0) then |
---|
522 | write(unitoutgrid) sp_count_i |
---|
523 | write(unitoutgrid) (sparse_dump_i(i),i=1,sp_count_i) |
---|
524 | write(unitoutgrid) sp_count_r |
---|
525 | write(unitoutgrid) (sparse_dump_r(i),i=1,sp_count_r) |
---|
526 | endif |
---|
527 | if (iouttype.eq.1) then |
---|
528 | write(unitoutgrid,*) sp_count_i |
---|
529 | write(unitoutgrid,*) (sparse_dump_i(i),i=1,sp_count_i) |
---|
530 | write(unitoutgrid,*) sp_count_r |
---|
531 | write(unitoutgrid,*) (sparse_dump_r(i),i=1,sp_count_r) |
---|
532 | endif |
---|
533 | ! write(unitoutgrid) sp_count_u |
---|
534 | ! write(unitoutgrid) (sparse_dump_u(i),i=1,sp_count_r) |
---|
535 | |
---|
536 | |
---|
537 | |
---|
538 | endif ! concentration output |
---|
539 | |
---|
540 | ! Mixing ratio output |
---|
541 | !******************** |
---|
542 | |
---|
543 | if ((iout.eq.2).or.(iout.eq.3)) then ! mixing ratio |
---|
544 | |
---|
545 | ! Wet deposition |
---|
546 | sp_count_i=0 |
---|
547 | sp_count_r=0 |
---|
548 | sp_fact=-1. |
---|
549 | sp_zer=.true. |
---|
550 | if ((ldirect.eq.1).and.(WETDEP)) then |
---|
551 | do jy=0,numygrid-1 |
---|
552 | do ix=0,numxgrid-1 |
---|
553 | if (wetgrid(ix,jy).gt.smallnum) then |
---|
554 | if (sp_zer.eqv..true.) then ! first non zero value |
---|
555 | sp_count_i=sp_count_i+1 |
---|
556 | sparse_dump_i(sp_count_i)= & |
---|
557 | ix+jy*numxgrid |
---|
558 | sp_zer=.false. |
---|
559 | sp_fact=sp_fact*(-1.) |
---|
560 | endif |
---|
561 | sp_count_r=sp_count_r+1 |
---|
562 | sparse_dump_r(sp_count_r)= & |
---|
563 | sp_fact* & |
---|
564 | 1.e12*wetgrid(ix,jy)/area(ix,jy) |
---|
565 | ! sparse_dump_u(sp_count_r)= |
---|
566 | ! + ,1.e12*wetgridsigma(ix,jy,ks,kp,nage)/area(ix,jy) |
---|
567 | else ! concentration is zero |
---|
568 | sp_zer=.true. |
---|
569 | endif |
---|
570 | end do |
---|
571 | end do |
---|
572 | else |
---|
573 | sp_count_i=0 |
---|
574 | sp_count_r=0 |
---|
575 | endif |
---|
576 | if (iouttype.eq.0) then |
---|
577 | write(unitoutgridppt) sp_count_i |
---|
578 | write(unitoutgridppt) (sparse_dump_i(i),i=1,sp_count_i) |
---|
579 | write(unitoutgridppt) sp_count_r |
---|
580 | write(unitoutgridppt) (sparse_dump_r(i),i=1,sp_count_r) |
---|
581 | endif |
---|
582 | if (iouttype.eq.1) then |
---|
583 | write(unitoutgridppt,*) sp_count_i |
---|
584 | write(unitoutgridppt,*) (sparse_dump_i(i),i=1,sp_count_i) |
---|
585 | write(unitoutgridppt,*) sp_count_r |
---|
586 | write(unitoutgridppt,*) (sparse_dump_r(i),i=1,sp_count_r) |
---|
587 | endif |
---|
588 | ! write(unitoutgridppt) sp_count_u |
---|
589 | ! write(unitoutgridppt) (sparse_dump_u(i),i=1,sp_count_r) |
---|
590 | |
---|
591 | ! Dry deposition |
---|
592 | sp_count_i=0 |
---|
593 | sp_count_r=0 |
---|
594 | sp_fact=-1. |
---|
595 | sp_zer=.true. |
---|
596 | if ((ldirect.eq.1).and.(DRYDEP)) then |
---|
597 | do jy=0,numygrid-1 |
---|
598 | do ix=0,numxgrid-1 |
---|
599 | if (drygrid(ix,jy).gt.smallnum) then |
---|
600 | if (sp_zer.eqv..true.) then ! first non zero value |
---|
601 | sp_count_i=sp_count_i+1 |
---|
602 | sparse_dump_i(sp_count_i)= & |
---|
603 | ix+jy*numxgrid |
---|
604 | sp_zer=.false. |
---|
605 | sp_fact=sp_fact*(-1) |
---|
606 | endif |
---|
607 | sp_count_r=sp_count_r+1 |
---|
608 | sparse_dump_r(sp_count_r)= & |
---|
609 | sp_fact* & |
---|
610 | 1.e12*drygrid(ix,jy)/area(ix,jy) |
---|
611 | ! sparse_dump_u(sp_count_r)= |
---|
612 | ! + ,1.e12*drygridsigma(ix,jy,ks,kp,nage)/area(ix,jy) |
---|
613 | else ! concentration is zero |
---|
614 | sp_zer=.true. |
---|
615 | endif |
---|
616 | end do |
---|
617 | end do |
---|
618 | else |
---|
619 | sp_count_i=0 |
---|
620 | sp_count_r=0 |
---|
621 | endif |
---|
622 | if (iouttype.eq.0) then |
---|
623 | write(unitoutgridppt) sp_count_i |
---|
624 | write(unitoutgridppt) (sparse_dump_i(i),i=1,sp_count_i) |
---|
625 | write(unitoutgridppt) sp_count_r |
---|
626 | write(unitoutgridppt) (sparse_dump_r(i),i=1,sp_count_r) |
---|
627 | endif |
---|
628 | if (iouttype.eq.1) then |
---|
629 | write(unitoutgridppt,*) sp_count_i |
---|
630 | write(unitoutgridppt,*) (sparse_dump_i(i),i=1,sp_count_i) |
---|
631 | write(unitoutgridppt,*) sp_count_r |
---|
632 | write(unitoutgridppt,*) (sparse_dump_r(i),i=1,sp_count_r) |
---|
633 | endif |
---|
634 | ! write(unitoutgridppt) sp_count_u |
---|
635 | ! write(unitoutgridppt) (sparse_dump_u(i),i=1,sp_count_r) |
---|
636 | |
---|
637 | |
---|
638 | ! Mixing ratios |
---|
639 | sp_count_i=0 |
---|
640 | sp_count_r=0 |
---|
641 | sp_fact=-1. |
---|
642 | sp_zer=.true. |
---|
643 | do kz=1,numzgrid |
---|
644 | do jy=0,numygrid-1 |
---|
645 | do ix=0,numxgrid-1 |
---|
646 | if (grid(ix,jy,kz).gt.smallnum) then |
---|
647 | if (sp_zer.eqv..true.) then ! first non zero value |
---|
648 | sp_count_i=sp_count_i+1 |
---|
649 | sparse_dump_i(sp_count_i)= & |
---|
650 | ix+jy*numxgrid+kz*numxgrid*numygrid |
---|
651 | sp_zer=.false. |
---|
652 | sp_fact=sp_fact*(-1.) |
---|
653 | endif |
---|
654 | sp_count_r=sp_count_r+1 |
---|
655 | sparse_dump_r(sp_count_r)= & |
---|
656 | sp_fact* & |
---|
657 | 1.e12*grid(ix,jy,kz) & |
---|
658 | /volume(ix,jy,kz)/outnum* & |
---|
659 | weightair/weightmolar(ks)/densityoutgrid(ix,jy,kz) |
---|
660 | ! sparse_dump_u(sp_count_r)= |
---|
661 | !+ ,1.e12*gridsigma(ix,jy,kz,ks,kp,nage)/volume(ix,jy,kz)/ |
---|
662 | !+ outnum*weightair/weightmolar(ks)/ |
---|
663 | !+ densityoutgrid(ix,jy,kz) |
---|
664 | else ! concentration is zero |
---|
665 | sp_zer=.true. |
---|
666 | endif |
---|
667 | end do |
---|
668 | end do |
---|
669 | end do |
---|
670 | if (iouttype.eq.0) then |
---|
671 | write(unitoutgridppt) sp_count_i |
---|
672 | write(unitoutgridppt) (sparse_dump_i(i),i=1,sp_count_i) |
---|
673 | write(unitoutgridppt) sp_count_r |
---|
674 | write(unitoutgridppt) (sparse_dump_r(i),i=1,sp_count_r) |
---|
675 | endif |
---|
676 | if (iouttype.eq.1) then |
---|
677 | write(unitoutgridppt,*) sp_count_i |
---|
678 | write(unitoutgridppt,*) (sparse_dump_i(i),i=1,sp_count_i) |
---|
679 | write(unitoutgridppt,*) sp_count_r |
---|
680 | write(unitoutgridppt,*) (sparse_dump_r(i),i=1,sp_count_r) |
---|
681 | endif |
---|
682 | ! write(unitoutgridppt) sp_count_u |
---|
683 | ! write(unitoutgridppt) (sparse_dump_u(i),i=1,sp_count_r) |
---|
684 | |
---|
685 | endif ! output for ppt |
---|
686 | |
---|
687 | endif ! iouttype.eq.2 |
---|
688 | |
---|
689 | end do |
---|
690 | end do |
---|
691 | |
---|
692 | if((iouttype.eq.0).or.(iouttype.eq.1)) then ! binary or ascii output |
---|
693 | close(unitoutgridppt) |
---|
694 | close(unitoutgrid) |
---|
695 | endif |
---|
696 | |
---|
697 | end do |
---|
698 | |
---|
699 | if (gridtotal.gt.0.) gridtotalunc=gridsigmatotal/gridtotal |
---|
700 | if (wetgridtotal.gt.0.) wetgridtotalunc=wetgridsigmatotal/ & |
---|
701 | wetgridtotal |
---|
702 | if (drygridtotal.gt.0.) drygridtotalunc=drygridsigmatotal/ & |
---|
703 | drygridtotal |
---|
704 | |
---|
705 | ! Dump values at receptors (binary or ascii only): |
---|
706 | ! When iouttype==2, this is handled by the default netcdf output routines, |
---|
707 | ! no extra call is needed here. |
---|
708 | if ( (iouttype.eq.0 .or. iouttype.eq.1) .and. numreceptor.gt.0 ) then |
---|
709 | ! Dump of receptor mixing ratios |
---|
710 | if (iout.eq.2 .or. iout.eq.3) then ! mix. rat. |
---|
711 | write(unitoutreceptppt) itime |
---|
712 | do ks=1,nspec |
---|
713 | write(unitoutreceptppt) (1.e12*creceptor(i,ks)/outnum* & |
---|
714 | weightair/weightmolar(ks)/densityoutrecept(i),i=1,numreceptor) |
---|
715 | end do |
---|
716 | endif |
---|
717 | ! Dump of receptor concentrations |
---|
718 | if (iout.eq.1 .or. iout.eq.3 .or. iout.eq.5) then |
---|
719 | write(unitoutrecept) itime |
---|
720 | do ks=1,nspec |
---|
721 | write(unitoutrecept) (1.e12*creceptor(i,ks)/outnum, i=1,numreceptor) |
---|
722 | end do |
---|
723 | endif |
---|
724 | endif ! Dump values at receptors |
---|
725 | |
---|
726 | do ks=1,nspec |
---|
727 | do kp=1,maxpointspec_act |
---|
728 | do i=1,numreceptor |
---|
729 | creceptor(i,ks)=0. |
---|
730 | end do |
---|
731 | do jy=0,numygrid-1 |
---|
732 | do ix=0,numxgrid-1 |
---|
733 | do l=1,nclassunc |
---|
734 | do nage=1,nageclass |
---|
735 | do kz=1,numzgrid |
---|
736 | gridunc(ix,jy,kz,ks,kp,l,nage)=0. |
---|
737 | end do |
---|
738 | end do |
---|
739 | end do |
---|
740 | end do |
---|
741 | end do |
---|
742 | end do |
---|
743 | end do |
---|
744 | |
---|
745 | |
---|
746 | end subroutine concoutput_irreg |
---|
747 | |
---|