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