title: Bash wrapper for fortran code
body: <p>I have a fortran code (wrote by somebody else - cannot change it...) that takes an input parameter file, executes it, then has an interactive prompt. This is how it works:</p>
  
  <pre><code>[user@host] ./mycode
  
  Welcome; what is the file name? _
  </code></pre>
  
  <p>Once you give it the param file and hit enter, the program executes it and prompts options:</p>
  
  <pre><code>OPTIONS  a=add something
           u=undo
           o=overplot
           q=quit
  </code></pre>
  
  <p>You then interact with the code, and quit. The problem I have is that every time I quit the program and have to start over, I have to keep re-typing the param file name (which is a pain for long names). I would like to write a simple shell-script that would do:</p>
  
  <pre><code>./mycode_auto param_file
  </code></pre>
  
  <p>Then it would execute the param_file and give the prompt with options. My first naive attempt, which I knew it was missing something:</p>
  
  <pre><code>#!/bin/bash
  
  ./mycode &lt;&lt; EOF
  
  $1
  
  EOF
  </code></pre>
  
  <p>It opens <code>mycode</code>, executes the param file, but breaks right after, and I get:</p>
  
  <pre><code>Fortran runtime error: End of file
  </code></pre>
  
  <p>I can actually understand what it happening, but don't know a way around it. Any ideas?</p>
  
  <p>Thanks!</p>