void nemo_main() { real x,y = 0; int count, random; string name; int work = 0; x = getdparam("real"); count = getiparam("count"); random = getiparam("random"); name = getparam("in"); if (*name) { work++; get_number(name,&y); } else dprintf(1,"No input file specified\n"); name = getparam("out"); if (*name) { work++; put_number(name,y+x,count,random); } else dprintf(1,"No output file specified\n"); if (work==0) warning("No work done, use in=, out=, or both"); }
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; }
void setparams() { input = getparam("in"); otimes = getparam("times"); if (strcmp(otimes,"all")==0) { trange[0] = -HUGE; trange[1] = HUGE; } else setrange(trange, otimes); nplot=getiparam("nplot"); xvar = getparam("xvar"); xvar_idx = get_idx(xvar); if (hasvalue("xlabel")) xlabel = getparam("xlabel"); else xlabel = xvar; setrange(xrange, getparam("xrange")); yvar = getparam("yvar"); yvar_idx = get_idx(yvar); if (hasvalue("ylabel")) ylabel = getparam("ylabel"); else ylabel = yvar; setrange(yrange, getparam("yrange")); visib = getparam("visib"); psize = getparam("psize"); #ifdef COLOR color = getparam("color"); #endif maxsteps = getiparam("maxsteps"); }
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; }
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"); }
void nemo_main() { stream outstr; int nx, ny, nz; int ix, iy, iz; imageptr optr=NULL; /* pointer to image, needs to be NULL to force new */ real tmp, sum = 0.0; outstr = stropen(getparam("out"), "w"); nx = getiparam("nx"); ny = getiparam("ny"); nz = getiparam("nz"); dprintf(0,"Creating image cube (size : %d x %d x %d)\n",nx,ny,nz); create_cube(&optr,nx,ny,nz); for (iz=0; iz<nz; iz++) { for (iy=0; iy<ny; iy++) { for (ix=0; ix<nx/2; ix++) { CubeValue(optr,ix,iy,iz) = 0.0; } } } write_image(outstr, optr); }
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 }
FITS *rawopen(string name, string status, int naxis, int *nsize) { FITS *f; int i,ndim,bitpix; f = (FITS *) allocate(sizeof(FITS)); if (streq(status,"old")){ /* handle an old file */ f->fd = stropen(name,"r"); ndim = nemoinpi(getparam("naxis"),nsize,naxis); if (ndim < 1) error("naxis= returns %d from parser",ndim); f->naxis = ndim; for (i=ndim; i<naxis; i++) nsize[i] = 1; for (i=0; i<ndim; i++) f->axes[i] = nsize[i]; for (i=ndim; i<MAXNAX; i++) f->axes[i] = 1; bitpix = getiparam("bitpix"); fit_setbitpix(bitpix); if (bitpix==8) f->type = TYPE_8INT; else if (bitpix==16) f->type = TYPE_16INT; else if (bitpix==32) f->type = TYPE_32INT; else if (bitpix==-32) f->type = TYPE_FLOAT; else error("Invalid bitpix: %d",bitpix); f->bytepix = ABS(bitpix)/8; f->status = STATUS_OLD; f->bscale = getdparam("bscale"); f->bzero = getdparam("bzero"); f->offset = getiparam("offset"); f->skip = f->offset; f->ncards = 0; } else error("Cannot rawopen %s as \"%s\"\n",name,status); fit_setblocksize( getiparam("blocksize") * getiparam("blocking") ); return f; }
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); }
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; }
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 }
nemo_main() { int n=getiparam("n"); int iter=getiparam("iter"); int m=getiparam("m"); int seed = init_xrandom(getparam("seed")); int i,j,k,l; real *x, sum; real t0,t1,t2; init_timers(100); stamp_timers(0); x = (real *) allocate(n*sizeof(real)); for (i=0; i<n; i++) /* init the whole array */ x[i] = xrandom(0.0,1.0); for (i=0; i<m; i++) /* cache it in again ? */ x[i] = xrandom(0.0,1.0); sum = 0.0; t0 = cputime(); stamp_timers(1); if (m==0) { /* do it in one sweep, the N^2 algorithm */ stamp_timers(2); for (l=0; l<iter; l++) for (j=0; j<n; j++) for (i=0; i<n; i++) sum += FUN(x[i],x[j]); stamp_timers(3); } else { /* N/M times a small M*M patch that may be in cache */ stamp_timers(2); for (l=0; l<iter; l++) for (k=0; k<n-m; k++) for (j=k; j<k+m; j++) for (i=k; i<k+m; i++) sum += FUN(x[i],x[j]); stamp_timers(3); } stamp_timers(4); t1 = cputime(); if (m) printf("%d %d %d sum=%lg Mops=%lg\n", n,iter,m,sum,iter*m*m*n/(t1-t0)/60.0/1e6); else printf("%d %d %d sum=%lg Mops=%lg\n", n,iter,m,sum,iter*n*n/(t1-t0)/60.0/1e6); stamp_timers(5); printf("%Ld %Ld %Ld %Ld %Ld\n", diff_timers(0,1), diff_timers(1,2), diff_timers(2,3), diff_timers(3,4), diff_timers(4,5)); }
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"); }
int main(int argc, string argv[]) { stream istr, ostr; real eps2, tnow; int nforce, nbody, i; bodyptr btab = NULL; string intags[MaxBodyFields]; initparam(argv, defv); layout_body(bodytags, Precision, NDIM); istr = stropen(getparam("in"), "r"); get_history(istr); ostr = stropen(getparam("out"), "w"); put_history(ostr); eps2 = rsqr(getdparam("eps")); nforce = -1; /* use nforce as flag... */ while (get_snap(istr, &btab, &nbody, &tnow, intags, FALSE)) { if (nforce == -1 && ! set_member(intags, MassTag)) error("%s: Mass data missing from 1st snapshot\n", getargv0()); if (! set_member(intags, PosTag)) error("%s: %s data missing\n", getargv0(), PosTag); if (nforce == -1) nforce = (strnull(getparam("nforce")) ? nbody : MIN(getiparam("nforce"), nbody)); for (i = 0; i < nforce; i++) sum1force(btab, nbody, i, eps2); put_snap(ostr, &btab, &nforce, &tnow, bodytags); } return (0); }
void nemo_main() { int i, nrad, n; int mode = getiparam("mode"); if (mode==1) { dubinski(); return; } sign_L = getdparam("sign"); nrad = nemoinpi(getparam("nbody"),nbody,MAXRAD); n = nemoinpd(getparam("radius"),radius,MAXRAD); if (n!=nrad) error("radius="); n = nemoinpd(getparam("mass"),mass,MAXRAD); if (n!=nrad) error("mass="); n = nemoinpd(getparam("phi"),phi,MAXRAD); if (n!=nrad) error("phi="); nobj_max = nbody[0]; for (i=1; i<nrad; i++) if (nbody[i] > nobj_max) nobj_max = nbody[i]; pmass = (real *) allocate(sizeof(real)*nobj_max); pphase = allocate_mdarray3(nobj_max,2,NDIM); headline = getparam("headline"); for (i=0; i<nrad; i++) { makering(nbody[i],mass[i],radius[i],phi[i]); writesnap(nbody[i]); } strclose(outstr); nemo_dprintf(1,"Total number of particles written: %d\n",ntot); }
int main(int argc, string argv[]) { string prog, itags[MaxBodyFields]; stream xstr; int nprof, nbody, nsamp; real *prof1, *prof2, rrange[2], tnow; bodyptr btab = NULL; initparam(argv, defv); layout_body(fields, Precision, NDIM); prog = mktemp((string) copxstr("/tmp/sm_XXXXXX", sizeof(char))); xstr = execmap(prog); get_history(xstr); nprof = getiparam("nprof"); prof1 = (real *) allocate((2 + nprof) * sizeof(real)); prof2 = (real *) allocate((2 + nprof) * sizeof(real)); setrange(rrange, getparam("rrange")); nsamp = 0; while (get_snap(xstr, &btab, &nbody, &tnow, itags, FALSE)) { setprofile(prof1, prof2, nprof, rrange, btab, nbody); nsamp++; } if (unlink(prog) != 0) error("%s: can't unlink %s\n", getargv0(), prog); if (nsamp == 0) error("%s: no data in input\n", getargv0()); listdensity(prof1, prof2, nprof, rrange, nsamp); return (0); }
void gspsphere(void) { real gamma0, mcut, r, sig2, eint = 0.0; static real *sig2tab = NULL; bodyptr bp; nbody = getiparam("nbody"); assert(nbody > 0); gamma0 = getdparam("gamma"); mcut = getdparam("mcut"); assert(0.0 < mcut && mcut <= 1.0); if (sig2tab == NULL) sig2tab = calc_sig2_gsp(gsp, ggsp, 0.0); if (btab == NULL) btab = (bodyptr) allocate(nbody * SizeofBody); 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)); pickshell(Pos(bp), NDIM, r); CLRV(Vel(bp)); Rho(bp) = rho_gsp(gsp, r); sig2 = sig2_gsp(gsp, ggsp, 0.0, sig2tab, r); EntFunc(bp) = sig2 / rpow(Rho(bp), gamma0 - 1); Uintern(bp) = sig2 / (gamma0 - 1); eint += Mass(bp) * Uintern(bp); } eprintf("[%s: thermal energy = %f]\n", getargv0(), eint); }
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); }
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); }
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 istr; gsprof *tgsp, *mgsp; real beta_a, *sig2, rrange[2], lgrs, r; int np, i; initparam(argv, defv); istr = stropen(getparam("gsp"), "r"); get_history(istr); tgsp = get_gsprof(istr); strclose(istr); if (! strnull(getparam("grav"))) { istr = stropen(getparam("grav"), "r"); get_history(istr); mgsp = get_gsprof(istr); strclose(istr); } else mgsp = tgsp; beta_a = getdparam("beta_a"); sig2 = calc_sig2_gsp(tgsp, mgsp, beta_a); np = getiparam("npoint"); setrange(rrange, getparam("rrange")); lgrs = rlog2(rrange[1] / rrange[0]) / (np - 1); printf("%12s %12s\n", "radius", "sig_r^2"); for (i = 0; i < np; i++) { r = rrange[0] * rpow(2.0, lgrs * i); printf("%12.5f %12.7f\n", r, sig2_gsp(tgsp, mgsp, beta_a, sig2, r)); } return (0); }
int main(int argc, string argv[]) { stream istr, ostr; gsprof *gsp; int np, i; real r0, lgrs, r; initparam(argv, defv); istr = stropen(getparam("in"), "r"); get_history(istr); gsp = get_gsprof(istr); if (! strnull(getparam("out"))) { ostr = stropen(getparam("out"), "w"); put_history(ostr); put_gsprof(ostr, gsp); strclose(ostr); } np = getiparam("npoint"); r0 = 1.0 / getdparam("r0inv"); lgrs = getdparam("lgrstep"); printf("%12s%12s%12s%12s%12s%12s\n", "radius", "log rho", "drho/dr", "mass", "mtot-mass", "radius(m)"); for (i = 0; i < np; i++) { r = r0 * rpow(2.0, lgrs * i); printf("%12.5f%12.7f%12.3e%12.8f%12.8f%12.5f\n", r, rlog10(rho_gsp(gsp, r)), drho_gsp(gsp, r), mass_gsp(gsp, r), gsp->mtot - mass_gsp(gsp, r), r_mass_gsp(gsp, mass_gsp(gsp, r))); } free_gsprof(gsp); return (0); }
int main(int argc, string argv[]) { stream istr, ostr; bodyptr btab = NULL; int nbody; real tnow; string intags[MaxBodyFields]; gsprof *gsp; initparam(argv, defv); layout_body(bodyfields, Precision, NDIM); istr = stropen(getparam("in"), "r"); get_history(istr); if (! get_snap(istr, &btab, &nbody, &tnow, intags, FALSE)) error("%s: snapshot input failed\n", getargv0()); if (! set_member(intags, PosTag)) error("%s: position data missing\n", getargv0()); if (! set_member(intags, MassTag)) error("%s: mass data missing\n", getargv0()); gsp = snapgsp(btab, nbody, getiparam("npoint"), getdparam("alpha"), getdparam("beta")); if (! strnull(getparam("out"))) { ostr = stropen(getparam("out"), "w"); put_history(ostr); put_gsprof(ostr, gsp); strclose(ostr); } return (0); }
nemo_main() { imageptr iptr=NULL, optr=NULL; string *filename; stream instr, outstr; int i, j, i0, j0, nfiles; int nx, ny, nx1, ny1, ix, iy, n; nx = hasvalue("nx") ? getiparam("nx") : 0; ny = hasvalue("ny") ? getiparam("ny") : 0; filename = burststring(getparam("in")," ,\n"); nfiles = xstrlen(filename,sizeof(string))-1; if (nx==0 && ny==0) error("Need at least one of nx= or ny="); else if (nx==0) { nx = nfiles/ny; dprintf(0,"nx=%d ny=%d nfiles=%d\n",nx,ny,nfiles); if (nfiles % ny) error("nfiles=%d/ny=%d does not divide evenly",nfiles,ny); } else if (ny==0) { ny = nfiles/nx; dprintf(0,"nx=%d ny=%d nfiles=%d\n",nx,ny,nfiles); if (nfiles % nx) error("nfiles=%d/nx=%d does not divide evenly",nfiles,nx); } for (iy=0, n=0; iy<ny; iy++) { for (ix=0; ix<nx; ix++, n++) { instr = stropen (filename[n],"r"); read_image (instr,&iptr); /* read image */ strclose(instr); /* close image file */ if (n==0) { nx1 = Nx(iptr); ny1 = Ny(iptr); create_image(&optr,nx*nx1,ny*ny1); } i0 = ix*nx1; j0 = iy*ny1; for (j=0; j<ny1; j++) for (i=0; i<nx1; i++) MapValue(optr,i+i0,j+j0) = MapValue(iptr,i,j); i++; } } outstr = stropen(getparam("out"),"w"); write_image(outstr,optr); strclose(outstr); }
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); }
nemo_main() { FunctionTable *ftp; string fmt1, fmode = getparam("mode"); char fmt[100]; real x[MAX_LINES], y; bool Qinv; int i, n, mode=FUNTAB_SPLINE; if (hasvalue("x") && hasvalue("y")) error("Can only handle x= or y="); Qinv = hasvalue("y"); if (streq(fmode,"linear")) mode = FUNTAB_LINEAR; if (Qinv) { n = nemoinpd(getparam("y"),x,MAX_LINES); if (n<0) error("Error # %d parsing y=; or too many?",n); } else { n = nemoinpd(getparam("x"),x,MAX_LINES); if (n<0) error("Error # %d parsing x=; or too many?",n); } fmt1 = getparam("format"); sprintf(fmt,"%s %s\n",fmt1,fmt1); dprintf(1,"Using format=\"%s\"\n",fmt); if (Qinv) ftp = ft_open(getparam("in"), mode, getiparam("ycol"), getiparam("xcol")); else ftp = ft_open(getparam("in"), mode, getiparam("xcol"), getiparam("ycol")); for (i=0; i<n; i++) { if (mode == FUNTAB_LINEAR) y = ft_linear(ftp, x[i]); else if (mode == FUNTAB_SPLINE) y = ft_spline(ftp, x[i]); else error("Bad mode"); printf(fmt,x[i], y); } ft_close(ftp); }
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[]) { initparam(argv, defv); readgsp(); init_random(getiparam("seed")); layout_body(bodyfields, Precision, NDIM); gspmodel(); writemodel(); return (0); }
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); }