Wednesday, April 11, 2012

With Fortran, how to overwrite the present line on the console screen?

program print_on_the_same_line

integer :: I, N

N=5

open(6,CARRIAGECONTROL ='FORTRAN')

do I=1,N
call sleep(1)
write(6,'(1H+" ",I,a,I)') I,' out of',N
enddo

close(6)

stop
end program

****************************************************
The above Fortran codes are adopted from the link:
http://stackoverflow.com/questions/1390125/how-do-i-format-a-print-or-write-statement-to-overwrite-the-current-line-on-the