From c15de742744bda4ec26f20a37299a933ef6b2b62 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 26 Nov 2024 19:26:50 +0000 Subject: [PATCH] Baseline rough unit test for function inside_a_polygon. Fixes #1000. --- tests/orog/CMakeLists.txt | 4 +++ tests/orog/ftst_inside_polygon.F90 | 58 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 tests/orog/ftst_inside_polygon.F90 diff --git a/tests/orog/CMakeLists.txt b/tests/orog/CMakeLists.txt index 97dbd4ec2..c55cad00b 100644 --- a/tests/orog/CMakeLists.txt +++ b/tests/orog/CMakeLists.txt @@ -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) diff --git a/tests/orog/ftst_inside_polygon.F90 b/tests/orog/ftst_inside_polygon.F90 new file mode 100644 index 000000000..df10766f4 --- /dev/null +++ b/tests/orog/ftst_inside_polygon.F90 @@ -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