#!/bin/sh

rm outCC
for x in `ls ~/data/grh/*.grh | fgrep -v bilink`
do
  for y in 1
  do 
    echo ./cypath C $x
    time -p (./cypath C $x) > 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
      cat out
      echo -n $x " " >> outCC
      fgrep user out | awk '{print $2}' >> outCC
      head -2 out | tail -1 >> outCC
    else 
      pkill cypath
      echo "=== not terminate" ./cypath C -S 1000000 $x
      time -p (./cypath C -S 1000000 $x) > out 2>&1
      echo -n $x "1M " >> outCC
      fgrep user out | awk '{print $2}' >> outCC
    fi
  done
done

