1 | !> @file data_output_profiles.f90 |
---|
2 | !--------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
7 | ! either version 3 of the License, or (at your option) any later version. |
---|
8 | ! |
---|
9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
12 | ! |
---|
13 | ! You should have received a copy of the GNU General Public License along with |
---|
14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ----------------- |
---|
21 | ! |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: data_output_profiles.f90 1683 2015-10-07 23:57:51Z hoffmann $ |
---|
26 | ! |
---|
27 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
28 | ! Code annotations made doxygen readable |
---|
29 | ! |
---|
30 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
31 | ! REAL constants provided with KIND-attribute |
---|
32 | ! |
---|
33 | ! 1327 2014-03-21 11:00:16Z raasch |
---|
34 | ! -netcdf output queries |
---|
35 | ! |
---|
36 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
37 | ! REAL functions provided with KIND-attribute |
---|
38 | ! |
---|
39 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
40 | ! ONLY-attribute added to USE-statements, |
---|
41 | ! kind-parameters added to all INTEGER declaration statements, |
---|
42 | ! kinds are defined in new module kinds, |
---|
43 | ! revision history before 2012 removed, |
---|
44 | ! comment fields (!:) to be used for variable explanations added to |
---|
45 | ! all variable declaration statements |
---|
46 | ! |
---|
47 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
48 | ! barrier argument removed from cpu_log, |
---|
49 | ! module interfaces removed |
---|
50 | ! |
---|
51 | ! 1106 2013-03-04 05:31:38Z raasch |
---|
52 | ! bugfix: initial time for preruns of coupled runs is output as |
---|
53 | ! -coupling_start_time |
---|
54 | ! |
---|
55 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
56 | ! unused variables removed |
---|
57 | ! |
---|
58 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
59 | ! code put under GPL (PALM 3.9) |
---|
60 | ! |
---|
61 | ! 964 2012-07-26 09:14:24Z raasch |
---|
62 | ! code for profil-output removed |
---|
63 | ! |
---|
64 | ! Revision 1.1 1997/09/12 06:28:48 raasch |
---|
65 | ! Initial revision |
---|
66 | ! |
---|
67 | ! |
---|
68 | ! Description: |
---|
69 | ! ------------ |
---|
70 | !> Plot output of 1D-profiles for PROFIL |
---|
71 | !------------------------------------------------------------------------------! |
---|
72 | SUBROUTINE data_output_profiles |
---|
73 | |
---|
74 | |
---|
75 | USE control_parameters, & |
---|
76 | ONLY: average_count_pr, averaging_interval_pr, coupling_start_time, & |
---|
77 | dopr_n, dopr_time_count, normalizing_region, & |
---|
78 | time_since_reference_point |
---|
79 | |
---|
80 | USE cpulog, & |
---|
81 | ONLY: cpu_log, log_point |
---|
82 | |
---|
83 | USE indices, & |
---|
84 | ONLY: nzb, nzt |
---|
85 | |
---|
86 | USE kinds |
---|
87 | |
---|
88 | USE netcdf_control |
---|
89 | |
---|
90 | USE pegrid |
---|
91 | |
---|
92 | USE profil_parameter |
---|
93 | |
---|
94 | USE statistics, & |
---|
95 | ONLY: flow_statistics_called, hom, hom_sum, pr_palm, statistic_regions |
---|
96 | |
---|
97 | IMPLICIT NONE |
---|
98 | |
---|
99 | |
---|
100 | INTEGER(iwp) :: i !< |
---|
101 | INTEGER(iwp) :: sr !< |
---|
102 | |
---|
103 | ! |
---|
104 | !-- If required, compute statistics |
---|
105 | IF ( .NOT. flow_statistics_called ) CALL flow_statistics |
---|
106 | |
---|
107 | ! |
---|
108 | !-- Flow_statistics has its own CPU time measurement |
---|
109 | CALL cpu_log( log_point(15), 'data_output_profiles', 'start' ) |
---|
110 | |
---|
111 | ! |
---|
112 | !-- If required, compute temporal average |
---|
113 | IF ( averaging_interval_pr == 0.0_wp ) THEN |
---|
114 | hom_sum(:,:,:) = hom(:,1,:,:) |
---|
115 | ELSE |
---|
116 | IF ( average_count_pr > 0 ) THEN |
---|
117 | hom_sum = hom_sum / REAL( average_count_pr, KIND=wp ) |
---|
118 | ELSE |
---|
119 | ! |
---|
120 | !-- This case may happen if dt_dopr is changed in the d3par-list of |
---|
121 | !-- a restart run |
---|
122 | RETURN |
---|
123 | ENDIF |
---|
124 | ENDIF |
---|
125 | |
---|
126 | |
---|
127 | IF ( myid == 0 ) THEN |
---|
128 | |
---|
129 | ! |
---|
130 | !-- Plot-output for each (sub-)region |
---|
131 | |
---|
132 | ! |
---|
133 | !-- Open file for profile output in NetCDF format |
---|
134 | CALL check_open( 104 ) |
---|
135 | |
---|
136 | ! |
---|
137 | !-- Increment the counter for number of output times |
---|
138 | dopr_time_count = dopr_time_count + 1 |
---|
139 | |
---|
140 | ! |
---|
141 | !-- Output of initial profiles |
---|
142 | IF ( dopr_time_count == 1 ) THEN |
---|
143 | |
---|
144 | IF ( .NOT. output_for_t0 ) THEN |
---|
145 | |
---|
146 | #if defined( __netcdf ) |
---|
147 | ! |
---|
148 | !-- Store initial time to time axis, but only if an output |
---|
149 | !-- is required for at least one of the profiles. The initial time |
---|
150 | !-- is either 0, or, in case of a prerun for coupled atmosphere-ocean |
---|
151 | !-- runs, has a negative value |
---|
152 | DO i = 1, dopr_n |
---|
153 | IF ( dopr_initial_index(i) /= 0 ) THEN |
---|
154 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_time_pr, & |
---|
155 | (/ -coupling_start_time /), & |
---|
156 | start = (/ 1 /), count = (/ 1 /) ) |
---|
157 | CALL handle_netcdf_error( 'data_output_profiles', 329 ) |
---|
158 | output_for_t0 = .TRUE. |
---|
159 | EXIT |
---|
160 | ENDIF |
---|
161 | ENDDO |
---|
162 | |
---|
163 | ! |
---|
164 | !-- Store normalization factors |
---|
165 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(1), & ! wpt0 |
---|
166 | (/ hom_sum(nzb,18,normalizing_region) /), & |
---|
167 | start = (/ 1 /), count = (/ 1 /) ) |
---|
168 | CALL handle_netcdf_error( 'data_output_profiles', 330 ) |
---|
169 | |
---|
170 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(2), & ! ws2 |
---|
171 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**2 /), & |
---|
172 | start = (/ 1 /), count = (/ 1 /) ) |
---|
173 | CALL handle_netcdf_error( 'data_output_profiles', 331 ) |
---|
174 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(3), & ! tsw2 |
---|
175 | (/ hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
176 | start = (/ 1 /), count = (/ 1 /) ) |
---|
177 | CALL handle_netcdf_error( 'data_output_profiles', 332 ) |
---|
178 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(4), & ! ws3 |
---|
179 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 /), & |
---|
180 | start = (/ 1 /), count = (/ 1 /) ) |
---|
181 | CALL handle_netcdf_error( 'data_output_profiles', 333 ) |
---|
182 | |
---|
183 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(5), &!ws2tsw |
---|
184 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 * & |
---|
185 | hom_sum(nzb+3,pr_palm,normalizing_region) /), & |
---|
186 | start = (/ 1 /), count = (/ 1 /) ) |
---|
187 | CALL handle_netcdf_error( 'data_output_profiles', 334 ) |
---|
188 | |
---|
189 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(6), &!wstsw2 |
---|
190 | (/ hom_sum(nzb+8,pr_palm,normalizing_region) * & |
---|
191 | hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
192 | start = (/ 1 /), count = (/ 1 /) ) |
---|
193 | CALL handle_netcdf_error( 'data_output_profiles', 335 ) |
---|
194 | |
---|
195 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(7), & ! z_i |
---|
196 | (/ hom_sum(nzb+6,pr_palm,normalizing_region) /), & |
---|
197 | start = (/ 1 /), count = (/ 1 /) ) |
---|
198 | CALL handle_netcdf_error( 'data_output_profiles', 336 ) |
---|
199 | |
---|
200 | #endif |
---|
201 | ! |
---|
202 | !-- Loop over all 1D variables |
---|
203 | DO i = 1, dopr_n |
---|
204 | |
---|
205 | IF ( dopr_initial_index(i) /= 0 ) THEN |
---|
206 | |
---|
207 | ! |
---|
208 | !-- Output for the individual (sub-)regions |
---|
209 | DO sr = 0, statistic_regions |
---|
210 | |
---|
211 | #if defined( __netcdf ) |
---|
212 | ! |
---|
213 | !-- Write data to netcdf file |
---|
214 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_dopr(i,sr), & |
---|
215 | hom(nzb:nzt+1,1,dopr_initial_index(i),sr), & |
---|
216 | start = (/ 1, 1 /), & |
---|
217 | count = (/ nzt-nzb+2, 1 /) ) |
---|
218 | CALL handle_netcdf_error( 'data_output_profiles', 337 ) |
---|
219 | #endif |
---|
220 | |
---|
221 | ENDDO |
---|
222 | |
---|
223 | ENDIF ! Initial profile available |
---|
224 | |
---|
225 | ENDDO ! Loop over dopr_n for initial profiles |
---|
226 | |
---|
227 | IF ( output_for_t0 ) THEN |
---|
228 | dopr_time_count = dopr_time_count + 1 |
---|
229 | ENDIF |
---|
230 | |
---|
231 | END IF |
---|
232 | ENDIF ! Initial profiles |
---|
233 | |
---|
234 | #if defined( __netcdf ) |
---|
235 | |
---|
236 | ! |
---|
237 | !-- Store time to time axis |
---|
238 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_time_pr, & |
---|
239 | (/ time_since_reference_point /), & |
---|
240 | start = (/ dopr_time_count /), & |
---|
241 | count = (/ 1 /) ) |
---|
242 | CALL handle_netcdf_error( 'data_output_profiles', 338 ) |
---|
243 | |
---|
244 | ! |
---|
245 | !-- Store normalization factors |
---|
246 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(1), & ! wpt0 |
---|
247 | (/ hom_sum(nzb,18,normalizing_region) /), & |
---|
248 | start = (/ dopr_time_count /), & |
---|
249 | count = (/ 1 /) ) |
---|
250 | CALL handle_netcdf_error( 'data_output_profiles', 339 ) |
---|
251 | |
---|
252 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(2), & ! ws2 |
---|
253 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**2 /), & |
---|
254 | start = (/ dopr_time_count /), & |
---|
255 | count = (/ 1 /) ) |
---|
256 | CALL handle_netcdf_error( 'data_output_profiles', 340 ) |
---|
257 | |
---|
258 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(3), & ! tsw2 |
---|
259 | (/ hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
260 | start = (/ dopr_time_count /), & |
---|
261 | count = (/ 1 /) ) |
---|
262 | CALL handle_netcdf_error( 'data_output_profiles', 341 ) |
---|
263 | |
---|
264 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(4), & ! ws3 |
---|
265 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 /), & |
---|
266 | start = (/ dopr_time_count /), & |
---|
267 | count = (/ 1 /) ) |
---|
268 | CALL handle_netcdf_error( 'data_output_profiles', 342 ) |
---|
269 | |
---|
270 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(5), & ! ws2tsw |
---|
271 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 * & |
---|
272 | hom_sum(nzb+3,pr_palm,normalizing_region) /), & |
---|
273 | start = (/ dopr_time_count /), & |
---|
274 | count = (/ 1 /) ) |
---|
275 | CALL handle_netcdf_error( 'data_output_profiles', 343 ) |
---|
276 | |
---|
277 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(6), & ! wstsw2 |
---|
278 | (/ hom_sum(nzb+8,pr_palm,normalizing_region) * & |
---|
279 | hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
280 | start = (/ dopr_time_count /), & |
---|
281 | count = (/ 1 /) ) |
---|
282 | CALL handle_netcdf_error( 'data_output_profiles', 344 ) |
---|
283 | |
---|
284 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(7), & ! z_i |
---|
285 | (/ hom_sum(nzb+6,pr_palm,normalizing_region) /), & |
---|
286 | start = (/ dopr_time_count /), & |
---|
287 | count = (/ 1 /) ) |
---|
288 | CALL handle_netcdf_error( 'data_output_profiles', 345 ) |
---|
289 | #endif |
---|
290 | |
---|
291 | ! |
---|
292 | !-- Output of the individual (non-initial) profiles |
---|
293 | DO i = 1, dopr_n |
---|
294 | |
---|
295 | ! |
---|
296 | !-- Output for the individual (sub-)domains |
---|
297 | DO sr = 0, statistic_regions |
---|
298 | |
---|
299 | #if defined( __netcdf ) |
---|
300 | ! |
---|
301 | !-- Write data to netcdf file |
---|
302 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_dopr(i,sr), & |
---|
303 | hom_sum(nzb:nzt+1,dopr_index(i),sr),& |
---|
304 | start = (/ 1, dopr_time_count /), & |
---|
305 | count = (/ nzt-nzb+2, 1 /) ) |
---|
306 | CALL handle_netcdf_error( 'data_output_profiles', 346 ) |
---|
307 | #endif |
---|
308 | |
---|
309 | ENDDO |
---|
310 | |
---|
311 | ENDDO |
---|
312 | |
---|
313 | ENDIF ! Output on PE0 |
---|
314 | |
---|
315 | ! |
---|
316 | !-- If averaging has been done above, the summation counter must be re-set. |
---|
317 | IF ( averaging_interval_pr /= 0.0_wp ) THEN |
---|
318 | average_count_pr = 0 |
---|
319 | ENDIF |
---|
320 | |
---|
321 | CALL cpu_log( log_point(15), 'data_output_profiles','stop' ) |
---|
322 | |
---|
323 | ! |
---|
324 | !-- Formats |
---|
325 | 100 FORMAT ('#1 ',A,1X,A) |
---|
326 | 101 FORMAT (E15.7,1X,E15.7) |
---|
327 | 102 FORMAT ('NEXT') |
---|
328 | |
---|
329 | END SUBROUTINE data_output_profiles |
---|