********************************************************************************
*                                                                              *
*  2DHF version 1-2003                                                         *
*  Copyright (C) 1996  Jacek Kobus, Leif Laaksonen, Dage Sundholm              *
*                                                                              *
*  This software may be used and distributed according to the terms            *
*  of the GNU General Public License, see README and COPYING.                  *
*                                                                              *
********************************************************************************
c ### asymptp ### 
c
      subroutine asymptp (iorb1,pot,excp)
      implicit integer*4 (i-n)
      implicit real*8 (a-h,o-z)
      include 'commons8.inc'
      dimension pot(*),excp(*)

c     determine values of Coulomb potentials in the asymptotic region
c     from the multipole expansion

      if (itouch(iorb1).eq.1) then	
         ibeg=i2b(iorb1)
         call zmulti(iorb1,pot(ibeg))
      endif	    

      if (islat.eq.1) return

c     initialize amul array needed to evaluate exch. potential in
c     the asymptotic region by calling zasyx

      do iorb2=1,norb
         if (itouch(iorb1).eq.0.and.itouch(iorb2).eq.0) goto 10
         k=i3xk(iorb1,iorb2)
c        check if k=0
         if (k.eq.0) goto 10
         ngrid=i3si(k)
         if (ilc(k).ne.0) then

c           the exchange potential address array should already be modified by
c           call to rfdexch routine

            i3beg=i3b(k)
            idel=abs(mgx(6,iorb1)-mgx(6,iorb2))
            if (iorb1.eq.iorb2) idel=2*mgx(6,iorb1)

            if (idbg(300).eq.0) then
               call zasyx1 (idel,k,excp(i3beg))
            else
               call zasyx (idel,k,excp(i3beg))
            endif

            if (ilc(k).eq.2) then
               idel=mgx(6,iorb2)+mgx(6,iorb1)
               k=k+norb*(norb+1)/2
               i3beg=i3beg+ngrid
               if (idbg(300).eq.0) then
                  call zasyx1 (idel,k,excp(i3beg))
               else
                  call zasyx (idel,k,excp(i3beg))
               endif
            endif
         endif
 10      continue
      enddo
      return
      end
