Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Show Progress

brunocalado
Beginner
876 Views
Hi,


I'm trying to show the progress of my program. It looks like:
0.0/100 %
1.0/100 %
2.0/100 %
3.0/100 %
4.0/100 %
...
99.0/100 %
100.0/100 %

My problem is: I don't know a nice way to return the cursor back and rewrite the last line. I want to know if is there a way to return to last printed line, clear it and rewrite again.


I know how to do it using system("clear"). But it erases other messages...


Thank you
0 Kudos
1 Solution
Steven_L_Intel1
Employee
876 Views
As Ron says, there is no standard way to do it. But you can do some tricks with extensions. For example:

[plain]open (unit=6,carriagecontrol='fortran')
do i=1,10
write (6,'($,A,A,i2)') '+',char(13),i
end do[/plain]

View solution in original post

0 Kudos
3 Replies
Ron_Green
Moderator
876 Views
Quoting - brunocalado
Hi,


I'm trying to show the progress of my program. It looks like:
0.0/100 %
1.0/100 %
2.0/100 %
3.0/100 %
4.0/100 %
...
99.0/100 %
100.0/100 %

My problem is: I don't know a nice way to return the cursor back and rewrite the last line. I want to know if is there a way to return to last printed line, clear it and rewrite again.


I know how to do it using system("clear"). But it erases other messages...


Thank you

There is no standard Fortran method for doing what you want to do - to update a terminal output on the same line.

In the old days, we had control codes for VT100/VT220 terminals that would allow such a thing - but this was not standard Fortran. Rather, you send the control codes/sequences that were unique to those terminals to explicitly control the output location. I don't know of a way to do that for terminal windows - and then terminal windows are not consistent across different OSes.

ron
0 Kudos
Steven_L_Intel1
Employee
877 Views
As Ron says, there is no standard way to do it. But you can do some tricks with extensions. For example:

[plain]open (unit=6,carriagecontrol='fortran')
do i=1,10
write (6,'($,A,A,i2)') '+',char(13),i
end do[/plain]

0 Kudos
brunocalado
Beginner
876 Views
As Ron says, there is no standard way to do it. But you can do some tricks with extensions. For example:

[plain]open (unit=6,carriagecontrol='fortran')
do i=1,10
write (6,'($,A,A,i2)') '+',char(13),i
end do[/plain]


Thank you. You're the best!
0 Kudos
Reply