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