title: Fortran: Automatic determination of character length during initialization
body: <p>In <code>Fortran</code> is it possible to automatically deduct the length of a character (string) when using an initializer during declaration? I want something like this (not working as it stands)</p>
  
  <pre><code>  character(*) :: a = 'John Doe'
    character(:) :: a = 'John Doe'
  </code></pre>
  
  <p>Example code</p>
  
  <pre><code>program char
    implicit none
  
    character(8) :: a = 'John Doe' !&lt;-automatically?
  
    write(*,*) a
    write(*,*) len(a)
  
  end program char
  </code></pre>
  
  <p>One correct way would be to use</p>
  
  <pre><code>  character(8) :: a = 'John Doe'
  </code></pre>
  
  <p>by simply counting the characters, which however is error-prone. Alternatively I could make the character longer than necessary and use <code>trim()</code></p>
  
  <pre><code>program char
    implicit none
  
    character(100) :: a = 'John Doe'
  
    write(*,*) trim(a)
    write(*,*) len(trim(a))
  
  end program char
  </code></pre>
  
  <p>But can the <code>8</code> be determined automatically? I am aware that this is an academic question, but I am still wondering...</p>