/* nbody hints */ #include #include /* command line default options and arguments */ double dT=1.0; /* delta-t */ double G=1.0; /* gravitational constant */ int maxiter=1; /* iterations to termination */ char *fin="in.mat"; /* input file name */ char *fout="out.mat"; /* output file name */ int bm=0; /* produce a bitmap every b iter's */ int vx=0, vy=0, vz=0; /* select the view plane */ int s=0; /* ignore the s most distant objects */ extern char *optarg; extern int optind, opterr, optopt; while ((i = getopt(argc, argv, "t:g:q:i:o:b:xyzs:")) != EOF) switch (i) { case 't': dT = atof(optarg); break; case 'g': G = atof(optarg); break; case 'q': maxiter = atoi(optarg); break; case 'i': fin = malloc(strlen(optarg)); strcpy(fin, optarg); break; case 'o': fout = malloc(strlen(optarg)); strcpy(fout, optarg); break; case 'b': bm = atoi(optarg); break; case 'x': vx = 1; break; case 'y': vy = 1; break; case 'z': vz = 1; break; case 's': s = atoi(optarg); break; case 'h': case '?': fprintf(stderr, "nbody: bad argument %s\n", optarg); exit(1); break; } /* option to display bodies * (from sequential nbody code) */ if (bm && k % bm == 0) { for (i=0; i 127) ? 127 : d; }