⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 outitf.c

📁 ngspice又一个电子CAD仿真软件代码.功能更全
💻 C
📖 第 1 页 / 共 3 页
字号:
    run->numData++;    return (OK);}static intaddSpecialDesc(runDesc *run, char *name, char *devname, char *param, int depind){    dataDesc *data;    char *unique;       /* unique char * from back-end */    if (!run->numData)        run->data = (dataDesc *) tmalloc(sizeof (dataDesc));    else        run->data = (dataDesc *) trealloc((char *) run->data,                sizeof (dataDesc) * (run->numData + 1));    data = &run->data[run->numData];    /* so freeRun will get nice NULL pointers for the fields we don't set */    bzero(data, sizeof(dataDesc));    data->name = copy(name);    unique = copy(devname);        /* MW. My "special" routine here */    INPinsertNofree(&unique, (INPtables *) ft_curckt->ci_symtab);    data->specName = unique;    data->specParamName = copy(param);    data->specIndex = depind;    data->specType = -1;    data->specFast = NULL;    data->regular = FALSE;    run->numData++;    return (OK);}intOUTpData(void *plotPtr, IFvalue *refValue, IFvalue *valuePtr){    runDesc *run = (runDesc *) plotPtr;    IFvalue val;    int i;#ifdef PARALLEL_ARCH    if (ARCHme != 0) return(OK);#endif /* PARALLEL_ARCH */    run->pointCount++;    if (run->writeOut) {	if (run->pointCount == 1)	    fileInit_pass2(plotPtr);        fileStartPoint(run->fp, run->binary, run->pointCount);        if (run->refIndex != -1) {          if (run->isComplex){            fileAddComplexValue(run->fp, run->binary, refValue->cValue);/*  While we're looking at the reference value, print it to the screen      every quarter of a second, to give some feedback without using      too much CPU time  */            currclock = clock();            if ((currclock-lastclock)>(0.25*CLOCKS_PER_SEC)) {            	fprintf(stderr, " Reference value : % 12.5e\r",                            refValue->cValue.real);              lastclock = currclock;            }         } else {/*  And the same for a non-complex value  */            fileAddRealValue(run->fp, run->binary, refValue->rValue);            currclock = clock();            if ((currclock-lastclock)>(0.25*CLOCKS_PER_SEC)) {            	fprintf(stderr, " Reference value : % 12.5e\r", refValue->rValue);              lastclock = currclock;            }        }    }        for (i = 0; i < run->numData; i++) {            /* we've already printed reference vec first */            if (run->data[i].outIndex == -1) continue;            if (run->data[i].regular) {                if(run->data[i].type == IF_REAL)                  fileAddRealValue(run->fp, run->binary,                    valuePtr->v.vec.rVec                    [run->data[i].outIndex]);                else if (run->data[i].type == IF_COMPLEX)                  fileAddComplexValue(run->fp, run->binary,                    valuePtr->v.vec.cVec                    [run->data[i].outIndex]);                else                  fprintf(stderr, "OUTpData: unsupported data type\n");            } else {                /* should pre-check instance */                if (!getSpecial(&run->data[i], run, &val))                   {/*  If this is the first data point, print a warning for any unrecognized    variables, since this has not already been checked  */                    if (run->pointCount==1)                       fprintf(stderr, "Warning: unrecognized variable - %s\n",                          run->data[i].name);                    if (run->isComplex) {                        val.cValue.real=0;                        val.cValue.imag=0;                        fileAddComplexValue(run->fp, run->binary,                           val.cValue);                    } else {                        val.rValue=0;                        fileAddRealValue(run->fp, run->binary,                           val.rValue);                    };                    continue;                  };                if (run->data[i].type == IF_REAL)                  fileAddRealValue(run->fp, run->binary,                     val.rValue);                else if (run->data[i].type == IF_COMPLEX)                  fileAddComplexValue(run->fp, run->binary,                     val.cValue);                else                  fprintf(stderr, "OUTpData: unsupported data type\n");            }        }        fileEndPoint(run->fp, run->binary);/*  Check that the write to disk completed successfully, otherwise abort  */        if (ferror(run->fp)) {             fprintf(stderr, "Warning: rawfile write error !!\n");             shouldstop = TRUE;        };    } else {/*  This is interactive mode. Update the screen with the reference    variable just the same  */        currclock = clock();#ifndef HAS_WINDOWS        if ((currclock-lastclock)>(0.25*CLOCKS_PER_SEC)) {          if (run->isComplex) {              fprintf(stderr, " Reference value : % 12.5e\n",                            refValue->cValue.real);          } else {              fprintf(stderr, " Reference value : % 12.5e\n",                            refValue->rValue);          }          lastclock = currclock;        }#endif        for (i = 0; i < run->numData; i++) {            if (run->data[i].outIndex == -1) {	      if (run->data[i].type == IF_REAL)		plotAddRealValue(&run->data[i],				 refValue->rValue);	      else if (run->data[i].type == IF_COMPLEX)		plotAddComplexValue(&run->data[i],				    refValue->cValue);            } else if (run->data[i].regular) {	      if (run->data[i].type == IF_REAL)		plotAddRealValue(&run->data[i],				 valuePtr->v.vec.rVec				 [run->data[i].outIndex]);	      else if (run->data[i].type == IF_COMPLEX)		plotAddComplexValue(&run->data[i],				    valuePtr->v.vec.cVec				    [run->data[i].outIndex]);            } else {	      /* should pre-check instance */	      if (!getSpecial(&run->data[i], run, &val))		continue;	      if (run->data[i].type == IF_REAL)		plotAddRealValue(&run->data[i],				 val.rValue);	      else if (run->data[i].type == IF_COMPLEX)		plotAddComplexValue(&run->data[i],                            val.cValue);	      else 		fprintf(stderr, "OUTpData: unsupported data type\n");            }        }        gr_iplot(run->runPlot);    }    if (ft_bpcheck(run->runPlot, run->pointCount) == FALSE)        shouldstop = TRUE;    return (OK);}/* ARGSUSED */ /* until some code gets written */intOUTwReference(void *plotPtr, IFvalue *valuePtr, void **refPtr){    return (OK);}/* ARGSUSED */ /* until some code gets written */intOUTwData(void *plotPtr, int dataIndex, IFvalue *valuePtr, void *refPtr){    return (OK);}/* ARGSUSED */ /* until some code gets written */intOUTwEnd(void *plotPtr){    return (OK);}intOUTendPlot(void *plotPtr){    runDesc *run = (runDesc *) plotPtr;#ifdef PARALLEL_ARCH    if (ARCHme != 0) return(OK);#endif /* PARALLEL_ARCH */        if (run->writeOut)        fileEnd(run);    else {        gr_end_iplot();        plotEnd(run);    }    freeRun(run);    return (OK);}/* ARGSUSED */ /* until some code gets written */intOUTbeginDomain(void *plotPtr, char *refName, int refType, IFvalue *outerRefValue){    return (OK);}/* ARGSUSED */ /* until some code gets written */intOUTendDomain(void *plotPtr){    return (OK);}/* ARGSUSED */ /* until some code gets written */intOUTattributes(void *plotPtr, char *varName, int param, IFvalue *value){    runDesc *run = (runDesc *) plotPtr;    struct dvec *d;    int type;    int i;    if (param == OUT_SCALE_LIN)	type = GRID_LIN;    else if (param == OUT_SCALE_LOG)	type = GRID_XLOG;    else	return E_UNSUPP;    if (run->writeOut) {	if (varName) {	    for (i = 0; i < run->numData; i++)		if (!strcmp(varName, run->data[i].name))		    run->data[i].gtype = type;	} else {	    run->data[run->refIndex].gtype = type;	}    } else {	if (varName) {	    for (d = run->runPlot->pl_dvecs; d; d = d->v_next)		if (!strcmp(varName, d->v_name))		    d->v_gridtype = type;	} else {	    run->runPlot->pl_scale->v_gridtype = type;	}    }    return (OK);}/* The file writing routines. */static voidfileInit(runDesc *run){    char buf[513];    int i;        lastclock = clock();    /* This is a hack. */    run->isComplex = FALSE;    for (i = 0; i < run->numData; i++)        if (run->data[i].type == IF_COMPLEX)            run->isComplex = TRUE;    i = 0;    sprintf(buf, "Title: %s\n", run->name);    i += strlen(buf);    fputs(buf, run->fp);    sprintf(buf, "Date: %s\n", datestring());    i += strlen(buf);    fputs(buf, run->fp);    sprintf(buf, "Plotname: %s\n", run->type);    i += strlen(buf);    fputs(buf, run->fp);    sprintf(buf, "Flags: %s\n", run->isComplex ? "complex" : "real");    i += strlen(buf);    fputs(buf, run->fp);    sprintf(buf, "No. Variables: %d\n", run->numData);    i += strlen(buf);    fputs(buf, run->fp);    sprintf(buf, "No. Points: ");    i += strlen(buf);    fputs(buf, run->fp);                                                            fflush(run->fp);        /* Gotta do this for LATTICE. */    if (run->fp == stdout || (run->pointPos = ftell(run->fp)) <= 0)        run->pointPos = i;    fprintf(run->fp, "0       \n"); /* Save 8 spaces here. */     fprintf(run->fp, "Command: version %s\n", ft_sim->version);    fprintf(run->fp, "Variables:\n");                                               fprintf(stderr, "No. of Data Columns : %d  \n", run->numData);    return;}static voidfileInit_pass2(runDesc *run){    int i, type;    char *name, buf[BSIZE_SP];    for (i = 0; i < run->numData; i++) {               if (isdigit(*run->data[i].name)) {        (void) sprintf(buf, "V(%s)", run->data[i].name);          name = buf;        } else {          name = run->data[i].name;        }        if (substring("#branch", name))            type = SV_CURRENT;        else if (cieq(name, "time"))            type = SV_TIME;        else if (cieq(name, "frequency"))            type = SV_FREQUENCY;        else if (cieq(name, "temp-sweep")) /* Added by H.T */            type = SV_TEMP;        else if (cieq(name, "res-sweep")) /* Added by H.T */            type = SV_RES;        else            type = SV_VOLTAGE;         fprintf(run->fp, "\t%d\t%s\t%s", i, name,                ft_typenames(type));        if (run->data[i].gtype == GRID_XLOG)            fprintf(run->fp, "\tgrid=3");        fprintf(run->fp, "\n");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -