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