| View previous topic :: View next topic |
| Author |
Message |
kuldeep gupta
Joined: 11 Oct 2011 Posts: 41
|
Posted: Sat Feb 18, 2012 11:00 am Post subject: fortran run time error |
|
|
when we get this error
"PGFIO-F-217/formatted attempt to read past end of file"
& what can we do to eliminate this error
Please help me, |
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Mon Feb 20, 2012 2:37 pm Post subject: |
|
|
| Quote: | | what can we do to eliminate this error | All we know from this error is that your program tried to continue reading a file after it reach the end. What type of file is it trying to read? How is the file being accessed? What does your open statement look like? What format is the data? How was the file's data created?
Most likely your program is expecting the file to be in one format but it's in another.
- Mat |
|
| Back to top |
|
 |
zbeekman
Joined: 04 Apr 2012 Posts: 5
|
Posted: Wed Apr 04, 2012 11:15 am Post subject: |
|
|
If you're doing unformatted IO then Fortran will include record indicators, and an entire record is typically consumed by each read statement whether or not you request all the data.
| Code: | OPEN(unit,file=myfile.dat, form='UNFORMATTED')
WRITE(unit) foo1, foo2, foo3
WRITE(unit) bar1, bar2, bar3
CLOSE(unit)
...
OPEN(unit,file=myfile.dat, form='UNFORMATTED')
READ(unit) foo1
READ(unit) foo2 ! This will likely be bar1, not foo2!
CLOSE(unit) |
In the above example the two read statements will likely consume all the data written by the two write statements. In formatted files the newline character is the marker of the end of the record, so after each read statement the file will be positioned at the next line (unless the ADVANCE='NO' specifier is used. |
|
| Back to top |
|
 |
|