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

Last change on this file since 4631 was 4631, checked in by suehring, 4 years ago

Spinup: Set pt1 attribute only element-wise

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