NAMD
Macros | Functions
Output.C File Reference
#include "largefiles.h"
#include <string.h>
#include <stdlib.h>
#include "InfoStream.h"
#include "IMDOutput.h"
#include "Output.h"
#include "dcdlib.h"
#include "strlib.h"
#include "Molecule.h"
#include "Node.h"
#include "Parameters.h"
#include "PDB.h"
#include "SimParameters.h"
#include "Vector.h"
#include "structures.h"
#include "MStream.h"
#include "Communicate.h"
#include "PatchMap.h"
#include "PatchMap.inl"
#include "ScriptTcl.h"
#include "Lattice.h"
#include "DataExchanger.h"
#include <fcntl.h>
#include <sys/stat.h>

Go to the source code of this file.

Macros

#define PATHSEPSTR   "/"
 
#define MKDIR(X)   mkdir(X,0777)
 
#define NAMD_open   NAMD_open64
 
#define NAMD_write   NAMD_write64
 
#define NAMD_close   NAMD_close64
 
#define O_LARGEFILE   0x0
 
#define seek_dcdfile   NAMD_seek
 
#define namdMyNode   Node::Object()
 
#define simParams   simParameters
 
#define pdbData   pdb
 
#define RAD2DEG   180.0/3.14159265359
 

Functions

int NAMD_open (const char *fname)
 
void NAMD_write (int fd, const char *buf, size_t count, const char *errmsg="NAMD_write64")
 
void NAMD_close (int fd, const char *fname)
 
static void lattice_to_unitcell (const Lattice *lattice, double *unitcell)
 
template<class xVector , class xDone >
void wrap_coor_int (xVector *coor, Lattice &lattice, xDone *done)
 
void wrap_coor (Vector *coor, Lattice &lattice, double *done)
 
void wrap_coor (FloatVector *coor, Lattice &lattice, float *done)
 

Macro Definition Documentation

#define MKDIR (   X)    mkdir(X,0777)

Definition at line 47 of file Output.C.

#define NAMD_close   NAMD_close64

Definition at line 52 of file Output.C.

Referenced by ofstream_namd::close().

#define NAMD_open   NAMD_open64

Definition at line 50 of file Output.C.

#define NAMD_write   NAMD_write64

Definition at line 51 of file Output.C.

#define namdMyNode   Node::Object()

Definition at line 126 of file Output.C.

#define O_LARGEFILE   0x0

Definition at line 55 of file Output.C.

Referenced by NAMD_open().

#define PATHSEPSTR   "/"

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

Definition at line 46 of file Output.C.

#define pdbData   pdb

Definition at line 128 of file Output.C.

#define RAD2DEG   180.0/3.14159265359

Definition at line 764 of file Output.C.

#define seek_dcdfile   NAMD_seek

Definition at line 123 of file Output.C.

#define simParams   simParameters

Definition at line 127 of file Output.C.

Referenced by ComputeCylindricalBC::ComputeCylindricalBC(), AngleElem::computeForce(), CrosstermElem::computeForce(), DihedralElem::computeForce(), ImproperElem::computeForce(), AnisoElem::computeForce(), TholeElem::computeForce(), BondElem::computeForce(), GromacsPairElem::computeForce(), ComputeFullDirect::ComputeFullDirect(), ComputeLCPO::ComputeLCPO(), ComputeRestraints::ComputeRestraints(), ComputeSphericalBC::ComputeSphericalBC(), ComputeStir::ComputeStir(), ComputeTclBC::ComputeTclBC(), Output::coordinate(), Output::coordinateNeeded(), LdbCoordinator::createLoadBalancer(), CudaComputeNonbonded::CudaComputeNonbonded(), ComputeEField::doForce(), ComputeConsTorque::doForce(), ComputeGridForce::doForce(), ComputeNonbondedPair::doForce(), ComputeNonbondedSelf::doForce(), ComputeRestraints::doForce(), ComputeTclBC::doWork(), ComputeNonbondedCUDA::doWork(), dumpbench(), ComputeNonbondedCUDA::finishReductions(), ComputeNonbondedCUDA::finishWork(), Output::force(), Output::forceNeeded(), Molecule::get_fep_bonded_type(), ComputePmeMgr::gridCalc2(), ComputePmeCUDA::initialize(), LdbCoordinator::initialize(), ComputePmeMgr::initialize(), ComputeMsmMgr::initialize(), ComputePmeMgr::initialize_pencils(), isPmeProcessor(), NamdHybridLB::NamdHybridLB(), ComputeNonbondedCUDA::noWork(), Molecule::num_deg_freedom(), Molecule::num_fixed_atoms(), Molecule::num_group_deg_freedom(), ComputeMsmSerialMgr::recvCoord(), ComputeExtMgr::recvCoord(), ComputeFmmSerialMgr::recvCoord(), ComputeNonbondedCUDA::recvYieldDevice(), ComputeNonbondedCUDA::registerPatches(), ComputeNonbondedUtil::select(), ComputeNonbondedCUDA::skip(), NamdHybridLB::splitComputes(), NamdCentLB::Strategy(), ComputeMgr::updateLocalComputes4(), Output::velocity(), Output::velocityNeeded(), wrap_coor_int(), and Controller::write_accelMDG_rest_file().

Function Documentation

static void lattice_to_unitcell ( const Lattice lattice,
double *  unitcell 
)
static

Definition at line 131 of file Output.C.

References Lattice::a(), Lattice::a_p(), Lattice::b(), Lattice::b_p(), Lattice::c(), Lattice::c_p(), and Vector::length().

131  {
132 
133  unitcell[0] = unitcell[2] = unitcell[5] = 0.0;
134  unitcell[1] = unitcell[3] = unitcell[4] = 0.0;
135 
136  if (lattice) {
137  const Vector &a=lattice->a();
138  const Vector &b=lattice->b();
139  const Vector &c=lattice->c();
140  unitcell[0] = (lattice->a_p()) ? a.length() : 0.0;
141  unitcell[2] = (lattice->b_p()) ? b.length() : 0.0;
142  unitcell[5] = (lattice->c_p()) ? c.length() : 0.0;
143  double cosAB = (lattice->a_p() && lattice->b_p() ) ?
144  (a*b)/(unitcell[0]*unitcell[2]) : 0.0;
145  double cosAC = (lattice->a_p() && lattice->c_p() ) ?
146  (a*c)/(unitcell[0]*unitcell[5]) : 0.0;
147  double cosBC = (lattice->b_p() && lattice->c_p() ) ?
148  (b*c)/(unitcell[2]*unitcell[5]) : 0.0;
149  if (cosAB > 1.0) cosAB = 1.0; else if (cosAB < -1.0) cosAB = -1.0;
150  if (cosAC > 1.0) cosAC = 1.0; else if (cosAC < -1.0) cosAC = -1.0;
151  if (cosBC > 1.0) cosBC = 1.0; else if (cosBC < -1.0) cosBC = -1.0;
152  unitcell[1] = cosAB;
153  unitcell[3] = cosAC;
154  unitcell[4] = cosBC;
155  }
156 }
Definition: Vector.h:64
BigReal length(void) const
Definition: Vector.h:169
Vector b() const
Definition: Lattice.h:253
int b_p() const
Definition: Lattice.h:274
int a_p() const
Definition: Lattice.h:273
Vector a() const
Definition: Lattice.h:252
Vector c() const
Definition: Lattice.h:254
int c_p() const
Definition: Lattice.h:275
void NAMD_close ( int  fd,
const char *  fname 
)

Definition at line 108 of file Output.C.

References NAMD_err().

108  {
109 #ifdef WIN32
110  while ( _close(fd) ) {
111 #else
112  while ( close(fd) ) {
113 #endif
114  if ( errno != EINTR ) {
115  char errmsg[1024];
116  sprintf(errmsg, "Error on closing file %s", fname);
117  NAMD_err(errmsg);
118  }
119  }
120 }
void NAMD_err(const char *err_msg)
Definition: common.C:102
int NAMD_open ( const char *  fname)

Definition at line 59 of file Output.C.

References NAMD_err(), and O_LARGEFILE.

59  {
60  int fd;
61 
62  // open the file and die if the open fails
63 #ifdef WIN32
64  while ( (fd = _open(fname, O_WRONLY|O_CREAT|O_EXCL|O_BINARY|O_LARGEFILE,_S_IREAD|_S_IWRITE)) < 0) {
65 #else
66 #ifdef NAMD_NO_O_EXCL
67  while ( (fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE,
68 #else
69  while ( (fd = open(fname, O_WRONLY|O_CREAT|O_EXCL|O_LARGEFILE,
70 #endif
71  S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) {
72 #endif
73  if ( errno != EINTR ) {
74  char errmsg[1024];
75  sprintf(errmsg, "Unable to open binary file %s", fname);
76  NAMD_err(errmsg);
77  }
78  }
79 
80  return fd;
81 }
void NAMD_err(const char *err_msg)
Definition: common.C:102
#define O_LARGEFILE
Definition: Output.C:55
void NAMD_write ( int  fd,
const char *  buf,
size_t  count,
const char *  errmsg = "NAMD_write64" 
)

Definition at line 84 of file Output.C.

References endi(), iout, iWARN(), NAMD_bug(), and NAMD_err().

84  {
85  double firsttime = 0.;
86  while ( count ) {
87 #if defined(WIN32) && !defined(__CYGWIN__)
88  long retval = _write(fd,buf,count);
89 #else
90  ssize_t retval = write(fd,buf,count);
91 #endif
92  if ( retval < 0 && errno == EINTR ) retval = 0;
93  if ( retval < 0 && errno == ENOMEM ) {
94  if ( firsttime == 0. ) firsttime = CmiWallTimer();
95  if ( (CmiWallTimer() - firsttime) < 300. ) retval = 0;
96  }
97  if ( retval < 0 ) NAMD_err(errmsg);
98  if ( retval > count ) NAMD_bug("extra bytes written in NAMD_write64()");
99  buf += retval;
100  count -= retval;
101  }
102  if ( firsttime != 0. ) {
103  iout << iWARN << errmsg << ": NAMD_write64() retried for " << (CmiWallTimer() - firsttime) << " seconds.\n" << endi;
104  }
105 }
void NAMD_err(const char *err_msg)
Definition: common.C:102
std::ostream & iWARN(std::ostream &s)
Definition: InfoStream.C:108
#define iout
Definition: InfoStream.h:87
void NAMD_bug(const char *err_msg)
Definition: common.C:123
infostream & endi(infostream &s)
Definition: InfoStream.C:38
void wrap_coor ( Vector coor,
Lattice lattice,
double *  done 
)

Definition at line 269 of file Output.C.

References wrap_coor_int().

Referenced by Output::coordinate().

269  {
270  wrap_coor_int(coor,lattice,done);
271 };
void wrap_coor_int(xVector *coor, Lattice &lattice, xDone *done)
Definition: Output.C:237
void wrap_coor ( FloatVector coor,
Lattice lattice,
float *  done 
)

Definition at line 273 of file Output.C.

References wrap_coor_int().

273  {
274  wrap_coor_int(coor,lattice,done);
275 };
void wrap_coor_int(xVector *coor, Lattice &lattice, xDone *done)
Definition: Output.C:237
template<class xVector , class xDone >
void wrap_coor_int ( xVector *  coor,
Lattice lattice,
xDone *  done 
)

Definition at line 237 of file Output.C.

References Molecule::get_cluster(), Molecule::get_clusterSize(), Molecule::is_water(), Node::molecule, Molecule::numAtoms, Node::Object(), Node::simParameters, simParams, Lattice::wrap_delta(), Lattice::wrap_nearest_delta(), SimParameters::wrapAll, SimParameters::wrapNearest, and SimParameters::wrapWater.

Referenced by wrap_coor().

237  {
239  if ( *done ) return;
240  *done = 1;
241  if ( ! ( simParams->wrapAll || simParams->wrapWater ) ) return;
242  const int wrapNearest = simParams->wrapNearest;
243  const int wrapAll = simParams->wrapAll;
244  Molecule *molecule = Node::Object()->molecule;
245  int n = molecule->numAtoms;
246  int i;
247 #ifndef MEM_OPT_VERSION
248  Position *con = new Position[n];
249  for ( i = 0; i < n; ++i ) {
250  con[i] = 0;
251  int ci = molecule->get_cluster(i);
252  con[ci] += coor[i];
253  }
254  for ( i = 0; i < n; ++i ) {
255  if ( ! wrapAll && ! molecule->is_water(i) ) continue;
256  int ci = molecule->get_cluster(i);
257  if ( ci == i ) {
258  Vector coni = con[i] / molecule->get_clusterSize(i);
259  Vector trans = ( wrapNearest ?
260  lattice.wrap_nearest_delta(coni) : lattice.wrap_delta(coni) );
261  con[i] = trans;
262  }
263  coor[i] = coor[i] + con[ci];
264  }
265  delete [] con;
266 #endif
267 }
static Node * Object()
Definition: Node.h:86
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
Vector wrap_delta(const Position &pos1) const
Definition: Lattice.h:206
int get_cluster(int anum) const
Definition: Molecule.h:1023
int numAtoms
Definition: Molecule.h:556
#define simParams
Definition: Output.C:127
Vector wrap_nearest_delta(Position pos1) const
Definition: Lattice.h:217
Bool is_water(int)
Molecule * molecule
Definition: Node.h:176
int get_clusterSize(int anum) const
Definition: Molecule.h:1024