title: Opening multiple files in Fortran 90
body: <p>I would like to open 10,000 files with file names starting from <code>abc25000</code> until <code>abc35000</code> and copy some information into each file. The code I have written is as below:</p>
  <pre><code>PROGRAM puppy
  IMPLICIT NONE
  
  integer :: i
  CHARACTER(len=3) :: n1
  CHARACTER(len=5) :: cnum
  CHARACTER(len=8) :: n2
  
  loop1: do i = 25000 ,35000  !in one frame
  
    n1='abc'
    write(cnum,'(i5)') i
    n2=n1//cnum
    print*, n2
    open(unit=i ,file=n2)
  
  enddo loop1
  </code></pre>
  <p>end</p>
  <p>This code is supposed to generate files starting from <code>abc24000</code> until <code>abc35000</code> but it stops about half way saying that</p>
  <blockquote>
  <p>At line 17 of file test-openFile.f90 (unit = 26021, file = '')</p>
  <p>Fortran runtime error: Too many open files</p>
  </blockquote>
  <p>What do I need to do to fix the above code?</p>