      subroutine RemoveIslands(d,q,n1,n2,m,n,grnd)
      real*8 d(m,n),q(m,n),grnd,d1,d2,d3,d4,depthmin
c..... Eliminate one-node islands ........
      do i=2,n1-1
       do j=2,n2-1
         if(d(i,j).LE.grnd) then
           if(d(i,j).GT.0) then
             write(3,100) i,j 
             d(i,j)=0.
           end if
           if(d(i+1,j).GT.grnd.AND.d(i-1,j).GT.grnd.OR.
     &        d(i,j+1).GT.grnd.AND.d(i,j-1).GT.grnd) then
             d1=(d(i,j)+d(i,j-1)+d(i+1,j-1)+d(i+1,j))*.25
             d2=(d(i,j)+d(i,j+1)+d(i+1,j+1)+d(i+1,j))*.25
             d3=(d(i,j)+d(i,j+1)+d(i-1,j+1)+d(i-1,j))*.25
             d4=(d(i,j)+d(i,j-1)+d(i-1,j-1)+d(i-1,j))*.25
             depthmin=MIN(d1,d2,d3,d4)
             if(d1.LE.depthmin) then
               if(d(i,j-1).GT.grnd) then
                 write(3,110) i,j-1
                 d(i,j-1)=0.
               end if
               if(d(i+1,j-1).GT.grnd) then
                 write(3,110) i+1,j-1
                 d(i+1,j-1)=0.
               end if
               if(d(i+1,j).GT.grnd) then
                 write(3,110) i+1,j
                 d(i+1,j)=0.
               end if
             else if(d2.LE.depthmin) then
               if(d(i,j+1).GT.grnd) then
                 write(3,110) i,j+1
                 d(i,j+1)=0.
               end if
               if(d(i+1,j+1).GT.grnd) then
                 write(3,110) i+1,j+1
                 d(i+1,j+1)=0.
               end if
               if(d(i+1,j).GT.grnd) then
                 write(3,110) i+1,j
                 d(i+1,j)=0.
               end if
             else if(d3.LE.depthmin) then
               if(d(i,j+1).GT.grnd) then
                 write(3,110) i,j+1
                 d(i,j+1)=0.
               end if
               if(d(i-1,j+1).GT.grnd) then
                 write(3,110) i-1,j+1
                 d(i-1,j+1)=0.
               end if
               if(d(i-1,j).GT.grnd) then
                 write(3,110) i-1,j
                 d(i-1,j)=0.
               end if
             else if(d4.LE.depthmin) then
               if(d(i,j-1).GT.grnd) then
                 write(3,110) i,j-1
                 d(i,j-1)=0.
               end if
               if(d(i-1,j-1).GT.grnd) then
                 write(3,110) i-1,j-1
                 d(i-1,j-1)=0.
               end if
               if(d(i-1,j).GT.grnd) then
                 write(3,110) i-1,j
                 d(i-1,j)=0.
               end if
             end if
           end if
         end if
       end do
      end do		! no 1-node islands any more
 100  format('  Setting point between grnd and 0 to 0, i=',i6,' j=',i6)
 110  format('  Setting 1-node point to zero, i=',i6,' j=',i6)
      return
      end
