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

Overprinting

michael_green
Beginner
834 Views
Hi,
I have a legacy program (F77) which gives a progress report using the following statement:
write(*,'(''+'',I3,''% completed.'')')percent
This statement was embedded in a loop, but produced a single line of output because the leading "+" character suppressed line feeds. I understand this worked because the standard output "file" had a carriagecontrol of 'FORTRAN'.
It doesn't work in F95 (I get 100 separate lines now) and I presume this is because carriagecontrol is now 'LIST'. Is there any way I can get it to work in F95?
With many thanks in advance,
Mike
0 Kudos
7 Replies
larsm
Beginner
834 Views
Here is something that works for me, at least in CVF.
Here's a small program to illustrate:
PROGRAM t1
IMPLICIT NONE
INTEGER :: i, n
n = 100053
DO i=1, n
IF (MOD(i,50)==0.OR.i==n) THEN
WRITE (*, '(A,"Processing (",I0,"/",I0,")",$)') ACHAR(13), i, n
! ...
! ...
! ...
ENDIF
END DO
END PROGRAM t1
Note that the "$" in theformat is not standard Fortran.
Best wishes
Lars M
0 Kudos
michael_green
Beginner
834 Views
Hi Lars,
Many thanks for your reply. Yes it works well for me and I shall use it. But is this a "legal" way of doing things? I'm curious now.
Thanks again.
Mike
0 Kudos
sabalan
New Contributor I
834 Views
See "Dollar-Sign ($)and Backslash ( ) Editing" in the on-line documentation of CVF.
Sabalan.
0 Kudos
forall
Beginner
834 Views
Specifying ADVANCE="NO" as a keyword in the WRITE statement will also work, and is quite clean and clear legal F95. Eg, WRITE(unt,fmt,advance='no',iostat=err). HTH.
0 Kudos
michael_green
Beginner
834 Views
Hi all,
I think I tried most of the suggestions before my first post, but anyway, I've tried them again and can report that Lars's suggestion is the only one that actually works.
The following statements:
write(*,'(I3,"% completed.",)',advance='no')percent
write(*,'(I3,"% completed.",$)')percent
write(*,'("+",I3,"% completed.",$)')percent
and others very similar all give output of:
0% completed. 1% completed. 2% completed. etc, etc
or
+ 0% completed.+ 1% completed. + 2% completed. etc, etc
Thanks again for the suggestions.
Mike
0 Kudos
sabalan
New Contributor I
834 Views
Mike, in CVF when using backslash editing try to check for Power Station compatibility through Project / Settings... / Fortran / Compatibility / Other Run-time Behaviour (which means /fpscomp:general).
Sabalan.
0 Kudos
michael_green
Beginner
834 Views
Thankyou! Yes, that was the answer. Now my original statement works and I understand what's going on.
Many thanks to all contributors.
Mike
0 Kudos
Reply