mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Fix infinite loop with words greater than 80 characters in write_message. Closes #196 on github.
This commit is contained in:
parent
21d3a51093
commit
e178c7b16d
1 changed files with 13 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue