From 035e2124aec729716b9c7db5ef0e1a92f1ea0d6a Mon Sep 17 00:00:00 2001 From: hawke <> Date: Fri, 23 Jan 2004 07:40:00 +0000 Subject: Modified Carpet2ygraphCat. Works with progressive and moving meshes. Wastes a lot more memory and disk space than it used to. darcs-hash:20040123074040-58737-eef0cd6ebc85e62611a2f15ab5eb0b927a4bc98a.gz --- Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl | 60 ++++++++++++++++++++--- 1 file changed, 53 insertions(+), 7 deletions(-) (limited to 'Carpet/CarpetIOASCII/src/util') diff --git a/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl b/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl index 5c312d66f..5608771e3 100755 --- a/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl +++ b/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl @@ -16,44 +16,90 @@ my $fh = new FileHandle(">$file") || die "Unable to open file \"$file\"."; my %data; my $time = -1; my $new = 0; +my $currentit = -1; +my $lastit = -1; +my @datatoprint; +my $nsets = 1; +my $maxlength = 0; +my @lengths; + +$lengths[0]=0; while () { $line = $_; - if ($line =~ /^#/) + if ($line =~ "iteration") { + @itline = split(/ +/,$line); + $currentit = @itline[2]; + } + elsif ($line =~ /^#/) { #Do nothing for headers! } elsif ($line =~ /([0-9+-ed.]+)*/) { @dataline = split(/ +/,$line); - if ($dataline[8] - $time > 1.e-10) + if ($currentit != $lastit) { if ($new) { - print $fh "\n\n\"Time = ",$time,"\n"; + push(@datatoprint,"\n\n\"Time = ".$time."\n"); my @sortedcoords = sort numerically (keys %data); my $localcoord; foreach $localcoord (@sortedcoords) { - print $fh $localcoord." ".$data{$localcoord}; + push(@datatoprint, $localcoord." ".$data{$localcoord}); } + $maxlength = $maxlength > (scalar @sortedcoords) ? $maxlength : (scalar @sortedcoords); + $lengths[$nsets-1]=(scalar @sortedcoords); + $nsets++; + $lengths[$nsets-1]=0; + %data=(); } $new++; $time = $dataline[8]; - + $lastit = $currentit; } my $coord = $dataline[9+$ARGV[0]]; my $val = $dataline[12]; $data{$coord} = $val; } } -print $fh "\n\"Time = ",$time,"\n"; +push(@datatoprint, "\n\"Time = ",$time,"\n"); my @sortedcoords = sort numerically (keys %data); my $localcoord; foreach $localcoord (@sortedcoords) { - print $fh $localcoord." ".$data{$localcoord}; + push(@datatoprint, $localcoord." ".$data{$localcoord}); +} +$maxlength = $maxlength > (scalar @sortedcoords) ? $maxlength : (scalar @sortedcoords); +$lengths[$nsets-1]=(scalar @sortedcoords); +$nsets++; +$lengths[$nsets-1]=0; + +my $oldline=""; +$nouts=0; +my $set=0; +foreach $line (@datatoprint) { + if ($line =~ "Time") { + if ($oldline) { + for (my $i=$lengths[$set-1]; $i<$maxlength;$i++) { + $nouts++; + print $fh $oldline; + } + } + $set++; + print $fh $line; + } + else { + $nouts++; + print $fh $line; + $oldline=$line + } +} +for (my $i=$lengths[$set-1]; $i<$maxlength;$i++) { + $nouts++; + print $fh $oldline; } sub numerically {$a <=> $b;} -- cgit v1.2.3