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