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