      function opac3(rhol,tl)
*
*  this acts like opac, but interpolates between opacities.
*  the vector x(1-3) must be set for this to work!
*  13 Nov 89 MAW
*  Added in calls to opacder under certain conditions. 4-91 PAB
*
      implicit double precision(a-h,o-z)
      common/opacfin/ifinal
      common/je/je
      common/comp/amhyhe,amheca,x(4)
      real*8 z(3),az(3)
*
* initialize constants
*
      az(1)=1.0
      az(2)=4.0
      az(3)=12.0
      z(1)=1.0
      z(2)=2.0
      z(3)=6.0
      opl = 0.
      jesav = je
*
* pure composition (comp. > 0.999) 
*
      do 50 i = 1,3
        xx = x(i)
        if(xx .gt. 0.999)then
          je = i
          if(ifinal.eq.0)then
 	    opac3 = opac(rhol,tl)
           else
            call opacder(rhol,tl,opcs,dlklr,dlklt)
            opac3 = opcs
          endif
          je = jesav
          return
        endif
50	continue
*
* mixtures
*
	do 100 i = 1,3
	   xje = x(i)
	   if ( xje.gt. 0.001) then
	     je = i
             opl = opl + xje * 10.**opac(rhol,tl)
	   endif
100	continue
	je = jesav
        opac3   = dlog10(opl)

999     return
	end

************************************************************************

