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

Last change on this file since 2014 was 2001, checked in by knoop, 8 years ago

last commit documented

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