title: Array of Strings in Fortran 77
body: <p>I've a question about Fortran 77 and I've not been able to find a solution.</p>
  <p>I'm trying to store an array of strings defined as the following:</p>
  <pre><code>character matname(255)*255
  </code></pre>
  <p>Which is an array of 255 strings of length 255.</p>
  <p>Later I read the list of names from a file and I set the content of the array like this:</p>
  <pre><code>matname(matcount) = mname
  </code></pre>
  <p><strong>EDIT:</strong> Actually <code>mname</code> value is hardcoded as <code>mname = 'AIR'</code> of type <code>character*255</code>, it is a parameter of a function <code>matadd()</code> which executes the previous line. But this is only for testing, in the future it will be read from a file.</p>
  <p>Later on I want to print it with:</p>
  <pre><code>write(*,*) matname(matidx)
  </code></pre>
  <p>But it seems to print all the 255 characters, it prints the string I assigned and a lot of garbage.</p>
  <ul>
  <li>So that is my question, how can I know the length of the string stored?</li>
  <li>Should I have another array with all the lengths?</li>
  <li>And how can I know the length of the string read?</li>
  </ul>
  <p>Thanks.</p>