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