From f7cbbb5c8f02fbb3205e439197233170ae43487f Mon Sep 17 00:00:00 2001 From: GeorgeGayno-NOAA <52789452+GeorgeGayno-NOAA@users.noreply.github.com> Date: Fri, 20 Aug 2021 14:33:45 -0400 Subject: [PATCH] Unit test for chgres_cube routine 'read_vcoord_info' (#569) Fixes #499. --- sorc/chgres_cube.fd/atmosphere.F90 | 1 + tests/chgres_cube/CMakeLists.txt | 6 ++ tests/chgres_cube/data/global_hyblev.l28.txt | 30 ++++++++ tests/chgres_cube/ftst_read_vcoord.F90 | 81 ++++++++++++++++++++ 4 files changed, 118 insertions(+) create mode 100755 tests/chgres_cube/data/global_hyblev.l28.txt create mode 100644 tests/chgres_cube/ftst_read_vcoord.F90 diff --git a/sorc/chgres_cube.fd/atmosphere.F90 b/sorc/chgres_cube.fd/atmosphere.F90 index 9c187c6dd..e00568a8a 100644 --- a/sorc/chgres_cube.fd/atmosphere.F90 +++ b/sorc/chgres_cube.fd/atmosphere.F90 @@ -104,6 +104,7 @@ module atmosphere !! target grid public :: atmosphere_driver + public :: read_vcoord_info contains diff --git a/tests/chgres_cube/CMakeLists.txt b/tests/chgres_cube/CMakeLists.txt index a501f9d3f..c86a6f788 100644 --- a/tests/chgres_cube/CMakeLists.txt +++ b/tests/chgres_cube/CMakeLists.txt @@ -26,6 +26,8 @@ execute_process( COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/data/config_gaussian_nemsio.nml ${CMAKE_CURRENT_BINARY_DIR}/data/config_gaussian_nemsio.nml) execute_process( COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/data/config_gfs_grib2.nml ${CMAKE_CURRENT_BINARY_DIR}/data/config_gfs_grib2.nml) +execute_process( COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/data/global_hyblev.l28.txt ${CMAKE_CURRENT_BINARY_DIR}/data/global_hyblev.l28.txt) execute_process( COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/data/config_spectral_sigio.nml ${CMAKE_CURRENT_BINARY_DIR}/data/config_spectral_sigio.nml) execute_process( COMMAND ${CMAKE_COMMAND} -E copy @@ -168,3 +170,7 @@ add_mpi_test(chgres_cube-ftst_surface_nst_landfill EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/ftst_surface_nst_landfill NUMPROCS 1 TIMEOUT 60) + +add_executable(ftst_read_vcoord ftst_read_vcoord.F90) +target_link_libraries(ftst_read_vcoord chgres_cube_lib) +add_test(NAME chgres_cube-ftst_read_vcoord COMMAND ftst_read_vcoord) diff --git a/tests/chgres_cube/data/global_hyblev.l28.txt b/tests/chgres_cube/data/global_hyblev.l28.txt new file mode 100755 index 000000000..7a970725a --- /dev/null +++ b/tests/chgres_cube/data/global_hyblev.l28.txt @@ -0,0 +1,30 @@ + 2 28 + .000 1.00000000 + .009 .98872586 + 11.635 .97440184 + 86.457 .95587239 + 292.577 .93174961 + 701.453 .90058087 + 1381.526 .86097487 + 2389.205 .81178485 + 3757.142 .75234710 + 5481.144 .68274682 + 7508.532 .60405491 + 9731.807 .51845667 + 11991.428 .42919536 + 14089.535 .34029321 + 15812.926 .25608430 + 16959.994 .18066704 + 17364.658 .11741761 + 16912.130 .06867500 + 15613.564 .03495010 + 13671.427 .01432627 + 11343.654 .00393276 + 8913.767 .00037868 + 6678.608 .00000000 + 4844.036 .00000000 + 3376.516 .00000000 + 2210.979 .00000000 + 1290.533 .00000000 + 566.898 .00000000 + .000 .00000000 diff --git a/tests/chgres_cube/ftst_read_vcoord.F90 b/tests/chgres_cube/ftst_read_vcoord.F90 new file mode 100644 index 000000000..cfff79454 --- /dev/null +++ b/tests/chgres_cube/ftst_read_vcoord.F90 @@ -0,0 +1,81 @@ + program vcoord + +! Test the 'read_vcoord_info' routine, which reads +! the 'global_hyblev' files. These files contain +! the definition of the model vertical hybrid levels. +! The levels are defined by two coefficients 'ak' +! and 'bk' as follows: +! +! pressure(level) = ak + (bk * surface pressure) +! +! The 'read_vcoord_info' routine returns the +! number of vertical levels, the number of level +! interfaces (# of levels plus 1), the number of +! level coordinates (two for 'ak' and 'bk') and +! the 'ak' and 'bk' values. All are compared to +! expected values. The sample 'global_hyblev' +! file is set by variable "vcoord_file_target_grid'. +! +! @author George Gayno + + use atmosphere, only : read_vcoord_info, & + vcoord_target, & + nvcoord_target, & + lev_target, & + levp1_target + + use program_setup, only : vcoord_file_target_grid + + implicit none + + integer :: j + + integer, parameter :: LEV_TARGET_EXPECTED=28 ! number of levels. + integer, parameter :: LEVP1_TARGET_EXPECTED=29 ! number of level interfaces. + integer, parameter :: NVCOORD_TARGET_EXPECTED=2 ! number of level coordinates. + + real :: VCOORD_AK_EXPECTED(LEVP1_TARGET_EXPECTED) ! 'ak' values for each interface. + real :: VCOORD_BK_EXPECTED(LEVP1_TARGET_EXPECTED) ! 'bk' values for each interface. + + data VCOORD_AK_EXPECTED /.000, .009, 11.635, & + 86.457, 292.577, 701.453, & + 1381.526, 2389.205, 3757.142, & + 5481.144, 7508.532, 9731.807, & + 11991.428, 14089.535, 15812.926, & + 16959.994, 17364.658, 16912.130, & + 15613.564, 13671.427, 11343.654, & + 8913.767, 6678.608, 4844.036, & + 3376.516, 2210.979, 1290.533, & + 566.898, 0.000/ + + data VCOORD_BK_EXPECTED /1.00000000, .98872586, .97440184, & + .95587239, .93174961, .90058087, & + .86097487, .81178485, .75234710, & + .68274682, .60405491, .51845667, & + .42919536, .34029321, .25608430, & + .18066704, .11741761, .06867500, & + .03495010, .01432627, .00393276, & + .00037868, 0.0, 0.0, & + 0.0, 0.0, 0.0, & + 0.0, 0.0 / + + print*,'Starting test of read_vcoord_info routine' + + vcoord_file_target_grid="./data/global_hyblev.l28.txt" + + call read_vcoord_info + + if (lev_target /= LEV_TARGET_EXPECTED) stop 2 + if (levp1_target /= LEVP1_TARGET_EXPECTED) stop 4 + if (nvcoord_target /= NVCOORD_TARGET_EXPECTED) stop 6 + + do j = 1, levp1_target + if (vcoord_target(j,1) /= VCOORD_AK_EXPECTED(j)) stop 8 + if (vcoord_target(j,2) /= VCOORD_BK_EXPECTED(j)) stop 10 + enddo + + print*,"OK" + + print*,"SUCCESS!" + + end program vcoord