title: Why one can't initialize INTENT(OUT) or RESULT variables in Fortran?
body: <p>Gfortran won't let me compile the following code because <code>nLines</code> and <code>nIOstts</code> can't be initialized like this; so I had to declare them first and then add two lines to the code to set their required initial values.  </p>
  
  <p>Why does this work like this? Perhaps with <code>INTENT(OUT)</code> it makes a little more sense since the variable in which the function will store the data already exists (and I don't recall right now whether Fortran subroutines worked by reference or not), but for the <code>RESULT</code> variable it would seem rather unnecessary. Is this specific of the compiler or is it a general Fortran characteristic?</p>
  
  <pre><code>FUNCTION LinesInFile(nUnit,nIOstts) RESULT(nLines)
  
  IMPLICIT NONE  
  INTEGER,INTENT(IN)  :: nUnit  
  INTEGER,INTENT(OUT) :: nIOstts=0  
  INTEGER             :: nLines=-1
  
  DO WHILE (nIOstts.EQ.0)  
  
      READ(UNIT=nUnit,FMT='(A)',nIOstts)
      nLines=nLines+1
  
  ENDDO
  
  END FUNCTION
  </code></pre>