Hi.
It's useful if you post your OS and language with your question.
Your program is clearly Fortran.
I'll assume that you want to change your program as little as possible. With that assumption, here are some techniques for entering data that is requested with read(*,*)
statements:
#!/usr/bin/env bash
# @(#) s1 Demonstrate data input into Fortran.
# Utility functions: print-as-echo, print-line-with-visual-space, debug.
# export PATH="/usr/local/bin:/usr/bin:/bin"
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
db() { : ; }
C=$HOME/bin/context && [ -f $C ] && $C gfortran
VALUE=${1-17.4}
pl " Script value argument: $VALUE"
pl " Sample choices text file inputs:"
head choices*
pl " Demonstration Fortran code:"
F=f2.f90
cat $F
# Compile code.
pe
gfortran $F
file a.out
pl " Execute, enter data from keyboard:"
./a.out
pl " Execute, read from choices-1:"
./a.out < choices-1.txt
pl " Execute, read from choices-2:"
./a.out < choices-2.txt
pl " Execute, read from in-line data, a \"here\" document:"
./a.out <<SIGNAL
97
SIGNAL
pl " Execute, read from in-line data, a \"here\" document, script parameter:"
./a.out <<CHEWING_GUM
$VALUE
CHEWING_GUM
exit 0
producing:
./s1 101.55
Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution : Debian GNU/Linux 5.0.8 (lenny)
bash GNU bash 3.2.39
gfortran GNU Fortran (Debian 4.3.2-1.1) 4.3.2
-----
Script value argument: 101.55
-----
Sample choices text file inputs:
==> choices-1.txt <==
33
==> choices-2.txt <==
67.24
-----
Demonstration Fortran code:
program f2
! @(#) f2 Demonstrate Fortran-90.
write(*,*) " First number:"
read(*,*) x
write(*,*) " You entered: ", x
end program f2
a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped
-----
Execute, enter data from keyboard:
First number:
22
You entered: 22.000000
-----
Execute, read from choices-1:
First number:
You entered: 33.000000
-----
Execute, read from choices-2:
First number:
You entered: 67.239998
-----
Execute, read from in-line data, a "here" document:
First number:
You entered: 97.000000
-----
Execute, read from in-line data, a "here" document, script parameter:
First number:
You entered: 101.55000
There are standard modules that one can call to process the control statement. They might be of use in processing the file arguments. However, it would be useful if you would post the code for initializing the input and output files: where the filenames are defined, the open & close statements, etc.
Best wishes ... cheers, drl