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

Last change on this file since 4456 was 4444, checked in by raasch, 4 years ago

bugfix: cpp-directives for serial mode added

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