Convert the lower case characters of a string to upper case one.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string |
String to be converted. |
Converted string.
elemental function upper_case(string) !< Convert the lower case characters of a string to upper case one. character(len=*), intent(in) :: string !< String to be converted. character(len=len(string)) :: upper_case !< Converted string. integer :: n1 !< Characters counter. integer :: n2 !< Characters counter. character(len=26), parameter :: upper_alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' !< Upper case alphabet. character(len=26), parameter :: lower_alphabet = 'abcdefghijklmnopqrstuvwxyz' !< Lower case alphabet. upper_case = string do n1=1, len(string) n2 = index(lower_alphabet, string(n1:n1)) if (n2>0) upper_case(n1:n1) = upper_alphabet(n2:n2) enddo endfunction upper_case