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 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 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(), TholeElem::computeForce(), ImproperElem::computeForce(), GromacsPairElem::computeForce(), DihedralElem::computeForce(), CrosstermElem::computeForce(), BondElem::computeForce(), AnisoElem::computeForce(), AngleElem::computeForce(), ComputeFullDirect::ComputeFullDirect(), ComputeLCPO::ComputeLCPO(), ComputeRestraints::ComputeRestraints(), ComputeSphericalBC::ComputeSphericalBC(), ComputeStir::ComputeStir(), ComputeTclBC::ComputeTclBC(), Output::coordinate(), Output::coordinateNeeded(), LdbCoordinator::createLoadBalancer(), CudaComputeNonbonded::CudaComputeNonbonded(), ComputeRestraints::doForce(), ComputeNonbondedSelf::doForce(), ComputeNonbondedPair::doForce(), ComputeGridForce::doForce(), ComputeEField::doForce(), ComputeConsTorque::doForce(), ComputeTclBC::doWork(), ComputeNonbondedCUDA::doWork(), dumpbench(), ComputeNonbondedCUDA::finishReductions(), ComputeNonbondedCUDA::finishWork(), Output::force(), Output::forceNeeded(), Molecule::get_fep_bonded_type(), ComputePmeMgr::gridCalc2(), LdbCoordinator::initialize(), ComputePmeCUDA::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(), ComputeFmmSerialMgr::recvCoord(), ComputeExtMgr::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().

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

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 273 of file Output.C.

References wrap_coor_int().

00273                                                                  {
00274   wrap_coor_int(coor,lattice,done);
00275 };

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

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

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

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

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


Generated on 19 Sep 2019 for NAMD by  doxygen 1.6.1