From 20e95219feb2d8edeb9e5e40a84bced5bc0615fc Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 8 Apr 2021 18:42:20 +0000 Subject: [PATCH 1/9] Add stub to test compile. Fixes #279 --- tests/chres_cube/CMakeLists.txt | 5 +++-- tests/chres_cube/ftst_search_util.F90 | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 tests/chres_cube/ftst_search_util.F90 diff --git a/tests/chres_cube/CMakeLists.txt b/tests/chres_cube/CMakeLists.txt index 0d3232d68..7868637e8 100644 --- a/tests/chres_cube/CMakeLists.txt +++ b/tests/chres_cube/CMakeLists.txt @@ -69,5 +69,6 @@ if(OpenMP_Fortran_FOUND) target_link_libraries(ftst_program_setup OpenMP::OpenMP_Fortran) endif() - - +add_executable(ftst_search_util + ftst_search_util.F90) +add_test(NAME ftst_search_util COMMAND ftst_search_util) diff --git a/tests/chres_cube/ftst_search_util.F90 b/tests/chres_cube/ftst_search_util.F90 new file mode 100644 index 000000000..ec9702982 --- /dev/null +++ b/tests/chres_cube/ftst_search_util.F90 @@ -0,0 +1,7 @@ + program test_search_util + + implicit none + + print*,'hello world' + + end program test_search_util From f9e3be7fb2f262b4af82829a5ab9f763729f1490 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 8 Apr 2021 21:19:36 +0000 Subject: [PATCH 2/9] Add some hooks to call the search routine. Fixes #279 --- sorc/chgres_cube.fd/search_util.F90 | 2 +- tests/chres_cube/CMakeLists.txt | 8 ++++++ tests/chres_cube/ftst_search_util.F90 | 35 +++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/sorc/chgres_cube.fd/search_util.F90 b/sorc/chgres_cube.fd/search_util.F90 index 1475cade4..844c22194 100644 --- a/sorc/chgres_cube.fd/search_util.F90 +++ b/sorc/chgres_cube.fd/search_util.F90 @@ -118,7 +118,7 @@ subroutine search (field, mask, idim, jdim, tile, field_num, latitude, terrain_l case (230) ! soil type on the input grid default_value = 11.0 case default - print*,'- FATAL ERROR. UNIDENTIFIED FIELD NUMBER : ', field + print*,'- FATAL ERROR. UNIDENTIFIED FIELD NUMBER : ', field_num call mpi_abort(mpi_comm_world, 77, ierr) end select diff --git a/tests/chres_cube/CMakeLists.txt b/tests/chres_cube/CMakeLists.txt index 7868637e8..1b0525066 100644 --- a/tests/chres_cube/CMakeLists.txt +++ b/tests/chres_cube/CMakeLists.txt @@ -70,5 +70,13 @@ if(OpenMP_Fortran_FOUND) endif() add_executable(ftst_search_util + "${CMAKE_SOURCE_DIR}/sorc/chgres_cube.fd/search_util.F90" ftst_search_util.F90) add_test(NAME ftst_search_util COMMAND ftst_search_util) +target_link_libraries( + ftst_search_util + esmf + MPI::MPI_Fortran) +if(OpenMP_Fortran_FOUND) + target_link_libraries(ftst_search_util OpenMP::OpenMP_Fortran) +endif() diff --git a/tests/chres_cube/ftst_search_util.F90 b/tests/chres_cube/ftst_search_util.F90 index ec9702982..1b79db146 100644 --- a/tests/chres_cube/ftst_search_util.F90 +++ b/tests/chres_cube/ftst_search_util.F90 @@ -1,7 +1,42 @@ program test_search_util + use mpi + use esmf + use search_util + implicit none + integer, parameter :: idim = 3 + integer, parameter :: jdim = 3 + integer, parameter :: tile = 1 + + integer :: field_num, ierr + integer(esmf_kind_i8) :: mask(idim,jdim) + + real(esmf_kind_r8) :: field(idim,jdim) + real(esmf_kind_r8) :: latitude(idim,jdim) + real(esmf_kind_r8) :: terrain_land(idim,jdim) + real(esmf_kind_r8) :: soilt_climo(idim,jdim) + + data mask /0, 0, 0, 1, 1, 1, 0, 0, 0/ + + data latitude /-30.0, -30.0, -30.0, 0., 0., 0., 25.0, 25.0, 25.0/ + + data terrain_land /0., 0., 0., 50.0, 75.0, 80.0, 0., 0., 0./ + + data soilt_climo /285.0, 285.0, 285.0, 0., 0., 0., 278.0, 278.0, 278.0/ + + data field/0., 0., 0., 0., 0., 0., 0., 0., 0./ + + call mpi_init(ierr) + print*,'hello world' + field_num = 0 + + call search (field, mask, idim, jdim, tile, field_num, latitude, terrain_land, & + soilt_climo) + + call mpi_finalize(ierr) + end program test_search_util From 02317963f95f66bf05a676363d6595c6f1f1bbad Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 13 Apr 2021 13:52:12 +0000 Subject: [PATCH 3/9] Rename test directory to 'chgres_cube'. Fixes #279. --- tests/CMakeLists.txt | 2 +- tests/{chres_cube => chgres_cube}/CMakeLists.txt | 0 tests/{chres_cube => chgres_cube}/config_fv3_netcdf.nml | 0 tests/{chres_cube => chgres_cube}/config_fv3_tiled.nml | 0 .../config_fv3_tiled_warm_restart.nml | 0 tests/{chres_cube => chgres_cube}/config_gaussian_nemsio.nml | 0 tests/{chres_cube => chgres_cube}/config_gfs_grib2.nml | 0 tests/{chres_cube => chgres_cube}/config_spectral_sigio.nml | 0 tests/{chres_cube => chgres_cube}/ftst_program_setup.F90 | 0 tests/{chres_cube => chgres_cube}/ftst_search_util.F90 | 0 tests/{chres_cube => chgres_cube}/ftst_utils.F90 | 0 11 files changed, 1 insertion(+), 1 deletion(-) rename tests/{chres_cube => chgres_cube}/CMakeLists.txt (100%) rename tests/{chres_cube => chgres_cube}/config_fv3_netcdf.nml (100%) rename tests/{chres_cube => chgres_cube}/config_fv3_tiled.nml (100%) rename tests/{chres_cube => chgres_cube}/config_fv3_tiled_warm_restart.nml (100%) rename tests/{chres_cube => chgres_cube}/config_gaussian_nemsio.nml (100%) rename tests/{chres_cube => chgres_cube}/config_gfs_grib2.nml (100%) rename tests/{chres_cube => chgres_cube}/config_spectral_sigio.nml (100%) rename tests/{chres_cube => chgres_cube}/ftst_program_setup.F90 (100%) rename tests/{chres_cube => chgres_cube}/ftst_search_util.F90 (100%) rename tests/{chres_cube => chgres_cube}/ftst_utils.F90 (100%) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f15672b6a..1772856b5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,6 +4,6 @@ # Ed Hartnett 2/11/21 # Add the test subdirecotries. -add_subdirectory(chres_cube) +add_subdirectory(chgres_cube) add_subdirectory(fre-nctools) diff --git a/tests/chres_cube/CMakeLists.txt b/tests/chgres_cube/CMakeLists.txt similarity index 100% rename from tests/chres_cube/CMakeLists.txt rename to tests/chgres_cube/CMakeLists.txt diff --git a/tests/chres_cube/config_fv3_netcdf.nml b/tests/chgres_cube/config_fv3_netcdf.nml similarity index 100% rename from tests/chres_cube/config_fv3_netcdf.nml rename to tests/chgres_cube/config_fv3_netcdf.nml diff --git a/tests/chres_cube/config_fv3_tiled.nml b/tests/chgres_cube/config_fv3_tiled.nml similarity index 100% rename from tests/chres_cube/config_fv3_tiled.nml rename to tests/chgres_cube/config_fv3_tiled.nml diff --git a/tests/chres_cube/config_fv3_tiled_warm_restart.nml b/tests/chgres_cube/config_fv3_tiled_warm_restart.nml similarity index 100% rename from tests/chres_cube/config_fv3_tiled_warm_restart.nml rename to tests/chgres_cube/config_fv3_tiled_warm_restart.nml diff --git a/tests/chres_cube/config_gaussian_nemsio.nml b/tests/chgres_cube/config_gaussian_nemsio.nml similarity index 100% rename from tests/chres_cube/config_gaussian_nemsio.nml rename to tests/chgres_cube/config_gaussian_nemsio.nml diff --git a/tests/chres_cube/config_gfs_grib2.nml b/tests/chgres_cube/config_gfs_grib2.nml similarity index 100% rename from tests/chres_cube/config_gfs_grib2.nml rename to tests/chgres_cube/config_gfs_grib2.nml diff --git a/tests/chres_cube/config_spectral_sigio.nml b/tests/chgres_cube/config_spectral_sigio.nml similarity index 100% rename from tests/chres_cube/config_spectral_sigio.nml rename to tests/chgres_cube/config_spectral_sigio.nml diff --git a/tests/chres_cube/ftst_program_setup.F90 b/tests/chgres_cube/ftst_program_setup.F90 similarity index 100% rename from tests/chres_cube/ftst_program_setup.F90 rename to tests/chgres_cube/ftst_program_setup.F90 diff --git a/tests/chres_cube/ftst_search_util.F90 b/tests/chgres_cube/ftst_search_util.F90 similarity index 100% rename from tests/chres_cube/ftst_search_util.F90 rename to tests/chgres_cube/ftst_search_util.F90 diff --git a/tests/chres_cube/ftst_utils.F90 b/tests/chgres_cube/ftst_utils.F90 similarity index 100% rename from tests/chres_cube/ftst_utils.F90 rename to tests/chgres_cube/ftst_utils.F90 From 23e56efc92c1e02d6e558d6d9081c536c15da799 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 13 Apr 2021 21:10:11 +0000 Subject: [PATCH 4/9] Add complete list of default tests. Fixes #279 --- tests/chgres_cube/ftst_search_util.F90 | 65 ++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 8 deletions(-) diff --git a/tests/chgres_cube/ftst_search_util.F90 b/tests/chgres_cube/ftst_search_util.F90 index 1b79db146..7bd2179ca 100644 --- a/tests/chgres_cube/ftst_search_util.F90 +++ b/tests/chgres_cube/ftst_search_util.F90 @@ -6,37 +6,86 @@ program test_search_util implicit none +! Test uses a simple 3x3 fv3 tile. + integer, parameter :: idim = 3 integer, parameter :: jdim = 3 integer, parameter :: tile = 1 - integer :: field_num, ierr + integer :: field_num, ierr, i integer(esmf_kind_i8) :: mask(idim,jdim) real(esmf_kind_r8) :: field(idim,jdim) + real(esmf_kind_r8) :: field_updated(idim,jdim) real(esmf_kind_r8) :: latitude(idim,jdim) real(esmf_kind_r8) :: terrain_land(idim,jdim) real(esmf_kind_r8) :: soilt_climo(idim,jdim) - data mask /0, 0, 0, 1, 1, 1, 0, 0, 0/ +! These variables are used to test the 'default' +! search routine option (i.e., when the search +! fails, a default must be used) + + integer, parameter :: num_default_tests = 21 + integer :: default_field_num(num_default_tests) + real(esmf_kind_r8) :: default_field_val(num_default_tests) + +! Definition of the mask. The '1' indicates an isolated +! island or lake depending on the field type. + + data mask /0, 0, 0, 0, 1, 0, 0, 0, 0/ data latitude /-30.0, -30.0, -30.0, 0., 0., 0., 25.0, 25.0, 25.0/ - data terrain_land /0., 0., 0., 50.0, 75.0, 80.0, 0., 0., 0./ + data terrain_land /0., 0., 0., 0., 75.0, 0., 0., 0., 0./ + + data soilt_climo /0., 0., 0., 0., 2., 0., 0., 0., 0./ + +! The field values input to the search routine. The +! flag value indicates an unmapped point that must +! be replaced. + + data field/0., 0., 0., 0., -9999.9, 0., 0., 0., 0./ + +! The complete list of field numbers the search +! routine works for. + + data default_field_num /0, 1, 7, 11, 21, & + 30, 65, 66, 83, 85, & + 86, 91, 92, 223, 224, & + 225, 226, 227, 228, 229, 230/ - data soilt_climo /285.0, 285.0, 285.0, 0., 0., 0., 278.0, 278.0, 278.0/ +! The field value that should be returned by the +! search routine for each field value. If the returned +! value does not match, this test fails. - data field/0., 0., 0., 0., 0., 0., 0., 0., 0./ + data default_field_val /0.0, 1.0, 75.0, 300.0, 265.0, & + 30.0, 0.0, 0.0, 0.01, 280.0, & + 0.18, 0.0, 1.0, 0.0, 2.0, & + -99999.9, 0.5, 0.5, 0.5, 1.0, 11.0/ call mpi_init(ierr) - print*,'hello world' + print*,'RUN TESTS TO CHECK DEFAULT LOGIC' - field_num = 0 + do i = 1, num_default_tests + + field_num = default_field_num(i) + field_updated = field - call search (field, mask, idim, jdim, tile, field_num, latitude, terrain_land, & + print*,'CHECK DEFAULT LOGIC FOR FIELD NUMBER ',field_num + + call search (field_updated, mask, idim, jdim, tile, field_num, latitude, terrain_land, & soilt_climo) + if (field_updated(2,2) /= default_field_val(i)) then + print*,'TEST FAILED ',field_updated(2,2), default_field_val(i) + stop 2 + endif + + enddo + call mpi_finalize(ierr) + print*,'DONE' + end program test_search_util From c65150ce5afd81e0d77148d937a314fc7e494a3c Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 14 Apr 2021 19:18:07 +0000 Subject: [PATCH 5/9] Add remaining tests. Add some comments. Fixes #279 --- tests/chgres_cube/ftst_search_util.F90 | 102 +++++++++++++++++++------ 1 file changed, 80 insertions(+), 22 deletions(-) diff --git a/tests/chgres_cube/ftst_search_util.F90 b/tests/chgres_cube/ftst_search_util.F90 index 7bd2179ca..a138ad352 100644 --- a/tests/chgres_cube/ftst_search_util.F90 +++ b/tests/chgres_cube/ftst_search_util.F90 @@ -1,53 +1,62 @@ program test_search_util +! Test search_util using a simple 3x3 fv3 tile. Two types +! of tests are performed. First, a missing value is +! replaced with a valid neighboring value. Second, a missing +! value is replaced by a default value. This can happen +! for an isolated island located far from a valid neighbor. + use mpi use esmf use search_util implicit none -! Test uses a simple 3x3 fv3 tile. - integer, parameter :: idim = 3 integer, parameter :: jdim = 3 integer, parameter :: tile = 1 + integer, parameter :: num_default_tests = 21 integer :: field_num, ierr, i - integer(esmf_kind_i8) :: mask(idim,jdim) + integer(esmf_kind_i8) :: mask_search1(idim,jdim) + integer(esmf_kind_i8) :: mask_search2(idim,jdim) + integer(esmf_kind_i8) :: mask_default(idim,jdim) + integer :: default_field_num(num_default_tests) - real(esmf_kind_r8) :: field(idim,jdim) + real(esmf_kind_r8) :: default_field_val(num_default_tests) + real(esmf_kind_r8) :: field_default(idim,jdim) real(esmf_kind_r8) :: field_updated(idim,jdim) + real(esmf_kind_r8) :: field_search1(idim,jdim) + real(esmf_kind_r8) :: field_search2(idim,jdim) real(esmf_kind_r8) :: latitude(idim,jdim) real(esmf_kind_r8) :: terrain_land(idim,jdim) real(esmf_kind_r8) :: soilt_climo(idim,jdim) +!-------------------------------------------------------- ! These variables are used to test the 'default' ! search routine option (i.e., when the search ! fails, a default must be used) - - integer, parameter :: num_default_tests = 21 - integer :: default_field_num(num_default_tests) - real(esmf_kind_r8) :: default_field_val(num_default_tests) +!-------------------------------------------------------- ! Definition of the mask. The '1' indicates an isolated ! island or lake depending on the field type. - data mask /0, 0, 0, 0, 1, 0, 0, 0, 0/ + data mask_default /0, 0, 0, 0, 1, 0, 0, 0, 0/ data latitude /-30.0, -30.0, -30.0, 0., 0., 0., 25.0, 25.0, 25.0/ data terrain_land /0., 0., 0., 0., 75.0, 0., 0., 0., 0./ - data soilt_climo /0., 0., 0., 0., 2., 0., 0., 0., 0./ + data soilt_climo /0., 0., 0., 0., 2., 0., 0., 0., 0./ ! soil type ! The field values input to the search routine. The -! flag value indicates an unmapped point that must +! flag value (-9999.9) indicates an unmapped point that must ! be replaced. - data field/0., 0., 0., 0., -9999.9, 0., 0., 0., 0./ - -! The complete list of field numbers the search -! routine works for. + data field_default/0., 0., 0., 0., -9999.9, 0., 0., 0., 0./ + +! The complete list of field numbers the default search +! works for. data default_field_num /0, 1, 7, 11, 21, & 30, 65, 66, 83, 85, & @@ -56,36 +65,85 @@ program test_search_util ! The field value that should be returned by the ! search routine for each field value. If the returned -! value does not match, this test fails. +! value does not match this value, the test fails. data default_field_val /0.0, 1.0, 75.0, 300.0, 265.0, & 30.0, 0.0, 0.0, 0.01, 280.0, & 0.18, 0.0, 1.0, 0.0, 2.0, & -99999.9, 0.5, 0.5, 0.5, 1.0, 11.0/ +!-------------------------------------------------------- +! These variables are used for the two search option +! tests. Both tests use vegetation greenness. For this +! test, the logic is is independent of the field type. +!-------------------------------------------------------- + +! Test 1 - The missing value at (2,2) should be replaced +! with the valid value at (1,1). + + data mask_search1 /1, 0, 0, 0, 1, 0, 0, 0, 0/ + data field_search1 /.88, 0., 0., 0., -9999.9, 0., 0., 0., 0./ + +! Test 2 - The missing value at (3,3) should be replaced +! with the valid value at (2,2). + + data mask_search2 /0, 0, 0, 0, 1, 0, 0, 0, 1/ + data field_search2 /0., 0., 0., 0., .88, 0., 0., 0., -9999.9/ + + print*,"Starting test of search util." + call mpi_init(ierr) - print*,'RUN TESTS TO CHECK DEFAULT LOGIC' + print*,'Run test 1 to check search logic.' + + field_num = 226 ! veg greenness + field_updated = field_search1 + + call search (field_updated, mask_search1, idim, jdim, tile, field_num) + + if (field_updated(2,2) /= field_updated(1,1)) then + print*,'TEST FAILED ',field_updated(2,2), field_updated(1,1) + stop 2 + endif + + print*,'Run test 2 to check search logic.' + + field_num = 226 + field_updated = field_search2 + + call search (field_updated, mask_search2, idim, jdim, tile, field_num) + + if (field_updated(2,2) /= field_updated(3,3)) then + print*,'TEST FAILED ',field_updated(2,2), field_updated(3,3) + stop 3 + else + print*,'OK' + endif + + print*,'Run tests to check default logic.' do i = 1, num_default_tests field_num = default_field_num(i) - field_updated = field + field_updated = field_default print*,'CHECK DEFAULT LOGIC FOR FIELD NUMBER ',field_num - call search (field_updated, mask, idim, jdim, tile, field_num, latitude, terrain_land, & - soilt_climo) + call search (field_updated, mask_default, idim, jdim, tile, field_num, & + latitude, terrain_land, soilt_climo) if (field_updated(2,2) /= default_field_val(i)) then print*,'TEST FAILED ',field_updated(2,2), default_field_val(i) - stop 2 + stop 4 + else + + print*,'OK' endif enddo call mpi_finalize(ierr) - print*,'DONE' + print*,"SUCCESS!" end program test_search_util From bca0faf8869eeb48e63385f29a3eab1aae885ef5 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 16 Apr 2021 19:35:02 +0000 Subject: [PATCH 6/9] Convert search util test to mpi. Fixes #279. --- tests/chgres_cube/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/chgres_cube/CMakeLists.txt b/tests/chgres_cube/CMakeLists.txt index ad34362b0..53ec10879 100644 --- a/tests/chgres_cube/CMakeLists.txt +++ b/tests/chgres_cube/CMakeLists.txt @@ -80,7 +80,6 @@ add_mpi_test(ftst_program_setup add_executable(ftst_search_util "${CMAKE_SOURCE_DIR}/sorc/chgres_cube.fd/search_util.F90" ftst_search_util.F90) -add_test(NAME ftst_search_util COMMAND ftst_search_util) target_link_libraries( ftst_search_util esmf @@ -88,3 +87,10 @@ target_link_libraries( if(OpenMP_Fortran_FOUND) target_link_libraries(ftst_search_util OpenMP::OpenMP_Fortran) endif() + +# Cause test to be run with MPI. The search routine was +# written to work on a single task. So set NUMPROCS to 1. +add_mpi_test(ftst_search_util + EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/ftst_search_util + NUMPROCS 1 + TIMEOUT 60) From c05b1e4762113ca57341c56a977aba1ef043fece Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 20 Apr 2021 13:10:10 +0000 Subject: [PATCH 7/9] Add four new SST tests so each 'if' branch of routine 'sst_guess' is tested. Fixes #279 --- tests/chgres_cube/ftst_search_util.F90 | 47 +++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/tests/chgres_cube/ftst_search_util.F90 b/tests/chgres_cube/ftst_search_util.F90 index a138ad352..13c5ffdd3 100644 --- a/tests/chgres_cube/ftst_search_util.F90 +++ b/tests/chgres_cube/ftst_search_util.F90 @@ -15,7 +15,8 @@ program test_search_util integer, parameter :: idim = 3 integer, parameter :: jdim = 3 integer, parameter :: tile = 1 - integer, parameter :: num_default_tests = 21 + integer, parameter :: num_default_tests = 20 + integer, parameter :: num_default_sst_tests = 4 integer :: field_num, ierr, i integer(esmf_kind_i8) :: mask_search1(idim,jdim) @@ -24,11 +25,13 @@ program test_search_util integer :: default_field_num(num_default_tests) real(esmf_kind_r8) :: default_field_val(num_default_tests) + real(esmf_kind_r8) :: default_sst_val(num_default_sst_tests) real(esmf_kind_r8) :: field_default(idim,jdim) real(esmf_kind_r8) :: field_updated(idim,jdim) real(esmf_kind_r8) :: field_search1(idim,jdim) real(esmf_kind_r8) :: field_search2(idim,jdim) real(esmf_kind_r8) :: latitude(idim,jdim) + real(esmf_kind_r8) :: latitude_sst(num_default_sst_tests) real(esmf_kind_r8) :: terrain_land(idim,jdim) real(esmf_kind_r8) :: soilt_climo(idim,jdim) @@ -55,10 +58,11 @@ program test_search_util data field_default/0., 0., 0., 0., -9999.9, 0., 0., 0., 0./ -! The complete list of field numbers the default search -! works for. +! A list of field numbers the default search +! works for. SST is handled with separate data statements +! below. - data default_field_num /0, 1, 7, 11, 21, & + data default_field_num /0, 1, 7, 21, & 30, 65, 66, 83, 85, & 86, 91, 92, 223, 224, & 225, 226, 227, 228, 229, 230/ @@ -67,11 +71,20 @@ program test_search_util ! search routine for each field value. If the returned ! value does not match this value, the test fails. - data default_field_val /0.0, 1.0, 75.0, 300.0, 265.0, & + data default_field_val /0.0, 1.0, 75.0, 265.0, & 30.0, 0.0, 0.0, 0.01, 280.0, & 0.18, 0.0, 1.0, 0.0, 2.0, & -99999.9, 0.5, 0.5, 0.5, 1.0, 11.0/ +! For SST, test the default for four latitudes to ensure +! all 'if' branches of routine 'sst_guess' are invoked. +! If the returned value does not match "default_sst_val", +! the test failes. + + data default_sst_val /273.16, 286.5785, 300.0, 273.16/ + + data latitude_sst /75.0, 45.0, 0.0, -65.0/ + !-------------------------------------------------------- ! These variables are used for the two search option ! tests. Both tests use vegetation greenness. For this @@ -142,6 +155,30 @@ program test_search_util enddo + print*,'Run tests to check default logic for SST.' + + do i = 1, num_default_sst_tests + + field_num = 11 + field_updated = field_default + + latitude(2,2) = latitude_sst(i) + + print*,'CHECK DEFAULT LOGIC FOR FIELD NUMBER ',field_num + + call search (field_updated, mask_default, idim, jdim, tile, field_num, & + latitude, terrain_land, soilt_climo) + + if (abs(field_updated(2,2)-default_sst_val(i)) > 0.00001) then + print*,'TEST FAILED ', field_updated(2,2),default_sst_val(i) + stop 5 + else + + print*,'OK' + endif + + enddo + call mpi_finalize(ierr) print*,"SUCCESS!" From 518b43762ea45c8f90a4d788298528f51de7d9a3 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 20 Apr 2021 13:54:46 +0000 Subject: [PATCH 8/9] Update documentation and print statements. Fixes #279 --- tests/chgres_cube/ftst_search_util.F90 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/chgres_cube/ftst_search_util.F90 b/tests/chgres_cube/ftst_search_util.F90 index 13c5ffdd3..254580438 100644 --- a/tests/chgres_cube/ftst_search_util.F90 +++ b/tests/chgres_cube/ftst_search_util.F90 @@ -5,6 +5,8 @@ program test_search_util ! replaced with a valid neighboring value. Second, a missing ! value is replaced by a default value. This can happen ! for an isolated island located far from a valid neighbor. +! +! author: George Gayno (george.gayno@noaa.gov) use mpi use esmf @@ -145,12 +147,13 @@ program test_search_util call search (field_updated, mask_default, idim, jdim, tile, field_num, & latitude, terrain_land, soilt_climo) - if (field_updated(2,2) /= default_field_val(i)) then - print*,'TEST FAILED ',field_updated(2,2), default_field_val(i) + if (abs(field_updated(2,2)-default_field_val(i)) > 0.00001) then + print*,'TEST FAILED ' + print*,'VALUE SHOULD BE:', default_sst_val(i) + print*,'VALUE FROM TEST:', field_updated(2,2) stop 4 else - - print*,'OK' + print*,'OK' endif enddo @@ -165,12 +168,15 @@ program test_search_util latitude(2,2) = latitude_sst(i) print*,'CHECK DEFAULT LOGIC FOR FIELD NUMBER ',field_num + print*,'AT LATITUDE ',latitude_sst(i) call search (field_updated, mask_default, idim, jdim, tile, field_num, & latitude, terrain_land, soilt_climo) if (abs(field_updated(2,2)-default_sst_val(i)) > 0.00001) then - print*,'TEST FAILED ', field_updated(2,2),default_sst_val(i) + print*,'TEST FAILED ' + print*,'SST SHOULD BE:', default_sst_val(i) + print*,'SST FROM TEST:', field_updated(2,2) stop 5 else From d69114e835c9975215dcfc423d9458fffd7e4054 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 20 Apr 2021 14:37:24 +0000 Subject: [PATCH 9/9] Fix bug in chgres_cube/sst_guess routine to correctly work for all points poleward of 60 degrees. Part of #279 Fixes #441 --- sorc/chgres_cube.fd/search_util.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sorc/chgres_cube.fd/search_util.F90 b/sorc/chgres_cube.fd/search_util.F90 index 844c22194..6d5016314 100644 --- a/sorc/chgres_cube.fd/search_util.F90 +++ b/sorc/chgres_cube.fd/search_util.F90 @@ -230,7 +230,7 @@ subroutine sst_guess(latitude, sst) real(esmf_kind_r8), intent(out) :: sst - if (latitude >= 60.0) then + if (abs(latitude) >= 60.0) then sst = 273.16 elseif (abs(latitude) <= 30.0) then sst = 300.0