source: palm/trunk/SOURCE/data_output_profiles.f90 @ 3799

Last change on this file since 3799 was 3655, checked in by knoop, 5 years ago

Bugfix: made "unit" and "found" intend INOUT in module interface subroutines + automatic copyright update

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