Skip to content

Commit

Permalink
Update unit test to also call the transpose_orog routine.
Browse files Browse the repository at this point in the history
  • Loading branch information
George Gayno committed Dec 3, 2024
1 parent dc516b6 commit 1c21bcf
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions tests/orog/ftst_transpose.F90
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
program transpose

use orog_utils, only : transpose_mask
! Unit test for routines transpose_mask and transpose_orog.
! They are essentially the same routine - one takes
! one byte integer data, and one takes two byte integer
! data.
!
! Author George Gayno NCEP/EMC

use orog_utils, only : transpose_mask, transpose_orog

implicit none

integer, parameter :: imn = 360
integer, parameter :: jmn = 181

integer(1) :: mask(imn,jmn)
integer(2) :: mask2(imn,jmn)
integer :: i, ii, j, jj

print*,"Starting test of transpose routines."

! Transpose is from S to N to the NCEP standard N to S,
! and from the dateline to the NCEP standard Greenwich.
! and, in the E/W direction, from the dateline to the
! NCEP standard Greenwich.

! Set up a one-degree global mask. Although mask is a
! yes/no flag, for this test set each row to the
! latitude to simplify checking the answer.
! Test N/S transpose. Set up a one-degree global mask.
! Although mask is a yes/no flag, for this test set each
! row to the latitude to simplify checking the answer.

jj=0
do j = -90, 90 ! row 1 is South Pole.
jj = jj + 1
mask(:,jj) = j
mask2(:,jj) = j
enddo

print*,"Call transpose routines to test N/S flip."

call transpose_mask(imn, jmn, mask)
call transpose_orog(imn, jmn, mask2)

jj=0
do j = 90, -90, -1 ! row 1 is North Pole.
jj = jj + 1
do i = 1, imn
if (mask(i,jj) /= j) stop 2
if (mask2(i,jj) /= j) stop 3
enddo
enddo

Expand All @@ -41,24 +55,31 @@ program transpose

do i = 1, 180
mask(i,:) = -1
mask2(i,:) = -1
enddo
do i = 181, 360
mask(i,:) = +1
mask2(i,:) = +1
enddo

print*,"Call transpose routines to test E/W flip."

call transpose_mask(imn, jmn, mask)
call transpose_orog(imn, jmn, mask2)

! After the transpose, the East half should be plus 1
! and the West half should be minus 1.

do i = 1, 180
do j = 1, jmn
if (mask(i,j) /= 1) stop 4
if (mask2(i,j) /= 1) stop 5
enddo
enddo
do i = 181, 360
do j = 1, jmn
if (mask(i,j) /= -1) stop 6
if (mask2(i,j) /= -1) stop 7
enddo
enddo

Expand Down

0 comments on commit 1c21bcf

Please sign in to comment.