source: palm/trunk/SOURCE/data_output_spectra.f90 @ 3254

Last change on this file since 3254 was 3241, checked in by raasch, 6 years ago

various changes to avoid compiler warnings (mainly removal of unused variables)

  • Property svn:keywords set to Id
File size: 9.2 KB
RevLine 
[1682]1!> @file data_output_spectra.f90
[2000]2!------------------------------------------------------------------------------!
[2696]3! This file is part of the PALM model system.
[1036]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!
[2718]17! Copyright 1997-2018 Leibniz Universitaet Hannover
[2000]18!------------------------------------------------------------------------------!
[1036]19!
[254]20! Current revisions:
[1327]21! ------------------
[1834]22!
[2001]23!
[1321]24! Former revisions:
25! -----------------
26! $Id: data_output_spectra.f90 3241 2018-09-12 15:02:00Z suehring $
[3241]27! unused variables removed
28!
29! 2718 2018-01-02 08:49:38Z maronga
[2716]30! Corrected "Former revisions" section
31!
32! 2696 2017-12-14 17:12:51Z kanani
33! Change in file header (GPL part)
[1321]34!
[2716]35! 2101 2017-01-05 16:42:31Z suehring
36!
[2001]37! 2000 2016-08-20 18:09:15Z knoop
38! Forced header and separation lines into 80 columns
39!
[1961]40! 1960 2016-07-12 16:34:24Z suehring
41! Additional default spectra for passive scalar
42!
[1834]43! 1833 2016-04-07 14:23:03Z raasch
44! spectrum renamed spectra_mod, spectra related variables moved to spectra_mod,
45! routines data_output_spectra_x/y removed
46!
[1787]47! 1786 2016-03-08 05:49:27Z raasch
48! cpp-directives for spectra removed, immediate return if no spectra levels are
49! given
50!
[1784]51! 1783 2016-03-06 18:36:17Z raasch
52! name change of netcdf routines and module + related changes
53!
[1683]54! 1682 2015-10-07 23:56:08Z knoop
55! Code annotations made doxygen readable
56!
[1354]57! 1353 2014-04-08 15:21:23Z heinze
58! REAL constants provided with KIND-attribute
59!
[1329]60! 1327 2014-03-21 11:00:16Z raasch
61! -netcdf output queries
62!
[1325]63! 1324 2014-03-21 09:13:16Z suehring
64! Bugfix: module statistics and module spectrum added, missing variables in ONLY
65! arguments added
66!
[1323]67! 1322 2014-03-20 16:38:49Z raasch
68! REAL functions provided with KIND-attribute
69!
[1321]70! 1320 2014-03-20 08:40:49Z raasch
[1320]71! ONLY-attribute added to USE-statements,
72! kind-parameters added to all INTEGER and REAL declaration statements,
73! kinds are defined in new module kinds,
74! revision history before 2012 removed,
75! comment fields (!:) to be used for variable explanations added to
76! all variable declaration statements
[1]77!
[1319]78! 1318 2014-03-17 13:35:16Z raasch
79! module interfaces removed
80!
[1037]81! 1036 2012-10-22 13:43:42Z raasch
82! code put under GPL (PALM 3.9)
83!
[965]84! 964 2012-07-26 09:14:24Z raasch
85! code for profil-output removed
86!
[1]87! Revision 1.1  2001/01/05 15:14:20  raasch
88! Initial revision
89!
90!
91! Description:
92! ------------
[1682]93!> Writing spectra data on file, using a special format which allows
94!> plotting of these data with PROFIL-graphic-software
[1]95!------------------------------------------------------------------------------!
[1682]96 SUBROUTINE data_output_spectra
97 
[1783]98#if defined( __netcdf )
[1320]99    USE control_parameters,                                                    &
[3241]100        ONLY:  message_string, time_since_reference_point
[1320]101
102    USE cpulog,                                                                &
103        ONLY:  cpu_log, log_point
104
105    USE kinds
106
[1783]107    USE NETCDF
[1320]108
[1783]109    USE netcdf_interface,                                                      &
110        ONLY:  id_set_sp, id_var_time_sp, nc_stat, netcdf_handle_error
111
[1]112    USE pegrid
113
[1833]114    USE spectra_mod,                                                           &
115        ONLY:  average_count_sp, averaging_interval_sp, comp_spectra_level,    &
116               data_output_sp, dosp_time_count, spectra_direction, spectrum_x, &
117               spectrum_y
[1]118
[1320]119
[1]120    IMPLICIT NONE
121
[1682]122    INTEGER(iwp) ::  m       !<
123    INTEGER(iwp) ::  pr      !<
[1320]124   
[1]125    CALL cpu_log( log_point(31), 'data_output_spectra', 'start' )
126
127!
[1786]128!-- Check if user gave any levels for spectra to be calculated
129    IF ( comp_spectra_level(1) == 999999 )  RETURN
130
131!
[1]132!-- Output is only performed on PE0
133    IF ( myid == 0 )  THEN
134
135!
136!--    Open file for spectra output in NetCDF format
[1327]137       CALL check_open( 107 )
[1]138
139!
140!--    Increment the counter for number of output times
141       dosp_time_count = dosp_time_count + 1
142
143!
144!--    Update the spectra time axis
[291]145       nc_stat = NF90_PUT_VAR( id_set_sp, id_var_time_sp,        &
146                               (/ time_since_reference_point /), &
[1]147                               start = (/ dosp_time_count /), count = (/ 1 /) )
[1783]148       CALL netcdf_handle_error( 'data_output_spectra', 47 )
[1]149
150!
151!--    If necessary, calculate time average and reset average counter
152       IF ( average_count_sp == 0 )  THEN
[254]153           message_string = 'no spectra data available'
154           CALL message( 'data_output_spectra', 'PA0186', 0, 0, 0, 6, 0 )
[1]155       ENDIF
156       IF ( average_count_sp /= 1 )  THEN
[1322]157          spectrum_x = spectrum_x / REAL( average_count_sp, KIND=wp )
158          spectrum_y = spectrum_y / REAL( average_count_sp, KIND=wp )
[1]159          average_count_sp = 0
160       ENDIF
161
162!
163!--    Loop over all spectra defined by the user
164       m = 1
165       DO WHILE ( data_output_sp(m) /= ' '  .AND.  m <= 10 )
166
167          SELECT CASE ( TRIM( data_output_sp(m) ) )
168
169             CASE ( 'u' )
170                pr = 1
171
172             CASE ( 'v' )
173                pr = 2
174
175             CASE ( 'w' )
176                pr = 3
177
178             CASE ( 'pt' )
179                pr = 4
180
181             CASE ( 'q' )
182                pr = 5
183
[1960]184             CASE ( 's' )
185                pr = 6
186
[1]187             CASE DEFAULT
[144]188!
189!--             The DEFAULT case is reached either if the parameter
190!--             data_output_sp(m) contains a wrong character string or if the
191!--             user has coded a special case in the user interface. There, the
192!--             subroutine user_spectra checks which of these two conditions
193!--             applies.
194                CALL user_spectra( 'data_output', m, pr )
[1]195
196          END SELECT
197
198!
199!--       Output of spectra in NetCDF format
[1327]200!--       Output of x-spectra
201          IF ( INDEX( spectra_direction(m), 'x' ) /= 0 ) THEN
202             CALL output_spectra_netcdf( m, 'x' )
203          ENDIF
[1]204!
[1327]205!--       Output of y-spectra
206          IF ( INDEX( spectra_direction(m), 'y' ) /= 0 ) THEN
207             CALL output_spectra_netcdf( m, 'y' )
[1]208          ENDIF
209
210!
211!--       Increase counter for next spectrum
212          m = m + 1
213
214       ENDDO
215
216!
217!--    Reset spectra values
[1353]218       spectrum_x = 0.0_wp; spectrum_y = 0.0_wp
[1]219
220    ENDIF
221
222    CALL cpu_log( log_point(31), 'data_output_spectra', 'stop' )
223
224#if defined( __parallel )
225!    CALL MPI_BARRIER( comm2d, ierr )  ! really necessary
226#endif
227
228#endif
229 END SUBROUTINE data_output_spectra
230
231
[1682]232!------------------------------------------------------------------------------!
233! Description:
234! ------------
235!> @todo Missing subroutine description.
236!------------------------------------------------------------------------------!
[1]237 SUBROUTINE output_spectra_netcdf( nsp, direction )
238#if defined( __netcdf )
239
[1320]240    USE constants,                                                             &
241        ONLY:  pi
242
243    USE grid_variables,                                                        &
244        ONLY:  dx, dy
245
246    USE indices,                                                               &
247        ONLY:  nx, ny
248
249    USE kinds
250
[1783]251    USE NETCDF
[1]252
[1783]253    USE netcdf_interface,                                                      &
254        ONLY:  id_set_sp, id_var_dospx, id_var_dospy, nc_stat,                 &
255               netcdf_handle_error
256
[1833]257    USE spectra_mod,                                                           &
258        ONLY:  dosp_time_count, n_sp_x, n_sp_y, spectrum_x, spectrum_y
[1320]259
260
[1]261    IMPLICIT NONE
262
[1682]263    CHARACTER (LEN=1), INTENT(IN) ::  direction     !<
[1]264
[1682]265    INTEGER(iwp), INTENT(IN)      ::  nsp           !<
[1]266
[1682]267    INTEGER(iwp)                  ::  i             !<
268    INTEGER(iwp)                  ::  k             !<
[1]269
[1682]270    REAL(wp)                      ::  frequency     !<
[1]271
[1682]272    REAL(wp), DIMENSION(nx/2)     ::  netcdf_data_x !<
273    REAL(wp), DIMENSION(ny/2)     ::  netcdf_data_y !<
[1]274
275
276    IF ( direction == 'x' )  THEN
277
278       DO  k = 1, n_sp_x
279
280          DO  i = 1, nx/2
[1353]281             frequency = 2.0_wp * pi * i / ( dx * ( nx + 1 ) )
[1]282             netcdf_data_x(i) = frequency * spectrum_x(i,k,nsp)
283          ENDDO
284
285          nc_stat = NF90_PUT_VAR( id_set_sp, id_var_dospx(nsp), netcdf_data_x, &
286                                  start = (/ 1, k, dosp_time_count /), &
287                                  count = (/ nx/2, 1, 1 /) )
[1783]288          CALL netcdf_handle_error( 'data_output_spectra', 348 )
[1]289
290       ENDDO
291
292    ENDIF
293
294    IF ( direction == 'y' )  THEN
295
296       DO  k = 1, n_sp_y
297
298          DO  i = 1, ny/2
[1353]299             frequency = 2.0_wp * pi * i / ( dy * ( ny + 1 ) )
[1]300             netcdf_data_y(i) = frequency * spectrum_y(i,k,nsp)
301          ENDDO
302
303          nc_stat = NF90_PUT_VAR( id_set_sp, id_var_dospy(nsp), netcdf_data_y, &
304                                  start = (/ 1, k, dosp_time_count /), &
305                                  count = (/ ny/2, 1, 1 /) )
[1783]306          CALL netcdf_handle_error( 'data_output_spectra', 349 )
[1]307
308       ENDDO
309
310    ENDIF
311
312#endif
313 END SUBROUTINE output_spectra_netcdf
Note: See TracBrowser for help on using the repository browser.