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