#!/bin/csh

# Last modified: January 31st, 1996

set grep_tmp_file = "$cwd/.grep"
set simlogfile = $1

#set datfile = "./dat.file"

#------------------------------------------------------------------------
# extract the datafiles
#------------------------------------------------------------------------

\rm $grep_tmp_file 

  
  foreach findkey ( ` cut -d" " -f1 $simlogfile | sort | uniq`)
     if ( $findkey != "#") then
	echo "DAT $findkey"
	cat $simlogfile
	cat $simlogfile > /tmp/j.$findkey
        grep "^"$findkey" " $simlogfile >! $grep_tmp_file
        cut -d" " -f2,3 $grep_tmp_file > $findkey".dat"
	mv ./.grep ./grep.$findkey

#cut -d" " -f2,3 $grep_tmp_file > $datfile
#cat $findkey".dat" | awk '{printf" %d %d\n", $1/1000, $2}' >!$datfile

     endif
  end
echo "Removing grep file"
#\rm $grep_tmp_file











