#!/usr/bin/perl
if( $ARGV[0] eq '-h' || $ARGV[0] eq '-help')
{
help();
exit;
}
sub help {
  print "\nExtract gradients from a Molpro output file.\n";
  print "Usage: molpro_extract_grad  molpro_out\n\n";
}

while(<>)
{
if (/GRADIENT/) {
$_=<>;$_=<>;$_=<>;
$ind=1;
$natm=-1;
while($ind>0){ $_=<>; $natm++; 
($ind, $xxx, $yyy,$zzz)=split;
$_=<> unless(($natm+1)%50);
print $xxx."  ".$yyy."   ".$zzz."\n" if $ind>0;
}
}
}


