title: Reading a character string of unknown length
body: <p>I have been tasked with writing a Fortran 95 program that will read character input from a file, and then (to start with) simply spit it back out again.
  The tricky part is that these lines of input are of varying length (no maximum length given) and there can be any number of lines within the file.</p>
  
  <p>I've used</p>
  
  <pre><code>    do
        read( 1, *, iostat = IO ) DNA    ! reads to EOF -- GOOD!!
        if ( IO &lt; 0 ) exit               ! if EOF is reached, exit do
        I = I + 1
        NumRec = I                       ! used later for total no. of records
        allocate( Seq(I) )
        Seq(I) = DNA
        print*, I, Seq(I)
        X = Len_Trim( Seq(I) )           ! length of individual sequence
        print*, 'Sequence size: ', X
        print*
      end do
  </code></pre>
  
  <p>However, my initial statements list</p>
  
  <pre><code>    character(100), dimension(:), allocatable :: Seq
      character(100)  DNA
  </code></pre>
  
  <p>and the appropriate integers etc.</p>
  
  <p>I guess what I'm asking is if there is any way to NOT list the size of the character strings in the first instance. Say I've got a string of DNA that is 200+ characters, and then another that is only 25, is there a way that the program can just read what there is and not need to include all the additional blanks? Can this be done without needing to use <code>len_trim</code>, since it can't be referenced in the declaration statements?</p>