mpcclose
if ls $MPCTOPO/* | fgrep -s "test_machine"
then 
     rm  $MPCTOPO/test_machine
fi
case $WHICHMPI in
  MPICH)   echo  `uname -n` "1"   > $MPCTOPO/test_machine ;;
  LAM)     echo  `uname -n` "12"  > $MPCTOPO/test_machine ;;
  LAM6.3)  echo  `uname -n` "12"  > $MPCTOPO/test_machine ;;
  *) echo Environmental variable WHICHMPI not defined, generating VPM description for LAM
     echo  `uname -n` "12"  > $MPCTOPO/test_machine
esac


echo Virtual parallel machine test_machine with description file
cat $MPCTOPO/test_machine
echo is created. 
echo
echo !
echo ! Warning. It is long time operation.
echo !
echo
mpccreate test_machine

echo
echo '*** BEGIN OF TESTING ***'
echo
if ls *.mpc | fgrep -s ".mpc"
then  
      for i in *.mpc
          do
                echo
                name=`basename $i .mpc`
                echo compiling $name.mpc
                mpcc $name.mpc
                cp $name.c $MPCLOAD
                rm -f $name.c
                echo loading $name.c
                mpcload -o $name $name.c
                echo test $i is running
                mpcrun $name
                wait
                rm -f $MPCLOAD/$name* $MPCTOPO/test_machine_$name*
          done
fi
echo
echo '*** END OF TESTING ***'
echo
mpcclose
rm -f PI* MPC*
