********************************************************************************
*                                                                              *
*  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 ### fill1 ###
c
c     Immerses FUN array into WORK and adds boundary values.
c 
      subroutine fill1 (nnit,nmit,fun,work)
      implicit integer*4 (i-n)
      implicit real*8 (a-h,o-z)
      include 'commons8.inc'
      dimension fun(nnit,nmit),work(nnit+8,nmit+8)

c     fill the interior of work array

      do i=1,nmit
         do j=1,nnit
            work(j+4,i+4)=fun(j,i)
         enddo
      enddo

c     isym = 1 - even symmetry, isym =-1 - odd symmetry
c     values over i=nmit bondary are determined from the asymptotic expansion

      if (isym.eq.1) then

c        mu=1...4	
	  do i=2,5
             do j=1,nnit
                work(j+4,6-i)= fun(j,i)
             enddo
          enddo

c         mu=nmu+5....nmu+8
c         the following code is unnecessary since the filled in values
c         are not used during relaxation

c	  do 102 i=1,4
c	  do 102 j=1,nnit
c00102	    work(j+4,nmit+4+i)= fun(j,nmit)

c         ni=1...4
	  do i=1,nmit
             do j=2,5
                work(6-j,i+4)= fun(j,i)
             enddo
          enddo

c         ni=ni+4...ni+8
	  do i=1,nmit
             jj=0
             do j=nnit-4,nnit-1
                jj=jj+1
                work(nnit+9-jj,i+4)= fun(j,i)
             enddo
          enddo
       else
          do i=2,5
             do j=1,nnit
                work(j+4,6-i)=-fun(j,i)
             enddo
          enddo

c	  do 122 i=1,4
c	  do 122 j=1,nnit
c00122	    work(j+4,nmit+4+i)=-fun(j,nmit)
c
	  do i=1,nmit
             do j=2,5
                work(6-j,i+4)=-fun(j,i)
             enddo
          enddo

	  do i=1,nmit
             jj=0
             do j=nnit-4,nnit-1
                jj=jj+1
                work(nnit+9-jj,i+4)=-fun(j,i)
             enddo
          enddo
      endif

      return
      end
