#
# $Id: run_test 19708 2010-10-29 18:04:21Z d3y133 $
#
#
# Script to do test runs of $argv[1].
#
if( $#argv != 1 ) then
  echo ""
  echo ""
  echo ""
  echo " Usage for run_test: run_test exec_file"
  echo ""
  echo "    where exec_file is the name of the executable file to run."
  echo ""
  echo ""
  exit(-1)
endif
#
set out_file = test_$argv[1]_$TARGET
#
echo ""
echo ""
echo "  Running " $argv[1] " with TARGET = " $TARGET
echo ""
echo ""


set proclist = (60 62 50 45 40 36 32 30 28 20 16 8 4 2)
set proclist = (375 350 300 280 256 200 185 168 150 128 100 76 64 48 32 25 16 14 8 4 )



if( $TARGET == 'Paragon' ) then

  set stat = `showpart -f | grep root`
  @ nfree = $stat[5]

else if( $TARGET == 'KSR' ) then

  set stat = `allocate_cells -A 90 |& grep allocate`
  @ nfree = $stat[7]

else if( $TARGET == 'SunUniproc' ) then

  @ nfree = 1

else

  @ nfree = 4

endif


echo ""
echo nfree = $nfree
echo ""

foreach nproc ( $proclist ) 
   
   @ npr = $nproc

   if( $TARGET == 'Paragon' ) then

     set stat = `showpart -f | grep root`
     @ nfree = $stat[5]

   else if( $TARGET == 'KSR' ) then

     set stat = `allocate_cells -A 90 |& grep allocate`
     @ nfree = $stat[7]

   endif

   if( $npr <= $nfree ) then

      echo prun $nproc $argv[1]' >>& '$out_file.$nproc

      echo "" > $out_file.$nproc
      prun $nproc $argv[1] >>& $out_file.$nproc

   endif
  
end

echo ""
echo -n 
sleep 1
echo -n 
echo ""
echo ""
