Issues with FORMAT TLn

Issues with FORMAT TLn

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

 

3 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

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:


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

Steve - Intel Developer Support
Best Reply

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

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui