title: Stop fortran program with non-zero exit status
body: <p>I'm adapting some Fortran code I haven't written, and without a lot of fortran experience myself. I just found a situation where some malformed input got silently ignored, and would like to change that code to do something more appropriate. If this were C, then I'd do something like</p>
  
  <pre class="lang-c prettyprint-override"><code>fprintf(stderr, "There was an error of kind foo");
  exit(EXIT_FAILURE);
  </code></pre>
  
  <p>But in fortran, the best I know how to do looks like</p>
  
  <pre><code>write(*,*) 'There was an error of kind foo'
  stop
  </code></pre>
  
  <p>which lacks the choice of output stream (minor issue) and exit status (major problem).</p>
  
  <p><strong>How can I terminate a fortran program with a non-zero exit status?</strong></p>
  
  <p>In case this is compiler-dependent, a solution which works with gfortran would be nice.</p>