Skip to content

Commit

Permalink
Baseline a unit test for routine "read_global_mask" and a
Browse files Browse the repository at this point in the history
low-resolution version of the umd land use file.

Fixes ufs-community#1000.
  • Loading branch information
George Gayno committed Jan 3, 2025
1 parent d63ecfd commit be93997
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/orog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-0 -fdefault-real-8")
endif()

#include_directories(${PROJECT_SOURCE_DIR})
# Copy necessary test files from the source data directory to the
# build data directory.

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

add_executable(ftst_ll2xyz ftst_ll2xyz.F90)
add_test(NAME orog-ftst_ll2xyz COMMAND ftst_ll2xyz)
Expand Down Expand Up @@ -57,3 +62,7 @@ target_link_libraries(ftst_get_xnsum3 orog_lib)
add_executable(ftst_rm_isolated_pts ftst_rm_isolated_pts.F90)
add_test(NAME orog-ftst_rm_isolated_pts COMMAND ftst_rm_isolated_pts)
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)
Binary file added tests/orog/data/landcover.umd.lowres.nc
Binary file not shown.
36 changes: 36 additions & 0 deletions tests/orog/ftst_read_global_mask.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
program read_gbl_mask

! Test routine "read_global_mask" using a reduced-size
! version (6 x 3 vs 43200 x 21600) of the umd land mask file.

use io_utils, only : read_global_mask

implicit none

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

integer :: i, j

integer(kind=1) :: mask(im,jm)
integer(kind=1) :: mask_expected(im,jm)

! Note the routine flips the i and j directions.
data mask_expected /1,1,1,0,0,1, &
1,1,1,0,0,0, &
1,1,1,0,0,0/

print*,"- Begin test of read_global_mask"

call read_global_mask(im, jm, mask)

do j = 1, jm
do i = 1, im
if (mask(i,j) /= mask_expected(i,j)) stop 3
enddo
enddo

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

end program read_gbl_mask

0 comments on commit be93997

Please sign in to comment.