I want to read matrix A
of dimension(n,n) from a input file, n
is a variable and n<=50. For testing I took an example matrix as:
5.0 6.0 7.0
4.0 3.0 8.0
1.0 4.0 2.0
I want to read it in same format element-wise using the below code:
But when I compiled it I was getting error:
At line 15 of file partial_pivot.f90 (unit = 9, file = 'gaussj.inp') Fortran runtime error: End of file.
How this problem can be resolved?
program gaussj
implicit none
integer::i,j,n
integer,parameter::nmax=50
real,dimension(nmax,nmax)::A
open(unit=9,file='gaussj.inp',status='old')
n = 0
do i = 1,nmax
n = n+1
read(9,*)(A(i,j),j = 1,nmax)
end do
close(9)
write(25,*)((A(i,j),j=1,n),i=1,n)
end program