Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

rs_scenarios.C

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 //----------------------------------------------------------------------------
00017 //   version 1:  Sept 1998   Simon Portegies Zwart   spz@grape.c.u-tokyo.ac.jp
00018 //                                                   University of Tokyo
00019 //   version 2:  July 2000  Simon Portegies Zwart   spz@mit.edu
00020 //                          Gijs Nelemans           gijsn@astro.uva.nl
00021 //............................................................................
00022 //   non-local functions: 
00023 //----------------------------------------------------------------------------
00024 
00025 
00026 #include "SeBa_hist.h"
00027 
00028 #define MAX_NSCENARIOS 5000
00029 
00030 #ifdef TOOLBOX
00031 local int extract_scenarios(SeBa_hist *hi, const real end_time) {
00032 
00033   int N_read = 0;
00034 
00035   SeBa_hist *scenarios[MAX_NSCENARIOS];
00036   int scenario_frequency[MAX_NSCENARIOS];
00037 
00038   for(int i=0; i< MAX_NSCENARIOS; i++) {
00039     scenarios[i] = NULL;
00040     scenario_frequency[i] = 0;
00041   }
00042   int N_scenarios = 0;
00043 
00044   SeBa_hist* next_hi = get_history(hi, cin);
00045   N_read++;
00046 //    cerr << "Print next_hi"<<endl;
00047 //    for_all_SeBa_hist(SeBa_hist, hi, ha) {
00048 //      cerr << *ha;
00049 //    }
00050 //    cerr << "Printed"<<endl;
00051 
00052   scenarios[N_scenarios] = hi;
00053   scenario_frequency[N_scenarios]++;
00054   N_scenarios++;
00055 //  delete hi;
00056   hi = next_hi;
00057   next_hi = get_history(hi, cin);
00058   N_read++;
00059   bool new_entry;
00060   do {
00061 
00062     new_entry = true;
00063 
00064     for(int i = 0; i<N_scenarios; i++) {
00065       
00066       if(scenarios_identical(hi, scenarios[i])) {
00067         new_entry = false;
00068         scenario_frequency[i]++;
00069         break;
00070       }
00071     }
00072 
00073     if(new_entry) {
00074       scenarios[N_scenarios] = hi;
00075       scenario_frequency[N_scenarios]++;
00076       
00077       N_scenarios++;
00078       if(N_scenarios >= MAX_NSCENARIOS)
00079         break;
00080     }    
00081 
00082     if(!new_entry)
00083       delete hi;
00084 
00085     hi = next_hi;
00086     next_hi = get_history(hi, cin);
00087     N_read++;
00088   }
00089   while (next_hi);
00090 
00091   int i=0;
00092 #if 0
00093   cerr << "print all scenarios"<<endl;
00094   do {
00095 
00096     for_all_SeBa_hist(SeBa_hist, scenarios[i], ha)
00097       cerr << *ha;
00098     i++;
00099   }
00100   while(scenarios[i]!=NULL);
00101 #endif
00102 
00103   cerr << "Scn. # \t freq." << endl;
00104   for(i=0; i<N_scenarios; i++) {
00105     cerr << i << "\t" << scenario_frequency[i] << ":  "; 
00106     put_state(scenarios[i], cerr);
00107   }
00108 
00109   cerr << "Binaries read = " << N_read-1 << endl;
00110   return N_scenarios;
00111 } 
00112 
00113 //----------------------------------------------------------------------------
00114 //  main  --  driver to reduce SeBa short dump data
00115 //----------------------------------------------------------------------------
00116 
00117 main(int argc, char ** argv) {
00118 
00119     real end_time = VERY_LARGE_NUMBER;
00120 
00121     char  *comment;
00122     check_help();
00123 
00124     extern char *poptarg;
00125     int c;
00126     char* param_string = "T:";
00127 
00128     while ((c = pgetopt(argc, argv, param_string)) != -1)
00129         switch(c)
00130             {
00131             case 'T': end_time = atof(poptarg);
00132                       break;
00133             case '?': params_to_usage(cerr, argv[0], param_string);
00134                       get_help();
00135                       exit(1);
00136             }            
00137 
00138 
00139     SeBa_hist* hi = new SeBa_hist;
00140     if (!hi->read_SeBa_hist(cin))
00141       exit(-1);
00142 
00143     if(end_time<VERY_LARGE_NUMBER)
00144       cerr << "End time = " << end_time << " [Myr]" << endl << endl;
00145 
00146     int N_scenarios = extract_scenarios(hi, end_time); 
00147 
00148 
00149     cerr << "Total number of scenarios recognized: " << N_scenarios << endl;
00150 }
00151 
00152 #endif // endof: TOOLBOX
00153 
00154 
00155 

Generated at Sun Feb 24 09:57:13 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001