|
| View previous topic :: View next topic |
| Author |
Message |
OmidKar
Joined: 23 Jan 2013 Posts: 10
|
Posted: Wed Apr 17, 2013 10:38 pm Post subject: I/O error: PGFIO-F-215 |
|
|
Hi,
I have coded a program to perform some operations on a sparse system of equations. The first step of the program is to read the matrix and the right hand side vector from a text file.
The data in the file include the dimension of the matrix (n) and the number of nonzero elements(nnz) in the first line separated by space, the entries of the matrix in the next line, each line contains the row number, the colum number and the value of the element separated by space, and finally the RHS vector, each entry in a separate line.
(for example for a 3*3 system:
3 5
1 1 10
1 2 5
2 2 4
3 1 -5
3 3 7
18
20
-15
)
The piece of code I am using to read these, which works fine in Intel Visual Fortran, is:
Open(unit=10, file="input.txt", status="old")
read(10,*) n, nonzero
allocate(mat(nonzero), row(nonzero), col(nonzero), b(n))
do i= 1, nonzero
read(10,*) row(i),col(i), mat(i)
end do
do i= 1, m
read(10,*) b(i)
end do
close(10)
The "input.txt" file is located in the project folder and also added to the project resources.
The error I get reads:
"
PGFIO-F-215/list-directed read/unit=10/formatted/attempt to read past end of file. File name = input.txt formatted, sequential access record = 1
"
As the record number shows, and I checked by putting pause after each reading line, the program opens the file with no problem, but can not perform the very first read line ( read(10,*) n, nonzero ) .
Can anyone help me with this issue?
Many thanks,
Omid |
|
| Back to top |
|
 |
mecej4
Joined: 19 Jun 2011 Posts: 42
|
Posted: Thu Apr 18, 2013 4:56 am Post subject: Re: I/O error: PGFIO-F-215 |
|
|
Using IMPLICIT NONE would have pointed out the bug on the following line, where you should have n instead of m.
Secondly, it is usually a losing game to comment on a post where only snippets of code are shown.
Check that you did not corrupt your data file by making it part of your project as a "resource".
Check that you are opening the input file in the correct directory. If the file was opened in a directory where it did not exist, an empty file would get created, and the first READ would cause EOF. |
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Thu Apr 18, 2013 8:42 am Post subject: |
|
|
| Quote: | | Using IMPLICIT NONE would have pointed out the bug on the following line, where you should have n instead of m | Definitely a problem, but not the cause of the above error.
| Quote: | | post where only snippets of code are shown. | Having a reproducing example is very helpful. Not always necessary, but helpful.
| Quote: | | Check that you are opening the input file in the correct directory. If the file was opened in a directory where it did not exist, an empty file would get created, and the first READ would cause EOF. | Since he has "old" for the status, the open would fail if it couldn't find the file.
| Quote: | | but can not perform the very first read line ( read(10,*) n, nonzero ) . | How was the "input.txt" file created? The error suggest to me that the end line isn't a newline (\n) or carriage-return/newline (\r\n).
Here's an reproducing example:
| Code: | PGI$ cat test_read.f90
program foo
integer, allocatable :: row(:), col(:), mat(:), b(:)
integer :: n, nonzero
Open(unit=10, file="input.txt", status="old")
read(10,*) n, nonzero
allocate(mat(nonzero), row(nonzero), col(nonzero), b(n))
do i= 1, nonzero
read(10,*) row(i),col(i), mat(i)
end do
do i= 1, n
read(10,*) b(i)
end do
close(10)
do i=1,nonzero
print *, row(i), col(i), mat(i)
enddo
do i = 1,n
print *, b(i)
enddo
end program foo
PGI$ pgfortran test_read.f90
PGI$ test_read.exe
PGFIO-F-209/OPEN/unit=10/'OLD' specified for file which does not exist.
File name = input.txt
In source file test_read.f90, at line number 7
PGI$ mv i.txt input.txt
PGI$ cat input.txt
3 5
1 1 10
1 2 5
2 2 4
3 1 -5
3 3 7
18
20
-15
PGI$ test_read.exe
1 1 10
1 2 5
2 2 4
3 1 -5
3 3 7
18
20
-15 |
- Mat |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|