File: betterTimeObs.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 (57 lines) | stat: -rwxr-xr-x 1,063 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl

use strict;
use warnings;
use utf8;

my ($file, $label) = @ARGV;
defined($label) or die "USAGE: $0 file label\n";

print "#CmdLine: $file $label\n";

my @a;
my %times;
open(FIN, "<", $file) or die "$0: Cannot open $file : $!\n";
while (<FIN>) {
	next unless /\Q$label/;
	next if (/CmdLine/);

	my @tmp = split;
	next if (scalar(@tmp) < 5);

	my $site = $tmp[0];
	my $value = $tmp[1];
	my $time = $tmp[2];
	my $superdensity = realPartOf($tmp[4]);

	$a[$site]{"$time"} = {"value" => $value, "superdensity" => $superdensity};
	$times{"$time"} = 1;
}

close(FIN);

my $nsites = scalar(@a);
my $tt = scalar(keys %times);
print STDERR "$0: Found $nsites sites and $tt times in $file\n";

foreach my $time (sort {$a <=> $b} keys %times) {
	for (my $site = 0; $site < $nsites; ++$site) {
		my $pair = $a[$site]{"$time"};
		if (!defined($pair)) {
			print "$time $site -100 -100\n";
			next;
		}

		print "$time $site ".$pair->{"value"}." ".$pair->{"superdensity"}."\n";
	}
}

sub realPartOf
{
	my ($x) = @_;
	$_ = $x;
	s/\,.*$//;
	s/\(//;
	return $_;
}