From: Marc Baaden (baaden_at_smplinux.de)
Date: Fri May 30 2003 - 08:39:14 CDT

John and dear list members,

thanks for all the help. I have meanwhile figured out what the problem
was (a simple typo). Finally I thought it would be helpful to have a
minimal program to test imd connection to VMD, so I post my very humble
first step. It randomly creates position data for a system comprising
one single atom.

It needs the imd.C, imd.h, vmdsock.C and vmdsock.h files from namd.
Compilation eg

g++ -DSOCKLEN_T=socklen_t -static -g -Wall -c -o imd.o imd.C
g++ -DSOCKLEN_T=socklen_t -static -g -Wall -c -o vmdsock.o vmdsock.C
g++ -g -Wall testimd.c imd.o vmdsock.o -o testimd

I also post a simple one-atom PDB to go with it. To test the program,
one runs ./testimd, then starts VMD, load unat.pdb and connect via
imd connect localhost 54321

Cheers,
  Marc


Content-Type: text/x-csrc ; name="testimd.c"; charset=iso-8859-1
Content-Description: testimd.c
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="testimd.c"

#include "vmdsock.h"
#include "imd.h"
#include <stdlib.h>
#include <unistd.h>

int main ()
{
  int port =3D 54321;
  void *sock;
  void *clientsock;
  int length;
  IMDEnergies energies;
  float coords[3];
  float tmp;
  =

  vmdsock_init();
  sock =3D vmdsock_create();
  clientsock =3D NULL;
  vmdsock_bind(sock, port);
  vmdsock_listen(sock);
  tmp =3D 0.23234;
  while (!clientsock) {
    if (vmdsock_selread(sock, 0) > 0) {
      clientsock =3D vmdsock_accept(sock);
      if (imd_handshake(clientsock)) {
        clientsock =3D NULL;
      };
    }
  }
  sleep(1);
  if (vmdsock_selread(clientsock, 0) !=3D 1 || =

      imd_recv_header(clientsock, &length) !=3D IMD_GO) {
    clientsock =3D NULL;
  }
  while (clientsock) {
    imd_send_energies(clientsock, &energies);
    tmp =3D ( (double)rand() / (double)(RAND_MAX) );
    coords[0] =3D tmp ; /* coordonn=E9e x */
    coords[1] =3D (tmp -1); /* coordonn=E9e y */
    coords[2] =3D (-tmp + 0.8); /* coordonn=E9e z */
    imd_send_fcoords(clientsock, 1, coords);
  }
}


 Dr. Marc Baaden - Institut de Biologie Physico-Chimique, Paris
 mailto:baaden_at_smplinux.de - http://www.marc-baaden.de
 FAX: +49 697912 39550 - Tel: +33 15841 5176 ou +33 609 843217