#!/bin/csh
#N.R. BADNELL

#Intel ifort (module) requires `source run_test'

#SIMPLE SCRIPT TO RUN AS TEST SUITE AND DIFF WITH ANY PREVIOUS RUN
# CASE 1-5 NON-RYD; 6-8 DR/RR; 9-10 DW; 11-17 MIXC; 18 CADW, 19 SRLX, 20 CA-DR

set ASLM = /home/badnell/autos/xlx/aslm30.xi      #Executable. In user path if not absolute.
set ncase_max = 21                            #Max no. test cases
set ncase_start = 1                           #First test case >=1 
set ncase_end = 21                            #Last test case
set RUN = clean                                 #run diff clean
set CLEAN = olgo                                #no, dd, ddo, olg, olgo or all


if ( $ncase_end > $ncase_max ) stop "Too many test cases requested"

set case = $ncase_start

echo " "
while ( $case <= $ncase_end )
  cd test_$case
  if ( $RUN == "run" ) then
    echo "Starting test case: $case"
    if ( -e olg ) mv olg olgo
    if ( -e dd ) mv dd ddo
    set das = das_$case
#    set errlog = ../errlog_$case
#    if ( -e $errlog ) rm $errlog
    $ASLM <$das           # >$errlog
    if ( -e olgo ) then
      echo "Starting diff for test case: $case"
      diff olg olgo >dd
#      if ( -e ddo ) diff dd ddo | more
    endif
  else if ( $RUN == "diff" ) then
      echo "Starting diff for test case: $case"
      diff olg olgo | m
#      cat ddo | m
  else if ( $RUN == "clean" ) then
    echo "Cleaning $CLEAN for test case: $case"
    if ( $CLEAN == "dd" ) then
      rm dd
    else if ( $CLEAN == "ddo" ) then
      rm ddo
    else if ( $CLEAN == "das" ) then
      rm das
    else if ( $CLEAN == "olg" ) then
      rm olg
    else if ( $CLEAN == "olgo" ) then
      rm olgo
    else if ( $CLEAN == "all" ) then
      rm  err* rado* dd* o* a* t* C* I* L* T* R* S* O*
    else
      echo "Unrecognized Clean operation: $CLEAN "
    endif
  endif
  cd ..
  @ case = $case + 1
end
echo " "
if ( $CLEAN == "no" ) then
  echo "Test suite completed (:"
else
  echo "Cleared out: $CLEAN files "
endif
echo " "
#ls -l errlog*
