io_progress_bar_module.f90 Source File


This file depends on

sourcefile~~io_progress_bar_module.f90~~EfferentGraph sourcefile~io_progress_bar_module.f90 io_progress_bar_module.f90 sourcefile~base_module.f90 base_module.f90 sourcefile~io_progress_bar_module.f90->sourcefile~base_module.f90 sourcefile~coarray_module.f90 coarray_module.f90 sourcefile~base_module.f90->sourcefile~coarray_module.f90

Files dependent on this one

sourcefile~~io_progress_bar_module.f90~~AfferentGraph sourcefile~io_progress_bar_module.f90 io_progress_bar_module.f90 sourcefile~swiftest_module.f90 swiftest_module.f90 sourcefile~swiftest_module.f90->sourcefile~io_progress_bar_module.f90 sourcefile~bindings_module.f90 bindings_module.f90 sourcefile~bindings_module.f90->sourcefile~swiftest_module.f90 sourcefile~coarray_clone.f90 coarray_clone.f90 sourcefile~coarray_clone.f90->sourcefile~swiftest_module.f90 sourcefile~coarray_collect.f90 coarray_collect.f90 sourcefile~coarray_collect.f90->sourcefile~swiftest_module.f90 sourcefile~collision_check.f90 collision_check.f90 sourcefile~collision_check.f90->sourcefile~swiftest_module.f90 sourcefile~symba_module.f90 symba_module.f90 sourcefile~collision_check.f90->sourcefile~symba_module.f90 sourcefile~collision_generate.f90 collision_generate.f90 sourcefile~collision_generate.f90->sourcefile~swiftest_module.f90 sourcefile~collision_io.f90 collision_io.f90 sourcefile~collision_io.f90->sourcefile~swiftest_module.f90 sourcefile~collision_regime.f90 collision_regime.f90 sourcefile~collision_regime.f90->sourcefile~swiftest_module.f90 sourcefile~collision_resolve.f90 collision_resolve.f90 sourcefile~collision_resolve.f90->sourcefile~swiftest_module.f90 sourcefile~collision_resolve.f90->sourcefile~symba_module.f90 sourcefile~collision_util.f90 collision_util.f90 sourcefile~collision_util.f90->sourcefile~swiftest_module.f90 sourcefile~encounter_check.f90 encounter_check.f90 sourcefile~encounter_check.f90->sourcefile~swiftest_module.f90 sourcefile~encounter_io.f90 encounter_io.f90 sourcefile~encounter_io.f90->sourcefile~swiftest_module.f90 sourcefile~encounter_util.f90 encounter_util.f90 sourcefile~encounter_util.f90->sourcefile~swiftest_module.f90 sourcefile~encounter_util.f90->sourcefile~symba_module.f90 sourcefile~fraggle_generate.f90 fraggle_generate.f90 sourcefile~fraggle_generate.f90->sourcefile~swiftest_module.f90 sourcefile~fraggle_module.f90 fraggle_module.f90 sourcefile~fraggle_generate.f90->sourcefile~fraggle_module.f90 sourcefile~fraggle_generate.f90->sourcefile~symba_module.f90 sourcefile~fraggle_module.f90->sourcefile~swiftest_module.f90 sourcefile~fraggle_util.f90 fraggle_util.f90 sourcefile~fraggle_util.f90->sourcefile~swiftest_module.f90 sourcefile~fraggle_util.f90->sourcefile~fraggle_module.f90 sourcefile~helio_drift.f90 helio_drift.f90 sourcefile~helio_drift.f90->sourcefile~swiftest_module.f90 sourcefile~helio_module.f90 helio_module.f90 sourcefile~helio_drift.f90->sourcefile~helio_module.f90 sourcefile~helio_gr.f90 helio_gr.f90 sourcefile~helio_gr.f90->sourcefile~swiftest_module.f90 sourcefile~helio_gr.f90->sourcefile~helio_module.f90 sourcefile~helio_kick.f90 helio_kick.f90 sourcefile~helio_kick.f90->sourcefile~swiftest_module.f90 sourcefile~helio_kick.f90->sourcefile~helio_module.f90 sourcefile~helio_module.f90->sourcefile~swiftest_module.f90 sourcefile~whm_module.f90 whm_module.f90 sourcefile~helio_module.f90->sourcefile~whm_module.f90 sourcefile~helio_step.f90 helio_step.f90 sourcefile~helio_step.f90->sourcefile~swiftest_module.f90 sourcefile~helio_step.f90->sourcefile~helio_module.f90 sourcefile~helio_util.f90 helio_util.f90 sourcefile~helio_util.f90->sourcefile~swiftest_module.f90 sourcefile~helio_util.f90->sourcefile~helio_module.f90 sourcefile~main.f90 main.f90 sourcefile~main.f90->sourcefile~swiftest_module.f90 sourcefile~operator_cross.f90 operator_cross.f90 sourcefile~operator_cross.f90->sourcefile~swiftest_module.f90 sourcefile~rmvs_discard.f90 rmvs_discard.f90 sourcefile~rmvs_discard.f90->sourcefile~swiftest_module.f90 sourcefile~rmvs_module.f90 rmvs_module.f90 sourcefile~rmvs_discard.f90->sourcefile~rmvs_module.f90 sourcefile~rmvs_encounter_check.f90 rmvs_encounter_check.f90 sourcefile~rmvs_encounter_check.f90->sourcefile~swiftest_module.f90 sourcefile~rmvs_encounter_check.f90->sourcefile~rmvs_module.f90 sourcefile~rmvs_kick.f90 rmvs_kick.f90 sourcefile~rmvs_kick.f90->sourcefile~swiftest_module.f90 sourcefile~rmvs_kick.f90->sourcefile~rmvs_module.f90 sourcefile~rmvs_module.f90->sourcefile~swiftest_module.f90 sourcefile~rmvs_module.f90->sourcefile~whm_module.f90 sourcefile~rmvs_step.f90 rmvs_step.f90 sourcefile~rmvs_step.f90->sourcefile~swiftest_module.f90 sourcefile~rmvs_step.f90->sourcefile~rmvs_module.f90 sourcefile~rmvs_util.f90 rmvs_util.f90 sourcefile~rmvs_util.f90->sourcefile~swiftest_module.f90 sourcefile~rmvs_util.f90->sourcefile~rmvs_module.f90 sourcefile~shgrav_accel.f90 shgrav_accel.f90 sourcefile~shgrav_accel.f90->sourcefile~swiftest_module.f90 sourcefile~shgrav_module.f90 shgrav_module.f90 sourcefile~shgrav_accel.f90->sourcefile~shgrav_module.f90 sourcefile~shgrav_module.f90->sourcefile~swiftest_module.f90 sourcefile~shgrav_pot.f90 shgrav_pot.f90 sourcefile~shgrav_pot.f90->sourcefile~swiftest_module.f90 sourcefile~shgrav_pot.f90->sourcefile~shgrav_module.f90 sourcefile~swiftest_coarray.f90 swiftest_coarray.f90 sourcefile~swiftest_coarray.f90->sourcefile~swiftest_module.f90 sourcefile~swiftest_coarray.f90->sourcefile~rmvs_module.f90 sourcefile~swiftest_coarray.f90->sourcefile~whm_module.f90 sourcefile~swiftest_discard.f90 swiftest_discard.f90 sourcefile~swiftest_discard.f90->sourcefile~swiftest_module.f90 sourcefile~swiftest_drift.f90 swiftest_drift.f90 sourcefile~swiftest_drift.f90->sourcefile~swiftest_module.f90 sourcefile~swiftest_driver.f90 swiftest_driver.f90 sourcefile~swiftest_driver.f90->sourcefile~swiftest_module.f90 sourcefile~swiftest_gr.f90 swiftest_gr.f90 sourcefile~swiftest_gr.f90->sourcefile~swiftest_module.f90 sourcefile~swiftest_io.f90 swiftest_io.f90 sourcefile~swiftest_io.f90->sourcefile~swiftest_module.f90 sourcefile~swiftest_io.f90->sourcefile~symba_module.f90 sourcefile~swiftest_kick.f90 swiftest_kick.f90 sourcefile~swiftest_kick.f90->sourcefile~swiftest_module.f90 sourcefile~swiftest_obl.f90 swiftest_obl.f90 sourcefile~swiftest_obl.f90->sourcefile~swiftest_module.f90 sourcefile~swiftest_obl.f90->sourcefile~shgrav_module.f90 sourcefile~swiftest_orbel.f90 swiftest_orbel.f90 sourcefile~swiftest_orbel.f90->sourcefile~swiftest_module.f90 sourcefile~swiftest_user.f90 swiftest_user.f90 sourcefile~swiftest_user.f90->sourcefile~swiftest_module.f90 sourcefile~swiftest_util.f90 swiftest_util.f90 sourcefile~swiftest_util.f90->sourcefile~swiftest_module.f90 sourcefile~swiftest_util.f90->sourcefile~fraggle_module.f90 sourcefile~swiftest_util.f90->sourcefile~helio_module.f90 sourcefile~swiftest_util.f90->sourcefile~rmvs_module.f90 sourcefile~swiftest_util.f90->sourcefile~symba_module.f90 sourcefile~swiftest_util.f90->sourcefile~whm_module.f90 sourcefile~symba_discard.f90 symba_discard.f90 sourcefile~symba_discard.f90->sourcefile~swiftest_module.f90 sourcefile~symba_discard.f90->sourcefile~symba_module.f90 sourcefile~symba_drift.f90 symba_drift.f90 sourcefile~symba_drift.f90->sourcefile~swiftest_module.f90 sourcefile~symba_drift.f90->sourcefile~symba_module.f90 sourcefile~symba_encounter_check.f90 symba_encounter_check.f90 sourcefile~symba_encounter_check.f90->sourcefile~swiftest_module.f90 sourcefile~symba_encounter_check.f90->sourcefile~symba_module.f90 sourcefile~symba_gr.f90 symba_gr.f90 sourcefile~symba_gr.f90->sourcefile~swiftest_module.f90 sourcefile~symba_gr.f90->sourcefile~symba_module.f90 sourcefile~symba_kick.f90 symba_kick.f90 sourcefile~symba_kick.f90->sourcefile~swiftest_module.f90 sourcefile~symba_kick.f90->sourcefile~symba_module.f90 sourcefile~symba_module.f90->sourcefile~swiftest_module.f90 sourcefile~symba_module.f90->sourcefile~helio_module.f90 sourcefile~symba_step.f90 symba_step.f90 sourcefile~symba_step.f90->sourcefile~swiftest_module.f90 sourcefile~symba_step.f90->sourcefile~symba_module.f90 sourcefile~symba_util.f90 symba_util.f90 sourcefile~symba_util.f90->sourcefile~swiftest_module.f90 sourcefile~symba_util.f90->sourcefile~fraggle_module.f90 sourcefile~symba_util.f90->sourcefile~symba_module.f90 sourcefile~tides_getacch_pl.f90 tides_getacch_pl.f90 sourcefile~tides_getacch_pl.f90->sourcefile~swiftest_module.f90 sourcefile~tides_spin_step.f90 tides_spin_step.f90 sourcefile~tides_spin_step.f90->sourcefile~swiftest_module.f90 sourcefile~walltime_implementations.f90 walltime_implementations.f90 sourcefile~walltime_implementations.f90->sourcefile~swiftest_module.f90 sourcefile~whm_coord.f90 whm_coord.f90 sourcefile~whm_coord.f90->sourcefile~swiftest_module.f90 sourcefile~whm_coord.f90->sourcefile~whm_module.f90 sourcefile~whm_drift.f90 whm_drift.f90 sourcefile~whm_drift.f90->sourcefile~swiftest_module.f90 sourcefile~whm_drift.f90->sourcefile~whm_module.f90 sourcefile~whm_gr.f90 whm_gr.f90 sourcefile~whm_gr.f90->sourcefile~swiftest_module.f90 sourcefile~whm_gr.f90->sourcefile~whm_module.f90 sourcefile~whm_kick.f90 whm_kick.f90 sourcefile~whm_kick.f90->sourcefile~swiftest_module.f90 sourcefile~whm_kick.f90->sourcefile~whm_module.f90 sourcefile~whm_module.f90->sourcefile~swiftest_module.f90 sourcefile~whm_step.f90 whm_step.f90 sourcefile~whm_step.f90->sourcefile~swiftest_module.f90 sourcefile~whm_step.f90->sourcefile~whm_module.f90 sourcefile~whm_util.f90 whm_util.f90 sourcefile~whm_util.f90->sourcefile~swiftest_module.f90 sourcefile~whm_util.f90->sourcefile~whm_module.f90

Source Code

module io_progress_bar
   !! author: The Purdue Swiftest Team - David A. Minton, Carlisle A. Wishard, Jennifer L.L. Pouplin, and Jacob R. Elliott
   !!
   !! Definition of classes and methods used to determine close encounters
   use globals
   use base
   implicit none
   public

   character(len=1),parameter, private                :: barchar = "#" 
         !! The progress bar character

   type :: progress_bar
      !! author: David A. Minton
      !! 
      !! Implements a class for a simple progress bar that can print on the screen.
      integer(I4B)                  :: PBARSIZE = 80 
         !! Number of characters acros for a whole progress bar
      integer(I8B)                  :: loop_length   
         !! The total number of loops that the progrees bar is executing
      character(len=:), allocatable :: barstr        
         !! The string that prints out as the progress bar
      integer(I4B)                  :: bar_pos       
         !! The current position of the progress bar
      character(len=32)             :: fmt           
         !! The format string that is used to define the progress bar itself
      character(len=64)             :: message       
         !! The current message displayed at the end of the progress bar
   contains
      procedure :: reset  => io_progress_bar_reset   
         !! Resets the progress bar to the beginning
      procedure :: update => io_progress_bar_update 
         !! Updates the progress bar with new values 
   end type progress_bar

contains

   subroutine io_progress_bar_reset(self, loop_length)
      !! author: David A. Minton
      !! 
      !! Resets the progress bar to the beginning
      implicit none
      ! Arguments
      class(progress_bar),intent(inout)        :: self         
         !! The progress bar object
      integer(I8B),       intent(in)           :: loop_length  
         !! The length of the loop that the progress bar is attached to
      ! Internals
      character(len=2) :: numchar
      integer(I4B) :: k

      if (.not.allocated(self%barstr)) then
         allocate(character(self%PBARSIZE) :: self%barstr)
      end if
      do k = 1, self%PBARSIZE
         self%barstr(k:k) = " "
      end do
      write(numchar,'(I2)') self%PBARSIZE
      self%fmt  = '(A1,"[",A' // numchar // ',"] ",A,$)'
      self%loop_length = loop_length
      self%bar_pos = 0
      self%message = ""

      write(*,fmt=self%fmt) char(13),self%barstr,trim(adjustl(self%message))

      return
   end subroutine io_progress_bar_reset


   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


end module io_progress_bar