      subroutine ccf(waveln,sza,tcl,rsurf,pt,ct,success)
      real*8  waveln, sza, tcl, rsurf, pt, ct
      logical success
      integer*4 lam0, lamn, lamx, ilam, klam
      integer*4 sza0, szan, szax, isza, ksza
      integer*4 tcl0, tcln, tclx, itcl, ktcl
      integer*4 rs0, rsn, rsx, irs, krs
      integer*4 ipt, kpt
      real*8    lamden(0:3), szaden(0:3), tclden(0:3), rsden(0:3)
      real*8    pt_coef(0:1)
      real*8    sum, prod, plam, psza, ptcl, prs, ppt
      include "ccf.cmn"
c     ---
      call int_rang(waveln, lam_t, nlam_t, lam0, lamn, lamden, lamx)
      call int_rang(sza, sza_t, nsza_t, sza0, szan, szaden, szax)
      call int_rang(tcl, tcl_t, ntcl_t, tcl0, tcln, tclden, tclx)
      call int_rang(rsurf, rs_t, nrs_t, rs0, rsn, rsden, rsx)
      pt_coef(0)= (pt - pt_t(0))/(pt_t(1)-pt_t(0))
      pt_coef(1)= (pt_t(1) - pt)/(pt_t(1)-pt_t(0))
      sum=0.
      do ilam= 0, lamn
         plam= 1./lamden(ilam) 
         do klam= 0, lamn
            if (klam .ne. ilam) plam=plam*(waveln-lam_t(lam0+klam))
         enddo
         do isza= 0, szan
            psza= 1./szaden(isza)
            do ksza= 0, szan
               if (ksza .ne. isza) psza=psza*(sza-sza_t(sza0+ksza))
            end do
            do itcl= 0, tcln
               ptcl= 1./tclden(itcl)
               do ktcl= 0, tcln
                  if (ktcl .ne. itcl) ptcl=ptcl*(tcl-tcl_t(tcl0+ktcl))
               enddo
               do irs= 0, rsn
                  prs= 1./rsden(irs)
                  do krs= 0, rsn
                     if (krs .ne. irs) prs=prs*(rsurf-rs_t(rs0+krs))
                  enddo
                  do ipt= 0, 1
                     ppt= pt_coef(ipt)
                     prod= plam*psza*ptcl*prs*ppt
                     sum= sum + prod *
     1                ccftab(lam0+ilam,sza0+isza,tcl0+itcl,rs0+irs,ipt)
                  enddo
               enddo
            enddo
         enddo
      enddo
      ct=sum
      success=.true.
      return
      end
