source: CONFIG/publications/ICOLMDZORINCA_CO2_Transport_GMD_2023/INCA/src/INCA_SRC/diurnal_geom.F90 @ 6610

Last change on this file since 6610 was 6610, checked in by acosce, 10 months ago

INCA used for ICOLMDZORINCA_CO2_Transport_GMD_2023

File size: 6.9 KB
Line 
1!$Id: diurnal_geom.F90 123 2009-03-27 10:38:52Z acosce $
2!! =========================================================================
3!! INCA - INteraction with Chemistry and Aerosols
4!!
5!! Copyright Laboratoire des Sciences du Climat et de l'Environnement (LSCE)
6!!           Unite mixte CEA-CNRS-UVSQ
7!!
8!! Contributors to this INCA subroutine:
9!!
10!! Stacy Walters, NCAR, stacy@ucar.edu
11!!
12!! Anne Cozic, LSCE, anne.cozic@cea.fr
13!! Yann Meurdesoif, LSCE, yann.meurdesoif@cea.fr
14!!
15!! This software is a computer program whose purpose is to simulate the
16!! atmospheric gas phase and aerosol composition. The model is designed to be
17!! used within a transport model or a general circulation model. This version
18!! of INCA was designed to be coupled to the LMDz GCM. LMDz-INCA accounts
19!! for emissions, transport (resolved and sub-grid scale), photochemical
20!! transformations, and scavenging (dry deposition and washout) of chemical
21!! species and aerosols interactively in the GCM. Several versions of the INCA
22!! model are currently used depending on the envisaged applications with the
23!! chemistry-climate model.
24!!
25!! This software is governed by the CeCILL  license under French law and
26!! abiding by the rules of distribution of free software.  You can  use,
27!! modify and/ or redistribute the software under the terms of the CeCILL
28!! license as circulated by CEA, CNRS and INRIA at the following URL
29!! "http://www.cecill.info".
30!!
31!! As a counterpart to the access to the source code and  rights to copy,
32!! modify and redistribute granted by the license, users are provided only
33!! with a limited warranty  and the software's author,  the holder of the
34!! economic rights,  and the successive licensors  have only  limited
35!! liability.
36!!
37!! In this respect, the user's attention is drawn to the risks associated
38!! with loading,  using,  modifying and/or developing or reproducing the
39!! software by the user in light of its specific status of free software,
40!! that may mean  that it is complicated to manipulate,  and  that  also
41!! therefore means  that it is reserved for developers  and  experienced
42!! professionals having in-depth computer knowledge. Users are therefore
43!! encouraged to load and test the software's suitability as regards their
44!! requirements in conditions enabling the security of their systems and/or
45!! data to be ensured and,  more generally, to use and operate it in the
46!! same conditions as regards security.
47!!
48!! The fact that you are presently reading this means that you have had
49!! knowledge of the CeCILL license and that you accept its terms.
50!! =========================================================================
51
52#include <inca_define.h>
53
54SUBROUTINE DIURNAL_GEOM(  &
55   lat                      ,&
56   time_of_year             ,&
57   polar_night              ,&
58   polar_day                ,&
59   sunon                    ,&
60   sunoff                   ,&
61   loc_angle                ,& 
62   zen_angle                ,&
63   zangtz )
64 
65  !    Stacy Walters, NCAR, 1998.
66
67  USE CONST_MOD
68  USE CHEM_CONS, ONLY : dayspy, d2r, phi, lambda
69  USE INCA_DIM
70 
71  IMPLICIT NONE
72
73  !------------------------------------------------------------------
74  !     ... Dummy arguments
75  !------------------------------------------------------------------
76  INTEGER, INTENT(in)  ::     lat                ! latitude index
77  REAL, INTENT(in)     ::     time_of_year       ! time of year
78  REAL, INTENT(out)    ::     sunon(PLON)        ! sunrise angle in radians
79  REAL, INTENT(out)    ::     sunoff(PLON)       ! sunset angle in radians
80  REAL, INTENT(out)    ::     zen_angle(PLON)    ! solar zenith angle
81  REAL, INTENT(out)    ::     loc_angle(PLON)    ! "local" time angle
82  LOGICAL, INTENT(out) ::     polar_day(PLON)    ! continuous daylight flag
83  LOGICAL, INTENT(out) ::     polar_night(PLON)  ! continuous night flag
84  LOGICAL, INTENT(out) ::     zangtz(PLON)
85 
86  !------------------------------------------------------------------
87  !        ... Local variables
88  !------------------------------------------------------------------
89  INTEGER :: i, k
90  REAL, SAVE    :: twopi, pid2, dec_max
91!$OMP THREADPRIVATE(twopi, pid2, dec_max)
92  REAL    ::  declination
93  REAL    ::  latitude, longitude
94  REAL    ::  doy                ! day of year
95  REAL    ::  tod                ! time of day
96  REAL    ::  sin_dec, cos_dec   ! sin, cos declination
97  REAL    ::  cosphi             ! cos latitude
98  REAL    ::  sinphi             ! sin latitude
99  LOGICAL, SAVE :: entered = .FALSE.
100!$OMP THREADPRIVATE(entered)
101
102
103  sunon(:) = 0. 
104  sunoff(:) = 0. 
105 
106
107  IF( .NOT. entered ) THEN
108      twopi = 2. * pi
109      pid2  = .5 * pi
110      dec_max = 23.45 * d2r
111      entered = .TRUE.
112  END IF
113
114  !------------------------------------------------------------------
115  !        Note: this formula assumes a 365 day year (inconsistent
116  !        with 360 in LMDz!!!)
117  !------------------------------------------------------------------
118  doy = AINT( time_of_year )
119  declination = dec_max * COS((doy - 172.)*twopi/dayspy)
120
121  !------------------------------------------------------------------
122  !     ... Compute base for zenith angle
123  !------------------------------------------------------------------
124  tod = (time_of_year - doy) + .5
125
126  DO k = 1, PLON
127
128    latitude  = phi(k)
129    longitude = lambda(k)
130    sinphi = SIN( latitude )
131    cosphi = COS( latitude )
132    polar_day(k) = .FALSE.
133    polar_night(k) = .FALSE.
134    !------------------------------------------------------------------
135    !        Determine if in polar day or night
136    !        If NOT in polar day or night then
137    !        calculate terminator longitudes
138    !------------------------------------------------------------------
139    IF( ABS(latitude) >= (pid2 - ABS(declination)) ) THEN
140        IF( SIGN(1.,declination) == SIGN(1.,latitude) ) THEN
141            polar_day(k) = .TRUE.
142            sunoff(k) = 2.*twopi
143            sunon(k)  = -twopi
144        ELSE
145            polar_night(k) = .TRUE.
146            zen_angle(k) = -1.0
147            CYCLE
148        END IF
149    ELSE
150        sunoff(k) = ACOS( -TAN(declination)*TAN(latitude) )
151        sunon(k)  = twopi - sunoff(k)
152    END IF
153
154    sin_dec = SIN( declination )
155    cos_dec = COS( declination )
156    !-------------------------------------------------------------------
157    !        Note: Longitude 0 (Greenwich) at 0:00 hrs
158    !              maps to local angle = pi
159    !-------------------------------------------------------------------
160    loc_angle(k) = (tod + longitude/twopi)*twopi
161    loc_angle(k) = MOD( loc_angle(k)+twopi,twopi )
162   
163    IF( polar_day(k) ) THEN
164        zen_angle(k) = ACOS( sinphi*sin_dec + & 
165           cosphi*cos_dec*COS(loc_angle(k)) )
166    ELSE
167        IF ( loc_angle(k) <= sunoff(k) .OR. &
168           loc_angle(k) >= sunon(k) ) THEN
169            zen_angle(k) = ACOS( sinphi*sin_dec + & 
170               cosphi*cos_dec*COS(loc_angle(k)) )
171        ELSE
172            zen_angle(k) = -1.0
173        ENDIF
174    END IF
175   
176  END DO
177
178  zangtz(:) = zen_angle(:) > 0.
179
180END SUBROUTINE DIURNAL_GEOM
181
Note: See TracBrowser for help on using the repository browser.