


      subroutine patch_interactions(isrc_pat, ifld_pat, imgprob)

      include 'ctparm.inc'
      include 'ctgeom2.inc' 
      include 'speed.inc'

      integer isrc_pat, ifld_pat, imgprob
      integer np_pot, np_test, ifldpnt, isrcpnt
      integer numimgs, imgnum
      real uf, vf, us, vs
      real rfield(3), rsource(3,8), dist(8)
      real r, ak, pi
      complex cj
      integer iget_num_int_points, iget_images
      real eps
      data eps /1.e-3/

      common/kkk/ ak,pi


      cj = cmplx(0.,1.)
      np_pot  = iget_num_int_points(isrc_pat,2)
      np_test = iget_num_int_points(ifld_pat,1)

      do ifldpnt=0,np_test 
        call rvec_indexed(ifld_pat,ifldpnt,1,rfield)

        do isrcpnt=1,np_pot
          call rvec_indexed(isrc_pat,isrcpnt,2,rsource(1,1))
          numimgs = iget_images(imgprob,rsource(1,1),1)
          call get_r_mult(rfield,rsource(1,1),numimgs,dist)

          do imgnum=1,numimgs
            rimgs(imgnum,isrcpnt,ifldpnt) = dist(imgnum)
            r = rimgs(imgnum,isrcpnt,ifldpnt)
            if(r .gt. eps) then
              cg(imgnum,isrcpnt,ifldpnt) = cexp(-cj*ak*r)/r
            endif
          end do
        end do
      end do

      return
      end




      subroutine rvec_indexed(ipat,int_pt_ref,itype,r)

      include 'ctparm.inc'
      include 'speed.inc'

      integer ipat, int_pt_ref,itype
      real r(3)

      r(1) = r_vect(1,ipat,int_pt_ref,itype)
      r(2) = r_vect(2,ipat,int_pt_ref,itype)
      r(3) = r_vect(3,ipat,int_pt_ref,itype)


      return
      end
      
            
