Topic: Progress Bar

I am trying to display a progress bar for a Monte Carlo simulation program written in Fortran.  I used the example program progress.f90 as a starting point.  When I changed 100 iterations to 1000, the progress bar does not close.  Are there other changes that need to be made in the module if the number of iterations is different than 100?  Thank you.

Re: Progress Bar

The code in progress.f90 was meant to display a percentage, so the number 100 appears in two places.  You hadn't pointed out where exactly you changed "iterations to 1000," but I'm assuming you meant that you changed something in progress.f90 itself? 

The progress bar shouldn't close by itself.  Are you getting to a line like:

call p%close()

Do you open any other windows along the way?

Jeff Armstrong
Approximatrix, LLC

Re: Progress Bar


Thank you for your reply.

Yes, the initial changes I made were in progress.f90 by merely substituting 1000 for 100.

The most recent changes I made are listed in the following code, and now the program runs the way I would like it.

program main
use progress
implicit none

    type(progresswindow), volatile::prog_bar
    integer::counter, i, kount, nsims, n_times
    real::last_time, now_time
    write(*,"(1x,'Enter number of simulations:  '$)")
    read(*,*) nsims
    n_times = nsims/100
    prog_bar = initprogress("Timed Progress", canceltest)
    call cpu_time(last_time)
    now_time = last_time
    kount = 0
    do i = 1, nsims
      kount = kount + 1
      if ( then
        do while(counter < 100)
            do while(now_time - last_time < 0.2)
                call cpu_time(now_time)
            end do
            last_time = now_time
            counter = counter + 1
            call prog_bar%draw(counter)
            kount = 0
        end do

      end if

    end do

    call prog_bar%close()
    subroutine canceltest
    implicit none
        counter = 101
        now_time = now_time + 1.0
    end subroutine canceltest

end program main