static void WriteLog(std::string const& type, std::string const& msg, Color const& c = Color()) { // Skip logging to file in the browser #ifndef EMSCRIPTEN if (!Main_Data::GetSavePath().empty()) { // Only write to file when project path is initialized // (happens after parsing the command line) for (std::string& log : log_buffer) { output_time() << log << std::endl; } log_buffer.clear(); output_time() << type << ": " << msg << std::endl; } else { // buffer log messages until file system is ready log_buffer.push_back(type + ": " + msg); } #endif #ifdef __ANDROID__ __android_log_print(type == "Error" ? ANDROID_LOG_ERROR : ANDROID_LOG_INFO, "EasyRPG Player", "%s", msg.c_str()); #else std::cerr << type << ": " << msg << std::endl; #endif if (type != "Debug") { if (DisplayUi) { message_overlay().AddMessage(msg, c); } } }
void simulatort::run(queuet &queue) { fine_timet start_time=current_time(); error_state_found=false; #ifdef DEBUG std::cout << "simulatort::run1\n"; #endif unsigned counter=0; state_projectiont state_projection(formula_container, program_formula); while(!queue.empty() && !error_state_found) { #ifdef DEBUG std::cout << "simulatort::run2\n"; #endif counter++; explore(queue.next(), queue); } if(error_state_found) std::cout << "VERIFICATION FAILED" << std::endl; else std::cout << "VERIFICATION SUCCESSFUL" << std::endl; std::cout << std::endl; std::cout << "States explored: " << counter << std::endl; std::cout << "Runtime: "; output_time(current_time()-start_time, std::cout); std::cout << std::endl; }
/*ARGSUSED*/ static int duration_fh(int outbytes, int width, format_key_t *key, struct radutmp *up) { return output_time((up->type == P_IDLE) ? up->duration : time(NULL) - up->time, width, key); }
static void HandleScreenOutput(char const* type, std::string const& msg, bool is_error) { Output::TakeScreenshot(); output_time() << type << ":\n " << msg << "\n"; if(ignore_pause) { return; } std::stringstream ss; ss << type << ":\n" << msg << "\n\n"; if (is_error) { ss << "EasyRPG Player will close now.\nPress any key to exit..."; } else { ss << "Press any key to continue..."; } DisplayUi->GetDisplaySurface()->Clear(); DisplayUi->DrawScreenText(ss.str(), 10, 30 + 10); DisplayUi->UpdateDisplay(); Input::ResetKeys(); while (!Input::IsAnyPressed()) { DisplayUi->Sleep(1); DisplayUi->ProcessEvents(); if (Player::exit_flag) break; Input::Update(); } Input::ResetKeys(); Graphics::FrameReset(); Graphics::Update(); }
static void WriteLog(std::string const& type, std::string const& msg, Color const& c = Color()) { // Skip logging to file in the browser #ifndef EMSCRIPTEN if (!Main_Data::GetSavePath().empty()) { // Only write to file when project path is initialized // (happens after parsing the command line) for (std::string& log : log_buffer) { output_time() << log << std::endl; } log_buffer.clear(); // Every new message is written once to the file. // When it is repeated increment a counter until a different message appears, // then write the buffered message with the counter. if (msg == last_message.msg) { last_message.repeat++; } else { if (last_message.repeat > 0) { output_time() << last_message.type << ": " << last_message.msg << " [" << last_message.repeat + 1 << "x]" << std::endl; output_time() << type << ": " << msg << std::endl; } else { output_time() << type << ": " << msg << std::endl; } last_message.repeat = 0; last_message.msg = msg; last_message.type = type; } } else { // buffer log messages until file system is ready log_buffer.push_back(type + ": " + msg); } #endif #ifdef __ANDROID__ __android_log_print(type == "Error" ? ANDROID_LOG_ERROR : ANDROID_LOG_INFO, "EasyRPG Player", "%s", msg.c_str()); #else std::cerr << type << ": " << msg << std::endl; #endif if (type != "Debug") { Graphics::GetMessageOverlay().AddMessage(msg, c); } }
void print_node(node &top, int indent, tmap &totals){ for(int i = 0; i < indent; i++) (*pfs) << " "; (*pfs) << top.name; int dots = 70 - 2 * indent - top.name.size(); for(int i = 0; i <dots; i++) (*pfs) << "."; output_time(*pfs, top.time); (*pfs) << std::endl; if(indent != 0)totals[top.name.c_str()].add(top.time); for(nmap::iterator it = top.sub.begin(); it != top.sub.end(); it++) print_node(it->second,indent+1,totals); }
void print(std::ostream &os) { pfs = &os; top.time = 0; for(nmap::iterator it = top.sub.begin(); it != top.sub.end(); it++) top.time += it->second.time; tmap totals; print_node(top,0,totals); (*pfs) << "TOTALS:" << std::endl; for(tmap::iterator it = totals.begin(); it != totals.end(); it++){ (*pfs) << (it->first) << " "; output_time(*pfs, it->second.t); (*pfs) << std::endl; } }
static void WriteLog(std::string const& type, std::string const& msg, Color const& c = Color()) { output_time() << type << ": " << msg << std::endl; #ifdef __ANDROID__ __android_log_print(type == "Error" ? ANDROID_LOG_ERROR : ANDROID_LOG_INFO, "EasyRPG Player", "%s", msg.c_str()); #else std::cerr << type << ": " << msg << std::endl; #endif if (type != "Debug") { if (DisplayUi) { message_overlay().AddMessage(msg, c); } } }
int nandroid_rest_exe() { if (ensure_path_mounted(SDCARD_ROOT) != 0) { ui_print("-- Could not mount: %s.\n-- Aborting.\n",SDCARD_ROOT); return 1; } time_t rStart, rStop; time(&rStart); ui_print("\n[RESTORE STARTED]\n\n"); if (tw_nan_system_x == 1) { if (tw_restore(sys,nan_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } if (tw_nan_data_x == 1) { if (tw_restore(dat,nan_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } if (tw_nan_boot_x == 1) { if (tw_restore(boo,nan_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } if (tw_nan_recovery_x == 1) { if (tw_restore(rec,nan_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } if (tw_nan_cache_x == 1) { if (tw_restore(cac,nan_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } if (tw_nan_wimax_x == 1) { if (tw_restore(wim,nan_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } if (tw_nan_andsec_x == 1) { if (tw_restore(ase,nan_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } if (tw_nan_sdext_x == 1) { if (tw_restore(sde,nan_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } time(&rStop); output_time("RESTORE", "COMPLETED", (int)difftime(rStop, rStart)); __system("sync"); LOGI("=> Let's update filesystem types.\n"); verifyFst(); LOGI("=> And update our fstab also.\n"); createFstab(); return 0; }
int tw_restore(struct dInfo rMnt, char *rDir) { int i; FILE *reFp; char rUppr[20]; char rMount[30]; char rFilesystem[10]; char rFilename[255]; char rCommand[255]; char rOutput[255]; time_t rStart, rStop; strcpy(rUppr,rMnt.mnt); for (i = 0; i < strlen(rUppr); i++) { rUppr[i] = toupper(rUppr[i]); } ui_print("[%s]\n",rUppr); ui_show_progress(1,150); time(&rStart); ui_print("...Verifying md5 hash for %s.\n",rMnt.mnt); if(checkMD5(rDir,rMnt.fnm) == 0) // verify md5, check if no error; 0 = no error. { strcpy(rFilename,rDir); strcat(rFilename,rMnt.fnm); sprintf(rCommand,"ls -l %s | awk -F'.' '{ print $2 }'",rFilename); // let's get the filesystem type from filename reFp = __popen(rCommand, "r"); LOGI("=> Filename is: %s\n",rMnt.fnm); while (fscanf(reFp,"%s",rFilesystem) == 1) { // if we get a match, store filesystem type LOGI("=> Filesystem is: %s\n",rFilesystem); // show it off to the world! } __pclose(reFp); if (DataManager_GetIntValue(TW_RM_RF_VAR) == 1 && (strcmp(rMnt.mnt,"system") == 0 || strcmp(rMnt.mnt,"data") == 0 || strcmp(rMnt.mnt,"cache") == 0)) { // we'll use rm -rf instead of formatting for system, data and cache if the option is set ui_print("...using rm -rf to wipe %s\n", rMnt.mnt); tw_mount(rMnt); // mount the partition first sprintf(rCommand,"rm -rf %s%s/*", "/", rMnt.mnt); LOGI("rm rf commad: %s\n", rCommand); reFp = __popen(rCommand, "r"); while (fscanf(reFp,"%s",rOutput) == 1) { ui_print_overwrite("%s",rOutput); } __pclose(reFp); } else { ui_print("...Formatting %s\n",rMnt.mnt); tw_format(rFilesystem,rMnt.blk); // let's format block, based on filesystem from filename above } ui_print("....Done.\n"); if (strcmp(rFilesystem,"mtd") == 0) { // if filesystem is mtd, we use flash image sprintf(rCommand,"flash_image %s %s",rMnt.mnt,rFilename); strcpy(rMount,rMnt.mnt); } else if (strcmp(rFilesystem,"emmc") == 0) { // if filesystem is emmc, we use dd sprintf(rCommand,"dd bs=%s if=%s of=%s",bs_size,rFilename,rMnt.dev); strcpy(rMount,rMnt.mnt); } else { tw_mount(rMnt); strcpy(rMount,"/"); if (strcmp(rMnt.mnt,".android_secure") == 0) { // if it's android_secure, we have add prefix strcat(rMount,"sdcard/"); } strcat(rMount,rMnt.mnt); sprintf(rCommand,"cd %s && tar -xvf %s",rMount,rFilename); // formulate shell command to restore } ui_print("...Restoring %s\n",rMount); reFp = __popen(rCommand, "r"); if(DataManager_GetIntValue(TW_SHOW_SPAM_VAR) == 2) { // twrp spam while (fgets(rOutput,sizeof(rOutput),reFp) != NULL) { ui_print_overwrite("%s",rOutput); } } else { while (fscanf(reFp,"%s",rOutput) == 1) { if(DataManager_GetIntValue(TW_SHOW_SPAM_VAR) == 1) ui_print_overwrite("%s",rOutput); } } __pclose(reFp); ui_print_overwrite("....Done.\n"); if (strcmp(rMnt.mnt,".android_secure") != 0) { // any partition other than android secure, tw_unmount(rMnt); // let's unmount (unmountable partitions won't matter) } } else { ui_print("...Failed md5 check. Aborted.\n\n"); return 1; } ui_reset_progress(); time(&rStop); output_time(rUppr, "DONE", (int)difftime(rStop,rStart)); return 0; }
int nandroid_back_exe() { if (ensure_path_mounted(SDCARD_ROOT) != 0) { ui_print("-- Could not mount: %s.\n-- Aborting.\n",SDCARD_ROOT); return 1; } struct tm *t; char timestamp[15]; char tw_image_dir[255]; char exe[255]; time_t start, stop; time_t seconds; seconds = time(0); t = localtime(&seconds); sprintf(timestamp,"%02d%02d%d%02d%02d%02d",t->tm_mon+1,t->tm_mday,t->tm_year+1900,t->tm_hour,t->tm_min,t->tm_sec); // make time stamp sprintf(tw_image_dir,"%s/%s/%s/",backup_folder,device_id,timestamp); // for backup folder sprintf(exe,"mkdir -p %s",tw_image_dir); // make the folder with timestamp if (__system(exe) != 0) { ui_print("-- Could not create: %s.\n-- Aborting.",tw_image_dir); return 1; } else { LOGI("=> Created folder: %s\n",tw_image_dir); } FILE *fp; char pOutput[25]; int sdSpaceFinal; LOGI("=> Checking space on %s.\n",SDCARD_ROOT); fp = __popen("df -k /sdcard | grep sdcard | awk '{ print $4 \" \" $3 }'", "r"); // how much space left on sdcard? fgets(pOutput,25,fp); __pclose(fp); if(pOutput[2] == '%') { // oh o, crespo devices report diskspace on the 3rd argument. if (sscanf(pOutput,"%*s %d",&sdSpaceFinal) != 1) { // is it a number? ui_print("-- Could not determine free space on %s.",SDCARD_ROOT); // oh noes! Can't find sdcard's free space. return 1; } } else { if (sscanf(pOutput,"%d %*s",&sdSpaceFinal) != 1) { // is it a number? ui_print("-- Could not determine free space on %s.",SDCARD_ROOT); // oh noes! Can't find sdcard's free space. return 1; } } LOGI("=> %s",pOutput); sdSpace = sdSpaceFinal; // set starting and running count of sd space LOGI("=> /sdcard has %d MB free.\n",sdSpace/1024); time(&start); ui_print("\n[BACKUP STARTED]\n\n"); ui_print("-- Verifying filesystems, please wait...\n"); verifyFst(); ui_print("-- Updating fstab.\n"); createFstab(); ui_print("-- Done.\n"); // SYSTEM if (DataManager_GetIntValue(TW_NANDROID_SYSTEM_VAR)) { // was system backup enabled? if (tw_backup(sys,tw_image_dir) == 1) { // did the backup process return an error ? 0 = no error ui_print("-- Error occured, check recovery.log. Aborting.\n"); //oh noes! abort abort! return 1; } } // DATA if (DataManager_GetIntValue(TW_NANDROID_DATA_VAR)) { if (tw_backup(dat,tw_image_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } // BOOT if (DataManager_GetIntValue(TW_NANDROID_BOOT_VAR)) { if (tw_backup(boo,tw_image_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } // RECOVERY if (DataManager_GetIntValue(TW_NANDROID_RECOVERY_VAR)) { if (tw_backup(rec,tw_image_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } // CACHE if (DataManager_GetIntValue(TW_NANDROID_CACHE_VAR)) { if (tw_backup(cac,tw_image_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } // WIMAX if (DataManager_GetIntValue(TW_NANDROID_WIMAX_VAR)) { if (tw_backup(wim,tw_image_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } // ANDROID-SECURE if (DataManager_GetIntValue(TW_NANDROID_ANDSEC_VAR)) { if (tw_backup(ase,tw_image_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } // SD-EXT if (DataManager_GetIntValue(TW_NANDROID_SDEXT_VAR)) { if (tw_backup(sde,tw_image_dir) == 1) { ui_print("-- Error occured, check recovery.log. Aborting.\n"); return 1; } } LOGI("=> Checking /sdcard space again.\n\n"); fp = __popen("df -k /sdcard| grep sdcard | awk '{ print $4 \" \" $3 }'", "r"); fgets(pOutput,25,fp); __pclose(fp); if(pOutput[2] == '%') { if (sscanf(pOutput,"%*s %d",&sdSpace) != 1) { // is it a number? ui_print("-- Could not determine free space on %s.\n",SDCARD_ROOT); // oh noes! Can't find sdcard's free space. return 1; } } else { if (sscanf(pOutput,"%d %*s",&sdSpace) != 1) { // is it a number? ui_print("-- Could not determine free space on %s.\n",SDCARD_ROOT); // oh noes! Can't find sdcard's free space. return 1; } } time(&stop); ui_print("[%d MB TOTAL BACKED UP TO SDCARD]\n",(int)(sdSpaceFinal - sdSpace) / 1024); output_time("BACKUP", "COMPLETED", (int)difftime(stop, start)); return 0; }
/* New backup function ** Condensed all partitions into one function */ int tw_backup(struct dInfo bMnt, char *bDir) { if (ensure_path_mounted(SDCARD_ROOT) != 0) { ui_print("-- Could not mount: %s.\n-- Aborting.\n",SDCARD_ROOT); return 1; } int bDiv; char bTarArg[10]; if (DataManager_GetIntValue(TW_USE_COMPRESSION_VAR)) { // set compression or not strcpy(bTarArg,"-czvf"); bDiv = 512; } else { strcpy(bTarArg,"-cvf"); bDiv = 2048; } FILE *bFp; int bPartSize; char *bImage = malloc(sizeof(char)*50); char *bMount = malloc(sizeof(char)*50); char *bCommand = malloc(sizeof(char)*255); if (strcmp(bMnt.mnt,"system") == 0 || strcmp(bMnt.mnt,"data") == 0 || strcmp(bMnt.mnt,"cache") == 0 || strcmp(bMnt.mnt,"sd-ext") == 0 || strcmp(bMnt.mnt,"efs") == 0 || strcmp(bMnt.mnt,".android_secure") == 0) { // detect mountable partitions if (strcmp(bMnt.mnt,".android_secure") == 0) { // if it's android secure, add sdcard to prefix strcpy(bMount,"/sdcard/"); strcat(bMount,bMnt.mnt); sprintf(bImage,"and-sec.%s.win",bMnt.fst); // set image name based on filesystem, should always be vfat for android_secure } else { strcpy(bMount,"/"); strcat(bMount,bMnt.mnt); sprintf(bImage,"%s.%s.win",bMnt.mnt,bMnt.fst); // anything else that is mountable, will be partition.filesystem.win ui_print("\n-- Mounting %s, please wait...\n",bMount); if (tw_mount(bMnt)) { ui_print("-- Could not mount: %s\n-- Aborting.\n",bMount); free(bCommand); free(bMount); free(bImage); return 1; } ui_print("-- Done.\n\n",bMount); } sprintf(bCommand,"du -sk %s | awk '{ print $1 }'",bMount); // check for partition/folder size bFp = __popen(bCommand, "r"); fscanf(bFp,"%d",&bPartSize); __pclose(bFp); sprintf(bCommand,"cd %s && tar %s %s%s ./*",bMount,bTarArg,bDir,bImage); // form backup command } else { strcpy(bMount,bMnt.mnt); bPartSize = bMnt.sze / 1024; sprintf(bImage,"%s.%s.win",bMnt.mnt,bMnt.fst); // non-mountable partitions such as boot/wimax/recovery if (strcmp(bMnt.fst,"mtd") == 0) { sprintf(bCommand,"dump_image %s %s%s",bMnt.mnt,bDir,bImage); // if it's mtd, we use dump image } else if (strcmp(bMnt.fst,"emmc") == 0) { sprintf(bCommand,"dd bs=%s if=%s of=%s%s",bs_size,bMnt.blk,bDir,bImage); // if it's emmc, use dd } ui_print("\n"); } LOGI("=> Filename: %s\n",bImage); LOGI("=> Size of %s is %d KB.\n\n",bMount,bPartSize); int i; char bUppr[20]; strcpy(bUppr,bMnt.mnt); for (i = 0; i < strlen(bUppr); i++) { // make uppercase of mount name bUppr[i] = toupper(bUppr[i]); } ui_print("[%s (%d MB)]\n",bUppr,bPartSize/1024); // show size in MB int bProgTime; time_t bStart, bStop; char bOutput[512]; if (sdSpace > bPartSize) { // Do we have enough space on sdcard? time(&bStart); // start timer bProgTime = bPartSize / bDiv; // not very accurate but better than nothing progress time for progress bar ui_show_progress(1,bProgTime); ui_print("...Backing up %s partition.\n",bMount); bFp = __popen(bCommand, "r"); // sending backup command formed earlier above if(DataManager_GetIntValue(TW_SHOW_SPAM_VAR) == 2) { // if twrp spam is on, show all lines while (fgets(bOutput,sizeof(bOutput),bFp) != NULL) { ui_print_overwrite("%s",bOutput); } } else { // else just show single line while (fscanf(bFp,"%s",bOutput) == 1) { if(DataManager_GetIntValue(TW_SHOW_SPAM_VAR) == 1) ui_print_overwrite("%s",bOutput); } } ui_print_overwrite("....Done.\n"); __pclose(bFp); int pFileSize; ui_print("...Double checking backup file size.\n"); sprintf(bCommand,"ls -l %s%s | awk '{ print $5 }'",bDir,bImage); // double checking to make sure we backed up something bFp = __popen(bCommand, "r"); fscanf(bFp,"%d",&pFileSize); __pclose(bFp); ui_print("....File size: %d bytes.\n",pFileSize); // file size if (pFileSize > 0) { // larger than 0 bytes? if (strcmp(bMnt.fst,"mtd") == 0 || strcmp(bMnt.fst,"emmc") == 0) { // if it's an unmountable partition, we can make sure LOGI("=> Expected size: %d Got: %d\n",bMnt.sze,pFileSize); // partition size matches file image size (they should match!) if (pFileSize != bMnt.sze) { ui_print("....File size is incorrect. Aborting...\n\n"); // they dont :( free(bCommand); free(bMount); free(bImage); return 1; } else { ui_print("....File size matches partition size.\n"); // they do, yay! } } ui_print("...Generating %s md5...\n", bMnt.mnt); makeMD5(bDir,bImage); // make md5 file ui_print("....Done.\n"); ui_print("...Verifying %s md5...\n", bMnt.mnt); checkMD5(bDir,bImage); // test the md5 we just made, just in case ui_print("....Done.\n"); time(&bStop); // stop timer ui_reset_progress(); // stop progress bar output_time(bUppr, "DONE", (int)difftime(bStop,bStart)); tw_unmount(bMnt); // unmount partition we just restored to (if it's not a mountable partition, it will just bypass) sdSpace -= bPartSize; // minus from sd space number (not accurate but, it's more than the real count so it will suffice) } else { ui_print("...File size is zero bytes. Aborting...\n\n"); // oh noes! file size is 0, abort! abort! tw_unmount(bMnt); free(bCommand); free(bMount); free(bImage); return 1; } } else { ui_print("...Not enough space on /sdcard. Aborting.\n"); // oh noes! no space left on sdcard, abort! abort! tw_unmount(bMnt); free(bCommand); free(bMount); free(bImage); return 1; } free(bCommand); free(bMount); free(bImage); return 0; }
void show_time(){ output_time(std::cout,current_time()); std::cout << "\n"; }
int main(int argc, char *argv[]) { /* Clear Screen */ system("clear"); printf("\nBEMRI simulator!\n"); /* Variable Declarations */ BEMRI *b; flags f; iParams iPars; double dt1, dt, tmax, e[3], t, t0, r_min, t_RK4 = 0.0,tau, t_node, sim_time, E0, PbN, dt_test; double r_bemri, r_current, r_node, r_1, r_2, theta_N, ecc_N, theta0h, r_tid, r0; double E1h,E2h,l1h,l2h,e1h,e2h,dAdt, dt_temp, dt_min, fmax[2], alpha = 1e-5, chi, node_phase, E_last, a1h, a2h; double Ph_init,eh_init, Q[3][3], Qtt[3][3], T_pm[4]; double R[3], m[3], timer=1e300; double test_rad, test_angle, del_ia, del_aop, frac = 1.0, max_hard_count, eh0; int xed, a = 0, N=1, single, minned, status, entered_node, passed_node, times_around, max_orbits, num_params; int m1NegY=0, hard_count, agent, amax, astep, nvar, zeroed, angle_counter = 0, inner_runs, ipsval = 1, past; double t_broken, Pb0, Esys0,Lsys0, eb0, Hrat = 3, ri, r_cm, percentage_as_double, gam_now, eb_prev, ab_prev, k1, k2; double e1h_prev, e2h_prev, timer0; long seed, iseed; double y[22],yscal[22],dydx[22], dscale, mconv, tconv; //these are the vectors used for BS integration, 22 = 7*N+1 double lan0, ia0, aop0, ab0; char fname[80]; /* for BS ODE integrator setup */ for(int i=0;i<22;i++) yscal[i] = 1; /* Vector from observer to system center of mass */ R[0] = 0; R[1] = 0; R[2] = 2.45027686e20; //distance to Sgr A* /* timing variables */ time_t start; time_t stop; struct timeval t1; /* command line argument check */ //possible flags: // -c run to completion // -s [value] use value for seed // -t [value] run to tmax = value*Ph // -nd do not stop sim when BEMRI is disrupted // -N [value] run simulation N times, do not output position or quadrupole data // -so suppress any screen output // -PbN [value] set Pb = value*tnode // -th0 [value] set theta0 = value // -RK4 use RK4 integrator instead of BS2 // -fname [string] use string as file name instead of BEMRI.dat // -fpars [string] use string as filename to find input parameters // -beta [value] use beta = value // -gam [value] use gamma = value // -ips [value] run [value] runs per set of parameters, sampling initial phases // -eh [value] set BH orbit eccentricity // -Htest Test Heggie values // -Hrat [value] Use [value] for rp/a ratio in Heggie test // -geo Use geometricized units -- G = c = 1 // -ang Randomize binary orientation angles b = (BEMRI *) malloc( sizeof(BEMRI) ); if(args(argc,argv,&iPars,&f,&N,&frac,&seed,&PbN,fname,&eh,&ipsval,&Hrat)) return 1; /* initialize BEMRI parameters */ init_params(b,f); /* file pointer declarations */ FILE *results_fp, *Q_fp, *pos_fp; if(f.fnameflag == 0) results_fp = fopen("BEMRI.dat","w"); else results_fp = fopen(fname,"w"); if(f.cflag != 1 && f.Nflag != 1) { Q_fp = fopen("QP.dat","w"); pos_fp = fopen("pos.dat","w"); } /* Chain declaration */ C = (CHAIN *) malloc( sizeof(CHAIN) ); /* set seed if not given on command line */ if(f.sflag == 0) {gettimeofday(&t1,NULL); seed = t1.tv_usec;} iseed = seed; //save initial seed to output /* master loop, changes parameters */ /* this is the total number of unique (gamma,inc,lan) values that will be run */ for(int ii=0;ii<N;ii++) { /* randomly assign angles if -ang flag is used */ if(f.angflag) // angle variation { iPars.lanA = 2*PI*ran2(&seed); iPars.incA = acos(2*ran2(&seed)-1); } /* if not using random angles OR a parameter file, then assign angles of zero */ else if(!f.fParflag) iPars.lanA = iPars.incA = 0.0; /* assign random gamma value unless certain flags are used */ if(!f.fParflag && !f.betaflag && !f.gamflag){ iPars.gamma = (0.35 + 4.65*ran2(&seed)); // randomly assigning beta from being uniform over gamma iPars.beta = 1.0/iPars.gamma; } /* starting the loop over all theta0 initial binary phase values */ for(angle_counter = 0; angle_counter<ipsval; angle_counter++) { /* set G and c, which will be reset if -geo is used */ c = 299792458e0; G = 6.673e-11; /* reset timer and m1NegY */ timer = 1e300; m1NegY = 0; /* parameter setup */ init_params(b,f); // initialize BEMRI parameters eb = 0.0; aop = 0.0; // aop is redundant for circular orbits, always set to 0 lan = iPars.lanA; // set dynamic value lan ia = iPars.incA; // set dynamic value ia if(!f.th0flag && !f.fParflag && f.ipsflag) // assign appropriate value of th0 if using -ips flag iPars.th0 = 2*PI * (float)angle_counter/ipsval; //only set theta0 if th0flag has NOT been set /* Setup for testing results from Heggie and Rasio paper */ if(f.Htflag == 1) { G = c = 1; ia = 0; lan = 0; aop = 0; m1 = m2 = 1; m3 = 1; ab = 1; eb = 0.0; eh = 1.0; rph = Hrat*ab; r0 = 100*rph; theta0h = -acos(2*rph/r0 - 1); Pb = 2*PI*sqrt(ab*ab*ab/(G*(m1+m2))); } /* setup for elliptical BEMRI */ else if(eh < 1) theta0h = PI; /* Setup for parabolic orbit evolution */ else if(eh >= 1) { if(f.geoflag) // if using geometricized units { mconv = G/(c*c); // conversion factor for masses tconv = c; G = c = 1.0; // set constants to 1 //ab /= dscale; m1 *= mconv; // convert mass values to meters m2 *= mconv; m3 *= mconv; Pb *= tconv; // recalculate the binary period with new ab and masses } r_tid = ab*pow(m3/(m1+m2),1.0/3.0); // calculate tidal radius r_tid rph = r_tid/iPars.beta; // calculate pericenter distance for BEMRI orbit r0 = 200.0*rph; // calculate r0 = initial separation theta0h = -acos(2.0*rph/r0 - 1.0); // calculate corresponding true anomaly if(isnan(theta0h) || fabs(theta0h) < 2.0) // see if the anomaly was in acceptable range theta0h = -2.0; // if not, just set to -2.0 radians //theta0h = -3.0; } /* recalculate BEMRI parameters using new values */ recalc_params(b); /* initial conditions and node passage time */ lh = sqrt(rph*(1+eh)*G*(m3*m3*m4*m4)/(m3+m4)); //initial angular momentum of SMBH orbit advance_orbit(&(b->binary_h),lh,theta0h); //begin cm-SMBH orbit at theta0h /* timestep tau and max simulation time tmax */ if(f.Htflag == 1) { tau = Pb/pow(2,7); tmax = 1e100; } else if(eh<1) { tau = Pb/pow(2,7); tmax = 1*Pb; } else { tau = Pb/pow(2,7); tmax = 1e100; } recalc_params(b); // update little binary positions and velocities for orbit around hole lb = sqrt(rpb*(1+eb)*G*(m1*m1*m2*m2)/(m1+m2)); //initial angular momentum of BEMRI advance_orbit(&(b->binary_b),lb,iPars.th0); //begin BEMRI at theta0 BEMRI_CM_update(b); load_vectors(rr,vv,m,b); //load initial values into working vectors dt = tau; dt1 = dt; /* Chain setup and testing */ setup_chain(C,m,3); nvar = 6*(C->N-1); /* BEMRI lifetime check */ if ( peters_lifetime(eb,ab,m1,m2) < 100*Ph ) //BEMRI lifetime too short, abort current run {status = 3;times_around = -1;} /* other setup */ eh0 = eh; t0 = 0; zeroed = 0; t_broken = 0.0; xed = 0; minned = 0; t_RK4 = 0.0; status = 0; entered_node = 0; passed_node = 0; times_around = 0; max_orbits = 1; a = -1; if(eh < 1) amax = (int)(abs((tmax-t0)/dt1)); else amax = 1e6; astep = 1;//(int)ceil((amax/200000.0)); //output management start = time(NULL); max_hard_count = 20; hard_count = 0; Pb0 = Pb; ri = sqrt( pow(X4-X3,2) + pow(Y4-Y3,2) + pow(Z4-Z3,2) ); // initial distance from binary cm to SMBH k1 = G*m3*m1; k2 = G*m3*m2; /* initial energy setup */ calc_energies(b,&E1h,&E2h); E0 = Eb; eb0 = eb; ab0 = ab; E_last = E0; //initialize E_last calc_total_energy(b); // compute total system energy calc_total_angular_momentum(b); // compute total system ang. mom. Esys0 = b->energy; Lsys0 = b->L; /* print out some diagnostic info */ if(!f.Nflag) { printf("\nbeta = %.3f",iPars.beta); printf("\ngamma = %.3f",iPars.gamma); printf("\nt_max = %.3e",tmax); printf("\ntheta0h = %.3e",theta0h); printf("\ntheta0 = %.10e",iPars.th0); printf("\nab = %.4e",ab); printf("\nPb = %.4e",Pb); printf("\nr_cm0 = %.4e",ri); printf("\nG = %.3e\nc = %.3e",G,c); printf("\nia = %.3f\tlan = %.3f\n",ia*180/PI,lan*180/PI); if(angle_counter==0) anykey(); } /* main simulation loop */ while( f.cflag*times_around < 100 && times_around >= 0 && t_RK4 <= tmax ) //something should happen before this, but if not... { /* this while loop will run under one of two conditions: if the -c flag is used, then completion = 1 and tmax = HUGE, so it will run until times_around < 100. If the -t or no flag is used, then completion = 0 and the sim will run until t_RK4 = tmax. */ gam_now = ah*(1-eh)/(ab*pow(m3/(m1+m2),1.0/3.0)); if( !f.Nflag ) { printf("t_RK4 = %.3e\r",t_RK4); //printf("Y1 = %.3e\r",Y1); fflush(stdout); } /* upkeep */ a += 1; E_last = Eb; //store old BEMRI energy eb_prev = eb; e1h_prev = e1h; e2h_prev = e2h; ab_prev = ab; /* actual integration call */ if(!f.bs2flag) { pack_y_vector_C(C,y); leap_derivs2(t_RK4,y,dydx); for(int i=0;i<nvar;i++) yscal[i]=FMAX(fabs(y[i])+fabs(dydx[i]*dt)+TINY,1); //bs_const_step(y,nvar,&t_RK4,dt1,&dt,1e-12,1e-6,yscal,1,leap_derivs2); bsstep(y,nvar,&t_RK4,&dt1,1e-12,1e-9,yscal,1,leap_derivs2); unpack_y_vector_C(C,y); if(a%10 == 0) check_chain(C); update_momenta(C); update_positions(C); } else{ //t_RK4 += N_body_main(rr,vv,m,dt1,3,&dt,1e-8,&minned); //evolves orbit from time t to t+dt1 with initial step size dt pack_y_vector(rr,vv,m,y); RK4A_const_step(y,22,&t_RK4,dt1,&dt,1e-9,1e-6,Nbody_derivs1); unpack_y_vector(rr,vv,m,y); } update_binaries(b,rr,vv); //copies values from v and r into the structures CM_values(b); //calculate values for the center of mass if(dt > dt1) //keeps integration step size at maximum of dt1 dt = dt1; timer -= dt1; // update timer value /* calculate desired values */ calc_angles(&(b->binary_b)); // calculate current orbital angles past = true_anomaly(&(b->binary_h)); // calculate current true anomaly of BH orbit calc_energies(b,&E1h,&E2h); // compute current binding energies calc_angular_momenta(b,&l1h,&l2h); // compute current pairwise angular momenta calc_ecc(b,&e1h,&e2h,E1h,E2h,l1h,l2h); // compute current pairwise eccentricities calc_total_energy(b); // compute total system energy calc_total_angular_momentum(b); // compute total system ang. mom. r_bemri = sqrt( pow(X1-X2,2) + pow(Y1-Y2,2) + pow(Z1-Z2,2)); //BEMRI separation r_1 = sqrt( pow(X1-X3,2) + pow(Y1-Y3,2) + pow(Z1-Z3,2) ); // m1-SMBH separation r_2 = sqrt( pow(X2-X3,2) + pow(Y2-Y3,2) + pow(Z2-Z3,2) ); // m2-SMBH separation r_current = min(r_1,r_2); //current distance from SMBH to closest BEMRI component r_cm = sqrt( pow(X4-X3,2) + pow(Y4-Y3,2) + pow(Z4-Z3,2) ); ab = E_to_a(Eb,m1,m2); //update semi-major axis of the BEMRI ah = E_to_a(Eh,m3,m1+m2); //update semi-major axis of the BH orbit Pb = 2*PI*sqrt(pow(ab,3)/(G*(m1+m2))); //current orbital periods Ph = 2*PI*sqrt(pow(ah,3)/(G*(m1+m2+m3))); b->binary_b.rp = ab*(1-eb); // compute new binary periapse b->binary_h.rp = ah*(1-eh); // compute new BEMRI periapse point_mass_QP(m,rr,3,R,Q,Qtt); // compute GW output if(eh<1) r_node = ah*(1-eh*eh); //SMBH-BEMRI separation when BEMRI is at the node /* stopping conditions */ if(eh0 < 1 || f.ipsflag==0) // for elliptical BEMRIs or single runs { if( passed_node && theta_h >= PI ) //if BEMRI has passed the node AND passed apoapse { passed_node = 0; //reset passed_node times_around += 1; //increment times_around if( (Eb/E_last) > 1 ) //compare current Eb to last orbit's initial Eb hard_count++; //the BEMRI has hardened, increment hard_count else hard_count = 0; //the BEMRI has softened, reset hard_count if( hard_count == max_hard_count) { status = 2; break; } E_last = Eb; } if(r_current < r_node && entered_node == 0) //updates values for overall while loop condition, don't want to update while BEMRI is in the node. { entered_node = 1; //then the node has been entered theta_N = theta_b; //save the phase when BEMRI entered the node ecc_N = eb; } if(r_current > r_node && entered_node == 1) //if BEMRI has just left the node { passed_node = 1; //set passed_node entered_node = 0; //reset entered_node } } /* if m1 has gone into negative y territory, start the clock */ if(Y1<=0 && !m1NegY){ m1NegY = 1; timer0 = t_RK4; timer = t_RK4; printf("\nTimer started!\n"); } /* if timer has gone off, then break */ if(timer<=0) { // printf("TIMER! eb=%.3e | e1h = %.3e | e2h = %.2e\n",eb,e1h,e2h); if(fabs(eb_prev-eb)/eb <1e-9 && k1/r_1 > Eb && k2/r_2 > Eb) { status = 0; printf("No change condition met\n"); break; } else if(fabs(e1h_prev-e1h)/e1h < 1e-9 || fabs(e2h_prev-e2h)/e2h < 1e-9) { status = 0; printf("No change condition met\n"); break; } } if(f.Htflag == 1 && r_cm > ri ) // if { status = 0; break; } if(r_bemri < 2*R_NS && G < 1) { status = -1; break; } //Energy conservation check if( fabs(Esys0 - b->energy) / fabs(Esys0) > 1e-6 ) { status = -3; printf("\nenergy violation\nEsys0 = %.10e\nEsys(t) = %.10e\n",Esys0,b->energy); break; } // angular momentum conservation check if( fabs(Lsys0 - b->L) / fabs(Lsys0) > 1e-6 ) { status = -4; printf("\nAng. mom violation\nLsys0 = %.10e\nLsys(t) = %.10e\n",Lsys0,b->L); break; } /* print progress */ if(f.cflag == 1 && f.soflag==0) { printf("Current Theta: %.3f\tOrbits Completed: %d\r",theta_h,times_around); fflush(stdout); } else if(f.soflag==0 && eh0 < 1) { if(print_percentage(a,ii,t_RK4,tmax,ipsval)) { xed = 1; status = -2; fflush(stdout); break; } } /* Full Data Output */ if(a%astep == 0 && f.cflag != 1 && f.Nflag != 1) { output_time(t_RK4+dt1,pos_fp); output_positions(rr,b,pos_fp); fprintf(pos_fp,"%.10e,%.10e,%.10e,%.10e,%.10e,",Eb,Eh,b->energy,b->L,eb); fprintf(pos_fp,"\n"); output_QP(Qtt, Q_fp); } } // END OF CURRENT SINGLE RUN /* initial clean up */ stop = time(NULL); sim_time = difftime(stop,start)/60.0; a1h = E_to_a(E1h,m1,m3); a2h = E_to_a(E2h,m2,m3); /* print percentage if eh0 >= 1 */ if(f.soflag==0 && eh0 >= 1) { print_percentage(0,ii,angle_counter,ipsval,N); printf("\nde = %.10e\n",eb - eb0); } /* assign proper status if came out with a zero */ if(status==0) { if(Eb>0) // binary disrupted status=0; else if(Eh < 0) // binary survived, bound to SMBH status=1; else status=2; } /* final state output */ if(Eb < 0) { e1h = e2h = -1; } fprintf(results_fp,"%d,%ld,",status,iseed); fprintf(results_fp,"%.4e,%.4e",t_RK4,timer0); fprintf(results_fp,"%.10e,%.10e,%.10e,%.10e,%.10e,",eb0,eb,eh,e1h,e2h); fprintf(results_fp,"%.10e,%.10e,%.10e,%.10e,%.10e,",ab0,ab,ah,a1h,a2h); fprintf(results_fp,"%.10e,%.10e,%.10e,%.10e,%.10e,",Eh,E1h,E2h,E0,Esys0); fprintf(results_fp,"%.10e,%.10e,%.10e,%.10e,",lh,l1h,l2h,Lsys0); fprintf(results_fp,"%.10e,%.10e,%.10e,%.10e",iPars.incA,iPars.lanA,iPars.th0,iPars.gamma); fprintf(results_fp,"\n"); /* status codes: */ //-4: ang. mom. conservation violation //-3: energy conservation violation //-2: run manually canceled //-1: simulation halted due to BEMRI proximity //0 : good simulation, BEMRI disrupted //1 : good simulation, BEMRI survived but bound to SMBH //2 : good simulation, BEMRI survived and remained unbound //3 : lifetime for given parameters was too short } // END OF CURRENT ANGLE_COUNTER LOOP /* 100% print */ if(xed == 0 && f.cflag == 0 && f.soflag==0) { fflush(stdout); printf("Running %d of %d... (100%%)\n\r",ii+1,N); printf("\n\r"); } } // END OF OVERALL N LOOP /* file clean up */ fclose(results_fp); if(f.cflag != 1 && f.Nflag != 1) { fclose(pos_fp); fclose(Q_fp); } printf("\nfcount = %d\n",fcount); free(b); free(C); return 0; }
std::string time2string(const fine_timet &fine_time) { std::ostringstream out; output_time(fine_time, out); return out.str(); }
int main(int argc, char *argv[]){ MPI_Init(&argc, &argv); MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &shmcomm); MPI_Comm_size(MPI_COMM_WORLD, &numprocs); MPI_Comm_rank(MPI_COMM_WORLD, &myid); double t_begin; int i, j, k, ii, id, id1; t_begin = MPI_Wtime(); // record the begining CPU time read_param(); lattice_vec(); allocate(); p_allocate(); if (flow_on!=0) { build_stream(); } if (Q_on!=0) { build_neighbor(); } init_surf(); add_patch(); p_init(); p_iden(); init(); if (flow_on!=0) cal_fequ(f); if (Q_on!=0) cal_dQ(); if (Q_on!=0 && flow_on!=0 && newrun_on!=0) { while(qconverge==0) { t_current++; for (ii=0; ii<n_evol_Q; ii++) { cal_dQ(); evol_Q(); } if (t_current%t_print==0) monitor(); } e_tot =-1; k_eng =-1; qconverge = 0; uconverge = 0; t_current =-1; } if (Q_on!=0 && flow_on!=0) { cal_W(); cal_stress(); cal_sigma_p(); } MPI_Barrier(MPI_COMM_WORLD); output1(1,'z',Nx/2,Ny/2); output3(1); if(myid==0) printf("Q initialized\n"); MPI_Barrier(MPI_COMM_WORLD); while (t_current<t_max && uconverge*qconverge==0) { e_toto=e_tot; if (Q_on!=0 && qconverge==0) { if (flow_on!=0 && uconverge==0) cal_W(); for (ii=0; ii<n_evol_Q; ii++) { cal_dQ(); evol_Q(); } } if (flow_on!=0 && uconverge==0) { if (Q_on!=0 && qconverge==0) { cal_stress(); cal_sigma_p(); } evol_f(f,f2); } if (Q_on!=0 && qconverge==0) { if (flow_on!=0 && uconverge==0) cal_W(); for (ii=0; ii<n_evol_Q; ii++) { cal_dQ(); evol_Q(); } } if (flow_on!=0 && uconverge==0) { if (Q_on!=0 && qconverge==0) { cal_stress(); cal_sigma_p(); } evol_f(f2,f); } if (t_current%t_print==0) monitor(); if (t_current%t_write==0) { output1(0,'z',Nx/2,Ny/2); output3(0); fflush(stdout); } t_current++; } output_time(t_begin); output1(0,'z',Nx/2,Ny/2); output3(0); write_restart(); p_deallocate(); deallocate(); return 0; }
void printlist(My402List *list) { My402ListElem* tmp1; tfile_list* tmp2; char *buf; tmp1=My402ListFirst(list); tmp2=(tfile_list*)tmp1->obj; //char* t; buf = (char *)malloc(20*sizeof(char)); char flaw[]="?,???,???.??"; int total=0; double f_total; double f_tot; char *str; str=(char*)malloc(sizeof(str)); //t = (char*) malloc(20*sizeof(char)); printf("12345678901234567890123456789012345678901234567890123456789012345678901234567890\n"); printf("+-----------------+--------------------------+----------------+----------------+\n"); printf("| Date | Description | Amount | Balance |\n"); printf("+-----------------+--------------------------+----------------+----------------+\n"); while ((tmp1!=My402ListLast(list)) | (tmp1==My402ListLast(list))) { output_time(tmp2->tran_time,buf); //float i=atof(tmp2->tran_amount); float i=atof(tmp2->tran_amount); //printf("i value is =%lf\n",i); double convert_factor=100.00; int cent=round(i*convert_factor); //printf("cent is=%d\n",cent); if (strncmp(tmp2->tran_type,"-",2)==0) { total=total-cent; //printf("Balance=%s\n",total); } else { total=total+cent; //printf("Balance=%s\n",total); } //printf("Total=%d\n",total); f_total=(double)total/100; if(f_total<0) { f_tot=-f_total; //printf("f_total=%f\n",f_total); } //printf("Final_total=%lf\n",f_total); str=comma_dots(i); if ((strncmp(tmp2->tran_type,"-",2)==0) && (atof)(tmp2->tran_amount)<10000000 && (-10000000<f_total) && (f_total<0)) { fprintf(stdout,"| %14s | %-24s | (%11s) | (%12.2f) |\n",buf,tmp2->tran_desc,str,f_tot); } else if ((strncmp(tmp2->tran_type,"-",2)==0) && (atof)(tmp2->tran_amount)<10000000 && (0<f_total) && (f_total<10000000)) { fprintf(stdout,"| %14s | %-24s | (%11s) | %14.2f |\n",buf,tmp2->tran_desc,str,f_total); } else if ((strncmp(tmp2->tran_type,"-",2)==0) && (atof)(tmp2->tran_amount)<10000000 && (f_total>10000000)) { fprintf(stdout,"| %14s | %-24s | (%11s) | %13.2s |\n",buf,tmp2->tran_desc,str,flaw); } else if ((strncmp(tmp2->tran_type,"-",2)==0) && (atof)(tmp2->tran_amount)<10000000 && (f_total<=-10000000)) { fprintf(stdout,"| %14s | %-24s | (%11s) | (%12.2s) |\n",buf,tmp2->tran_desc,str,flaw); } else if ((strncmp(tmp2->tran_type,"-",2)==0) && (atof)(tmp2->tran_amount)>=10000000 && (0<f_total) && (f_total<10000000)) { fprintf(stdout,"| %14s | %-24s | (%11s) | %14.2f |\n",buf,tmp2->tran_desc,flaw,f_total); } else if ((strncmp(tmp2->tran_type,"-",2)==0) && (atof)(tmp2->tran_amount)>=10000000 && (f_total>=10000000)) { fprintf(stdout,"| %14s | %-24s | (%11s) | %13.2s |\n",buf,tmp2->tran_desc,flaw,flaw); } else if ((strncmp(tmp2->tran_type,"-",2)==0) && (atof)(tmp2->tran_amount)>=10000000 && (-10000000<f_total)&& (f_total<0)) { fprintf(stdout,"| %14s | %-24s | (%11s) | (%12.2f) |\n",buf,tmp2->tran_desc,flaw,f_tot); } else if ((strncmp(tmp2->tran_type,"-",2)==0) && (atof)(tmp2->tran_amount)>=10000000 && (f_total<-10000000)) { fprintf(stdout,"| %14s | %-24s | (%11s) | (%12.2s) |\n",buf,tmp2->tran_desc,flaw,flaw); } else if ((strncmp(tmp2->tran_type,"+",2)==0) && (atof)(tmp2->tran_amount)<10000000 && (0<f_total) && (f_total<10000000)) { fprintf(stdout,"| %14s | %-24s | %13s | %14.2f |\n",buf,tmp2->tran_desc,str,f_total); } else if ((strncmp(tmp2->tran_type,"+",2)==0) && (atof)(tmp2->tran_amount)<10000000 && (f_total>=10000000)) { fprintf(stdout,"| %14s | %-24s | %13s | %13.2s |\n",buf,tmp2->tran_desc,str,flaw); } else if ((strncmp(tmp2->tran_type,"+",2)==0) && (atof)(tmp2->tran_amount)<10000000 && (-10000000<f_total) && (f_total<0)) { fprintf(stdout,"| %14s | %-24s | %13s | (%12.2f) |\n",buf,tmp2->tran_desc,str,f_tot); } else if ((strncmp(tmp2->tran_type,"+",2)==0) && (atof)(tmp2->tran_amount)<10000000 && (f_total<=-10000000)) { fprintf(stdout,"| %14s | %-24s | %13s | (%12.2s) |\n",buf,tmp2->tran_desc,str,flaw); } else if ((strncmp(tmp2->tran_type,"+",2)==0) && (atof)(tmp2->tran_amount)>10000000 && (0<f_total) && (f_total<10000000)) { fprintf(stdout,"| %14s | %-24s | %13s | %14.2f |\n",buf,tmp2->tran_desc,flaw,f_total); } else if ((strncmp(tmp2->tran_type,"+",2)==0) && (atof)(tmp2->tran_amount)>10000000 && (f_total>=10000000)) { fprintf(stdout,"| %14s | %-24s | %13s | %13.2s |\n",buf,tmp2->tran_desc,flaw,flaw); } else if ((strncmp(tmp2->tran_type,"+",2)==0) && (atof)(tmp2->tran_amount)>10000000 && (-1000000<f_total) && (f_total<0)) { fprintf(stdout,"| %14s | %-24s | %13s | (%12.2f) |\n",buf,tmp2->tran_desc,flaw,f_tot); } else { fprintf(stdout,"| %14s | %-24s | %13s | (%12.2s) |\n",buf,tmp2->tran_desc,flaw,flaw); } if (tmp1!=My402ListLast(list)){ tmp1 = My402ListNext(list,tmp1); tmp2 = (tfile_list*)tmp1->obj;} else break; } //printf("Total=%d\n",total); f_total=(float)total/100; //printf("Final_total=%f\n",f_total); //f_t=f_total/1000000; printf("+-----------------+--------------------------+----------------+----------------+\n"); }
void Output::DebugStr(std::string const& msg) { output_time() << "Debug:\n " << msg <<std::endl; }
/*ARGSUSED*/ static int delay_fh(int outbytes, int width, format_key_t *key, struct radutmp *up) { return output_time(up->delay, width, key); }