Skip to content

Commit

Permalink
Add more test points to ftst_get_index.F90 unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeGayno-NOAA committed Nov 25, 2024
1 parent 73f9e7d commit 546153f
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 7 deletions.
3 changes: 2 additions & 1 deletion sorc/orog_mask_tools.fd/orog.fd/orog_utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,8 @@ end subroutine remove_isolated_pts
!! @param[in] jmn 'j' dimension of the high-resolution orography
!! data set.
!! @param[in] npts Number of vertices to describe the cubed-sphere point.
!! @param[in] lonO The longitudes of the cubed-sphere vertices.
!! @param[in] lonO The longitudes of the cubed-sphere vertices. Must
!! range from 0 - 360.
!! @param[in] latO The latitudes of the cubed-sphere vertices.
!! @param[in] delxn Resolution of the high-resolution orography
!! data set.
Expand Down
69 changes: 63 additions & 6 deletions tests/orog/ftst_get_index.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
program test_get_index

! Unit test for routine get_index, which finds the
! i/j location of the model point on the high-resolution
! mask and orography grids.
!
! Author George Gayno NCEP/EMC

use orog_utils, only : get_index

implicit none
Expand All @@ -8,12 +14,15 @@ program test_get_index
integer, parameter :: jmn=180*120
integer, parameter :: npts=4

integer :: jst, jen, ilist(imn), numx
integer :: i, ii, jst, jen, ilist(imn), numx

real :: lono(npts), lato(npts)
real, parameter :: delxn=360.0/imn
real, parameter :: delxn=360.0/float(imn)

print*,"Starting test of get_index."

print*,'hello world'
! Point 1 - At equator. Western edge of grid cell at
! Greenwich.

lato(1) = 0.0; lono(1) = 0.0
lato(2) = 1.0; lono(2) = 0.5
Expand All @@ -22,11 +31,59 @@ program test_get_index

ilist = -999

call get_index(imn,jmn,npts,lonO,latO,delxn,jst,jen,ilist,numx)
call get_index(imn,jmn,npts,lono,lato,delxn,jst,jen,ilist,numx)

if (jst /= 10676) stop 2
if (jen /= 10925) stop 4
if (numx /= 121) stop 6
do i = 1, numx
if (ilist(i) /= i) stop 8
enddo

! Point 2 - At equator. Grid cell centered at
! Greenwich.

lato(1) = 0.0; lono(1) = -0.5
lato(2) = 1.0; lono(2) = 0.0
lato(3) = 0.0; lono(3) = 0.5
lato(4) = -1.0; lono(4) = 0.0

ilist = -999

call get_index(imn,jmn,npts,lono,lato,delxn,jst,jen,ilist,numx)

if (jst /= 10676) stop 12
if (jen /= 10925) stop 14
if (numx /= 121) stop 16
ii = 1
do i = -59, 61, 1
if (ilist(ii) /= i) stop 18
ii = ii + 1
enddo

! Point 3 - At equator. Grid cell centered at
! the dateline.

lato(1) = -1.0; lono(1) = 179.0
lato(2) = 1.0; lono(2) = 179.0
lato(3) = 1.0; lono(3) = 181.0
lato(4) = -1.0; lono(4) = 181.0

ilist = -999

call get_index(imn,jmn,npts,lono,lato,delxn,jst,jen,ilist,numx)

print*,jst,jen,numx
if (jst /= 10676) stop 22
if (jen /= 10925) stop 24
if (numx /= 241) stop 26
ii = 1
do i = 21481, 21721
if (ilist(ii) /= i) stop 28
ii = ii + 1
enddo

print*,ilist(1:numx)
print*,"OK"

print*,"SUCCESS"

end program test_get_index

0 comments on commit 546153f

Please sign in to comment.