source: CIVL/mods/dev.civl.com/scripts/scale/parseScale.pl@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5664 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100755
File size: 2.6 KB
RevLine 
[948e320]1#!/usr/bin/perl
2use File::Path qw(make_path);
3
[c55ef7f]4$input_file = $ARGV[0];
5$out_folder = $ARGV[1];
6open(INPUT, "<", $input_file) || die "Could not open $input_file";
7my $outFH;
[948e320]8my $currentName="";
9my $last=3;
10my $id=0;
[2138309]11my $tmpDAT="scale.dat.tmp";
12my $dat="scale.dat";
[c55ef7f]13
14#print "$out_folder\n";
15
[2138309]16open(my $allFH, '>', $tmpDAT) or die "Can't write to file: $!";
[948e320]17
18print $allFH "Name\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15";
19
[c55ef7f]20unless (-d $out_folder) {
21 mkdir $out_folder;
22}
23
24while ($line=<INPUT>) {
[948e320]25 my($name,$size,$time);
26
27 chomp($line);
28 next unless ($line =~/^>>>>>>>>\s/);
29
30 #print $line . "\n";
31 ($name) = ($line =~/^>>>>>>>>\s(.*)\s<<<<<<<<$/);
32
33 die "no name" unless defined($name);
34 $name =~ tr/ //ds;
35 if($currentName ne $name){
36 $currentName=$name;
[c55ef7f]37 if(defined($outFH)){
38 close $outFH;
39 }
40 open($outFH, '>', "$out_folder/$name.dat") or die "Can't write to file: $!";
[948e320]41 $id++;
42 if(($id != 1) and ($last <= 15)){
43 for(my $j = $last; $j <= 15; $j++){
44 print $allFH "\t-";
45 }
46 }
47 #print "name = $name\n";
48 print $allFH "\n$name";
49 $last=3;
50 }
51
[c55ef7f]52 while ($line=<INPUT>) {
[948e320]53 chomp($line);
54 if ($line =~ /time\s\(s\).*:/) {
55 #print $line . "\n";
56 ($time)=($line =~ /time.*:\s*(\S+)\s*$/);
57 last;
58 }
59 }
60
[c55ef7f]61 while ($line=<INPUT>) {
[948e320]62 chomp($line);
63 if ($line =~ /max\sprocess\scount/) {
64 #print $line . "\n";
65 ($size)=($line =~ /max\sprocess\scount.*:\s*(\d+)\s*$/);
66 last;
67 }
68 }
69
70 die "no size" unless defined($size);
71 die "no time" unless defined($time);
72
[04f9ccd]73 # $time=round($time); don't round the time
[948e320]74 $time=1 if $time==0;
75
76 next unless ($size >= $last);
77
78 if($size>$last){
79 #print "size=$size but last=$last\n";
80 for (my $i=$last; $i < $size; $i++) {
81 print $allFH "\t-";
82 }
83 }
84
85 print $allFH "\t$time";
[c55ef7f]86 print $outFH "$size\t$time\n";
[948e320]87 $last=$size+1;
88
89 # for debugging:
90
91 #print "size = $size\t";
92 #print "time = $time\n";
93 #print " $type & $name$cite & $result & $loc & $states & $steps & $time & $mem & $valid & $prove & $scale \\\\","\n";
94}
95if(($id != 1) and ($last <= 15)){
96 for(my $j = $last; $j <= 15; $j++){
97 print $allFH "\t-";
98 }
99}
100close $allFH;
[2138309]101open(my $newFH, '>', $dat) or die "Can't write to file: $!";
102open(DATA, '<', $tmpDAT) or die "Can't open file: $!";
[948e320]103my $count=0;
104my @lines;
105my $width;
106
107
108while ($line=<DATA>) {
109 chomp($line);
110 @new=split(/\t/, $line);
111 $width=@new;
112 push @lines, [ @new ]; # split = split( ' ', $_ )
113 $count++;
114}
115
116for(my $k=0; $k<$width;$k++){
117 foreach my $row (@lines) {
118 print $newFH $row->[$k] . "\t";
119 }
120 print $newFH "\n";
121}
[2138309]122close $newFH;
123close DATA;
124unlink $tmpDAT;
[948e320]125
126
127
Note: See TracBrowser for help on using the repository browser.