aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetIOASCII
diff options
context:
space:
mode:
authorI.Hawke <schnetter@cct.lsu.edu>2006-02-06 10:21:00 +0000
committerI.Hawke <schnetter@cct.lsu.edu>2006-02-06 10:21:00 +0000
commit34ef15bf8538f2e0fc6a7b91158f700a63cbbba1 (patch)
tree4e376f265fb0d41636c8fb84f7e379d8ebca2e1e /Carpet/CarpetIOASCII
parent3fbb75842946a5f2aff3b39521252b74c29fa0c3 (diff)
Carpet2ygraphCat: minor modifications
Add a couple of Luca and Erik's wish list modifications; direction is determined from filename and so is output filename. darcs-hash:20060206102125-34bfa-c982b006c1f3c7544803610b6cb0714af3a70e07.gz
Diffstat (limited to 'Carpet/CarpetIOASCII')
-rwxr-xr-xCarpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl28
1 files changed, 23 insertions, 5 deletions
diff --git a/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl b/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl
index 669c8e64b..d983b65a8 100755
--- a/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl
+++ b/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl
@@ -2,15 +2,33 @@
use FileHandle;
-if(@ARGV != 3)
+if(@ARGV != 1)
{
- print "Usage: $0 direction <Inputfile> <Outputfile> \n";
+ print "Usage: $0 <Inputfile> \n";
exit;
}
-open(CARPETFILE, "<$ARGV[1]") || die "Unable to find file \"$ARGV[1]\".";
+open(CARPETFILE, "<$ARGV[0]") || die "Unable to find file \"$ARGV[0]\".";
-$file = $ARGV[2].".xg";
+my $dirn;
+my $filename;
+$ARGV[0] =~ /(.*)\.([xyz])\..*/;
+$filename = $1; $dirn = $2;
+my $direction;
+if ($dirn eq "x") {
+ $direction = 0;
+}
+elsif ($dirn eq "y") {
+ $direction = 1;
+}
+elsif ($dirn eq "z") {
+ $direction = 2;
+}
+else {
+ die "Do not recognize direction \"${dirn}\" (file \"${ARGV[0]}\").";
+}
+
+$file = $filename."_${dirn}.xg";
my $fh = new FileHandle(">$file") || die "Unable to open file \"$file\".";
my %data;
@@ -60,7 +78,7 @@ while (<CARPETFILE>)
$time = $dataline[8];
$lastit = $currentit;
}
- my $coord = $dataline[9+$ARGV[0]];
+ my $coord = $dataline[9+$direction];
my $val = $dataline[12];
$data{$coord} = $val;
}