From e3ad5a007bf57bdab88e2a9ef9b25bfa16d16d83 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Thu, 18 Feb 2021 08:56:30 -0700 Subject: [PATCH 1/2] adding program_setup test --- tests/chres_cube/CMakeLists.txt | 40 +++++++++++++++++++------ tests/chres_cube/config.nml | 23 ++++++++++++++ tests/chres_cube/ftst_program_setup.F90 | 20 +++++++++++++ 3 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 tests/chres_cube/config.nml create mode 100644 tests/chres_cube/ftst_program_setup.F90 diff --git a/tests/chres_cube/CMakeLists.txt b/tests/chres_cube/CMakeLists.txt index f7c3b64ae..bf2dd2210 100644 --- a/tests/chres_cube/CMakeLists.txt +++ b/tests/chres_cube/CMakeLists.txt @@ -3,22 +3,20 @@ # # George Gayno, Lin Gan, Ed Hartnett -set(fortran_src - "${CMAKE_SOURCE_DIR}/sorc/chgres_cube.fd/utils.f90" - ftst_utils.F90) - if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8 -convert big_endian -assume byterecl") elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-0 -fdefault-real-8 -fconvert=big-endian") endif() -include_directories( - ${PROJECT_SOURCE_DIR} -) +include_directories(${PROJECT_SOURCE_DIR}) + +# Copy necessary test files. +execute_process( COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/config.nml + ${CMAKE_CURRENT_BINARY_DIR}/fort.41) -set(exe_name ftst_utils) -add_executable(${exe_name} ${fortran_src}) +add_executable(ftst_utils "${CMAKE_SOURCE_DIR}/sorc/chgres_cube.fd/utils.f90" ftst_utils.F90) add_test(NAME ftst_utils COMMAND ftst_utils) target_link_libraries( ftst_utils @@ -37,6 +35,30 @@ if(OpenMP_Fortran_FOUND) target_link_libraries(ftst_utils OpenMP::OpenMP_Fortran) endif() +add_executable(ftst_program_setup "${CMAKE_SOURCE_DIR}/sorc/chgres_cube.fd/input_data.F90" + "${CMAKE_SOURCE_DIR}/sorc/chgres_cube.fd/model_grid.F90" + "${CMAKE_SOURCE_DIR}/sorc/chgres_cube.fd/program_setup.f90" + "${CMAKE_SOURCE_DIR}/sorc/chgres_cube.fd/grib2_util.F90" + "${CMAKE_SOURCE_DIR}/sorc/chgres_cube.fd/search_util.f90" + "${CMAKE_SOURCE_DIR}/sorc/chgres_cube.fd/utils.f90" + ftst_program_setup.F90) +add_test(NAME ftst_program_setup COMMAND ftst_program_setup) +target_link_libraries( + ftst_program_setup + nemsio::nemsio + sfcio::sfcio + sigio::sigio + bacio::bacio_4 + sp::sp_d + w3nco::w3nco_d + esmf + wgrib2::wgrib2_lib + wgrib2::wgrib2_api + MPI::MPI_Fortran + NetCDF::NetCDF_Fortran) +if(OpenMP_Fortran_FOUND) + target_link_libraries(ftst_program_setup OpenMP::OpenMP_Fortran) +endif() diff --git a/tests/chres_cube/config.nml b/tests/chres_cube/config.nml new file mode 100644 index 000000000..7d47c9b8d --- /dev/null +++ b/tests/chres_cube/config.nml @@ -0,0 +1,23 @@ +&config + mosaic_file_target_grid="/scratch1/NCEPDEV/da/George.Gayno/noscrub/reg_tests/chgres_cube/fix/C96/C96_mosaic.nc" + fix_dir_target_grid="/scratch1/NCEPDEV/da/George.Gayno/noscrub/reg_tests/chgres_cube/fix/C96/fix_sfc" + orog_dir_target_grid="/scratch1/NCEPDEV/da/George.Gayno/noscrub/reg_tests/chgres_cube/fix/C96" + orog_files_target_grid="C96_oro_data.tile1.nc","C96_oro_data.tile2.nc","C96_oro_data.tile3.nc","C96_oro_data.tile4.nc","C96_oro_data.tile5.nc","C96_oro_data.tile6.nc" + vcoord_file_target_grid="/scratch1/NCEPDEV/da/George.Gayno/ufs_utils.git/UFS_UTILS/reg_tests/chgres_cube/../../fix/fix_am/global_hyblev.l64.txt" + data_dir_input_grid="/scratch1/NCEPDEV/da/George.Gayno/noscrub/reg_tests/chgres_cube/input_data/fv3.nemsio" + atm_files_input_grid="gfs.t12z.atmf000.nemsio" + sfc_files_input_grid="gfs.t12z.sfcf000.nemsio" + cycle_mon=07 + cycle_day=04 + cycle_hour=12 + convert_atm=.true. + convert_sfc=.true. + convert_nst=.true. + input_type="gaussian_nemsio" + tracers="sphum","liq_wat","o3mr","ice_wat","rainwat","snowwat","graupel" + tracers_input="spfh","clwmr","o3mr","icmr","rwmr","snmr","grle" + regional=0 + halo_bndy=0 + halo_blend=0 + / + \ No newline at end of file diff --git a/tests/chres_cube/ftst_program_setup.F90 b/tests/chres_cube/ftst_program_setup.F90 new file mode 100644 index 000000000..0b48b3a37 --- /dev/null +++ b/tests/chres_cube/ftst_program_setup.F90 @@ -0,0 +1,20 @@ +! Unit test for chres_cube utility, input_data.F90. +! +! Ed Hartnett 2/16/21 + +program ftst_program_setup + use esmf + use netcdf + use program_setup + implicit none + + + print*, "Starting test of program_setup." + + print*, "testing read_setup_namelist..." + + + print*, "OK" + call read_setup_namelist() + print*, "SUCCESS!" +end program ftst_program_setup From 848a31230c6a46144bbfaa6dca972a73d32d1830 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Thu, 18 Feb 2021 09:30:15 -0700 Subject: [PATCH 2/2] more test on program_setup test --- tests/chres_cube/ftst_program_setup.F90 | 30 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/tests/chres_cube/ftst_program_setup.F90 b/tests/chres_cube/ftst_program_setup.F90 index 0b48b3a37..8bb3b02c0 100644 --- a/tests/chres_cube/ftst_program_setup.F90 +++ b/tests/chres_cube/ftst_program_setup.F90 @@ -7,14 +7,36 @@ program ftst_program_setup use netcdf use program_setup implicit none - print*, "Starting test of program_setup." print*, "testing read_setup_namelist..." - - - print*, "OK" call read_setup_namelist() + if (cycle_mon .ne. 7 .or. cycle_day .ne. 4 .or. cycle_hour .ne. 12) stop 4 + if (.not. convert_atm .or. .not. convert_sfc .or. .not. convert_nst) stop 5 + if (regional .ne. 0 .or. halo_bndy .ne. 0 .or. halo_blend .ne. 0) stop 6 + if (trim(mosaic_file_target_grid) .ne. "/scratch1/NCEPDEV/da/George.Gayno/noscrub/reg_tests/chgres_cube/fix/C96/C96_mosaic.nc") stop 7 + if (trim(fix_dir_target_grid) .ne. "/scratch1/NCEPDEV/da/George.Gayno/noscrub/reg_tests/chgres_cube/fix/C96/fix_sfc") stop 8 + if (trim(orog_dir_target_grid) .ne. "/scratch1/NCEPDEV/da/George.Gayno/noscrub/reg_tests/chgres_cube/fix/C96/") stop 9 + if (trim(vcoord_file_target_grid) .ne. "/scratch1/NCEPDEV/da/George.Gayno/ufs_utils.git/UFS_UTILS/reg_tests/chgres_cube/../../fix/fix_am/global_hyblev.l64.txt") stop 10 + if (trim(data_dir_input_grid) .ne. "/scratch1/NCEPDEV/da/George.Gayno/noscrub/reg_tests/chgres_cube/input_data/fv3.nemsio") stop 11 + if (trim(atm_files_input_grid(1)) .ne. 'gfs.t12z.atmf000.nemsio') stop 12 + if (trim(sfc_files_input_grid(1)) .ne. 'gfs.t12z.sfcf000.nemsio') stop 13 + if (varmap_file .ne. "NULL") stop 14 + if (thomp_mp_climo_file .ne. "NULL") stop 16 + if (trim(cres_target_grid) .ne. "C96") stop 17 + if (atm_weight_file .ne. "NULL") stop 18 + if (trim(input_type) .ne. "gaussian_nemsio") stop 19 + if (trim(external_model) .ne. "GFS") stop 20 + if (num_tracers .ne. 7) stop 21 + if (tracers(1) .ne. "sphum" .or. tracers(2) .ne. "liq_wat" .or. tracers(3) .ne. "o3mr" .or. & + tracers(4) .ne. "ice_wat" .or. tracers(5) .ne. "rainwat" .or. tracers(6) .ne. "snowwat" .or. & + tracers(7) .ne. "graupel") stop 22 + if (tracers_input(1) .ne. "spfh" .or. tracers_input(2) .ne. "clwmr" .or. & + tracers_input(3) .ne. "o3mr" .or. tracers_input(4) .ne. "icmr" .or. & + tracers_input(5) .ne. "rwmr" .or. tracers_input(6) .ne. "snmr" .or. & + tracers_input(7) .ne. "grle") stop 23 + print*, "OK" + print*, "SUCCESS!" end program ftst_program_setup