void DumpSpectrum(const dCVector* pEnergy, const dCVector* pEnergyWidth, const Spectrum* pSpectrum, const char* filename) { FILE* dumpFile; char f1[80] = "datafiles/"; if ((pEnergy->dimension != pEnergyWidth->dimension) || (pEnergyWidth->dimension != pSpectrum->numberOfMainBins)) Error("DumpSpectrum: inconsistent dimensions", PROGRAM_ERROR); strncat(f1, filename, 79 - strlen(filename)); dumpFile = SafeFOpen(f1, "w"); // this is to send the dump file to a different directory (datafiles) // by Guenter (7/20/1998) for (int i=0; i<NUM_SPECIES; i++) { for (int j=0; j<pSpectrum->numberOfMainBins; j++) { fprintf(dumpFile, "%15.4E %15.4E\n", ELECTRON_MASS*(pEnergy->vector)[j], (pSpectrum->spectrum)[i][j]/(pEnergyWidth->vector)[j]* (pEnergy->vector)[j]*(pEnergy->vector)[j]); // proper unit conversion for energy } } fclose(dumpFile); }
char* _load_text_file(const char* _file_name) { FILE* fp = SafeFOpen(_file_name, "r"); euint len = _file_length( fp ); char* buffer = (char*)SMalloc(len); fread(buffer, len, 1, fp); fclose(fp); return buffer; }
void ELog_Init() { ELock_lock(&g_elog_lock); #ifdef USE_LOG_SYSTEM if (!g_elog_file) { #if defined(_WIN32) || defined(_WIN64) g_elog_file = SafeFOpen("log.log", "w+"); #elif defined(__APPLE__) char homeDir[256]; GetHomeDirectory(homeDir, 255); char logFilename[256]; snprintf(logFilename, 255, "%s/Documents/log.log", homeDir); g_elog_file = SafeFOpen(logFilename, "w+"); #endif } #endif ELock_unlock(&g_elog_lock); }
void LoadSyncTable(dCVector* syncTable, string aDirTables) { FILE* syncData; double temporary; int i; syncData = SafeFOpen((aDirTables+"/syncTable.dat").c_str(), "r"); for (i = 0; i < syncTable->dimension; i++) { fscanf(syncData, "%lf %lf", &temporary, &((syncTable->vector)[i])); } fclose(syncData) ; // added June 2005 - E.A. }