10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-12-28 15:16:01 +01:00
quantum_package/src/Utils/progress.irp.f

78 lines
1.9 KiB
Fortran
Raw Normal View History

2014-10-02 01:06:13 +02:00
subroutine start_progress(max,title,progress_init)
implicit none
integer, intent(in) :: max
double precision, intent(in) :: progress_init
character*(*), intent(in) :: title
BEGIN_DOC
! Starts the progress bar
END_DOC
progress_bar(1) = 0
progress_bar(2) = max
progress_title = title
progress_active = .True.
progress_value = progress_init
2015-01-09 23:52:44 +01:00
! call run_progress()
2014-10-02 01:06:13 +02:00
end
subroutine stop_progress
implicit none
BEGIN_DOC
! Stop the progress bar
END_DOC
progress_active = .False.
end
BEGIN_PROVIDER [ real, progress_bar, (2) ]
&BEGIN_PROVIDER [ integer, progress_timeout ]
&BEGIN_PROVIDER [ logical, progress_active ]
&BEGIN_PROVIDER [ double precision, progress_value ]
&BEGIN_PROVIDER [ character*(20) , progress_title ]
implicit none
BEGIN_DOC
! Current status for displaying progress bars. Global variable.
END_DOC
progress_bar = 0
progress_value = 0.d0
progress_title = ''
progress_active = .False.
progress_timeout = 1
2015-03-24 09:39:13 +01:00
! open (unit=0, carriagecontrol='fortran')
2014-10-02 01:06:13 +02:00
END_PROVIDER
recursive subroutine run_progress
implicit none
BEGIN_DOC
! Display a progress bar with documentation of what is happening
END_DOC
character(75), parameter :: bar0= &
' --- : --- | | ---%'
character(75) :: bar
integer :: prog
bar = bar0
if (.not.progress_active) then
call stop_progress
write(unit=0,fmt="(a1,a1,a70)") '+',char(13), bar
else
prog = int( progress_bar(1)*100./progress_bar(2) )
2016-02-19 00:20:28 +01:00
write(bar(1:25),'(A)') progress_title
write(bar(29:47),'(G17.10)') progress_value
2014-10-02 01:06:13 +02:00
write(bar(72:74),'(i3)') prog
integer :: k,j
j = int( progress_bar(1)*20./progress_bar(2) )
do k=1, j
bar(49+k:49+k)="="
enddo
write(unit=0,fmt="(a1,a1,a75)") '+',char(13), bar
2015-03-24 09:39:13 +01:00
call alarm(progress_timeout,run_progress)
2014-10-02 01:06:13 +02:00
endif
end