#!/bin/sh

rm outC
for x in 25 50 100 200 400 800 1600 3200 6400
do
  for y in 1 2 3 4 5 6 7 8 9
  do 
    echo ./cypath C u"$x"_$y.grh 
    time -p (./cypath C u"$x"_$y.grh) > out 2>&1 & 
    pid=$!
    a=0
    flag=""
    while [ $a -le 3600 ]
    do
      w=`pmap $pid`
      if [ -z "$w" ] ; then
        flag=1
        a=40000000
      fi
      a=`expr $a + 1`
      sleep 1
    done
    
    if [ -n "$flag" ] ; then
      echo -n u"$x"_$y.grh " " >> outC
      fgrep user out | awk '{print $2}' >> outC
      head -2 out | tail -1 >> outC
    else 
      pkill cypath
      echo "=== not terminate" ./cypath C -S 1000000 u"$x"_$y.grh 
      time -p (./cypath C -S 1000000 u"$x"_$y.grh) > out 2>&1
      echo -n u"$x"_$y.grh "1M " >> outC
      fgrep user out | awk '{print $2}' >> outC
    fi
  done
done

