In my excitement about modifying Babel to accept Molecular Arts
M3D files, I posted before thoroughly testing the thing, and I
found a mistake. M3D files include "ep" atoms which represent lone
electron pairs, and Babel doesn't know how to handle these. I've
been trying to rewrite rdm3d.c to simply discard the lone pairs,
but for various reasons internal to Babel's source code, this is
difficult.

It's much easier to write a small program that translates M3D files
to one of the formats already understood by Babel (XYZ files), and
then discard lone pairs in the small program. Here is a C program that
does this. This is a re-write of an earlier version of this program,
which didn't correctly handle lone pairs.

Compile this program with any C compiler, and then type:

	m3dxyz < stuff.m3d > stuff.xyz

to convert a file from M3D to XYZ format. The XYZ file can then be
used with the unmodified version of Babel to produce any of the
other formats it knows about.

You can get m3dxyz.c by snipping it from this note, or via FTP at
ftp://ftp.std.com/pub/wware/m3dxyz.c.

-------- snip ----------- snip ------------ snip -----------
/*
 * m3dxyz.c - C program, translate M3D files to XYZ files
 * Copyright (C) 1996 Will Ware
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You can get a copy of the GNU General Public License by writing
 * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
 * MA 02139, USA.  It's also in a million places on the net.
 *
 * I can be reached via email at <wware@world.std.com>.
 */

#include <stdio.h>

#define MAX_NUM_ATOMS 1000

struct
{
  char name[5];
  float x, y, z;
} atoms[MAX_NUM_ATOMS];

void main(void)
{
  char line[200];
  int num_atoms;
  int i, dummy1, dummy2;

  gets(line);
  gets(line);
  sscanf(line, " %d", &num_atoms);

  if (num_atoms >= MAX_NUM_ATOMS)
    {
      fprintf(stderr, "Too many atoms, increase MAX_NUM_ATOMS\n");
      exit(1);
    }

  for (i = 0; i < num_atoms; i++)
    {
      gets(line);
      sscanf(line, "%d %s %d %f %f %f",
	     &dummy1, atoms[i].name, &dummy2,
	     &atoms[i].x, &atoms[i].y, &atoms[i].z);

      /* discard electron pairs, Babel doesn't understand them */
      if (strcmp(atoms[i].name, "ep") == 0)
	num_atoms--;
    }

  printf("%d\nGlop\n", num_atoms);
  for (i = 0; i < num_atoms; i++)
    printf("%s %f %f %f\n",
	   atoms[i].name, atoms[i].x, atoms[i].y, atoms[i].z);
}
-------- snip ----------- snip ------------ snip -----------
