#! /bin/csh 
# Last edited on 2002-12-26 17:40:23 by anamaria

set name = "$1"

set tmp = "/tmp/$$"

set secfile = ${name}-sec.plt
set maxfile = ${tmp}-x.max

cat ${secfile} | tail -1 | gawk '/[.][0-9]/{ print $2; exit 0; }' > ${maxfile}
set dmax = `cat ${maxfile}`
cat ${secfile} \
  | gawk 'BEGIN{qm=999999999;} /[.][0-9]/{q=$3+0;if(q<qm){qm=q;}} END{print qm;}' \
  > ${maxfile}
set qmin = `cat ${maxfile}`

echo "${name}: dmax = ${dmax}  qmin = ${qmin}"

gnuplot <<EOF
set term x11
dmax = ${dmax}
qmin = ${qmin}
set yrange [(-0.05*qmin):(8.05*qmin)]
plot \
  "${secfile}" using 2:3 title "${name}: q" with linespoints linetype 2
  
pause 60
quit
EOF

rm -f ${tmp}-*

