// Given a frame number, read the coord data into the internal array // and retrieve the corresponding periodic box (if present) void AmberNetcdf::readRawFrame(const uint frameno) { size_t start[3] = {0, 0, 0}; size_t count[3] = {1, 1, 3}; // Read coordinates first... start[0] = frameno; count[1] = _natoms; int retval = VarTypeDecider<GCoord::element_type>::read(_ncid, _coord_id, start, count, _coord_data); if (retval) throw(FileReadError(_filename, "Cannot read Amber netcdf frame", retval)); // Now get box if present... if (_periodic) { start[1] = 0; count[1] = 3; retval = VarTypeDecider<GCoord::element_type>::read(_ncid, _cell_lengths_id, start, count, _box_data); if (retval) throw(FileReadError(_filename, "Cannot read Amber netcdf periodic box", retval)); } }
void MultiTrajectory::seekFrameImpl(const uint i) { if (i >= _nframes) throw(FileReadError("Cannot seek past end of MultiTraj")); Location loc = frameIndexToLocation(i); _curtraj = loc.first; _curframe = loc.second; }
void ROFile::ReadBuffer(void* pBuffer, unsigned int uiBufferSize) { if(!m_File) { throw FileError("NULL File pointer", EL_BAD, "ROFile::ReadBuffer", "File hasn't been opened!"); } unsigned int rc = fread(pBuffer, uiBufferSize, 1, m_File); if(feof(m_File)) { throw FileEOF(m_sFilename.c_str(), rc); } else if(ferror(m_File)) { throw FileReadError(m_sFilename.c_str(), EL_BAD, "ROFile::ReadBuffer", "Error while reading file:\r\n" + m_sFilename); } }