Strips string of all blank spaces
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string |
function utility_strip(string)!
!=============================!
! !
!! Strips string of all blank spaces
! !
!=============================!
use w90_io, only: maxlen
implicit none
character(len=*), intent(in) :: string
character(len=maxlen) :: utility_strip
integer :: ispc, ipos, ilett, icount
! Initialise
utility_strip = repeat(' ', maxlen)
ispc = ichar(' ')
icount = 0
do ipos = 1, len(string)
ilett = ichar(string(ipos:ipos))
if (ilett .ne. ispc) then
icount = icount + 1
utility_strip(icount:icount) = string(ipos:ipos)
endif
enddo
utility_strip = trim(utility_strip)
return
end function utility_strip