anchor.diff:            call random_number(pos(1,i))
             call random_number(pos(2,i))
         end do
  -
         
   end subroutine
   
  -!! finds centroid position
  +!! finds centroid position 
   pure subroutine centroid(pos, min, max, dim)
         implicit none
         real*8, intent(inout)  :: pos(:,:)
  
positive.code: !!----------------------------------------------------------------------------!!
  
        integer, parameter :: dim = 6
        integer :: min, max
        real*8, dimension(2, dim)  :: pos
        real*8, dimension(dim)     :: value
        real*8  :: x, y, alpha, beta, gamma
  
        interface
            subroutine findval(pos, value, dim)
            real*8, intent(in), dimension(:,:) :: pos
            real*8, intent(out), dimension(:)  :: value
            integer, intent(in)                :: dim
            end subroutine findval
        end interface
  
        call findval(pos, value, dim)
        write(*,*) value
  
  end program
  
  
negative.code: !! minimum currently set to 0.5, should be found via Downhill Simplex!
  subroutine findval(pos, value, dim)
        implicit none
        real*8,  dimension(:,:):: pos
        real*8,  dimension(:)  :: value
        real*8                 :: sourcex = 0.5, sourcey = 0.5
        integer                :: dim
        integer                :: i
  
        do i = 1, dim - 3
            value(i) = sqrt((pos(1,i) - sourcex) * (pos(1,i) - sourcex) &
                       + (pos(2,i) - sourcey) * (pos(2,i) - sourcey))
        end do
  
        do i = dim - 2, dim
            value(i) = 0
        end do
  
  end subroutine
  