Skip to content

Instantly share code, notes, and snippets.

@glennklockwood
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glennklockwood/8792456 to your computer and use it in GitHub Desktop.
Save glennklockwood/8792456 to your computer and use it in GitHub Desktop.
analyzecoord, Original Perl Implementation
#!/usr/bin/perl
@show = qw/ Siloxane SiO4 Si3O SiO3 SiO2 SiO1 NBO FreeOH H2O H3O SiOH SiOH2 Si2OH/;
printf("\n%-8.8s ", "ird");
foreach $specie ( @show )
{
printf("%8.8s ", $specie);
}
print "\n";
$current = 0;
$isave = 0;
while ( $line = <> )
{
chomp($line);
$line =~ s/^\s+//g;
@arg = split(/\s+/, $line);
next unless $line =~ m/^\d+\s+[\d\w]+\s+\d+\s+[\w\.]+\s+[\w\.]+\s+[\w\.]+\s*$/o;
if ( $current == 0 )
{
$current = $arg[0];
$isave = $current;
}
if ( $arg[0] != $current )
{
&printargs();
$current = $arg[0];
$isave++;
}
$type{$arg[1]}++;
}
&printargs();
sub printargs( )
{
printf("%-8s ", $isave);
foreach $specie ( @show )
{
printf("%8d ", $type{$specie});
}
print "\n";
foreach $i ( keys(%type) )
{
$type{$i} = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment