progress_bar_terminal Subroutine

public subroutine progress_bar_terminal(val, max_val, init)

Print a progress bar on the terminal

Arguments

Type IntentOptional Attributes Name
integer(kind=I4), intent(in) :: val

actual position

integer(kind=I4), intent(in) :: max_val

maximum value reached

logical(kind=I4), intent(in) :: init

progress bar initialization


Called by

proc~~progress_bar_terminal~~CalledByGraph proc~progress_bar_terminal progress_bar_terminal program~test_data_arch test_data_arch program~test_data_arch->proc~progress_bar_terminal

Source Code

   subroutine progress_bar_terminal(val, max_val, init)
   !! Print a progress bar on the terminal
   implicit none
   integer(kind=I4), intent(in) :: val       !! *actual position*
   integer(kind=I4), intent(in) :: max_val   !! *maximum value reached*
   logical(kind=I4), intent(in) :: init      !! *progress bar initialization*

      character(len=102) :: bar
      integer(kind=I4)   :: ival

      if ( init ) then

         write(*, *)

         write(bar, '(a)') '[' // repeat('.', 100) // ']'

         write(*, '(a)', advance = 'no') bar

         return

      endif

      ival = nint( 99.99 * ( real(val, kind = R8) / max_val ) )

      write(bar, '(a)') '[' // repeat('*', ival) // repeat('.', 100 - ival) // ']'

      write(*, '(a)', advance = 'no') repeat(achar(8), 102) // bar

      if ( val == max_val ) then

         write(*, *) ' ... done'

         write(*, *)

      endif

   return
   endsubroutine progress_bar_terminal