void seissol::checkpoint::h5::Fault::load(int ×tepFault) { if (numSides() == 0) return; logInfo(rank()) << "Loading fault checkpoint"; seissol::checkpoint::CheckPoint::load(); hid_t h5file = open(linkFile()); checkH5Err(h5file); // Attributes hid_t h5attr = H5Aopen(h5file, "timestep_fault", H5P_DEFAULT); checkH5Err(h5attr); checkH5Err(H5Aread(h5attr, H5T_NATIVE_INT, ×tepFault)); checkH5Err(H5Aclose(h5attr)); // Set the memory space (this is the same for all variables) hsize_t count[2] = {numSides(), numBndGP()}; hid_t h5memSpace = H5Screate_simple(2, count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); // Offset for the file space hsize_t fStart[2] = {fileOffset(), 0}; // Read the data for (unsigned int i = 0; i < NUM_VARIABLES; i++) { hid_t h5data = H5Dopen(h5file, VAR_NAMES[i], H5P_DEFAULT); checkH5Err(h5data); hid_t h5fSpace = H5Dget_space(h5data); checkH5Err(h5fSpace); // Read the data checkH5Err(H5Sselect_hyperslab(h5fSpace, H5S_SELECT_SET, fStart, 0L, count, 0L)); checkH5Err(H5Dread(h5data, H5T_NATIVE_DOUBLE, h5memSpace, h5fSpace, h5XferList(), data(i))); checkH5Err(H5Sclose(h5fSpace)); checkH5Err(H5Dclose(h5data)); } checkH5Err(H5Sclose(h5memSpace)); checkH5Err(H5Fclose(h5file)); }
void seissol::checkpoint::h5::Fault::write(int timestepFault) { EPIK_TRACER("CheckPointFault_write"); SCOREP_USER_REGION("CheckPointFault_write", SCOREP_USER_REGION_TYPE_FUNCTION); if (numSides() == 0) return; logInfo(rank()) << "Writing fault check point."; // Create array with all pointers EPIK_USER_REG(r_write_fault, "checkpoint_write_fault"); SCOREP_USER_REGION_DEFINE(r_write_fault); EPIK_USER_START(r_write_fault); SCOREP_USER_REGION_BEGIN(r_write_fault, "checkpoint_write_fault", SCOREP_USER_REGION_TYPE_COMMON); // Attributes checkH5Err(H5Awrite(m_h5timestepFault[odd()], H5T_NATIVE_INT, ×tepFault)); // Set memory and file space hsize_t fStart[2] = {fileOffset(), 0}; hsize_t count[2] = {numSides(), numBndGP()}; hid_t h5memSpace = H5Screate_simple(2, count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); checkH5Err(H5Sselect_hyperslab(m_h5fSpaceData, H5S_SELECT_SET, fStart, 0L, count, 0L)); for (unsigned int i = 0; i < NUM_VARIABLES; i++) { checkH5Err(H5Dwrite(m_h5data[odd()][i], H5T_NATIVE_DOUBLE, h5memSpace, m_h5fSpaceData, h5XferList(), data(i))); } checkH5Err(H5Sclose(h5memSpace)); EPIK_USER_END(r_write_fault); SCOREP_USER_REGION_END(r_write_fault); // Finalize the checkpoint finalizeCheckpoint(); logInfo(rank()) << "Writing fault check point. Done."; }
void seissol::checkpoint::h5::Wavefield::write(double time, int waveFieldTimeStep) { EPIK_TRACER("CheckPoint_write"); SCOREP_USER_REGION("CheckPoint_write", SCOREP_USER_REGION_TYPE_FUNCTION); logInfo(rank()) << "Writing check point."; EPIK_USER_REG(r_header, "checkpoint_write_header"); SCOREP_USER_REGION_DEFINE(r_header); EPIK_USER_START(r_header); SCOREP_USER_REGION_BEGIN(r_header, "checkpoint_write_header", SCOREP_USER_REGION_TYPE_COMMON); // Time checkH5Err(H5Awrite(m_h5time[odd()], H5T_NATIVE_DOUBLE, &time)); // Wavefield writer checkH5Err(H5Awrite(m_h5timestepWavefield[odd()], H5T_NATIVE_INT, &waveFieldTimeStep)); EPIK_USER_END(r_header); SCOREP_USER_REGION_END(r_header); // Save data EPIK_USER_REG(r_write_wavefield, "checkpoint_write_wavefield"); SCOREP_USER_REGION_DEFINE(r_write_wavefield); EPIK_USER_START(r_write_wavefield); SCOREP_USER_REGION_BEGIN(r_write_wavefield, "checkpoint_write_wavefield", SCOREP_USER_REGION_TYPE_COMMON); // Write the wave field unsigned int offset = 0; hsize_t fStart = fileOffset(); hsize_t count = dofsPerIteration(); hid_t h5memSpace = H5Screate_simple(1, &count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); for (unsigned int i = 0; i < totalIterations()-1; i++) { checkH5Err(H5Sselect_hyperslab(m_h5fSpaceData, H5S_SELECT_SET, &fStart, 0L, &count, 0L)); checkH5Err(H5Dwrite(m_h5data[odd()], H5T_NATIVE_DOUBLE, h5memSpace, m_h5fSpaceData, h5XferList(), &const_cast<real*>(dofs())[offset])); // We are finished in less iterations, read data twice // so everybody needs the same number of iterations if (i < iterations()-1) { fStart += count; offset += count; } } checkH5Err(H5Sclose(h5memSpace)); // Save reminding data in the last iteration count = numDofs() - (iterations() - 1) * count; h5memSpace = H5Screate_simple(1, &count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); checkH5Err(H5Sselect_hyperslab(m_h5fSpaceData, H5S_SELECT_SET, &fStart, 0L, &count, 0L)); checkH5Err(H5Dwrite(m_h5data[odd()], H5T_NATIVE_DOUBLE, h5memSpace, m_h5fSpaceData, h5XferList(), &dofs()[offset])); checkH5Err(H5Sclose(h5memSpace)); EPIK_USER_END(r_write_wavefield); SCOREP_USER_REGION_END(r_write_wavefield); // Finalize the checkpoint finalizeCheckpoint(); logInfo(rank()) << "Writing check point. Done."; }
void seissol::checkpoint::h5::Wavefield::load(double &time, int ×tepWavefield, real* dofs) { logInfo(rank()) << "Loading wave field checkpoint"; seissol::checkpoint::CheckPoint::setLoaded(); hid_t h5file = open(linkFile()); checkH5Err(h5file); // Attributes hid_t h5attr = H5Aopen(h5file, "time", H5P_DEFAULT); checkH5Err(h5attr); checkH5Err(H5Aread(h5attr, H5T_NATIVE_DOUBLE, &time)); checkH5Err(H5Aclose(h5attr)); h5attr = H5Aopen(h5file, "timestep_wavefield", H5P_DEFAULT); checkH5Err(h5attr); checkH5Err(H5Aread(h5attr, H5T_NATIVE_INT, ×tepWavefield)); checkH5Err(H5Aclose(h5attr)); // Get dataset hid_t h5data = H5Dopen(h5file, "values", H5P_DEFAULT); checkH5Err(h5data); hid_t h5fSpace = H5Dget_space(h5data); checkH5Err(h5fSpace); // Read the data unsigned int offset = 0; hsize_t fStart = fileOffset(); hsize_t count = dofsPerIteration(); hid_t h5memSpace = H5Screate_simple(1, &count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); for (unsigned int i = 0; i < totalIterations()-1; i++) { checkH5Err(H5Sselect_hyperslab(h5fSpace, H5S_SELECT_SET, &fStart, 0L, &count, 0L)); checkH5Err(H5Dread(h5data, H5T_NATIVE_DOUBLE, h5memSpace, h5fSpace, h5XferList(), &dofs[offset])); // We are finished in less iterations, read data twice // so everybody needs the same number of iterations if (i < iterations()-1) { fStart += count; offset += count; } } checkH5Err(H5Sclose(h5memSpace)); // Read reminding data in the last iteration count = numDofs() - (iterations() - 1) * count; h5memSpace = H5Screate_simple(1, &count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); checkH5Err(H5Sselect_hyperslab(h5fSpace, H5S_SELECT_SET, &fStart, 0L, &count, 0L)); checkH5Err(H5Dread(h5data, H5T_NATIVE_DOUBLE, h5memSpace, h5fSpace, h5XferList(), &dofs[offset])); checkH5Err(H5Sclose(h5memSpace)); checkH5Err(H5Sclose(h5fSpace)); checkH5Err(H5Dclose(h5data)); checkH5Err(H5Fclose(h5file)); }
int main(int argc, _TCHAR* argv[]) { mkdir("Dec");mkdir("Enc"); std::wstring wstrFindPath = getCurrentDirectory(); CDir dir; dir.ReadDir(wstrFindPath); for (size_t i=0; i<dir.m_FileInfo.size(); i++) { if (!dir.m_FileInfo[i].IsDirectory()) { std::wstring wstrExt = GetExtension(dir.m_FileInfo[i].wstrFilename); std::string strFilename = ws2s(dir.m_FileInfo[i].wstrFilename); if (wstrExt==L".ozj") { std::string strDestFilename = "Dec\\"+ChangeExtension(strFilename,".jpg"); fileOffset(strFilename,strDestFilename,24); } else if (wstrExt==L".ozt") { std::string strDestFilename = "Dec\\"+ChangeExtension(strFilename,".tga"); fileOffset(strFilename,strDestFilename,4); } else if (wstrExt==L".ozb") { std::string strDestFilename = "Dec\\"+ChangeExtension(strFilename,".bmp"); fileOffset(strFilename,strDestFilename,4); } else if (wstrExt==L".jpg") { std::string strDestFilename = "Enc\\"+ChangeExtension(strFilename,".ozj"); fileOffset(strFilename,strDestFilename,-24); } else if (wstrExt==L".tga") { std::string strDestFilename = "Enc\\"+ChangeExtension(strFilename,".ozt"); fileOffset(strFilename,strDestFilename,-4); } else if (wstrExt==L".bmp") { std::string strDestFilename = "Enc\\"+ChangeExtension(strFilename,".ozb"); fileOffset(strFilename,strDestFilename,-4); } else if (wstrExt==L".map"||wstrExt==L".obj") { decryptMuFile(strFilename,"Dec\\"+strFilename+"d"); } else if (wstrExt==L".att") { decryptMuATTFile(strFilename,"Dec\\"+strFilename+"d"); } else if (wstrExt==L".bmd") { if ("item.bmd"==strFilename) { decryptItemBMD(strFilename,"Dec\\"+ChangeExtension(strFilename,".csv")); } else if ("BuffEffect.bmd"==strFilename) { decryptBuffEffectFile(strFilename,"Dec\\"+strFilename+"d"); } //else if (isEncBmd(strFilename)) //{ // decryptMuFile(strFilename,"Dec\\"+strFilename); //} else { Bmd2Smd(strFilename,"Dec\\"+ChangeExtension(strFilename,".smd")); // decryptMuFileXOR3(strFilename,"Dec\\"+strFilename); } } else if (wstrExt==L".csv") { if ("item.csv"==strFilename) { encryptItemBMD(strFilename,"Enc\\"+ChangeExtension(strFilename,".bmd")); } } else if (wstrExt==L".smd") { Smd2Bmd(strFilename,"Enc\\"+ChangeExtension(strFilename,".bmd")); } } } return 0; }
void CImMobilityLogger::DoCreateStandardLogL(const TDesC& /*aFilePartName*/, TInt& /*aLogId*/) #endif //__IM_MOBILITY_LOGGING { #ifdef __IM_MOBILITY_LOGGING aLogId = KDefaultLog; TBool fileOpen(ETrue); TFileName filename; TInt err; TInt fileOffset(0); do { ++fileOffset; filename.Format(KStandardLogFileFormat, &KLogDir(), &aFilePartName, fileOffset); err = iFs.IsFileOpen(filename, fileOpen); if (err == KErrNotFound) { err = KErrNone; fileOpen = EFalse; } User::LeaveIfError(err); } while (fileOpen); // See if we should take a backup of the log file if (BaflUtils::FolderExists(iFs, KBackupLogDir)) { TInt backupOffset(KMaxBackupOffset); TFileName source; TFileName dest; dest.Format(KBackupLogFileFormat, &KBackupLogDir(), &aFilePartName, fileOffset, backupOffset); while (backupOffset > 1) { --backupOffset; source.Format(KBackupLogFileFormat, &KBackupLogDir(), &aFilePartName, fileOffset, backupOffset); BaflUtils::CopyFile(iFs, source, dest); dest = source; } BaflUtils::CopyFile(iFs, filename, dest); } TLogFileInfo info; info.iLoggingOn = ETrue; err = info.iFile.Replace(iFs, filename, EFileWrite | EFileShareAny); if (err != KErrNone) { return; } CleanupClosePushL(info.iFile); iFileList.AppendL(info); CleanupStack::Pop(&info.iFile); HBufC8* buf; TRAP(err, buf = CnvUtfConverter::ConvertFromUnicodeToUtf8L(filename)); if (err == KErrNone) { const TDesC8& bufRef = *buf; LogFormat(KDefaultLog, KTxtFormatStandardLogStarted, &bufRef); delete buf; } aLogId = iFileList.Count() - 1; #endif //__IM_MOBILITY_LOGGING }
void Img::fileOffset (std::istream &f, const std::string &fname) const { Dir::const_iterator iter = find(fname); fileOffset(f, iter->second); }
void Img::fileOffset (std::istream &f, unsigned long i) const { f.seekg(fileOffset(i)); APP_ASSERT_IO_SUCCESSFUL(f,"seeking to: "+fileName(i)); }
unsigned long Img::fileOffset (const std::string &fname) const { Dir::const_iterator iter = find(fname); return fileOffset(iter->second); }