      subroutine calt70(temp,den,eth,ic,m,dtype70,itype70,
     1                  nx,xe,xs,rec,al,lun11,lpri)
c
c  This routine takes the coefficients in data type 70 (dtype70 reals
c  in itype70 integers) and returns the recombination rate (in s-1cm-3)
c  and the correstpondent phot. x-section for the superlevel. m is the
c  dimension of dtype70. nx is the number of points in the x-section
c  xe() contains the photon energy in Ry and xx() is the x-section
c  in Mb.
c  temp, den, and ic are the temperature, electron density
c  and effective charge of the ion respectively.
c  eth is the threshold energy for the superlevel in Ry.
c      author: M. Bautista
c

       implicit none
c
      integer nptmpdim
      parameter (nptmpdim=200000)
      include './PARAM'
c
      integer m
      real dtype70(nptmpdim),xe(nptmpdim),xs(nptmpdim),rne,rte,rm,
     $      rec1,rec2,rec,scale,al,crit,temp,den,eth,dt
      integer itype70(nptmpdim),nden,ntem,nxs,in,it,kt1,i1,imax,nx,
     $      lun11,lpri,lprim,ic,i
c
c     alpf: fitting coef. for hydrogenic recombination n=12,l=0
c      dimension alpf(3)
c      data alpf/-7.1094841E-02,-9.0274535E-02,-14.26129/
c
      if (lpri.gt.1)
     $  write (lun11,*)'in calt70:',temp,den,eth,ic,m,dtype70(1),
     $                  itype70(1)
      rne=log10(den)
      rte=log10(temp)
      nden=itype70(1)
      ntem=itype70(2)
      nxs=itype70(3)
      if (nden.gt.1) then
      if (rne.gt.dtype70(nden)) then
       write (lun11,*)'DENSITY TOO HIGH AT SUPREC'
       write (lun11,*)'z=',ic,' temp=',temp,' Ne=',den
       stop
      endif
      if (rne.le.dtype70(1)) then
       in=1
      else
       in=int(rne/dtype70(nden)*nden)-1
       if (in.ge.nden) in=in-1
 5     in=in+1
       if (in.lt.nden .and. rne.ge.dtype70(in+1)) goto 5
       if (rne.lt.dtype70(in)) then
        in=in-2
        goto 5
       endif
      endif
      else
       in=1
      endif
      if (rte.lt.dtype70(nden+1)) then
       it=1
      else
       dt=(dtype70(nden+ntem)-dtype70(nden+1))/float(ntem)
       it=int((rte-dtype70(nden+1))/dt)
 6     it=it+1
       if (it.ge.ntem) then
        it=ntem-1
       else
        if (rte.ge.dtype70(nden+it+1)) goto 6
        if (rte.lt.dtype70(nden+it)) then
         it=it-2
         goto 6
        endif
       endif
      endif
      kt1=nden+ntem+(in-1)*ntem+it
      rm=(dtype70(kt1+1)-dtype70(kt1))/(dtype70(nden+it+1)-
     #    dtype70(nden+it))
      rec1=dtype70(kt1)+rm*(rte-dtype70(nden+it))
      if (nden.gt.1) then
       kt1=kt1+ntem
       rm=(dtype70(kt1+1)-dtype70(kt1))/(dtype70(nden+it+1)-
     #    dtype70(nden+it))
       rec2=dtype70(kt1)+rm*(rte-dtype70(nden+it))
       rm=(rec2-rec1)/(dtype70(in+1)-dtype70(in))
       rec=rec1+rm*(rne-dtype70(in))
      else
       rec=rec1
      endif
      if (lpri.gt.1) write (lun11,*)nden,ntem,it,in,kt1,
     $             dtype70(kt1),rm,rec2,rec1,rec
      rec=10.**rec
c
      i1=ntem*nden+ntem+nden
      do i=1,nxs
       xe(i)=dtype70(i1+(i-1)*2+1)
       xs(i)=dtype70(i1+(i-1)*2+2)
      if (lpri.gt.1)
     $  write (lun11,*)i,xe(i),xs(i)
      enddo
      lprim=0
      call milne(temp,nxs,xe,xs,eth,al,lun11,lprim)
      scale=rec/(1.e-24+al)
      if (lpri.gt.1)
     $ write (lun11,*)'in calt70:',rec,al,scale,xs(1),nxs,eth
      crit=1.e-6
      imax=nxs
      do i=1,nxs
       xs(i)=xs(i)*scale
       xs(i)=min(xs(i),1000000.)
       if (xs(i).gt.xs(1)*crit) imax=i
      if (lpri.gt.1)
     $  write (lun11,*)i,xe(i),xs(i)
      enddo
      nxs=imax
      nx=nxs
c
      return
      end
