I have a file with three columns (ID number, x, y)
ifile.txt
1 32.2 21.4
4 33.2 43.5
5 21.3 45.6
12 22.3 32.5
32 21.5 56.3
43 33.4 23.4
44 23.3 22.3
55 22.5 32.4
I would like to make a loop over column 2 and 3 so that is will read like
for x=32.2 and y=21.4; do execute a fortran program
for x=33.2 and y=43.5; do execute the same program
and so on
Though my following script is working, but I need it in an efficient way.
s1=1 #serial number
s2=$(wc -l < ifile.txt) #total number to be loop
while [ $s1 -le $s2 ]
do
x=$(awk 'NR=='$s1' {print $2}' ifile.txt)
y=$(awk 'NR=='$s1' {print $3}' ifile.txt)
cat << EOF > myprog.f
...
take value of x and y
...
EOF
ifort myprog.f
./a.out
(( s1++ ))
done
Kindly Note: myprog.f is written within a cat program. for example,
cat << EOF > myprog.f
....
....
take value of x and y
....
....
EOF
xyzrelate to shell variables$xand$y, and ifxyrefers to these shell variables, what doeszrefer to?$xand$yto be environment variables thatmyprog.fwill be able to read? Is$s1of relevance, or is it only used to drive the loop?ifort, and then executing it? Why would you not statically compile a program that takes arguments?