#!/bin/csh -f

# Run synthetic test cases

set sources = (test0.java  test1.java  test2.java)
#  test3.java  test4.java \
#               test5.java  test6.java )
#  test7.C  test8.C  test9.C  test10.C test14.C \
#               test16.C test17.C test18.C test19.C                   \
#               testGather.C      testGprintf.C     testMultiShift.C  \
#               testScatterComb.C testStep.C        \
#               testRange.C       testLarge.C       testDimRange.C)

set nprocs  = (4  4  4 )
# 4  4 \
#               4  4 )
#6  6  6  6  6 \
#               6  6  6  6       \
#               6     6     6    \
#               6     6    \
#               6  4  6)

set buildSamples = 0

set adlibHome = @top_srcdir@

set MPI       = @MPI@

if ($MPI == mpich) then
  (hostname; hostname; hostname; hostname; hostname ; hostname ; hostname ; hostname ) > machines
else if ($MPI == sp2) then
  (hostname; hostname; hostname; hostname; hostname ; hostname ; hostname ; hostname ) > host.list
#else
#  echo Not supported yet. ; exit 1
endif

if($buildSamples) then
  cat > diffs.sample <<.
.
else
  cat > diffs <<.
.
endif


foreach source ($sources)
  set executable=${source:r}
  echo env CLASSPATH=$adlibHome/src javac $source
  env CLASSPATH=$adlibHome/src javac $source
  if($buildSamples) then
    echo $adlibHome/src/hpjava/native/tools/prunjava ${nprocs[1]} $executable \| tee ${executable}.out.sample
    $adlibHome/src/hpjava/native/tools/prunjava ${nprocs[1]} $executable | tee ${executable}.out.sample
    shift nprocs
    cat >> diffs.sample <<.
diff ${executable}.out ${executable}.out.sample
.
  else
    echo $adlibHome/src/hpjava/native/tools/prunjava ${nprocs[1]} $executable \| tee ${executable}.out
    $adlibHome/src/hpjava/native/tools/prunjava ${nprocs[1]} $executable | tee ${executable}.out
    shift nprocs
    echo diff ${executable}.out ${executable}.out.sample \| tee -a diffs
    cat >> diffs <<.
diff ${executable}.out ${executable}.out.sample
.
    diff ${executable}.out ${executable}.out.sample | tee -a diffs
  endif
  echo rm -f ${executable}.class
  rm -f ${executable}.class
end

if($buildSamples) then
else
  diff diffs diffs.sample > /dev/null
  if($status) then
    echo Warning: see file \"diffs\" for differences to sample output
  endif
endif

#rm -f $machineFile

