common.h File Reference

#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#include "converse.h"

Go to the source code of this file.

Defines

#define COULOMB   332.0636
#define BOLTZMANN   0.001987191
#define TIMEFACTOR   48.88821
#define PRESSUREFACTOR   6.95E4
#define PDBVELFACTOR   20.45482706
#define PDBVELINVFACTOR   (1.0/PDBVELFACTOR)
#define PNPERKCALMOL   69.479
#define mynearbyint(x)   floor((x)+0.5)
#define PI   3.141592653589793
#define TWOPI   2.0 * PI
#define ONE   1.000000000000000
#define ZERO   0.000000000000000
#define SMALLRAD   0.0005
#define SMALLRAD2   SMALLRAD*SMALLRAD
#define FALSE   0
#define TRUE   1
#define NO   0
#define YES   1
#define STRINGNULL   '\0'
#define MAX_NEIGHBORS   27
#define SIMPARAMSTAG   100
#define STATICPARAMSTAG   101
#define MOLECULETAG   102
#define FULLTAG   104
#define FULLFORCETAG   105
#define DPMTATAG   106
#define GRIDFORCEGRIDTAG   107
#define COMPUTEMAPTAG   108
#define CYCLE_BARRIER   0
#define PME_BARRIER   0
#define STEP_BARRIER   0
#define USE_BARRIER   (CYCLE_BARRIER || PME_BARRIER || STEP_BARRIER)
#define NAMD_SeparateWaters   0
#define NAMD_ComputeNonbonded_SortAtoms   1
#define NAMD_ComputeNonbonded_SortAtoms_LessBranches   1
#define WAT_TIP3   0
#define WAT_TIP4   1
#define WAT_SWM4   2

Typedefs

typedef long long int64
typedef float Real
typedef double BigReal
typedef int Bool

Functions

void NAMD_quit (const char *)
void NAMD_die (const char *)
void NAMD_err (const char *)
void NAMD_bug (const char *)
int NAMD_file_exists (const char *filename)
void NAMD_backup_file (const char *filename, const char *extension=0)
int NAMD_open_text (const char *fname, int append=0)
void NAMD_write (int fd, const char *buf, size_t count, const char *fname="in NAMD_write()")
void NAMD_close (int fd, const char *fname)
char * NAMD_stringdup (const char *)
FILE * Fopen (const char *filename, const char *mode)
int Fclose (FILE *fout)


Define Documentation

#define BOLTZMANN   0.001987191

Definition at line 45 of file common.h.

Referenced by Controller::Controller(), HomePatch::hardWallDrude(), Controller::langevinPiston1(), Controller::langevinPiston2(), Sequencer::langevinVelocities(), Sequencer::langevinVelocitiesBBK2(), Controller::multigatorCalcEnthalpy(), Controller::multigratorPressure(), Controller::multigratorTemperature(), Controller::outputFepEnergy(), Sequencer::reassignVelocities(), Controller::receivePressure(), Sequencer::reinitVelocities(), SELF(), and Controller::writeFepEnergyData().

#define COMPUTEMAPTAG   108

Definition at line 138 of file common.h.

Referenced by WorkDistrib::recvComputeMapChanges().

#define COULOMB   332.0636

Definition at line 44 of file common.h.

Referenced by ComputeNonbondedUtil::calcGBIS(), ExclElem::computeForce(), ComputeMsm::ComputeMsm(), ComputePme::doWork(), ComputeNonbondedCUDA::doWork(), ComputeEwald::doWork(), HomePatch::gbisComputeAfterP2(), HomePatch::positionsReady(), ComputeMsmSerialMgr::recvCoord(), ComputeFmmSerialMgr::recvCoord(), ComputeQMMgr::recvPntChrg(), scale_n_copy_coordinates(), and SELF().

#define CYCLE_BARRIER   0

Definition at line 140 of file common.h.

#define DPMTATAG   106

Definition at line 136 of file common.h.

#define FALSE   0

Definition at line 97 of file common.h.

Referenced by Molecule::atoms_1to4(), ParseOptions::check_consistency(), GridforceFullMainGrid::compute_b(), ComputeCylindricalBC::ComputeCylindricalBC(), ComputeSphericalBC::ComputeSphericalBC(), ConfigList::ConfigList(), WorkDistrib::createAtomLists(), ParseOptions::DataElement::DataElement(), ParseOptions::defined(), PDBData::field(), ParseOptions::get(), Parameters::get_table_pair_params(), Parameters::get_vdw_pair_params(), Molecule::go_restricted(), GridforceFullBaseGrid::GridforceFullBaseGrid(), GridforceFullSubGrid::initialize(), GridforceFullMainGrid::initialize(), Molecule::is_atom_constorqued(), Molecule::is_atom_constrained(), Molecule::is_atom_gridforced(), Molecule::is_atom_movdragged(), Molecule::is_atom_rotdragged(), Molecule::is_atom_stirred(), MGridforceParams::MGridforceParams(), Parameters::Parameters(), Molecule::read_go_file(), Vector::set(), ParseOptions::set(), and ParseOptions::units().

#define FULLFORCETAG   105

Definition at line 135 of file common.h.

#define FULLTAG   104

Definition at line 134 of file common.h.

#define GRIDFORCEGRIDTAG   107

Definition at line 137 of file common.h.

Referenced by Node::reloadGridforceGrid().

#define MAX_NEIGHBORS   27

Definition at line 110 of file common.h.

#define MOLECULETAG   102

Definition at line 133 of file common.h.

Referenced by Node::resendMolecule().

#define mynearbyint ( x   )     floor((x)+0.5)

Definition at line 58 of file common.h.

Referenced by ALCHPAIR(), Parameters::read_ener_table(), Parameters::read_energy_type(), Parameters::read_energy_type_bothcubspline(), and Parameters::read_energy_type_cubspline().

#define NAMD_ComputeNonbonded_SortAtoms   1

Definition at line 165 of file common.h.

Referenced by SELF().

#define NAMD_ComputeNonbonded_SortAtoms_LessBranches   1

Definition at line 166 of file common.h.

#define NAMD_SeparateWaters   0

Definition at line 152 of file common.h.

#define NO   0

Definition at line 102 of file common.h.

#define ONE   1.000000000000000

Definition at line 70 of file common.h.

#define PDBVELFACTOR   20.45482706

Definition at line 48 of file common.h.

Referenced by ParallelIOMgr::bcastMolInfo(), and Sequencer::maximumMove().

#define PDBVELINVFACTOR   (1.0/PDBVELFACTOR)

Definition at line 49 of file common.h.

#define PI   3.141592653589793

Definition at line 62 of file common.h.

Referenced by calcOverlap(), ImproperElem::computeForce(), DihedralElem::computeForce(), CrosstermElem::computeForce(), crossterm_setup(), ComputeEField::doForce(), GromacsTopFile::GromacsTopFile(), proc_getangle(), proc_getdihedral(), and vec_rotation_matrix().

#define PME_BARRIER   0

Definition at line 141 of file common.h.

#define PNPERKCALMOL   69.479

Definition at line 50 of file common.h.

#define PRESSUREFACTOR   6.95E4

Definition at line 47 of file common.h.

Referenced by PressureProfileReduction::getData(), Controller::printEnergies(), Controller::receivePressure(), Controller::rescaleaccelMD(), and SimParameters::scriptSet().

#define SIMPARAMSTAG   100

Definition at line 131 of file common.h.

#define SMALLRAD   0.0005

Definition at line 78 of file common.h.

#define SMALLRAD2   SMALLRAD*SMALLRAD

Definition at line 82 of file common.h.

#define STATICPARAMSTAG   101

Definition at line 132 of file common.h.

Referenced by Node::resendMolecule().

#define STEP_BARRIER   0

Definition at line 142 of file common.h.

#define STRINGNULL   '\0'

Definition at line 107 of file common.h.

Referenced by ParseOptions::get(), NAMD_find_first_word(), NAMD_pad(), NAMD_read_int(), NAMD_read_line(), NAMD_remove_comment(), and NAMD_truncate().

#define TIMEFACTOR   48.88821

Definition at line 46 of file common.h.

Referenced by HomePatch::addForceToMomentum(), HomePatch::addForceToMomentum3(), Sequencer::addMovDragToPosition(), Sequencer::addRotDragToPosition(), HomePatch::addVelocityToPosition(), Sequencer::correctMomentum(), HomePatch::hardWallDrude(), Sequencer::maximumMove(), Sequencer::minimize(), HomePatch::minimize_rattle2(), Sequencer::newMinimizeDirection(), HomePatch::rattle1(), HomePatch::rattle1old(), HomePatch::rattle2(), ComputeQMMgr::recvPartQM(), SELF(), and Sequencer::submitMinimizeReductions().

#define TRUE   1

Definition at line 98 of file common.h.

Referenced by Molecule::atoms_1to4(), ParseOptions::check_consistency(), GridforceFullMainGrid::compute_b(), ComputeCylindricalBC::ComputeCylindricalBC(), ComputeSphericalBC::ComputeSphericalBC(), ConfigList::ConfigList(), WorkDistrib::createAtomLists(), ParseOptions::defined(), Parameters::done_reading_files(), PDBData::field(), ParseOptions::get(), Parameters::get_table_pair_params(), Parameters::get_vdw_pair_params(), Molecule::go_restricted(), GridforceFullSubGrid::initialize(), GridforceFullMainGrid::initialize(), MGridforceParams::MGridforceParams(), ParseOptions::ParseOptions(), Molecule::read_go_file(), Parameters::receive_Parameters(), Vector::set(), ParseOptions::set(), and ParseOptions::units().

#define TWOPI   2.0 * PI

Definition at line 66 of file common.h.

Referenced by ImproperElem::computeForce(), DihedralElem::computeForce(), and ComputeEField::doForce().

#define USE_BARRIER   (CYCLE_BARRIER || PME_BARRIER || STEP_BARRIER)

Definition at line 144 of file common.h.

#define WAT_SWM4   2

Definition at line 171 of file common.h.

Referenced by HomePatch::buildRattleList(), HomePatch::minimize_rattle2(), HomePatch::rattle1old(), and HomePatch::rattle2().

#define WAT_TIP3   0

Definition at line 169 of file common.h.

Referenced by HomePatch::rattle1().

#define WAT_TIP4   1

Definition at line 170 of file common.h.

Referenced by HomePatch::buildRattleList(), HomePatch::minimize_rattle2(), Molecule::num_deg_freedom(), HomePatch::rattle1old(), and HomePatch::rattle2().

#define YES   1

Definition at line 103 of file common.h.

#define ZERO   0.000000000000000

Definition at line 74 of file common.h.

Referenced by ComputeNonbondedUtil::calcGBIS().


Typedef Documentation

typedef double BigReal

Definition at line 93 of file common.h.

typedef int Bool

Definition at line 112 of file common.h.

typedef long long int64

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

Definition at line 34 of file common.h.

typedef float Real

Definition at line 88 of file common.h.


Function Documentation

int Fclose ( FILE *  fout  ) 

Definition at line 350 of file common.C.

Referenced by ConfigList::ConfigList(), parm::genclose(), PDB::PDB(), read_binary_file(), and Parameters::read_parameter_file().

00351 {
00352   int rc = -1;
00353 #if !defined(NOCOMPRESSED)
00354   rc = pclose(fout);
00355 #endif
00356   if (rc == -1) // stream not associated with a popen()
00357     {
00358     rc = fclose(fout);
00359     }
00360   return rc;
00361 } /* Fclose() */

FILE* Fopen ( const char *  filename,
const char *  mode 
)

Definition at line 256 of file common.C.

References endi(), and iout.

Referenced by ConfigList::ConfigList(), parm::genopen(), GridforceFullMainGrid::initialize(), PDB::PDB(), read_binary_file(), and Parameters::read_parameter_file().

00257 {
00258   struct stat buf;
00259   // check if basic filename exists (and not a directory)
00260 
00261 #if defined(NOCOMPRESSED)
00262   if (!stat(filename,&buf))
00263     {
00264       FILE *rval;
00265       while ( ! (rval = fopen(filename,mode)) ) {
00266         if ( errno != EINTR ) break;
00267       }
00268       return(rval);
00269     }
00270 #else
00271   if (!stat(filename,&buf))
00272     {
00273       if (!S_ISDIR(buf.st_mode)) {
00274         FILE *rval;
00275         while ( ! (rval = fopen(filename,mode)) ) {
00276           if ( errno != EINTR ) break;
00277         }
00278         return(rval);
00279       }
00280     }
00281   // check for a compressed file
00282   char *realfilename;
00283   char *command;
00284   FILE *fout;
00285   command = (char *)malloc(strlen(filename)+25);
00286   // check for .Z (unix compress)
00287   sprintf(command,"zcat %s.Z",filename);
00288   realfilename = command+5;
00289   iout << "Command = " << command << "\n" << endi;
00290   iout << "Filename.Z = " << realfilename << "\n" << endi;
00291   if (!stat(realfilename,&buf))
00292         {
00293         if (!S_ISDIR(buf.st_mode))
00294                 {
00295                 fout = popen(command,mode);
00296                 // on HP-UX, the first character(s) out of pipe may be
00297                 // garbage!  (Argh!)
00298                 int C;
00299                 do
00300                   {
00301                   C = fgetc(fout);
00302                   // iout << "C is " << C << "\n" << endi;
00303                   if (isalnum(C) || isspace(C))
00304                         {
00305                         ungetc(C,fout);
00306                         C = -1; // outta loop
00307                         }
00308                   } while(C != -1);
00309                 free(command);
00310                 return(fout);
00311                 }
00312         }
00313   // check for .gz (gzip)
00314   sprintf(command,"gzip -d -c %s.gz",filename);
00315   realfilename = command+11;
00316   iout << "Command = " << command << "\n" << endi;
00317   iout << "Filename.gz = " << realfilename << "\n" << endi;
00318   if (!stat(realfilename,&buf))
00319         {
00320         if (!S_ISDIR(buf.st_mode))
00321                 {
00322                 fout = popen(command,mode);
00323                 // on HP-UX, the first character(s) out of pipe may be
00324                 // garbage!  (Argh!)
00325                 int C;
00326                 do
00327                   {
00328                   C = fgetc(fout);
00329                   // iout << "C is " << C << "\n" << endi;
00330                   if (isalnum(C) || isspace(C))
00331                         {
00332                         ungetc(C,fout);
00333                         C = -1; // outta loop
00334                         }
00335                   } while(C != -1);
00336                 free(command);
00337                 return(fout);
00338                 }
00339         }
00340   free(command);
00341 #endif /* !defined(NOCOMPRESSED) */
00342 
00343   return(NULL);
00344 } /* Fopen() */

void NAMD_backup_file ( const char *  filename,
const char *  extension = 0 
)

Definition at line 150 of file common.C.

References endi(), iERROR(), iout, and NAMD_file_exists().

Referenced by colvarproxy_namd::backup_file(), ofstream_namd::open(), open_dcd_write(), Controller::outputExtendedSystem(), Controller::outputFepEnergy(), Controller::outputTiEnergy(), CollectionMaster::receiveDataStream(), and Controller::write_accelMDG_rest_file().

00151 {
00152   if (NAMD_file_exists(filename)) {
00153     if ( ! extension ) extension = ".BAK";
00154     char *backup = new char[strlen(filename)+strlen(extension)+1];
00155     strcpy(backup, filename);
00156     strcat(backup, extension);
00157 #if defined(WIN32) && !defined(__CYGWIN__)
00158     if ( remove(backup) ) if ( errno != ENOENT ) {
00159       char *sys_err_msg = strerror(errno);
00160       if ( ! sys_err_msg ) sys_err_msg = "(unknown error)";
00161       iout << iERROR << "Error on removing file "
00162         << backup << ": " << sys_err_msg << "\n" << endi;
00163       fflush(stdout);
00164     }
00165 #endif
00166     while ( rename(filename,backup) )
00167     {
00168       if ( errno == EINTR ) continue;
00169       char *sys_err_msg = strerror(errno);
00170       if ( ! sys_err_msg ) sys_err_msg = "(unknown error)";
00171       iout << iERROR << "Error on renaming file " << filename
00172         << " to " << backup << ": " << sys_err_msg << "\n" << endi;
00173       fflush(stdout);
00174       if ( errno == EXDEV ) continue;
00175       break;
00176       // char errmsg[256];
00177       // sprintf(errmsg, "Error on renaming file %s to %s",filename,backup);
00178       // NAMD_err(errmsg);
00179     }
00180     delete [] backup;
00181   }
00182 }

void NAMD_bug ( const char *   ) 

Definition at line 117 of file common.C.

Referenced by Controller::algorithm(), Sequencer::algorithm(), CudaComputeNonbonded::assignPatches(), CudaComputeNonbonded::assignPatchesOnPe(), PmePencilXYZ::backwardDone(), LdbCoordinator::barrier(), ComputeNonbondedCUDA::build_exclusions(), ComputeNonbondedCUDA::build_lj_table(), HomePatch::buildSpanningTree(), ReductionMgr::buildSpanTree(), ComputeNonbondedUtil::calc_error(), Controller::calcPressure(), ComputePmeMgr::chargeGridReady(), checkSum(), Box< Patch, CompAtom >::close(), ofstream_namd::close(), Controller::compareChecksums(), ComputeCUDAMgr::ComputeCUDAMgr(), ComputeNonbondedCUDA::ComputeNonbondedCUDA(), ComputePmeCUDAMgr::ComputePmeCUDAMgr(), ComputeTclBC::ComputeTclBC(), CudaPmeTranspose::copyDataDeviceToDevice(), CudaPmeTranspose::copyDataDeviceToHost(), CudaPmeTranspose::copyDataHostToDevice(), WorkDistrib::createAtomLists(), ComputeCUDAMgr::createCudaComputeNonbonded(), ComputePmeCUDAMgr::createDevicesAndAtomFiler(), CsmAckHandler(), CsmHandler(), cuda_check_local_progress(), cuda_check_pme_charges(), cuda_check_pme_forces(), cuda_check_remote_progress(), cudaNAMD_bug(), CudaPmeRealSpaceCompute::CudaPmeRealSpaceCompute(), MigrateAtomsCombinedMsg::distribute(), ComputeGridForce::doForce(), HomePatch::doGroupSizeCheck(), ComputeNonbondedCUDA::doWork(), CudaComputeNonbonded::doWork(), WorkDistrib::enqueueAngles(), WorkDistrib::enqueueAniso(), WorkDistrib::enqueueBonds(), WorkDistrib::enqueueCrossterms(), WorkDistrib::enqueueDihedrals(), WorkDistrib::enqueueExcls(), WorkDistrib::enqueueGromacsPair(), WorkDistrib::enqueueImpropers(), WorkDistrib::enqueueLCPO(), WorkDistrib::enqueuePme(), WorkDistrib::enqueueSelfA1(), WorkDistrib::enqueueSelfA2(), WorkDistrib::enqueueSelfA3(), WorkDistrib::enqueueSelfB1(), WorkDistrib::enqueueSelfB2(), WorkDistrib::enqueueSelfB3(), WorkDistrib::enqueueThole(), WorkDistrib::enqueueWork(), WorkDistrib::enqueueWorkA1(), WorkDistrib::enqueueWorkA2(), WorkDistrib::enqueueWorkA3(), WorkDistrib::enqueueWorkB1(), WorkDistrib::enqueueWorkB2(), WorkDistrib::enqueueWorkB3(), WorkDistrib::enqueueWorkC(), ScriptTcl::eval(), ComputeMap::extendPtrs(), findRecipEvirPe(), CudaComputeNonbonded::finishReductions(), ofstream_namd::flush(), PmeAtomStorage::getAtomIndex(), getBlockDim(), CudaPmeTranspose::getBuffer(), ComputeCUDAMgr::getComputeCUDAMgr(), ComputeCUDAMgr::getCudaComputeNonbonded(), ComputePmeCUDAMgr::getDevice(), ComputePmeCUDAMgr::getDevicePencilY(), ComputePmeCUDAMgr::getDevicePencilZ(), ParseOptions::getfromptr(), ComputePmeCUDAMgr::getHomePencil(), Communicate::getMessage(), ComputePmeCUDAMgr::getNode(), getPencilDim(), GridforceFullBaseGrid::grid_index(), FFTCompute::init(), ComputeHomePatch::initialize(), ComputePatch::initialize(), ComputePmeMgr::initialize(), ComputePme::initialize(), ComputePmeCUDA::initialize(), LdbCoordinator::initialize(), ParallelIOMgr::initialize(), ComputePmeMgr::initialize_computes(), IRSet::insert(), ParseOptions::issetfromptr(), ParseOptions::istruefromptr(), CudaComputeNonbonded::launchWork(), LdbCoordinator::LdbCoordinator(), ScriptTcl::load(), NamdState::loadStructure(), PatchMap::makePatches(), CudaComputeNonbonded::messageEnqueueWork(), WorkDistrib::messageEnqueueWork(), WorkDistrib::messageFinishCUDA(), WorkDistrib::messageFinishMIC(), HomePatch::minimize_rattle2(), Sequencer::multigratorPressure(), NAMD_write(), Node::Node(), Box< Patch, CompAtom >::open(), ofstream_namd::open(), CudaComputeNonbonded::openBoxesOnPe(), PatchMap::pack(), PatchMgr::PatchMgr(), CudaComputeNonbonded::patchReady(), PmePencilX::PmePencilX(), PmePencilXY::PmePencilXY(), PmePencilXYZ::PmePencilXYZ(), PmePencilY::PmePencilY(), PmePencilZ::PmePencilZ(), PmeTranspose::PmeTranspose(), ComputePmeMgr::pollChargeGridReady(), ComputePmeMgr::pollForcesReady(), PmePencilMap::populateInitial(), PmePencilXYZMap::populateInitial(), PmePencilXMap::populateInitial(), PmePencilXYMap::populateInitial(), Controller::printEnergies(), Rebalancer::printLoads(), PmePencilXMap::procNum(), PmePencilXYMap::procNum(), ProxyMgr::ProxyMgr(), HomePatch::rattle2(), Sequencer::reassignVelocities(), ProxyPatch::receiveAll(), ProxyPatch::receiveData(), recursive_bisect_with_curve(), ComputePmeMgr::recvAck(), recvAck(), ComputePmeCUDADevice::recvAtoms(), ComputePmeCUDADevice::recvAtomsFromNeighbor(), recvBcast(), BroadcastMgr::recvBroadcast(), PatchMgr::recvCheckpointAck(), HomePatch::recvCheckpointLoad(), PatchMgr::recvCheckpointReq(), WorkDistrib::recvComputeMapChanges(), recvData(), GlobalMasterServer::recvData(), ComputePmeCUDAMgr::recvDevices(), recvEvalCommand(), recvEvalResult(), PatchMgr::recvExchangeReq(), ComputePmeCUDADevice::recvForcesFromNeighbor(), ComputePmeMgr::recvGrid(), ComputeQMMgr::recvPartQM(), ComputePmeMgr::recvRecipEvir(), Output::recvReplicaDcdData(), ComputeGlobal::recvResults(), ProxyMgr::recvResults(), NodePmeMgr::recvUngrid(), ComputePmeMgr::recvUngrid(), OptPmeMgr::recvUngrid(), ReductionSet::ReductionSet(), register_cuda_compute_pair(), register_cuda_compute_self(), AtomMapper::registerIDsCompAtomExt(), AtomMapper::registerIDsFullAtom(), registerUserEventsForAllComputeObjs(), Node::reloadGridforceGrid(), ReductionMgr::remoteSubmit(), IRSet::remove(), replica_bcast(), replica_min_double(), CollectionMaster::CollectVectorInstance::reset(), CollectionMgr::CollectVectorInstance::reset(), WorkDistrib::saveComputeMap(), ComputeGlobal::saveTotalForces(), Sequencer::scalePositionsVelocities(), ComputeNonbondedUtil::select(), SELF(), PatchMgr::sendAtoms(), NodePmeMgr::sendDataHelper(), ComputePmeMgr::sendDataPart(), Communicate::sendMessage(), PatchMgr::sendMovePatches(), PatchMgr::sendOneHomePatch(), NodePmeMgr::sendPencilsHelper(), ComputePmeMgr::sendPencilsPart(), CudaPmeTranspose::setDataPtrsYZX(), CudaPmeTranspose::setDataPtrsZXY(), ComputePmeCUDADevice::setPencilProxy(), ComputePmeCUDAMgr::setupPencils(), SimpleBroadcastObject< Tensor >::SimpleBroadcastObject(), Box< Patch, CompAtom >::skip(), CudaComputeNonbonded::skipPatchesOnPe(), CudaPmeKSpaceCompute::solve(), Node::startup(), ComputeMap::storeCompute(), ComputePmeCUDA::storePmeForceMsg(), ComputePmeMgr::submitReductions(), PmePencilXYZ::submitReductions(), PmePencilZ::submitReductions(), Sync::Sync(), TopoManagerWrapper::TopoManagerWrapper(), CudaPmeTranspose::transposeXYZtoYZX(), CudaPmeTranspose::transposeXYZtoZXY(), IRSet::unchecked_insert(), ComputePme::ungridForces(), ComputeMap::unpack(), GridforceGrid::unpack_grid(), unregister_cuda_compute(), CudaComputeNonbonded::unregisterBoxesOnPe(), AtomMapper::unregisterIDsCompAtomExt(), AtomMapper::unregisterIDsFullAtom(), ComputeMgr::updateComputes(), Node::updateGridScale(), WorkDistrib::WorkDistrib(), AtomMapper::~AtomMapper(), and Rebalancer::~Rebalancer().

00119 {
00120    if ( ! err_msg ) err_msg = "(unknown error)";
00121    const char *bug_msg = 
00122      "FATAL ERROR: See http://www.ks.uiuc.edu/Research/namd/bugreport.html";
00123    char *new_err_msg = new char[strlen(err_msg) + 40 + strlen(bug_msg)];
00124    sprintf(new_err_msg,"FATAL ERROR: %s\n%s\n",err_msg,bug_msg);
00125    CkPrintf(new_err_msg);
00126    fflush(stdout);
00127    if ( CmiNumPartitions() > 1 ) {
00128      sprintf(new_err_msg,"REPLICA %d FATAL ERROR: %s\n%s\n", CmiMyPartition(), err_msg,bug_msg);
00129    }
00130    CmiAbort(new_err_msg);
00131    delete [] new_err_msg;
00132 }

void NAMD_close ( int  fd,
const char *  fname 
)

Definition at line 230 of file common.C.

References NAMD_err().

00230                                            {
00231 #ifdef WIN32
00232   while ( _close(fd) ) {
00233 #else
00234   while ( close(fd) ) {
00235 #endif
00236     if ( errno != EINTR ) {
00237       char errmsg[1024];
00238       sprintf(errmsg, "Error on closing file %s", fname);
00239       NAMD_err(errmsg);
00240     }
00241   }
00242 }

void NAMD_die ( const char *   ) 

Definition at line 81 of file common.C.

00083 {
00084    if ( ! err_msg ) err_msg = "(unknown error)";
00085    char *new_err_msg = new char[strlen(err_msg) + 40];
00086    sprintf(new_err_msg,"FATAL ERROR: %s\n",err_msg);
00087    CkPrintf(new_err_msg);
00088    fflush(stdout);
00089    if ( CmiNumPartitions() > 1 ) {
00090      sprintf(new_err_msg,"REPLICA %d FATAL ERROR: %s\n", CmiMyPartition(), err_msg);
00091    }
00092    CmiAbort(new_err_msg);
00093    delete [] new_err_msg;
00094 }

void NAMD_err ( const char *   ) 

Definition at line 98 of file common.C.

Referenced by after_backend_init(), close_dcd_write(), colvarproxy_namd::fatal_error(), NAMD_close(), NAMD_open(), NAMD_open_text(), NAMD_seek(), NAMD_write(), Controller::outputExtendedSystem(), PDB::PDB(), ComputeQMMgr::recvPartQM(), Output::recvReplicaDcdData(), and PDB::write().

00100 {
00101    if ( ! err_msg ) err_msg = "(unknown error)";
00102    char *sys_err_msg = strerror(errno);
00103    if ( ! sys_err_msg ) sys_err_msg = "(unknown error)";
00104    char *new_err_msg = new char[strlen(err_msg) + 40 + strlen(sys_err_msg)];
00105    sprintf(new_err_msg,"FATAL ERROR: %s: %s\n",err_msg, sys_err_msg);
00106    CkPrintf(new_err_msg);
00107    fflush(stdout);
00108    if ( CmiNumPartitions() > 1 ) {
00109      sprintf(new_err_msg,"REPLICA %d FATAL ERROR: %s: %s\n", CmiMyPartition(), err_msg, sys_err_msg);
00110    }
00111    CmiAbort(new_err_msg);
00112    delete [] new_err_msg;
00113 }

int NAMD_file_exists ( const char *  filename  ) 

Definition at line 134 of file common.C.

References endi(), iERROR(), and iout.

Referenced by NAMD_backup_file().

00134                                            {
00135   int rval;
00136   do {
00137     rval = access(filename, F_OK);
00138   } while ( rval != 0 && errno == EINTR );
00139   if ( rval != 0 && errno != ENOENT ) {
00140     char *sys_err_msg = strerror(errno);
00141     if ( ! sys_err_msg ) sys_err_msg = "(unknown error)";
00142     iout << iERROR << "Error on checking file "
00143       << filename << ": " << sys_err_msg << "\n" << endi;
00144     fflush(stdout);
00145   }
00146   return ! rval;
00147 }

int NAMD_open_text ( const char *  fname,
int  append = 0 
)

Definition at line 185 of file common.C.

References NAMD_err().

Referenced by ofstream_namd::open().

00185                                                   {
00186   int fd;
00187 
00188   //  open the file and die if the open fails
00189 #ifdef WIN32
00190   while ( (fd = _open(fname, O_WRONLY|(append?O_APPEND:O_EXCL)|O_CREAT|O_TEXT,_S_IREAD|_S_IWRITE)) < 0) {
00191 #else
00192 #ifdef NAMD_NO_O_EXCL
00193   while ( (fd = open(fname, O_WRONLY|(append?O_APPEND:O_TRUNC)|O_CREAT,
00194 #else
00195   while ( (fd = open(fname, O_WRONLY|(append?O_APPEND:O_EXCL)|O_CREAT,
00196 #endif
00197                            S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) {
00198 #endif
00199     if ( errno != EINTR ) {
00200       char errmsg[1024];
00201       sprintf(errmsg, "Unable to open text file %s", fname);
00202       NAMD_err(errmsg);
00203     }
00204   }
00205 
00206   return fd;
00207 }

void NAMD_quit ( const char *   ) 

Definition at line 64 of file common.C.

Referenced by Node::earlyExit(), and GlobalMasterIMD::get_vmd_forces().

00066 {
00067    if ( ! err_msg ) err_msg = "(unknown error)";
00068    char *new_err_msg = new char[strlen(err_msg) + 40];
00069    sprintf(new_err_msg,"EXITING: %s\n",err_msg);
00070    CkPrintf(new_err_msg);
00071    fflush(stdout);
00072    if ( CmiNumPartitions() > 1 ) {
00073      sprintf(new_err_msg,"REPLICA %d EXITING: %s\n", CmiMyPartition(), err_msg);
00074    }
00075    CmiAbort(new_err_msg);
00076    delete [] new_err_msg;
00077 }

char* NAMD_stringdup ( const char *  s  ) 

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

Definition at line 50 of file common.C.

00050                                     {
00051   char *rs;
00052 
00053   if(!s)
00054     return NULL;
00055 
00056   rs = new char[strlen(s) + 1];
00057   strcpy(rs,s);
00058 
00059   return rs;
00060 }

void NAMD_write ( int  fd,
const char *  buf,
size_t  count,
const char *  fname = "in NAMD_write()" 
)

Definition at line 210 of file common.C.

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

00210                                                                           {
00211   while ( count ) {
00212 #if defined(WIN32) && !defined(__CYGWIN__)
00213     long retval = _write(fd,buf,count);
00214 #else
00215     ssize_t retval = write(fd,buf,count);
00216 #endif
00217     if ( retval < 0 && errno == EINTR ) retval = 0;
00218     if ( retval < 0 ) {
00219       char errmsg[1024];
00220       sprintf(errmsg, "Error on writing to file %s", fname);
00221       NAMD_err(errmsg);
00222     }
00223     if ( retval > count ) NAMD_bug("extra bytes written in NAMD_write()");
00224     buf += retval;
00225     count -= retval;
00226   }
00227 }


Generated on Tue Sep 26 01:17:15 2017 for NAMD by  doxygen 1.4.7