anchor.diff:        integer                :: i
   
         do i = 1, dim - 1
  -          value(i) = sqrt((pos(1,i) - sourcex) * (pos(1,i) - sourcex) &
  +          value(i) = -sqrt((pos(1,i) - sourcex) * (pos(1,i) - sourcex) &
                        + (pos(2,i) - sourcey) * (pos(2,i) - sourcey))
         end do
   
  
positive.code:               call expand(pos, max, dim, gamma)
                call findval(pos, value, dim)
                call minmax(value, min, max)
                call centroid(pos, min, max, dim)
  
                !! Setting things back, if expansion is worse than 
                !! standard reflection
  
negative.code:           dist = sqrt((pos(1,min)-pos(1,max)) * (pos(1,min)-pos(1,max)) &
                        + (pos(2,min)-pos(2,max)) * (pos(2,min)-pos(2,max)))
  
            !write(100,*) pos(1,1), pos(2,1)
            !write(100,*) pos(1,2), pos(2,2)
            !write(100,*) pos(1,3), pos(2,3)
            !write(100,*) pos(1,1), pos(2,1)
            !write(100,*)
            !write(100,*)
  
        end do
  
        write(*,*) pos(1,1), pos(1,2), pos(1,3), pos(1,4)
        write(*,*) pos(2,1), pos(2,2), pos(2,3), pos(2,4)
        write(*,*) min, max, dim
  
  
  end subroutine
  
  