- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thnx...it is working
![](/skins/images/06022F5BB6D2F28C8F102671A0F06E85/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page