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