source: palm/trunk/SOURCE/time_integration_spinup.f90 @ 4667

Last change on this file since 4667 was 4667, checked in by pavelkrc, 4 years ago

Limit vertical r_a in USM similarly to horizontal; improve debug messages

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