For Programmers: Free Programming Magazines  


Home > Archive > Fortran > June 2004 > [Q] Write file and check it while the program runs









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author [Q] Write file and check it while the program runs
Jaegu Lee

2004-06-25, 7:43 pm

Hello, everybody

I have a question.
I would like to check the result while the program runs.
But I found that if 'CLOSE' is not excuted, the writing file is empty.
So, If the result does not converge, I can not get the output file.

main. f90=====================================
=============
OPEN( UNIT=1, FILE="TEMP", STATUS="REPLACE")
DO ( until the result converges )
WRITE(1,*) results
ENDDO
CLOSE(1)
========================================
=================

so I coded like below.

main. f90=====================================
=============
OPEN( UNIT=1, FILE="TEMP", STATUS="REPLACE")

CLOSE(1)
DO ( until the result converges )
OPEN( UNIT=1, FILE="TEMP", STATUS="OLD", POSITION="APPEND" )
WRITE(1,*) results
CLOSE(1)
END DO
========================================
=================

I'm wondering if there is any other way to check the writing file, and
if the OPEN statement in DO loop affects the speed of the program.

OS:Redhat 7 , Compiler : lf95



Tom Micevski

2004-06-25, 7:43 pm

Jaegu Lee wrote:
> I have a question.
> I would like to check the result while the program runs.
> But I found that if 'CLOSE' is not excuted, the writing file is empty.
> So, If the result does not converge, I can not get the output file.


it probably buffers the output --- waiting until there is a sufficient data before flushing to the file. there probably is a compiler switch to force immediate flushing to file.
Dick Hendrickson

2004-06-25, 7:43 pm

As another poster said, output is usually held in a
buffer until a track or so can be written to the
disk. Many compilers support some sort of FLUSH
statement which forces output to the disk. Check
your documentation, or just try
FLUSH(1)
after the WRITE and see if it works.

Dick Hendrickson

Jaegu Lee wrote:

> Hello, everybody
>
> I have a question.
> I would like to check the result while the program runs.
> But I found that if 'CLOSE' is not excuted, the writing file is empty.
> So, If the result does not converge, I can not get the output file.
>
> main. f90=====================================
=============
> OPEN( UNIT=1, FILE="TEMP", STATUS="REPLACE")
> DO ( until the result converges )
> WRITE(1,*) results
> ENDDO
> CLOSE(1)
> ========================================
=================
>
> so I coded like below.
>
> main. f90=====================================
=============
> OPEN( UNIT=1, FILE="TEMP", STATUS="REPLACE")
>
> CLOSE(1)
> DO ( until the result converges )
> OPEN( UNIT=1, FILE="TEMP", STATUS="OLD", POSITION="APPEND" )
> WRITE(1,*) results
> CLOSE(1)
> END DO
> ========================================
=================
>
> I'm wondering if there is any other way to check the writing file, and
> if the OPEN statement in DO loop affects the speed of the program.
>
> OS:Redhat 7 , Compiler : lf95
>
>
>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com