#!/bin/csh -f

# Run synthetic test cases

set sources = (test0  test1  test2  test3  test4  test5  \
               test6  test7  test8  test9  test10 test11 \
               test12 test13 test14 test15 test16 test17 \
               test18 test19 test20 test21)

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

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
endif


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


foreach source ($sources)
  set executable=$source
  echo $adlibHome/src/shpfFortran/adaptf -o $executable hpfrtf.f ${source}-OUT.f
  $adlibHome/src/shpfFortran/adaptf -o $executable hpfrtf.f ${source}-OUT.f
  if($buildSamples) then
    echo $adlibHome/src/script/prun ${nprocs[1]} $executable \| tee ${executable}.out.sample
    $adlibHome/src/script/prun ${nprocs[1]} $executable | tee ${executable}.out.sample
    shift nprocs
    cat >> diffs.sample <<.
diff ${executable}.out ${executable}.out.sample
.
  else
    echo $adlibHome/src/script/prun ${nprocs[1]} $executable \| tee ${executable}.out
    $adlibHome/src/script/prun ${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 ${executable}.o
  rm -f $executable ${executable}.o
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

