Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

FLUSH not doing what I expect!

andrew_valentine
Beginner
415 Views
Hi,

I'm trying to get the following to work, using the Intel Fortran Compiler 8.1:

[...]
USE IFPORT
[...]
DO i=1,A
[...]
CALL ABC
END DO

SUBROUTINE ABC
IF (...)
[...]
WRITE (*, '(A)' ADVANCE='NO') "..."
CALL FLUSH(6)
END IF
END SUBROUTINE ABC
[...]

It compiles fine, but then on runtime the flushing doesn't seem to occur: the data is only written to screen when the DO loop is complete. I've compiled the same code using the NAG F95 compiler, except with USE F90_UNIX instead of USE IFPORT, and everything seems to work fine. Am I doing something silly somewhere? I've looked in the documentation, but I can't find anything that seems to help!

Thanks,
Andrew
0 Kudos
1 Reply
Steven_L_Intel1
Employee
415 Views
CALL FLUSH is used to make sure that the file system writes data back to the file, rather than keeping it in internal buffers. It does not cause partial records to be written, which is what your case has.
The behavior you are looking for is implementation-dependent, and non-advancing I/O was not intended for this purpose. I recommend instead using the $ edit descriptor in an explicit formatted write. This will do what you want.
0 Kudos
Reply