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