title: How to open and read multiple files in Fortran 90
body: <p>I have some issues about opening and reading multiple files. I have to write a code which reads two columns in n files formatted in the same way (they are different only for the values...). Before this, I open another input file and an output file in which I will write my results. I read other questions in this forum (<a href="https://stackoverflow.com/questions/7611360/opening-multiple-files-in-fortran-90">such as this one</a>) and tried to do the same thing, but I receive these errors:</p>
  
  <pre><code> read(fileinp,'(I5)') i-49
                     1
   devstan.f90:20.24:
  
   fileLoop : do i = 50,52
                      2
   Error: Variable 'i' at (1) cannot be redefined inside loop beginning at (2)
  </code></pre>
  
  <p>and </p>
  
  <pre><code> read(fileinp,'(I5)') i-49
             1
   Error: Invalid character in name at (1)
  </code></pre>
  
  <p>My files are numbered from 1 to n and are named 'lin*27-n.dat' (where n is the index starts from 1) and the code is:</p>
  
  <pre><code> program deviation
    implicit none
  
    character(len=15) :: filein,fileout,fileinp
    integer :: row,i,h
    real :: usv,usf,tsv,tsf,diff
  
  
    write(*,'(2x,''Input file .......''/)')
    read(*,'(a12)') filein
    write(*,'(2x,''Output file........''/)')
    read(*,'(a12)') fileout
    open(unit = 30,File=filein)
    open(unit = 20,File=fileout)
  
  
    fileLoop : do i = 50,52
    fileinp = 'lin*27-'
    read(fileinp,'(I5)') i-49
    open(unit = i,File=fileinp)
  
  
     do row = 1,24
      read(30,*) h,usv,tsv
      read(i,*)  h,usf,tsf
  
       diff = usf - usv
  
      write(20,*) diff
     enddo
     close(i)
    enddo fileLoop
  
   end program deviation
  </code></pre>
  
  <p>How can I solve it? I am not pro in Fortran, so please don't use difficult language, thanks.</p>