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

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

last commit documented

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