"
+ ],
+ "text/plain": [
+ "\n",
+ "Dimensions: (name: 10, time: 1)\n",
+ "Coordinates:\n",
+ " * name (name) 4) self%spinner = 1
- select case(self%spinner)
- case(1)
- self%barstr(pos:pos) = "/"
- case(2)
- self%barstr(pos:pos) = "-"
- case(3)
- self%barstr(pos:pos) = "\"
- case(4)
- self%barstr(pos:pos) = "|"
- end select
-
- write(*,fmt=self%fmt) char(13),self%barstr
-
-
- return
- end subroutine io_pbar_update
-
-
-
-
module subroutine io_conservation_report(self, param, lterminal)
!! author: The Purdue Swiftest Team - David A. Minton, Carlisle A. Wishard, Jennifer L.L. Pouplin, and Jacob R. Elliott
!!
diff --git a/src/io/io_progress_bar.f90 b/src/io/io_progress_bar.f90
new file mode 100644
index 000000000..4de94f15a
--- /dev/null
+++ b/src/io/io_progress_bar.f90
@@ -0,0 +1,105 @@
+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 swiftest_globals
+ use swiftest_classes
+ implicit none
+ public
+
+ 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) :: nloops !! 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) :: spinner !! Position of the "spinner" that indicates that progress is being made
+ character(len=1) :: barchar = "=" !! The progress bar character
+ character(len=32) :: fmt !! The format string that is used to define the progress bar itself
+ integer(I4B) :: pos !! The current position of the progress bar
+ character(len=32) :: message !! The current message displayed at the end of the progress bar
+ contains
+ procedure :: reset => io_pbar_reset !! Resets the progress bar to the beginning
+ procedure :: update => io_pbar_update !! Updates the progress bar with new values and causes the "spinner" to flip.
+ end type progress_bar
+
+contains
+
+ subroutine io_pbar_reset(self, nloops)
+ !! author: David A. Minton
+ !!
+ !! Resets the progress bar to the beginning
+ implicit none
+ ! Arguments
+ class(progress_bar),intent(inout) :: self
+ integer(I8B), intent(in) :: nloops
+ ! Internals
+ character(len=2) :: numchar,numchar2
+ character(len=32) :: startfmt
+ character(len=self%PBARSIZE) :: empty
+ 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 // ',"]",$)'
+ self%nloops = nloops
+ self%spinner = 0
+ self%pos = 0
+ self%message = ""
+
+ write(*,fmt=self%fmt) char(13),empty
+
+ return
+ end subroutine io_pbar_reset
+
+
+ subroutine io_pbar_update(self,i,message)
+ !! author: David A. Minton
+ !!
+ !! Updates the progress bar with new values and causes the "spinner" to flip.
+ 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) :: pos !! The current integer position of the progress bar
+
+ ! Compute the current position
+ frac = real(i,kind=DP) / real(self%nloops,kind=DP)
+ pos = min(int(ceiling(frac * self%PBARSIZE),kind=I4B),self%PBARSIZE)
+ if (pos /= self%pos) then
+ self%pos = pos
+
+ ! Fill in the bar character up to the current position
+ self%barstr(pos:pos) = self%barchar
+ end if
+
+ self%spinner = self%spinner + 1
+ if (self%spinner > 4) self%spinner = 1
+ select case(self%spinner)
+ case(1)
+ self%barstr(pos+1:pos+1) = "/"
+ case(2)
+ self%barstr(pos+1:pos+1) = "-"
+ case(3)
+ self%barstr(pos+1:pos+1) = "\"
+ case(4)
+ self%barstr(pos+1:pos+1) = "|"
+ end select
+
+ write(*,fmt=self%fmt) char(13),self%barstr
+
+
+ return
+ end subroutine io_pbar_update
+
+
+end module io_progress_bar
diff --git a/src/main/swiftest_driver.f90 b/src/main/swiftest_driver.f90
index 0eca02509..1d3535daf 100644
--- a/src/main/swiftest_driver.f90
+++ b/src/main/swiftest_driver.f90
@@ -90,6 +90,7 @@ program swiftest_driver
write(*, *) " *************** Main Loop *************** "
if (param%lrestart .and. param%lenergy) call nbody_system%conservation_report(param, lterminal=.true.)
call pbar%reset(nloops)
+ call pbar%update(1)
do iloop = 1, nloops
!> Step the system forward in time
call integration_timer%start()
@@ -102,7 +103,6 @@ program swiftest_driver
call nbody_system%discard(param)
!> If the loop counter is at the output cadence value, append the data file with a single frame
- call pbar%update(iloop)
if (istep_out > 0) then
iout = iout - 1
if (iout == 0) then
@@ -122,6 +122,7 @@ program swiftest_driver
!call integration_timer%reset()
iout = istep_out
+ call pbar%update(iloop)
end if
end if
diff --git a/src/modules/swiftest.f90 b/src/modules/swiftest.f90
index 6f84c66b9..edc41f134 100644
--- a/src/modules/swiftest.f90
+++ b/src/modules/swiftest.f90
@@ -23,6 +23,7 @@ module swiftest
use lambda_function
use walltime_classes
use encounter_classes
+ use io_progress_bar
!use advisor_annotate
!$ use omp_lib
implicit none
diff --git a/src/modules/swiftest_classes.f90 b/src/modules/swiftest_classes.f90
index 49735a424..6bbcb537b 100644
--- a/src/modules/swiftest_classes.f90
+++ b/src/modules/swiftest_classes.f90
@@ -414,20 +414,6 @@ module swiftest_classes
generic :: read_particle_info => read_particle_info_bin, read_particle_info_netcdf !! Genereric method call for reading in the particle information metadata
end type swiftest_nbody_system
- 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) :: nloops !! 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) :: spinner !! Position of the "spinner" that indicates that progress is being made
- character(len=1) :: barchar = "=" !! The progress bar character
- character(len=32) :: fmt !! The format string that is used to define the progress bar itself
- contains
- procedure :: reset => io_pbar_reset !! Resets the progress bar to the beginning
- procedure :: update => io_pbar_update !! Updates the progress bar with new values and causes the "spinner" to flip.
- end type progress_bar
abstract interface
@@ -597,18 +583,6 @@ pure module subroutine gr_vh2pv_body(self, param)
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
end subroutine gr_vh2pv_body
- module subroutine io_pbar_reset(self, nloops)
- implicit none
- class(progress_bar),intent(inout) :: self
- integer(I8B), intent(in) :: nloops
- end subroutine io_pbar_reset
-
- module subroutine io_pbar_update(self,i)
- implicit none
- class(progress_bar), intent(inout) :: self
- integer(I8B), intent(in) :: i
- end subroutine io_pbar_update
-
module subroutine io_conservation_report(self, param, lterminal)
implicit none
class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody system object