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

Last change on this file since 1322 was 1322, checked in by raasch, 10 years ago

REAL functions and a lot of REAL constants provided with KIND-attribute,
some small bugfixes

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