[2296] | 1 | !> @file time_integration_spinup.f90 |
---|
| 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[2296] | 4 | ! |
---|
| 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. |
---|
| 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 |
---|
[2296] | 18 | !------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
| 20 | ! Current revisions: |
---|
| 21 | ! ------------------ |
---|
| 22 | ! |
---|
| 23 | ! |
---|
| 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: time_integration_spinup.f90 2782 2018-02-02 11:51:10Z suehring $ |
---|
[2782] | 27 | ! Bugfix and re-activation of homogeneous setting of velocity components |
---|
| 28 | ! during spinup |
---|
| 29 | ! |
---|
| 30 | ! 2758 2018-01-17 12:55:21Z suehring |
---|
[2758] | 31 | ! Comment out homogeneous setting of wind velocity as this will lead to zero |
---|
| 32 | ! friction velocity and cause problems in MOST relationships. |
---|
| 33 | ! |
---|
| 34 | ! 2728 2018-01-09 07:03:53Z maronga |
---|
[2728] | 35 | ! Set velocity componenets to homogeneous values during spinup |
---|
| 36 | ! |
---|
| 37 | ! 2724 2018-01-05 12:12:38Z maronga |
---|
[2724] | 38 | ! Use dt_spinup for all active components during spinup |
---|
| 39 | ! |
---|
| 40 | ! 2723 2018-01-05 09:27:03Z maronga |
---|
[2723] | 41 | ! Bugfix: array rad_sw_in no longer exists and is thus removed from RUN_CONTROL |
---|
| 42 | ! output. |
---|
| 43 | ! Added output of XY and 3D data during spinup. |
---|
| 44 | ! Bugfix: time step in LSM and USM was set to dt_3d instead of dt_spinup |
---|
| 45 | ! |
---|
| 46 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 47 | ! Corrected "Former revisions" section |
---|
| 48 | ! |
---|
| 49 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 50 | ! Change in file header (GPL part) |
---|
[2696] | 51 | ! Added radiation interactions (moved from USM) (MS) |
---|
| 52 | ! |
---|
| 53 | ! 2544 2017-10-13 18:09:32Z maronga |
---|
[2544] | 54 | ! Date and time quantities are now read from date_and_time_mod |
---|
| 55 | ! |
---|
| 56 | ! 2299 2017-06-29 10:14:38Z maronga |
---|
[2299] | 57 | ! Call of soil model adjusted to avoid prognostic equation for soil moisture |
---|
| 58 | ! during spinup. |
---|
| 59 | ! Better representation of diurnal cycle of near-surface temperature. |
---|
| 60 | ! Excluded prognostic equation for soil moisture during spinup. |
---|
| 61 | ! Added output of run control data for spinup. |
---|
| 62 | ! |
---|
| 63 | ! 2297 2017-06-28 14:35:57Z scharf |
---|
[2297] | 64 | ! bugfixes |
---|
| 65 | ! |
---|
| 66 | ! 2296 2017-06-28 07:53:56Z maronga |
---|
[2296] | 67 | ! Initial revision |
---|
| 68 | ! |
---|
| 69 | ! |
---|
| 70 | ! Description: |
---|
| 71 | ! ------------ |
---|
| 72 | !> Integration in time of the non-atmospheric model components such as land |
---|
| 73 | !> surface model and urban surface model |
---|
| 74 | !------------------------------------------------------------------------------! |
---|
| 75 | SUBROUTINE time_integration_spinup |
---|
| 76 | |
---|
| 77 | USE arrays_3d, & |
---|
[2728] | 78 | ONLY: pt, pt_p, u, v |
---|
[2296] | 79 | |
---|
| 80 | USE control_parameters, & |
---|
[2297] | 81 | ONLY: averaging_interval_pr, constant_diffusion, constant_flux_layer, & |
---|
| 82 | coupling_start_time, current_timestep_number, & |
---|
| 83 | data_output_during_spinup, disturbance_created, dopr_n, do_sum, & |
---|
[2728] | 84 | dt_averaging_input_pr, dt_dopr, dt_dots, dt_do2d_xy, dt_do3d, & |
---|
| 85 | dt_run_control, dt_spinup, dt_3d, humidity, & |
---|
| 86 | intermediate_timestep_count, & |
---|
[2297] | 87 | intermediate_timestep_count_max, land_surface, & |
---|
[2723] | 88 | simulated_time, simulated_time_chr, & |
---|
[2728] | 89 | skip_time_dopr, skip_time_do2d_xy, skip_time_do3d, spinup, & |
---|
| 90 | spinup_pt_amplitude, spinup_pt_mean, spinup_time, & |
---|
| 91 | timestep_count, timestep_scheme, time_dopr, time_dopr_av, & |
---|
| 92 | time_dots, time_do2d_xy, time_do3d, time_run_control, & |
---|
| 93 | time_since_reference_point, ug_surface, vg_surface, urban_surface |
---|
[2296] | 94 | |
---|
| 95 | USE constants, & |
---|
| 96 | ONLY: pi |
---|
| 97 | |
---|
| 98 | USE cpulog, & |
---|
| 99 | ONLY: cpu_log, log_point, log_point_s |
---|
| 100 | |
---|
[2544] | 101 | USE date_and_time_mod, & |
---|
| 102 | ONLY: day_of_year_init, time_utc_init |
---|
| 103 | |
---|
[2296] | 104 | USE indices, & |
---|
| 105 | ONLY: nbgp, nzb, nzt, nysg, nyng, nxlg, nxrg |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | USE land_surface_model_mod, & |
---|
[2299] | 109 | ONLY: lsm_energy_balance, lsm_soil_model, lsm_swap_timelevel |
---|
[2296] | 110 | |
---|
[2299] | 111 | USE pegrid, & |
---|
| 112 | ONLY: myid |
---|
[2296] | 113 | |
---|
| 114 | USE kinds |
---|
| 115 | |
---|
| 116 | USE radiation_model_mod, & |
---|
[2724] | 117 | ONLY: force_radiation_call, radiation, & |
---|
[2696] | 118 | radiation_control, rad_sw_in, time_radiation, & |
---|
| 119 | radiation_interaction, radiation_interactions |
---|
[2296] | 120 | |
---|
| 121 | USE statistics, & |
---|
| 122 | ONLY: flow_statistics_called |
---|
| 123 | |
---|
| 124 | USE surface_layer_fluxes_mod, & |
---|
| 125 | ONLY: surface_layer_fluxes |
---|
| 126 | |
---|
[2297] | 127 | USE surface_mod, & |
---|
| 128 | ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, & |
---|
[2296] | 129 | surf_usm_v |
---|
| 130 | |
---|
| 131 | USE urban_surface_mod, & |
---|
| 132 | ONLY: usm_material_heat_model, usm_material_model, & |
---|
[2696] | 133 | usm_surface_energy_balance, usm_swap_timelevel, & |
---|
| 134 | usm_green_heat_model, usm_temperature_near_surface |
---|
[2296] | 135 | |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | |
---|
| 139 | IMPLICIT NONE |
---|
| 140 | |
---|
| 141 | CHARACTER (LEN=9) :: time_to_string !< |
---|
| 142 | |
---|
[2299] | 143 | INTEGER(iwp) :: i !< running index |
---|
| 144 | INTEGER(iwp) :: j !< running index |
---|
| 145 | INTEGER(iwp) :: k !< running index |
---|
| 146 | INTEGER(iwp) :: l !< running index |
---|
| 147 | INTEGER(iwp) :: m !< running index |
---|
| 148 | |
---|
| 149 | INTEGER(iwp) :: current_timestep_number_spinup = 0 !< number if timestep during spinup |
---|
[2296] | 150 | |
---|
[2299] | 151 | LOGICAL :: run_control_header_spinup = .FALSE. !< flag parameter for steering whether the header information must be output |
---|
| 152 | |
---|
[2296] | 153 | REAL(wp) :: pt_spinup !< temporary storage of temperature |
---|
[2723] | 154 | REAL(wp) :: dt_save !< temporary storage for time step |
---|
[2296] | 155 | |
---|
[2728] | 156 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pt_save !< temporary storage of temperature |
---|
| 157 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: u_save !< temporary storage of u wind component |
---|
| 158 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: v_save !< temporary storage of v wind component |
---|
[2296] | 159 | |
---|
[2728] | 160 | |
---|
| 161 | ! |
---|
| 162 | !-- Save 3D arrays because they are to be changed for spinup purpose |
---|
[2296] | 163 | ALLOCATE( pt_save(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[2728] | 164 | ALLOCATE( u_save(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 165 | ALLOCATE( v_save(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[2296] | 166 | |
---|
[2299] | 167 | CALL exchange_horiz( pt, nbgp ) |
---|
[2728] | 168 | CALL exchange_horiz( u, nbgp ) |
---|
| 169 | CALL exchange_horiz( v, nbgp ) |
---|
| 170 | |
---|
[2299] | 171 | pt_save = pt |
---|
[2728] | 172 | u_save = u |
---|
| 173 | v_save = v |
---|
[2296] | 174 | |
---|
[2728] | 175 | ! |
---|
| 176 | !-- Set the same wall-adjacent velocity to all grid points. The sign of the |
---|
| 177 | !-- original velocity field must be preserved because the surface schemes crash |
---|
| 178 | !-- otherwise. The precise reason is still unknown. A minimum velocity of 0.1 |
---|
| 179 | !-- m/s is used to maintain turbulent transfer at the surface. |
---|
[2782] | 180 | IF ( land_surface ) THEN |
---|
| 181 | DO m = 1, surf_lsm_h%ns |
---|
| 182 | i = surf_lsm_h%i(m) |
---|
| 183 | j = surf_lsm_h%j(m) |
---|
| 184 | k = surf_lsm_h%k(m) |
---|
| 185 | u(k,j,i) = SIGN(1.0_wp,u(k,j,i)) * MAX(ug_surface,0.1_wp) |
---|
| 186 | v(k,j,i) = SIGN(1.0_wp,v(k,j,i)) * MAX(vg_surface,0.1_wp) |
---|
| 187 | ENDDO |
---|
[2728] | 188 | |
---|
[2782] | 189 | DO l = 0, 3 |
---|
| 190 | DO m = 1, surf_lsm_v(l)%ns |
---|
| 191 | i = surf_lsm_v(l)%i(m) |
---|
| 192 | j = surf_lsm_v(l)%j(m) |
---|
| 193 | k = surf_lsm_v(l)%k(m) |
---|
| 194 | u(k,j,i) = SIGN(1.0_wp,u(k,j,i)) * MAX(ug_surface,0.1_wp) |
---|
| 195 | v(k,j,i) = SIGN(1.0_wp,v(k,j,i)) * MAX(vg_surface,0.1_wp) |
---|
| 196 | ENDDO |
---|
| 197 | ENDDO |
---|
| 198 | ENDIF |
---|
| 199 | |
---|
| 200 | IF ( urban_surface ) THEN |
---|
| 201 | DO m = 1, surf_usm_h%ns |
---|
| 202 | i = surf_usm_h%i(m) |
---|
| 203 | j = surf_usm_h%j(m) |
---|
| 204 | k = surf_usm_h%k(m) |
---|
| 205 | u(k,j,i) = SIGN(1.0_wp,u(k,j,i)) * MAX(ug_surface,0.1_wp) |
---|
| 206 | v(k,j,i) = SIGN(1.0_wp,v(k,j,i)) * MAX(vg_surface,0.1_wp) |
---|
| 207 | ENDDO |
---|
| 208 | |
---|
| 209 | DO l = 0, 3 |
---|
| 210 | DO m = 1, surf_usm_v(l)%ns |
---|
| 211 | i = surf_usm_v(l)%i(m) |
---|
| 212 | j = surf_usm_v(l)%j(m) |
---|
| 213 | k = surf_usm_v(l)%k(m) |
---|
| 214 | u(k,j,i) = SIGN(1.0_wp,u(k,j,i)) * MAX(ug_surface,0.1_wp) |
---|
| 215 | v(k,j,i) = SIGN(1.0_wp,v(k,j,i)) * MAX(vg_surface,0.1_wp) |
---|
| 216 | ENDDO |
---|
| 217 | ENDDO |
---|
| 218 | ENDIF |
---|
| 219 | |
---|
[2723] | 220 | dt_save = dt_3d |
---|
| 221 | dt_3d = dt_spinup |
---|
| 222 | |
---|
[2296] | 223 | CALL location_message( 'starting spinup-sequence', .TRUE. ) |
---|
| 224 | ! |
---|
| 225 | !-- Start of the time loop |
---|
| 226 | DO WHILE ( simulated_time < spinup_time ) |
---|
| 227 | |
---|
| 228 | CALL cpu_log( log_point_s(15), 'timesteps spinup', 'start' ) |
---|
| 229 | |
---|
| 230 | ! |
---|
| 231 | !-- Start of intermediate step loop |
---|
| 232 | intermediate_timestep_count = 0 |
---|
| 233 | DO WHILE ( intermediate_timestep_count < & |
---|
| 234 | intermediate_timestep_count_max ) |
---|
| 235 | |
---|
| 236 | intermediate_timestep_count = intermediate_timestep_count + 1 |
---|
| 237 | |
---|
| 238 | ! |
---|
| 239 | !-- Set the steering factors for the prognostic equations which depend |
---|
| 240 | !-- on the timestep scheme |
---|
| 241 | CALL timestep_scheme_steering |
---|
| 242 | |
---|
| 243 | |
---|
[2299] | 244 | ! |
---|
| 245 | !-- Estimate a near-surface air temperature based on the position of the |
---|
| 246 | !-- sun and user input about mean temperature and amplitude. The time is |
---|
| 247 | !-- shifted by one hour to simulate a lag between air temperature and |
---|
| 248 | !-- incoming radiation |
---|
| 249 | pt_spinup = spinup_pt_mean + spinup_pt_amplitude & |
---|
| 250 | * solar_angle (time_utc_init + time_since_reference_point - 3600.0) |
---|
[2296] | 251 | |
---|
[2299] | 252 | ! |
---|
| 253 | !-- Map air temperature to all grid points in the vicinity of a surface |
---|
| 254 | !-- element |
---|
[2296] | 255 | IF ( land_surface ) THEN |
---|
| 256 | DO m = 1, surf_lsm_h%ns |
---|
| 257 | i = surf_lsm_h%i(m) |
---|
| 258 | j = surf_lsm_h%j(m) |
---|
| 259 | k = surf_lsm_h%k(m) |
---|
[2299] | 260 | pt(k,j,i) = pt_spinup |
---|
[2296] | 261 | ENDDO |
---|
| 262 | |
---|
| 263 | DO l = 0, 3 |
---|
| 264 | DO m = 1, surf_lsm_v(l)%ns |
---|
| 265 | i = surf_lsm_v(l)%i(m) |
---|
| 266 | j = surf_lsm_v(l)%j(m) |
---|
| 267 | k = surf_lsm_v(l)%k(m) |
---|
[2299] | 268 | pt(k,j,i) = pt_spinup |
---|
[2296] | 269 | ENDDO |
---|
| 270 | ENDDO |
---|
| 271 | ENDIF |
---|
| 272 | |
---|
| 273 | IF ( urban_surface ) THEN |
---|
| 274 | DO m = 1, surf_usm_h%ns |
---|
| 275 | i = surf_usm_h%i(m) |
---|
| 276 | j = surf_usm_h%j(m) |
---|
| 277 | k = surf_usm_h%k(m) |
---|
[2299] | 278 | pt(k,j,i) = pt_spinup |
---|
[2296] | 279 | ENDDO |
---|
| 280 | |
---|
| 281 | DO l = 0, 3 |
---|
| 282 | DO m = 1, surf_usm_v(l)%ns |
---|
| 283 | i = surf_usm_v(l)%i(m) |
---|
| 284 | j = surf_usm_v(l)%j(m) |
---|
| 285 | k = surf_usm_v(l)%k(m) |
---|
[2299] | 286 | pt(k,j,i) = pt_spinup |
---|
[2296] | 287 | ENDDO |
---|
| 288 | ENDDO |
---|
| 289 | ENDIF |
---|
| 290 | |
---|
| 291 | ! |
---|
| 292 | !-- Swap the time levels in preparation for the next time step. |
---|
| 293 | timestep_count = timestep_count + 1 |
---|
| 294 | |
---|
| 295 | IF ( land_surface ) THEN |
---|
| 296 | CALL lsm_swap_timelevel ( 0 ) |
---|
| 297 | ENDIF |
---|
| 298 | |
---|
| 299 | IF ( urban_surface ) THEN |
---|
| 300 | CALL usm_swap_timelevel ( 0 ) |
---|
| 301 | ENDIF |
---|
| 302 | |
---|
| 303 | IF ( land_surface ) THEN |
---|
| 304 | CALL lsm_swap_timelevel ( MOD( timestep_count, 2) ) |
---|
| 305 | ENDIF |
---|
| 306 | |
---|
| 307 | IF ( urban_surface ) THEN |
---|
| 308 | CALL usm_swap_timelevel ( MOD( timestep_count, 2) ) |
---|
| 309 | ENDIF |
---|
| 310 | |
---|
| 311 | ! |
---|
| 312 | !-- If required, compute virtual potential temperature |
---|
| 313 | IF ( humidity ) THEN |
---|
| 314 | CALL compute_vpt |
---|
| 315 | ENDIF |
---|
| 316 | |
---|
| 317 | ! |
---|
| 318 | !-- Compute the diffusion quantities |
---|
| 319 | IF ( .NOT. constant_diffusion ) THEN |
---|
| 320 | |
---|
| 321 | ! |
---|
| 322 | !-- First the vertical (and horizontal) fluxes in the surface |
---|
| 323 | !-- (constant flux) layer are computed |
---|
| 324 | IF ( constant_flux_layer ) THEN |
---|
| 325 | CALL cpu_log( log_point(19), 'surface_layer_fluxes', 'start' ) |
---|
| 326 | CALL surface_layer_fluxes |
---|
| 327 | CALL cpu_log( log_point(19), 'surface_layer_fluxes', 'stop' ) |
---|
| 328 | ENDIF |
---|
| 329 | |
---|
| 330 | ! |
---|
| 331 | !-- If required, solve the energy balance for the surface and run soil |
---|
[2299] | 332 | !-- model. Call for horizontal as well as vertical surfaces. |
---|
| 333 | !-- The prognostic equation for soil moisure is switched off |
---|
| 334 | IF ( land_surface ) THEN |
---|
[2296] | 335 | |
---|
| 336 | CALL cpu_log( log_point(54), 'land_surface', 'start' ) |
---|
| 337 | ! |
---|
| 338 | !-- Call for horizontal upward-facing surfaces |
---|
| 339 | CALL lsm_energy_balance( .TRUE., -1 ) |
---|
[2299] | 340 | CALL lsm_soil_model( .TRUE., -1, .FALSE. ) |
---|
[2296] | 341 | ! |
---|
| 342 | !-- Call for northward-facing surfaces |
---|
| 343 | CALL lsm_energy_balance( .FALSE., 0 ) |
---|
[2299] | 344 | CALL lsm_soil_model( .FALSE., 0, .FALSE. ) |
---|
[2296] | 345 | ! |
---|
| 346 | !-- Call for southward-facing surfaces |
---|
| 347 | CALL lsm_energy_balance( .FALSE., 1 ) |
---|
[2299] | 348 | CALL lsm_soil_model( .FALSE., 1, .FALSE. ) |
---|
[2296] | 349 | ! |
---|
| 350 | !-- Call for eastward-facing surfaces |
---|
| 351 | CALL lsm_energy_balance( .FALSE., 2 ) |
---|
[2299] | 352 | CALL lsm_soil_model( .FALSE., 2, .FALSE. ) |
---|
[2296] | 353 | ! |
---|
| 354 | !-- Call for westward-facing surfaces |
---|
| 355 | CALL lsm_energy_balance( .FALSE., 3 ) |
---|
[2299] | 356 | CALL lsm_soil_model( .FALSE., 3, .FALSE. ) |
---|
[2296] | 357 | |
---|
| 358 | CALL cpu_log( log_point(54), 'land_surface', 'stop' ) |
---|
| 359 | ENDIF |
---|
| 360 | |
---|
| 361 | ! |
---|
| 362 | !-- If required, solve the energy balance for urban surfaces and run |
---|
| 363 | !-- the material heat model |
---|
| 364 | IF (urban_surface) THEN |
---|
| 365 | CALL cpu_log( log_point(74), 'urban_surface', 'start' ) |
---|
| 366 | CALL usm_surface_energy_balance |
---|
| 367 | IF ( usm_material_model ) THEN |
---|
[2696] | 368 | CALL usm_green_heat_model |
---|
[2296] | 369 | CALL usm_material_heat_model |
---|
| 370 | ENDIF |
---|
[2696] | 371 | IF ( urban_surface ) THEN |
---|
| 372 | CALL usm_temperature_near_surface |
---|
| 373 | ENDIF |
---|
[2296] | 374 | CALL cpu_log( log_point(74), 'urban_surface', 'stop' ) |
---|
| 375 | ENDIF |
---|
| 376 | |
---|
| 377 | ENDIF |
---|
| 378 | |
---|
| 379 | ! |
---|
| 380 | !-- If required, calculate radiative fluxes and heating rates |
---|
| 381 | IF ( radiation .AND. intermediate_timestep_count & |
---|
[2299] | 382 | == intermediate_timestep_count_max ) THEN |
---|
[2296] | 383 | |
---|
[2723] | 384 | time_radiation = time_radiation + dt_3d |
---|
[2296] | 385 | |
---|
[2724] | 386 | IF ( time_radiation >= dt_3d .OR. force_radiation_call ) & |
---|
[2296] | 387 | THEN |
---|
| 388 | |
---|
| 389 | CALL cpu_log( log_point(50), 'radiation', 'start' ) |
---|
| 390 | |
---|
| 391 | IF ( .NOT. force_radiation_call ) THEN |
---|
[2724] | 392 | time_radiation = time_radiation - dt_3d |
---|
[2296] | 393 | ENDIF |
---|
| 394 | |
---|
| 395 | CALL radiation_control |
---|
| 396 | |
---|
| 397 | CALL cpu_log( log_point(50), 'radiation', 'stop' ) |
---|
| 398 | |
---|
[2696] | 399 | IF ( radiation_interactions ) THEN |
---|
| 400 | CALL cpu_log( log_point(75), 'radiation_interaction', 'start' ) |
---|
| 401 | CALL radiation_interaction |
---|
| 402 | CALL cpu_log( log_point(75), 'radiation_interaction', 'stop' ) |
---|
[2296] | 403 | ENDIF |
---|
| 404 | ENDIF |
---|
| 405 | ENDIF |
---|
| 406 | |
---|
| 407 | ENDDO ! Intermediate step loop |
---|
| 408 | |
---|
| 409 | ! |
---|
| 410 | !-- Increase simulation time and output times |
---|
[2299] | 411 | current_timestep_number_spinup = current_timestep_number_spinup + 1 |
---|
[2723] | 412 | simulated_time = simulated_time + dt_3d |
---|
[2296] | 413 | simulated_time_chr = time_to_string( simulated_time ) |
---|
| 414 | time_since_reference_point = simulated_time - coupling_start_time |
---|
| 415 | |
---|
| 416 | IF ( data_output_during_spinup ) THEN |
---|
[2723] | 417 | IF ( simulated_time >= skip_time_do2d_xy ) THEN |
---|
| 418 | time_do2d_xy = time_do2d_xy + dt_3d |
---|
| 419 | ENDIF |
---|
| 420 | IF ( simulated_time >= skip_time_do3d ) THEN |
---|
| 421 | time_do3d = time_do3d + dt_3d |
---|
| 422 | ENDIF |
---|
| 423 | time_dots = time_dots + dt_3d |
---|
[2296] | 424 | IF ( simulated_time >= skip_time_dopr ) THEN |
---|
[2723] | 425 | time_dopr = time_dopr + dt_3d |
---|
[2296] | 426 | ENDIF |
---|
[2723] | 427 | time_run_control = time_run_control + dt_3d |
---|
[2296] | 428 | |
---|
| 429 | ! |
---|
| 430 | !-- Carry out statistical analysis and output at the requested output times. |
---|
| 431 | !-- The MOD function is used for calculating the output time counters (like |
---|
| 432 | !-- time_dopr) in order to regard a possible decrease of the output time |
---|
| 433 | !-- interval in case of restart runs |
---|
| 434 | |
---|
| 435 | ! |
---|
| 436 | !-- Set a flag indicating that so far no statistics have been created |
---|
| 437 | !-- for this time step |
---|
| 438 | flow_statistics_called = .FALSE. |
---|
| 439 | |
---|
| 440 | ! |
---|
| 441 | !-- If required, call flow_statistics for averaging in time |
---|
| 442 | IF ( averaging_interval_pr /= 0.0_wp .AND. & |
---|
| 443 | ( dt_dopr - time_dopr ) <= averaging_interval_pr .AND. & |
---|
| 444 | simulated_time >= skip_time_dopr ) THEN |
---|
[2723] | 445 | time_dopr_av = time_dopr_av + dt_3d |
---|
[2296] | 446 | IF ( time_dopr_av >= dt_averaging_input_pr ) THEN |
---|
| 447 | do_sum = .TRUE. |
---|
| 448 | time_dopr_av = MOD( time_dopr_av, & |
---|
[2723] | 449 | MAX( dt_averaging_input_pr, dt_3d ) ) |
---|
[2296] | 450 | ENDIF |
---|
| 451 | ENDIF |
---|
| 452 | IF ( do_sum ) CALL flow_statistics |
---|
| 453 | |
---|
| 454 | ! |
---|
| 455 | !-- Output of profiles |
---|
| 456 | IF ( time_dopr >= dt_dopr ) THEN |
---|
| 457 | IF ( dopr_n /= 0 ) CALL data_output_profiles |
---|
[2723] | 458 | time_dopr = MOD( time_dopr, MAX( dt_dopr, dt_3d ) ) |
---|
[2296] | 459 | time_dopr_av = 0.0_wp ! due to averaging (see above) |
---|
| 460 | ENDIF |
---|
| 461 | |
---|
| 462 | ! |
---|
| 463 | !-- Output of time series |
---|
| 464 | IF ( time_dots >= dt_dots ) THEN |
---|
| 465 | CALL data_output_tseries |
---|
[2723] | 466 | time_dots = MOD( time_dots, MAX( dt_dots, dt_3d ) ) |
---|
[2296] | 467 | ENDIF |
---|
| 468 | |
---|
[2723] | 469 | ! |
---|
| 470 | !-- 2d-data output (cross-sections) |
---|
| 471 | IF ( time_do2d_xy >= dt_do2d_xy ) THEN |
---|
| 472 | CALL data_output_2d( 'xy', 0 ) |
---|
| 473 | time_do2d_xy = MOD( time_do2d_xy, MAX( dt_do2d_xy, dt_3d ) ) |
---|
| 474 | ENDIF |
---|
| 475 | |
---|
| 476 | ! |
---|
| 477 | !-- 3d-data output (volume data) |
---|
| 478 | IF ( time_do3d >= dt_do3d ) THEN |
---|
| 479 | CALL data_output_3d( 0 ) |
---|
| 480 | time_do3d = MOD( time_do3d, MAX( dt_do3d, dt_3d ) ) |
---|
| 481 | ENDIF |
---|
| 482 | |
---|
| 483 | |
---|
[2296] | 484 | ENDIF |
---|
| 485 | |
---|
| 486 | ! |
---|
| 487 | !-- Computation and output of run control parameters. |
---|
| 488 | !-- This is also done whenever perturbations have been imposed |
---|
[2299] | 489 | ! IF ( time_run_control >= dt_run_control .OR. & |
---|
| 490 | ! timestep_scheme(1:5) /= 'runge' .OR. disturbance_created ) & |
---|
| 491 | ! THEN |
---|
| 492 | ! CALL run_control |
---|
| 493 | ! IF ( time_run_control >= dt_run_control ) THEN |
---|
| 494 | ! time_run_control = MOD( time_run_control, & |
---|
[2723] | 495 | ! MAX( dt_run_control, dt_3d ) ) |
---|
[2299] | 496 | ! ENDIF |
---|
| 497 | ! ENDIF |
---|
[2296] | 498 | |
---|
| 499 | CALL cpu_log( log_point_s(15), 'timesteps spinup', 'stop' ) |
---|
| 500 | |
---|
[2299] | 501 | |
---|
| 502 | ! |
---|
| 503 | !-- Run control output |
---|
[2296] | 504 | IF ( myid == 0 ) THEN |
---|
[2299] | 505 | ! |
---|
| 506 | !-- If necessary, write header |
---|
| 507 | IF ( .NOT. run_control_header_spinup ) THEN |
---|
| 508 | CALL check_open( 15 ) |
---|
| 509 | WRITE ( 15, 100 ) |
---|
| 510 | run_control_header_spinup = .TRUE. |
---|
| 511 | ENDIF |
---|
| 512 | ! |
---|
| 513 | !-- Write some general information about the spinup in run control file |
---|
[2723] | 514 | WRITE ( 15, 101 ) current_timestep_number_spinup, simulated_time_chr, dt_3d, pt_spinup |
---|
[2299] | 515 | ! |
---|
| 516 | !-- Write buffer contents to disc immediately |
---|
| 517 | FLUSH( 15 ) |
---|
[2296] | 518 | ENDIF |
---|
| 519 | |
---|
[2299] | 520 | |
---|
| 521 | |
---|
[2296] | 522 | ENDDO ! time loop |
---|
| 523 | |
---|
| 524 | ! |
---|
[2728] | 525 | !-- Write back saved arrays to the 3D arrays |
---|
| 526 | pt = pt_save |
---|
| 527 | pt_p = pt_save |
---|
| 528 | u = u_save |
---|
| 529 | v = v_save |
---|
[2296] | 530 | |
---|
[2723] | 531 | ! |
---|
| 532 | !-- Reset time step |
---|
| 533 | dt_3d = dt_save |
---|
| 534 | |
---|
[2296] | 535 | DEALLOCATE(pt_save) |
---|
[2728] | 536 | DEALLOCATE(u_save) |
---|
| 537 | DEALLOCATE(v_save) |
---|
[2296] | 538 | |
---|
[2299] | 539 | CALL location_message( 'finished spinup-sequence', .TRUE. ) |
---|
[2296] | 540 | |
---|
[2299] | 541 | |
---|
| 542 | ! |
---|
| 543 | !-- Formats |
---|
| 544 | 100 FORMAT (///'Spinup control output:'/ & |
---|
[2723] | 545 | '--------------------------------'// & |
---|
| 546 | 'ITER. HH:MM:SS DT PT(z_MO)'/ & |
---|
| 547 | '--------------------------------') |
---|
[2299] | 548 | 101 FORMAT (I5,2X,A9,1X,F6.2,3X,F6.2,2X,F6.2) |
---|
| 549 | |
---|
| 550 | CONTAINS |
---|
| 551 | |
---|
| 552 | ! |
---|
| 553 | !-- Returns the cosine of the solar zenith angle at a given time. This routine |
---|
| 554 | !-- is similar to that for calculation zenith (see radiation_model_mod.f90) |
---|
| 555 | FUNCTION solar_angle( local_time ) |
---|
| 556 | |
---|
| 557 | USE constants, & |
---|
[2544] | 558 | ONLY: pi |
---|
| 559 | |
---|
[2299] | 560 | USE kinds |
---|
| 561 | |
---|
| 562 | USE radiation_model_mod, & |
---|
[2544] | 563 | ONLY: decl_1, decl_2, decl_3, lat, lon |
---|
[2299] | 564 | |
---|
| 565 | IMPLICIT NONE |
---|
| 566 | |
---|
| 567 | |
---|
| 568 | REAL(wp) :: solar_angle !< cosine of the solar zenith angle |
---|
| 569 | |
---|
| 570 | REAL(wp) :: day !< day of the year |
---|
| 571 | REAL(wp) :: declination !< solar declination angle |
---|
| 572 | REAL(wp) :: hour_angle !< solar hour angle |
---|
| 573 | REAL(wp) :: time_utc !< current time in UTC |
---|
| 574 | REAL(wp), INTENT(IN) :: local_time |
---|
| 575 | ! |
---|
| 576 | !-- Calculate current day and time based on the initial values and simulation |
---|
| 577 | !-- time |
---|
| 578 | |
---|
[2544] | 579 | day = day_of_year_init + INT(FLOOR( local_time / 86400.0_wp ), KIND=iwp) |
---|
[2299] | 580 | time_utc = MOD(local_time, 86400.0_wp) |
---|
| 581 | |
---|
| 582 | |
---|
| 583 | ! |
---|
| 584 | !-- Calculate solar declination and hour angle |
---|
| 585 | declination = ASIN( decl_1 * SIN(decl_2 * REAL(day, KIND=wp) - decl_3) ) |
---|
| 586 | hour_angle = 2.0_wp * pi * (time_utc / 86400.0_wp) + lon - pi |
---|
| 587 | |
---|
| 588 | ! |
---|
| 589 | !-- Calculate cosine of solar zenith angle |
---|
| 590 | solar_angle = SIN(lat) * SIN(declination) + COS(lat) * COS(declination) & |
---|
| 591 | * COS(hour_angle) |
---|
| 592 | |
---|
| 593 | |
---|
| 594 | END FUNCTION solar_angle |
---|
| 595 | |
---|
| 596 | |
---|
[2296] | 597 | END SUBROUTINE time_integration_spinup |
---|