aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetIOASCII
diff options
context:
space:
mode:
authorThomas Radke <tradke@aei.mpg.de>2008-12-08 15:27:23 +0100
committerThomas Radke <tradke@aei.mpg.de>2008-12-08 15:27:23 +0100
commitccf676ec1d94380150bcb3268968b922b2baa571 (patch)
tree8b12bfbf493b70c787faed93fdb650fd1c7cd6c0 /Carpet/CarpetIOASCII
parent26ad810261d769680f747a4da02b950d0a521fd5 (diff)
CarpetIOASCII: fix for utility script Carpet2ygraphCat.pl
Extract the iteration number from data column rather than from a (possibly non-existing) comment line
Diffstat (limited to 'Carpet/CarpetIOASCII')
-rwxr-xr-xCarpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl18
1 files changed, 6 insertions, 12 deletions
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 (<CARPETFILE>)
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 (<CARPETFILE>)
}
# 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;}