00001 /* 00002 * red_stellar system.C: reduce some useful information from the 00003 * stellar system 00004 *............................................................................. 00005 * version 1: Jan 1997 Simon Portegies Zwart email: spz@astro.uva.nl 00006 *............................................................................. 00007 * non-local function: 00008 * all functions are local 00009 *............................................................................. 00010 * Input options: 00011 * -B: Binning option of the Lagrangian radii. 00012 * -C: Cut off creterium, mass, luminosity, number of stars. 00013 * -l: Lower luminosity limit (see below). 00014 * -n: Number of Lagrangian radii bins. 00015 * Might for some choises be forced. 00016 * -O: Output option, what information should be studied. 00017 * -o: Output the story with data written in root. 00018 * -S: Sort option, on what parameter must information be sorted. 00019 *............................................................................. 00020 * Conserning the Lower luminosity limit option (-l, see above). 00021 * Currently this option is only applied to the sorting functions. 00022 * This means that the binning (using Lagrangian radii) is applied 00023 * on all cluster members. 00024 * whether or not this is realistic depends on the application. 00025 * Consequently, the luminosity cut-off does not affect the 00026 * Lagrangian radii. 00027 *............................................................................. 00028 */ 00029 #include "stardyn_util.h" 00030 00031 #ifdef TOOLBOX 00032 00033 #define SCRATCH_PAD_LINE_LENGTH 255 00034 00035 //----------------------------------------------------------------------------- 00036 // compare_parameters -- compare parameters of two particles 00037 //----------------------------------------------------------------------------- 00038 00039 local int compare_parameters(const void* pi, const void* pj) 00040 { 00041 if ((*(const real *)pi) > (*(const real *)pj)) 00042 return(1); 00043 else if ((*(const real *)pi) < (*(const real *)pj)) 00044 return(-1); 00045 else 00046 return(0); 00047 } 00048 00049 local void rearrange_mf(dyn* b) { 00050 00051 int n = b->n_daughters(); 00052 00053 int* name = new int[n]; 00054 real* mass = new real[n]; 00055 00056 int i=0; 00057 00058 for_all_daughters(dyn, b, bi) { 00059 00060 name[i] = bi->get_index(); 00061 mass[i] = bi->get_starbase()->conv_m_dyn_to_star(bi->get_mass()); 00062 i++; 00063 } 00064 n=i-1; 00065 qsort((real*)mass, (size_t)n, sizeof(real), compare_parameters); 00066 00067 for (i=0; i<n; i++) 00068 cerr << mass[i] << endl; 00069 } 00070 00071 /*----------------------------------------------------------------------------- 00072 * main -- driver to use compute_mass_radii() as a tool 00073 *----------------------------------------------------------------------------- 00074 */ 00075 main(int argc, char ** argv) 00076 { 00077 char *comment; 00078 bool verbatim = false; 00079 bool c_flag = FALSE; /* if TRUE: a comment given on command line */ 00080 00081 extern char *poptarg; 00082 int c; 00083 char* param_string = "c:"; 00084 00085 dyn *b; 00086 00087 cerr.precision(STD_PRECISION); 00088 while (b = get_dyn(cin)) { 00089 00090 if (c_flag == TRUE) 00091 b->log_comment(comment); 00092 00093 b->log_history(argc, argv); 00094 00095 rearrange_mf(b); 00096 00097 delete b; 00098 } 00099 } 00100 00101 #endif