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

Last change on this file since 3082 was 2932, checked in by maronga, 6 years ago

renamed all Fortran NAMELISTS

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