Convert string in input from upper case to lower case and return the lower case string as output.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | s |
String to be converted in lowercase |
String converted to lowercase
function str_to_lower(s)
!! Convert string in input from upper case to lower case and return
!! the lower case string as output.
implicit none
character(len=*), intent(in) :: s
!! String to be converted in lowercase
character(len(s)) :: str_to_lower
!! String converted to lowercase
integer :: ic, i
character(26), parameter :: capital = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
character(26), parameter :: lower = 'abcdefghijklmnopqrstuvwxyz'
str_to_lower = s
do i=1, len_trim(s)
ic = index(capital, s(i:i))
if(ic > 0) str_to_lower(i:i) = lower(ic:ic)
end do
return
end function str_to_lower