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