51 signal(signum, SIG_DFL);
58 "usage: testsocket [options]\n"
59 "\t-c [random:]<c>\t\tnumber of iterations\n"
60 "\t-H <url>\tURL (file://path)\n"
61 "\t-M <modes>\tmodes number\n"
62 "\t-r\t\tuse reference node data\n"
63 "\t-s <sleeptime>\t\tsleep time between tries\n"
65 "\t-x\t\tdata_and_next\n");
70 main(
int argc,
char *argv[])
77 std::string fname_in, fname_out, tmpfname_out;
83 double x[3],
R[3][3], v[3], w[3], f[3], m[3];
84 double *q = 0, *qp = 0, *p = 0;
87 int opt =
getopt(argc, argv,
"c:i:M:o:rs:vx");
95 if (strncasecmp(
optarg,
"random:",
sizeof(
"random:") -1) == 0) {
97 iters = atoi(&
optarg[
sizeof(
"random:") -1]);
101 printf(
"iterations: %d\n", iters);
104 fprintf(stderr,
"testedge: "
105 "invalid iterations %s\n",
118 fprintf(stderr,
"testedge: "
119 "invalid mode number %s\n",
136 fprintf(stderr,
"testedge: "
137 "invalid iters %s\n",
156 if (fname_in.empty() || fname_out.empty()) {
160 tmpfname_out = fname_out +
".tmp";
163 q =
new double[3*modes];
171 for (steps = 0; keep_going > 0; steps++) {
176 niters = rand() % iters + 1;
177 printf(
" iterations within this iter: %d\n", niters);
183 for (iter = 0; iter < niters; iter++) {
187 fin.open(fname_in.c_str());
190 printf(
"interrupted\n");
202 >> x[0] >> x[1] >> x[2]
203 >> R[0][0] >> R[0][1] >> R[0][2]
204 >> R[1][0] >> R[1][1] >> R[1][2]
205 >> R[2][0] >> R[2][1] >> R[2][2]
206 >> v[0] >> v[1] >> v[2]
207 >> w[0] >> w[1] >> w[2];
212 fprintf(stdout,
"x={%+16.8e,%+16.8e,%+16.8e}\n", x[0], x[1], x[2]);
213 fprintf(stdout,
"R={{%+16.8e,%+16.8e,%+16.8e};\n", R[0][0], R[0][1], R[0][2]);
214 fprintf(stdout,
" {%+16.8e,%+16.8e,%+16.8e};\n", R[1][0], R[1][1], R[1][2]);
215 fprintf(stdout,
" {%+16.8e,%+16.8e,%+16.8e}};\n", R[2][0], R[2][1], R[2][2]);
216 fprintf(stdout,
"v={%+16.8e,%+16.8e,%+16.8e}\n", v[0], v[1], v[2]);
217 fprintf(stdout,
"w={%+16.8e,%+16.8e,%+16.8e}\n", w[0], w[1], w[2]);
221 for (
unsigned m = 0; m < modes; m++) {
222 fin >> q[m] >> qp[m];
226 fprintf(stdout,
"mode #%d: %+16.8e %+16.8e\n", m, q[m], qp[m]);
231 unlink(fname_in.c_str());
239 std::ofstream fout(tmpfname_out.c_str());
251 << f[0] <<
' ' << f[1] <<
' ' << f[2] << std::endl
252 << m[0] <<
' ' << m[1] <<
' ' << m[2] << std::endl;
256 for (
unsigned m = 0; m < modes; m++) {
257 p[m] = (double)(m + 1);
259 fout << p[m] << std::endl;
263 rename(tmpfname_out.c_str(), fname_out.c_str());
static void sh(int signum)
int mbsleep(const mbsleep_t *t)
mbsleep_t mbsleep_init(long t)
int main(int argc, char *argv[])
int getopt(int argc, char *const argv[], const char *opts)
static volatile sig_atomic_t keep_going