      subroutine gradt2
*
*     solution of the cubic equation characteristic of the mixing length
*     theory  (u is essentially the ratio of radiative to convective
*     conductivities)  Bohm & Cassinelli version (ML2 or ML3)
*
      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
*
* ml2 (and ml3) versions use different constants in q and r.
*
      q=17./81.*u**2
      r=26./729.*u**3+1./6.*u*(rtgx-atgx)
      s1=(r+(q**3+r**2)**0.5)**0.3333333
      s2=-q/s1

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

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

