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