Bash wrapper for fortran code

Viewed 87

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:

[user@host] ./mycode

Welcome; what is the file name? _

Once you give it the param file and hit enter, the program executes it and prompts options:

OPTIONS  a=add something
         u=undo
         o=overplot
         q=quit

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:

./mycode_auto param_file

Then it would execute the param_file and give the prompt with options. My first naive attempt, which I knew it was missing something:

#!/bin/bash

./mycode << EOF

$1

EOF

It opens mycode, executes the param file, but breaks right after, and I get:

Fortran runtime error: End of file

I can actually understand what it happening, but don't know a way around it. Any ideas?

Thanks!

1 Answers
Related