2 # (C) Hans Wolfgang Loidl, July 1995
3 ##############################################################################
4 # Time-stamp: <Thu Oct 26 1995 18:40:10 Stardate: [-31]6498.68 hwloidl>
6 # Usage: gr2RTS [options] <sim-file>
9 # -o <file> ... write output to <file>
10 # -h ... help; print this text.
11 # -v ... verbose mode.
13 ##############################################################################
15 # ----------------------------------------------------------------------------
16 # Command line processing and initialization
17 # ----------------------------------------------------------------------------
26 do print_verbose_message ();
29 # ----------------------------------------------------------------------------
31 # ----------------------------------------------------------------------------
33 open(INPUT,"<$input") || die "Couldn't open input file $input";
34 open(OUTPUT,"| sort -n > $output") || die "Couldn't open output file $output";
43 next if /^--/; # Comment lines start with --
44 next if /^\s*$/; # Skip empty lines
46 @fields = split(/[:,]/,$_);
49 foreach $elem (@fields) {
51 $pe = $1, $end = $2 , last foo if $elem =~ /^\s*PE\s+(\d+)\s+\[(\d+)\].*$/;
52 $tn = $1, $has_end = 1 , last foo if $elem =~ /^\s*END\s+(\w+).*$/;
53 # $tn = $1 , last foo if $elem =~ /^\s*TN\s+(\w+).*$/;
54 $sn = $1 , last foo if $elem =~ /^\s*SN\s+(\d+).*$/;
55 $start = $1 , last foo if $elem =~ /^\s*ST\s+(\d+).*$/;
56 $is_global = $1 , last foo if $elem =~ /^\s*EXP\s+(T|F).*$/;
57 $bbs = $1 , last foo if $elem =~ /^\s*BB\s+(\d+).*$/;
58 $ha = $1 , last foo if $elem =~ /^\s*HA\s+(\d+).*$/;
59 $rt = $1 , last foo if $elem =~ /^\s*RT\s+(\d+).*$/;
60 $bt = $1, $bc = $2 , last foo if $elem =~ /^\s*BT\s+(\d+)\s+\((\d+)\).*$/;
61 $ft = $1, $fc = $2 , last foo if $elem =~ /^\s*FT\s+(\d+)\s+\((\d+)\).*$/;
62 $lsp = $1 , last foo if $elem =~ /^\s*LS\s+(\d+).*$/;
63 $gsp = $1 , last foo if $elem =~ /^\s*GS\s+(\d+).*$/;
64 $my = $1 , last foo if $elem =~ /^\s*MY\s+(T|F).*$/;
68 next unless $has_end == 1;
70 $total_rt = $end - $start;
71 $tot_total_rt += $total_rt;
76 $max_rt = $rt if $rt > $max_rt;
82 # Hack to fake a filter
83 if ( $output eq $filter_output ) {
90 # ---------------------------------------------------------------------------
94 open(ME,$0) || die "Can't open myself ($0)";
103 # system "cat $0 | awk 'BEGIN { n = 0; } \
110 $input = $#ARGV == -1 ? "-" : $ARGV[0] ;
113 #print "Usage: gran-extr [options] <sim-file>\n";
114 #print "Use -h option to get details\n";
119 $filter_output = $ENV{'TMPDIR'} . "./,gr2RTS-out";
123 if ( $input eq "-" ) {
124 $output = $filter_output;
126 $output = $input; # "RTS";
127 $output =~ s/\.gr$/.rts/g;
132 # ----------------------------------------------------------------------------
134 sub print_verbose_message {
135 print "Input file: $input\t Output file: $output\n";
138 # ----------------------------------------------------------------------------