From e4a2f33f569edbe04440f69e4dc50f40d65b48fa Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 14 Nov 2024 14:47:20 -0600 Subject: [PATCH] Add unit test for 'read_ocean_frac'. Fixes #944. --- tests/ocean_merge/CMakeLists.txt | 7 ++++ tests/ocean_merge/data/C48.mx500.tile1.nc | Bin 0 -> 1272 bytes tests/ocean_merge/ftst_read_ocean_frac.F90 | 37 +++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 tests/ocean_merge/data/C48.mx500.tile1.nc create mode 100644 tests/ocean_merge/ftst_read_ocean_frac.F90 diff --git a/tests/ocean_merge/CMakeLists.txt b/tests/ocean_merge/CMakeLists.txt index 513f9fb57..6057e61a3 100644 --- a/tests/ocean_merge/CMakeLists.txt +++ b/tests/ocean_merge/CMakeLists.txt @@ -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) @@ -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) diff --git a/tests/ocean_merge/data/C48.mx500.tile1.nc b/tests/ocean_merge/data/C48.mx500.tile1.nc new file mode 100644 index 0000000000000000000000000000000000000000..d3999075f4ef31be86cd7367d44199495e9fb120 GIT binary patch literal 1272 zcmZ>EabseD04^W}VzZ|gWv0YemViWA;rt3PpAE?80b;PajLhPa{Gv)A7tB8!l2NMQ zmtUq}Xrf?fY-MC_WniXYWME`srI44LU96y+q5w9zqD05gT*t^rp(M4qL@zHHOdA0i zTxbTES{WE)GoZ3W$H-F0*jPcoJijR0NIx$>F;PDyQ9nIBu`(}Tzc{fhRX@}%I6gGQ z(~ zB?VUc`gzIudc|paK#e*I&iN@wGU=Hm8Kp^j$@#e;MIfvRvWFXpnSmG*2aqs_#SbG$ z0Th7Z;RA%tqyeOn5}s4^qD|ZS@S0dQp?_8X)y^wZk@p)Vs>OH3O-)UnH{#r2c5#!gi4Q$y1!& zK*>3yPVAoWF|+Oa_O8t>VAb^_Jk|Jssd z2U5RzF2_-zdj4Zr4t2d%!3u9@@aIcTleD<31+?4Y%aP4VT09}c?z>LNCnUv$tjpC9bozQ#c>eIMu7 ziYy1czA2p|v)di?R=>1!{UhL@w|@fjt8JVP2A_;vv-#y542Ae4JDFJ>40Rr{+i?AG zFm!7F#dfmO!7%8-{6y9w2gBIQU(-tVI2b+Xdin7FIR|6rmQyL7D;s|JFMgdoAmGRmkOF9JX?PPll;IG&RBLBgaonvlH0`Nn@BKTpdi`krT1LtK*hp zs)UHxzyA*cU!eLp?T?&f*H52fLqPo-xIITs9@*9^`z&j`Cr`AZ@;~K U)k0tW`SzRj1!FgCjDqP00N$K}jsO4v literal 0 HcmV?d00001 diff --git a/tests/ocean_merge/ftst_read_ocean_frac.F90 b/tests/ocean_merge/ftst_read_ocean_frac.F90 new file mode 100644 index 000000000..ec35621ab --- /dev/null +++ b/tests/ocean_merge/ftst_read_ocean_frac.F90 @@ -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