      subroutine calt77(lpri,lun11,temp,den,m,
     $                       dtype77,itype77,cul,clu)
c
c  This rutine takes the coefficients in data type 77 (dtype77 reals
c  and itype77 integers) and returns the collisional transition rates
c  (in s-1) from the superlevel (cul) and to the superlevel (clu) from
c  the spectroscopic level given by itype77(3).
c  The wavelength for the transition is also given in wav
c  temp, den, and ic are the temperature, electron density
c  and effective charge of the ion respectively.
c      author: M. Bautista
c
      implicit none
c
      integer nptmpdim
      parameter (nptmpdim=200000)
c
      integer m
      real dtype77(m),temp,den,cul,clu,rne,rte,div,rm,rec1,rec2,
     $         gg,wav,rec,xt
      integer itype77(nptmpdim),nden,ntem,in,it,kt1,nl,k,nl1,nl2,il,
     $        lpri,lun11
c
      rne=log10(den)
      rte=log10(temp)
      nden=itype77(1)
      ntem=itype77(2)
      if (rne.gt.dtype77(nden)) then
c       print*,'DENSITY TOO HIGH AT CALT77'
c       print*,'z=',ic,' temp=',temp,' Ne=',den,nden,dtype77(nden)
       rne=dtype77(nden)
      endif
      if (rte.gt.(dtype77(nden+ntem)+1.)) then
c       print*,'TEMPERATURE TOO HIGH AT CALT77'
c       print*,'z=',ic,' temp=',temp,' Ne=',den
         rte=(dtype77(nden+ntem)+1.)
      endif
      if (rte.lt.(dtype77(nden+1)-1.)) then
       rte=dtype77(nden+1)-1.
      endif
c
      wav=dtype77(nden*ntem+nden+ntem+1)
      if (rne.le.dtype77(1)) then
       in=1
      else
       in=0
 5     in=in+1
       if (rne.ge.dtype77(in+1).and.in.lt.nden) goto 5
      endif
      if (rte.lt.dtype77(nden+1)) then
       it=1
      else
       it=0
 6     it=it+1
       if (it.ge.ntem) then
        it=ntem-1
       else
        if (rte.ge.dtype77(nden+it+1)) goto 6
       endif
      endif
c
      kt1=nden+ntem+(in-1)*ntem+it
      div=dtype77(nden+it+1)-dtype77(nden+it)
      rm=(dtype77(kt1+1)-dtype77(kt1))/(div+1.e-36)
      rec1=dtype77(kt1)+rm*(rte-dtype77(nden+it))
      kt1=kt1+ntem
      rm=(dtype77(kt1+1)-dtype77(kt1))/(dtype77(nden+it+1)-
     #    dtype77(nden+it)+1.e-36)
      rec2=dtype77(kt1)+rm*(rte-dtype77(nden+it))
c
      rm=(rec2-rec1)/(dtype77(in+1)-dtype77(in)+1.e-36)
      rec=rec1+rm*(rne-dtype77(in))
      if (lpri.ne.0) write (lun11,*)'in calt77:',
     $ temp,den,nden,ntem,rte,rne,wav,in,it,div,rm,
     $ rec1,rec2,rec
      cul=10.**rec
c
      nl=itype77(3)
      k=0
  7   k=k+1
      nl1=k*(k-1)/2+1
      nl2=(k+1)*k/2+1
      if (nl.ge.nl2) goto 7
      il=nl-nl1
      gg=float(2*il+1)*2.
      xt=1.43817e+8/wav/temp
      if (xt.lt.100) then
       clu=cul*exp(-xt)/gg
      else
       clu=0.e0
      endif
c
c
      return
      end
