Skip to content

Commit

Permalink
Add partial unit test for routine find_nearest_pole_points.
Browse files Browse the repository at this point in the history
  • Loading branch information
George Gayno committed Dec 3, 2024
1 parent 92bac68 commit 58cd3bc
Show file tree
Hide file tree
Showing 2 changed files with 112 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 @@ -37,3 +37,7 @@ 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)

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

use orog_utils, only : find_nearest_pole_points

implicit none

integer, parameter :: im=48
integer, parameter :: jm=48

integer :: i, j
integer :: i_north_pole, j_north_pole
integer :: i_south_pole, j_south_pole

logical :: is_north_pole(im,jm)
logical :: is_south_pole(im,jm)

! Test 1 - C48 uniform tile containing north pole.

i_north_pole = 49 ! supergrid index
j_north_pole = 49 ! uniform grid
i_south_pole = 0
j_south_pole = 0

call find_nearest_pole_points(i_north_pole, j_north_pole, &
i_south_pole, j_south_pole, im, jm, is_north_pole, &
is_south_pole)

do j = 1, im
do i = 1, jm
if((i == 24 .and. j == 24) .or. &
(i == 24 .and. j == 25) .or. &
(i == 25 .and. j == 24) .or. &
(i == 25 .and. j == 25)) then
if (.not.is_north_pole(i,j)) stop 2
else
if (is_north_pole(i,j)) stop 4
endif
if (is_south_pole(i,j)) stop 8
enddo
enddo

! Test 2 - C48 uniform tile containing south pole.

i_north_pole = 0
j_north_pole = 0
i_south_pole = 49
j_south_pole = 49

call find_nearest_pole_points(i_north_pole, j_north_pole, &
i_south_pole, j_south_pole, im, jm, is_north_pole, &
is_south_pole)

do j = 1, im
do i = 1, jm
if((i == 24 .and. j == 24) .or. &
(i == 24 .and. j == 25) .or. &
(i == 25 .and. j == 24) .or. &
(i == 25 .and. j == 25)) then
if (.not.is_south_pole(i,j)) stop 12
else
if (is_south_pole(i,j)) stop 14
endif
if (is_north_pole(i,j)) stop 18
enddo
enddo

! Test 3 - C48 uniform tile containing no pole.

i_north_pole = 0
j_north_pole = 0
i_south_pole = 0
j_south_pole = 0

call find_nearest_pole_points(i_north_pole, j_north_pole, &
i_south_pole, j_south_pole, im, jm, is_north_pole, &
is_south_pole)

do j = 1, im
do i = 1, jm
if (is_south_pole(i,j)) stop 24
if (is_north_pole(i,j)) stop 26
enddo
enddo

! Test 4 - C48 stretched grid tile containing south pole.

i_north_pole = 0
j_north_pole = 0
i_south_pole = 10
j_south_pole = 49

call find_nearest_pole_points(i_north_pole, j_north_pole, &
i_south_pole, j_south_pole, im, jm, is_north_pole, &
is_south_pole)

do j = 1, im
do i = 1, jm
if((i == 5 .and. j == 24) .or. &
(i == 5 .and. j == 25)) then
if (.not.is_south_pole(i,j)) stop 32
else
if (is_south_pole(i,j)) stop 34
endif
if (is_north_pole(i,j)) stop 38
enddo
enddo

end program find_nearest_pole_pts

0 comments on commit 58cd3bc

Please sign in to comment.