Skip to content

Commit

Permalink
Remove duplicate 'to_upper'. One version was a function
Browse files Browse the repository at this point in the history
and the other was a subroutine. Only the function was
being used by chgres_cube. The unit test was using the
subroutine. So the test was updated to use the function.

Fixes ufs-community#303
  • Loading branch information
GeorgeGayno-NOAA committed Feb 26, 2021
1 parent 693dd0e commit 72eb0ff
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 43 deletions.
26 changes: 0 additions & 26 deletions sorc/chgres_cube.fd/grib2_util.F90
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,4 @@ subroutine convert_omega(omega,p,t,q,clb,cub)

end subroutine convert_omega

!> Convert string from lower to uppercase.
!! @author Clive Page
!!
!! Adapted from http://www.star.le.ac.uk/~cgp/fortran.html (25 May 2012)
!!
!! @param[in] strIn string to convert
!! @return strOut string in uppercase
function to_upper(strIn) result(strOut)

implicit none

character(len=*), intent(in) :: strIn
character(len=len(strIn)) :: strOut
integer :: i,j

do i = 1, len(strIn)
j = iachar(strIn(i:i))
if (j>= iachar("a") .and. j<=iachar("z") ) then
strOut(i:i) = achar(iachar(strIn(i:i))-32)
else
strOut(i:i) = strIn(i:i)
end if
end do

end function to_upper

end module grib2_util
7 changes: 3 additions & 4 deletions sorc/chgres_cube.fd/input_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4580,7 +4580,6 @@ end subroutine read_input_sfc_netcdf_file
subroutine read_input_sfc_grib2_file(localpet)

use wgrib2api
use grib2_util, only : to_upper
use program_setup, only : vgtyp_from_climo, sotyp_from_climo
use model_grid, only : input_grid_type
use search_util
Expand All @@ -4593,9 +4592,9 @@ subroutine read_input_sfc_grib2_file(localpet)
character(len=250) :: the_file
character(len=250) :: geo_file
character(len=20) :: vname, vname_file,slev

character(len=50) :: method

character(len=50) :: method
character(len=20) :: to_upper
integer :: rc, varnum, iret, i, j,k
integer :: ncid2d, varid, varsize
integer, parameter :: icet_default = 265.0
Expand Down
17 changes: 9 additions & 8 deletions sorc/chgres_cube.fd/utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ subroutine error_handler(string, rc)

end subroutine error_handler

!> @brief Error handler for netcdf
!> Error handler for netcdf
!!
!! @param[in] err error status code
!! @param[in] string error message
Expand All @@ -49,17 +49,18 @@ subroutine netcdf_err( err, string )
return
end subroutine netcdf_err

!> @brief Convert from lower to uppercase.
!> Convert string from lower to uppercase.
!! @author Clive Page
!!
!! Adapted from http://www.star.le.ac.uk/~cgp/fortran.html (25 May 2012)
!!
!! @param[in,out] strIn string to convert
subroutine to_upper(strIn)
!! @param[in] strIn string to convert
!! @return strOut string in uppercase
function to_upper(strIn) result(strOut)

implicit none

character(len=*), intent(inout) :: strIn
character(len=*), intent(in) :: strIn
character(len=len(strIn)) :: strOut
integer :: i,j

Expand All @@ -71,10 +72,10 @@ subroutine to_upper(strIn)
strOut(i:i) = strIn(i:i)
end if
end do
strIn(:) = strOut(:)
end subroutine to_upper

!> @brief Convert from upper to lowercase
end function to_upper

!> Convert from upper to lowercase
!! @author Clive Page
!!
!! Adapted from http://www.star.le.ac.uk/~cgp/fortran.html (25 May 2012)
Expand Down
9 changes: 4 additions & 5 deletions tests/chres_cube/ftst_utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ program ftst_utils

logical :: match_result

character(len=12) :: to_upper
character(len=12) :: test_input_char_1, test_input_char_2, u_st_base, l_st_base

u_st_base="STAGGERLOCCE"
Expand All @@ -29,13 +30,11 @@ program ftst_utils
call to_lower(test_input_char_1)
match_result = test_input_char_1 == l_st_base
if (.not.match_result) then
stop
stop 1
endif

call to_upper(test_input_char_2)
match_result = test_input_char_2 == u_st_base
if (.not.match_result) then
stop
if (to_upper(test_input_char_2) /= u_st_base) then
stop 2
endif

!-------------------------------------------------------------------------
Expand Down

0 comments on commit 72eb0ff

Please sign in to comment.