Overwriting lines

View: New views
2 Messages — Rating Filter:   Alert me  

Overwriting lines

by rahul_2410 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi There,

I am using gfortran for a cosmology simulation package (v 4.3.3). I have
a question which is simple and frequently asked, however none of the
suggested solutions seem to work.

I want to overwrite a line on screen. Whether I use "$" or advance="no"
with a TL (TR works fine, with the origin at whichever column the
previous line ended) statement of use "+" as my first character, I am
only able to write from where the previous line finished or next line.

Kindly suggest how to resolve this!

Best Regards
Rahul Gupta

Re: Overwriting lines

by Tobias Burnus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am 06.11.2009 20:14, schrieb Rahul Gupta:
> I want to overwrite a line on screen. Whether I use "$" or
> advance="no" with a TL (TR works fine, with the origin at whichever
> column the previous line ended) statement of use "+" as my first
> character, I am only able to write from where the previous line
> finished or next line.

I think the Fortran standard provides no way to do this. Additionally,
it is also not possible if you write for instance into a pipe of another
program. However, with most terminals, doing a carriage-return ('\r')
should work. As you will see, you need to take care yourself that you
clean up the line.

implicit none
intrinsic sleep
integer :: i
do i = 0, 100,17
  write(*,'(a,i3,"%",a)',advance='no') &
             'Performing nothing: ', i,achar(13)
  call sleep(1)
end do
write(*,*) 'DONE '   ! << have a look at the output
end

Tobias