#!/usr/bin/perl 
# This is Prgram is read the NAMD log output
# Use: perl namdlog.pl "input NAMD log file name" > Output.dat 
my $filename;
$filename = shift;
open(OPENINPUT,$filename) or dienice(" Can't open sorted data file $!.");
my @INPUTFILE=<OPENINPUT>;
chomp(@INPUTFILE);

print "#      TS           BOND          ANGLE          DIHED          IMPRP           ELECT            VDW            BOUNDARY           MISC        KINETIC          TOTAL           TEMP           TOTAL2            TOTAL3        TEMPAVG\n";

my $count=0;
foreach my $line (@INPUTFILE) 
   {
    if( $line =~ /^ENERGY:\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/ )
	{
	printf("%8d %15.5f %15.5f %15.5f %15.5f %15.5f %15.5f %15.5f %15.5f %15.5f %15.5f %15.5f %15.5f %15.5f %15.5f\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15);
        }
    }
   print "\n";
