Skip to content

Commit

Permalink
All unit test for routine read_lake_mask.
Browse files Browse the repository at this point in the history
  • Loading branch information
George Gayno committed Oct 9, 2024
1 parent c64161b commit b4188b9
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/ocean_merge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ endif()
execute_process( COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/data/input.nml ${CMAKE_CURRENT_BINARY_DIR}/input.nml)

execute_process( COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/data/oro.C48.tile1.nc ${CMAKE_CURRENT_BINARY_DIR}/oro.C48.tile1.nc)

add_executable(ftst_read_nml ftst_read_nml.F90)
target_link_libraries(ftst_read_nml om_lib)

add_executable(ftst_merge ftst_merge.F90)
target_link_libraries(ftst_merge om_lib)

add_executable(ftst_read_lake_mask ftst_read_lake_mask.F90)
target_link_libraries(ftst_read_lake_mask om_lib)

add_test(NAME ocean_merge-ftst_read_nml COMMAND ftst_read_nml)
add_test(NAME ocean_merge-ftst_merge COMMAND ftst_merge)
add_test(NAME ocean_merge-ftst_read_lake_mask COMMAND ftst_read_lake_mask)
Binary file added tests/ocean_merge/data/oro.C48.tile1.nc
Binary file not shown.
42 changes: 42 additions & 0 deletions tests/ocean_merge/ftst_read_lake_mask.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
! Unit test for the read_lake_mask routine.
!
! Reads a 6x4 version of the lake mask file and
! checks values from the lake fraction, lake depth
! and latitude records. If differences exceed a
! threshold, then the test fails.
!
program read_lake_info

implicit none

integer, parameter :: lon = 6
integer, parameter :: lat = 4
integer, parameter :: tile = 1

character(len=3) :: pth2="./"
character(len=3) :: atmres="C48"

real, parameter :: thresh = 0.001
real :: lake_frac(lon,lat)
real :: lake_depth(lon,lat)
real :: lat2d(lon,lat)

print*,"Call routine read_lake_mask."

call read_lake_mask(pth2,atmres,tile,lon,lat,lake_frac, &
lake_depth,lat2d)

print*,"Check records."

if (abs(lake_depth(1,1)-0.0) > thresh) stop 2
if (abs(lake_depth(5,2)-68.3817) > thresh) stop 4
if (abs(lake_frac(4,3)-1.0) > thresh) stop 6
if (abs(lake_frac(4,4)-0.0) > thresh) stop 8
if (abs(lat2d(1,4)-0.399218) > thresh) stop 10
if (abs(lat2d(6,1)-(-1.87402)) > thresh) stop 12

print*,"OK"

print*,"SUCCESS"

end program read_lake_info

0 comments on commit b4188b9

Please sign in to comment.