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

advance =no

roddur
Beginner
458 Views
Dear friends,
while i am running thi following code,
1 implicit none
2 write(*,'(a20)',advance='no')"checking .."
3 call sleep(2)
4 write(*,*) "checked"
5 end

i would expect the program to write "checking .." then wait for 2 sec and the write "checked" in the same line.
instead its waiting for two second and writing the whole thing in one go!!! why? am i missing some thing?
thnx in advance
0 Kudos
3 Replies
Ron_Green
Moderator
458 Views
The runtime library buffers an entire line for stdout. Thus, until the end of line is written, the output is not sent to stdout.

ron
0 Kudos
Ron_Green
Moderator
458 Views
What you can do is use the $ or edit descriptors instead of non-advancing IO:

write(*,'(a20,$)') "checking ..."

to accomplish what you are after.

The FRTL does recognize a transistion from write to read and will flush the line buffer at the transition. This so that one can do this:

write(*,'(a)',advance='no') "enter the number of elements-> "
read(*,*) i

So that one can create prompts.

In the case of write following write, the FRTL assumes that the user is formatting a complete line using multiple write operations. And again, it waits for the final end-of-line OR $ edit descriptors before flushing the buffer.

I hope this helps.

ron
0 Kudos
roddur
Beginner
458 Views
thnx...it is working
0 Kudos
Reply