- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is something that works for me, at least in CVF.
Here's a small program to illustrate:
PROGRAM t1
IMPLICIT NONE
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
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
! ...
! ...
ENDIF
END DO
END PROGRAM t1
Note that the "$" in theformat is not standard Fortran.
Best wishes
Lars M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
See "Dollar-Sign ($)and Backslash ( ) Editing" in the on-line documentation of CVF.
Sabalan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thankyou! Yes, that was the answer. Now my original statement works and I understand what's going on.
Many thanks to all contributors.
Mike

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