#!/bin/csh -f
#
# gapstimes - extract the times from elogs created with the GAPS or
#   RGAPS predictors. These are times needed for various parts of the
#   predictor.
#
# usage: gapstimes logfile...
#
# (logfile may a be compressed elog)
# creates files with the same base filename as logfile, with suffixes:
#    notify  random  contin  wfifo  watch  toseq
# The output files have two columns: elapsed time and event time (in msec)

set P=`procdir`

onintr cleanup

foreach logfile ($*)
    elogdump -stmp =22 =33 =34 =35 =36 =37 $logfile | Awk -f $P/gapstimes.awk
    if ($logfile:e == Z) then
        set log=$logfile:r
        set log=$log:r
    else
        set log=$logfile:r
    endif
    mv notify $log.notify
    mv random $log.random
    mv contin $log.contin
    mv wfifo  $log.wfifo
    mv watch  $log.watch
    mv toseq  $log.toseq
end

exit 0

cleanup:
rm -f notify  random  contin  wfifo  watch  toseq
exit 1
