[1833] | 1 | !> @file spectra_mod.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 | ! |
---|
[247] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[2216] | 22 | ! |
---|
| 23 | ! |
---|
[1787] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: spectra_mod.f90 2841 2018-02-27 15:02:57Z suehring $ |
---|
[2841] | 27 | ! Bugfix: wrong placement of include 'mpif.h' corrected |
---|
| 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) |
---|
[1787] | 34 | ! |
---|
[2716] | 35 | ! 2216 2017-04-28 12:54:20Z suehring |
---|
| 36 | ! |
---|
[2216] | 37 | ! 2193 2017-03-22 04:21:28Z raasch |
---|
| 38 | ! Normalization of spectra output adjusted |
---|
| 39 | ! |
---|
[2193] | 40 | ! 2192 2017-03-22 04:14:10Z raasch |
---|
| 41 | ! bugfix for index bounds of arrays spectrum_x and spectrum_y |
---|
| 42 | ! |
---|
[2001] | 43 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 44 | ! Forced header and separation lines into 80 columns |
---|
| 45 | ! |
---|
[1961] | 46 | ! 1960 2016-07-12 16:34:24Z suehring |
---|
| 47 | ! Additional default spectra for passive scalar |
---|
| 48 | ! |
---|
[1834] | 49 | ! 1833 2016-04-07 14:23:03Z raasch |
---|
| 50 | ! file renamed, reading the spectra_par NAMELIST moved from package_parin to |
---|
| 51 | ! here |
---|
| 52 | ! |
---|
[1816] | 53 | ! 1815 2016-04-06 13:49:59Z raasch |
---|
| 54 | ! bugfix: preprocessor directives included for the non-parallel case |
---|
| 55 | ! |
---|
[1809] | 56 | ! 1808 2016-04-05 19:44:00Z raasch |
---|
| 57 | ! MPI module used by default on all machines |
---|
| 58 | ! |
---|
[1787] | 59 | ! 1786 2016-03-08 05:49:27Z raasch |
---|
[1786] | 60 | ! routine is modularized, filename renamed from calc_spectra to spectrum, |
---|
| 61 | ! privious data module spectrum moved from modules.f90 to here, |
---|
| 62 | ! cpp-direktives for spectra removed, immediate return if no spectra levels are |
---|
| 63 | ! given |
---|
[1321] | 64 | ! |
---|
[1683] | 65 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 66 | ! Code annotations made doxygen readable |
---|
| 67 | ! |
---|
[1576] | 68 | ! 1575 2015-03-27 09:56:27Z raasch |
---|
| 69 | ! adjustments for psolver-queries |
---|
| 70 | ! |
---|
[1512] | 71 | ! 1511 2014-12-16 15:54:16Z suehring |
---|
| 72 | ! Bugfix concerning spectra normalization |
---|
| 73 | ! |
---|
[1432] | 74 | ! 1431 2014-07-15 14:47:17Z suehring |
---|
| 75 | ! Wavenumber-integrated spectra coincide with respective variance. |
---|
| 76 | ! |
---|
[1343] | 77 | ! 1342 2014-03-26 17:04:47Z kanani |
---|
| 78 | ! REAL constants defined as wp-kinds |
---|
| 79 | ! |
---|
[1325] | 80 | ! 1324 2014-03-21 09:13:16Z suehring |
---|
| 81 | ! Bugfix: nzb_x, nzb_yd, nyn_x, nyn_x, nzt_x, nzt_yd belong to transpose_indices |
---|
| 82 | ! |
---|
[1321] | 83 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 84 | ! ONLY-attribute added to USE-statements, |
---|
| 85 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 86 | ! kinds are defined in new module kinds, |
---|
| 87 | ! revision history before 2012 removed, |
---|
| 88 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 89 | ! all variable declaration statements |
---|
[198] | 90 | ! |
---|
[1319] | 91 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
| 92 | ! module interfaces removed |
---|
| 93 | ! |
---|
[1217] | 94 | ! 1216 2013-08-26 09:31:42Z raasch |
---|
| 95 | ! resorting of array moved to separate routine resort_for_zx, |
---|
| 96 | ! one argument removed from the transpose_..d routines |
---|
| 97 | ! |
---|
[1121] | 98 | ! 1120 2013-04-05 15:11:35Z raasch |
---|
| 99 | ! bugfix: calls of fft_x|y replaced by fft_x|y_1d |
---|
| 100 | ! |
---|
[1037] | 101 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 102 | ! code put under GPL (PALM 3.9) |
---|
| 103 | ! |
---|
[1004] | 104 | ! 1003 2012-09-14 14:35:53Z raasch |
---|
| 105 | ! adjustment of array tend for cases with unequal subdomain sizes removed |
---|
| 106 | ! |
---|
[1] | 107 | ! Revision 1.1 2001/01/05 15:08:07 raasch |
---|
| 108 | ! Initial revision |
---|
| 109 | ! |
---|
| 110 | ! |
---|
| 111 | ! Description: |
---|
| 112 | ! ------------ |
---|
[1682] | 113 | !> Calculate horizontal spectra along x and y. |
---|
| 114 | !> ATTENTION: 1d-decomposition along y still needs improvement, because in that |
---|
| 115 | !> case the gridpoint number along z still depends on the PE number |
---|
| 116 | !> because transpose_xz has to be used (and possibly also |
---|
| 117 | !> transpose_zyd needs modification). |
---|
[1] | 118 | !------------------------------------------------------------------------------! |
---|
[1833] | 119 | MODULE spectra_mod |
---|
[1] | 120 | |
---|
[1786] | 121 | USE kinds |
---|
[1320] | 122 | |
---|
[1786] | 123 | PRIVATE |
---|
[1320] | 124 | |
---|
[1833] | 125 | CHARACTER (LEN=2), DIMENSION(10) :: spectra_direction = 'x' |
---|
| 126 | CHARACTER (LEN=10), DIMENSION(10) :: data_output_sp = ' ' |
---|
[1320] | 127 | |
---|
[1833] | 128 | INTEGER(iwp) :: average_count_sp = 0 |
---|
| 129 | INTEGER(iwp) :: dosp_time_count = 0 |
---|
| 130 | INTEGER(iwp) :: n_sp_x = 0, n_sp_y = 0 |
---|
[1320] | 131 | |
---|
[1833] | 132 | INTEGER(iwp) :: comp_spectra_level(100) = 999999 |
---|
[1320] | 133 | |
---|
[1833] | 134 | LOGICAL :: calculate_spectra = .FALSE. !< internal switch that spectra are calculated |
---|
| 135 | LOGICAL :: spectra_initialized = .FALSE. !< internal switch that spectra related quantities are initialized |
---|
[1320] | 136 | |
---|
[1833] | 137 | REAL(wp) :: averaging_interval_sp = 9999999.9_wp !< averaging interval for spectra output |
---|
| 138 | REAL(wp) :: dt_dosp = 9999999.9_wp !< time interval for spectra output |
---|
| 139 | REAL(wp) :: skip_time_dosp = 9999999.9_wp !< no output of spectra data before this interval has passed |
---|
[1] | 140 | |
---|
[1833] | 141 | REAL(wp), DIMENSION(:), ALLOCATABLE :: var_d |
---|
| 142 | |
---|
| 143 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: spectrum_x, spectrum_y |
---|
| 144 | |
---|
[1786] | 145 | SAVE |
---|
[1320] | 146 | |
---|
[1786] | 147 | INTERFACE calc_spectra |
---|
| 148 | MODULE PROCEDURE calc_spectra |
---|
| 149 | END INTERFACE calc_spectra |
---|
[1320] | 150 | |
---|
[1786] | 151 | INTERFACE preprocess_spectra |
---|
| 152 | MODULE PROCEDURE preprocess_spectra |
---|
| 153 | END INTERFACE preprocess_spectra |
---|
[1] | 154 | |
---|
[1786] | 155 | INTERFACE calc_spectra_x |
---|
| 156 | MODULE PROCEDURE calc_spectra_x |
---|
| 157 | END INTERFACE calc_spectra_x |
---|
[1] | 158 | |
---|
[1786] | 159 | INTERFACE calc_spectra_y |
---|
| 160 | MODULE PROCEDURE calc_spectra_y |
---|
| 161 | END INTERFACE calc_spectra_y |
---|
[1] | 162 | |
---|
[1833] | 163 | INTERFACE spectra_check_parameters |
---|
| 164 | MODULE PROCEDURE spectra_check_parameters |
---|
| 165 | END INTERFACE spectra_check_parameters |
---|
[1] | 166 | |
---|
[1833] | 167 | INTERFACE spectra_header |
---|
| 168 | MODULE PROCEDURE spectra_header |
---|
| 169 | END INTERFACE spectra_header |
---|
[1786] | 170 | |
---|
[1833] | 171 | INTERFACE spectra_init |
---|
| 172 | MODULE PROCEDURE spectra_init |
---|
| 173 | END INTERFACE spectra_init |
---|
| 174 | |
---|
| 175 | INTERFACE spectra_parin |
---|
| 176 | MODULE PROCEDURE spectra_parin |
---|
| 177 | END INTERFACE spectra_parin |
---|
| 178 | |
---|
| 179 | PUBLIC average_count_sp, averaging_interval_sp, calc_spectra, & |
---|
| 180 | calculate_spectra, comp_spectra_level, data_output_sp, & |
---|
| 181 | dosp_time_count, dt_dosp, n_sp_x, n_sp_y, plot_spectra_level, & |
---|
| 182 | skip_time_dosp, spectra_check_parameters, spectra_direction, & |
---|
| 183 | spectra_header, spectra_init, spectra_parin, spectrum_x, & |
---|
| 184 | spectrum_y, var_d |
---|
| 185 | |
---|
| 186 | |
---|
[1786] | 187 | CONTAINS |
---|
| 188 | |
---|
[1833] | 189 | !------------------------------------------------------------------------------! |
---|
| 190 | ! Description: |
---|
| 191 | ! ------------ |
---|
| 192 | !> Parin for &spectra_par for calculating spectra |
---|
| 193 | !------------------------------------------------------------------------------! |
---|
| 194 | SUBROUTINE spectra_parin |
---|
| 195 | |
---|
| 196 | USE control_parameters, & |
---|
| 197 | ONLY: dt_data_output |
---|
| 198 | |
---|
| 199 | IMPLICIT NONE |
---|
| 200 | |
---|
| 201 | CHARACTER (LEN=80) :: line !< dummy string that contains the current & |
---|
| 202 | !< line of the parameter file |
---|
| 203 | |
---|
| 204 | NAMELIST /spectra_par/ averaging_interval_sp, comp_spectra_level, & |
---|
| 205 | data_output_sp, dt_dosp, skip_time_dosp, & |
---|
| 206 | spectra_direction |
---|
| 207 | |
---|
| 208 | |
---|
| 209 | ! |
---|
| 210 | !-- Position the namelist-file at the beginning (it was already opened in |
---|
| 211 | !-- parin), search for the namelist-group of the package and position the |
---|
| 212 | !-- file at this line. |
---|
| 213 | line = ' ' |
---|
| 214 | |
---|
| 215 | ! |
---|
| 216 | !-- Try to find the spectra package |
---|
| 217 | REWIND ( 11 ) |
---|
| 218 | line = ' ' |
---|
| 219 | DO WHILE ( INDEX( line, '&spectra_par' ) == 0 ) |
---|
| 220 | READ ( 11, '(A)', END=10 ) line |
---|
| 221 | ENDDO |
---|
| 222 | BACKSPACE ( 11 ) |
---|
| 223 | |
---|
| 224 | ! |
---|
| 225 | !-- Read namelist |
---|
| 226 | READ ( 11, spectra_par ) |
---|
| 227 | |
---|
| 228 | ! |
---|
| 229 | !-- Default setting of dt_dosp here (instead of check_parameters), because |
---|
| 230 | !-- its current value is needed in init_pegrid |
---|
| 231 | IF ( dt_dosp == 9999999.9_wp ) dt_dosp = dt_data_output |
---|
| 232 | |
---|
| 233 | ! |
---|
| 234 | !-- Set general switch that spectra shall be calculated |
---|
| 235 | calculate_spectra = .TRUE. |
---|
| 236 | |
---|
| 237 | 10 CONTINUE |
---|
| 238 | |
---|
| 239 | END SUBROUTINE spectra_parin |
---|
| 240 | |
---|
| 241 | |
---|
| 242 | |
---|
| 243 | !------------------------------------------------------------------------------! |
---|
| 244 | ! Description: |
---|
| 245 | ! ------------ |
---|
| 246 | !> Initialization of spectra related variables |
---|
| 247 | !------------------------------------------------------------------------------! |
---|
| 248 | SUBROUTINE spectra_init |
---|
| 249 | |
---|
| 250 | USE indices, & |
---|
| 251 | ONLY: nx, ny, nzb, nzt |
---|
| 252 | |
---|
| 253 | IMPLICIT NONE |
---|
| 254 | |
---|
| 255 | IF ( spectra_initialized ) RETURN |
---|
| 256 | |
---|
| 257 | IF ( dt_dosp /= 9999999.9_wp ) THEN |
---|
[2192] | 258 | ALLOCATE( spectrum_x( 1:nx/2, 1:100, 1:10 ), & |
---|
| 259 | spectrum_y( 1:ny/2, 1:100, 1:10 ) ) |
---|
[1833] | 260 | spectrum_x = 0.0_wp |
---|
| 261 | spectrum_y = 0.0_wp |
---|
| 262 | |
---|
| 263 | ALLOCATE( var_d(nzb:nzt+1) ) |
---|
| 264 | var_d = 0.0_wp |
---|
| 265 | ENDIF |
---|
| 266 | |
---|
| 267 | spectra_initialized = .TRUE. |
---|
| 268 | |
---|
| 269 | END SUBROUTINE spectra_init |
---|
| 270 | |
---|
| 271 | |
---|
| 272 | |
---|
| 273 | !------------------------------------------------------------------------------! |
---|
| 274 | ! Description: |
---|
| 275 | ! ------------ |
---|
| 276 | !> Check spectra related quantities |
---|
| 277 | !------------------------------------------------------------------------------! |
---|
| 278 | SUBROUTINE spectra_check_parameters |
---|
| 279 | |
---|
| 280 | USE control_parameters, & |
---|
| 281 | ONLY: averaging_interval, message_string, skip_time_data_output |
---|
| 282 | |
---|
| 283 | IMPLICIT NONE |
---|
| 284 | |
---|
| 285 | ! |
---|
| 286 | !-- Check the average interval |
---|
| 287 | IF ( averaging_interval_sp == 9999999.9_wp ) THEN |
---|
| 288 | averaging_interval_sp = averaging_interval |
---|
| 289 | ENDIF |
---|
| 290 | |
---|
| 291 | IF ( averaging_interval_sp > dt_dosp ) THEN |
---|
| 292 | WRITE( message_string, * ) 'averaging_interval_sp = ', & |
---|
| 293 | averaging_interval_sp, ' must be <= dt_dosp = ', dt_dosp |
---|
| 294 | CALL message( 'spectra_check_parameters', 'PA0087', 1, 2, 0, 6, 0 ) |
---|
| 295 | ENDIF |
---|
| 296 | |
---|
| 297 | ! |
---|
| 298 | !-- Set the default skip time interval for data output, if necessary |
---|
| 299 | IF ( skip_time_dosp == 9999999.9_wp ) & |
---|
| 300 | skip_time_dosp = skip_time_data_output |
---|
| 301 | |
---|
| 302 | END SUBROUTINE spectra_check_parameters |
---|
| 303 | |
---|
| 304 | |
---|
| 305 | |
---|
| 306 | !------------------------------------------------------------------------------! |
---|
| 307 | ! Description: |
---|
| 308 | ! ------------ |
---|
| 309 | !> Header output for spectra |
---|
| 310 | !> |
---|
| 311 | !> @todo Output of netcdf data format and compression level |
---|
| 312 | !------------------------------------------------------------------------------! |
---|
| 313 | SUBROUTINE spectra_header ( io ) |
---|
| 314 | |
---|
| 315 | USE control_parameters, & |
---|
| 316 | ONLY: dt_averaging_input_pr |
---|
| 317 | |
---|
| 318 | ! USE netcdf_interface, & |
---|
| 319 | ! ONLY: netcdf_data_format_string, netcdf_deflate |
---|
| 320 | |
---|
| 321 | IMPLICIT NONE |
---|
| 322 | |
---|
| 323 | CHARACTER (LEN=40) :: output_format !< internal string |
---|
| 324 | |
---|
| 325 | INTEGER(iwp) :: i !< internal counter |
---|
| 326 | INTEGER(iwp), INTENT(IN) :: io !< Unit of the output file |
---|
| 327 | |
---|
| 328 | ! |
---|
| 329 | !-- Spectra output |
---|
| 330 | IF ( dt_dosp /= 9999999.9_wp ) THEN |
---|
| 331 | WRITE ( io, 1 ) |
---|
| 332 | |
---|
| 333 | ! output_format = netcdf_data_format_string |
---|
| 334 | ! IF ( netcdf_deflate == 0 ) THEN |
---|
| 335 | ! WRITE ( io, 2 ) output_format |
---|
| 336 | ! ELSE |
---|
| 337 | ! WRITE ( io, 3 ) TRIM( output_format ), netcdf_deflate |
---|
| 338 | ! ENDIF |
---|
| 339 | WRITE ( io, 2 ) 'see profiles or other quantities' |
---|
| 340 | WRITE ( io, 4 ) dt_dosp |
---|
| 341 | IF ( skip_time_dosp /= 0.0_wp ) WRITE ( io, 5 ) skip_time_dosp |
---|
| 342 | WRITE ( io, 6 ) ( data_output_sp(i), i = 1,10 ), & |
---|
| 343 | ( spectra_direction(i), i = 1,10 ), & |
---|
| 344 | ( comp_spectra_level(i), i = 1,100 ), & |
---|
| 345 | averaging_interval_sp, dt_averaging_input_pr |
---|
| 346 | ENDIF |
---|
| 347 | |
---|
| 348 | 1 FORMAT (' Spectra:') |
---|
| 349 | 2 FORMAT (' Output format: ',A/) |
---|
| 350 | 3 FORMAT (' Output format: ',A, ' compressed with level: ',I1/) |
---|
| 351 | 4 FORMAT (' Output every ',F7.1,' s'/) |
---|
| 352 | 5 FORMAT (' No output during initial ',F8.2,' s') |
---|
| 353 | 6 FORMAT (' Arrays: ', 10(A5,',')/ & |
---|
| 354 | ' Directions: ', 10(A5,',')/ & |
---|
| 355 | ' height levels k = ', 20(I3,',')/ & |
---|
| 356 | ' ', 20(I3,',')/ & |
---|
| 357 | ' ', 20(I3,',')/ & |
---|
| 358 | ' ', 20(I3,',')/ & |
---|
| 359 | ' ', 19(I3,','),I3,'.'/ & |
---|
| 360 | ' Time averaged over ', F7.1, ' s,' / & |
---|
| 361 | ' Profiles for the time averaging are taken every ', & |
---|
| 362 | F6.1,' s') |
---|
| 363 | |
---|
| 364 | END SUBROUTINE spectra_header |
---|
| 365 | |
---|
| 366 | |
---|
| 367 | |
---|
[1786] | 368 | SUBROUTINE calc_spectra |
---|
| 369 | |
---|
| 370 | USE arrays_3d, & |
---|
| 371 | ONLY: d, tend |
---|
| 372 | |
---|
| 373 | USE control_parameters, & |
---|
[1833] | 374 | ONLY: bc_lr_cyc, bc_ns_cyc, message_string, psolver |
---|
[1786] | 375 | |
---|
| 376 | USE cpulog, & |
---|
| 377 | ONLY: cpu_log, log_point |
---|
| 378 | |
---|
| 379 | USE fft_xy, & |
---|
| 380 | ONLY: fft_init |
---|
| 381 | |
---|
| 382 | USE indices, & |
---|
| 383 | ONLY: nxl, nxr, nyn, nys, nzb, nzt |
---|
| 384 | |
---|
| 385 | USE kinds |
---|
| 386 | |
---|
| 387 | USE pegrid, & |
---|
| 388 | ONLY: myid, pdims |
---|
| 389 | |
---|
| 390 | IMPLICIT NONE |
---|
| 391 | |
---|
| 392 | INTEGER(iwp) :: m !< |
---|
| 393 | INTEGER(iwp) :: pr !< |
---|
| 394 | |
---|
| 395 | |
---|
[1] | 396 | ! |
---|
[1786] | 397 | !-- Check if user gave any levels for spectra to be calculated |
---|
| 398 | IF ( comp_spectra_level(1) == 999999 ) RETURN |
---|
[1] | 399 | |
---|
[1786] | 400 | CALL cpu_log( log_point(30), 'calc_spectra', 'start' ) |
---|
| 401 | |
---|
[1] | 402 | ! |
---|
[1833] | 403 | !-- Initialize spectra related quantities |
---|
| 404 | CALL spectra_init |
---|
| 405 | |
---|
| 406 | ! |
---|
[1786] | 407 | !-- Initialize ffts |
---|
| 408 | CALL fft_init |
---|
[225] | 409 | |
---|
[1] | 410 | ! |
---|
[1786] | 411 | !-- Reallocate array d in required size |
---|
| 412 | IF ( psolver(1:9) == 'multigrid' ) THEN |
---|
| 413 | DEALLOCATE( d ) |
---|
| 414 | ALLOCATE( d(nzb+1:nzt,nys:nyn,nxl:nxr) ) |
---|
| 415 | ENDIF |
---|
[1] | 416 | |
---|
[1786] | 417 | m = 1 |
---|
| 418 | DO WHILE ( data_output_sp(m) /= ' ' .AND. m <= 10 ) |
---|
[1] | 419 | ! |
---|
[1786] | 420 | !-- Transposition from z --> x ( y --> x in case of a 1d-decomposition |
---|
| 421 | !-- along x) |
---|
| 422 | IF ( INDEX( spectra_direction(m), 'x' ) /= 0 ) THEN |
---|
[247] | 423 | |
---|
[1786] | 424 | ! |
---|
| 425 | !-- Calculation of spectra works for cyclic boundary conditions only |
---|
| 426 | IF ( .NOT. bc_lr_cyc ) THEN |
---|
[1] | 427 | |
---|
[1786] | 428 | message_string = 'non-cyclic lateral boundaries along x do'// & |
---|
| 429 | ' not & allow calculation of spectra along x' |
---|
| 430 | CALL message( 'calc_spectra', 'PA0160', 1, 2, 0, 6, 0 ) |
---|
| 431 | ENDIF |
---|
[1] | 432 | |
---|
[1786] | 433 | CALL preprocess_spectra( m, pr ) |
---|
| 434 | |
---|
[1] | 435 | #if defined( __parallel ) |
---|
[1786] | 436 | IF ( pdims(2) /= 1 ) THEN |
---|
| 437 | CALL resort_for_zx( d, tend ) |
---|
| 438 | CALL transpose_zx( tend, d ) |
---|
| 439 | ELSE |
---|
| 440 | CALL transpose_yxd( d, d ) |
---|
| 441 | ENDIF |
---|
| 442 | CALL calc_spectra_x( d, pr, m ) |
---|
[1] | 443 | #else |
---|
[1786] | 444 | message_string = 'sorry, calculation of spectra in non paral' // & |
---|
| 445 | 'lel mode& is still not realized' |
---|
| 446 | CALL message( 'calc_spectra', 'PA0161', 1, 2, 0, 6, 0 ) |
---|
[1] | 447 | #endif |
---|
| 448 | |
---|
[1786] | 449 | ENDIF |
---|
[1] | 450 | |
---|
| 451 | ! |
---|
[1786] | 452 | !-- Transposition from z --> y (d is rearranged only in case of a |
---|
| 453 | !-- 1d-decomposition along x) |
---|
| 454 | IF ( INDEX( spectra_direction(m), 'y' ) /= 0 ) THEN |
---|
[1] | 455 | |
---|
| 456 | ! |
---|
[1786] | 457 | !-- Calculation of spectra works for cyclic boundary conditions only |
---|
| 458 | IF ( .NOT. bc_ns_cyc ) THEN |
---|
| 459 | IF ( myid == 0 ) THEN |
---|
| 460 | message_string = 'non-cyclic lateral boundaries along y' // & |
---|
| 461 | ' do not & allow calculation of spectr' // & |
---|
| 462 | 'a along y' |
---|
| 463 | CALL message( 'calc_spectra', 'PA0162', 1, 2, 0, 6, 0 ) |
---|
| 464 | ENDIF |
---|
| 465 | CALL local_stop |
---|
[1] | 466 | ENDIF |
---|
| 467 | |
---|
[1786] | 468 | CALL preprocess_spectra( m, pr ) |
---|
[1] | 469 | |
---|
| 470 | #if defined( __parallel ) |
---|
[1786] | 471 | CALL transpose_zyd( d, d ) |
---|
| 472 | CALL calc_spectra_y( d, pr, m ) |
---|
[1] | 473 | #else |
---|
[1786] | 474 | message_string = 'sorry, calculation of spectra in non paral' // & |
---|
| 475 | 'lel mode& is still not realized' |
---|
| 476 | CALL message( 'calc_spectra', 'PA0161', 1, 2, 0, 6, 0 ) |
---|
[1] | 477 | #endif |
---|
| 478 | |
---|
[1786] | 479 | ENDIF |
---|
[1] | 480 | |
---|
| 481 | ! |
---|
[1786] | 482 | !-- Increase counter for next spectrum |
---|
| 483 | m = m + 1 |
---|
[1] | 484 | |
---|
[1786] | 485 | ENDDO |
---|
[1] | 486 | |
---|
| 487 | ! |
---|
[1786] | 488 | !-- Increase counter for averaging process in routine plot_spectra |
---|
| 489 | average_count_sp = average_count_sp + 1 |
---|
[1] | 490 | |
---|
[1786] | 491 | CALL cpu_log( log_point(30), 'calc_spectra', 'stop' ) |
---|
[1] | 492 | |
---|
[1786] | 493 | END SUBROUTINE calc_spectra |
---|
[1] | 494 | |
---|
| 495 | |
---|
[1682] | 496 | !------------------------------------------------------------------------------! |
---|
| 497 | ! Description: |
---|
| 498 | ! ------------ |
---|
| 499 | !> @todo Missing subroutine description. |
---|
| 500 | !------------------------------------------------------------------------------! |
---|
[1786] | 501 | SUBROUTINE preprocess_spectra( m, pr ) |
---|
[1] | 502 | |
---|
[1786] | 503 | USE arrays_3d, & |
---|
[1960] | 504 | ONLY: d, pt, q, s, u, v, w |
---|
[1320] | 505 | |
---|
[1786] | 506 | USE indices, & |
---|
| 507 | ONLY: ngp_2dh, nxl, nxr, nyn, nys, nzb, nzt |
---|
[1320] | 508 | |
---|
[1786] | 509 | USE kinds |
---|
[1320] | 510 | |
---|
[1815] | 511 | #if defined( __parallel ) |
---|
[2841] | 512 | #if !defined( __mpifh ) |
---|
[1786] | 513 | USE MPI |
---|
| 514 | #endif |
---|
[1815] | 515 | #endif |
---|
[2841] | 516 | |
---|
[1786] | 517 | USE pegrid, & |
---|
| 518 | ONLY: collective_wait, comm2d, ierr |
---|
[1] | 519 | |
---|
[1786] | 520 | USE statistics, & |
---|
[1833] | 521 | ONLY: hom |
---|
[1320] | 522 | |
---|
| 523 | |
---|
[1786] | 524 | IMPLICIT NONE |
---|
[1320] | 525 | |
---|
[2841] | 526 | #if defined( __parallel ) |
---|
| 527 | #if defined( __mpifh ) |
---|
| 528 | INCLUDE "mpif.h" |
---|
| 529 | #endif |
---|
| 530 | #endif |
---|
| 531 | |
---|
[1786] | 532 | INTEGER(iwp) :: i !< |
---|
| 533 | INTEGER(iwp) :: j !< |
---|
| 534 | INTEGER(iwp) :: k !< |
---|
| 535 | INTEGER(iwp) :: m !< |
---|
| 536 | INTEGER(iwp) :: pr !< |
---|
[1] | 537 | |
---|
[1786] | 538 | REAL(wp), DIMENSION(nzb:nzt+1) :: var_d_l |
---|
[1] | 539 | |
---|
[1786] | 540 | SELECT CASE ( TRIM( data_output_sp(m) ) ) |
---|
[1] | 541 | |
---|
[1786] | 542 | CASE ( 'u' ) |
---|
| 543 | pr = 1 |
---|
| 544 | d(nzb+1:nzt,nys:nyn,nxl:nxr) = u(nzb+1:nzt,nys:nyn,nxl:nxr) |
---|
[1] | 545 | |
---|
[1786] | 546 | CASE ( 'v' ) |
---|
| 547 | pr = 2 |
---|
| 548 | d(nzb+1:nzt,nys:nyn,nxl:nxr) = v(nzb+1:nzt,nys:nyn,nxl:nxr) |
---|
[1] | 549 | |
---|
[1786] | 550 | CASE ( 'w' ) |
---|
| 551 | pr = 3 |
---|
| 552 | d(nzb+1:nzt,nys:nyn,nxl:nxr) = w(nzb+1:nzt,nys:nyn,nxl:nxr) |
---|
[1] | 553 | |
---|
[1786] | 554 | CASE ( 'pt' ) |
---|
| 555 | pr = 4 |
---|
| 556 | d(nzb+1:nzt,nys:nyn,nxl:nxr) = pt(nzb+1:nzt,nys:nyn,nxl:nxr) |
---|
[1] | 557 | |
---|
[1786] | 558 | CASE ( 'q' ) |
---|
| 559 | pr = 41 |
---|
| 560 | d(nzb+1:nzt,nys:nyn,nxl:nxr) = q(nzb+1:nzt,nys:nyn,nxl:nxr) |
---|
[1960] | 561 | |
---|
| 562 | CASE ( 's' ) |
---|
| 563 | pr = 117 |
---|
| 564 | d(nzb+1:nzt,nys:nyn,nxl:nxr) = s(nzb+1:nzt,nys:nyn,nxl:nxr) |
---|
[1] | 565 | |
---|
[1786] | 566 | CASE DEFAULT |
---|
[144] | 567 | ! |
---|
[1786] | 568 | !-- The DEFAULT case is reached either if the parameter data_output_sp(m) |
---|
| 569 | !-- contains a wrong character string or if the user has coded a special |
---|
| 570 | !-- case in the user interface. There, the subroutine user_spectra |
---|
| 571 | !-- checks which of these two conditions applies. |
---|
| 572 | CALL user_spectra( 'preprocess', m, pr ) |
---|
[1] | 573 | |
---|
[1786] | 574 | END SELECT |
---|
[1] | 575 | |
---|
| 576 | ! |
---|
[1786] | 577 | !-- Subtract horizontal mean from the array, for which spectra have to be |
---|
[2215] | 578 | !-- calculated. Moreover, calculate variance of the respective quantitiy, |
---|
| 579 | !-- later used for normalizing spectra output. |
---|
[1786] | 580 | var_d_l(:) = 0.0_wp |
---|
| 581 | DO i = nxl, nxr |
---|
| 582 | DO j = nys, nyn |
---|
| 583 | DO k = nzb+1, nzt |
---|
| 584 | d(k,j,i) = d(k,j,i) - hom(k,1,pr,0) |
---|
| 585 | var_d_l(k) = var_d_l(k) + d(k,j,i) * d(k,j,i) |
---|
| 586 | ENDDO |
---|
[1] | 587 | ENDDO |
---|
| 588 | ENDDO |
---|
[1431] | 589 | ! |
---|
[1786] | 590 | !-- Compute total variance from local variances |
---|
| 591 | var_d(:) = 0.0_wp |
---|
[1431] | 592 | #if defined( __parallel ) |
---|
[1786] | 593 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 594 | CALL MPI_ALLREDUCE( var_d_l(0), var_d(0), nzt+1-nzb, MPI_REAL, MPI_SUM, & |
---|
| 595 | comm2d, ierr ) |
---|
[1431] | 596 | #else |
---|
[1786] | 597 | var_d(:) = var_d_l(:) |
---|
[1431] | 598 | #endif |
---|
[1786] | 599 | var_d(:) = var_d(:) / ngp_2dh(0) |
---|
[1] | 600 | |
---|
[1786] | 601 | END SUBROUTINE preprocess_spectra |
---|
[1] | 602 | |
---|
| 603 | |
---|
[1682] | 604 | !------------------------------------------------------------------------------! |
---|
| 605 | ! Description: |
---|
| 606 | ! ------------ |
---|
| 607 | !> @todo Missing subroutine description. |
---|
| 608 | !------------------------------------------------------------------------------! |
---|
[1786] | 609 | SUBROUTINE calc_spectra_x( ddd, pr, m ) |
---|
[1] | 610 | |
---|
[1786] | 611 | USE control_parameters, & |
---|
| 612 | ONLY: fft_method |
---|
[1320] | 613 | |
---|
[1786] | 614 | USE fft_xy, & |
---|
| 615 | ONLY: fft_x_1d |
---|
[1320] | 616 | |
---|
[1786] | 617 | USE grid_variables, & |
---|
| 618 | ONLY: dx |
---|
[1320] | 619 | |
---|
[1786] | 620 | USE indices, & |
---|
| 621 | ONLY: nx, ny |
---|
[1320] | 622 | |
---|
[1786] | 623 | USE kinds |
---|
[1320] | 624 | |
---|
[1816] | 625 | #if defined( __parallel ) |
---|
[2841] | 626 | #if !defined( __mpifh ) |
---|
[1786] | 627 | USE MPI |
---|
| 628 | #endif |
---|
[1815] | 629 | #endif |
---|
[2841] | 630 | |
---|
[1786] | 631 | USE pegrid, & |
---|
| 632 | ONLY: comm2d, ierr, myid |
---|
[1320] | 633 | |
---|
[1786] | 634 | USE transpose_indices, & |
---|
| 635 | ONLY: nyn_x, nys_x, nzb_x, nzt_x |
---|
[1320] | 636 | |
---|
| 637 | |
---|
[1786] | 638 | IMPLICIT NONE |
---|
[1] | 639 | |
---|
[2841] | 640 | #if defined( __parallel ) |
---|
| 641 | #if defined( __mpifh ) |
---|
| 642 | INCLUDE "mpif.h" |
---|
| 643 | #endif |
---|
| 644 | #endif |
---|
| 645 | |
---|
[1786] | 646 | INTEGER(iwp) :: i !< |
---|
| 647 | INTEGER(iwp) :: ishape(1) !< |
---|
| 648 | INTEGER(iwp) :: j !< |
---|
| 649 | INTEGER(iwp) :: k !< |
---|
| 650 | INTEGER(iwp) :: m !< |
---|
| 651 | INTEGER(iwp) :: n !< |
---|
| 652 | INTEGER(iwp) :: pr !< |
---|
[1320] | 653 | |
---|
[1786] | 654 | REAL(wp) :: exponent !< |
---|
| 655 | REAL(wp) :: sum_spec_dum !< wavenumber-integrated spectrum |
---|
[1320] | 656 | |
---|
[1786] | 657 | REAL(wp), DIMENSION(0:nx) :: work !< |
---|
[1320] | 658 | |
---|
[1786] | 659 | REAL(wp), DIMENSION(0:nx/2) :: sums_spectra_l !< |
---|
[1320] | 660 | |
---|
[1786] | 661 | REAL(wp), DIMENSION(0:nx/2,100) :: sums_spectra !< |
---|
[1320] | 662 | |
---|
[1786] | 663 | REAL(wp), DIMENSION(0:nx,nys_x:nyn_x,nzb_x:nzt_x) :: ddd !< |
---|
[1] | 664 | |
---|
| 665 | ! |
---|
[1786] | 666 | !-- Exponent for geometric average |
---|
| 667 | exponent = 1.0_wp / ( ny + 1.0_wp ) |
---|
[1] | 668 | |
---|
| 669 | ! |
---|
[1786] | 670 | !-- Loop over all levels defined by the user |
---|
| 671 | n = 1 |
---|
| 672 | DO WHILE ( comp_spectra_level(n) /= 999999 .AND. n <= 100 ) |
---|
[1] | 673 | |
---|
[1786] | 674 | k = comp_spectra_level(n) |
---|
[1] | 675 | |
---|
| 676 | ! |
---|
[1786] | 677 | !-- Calculate FFT only if the corresponding level is situated on this PE |
---|
| 678 | IF ( k >= nzb_x .AND. k <= nzt_x ) THEN |
---|
[1] | 679 | |
---|
[1786] | 680 | DO j = nys_x, nyn_x |
---|
[1] | 681 | |
---|
[1786] | 682 | work = ddd(0:nx,j,k) |
---|
| 683 | CALL fft_x_1d( work, 'forward' ) |
---|
[1] | 684 | |
---|
[1786] | 685 | ddd(0,j,k) = dx * work(0)**2 |
---|
| 686 | DO i = 1, nx/2 |
---|
| 687 | ddd(i,j,k) = dx * ( work(i)**2 + work(nx+1-i)**2 ) |
---|
| 688 | ENDDO |
---|
| 689 | |
---|
[1] | 690 | ENDDO |
---|
| 691 | |
---|
| 692 | ! |
---|
[1786] | 693 | !-- Local sum and geometric average of these spectra |
---|
| 694 | !-- (WARNING: no global sum should be performed, because floating |
---|
| 695 | !-- point overflow may occur) |
---|
| 696 | DO i = 0, nx/2 |
---|
[1] | 697 | |
---|
[1786] | 698 | sums_spectra_l(i) = 1.0_wp |
---|
| 699 | DO j = nys_x, nyn_x |
---|
| 700 | sums_spectra_l(i) = sums_spectra_l(i) * ddd(i,j,k)**exponent |
---|
| 701 | ENDDO |
---|
| 702 | |
---|
[1] | 703 | ENDDO |
---|
| 704 | |
---|
[1786] | 705 | ELSE |
---|
[1] | 706 | |
---|
[1786] | 707 | sums_spectra_l = 1.0_wp |
---|
[1] | 708 | |
---|
[1786] | 709 | ENDIF |
---|
[1] | 710 | |
---|
| 711 | ! |
---|
[1786] | 712 | !-- Global sum of spectra on PE0 (from where they are written on file) |
---|
| 713 | sums_spectra(:,n) = 0.0_wp |
---|
[1] | 714 | #if defined( __parallel ) |
---|
[1786] | 715 | CALL MPI_BARRIER( comm2d, ierr ) ! Necessary? |
---|
| 716 | CALL MPI_REDUCE( sums_spectra_l(0), sums_spectra(0,n), nx/2+1, & |
---|
| 717 | MPI_REAL, MPI_PROD, 0, comm2d, ierr ) |
---|
[1] | 718 | #else |
---|
[1786] | 719 | sums_spectra(:,n) = sums_spectra_l |
---|
[1] | 720 | #endif |
---|
[1431] | 721 | ! |
---|
[1786] | 722 | !-- Normalize spectra by variance |
---|
[2215] | 723 | sum_spec_dum = SUM( sums_spectra(1:nx/2,n) ) |
---|
| 724 | |
---|
[1786] | 725 | IF ( sum_spec_dum /= 0.0_wp ) THEN |
---|
[2215] | 726 | sums_spectra(1:nx/2,n) = sums_spectra(1:nx/2,n) * & |
---|
| 727 | var_d(k) / sum_spec_dum |
---|
[1786] | 728 | ENDIF |
---|
| 729 | n = n + 1 |
---|
[1] | 730 | |
---|
[1786] | 731 | ENDDO |
---|
| 732 | n = n - 1 |
---|
[1] | 733 | |
---|
[1786] | 734 | IF ( myid == 0 ) THEN |
---|
[1] | 735 | ! |
---|
[1786] | 736 | !-- Sum of spectra for later averaging (see routine data_output_spectra) |
---|
| 737 | DO i = 1, nx/2 |
---|
| 738 | DO k = 1, n |
---|
| 739 | spectrum_x(i,k,m) = spectrum_x(i,k,m) + sums_spectra(i,k) |
---|
| 740 | ENDDO |
---|
[1] | 741 | ENDDO |
---|
| 742 | |
---|
[1786] | 743 | ENDIF |
---|
[1] | 744 | ! |
---|
[1786] | 745 | !-- n_sp_x is needed by data_output_spectra_x |
---|
| 746 | n_sp_x = n |
---|
[1] | 747 | |
---|
[1786] | 748 | END SUBROUTINE calc_spectra_x |
---|
[1] | 749 | |
---|
| 750 | |
---|
[1682] | 751 | !------------------------------------------------------------------------------! |
---|
| 752 | ! Description: |
---|
| 753 | ! ------------ |
---|
| 754 | !> @todo Missing subroutine description. |
---|
| 755 | !------------------------------------------------------------------------------! |
---|
[1786] | 756 | SUBROUTINE calc_spectra_y( ddd, pr, m ) |
---|
[1] | 757 | |
---|
[1786] | 758 | USE control_parameters, & |
---|
| 759 | ONLY: fft_method |
---|
[1320] | 760 | |
---|
[1786] | 761 | USE fft_xy, & |
---|
| 762 | ONLY: fft_y_1d |
---|
[1320] | 763 | |
---|
[1786] | 764 | USE grid_variables, & |
---|
| 765 | ONLY: dy |
---|
[1320] | 766 | |
---|
[1786] | 767 | USE indices, & |
---|
| 768 | ONLY: nx, ny |
---|
[1320] | 769 | |
---|
[1786] | 770 | USE kinds |
---|
[1320] | 771 | |
---|
[1815] | 772 | #if defined( __parallel ) |
---|
[2841] | 773 | #if !defined( __mpifh ) |
---|
[1786] | 774 | USE MPI |
---|
| 775 | #endif |
---|
[1815] | 776 | #endif |
---|
[2841] | 777 | |
---|
[1786] | 778 | USE pegrid, & |
---|
| 779 | ONLY: comm2d, ierr, myid |
---|
[1320] | 780 | |
---|
[1786] | 781 | USE transpose_indices, & |
---|
| 782 | ONLY: nxl_yd, nxr_yd, nzb_yd, nzt_yd |
---|
[1320] | 783 | |
---|
| 784 | |
---|
[1786] | 785 | IMPLICIT NONE |
---|
[1] | 786 | |
---|
[2841] | 787 | #if defined( __parallel ) |
---|
| 788 | #if defined( __mpifh ) |
---|
| 789 | INCLUDE "mpif.h" |
---|
| 790 | #endif |
---|
| 791 | #endif |
---|
| 792 | |
---|
[1786] | 793 | INTEGER(iwp) :: i !< |
---|
| 794 | INTEGER(iwp) :: j !< |
---|
| 795 | INTEGER(iwp) :: jshape(1) !< |
---|
| 796 | INTEGER(iwp) :: k !< |
---|
| 797 | INTEGER(iwp) :: m !< |
---|
| 798 | INTEGER(iwp) :: n !< |
---|
| 799 | INTEGER(iwp) :: pr !< |
---|
[1320] | 800 | |
---|
[1786] | 801 | REAL(wp) :: exponent !< |
---|
| 802 | REAL(wp) :: sum_spec_dum !< wavenumber-integrated spectrum |
---|
[1320] | 803 | |
---|
[1786] | 804 | REAL(wp), DIMENSION(0:ny) :: work !< |
---|
[1320] | 805 | |
---|
[1786] | 806 | REAL(wp), DIMENSION(0:ny/2) :: sums_spectra_l !< |
---|
[1320] | 807 | |
---|
[1786] | 808 | REAL(wp), DIMENSION(0:ny/2,100) :: sums_spectra !< |
---|
[1320] | 809 | |
---|
[1786] | 810 | REAL(wp), DIMENSION(0:ny,nxl_yd:nxr_yd,nzb_yd:nzt_yd) :: ddd !< |
---|
[1] | 811 | |
---|
| 812 | |
---|
| 813 | ! |
---|
[1786] | 814 | !-- Exponent for geometric average |
---|
| 815 | exponent = 1.0_wp / ( nx + 1.0_wp ) |
---|
[1] | 816 | |
---|
| 817 | ! |
---|
[1786] | 818 | !-- Loop over all levels defined by the user |
---|
| 819 | n = 1 |
---|
| 820 | DO WHILE ( comp_spectra_level(n) /= 999999 .AND. n <= 100 ) |
---|
[1] | 821 | |
---|
[1786] | 822 | k = comp_spectra_level(n) |
---|
[1] | 823 | |
---|
| 824 | ! |
---|
[1786] | 825 | !-- Calculate FFT only if the corresponding level is situated on this PE |
---|
| 826 | IF ( k >= nzb_yd .AND. k <= nzt_yd ) THEN |
---|
[1] | 827 | |
---|
[1786] | 828 | DO i = nxl_yd, nxr_yd |
---|
[1] | 829 | |
---|
[1786] | 830 | work = ddd(0:ny,i,k) |
---|
| 831 | CALL fft_y_1d( work, 'forward' ) |
---|
[1] | 832 | |
---|
[1786] | 833 | ddd(0,i,k) = dy * work(0)**2 |
---|
| 834 | DO j = 1, ny/2 |
---|
| 835 | ddd(j,i,k) = dy * ( work(j)**2 + work(ny+1-j)**2 ) |
---|
| 836 | ENDDO |
---|
| 837 | |
---|
[1] | 838 | ENDDO |
---|
| 839 | |
---|
| 840 | ! |
---|
[1786] | 841 | !-- Local sum and geometric average of these spectra |
---|
| 842 | !-- (WARNING: no global sum should be performed, because floating |
---|
| 843 | !-- point overflow may occur) |
---|
| 844 | DO j = 0, ny/2 |
---|
[1] | 845 | |
---|
[1786] | 846 | sums_spectra_l(j) = 1.0_wp |
---|
| 847 | DO i = nxl_yd, nxr_yd |
---|
| 848 | sums_spectra_l(j) = sums_spectra_l(j) * ddd(j,i,k)**exponent |
---|
| 849 | ENDDO |
---|
| 850 | |
---|
[1] | 851 | ENDDO |
---|
| 852 | |
---|
[1786] | 853 | ELSE |
---|
[1] | 854 | |
---|
[1786] | 855 | sums_spectra_l = 1.0_wp |
---|
[1] | 856 | |
---|
[1786] | 857 | ENDIF |
---|
[1] | 858 | |
---|
| 859 | ! |
---|
[1786] | 860 | !-- Global sum of spectra on PE0 (from where they are written on file) |
---|
| 861 | sums_spectra(:,n) = 0.0_wp |
---|
[1] | 862 | #if defined( __parallel ) |
---|
[1786] | 863 | CALL MPI_BARRIER( comm2d, ierr ) ! Necessary? |
---|
| 864 | CALL MPI_REDUCE( sums_spectra_l(0), sums_spectra(0,n), ny/2+1, & |
---|
| 865 | MPI_REAL, MPI_PROD, 0, comm2d, ierr ) |
---|
[1] | 866 | #else |
---|
[1786] | 867 | sums_spectra(:,n) = sums_spectra_l |
---|
[1] | 868 | #endif |
---|
[1431] | 869 | ! |
---|
[1786] | 870 | !-- Normalize spectra by variance |
---|
[2215] | 871 | sum_spec_dum = SUM( sums_spectra(1:ny/2,n) ) |
---|
| 872 | IF ( sum_spec_dum /= 0.0_wp ) THEN |
---|
| 873 | sums_spectra(1:ny/2,n) = sums_spectra(1:ny/2,n) * & |
---|
| 874 | var_d(k) / sum_spec_dum |
---|
[1786] | 875 | ENDIF |
---|
| 876 | n = n + 1 |
---|
[1] | 877 | |
---|
[1786] | 878 | ENDDO |
---|
| 879 | n = n - 1 |
---|
[1] | 880 | |
---|
| 881 | |
---|
[1786] | 882 | IF ( myid == 0 ) THEN |
---|
[1] | 883 | ! |
---|
[1786] | 884 | !-- Sum of spectra for later averaging (see routine data_output_spectra) |
---|
| 885 | DO j = 1, ny/2 |
---|
| 886 | DO k = 1, n |
---|
| 887 | spectrum_y(j,k,m) = spectrum_y(j,k,m) + sums_spectra(j,k) |
---|
| 888 | ENDDO |
---|
[1] | 889 | ENDDO |
---|
| 890 | |
---|
[1786] | 891 | ENDIF |
---|
[1] | 892 | |
---|
| 893 | ! |
---|
[1786] | 894 | !-- n_sp_y is needed by data_output_spectra_y |
---|
| 895 | n_sp_y = n |
---|
[1] | 896 | |
---|
[1786] | 897 | END SUBROUTINE calc_spectra_y |
---|
| 898 | |
---|
[1833] | 899 | END MODULE spectra_mod |
---|