Skip to content

Commit

Permalink
Add unit test for 'read_ocean_frac'.
Browse files Browse the repository at this point in the history
  • Loading branch information
George Gayno committed Nov 14, 2024
1 parent f96db7b commit e4a2f33
Show file tree
Hide file tree
Showing 3 changed files with 44 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 @@ -18,6 +18,9 @@ execute_process( COMMAND ${CMAKE_COMMAND} -E copy
execute_process( COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/data/oro.C48.tile1.nc ${CMAKE_CURRENT_BINARY_DIR}/oro.C48.tile1.nc)

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

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

Expand All @@ -27,6 +30,10 @@ 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_executable(ftst_read_ocean_frac ftst_read_ocean_frac.F90)
target_link_libraries(ftst_read_ocean_frac 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)
add_test(NAME ocean_merge-ftst_read_ocean_frac COMMAND ftst_read_ocean_frac)
Binary file added tests/ocean_merge/data/C48.mx500.tile1.nc
Binary file not shown.
37 changes: 37 additions & 0 deletions tests/ocean_merge/ftst_read_ocean_frac.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
! Unit test for the read_ocean_frac routine.
!
! Reads a 6x5 version of the ocean mask file and
! checks values from the ocean fraction record.
! If differences exceed a threshold, then the test fails.
!
program read_ocean_info

implicit none

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

character(len=3) :: pth1="./"
character(len=3) :: atmres="C48"
character(len=5) :: ocnres="mx500"

real, parameter :: thresh = 0.001
real :: ocn_frac(lon,lat)

print*,"Call routine read_ocean_frac."

call read_ocean_frac(pth1,atmres,ocnres,tile,lon,lat,ocn_frac)

print*,"Check records."

if (abs(ocn_frac(1,1)-1.0) > thresh) stop 2
if (abs(ocn_frac(6,5)-0.0) > thresh) stop 4
if (abs(ocn_frac(4,5)-0.0917) > thresh) stop 6
if (abs(ocn_frac(3,1)-0.162347) > thresh) stop 8

print*,"OK"

print*,"SUCCESS"

end program read_ocean_info

0 comments on commit e4a2f33

Please sign in to comment.