SURFEX v7.3
General documentation of Surfex
 All Classes Files Functions Variables Typedefs
/home/dasprezs/EXPORT_v7_3/src/SURFEX/sunpos.F90
Go to the documentation of this file.
00001 !     #########
00002       SUBROUTINE SUNPOS (KSIZE_OMP, KYEAR, KMONTH, KDAY, PTIME, &
00003                          PLON, PLAT, PTSUN, PZENITH, PAZIMSOL)
00004 !     ####################################################################################
00005 !
00006 !!****  *SUNPOS * - routine to compute the position of the sun
00007 !!
00008 !!    PURPOSE
00009 !!    -------
00010 !!      The purpose of this routine is to compute the cosine and sinus of the 
00011 !!    solar zenithal angle (angle defined by the local vertical at the position
00012 !!    XLAT, XLON and the direction of the sun) and the azimuthal solar
00013 !!    angle (angle between an horizontal direction (south or north according
00014 !!    to the terrestrial hemisphere) and the horizontal projection of the
00015 !!    direction of the sun.
00016 !!
00017 !!**  METHOD
00018 !!    ------
00019 !!      The cosine and sinus of the zenithal solar angle  and the azimuthal 
00020 !!    solar angle are computed from the true universal time, valid for the (XLAT,
00021 !!    XLON) location, and from the solar declination aPD_ICE(:)ngle of the day. There
00022 !!    is a special convention to define the azimuthal solar angle.
00023 !!     
00024 !!    EXTERNAL
00025 !!    --------
00026 !!      NONE
00027 !!
00028 !!    IMPLICIT ARGUMENTS
00029 !!    ------------------
00030 !!
00031 !!    REFERENCE
00032 !!    ---------
00033 !!      "Radiative Processes in Meteorology and Climatology"  
00034 !!                          (1976)   Paltridge and Platt 
00035 !!
00036 !!    AUTHOR
00037 !!    ------
00038 !!      J.-P. Pinty      * Laboratoire d'Aerologie*
00039 !!
00040 !!    MODIFICATIONS
00041 !!    -------------
00042 !!      Original             16/10/94 
00043 !!      Revised              12/09/95
00044 !!      (J.Stein)            01:04/96  bug correction for ZZEANG     
00045 !!      (K. Suhre)           14/02/97  bug correction for ZLON0     
00046 !!      (V. Masson)          01/03/03  add zenithal angle output
00047 !-------------------------------------------------------------------------------
00048 !
00049 !*       0.    DECLARATIONS
00050 !              ------------
00051 !
00052 USE MODD_CSTS,          ONLY : XPI, XDAY
00053 USE MODD_SURFEX_OMP, ONLY : NBLOCK, NBLOCKTOT, INIT_DIM
00054 !
00055 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
00056 USE PARKIND1  ,ONLY : JPRB
00057 !
00058 #ifdef AIX64
00059 USE OMP_LIB
00060 #endif
00061 !
00062 IMPLICIT NONE
00063 !
00064 #ifndef AIX64
00065 INCLUDE 'omp_lib.h'
00066 #endif
00067 !
00068 !*       0.1   Declarations of dummy arguments :
00069 !
00070 INTEGER, DIMENSION(:), INTENT(IN) :: KSIZE_OMP
00071 INTEGER,                      INTENT(IN)   :: KYEAR      ! current year                        
00072 INTEGER,                      INTENT(IN)   :: KMONTH     ! current month                        
00073 INTEGER,                      INTENT(IN)   :: KDAY       ! current day                        
00074 REAL,                         INTENT(IN)   :: PTIME      ! current time                        
00075 REAL, DIMENSION(:),           INTENT(IN)   :: PLON       ! longitude
00076 REAL, DIMENSION(:),           INTENT(IN)   :: PLAT       ! latutude
00077 !
00078 REAL, DIMENSION(:),           INTENT(OUT)  :: PZENITH    ! Solar zenithal angle
00079 REAL, DIMENSION(:),           INTENT(OUT)  :: PAZIMSOL   ! Solar azimuthal angle
00080 REAL, DIMENSION(:),           INTENT(OUT)  :: PTSUN      ! Solar time
00081 !
00082 !*       0.2   declarations of local variables
00083 !
00084 !
00085 REAL                                       :: ZUT        ! Universal time
00086 !
00087 REAL, DIMENSION(SIZE(PLON))                :: ZTUT    ,! True (absolute) Universal Time
00088                                                 ZSOLANG ,! Hourly solar angle
00089                                                 ZSINAZI ,! Sine of the solar azimuthal angle
00090                                                 ZCOSAZI ,! Cosine of the solar azimuthal angle
00091                                                 ZLAT,    
00092                                                 ZLON,    ! Array of latitudes and longitudes
00093                                                 ZSINZEN, !Sine of zenithal angle
00094                                                 ZCOSZEN   !Cosine of zenithal angle  
00095 INTEGER, DIMENSION(0:11)                   :: IBIS, INOBIS ! Cumulative number of days per month
00096                                                            ! for bissextile and regular years
00097 REAL                                       :: ZDATE         ! Julian day of the year
00098 REAL                                       :: ZAD           ! Angular Julian day of the year
00099 REAL                                       :: ZDECSOL       ! Daily solar declination angle 
00100 REAL                                       :: ZA1, ZA2      ! Ancillary variables
00101 REAL                                       :: ZTSIDER, 
00102                                                 ZSINDEL, !azimuthal angle
00103                                                 ZCOSDEL !azimuthal angle  
00104 !                                            
00105 INTEGER                                    :: JI, JJ, INKPROMA
00106 INTEGER    :: IINDX1, IINDX2
00107 REAL(KIND=JPRB) :: ZHOOK_HANDLE
00108 !
00109 !-------------------------------------------------------------------------------
00110 !
00111 !*       1.    TO COMPUTE THE TRUE SOLAR TIME
00112 !              -------------------------------
00113 !
00114 IF (LHOOK) CALL DR_HOOK('SUNPOS',0,ZHOOK_HANDLE)
00115 ZUT  = MOD( 24.0+MOD(PTIME/3600.,24.0),24.0 )
00116 
00117 INOBIS(:) = (/0,31,59,90,120,151,181,212,243,273,304,334/)
00118 IBIS(0:1) = INOBIS(0:1)
00119 DO JI=2,11
00120   IBIS(JI) = INOBIS(JI)+1
00121 END DO
00122 IF( MOD(KYEAR,4).EQ.0 .AND. (MOD(KYEAR,100).NE.0 .OR. MOD(KYEAR,400).EQ.0)) THEN
00123   ZDATE = FLOAT(KDAY +   IBIS(KMONTH-1)) - 1
00124   ZAD = 2.0*XPI*ZDATE/366.0
00125 ELSE
00126   ZDATE = FLOAT(KDAY + INOBIS(KMONTH-1)) - 1
00127   ZAD = 2.0*XPI*ZDATE/365.0
00128 END IF
00129 
00130 ZA1 = (1.00554*ZDATE- 6.28306)*(XPI/180.0)
00131 ZA2 = (1.93946*ZDATE+23.35089)*(XPI/180.0)
00132 ZTSIDER = (7.67825*SIN(ZA1)+10.09176*SIN(ZA2)) / 60.0
00133 !
00134 !-------------------------------------------------------------------------------
00135 !
00136 !*       2.     COMPUTE THE SOLAR DECLINATION ANGLE
00137 !               -----------------------------------
00138 !
00139 ZDECSOL = 0.006918-0.399912*COS(ZAD)   +0.070257*SIN(ZAD)    &
00140            -0.006758*COS(2.*ZAD)+0.000907*SIN(2.*ZAD) &
00141            -0.002697*COS(3.*ZAD)+0.00148 *SIN(3.*ZAD)  
00142 ZSINDEL = SIN(ZDECSOL)
00143 ZCOSDEL = COS(ZDECSOL)
00144 !-------------------------------------------------------------------------------
00145 !
00146 !$OMP PARALLEL PRIVATE(INKPROMA,IINDX1,IINDX2)
00147 !
00148 !$ NBLOCK = OMP_GET_THREAD_NUM()
00149 !
00150 IF (NBLOCK==NBLOCKTOT) THEN
00151   CALL INIT_DIM(KSIZE_OMP,0,INKPROMA,IINDX1,IINDX2)
00152 ELSE
00153   CALL INIT_DIM(KSIZE_OMP,NBLOCK,INKPROMA,IINDX1,IINDX2)
00154 ENDIF
00155 !
00156 DO JJ = IINDX1,IINDX2
00157 !
00158 !*       3.    LOADS THE ZLAT, ZLON ARRAYS
00159 !              ---------------------------
00160 !
00161   ZLAT(JJ) = PLAT(JJ)*(XPI/180.)
00162   ZLON(JJ) = PLON(JJ)*(XPI/180.)
00163 !
00164 !-------------------------------------------------------------------------------
00165 !
00166 !*       4.    COMPUTE THE TRUE SOLAR TIME
00167 !              ----------------------------
00168 !
00169   ZTUT(JJ) = ZUT - ZTSIDER + ZLON(JJ)*((180./XPI)/15.0)
00170 !
00171   PTSUN(JJ) = MOD(PTIME -ZTSIDER*3600. +PLON(JJ)*240., XDAY)
00172 !
00173 !-------------------------------------------------------------------------------
00174 !*       3.    COMPUTES THE COSINE AND SINUS OF THE ZENITHAL SOLAR ANGLE
00175 !              ---------------------------------------------------------
00176 !
00177   ZSOLANG(JJ) = (ZTUT(JJ)-12.0)*15.0*(XPI/180.)          ! hour angle in radians
00178 !
00179   ZCOSZEN(JJ) = SIN(ZLAT(JJ))*ZSINDEL +                 &! Cosine of the zenithal
00180                  COS(ZLAT(JJ))*ZCOSDEL*COS(ZSOLANG(JJ))  !       solar angle  
00181 !
00182   ZSINZEN(JJ)  = SQRT( 1. - ZCOSZEN(JJ)*ZCOSZEN(JJ) )
00183 !
00184 !-------------------------------------------------------------------------------
00185 !
00186 !*       5.    ZENITHAL SOLAR ANGLE
00187 !              --------------------
00188 !
00189   PZENITH(JJ) = ACOS(ZCOSZEN(JJ))
00190 !
00191 !-------------------------------------------------------------------------------
00192 !
00193 !*       6.    COMPUTE THE AZIMUTHAL SOLAR ANGLE (PAZIMSOL)
00194 !              --------------------------------------------
00195 !
00196   IF (ZSINZEN(JJ)/=0.) THEN
00197     !Azimuth is measured counter-opposite-clockwise from due south
00198     ZSINAZI(JJ)  = - ZCOSDEL * SIN(ZSOLANG(JJ)) / ZSINZEN(JJ)
00199     ZCOSAZI(JJ)  = (-SIN(ZLAT(JJ))*ZCOSDEL*COS(ZSOLANG(JJ))      &
00200                        +COS(ZLAT(JJ))*ZSINDEL                       &
00201                       ) / ZSINZEN(JJ)  
00202     PAZIMSOL(JJ) = ATAN2(ZSINAZI(JJ),ZCOSAZI(JJ))
00203   ELSE
00204     PAZIMSOL(JJ) = XPI
00205   ENDIF
00206 !
00207 ENDDO
00208 !
00209 !$OMP END PARALLEL
00210 !
00211 IF (LHOOK) CALL DR_HOOK('SUNPOS',1,ZHOOK_HANDLE)
00212 !-------------------------------------------------------------------------------
00213 !
00214 END SUBROUTINE SUNPOS