-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/unit tests for chgres_cube.fd/utils.f90 (#276)
* Create unit-tests for testing to_upper and to_lower. This commit references issue #257 * Add unit test to_upper_lower into CMake build * Clean up build and push for draft pull request * Making following improvement: - Using env parameter to assign source code - Add auther name - Modify comment - Change test failing procedure - rename directory for unit test * turned on testing in workflows * added test as test in cmake * added test as test in cmake * clean up test cmake file * renamed test * cleanup output * cleanup output * moved to new test directory * added tests subdirectory Co-authored-by: Edward Hartnett <[email protected]> Co-authored-by: Edward Hartnett <[email protected]>
- Loading branch information
1 parent
f955ba1
commit edc1af7
Showing
6 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,7 @@ jobs: | |
mkdir build && cd build | ||
cmake .. -DCMAKE_PREFIX_PATH='~;~/jasper' | ||
make -j2 | ||
make test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This is the CMake file for the tests directory of the UFS_UTILS | ||
# project. | ||
# | ||
# Ed Hartnett 2/11/21 | ||
|
||
# Add the test subdirecotries. | ||
add_subdirectory(chres_cube) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This is the cmake build file for the tests directory of the | ||
# UFS_UTILS project. | ||
# | ||
# 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} | ||
) | ||
|
||
set(exe_name ftst_utils) | ||
add_executable(${exe_name} ${fortran_src}) | ||
add_test(NAME ftst_utils COMMAND ftst_utils) | ||
target_link_libraries( | ||
ftst_utils | ||
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_utils OpenMP::OpenMP_Fortran) | ||
endif() | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
! Unit test for to_upper() and to_lower() functions under UFS_UTILS | ||
! package, chres_cube utility. | ||
! | ||
! Lin Gan NCEP/EMC | ||
|
||
program ftst_utils | ||
|
||
|
||
implicit none | ||
|
||
logical :: match_result | ||
|
||
character(len=12) :: test_input_char_1, test_input_char_2, u_st_base, l_st_base | ||
|
||
u_st_base="STAGGERLOCCE" | ||
l_st_base="staggerlocce" | ||
test_input_char_1="sTAGGErLOCCE" | ||
test_input_char_2="staGGErLOCCE" | ||
|
||
print*, "Starting Unit Testing to_upper_lower." | ||
print*, "testing to_lower and to_upper..." | ||
|
||
!------------------------------------------------------------------------- | ||
! Execute testing below by running target function with testing string | ||
! When match_result set to be T - compare to base line is identical | ||
! When match_result set to be F - compare to base line is NOT identical | ||
!------------------------------------------------------------------------- | ||
|
||
call to_lower(test_input_char_1) | ||
match_result = test_input_char_1 == l_st_base | ||
if (.not.match_result) then | ||
stop | ||
endif | ||
|
||
call to_upper(test_input_char_2) | ||
match_result = test_input_char_2 == u_st_base | ||
if (.not.match_result) then | ||
stop | ||
endif | ||
|
||
!------------------------------------------------------------------------- | ||
! Display final result | ||
!------------------------------------------------------------------------- | ||
|
||
print*, "OK" | ||
print*, "SUCCESS!" | ||
|
||
end program ftst_utils |