diff --git a/tests/ocean_merge/CMakeLists.txt b/tests/ocean_merge/CMakeLists.txt index 6f1bec5bc..513f9fb57 100644 --- a/tests/ocean_merge/CMakeLists.txt +++ b/tests/ocean_merge/CMakeLists.txt @@ -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) diff --git a/tests/ocean_merge/data/oro.C48.tile1.nc b/tests/ocean_merge/data/oro.C48.tile1.nc new file mode 100644 index 000000000..64366c355 Binary files /dev/null and b/tests/ocean_merge/data/oro.C48.tile1.nc differ diff --git a/tests/ocean_merge/ftst_read_lake_mask.F90 b/tests/ocean_merge/ftst_read_lake_mask.F90 new file mode 100644 index 000000000..e345607cc --- /dev/null +++ b/tests/ocean_merge/ftst_read_lake_mask.F90 @@ -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