advance=no problem
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
advance=no problem         


Author: rudra
Date: May 12, 2008 06:22

dear friends,
i am using ifort compiler in linux.
when i am trying to write something like
write(*,'(1x,'a20',advance='no')"STARTING CALCULATION"
.
!do the calculation.
.
write(*,'a18')"calculation done'

i am expecting the program to write "STARTING CALCULATION" at the
beginning of the calc; do the calc. and write "calculation done' in
the same line when its over.
but its not doing the same thing..rather its waiting to finish the
calc. and writing the whole line in one go...anu idea?
44 Comments
Re: advance=no problem         


Author: rudra
Date: May 12, 2008 06:40

check with this program.....
1 implicit none
2 write(*,'(a20)',advance='no')"checking "
3 call sleep(2)
4 write(*,*) "checked"
5 end
no comments
Re: advance=no problem         


Author: Gordon Sande
Date: May 12, 2008 06:50

On 2008-05-12 10:22:39 -0300, rudra gmail.com> said:
> dear friends,
> i am using ifort compiler in linux.
> when i am trying to write something like
> write(*,'(1x,'a20',advance='no')"STARTING CALCULATION"
> .
> !do the calculation.
> .
> write(*,'a18')"calculation done'

Unbalance quotes so it is not what you actually did.
> i am expecting the program to write "STARTING CALCULATION" at the
> beginning of the calc; do the calc. and write "calculation done' in
> the same line when its over.
> but its not doing the same thing..rather its waiting to finish the
> calc. and writing the whole line in one go...anu idea?

When you use the advance="no" it makes sense to think of it as "to be
continued".
Here you just took a long time to continue you thoughts about the output.

Remove the advance="no" if you want to see the output sooner.
Show full article (1.75Kb)
no comments
Re: advance=no problem         


Author: tholen
Date: May 12, 2008 12:26

rudra gmail.com> writes:
> dear friends,
> i am using ifort compiler in linux.
> when i am trying to write something like
> write(*,'(1x,'a20',advance='no')"STARTING CALCULATION"
> ..
> !do the calculation.
> ..
> write(*,'a18')"calculation done'
>
> i am expecting the program to write "STARTING CALCULATION" at the
> beginning of the calc; do the calc. and write "calculation done' in
> the same line when its over.
> but its not doing the same thing..rather its waiting to finish the
> calc. and writing the whole line in one go...anu idea?

You need to flush the output buffer after the first write. The system
is just trying to be more efficient by buffering its output. It has
no idea in advance how long the computation is going to take.
no comments
Re: advance=no problem         


Author: glen herrmannsfeldt
Date: May 12, 2008 12:43

tholen@antispam.ham wrote:
> rudra gmail.com> writes:
>>dear friends,
>> i am using ifort compiler in linux.
>>when i am trying to write something like
>>write(*,'(1x,'a20',advance='no')"STARTING CALCULATION"
(snip)
>>i am expecting the program to write "STARTING CALCULATION" at the
>>beginning of the calc;
(snip)
> You need to flush the output buffer after the first write. The system
> is just trying to be more efficient by buffering its output. It has
> no idea in advance how long the computation is going to take.

The C/unix tradition is that terminal output (either stderr, or
stdout not redirected to a file) is unbuffered. The output will
appear immediately without the need for fflush(). When going
to a file or even a pipe it is buffered and normally doesn't appear
immediately.
Show full article (1.13Kb)
no comments
Re: advance=no problem         


Author: tholen
Date: May 12, 2008 13:12

glen herrmannsfeldt ugcs.caltech.edu> writes:
>> rudra gmail.com> wrote:
>>> dear friends,
>>> i am using ifort compiler in linux.
>>> when i am trying to write something like
>>> write(*,'(1x,'a20',advance='no')"STARTING CALCULATION"
> (snip)
>>> i am expecting the program to write "STARTING CALCULATION" at the
>>> beginning of the calc;
> (snip)
>> You need to flush the output buffer after the first write. The system
>> is just trying to be more efficient by buffering its output. It has
>> no idea in advance how long the computation is going to take.
Show full article (1.36Kb)
no comments
Re: advance=no problem         


Author: James Giles
Date: May 12, 2008 13:32

glen herrmannsfeldt wrote:
...
>> rudra gmail.com> writes:
>
>>> dear friends,
>>> i am using ifort compiler in linux.
>>> when i am trying to write something like
>>> write(*,'(1x,'a20',advance='no')"STARTING CALCULATION"
> (snip)
>
>>> i am expecting the program to write "STARTING CALCULATION" at the
>>> beginning of the calc;
...
> The C/unix tradition is that terminal output (either stderr, or
> stdout not redirected to a file) is unbuffered. The output will
> appear immediately without the need for fflush(). When going
> to a file or even a pipe it is buffered and normally doesn't appear
> immediately.
Show full article (1.55Kb)
no comments
Re: advance=no problem         


Author: Janne Blomqvist
Date: May 12, 2008 13:55

On 2008-05-12, glen herrmannsfeldt ugcs.caltech.edu> wrote:
> The C/unix tradition is that terminal output (either stderr, or
> stdout not redirected to a file) is unbuffered. The output will
> appear immediately without the need for fflush(). When going
> to a file or even a pipe it is buffered and normally doesn't appear
> immediately.

From the latest(?) ISO C draft (n1256.pdf), page 267:

"""
At program startup, three text streams are predefined and need not be
opened explicitly - standard input (for reading conventional input),
standard output (for writing conventional output), and standard error
(for writing diagnostic output). As initially opened, the standard
error stream is not fully buffered; the standard input and standard
output streams are fully buffered if and only if the stream can be
determined not to refer to an interactive device.
"""
Show full article (1.68Kb)
no comments
Re: advance=no problem         


Author: glen herrmannsfeldt
Date: May 12, 2008 14:09

Janne Blomqvist wrote:
> On 2008-05-12, glen herrmannsfeldt ugcs.caltech.edu> wrote:
>>The C/unix tradition is that terminal output (either stderr, or
>>stdout not redirected to a file) is unbuffered. The output will
>>appear immediately without the need for fflush(). When going
>>to a file or even a pipe it is buffered and normally doesn't appear
>>immediately.
> From the latest(?) ISO C draft (n1256.pdf), page 267:
> At program startup, three text streams are predefined and need not be
> opened explicitly - standard input (for reading conventional input),
> standard output (for writing conventional output), and standard error
> (for writing diagnostic output). As initially opened, the standard
> error stream is not fully buffered; the standard input and standard
> output streams are fully buffered if and only if the stream can be
> determined not to refer to an interactive device.
Show full article (2.38Kb)
no comments
Re: advance=no problem         


Author: Janne Blomqvist
Date: May 12, 2008 14:48

On 2008-05-12, glen herrmannsfeldt ugcs.caltech.edu> wrote:
> Janne Blomqvist wrote:
>> On 2008-05-12, glen herrmannsfeldt ugcs.caltech.edu> wrote:
>
>>>The C/unix tradition is that terminal output (either stderr, or
>>>stdout not redirected to a file) is unbuffered. The output will
>>>appear immediately without the need for fflush(). When going
>>>to a file or even a pipe it is buffered and normally doesn't appear
>>>immediately.
>
>> From the latest(?) ISO C draft (n1256.pdf), page 267:
>
>> At program startup, three text streams are predefined and need not be
>> opened explicitly - standard input (for reading conventional input),
>> standard output (for writing conventional output), and standard error
>> (for writing diagnostic output). As initially opened, the standard
>> error stream is not fully buffered; the standard input and standard
>> output streams are fully buffered if and only if the stream can be
>> determined not to refer to an interactive device.
> ...
Show full article (4.37Kb)
no comments
1 2 3 4 5