#!/bin/sh

MACH=`uname -s`
Sysx="`echo $MACH | cut -b -6`"
if [ $Sysx = "CYGWIN" ]; then
   MACH=`uname -o`
elif [ $Sysx = "AIX" ]; then
   MACH=`uname -s`
else
   MACH=`uname -sm | sed 's/[ ]/_/'`
fi

#buck=""
buck="BK0"

inum=2
ilast=12
CASCAS="CASCAS"
while [ $inum -le $ilast ]
  do 
  cp mydata/rep900cluster_mco_template.x2m mydata/rep900cluster${buck}_mco${inum}.x2m 
  cp mydata/rep900cluster_mco_template.save mydata/rep900cluster${buck}_mco${inum}.save
  perl -pi -e "s/$CASCAS/$inum/g" mydata/rep900cluster${buck}_mco${inum}.x2m
  perl -pi -e "s/$CASCAS/$inum/g" mydata/rep900cluster${buck}_mco${inum}.save
  rm -r mydata/rep900cluster${buck}_mco${inum}_proc
  cp -r mydata/rep900cluster_mco_proc mydata/rep900cluster${buck}_mco${inum}_proc 
  cp mydata/rep900cluster_mco.access mydata/rep900cluster${buck}_mco${inum}.access 
  nohup ./rdragon -p rep900cluster${buck}_mco${inum}.x2m &
#  mv ${MACH}/AEDI Darwin_x86_64/AEDI_$inum
#  mv ${MACH}/AFLUX2 Darwin_x86_64/AFLUX2_$inum
#  mv ${MACH}/APSPFLUCL Darwin_x86_64/APSPFLUCL_$inum
#  mv ${MACH}/rep900het_mco.result Darwin_x86_64/rep900het_mco.result_$inum
  inum=`expr $inum + 1 `
done
