#!/bin/csh -f
# ke_check
# checks to see if the impact event has completed by monitoring KE(t)
# if it has captured rebound, the current pronto job is aborted
#
set chk=1
set wtime = $1
while ( $chk == 1 )
   sleep $wtime
   blot -input ke_blt.inp -dev met pat_end.h >& ke.junk
   rm ke.junk
   ke_rebound.exe | grep "Rebound captured" > /dev/null
   #Monitors the results of the ke_rebound program for the above string
   #and returns 0 in $status if the string is found, 1 otherwise.
   set chk=$status
   echo "ke_check.exe: KE(t) monitored for rebound capture, status = "$chk
end

# ke rebound was captured
echo "Rebound captured.  Terminate PRONTO."
echo "Final process duration:"
ps | grep /usr/local/bin/pronto2d | grep -v grep
killn pronto2d
