Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delay when writing to a file

Status
Not open for further replies.

zanzibar4

Programmer
Nov 1, 2010
1
US
I have a rather large program that periodically calls a subroutine. Inside the subroutine I write out a variable each time the subroutine is called. If I write it to the screen:

WRITE(*,*) HGT (1)

the correct value appears immediately. However, if I write it to a file

WRITE(4,*) HGT (1), the file remains empty for hundreds of subroutine calls, and then suddenly fills up with hundreds of values.

They are the correct values, but I would rather not wait 5 minutes before I can check whether or not the code is writing out the correct values.

Does anyone have any idea what the issue might be?
 
It is buffered to improve processing. Some compilers support FLUSH as a keyword, others as a subroutine. Something like

CALL FLUSH(channel)

or

FLUSH (UNIT=channel)

You could try that.
 
If you are using the IVF compiler, you could use COMMITQQ. On IVF, FLUSH only works in non-blocking mode so the I/O may not have completed when you call FLUSH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top