      subroutine calt71(temp,den,ic,m,dtype71,itype71,wav,aij,lun11,
     $                  lpri)
c
c  This rutine takes the coefficients in data type 71 (dtype71 reals
c  in itype71 integers) and returns the radiative transition prbability
c  (in s-1) from the superlevels to the spectroscopic level given by
c  itype71(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 dtype71(nptmpdim),wav,aij,temp,den,rne,rte,dtmp,rm,rec1,
     $     rec,rec2
      integer itype71(nptmpdim),lun11,lpri,nden,ntem,in,it,kt1,ic
      integer javi
c
      javi=m
      m=javi
c
      rne=log10(den)
      rte=log10(temp)
      nden=itype71(1)
      ntem=itype71(2)
      if (lpri.ne.0) write (lun11,*)'in calt71:',nden,ntem

      if (nden.eq.1 .and. ntem.eq.1) then
        if (dtype71(3).gt.30.) then
          dtmp=log10(dtype71(3))
        else
          dtmp=dtype71(3)
        endif
       wav=dtype71(4)
       aij=10.**dtmp
c       aij=min(aij,1.e+12)
       if (lpri.ne.0) write (lun11,*)'early return',aij,wav
       return
      endif
      if (rne.gt.dtype71(nden)) then
        if (lpri.ne.0) then
          write (lun11,*)'DENSITY TOO HIGH AT CALT71'
          write (lun11,*)'z=',ic,' temp=',temp,' Ne=',den,nden,
     $                   dtype71(nden)
          endif
        rne=min(rne,dtype71(nden))
      endif
      if (rte.gt.(dtype71(nden+ntem)+1.)) then
       rte=dtype71(nden+ntem)+1.
      endif
      if (rte.lt.(dtype71(nden+1)-1.)) then
       rte=dtype71(nden+1)-1.
      endif
c
      wav=dtype71(nden*ntem+nden+ntem+1)
      if (rne.le.dtype71(1)) then
       in=1
      else
       in=0
 5     in=in+1
       if (rne.ge.dtype71(in+1).and.in.lt.nden) goto 5
      endif
      if (rte.lt.dtype71(nden+1)) then
       it=1
      else
       it=0
 6     it=it+1
       if (it.ge.ntem) then
        it=ntem-1
       else
        if (rte.ge.dtype71(nden+it+1)) goto 6
       endif
      endif
      kt1=nden+ntem+(in-1)*ntem+it
      rm=(dtype71(kt1+1)-dtype71(kt1))/(dtype71(nden+it+1)-
     #    dtype71(nden+it))
      rec1=dtype71(kt1)+rm*(rte-dtype71(nden+it))
      kt1=kt1+ntem
      rm=(dtype71(kt1+1)-dtype71(kt1))/(dtype71(nden+it+1)-
     #    dtype71(nden+it))
      rec2=dtype71(kt1)+rm*(rte-dtype71(nden+it))
c
      rm=(rec2-rec1)/(dtype71(in+1)-dtype71(in))
      rec=rec1+rm*(rne-dtype71(in))
      aij=10.**rec
c      aij=min(aij,1.e+12)
      if (lpri.ne.0) write (lun11,*)'late return',rm,rec2,
     $       rec1,rec,aij,wav
c
      return
      end
