00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "node.h"
00020 #include "double_star.h"
00021 #include "main_sequence.h"
00022 #include "dstar_to_kira.h"
00023 #include "seba.h"
00024
00025 local void putq(story* s, char* l, int i) {putiq (s, l, i);}
00026 local void putq(story* s, char* l, unsigned long i) {putulq(s, l, i);}
00027 local void putq(story* s, char* l, real r) {putrq (s, l, r);}
00028 local void putq(story* s, char* l, vector v) {putvq (s, l, v);}
00029
00030 #define PUTLOG(x) putq(sb->get_star_story(), #x, sb->get_seba_counters()->x);
00031
00032 #define PRLOGC(x) cerr << #x << " = " << sb->get_seba_counters()->x << ", "
00033 #define PRLOGL(x) cerr << #x << " = " << sbc->x; \
00034 if (sbc_prev) cerr << " (" << sbc->x - sbc_prev->x << ")"; \
00035 cerr << endl
00036
00037 void print_counters(seba_counters* sbc, seba_counters* sbc_prev)
00038 {
00039 cerr << "\n Counters: \n";
00040
00041 cerr << " CPU time = " << sbc->cpu_time;
00042 if (sbc_prev)
00043 cerr << " (delta = " << sbc->cpu_time - sbc_prev->cpu_time << ")";
00044 cerr << endl;
00045
00046 PRI(4); PRLOGL(add_dstar);
00047 PRI(4); PRLOGL(del_dstar);
00048
00049 PRI(4); PRLOGL(step_seba);
00050 PRI(4); PRLOGL(step_sstar);
00051 PRI(4); PRLOGL(step_dstar);
00052
00053 PRI(4); PRLOGL(detached);
00054 PRI(4); PRLOGL(semi_detached);
00055 PRI(4); PRLOGL(contact);
00056
00057 PRI(4); PRLOGL(dynamic);
00058 PRI(4); PRLOGL(thermal);
00059 PRI(4); PRLOGL(nuclear);
00060 PRI(4); PRLOGL(aml_driven);
00061
00062 PRI(4); PRLOGL(supernovae);
00063 PRI(4); PRLOGL(first_rlof);
00064 PRI(4); PRLOGL(common_envelope);
00065 PRI(4); PRLOGL(spiral_in);
00066 PRI(4); PRLOGL(double_spiral_in);
00067 PRI(4); PRLOGL(mergers);
00068
00069 PRI(4); PRLOGL(aml_mergers);
00070 PRI(4); PRLOGL(gwr_mergers);
00071
00072 PRI(4); PRLOGL(recursive_overflow);
00073
00074 if (sbc_prev)
00075 *sbc_prev = *sbc;
00076 }
00077
00078 local void write_counters_to_log(starbase* sb)
00079 {
00080
00081
00082 PUTLOG(cpu_time);
00083
00084 PUTLOG(add_dstar);
00085 PUTLOG(del_dstar);
00086
00087 PUTLOG(step_seba);
00088 PUTLOG(step_sstar);
00089 PUTLOG(step_dstar);
00090
00091 PUTLOG(detached);
00092 PUTLOG(semi_detached);
00093 PUTLOG(contact);
00094
00095 PUTLOG(dynamic);
00096 PUTLOG(thermal);
00097 PUTLOG(nuclear);
00098 PUTLOG(aml_driven);
00099
00100 PUTLOG(supernovae);
00101 PUTLOG(first_rlof);
00102 PUTLOG(common_envelope);
00103 PUTLOG(spiral_in);
00104 PUTLOG(double_spiral_in);
00105 PUTLOG(mergers);
00106
00107 PUTLOG(aml_mergers);
00108 PUTLOG(gwr_mergers);
00109
00110 PUTLOG(recursive_overflow);
00111
00112 }
00113
00114
00115
00116 typedef struct {
00117 real dt;
00118 star* s;
00119 } dt_pair, *dt_pair_ptr;
00120
00121 local int compare_dt(const void * pi, const void * pj)
00122 {
00123 if (((dt_pair_ptr) pi)->dt < ((dt_pair_ptr) pj)->dt)
00124 return -1;
00125 else if (((dt_pair_ptr)pi)->dt > ((dt_pair_ptr)pj)->dt)
00126 return +1;
00127 else
00128 return 0;
00129 }
00130
00131 typedef struct {
00132 real count;
00133 star* s;
00134 } count_pair, *count_pair_ptr;
00135
00136 local int compare_steps(const void * pi, const void * pj)
00137 {
00138 if (((count_pair_ptr) pi)->count > ((count_pair_ptr) pj)->count)
00139 return -1;
00140 else if (((count_pair_ptr)pi)->count < ((count_pair_ptr)pj)->count)
00141 return +1;
00142 else
00143 return 0;
00144 }