Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Issues with FORMAT TLn

mohanmuthu
New Contributor I
719 Views

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

 

0 Kudos
1 Solution
mohanmuthu
New Contributor I
719 Views
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

View solution in original post

0 Kudos
2 Replies
Steven_L_Intel1
Employee
719 Views
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]
0 Kudos
mohanmuthu
New Contributor I
720 Views
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
0 Kudos
Reply