您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ strclose函数代码示例

51自学网 2021-06-03 08:28:04
  C++
这篇教程C++ strclose函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中strclose函数的典型用法代码示例。如果您正苦于以下问题:C++ strclose函数的具体用法?C++ strclose怎么用?C++ strclose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了strclose函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: nemo_main

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);}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:34,


示例2: nemo_main

void nemo_main (){    setparams();			/* set par's in globals */    instr = stropen (infile, "r");    read_image (instr,&iptr);				/* set some global paramters */    nx = Nx(iptr);	    ny = Ny(iptr);    nz = Nz(iptr);    xmin = Xmin(iptr);    ymin = Ymin(iptr);    zmin = Zmin(iptr);    dx = Dx(iptr);    dy = Dy(iptr);    dz = Dz(iptr);    if(hasvalue("gauss"))        make_gauss_beam(getparam("dir"));    outstr = stropen (outfile,"w");    if (hasvalue("wiener"))      wiener();    else      smooth_it();    write_image (outstr,iptr);    strclose(instr);    strclose(outstr);}
开发者ID:jobovy,项目名称:nemo,代码行数:30,


示例3: stopoutput

void stopoutput(){    if (outstr != NULL)        strclose(outstr);    if (quadstr != NULL)        strclose(quadstr);}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:7,


示例4: nemo_main

nemo_main(){    real frame[N][N];    image f1;    imageptr fp1, fp2;	/* or image *fp1 */    stream instr,outstr;    if (strcmp(getparam("mode"),"w")==0) {		/* write test */	printf ("WRITING test (mode=w) foo.dat/n");	outstr = stropen ("foo.dat","w");	f1.frame = &frame[0][0];  /* compiler complained when = frame used ???? */				  /* would be same as fp2->frame = ... */	fp1 = &f1;		  /* to initialize structures, we need pointer to them */	ini_matrix (&fp1,N,N);    /* ini_matrix MUST have pointer to pointer to image */		fp2 = NULL;		  /* This is to check dynamic allocation of whole thing */	ini_matrix (&fp2,N,N);	write_image (outstr,fp2);	write_image (outstr,&f1);		/* or fp1 */	strclose(outstr);	exit(0);    } else {	printf ("READING test (mode<>w) foo.dat/n");	fp2=NULL;					/* read test */	instr = stropen ("foo.dat","r");	while (read_image(instr,&fp2)) {            printf ("Read image/n");            printf ("with MapValue(5,5)=%f/n",MapValue(fp2,5,5));	}	strclose(instr);    }}
开发者ID:jobovy,项目名称:nemo,代码行数:34,


示例5: nemo_main

nemo_main(){  stream instr, outstr;  int    i, n, nfile, blocking[2];  string outfile, hdselect, *insert, *fix, *deletes, *keep, *print;  char   basename[128];  struct fits_header fh;  bool   split, sel_head, sel_data;    instr = stropen(getparam("in"),"r");    /* open input */  outfile = getparam("out");            outstr = stropen(outfile,"w");	/* open file now */  for (i=1;;i++) {			             /* loop over all HDU's */    fts_zero(&fh);			             /* reset header */    n = fts_rhead(&fh,instr);	              /* read header */    if (n<0)				              /* if no data (EOF) .. */      break;			              /* ... quit */    fts_chead816(&fh,outstr);                         /* copy header */    fts_cdata816(&fh,instr,outstr);         /* copy data, with trailing bits */                                               /* this also modifies fh->bitpix */  }  strclose(outstr);  strclose(instr);                    /* close files */}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:26,


示例6: main

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);}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:32,


示例7: readgsp

void readgsp(void){    stream istr;    istr = stropen(getparam("gsp"), "r");    get_history(istr);    gsp = ggsp = get_gsprof(istr);    strclose(istr);    if (! strnull(getparam("grav"))) {        istr = stropen(getparam("grav"), "r");        get_history(istr);        ggsp = get_gsprof(istr);        strclose(istr);    }}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:15,


示例8: nemo_main

nemo_main(){  int n = 0;  setparams();                    /* set globals */  instr = stropen (infile, "r");  plinit ("***", 0.0, 20.0, 0.0, 20.0);       /* init yapp */  while (read_image(instr,&iptr)) {   /* loop while more images found */    dprintf(1,"Time= %g MinMax= %g %g/n",Time(iptr),MapMin(iptr),MapMax(iptr));    nx=Nx(iptr);			    ny=Ny(iptr);    nz=Nz(iptr);    if (nz > 1) error("Cannot handle 3D images [%d,%d,%d]",nx,ny,nz);    xmin=Xmin(iptr);    ymin=Ymin(iptr);    dx=Dx(iptr);    dy=Dy(iptr);    xsize = nx * dx;    ysize = ny * dy;    if (n>0) {      sleep(1);      plframe();    }    plot_map();                                 /* plot the map */    n++;  }  plstop();                                   /* end of yapp */  strclose(instr);}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:29,


示例9: main

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);}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:29,


示例10: nemo_main

nemo_main (){    setparams();    outstr = stropen(getparam("out"),"w");    cube_create(outstr);    strclose(outstr);}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:7,


示例11: restorestate

int restorestate(string file){    stream str;    string program, version;    str = stropen(file, "r");			/* open state input file    */    program = get_string(str, "program");    version = get_string(str, "version");    if (! streq(version, getparam("VERSION")))	printf("warning: state file may be outdated/n/n");    headline = get_string(str, "headline");	/* read control parameters  */    get_data(str, "freq", RealType, &freq, 0);    get_data(str, "mode", IntType, &mode, 0);    get_data(str, "eps1", RealType, &eps1, 0);    get_data(str, "eps2", RealType, &eps2, 0);    options = get_string(str, "options");    get_data(str, "tstop", RealType, &tstop, 0);    get_data(str, "minor_freqout", RealType, &minor_freqout, 0);    get_data(str, "freqout", RealType, &freqout, 0);    get_data(str, "tnow", RealType, &tnow, 0);	/* read system state        */    get_data(str, "minor_tout", RealType, &minor_tout, 0);    get_data(str, "tout", RealType, &tout, 0);    get_data(str, "nbody", IntType, &nbody, 0);    bodytab = (Body *) allocate(nbody * sizeof(body));    get_data(str, "bodytab", AnyType, bodytab, nbody, sizeof(body), 0);    get_data(str, "qfld", AnyType, &qfld, sizeof(qfld), 0);    strclose(str);}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:28,


示例12: nemo_main

nemo_main(){    setparams();    read_data();    if (scanopt(method,"line")) {        do_line();    } else if (scanopt(method,"ellipse")) {        do_ellipse();    } else if (scanopt(method,"imageshift")) {        do_imageshift();    } else if (scanopt(method,"plane")) {    	do_plane();    } else if (scanopt(method,"gauss1d")) {    	do_gauss1d();    } else if (scanopt(method,"gauss2d")) {    	do_gauss2d();    } else if (scanopt(method,"poly")) {    	do_poly();    } else if (scanopt(method,"area")) {        do_area();    } else if (scanopt(method,"peak")) {    	do_peak();    } else if (scanopt(method,"zero")) {    	do_zero();    } else if (scanopt(method,"fourier")) {    	do_fourier();    } else        error("fit=%s invalid; try [line,ellipse,imageshift,plane,gauss1d,gauss2d,poly,area,peak,zero,fourier]",	      getparam("fit"));    if (outstr) strclose(outstr);}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:34,


示例13: savestate

void savestate(string pattern){    char namebuf[256];    stream str;    sprintf(namebuf, pattern, nstep & 1);		// construct alternate name    str = stropen(namebuf, "w!");			// open state output file    put_string(str, "program", getprog());    put_string(str, "version", getversion());    put_string(str, "headline", headline);	// save control parameters    put_data(str, "dtime", RealType, &dtime, 0);    put_data(str, "nstatic", IntType, &nstatic, 0);#if !defined(QUICKSCAN)    put_data(str, "theta", RealType, &theta, 0);#endif    put_data(str, "usequad", BoolType, &usequad, 0);    put_data(str, "eps", RealType, &eps, 0);    put_string(str, "options", options);    put_string(str, "outputs", outputs);    put_data(str, "tstop", RealType, &tstop, 0);    put_data(str, "dtout", RealType, &dtout, 0);    put_data(str, "tnow", RealType, &tnow, 0);	// save state variables    put_data(str, "tout", RealType, &tout, 0);    put_data(str, "nstep", IntType, &nstep, 0);    put_data(str, "rsize", RealType, &rsize, 0);    put_data(str, "nbody", IntType, &nbody, 0);    put_data(str, "timesteps", IntType, &nbody, 0);    put_data(str, "bodytab", AnyType, bodytab, nbody, sizeof(body), 0);    strclose(str);}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:30,


示例14: setcolors

setcolors(){    stream cstr;    int ncolors;    real red[MAXCOL], green[MAXCOL], blue[MAXCOL];    char line[256];    if (hasvalue("color_table")) {	cstr = stropen(getparam("color_table"), "r");        if(qsf(cstr)) {	    get_data(cstr, "ncolors", IntType, &ncolors, 0);	    get_data(cstr, "red", RealType, red, ncolors, 0);	    get_data(cstr, "green", RealType, green, ncolors, 0);	    get_data(cstr, "blue", RealType, blue, ncolors, 0);	    plpalette(red, green, blue, ncolors);        } else {            rewind(cstr);            ncolors = 0;            while (fgets(line,256,cstr)) {                sscanf(line,"%g %g %g",&red[ncolors], &green[ncolors], &blue[ncolors]);                ncolors++;            }	    plpalette(red, green, blue, ncolors);        }	strclose(cstr);        dprintf(0,"New colortable with %d entries/n",ncolors);    }}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:28,


示例15: trace

// disconnect from external sources -----------------------------------------void __fastcall TPlot::Disconnect(void){    AnsiString s;    char *cmd;    int i;        trace(3,"Disconnect/n");        if (!ConnectState) return;        ConnectState=0;        for (i=0;i<2;i++) {        if (StrCmdEna[i][1]) {            cmd=StrCmds[i][1].c_str();            strwrite(Stream+i,(unsigned char *)cmd,strlen(cmd));        }        strclose(Stream+i);    }    if (strstr(Caption.c_str(),"CONNECT")) {        Caption=s.sprintf("DISCONNECT%s",Caption.c_str()+7);    }    UpdateTime();    UpdatePlot();}
开发者ID:brNX,项目名称:rtklibros,代码行数:26,


示例16: restorestate

restorestate(string file){    stream str;    string program, version;    str = stropen(file, "r");			/* open state input file    */    program = get_string(str, "program");    version = get_string(str, "version");    if (! streq(program, getargv0()) ||		/* check program, version   */	  ! streq(version, getparam("VERSION")))	printf("warning: state file may be outdated/n/n");    headline = get_string(str, "headline");	/* read control parameters  */    get_data(str, "freq", RealType, &freq, 0);    get_data(str, "tol", RealType, &tol, 0);    get_data(str, "eps", RealType, &eps, 0);    get_data(str, "fcells", RealType, &fcells, 0);    options = get_string(str, "options");    get_data(str, "tstop", RealType, &tstop, 0);    get_data(str, "freqout", RealType, &freqout, 0);    get_data(str, "minor_freqout", RealType, &minor_freqout, 0);    get_data(str, "tnow", RealType, &tnow, 0);	/* read state variables     */    get_data(str, "tout", RealType, &tout, 0);    get_data(str, "minor_tout", RealType, &minor_tout, 0);    get_data(str, "nstep", IntType, &nstep, 0);    get_data(str, "rmin", RealType, rmin, NDIM, 0);    get_data(str, "rsize", RealType, &rsize, 0);    get_data(str, "nbody", IntType, &nbody, 0);    bodytab = (bodyptr) allocate(nbody * sizeof(body));    if (bodytab == NULL)	error("restorestate: not enuf memory/n");    get_data(str, "bodytab", AnyType, bodytab, nbody, sizeof(body), 0);    strclose(str);}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:33,


示例17: nemo_main

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);}
开发者ID:jobovy,项目名称:nemo,代码行数:29,


示例18: main

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);}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:30,


示例19: main

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);}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:29,


示例20: main

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);}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:25,


示例21: restorestate

void restorestate(string file){    stream str;    string program, version;    str = stropen(file, "r");			// open state input file    program = get_string(str, "program");    version = get_string(str, "version");    if (! streq(program, getprog()) ||		// check program, version            ! streq(version, getversion()))        eprintf("[%s: warning: state file may be outdated]/n", getprog());    headline = get_string(str, "headline");	// read control parameters    get_data(str, "dtime", RealType, &dtime, 0);    get_data(str, "nstatic", IntType, &nstatic, 0);#if !defined(QUICKSCAN)    get_data(str, "theta", RealType, &theta, 0);#endif    get_data(str, "usequad", BoolType, &usequad, 0);    get_data(str, "eps", RealType, &eps, 0);    options = get_string(str, "options");    outputs = get_string(str, "outputs");    get_data(str, "tstop", RealType, &tstop, 0);    get_data(str, "dtout", RealType, &dtout, 0);    get_data(str, "tnow", RealType, &tnow, 0);	// read state variables    get_data(str, "tout", RealType, &tout, 0);    get_data(str, "nstep", IntType, &nstep, 0);    get_data(str, "rsize", RealType, &rsize, 0);    get_data(str, "nbody", IntType, &nbody, 0);    get_data(str, "timesteps", IntType, &nbody, 0);    bodytab = (bodyptr) allocate(nbody * sizeof(body));    get_data(str, "bodytab", AnyType, bodytab, nbody, sizeof(body), 0);    strclose(str);}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:33,


示例22: nemo_main

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);}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:35,


示例23: savestate

int savestate(string file){    stream str;    str = stropen(file, "a");			/* open state output file   */    fseek(str, 0L, 0);				/* rewind stream to origin  */    put_string(str, "program", getargv0());    put_string(str, "version", getparam("VERSION"));    put_string(str, "headline", headline);	/* save control parameters  */    put_data(str, "freq", RealType, &freq, 0);    put_data(str, "mode", IntType, &mode, 0);    put_data(str, "eps1", RealType, &eps1, 0);    put_data(str, "eps2", RealType, &eps2, 0);    put_string(str, "options", options);    put_data(str, "tstop", RealType, &tstop, 0);    put_data(str, "minor_freqout", RealType, &minor_freqout, 0);    put_data(str, "freqout", RealType, &freqout, 0);    put_data(str, "tnow", RealType, &tnow, 0);	/* save state variables     */    put_data(str, "minor_tout", RealType, &minor_tout, 0);    put_data(str, "tout", RealType, &tout, 0);    put_data(str, "nbody", IntType, &nbody, 0);    put_data(str, "bodytab", AnyType, bodytab, nbody, sizeof(body), 0);    put_data(str, "qfld", AnyType, &qfld, sizeof(qfld), 0);    strclose(str);}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:25,


示例24: testing

void testing(string name, string mode, string text, bool del){    char buf[128];    stream str;    str = stropen(name, mode);    dprintf(0,"%s has strname -> %s/n", name, strname(str));    dprintf(0,"%s has strseek -> %d/n", name, strseek(str)?1:0);    if (streq(mode, "a") || streq(mode, "r")) {        printf("READING/n");	while (fgets(buf, 127, str) != NULL)	    printf("%s", buf);    }    if (streq(mode,"w") || streq(mode,"w!") ||	streq(mode,"s") || streq(mode,"a")) {        printf("WRITING/n");        sprintf(buf, "%s/n", text);	fputs(buf, str);    }    if (streq(mode, "s")) {      printf("REWIND AND READING/n");        rewind(str);	while (fgets(buf, 127, str) != NULL)	    printf("%s", buf);    }    if (del)        strdelete(str,TRUE);    else        strclose(str);}
开发者ID:jobovy,项目名称:nemo,代码行数:34,


示例25: main

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);}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:32,


示例26: main

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);}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:32,


示例27: nemo_main

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);}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:47,


示例28: read_data

local void read_data(){  int   i, k, ndata, n;  real *data;  stream instr;  imageptr iptr=NULL;	  instr = stropen (input, "r");  read_image (instr,&iptr);  strclose(instr);  ndata = Nx(iptr) * Ny(iptr) * Nz(iptr);  data = Frame(iptr);  x = (real *) allocate(ndata*sizeof(real));  if (scale != 1.0) {    for (i=0; i<ndata; i++)      data[i] *= scale;  }  if (Qdual) {    /* pass over the data, finding the mean */    dual_mean = 0.0;    n = 0;    for (i=0; i<ndata; i++) {      if (Qblank && data[i]==blankval) continue;      dual_mean += data[i];      n++;    }    dual_mean /= n;    dprintf(0,"Dual pass mean       : %g/n",dual_mean);  } else    dual_mean = 0.0;  Nunder = Nover = Nblank = 0;  for (i=0, k=0; i<ndata; i++) {    if (Qblank && data[i]==blankval) { Nblank++; continue;}    data[i] -= dual_mean;    if (Qmin && data[i] < xrange[0]) { Nunder++; continue;}    if (Qmax && data[i] > xrange[1]) { Nover++;  continue;}    /* should now copy data into new array for later work */    x[k++] = data[i];  }  npt = k;  dprintf(0,"Under/Over flow: %d %d/n",Nunder,Nover);  dprintf(0,"Blanked:         %d/n",Nblank);  minmax(npt, x, &xmin, &xmax);  if (!Qmin) xrange[0] = xmin;  if (!Qmax) xrange[1] = xmax;  /*  allocate index arrray , and compute sorted index for median */  if (Qmedian)     (mysort)(x,npt,sizeof(real),compar_real);  free_image(iptr);}
开发者ID:jobovy,项目名称:nemo,代码行数:59,


示例29: nemo_main

void nemo_main(void){    stream instr, outstr;    real   tsnap;    string times;    Body *btab = NULL, *bp;    float mass, pos[NDIM], vel[NDIM], t;    int j, nbody, bits;                instr = stropen(getparam("in"), "r");	/* open input file */    outstr = stropen(getparam("out"), "w");	/* open output file */    times = getparam("times");    get_history(instr);                 /* read history */    for(;;) {                /* repeating until first or all times are read */	get_history(instr);        if (!get_tag_ok(instr, SnapShotTag))            break;                                  /* done with work */        get_snap(instr, &btab, &nbody, &tsnap, &bits);        if (!streq(times,"all") && !within(tsnap,times,0.0001))            continue;                   /* skip work on this snapshot */        if ( (bits & PhaseSpaceBit) == 0)            continue;                   /* skip work, only diagnostics here */        dprintf(0,"Converting time=%f to RV format",tsnap);        	fwrite(&nbody,sizeof(int),1,outstr);        for (bp = btab; bp < btab+nbody; bp++) {	    mass = Mass(bp);            fwrite(&mass,sizeof(float),1,outstr);        }        t = tsnap;        fwrite(&t,sizeof(float),1,outstr);        for (bp = btab; bp < btab+nbody; bp++) {	    for(j = 0; j < NDIM; j++) {		pos[j] = Pos(bp)[j];		vel[j] = Vel(bp)[j];	    }	    fwrite(pos,sizeof(float),NDIM,outstr);	    fwrite(vel,sizeof(float),NDIM,outstr);        }    }    strclose(instr);    strclose(outstr);}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:46,


示例30: nemo_main

void nemo_main(){  int n;  stream parstr, outstr;  string molfile = getparam("mol");  string outfile = getparam("out");  string outdir  = getparam("outdir");  string exefile = "radex";  string datfile = "mol.dat";  string parfile = "input.txt";  string logfile = "radex.txt";  char dname[256], cmd[256];  real  fmin = getdparam("fmin");  real  fmax = getdparam("fmax");  real  tkin = getdparam("tkin");  int   npartner;  string *partner;  real  density[MAXPARTNER];  real  tbg = getdparam("tbg");  real  cdmol = getdparam("cdmol");  real  deltav = getdparam("deltav");  partner = burststring(getparam("partner"),",");  npartner = xstrlen(partner,sizeof(string))-1;  if (npartner < 1 || npartner>MAXPARTNER) error("too few/many partners");  n = nemoinpr(getparam("density"),density,MAXPARTNER);  if (n != npartner) error("need matching numbers for partner= and density=");  run_mkdir(outdir);  sprintf(dname,"%s/%s",outdir,parfile);  parstr = stropen(dname,"w");  fprintf(parstr,"%s/n",molfile);  fprintf(parstr,"%s/n",outfile);  fprintf(parstr,"%g %g/n",fmin,fmax);  fprintf(parstr,"%g/n",tkin);  fprintf(parstr,"%d/n",npartner);  for (n=0; n<npartner; n++) {    fprintf(parstr,"%s/n",partner[n]);    fprintf(parstr,"%g/n",density[n]);  }   fprintf(parstr,"%g/n",tbg);  fprintf(parstr,"%g/n",cdmol);  fprintf(parstr,"%g/n",deltav);  fprintf(parstr,"0/n");  strclose(parstr);  run_cd(outdir);  sprintf(cmd,"%s < %s > %s ", exefile, parfile, logfile);  run_sh(cmd);}
开发者ID:jobovy,项目名称:nemo,代码行数:57,



注:本文中的strclose函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ strcmp函数代码示例
C++ strclone函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。