Skip to content

Commit

Permalink
Create an initial unit test for the 'merge' routine.
Browse files Browse the repository at this point in the history
  • Loading branch information
George Gayno committed Sep 27, 2024
1 parent d89bb26 commit 70c1233
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sorc/ocean_merge.fd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(lib_src utils.F90 namelist.F90)
set(lib_src merge.F90 utils.F90 namelist.F90)
set(exe_src merge_lake_ocnmsk.F90)

if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
Expand Down
2 changes: 1 addition & 1 deletion sorc/ocean_merge.fd/merge.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ subroutine merge(lon, lat, binary_lake, lat2d, ocn_frac, &
real, intent(in) :: ocn_frac(lon,lat)
real, intent(inout) :: lake_frac(lon,lat)
real, intent(inout) :: lake_depth(lon,lat)
real, intent(inout) :: land_frac(lon,lat)
real, intent(out) :: land_frac(lon,lat)
real, intent(out) :: slmsk(lon,lat)

real, parameter :: min_land=1.e-4, def_lakedp=10.
Expand Down
4 changes: 4 additions & 0 deletions tests/ocean_merge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ execute_process( COMMAND ${CMAKE_COMMAND} -E copy
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_test(NAME ocean_merge-ftst_read_nml COMMAND ftst_read_nml)
add_test(NAME ocean_merge-ftst_merge COMMAND ftst_merge)
64 changes: 64 additions & 0 deletions tests/ocean_merge/ftst_merge.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
! Unit test for the merge routine.

program ftst_merge

implicit none

integer, parameter :: lon = 1
integer, parameter :: lat = 1

integer :: binary_lake

real :: lat2d(lon,lat)
real :: ocn_frac(lon,lat)
real :: lake_frac(lon,lat)
real :: lake_depth(lon,lat)
real :: land_frac(lon,lat)
real :: slmsk(lon,lat)

print*,"Begin test of merge routine"

! test point 1

binary_lake = 0
lat2d(1,1) = 30.0
ocn_frac(1,1) = .75
lake_frac(1,1) = 0.0
lake_depth(1,1) = 0.0
land_frac(1,1) = -99.
slmsk(1,1) = -99.

call merge(lon, lat, binary_lake, lat2d, ocn_frac, &
lake_frac, lake_depth, land_frac, slmsk)

print*,'test point 1 '
print*,'ocn_frac ',ocn_frac(1,1)
print*,'lake_frac ',lake_frac(1,1)
print*,'lake_depth ',lake_depth(1,1)
print*,'land_frac ',land_frac(1,1)
print*,'slmsk ', slmsk(1,1)

! test point 2

binary_lake = 0
lat2d(1,1) = 30.0
ocn_frac(1,1) = 0.0
lake_frac(1,1) = .75
lake_depth(1,1) = 100.0
land_frac(1,1) = -99.
slmsk(1,1) = -99.

call merge(lon, lat, binary_lake, lat2d, ocn_frac, &
lake_frac, lake_depth, land_frac, slmsk)

print*,'test point 2 '
print*,'ocn_frac ',ocn_frac(1,1)
print*,'lake_frac ',lake_frac(1,1)
print*,'lake_depth ',lake_depth(1,1)
print*,'land_frac ',land_frac(1,1)
print*,'slmsk ', slmsk(1,1)
print*, "OK"

print*, "SUCCESS!"

end program ftst_merge

0 comments on commit 70c1233

Please sign in to comment.