# csh shell script for ATLAS C BLAS testing

set EXE_PATH=$1/interfaces/blas/C/testing/
set RES_PATH=../res

set SUMM=${RES_PATH}/C_BLAS_SUMM_SAN

echo "     ATLAS / CBLAS Testing        "                  >  $SUMM
echo "     ---------------------        "                  >> $SUMM
echo "                                  "                  >> $SUMM
echo "Starting Testing C BLAS interface "                  >> $SUMM
echo "                                  "                  >> $SUMM

echo "Starting Testing C BLAS interface "
#
# short tests
#
foreach prec ( s c d z )

if( -e ${EXE_PATH}/x${prec}cblat1 ) then
 ${EXE_PATH}/x${prec}cblat1                                > ${prec}CBLAT1.SUMM
 grep FAIL ${prec}CBLAT1.SUMM
 cat ${prec}CBLAT1.SUMM                                    >> $SUMM
 rm -f ${prec}CBLAT1.SUMM
 echo "End of short ($prec) L1 tests"
endif

if( -e ${EXE_PATH}/x${prec}cblat2 ) then
 ${EXE_PATH}/x${prec}cblat2 < c_${prec}blat2.short   > ${prec}CBLAT2.SUMM
 grep FAIL ${prec}CBLAT2.SUMM
 cat ${prec}CBLAT2.SUMM                                    >> $SUMM
 rm -f ${prec}CBLAT2.SUMM
 echo "End of short ($prec) L2 tests, input file : c_${prec}blat2.short"
endif

if( -e ${EXE_PATH}/x${prec}cblat3 ) then
 ${EXE_PATH}/x${prec}cblat3 < c_${prec}blat3.short   > ${prec}CBLAT3.SUMM
 grep FAIL ${prec}CBLAT3.SUMM
 cat ${prec}CBLAT3.SUMM                                    >> $SUMM
 rm -f ${prec}CBLAT3.SUMM
 echo "End of short ($prec) L3 tests, input file : c_${prec}blat3.short"
endif

end
#
# long tests
#
foreach prec ( s c d z )
 
if( -e ${EXE_PATH}/x${prec}cblat2 ) then
 ${EXE_PATH}/x${prec}cblat2 < c_${prec}blat2.long    > ${prec}CBLAT2.SUMM
 grep FAIL ${prec}CBLAT2.SUMM
 cat ${prec}CBLAT2.SUMM                                    >> $SUMM
 rm -f ${prec}CBLAT2.SUMM
 echo "End of long  ($prec) L2 tests, input file : c_${prec}blat2.long"
endif

if( -e ${EXE_PATH}/x${prec}cblat3 ) then
 ${EXE_PATH}/x${prec}cblat3 < c_${prec}blat3.long    > ${prec}CBLAT3.SUMM
 grep FAIL ${prec}CBLAT3.SUMM
 cat ${prec}CBLAT3.SUMM                                    >> $SUMM
 rm -f ${prec}CBLAT3.SUMM
 echo "End of long  ($prec) L3 tests, input file : c_${prec}blat3.long"
endif

end
#
# Same thing for the multi-threaded testers
#
# short tests
#
foreach prec ( s c d z )

if( -e ${EXE_PATH}/x${prec}cptblat1 ) then                  
 ${EXE_PATH}/x${prec}cptblat1                              > ${prec}CBLAT1.SUMM
 grep FAIL ${prec}CBLAT1.SUMM                           
 cat ${prec}CBLAT1.SUMM                                    >> $SUMM
 rm -f ${prec}CBLAT1.SUMM
 echo "End of short ($prec) L1 pt tests"
endif

if( -e ${EXE_PATH}/x${prec}cptblat2 ) then
 ${EXE_PATH}/x${prec}cptblat2 < c_${prec}blat2.short > ${prec}CBLAT2.SUMM
 grep FAIL ${prec}CBLAT2.SUMM
 cat ${prec}CBLAT2.SUMM                                    >> $SUMM
 rm -f ${prec}CBLAT2.SUMM
 echo "End of short ($prec) L2 pt tests, input file : c_${prec}blat2.short"
endif

if( -e ${EXE_PATH}/x${prec}cptblat3 ) then
 ${EXE_PATH}/x${prec}cptblat3 < c_${prec}blat3.short > ${prec}CBLAT3.SUMM
 grep FAIL ${prec}CBLAT3.SUMM
 cat ${prec}CBLAT3.SUMM                                    >> $SUMM
 rm -f ${prec}CBLAT3.SUMM
 echo "End of short ($prec) L3 pt tests, input file : c_${prec}blat3.short"
endif

end
#
# long tests
#
foreach prec ( s c d z )
 
if( -e ${EXE_PATH}/x${prec}cptblat2 ) then
 ${EXE_PATH}/x${prec}cptblat2 < c_${prec}blat2.long  > ${prec}CBLAT2.SUMM
 grep FAIL ${prec}CBLAT2.SUMM
 cat ${prec}CBLAT2.SUMM                                    >> $SUMM
 rm -f ${prec}CBLAT2.SUMM
 echo "End of long  ($prec) L2 pt tests, input file : c_${prec}blat2.long"
endif

if( -e ${EXE_PATH}/x${prec}cptblat3 ) then
 ${EXE_PATH}/x${prec}cptblat3 < c_${prec}blat3.long  > ${prec}CBLAT3.SUMM
 grep FAIL ${prec}CBLAT3.SUMM
 cat ${prec}CBLAT3.SUMM                                    >> $SUMM
 rm -f ${prec}CBLAT3.SUMM
 echo "End of long  ($prec) L3 pt tests, input file : c_${prec}blat3.long"
endif

end
