Skip to content

Commit

Permalink
Add unit test for 'read_global_orog'.
Browse files Browse the repository at this point in the history
  • Loading branch information
George Gayno committed Jan 3, 2025
1 parent ddfbc61 commit 53250b2
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/orog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ endif()
execute_process( COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/data/landcover.umd.lowres.nc ${CMAKE_CURRENT_BINARY_DIR}/landcover.umd.30s.nc)

# Note, the "read_global_mask" routine expects the filename "topography.gmted2010.30s.nc".
execute_process( COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/data/topography.gmted2010.lowres.nc ${CMAKE_CURRENT_BINARY_DIR}/topography.gmted2010.30s.nc)

add_executable(ftst_ll2xyz ftst_ll2xyz.F90)
add_test(NAME orog-ftst_ll2xyz COMMAND ftst_ll2xyz)
target_link_libraries(ftst_ll2xyz orog_lib)
Expand Down Expand Up @@ -66,3 +70,7 @@ target_link_libraries(ftst_rm_isolated_pts orog_lib)
add_executable(ftst_read_global_mask ftst_read_global_mask.F90)
add_test(NAME orog-ftst_read_global_mask COMMAND ftst_read_global_mask)
target_link_libraries(ftst_read_global_mask orog_lib)

add_executable(ftst_read_global_orog ftst_read_global_orog.F90)
add_test(NAME orog-ftst_read_global_orog COMMAND ftst_read_global_orog)
target_link_libraries(ftst_read_global_orog orog_lib)
Binary file added tests/orog/data/topography.gmted2010.lowres.nc
Binary file not shown.
36 changes: 36 additions & 0 deletions tests/orog/ftst_read_global_orog.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
program read_gbl_orog

! Test routine "read_global_orog" using a reduced-size
! version (6 x 3 vs 43200 x 21600) of the gmted 2010 orog file.

use io_utils, only : read_global_orog

implicit none

integer, parameter :: im=6
integer, parameter :: jm=3

integer :: i, j

integer(kind=2) :: glob(im,jm)
integer(kind=2) :: glob_expected(im,jm)

! Note the routine flips the i and j directions.
data glob_expected /161,162,163,167,162,162, &
157,153,148,166,165,162, &
169,163,155,169,170,171/

print*,"- Begin test of read_global_orog"

call read_global_orog(im, jm, glob)

do j = 1, jm
do i = 1, im
if (glob(i,j) /= glob_expected(i,j)) stop 3
enddo
enddo

print*,"OK"
print*,"SUCCSSS"

end program read_gbl_orog

0 comments on commit 53250b2

Please sign in to comment.