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

Last change on this file since 1783 was 1783, checked in by raasch, 8 years ago

NetCDF routines modularized; new parameter netcdf_deflate; further changes in the pmc

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