This question seems to be related to Error: Expected variable in READ statement at (1) but it is not the same, since I have declared the variables.
program read_matrix
integer :: m(3,3),n(3), i, j
open(1001, file='data1.txt')
do i = 1, 3
read(1001,*) (m(i,j), (j=1,3))
end do
end program read_matrix
data1.txt is
1 2 3
4 5 6
7 8 9
10
I used gfortran to compile the above fortran code, and got
read-1.f90:7.16:
read(1001,*) (m(i,j), (j=1,3))
1
Error: Expected variable in READ statement at (1)
Hence, I am wondering what is the reason for it. Thanks.
Your implied-do loop is wrong. Look at the parentheses. Here what you want
read(1001,*) (m(i,j), j=1, 3)