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