NAMD
Classes | Macros | Functions | Variables
GlobalMasterIMD.C File Reference
#include "InfoStream.h"
#include "common.h"
#include "vmdsock.h"
#include "Node.h"
#include "IMDOutput.h"
#include "imd.h"
#include "SimParameters.h"
#include "UniqueSortedArray.h"
#include "GlobalMaster.h"
#include "GlobalMasterIMD.h"
#include "Vector.h"
#include <errno.h>
#include <string>
#include "Debug.h"

Go to the source code of this file.

Classes

struct  vmdforce
 

Macros

#define MIN_DEBUG_LEVEL   1
 

Functions

static int find_free_port (void *sock, int defport)
 
static int my_imd_connect (void *s, const int IMDversion, const IMDSessionInfo *sessionInfo)
 

Variables

static UniqueSortedArray< vmdforcevmdforces
 

Macro Definition Documentation

◆ MIN_DEBUG_LEVEL

#define MIN_DEBUG_LEVEL   1

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 23 of file GlobalMasterIMD.C.

Function Documentation

◆ find_free_port()

static int find_free_port ( void *  sock,
int  defport 
)
static

Definition at line 48 of file GlobalMasterIMD.C.

References vmdsock_bind().

Referenced by GlobalMasterIMD::GlobalMasterIMD().

48  {
49  if (vmdsock_bind(sock, defport)==0) return defport; // success
50  for (int port=1025; port < 4096; port++)
51  if (vmdsock_bind(sock, port)==0) return port;
52  return -1;
53 }
int vmdsock_bind(void *v, int port)
Definition: vmdsock.C:114

◆ my_imd_connect()

static int my_imd_connect ( void *  s,
const int  IMDversion,
const IMDSessionInfo sessionInfo 
)
static

Definition at line 104 of file GlobalMasterIMD.C.

References endi(), IMD_GO, imd_handshake(), imd_recv_header(), imd_sessioninfo(), IMDv3, iout, iWARN(), and vmdsock_selread().

Referenced by GlobalMasterIMD::calculate().

104  {
105  if (imd_handshake(s, static_cast<int>(IMDversion))) {
106  iout << iWARN << "IMD handshake failed\n" << endi;
107  return 0;
108  }
109 
110  if (IMDversion == IMDversion_t::IMDv3) {
111  iout << iWARN << "IMD protocol version 3 detected\n" << endi;
112  if (imd_sessioninfo(s, sessionInfo)) {
113  iout << iWARN << "IMD sessioninfo not sent\n" << endi;
114  return 0;
115  }
116  }
117 
118  // Wait a second, then see if VMD has responded.
119  int32 length;
120  if (vmdsock_selread(s,1) != 1 || imd_recv_header(s, &length) != IMD_GO) {
121  iout << iWARN << "Incompatible Interactive MD, use VMD v1.4b2 or higher\n"
122  << endi;
123  return 0;
124  }
125  return 1;
126 }
int vmdsock_selread(void *v, int sec)
Definition: vmdsock.C:177
Definition: common.h:275
int32_t int32
Definition: common.h:38
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
std::ostream & iWARN(std::ostream &s)
Definition: InfoStream.C:82
Definition: imd.h:19
#define iout
Definition: InfoStream.h:51
int imd_sessioninfo(void *s, const IMDSessionInfo *info)
Definition: imd.C:160
int imd_handshake(void *s, const int IMDVersion)
Definition: imd.C:132
IMDType imd_recv_header(void *s, int32 *length)
Definition: imd.C:276

Variable Documentation

◆ vmdforces

UniqueSortedArray<vmdforce> vmdforces
static