Unit test routine
x0,y0= 0.59999999999999998 0.59999999999999998
l= 1
m= -1
dist to path= 0.40000000000000002
x0,y0= 1.5000000000000000 0.50000000000000000
l= -1
m= 0
dist to path= -0.50000000000000000
x0,y0= 1.0000000000000000 0.0000000000000000
l= 0
m= 0
dist to path= 0.0000000000000000
subroutine geometry_unit_test() implicit none integer :: l,m real(wp) :: x0,y0 !a 1x1 square: integer,parameter :: n = 4 real(wp),dimension(n),parameter :: x = [0.0_wp, 0.0_wp, 1.0_wp, 1.0_wp] real(wp),dimension(n),parameter :: y = [0.0_wp, 1.0_wp, 1.0_wp, 0.0_wp] x0 = 0.6_wp !inside the path y0 = 0.6_wp call go() x0 = 1.5_wp !outside the path y0 = 0.5_wp call go() x0 = 10.0_wp !outside the path y0 = 0.0_wp call go() x0 = 1.0_wp !on the path y0 = 0.0_wp call go() contains subroutine go() !call locpt for the x0,y0 point, and print results implicit none real(wp) :: d call locpt (x0, y0, x, y, n, l, m) write(*,*) '' write(*,*) 'x0,y0=',x0,y0 write(*,*) 'l=',l write(*,*) 'm=',m d = distance_from_point_to_path(x0, y0, x, y, n) write(*,*) 'dist to path=',d end subroutine go end subroutine geometry_unit_test