lowercase Function

public pure function lowercase(text) result(out)

Converts an input string to all lowercase characters.

Useful for normalizing namelist inputs and performing case-insensitive comparison of species names or boundary conditions.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: text

The source string to convert.

Return Value character(len=len)


Source Code

   pure function lowercase(text) result(out)
      character(len=*), intent(in) :: text
      character(len=len(text)) :: out

      integer :: i
      integer :: code

      do i = 1, len(text)
         code = iachar(text(i:i))
         if (code >= iachar('A') .and. code <= iachar('Z')) then
            out(i:i) = achar(code + iachar('a') - iachar('A'))
          else
            out(i:i) = text(i:i)
         end if
      end do
   end function lowercase