showProgress Subroutine

public subroutine showProgress(m, p)

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: m

Message to show

real(kind=wp), intent(in) :: p

Progress level \(p\in[0,1]\)

Description

Show a progress bar with a message

Calls

proc~~showprogress~~CallsGraph proc~showprogress showProgress proc~colorize colorize proc~showprogress->proc~colorize proc~real2char real2char proc~showprogress->proc~real2char
Help

Variables

TypeVisibility AttributesNameInitial
real(kind=wp), public :: r
real(kind=wp), public, save:: po
integer, public :: N
integer, public :: k

Source Code

	subroutine showProgress(m,p)
		!! Show a progress bar with a message
		character(*),intent(in)::m
			!! Message to show
		real(wp),intent(in)::p
			!! Progress level \(p\in[0,1]\)
		
		real(wp)::r
		real(wp),save::po
		integer::N,k
		
		N = 40
		
		if(p<=0.0_wp) then
			po = p
		end if
		if(p-po<0.05 .and. p<1.0_wp) then
			return
		else
			po = p
		end if
		
		write(stdout,'(1A)',advance='no') achar(13)//colorize(m//' [',[5,5,0])
		do k=1,N
			r = real(k-1,wp)/real(N-1,wp)
			if(r<=p) then
				write(stdout,'(1A)',advance='no') colorize('=',cmap(r,[0.0_wp,1.0_wp]))
			else
				write(stdout,'(1A)',advance='no') colorize(' ',[0,0,0])
			end if
		end do
		write(stdout,'(1A,1A,1X,1A)',advance='no') colorize('] ',[5,5,0]), &
		& colorize(real2char(100.0_wp*p,'1F5.1'),cmap(p,[0.0_wp,1.0_wp])), &
		& colorize('%',[5,5,0])
		if(p>=1.0_wp) write(stdout,'(1A)') ''
		flush(stdout)
	end subroutine showProgress