      subroutine read1
*
*  read in the Heubner opacities and the envelope eos.
*  then compute the optical depths.
*
      implicit double precision(a-h,o-z)

      dimension dummy(7)
      common/tenv/rhok(3,60,35),eta(3,60,35),pp(3,60,35),datg(3,60,35),
     1 od(3,18,35),tk(3,60),uu(3,60,35),xtt(3,60,35),xrt(3,60,35)
      common/je/je
      common/comp/amhyhe,amheca,x(4)
      common/comptmp/amhyhe_tmp,amheca_tmp
      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/d/ ml(3,60),nmax,kind,lmax,nsuff,nlim,nlim1,j,iter,lmam, 
     1 nlum,ko,nhp
      common/opacs/cso(3,29,8),csr(29),cst(29)
      common/dirac/ psi(141),f12(141),f32(141)
      common/ac/ac(6)
      common/ao/ao(6)
      common/alpha/alph(4),qmix1,qmix2,zone(2,2)
      common/opacfin/ifinal
      common/opcswch/first
      logical first
*
*  melting coefficients for carbon.
*
      data ac/1.24605188e3,-9.32465995e2,2.776543312e2,-4.080201741e1,
     1       2.979129728e0,-8.665569421e-2/
*
*  melting coefficients for oxygen from a fit to the output of
*  xtal for temps in the range 5.4 < log(t) < 8.0.
*
      data ao/-2513.772484, 1823.347553, -528.588773, 76.834498,
     1       -5.580515, 0.161850/
*
* format statements 
*
2     format(i5,i3,f7.4,2i3)
31    format(1x,f5.1,2(1x,f10.6),40x)
1004  format(f16.6,8f8.2)
1005  format(8f10.4)
1006  format(1p,2e12.2,0p,4f8.4,' < amhyhe, amheca, alph(1-4)')
*
*     read the mass boundaries and alpha's for diffusion calculation
* (changed, now read from input (first line))
*
      read(7,*) amhyhe_dum,amheca_dum, alph(1),alph(2),alph(3),alph(4)

*** transfer H and He boundaries from COMMON block ***
      amhyhe = amhyhe_tmp
      amheca = amheca_tmp
*
*     read control parameters and the atomic number z and mass az
*     for hydrogen, helium, and carbon. 
*
      read(15,2) nmax,lmax,err,lmam,nlum 
      first = .true.
      ifinal = 0
      az(1)=1.0
      az(2)=4.0
      az(3)=12.0
      z(1)=1.0
      z(2)=2.0
      z(3)=6.0
*
*     define the eos grid
*
      do 200 nel = 1,3
        lunit = nel + 1
          read ( lunit, * ) dum
        do 175 l = 1, lmax
          read (lunit,*) ml(nel,l)
          kmax = ml(nel,l)
          do 150 k = 1,kmax 
            read (lunit,*) tk(nel,l),rhok(nel,l,k),pp(nel,l,k),
     1        uu(nel,l,k),xtt(nel,l,k),xrt(nel,l,k),
     2        datg(nel,l,k),eta(nel,l,k) 
150       continue
175     continue
        rewind lunit
200   continue
*
* read the Heubner radiative opacities cso on the density-
* temperature grid csr-cst
* Used to be Cox-Stewart opacities.
*
      read(15,1004) (cst(l),csr(l),dummy,l=1,29)
      read(15,1005) (((cso(jm,l,k),k=1,8),l=1,29),jm=1,3)
*
* compute optical depths(log) od for first lmam isotherms
*
      gs=1.e+08
      do 23 jm=1,3
        je=jm
        do 22 l=1,lmam
          kmax=ml(jm,l)
          tau=10.**(opac(rhok(jm,l,1),tk(jm,l))+pp(jm,l,1))/gs*0.5
          od(jm,l,1)=dlog10(tau)
          do 21 k=2,kmax
            tau=tau+0.5/gs*(10.**pp(jm,l,k)-10.**pp(jm,l,k-1))
     1            *(10.**opac(rhok(jm,l,k),tk(jm,l))
     2            +10.**opac(rhok(jm,l,k-1),tk(jm,l)))
            od(jm,l,k)=dlog10(tau)
21        continue
22      continue
23    continue
*
*     read fermi-dirac f12,f32 functions in the range of degeneracy
*     parameter -4 < psi < 10 
*
      do 30 k=1,141 
        read(15,31) psi(k),f32(k),f12(k)
30    continue

      return
      end 

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

