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