- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I was trying to implement the EOF function, in order to read until end of the input file, as
DO WHILE (.NOT. EOF(unit number of open file))
It gives the following error:
forrtl: severe (24): end-of-file during read, unit 121,
Attached herewith is the test code and input file.
Any suggestions in this regard would be greatly helpful.
Thank you.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I was trying to implement the EOF function, in order to read until end of the input file, as
DO WHILE (.NOT. EOF(unit number of open file))
It gives the following error:
forrtl: severe (24): end-of-file during read, unit 121,
Attached herewith is the test code and input file.
Any suggestions in this regard would be greatly helpful.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your program reads from the file in groups of three records, but the file doesn't have a multiple of three lines. The EOF will tell you if the first READ in the DO will get an endfile, but it's the second that is the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Steve, I deleted the two READ statements, and now it works fine. Now I learnt that the EOF statement is specific to the DO loop (when you said the EOF will tell if the first READ in the DO will get an endfile).
Thanks again for everything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, EOF is not specific to the DO loop, that;s just where you had it. While you can use EOF to test to see if you are at end of file, most Fortran programmers would add IOSTAT=integer-variable on each READ and test to see if it was negative, indicating an end of file. Or, they might use END= to branch to a label on end of file. I don't see EOF used too often.
Each of your READ statements reads a line from the file. Since you had two READs that had no variables, they simply skipped a line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Steve for the clarification, this is very helpful also.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page