- #1
- 16
- 0
I'm new to fortran coding and trying to read a file called "data.dat" with data like a triangular matrix
using the code
While executing the code I get the following error
At line 11 of file matrix.f90 (unit = 10, file = 'dat.dat')
Fortran runtime error: End of file
Error termination. Backtrace:
How do I rectify this error. kinldy help me.
0.1
0.1 0.2
0.1 0.2 0.3
0.1 0.2 0.3 0.4
0.1 0.2 0.3 0.4 0.5
using the code
PROGRAM matrix
IMPLICIT NONE
REAL, DIMENSION(5,5) :: a
INTEGER :: row,col,max_rows,max_cols
max_rows=5
max_cols=5
OPEN(UNIT=10, FILE="dat.dat",status='old')
DO row = 1,max_rows
DO col = 1,max_cols
if (col .le. row) then
read(10,*) a(row,col)
else
a(row,col) = 0.0
endif
END DO
END DO
DO row = 1,max_rows
WRITE(*,*) (a(row,col),col = 1,max_cols)
END DO
END PROGRAM matrix
While executing the code I get the following error
At line 11 of file matrix.f90 (unit = 10, file = 'dat.dat')
Fortran runtime error: End of file
Error termination. Backtrace:
How do I rectify this error. kinldy help me.