

      subroutine pots_wire( ifield, utest, vtest, isourc, inode, 
     &         cvpot, cspot, imgprob)

      include 'ctparm.inc'
      include 'ctgeom.inc'
      include 'ctgeomwire.inc'

      integer ifield, isourc, inode, imgprob
      real utest, vtest
      complex cvpot(3), cspot, cg
      complex cj
      real ru(3), rv(3), ruu(3), rvv(3), ruv(3)
      real ak, pi, a, u, v, deltal, us, vs, delt
      real basis(3,8), divbasis(8)
      real posfield(3), posvects(3,8), r(8)
      integer k, np, i
      integer numimgs, imgnum, ii
      real vecmag, get_r, fget_divbasis
      integer iget_images, iget_div_images

      common /kkk/ ak, pi

c source patch is known to be a wire. field patch could be either a
c  wire or a triangular patch

      cspot = cmplx(0.,0.)
      do k=1,3
        cvpot(k) = cmplx(0.,0.)
      end do

      cj = cmplx(0.,1.)
      a = radius(isourc)

      u = datctr(1,isourc)
      v = datctr(2,isourc)
      call tanvecs(isourc,u,v,ru,rv,ruu,rvv,ruv)
      deltal = vecmag(ru)

      vs = 0.
      np = 10
      delt = 1./np
      call rvec(ifield,utest,vtest,posfield)

      do i=1,np
        us = delt/2. + (i-1)*delt

        call rvec(isourc,us,vs,posvects(1,1))

        numimgs = iget_images(imgprob, posvects(1,1), 1)

        call get_r_mult(posfield, posvects(1,1), numimgs, r)
        do ii=1,numimgs
          r(ii) = sqrt(r(ii)*r(ii) + a*a)
        end do

        call get_basis(isourc,inode,us,vs,basis(1,1))
        numimgs = iget_images(imgprob,basis(1,1),2)

        divbasis(1) = fget_divbasis(isourc,inode,us,vs)
        numimgs = iget_div_images(imgprob,divbasis)


        do imgnum=1,numimgs
          cg = cexp(-cj*ak*r(imgnum))/r(imgnum)
        
          do k=1,3
            cvpot(k) = cvpot(k) + basis(k,imgnum)*cg*delt
          end do
          cspot = cspot + divbasis(imgnum)*cg*delt

        end do
      end do

      do k=1,3
        cvpot(k) = cvpot(k) * deltal
      end do
      cspot = cspot

      return 
      end

