1 | !> @file time_integration_spinup.f90 |
---|
2 | !--------------------------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
4 | ! |
---|
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. |
---|
8 | ! |
---|
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. |
---|
12 | ! |
---|
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/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: time_integration_spinup.f90 4655 2020-08-28 14:28:34Z pavelkrc $ |
---|
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 |
---|
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 |
---|
35 | ! Set pt1 attribute only element-wise |
---|
36 | ! |
---|
37 | ! 4540 2020-05-18 15:23:29Z raasch |
---|
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 | ! |
---|
43 | ! 4444 2020-03-05 15:59:50Z raasch |
---|
44 | ! Bugfix: cpp-directives for serial mode added |
---|
45 | ! |
---|
46 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
47 | ! Enable output of diagnostic quantities, e.g. 2-m temperature |
---|
48 | ! |
---|
49 | ! 4227 2019-09-10 18:04:34Z gronemeier |
---|
50 | ! Implement new palm_date_time_mod |
---|
51 | ! |
---|
52 | ! 4223 2019-09-10 09:20:47Z gronemeier |
---|
53 | ! Corrected "Former revisions" section |
---|
54 | ! |
---|
55 | ! 4064 2019-07-01 05:33:33Z gronemeier |
---|
56 | ! Moved call to radiation module out of intermediate time loop |
---|
57 | ! |
---|
58 | ! 4023 2019-06-12 13:20:01Z maronga |
---|
59 | ! Time stamps are now negative in run control output |
---|
60 | ! |
---|
61 | ! 3885 2019-04-11 11:29:34Z kanani |
---|
62 | ! Changes related to global restructuring of location messages and introduction of additional debug |
---|
63 | ! messages |
---|
64 | ! |
---|
65 | ! 3766 2019-02-26 16:23:41Z raasch |
---|
66 | ! Unused variable removed |
---|
67 | ! |
---|
68 | ! 3719 2019-02-06 13:10:18Z kanani |
---|
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 | ! |
---|
73 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
74 | ! Removed call to calculation of near air (10 cm) potential temperature (now in surface layer fluxes) |
---|
75 | ! |
---|
76 | ! 2296 2017-06-28 07:53:56Z maronga |
---|
77 | ! Initial revision |
---|
78 | ! |
---|
79 | ! |
---|
80 | ! Description: |
---|
81 | ! ------------ |
---|
82 | !> Integration in time of the non-atmospheric model components such as land surface model and urban |
---|
83 | !> surface model |
---|
84 | !--------------------------------------------------------------------------------------------------! |
---|
85 | SUBROUTINE time_integration_spinup |
---|
86 | |
---|
87 | USE arrays_3d, & |
---|
88 | ONLY: pt, & |
---|
89 | pt_p, & |
---|
90 | u, & |
---|
91 | u_init, & |
---|
92 | v, & |
---|
93 | v_init |
---|
94 | |
---|
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, & |
---|
123 | surface_output, & |
---|
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 |
---|
133 | |
---|
134 | USE cpulog, & |
---|
135 | ONLY: cpu_log, & |
---|
136 | log_point_s |
---|
137 | |
---|
138 | USE diagnostic_output_quantities_mod, & |
---|
139 | ONLY: doq_calculate |
---|
140 | |
---|
141 | USE exchange_horiz_mod, & |
---|
142 | ONLY: exchange_horiz |
---|
143 | |
---|
144 | USE indices, & |
---|
145 | ONLY: nbgp, & |
---|
146 | nzb, & |
---|
147 | nzt, & |
---|
148 | nysg, & |
---|
149 | nyng, & |
---|
150 | nxlg, & |
---|
151 | nxrg |
---|
152 | |
---|
153 | USE land_surface_model_mod, & |
---|
154 | ONLY: lsm_energy_balance, & |
---|
155 | lsm_soil_model, & |
---|
156 | lsm_swap_timelevel |
---|
157 | |
---|
158 | USE pegrid |
---|
159 | |
---|
160 | #if defined( __parallel ) |
---|
161 | USE pmc_interface, & |
---|
162 | ONLY: nested_run |
---|
163 | #endif |
---|
164 | |
---|
165 | USE kinds |
---|
166 | |
---|
167 | USE palm_date_time_mod, & |
---|
168 | ONLY: get_date_time, & |
---|
169 | seconds_per_hour |
---|
170 | |
---|
171 | USE radiation_model_mod, & |
---|
172 | ONLY: dt_radiation, & |
---|
173 | force_radiation_call, & |
---|
174 | radiation, & |
---|
175 | radiation_control, & |
---|
176 | radiation_interaction, & |
---|
177 | radiation_interactions, & |
---|
178 | time_radiation |
---|
179 | |
---|
180 | USE statistics, & |
---|
181 | ONLY: flow_statistics_called |
---|
182 | |
---|
183 | USE surface_data_output_mod, & |
---|
184 | ONLY: dt_dosurf, & |
---|
185 | skip_time_dosurf, & |
---|
186 | surface_data_output, & |
---|
187 | time_dosurf |
---|
188 | |
---|
189 | USE surface_layer_fluxes_mod, & |
---|
190 | ONLY: surface_layer_fluxes |
---|
191 | |
---|
192 | USE surface_mod, & |
---|
193 | ONLY : surf_lsm_h, & |
---|
194 | surf_lsm_v, surf_usm_h, & |
---|
195 | surf_usm_v |
---|
196 | |
---|
197 | USE urban_surface_mod, & |
---|
198 | ONLY: usm_material_heat_model, & |
---|
199 | usm_material_model, & |
---|
200 | usm_surface_energy_balance, & |
---|
201 | usm_swap_timelevel, & |
---|
202 | usm_green_heat_model |
---|
203 | |
---|
204 | |
---|
205 | |
---|
206 | |
---|
207 | IMPLICIT NONE |
---|
208 | |
---|
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 !< |
---|
212 | |
---|
213 | |
---|
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 |
---|
228 | REAL(wp) :: pt_spinup !< temporary storage of temperature |
---|
229 | REAL(wp) :: second_of_day !< second of the day |
---|
230 | |
---|
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 |
---|
234 | |
---|
235 | |
---|
236 | ! |
---|
237 | !-- Save 3D arrays because they are to be changed for spinup purpose |
---|
238 | ALLOCATE( pt_save(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
239 | ALLOCATE( u_save(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
240 | ALLOCATE( v_save(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
241 | |
---|
242 | CALL exchange_horiz( pt, nbgp ) |
---|
243 | CALL exchange_horiz( u, nbgp ) |
---|
244 | CALL exchange_horiz( v, nbgp ) |
---|
245 | |
---|
246 | pt_save = pt |
---|
247 | u_save = u |
---|
248 | v_save = v |
---|
249 | |
---|
250 | ! |
---|
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. |
---|
254 | IF ( land_surface ) THEN |
---|
255 | DO m = 1, surf_lsm_h%ns |
---|
256 | i = surf_lsm_h%i(m) |
---|
257 | j = surf_lsm_h%j(m) |
---|
258 | k = surf_lsm_h%k(m) |
---|
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) |
---|
261 | ENDDO |
---|
262 | |
---|
263 | DO l = 0, 3 |
---|
264 | DO m = 1, surf_lsm_v(l)%ns |
---|
265 | i = surf_lsm_v(l)%i(m) |
---|
266 | j = surf_lsm_v(l)%j(m) |
---|
267 | k = surf_lsm_v(l)%k(m) |
---|
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) |
---|
270 | ENDDO |
---|
271 | ENDDO |
---|
272 | ENDIF |
---|
273 | |
---|
274 | IF ( urban_surface ) THEN |
---|
275 | DO m = 1, surf_usm_h%ns |
---|
276 | i = surf_usm_h%i(m) |
---|
277 | j = surf_usm_h%j(m) |
---|
278 | k = surf_usm_h%k(m) |
---|
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) |
---|
281 | ENDDO |
---|
282 | |
---|
283 | DO l = 0, 3 |
---|
284 | DO m = 1, surf_usm_v(l)%ns |
---|
285 | i = surf_usm_v(l)%i(m) |
---|
286 | j = surf_usm_v(l)%j(m) |
---|
287 | k = surf_usm_v(l)%k(m) |
---|
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) |
---|
290 | ENDDO |
---|
291 | ENDDO |
---|
292 | ENDIF |
---|
293 | |
---|
294 | CALL exchange_horiz( u, nbgp ) |
---|
295 | CALL exchange_horiz( v, nbgp ) |
---|
296 | |
---|
297 | dt_save = dt_3d |
---|
298 | dt_3d = dt_spinup |
---|
299 | |
---|
300 | CALL location_message( 'wall/soil spinup time-stepping', 'start' ) |
---|
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' ) |
---|
306 | |
---|
307 | ! |
---|
308 | !-- Start of intermediate step loop |
---|
309 | intermediate_timestep_count = 0 |
---|
310 | DO WHILE ( intermediate_timestep_count < intermediate_timestep_count_max ) |
---|
311 | |
---|
312 | intermediate_timestep_count = intermediate_timestep_count + 1 |
---|
313 | |
---|
314 | ! |
---|
315 | !-- Set the steering factors for the prognostic equations which depend on the timestep scheme |
---|
316 | CALL timestep_scheme_steering |
---|
317 | |
---|
318 | |
---|
319 | ! |
---|
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 ) |
---|
325 | |
---|
326 | pt_spinup = spinup_pt_mean + spinup_pt_amplitude * & |
---|
327 | solar_angle( day_of_year, second_of_day ) |
---|
328 | |
---|
329 | ! |
---|
330 | !-- Map air temperature to all grid points in the vicinity of a surface element |
---|
331 | IF ( land_surface ) THEN |
---|
332 | DO m = 1, surf_lsm_h%ns |
---|
333 | i = surf_lsm_h%i(m) |
---|
334 | j = surf_lsm_h%j(m) |
---|
335 | k = surf_lsm_h%k(m) |
---|
336 | pt(k,j,i) = pt_spinup |
---|
337 | ENDDO |
---|
338 | |
---|
339 | DO l = 0, 3 |
---|
340 | DO m = 1, surf_lsm_v(l)%ns |
---|
341 | i = surf_lsm_v(l)%i(m) |
---|
342 | j = surf_lsm_v(l)%j(m) |
---|
343 | k = surf_lsm_v(l)%k(m) |
---|
344 | pt(k,j,i) = pt_spinup |
---|
345 | ENDDO |
---|
346 | ENDDO |
---|
347 | ENDIF |
---|
348 | |
---|
349 | IF ( urban_surface ) THEN |
---|
350 | DO m = 1, surf_usm_h%ns |
---|
351 | i = surf_usm_h%i(m) |
---|
352 | j = surf_usm_h%j(m) |
---|
353 | k = surf_usm_h%k(m) |
---|
354 | pt(k,j,i) = pt_spinup |
---|
355 | !!!!!!!!!!!!!!!!HACK!!!!!!!!!!!!! |
---|
356 | surf_usm_h%pt1(m) = pt_spinup |
---|
357 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
358 | ENDDO |
---|
359 | |
---|
360 | DO l = 0, 3 |
---|
361 | DO m = 1, surf_usm_v(l)%ns |
---|
362 | i = surf_usm_v(l)%i(m) |
---|
363 | j = surf_usm_v(l)%j(m) |
---|
364 | k = surf_usm_v(l)%k(m) |
---|
365 | pt(k,j,i) = pt_spinup |
---|
366 | !!!!!!!!!!!!!!!!HACK!!!!!!!!!!!!! |
---|
367 | surf_usm_v(l)%pt1(m) = pt_spinup |
---|
368 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
369 | ENDDO |
---|
370 | ENDDO |
---|
371 | ENDIF |
---|
372 | |
---|
373 | CALL exchange_horiz( pt, nbgp ) |
---|
374 | |
---|
375 | |
---|
376 | ! |
---|
377 | !-- Swap the time levels in preparation for the next time step. |
---|
378 | timestep_count = timestep_count + 1 |
---|
379 | |
---|
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 |
---|
389 | CALL lsm_swap_timelevel ( MOD( timestep_count, 2 ) ) |
---|
390 | ENDIF |
---|
391 | |
---|
392 | IF ( urban_surface ) THEN |
---|
393 | CALL usm_swap_timelevel ( MOD( timestep_count, 2 ) ) |
---|
394 | ENDIF |
---|
395 | |
---|
396 | ! |
---|
397 | !-- If required, compute virtual potential temperature |
---|
398 | IF ( humidity ) THEN |
---|
399 | CALL compute_vpt |
---|
400 | ENDIF |
---|
401 | |
---|
402 | ! |
---|
403 | !-- Compute the diffusion quantities |
---|
404 | IF ( .NOT. constant_diffusion ) THEN |
---|
405 | |
---|
406 | ! |
---|
407 | !-- First the vertical (and horizontal) fluxes in the surface (constant flux) layer are |
---|
408 | !-- computed |
---|
409 | IF ( constant_flux_layer ) THEN |
---|
410 | CALL surface_layer_fluxes |
---|
411 | ENDIF |
---|
412 | |
---|
413 | ! |
---|
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 |
---|
417 | IF ( land_surface ) THEN |
---|
418 | |
---|
419 | ! |
---|
420 | !-- Call for horizontal upward-facing surfaces |
---|
421 | CALL lsm_energy_balance( .TRUE., -1 ) |
---|
422 | CALL lsm_soil_model( .TRUE., -1, calc_soil_moisture_during_spinup ) |
---|
423 | ! |
---|
424 | !-- Call for northward-facing surfaces |
---|
425 | CALL lsm_energy_balance( .FALSE., 0 ) |
---|
426 | CALL lsm_soil_model( .FALSE., 0, calc_soil_moisture_during_spinup ) |
---|
427 | ! |
---|
428 | !-- Call for southward-facing surfaces |
---|
429 | CALL lsm_energy_balance( .FALSE., 1 ) |
---|
430 | CALL lsm_soil_model( .FALSE., 1, calc_soil_moisture_during_spinup ) |
---|
431 | ! |
---|
432 | !-- Call for eastward-facing surfaces |
---|
433 | CALL lsm_energy_balance( .FALSE., 2 ) |
---|
434 | CALL lsm_soil_model( .FALSE., 2, calc_soil_moisture_during_spinup ) |
---|
435 | ! |
---|
436 | !-- Call for westward-facing surfaces |
---|
437 | CALL lsm_energy_balance( .FALSE., 3 ) |
---|
438 | CALL lsm_soil_model( .FALSE., 3, calc_soil_moisture_during_spinup ) |
---|
439 | |
---|
440 | ENDIF |
---|
441 | |
---|
442 | ! |
---|
443 | !-- If required, solve the energy balance for urban surfaces and run the material heat model |
---|
444 | IF (urban_surface) THEN |
---|
445 | |
---|
446 | CALL usm_surface_energy_balance( .TRUE. ) |
---|
447 | IF ( usm_material_model ) THEN |
---|
448 | CALL usm_green_heat_model |
---|
449 | CALL usm_material_heat_model( .TRUE. ) |
---|
450 | ENDIF |
---|
451 | |
---|
452 | ENDIF |
---|
453 | |
---|
454 | ENDIF |
---|
455 | |
---|
456 | ENDDO ! Intermediate step loop |
---|
457 | |
---|
458 | ! |
---|
459 | !-- If required, calculate radiative fluxes and heating rates |
---|
460 | IF ( radiation ) THEN |
---|
461 | |
---|
462 | time_radiation = time_radiation + dt_3d |
---|
463 | |
---|
464 | IF ( time_radiation >= dt_radiation .OR. force_radiation_call ) THEN |
---|
465 | |
---|
466 | IF ( .NOT. force_radiation_call ) THEN |
---|
467 | time_radiation = time_radiation - dt_radiation |
---|
468 | ENDIF |
---|
469 | |
---|
470 | CALL radiation_control |
---|
471 | |
---|
472 | IF ( radiation_interactions ) THEN |
---|
473 | CALL radiation_interaction |
---|
474 | ENDIF |
---|
475 | ENDIF |
---|
476 | ENDIF |
---|
477 | |
---|
478 | ! |
---|
479 | !-- Increase simulation time and output times |
---|
480 | current_timestep_number_spinup = current_timestep_number_spinup + 1 |
---|
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 | |
---|
486 | IF ( time_since_reference_point < 0.0_wp ) THEN |
---|
487 | sign_chr = '-' |
---|
488 | ELSE |
---|
489 | sign_chr = ' ' |
---|
490 | ENDIF |
---|
491 | |
---|
492 | |
---|
493 | IF ( data_output_during_spinup ) THEN |
---|
494 | IF ( simulated_time >= skip_time_do2d_xy ) THEN |
---|
495 | time_do2d_xy = time_do2d_xy + dt_3d |
---|
496 | ENDIF |
---|
497 | IF ( simulated_time >= skip_time_do3d ) THEN |
---|
498 | time_do3d = time_do3d + dt_3d |
---|
499 | ENDIF |
---|
500 | time_dots = time_dots + dt_3d |
---|
501 | IF ( simulated_time >= skip_time_dopr ) THEN |
---|
502 | time_dopr = time_dopr + dt_3d |
---|
503 | ENDIF |
---|
504 | IF ( surface_output ) THEN |
---|
505 | IF ( simulated_time >= skip_time_dosurf ) THEN |
---|
506 | time_dosurf = time_dosurf + dt_3d |
---|
507 | ENDIF |
---|
508 | ENDIF |
---|
509 | time_run_control = time_run_control + dt_3d |
---|
510 | |
---|
511 | ! |
---|
512 | !-- Carry out statistical analysis and output at the requested output times. |
---|
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. |
---|
515 | |
---|
516 | ! |
---|
517 | !-- Set a flag indicating that so far no statistics have been created for this time step |
---|
518 | flow_statistics_called = .FALSE. |
---|
519 | |
---|
520 | ! |
---|
521 | !-- If required, call flow_statistics for averaging in time |
---|
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 |
---|
526 | time_dopr_av = time_dopr_av + dt_3d |
---|
527 | IF ( time_dopr_av >= dt_averaging_input_pr ) THEN |
---|
528 | do_sum = .TRUE. |
---|
529 | time_dopr_av = MOD( time_dopr_av, MAX( dt_averaging_input_pr, dt_3d ) ) |
---|
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 |
---|
538 | time_dopr = MOD( time_dopr, MAX( dt_dopr, dt_3d ) ) |
---|
539 | time_dopr_av = 0.0_wp ! Due to averaging (see above) |
---|
540 | ENDIF |
---|
541 | |
---|
542 | ! |
---|
543 | !-- Output of time series |
---|
544 | IF ( time_dots >= dt_dots ) THEN |
---|
545 | CALL data_output_tseries |
---|
546 | time_dots = MOD( time_dots, MAX( dt_dots, dt_3d ) ) |
---|
547 | ENDIF |
---|
548 | |
---|
549 | ! |
---|
550 | !-- 2d-data output (cross-sections) |
---|
551 | IF ( time_do2d_xy >= dt_do2d_xy ) THEN |
---|
552 | CALL doq_calculate |
---|
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 |
---|
560 | CALL doq_calculate |
---|
561 | CALL data_output_3d( 0 ) |
---|
562 | time_do3d = MOD( time_do3d, MAX( dt_do3d, dt_3d ) ) |
---|
563 | ENDIF |
---|
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 |
---|
572 | |
---|
573 | ENDIF |
---|
574 | |
---|
575 | ! |
---|
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 |
---|
580 | ! CALL run_control |
---|
581 | ! IF ( time_run_control >= dt_run_control ) THEN |
---|
582 | ! time_run_control = MOD( time_run_control, MAX( dt_run_control, dt_3d ) ) |
---|
583 | ! ENDIF |
---|
584 | ! ENDIF |
---|
585 | |
---|
586 | CALL cpu_log( log_point_s(15), 'timesteps spinup', 'stop' ) |
---|
587 | |
---|
588 | |
---|
589 | ! |
---|
590 | !-- Run control output |
---|
591 | IF ( myid == 0 ) THEN |
---|
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 |
---|
601 | WRITE ( 15, 101 ) current_timestep_number_spinup, sign_chr, & |
---|
602 | time_since_reference_point_chr, dt_3d, pt_spinup |
---|
603 | ! |
---|
604 | !-- Write buffer contents to disc immediately |
---|
605 | FLUSH( 15 ) |
---|
606 | ENDIF |
---|
607 | |
---|
608 | |
---|
609 | |
---|
610 | ENDDO ! Time loop |
---|
611 | |
---|
612 | ! |
---|
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 |
---|
618 | |
---|
619 | ! |
---|
620 | !-- Reset time step |
---|
621 | dt_3d = dt_save |
---|
622 | |
---|
623 | DEALLOCATE(pt_save) |
---|
624 | DEALLOCATE(u_save) |
---|
625 | DEALLOCATE(v_save) |
---|
626 | |
---|
627 | #if defined( __parallel ) |
---|
628 | IF ( nested_run ) CALL MPI_BARRIER( MPI_COMM_WORLD, ierr ) |
---|
629 | #endif |
---|
630 | |
---|
631 | CALL location_message( 'wall/soil spinup time-stepping', 'finished' ) |
---|
632 | |
---|
633 | |
---|
634 | ! |
---|
635 | !-- Formats |
---|
636 | 100 FORMAT (///'Spinup control output:---------------------------------'// & |
---|
637 | 'ITER. HH:MM:SS DT PT(z_MO)---------------------------------') |
---|
638 | 101 FORMAT (I5,2X,A1,A9,1X,F6.2,3X,F6.2,2X,F6.2) |
---|
639 | |
---|
640 | CONTAINS |
---|
641 | |
---|
642 | ! |
---|
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 ) |
---|
647 | |
---|
648 | USE basic_constants_and_equations_mod, & |
---|
649 | ONLY: pi |
---|
650 | |
---|
651 | USE kinds |
---|
652 | |
---|
653 | USE radiation_model_mod, & |
---|
654 | ONLY: decl_1, & |
---|
655 | decl_2, & |
---|
656 | decl_3, & |
---|
657 | lat, & |
---|
658 | lon |
---|
659 | |
---|
660 | IMPLICIT NONE |
---|
661 | |
---|
662 | |
---|
663 | INTEGER(iwp), INTENT(IN) :: day_of_year !< day of the year |
---|
664 | |
---|
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 |
---|
669 | ! |
---|
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 |
---|
673 | |
---|
674 | ! |
---|
675 | !-- Calculate cosine of solar zenith angle |
---|
676 | solar_angle = SIN( lat ) * SIN( declination ) + COS( lat ) * COS( declination ) * & |
---|
677 | COS( hour_angle ) |
---|
678 | |
---|
679 | END FUNCTION solar_angle |
---|
680 | |
---|
681 | |
---|
682 | END SUBROUTINE time_integration_spinup |
---|