- #1
Telemachus
- 835
- 30
SOLVED
Hi there. I have the elements of a matrix written in a txt file (in row major order). I need to read this matrix to use it in my fortran77 program. The text file contains the elements written in this way:
A(1,1)
A(1,2)
...
A(1,N)
...
A(N,N-1)
A(N,N).
I was thinking in doing a do loop, but I haven't used the read statement before for this kind of tasks. So I wasn't sure on how to do this.
I don't know what the statement at ? should be, in order to get the elements of the file matrix.dat written in the array A(rows,cols).
Thanks in advance.
Edit: just had to use read(file,*)A(i,j)!
Hi there. I have the elements of a matrix written in a txt file (in row major order). I need to read this matrix to use it in my fortran77 program. The text file contains the elements written in this way:
A(1,1)
A(1,2)
...
A(1,N)
...
A(N,N-1)
A(N,N).
I was thinking in doing a do loop, but I haven't used the read statement before for this kind of tasks. So I wasn't sure on how to do this.
Fortran:
open (unit=10,file='matrix.dat',status='old')
do i=1,cols
do j=1,rows
A(i,j)=?
enddo
enddo
I don't know what the statement at ? should be, in order to get the elements of the file matrix.dat written in the array A(rows,cols).
Thanks in advance.
Edit: just had to use read(file,*)A(i,j)!
Last edited: