24 #define MIN_DEBUG_LEVEL 1    51   for (
int port=1025; port < 4096; port++) 
    57   DebugM(3,
"Constructing\n");
    73     NAMD_die(
"Unable to initialize socket interface for IMD.\n");
    77   if (newport != port) {
    78     iout << 
iWARN << 
"Interactive MD failed to bind to port "    79                   << port << 
".\n" << 
endi;
    83     NAMD_die(
"Interactive MD failed to find free port.\n");
    86   iout << 
iINFO << 
"Interactive MD listening on port "    87                   << newport << 
".\n" << 
endi;
   106 #if (defined (NAMD_CUDA) || defined (NAMD_HIP))   135     iout << 
iWARN << 
"IMD protocol version 3 detected\n" << 
endi;
   145     iout << 
iWARN << 
"Incompatible Interactive MD, use VMD v1.4b2 or higher\n"   157     iout << 
iINFO << 
"INTERACTIVE MD AWAITING CONNECTION\n" << 
endi;
   209   DebugM(2,
"Setting " << num << 
" forces.\n");
   217     for ( i = 0; i < num; ++i, ++v_i) {
   241   for (
int i_client=0; i_client<
clients.
size(); i_client++) {
   242     void *clientsock = 
clients[i_client];
   250           vmd_atoms = 
new int32[length];
   251           vmd_forces = 
new float[3*length];
   254               "Error reading IMD forces, killing connection\n" << 
endi;
   255             goto vmdDestroySocket;
   258             iout << 
iWARN << 
"Ignoring IMD forces as receiving forces is not supported in IMDv3 as of now\n" << 
endi;
   264               if (
IMDignore) strcpy(option, 
"IMDignore");
   265               else strcpy(option, 
"IMDignoreForces");  
   266               iout << 
iWARN << 
"Ignoring IMD forces due to " << option << 
"\n" << 
endi;
   269             for (
int i=0; i<length; i++) {
   270               vnew.
index = vmd_atoms[i];
   271               if ( (vtest=
vmdforces.find(vnew)) != NULL) {
   273                 if (vmd_forces[3*i] != 0.0f || vmd_forces[3*i+1] != 0.0f
   274                     || vmd_forces[3*i+2] != 0.0f) {
   275                   vtest->
force.
x = vmd_forces[3*i];
   276                   vtest->
force.
y = vmd_forces[3*i+1];
   277                   vtest->
force.
z = vmd_forces[3*i+2];
   285                 if (vmd_forces[3*i] != 0.0f || vmd_forces[3*i+1] != 0.0f
   286                     || vmd_forces[3*i+2] != 0.0f) {
   287                   vnew.
force.
x = vmd_forces[3*i];
   288                   vnew.
force.
y = vmd_forces[3*i+1];
   289                   vnew.
force.
z = vmd_forces[3*i+2];
   296           delete [] vmd_forces;
   299           iout << 
iINFO << 
"Setting transfer rate to " << length<<
'\n'<<
endi;   
   304             iout << 
iWARN << 
"Ignoring IMD pause due to IMDignore\n" << 
endi;
   345           if ( paused ) paused = ! paused;
   352             iout << 
iWARN << 
"Ignoring IMD kill due to IMDignore\n" << 
endi;
   355           NAMD_quit(
"Received IMD kill from client\n");
   362           vmd_forces = 
new float[3*length];
   364           delete [] vmd_forces;
   369             iout << 
iINFO << 
"IMD set to " << (
IMDwait ? 
"wait" : 
"not wait") << 
" for incoming connection" << 
'\n' << 
endi;
   393       if (!clientsock) 
continue;
   395         const std::string error =
   396           std::string{
"IMDv3: GlobalMasterIMD::send_energies socket timeout in "} +
   419       if (!clientsock) 
continue;
   421         const std::string error =
   422           std::string{
"IMDv3: GlobalMasterIMD::send_fcoords socket timeout in "} +
   435       for (
int i=0; i<N; i++) {
   451     if (!clientsock) 
continue;
   453       const std::string error =
   454         std::string{
"IMDv3: GlobalMasterIMD::send_velocities socket timeout in "} +
   466       for (
int i=0; i<N; i++) {
   468         veltmp[3*i+1] = velocities[i].
y; 
   469         veltmp[3*i+2] = velocities[i].
z; 
   482     if (!clientsock) 
continue;
   484       const std::string error =
   485         std::string{
"IMDv3: GlobalMasterIMD::send_forces socket timeout in "} +
   497       for (
int i=0; i<N; i++) {
   513     if (!clientsock) 
continue;
   515       const std::string error =
   516         std::string{
"IMDv3: GlobalMasterIMD::send_box socket timeout in "} +
   530     if (!clientsock) 
continue;
   532       const std::string error =
   533         std::string{
"IMDv3: GlobalMasterIMD::send_time socket timeout in "} +
 
int vmdsock_selwrite(void *v, int sec)
 
void * vmdsock_create(void)
 
ForceList & modifyAppliedForces()
 
std::ostream & iINFO(std::ostream &s)
 
static int find_free_port(void *sock, int defport)
 
int vmdsock_selread(void *v, int sec)
 
void send_time(IMDTime *)
 
static int my_imd_connect(void *s, const int IMDversion, const IMDSessionInfo *sessionInfo)
 
void NAMD_quit(const char *err_msg)
 
int imd_send_energies(void *s, const IMDEnergies *energies)
 
SimParameters * simParameters
 
std::ostream & endi(std::ostream &s)
 
std::ostream & iWARN(std::ostream &s)
 
int imd_send_box(void *s, const IMDBox *box)
 
int add(const Elem &elem)
 
const ResizeArray< AtomIDList > & requestedGroups()
 
void send_velocities(int, FloatVector *)
 
SubmitReduction * reductionGpuResident
 
int imd_send_fcoords(void *s, int32 n, const float *coords)
 
SubmitReduction * reduction
 
vmdforce & operator=(const vmdforce &v)
 
int vmdsock_listen(void *v)
 
int imd_send_forces(void *s, int32 n, const float *forces)
 
int vmdsock_bind(void *v, int port)
 
int imd_recv_fcoords(void *s, int32 n, float *coords)
 
int imd_send_time(void *s, const IMDTime *time)
 
int imd_recv_mdcomm(void *s, int32 n, int32 *indices, float *forces)
 
int imd_sessioninfo(void *s, const IMDSessionInfo *info)
 
AtomIDList & modifyForcedAtoms()
 
void NAMD_die(const char *err_msg)
 
ForceList & modifyGroupForces()
 
int imd_handshake(void *s, const int IMDVersion)
 
IMDSessionInfo IMDsendsettings
 
ResizeArray< void * > clients
 
static UniqueSortedArray< vmdforce > vmdforces
 
void send_energies(IMDEnergies *)
 
void vmdsock_destroy(void *v)
 
void send_forces(int, FloatVector *)
 
int operator<(const vmdforce &v)
 
void del(int index, int num=1)
 
int imd_recv_energies(void *s, IMDEnergies *energies)
 
int operator==(const vmdforce &v)
 
IMDSessionInfo IMDsendsettings
 
IMDType imd_recv_header(void *s, int32 *length)
 
void set_transrate(int newrate)
 
void use_imd(GlobalMasterIMD *)
 
void send_fcoords(int, FloatVector *)
 
int imd_send_velocities(void *s, int32 n, const float *vels)
 
void * vmdsock_accept(void *v)