title: Allocatable character variables in Fortran
body: <p>My code (stripped down to what I think is relevant for this question) is</p>
  
  <pre><code>PROGRAM test
  
  IMPLICIT NONE
  
  CHARACTER(len=37) input
  CHARACTER(len=:), allocatable :: input_trim
  
  
  WRITE(*,*) 'Filename?'
  READ(*,*) input
  ALLOCATE(character(len=LEN(TRIM(input))) :: input_trim)
  input_trim=trim(input)
  
  .
  .
  .
  
  END PROGRAM test
  </code></pre>
  
  <p>It works fine with Intel's Fortran compiler, however gfortran gives me a couple of errors, the first one being in the line saying</p>
  
  <pre><code>CHARACTER(len=:), allocatable :: input_trim
  </code></pre>
  
  <p>I'm not sure which compiler is 'right' regarding the Fortran standard. Plus I don't know how to achieve what I need in a different way?! I think what I'm doing is more of a workaround anyway. What I need is a character variable containing exactly the filename that was entered with no following spaces.</p>
  
  <p>EDIT: The error is "Syntax error in CHARACTER declaration".
  gfortran --version gives me "GNU Fortran (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)"</p>
  
  <p>EDIT 2: You're right regarding the allocate: With ifort, I don't need it. And gfortran crashes before that so maybe it doesn't need the allocate either but I cannot test this at the moment...</p>