Fortran error with CARRIAGECONTROL

I use the following statement to enable writing progress lines onto the screen on top of each other.

OPEN (6, CARRIAGECONTROL = “FORTRAN”)

When a “+” is the first character in subsequent WRITE statements the output is on top of the previous line on the monitor. It is useful for updating program progress without causing the output to scroll up and up. The effect lasts until CLOSE (6) occurs.

I think the feature is obsolete or deleted from current Fortran. I think this because PGI Fortran produces a syntax error for the line. GNU Fortran also produces a syntax error. However, Intel Fortran accepts it. Is there a similiar statement that I can use with PGI Fortran that will produce the same effect?

By the way, ADVANCE = “NO” is not an adequate replacement. It writes on the same line, but after the last output. Also, it doesn’t display on the screen right away. It waits until all the output is done.

Hi David,

OPEN (6, CARRIAGECONTROL = “FORTRAN”)

This is a non-Standard extension used to toggle the use of control characters. The carriage control characters, “0”, “1”, and “+”, were introduced to support the old line printers but were specifically deleted from the F2003 standard.

An alternative would be to use the ASCII carriage return character, “CHAR(13)”, along with non-advancing I/O to get the behavior you’re looking for. For example:

  do i=1,10
    write (*,"(AI)",advance="no") char(13), i
    call flush(6)
    call sleep(1)
  enddo
  write (*,*)
  end

Hope this helps,
Mat

Yes. Your code does what I want. The call to flush makes all the difference. I didn’t know there was an intrinsic subroutine named flush.
Thanks.

Mat,

I just discovered that there is a FLUSH statement in Fortran 2003 which is preferred over the FLUSH intrinsic. I will try to use the new FLUSH statement now.

Best Regards,
David