Skip to content

Commit

Permalink
Baseline rough unit test for function inside_a_polygon.
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeGayno-NOAA committed Nov 26, 2024
1 parent 9d47f97 commit c15de74
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/orog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ target_link_libraries(ftst_get_ll_angle orog_lib)
add_executable(ftst_get_index ftst_get_index.F90)
add_test(NAME orog-ftst_get_index COMMAND ftst_get_index)
target_link_libraries(ftst_get_index orog_lib)

add_executable(ftst_inside_polygon ftst_inside_polygon.F90)
add_test(NAME orog-ftst_inside_polygon COMMAND ftst_inside_polygon)
target_link_libraries(ftst_inside_polygon orog_lib)
58 changes: 58 additions & 0 deletions tests/orog/ftst_inside_polygon.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
program inside_polygon

use orog_utils, only : inside_a_polygon

implicit none

integer, parameter :: npts=4

real, parameter :: D2R = 3.14159265358979/180.
logical :: inside

real :: lon1, lat1
real :: lon2(npts), lat2(npts)

! Test to trip the first 'if' range check

print*, "Test point 1"

lon1 = 90.0 * D2R
lat1 = 0.0 * D2R

lon2(1) = 94.0 * D2R
lat2(1) = -1.0 * D2R
lon2(2) = 94.0 * D2R
lat2(2) = 1.0 * D2R
lon2(3) = 95.0 * D2R
lat2(3) = 1.0 * D2R
lon2(4) = 95.0 * D2R
lat2(4) = -1.0 * D2R

inside=inside_a_polygon(lon1, lat1, npts, lon2, lat2)

if (inside) stop 2

! Test to trip the second 'if' range check

print*, "Test point 2"

lon1 = 90.0 * D2R
lat1 = 0.0 * D2R

lon2(1) = 84.0 * D2R
lat2(1) = -1.0 * D2R
lon2(2) = 84.0 * D2R
lat2(2) = 1.0 * D2R
lon2(3) = 85.0 * D2R
lat2(3) = 1.0 * D2R
lon2(4) = 85.0 * D2R
lat2(4) = -1.0 * D2R

inside=inside_a_polygon(lon1, lat1, npts, lon2, lat2)

if (inside) stop 4

print*,"OK"
print*,"SUCCSSS"

end program inside_polygon

0 comments on commit c15de74

Please sign in to comment.