#!/bin/sh

rm outSS
for x in "10 0" "10 1" "15 0" "15 1" "15 2" "20 0" "20 1" "20 2" "30 0" "30 1" "30 2" "30 3" "60 0" "60 2" "60 4" "60 6"
do
    echo ./simstr GwI -f 10 -s 2 X.6400k $x $y out
    time -p (./simstr GwI -f 10 -s 2 X.6400k $x $y out ) > outt 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 X."$x" " " >> outSS
      fgrep user outt | awk '{print $2}' >> outSS
      n=`wc out | awk '{print $1}'`
      l=`ls -l out | awk '{print $5}'`
      echo $n " ;  " $l " ; " `expr $l / $n` >> outSS
      
      ./exp_sub out 30 2 >> outSS

    else 
      pkill simstr
    fi
done


for x in "8 0" "8 1" "12 0" "12 1" "12 2" "18 0" "18 1" "18 2" "18 3" "25 0" "25 1" "25 2" "25 3" "25 4" "40 0" "40 2" "40 4" "40 8"
do
    echo ./simstr32 twI -f 10 -s 2 word.1600k $x out
    time -p (./simstr twI -f 10 -s 2 word.1600k $x out ) > outt 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 word."$x" " " >> outSS
      fgrep user outt | awk '{print $2}' >> outSS
      n=`wc out | awk '{print $1}'`
      l=`ls -l out | awk '{print $5}'`
      echo $n " " $l " " `expr $l / $n` >> outSS

      ./exp_sub32 out 10 1 >> outSS 

    else 
      pkill simstr
    fi
done
