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