Routine that converts a (sub-)string to lowercase author: P J Knight, CCFE, Culham Science Centre string : input string : character string of interest start : optional input integer : starting character for conversion finish : optional input integer : final character for conversion This routine converts the specified section of a string to lowercase. By default, the whole string will be converted. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(inout) | :: | string | |||
integer, | intent(in), | optional | :: | start | ||
integer, | intent(in), | optional | :: | finish |
subroutine lower_case(string,start,finish)
!! Routine that converts a (sub-)string to lowercase
!! author: P J Knight, CCFE, Culham Science Centre
!! string : input string : character string of interest
!! start : optional input integer : starting character for conversion
!! finish : optional input integer : final character for conversion
!! This routine converts the specified section of a string
!! to lowercase. By default, the whole string will be converted.
!! None
!
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
implicit none
! Arguments
character(len=*), intent(inout) :: string
integer, optional, intent(in) :: start,finish
! Local variables
character(len=1) :: letter
character(len=27), parameter :: lowtab = 'abcdefghijklmnopqrstuvwxyz_'
integer :: loop, i
integer :: first, last
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (present(start)) then
first = start
else
first = 1
end if
if (present(finish)) then
last = finish
else
last = len(string)
end if
if (first <= last) then
do loop = first,last
letter = string(loop:loop)
i = index('ABCDEFGHIJKLMNOPQRSTUVWXYZ_',letter)
if (i > 0) string(loop:loop) = lowtab(i:i)
end do
end if
end subroutine lower_case