From ccf676ec1d94380150bcb3268968b922b2baa571 Mon Sep 17 00:00:00 2001 From: Thomas Radke Date: Mon, 8 Dec 2008 15:27:23 +0100 Subject: CarpetIOASCII: fix for utility script Carpet2ygraphCat.pl Extract the iteration number from data column rather than from a (possibly non-existing) comment line --- Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'Carpet/CarpetIOASCII') diff --git a/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl b/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl index 7e85340df..de8ad2626 100755 --- a/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl +++ b/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl @@ -102,7 +102,6 @@ if ($direction == 0) { my %data; my $time = -1; my $new = 0; -my $currentit = -1; my $lastit = -1; my @datatoprint; @@ -117,22 +116,19 @@ while () chomp; next if (/^$/); - if (/iteration/) { - @itline = split(/ +/); - $currentit = $itline[2]; - } @dataColumns = split(/[ :]/, $1) if (/^# data columns: (.+)/); #Do nothing for headers! next if (/^#/); - @dataline = split(/[ \t]+/); + my @dataline = split(/[ \t]+/); + my $currentit = $dataline[0]; if ($currentit != $lastit) { if ($new) { # do not print "Time..." for zero-D data - push(@datatoprint,"\n\n\#Time = ".$time."\n") if ($direction !~ 8); + push(@datatoprint,"\n\n\#Time = $time\n") if ($direction !~ 8); - my @sortedcoords = sort numerically (keys %data); + my @sortedcoords = sort {$a <=> $b} (keys %data); foreach my $localcoord (@sortedcoords) { push(@datatoprint, $localcoord." ".$data{$localcoord}."\n"); } @@ -158,9 +154,9 @@ while () } # do not print "Time..." for zero-D data -push(@datatoprint,"\n\n\#Time = ".$time."\n") if ($direction !~ 8); +push(@datatoprint,"\n\n\#Time = $time\n") if ($direction !~ 8); -my @sortedcoords = sort numerically (keys %data); +my @sortedcoords = sort {$a <=> $b} (keys %data); foreach my $localcoord (@sortedcoords) { push(@datatoprint, $localcoord." ".$data{$localcoord}."\n"); } @@ -214,5 +210,3 @@ foreach $line (@datatoprint) { # $nouts++; # print $fh $oldline; #} - -sub numerically {$a <=> $b;} -- cgit v1.2.3