!$Id: diurnal_geom.F90 123 2009-03-27 10:38:52Z acosce $ !! ========================================================================= !! INCA - INteraction with Chemistry and Aerosols !! !! Copyright Laboratoire des Sciences du Climat et de l'Environnement (LSCE) !! Unite mixte CEA-CNRS-UVSQ !! !! Contributors to this INCA subroutine: !! !! Stacy Walters, NCAR, stacy@ucar.edu !! !! Anne Cozic, LSCE, anne.cozic@cea.fr !! Yann Meurdesoif, LSCE, yann.meurdesoif@cea.fr !! !! This software is a computer program whose purpose is to simulate the !! atmospheric gas phase and aerosol composition. The model is designed to be !! used within a transport model or a general circulation model. This version !! of INCA was designed to be coupled to the LMDz GCM. LMDz-INCA accounts !! for emissions, transport (resolved and sub-grid scale), photochemical !! transformations, and scavenging (dry deposition and washout) of chemical !! species and aerosols interactively in the GCM. Several versions of the INCA !! model are currently used depending on the envisaged applications with the !! chemistry-climate model. !! !! This software is governed by the CeCILL license under French law and !! abiding by the rules of distribution of free software. You can use, !! modify and/ or redistribute the software under the terms of the CeCILL !! license as circulated by CEA, CNRS and INRIA at the following URL !! "http://www.cecill.info". !! !! As a counterpart to the access to the source code and rights to copy, !! modify and redistribute granted by the license, users are provided only !! with a limited warranty and the software's author, the holder of the !! economic rights, and the successive licensors have only limited !! liability. !! !! In this respect, the user's attention is drawn to the risks associated !! with loading, using, modifying and/or developing or reproducing the !! software by the user in light of its specific status of free software, !! that may mean that it is complicated to manipulate, and that also !! therefore means that it is reserved for developers and experienced !! professionals having in-depth computer knowledge. Users are therefore !! encouraged to load and test the software's suitability as regards their !! requirements in conditions enabling the security of their systems and/or !! data to be ensured and, more generally, to use and operate it in the !! same conditions as regards security. !! !! The fact that you are presently reading this means that you have had !! knowledge of the CeCILL license and that you accept its terms. !! ========================================================================= #include SUBROUTINE DIURNAL_GEOM( & lat ,& time_of_year ,& polar_night ,& polar_day ,& sunon ,& sunoff ,& loc_angle ,& zen_angle ,& zangtz ) ! Stacy Walters, NCAR, 1998. USE CONST_MOD USE CHEM_CONS, ONLY : dayspy, d2r, phi, lambda USE INCA_DIM IMPLICIT NONE !------------------------------------------------------------------ ! ... Dummy arguments !------------------------------------------------------------------ INTEGER, INTENT(in) :: lat ! latitude index REAL, INTENT(in) :: time_of_year ! time of year REAL, INTENT(out) :: sunon(PLON) ! sunrise angle in radians REAL, INTENT(out) :: sunoff(PLON) ! sunset angle in radians REAL, INTENT(out) :: zen_angle(PLON) ! solar zenith angle REAL, INTENT(out) :: loc_angle(PLON) ! "local" time angle LOGICAL, INTENT(out) :: polar_day(PLON) ! continuous daylight flag LOGICAL, INTENT(out) :: polar_night(PLON) ! continuous night flag LOGICAL, INTENT(out) :: zangtz(PLON) !------------------------------------------------------------------ ! ... Local variables !------------------------------------------------------------------ INTEGER :: i, k REAL, SAVE :: twopi, pid2, dec_max !$OMP THREADPRIVATE(twopi, pid2, dec_max) REAL :: declination REAL :: latitude, longitude REAL :: doy ! day of year REAL :: tod ! time of day REAL :: sin_dec, cos_dec ! sin, cos declination REAL :: cosphi ! cos latitude REAL :: sinphi ! sin latitude LOGICAL, SAVE :: entered = .FALSE. !$OMP THREADPRIVATE(entered) sunon(:) = 0. sunoff(:) = 0. IF( .NOT. entered ) THEN twopi = 2. * pi pid2 = .5 * pi dec_max = 23.45 * d2r entered = .TRUE. END IF !------------------------------------------------------------------ ! Note: this formula assumes a 365 day year (inconsistent ! with 360 in LMDz!!!) !------------------------------------------------------------------ doy = AINT( time_of_year ) declination = dec_max * COS((doy - 172.)*twopi/dayspy) !------------------------------------------------------------------ ! ... Compute base for zenith angle !------------------------------------------------------------------ tod = (time_of_year - doy) + .5 DO k = 1, PLON latitude = phi(k) longitude = lambda(k) sinphi = SIN( latitude ) cosphi = COS( latitude ) polar_day(k) = .FALSE. polar_night(k) = .FALSE. !------------------------------------------------------------------ ! Determine if in polar day or night ! If NOT in polar day or night then ! calculate terminator longitudes !------------------------------------------------------------------ IF( ABS(latitude) >= (pid2 - ABS(declination)) ) THEN IF( SIGN(1.,declination) == SIGN(1.,latitude) ) THEN polar_day(k) = .TRUE. sunoff(k) = 2.*twopi sunon(k) = -twopi ELSE polar_night(k) = .TRUE. zen_angle(k) = -1.0 CYCLE END IF ELSE sunoff(k) = ACOS( -TAN(declination)*TAN(latitude) ) sunon(k) = twopi - sunoff(k) END IF sin_dec = SIN( declination ) cos_dec = COS( declination ) !------------------------------------------------------------------- ! Note: Longitude 0 (Greenwich) at 0:00 hrs ! maps to local angle = pi !------------------------------------------------------------------- loc_angle(k) = (tod + longitude/twopi)*twopi loc_angle(k) = MOD( loc_angle(k)+twopi,twopi ) IF( polar_day(k) ) THEN zen_angle(k) = ACOS( sinphi*sin_dec + & cosphi*cos_dec*COS(loc_angle(k)) ) ELSE IF ( loc_angle(k) <= sunoff(k) .OR. & loc_angle(k) >= sunon(k) ) THEN zen_angle(k) = ACOS( sinphi*sin_dec + & cosphi*cos_dec*COS(loc_angle(k)) ) ELSE zen_angle(k) = -1.0 ENDIF END IF END DO zangtz(:) = zen_angle(:) > 0. END SUBROUTINE DIURNAL_GEOM