File: getInSitu.pl

package info (click to toggle)
dmrgpp 6.06-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 113,900 kB
  • sloc: cpp: 80,986; perl: 14,772; ansic: 2,923; makefile: 83; sh: 17
file content (41 lines) | stat: -rwxr-xr-x 754 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl

use strict;
use warnings;
use utf8;

my ($file, $label, $lx, $ly) = @ARGV;
defined($lx) or die "USAGE: $0 filename label lx [ly]\n";
defined($ly) or $ly = 1;

my @value;
open(FILE, "<", $file) or die "$0: Cannot open $file : $!\n";

while (<FILE>) {
	if (/\Q$label/) {
	#63 0.899850 0.000000 <gs|n|gs> 1.000000
		my @temp = split;
		next if (scalar(@temp) != 5);
		my $obs = $temp[3];
		next unless ($obs eq $label);
		$value[$temp[0]] = $temp[1];
	}
}

close(FILE);

my $total = 0;
for (my $y = 0; $y < $ly; ++$y) {
	for (my $x = 0; $x < $lx; ++$x) {
		my $ind = $y + $x*$ly;
		my $tmp = $value[$ind];
		defined($tmp) or $tmp = "X";
		$total += $tmp unless ($tmp eq  "X");
		print "$tmp ";
	}

	print "\n";
}

print "#TOTAL=$total\n";