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

Last change on this file since 1834 was 1818, checked in by maronga, 8 years ago

last commit documented / copyright update

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