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

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

Forced header and separation lines into 80 columns

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