File Coverage

blib/lib/Simulation/Automate/PostProcLib.pm
Criterion Covered Total %
statement 179 353 50.7
branch 25 86 29.0
condition 37 128 28.9
subroutine 16 21 76.1
pod 0 8 0.0
total 257 596 43.1


line stmt bran cond sub pod time code
1             package Simulation::Automate::PostProcLib;
2              
3 1     1   5 use vars qw( $VERSION );
  1         1  
  1         99  
4             $VERSION = "1.0.1";
5              
6             ################################################################################
7             # #
8             # Copyright (C) 2000,2002 Wim Vanderbauwhede. All rights reserved. #
9             # This program is free software; you can redistribute it and/or modify it #
10             # under the same terms as Perl itself. #
11             # #
12             ################################################################################
13              
14             #=headers
15              
16             #Module to support synsim script for simulation automation.
17             #This module contains a set of utility functions for use in the
18             #PostProcessors.pm module.
19             #This module is generic.
20              
21             #$Id$
22              
23             #=cut
24              
25 1     1   5 use warnings;
  1         2  
  1         41  
26 1     1   5 use strict;
  1         7  
  1         25  
27 1     1   5 use Carp;
  1         2  
  1         58  
28 1     1   5 use Exporter;
  1         1  
  1         32  
29 1     1   5 use lib '.','..';
  1         2  
  1         5  
30              
31 1     1   148 use Simulation::Automate::Analysis;
  1         2  
  1         98  
32 1     1   388 use Simulation::Automate::Dictionary;
  1         3  
  1         200  
33              
34             @Simulation::Automate::PostProcLib::ISA = qw(Exporter);
35             @Simulation::Automate::PostProcLib::EXPORT = qw(
36             &prepare_plot
37             &prepare
38             &gnuplot
39             &gnuplot_combined
40             %simdata
41             $last
42             $verylast
43             $every_sweep_val
44             $current_set_str
45             $current_set_except_setvar_str
46             $results_file_name
47             @all_results_file_names
48             %current_set_vals
49             @results
50             &import_symbols
51             $verbose
52             );
53              
54             ##################################################################################
55              
56             sub AUTOLOAD {
57 0     0   0 my $subref=$Simulation::Automate::PostProcLib::AUTOLOAD;
58 0         0 $subref=~s/.*:://;
59 0         0 print STDERR "
60             There is no script for this analysis in the PostProcLib.pm module.
61             This might not be what you intended.
62             You can add your own subroutine $subref to the PostProcLib.pm module.
63             ";
64              
65             }
66              
67             #------------------------------------------------------------------------------
68             sub prepare {
69             #print "Entering prepare()\n";
70 1     1   4 use Cwd;
  1         10  
  1         2551  
71              
72             #*&Simulation::Automate::PostProcessors::$subref(\$dataset,\$i,\$dataref1,\$flagsref,\$returnvalue,\$preprocref);
73             #&prepare_plot(@args);
74             # print "PREPARE\n";
75 2     2 0 8 my $datafile_name=shift;
76 2         6 my $count=shift;
77 2         4 my $dataref=shift;
78 2         7 my $flagsref=shift;
79 2         4 my $verylastref=shift;
80 2         8 my @extra_args=@_;
81              
82 2 50 33     93 my $preprocref=((@extra_args>=1) && $extra_args[0])?$extra_args[0]:0;
83            
84 2 50 33     10 my $every_sweep_val=((@extra_args==2) && ($extra_args[1]==2))?1:0;
85 2         6 my $verylast=1;
86 2         7 my @results=();
87              
88 2 100 66     29 if($verylastref && $verylastref!=1){
89 1         1 @results=@{$verylastref};
  1         5  
90 1         3 $verylast=0;
91             }
92              
93 2         3 (my $batch, $Simulation::Automate::PostProcLib::interactive,my $nosims,$Simulation::Automate::PostProcLib::plot,$Simulation::Automate::PostProcLib::verbose)=@{$flagsref};
  2         12  
94 2         5 my $copy_results=1;
95 2         3 (my $nsims, my $simdataref,my $current_set_valsref,my $lastref)=@{$dataref};
  2         8  
96            
97 2         6 my %synsimdata=%{$simdataref};
  2         38  
98 2         4 my %current_set_vals=%{$current_set_valsref};
  2         6  
99             #to be exported: current_set_str
100 2         7 my $current_set_str='';
101 2         13 foreach my $key (sort keys %current_set_vals) {
102 0         0 $current_set_str.="${key}-".$current_set_vals{$key}.'-';
103             }
104 2         5 $current_set_str=~s/-$//;
105              
106             #The idea is to use XVAR or SWEEPVAR for any X-value sweep. As there is no longer a requirement to have semicol-lists for grouping, if XVAR is not semicol, make it semicol.
107             #If there was a semicol-list, make it comma.
108             #If there were 2 or more semicol lists, add them to %grouped
109             #CONDVAR must only be defined if a CONDITION is present. In this case, CONDVAR is swept, XVAR is stepped, so XVAR should be a comma-separated list. If not, make it one. Again, if semicol grouping is used, convert to new grouping
110             #So, internally:
111             #(COND or CONDITION) {
112             #XVAR=SETVAR
113             #SWEEPVAR=CONDVAR
114             #} else {
115             #XVAR=SWEEPVAR
116             #}
117              
118              
119 2   50     21 my $setvar=$synsimdata{SETVAR}||'';
120 2 50 33     20 if(exists $synsimdata{COND} or exists $synsimdata{CONDITION}) {
121             # my $condvar= $synsimdata{CONDVAR}||$synsimdata{SWEEPVAR}||'none';
122             #WV 010704: only CONDVAR, not SWEEPVAR
123 0   0     0 my $condvar= $synsimdata{CONDVAR}||'none';
124             # $synsimdata{CONDVAR}=$synsimdata{SWEEPVAR}=$condvar;
125 0   0     0 my $xvar= $synsimdata{XVAR}|| $synsimdata{SETVAR}||$synsimdata{SWEEPVAR}||'';
126 0         0 $synsimdata{XVAR}=$synsimdata{SETVAR}=$synsimdata{SWEEPVAR}=$xvar;
127 0         0 $setvar=$xvar;
128             } else {
129 2   50     27 my $xvar= $synsimdata{XVAR}|| $synsimdata{SWEEPVAR}||'';
130 2         10 $synsimdata{XVAR}=$synsimdata{SWEEPVAR}=$xvar;
131             }
132              
133 2   50     23 my $cond=$synsimdata{COND}||$synsimdata{CONDITION}||'<1';
134 2         11 $synsimdata{COND}=$synsimdata{CONDITION}=$cond;
135              
136 2         9 my $setvarval=$synsimdata{$setvar}->[0]; # if SETVAR is defined, this would be the first value in the list for SETVAR. This is to used check if the last element in the SETVAR value list has been reached
137 2         4 my $current_set_except_setvar_str=$current_set_str;
138 2 50       10 my $setvar_str=($setvar ne '')?$setvar.'-'.$setvarval:'';
139 2         32 $current_set_except_setvar_str=~s/$setvar_str\-*//;
140              
141 2         4 my %last=%{$lastref}; # the last value in the list for every variable
  2         6  
142              
143 2   0     13 my $last=($setvar && (exists $last{$setvar}) && ($setvar ne '') && $setvarval && ($setvarval==$last{$setvar})); # SETVAR is defined and the element in the value list has been reached.
144              
145 2   50     33 $synsimdata{OUTPUT_FILTER_PATTERN}||= '.*';
146              
147 2   50     31 my $plotext=$synsimdata{PLOTTEMPL}||$synsimdata{PLOTTEMPLATE}||$synsimdata{PLOT_TEMPLATE}||'.gnuplot';
148 2         8 $synsimdata{PLOTTEMPL}=$synsimdata{PLOTTEMPLATE}=$synsimdata{PLOT_TEMPLATE}=$plotext;
149              
150 2   50     13 $synsimdata{PLOTCOMMAND}||='/usr/bin/ggv';
151 2 50 33     169 if((not -e '/usr/bin/ggv') and ( -e '/usr/X11R6/bin/gv')) {
152 0   0     0 $synsimdata{PLOTCOMMAND}||='/usr/X11R6/bin/gv';
153             }
154 2   50     35 my $normvar=$synsimdata{NORMVAR}||1;
155 2 50 33     16 (!$synsimdata{$normvar} || !@{$synsimdata{$normvar}})&&(${$synsimdata{$normvar}}[0]=1);
  2         10  
  0         0  
156 2 50       3 my $current_norm_val=(@{$synsimdata{$normvar}}>1)?$current_set_vals{$normvar}:${$synsimdata{$normvar}}[0];
  2         7  
  2         5  
157 2         8 $synsimdata{NORMVAR}=$normvar;
158              
159 2 50 50     20 (exists $synsimdata{XVAR}) && ($synsimdata{XCOL}||=1);
160 2   50     21 my $datacol=$synsimdata{DATACOL}||$synsimdata{YCOL}||1;
161 2         5 $synsimdata{DATACOL}=$synsimdata{YCOL}=$datacol;
162              
163 2   33     22 my $simtempl=$synsimdata{SIMULATION}||$synsimdata{SIMNAME}||$synsimdata{SIMTYPE}||$synsimdata{TEMPLATE}||$synsimdata{SIMTEMPL};
164 2         16 $synsimdata{SIMULATION}=$synsimdata{SIMNAME}=$synsimdata{SIMTYPE}=$synsimdata{TEMPLATE}=$synsimdata{SIMTEMPL}=$simtempl;
165              
166 2   50     36 my $anatempl=$synsimdata{ANALYSIS_TEMPLATE}||$synsimdata{ANALYSIS}||$synsimdata{ANATEMPL}||'None';
167 2         10 $synsimdata{ANALYSIS_TEMPLATE}=$synsimdata{ANALYSIS}=$synsimdata{ANATEMPL}=$anatempl;
168              
169 2         9 my $results_file_name=$simtempl.'-'.$anatempl.'-'.$current_set_str.'.res';
170              
171             #NEW 24/11/2003 Copy "old" results files to new names
172 2 100       5 if(not $verylast){
173 1         8108 system("cp ${simtempl}_C${count}.res $results_file_name");
174             }
175 2   50     312 my $devtype=$synsimdata{DEVTYPE}|| $synsimdata{DEVICE}||'';
176 2         23 $synsimdata{DEVTYPE}=$synsimdata{DEVICE}=$devtype;
177 2   33     19 $synsimdata{TITLE}||="$devtype $simtempl simulation";
178 2         13 my $simtitle = my $title = $synsimdata{TITLE};
179 2         59 foreach my $key (keys %synsimdata) {
180 56 50       129 ($key!~/^_/) && next;
181 0 0       0 ($simtitle=~/$key/) && do {
182 0         0 my $val=$synsimdata{$key};
183 0   0     0 my $nicekey=$make_nice{$key}{title}||&make_nice($key);
184 0   0     0 my $niceval=$make_nice{$key}{${$val}[0]}||join(',',@{$val});
185 0         0 $simtitle=~s/$key/$nicekey:\ $niceval/;
186             };
187 0         0 $title=$simtitle;
188             }
189              
190             # For Gnuplot
191             #XSTART, XSTOP, YSTART, YSTOP, XTICS, YTICS, YLABEL, XLABEL, LOGSCALE, STYLE,
192 2   50     29 $synsimdata{XSTART}||="";
193 2   50     16 $synsimdata{XSTOP}||="";
194 2   50     14 $synsimdata{YSTART}||="";
195 2   50     32 $synsimdata{YSTOP}||="";
196 2   50     26 $synsimdata{XTICS}||="";
197 2   50     16 $synsimdata{YTICS}||="";
198 2   33     14 $synsimdata{YLABEL}||="$title";
199 2   33     29 $synsimdata{XLABEL}||=&make_nice($synsimdata{XVAR});#"$title";
200 2 50       11 $synsimdata{LOGSCALE}=($synsimdata{LOGSCALE})?"set nologscale xy\nset logscale ".lc($synsimdata{LOGSCALE}):'set nologscale xy';
201 2   50     19 my $plotstyle=$synsimdata{PLOTSTYLE}||$synsimdata{STYLE}||'linespoints';
202 2         10 $synsimdata{PLOTSTYLE}=$synsimdata{STYLE}=$plotstyle;
203 2         10 $synsimdata{DATAFILENAME}=$datafile_name;
204 2         2 (my $legendtitle, my $legend)=@{&create_legend($current_set_str,\%make_nice)};
  2         23  
205 2         260 my @all_results_file_names=glob($simtempl.'-'.$anatempl.'*.res');
206              
207 2         8 @Simulation::Automate::PostProcLib::all_results_file_names=@all_results_file_names;
208 2         23 @Simulation::Automate::PostProcLib::results=@results;
209 2         150 %Simulation::Automate::PostProcLib::simdata=%synsimdata;
210 2         20 %Simulation::Automate::PostProcLib::current_set_vals=%current_set_vals;
211 2         4 $Simulation::Automate::PostProcLib::results_file_name=$results_file_name;
212 2         4 $Simulation::Automate::PostProcLib::current_set_str=$current_set_str;
213 2         4 $Simulation::Automate::PostProcLib::current_set_except_setvar_str=$current_set_except_setvar_str;
214 2         12 $Simulation::Automate::PostProcLib::verylast=$verylast;
215 2         8 $Simulation::Automate::PostProcLib::last=$last;
216 2         7 $Simulation::Automate::PostProcLib::simtempl=$simtempl;
217 2         4 $Simulation::Automate::PostProcLib::anatempl=$anatempl;
218 2         7 $Simulation::Automate::PostProcLib::plotext=$plotext;
219             # if ($preprocref!=0) {
220             # eval('use Simulation::Automate::PostProcessors;');
221             # &{$preprocref}();
222             # }
223             #%Simulation::Automate::PostProcessors::simdata=%synsimdata;
224             #@Simulation::Automate::PostProcessors::results=@results;
225              
226 2         11 &import_symbols();
227 2         17 my $postprocpath= $INC{"Simulation/Automate/PostProcLib.pm"};
228 2         22 $postprocpath=~s/Lib/essors/;
229 2 50       12 ($postprocpath=~/^\./)&&($postprocpath='../'.$postprocpath);
230 2         1189 require $postprocpath;
231              
232 2         9789 my $workingdir=cwd();
233 2 50       106 if( -d "../PLUGINS") {
234 2         237 my @preprocs=glob("../PLUGINS/*.pm");
235 2         13 foreach my $plugin (@preprocs) {
236 2 50 33     191 if($synsimdata{PREPROCESSOR} && ($plugin=~/$synsimdata{PREPROCESSOR}/) or $synsimdata{POSTPROCESSOR} && ($plugin=~/$synsimdata{POSTPROCESSOR}/) or ($plugin=~/$synsimdata{ANATEMPL}\.pm/)) {
      33        
      33        
      33        
237 0         0 require $plugin;
238             }
239             }
240             }
241 2 50       31 if(exists $synsimdata{PREPROCESSOR}) {
242             #print "Calling preprocessor $synsimdata{PREPROCESSOR} from prepare\n";
243             #@_= @Simulation::Automate::PostProcLib::results;
244 0         0 eval('&Simulation::Automate::PostProcessors::'.$synsimdata{PREPROCESSOR});#.'(@_)');
245             # @Simulation::Automate::PostProcLib::results=@_;
246             }
247              
248             #print "Calling Simulation::Automate::PostProcessors::$synsimdata{ANATEMPL} from prepare\n";
249 2 50       16 if( $synsimdata{ANATEMPL} ne 'None' ) {
250 0         0 eval('&Simulation::Automate::PostProcessors::'.$synsimdata{ANATEMPL});
251             }
252              
253             #print "Leaving prepare()\n";
254 2         326 return [@_];
255             } # END of prepare()
256              
257             #------------------------------------------------------------------------------
258             sub gnuplot {
259 0     0 0 0 my $commands=shift;
260 0   0     0 my $persist=shift||'';
261 0 0       0 if($Simulation::Automate::PostProcLib::plot) {
262 0         0 open GNUPLOT,"| gnuplot $persist";
263 0         0 print GNUPLOT $commands;
264 0         0 close GNUPLOT;
265             }
266             } # END of gnuplot()
267             #------------------------------------------------------------------------------
268             sub gnuplot_combined {
269             #my $firstplotline=shift||'';
270             #my $plotlinetempl=shift||'';
271             #my $col=$Simulation::Automate::PostProcLib::datacol;
272             #my $ycol=$Simulation::Automate::PostProcLib::ycol;
273             #if($firstplotline=~/^\d+$/) {
274             #$ycol=$firstplotline;
275             #$firstplotline='';
276             #}
277 0     0 0 0 my $firstplotline='';
278 0         0 my $plotlinetempl='';
279             #my $synsimdataref=shift;
280             #my %synsimdata=%Simulation::Automate::PostProcLib::synsimdata;
281 0         0 my %synsimdata=%Simulation::Automate::PostProcLib::simdata;
282 0         0 $synsimdata{YCOL}= $Simulation::Automate::PostProcLib::ycol;
283              
284             ### On the very last run, collect the results
285             #1. get a list of all plot files
286 0         0 my @plotfiles=glob("${Simulation::Automate::PostProcLib::simtempl}-${Simulation::Automate::PostProcLib::anatempl}-*.res");
287              
288             #2. create a gnuplot script
289             #this should be a full script, but with room for additional feature
290 0         0 my @lines=();
291 0         0 my $legendtitle='';
292 0         0 my $lt=0;
293 0         0 my $range='';
294 0         0 foreach my $filename (@plotfiles) {
295 0         0 $lt++;
296 0         0 my $title=$filename;
297              
298 0         0 $title=~s/${Simulation::Automate::PostProcLib::simtempl}-${Simulation::Automate::PostProcLib::anatempl}-//;
299 0         0 $title=~s/\.res//;
300 0         0 $title=~s/\-\-/\-\_MINUS_/g;
301             #(my $legendkey,my $legendvalue)=split('-',$title);
302 0         0 my %legend=split('-',$title);
303 0         0 my @legendkeys=();
304 0         0 my @legendvalues=();
305 0         0 foreach my $varname (sort keys %legend){
306 0         0 push @legendkeys,$varname;
307 0         0 push @legendvalues,$legend{$varname};
308             }
309 0         0 my $legendkey='';
310 0         0 $legendkey.=join(', ',@legendkeys);
311 0         0 my $legendvalue='';
312 0         0 $legendvalue.=join(', ', @legendvalues);
313              
314             #$legendkey||=' ';
315 0 0       0 ($legendkey eq '') && ( $legendkey=' ');
316 0 0       0 ($legendvalue eq '') && ($legendvalue=' ');
317             #($legendvalue=~/^\d+$/)&&($legendvalue!=0) && ($legendvalue||=' ');
318 0 0       0 ($legendkey=~/_MINUS_/)&&($legendkey=~s/_MINUS_/\-/g);
319 0 0       0 ($legendvalue=~/_MINUS_/)&&($legendvalue=~s/_MINUS_/\-/g);
320              
321 0         0 my %title= ($legendkey=>$legendvalue);
322              
323 0         0 my $legend='';
324 0         0 $legendtitle='';
325 0         0 foreach my $key (sort keys %title) {
326 0         0 $legendtitle.=',';
327 0   0     0 $legendtitle.=$make_nice{$key}{title}||&make_nice($key);
328 0   0     0 $legend.=$make_nice{$key}{$title{$key}}||&make_nice($title{$key});
329 0         0 $legend.=',';
330             }
331 0         0 $legend=~s/,$//;
332 0         0 $legendtitle=~s/^,//;
333 0         0 $synsimdata{LEGEND}=$legend;
334 0         0 $synsimdata{LEGENDTITLE}=$legendtitle;
335              
336 0 0 0     0 if(($firstplotline eq '') and ($plotlinetempl eq '')){
337 0         0 ($firstplotline, $plotlinetempl,$range)=@{&parse_gnuplot_templ(\%synsimdata)};
  0         0  
338             }
339              
340 0         0 my $plotline;
341             #print "PLOTLINE:", '$plotline='.$plotlinetempl;
342 0         0 eval('$plotline='.$plotlinetempl);
343             #carp "PLOTLINE:$plotline";
344 0         0 push @lines, $plotline
345             }
346 0         0 $firstplotline=~s/set\s+key\s+title.*/set key title "$legendtitle"/;
347 0         0 my $plot="\nplot $range ";
348 0 0       0 if($firstplotline=~/$plot/ms){$plot=''};
  0         0  
349 0         0 my $line=$firstplotline.$plot.join(",\\\n",@lines);
350              
351 0 0       0 if($Simulation::Automate::PostProcLib::plot) {
352 0         0 open GNUPLOT,"| gnuplot";
353 0         0 print GNUPLOT $line;
354 0         0 close GNUPLOT;
355             }
356 0         0 open GNUPLOT,">${Simulation::Automate::PostProcLib::simtempl}-${Simulation::Automate::PostProcLib::anatempl}.gnuplot";
357 0         0 print GNUPLOT $line;
358 0         0 close GNUPLOT;
359              
360 0 0       0 if($Simulation::Automate::PostProcLib::interactive) {
361 0         0 system("${Simulation::Automate::PostProcLib::plotcommand} ${Simulation::Automate::PostProcLib::simtempl}-${Simulation::Automate::PostProcLib::anatempl}.ps &");
362             }
363             } # END of gnuplot_combined()
364             #------------------------------------------------------------------------------
365             sub parse_gnuplot_templ {
366 0     0 0 0 my $synsimdataref=shift;
367 0         0 my %synsimdata=%{$synsimdataref};
  0         0  
368              
369 1     1   8 no strict;
  1         3  
  1         942  
370              
371 0         0 foreach my $key (keys %synsimdata){
372 0 0       0 ($key=~/^\d*$/)&&next;
373 0         0 my $lcname=lc($key);
374 0 0       0 if($key=~/^_/) {
375 0         0 @{$lcname}=@{$synsimdata{$key}};
  0         0  
  0         0  
376             } else {
377 0         0 $$lcname=$synsimdata{$key};
378             }
379             }
380 0         0 my $normvarval=$synsimdata{$normvar}[0];
381              
382             #plot templates can be either
383             #SIMPTYPE.PLOTTEMPL, stored under TEMPLATES or TEMPLATES/SYMTYPE
384             #$dataset.PLOTTEMPL, stored next to $dataset.data
385 0         0 my $plot_templ_file="../$datafilename$plottempl";
386             #print "../$datafilename$plottempl\n";
387 0 0       0 if( not -e $plot_templ_file) {
388 0         0 $plot_templ_file="../TEMPLATES/$simtempl$plottempl";
389 0 0       0 if( not -e $plot_templ_file) {
390 0         0 $plot_templ_file='';
391             }
392             }
393             #print " plot_templ_file $plot_templ_file\n";
394              
395 0         0 my $xcolentry='(\$_XCOL*1):';
396              
397 0 0 0     0 if(not exists $synsimdata{XCOL} and not exists $synsimdata{XVAR} and not exists $synsimdata{SWEEPVAR} and ($xcol && ($xcol!~/\d/))){
      0        
      0        
398 0         0 $xcolentry='';
399             }
400 0         0 my $firstplotline=<<"ENDH";
401             set terminal postscript landscape enhanced color solid "Helvetica" 14
402             set output "${simtempl}-${anatempl}.ps"
403              
404             $logscale
405              
406             #set xtics $xtics
407             #set mxtics 2
408             set grid xtics ytics mxtics mytics
409              
410             set key right top box
411             set key title "$legendtitle"
412              
413             set title "$title" "Helvetica,18"
414             set xlabel "$xlabel" "Helvetica,16"
415             set ylabel "$ylabel" "Helvetica,16"
416              
417             ENDH
418              
419 0         0 my $plotlinetempl=q["\'$filename\' using _XCOLENTRY(\$_YCOL/_NORMVAR) title \"$legend\" with _PLOTSTYLE"];
420 0         0 $plotlinetempl=~s/_XCOLENTRY/$xcolentry/;
421 0         0 $plotlinetempl=~s/_NORMVAR/$normvarval/;
422 0         0 $plotlinetempl=~s/_YCOL/$ycol/;
423 0         0 $plotlinetempl=~s/_XCOL/$xcol/;
424 0         0 $plotlinetempl=~s/_PLOTSTYLE/$plotstyle/;
425 0         0 my $range='';
426 0 0       0 if($plot_templ_file) {
427 0         0 $firstplotline='';
428 0         0 open(PLOTTEMPL,"<$plot_templ_file");
429              
430 0         0 while () {
431 0 0 0     0 /FILENAME/ && ($plotlinetempl=$_) && last;
432 0         0 s/OUTPUT/${simtempl}-${anatempl}/;
433 0         0 s/PLOTTITLE/$title/;
434 0         0 s/LEGENDTITLE/$legendtitle/;
435 0         0 s/XLABEL/$xlabel/;
436 0         0 s/YLABEL/$ylabel/;
437 0         0 s/XTICS/$xtics/;
438 0         0 s/YTICS/$ytics/;
439 0         0 s/LOGSCALE/$logscale/;
440 0         0 $firstplotline.=$_;
441             }
442 0         0 chomp($plotlinetempl);
443 0         0 $plotlinetempl=~s/\$/\\\$/g;
444 0         0 $plotlinetempl=~s/RESULTSFILENAME/\$filename/g;
445 0         0 $plotlinetempl=~s/FILENAME/\$filename/g;
446 0         0 $plotlinetempl=~s/XCOL/$xcol/;
447 0         0 $plotlinetempl=~s/YCOL/$ycol/;
448 0         0 $plotlinetempl=~s/NORMVAR/$normvarval/;
449 0         0 $plotlinetempl=~s/LEGENDENTRY/\$legend/;
450 0         0 $plotlinetempl=~s/LEGEND/\$legend/;
451 0         0 $plotlinetempl=~s/PLOTSTYLE/$plotstyle/;
452 0         0 $plotlinetempl=~s/^plot\s+//;
453 0         0 $plotlinetempl=~s/\'/\\\'/g;
454 0         0 $plotlinetempl=~s/\"/\\\"/g;
455 0         0 $plotlinetempl=~s/XSTART/$xstart/;
456 0         0 $plotlinetempl=~s/XSTOP/$xstop/;
457 0         0 $plotlinetempl=~s/YSTART/$ystart/;
458 0         0 $plotlinetempl=~s/YSTOP/$ystop/;
459              
460              
461 0 0       0 ( $plotlinetempl=~s/(\[[\d\.eE\-\+]*\:[\d\.eE\-\+]*\]\s+)//) && do {
462 0         0 $range=$1;
463             };
464 0         0 $plotlinetempl='"'.$plotlinetempl.'"';
465             }
466 0   0     0 $range||='';
467              
468 0         0 return [$firstplotline,$plotlinetempl,$range];
469              
470             } # END of parse_gnuplot_templ()
471             #------------------------------------------------------------------------------
472             sub copy_results {
473 1     1   6 use Cwd;
  1         2  
  1         491  
474 0     0 0 0 my $workingdir=cwd();
475 0 0       0 if(not(-e "$workingdir/../../Results")) {
476 0         0 mkdir "$workingdir/../../Results";
477             }
478 0 0       0 if(not(-e "$workingdir/../../Results/$Simulation::Automate::PostProcLib::simtempl")) {
479 0         0 mkdir "$workingdir/../../Results/$Simulation::Automate::PostProcLib::simtempl";
480             }
481              
482 0 0       0 if(not(-e "$workingdir/../../Results/$Simulation::Automate::PostProcLib::simtempl/$Simulation::Automate::PostProcLib::anatempl")) {
483 0         0 mkdir "$workingdir/../../Results/$Simulation::Automate::PostProcLib::simtempl/$Simulation::Automate::PostProcLib::dataset";
484             }
485 0         0 system("cp ${Simulation::Automate::PostProcLib::simtempl}-${Simulation::Automate::PostProcLib::anatempl}.* $workingdir/../../Results/$Simulation::Automate::PostProcLib::simtempl/$Simulation::Automate::PostProcLib::dataset");
486              
487             } #END of copy_results()
488             #------------------------------------------------------------------------------
489             sub create_legend {
490 2     2 0 8 my $title=shift;
491              
492 2         4 my %make_nice=%{shift(@_)};
  2         62  
493              
494 2         7 $title=~s/\-\-/\-\_MINUS_/g;
495 2         7 (my $legendkey,my $legendvalue)=split('-',$title);
496 2   50     21 $legendkey||=' ';
497 2   50     16 $legendvalue||=' ';
498 2 50       11 ($legendkey=~/_MINUS_/)&&($legendkey=~s/_MINUS_/\-/g);
499 2 50       11 ($legendvalue=~/_MINUS_/)&&($legendvalue=~s/_MINUS_/\-/g);
500              
501 2         9 my %title= ($legendkey=>$legendvalue);
502              
503 2         5 my $legend='';
504 2         6 my $legendtitle='';
505 2         15 foreach my $key (sort keys %title) {
506 2   33     15 my $titlepart=$make_nice{$key}{title}||&make_nice($key);
507 2         8 $legendtitle.=','.$titlepart;
508 2   33     55 my $legendpart=$make_nice{$key}{$title{$key}}||$title{$key};
509 2         8 $legend.=','.$legendpart;
510             }
511 2         15 $legend=~s/^,//;
512 2         7 $legendtitle=~s/^,//;
513              
514 2         17 return [$legendtitle,$legend];
515             }
516             #------------------------------------------------------------------------------
517             sub import_symbols {
518 1     1   6 no strict;
  1         2  
  1         455  
519 2     2 0 46 foreach my $name (sort keys %Simulation::Automate::PostProcLib::simdata) {
520 80 100       207 ($name=~/^\d*$/) && next;
521 76         93 my $lcname=lc($name);
522 76 50       147 if($name=~/^_/) {
523 0         0 @{"Simulation::Automate::PostProcLib::$lcname"}=@{$Simulation::Automate::PostProcLib::simdata{$name}};
  0         0  
  0         0  
524 0         0 @{"Simulation::Automate::PostProcessors::$lcname"}=@{$Simulation::Automate::PostProcLib::simdata{$name}};
  0         0  
  0         0  
525 0         0 push @Simulation::Automate::PostProcLib::EXPORT,'@'.$lcname;
526             } else {
527 76         95 ${"Simulation::Automate::PostProcLib::$lcname"}=$Simulation::Automate::PostProcLib::simdata{$name};
  76         340  
528 76         83 ${"Simulation::Automate::PostProcessors::$lcname"}=$Simulation::Automate::PostProcLib::simdata{$name};
  76         328  
529 76         181 push @Simulation::Automate::PostProcLib::EXPORT,'$'.$lcname;
530             }
531             }
532             }
533             #------------------------------------------------------------------------------
534             sub make_nice {
535 4     4 0 15 my $varname=shift;
536 4 50       20 if($varname=~/,/){
537 0         0 my @varnames=split(', ',$varname);
538 0         0 foreach my $varname (@varnames) {
539 0         0 $varname=~s/^_//;
540 0         0 $varname=~s/_/ /g;
541 0         0 $varname=lc($varname);
542 0         0 $varname=~s/^([a-z])/uc($1)/e;
  0         0  
543             }
544 0         0 $varname=join(', ',@varnames);
545             } else {
546 4         9 $varname=~s/^_//;
547 4         6 $varname=~s/_/ /g;
548 4         7 $varname=lc($varname);
549 4         24 $varname=~s/^([a-z])/uc($1)/e;
  0         0  
550             }
551 4         14 return $varname;
552             }
553             #------------------------------------------------------------------------------
554             1;
555             #print STDERR "#" x 80,"\n#\t\t\tSynSim simulation automation tool\n#\n#\t\t\t(C) Wim Vanderbauwhede 2002\n#\n","#" x 80,"\n\n Module SynSim::PostProcLib loaded\n\n";
556              
557