/usr/share/perl5/AtomicBasis.pm is in mpqc-support 2.3.1-11ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | #
eval 'exec perl $0 $*'
if 0;
package AtomicBasis;
$fltrx = "((?:-?\\d+|-?\\d+\\.\\d*|-?\\d*\\.\\d+)(?:[eEdD][+-]?\\d+)?)";
sub new {
my $this = shift;
my $class = ref($this) || $this;
my $self = {};
bless $self, $class;
$self->initialize(@_);
return $self;
}
sub initialize {
my $self = shift;
$self->{"pure_d"} = 1;
$self->{"pure_f_plus"} = 1;
$self->{"exponents"} = [];
$self->{"coefficients"} = [];
$self->{"am"} = [];
$self->{"pure"} = [];
}
sub default_pure {
my $self = shift;
my $am = shift;
if ($am == 2 && $self->{"pure_d"}) { return 1; }
elsif ($am > 2 && $self->{"pure_f_plus"}) { return 1; }
return 0;
}
my $amtypes = "SPDFGHIKLMN";
sub am_string_to_number {
my $amstr = uc(shift);
if (length($amstr) != 1) {
die "invalid am string \"$amstr\"";
}
my $index = index($amtypes,$amstr);
if ($index == -1) {
die "am string \"$amstr\" not found";
}
return $index;
}
sub am_number_to_string {
my $am = shift;
return substr($amtypes,$am,1);
}
sub stdflt {
my $num = shift;
$num =~ s/D/e/;
$num =~ s/d/e/;
$num =~ s/E/e/;
return $num;
}
sub read_gaussian {
my $self = shift;
my $file = shift;
my $ishell = 0;
while (<$file>) {
if (/\*\*\*\*/) {
last;
}
elsif (/([A-Za-z]+) +([0-9]+) +([0-9.]+)/) {
my $amstr = uc($1);
my $nprim = $2;
my $scale = $3;
if ($scale != 1) {
die "cannot handle scale = $scale (must be 1)";
}
if ($amstr eq "SP") {
$self->{"am"}->[$ishell]->[0] = 0;
$self->{"am"}->[$ishell]->[1] = 1;
$self->{"pure"}->[$ishell]->[0] = 0;
$self->{"pure"}->[$ishell]->[1] = 0;
foreach my $i (0..$nprim-1) {
while (<$file>) { last; }
if (/$fltrx\s+$fltrx\s+$fltrx\s*$/) {
my $exp = $1;
my $coefs = $2;
my $coefp = $3;
$self->{"exponents"}->[$ishell]->[$i]
= stdflt($exp);
$self->{"coefficients"}->[$ishell]->[$i]->[0]
= stdflt($coefs);
$self->{"coefficients"}->[$ishell]->[$i]->[1]
= stdflt($coefp);
}
else {
die "bad exponent coefficient line";
}
}
}
else {
my $am = am_string_to_number($amstr);
$self->{"am"}->[$ishell]->[0] = $am;
$self->{"pure"}->[$ishell]->[0] = $self->default_pure($am);
foreach my $i (0..$nprim-1) {
while (<$file>) { last; }
if (/$fltrx\s+$fltrx\s*$/) {
my $exp = $1;
my $coef = $2;
$self->{"exponents"}->[$ishell]->[$i]
= stdflt($exp);
$self->{"coefficients"}->[$ishell]->[$i]->[0]
= stdflt($coef);
}
else {
die "bad exponent coefficient line";
}
}
}
$ishell++;
}
else {
die "could not parse line $_";
}
}
}
sub nshell {
my $self = shift;
my @exp = @{$self->{"exponents"}};
return $#exp + 1;
}
sub nprim {
my $self = shift;
my $ishell = shift;
my @exp = @{$self->{"exponents"}->[$ishell]};
return $#exp + 1;
}
sub ncon {
my $self = shift;
my $ishell = shift;
my @exp = @{$self->{"am"}->[$ishell]};
return $#exp + 1;
}
sub exp {
my $self = shift;
my $ishell = shift;
my $iprim = shift;
my $exp = $self->{"exponents"}->[$ishell]->[$iprim];
return $exp;
}
sub coef {
my $self = shift;
my $ishell = shift;
my $iprim = shift;
my $icon = shift;
my $coef = $self->{"coefficients"}->[$ishell]->[$iprim]->[$icon];
return $coef;
}
sub am {
my $self = shift;
my $ishell = shift;
my $icon = shift;
my $am = $self->{"am"}->[$ishell]->[$icon];
return $am;
}
sub pure {
my $self = shift;
my $ishell = shift;
my $icon = shift;
my $pure = $self->{"pure"}->[$ishell]->[$icon];
return $pure;
}
sub amstr {
my $self = shift;
my $ishell = shift;
my $icon = shift;
my $am = $self->{"am"}->[$ishell]->[$icon];
return am_number_to_string($am);
}
sub write_keyval {
my $self = shift;
my $file = shift;
foreach my $ishell (0..$self->nshell()-1) {
print $file " (type: [";
# write out am (and puream)
foreach my $icon (0..$self->ncon($ishell)-1) {
if ($icon > 0) { print $file " "; }
if ($self->pure($ishell,$icon)) {
printf $file "(am=%s puream=1)",
lc($self->amstr($ishell,$icon));
}
else {
printf $file "am=%s", lc($self->amstr($ishell,$icon));
}
}
print $file "]\n";
print $file " {exp";
# write out coef:0...
foreach my $icon (0..$self->ncon($ishell)-1) {
print $file " coef:$icon";
}
print "} = {\n";
foreach my $iprim (0..$self->nprim($ishell)-1) {
printf $file " %s", $self->exp($ishell,$iprim);
# write out coefficients
foreach my $icon (0..$self->ncon($ishell)-1) {
printf $file " %s", $self->coef($ishell,$iprim,$icon);
}
printf $file "\n";
}
print $file " })\n";
}
}
1;
|