title: Efficiency in writing to disk in Fortran
body: <p>I am trying to write a bunch of large matrices in fortran to disk. 
  Matrices are <code>V</code>, <code>C</code> and <code>d</code>. All have size <code>(2 , n1, n2, n3, n4, n5).</code></p>
  
  <p>These are large matrices. And fortran is taking around 3 hours to write them.</p>
  
  <pre><code>do ind1=1,n1
  do ind2=1,n2
  do ind3=1,n3
  do ind4=1,n4
  
       write(filename,'(a,i0,a,i0,a,i0,a,i0,a,i0,a)')'PF',t,'_',ind1,'_',ind2,'_',ind3,'_',ind4,'.txt'
  
       OPEN(UNIT=25,FILE=filename,STATUS='replace',ACTION='write')
       do ind5=1,n5
        WRITE(25,*) c(2,ind1,ind2,ind3, ind4,ind5)
       end do
       do ind5=1,n5
        WRITE(25,*) v(2,ind1,ind2,ind3, ind4,ind5)
       end do
       do ind5=1,n5
        WRITE(25,*) d(1,ind1,ind2,ind3, ind4,ind5)
       end do
       CLOSE(UNIT=25)
  
  end do
  end do
  end do
  end do
  </code></pre>
  
  <p>Any smart way of doing this faster?</p>