Example #1
0
writesnap(int n)
{
    int cs = CSCode(Cartesian, NDIM, 2);
    static bool first = TRUE;

    if (n==0) return;

    if (first) {
        if (! streq(headline, ""))
            set_headline(headline);
        outstr = stropen(getparam("out"), "w");
        put_history(outstr);
	first = FALSE;
    }

    put_set(outstr, SnapShotTag);
     put_set(outstr, ParametersTag);
      put_data(outstr, NobjTag, IntType, &n, 0);
     put_tes(outstr, ParametersTag);
     put_set(outstr, ParticlesTag);
      put_data(outstr, CoordSystemTag, IntType, &cs, 0);
      put_data(outstr, MassTag, RealType, pmass, n, 0);
      put_data(outstr, PhaseSpaceTag, RealType, pphase[0][0], n, 2, NDIM, 0);
     put_tes(outstr, ParticlesTag);
    put_tes(outstr, SnapShotTag);
    ntot += n;
}
Example #2
0
int main(int argc, string argv[])
{
  string prog, itags[MaxBodyFields];
  stream xstr, ostr;
  int nold = -1;

  initparam(argv, defv);
  exprs[0] = getparam("group");
  prog = mktemp((string) copxstr("/tmp/sm_XXXXXX", sizeof(char)));
  buildmap(prog, names, exprs, types, NULL, Precision, NDIM, TRUE);
  xstr = execmap(prog);
  if (get_tag_ok(xstr, "History"))
    skip_item(xstr);
  get_history(xstr);
  ostr = stropen(getparam("out"), "w");
  put_history(ostr);
  new_field(&GroupField, IntType, "Group");
  new_field(&GroupField + 1, NULL, NULL);
  layout_body(btags, Precision, NDIM);
  while (get_snap(xstr, &bodytab, &nbody, &tbody, itags, FALSE)) {
    snaptrak();
    put_snap(ostr, &traktab, &ntrak, &tbody, otags);
    if (ntrak != nold)
      eprintf("[%s: wrote %d groups at t = %f]\n",
	      getprog(), ntrak, tbody);
    nold = ntrak;
  }
  strclose(ostr);
  if (unlink(prog) != 0)
    error("%s: can't unlink %s\n", getprog(), prog);
  return (0);
}
Example #3
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);
}
Example #4
0
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);
}
Example #5
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);
}
Example #6
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);
}
Example #7
0
nemo_main()
{
    stream instr, quadstr, outstr;
    Body *btab = NULL, *bp;
    int nbody, bits;
    real eps_r, eps_t, tsnap = 0.0;

    if (!hasvalue("out"))
        warning("No output supplied (out=)");

    quadstr = stropen(getparam("quad"), "r");
    get_history(quadstr);
    instr = stropen(getparam("in"), "r");
    get_history(instr);
    get_quadfield(quadstr, &eps_r, &eps_t);
    get_snap(instr, &btab, &nbody, &tsnap, &bits);
    if (bits & PhaseSpaceBit == 0)
	error("not enuf info: bits = %o", bits);
    for (bp = btab; bp < btab+nbody; bp++) {
	CLRV(Acc(bp));
	Phi(bp) = 0.0;
    }
    quadinter(btab, nbody, eps_r, eps_t);
    if (hasvalue("out")) {
	outstr = stropen(getparam("out"), "w");
	put_history(outstr);
	bits = bits | PotentialBit | AccelerationBit;
	put_snap(outstr, &btab, &nbody, &tsnap, &bits);
    }
}
Example #8
0
int main(int argc, string argv[])
{
  string prog, itags[MaxBodyFields], otags[MaxBodyFields];
  stream xstr, ostr;
  bodyptr btab = NULL;
  int nbody;
  real tnow;

  initparam(argv, defv);
  exprs[0] = getparam("weight");
  prog = mktemp((string) copxstr("/tmp/sm_XXXXXX", sizeof(char)));
  buildmap(prog, names, exprs, types, NULL, Precision, NDIM, TRUE);
  xstr = execmap(prog);
  if (get_tag_ok(xstr, "History"))
    skip_item(xstr);
  get_history(xstr);
  ostr = stropen(getparam("out"), "w");
  put_history(ostr);
  new_field(&WeightField, RealType, "Weight");
  new_field(&WeightField + 1, NULL, NULL);
  while (get_snap(xstr, &btab, &nbody, &tnow, itags, TRUE)) {
    snaprect(btab, nbody);
    del_tag(otags, itags, "Weight");
    put_snap(ostr, &btab, &nbody, &tnow, otags);
  }
  strclose(ostr);
  if (unlink(prog) != 0)
    error("%s: can't unlink %s\n", getargv0(), prog);
  return (0);
}
Example #9
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;
}
Example #10
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);
}
Example #11
0
void writeview(void)
{
    static stream viewstr = NULL;
    real aspect, tempmat[4][4];
    int i, j, k;

    if (viewstr == NULL) {
        viewstr = stropen(getparam("viewfile"), "w");
	put_history(viewstr);
    }
    aspect = ((float) wscreen) / ((float) hscreen);
    for (i = 0; i < 4; i++)
        for (j = 0; j < 4; j++) {
	    tempmat[i][j] = 0.0;
	    for (k = 0; k < 4; k++)
	        tempmat[i][j] += viewmat[i][k] * projmat[k][j];
        }
    put_set(viewstr, "SnapView");
    put_data(viewstr, "Time", RealType, &tnow, 0);
    put_data(viewstr, "Aspect", RealType, &aspect, 0);
    put_data(viewstr, "ViewMatrix", FloatType, tempmat, 4, 4, 0);
    put_data(viewstr, "MouseValues", FloatType, mouseval, NVALUES, 2, 0);
    put_tes(viewstr, "SnapView");
    fflush(viewstr);
}
Example #12
0
void nemo_main(void) /* this replaces main(argc,argv)        <--- required */
{
    stream instr, outstr;
    string times = getparam("times");
    real   tsnap;
    Body  *btab = NULL, *bp;
    int    i, nbody, bits;
    bool   first = TRUE;

    instr = stropen(getparam("in"), "r");
    outstr = stropen(getparam("out"), "w");

    for (;;) {    /* infinite loop, broken only when ran out of snapshots */
    	get_history(instr);                    /* read history */
        if (!get_tag_ok(instr, SnapShotTag)) break; /* check if done */
        get_snap(instr, &btab, &nbody, &tsnap, &bits);  /* get next */
        
        /* Operate on the snapshot here : */
        for (bp=btab, i=0; i<nbody; bp++, i++) {
            /* all the work goes here */
        }
        if (first) {
            put_history(outstr);
            first = FALSE;
        }
        put_snap(outstr, &btab, &nbody, &tsnap, &bits);     /* output */
    }
    strclose(instr);
    if (first) {
    	warning("No snapshots processed");
  	strdelete(outstr,TRUE);
    } else
        strclose(outstr);
}
Example #13
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);
}
Example #14
0
void nemo_main ()
{
  setparams();	/* get cmdline stuff and compute x,y,u,v,etot,lz */

  optr = NULL;				/* make an orbit */
  allocate_orbit (&optr, 3, 1);
  Masso(optr)  = 1.0;                     /* and set Mass */
  Key(optr) = 0;
  Torb(optr,0) = tnow;
  Xorb(optr,0) = x;			/* .. positions */
  Yorb(optr,0) = y;
  Zorb(optr,0) = z;
  Uorb(optr,0) = u;			/* .. velocities */
  Vorb(optr,0) = v;
  Worb(optr,0) = w;
  I1(optr) = etot;			/*  energy (zero if not used) */
  I2(optr) = lz;                          /* angular momentum */
  
  dprintf(0,"pos: %f %f %f  \nvel: %f %f %f  \netot: %f\nlz=%f\n",
	  x,y,z,u,v,w,etot,lz);

  outstr = stropen (outfile,"w");		/* write to file */
  put_history(outstr);
  PotName(optr) = p.name;
  PotPars(optr) = p.pars;
  PotFile(optr) = p.file;
  write_orbit(outstr,optr);
  strclose(outstr);
}
Example #15
0
void writemodel(void)
{
  stream ostr;
  real tsnap = 0.0;

  ostr = stropen(getparam("out"), "w");
  put_history(ostr);
  put_snap(ostr, &disk, &ndisk, &tsnap, bodyfields);
}
Example #16
0
void nemo_main()
{
    stream instr, outstr;
    string times, ctypei, ctypeo;
    real   tsnap;
    int i, nbody, bits, mode;
    Body *btab = NULL, *bp;
    proc transform, trans2;

    times = getparam("times");
    ctypei = getparam("ctypei");
    ctypeo = getparam("ctypeo");
    if (streq(ctypei,"cart") && streq(ctypeo,"sph"))
        transform = cartesian_spherical;
    else if (streq(ctypei,"sph") && streq(ctypeo,"cart"))
        transform = spherical_cartesian;
    else if (streq(ctypei,"cart") && streq(ctypeo,"cyl"))
        transform = cartesian_cylindrical;
    else if (streq(ctypei,"cyl") && streq(ctypeo,"cart"))
        transform = cylindrical_cartesian;
    else
        error("Unimplemented ctype i/o : %s -> %s",ctypei,ctypeo);
    dprintf(0,"converting from %s to %s\n",ctypei,ctypeo);
    
    instr = stropen(getparam("in"), "r");   
    outstr = stropen(getparam("out"), "w");

    get_history(instr);
    put_history(outstr);		
    for (;;) {
    	get_history(instr);		/* skip over stuff we can forget */
        if (!get_tag_ok(instr, SnapShotTag))
		break;			/* done with work in loop */
        get_snap(instr, &btab, &nbody, &tsnap, &bits);
        if ((bits & MassBit) == 0 && (bits & PhaseSpaceBit) == 0) {
	    continue;       /* just skip it's probably a diagnostics */
        }

        if ((bits & TimeBit) == 0)
	    tsnap = 0.0;
        else if (!streq(times,"all") && !within(tsnap, times, TIMEFUZZ))
            continue;
        dprintf (1,"Transforming snapshot at time= %f bits=0x%x\n",tsnap,bits);
#if 0
        Qmass  = MassBit & bits;       
        Qphase = PhaseSpaceBit & bits;
        Qacc   = AccelerationBit & bits;
        Qaux   = AuxBit & bits;
        Qkey   = KeyBit & bits;
#endif

        for (bp = btab; bp < btab+nbody; bp++) {
            (transform)(Pos(bp),Vel(bp),Acc(bp));
        }
        put_snap(outstr, &btab, &nbody, &tsnap, &bits);
    }
}
static void runcl(GtkWidget * entry, gpointer data)
{
    gchar *cmd = gtk_entry_get_text(GTK_ENTRY(entry));
    if (do_run(cmd, FALSE)) {
        // save history
        put_history(cmd, FALSE, History);
    }
    gtk_entry_set_text(GTK_ENTRY(entry), "");
};
Example #18
0
void writegal(string name)
{
    stream outstr;
    real tsnap = 0.0;

    outstr = stropen(name, "w");
    put_history(outstr);
    put_snap(outstr, &galaxy, &ngalaxy, &tsnap, bodyfields);
    strclose(outstr);
}
Example #19
0
int main(int argc, string argv[])
{
  string prog, coords, itags[MaxBodyFields], otags[MaxBodyFields];
  stream xstr, ostr;
  bodyptr btab = NULL, bp;
  int nbody;
  real tnow;
  vector cmpos, cmvel, cmacc;

  initparam(argv, defv);
  exprs[0] = getparam("weight");
  prog = mktemp((string) copxstr("/tmp/sm_XXXXXX", sizeof(char)));
  buildmap(prog, names, exprs, types, NULL, Precision, NDIM, TRUE);
  xstr = execmap(prog);
  if (get_tag_ok(xstr, "History"))
    skip_item(xstr);
  get_history(xstr);
  ostr = stropen(getparam("out"), "w");
  put_history(ostr);
  coords = getparam("coords");
  new_field(&WeightField, RealType, "Weight");
  new_field(&WeightField + 1, NULL, NULL);
  while (get_snap(xstr, &btab, &nbody, &tnow, itags, TRUE, NULL)) {
    if (scanopt(coords, PosTag) && set_member(itags, PosTag)) {
      snapcmpos(cmpos, btab, nbody, WeightField.offset);
      for (bp = btab; bp < NthBody(btab, nbody); bp = NextBody(bp)) {
	SUBV(Pos(bp), Pos(bp), cmpos);
      }
      eprintf("[%s: centroid position: %f,%f,%f]\n", getprog(),
	      cmpos[0], cmpos[1], cmpos[2]);
    }
    if (scanopt(coords, VelTag) && set_member(itags, VelTag)) {
      snapcmvel(cmvel, btab, nbody, WeightField.offset);
      for (bp = btab; bp < NthBody(btab, nbody); bp = NextBody(bp)) {
	SUBV(Vel(bp), Vel(bp), cmvel);
      }
      eprintf("[%s: centroid velocity: %f,%f,%f]\n", getprog(),
	      cmvel[0], cmvel[1], cmvel[2]);
    }
    if (scanopt(coords, AccTag) && set_member(itags, AccTag)) {
      snapcmacc(cmacc, btab, nbody, WeightField.offset);
      for (bp = btab; bp < NthBody(btab, nbody); bp = NextBody(bp)) {
	SUBV(Acc(bp), Acc(bp), cmacc);
      }
      eprintf("[%s: cen. acceleration: %f,%f,%f]\n", getprog(),
	      cmacc[0], cmacc[1], cmacc[2]);
    }
    del_tag(otags, itags, "Weight");
    put_snap(ostr, &btab, &nbody, &tnow, otags);
  }
  strclose(ostr);
  if (unlink(prog) != 0)
    error("%s: can't unlink %s\n", getprog(), prog);
  return (0);
}
Example #20
0
void out_result(void)
{
    string out;

    if (outstr==NULL) {
        out = getparam("out");
	outstr = stropen(out, "w");
	put_history(outstr);
    }
    write_snapshot();			/* output testdata results */
}
Example #21
0
void writemodel(void)
{
    stream ostr;
    real tsnap = 0.0;

    if (! strnull(getparam("out"))) {
        ostr = stropen(getparam("out"), "w");
        put_history(ostr);
        put_snap(ostr, &btab, &nbody, &tsnap, bodyfields);
        strclose(ostr);
    }
}
Example #22
0
void put_number(string name, real x, int n, int r)
{
    stream str;
    real *buf;
    int nout,i;

    str = stropen(name,"w");
    put_history(str);
    nout = n*r;
    //put_set(str,"Testing");
    put_data(str,"n",IntType,&nout,0);
    buf = (real *) allocate(n*sizeof(real));
    buf[0] = x;   /* only set first and third number */
    if (n>2) buf[2] = x;
    if (r==1) {
        put_data(str,"x",RealType,buf,0,n);
        put_data(str,"y",RealType,buf,0,n);
    } else {
        put_data_set(str,"x",RealType,nout,0);
        for (i=r;i>0;i--) {
            buf[i] = -1.0 * i;
            if (n>3) get_nand((double*)&buf[3]);
	    if (n>4) get_nanf((float *)&buf[4]);
            put_data_ran(str,"x",buf,(i-1)*n,n);
        }
        put_data_tes(str,"x");

        put_data_set(str,"y",RealType,nout,0);
        for (i=r;i>0;i--) {
            buf[i] = -1.0 * i;
            if (n>3) get_nand((double *)&buf[3]);
	    if (n>4) get_nanf((float  *)&buf[4]);
            put_data_ran(str,"y",buf,(i-1)*n,n);
        }
        put_data_tes(str,"y");

#if 1
    dprintf(0,"nout=%d\n",nout);
    for (i=0; i<nout; i++) buf[i]=10+i;
    put_data_set(str,"z1",RealType,nout,0);

    //    for (i=nout-1; i>=0; i--) put_data_ran(str,"z1",&buf[i],i,1);
    //    for (i=0; i<nout; i++) put_data_ran(str,"z1",&buf[i],i,1);
    put_data_ran(str,"z1",buf,0,1);
    put_data_tes(str,"z1");
#endif
    }
    //put_tes(str,"Testing");
    strclose(str);
    dprintf(1,"Wrote number %f to file %s\n",x,name);
    free( (char *) buf);
}
Example #23
0
local void writesnap(string name, string headline)
{
    stream outstr;
    real tzero = getdparam("time");
    int bits = MassBit | PhaseSpaceBit | TimeBit;

    if (! streq(headline, ""))
	set_headline(headline);
    outstr = stropen(name, "w");
    put_history(outstr);
    put_snap(outstr, &disktab, &ndisk, &tzero, &bits);
    strclose(outstr);
}
Example #24
0
void initoutput()
{
    if (! streq(headline, "")) {		/* nontrivial headline?     */
	printf("\n%s\n", headline);		/* headline log stream      */
	set_headline(headline);			/* and save with history    */
    }
    if (*outfile) {                             /* output file given?       */
        outstr = stropen(outfile, "w");         /*   setup out. stream      */
	put_history(outstr);
    }
    if (*quadfile) {                            /* field file given?        */
        quadstr = stropen(quadfile, "w");       /*   setup out. stream      */
        put_history(quadstr);
    }
    printf("\n%12s%12s%12s%12s%12s%12s\n",
           "nbody", "freq", "eps_r", "eps_t", "mode", "tstop");
    printf("%12d%12.4f%12.4f%12.4f%12d%12.2f\n\n",
	   nbody, freq, eps1, eps2, mode, tstop);
    if (*options)
	printf("\toptions: %s\n\n", options);
    minor_tout = tout = tnow;			/* schedule 1st outputs     */
    if (*savefile)       			/* restart file enabled?    */
	savestate(savefile);			/*   save inital state      */
}
Example #25
0
void writemodel(void)
{
    stream ostr;
    real tsnap = 0.0;
    string outfields[] = { PosTag, VelTag, MassTag, PhiTag, AuxTag, NULL };

    if (! strnull(getparam("out"))) {
	if (strnull(getparam("auxvar")))
	    outfields[3] = NULL;
	ostr = stropen(getparam("out"), "w");
	put_history(ostr);
	put_snap(ostr, &btab, &nbody, &tsnap, outfields);
	strclose(ostr);
    }
}
Example #26
0
int main(int argc, string argv[])
{
    real rrange[2];
    gsprof *gsp;
    stream ostr;

    initparam(argv, defv);
    setrange(rrange, getparam("rrange"));
    gsp = plumgsp(getdparam("mtot"), getdparam("a"),
		  getiparam("npoint"), rrange[0], rrange[1]);
    ostr = stropen(getparam("out"), "w");
    put_history(ostr);
    put_gsprof(ostr, gsp);
    strclose(ostr);
    return (0);
}
Example #27
0
File: image.c Project: jobovy/nemo
int write_image (stream outstr, imageptr iptr)
{
  put_history(outstr);
  put_set (outstr,ImageTag);
    put_set (outstr,ParametersTag);
      put_data (outstr,NxTag,  IntType,  &(Nx(iptr)),   0);
      put_data (outstr,NyTag,  IntType,  &(Ny(iptr)),   0);
      put_data (outstr,NzTag,  IntType,  &(Nz(iptr)),   0);
      put_data (outstr,XminTag,RealType, &(Xmin(iptr)), 0);
      put_data (outstr,YminTag,RealType, &(Ymin(iptr)), 0);
      put_data (outstr,ZminTag,RealType, &(Zmin(iptr)), 0);
      put_data (outstr,DxTag,  RealType, &(Dx(iptr)),   0);
      put_data (outstr,DyTag,  RealType, &(Dy(iptr)),   0);
      put_data (outstr,DzTag,  RealType, &(Dz(iptr)),   0);
      put_data (outstr,XrefTag,RealType, &(Xref(iptr)), 0);
      put_data (outstr,YrefTag,RealType, &(Yref(iptr)), 0);
      put_data (outstr,ZrefTag,RealType, &(Zref(iptr)), 0);
      put_data (outstr,MapMinTag, RealType, &(MapMin(iptr)), 0);
      put_data (outstr,MapMaxTag, RealType, &(MapMax(iptr)), 0);
      put_data (outstr,BeamTypeTag, IntType, &(BeamType(iptr)), 0);
      put_data (outstr,BeamxTag, RealType, &(Beamx(iptr)), 0);
      put_data (outstr,BeamyTag, RealType, &(Beamy(iptr)), 0);
      put_data (outstr,BeamzTag, RealType, &(Beamz(iptr)), 0);
      if (Namex(iptr))
         put_string (outstr,NamexTag,Namex(iptr));
      if (Namey(iptr))
         put_string (outstr,NameyTag,Namey(iptr));
      if (Namez(iptr))
         put_string (outstr,NamezTag,Namez(iptr));
      if (Unit(iptr))
         put_string (outstr,UnitTag,Unit(iptr));
      put_data (outstr,TimeTag,  RealType, &(Time(iptr)), 0);
      put_string(outstr,StorageTag,matdef[idef]);
      put_data (outstr,AxisTag,  IntType, &(Axis(iptr)), 0);
    put_tes (outstr, ParametersTag);
         
    put_set (outstr,MapTag);
    if (Nz(iptr)==1)
      put_data (outstr,MapValuesTag,RealType,
		Frame(iptr),Nx(iptr),Ny(iptr),0);
    else
      put_data (outstr,MapValuesTag,RealType,
		Frame(iptr),Nx(iptr),Ny(iptr),Nz(iptr),0);
    put_tes (outstr, MapTag);
  put_tes (outstr, ImageTag);
  return 1;
}
Example #28
0
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);
}
Example #29
0
/* YY_STARTBLOCK -- Terminate the last command block and start a new one.
 * Save old command block in history (if interactive) and in logfile (if
 * interactive, logging is enabled, and logflag argument is true).  Even
 * if logging is enabled, a command will not be logged which aborts or is
 * interrupted.
 */
void
yy_startblock (
  int	logflag
)
{
	register char *ip;

	if (cldebug)
	    eprintf ("startblock (%d)\n", logflag);

	/* Log cmdblk only if it was filled by an interactive task.  We must
	 * make the test when the new block is initialized since the write is
	 * delayed.
	 */
	if (cmdblk_save) { 
	    /* Do not record commands which consist only of whitespace.
	     */
	    for (ip=cmdblk;  isspace (*ip);  ip++)
		;
	    if (*ip != EOS) {
		/* Use the raw_cmdblk, saved in get_command().
		 */
		put_history (raw_cmdblk);
		if (logflag && log_commands())
		    put_logfile (raw_cmdblk);
	    }
	}

	if (cldebug) 
	    eprintf ("startblock: ifseen=%d\n", ifseen);

	if (!ifseen) {
	    ip_cmdblk = op_cmdblk = cmdblk;
	    *ip_cmdblk = EOS;
	}
	cmdblk_line = 0;
	cmdblk_save = (currentask->t_flags & T_INTERACTIVE);

	/* Mode switching of the lexical analyzer is enabled by this call
	 * if the CL parameter lexmodes is set.  Called between blocks
	 * entered interactively and also during error recovery.
	 */
	lexinit();
}
Example #30
0
/***********
 * Put a packet into the jitterbuffers 
 * Only the timestamps of voicepackets are put in the history
 * this because the jitterbuffer only works for voicepackets
 * don't put packets twice in history and queue (e.g. transmitting every frame twice)
 * keep track of statistics
 */
void jb_put(jitterbuffer *jb, void *data, int type, long ms, long ts, long now, int codec) 
{ 
  long pointer, max_index;
  
  if (jb == NULL) {
    jb_err("no jitterbuffer in jb_put()\n");
    return;
  }
  
  jb->info.frames_received++;

  if (type == JB_TYPE_CONTROL) {
    //put the packet into the contol-queue of the jitterbuffer
    jb_dbg("pC");
    put_control(jb,data,type,ts);

  } else if (type == JB_TYPE_VOICE) {
    // only add voice that aren't already in the buffer
    max_index = (jb->hist_pointer < JB_HISTORY_SIZE) ? jb->hist_pointer : JB_HISTORY_SIZE-1;
    pointer = find_pointer(&jb->hist_sorted_timestamp[0], max_index, ts);
    if (jb->hist_sorted_timestamp[pointer]==ts) { //timestamp already in queue
      jb_dbg("pT");
      free(data); 
      jb->info.frames_dropped_twice++;
    } else { //add
      jb_dbg("pV");
      /* add voicepacket to history */
      put_history(jb,ts,now,ms,codec);
      /*calculate jitterbuffer size*/
      calculate_info(jb, ts, now, codec);
      /*put the packet into the queue of the jitterbuffer*/
      put_voice(jb,data,type,ms,ts,codec);
    } 

  } else if (type == JB_TYPE_SILENCE){ //silence
    jb_dbg("pS");
    put_voice(jb,data,type,ms,ts,codec);

  } else {//should NEVER happen
    jb_err("jb_put(): type not known\n");
    free(data);
  }
}