- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have the console application developed to handle large data. Since it takes longer time, I wanted to report % completion. Attached the simple code I tested. Unfortunately, TL4 doesn't work, but it keeps printing continuously (as if TL4 is not added in the format). Can someone help me fixing this?
Thanks,
Mohan
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PROGRAM test
IMPLICIT NONE
INTEGER :: i
WRITE(*,'(A,$)') 'Completion ... 0%'
DO i = 1,10000
WRITE(*,'(TL4,I3,A,$)') INT(i*100/10000),'%'
END DO
WRITE(*,*)
END PROGRAM test
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve. Using ADVANCE='NO', I got the idea using backspace through ACHAR. Following code worked for me and this solves the problem.
-----------------
PROGRAM test
IMPLICIT NONE
INTEGER :: i
WRITE(*,'(A)',ADVANCE='NO') 'Test Start ... 0%'
DO i = 1,10000
WRITE (*,'(A,I3,A)',ADVANCE='NO') REPEAT(ACHAR(8),4),I/100,'%'
END DO
END PROGRAM test
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can't do it that way. The left margin (for the TL) is reset for each of the WRITEs in the loop. All the $ does is prevent a newline from being written as well.
One way to do this sort of thing is like this:
[fortran]
PROGRAM test
IMPLICIT NONE
INTEGER :: i
WRITE(*,'(A)',ADVANCE='NO') 'Completion ... 0%'
DO i = 1,10000
IF (MOD(I,1000) == 0) THEN
WRITE (*,'(A,I0,A)',ADVANCE='NO') '..',I/100,'%'
END IF
END DO
WRITE(*,*)
END PROGRAM test
[/fortran]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve. Using ADVANCE='NO', I got the idea using backspace through ACHAR. Following code worked for me and this solves the problem.
-----------------
PROGRAM test
IMPLICIT NONE
INTEGER :: i
WRITE(*,'(A)',ADVANCE='NO') 'Test Start ... 0%'
DO i = 1,10000
WRITE (*,'(A,I3,A)',ADVANCE='NO') REPEAT(ACHAR(8),4),I/100,'%'
END DO
END PROGRAM test

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page