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 namdnearbyint(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
#define COMPUTEMAPTAG   108

Definition at line 157 of file common.h.

Referenced by WorkDistrib::recvComputeMapChanges(), and WorkDistrib::sendComputeMap().

#define COULOMB   332.0636
#define CYCLE_BARRIER   0

Definition at line 159 of file common.h.

#define DPMTATAG   106

Definition at line 155 of file common.h.

#define FALSE   0
#define FULLFORCETAG   105

Definition at line 154 of file common.h.

Referenced by ComputeFullDirect::doWork().

#define FULLTAG   104

Definition at line 153 of file common.h.

Referenced by ComputeFullDirect::doWork().

#define GRIDFORCEGRIDTAG   107

Definition at line 156 of file common.h.

Referenced by Node::reloadGridforceGrid().

#define MAX_NEIGHBORS   27

Definition at line 129 of file common.h.

#define MOLECULETAG   102

Definition at line 152 of file common.h.

Referenced by Node::resendMolecule().

#define NAMD_ComputeNonbonded_SortAtoms   1

Definition at line 184 of file common.h.

#define NAMD_ComputeNonbonded_SortAtoms_LessBranches   1

Definition at line 185 of file common.h.

#define NAMD_SeparateWaters   0

Definition at line 171 of file common.h.

#define namdnearbyint (  )     floor((x)+0.5)
#define NO   0

Definition at line 121 of file common.h.

#define ONE   1.000000000000000

Definition at line 89 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
#define PME_BARRIER   0

Definition at line 160 of file common.h.

#define PNPERKCALMOL   69.479

Definition at line 50 of file common.h.

#define PRESSUREFACTOR   6.95E4
#define SIMPARAMSTAG   100

Definition at line 150 of file common.h.

#define SMALLRAD   0.0005

Definition at line 97 of file common.h.

#define SMALLRAD2   SMALLRAD*SMALLRAD

Definition at line 101 of file common.h.

#define STATICPARAMSTAG   101

Definition at line 151 of file common.h.

Referenced by Node::resendMolecule().

#define STEP_BARRIER   0

Definition at line 161 of file common.h.

#define STRINGNULL   '\0'
#define TIMEFACTOR   48.88821
#define TRUE   1
#define TWOPI   2.0 * PI
#define USE_BARRIER   (CYCLE_BARRIER || PME_BARRIER || STEP_BARRIER)

Definition at line 163 of file common.h.

#define WAT_SWM4   2
#define WAT_TIP3   0

Definition at line 188 of file common.h.

Referenced by HomePatch::rattle1().

#define WAT_TIP4   1
#define YES   1

Definition at line 122 of file common.h.

#define ZERO   0.000000000000000

Definition at line 93 of file common.h.

Referenced by ComputeNonbondedUtil::calcGBIS().


Typedef Documentation

typedef double BigReal

Definition at line 112 of file common.h.

typedef int Bool

Definition at line 131 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 107 of file common.h.


Function Documentation

int Fclose ( FILE *  fout  ) 

Definition at line 343 of file common.C.

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

00344 {
00345   int rc = -1;
00346 #if !defined(NOCOMPRESSED)
00347   rc = pclose(fout);
00348 #endif
00349   if (rc == -1) // stream not associated with a popen()
00350     {
00351     rc = fclose(fout);
00352     }
00353   return rc;
00354 } /* Fclose() */

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

Definition at line 249 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().

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

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

Definition at line 143 of file common.C.

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

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

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

void NAMD_bug ( const char *   ) 

Definition at line 111 of file common.C.

Referenced by Sequencer::algorithm(), Controller::algorithm(), CollectProxyVectorInstance::append(), 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(), ofstream_namd::close(), Box< Patch, CompAtom >::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_remote_progress(), cudaNAMD_bug(), CudaPmeRealSpaceCompute::CudaPmeRealSpaceCompute(), MigrateAtomsCombinedMsg::distribute(), ComputeGridForce::doForce(), HomePatch::doGroupSizeCheck(), CudaComputeNonbonded::doWork(), ComputePme::doWork(), ComputeNonbondedCUDA::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(), ParallelIOMgr::initialize(), LdbCoordinator::initialize(), ComputePmeCUDA::initialize(), ComputePme::initialize(), ComputePmeMgr::initialize(), ComputePatch::initialize(), ComputeHomePatch::initialize(), ComputePmeMgr::initialize_computes(), IRSet::insert(), ParseOptions::issetfromptr(), ParseOptions::istruefromptr(), CudaComputeNonbonded::launchWork(), LdbCoordinator::LdbCoordinator(), ScriptTcl::load(), NamdState::loadStructure(), PatchMap::makePatches(), WorkDistrib::messageEnqueueWork(), CudaComputeNonbonded::messageEnqueueWork(), WorkDistrib::messageFinishCUDA(), WorkDistrib::messageFinishMIC(), HomePatch::minimize_rattle2(), Sequencer::multigratorPressure(), NAMD_write(), Node::Node(), PmeZPencil::node_process_untrans(), PmeYPencil::node_process_untrans(), ofstream_namd::open(), Box< Patch, CompAtom >::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(), PmePencilXYMap::populateInitial(), PmePencilXMap::populateInitial(), PmePencilXYZMap::populateInitial(), PmePencilMap::populateInitial(), Controller::printEnergies(), Rebalancer::printLoads(), PmePencilXYMap::procNum(), PmePencilXMap::procNum(), ProxyMgr::ProxyMgr(), HomePatch::rattle2(), Sequencer::reassignVelocities(), ProxyPatch::receiveAll(), ProxyPatch::receiveData(), ParallelIOMgr::receiveForces(), ParallelIOMgr::receivePositions(), ParallelIOMgr::receiveVelocities(), recursive_bisect_with_curve(), recvAck(), ComputePmeMgr::recvAck(), ComputePmeCUDADevice::recvAtoms(), ComputePmeCUDADevice::recvAtomsFromNeighbor(), recvBcast(), BroadcastMgr::recvBroadcast(), PatchMgr::recvCheckpointAck(), HomePatch::recvCheckpointLoad(), PatchMgr::recvCheckpointReq(), WorkDistrib::recvComputeMapChanges(), GlobalMasterServer::recvData(), recvData(), ComputePmeCUDAMgr::recvDevices(), recvEvalCommand(), recvEvalResult(), PatchMgr::recvExchangeReq(), ComputePmeCUDADevice::recvForcesFromNeighbor(), ComputePmeMgr::recvGrid(), ComputeQMMgr::recvPartQM(), ComputePmeMgr::recvRecipEvir(), Output::recvReplicaDcdData(), ProxyMgr::recvResults(), ComputeGlobal::recvResults(), ComputePmeMgr::recvUngrid(), NodePmeMgr::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(), CollectProxyVectorInstance::reset(), CollectionMgr::CollectVectorInstance::reset(), CollectionMaster::CollectVectorInstance::reset(), ComputeGlobal::saveTotalForces(), Sequencer::scalePositionsVelocities(), ComputeNonbondedUtil::select(), PmeZPencil::send_ungrid(), 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(), PmePencilZ::submitReductions(), PmePencilXYZ::submitReductions(), ComputePmeMgr::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(), ComputeCUDAMgr::update(), ComputeMgr::updateComputes(), Node::updateGridScale(), WorkDistrib::WorkDistrib(), AtomMapper::~AtomMapper(), and Rebalancer::~Rebalancer().

00112 {
00113   if ( ! err_msg ) err_msg = "(unknown error)";
00114   const char *bug_msg = 
00115     "FATAL ERROR: See http://www.ks.uiuc.edu/Research/namd/bugreport.html";
00116   CkPrintf("FATAL ERROR: %s\n%s\n",err_msg, bug_msg);
00117   fflush(stdout);
00118   char repstr[24] = "";
00119   if (CmiNumPartitions() > 1) {
00120     sprintf(repstr,"REPLICA %d ", CmiMyPartition());
00121   }
00122   CkError("%sFATAL ERROR: %s\n%s\n", repstr, err_msg, bug_msg);
00123   CkExit(2);
00124 }

void NAMD_close ( int  fd,
const char *  fname 
)

Definition at line 223 of file common.C.

References NAMD_err().

00223                                            {
00224 #ifdef WIN32
00225   while ( _close(fd) ) {
00226 #else
00227   while ( close(fd) ) {
00228 #endif
00229     if ( errno != EINTR ) {
00230       char errmsg[1024];
00231       sprintf(errmsg, "Error on closing file %s", fname);
00232       NAMD_err(errmsg);
00233     }
00234   }
00235 }

void NAMD_die ( const char *   ) 

Definition at line 79 of file common.C.

00080 {
00081   if ( ! err_msg ) err_msg = "(unknown error)";
00082   CkPrintf("FATAL ERROR: %s\n", err_msg);
00083   fflush(stdout);
00084   char repstr[24] = "";
00085   if (CmiNumPartitions() > 1) {
00086     sprintf(repstr,"REPLICA %d ", CmiMyPartition());
00087   }
00088   CkError("%sFATAL ERROR: %s\n", repstr, err_msg);
00089   CkExit(1);
00090 }

void NAMD_err ( const char *   ) 

Definition at line 94 of file common.C.

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

00095 {
00096   if ( ! err_msg ) err_msg = "(unknown error)";
00097   const char *sys_err_msg = strerror(errno);
00098   if ( ! sys_err_msg ) sys_err_msg = "(unknown error)";
00099   CkPrintf("FATAL ERROR: %s: %s\n", err_msg, sys_err_msg);
00100   fflush(stdout);
00101   char repstr[24] = "";
00102   if (CmiNumPartitions() > 1) {
00103     sprintf(repstr,"REPLICA %d ", CmiMyPartition());
00104   }
00105   CkError("%sFATAL ERROR: %s: %s\n", repstr, err_msg, sys_err_msg);
00106   CkExit(1);
00107 }

int NAMD_file_exists ( const char *  filename  ) 

Definition at line 127 of file common.C.

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

Referenced by NAMD_backup_file().

00127                                            {
00128   int rval;
00129   do {
00130     rval = access(filename, F_OK);
00131   } while ( rval != 0 && errno == EINTR );
00132   if ( rval != 0 && errno != ENOENT ) {
00133     const char *sys_err_msg = strerror(errno);
00134     if ( ! sys_err_msg ) sys_err_msg = "(unknown error)";
00135     iout << iERROR << "Error on checking file "
00136       << filename << ": " << sys_err_msg << "\n" << endi;
00137     fflush(stdout);
00138   }
00139   return ! rval;
00140 }

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

Definition at line 178 of file common.C.

References NAMD_err().

Referenced by ofstream_namd::open().

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

void NAMD_quit ( const char *   ) 

Definition at line 64 of file common.C.

Referenced by GlobalMasterIMD::get_vmd_forces().

00065 {
00066   if ( ! err_msg ) err_msg = "(unknown error)";
00067   CkPrintf("EXITING: %s\n", err_msg);
00068   fflush(stdout);
00069   char repstr[24] = "";
00070   if (CmiNumPartitions() > 1) {
00071     sprintf(repstr,"REPLICA %d ", CmiMyPartition());
00072   }
00073   CkError("%sEXITING: %s\n", repstr, err_msg);
00074   CkExit(0);
00075 }

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 203 of file common.C.

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

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


Generated on 10 Apr 2020 for NAMD by  doxygen 1.6.1