title: how to write a huge matrix to file row by row (fortran 90)
body: <p>I want to write a matrix with a lot of data to a file row by row. For example, I have a matrix 100*100 and I want to have it in form 100*100 in the file. However, it doesn't work.Following is my code and some description. N and M are integers around some hundreds. RECL is expected length I set the file but here it seems this command does not work. The output is with 198 lines when N is set 99
  and M is set 200. Vec is a double precision complex matrix. How could I output the values of Vec keeping its original format N*M? My compile command is "ifort -o out test.f90".</p>
  
  <pre><code>open(unit=2, file='graph1.txt', ACTION="write", STATUS="replace",RECL=40*M+10)
  do i=1,N
   do j=1,M
    write(2, '(F)', advance='no') real(Vec(i,j)) 
   end do
    write(2, *) '' 
  end do
  </code></pre>
  
  <p>Following @george advice, I coded a program like this:</p>
  
  <pre><code>program test
  implicit none
  
  integer i,j
  
  open(unit=2, file='graph1.txt', ACTION="write", STATUS="replace")
  do i=1,500
   write(2, '(1600F14.7)')( 0.00001 ,j=1,499)
  end do
  
  close(2)
  
  end
  </code></pre>
  
  <p>With this code, problem solved! Maybe I didn't compile correctly last time.</p>