How can I read the data file containing known number of lines but the number of entries in each line is unknown, e.g. if my data file contain some thing like
This is a program that can count numbers in a line (or number of columns) but for a line. If you have many lines, you should change it slightly.
program test12
implicit none
integer n,m,i
integer,allocatable::x(:)
open(10,file='C:\Users\user\Desktop\file.txt')
allocate(x(n))
20 n=n+1
deallocate(x)
allocate(x(n))
read(10,*,iostat=m)(x(i),i=1,n)
if (m==-1)then
goto 30
else
rewind 10
goto 20
end if
30 print*,n-1
end