Fix infinite loop with words greater than 80 characters in write_message. Closes #196 on github.

This commit is contained in:
Paul Romano 2013-07-12 19:06:29 -04:00
parent 21d3a51093
commit e178c7b16d

View file

@ -185,10 +185,11 @@ contains
integer, optional :: level ! verbosity level
integer :: i_start ! starting position
integer :: i_end ! ending position
integer :: line_wrap ! length of line
integer :: length ! length of message
integer :: i_start ! starting position
integer :: i_end ! ending position
integer :: line_wrap ! length of line
integer :: length ! length of message
integer :: last_space ! index of last space (relative to start)
! Set length of line
line_wrap = 80
@ -209,11 +210,17 @@ contains
else
! Determine last space in current line
i_end = i_start + index(message(i_start+1:i_start+line_wrap), &
last_space = index(message(i_start+1:i_start+line_wrap), &
' ', BACK=.true.)
if (last_space == 0) then
i_end = min(length + 1, i_start+line_wrap) - 1
write(ou, fmt='(1X,A)') message(i_start+1:i_end)
else
i_end = i_start + last_space
write(ou, fmt='(1X,A)') message(i_start+1:i_end-1)
end if
! Write up to last space
write(ou, fmt='(1X,A)') message(i_start+1:i_end-1)
! Advance starting position
i_start = i_end