From: rudra on
dear friends,
as we install a rpm file or install via yum, we saw a progress bar
like

ftnchek-emacs-3.3. 100% |=========================|

is there any way to generate something like that using fortran? where
the progress percentage will update in the same line?
From: Lorenzo `paulatz' Paulatto on
rudra ha scritto:
> is there any way to generate something like that using fortran? where
> the progress percentage will update in the same line?

I dodn't know if this is enough, but you can print a backspace from
fortran, in this way:
write(*,'(a)',advance='no') char(8)
it is possible to print the bar in this way, just use a bit of fantasy.
You can delete the entire line, but you cannot go to the previous line
in this way. Also I don't know how portable it is.



--
Lorenzo `paulatz' Paulatto
Trieste

``Grandissima mi par l'inezia di coloro che vorrebbero che Iddio avesse
fatto l'universo pi� proporzionato alla piccola capacit� del lor discorso.''
--Galileo Galilei (Opere VII)
From: John Harper on
In article <d46a483c-164d-4cd8-8f4e-04bb0ca26566(a)s19g2000prg.googlegroups.com>,
rudra <bnrj.rudra(a)gmail.com> wrote:
>dear friends,
> as we install a rpm file or install via yum, we saw a progress bar
>like
>
>ftnchek-emacs-3.3. 100% |=========================|
>
>is there any way to generate something like that using fortran? where
>the progress percentage will update in the same line?

This does it, at least with g95, gfortran and Sun Sparc f95, writing 10
asterisks on the same line, one per second. But some compilers don't yet
allow the FLUSH statement, and some that do won't do what's required
without it.

PROGRAM progressbar
! Uses FLUSH (f2003 but not f95) and assumes unit 6 = stdout
DO i=1,10
CALL sleep(1)
WRITE(6,"(A)",ADVANCE='NO')'*'
FLUSH 6
END DO
WRITE(*,*)
END PROGRAM progressbar

-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail john.harper(a)vuw.ac.nz phone (+64)(4)463 6780 fax (+64)(4)463 5045
From: Sjouke Burry on
Lorenzo `paulatz' Paulatto wrote:
> rudra ha scritto:
>> is there any way to generate something like that using fortran? where
>> the progress percentage will update in the same line?
>
> I dodn't know if this is enough, but you can print a backspace from
> fortran, in this way:
> write(*,'(a)',advance='no') char(8)
> it is possible to print the bar in this way, just use a bit of fantasy.
> You can delete the entire line, but you cannot go to the previous line
> in this way. Also I don't know how portable it is.
>
>
>
After the initial write,
1 write(*,'(a)', )' -----------------------------'
2 write(*,'(a)',advance='no')'waiting'
you can add to line 2 with something like
3 write(*,'(a)',advance='no')'.'
until you reach the end of the(non-advancing) line 1.
From: FX on
> PROGRAM progressbar
> ! Uses FLUSH (f2003 but not f95) and assumes unit 6 = stdout
> DO i=1,10
> CALL sleep(1)
> WRITE(6,"(A)",ADVANCE='NO')'*'
> FLUSH 6
> END DO
> WRITE(*,*)
> END PROGRAM progressbar

I suggest that if you go for Fortran 2003, you do it completely and use
OUTPUT_UNIT of the ISO_FORTRAN_ENV intrinsic module instead of "6". Which
gives:

program progressbar
use iso_fortran_env
do i = 1, 10
call sleep(1) ! SLEEP is not a standard intrinsic, but you will
! replace this with code actually doing something anyway!
write (*,"(a)",advance='no') '*'
flush (output_unit)
end do
write(*,*)
end program progressbar

It still isn't what the OP wanted (ie having the progress percentage
overwriting itself all along). I've tried making TL format descriptors
and non-advancing I/O but can't get anything that works.

--
FX