        subroutine SUNLYS(LIGHTL,K2)
      include 'SIZE.INC'
      include 'GLOBAL.INC'
      include 'LOCAL.INC'
      include 'LOCAL1.INC'
      include 'LOCAL2.INC'
      include 'LOCAL3.INC'
      include 'SUNCOM.INC'
        real LIGHTL(NPX)
        integer I, II, ILM(7), ION, J, K, K2, KK, LAMKNT
      ICALL = ICALL+1
      call SUNDAT (K2)
      do 100 ION = 1, 7
         ILM(ION) = 0
100   continue
      do 180 J = 1, KOUNT
         if (TYPEG(J).eq.'B') go to 180
         do 110 ION = 1, 7
            AVELIT(ION) = 0.0
110      continue
         call BEER (LIGHTL,J,K2,ILM)
         II = -2
         do 170 K = 1, 7
            if (SPFLGG(K,K2).eq.0) go to 160
            if (ABSTOL(K).eq.0.) go to 130
            do 120 LAMKNT = 1, 46
               KDPL(K,J) = KDPL(K,J)+DFACG(J,NDAT)*WAVEL(LAMKNT)*ABSORG(
     &            LAMKNT,K,K2)
120         continue
            go to 140
130         continue
            if (KDPG(K,K2).gt.0.) KDPL(K,J) = KDPG(K,K2)*AVELIT(K)*(1.-
     &         0.056*CLOUDG(NDAT))*(191696.65+87054.63*cos(0.0349*LATG))
     &         /(191696.65+87054.63*cos(0.0349*RFLATG(K,K2)))
140         continue
            do 150 I = 1, 3
               KK = 3*K+II+I-1
               PHOTKL(J,K2) = PHOTKL(J,K2)+ALPHA(KK,J,K2)*KDPL(K,J)*
     &            QUANTG(I,K,K2)
150         continue
160         continue
            II = II+1
170      continue
         if (SINGSW) call SINGO2 (K2,J)
         if (K2.eq.KCHEM.and.SINCAL.lt.J.and..not.SINGSW)
     &       call SINGO2 (K2,J)
180   continue
      if (PHOXSW.or.K2.eq.KCHEM) call PHOX (K2,LIGHTL)
      return
      end
