###################################################################
#  Program Make.vib  csh script
#  make.vib 9 output
#           where 9 is the number of normal modes
#           and ouput is the spartan output file
#  generate all n vibrations from a spartan output file
set i=0
set n=$1
while($i < $n)
@ i++
echo Making $i vibration of $n
nawk -f vibspartan.awk sf=$i $2 > vib$i.xyz
end
echo "all done"
###################################################################
#     Program spartan.awk  nawk script
#     generate vibrational file for chime from spartan output file
#     freqency sf  sets normal mode number
#     scale sc     scales vibration up by sc
#     to print out the third frequency
#     nawk -f spartan.awk sf=3 output
BEGIN	{
	nn=22
	sc=1.0
	if(sd != "") sc=sd
	sfr=1
	if(sf != "") sfr=sf
	pi=3.1415927
	pi2=2.0*pi
	step=pi2/nn
	r[1]="-"
	r[2]="\\"
	r[3]="|"
	r[4]="/"
	r[5]="-"
	r[6]="\\"
	r[7]="|"
	r[8]="/"
	if(sd != "") s=sd
	}
#
#  loop through and read the pdb coordineate
/Coordinates/	{
	getline
	getline
	getline
	i=0
	while (NF > 0)
		{
			i++
			getline
			ta[i]=$1 $2
			x[i]=$3
			y[i]=$4
			z[i]=$5
		}			
	natom=i-1
#
#  print if debug is set
#	for(i=1;i <= natom; i++) print i,ta[i],x[i],y[i],z[i]
	}
#
# get all of the normal modes
/Normal/ {
	getline
	getline
	getline
	kk=0
	k=0
	num=NF
	while (num > 0)
		{
		kold=kk
		for(i=1; i <= num; i++)
			{ 
			kk++
			freq[kk]=$i
			}
		getline
		getline
		for (i=1; i <= natom; i++) 
			{
			getline
			k++
			i3=1
			for(j=1; j<= num; j++)
				{
				i1=i3+1
				i2=i1+1
				i3=i1+2 
				k1=k+(j-1)*natom
				xv[k1]=$i1
				yv[k1]=$i2
				zv[k1]=$i3
				}
			}
		getline
		getline
		getline
		num=NF
		k=k+(num-1)*natom
		}
	numfreq=kk
#
# print out nn xyz coordinates with a cosine oscillation
END	{
	k=1
	j=0
	c=""
	b=-step
	while (j <= nn)
		{
		b=b+step
		s=sc*cos(b)
# print out xyz coordinates
		print natom
		k++
		if (k > 8) {
				k=1
				c=c"*"
				}
		ii=natom*(sfr-1)
		print r[k] c
		for (i=1; i <= natom; i++){
			ii++
			xp=x[i]+s*xv[ii]
			yp=y[i]+s*yv[ii]
			zp=z[i]+s*zv[ii]
			print ta[i],xp,yp,zp
			}
		j++
		}
  	}

To return