      subroutine gradt
*
*     solution of the cubic equation characteristic of the mixing length
*     theory  (u is essentially the ratio of radiative to convective
*     conductivities)  Bohm-Vitense version  (ML1)
*
      implicit double precision(a-h,o-z)

      common/c/az(3),z(3),taux,ts,ps,sm,rs,err,te,gs,rho,ol1x,rl1x,el1x
     1 ,atgx,rtgx,tl,pl,xmass,acu,am,bk,an0,pi
      common/grad/ drdtp(400),cp(400),ttg(400),drdtpx,cpx,pecx,ttgx,
     1 deptx,dpdr,dtdr,dmdr,dr,xr,xt,cv,drdptx

      u=pecx
      if ( u .lt. 1.e-10 ) then
         ttgx=atgx
         return
      elseif ( u .gt. 1.e+10 ) then
         ttgx=rtgx
         return
      endif

      q=368./729.*u**2
      r=4672./19683.*u**3+4./9.*u*(rtgx-atgx)
      s1=(r+(q**3+r**2)**0.5)**0.3333333
      s2=-q/s1

      if ( u .le. 1. ) then
         super=(s1+s2+19./27.*u)**2-u**2
         if ( super .le. 0. ) super=0.
         ttgx=atgx+super
         return
      else
         super=9.*(s1+s2-8./27.*u)**3/u/8.
         if ( super .le. 0. ) super=0.
         ttgx=rtgx-super
         return
      endif
      end 

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


