Updates the progress bar with new values
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(progress_bar), | intent(inout) | :: | self | Progres bar object |
||
| integer(kind=I8B), | intent(in) | :: | i | The current loop index of the progress loop |
||
| character(len=*), | intent(in), | optional | :: | message | An optional message to display to the right of the progress bar |
subroutine io_progress_bar_update(self,i,message)
!! author: David A. Minton
!!
!! Updates the progress bar with new values
implicit none
! Arguments
class(progress_bar), intent(inout) :: self
!! Progres bar object
integer(I8B), intent(in) :: i
!! The current loop index of the progress loop
character(len=*), intent(in), optional :: message
!! An optional message to display to the right of the progress bar
! Internals
real(DP) :: frac
integer(I4B) :: bar_pos
!! The current integer position of the progress bar
logical :: update = .false.
! Compute the current position
frac = real(i,kind=DP) / real(self%loop_length,kind=DP)
bar_pos = min(int(ceiling(frac * self%PBARSIZE),kind=I4B),self%PBARSIZE)
if (bar_pos /= self%bar_pos) then
! Fill in the bar character up to the current position
self%barstr(bar_pos:bar_pos) = barchar
update = .true.
self%bar_pos = bar_pos
end if
if (present(message)) then
if (message /= self%message) then
update = .true.
self%message = message
end if
end if
if (update) write(*,fmt=self%fmt) char(13),self%barstr,trim(adjustl(self%message))
return
end subroutine io_progress_bar_update