title: What's the best way (in Fortran 90) to return an array (of unknown size) of strings?
body: <p>I want to write a function that parses a file and return an array of the "matching" lines. I don't care if it is a function or a subroutine, but I am unsure about how to do that. </p>
  
  <p>Let's make this concrete with an example: suppose we want to return an array of all the lines in file <code>inputFile</code> that start with a certain character <code>startingCharacter</code> and return these lines in an array <code>matchingLines</code>. For convenience, let's also return the number of lines in this output array and call that number <code>matchingLineCount</code>. (We'll assume lines are less than 256 characters.) The subroutine code for that example should look something like the following:</p>
  
  <pre><code>subroutine parse_file( inputFile, startingCharacter, matchingLines, matchingLineCount )
  
  implicit none
  
  character(len=*), intent(in) :: inputFile
  character, intent(in)        :: startingCharacter
  character(len=256), dimension(*), intent(out) :: matchingLines
  integer, intent(out)         :: matchingLineCount
  
  ! Open file
  
  ! While there are still lines to be read....
  
      ! Read in a line
      ! See if line(1) == startingCharacter
      ! If it does, add it to matchingLines
  
  ! Close file
  
  end
  </code></pre>
  
  <p>I suspect the trick is how to return a variable-length array....</p>
  
  <p>Thanks!</p>