Skip to content

Commit

Permalink
Add unit test for routine find_poles.
Browse files Browse the repository at this point in the history
  • Loading branch information
George Gayno committed Dec 3, 2024
1 parent 1c21bcf commit 92bac68
Show file tree
Hide file tree
Showing 2 changed files with 73 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 @@ -33,3 +33,7 @@ target_link_libraries(ftst_inside_polygon orog_lib)
add_executable(ftst_transpose ftst_transpose.F90)
add_test(NAME orog-ftst_transpose COMMAND ftst_transpose)
target_link_libraries(ftst_transpose orog_lib)

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

! Unit test for routine find_poles.
!
! Author George Gayno NCEP/EMC

use orog_utils, only : find_poles

implicit none

integer, parameter :: nx=9
integer, parameter :: ny=9

integer :: i_north_pole, j_north_pole
integer :: i_south_pole, j_south_pole

real :: geolat(nx+1,ny+1)

print*,"Starting test of find_poles."

! Point 1 - North Pole at (4,5)

print*,"North pole test."

geolat = 89.0
geolat(4,5) = 89.95 ! North pole

call find_poles(geolat, nx, ny, i_north_pole, j_north_pole, &
i_south_pole, j_south_pole)

if (i_north_pole /= 4) stop 2
if (j_north_pole /= 5) stop 4
if (i_south_pole /= 0) stop 6
if (j_south_pole /= 0) stop 8

! Point 2 - South Pole at (2,8)

print*,"South pole test."

geolat = -89.0
geolat(2,8) = -89.95 ! South pole

call find_poles(geolat, nx, ny, i_north_pole, j_north_pole, &
i_south_pole, j_south_pole)

if (i_north_pole /= 0) stop 12
if (j_north_pole /= 0) stop 14
if (i_south_pole /= 2) stop 16
if (j_south_pole /= 8) stop 18

! Point 3 - No pole points.

print*,"No pole test."

geolat = -89.3

call find_poles(geolat, nx, ny, i_north_pole, j_north_pole, &
i_south_pole, j_south_pole)

if (i_north_pole /= 0) stop 22
if (j_north_pole /= 0) stop 24
if (i_south_pole /= 0) stop 26
if (j_south_pole /= 0) stop 28

print*,"OK"

print*,"SUCCESS"

end program ftst_find_poles

0 comments on commit 92bac68

Please sign in to comment.