c======================================================================

      subroutine taucor(w1,w2,w3,t1,t2,t3,amu,utau,cf) 1
c
c purpose: find a correction factor, cf, which corrects the
c  k-distribution optical depths so that 
c
c   w1*exp(-cf*t1/amu)+w2*exp(-cf*t2/amu)+w3*exp(-cf*t3/amu)=exp(-utau)
c
c input:
c 
c   w1,w2,w3    k-distribution weights
c   t1,t2,t3    k-distribution optical depths
c   amu         cosine of solar zenith
c   utau        optical depth along slant path due to line absorption
c
c output:
c   t1,t2,t3    modified optical depths
c
c  
      cf=1.
      do 10 i=1,20
        e1=exp(-cf*t1/amu)
        e2=exp(-cf*t2/amu)
        e3=exp(-cf*t3/amu)
        ff=w1*e1+w2*e2+w3*e3
        f=log(ff)+utau
        if(abs(f).lt..000001) goto 20
        fp=-(w1*e1*t1+w2*e2*t2+w3*e3*t3)/(ff*amu)
        dcf=-f/fp
        cf=cf+dcf
 10   continue
      write(*,'(8a12)') 'w1','w2','w3','t1','t2','t3','amu','utau'
      write(*,'(1p8e12.4)') w1,w2,w3,t1,t2,t3,amu,utau
      stop 'TAUCOR: iteration did not converge'
 20   continue
      return
      end