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