#!/usr/bin/perl
#
#
# Takes a g98 output and makes a "movie" input for Xmol.
#

%elsymb=( "1" => "H ",
	  "4" => "C ", # beryllium
	  "6" => "C ", 
	  "7" => "N ", 
	  "8" => "O ",
	  "9" => "F" ,
	 "12" => "Mg",
	 "16" => "S" ,
	 "17" => "Cl",
         "22" => "Ti",
         "29" => "Cu" );

$NN=55; # Change the number of atoms here.
$NN=1+18*3; # Change the number of atoms here.
$NN=28; # jaagu molekul; bimorfoliin
$NN=13; # eddaoonium
$NN=15;
$NN=12;
$NN=59;
$NN=21;

while (<>) {
#    if (/Z-Matrix orientation/) {
#     if (/Standard orientation/) {
    if (/Input orientation/) {
	$_=<>;$_=<>;$_=<>;$_=<>;$_=<>;  # skip 5 lines
	print $NN,"\n\n";
	while (! /----------/) {
#	    print;
	    chop;
	    @x=split;
#	    print $_,"\n";
	    printf ("%-3s %12.6f %12.6f %12.6f\n",$elsymb{$x[1]},$x[3],$x[4],$x[5]);
	    $_=<>;
	}
    }
}
