title: Format string for output dependent on a variable
body: <p>I would like to have a Fortran write statement formatted to depend on some variable. For example, I could write:</p>
  
  <pre><code>write(*,'(3f15.3,3f9.2)') x,y,z,(var(i),i=1,nvari)
  </code></pre>
  
  <p>where <code>nvari = 3</code>. But, what if, in some cases, I actually have 4 variables (i.e. <code>nvari = 4</code>). I would like to write something like this:</p>
  
  <pre><code>write(*,'(3f15.3,nvari(f9.2))') x,y,z,(var(i),i=1,nvari)
  </code></pre>
  
  <p>Now, <code>nvari</code> can be anything and the output will work as I like. How can I make something like this work?</p>