title: Open and read data in one row in fortran 90
body: <p>I did some dummy code to learn to open and read file. Let's say I have the following test.dat which reads</p>
  
  <pre><code>1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  </code></pre>
  
  <p>I wrote the following code to open and read the data file</p>
  
  <pre><code>subroutine readdata
  implicit none
  
  integer             :: j
  double precision    :: test
  
  open(unit = 100, file = 'test.dat', status = 'old', action = 'read')
   do j = 1,  10
   read(100,*) test
   print *, 'N1=', test
  end do
  
  end subroutine
  </code></pre>
  
  <p>The output is shown below, as expected</p>
  
  <pre><code> gfortran -g  -I/usr/include -o main main.o subroutines.o -L/usr/lib64/liblapack -L/usr/lib64/libblas
   test=   1.0000000000000000     
   test=   2.0000000000000000     
   test=   3.0000000000000000     
   test=   4.0000000000000000     
   test=   5.0000000000000000     
   test=   6.0000000000000000     
   test=   7.0000000000000000     
   test=   8.0000000000000000     
   test=   9.0000000000000000     
   test=   10.000000000000000     
   Main finished.
  </code></pre>
  
  <p>However, if the data is stored in a single row as follows</p>
  
  <pre><code>1 2 3 4 5 6 7 8 9 10
  </code></pre>
  
  <p>then the above code does not work as desired. It only reads the first element in the row and then prompt an error</p>
  
  <pre><code>sharwani@linux-h6qd:~/PHD_research/myCodes/data&gt; ./runcase.sh
  rm -f *.o *.mod *.MOD *.exe *.stackdump main
  gfortran -g  -I/usr/include -c main.f90
  gfortran -g  -I/usr/include -c subroutines.f90
  gfortran -g  -I/usr/include -o main main.o subroutines.o -L/usr/lib64/liblapack -L/usr/lib64/libblas
  test=   1.0000000000000000    
  At line 9 of file subroutines.f90 (unit = 100, file = 'test.dat')
  Fortran runtime error: End of file
  </code></pre>
  
  <p>So, my question is that I have a data file which contains 2879 (1 x 2879) numbers stored in a single row. How am I going to open and read all those numbers in the data file?</p>