#!/usr/bin/perl -w # # convert xyz file into schakal files # # (c) 2007 Robin Haunschild # # Lizenz: GNU/GPLV2 # if (! $ARGV[0]) { print "Error: No input file was given.\n"; print "For help use -h\n"; exit 1; } if ($ARGV[0] eq "-h" || $ARGV[0] eq "-H") { print "Help:\n\n"; $PRGNAME = `basename $0`; chomp($PRGNAME); print "$PRGNAME can convert xyz files into schakal dat files. \n"; print "Example of input file:\n\n"; print ",-------------------------------------------------\n"; print "8 \n"; print "C4H4-Tetraeder \n"; print " C 0.5212340 0.5212340 0.5212340 \n"; print " C -0.5212340 -0.5212340 0.5212340 \n"; print " C -0.5212340 0.5212340 -0.5212340 \n"; print " C 0.5212340 -0.5212340 -0.5212340 \n"; print " H 1.1379400 1.1379400 1.1379400 \n"; print " H -1.1379400 1.1379400 -1.1379400 \n"; print " H -1.1379400 -1.1379400 1.1379400 \n"; print " H 1.1379400 -1.1379400 -1.1379400 \n"; print "`-------------------------------------------------\n"; exit 0; } open INFILE, "$ARGV[0]" || die "Can't open file $ARGV[0]!!! EOP - End Of Program!!!\n"; # Read in the xyz file $i = 0; while ($xyzfile[$i] = ) { $i++; } $atomquant = $xyzfile[0]; $comment = $xyzfile[1]; print "TITL $comment"; print "CELL 1 1 1 90 90 90 \n"; for($i=2; $i<$atomquant+2; $i++) { ($atom, $x, $y, $z) = split(" ", $xyzfile[$i]); # print "ATOM $atom $x $y $z \n"; printf "ATOM $atom %14.10f %14.10f %14.10f \n", $x, $y, $z; } print "END\n";