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 "ReductionMgr.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 24 of file GlobalMasterIMD.C.

Function Documentation

◆ find_free_port()

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

Definition at line 49 of file GlobalMasterIMD.C.

References vmdsock_bind().

Referenced by GlobalMasterIMD::GlobalMasterIMD().

49  {
50  if (vmdsock_bind(sock, defport)==0) return defport; // success
51  for (int port=1025; port < 4096; port++)
52  if (vmdsock_bind(sock, port)==0) return port;
53  return -1;
54 }
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 128 of file GlobalMasterIMD.C.

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

Referenced by GlobalMasterIMD::imd_connection().

128  {
129  if (imd_handshake(s, static_cast<int>(IMDversion))) {
130  iout << iWARN << "IMD handshake failed\n" << endi;
131  return 0;
132  }
133 
134  if (IMDversion == IMDversion_t::IMDv3) {
135  iout << iWARN << "IMD protocol version 3 detected\n" << endi;
136  if (imd_sessioninfo(s, sessionInfo)) {
137  iout << iWARN << "IMD sessioninfo not sent\n" << endi;
138  return 0;
139  }
140  }
141 
142  // Wait a second, then see if VMD has responded.
143  int32 length;
144  if (vmdsock_selread(s,1) != 1 || imd_recv_header(s, &length) != IMD_GO) {
145  iout << iWARN << "Incompatible Interactive MD, use VMD v1.4b2 or higher\n"
146  << endi;
147  return 0;
148  }
149  return 1;
150 }
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