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