#!/bin/sh

rm outUC
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 " " >> outUC
      fgrep user out | awk '{print $2}' >> outUC
      head -2 out | tail -1 >> outUC
    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 " >> outUC
      fgrep user out | awk '{print $2}' >> outUC
    fi
  done
done

