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.

Defines

#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)


Define Documentation

#define MKDIR (  )     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.

#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 760 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 HomePatch::addForceToMomentum(), HomePatch::addForceToMomentum3(), HomePatch::addVelocityToPosition(), HomePatch::buildRattleList(), ComputePmeMgr::chargeGridSubmitted(), ComputeCylindricalBC::ComputeCylindricalBC(), ImproperElem::computeForce(), GromacsPairElem::computeForce(), DihedralElem::computeForce(), BondElem::computeForce(), AngleElem::computeForce(), ComputeFullDirect::ComputeFullDirect(), ComputeLCPO::ComputeLCPO(), ComputeMsm::ComputeMsm(), ComputePme::ComputePme(), ComputeRestraints::ComputeRestraints(), ComputeSphericalBC::ComputeSphericalBC(), ComputeStir::ComputeStir(), ComputeTclBC::ComputeTclBC(), Output::coordinate(), Output::coordinateNeeded(), ComputeMgr::createComputes(), LdbCoordinator::createLoadBalancer(), CudaComputeNonbonded::CudaComputeNonbonded(), ComputeStir::doForce(), ComputeRestraints::doForce(), ComputeNonbondedSelf::doForce(), ComputeNonbondedPair::doForce(), ComputeGridForce::doForce(), ComputeEField::doForce(), ComputeConsTorque::doForce(), HomePatch::doGroupSizeCheck(), HomePatch::doMarginCheck(), HomePatch::doPairlistCheck(), CudaComputeNonbonded::doWork(), ComputeTclBC::doWork(), ComputeNonbondedCUDA::doWork(), ComputeGBISser::doWork(), dumpbench(), HomePatch::exchangeAtoms(), HomePatch::exchangeCheckpoint(), OptPmeXPencil::fft_init(), OptPmeYPencil::fft_init(), OptPmeZPencil::fft_init(), PmeXPencil::fft_init(), PmeYPencil::fft_init(), PmeZPencil::fft_init(), CudaComputeNonbonded::finishReductions(), ComputeNonbondedCUDA::finishReductions(), ComputeNonbondedCUDA::finishWork(), Output::force(), Output::forceNeeded(), ComputePmeCUDADevice::gatherForce(), HomePatch::gbisComputeAfterP1(), HomePatch::gbisComputeAfterP2(), Molecule::get_fep_bonded_type(), ComputePmeMgr::gridCalc2(), HomePatch::hardWallDrude(), OptPmeMgr::initialize(), LdbCoordinator::initialize(), GridforceLiteGrid::initialize(), GridforceFullSubGrid::initialize(), GridforceFullMainGrid::initialize(), ComputePmeCUDA::initialize(), ComputePmeMgr::initialize(), ComputeMsmMgr::initialize(), ComputePmeMgr::initialize_computes(), OptPmeMgr::initialize_pencils(), ComputePmeMgr::initialize_pencils(), initializePmeGrid(), isPmeProcessor(), CudaComputeNonbonded::launchWork(), HomePatch::loweAndersenVelocities(), WorkDistrib::mapComputes(), HomePatch::minimize_rattle2(), HomePatch::mollyAverage(), HomePatch::mollyMollify(), NamdHybridLB::NamdHybridLB(), GridforceGrid::new_grid(), ComputeNonbondedCUDA::noWork(), Molecule::num_deg_freedom(), Molecule::num_fixed_atoms(), Molecule::num_group_deg_freedom(), OptPmeCompute::OptPmeCompute(), Parameters::Parameters(), HomePatch::positionsReady(), HomePatch::qmSwapAtoms(), HomePatch::rattle1(), HomePatch::rattle1old(), HomePatch::rattle2(), Parameters::read_ener_table(), recursive_bisect_with_curve(), ComputePmeCUDADevice::recvAtoms(), HomePatch::recvCheckpointLoad(), ComputeMsmSerialMgr::recvCoord(), ComputeFmmSerialMgr::recvCoord(), ComputeExtMgr::recvCoord(), OptPmeMgr::recvEvir(), ComputeNonbondedCUDA::recvYieldDevice(), ComputeNonbondedCUDA::registerPatches(), GridforceLiteGrid::reinitialize(), GridforceFullMainGrid::reinitialize(), ScriptTcl::run(), ComputeNonbondedUtil::select(), SELF(), HomePatch::setGBISIntrinsicRadii(), ComputePmeCUDAMgr::setupPencils(), ComputeNonbondedCUDA::skip(), NamdHybridLB::splitComputes(), ComputePmeCUDADevice::spreadCharge(), NamdCentLB::Strategy(), OptPmeXPencil::submit_evir(), ComputePmeMgr::submitReductions(), ComputePme::ungridForces(), OptPmeCompute::ungridForces_compute(), OptPmeCompute::ungridForces_finalize(), 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().

00131                                                                           {
00132    if (lattice && lattice->a_p() && lattice->b_p() && lattice->c_p()) {
00133       const Vector &a=lattice->a();
00134       const Vector &b=lattice->b();
00135       const Vector &c=lattice->c();
00136       unitcell[0] = a.length();
00137       unitcell[2] = b.length();
00138       unitcell[5] = c.length();
00139       double cosAB = (a*b)/(unitcell[0]*unitcell[2]);
00140       double cosAC = (a*c)/(unitcell[0]*unitcell[5]);
00141       double cosBC = (b*c)/(unitcell[2]*unitcell[5]);
00142       if (cosAB > 1.0) cosAB = 1.0; else if (cosAB < -1.0) cosAB = -1.0;
00143       if (cosAC > 1.0) cosAC = 1.0; else if (cosAC < -1.0) cosAC = -1.0;
00144       if (cosBC > 1.0) cosBC = 1.0; else if (cosBC < -1.0) cosBC = -1.0;
00145       unitcell[1] = cosAB;
00146       unitcell[3] = cosAC;
00147       unitcell[4] = cosBC;
00148    } else {
00149       unitcell[0] = unitcell[2] = unitcell[5] = 1.0;
00150       unitcell[1] = unitcell[3] = unitcell[4] = 0.0;
00151    }
00152 }

void NAMD_close ( int  fd,
const char *  fname 
)

Definition at line 108 of file Output.C.

References NAMD_err().

00108                                            {
00109 #ifdef WIN32
00110   while ( _close(fd) ) {
00111 #else
00112   while ( close(fd) ) {
00113 #endif
00114     if ( errno != EINTR ) {
00115       char errmsg[1024];
00116       sprintf(errmsg, "Error on closing file %s", fname);
00117       NAMD_err(errmsg);
00118     }
00119   }
00120 }

int NAMD_open ( const char *  fname  ) 

Definition at line 59 of file Output.C.

References NAMD_err(), and O_LARGEFILE.

00059                                  {
00060   int fd;
00061 
00062   //  open the file and die if the open fails
00063 #ifdef WIN32
00064   while ( (fd = _open(fname, O_WRONLY|O_CREAT|O_EXCL|O_BINARY|O_LARGEFILE,_S_IREAD|_S_IWRITE)) < 0) {
00065 #else
00066 #ifdef NAMD_NO_O_EXCL
00067   while ( (fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE,
00068 #else
00069   while ( (fd = open(fname, O_WRONLY|O_CREAT|O_EXCL|O_LARGEFILE,
00070 #endif
00071                            S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) {
00072 #endif
00073     if ( errno != EINTR ) {
00074       char errmsg[1024];
00075       sprintf(errmsg, "Unable to open binary file %s", fname);
00076       NAMD_err(errmsg);
00077     }
00078   }
00079 
00080   return fd;
00081 }

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().

00084                                                                                           {
00085   double firsttime = 0.;
00086   while ( count ) {
00087 #if defined(WIN32) && !defined(__CYGWIN__)
00088     long retval = _write(fd,buf,count);
00089 #else
00090     ssize_t retval = write(fd,buf,count);
00091 #endif
00092     if ( retval < 0 && errno == EINTR ) retval = 0;
00093     if ( retval < 0 && errno == ENOMEM ) {
00094       if ( firsttime == 0. ) firsttime = CmiWallTimer();
00095       if ( (CmiWallTimer() - firsttime) < 300. ) retval = 0;
00096     }
00097     if ( retval < 0 ) NAMD_err(errmsg);
00098     if ( retval > count ) NAMD_bug("extra bytes written in NAMD_write64()");
00099     buf += retval;
00100     count -= retval;
00101   }
00102   if ( firsttime != 0. ) {
00103     iout << iWARN << errmsg << ": NAMD_write64() retried for " << (CmiWallTimer() - firsttime) << " seconds.\n" << endi;
00104   }
00105 }

void wrap_coor ( FloatVector coor,
Lattice lattice,
float *  done 
)

Definition at line 269 of file Output.C.

References wrap_coor_int().

00269                                                                  {
00270   wrap_coor_int(coor,lattice,done);
00271 };

void wrap_coor ( Vector coor,
Lattice lattice,
double *  done 
)

Definition at line 265 of file Output.C.

References wrap_coor_int().

Referenced by Output::coordinate().

00265                                                              {
00266   wrap_coor_int(coor,lattice,done);
00267 };

template<class xVector, class xDone>
void wrap_coor_int ( xVector *  coor,
Lattice lattice,
xDone *  done 
)

Definition at line 233 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(), and Lattice::wrap_nearest_delta().

Referenced by wrap_coor().

00233                                                                  {
00234   SimParameters *simParams = Node::Object()->simParameters;
00235   if ( *done ) return;
00236   *done = 1;
00237   if ( ! ( simParams->wrapAll || simParams->wrapWater ) ) return;
00238   const int wrapNearest = simParams->wrapNearest;
00239   const int wrapAll = simParams->wrapAll;
00240   Molecule *molecule = Node::Object()->molecule;
00241   int n = molecule->numAtoms;
00242   int i;
00243 #ifndef MEM_OPT_VERSION
00244   Position *con = new Position[n];
00245   for ( i = 0; i < n; ++i ) {
00246     con[i] = 0;
00247     int ci = molecule->get_cluster(i);
00248     con[ci] += coor[i];
00249   }
00250   for ( i = 0; i < n; ++i ) {
00251     if ( ! wrapAll && ! molecule->is_water(i) ) continue;
00252     int ci = molecule->get_cluster(i);
00253     if ( ci == i ) {
00254       Vector coni = con[i] / molecule->get_clusterSize(i);
00255       Vector trans = ( wrapNearest ?
00256         lattice.wrap_nearest_delta(coni) : lattice.wrap_delta(coni) );
00257       con[i] = trans;
00258     }
00259     coor[i] = coor[i] + con[ci];
00260   }
00261   delete [] con;
00262 #endif
00263 }


Generated on Thu Nov 23 01:17:16 2017 for NAMD by  doxygen 1.4.7