00001
00031
00032
00033
00034 #include "sigma3.h"
00035
00036 #ifdef TOOLBOX
00037
00038 main(int argc, char **argv)
00039 {
00040 int debug = 0;
00041 int seed = 0;
00042 int n_rand = 0;
00043 real max_trial_density = 1.0;
00044
00045 real cpu_time_check = 3600;
00046 real dt_snap = VERY_LARGE_NUMBER;
00047 real snap_cube_size = 10;
00048 int scatter_summary_level = 0;
00049
00050 bool print_counts = FALSE;
00051 bool intermediate_sigma = TRUE;
00052
00053
00054
00055 bool pvm = false;
00056 if (strstr(argv[0], ".pvm")) {
00057
00058 #ifndef HAS_PVM // Compile-time check.
00059 err_exit("PVM not available");
00060 #endif
00061 if (getenv("PVM_ROOT") == NULL)
00062 err_exit("PVM not available");
00063
00064 pvm = true;
00065 }
00066
00067 check_help();
00068
00069 scatter_profile prof;
00070 make_standard_profile(prof);
00071
00072 extern char *poptarg;
00073 int c;
00074 char* param_string = "A:c:C:d:D:e:g:Im:M:N:pqQs:v:V:x:y:z:";
00075
00076 while ((c = pgetopt(argc, argv, param_string)) != -1)
00077 switch(c) {
00078 case 'A': prof.eta = atof(poptarg);
00079 break;
00080 case 'c': cpu_time_check = 3600*atof(poptarg);
00081 break;
00082 case 'C': if (!pvm)
00083 snap_cube_size = atof(poptarg);
00084 else
00085 cerr << "\"-C\" option disallowed in PVM mode\n";
00086 break;
00087 case 'd': max_trial_density = atof(poptarg);
00088 break;
00089 case 'D': if (!pvm) {
00090 dt_snap = atof(poptarg);
00091 scatter_summary_level = 2;
00092 } else
00093 cerr << "\"-D\" option disallowed in PVM mode\n";
00094 break;
00095 case 'e': prof.ecc = atof(poptarg);
00096 prof.ecc_flag = 1;
00097 break;
00098 case 'g': prof.tidal_tol_factor = atof(poptarg);
00099 break;
00100 case 'I': intermediate_sigma = 1 - intermediate_sigma;
00101 break;
00102 case 'm': prof.m2 = atof(poptarg);
00103 break;
00104 case 'M': prof.m3 = atof(poptarg);
00105 break;
00106 case 'N': n_rand = atoi(poptarg);
00107 break;
00108 case 'p': print_counts = 1 - print_counts;
00109 break;
00110 case 'q': if (scatter_summary_level > 0)
00111 scatter_summary_level = 0;
00112 else
00113 scatter_summary_level = 1;
00114 break;
00115 case 'Q': if (scatter_summary_level > 0)
00116 scatter_summary_level = 0;
00117 else
00118 scatter_summary_level = 2;
00119 break;
00120 case 's': seed = atoi(poptarg);
00121 break;
00122 case 'v': prof.v_inf = atof(poptarg);
00123 break;
00124 case 'V': debug = atoi(poptarg);
00125 break;
00126 case 'x': prof.r1 = atof(poptarg);
00127 break;
00128 case 'y': prof.r2 = atof(poptarg);
00129 break;
00130 case 'z': prof.r3 = atof(poptarg);
00131 break;
00132 case '?': params_to_usage(cerr, argv[0], param_string);
00133 get_help();
00134 }
00135
00136
00137
00138
00139
00140
00141
00142
00143 cpu_init();
00144
00145 sigma_out out;
00146 int first_seed = srandinter(seed, n_rand);
00147
00148 cerr << "random seed = " << first_seed << endl;
00149 print_profile(cerr, prof);
00150
00151
00152
00153
00154 int k = 0;
00155 real init_dens = max_trial_density;
00156
00157 if (intermediate_sigma) {
00158 int min_dens = (pvm ? 16 : 4);
00159 while (init_dens > min_dens) {
00160 k++;
00161 init_dens /= 4;
00162 }
00163 }
00164
00165
00166
00167 for (real max_dens = init_dens; k >= 0; k--, max_dens *= 4) {
00168 get_sigma3(max_dens, prof, out,
00169 debug, cpu_time_check,
00170 dt_snap, snap_cube_size,
00171 scatter_summary_level);
00172 print_sigma3(out, prof.v_inf * prof.v_inf);
00173 if (print_counts) print_all_sigma3_counts(out, cerr);
00174 }
00175
00176 }
00177
00178 #endif