forked from ufs-community/UFS_UTILS
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add partial unit test for routine find_nearest_pole_points.
Fixes ufs-community#1000.
- Loading branch information
George Gayno
committed
Dec 3, 2024
1 parent
92bac68
commit 58cd3bc
Showing
2 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |