- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to show, in percentages,the progresswith a calculationdone in a DO-loop. Instead of having a new line for each percentage, I want the new percentage to overwrite the same percentage on the same line. This is what I have so far, but it does not work:
[cpp]DO Number = 1, Maximum WRITE(*, 100, ADVANCE = "No") REAL(Number)/REAL(Maximum)*100 100 FORMAT(TL10, F10.2) END DO
[/cpp]
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This works:
[plain]OPEN (UNIT=6,FORM='FORMATTED',CARRIAGECONTROL='FORTRAN') MAXIMUM = 100 DO Number = 1, MAXIMUM WRITE(6, 100) REAL(Number)/REAL(Maximum)*100 100 FORMAT('+', F10.2) END DO END[/plain]The '+' carriage control character is for "overprinting". You have to ask for 'FORTRAN' carriage control, however, as that is not the default. I will note that carriage control was deleted from the Fortran 2003 standard, but it is still supported by Intel Fortran. The CARRIAGECONTROL keyword for OPEN is non-standard.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, Steve. But how do I write it to the console? With the OPEN statement, it seems to write to a file.
EDIT:
No problem. I found the argument FILETYPE = 'TTY' for the OPEN statement.
EDIT:
No problem. I found the argument FILETYPE = 'TTY' for the OPEN statement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Opening unit 6 should write to the console. It does for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a very old code where following is used and works well if you want to stay on 1 line when writing to the console:
[cpp]write(*,'(1h+,a,f5.1,a)') 'Progress: ', pct, '%'[/cpp]1h+ does the trick, but I am not sure if it is not something what should not be used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - jirina
I have a very old code where following is used and works well if you want to stay on 1 line when writing to the console:
[cpp]write(*,'(1h+,a,f5.1,a)') 'Progress: ', pct, '%'[/cpp]1h+ does the trick, but I am not sure if it is not something what should not be used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
This works:
[plain]OPEN (UNIT=6,FORM='FORMATTED',CARRIAGECONTROL='FORTRAN')The '+' carriage control character is for "overprinting". You have to ask for 'FORTRAN' carriage control, however, as that is not the default. I will note that carriage control was deleted from the Fortran 2003 standard, but it is still supported by Intel Fortran. The CARRIAGECONTROL keyword for OPEN is non-standard.
MAXIMUM = 100
DO Number = 1, MAXIMUM
WRITE(6, 100) REAL(Number)/REAL(Maximum)*100
100 FORMAT('+', F10.2)
END DO
END[/plain]
Hi, Steve. This is so so useful. I have been looking for this for a long long time. Thanks

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