int main(int argc, string argv[]) { stream istr, ostr; string itags[MaxBodyFields]; initparam(argv, defv); new_field(&LinkField, IntType, LinkTag); /* use int's worth of space */ new_field(&LinkField + 1, NULL, NULL); layout_body(bodytags, Precision, NDIM); istr = stropen(getparam("in"), "r"); get_history(istr); if (! get_snap(istr, &btab, &nbody, &tnow, itags, TRUE)) error("%s: snapshot input failed\n", getargv0()); if (! set_member(itags, PosTag)) error("%s: %s data missing\n", getargv0(), PosTag); if (getbparam("subkey") && ! set_member(itags, KeyTag)) error("%s: %s data missing\n", getargv0(), KeyTag); findobj(getdparam("bcrit"), getiparam("nmin"), getbparam("subkey")); ostr = stropen(getparam("out"), "w"); put_history(ostr); put_snap(ostr, &btab, &nbody, &tnow, set_union(itags, set_cons(KeyTag, NULL))); strclose(ostr); return (0); }
int main(int argc, string argv[]) { stream outstr; int nmodel; real tzero = 0.0; initparam(argv, defv); layout_body(bodyfields, Precision, NDIM); nbody = getiparam("nbody"); nmodel = getiparam("nmodel"); if (nbody < 1 || nmodel < 1) error("%s: absurd value for nbody or nmodel\n", getprog()); btab = (bodyptr) allocate(nbody * SizeofBody); init_random(getiparam("seed")); outstr = stropen(getparam("out"), "w"); put_history(outstr); while (--nmodel >= 0) { plummodel(getdparam("mfrac")); if (getbparam("besort")) qsort(btab, nbody, SizeofBody, berank); if (getbparam("zerocm")) snapcenter(btab, nbody, MassField.offset); put_snap(outstr, &btab, &nbody, &tzero, bodyfields); fflush(outstr); } return (0); }
void nemo_main() { string *tags; dprintf(2,"TSF: MaxSetLen = %d\n",MaxSetLen); /* DEBUG - PJT */ instr = stropen(getparam("in"), "r"); maxprec = getbparam("maxprec"); maxline = getiparam("maxline"); indent = getiparam("indent"); #ifdef unix if(!hasvalue("margin")) { struct winsize w; ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); margin = w.ws_col; } else #endif margin = getiparam("margin"); allline = getbparam("allline"); if (hasvalue("item")) warning("item= is broken"); testtag = getparam("item"); xml = getbparam("xml"); if (xml) { /* if XML output used, it should print all items */ allline = TRUE; printf("<nemo>\n"); } octal = getbparam("octal"); while ((tags = list_tags(instr)) != NULL) { print_item(*tags); free(*tags); free((char *)tags); } if (xml) printf("</nemo>\n"); }
int main(int argc, string *argv) { initparam(argv, defv); printf("program %s:\n", getprog()); printf(" input = \"%s\" [%o]\n", getparam("input"), getparamstat("input")); printf(" output = \"%s\" [%o]\n", getparam("output"), getparamstat("output")); printf(" answer = %d [%o]\n", getiparam("answer"), getparamstat("answer")); printf(" value = %g [%o]\n", getdparam("value"), getparamstat("value")); printf(" flag = %s [%o]\n", getbparam("flag") ? "TRUE" : "FALSE", getparamstat("flag")); printf(" foobar = \"%s\" [%o]\n", getparam("foobar"), getparamstat("foobar")); printf(" VERSION = \"%s\" [%o]\n", getversion(), getparamstat("VERSION")); if (getbparam("flag")) { printf("getparamstat(\"junk\") = %o\n", getparamstat("junk")); printf("calling getparam(\"junk\")\n"); (void) getparam("junk"); } return (0); }
void setparams(void) { int i,n; real tmpr[3]; isel = getiparam("select"); switch (nemoinpd(getparam("scale"),scale,3)) { case 1: scale[1] = scale[0]; scale[2] = 1.0; break; case 2: scale[2] = 1.0; break; case 3: break; case 0: scale[0] = scale[1] = scale[2] = 1.0; break; default: error("parsing error scale=%s",getparam("scale")); } if (nemoinpd(getparam("iscale"),iscale,2) != 2) error("parsing error scale=%s - must be 2 numbers",getparam("scale")); object = getparam("object"); comment = getparam("comment"); Qcdmatrix = getbparam("cdmatrix"); Qradecvel = getbparam("radecvel"); Qrefmap = hasvalue("refmap"); if (Qrefmap) set_refmap(getparam("refmap")); Qcrpix = hasvalue("crpix"); if (Qcrpix) { nref = nemoinpr(getparam("crpix"),tmpr,3); for (i=0; i<nref; i++) ref_crpix[i] = tmpr[i]; } Qcrval = hasvalue("crval"); if (Qcrval) { nref = nemoinpr(getparam("crval"),tmpr,3); for (i=0; i<nref; i++) ref_crval[i] = tmpr[i]; } Qcdelt = hasvalue("cdelt"); if (Qcdelt) { nref = nemoinpr(getparam("cdelt"),tmpr,3); for (i=0; i<nref; i++) ref_cdelt[i] = tmpr[i]; } Qdummy = getbparam("dummy"); nfill = getiparam("nfill"); }
nemo_main() { testing(getparam("name"), getparam("mode"), getparam("text"), getbparam("delete")); if(hasvalue("name2")) testing(getparam("name2"), getparam("mode2"), getparam("text2"), getbparam("delete2")); }
void gspmodel(void) { real beta_a, mcut, vcut, vfac; static real *sig2 = NULL; real r, vmax2, sigr, sig, x, y, vr, v1, v2; bodyptr bp; vector rhat, vec1, vec2, vtmp; beta_a = getdparam("beta_a"); assert(beta_a <= 1.0); nbody = getiparam("nbody"); assert(nbody > 0); mcut = getdparam("mcut"); assert(0.0 < mcut && mcut <= 1.0); vcut = getdparam("vcut"); assert(vcut > 0.0); if (sig2 == NULL) sig2 = calc_sig2_gsp(gsp, ggsp, beta_a); if (btab == NULL) btab = (bodyptr) allocate(nbody * SizeofBody); vfac = rsqrt(1 - beta_a); for (bp = btab; bp < NthBody(btab, nbody); bp = NextBody(bp)) { Mass(bp) = gsp->mtot / nbody; r = r_mass_gsp(gsp, xrandom(0.0, mcut * gsp->mtot)); vmax2 = -2 * rsqr(vcut) * phi_gsp(ggsp, r); if (vfac > 1.0) vmax2 = vmax2 / rsqr(vfac); sigr = rsqrt(sig2_gsp(gsp, ggsp, beta_a, sig2, r)); sig = fixsigma(sigr, rsqrt(vmax2)); do { vr = grandom(0.0, sig); v1 = grandom(0.0, sig); v2 = grandom(0.0, sig); } while (vr*vr + v1*v1 + v2*v2 > vmax2); picktriad(rhat, vec1, vec2); MULVS(Pos(bp), rhat, r); MULVS(Vel(bp), rhat, vr); MULVS(vtmp, vec1, v1 * vfac); ADDV(Vel(bp), Vel(bp), vtmp); MULVS(vtmp, vec2, v2 * vfac); ADDV(Vel(bp), Vel(bp), vtmp); Phi(bp) = phi_gsp(ggsp, r); Aux(bp) = Phi(bp) + 0.5 * dotvp(Vel(bp), Vel(bp)); } if (getbparam("besort")) qsort(btab, nbody, SizeofBody, berank); if (getbparam("zerocm")) snapcenter(btab, nbody, MassField.offset); if (! strnull(getparam("auxvar"))) setauxvar(btab, nbody); }
int nemo_main() { int sock, mode = 0, direction = 0, port = getiparam("port"), buffer_size = getiparam("bufsize"); string rhost = NULL; bool Qreport = getbparam("report"); if (hasvalue("host_sender")) { mode = CONNECT; direction = RECEIVE; rhost = getparam("host_sender"); } else { mode = LISTEN; direction = SEND; } switch (mode) { case LISTEN: sock = do_listen(port, rhost); break; case CONNECT: sock = do_connect(port, rhost); break; default: error("bad mode"); break; } switch (direction) { case SEND: do_transfer(STDIN_FILENO, sock, buffer_size, FALSE, port); break; case RECEIVE: do_transfer(sock, STDOUT_FILENO, buffer_size, Qreport, port); break; default: error("bad direction"); break; } return 0; }
int main(int argc, string argv[]) { real rrange[2], rmax; int np; double lgrs; gsprof *gsp; stream ostr; initparam(argv, defv); setrange(rrange, getparam("rrange")); np = getiparam("npoint"); rmax = pow(2.0, floor(log2(32.0 / getdparam("alpha")))); if (rmax < rrange[1] && getbparam("smartrange")) { lgrs = log2(rrange[1] / rrange[0]) / (np - 1); np = 1 + log2(rmax / rrange[0]) / lgrs; eprintf("[%s: warning: npoint = %d -> %d rrange[1] = %f -> %f]\n", getprog(), getiparam("npoint"), np, rrange[1], rmax); rrange[1] = rmax; } gsp = gsp_expd(getdparam("mtot"), getdparam("alpha"), getdparam("zdisk"), np, rrange[0], rrange[1]); ostr = stropen(getparam("out"), "w"); put_history(ostr); gsp_write(ostr, gsp); fflush(NULL); return 0; }
int main(int argc, string argv[]) { stream istr, ostr; string times, *vecs, *produce, iotags[MaxBodyFields]; bool expand; snapshot snap = { NULL, 0, 0.0 }; initparam(argv, defv); istr = stropen(getparam("in"), "r"); get_history(istr); ostr = stropen(getparam("out"), "w"); put_history(ostr); times = getparam("times"); vecs = burststring(getparam("vectors"), ", "); expand = streq(getparam("produce"), "*"); if (! expand) { produce = burststring(getparam("produce"), ", "); layout_body(produce, Precision, NDIM); } while (get_snapshot_timed(istr, snap, iotags, expand, times)) { eprintf("[%s: rotating time %f]\n", getprog(), snap.time); snaprotate(&snap, iotags, vecs, getparam("order"), getbparam("invert"), getdparam("thetax"), getdparam("thetay"), getdparam("thetaz")); put_snapshot(ostr, snap, iotags); skip_history(istr); } strclose(ostr); return (0); }
void nemo_main() { stream instr, outstr; int nx, ny, nz; /* size of scratch map */ int nx1,ny1,nz1; int nxaver, nyaver,nzaver; int i,j,k, i0,j0,k0, i1,j1,k1; imageptr iptr=NULL, iptr1=NULL; /* pointer to images */ real sum, tmp, zzz; bool Qreorder = FALSE; bool Qdummy, Qsample; string reorder; instr = stropen(getparam("in"), "r"); nxaver=getiparam("nxaver"); nyaver=getiparam("nyaver"); nzaver=getiparam("nzaver"); Qdummy = getbparam("dummy"); nx1 = nemoinpi(getparam("x"),ix,MAXDIM); ny1 = nemoinpi(getparam("y"),iy,MAXDIM); nz1 = nemoinpi(getparam("z"),iz,MAXDIM); if (nx1<0 || ny1<0 || nz1<0) error("Error parsing x,y,z="); Qsample = nx1>0 || ny1>0 || nz1>0; if (Qsample) warning("Sampling will be done"); read_image( instr, &iptr); nx = Nx(iptr); /* old cube size */ ny = Ny(iptr); nz = Nz(iptr); nx1 = ax_index("x",nx,nx1,ix); /* initialize new cube axes */ ny1 = ax_index("y",ny,ny1,iy); /* before any reordering */ nz1 = ax_index("z",nz,nz1,iz); Qreorder = hasvalue("reorder"); if (Qreorder) { reorder = getparam("reorder"); if (strlen(reorder) != 3) error("Reorder must have 3 letters"); } outstr = stropen(getparam("out"), "w"); if (nxaver>1 || nyaver>1 || nzaver>1) { /* averaging, but retaining size */ dprintf(0,"Averaging map %d * %d * %d pixels; mapsize %d * %d * %d\n", nxaver,nyaver,nzaver,nx,ny,nz); nx1 = nx/nxaver; if (nx % nxaver) warning("X binning not even"); ny1 = ny/nyaver; if (ny % nyaver) warning("Y binning not even"); nz1 = nz/nzaver; if (nz % nzaver) warning("X binning not even"); LOOP(k1,nz1) { k = k1*nzaver; LOOP(j1,ny1) { j = j1*nyaver; LOOP(i1,nx1) { i = i1*nxaver; sum = 0.0; LOOP(k0,nzaver) LOOP(j0,nyaver) LOOP(i0,nxaver) sum += CV(iptr, i+i0, j+j0, k+k0); sum /= (real) (nxaver*nyaver*nzaver); LOOP(k0,nzaver) LOOP(j0,nyaver) LOOP(i0,nxaver) CV(iptr, i+i0, j+j0, k+k0) = sum; }
local void newrun(void) { eps = getdparam("eps"); // get input parameters dtime = getdparam("dtime"); nstatic = getiparam("nstatic"); #if !defined(QUICKSCAN) theta = getdparam("theta"); #endif usequad = getbparam("usequad"); tstop = getdparam("tstop"); dtout = getdparam("dtout"); options = getparam("options"); outputs = getparam("outputs"); if (! strnull(infile)) // if data file was given inputdata(); // then read inital data else { // else make initial data nbody = getiparam("nbody"); // get number of bodies // I added this timesteps = getiparam("timesteps"); // get number of timesteps init_random(getiparam("seed")); // set random number gen. testdata(); // and make plummer model } rsize = 1.0; // start root w/ unit cube nstep = 0; // begin counting steps tout = tnow; // schedule first output }
setparams() { trakflag = FALSE; input = getparam("in"); times = getparam("times"); xvar = getparam("xvar"); if (hasvalue("xlabel")) xlabel = getparam("xlabel"); else xlabel = xvar; setrange(xrange, getparam("xrange")); yvar = getparam("yvar"); if (hasvalue("ylabel")) ylabel = getparam("ylabel"); else ylabel = yvar; setrange(yrange, getparam("yrange")); zvar = getparam("zvar"); if (hasvalue("zlabel")) zlabel = getparam("zlabel"); else zlabel = zvar; setrange(zrange, getparam("zrange")); visib = getparam("visib"); psize = getparam("psize"); fillcircle = getbparam("fill_circle"); if (hasvalue("xticks")) setticks(xticks, &nxticks, getparam("xticks")); else { xticks[0] = xrange[0]; xticks[1] = xrange[1]; nxticks = - getiparam("nxticks"); } if (hasvalue("yticks")) setticks(yticks, &nyticks, getparam("yticks")); else { yticks[0] = yrange[0]; yticks[1] = yrange[1]; nyticks = - getiparam("nyticks"); } if (hasvalue("zticks")) setticks(zticks, &nzticks, getparam("zticks")); else { zticks[0] = zrange[0]; zticks[1] = zrange[1]; nzticks = - getiparam("nzticks"); } s2box_opt = getparam("s2box"); #ifdef COLOR color = getparam("color"); setrange(crange, getparam("crange")); #endif }
void nemo_main() { stream outstr; potential = get_potential(getparam("potname"), getparam("potpars"), getparam("potfile")); rmin = getdparam("rmin"); rmax = getdparam("rmax"); rref = rmax; if (hasvalue("rref")) rref = getdparam("rref"); Qkey = hasvalue("key"); if (Qkey) key = getiparam("key"); Qconstant = getbparam("constant"); ndisk = getiparam("nbody"); jz_sign = getiparam("sign"); nmodel = getiparam("nmodel"); totmass = getdparam("mass"); offset = getdparam("phase") * PI / 180.0; Qtest = getbparam("test"); Quniform = getbparam("uniform"); if (ABS(jz_sign) != 1) error("sign must be +1 or -1"); Qlinear = hasvalue("k"); if (Qlinear) SPk = getdparam("k"); /* corrected for rot counter clock wise */ else if (hasvalue("pitch")) pitch = getdparam("pitch"); /* corrected for rot counter clock wise */ else error("Either k= (linear) or pitch= (logarithmic) spiral indicator needed"); init_xrandom(getparam("seed")); outstr = stropen(getparam("out"), "w"); put_history(outstr); if (hasvalue("headline")) set_headline(getparam("headline")); setdensity(); while (nmodel--) { testdisk(nmodel); writegalaxy(outstr); } strclose(outstr); free(disk); }
int main(int argc, string argv[]) { real mass_scale; initparam(argv, defv); nmax = getiparam("nmax"); radius_tab = (double *) allocate(nmax * sizeof(double)); density_tab = (double *) allocate(nmax * sizeof(double)); mass_tab = (double *) allocate(nmax * sizeof(double)); read_table(getparam("in"), getbparam("smooth")); integ_mass(getbparam("smooth")); fit_params(); mass_scale = (strnull(getparam("mtot")) ? 1 : getdparam("mtot") / mtot); if (!strnull(getparam("out"))) write_gsp(getparam("out"), mass_scale); return (0); }
nemo_main() { stream instr; real tsnap, x, y, v, d; int i, nbody, bits, iy, ny, nout; Body *btab = NULL, *bp; Grid g; real yrange[MAXY], sumd[MAXY], sumvd[MAXY], sumxd[MAXY]; bool Qmass = getbparam("mass"); instr = stropen(getparam("in"), "r"); /* open input file */ ny = nemoinpr(getparam("y"),yrange,MAXY); if (ny<2) error("yrange syntax error or not enuf slices"); #if 0 inia_grid(&g, ny, yrange); #else inil_grid(&g, ny-1, yrange[0], yrange[ny-1]); #endif get_history(instr); /* accumulate data history */ for(;;) { /* loop for all times */ get_history(instr); /* for paranoidici */ if (!get_tag_ok(instr, SnapShotTag)) /* check if done */ break; get_snap(instr, &btab, &nbody, &tsnap, &bits); /* get one */ if ((bits & PhaseSpaceBit) == 0) continue; /* if no positions - skip */ for (i=0; i<ny; i++) sumd[i] = sumxd[i] = sumvd[i] = 0.0; for (bp = btab; bp < btab+nbody; bp++) { /* loop all bodies */ y = Pos(bp)[1]; iy = index_grid(&g, y); if (iy < 0) continue; d = Qmass ? Mass(bp) : Dens(bp); x = Pos(bp)[0]; v = Vel(bp)[1]; sumd[iy] += d; sumvd[iy] += v*d; sumxd[iy] += x*d; } break; /* for now just first snapshot */ } nout = 0; for (i=0; i<ny-1; i++) { if (sumd[i] > 0.0) { nout++; printf("%g %g %g %g\n",value_grid(&g, (real)i+0.5), sumxd[i]/sumd[i], sumvd[i]/sumd[i], sumd[i]); } } if (nout==0) warning("No densities found in slices %s",getparam("y")); } /* nemo_main() */
void testdisk(void) { int ndisk, i; real rmin2, rmax2, eps2, sigma, r_i, theta_i, m_i, v_i; bodyptr gp, sp; ndisk = getiparam("ndisk"); ngalaxy = ndisk + (getbparam("nosphr") ? 0 : nspheroid); galaxy = (bodyptr) allocate(ngalaxy * SizeofBody); rmin2 = rsqr(getdparam("rmin")); rmax2 = rsqr(getdparam("rmax")); eps2 = rsqr(getdparam("eps")); sigma = getdparam("sigma"); init_random(getiparam("seed")); for (i = 0; i < ndisk; i++) { /* build disk */ gp = NthBody(galaxy, i); Mass(gp) = 0.0; /* set mass to zero */ r_i = rsqrt(rmin2 + i * (rmax2 - rmin2) / (ndisk - 1.0)); theta_i = xrandom(0.0, TWO_PI); Pos(gp)[0] = r_i * rsin(theta_i); /* set positions */ Pos(gp)[1] = r_i * rcos(theta_i); Pos(gp)[2] = 0.0; if (r_i < rsph[NTAB-1]) m_i = seval(r_i, &rsph[0], &msph[0], &msph[NTAB], NTAB); else m_i = msph[NTAB-1]; v_i = rsqrt(MAX(m_i, 0.0) * r_i*r_i / rpow(r_i*r_i + eps2, 1.5)); /* set velocities */ Vel(gp)[0] = grandom( v_i * rcos(theta_i), sigma); Vel(gp)[1] = grandom(- v_i * rsin(theta_i), sigma); Vel(gp)[2] = grandom( 0.0, sigma); } if (! getbparam("nosphr")) for (i = 0; i < nspheroid; i++) { /* append spheroid */ sp = NthBody(spheroid, i); gp = NthBody(galaxy, ndisk + i); memcpy(gp, sp, SizeofBody); } if (getbparam("zerocm")) snapcenter(galaxy, ngalaxy, MassField.offset); }
int main(int argc, string argv[]) { initparam(argv, defv); readgsp(); init_random(getiparam("seed")); layout_body(bodyfields, Precision, NDIM); gspsphere(); if (getbparam("zerocm")) snapcenter(btab, nbody, MassField.offset); writemodel(); return (0); }
void nemo_main() { int seed; rmin = -0.5 * getdparam("size"); rmax = -rmin; ngrid = getiparam("ngrid"); nbody = ngrid * ngrid * ngrid ; zerocm = getbparam("zerocm"); mkgrid(); writegalaxy(getparam("out"), getparam("headline")); free(btab); }
int main(int argc, string argv[]) { double alpha, rcut; int model; initparam(argv, defv); alpha = getdparam("alpha"); rcut = getdparam("rcut"); model = (alpha <= 0.0 ? -1 : getiparam("model")); ndisk = getiparam("ndisk"); init_random(getiparam("seed")); readgsp(); setprof(model, alpha, rcut); layout_body(bodyfields, Precision, NDIM); disk = (bodyptr) allocate(ndisk * SizeofBody); makedisk(getbparam("randspin")); if (! getbparam("randspin")) // if spins not random bodyfields[2] = NULL; // don't write AuxVec field writemodel(); fflush(NULL); return 0; }
int main(int argc, string argv[]) { stream outstr = NULL; int nmodel; real tzero = 0.0; initparam(argv, defv); layout_body(bodyfields, Precision, NDIM); npol = getdparam("n"); mpol = getdparam("m"); nbody = getiparam("nbody"); btab = (bodyptr) allocate(nbody * SizeofBody); init_random(getiparam("seed")); nmodel = getiparam("nmodel"); if (! ((npol == 1.0 && mpol == -1.0) || (npol == 0.5 && mpol == -0.5))) polysolve(getdparam("hstep"), getbparam("listmodel")); if (! strnull(getparam("out"))) { outstr = stropen(getparam("out"), "w"); put_history(outstr); } while (--nmodel >= 0) { if (npol == 1.0 && mpol == -1.0) polymodel1(); else if (npol == 0.5 && mpol == -0.5) polymodel2(); else polymodel(); if (getbparam("besort")) qsort(btab, nbody, SizeofBody, berank); if (getbparam("zerocm")) snapcenter(btab, nbody, MassField.offset); if (outstr != NULL) put_snap(outstr, &btab, &nbody, &tzero, bodyfields); fflush(outstr); } return (0); }
void nemo_main() { int seed; rmin = -0.5 * getdparam("size"); rmax = -rmin; nbody = getiparam("nbody"); sigma = getdparam("sigma"); seed = init_xrandom(getparam("seed")); zerocm = getbparam("zerocm"); mkcube(); writegalaxy(getparam("out"), getparam("headline")); free(btab); }
void nemo_main(void) { char line[80]; stream instr = stropen(getparam("in"),"r"); int mom = getiparam("moment"); int maxsize = getiparam("maxsize"); real x; Moment m; bool Qminmax = getbparam("minmax"); bool Qmedian = getbparam("median"); ini_moment(&m,ABS(mom),maxsize); while (fgets(line,80,instr) != NULL) { x = atof(line); accum_moment(&m,x,1.0); if (maxsize > 0) { debug_moment(1,&m); printf("%d ",n_moment(&m)); if (Qminmax) printf("%g %g\n",min_moment(&m), max_moment(&m)); else if (Qmedian) printf("%g\n",median_moment(&m)); else printf("%g\n",show_moment(&m,mom)); } } if (maxsize == 0) { printf("%d ",n_moment(&m)); if (Qminmax) printf("%g %g\n",min_moment(&m), max_moment(&m)); else if (Qmedian) printf("%g\n",median_moment(&m)); else printf("%g\n",show_moment(&m,mom)); } }
nemo_main() { real xtrans(real), ytrans(real); formalaxis = getbparam("formalaxis"); xlabdn = getdparam("xlabdn"); xszlab = getdparam("xszlab"); ylablf = getdparam("ylablf"); yszlab = getdparam("yszlab"); plinit("***", 0.0, 20.0, 0.0, 20.0); xaxis( 2.0, 2.0, 16.0, xrange, -3, xtrans, "x"); xaxis( 2.0, 18.0, 16.0, xrange, -3, xtrans, NULL); yaxis( 2.0, 2.0, 16.0, yrange, -7, ytrans, "y"); yaxis(18.0, 2.0, 16.0, yrange, -7, ytrans, NULL); plstop(); }
int main(int argc, string argv[]) { string tag; initparam(argv, defv); instr = stropen(getparam("in"), "r"); maxprec = getbparam("maxprec"); maxline = getiparam("maxline"); indent = getiparam("indent"); margin = getiparam("margin"); while ((tag = next_item_tag(instr)) != NULL) { print_item(tag); free(tag); } return (0); }
void nemo_main() { bool q = BigEndian(); bool v = getbparam("verbose"); if (v) printf("%s\n", q ? "BigEndian" : "LittleEndian"); else printf("%d\n", q ? 1 : 0); #ifdef WORDS_BIGENDIAN if (v) printf("autoconf -> big endian\n"); if (!q) error("conflict-1 determining endianism, try verbose=t"); #else if (v) printf("autoconf -> little endian\n"); if (q) error("conflict-2 determining endianism, try verbose=t"); #endif }
nemo_main() { int seed; alpha = getdparam("alpha"); rcut = getdparam("rcut"); mdisk = getdparam("mdisk"); Qtoomre = getdparam("Qtoomre"); gammas = getdparam("gamma"); ndisk = getiparam("nbody"); z0 = getdparam("z0"); /* was called epsi in mkbaredisk */ cmode = getiparam("mode"); zmode = getiparam("zmode"); seed = init_xrandom(getparam("seed")); Qtab = getbparam("tab"); inittables(); makedisk(); writesnap(getparam("out"), getparam("headline")); }
setparams() { string inname = getparam("in"); nmax = nemo_file_lines(inname,getiparam("nmax")); if (nmax<0) error("Error opening %s",inname); if (nmax==0) error("No data?"); instr = stropen (inname,"r"); if (hasvalue("out")) outstr=stropen(getparam("out"),"w"); else outstr=NULL; nxcol = nemoinpi(getparam("xcol"),xcolnr,MAXCOL); if (nxcol<0) error("Illegal xcol= nxcol=%d",nxcol); nycol = nemoinpi(getparam("ycol"),ycolnr,MAXCOL); if (nycol<0) error("Illegal ycol= nycol=%d",nycol); if (hasvalue("dxcol")) dxcolnr = getiparam("dxcol"); else dxcolnr = 0; if (hasvalue("dycol")) dycolnr = getiparam("dycol"); else dycolnr = 0; if (hasvalue("xrange")) setrange(xrange,getparam("xrange")); else { xrange[0] = -HUGE; xrange[1] = HUGE; } method = getparam("fit"); nsigma = getdparam("nsigma"); order = getiparam("order"); if (order<0) error("order=%d of %s cannot be negative",order,method); Qtab = getbparam("tab"); mpfit_mode = getiparam("mpfit"); }
int main(int argc, string argv[]) { stream istr; string bodytags[] = { PosTag, NULL }, intags[MaxBodyFields]; bodyptr btab = NULL, bp; int nbody, nshell, n; real tnow, vals[3]; matrix tmpm, qmat; vector v1, v2, v3; initparam(argv, defv); istr = stropen(getparam("in"), "r"); get_history(istr); layout_body(bodytags, Precision, NDIM); printf("#%11s %3s %11s %11s %11s\n", "time", "n", "r_rms", "c/a", "b/a"); while (get_snap(istr, &btab, &nbody, &tnow, intags, FALSE)) { if (! set_member(intags, PosTag)) error("%s: %s data missing\n", getargv0(), PosTag); if (nbody % getiparam("nbin") != 0) error("%s: nbin does not divide number of bodies\n", getargv0()); nshell = nbody / getiparam("nbin"); for (n = 0; n < nbody; n += nshell) { CLRM(qmat); for (bp = NthBody(btab, n); bp < NthBody(btab, n + nshell); bp = NextBody(bp)) { OUTVP(tmpm, Pos(bp), Pos(bp)); ADDM(qmat, qmat, tmpm); } eigensolve(v1, v2, v3, vals, qmat); printf(" %11.6f %3d %11.6f %11.6f %11.6f\n", tnow, n / nshell, rsqrt(tracem(qmat) / nshell), rsqrt(vals[2] / vals[0]), rsqrt(vals[1] / vals[0])); if (getbparam("listvec")) { printf("#\t\t\t\t\t\t\t%8.5f %8.5f %8.5f\n", v1[0], v1[1], v1[2]); printf("#\t\t\t\t\t\t\t%8.5f %8.5f %8.5f\n", v2[0], v2[1], v2[2]); printf("#\t\t\t\t\t\t\t%8.5f %8.5f %8.5f\n", v3[0], v3[1], v3[2]); } } } return (0); }
nemo_main() { stream instr, outstr; real tsnap, mscale; Body *btab = NULL, *bp; int i, j, n, nbody, nbodymass, bits, bitsmass, seed; rproc bfunc, btrtrans(); instr = stropen(getparam("in"), "r"); outstr = hasvalue("out") ? stropen(getparam("out"),"w") : NULL; n = getiparam("iter"); get_history(instr); if (!get_tag_ok(instr, SnapShotTag)) error("not a snapshot"); get_snap(instr, &btab, &nbody, &tsnap, &bits); if (getbparam("bodytrans")) { dprintf(0,"bodytrans scaling, iter=%d\n",n); bfunc = btrtrans(getparam("mass")); /* use bodytrans expression */ for (j=0; j<n; j++) for (bp=btab, i=0; i<nbody; bp++,i++) Mass(bp) = bfunc(bp, tsnap, i); } else { dprintf(0,"simple inline scaling, iter=%d\n",n); mscale = getdparam("mass"); for (j=0; j<n; j++) for (bp=btab, i=0; i<nbody; bp++,i++) Mass(bp) = mscale*Mass(bp); } strclose(instr); if (outstr) { put_history(outstr); put_snap(outstr, &btab, &nbody, &tsnap, &bits); strclose(outstr); } }