diff --git a/sorc/orog_mask_tools.fd/orog.fd/io_utils.F90 b/sorc/orog_mask_tools.fd/orog.fd/io_utils.F90 index a89d6e238..d6dc508cc 100644 --- a/sorc/orog_mask_tools.fd/orog.fd/io_utils.F90 +++ b/sorc/orog_mask_tools.fd/orog.fd/io_utils.F90 @@ -343,9 +343,9 @@ end subroutine write_mask_netcdf !> Read the land mask file !! !! @param[in] merge_file path -!! @param[in] slm Land-sea mask. -!! @param[in] land_frac Land fraction. -!! @param[in] lake_frac Lake fraction +!! @param[out] slm Land-sea mask. +!! @param[out] land_frac Land fraction. +!! @param[out] lake_frac Lake fraction !! @param[in] im 'i' dimension of a model grid tile. !! @param[in] jm 'j' dimension of a model grid tile. !! @author George Gayno NOAA/EMC diff --git a/tests/orog/CMakeLists.txt b/tests/orog/CMakeLists.txt index 7986143ea..ca02d8215 100644 --- a/tests/orog/CMakeLists.txt +++ b/tests/orog/CMakeLists.txt @@ -23,6 +23,10 @@ execute_process( COMMAND ${CMAKE_COMMAND} -E copy execute_process( COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/data/C12_grid.tile1.nc ${CMAKE_CURRENT_BINARY_DIR}/C12_grid.tile1.nc) +# Note, the "read_mask" test expects this file. +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_ll2xyz ftst_ll2xyz.F90) add_test(NAME orog-ftst_ll2xyz COMMAND ftst_ll2xyz) target_link_libraries(ftst_ll2xyz orog_lib) @@ -86,3 +90,7 @@ target_link_libraries(ftst_read_mdl_dims orog_lib) add_executable(ftst_read_mdl_grid_file ftst_read_mdl_grid_file.F90) add_test(NAME orog-ftst_read_mdl_grid_file COMMAND ftst_read_mdl_grid_file) target_link_libraries(ftst_read_mdl_grid_file orog_lib) + +add_executable(ftst_read_mask ftst_read_mask.F90) +add_test(NAME orog-ftst_read_mask COMMAND ftst_read_mask) +target_link_libraries(ftst_read_mask orog_lib) diff --git a/tests/orog/data/C48.mx500.tile1.nc b/tests/orog/data/C48.mx500.tile1.nc new file mode 100644 index 000000000..51b5fc0a4 Binary files /dev/null and b/tests/orog/data/C48.mx500.tile1.nc differ diff --git a/tests/orog/ftst_read_mask.F90 b/tests/orog/ftst_read_mask.F90 new file mode 100644 index 000000000..e7d9f552f --- /dev/null +++ b/tests/orog/ftst_read_mask.F90 @@ -0,0 +1,82 @@ + program read_mask_test + +! Test routine 'read_mask' by reading a sample C48 global +! uniform tile file. +! +! Author George Gayno NCEP/EMC + + use io_utils, only : read_mask + + implicit none + + character(len=20) :: merge_file + + integer, parameter :: im=48 + integer, parameter :: jm=48 + integer, parameter :: chk_pts = 4 + integer :: i, j, ij + + real, parameter :: EPSILON = 0.001 + real :: land_frac(im,jm) + real :: lake_frac(im,jm) + real :: slm(im,jm) + real :: land_frac_chk(chk_pts) + real :: lake_frac_chk(chk_pts) + real :: slm_chk(chk_pts) + + type :: indices + integer :: i + integer :: j + end type indices + + type(indices) :: idx(chk_pts) + +! The i/j indicies of the check points. + + data idx%i /1,29,47,48/ + data idx%j /1,25,23,48/ + +! The expected values of the check points. + + data land_frac_chk /0.58463, 0.8377, 0.0, 0.415374/ + data lake_frac_chk /0.0, 0.0, 1.0, 0.0/ + data slm_chk /1.0, 1.0, 0.0, 0.0/ + + print*,"- Starting test of routine read_mask." + + merge_file = "./C48.mx500.tile1.nc" + +! Initialize output fields to flag value. + + land_frac = -999.9 + lake_frac = -999.9 + slm = -999.9 + + call read_mask(merge_file,slm,land_frac,lake_frac,im,jm) + +! All flag values should have been replaced. All fields +! should have values greater than zero. + + do j = 1, jm + do i = 1, im + if (land_frac(i,j) < 0.0) stop 3 + if (lake_frac(i,j) < 0.0) stop 5 + if (slm(i,j) < 0.0) stop 7 + enddo + enddo + +! Check some points against expected values. + + do ij = 1, chk_pts + i = idx(ij)%i + j = idx(ij)%j + if (abs(land_frac(i,j)-land_frac_chk(ij)) > EPSILON) stop 12 + if (abs(lake_frac(i,j)-lake_frac_chk(ij)) > EPSILON) stop 15 + if (abs(slm(i,j)-slm_chk(ij)) > EPSILON) stop 18 + enddo + + print*,"OK" + + print*,"SUCCESS" + + end program read_mask_test