extracting normal modes from gaussian output



 Dear netters,
 There was a PERL utility which extracts vibratinal modes
 (for XMOL input) from gaussian frequency calculation output.
 This works perfect but I wrote it in AWK so that
 people who don't have PERL can use it.
 I guess this version will be more readable than PERL code.
 Do whatever you want with this.
 -DL
 <PS> I never used XMOL before. If the output doesn't work for
      XMOL, please let me know.
 ------------------- CUT HERE -------------------------------------------------
 #!/usr/bin/nawk -f
 #  "at@at" (#) g92vib: extracts vibrational modes from gaussian output for XMOL
 # Dongchul Lim, dlim "at@at" minerva.ycc.yale.edu
 # Usage: g92vib filename
 BEGIN {
 	# initialize atomic symbols (add more rows if you need beyond Kr)
 	nrows = 0;
 	row[++nrows] = "H
 He";
 	row[++nrows] = "Li Be                               B  C  N  O  F
 Ne";
 	row[++nrows] = "Na Mg                               Al Si P  S  Cl
 Ar";
 	row[++nrows] = "K  Ca Sc Ti V  Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br
 Kr";
 	for(i=1;i<=nrows;i++) {
 		n = split(row[i], s, " ");
 		for(j=1;j<=n;j++) symbol[nsymbol+j] = s[j];
 		nsymbol += n;
 	}
 	natoms = 0;
 }
 # get either Z-Matrix orientation or Standard orientation.
 # if both are present, Standard orientation will be used, since
 # it is found later than Z-Matrix orientation in Gaussian output.
 /(Z-Matrix orientation:|Standard orientation:)/	{
 	natoms = 0;
 	for(i=1;i<=4;i++) getline;	# skip 4 lines
 	while (1) {
 		getline;
 		if (match($0, "---")) break;
 		if ($2 <= 0) continue;	# skip dummies
 		natoms++;
 		an[natoms] = $2;
 		x[natoms]  = $3;
 		y[natoms]  = $4;
 		z[natoms]  = $5;
 	}
 	next;
 }
 # look for Harmonic frequencies
 /Harmonic frequencies/	{
 	if (natoms == 0 ) {
 		printf("Standard orientation / Z-Matrix orientation not found.\n");
 		exit;
 	}
 	# skip two lines
 	getline; getline;
 	nfreq = 0;
 	while (1) {
 		getline;
 		if (match($0, "Harmonic") != 0) break;
 		getline;
 		# read in frequencies
 		getline;
 		nf = split(substr($0, 24), freq, " ");
 		# skip 6 lines
 		for(i=1;i<=6;i++) getline;
 		# read in normal mode vectors
 		for(i=1;i<=natoms;i++) {
 			getline;
 			for(j=1;j<=nf;j++) xmode[i,j] = $(j+3);
 			getline;
 			for(j=1;j<=nf;j++) ymode[i,j] = $(j+3);
 			getline;
 			for(j=1;j<=nf;j++) zmode[i,j] = $(j+3);
 		}
 		# print out coords and normval mode vectors for each mode
 		for(i=1;i<=nf;i++) {
 			nfreq++;
 			file = sprintf("%s.nu%02d", FILENAME, nfreq);
 			printf("%d\n", natoms) > file
 			printf("NU=%.3f\n", freq[i]) > file
 			for(j=1;j<=natoms;j++) {
 				sym = (an[j] <= 0 || an[j] > nsymbol) ? "X" : symbol[an[j]];
 				printf(" %2s % 12.6f % 12.6f % 12.6f % 12.6f % 12.6f % 12.6f\n",
 				sym, x[j], y[j], z[j], xmode[j,i], ymode[j,i], zmode[j,i]) > file
 			}
 			close(file);
 		}
 	}
 	exit;
 }
 ------------------- CUT HERE -------------------------------------------------