#! /bin/csh 
# Last edited on 2002-12-24 01:09:35 by anamaria

set name = "$1"

set tmp = "/tmp/$$"

set optfile = ${name}-opt.plt
set maxfile = ${tmp}-x.max

cat ${optfile} | gawk '/[.][0-9]/{ print 2*($6); exit 0; }' > ${maxfile}
set qmax = `cat ${maxfile}`
cat ${optfile} | gawk '/[.][0-9]/{ print 2*($4); exit 0; }' > ${maxfile}
set emax = `cat ${maxfile}`
cat ${optfile} | tail -1 | gawk '/[.][0-9]/{ print 2*($2); exit 0; }' > ${maxfile}
set tmax = `cat ${maxfile}`

echo "${name}: tmax = ${tmax}  qmax = ${qmax}  emax = ${emax}"

gnuplot <<EOF
set term x11
tmax = ${tmax}
qmax = ${qmax}
emax = ${emax}
set xrange [(-0.05*tmax):(0.25*tmax)]
set yrange [(-0.05*qmax):(1.05*qmax)]
plot \
  "${optfile}" using 2:6 title "${name}: qbest" with steps linetype 1, \
  "${optfile}" using 2:5 title "${name}:     q" with points linetype 3, \
  "${optfile}" using 2:(qmax*\$4/emax) title "${name}:  eps" with lines  linetype 2
  
pause 60
quit
EOF

rm -f ${tmp}-*

