#!/map/sys/bin/perl

sub PRINT_CM5_TIMES {
    open(CM5TIME, "axy1d-cm5.data");
    while (<CM5TIME>) {
	local($size, $nzones, $its) = split(" ", $_);
	local($t, $time, $mflops) = split(" ", <CM5TIME>);

	print TMP "$nzones $mflops ";
    }
    close(CM5TIME);
}

sub PRINT_DEC_TIMES {
    local($filename) = @_;
    open(DECTIME, $filename);
    while (<DECTIME>) {
	local($nzones, $mflops) = split(" ", $_);

	print TMP "$nzones $mflops ";
    }
    close(DECTIME);
}

$header = "newgraph
xaxis size 5 min 1e3 max 1e7 log log_base 10
xaxis hash_format E hash_labels font Helvetica fontsize 11
xaxis label font Helvetica fontsize 14 : Vector Length (64-bit)
yaxis size 3 min 0 max 1000
yaxis hash_labels font Helvetica fontsize 11
yaxis label font Helvetica fontsize 14 : Megaflops
title x 1e7 y 1000 hjr vjt font Helvetica-Bold fontsize 16 : 1D daxpy
";

$legend = "legend defaults
 font Helvetica fontsize 12 x 2000 y 850 hjl vjc
 linebreak 30
";

open(TMP,">tmp.jg");
print TMP $header;
print TMP $legend;

print TMP "newcurve marktype cross linetype solid";
print TMP " label : CM-5, 32 procs\n";
print TMP " pts ";
&PRINT_CM5_TIMES();
print TMP "\n";

print TMP "newcurve marktype circle fill 1.0 linetype dashed";
print TMP " label : DEC 8400, 4 procs\n";
print TMP " pts ";
&PRINT_DEC_TIMES("axy1d-4pe.data");
print TMP "\n";

print TMP "newcurve marktype triangle fill 1.0 linetype dashed";
print TMP " label : DEC 8400, 2 procs\n";
print TMP " pts ";
&PRINT_DEC_TIMES("axy1d-2pe.data");
print TMP "\n";

print TMP "newcurve marktype box fill 1.0 linetype dashed";
print TMP " label : DEC 8400, 1 procs\n";
print TMP " pts ";
&PRINT_DEC_TIMES("axy1d-1pe.data");
print TMP "\n";

print TMP "newcurve marktype none linetype solid rarrow\n";
print TMP " pts 2e6 500 1.4e6 450 8.2e5 270\n";

print TMP "newcurve marktype none linetype solid rarrow\n";
print TMP " pts 2e6 500 1.3e6 470 4.2e5 150\n";

print TMP "newcurve marktype none linetype solid rarrow\n";
print TMP " pts 2e6 500 1.2e6 490 2.2e5 70\n";

print TMP "newstring x 2.3e6 y 500 font Helvetica fontsize 12 linesep 6 vjc hjl : 3rd-level\\\n";
print TMP "cache\\\n";
print TMP "shoulder\n";

close(TMP);

`jgraph tmp.jg > tmp.ps; ghostview tmp.ps`;
