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