From c8dad116266ce555e788b454527f7e163929fa44 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 5 Dec 2024 08:23:28 -0600 Subject: [PATCH] Complete unit test for "file_nearest_pole_points". Fixes #1000. --- tests/orog/ftst_find_nearest_pole_pts.F90 | 58 +++++++++++++++++++++-- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/tests/orog/ftst_find_nearest_pole_pts.F90 b/tests/orog/ftst_find_nearest_pole_pts.F90 index b0da658da..4c6844790 100644 --- a/tests/orog/ftst_find_nearest_pole_pts.F90 +++ b/tests/orog/ftst_find_nearest_pole_pts.F90 @@ -1,5 +1,14 @@ program find_nearest_pole_pts +! Unit test for routine find_nearest_pole_points. +! +! The routine is passed the supergrid indices of +! the pole (from the 'grid' files) and returns the +! nearest pole points (using a logical array) on +! the model tile. +! +! Author George Gayno NCEP/EMC + use orog_utils, only : find_nearest_pole_points implicit none @@ -14,10 +23,14 @@ program find_nearest_pole_pts logical :: is_north_pole(im,jm) logical :: is_south_pole(im,jm) + print*,"Starting test of find_nearest_pole_points routine." + ! Test 1 - C48 uniform tile containing north pole. - i_north_pole = 49 ! supergrid index - j_north_pole = 49 ! uniform grid + print*,"Test number 1." + + i_north_pole = 49 ! Supergrid index + j_north_pole = 49 i_south_pole = 0 j_south_pole = 0 @@ -41,9 +54,11 @@ program find_nearest_pole_pts ! Test 2 - C48 uniform tile containing south pole. + print*,"Test number 2." + i_north_pole = 0 j_north_pole = 0 - i_south_pole = 49 + i_south_pole = 49 ! Supergrid index. j_south_pole = 49 call find_nearest_pole_points(i_north_pole, j_north_pole, & @@ -66,7 +81,9 @@ program find_nearest_pole_pts ! Test 3 - C48 uniform tile containing no pole. - i_north_pole = 0 + print*,"Test number 3." + + i_north_pole = 0 ! Zero indicates no pole. j_north_pole = 0 i_south_pole = 0 j_south_pole = 0 @@ -84,9 +101,11 @@ program find_nearest_pole_pts ! Test 4 - C48 stretched grid tile containing south pole. + print*,"Test number 4." + i_north_pole = 0 j_north_pole = 0 - i_south_pole = 10 + i_south_pole = 10 ! Supergrid index. j_south_pole = 49 call find_nearest_pole_points(i_north_pole, j_north_pole, & @@ -105,4 +124,33 @@ program find_nearest_pole_pts enddo enddo +! Test 5 - C48 stretched grid tile containing north pole. + + print*,"Test number 5." + + i_north_pole = 62 ! Supergrid index. + j_north_pole = 49 + 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 == 31 .and. j == 24) .or. & + (i == 31 .and. j == 25)) then + if (.not.is_north_pole(i,j)) stop 32 + else + if (is_north_pole(i,j)) stop 34 + endif + if (is_south_pole(i,j)) stop 38 + enddo + enddo + + print*,"OK" + + print*,"SUCCESS" + end program find_nearest_pole_pts