- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a FORTRAN (IVF-9.0) compiled program which does computations and is heavy on memory and processor. Intermittently the program writes large sets of results to one or more text files on the disk. As expected during the writing phase the program slows down tremendously. Will the speed of the overall program be faster if the printing is done using a separate thread while the computations proceed on the main thread? Or can some other method be suggested to speed up the overall progress of the program. Thank you.
- Santhosh
- Santhosh
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may be able to recover some computation time by copying your results data in internal format then writing to files using seperate thread. A better route would be (if possible) to double buffer. Which will avoid the copy of results data.
As to if it is worth the programming effort, you have to determine how much time is spent writing out the data files. If this is only a small percent of the time then it is probably not worth the effort.
My son went to Purdue University and one of his friends was named Santosh. Would you happen to be this Santosh?
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Jim for the suggestions. In this case it is probably not worth the effort since it will be quite an effort for me. I haveto first learn to write the code for a separate thread.
No, I went to school at UMass.
- Santhosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - jimdempseyatthecove
You may be able to recover some computation time by copying your results data in internal format then writing to files using seperate thread. A better route would be (if possible) to double buffer. Which will avoid the copy of results data.
As to if it is worth the programming effort, you have to determine how much time is spent writing out the data files. If this is only a small percent of the time then it is probably not worth the effort.
My son went to Purdue University and one of his friends was named Santosh. Would you happen to be this Santosh?
Jim Dempsey
Hi Jim,
what do you mean to double buffer the data?
Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - onkelhotte
what do you mean to double buffer the data?
Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use either one thread and asychronous I/O with two buffers in a single threaded loop
open file asychronous
read buffer 1 (no wait)
read buffer 2 (no wait)
loop:
wait for I/O to buffer 1
process buffer 1
read buffer 1 (no wait)
wait for I/O buffer 2
process buffer 2
read buffer 2 (no wait)
goto loop
Add end of file tests.
Alternate way is to use multiple threads (2). Use synchronous I/O and semephores. (WaitForSingleEvent).
Jim Demspey

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