1 | ! SPDX-FileCopyrightText: FLEXPART 1998-2019, see flexpart_license.txt |
---|
2 | ! SPDX-License-Identifier: GPL-3.0-or-later |
---|
3 | |
---|
4 | subroutine initial_cond_output(itime) |
---|
5 | ! i |
---|
6 | !***************************************************************************** |
---|
7 | ! * |
---|
8 | ! Output of the initial condition sensitivity field. * |
---|
9 | ! * |
---|
10 | ! Author: A. Stohl * |
---|
11 | ! * |
---|
12 | ! 24 May 1995 * |
---|
13 | ! * |
---|
14 | ! 13 April 1999, Major update: if output size is smaller, dump output * |
---|
15 | ! in sparse matrix format; additional output of * |
---|
16 | ! uncertainty * |
---|
17 | ! * |
---|
18 | ! 05 April 2000, Major update: output of age classes; output for backward* |
---|
19 | ! runs is time spent in grid cell times total mass of * |
---|
20 | ! species. * |
---|
21 | ! * |
---|
22 | ! 17 February 2002, Appropriate dimensions for backward and forward runs * |
---|
23 | ! are now specified in file par_mod * |
---|
24 | ! * |
---|
25 | ! June 2006, write grid in sparse matrix with a single write command * |
---|
26 | ! in order to save disk space * |
---|
27 | ! * |
---|
28 | ! 2008 new sparse matrix format * |
---|
29 | ! * |
---|
30 | !***************************************************************************** |
---|
31 | ! * |
---|
32 | ! Variables: * |
---|
33 | ! ncells number of cells with non-zero concentrations * |
---|
34 | ! sparse .true. if in sparse matrix format, else .false. * |
---|
35 | ! * |
---|
36 | !***************************************************************************** |
---|
37 | |
---|
38 | use unc_mod |
---|
39 | use point_mod |
---|
40 | use outg_mod |
---|
41 | use par_mod |
---|
42 | use com_mod |
---|
43 | |
---|
44 | implicit none |
---|
45 | |
---|
46 | integer :: itime,i,ix,jy,kz,ks,kp,sp_count_i,sp_count_r |
---|
47 | real :: sp_fact,fact_recept |
---|
48 | real,parameter :: smallnum = tiny(0.0) ! smallest number that can be handled |
---|
49 | logical :: sp_zer |
---|
50 | character(len=3) :: anspec |
---|
51 | |
---|
52 | |
---|
53 | !********************************************************************* |
---|
54 | ! Determine the standard deviation of the mean concentration or mixing |
---|
55 | ! ratio (uncertainty of the output) and the dry and wet deposition |
---|
56 | !********************************************************************* |
---|
57 | |
---|
58 | do ks=1,nspec |
---|
59 | |
---|
60 | write(anspec,'(i3.3)') ks |
---|
61 | open(97,file=path(2)(1:length(2))//'grid_initial'// & |
---|
62 | '_'//anspec,form='unformatted') |
---|
63 | write(97) itime |
---|
64 | |
---|
65 | do kp=1,maxpointspec_act |
---|
66 | |
---|
67 | if (ind_rel.eq.1) then |
---|
68 | fact_recept=rho_rel(kp) |
---|
69 | else |
---|
70 | fact_recept=1. |
---|
71 | endif |
---|
72 | |
---|
73 | !******************************************************************* |
---|
74 | ! Generate output: may be in concentration (ng/m3) or in mixing |
---|
75 | ! ratio (ppt) or both |
---|
76 | ! Output the position and the values alternated multiplied by |
---|
77 | ! 1 or -1, first line is number of values, number of positions |
---|
78 | ! For backward simulations, the unit is seconds, stored in grid_time |
---|
79 | !******************************************************************* |
---|
80 | |
---|
81 | ! Write out dummy "wet and dry deposition" fields, to keep same format |
---|
82 | ! as for concentration output |
---|
83 | sp_count_i=0 |
---|
84 | sp_count_r=0 |
---|
85 | write(97) sp_count_i |
---|
86 | write(97) (sparse_dump_i(i),i=1,sp_count_i) |
---|
87 | write(97) sp_count_r |
---|
88 | write(97) (sparse_dump_r(i),i=1,sp_count_r) |
---|
89 | write(97) sp_count_i |
---|
90 | write(97) (sparse_dump_i(i),i=1,sp_count_i) |
---|
91 | write(97) sp_count_r |
---|
92 | write(97) (sparse_dump_r(i),i=1,sp_count_r) |
---|
93 | |
---|
94 | |
---|
95 | ! Write out sensitivity to initial conditions |
---|
96 | sp_count_i=0 |
---|
97 | sp_count_r=0 |
---|
98 | sp_fact=-1. |
---|
99 | sp_zer=.true. |
---|
100 | do kz=1,numzgrid |
---|
101 | do jy=0,numygrid-1 |
---|
102 | do ix=0,numxgrid-1 |
---|
103 | if (init_cond(ix,jy,kz,ks,kp).gt.smallnum) then |
---|
104 | if (sp_zer.eqv..true.) then ! first non zero value |
---|
105 | sp_count_i=sp_count_i+1 |
---|
106 | sparse_dump_i(sp_count_i)= & |
---|
107 | ix+jy*numxgrid+kz*numxgrid*numygrid |
---|
108 | sp_zer=.false. |
---|
109 | sp_fact=sp_fact*(-1.) |
---|
110 | endif |
---|
111 | sp_count_r=sp_count_r+1 |
---|
112 | sparse_dump_r(sp_count_r)=sp_fact* & |
---|
113 | init_cond(ix,jy,kz,ks,kp)/xmass(kp,ks)*fact_recept |
---|
114 | else ! concentration is zero |
---|
115 | sp_zer=.true. |
---|
116 | endif |
---|
117 | end do |
---|
118 | end do |
---|
119 | end do |
---|
120 | write(97) sp_count_i |
---|
121 | write(97) (sparse_dump_i(i),i=1,sp_count_i) |
---|
122 | write(97) sp_count_r |
---|
123 | write(97) (sparse_dump_r(i),i=1,sp_count_r) |
---|
124 | |
---|
125 | |
---|
126 | end do |
---|
127 | |
---|
128 | close(97) |
---|
129 | |
---|
130 | end do |
---|
131 | |
---|
132 | |
---|
133 | end subroutine initial_cond_output |
---|