00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00018
00019
00020
00021 #ifdef TOOLBOX
00022
00023 #include "dyn.h"
00024
00025 main(int argc, char *argv[])
00026 {
00027 bool c_flag = false;
00028 char *comment;
00029
00030 bool J_flag = false;
00031 real input_r_jacobi = -1;
00032
00033
00034
00035
00036 bool F_flag = false;
00037 int tidal_field_type = 0;
00038
00039 check_help();
00040
00041 extern char *poptarg;
00042 int c;
00043 char* param_string = "c:F:J:";
00044
00045 dyn *b = get_dyn(cin);
00046 if (b == NULL) err_exit("Can't read input snapshot");
00047
00048 b->log_history(argc, argv);
00049
00050
00051
00052 while ((c = pgetopt(argc, argv, param_string)) != -1) {
00053 switch (c) {
00054 case 'c': c_flag = TRUE;
00055 comment = poptarg;
00056 break;
00057 case 'F': F_flag = true;
00058 tidal_field_type = atoi(poptarg);
00059 break;
00060 case 'J': J_flag = true;
00061 input_r_jacobi = atof(poptarg);
00062 break;
00063 default:
00064 case '?': params_to_usage(cerr, argv[0], param_string);
00065 get_help();
00066 return false;
00067 }
00068 }
00069
00070 if (c_flag)
00071 b->log_comment(comment);
00072
00073 if (tidal_field_type < 1) tidal_field_type = 1;
00074 if (tidal_field_type > 4) tidal_field_type = 4;
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 bool print = false;
00107 real RtRv;
00108
00109 if (!find_qmatch(b->get_log_story(), "initial_rtidal_over_rvirial")) {
00110
00111
00112
00113 if (input_r_jacobi <= 0)
00114 err_exit("add_tidal: insufficient data to set tidal radius.");
00115
00116 putrq(b->get_log_story(), "initial_rtidal_over_rvirial",
00117 input_r_jacobi);
00118 putiq(b->get_log_story(), "kira_tidal_field_type", tidal_field_type);
00119
00120 print = true;
00121 RtRv = input_r_jacobi;
00122
00123 } else {
00124
00125 if (find_qmatch(b->get_log_story(), "alpha3_over_alpha1")
00126 || find_qmatch(b->get_log_story(), "kira_tidal_field_type")) {
00127
00128
00129
00130 if (F_flag) warning("add_tidal: ignored -F flag");
00131 if (J_flag) warning("add_tidal: ignored -J flag");
00132
00133 } else {
00134
00135
00136
00137
00138 if (J_flag) {
00139 if (input_r_jacobi <= 0)
00140 err_exit("add_tidal: input Jacobi radius < 0");
00141 }
00142
00143 real r_tidal_over_rvirial
00144 = getrq(b->get_log_story(), "initial_rtidal_over_rvirial");
00145
00146 if (r_tidal_over_rvirial <= 0)
00147 err_exit("add_tidal: error reading initial_rtidal_over_rvirial");
00148
00149 if (input_r_jacobi > 0)
00150 r_tidal_over_rvirial *= input_r_jacobi;
00151 else
00152 warning("add_tidal: ignored input_r_jacobi < 0");
00153
00154 putrq(b->get_log_story(), "initial_rtidal_over_rvirial",
00155 r_tidal_over_rvirial);
00156 putiq(b->get_log_story(), "kira_tidal_field_type",
00157 tidal_field_type);
00158
00159 print = true;
00160 RtRv = r_tidal_over_rvirial;
00161 }
00162 }
00163
00164 if (print)
00165 cerr << "add_tidal: Rt/Rv = " << RtRv << ", field type = "
00166 << tidal_field_type << endl;
00167
00168 put_node(cout, *b);
00169 }
00170 #endif