00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "worldline.h"
00010
00011 local void print_worldline_stats(worldbundleptr wh[], int nh)
00012 {
00013 cerr << endl << "statistics on " << nh << " worldbundle";
00014 if (nh != 1) cerr << "s";
00015 cerr << ":" << endl;
00016
00017 int nwtot = 0, nstot = 0, netot = 0;
00018 for (int ih = 0; ih < nh; ih++) {
00019 worldbundleptr wb = wh[ih];
00020 real t = wb->get_t_min();
00021 int nw = wb->get_nw(), ns = count_segments(wb), ne = count_events(wb);
00022 cerr << "worldbundle " << ih << ": "
00023 << nw << " worldlines, "
00024 << ns << " segments, "
00025 << ne << " events, t = "
00026 << wb->get_t_min() << " to " << wb->get_t_max()
00027 << endl;
00028 nwtot += nw;
00029 nstot += ns;
00030 netot += ne;
00031 }
00032 cerr << "totals: " << nwtot << " worldlines, "
00033 << nstot << " segments, " << netot << " events"
00034 << endl << endl;
00035
00036 for (int ih = 0; ih < nh; ih++)
00037 wh[ih]->check();
00038 }
00039
00040 main(int argc, char** argv)
00041 {
00042 check_help();
00043
00044 real dt = 0.0625;
00045 char infile[128];
00046 strcpy(infile, "run.out");
00047 int nloop = VERY_LARGE_INTEGER;
00048
00049 extern char *poptarg;
00050 char* params = "D:F:L:";
00051 int c;
00052
00053 while ((c = pgetopt(argc, argv, params)) != -1)
00054 switch(c) {
00055
00056 case 'D': dt = atof(poptarg);
00057 if (dt < 0)
00058 dt = pow(2.0, dt);
00059 break;
00060 case 'F': strcpy(infile, poptarg);
00061 break;
00062 case 'L': nloop = atoi(poptarg);
00063 break;
00064 case '?': params_to_usage(cerr, argv[0], params);
00065 get_help();
00066 exit(0);
00067 }
00068
00069 ifstream s(infile);
00070 if (!s) {
00071 cerr << "Data file " << infile << " not found." << endl;
00072 exit(1);
00073 }
00074
00075 worldbundleptr wb, wh[1024];
00076
00077 int nh = 0;
00078 while (nh < 1024 && (wb = read_bundle(s, false))) wh[nh++] = wb;
00079
00080 for (int i = 0; i < 5; i++) cerr << endl;
00081
00082 print_worldline_stats(wh, nh);
00083 preload_pdyn(wh, nh, true);
00084
00085 for (int i = 0; i < 5; i++) cerr << endl;
00086
00087 PRL(nloop);
00088
00089 int ih = 0;
00090 wb = wh[ih];
00091 real t = wb->get_t_min();
00092
00093 int iloop = 0;
00094 while (iloop < nloop) {
00095
00096 real cpu = cpu_time();
00097 pdyn *root = create_interpolated_tree2(wb, t);
00098 cpu = cpu_time() - cpu;
00099 if (abs(cpu) < 1.e-6) cpu = 0;
00100
00101
00102
00103 PRC(t); PRC(root); PRL(root->format_label());
00104 PRI(4); PRC(wb->get_nw()); PRC(root->n_daughters()); PRL(cpu);
00105
00106 for_all_nodes(pdyn, root, p)
00107 if (p->get_worldline_index() < 0) {
00108 PRC(p); PRC(p->format_label()); PRL(p->get_worldline_index());
00109 }
00110
00111 t += dt;
00112
00113
00114
00115 #define EPS 1.e-12
00116
00117 if (dt > 0 && t > wb->get_t_max() + EPS) {
00118 if (++ih >= nh) {
00119 ih = 0;
00120 wb = wh[ih];
00121 t = wb->get_t_min();
00122 iloop++;
00123 PRL(iloop);
00124 } else
00125 wb = wh[ih];
00126 }
00127
00128
00129
00130 if (dt < 0 && t < wb->get_t_min() - EPS) {
00131 if (--ih < 0) {
00132 ih = nh-1;
00133 wb = wh[ih];
00134 t = wb->get_t_max();
00135 iloop++;
00136 PRL(iloop);
00137 } else
00138 wb = wh[ih];
00139 }
00140 }
00141 }