2000-04-27 22:03:57 +02:00
|
|
|
/**********
|
|
|
|
|
Copyright 1990 Regents of the University of California. All rights reserved.
|
2012-05-01 14:32:07 +02:00
|
|
|
Author: 1988 Wayne A. Christopher, U. C. Berkeley CAD Group
|
2005-05-30 22:28:29 +02:00
|
|
|
Modified: 2000 AlansFixes
|
2000-04-27 22:03:57 +02:00
|
|
|
**********/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This module replaces the old "writedata" routines in nutmeg.
|
|
|
|
|
* Unlike the writedata routines, the OUT routines are only called by
|
|
|
|
|
* the simulator routines, and only call routines in nutmeg. The rest
|
|
|
|
|
* of nutmeg doesn't deal with OUT at all.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-12-11 19:05:00 +01:00
|
|
|
#include "ngspice/ngspice.h"
|
|
|
|
|
#include "ngspice/cpdefs.h"
|
|
|
|
|
#include "ngspice/ftedefs.h"
|
|
|
|
|
#include "ngspice/dvec.h"
|
|
|
|
|
#include "ngspice/plot.h"
|
|
|
|
|
#include "ngspice/sim.h"
|
|
|
|
|
#include "ngspice/inpdefs.h" /* for INPtables */
|
|
|
|
|
#include "ngspice/ifsim.h"
|
|
|
|
|
#include "ngspice/jobdefs.h"
|
|
|
|
|
#include "ngspice/iferrmsg.h"
|
2000-06-27 18:09:02 +02:00
|
|
|
#include "circuits.h"
|
2000-04-27 22:03:57 +02:00
|
|
|
#include "outitf.h"
|
2000-06-27 18:09:02 +02:00
|
|
|
#include "variable.h"
|
2000-10-03 07:22:07 +02:00
|
|
|
#include <fcntl.h>
|
2011-12-11 19:05:00 +01:00
|
|
|
#include "ngspice/cktdefs.h"
|
|
|
|
|
#include "ngspice/inpdefs.h"
|
2005-05-30 22:28:29 +02:00
|
|
|
#include "breakp2.h"
|
|
|
|
|
#include "runcoms.h"
|
|
|
|
|
#include "plotting/graf.h"
|
2010-10-15 20:15:29 +02:00
|
|
|
#include "../misc/misc_time.h"
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2000-09-05 21:48:22 +02:00
|
|
|
extern char *spice_analysis_get_name(int index);
|
|
|
|
|
extern char *spice_analysis_get_description(int index);
|
|
|
|
|
|
2000-10-03 07:22:07 +02:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
static int beginPlot(JOB *analysisPtr, CKTcircuit *circuitPtr, char *cktName, char *analName,
|
|
|
|
|
char *refName, int refType, int numNames, char **dataNames, int dataType,
|
|
|
|
|
bool windowed, runDesc **runp);
|
2000-04-27 22:03:57 +02:00
|
|
|
static int addDataDesc(runDesc *run, char *name, int type, int ind);
|
|
|
|
|
static int addSpecialDesc(runDesc *run, char *name, char *devname, char *param, int depind);
|
|
|
|
|
static void fileInit(runDesc *run);
|
|
|
|
|
static void fileInit_pass2(runDesc *run);
|
|
|
|
|
static void fileStartPoint(FILE *fp, bool bin, int num);
|
|
|
|
|
static void fileAddRealValue(FILE *fp, bool bin, double value);
|
|
|
|
|
static void fileAddComplexValue(FILE *fp, bool bin, IFcomplex value);
|
|
|
|
|
static void fileEndPoint(FILE *fp, bool bin);
|
|
|
|
|
static void fileEnd(runDesc *run);
|
|
|
|
|
static void plotInit(runDesc *run);
|
|
|
|
|
static void plotAddRealValue(dataDesc *desc, double value);
|
|
|
|
|
static void plotAddComplexValue(dataDesc *desc, IFcomplex value);
|
|
|
|
|
static void plotEnd(runDesc *run);
|
|
|
|
|
static bool parseSpecial(char *name, char *dev, char *param, char *ind);
|
|
|
|
|
static bool name_eq(char *n1, char *n2);
|
|
|
|
|
static bool getSpecial(dataDesc *desc, runDesc *run, IFvalue *val);
|
|
|
|
|
static void freeRun(runDesc *run);
|
2014-02-01 14:24:04 +01:00
|
|
|
static int InterpFileAdd(runDesc *plotPtr, IFvalue *refValue, IFvalue *valuePtr);
|
|
|
|
|
static int InterpPlotAdd(runDesc *plotPtr, IFvalue *refValue, IFvalue *valuePtr);
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2013-12-30 14:34:07 +01:00
|
|
|
/*Output data to spice module*/
|
2008-08-27 15:39:05 +02:00
|
|
|
#ifdef TCL_MODULE
|
2011-12-11 19:05:00 +01:00
|
|
|
#include "ngspice/tclspice.h"
|
2013-03-23 17:40:37 +01:00
|
|
|
#elif defined SHARED_MODULE
|
|
|
|
|
extern int sh_ExecutePerLoop(void);
|
|
|
|
|
extern void sh_vecinit(runDesc *run);
|
2008-08-27 15:39:05 +02:00
|
|
|
#endif
|
2013-12-30 14:34:07 +01:00
|
|
|
|
|
|
|
|
/*Suppressing progress info in -o option */
|
|
|
|
|
#ifndef HAS_WINGUI
|
|
|
|
|
extern bool orflag;
|
|
|
|
|
#endif
|
2008-08-27 15:39:05 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
#define DOUBLE_PRECISION 15
|
|
|
|
|
|
|
|
|
|
|
2000-09-13 00:00:57 +02:00
|
|
|
static clock_t lastclock, currclock;
|
2001-01-21 18:18:20 +01:00
|
|
|
static double *rowbuf;
|
2010-11-06 21:11:24 +01:00
|
|
|
static size_t column, rowbuflen;
|
2000-09-13 00:00:57 +02:00
|
|
|
|
2000-09-12 21:02:26 +02:00
|
|
|
static bool shouldstop = FALSE; /* Tell simulator to stop next time it asks. */
|
2000-10-03 07:22:07 +02:00
|
|
|
|
2014-02-01 14:24:04 +01:00
|
|
|
static bool interpolated = FALSE;
|
|
|
|
|
static double *valueold, *valuenew;
|
2000-09-03 11:00:08 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* The two "begin plot" routines share all their internals... */
|
|
|
|
|
|
|
|
|
|
int
|
2011-12-13 20:10:34 +01:00
|
|
|
OUTpBeginPlot(CKTcircuit *circuitPtr, JOB *analysisPtr,
|
|
|
|
|
IFuid analName,
|
|
|
|
|
IFuid refName, int refType,
|
2012-02-07 18:43:07 +01:00
|
|
|
int numNames, IFuid *dataNames, int dataType, runDesc **plotPtr)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2012-05-01 14:32:07 +02:00
|
|
|
char *name;
|
2003-12-25 18:30:36 +01:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
if (ft_curckt->ci_ckt == circuitPtr)
|
|
|
|
|
name = ft_curckt->ci_name;
|
|
|
|
|
else
|
|
|
|
|
name = "circuit name";
|
|
|
|
|
|
|
|
|
|
return (beginPlot(analysisPtr, circuitPtr, name,
|
|
|
|
|
analName, refName, refType, numNames,
|
|
|
|
|
dataNames, dataType, FALSE,
|
|
|
|
|
plotPtr));
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
int
|
2011-12-13 20:10:34 +01:00
|
|
|
OUTwBeginPlot(CKTcircuit *circuitPtr, JOB *analysisPtr,
|
|
|
|
|
IFuid analName,
|
|
|
|
|
IFuid refName, int refType,
|
2012-02-07 18:43:07 +01:00
|
|
|
int numNames, IFuid *dataNames, int dataType, runDesc **plotPtr)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
return (beginPlot(analysisPtr, circuitPtr, "circuit name",
|
2012-05-01 14:32:07 +02:00
|
|
|
analName, refName, refType, numNames,
|
|
|
|
|
dataNames, dataType, TRUE,
|
|
|
|
|
plotPtr));
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static int
|
2010-10-08 18:49:18 +02:00
|
|
|
beginPlot(JOB *analysisPtr, CKTcircuit *circuitPtr, char *cktName, char *analName, char *refName, int refType, int numNames, char **dataNames, int dataType, bool windowed, runDesc **runp)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
|
|
|
|
runDesc *run;
|
|
|
|
|
struct save_info *saves;
|
2001-02-09 20:46:36 +01:00
|
|
|
bool *savesused = NULL;
|
2000-04-27 22:03:57 +02:00
|
|
|
int numsaves;
|
2001-02-09 20:46:36 +01:00
|
|
|
int i, j, depind = 0;
|
2000-04-27 22:03:57 +02:00
|
|
|
char namebuf[BSIZE_SP], parambuf[BSIZE_SP], depbuf[BSIZE_SP];
|
2000-10-03 07:22:07 +02:00
|
|
|
char *ch, tmpname[BSIZE_SP];
|
|
|
|
|
bool saveall = TRUE;
|
|
|
|
|
bool savealli = FALSE;
|
2003-12-25 18:30:36 +01:00
|
|
|
char *an_name;
|
2003-07-23 21:36:39 +02:00
|
|
|
/*to resume a run saj
|
2012-09-20 20:30:53 +02:00
|
|
|
*All it does is reassign the file pointer and return (requires *runp to be NULL if this is not needed)
|
|
|
|
|
*/
|
|
|
|
|
if (dataType == 666 && numNames == 666) {
|
2012-05-01 14:32:07 +02:00
|
|
|
run = *runp;
|
|
|
|
|
run->writeOut = ft_getOutReq(&run->fp, &run->runPlot, &run->binary,
|
|
|
|
|
run->type, run->name);
|
|
|
|
|
|
2003-07-23 21:36:39 +02:00
|
|
|
} else {
|
2012-05-01 14:32:07 +02:00
|
|
|
/*end saj*/
|
|
|
|
|
|
|
|
|
|
/* Check to see if we want to print informational data. */
|
|
|
|
|
if (cp_getvar("printinfo", CP_BOOL, NULL))
|
|
|
|
|
fprintf(cp_err, "(debug printing enabled)\n");
|
|
|
|
|
|
2014-02-01 14:24:04 +01:00
|
|
|
/* Check to see if we want to save only interpolated data. */
|
|
|
|
|
if (cp_getvar("interp", CP_BOOL, NULL)) {
|
|
|
|
|
interpolated = TRUE;
|
|
|
|
|
fprintf(cp_out, "Warning: Interpolated raw file data!\n\n");
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
*runp = run = alloc(struct runDesc);
|
|
|
|
|
|
|
|
|
|
/* First fill in some general information. */
|
|
|
|
|
run->analysis = analysisPtr;
|
|
|
|
|
run->circuit = circuitPtr;
|
|
|
|
|
run->name = copy(cktName);
|
|
|
|
|
run->type = copy(analName);
|
|
|
|
|
run->windowed = windowed;
|
|
|
|
|
run->numData = 0;
|
|
|
|
|
|
|
|
|
|
an_name = spice_analysis_get_name(analysisPtr->JOBtype);
|
|
|
|
|
ft_curckt->ci_last_an = an_name;
|
|
|
|
|
|
|
|
|
|
/* Now let's see which of these things we need. First toss in the
|
|
|
|
|
* reference vector. Then toss in anything that getSaves() tells
|
|
|
|
|
* us to save that we can find in the name list. Finally unpack
|
|
|
|
|
* the remaining saves into parameters.
|
|
|
|
|
*/
|
|
|
|
|
numsaves = ft_getSaves(&saves);
|
|
|
|
|
if (numsaves) {
|
|
|
|
|
savesused = TMALLOC(bool, numsaves);
|
|
|
|
|
saveall = FALSE;
|
|
|
|
|
for (i = 0; i < numsaves; i++) {
|
|
|
|
|
if (saves[i].analysis && !cieq(saves[i].analysis, an_name)) {
|
|
|
|
|
/* ignore this one this time around */
|
|
|
|
|
savesused[i] = TRUE;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2001-02-07 16:24:51 +01:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
/* Check for ".save all" and new synonym ".save allv" */
|
2001-02-07 16:24:51 +01:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
if (cieq(saves[i].name, "all") || cieq(saves[i].name, "allv")) {
|
|
|
|
|
saveall = TRUE;
|
|
|
|
|
savesused[i] = TRUE;
|
|
|
|
|
saves[i].used = 1;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
/* And now for the new ".save alli" option */
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
if (cieq(saves[i].name, "alli")) {
|
|
|
|
|
savealli = TRUE;
|
|
|
|
|
savesused[i] = TRUE;
|
|
|
|
|
saves[i].used = 1;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
/* Pass 0. */
|
|
|
|
|
if (refName) {
|
|
|
|
|
addDataDesc(run, refName, refType, -1);
|
|
|
|
|
for (i = 0; i < numsaves; i++)
|
|
|
|
|
if (!savesused[i] && name_eq(saves[i].name, refName)) {
|
|
|
|
|
savesused[i] = TRUE;
|
|
|
|
|
saves[i].used = 1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
run->refIndex = -1;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-05-01 14:32:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Pass 1. */
|
|
|
|
|
if (numsaves && !saveall) {
|
2012-09-20 20:30:53 +02:00
|
|
|
for (i = 0; i < numsaves; i++)
|
|
|
|
|
if (!savesused[i])
|
|
|
|
|
for (j = 0; j < numNames; j++)
|
2012-05-01 14:32:07 +02:00
|
|
|
if (name_eq(saves[i].name, dataNames[j])) {
|
|
|
|
|
addDataDesc(run, dataNames[j], dataType, j);
|
|
|
|
|
savesused[i] = TRUE;
|
|
|
|
|
saves[i].used = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (i = 0; i < numNames; i++)
|
2012-09-20 20:30:53 +02:00
|
|
|
if (!refName || !name_eq(dataNames[i], refName))
|
2012-05-01 14:32:07 +02:00
|
|
|
/* Save the node as long as it's an internal device node */
|
|
|
|
|
if (!strstr(dataNames[i], "#internal") &&
|
2012-09-20 20:30:53 +02:00
|
|
|
!strstr(dataNames[i], "#source") &&
|
|
|
|
|
!strstr(dataNames[i], "#drain") &&
|
|
|
|
|
!strstr(dataNames[i], "#collector") &&
|
|
|
|
|
!strstr(dataNames[i], "#emitter") &&
|
|
|
|
|
!strstr(dataNames[i], "#base"))
|
|
|
|
|
{
|
2012-05-01 14:32:07 +02:00
|
|
|
addDataDesc(run, dataNames[i], dataType, i);
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
/* Pass 1 and a bit.
|
|
|
|
|
This is a new pass which searches for all the internal device
|
|
|
|
|
nodes, and saves the terminal currents instead */
|
2001-02-07 16:24:51 +01:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
if (savealli) {
|
2012-05-18 21:38:42 +02:00
|
|
|
depind = 0;
|
2012-05-01 14:32:07 +02:00
|
|
|
for (i = 0; i < numNames; i++) {
|
2000-09-13 00:00:57 +02:00
|
|
|
if (strstr(dataNames[i], "#internal") ||
|
2012-09-20 20:30:53 +02:00
|
|
|
strstr(dataNames[i], "#source") ||
|
|
|
|
|
strstr(dataNames[i], "#drain") ||
|
|
|
|
|
strstr(dataNames[i], "#collector") ||
|
|
|
|
|
strstr(dataNames[i], "#emitter") ||
|
|
|
|
|
strstr(dataNames[i], "#base"))
|
|
|
|
|
{
|
2012-05-18 21:38:42 +02:00
|
|
|
tmpname[0] = '@';
|
|
|
|
|
tmpname[1] = '\0';
|
2012-05-01 14:32:07 +02:00
|
|
|
strncat(tmpname, dataNames[i], BSIZE_SP-1);
|
2012-05-18 21:38:42 +02:00
|
|
|
ch = strchr(tmpname, '#');
|
2012-05-01 14:32:07 +02:00
|
|
|
|
2012-05-18 21:13:31 +02:00
|
|
|
if (strstr(ch, "#collector")) {
|
2012-05-01 14:32:07 +02:00
|
|
|
strcpy(ch, "[ic]");
|
2012-05-18 21:13:31 +02:00
|
|
|
} else if (strstr(ch, "#base")) {
|
2012-05-01 14:32:07 +02:00
|
|
|
strcpy(ch, "[ib]");
|
2012-05-18 21:13:31 +02:00
|
|
|
} else if (strstr(ch, "#emitter")) {
|
2012-05-01 14:32:07 +02:00
|
|
|
strcpy(ch, "[ie]");
|
2012-05-18 21:13:31 +02:00
|
|
|
if (parseSpecial(tmpname, namebuf, parambuf, depbuf))
|
2012-05-01 14:32:07 +02:00
|
|
|
addSpecialDesc(run, tmpname, namebuf, parambuf, depind);
|
|
|
|
|
strcpy(ch, "[is]");
|
2012-05-18 21:13:31 +02:00
|
|
|
} else if (strstr(ch, "#drain")) {
|
2012-05-01 14:32:07 +02:00
|
|
|
strcpy(ch, "[id]");
|
2012-05-18 21:13:31 +02:00
|
|
|
if (parseSpecial(tmpname, namebuf, parambuf, depbuf))
|
2012-05-01 14:32:07 +02:00
|
|
|
addSpecialDesc(run, tmpname, namebuf, parambuf, depind);
|
|
|
|
|
strcpy(ch, "[ig]");
|
2012-05-18 21:13:31 +02:00
|
|
|
} else if (strstr(ch, "#source")) {
|
2012-05-01 14:32:07 +02:00
|
|
|
strcpy(ch, "[is]");
|
2012-05-18 21:13:31 +02:00
|
|
|
if (parseSpecial(tmpname, namebuf, parambuf, depbuf))
|
2012-05-01 14:32:07 +02:00
|
|
|
addSpecialDesc(run, tmpname, namebuf, parambuf, depind);
|
|
|
|
|
strcpy(ch, "[ib]");
|
2012-05-18 21:13:31 +02:00
|
|
|
} else if (strstr(ch, "#internal") && (tmpname[1] == 'd')) {
|
2012-05-01 14:32:07 +02:00
|
|
|
strcpy(ch, "[id]");
|
2000-09-13 00:00:57 +02:00
|
|
|
} else {
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(cp_err,
|
|
|
|
|
"Debug: could output current for %s\n", tmpname);
|
|
|
|
|
continue;
|
2012-05-18 21:07:46 +02:00
|
|
|
}
|
2012-05-01 14:32:07 +02:00
|
|
|
if (parseSpecial(tmpname, namebuf, parambuf, depbuf)) {
|
|
|
|
|
if (*depbuf) {
|
2012-09-20 20:30:53 +02:00
|
|
|
fprintf(stderr,
|
|
|
|
|
"Warning : unexpected dependent variable on %s\n", tmpname);
|
2012-05-01 14:32:07 +02:00
|
|
|
} else {
|
|
|
|
|
addSpecialDesc(run, tmpname, namebuf, parambuf, depind);
|
|
|
|
|
}
|
2000-09-13 00:00:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
2012-05-01 14:32:07 +02:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-05-01 14:32:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Pass 2. */
|
|
|
|
|
for (i = 0; i < numsaves; i++) {
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
if (savesused[i])
|
|
|
|
|
continue;
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
if (!parseSpecial(saves[i].name, namebuf, parambuf, depbuf)) {
|
|
|
|
|
if (saves[i].analysis)
|
|
|
|
|
fprintf(cp_err, "Warning: can't parse '%s': ignored\n",
|
|
|
|
|
saves[i].name);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
/* Now, if there's a dep variable, do we already have it? */
|
|
|
|
|
if (*depbuf) {
|
|
|
|
|
for (j = 0; j < run->numData; j++)
|
|
|
|
|
if (name_eq(depbuf, run->data[j].name))
|
2000-04-27 22:03:57 +02:00
|
|
|
break;
|
2012-05-01 14:32:07 +02:00
|
|
|
if (j == run->numData) {
|
|
|
|
|
/* Better add it. */
|
|
|
|
|
for (j = 0; j < numNames; j++)
|
|
|
|
|
if (name_eq(depbuf, dataNames[j]))
|
|
|
|
|
break;
|
|
|
|
|
if (j == numNames) {
|
|
|
|
|
fprintf(cp_err,
|
|
|
|
|
"Warning: can't find '%s': value '%s' ignored\n",
|
|
|
|
|
depbuf, saves[i].name);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
addDataDesc(run, dataNames[j], dataType, j);
|
|
|
|
|
savesused[i] = TRUE;
|
|
|
|
|
saves[i].used = 1;
|
|
|
|
|
depind = j;
|
2012-05-18 21:13:31 +02:00
|
|
|
} else {
|
2012-05-01 14:32:07 +02:00
|
|
|
depind = run->data[j].outIndex;
|
2012-05-18 21:38:42 +02:00
|
|
|
}
|
2012-05-18 21:13:31 +02:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
addSpecialDesc(run, saves[i].name, namebuf, parambuf, depind);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
if (numsaves) {
|
|
|
|
|
for (i = 0; i < numsaves; i++) {
|
|
|
|
|
tfree(saves[i].analysis);
|
|
|
|
|
tfree(saves[i].name);
|
|
|
|
|
}
|
2013-08-21 21:50:37 +02:00
|
|
|
tfree(saves);
|
2012-05-01 14:32:07 +02:00
|
|
|
tfree(savesused);
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
if (numNames &&
|
2012-09-20 20:30:53 +02:00
|
|
|
((run->numData == 1 && run->refIndex != -1) ||
|
|
|
|
|
(run->numData == 0 && run->refIndex == -1)))
|
|
|
|
|
{
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(cp_err, "Error: no data saved for %s; analysis not run\n",
|
|
|
|
|
spice_analysis_get_description(analysisPtr->JOBtype));
|
|
|
|
|
return E_NOTFOUND;
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
/* Now that we have our own data structures built up, let's see what
|
|
|
|
|
* nutmeg wants us to do.
|
|
|
|
|
*/
|
|
|
|
|
run->writeOut = ft_getOutReq(&run->fp, &run->runPlot, &run->binary,
|
|
|
|
|
run->type, run->name);
|
|
|
|
|
|
2012-05-18 21:13:31 +02:00
|
|
|
if (run->writeOut) {
|
2012-05-01 14:32:07 +02:00
|
|
|
fileInit(run);
|
2012-05-18 21:13:31 +02:00
|
|
|
} else {
|
2012-05-01 14:32:07 +02:00
|
|
|
plotInit(run);
|
|
|
|
|
if (refName)
|
|
|
|
|
run->runPlot->pl_ndims = 1;
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2014-02-01 14:24:04 +01:00
|
|
|
/* define storage for old and new data, to allow interpolation */
|
|
|
|
|
if (interpolated && run->circuit->CKTcurJob->JOBtype == 4) {
|
|
|
|
|
valueold = TMALLOC(double, run->numData);
|
|
|
|
|
for (i = 0; i < run->numData; i++)
|
|
|
|
|
valueold[i] = 0.0;
|
|
|
|
|
valuenew = TMALLOC(double, run->numData);
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-27 15:39:05 +02:00
|
|
|
/*Start BLT, initilises the blt vectors saj*/
|
2012-05-01 14:32:07 +02:00
|
|
|
#ifdef TCL_MODULE
|
2008-08-27 15:39:05 +02:00
|
|
|
blt_init(run);
|
2013-03-23 17:40:37 +01:00
|
|
|
#elif defined SHARED_MODULE
|
|
|
|
|
sh_vecinit(run);
|
2008-08-27 15:39:05 +02:00
|
|
|
#endif
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
return (OK);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static int
|
|
|
|
|
addDataDesc(runDesc *run, char *name, int type, int ind)
|
|
|
|
|
{
|
|
|
|
|
dataDesc *data;
|
|
|
|
|
|
|
|
|
|
if (!run->numData)
|
2010-10-28 21:32:34 +02:00
|
|
|
run->data = TMALLOC(dataDesc, 1);
|
2000-04-27 22:03:57 +02:00
|
|
|
else
|
2010-10-28 21:32:34 +02:00
|
|
|
run->data = TREALLOC(dataDesc, run->data, run->numData + 1);
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
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);
|
|
|
|
|
data->type = type;
|
|
|
|
|
data->gtype = GRID_LIN;
|
|
|
|
|
data->regular = TRUE;
|
|
|
|
|
data->outIndex = ind;
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
/* It's the reference vector. */
|
2012-05-18 21:13:31 +02:00
|
|
|
if (ind == -1)
|
2000-04-27 22:03:57 +02:00
|
|
|
run->refIndex = run->numData;
|
|
|
|
|
|
|
|
|
|
run->numData++;
|
|
|
|
|
|
|
|
|
|
return (OK);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static int
|
|
|
|
|
addSpecialDesc(runDesc *run, char *name, char *devname, char *param, int depind)
|
|
|
|
|
{
|
|
|
|
|
dataDesc *data;
|
|
|
|
|
char *unique; /* unique char * from back-end */
|
|
|
|
|
|
|
|
|
|
if (!run->numData)
|
2010-10-28 21:32:34 +02:00
|
|
|
run->data = TMALLOC(dataDesc, 1);
|
2000-04-27 22:03:57 +02:00
|
|
|
else
|
2010-10-28 21:32:34 +02:00
|
|
|
run->data = TREALLOC(dataDesc, run->data, run->numData + 1);
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
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);
|
2012-05-01 14:32:07 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* MW. My "special" routine here */
|
2010-07-08 19:50:29 +02:00
|
|
|
INPinsertNofree(&unique, ft_curckt->ci_symtab);
|
2000-04-27 22:03:57 +02:00
|
|
|
data->specName = unique;
|
|
|
|
|
|
|
|
|
|
data->specParamName = copy(param);
|
|
|
|
|
|
|
|
|
|
data->specIndex = depind;
|
|
|
|
|
data->specType = -1;
|
|
|
|
|
data->specFast = NULL;
|
|
|
|
|
data->regular = FALSE;
|
|
|
|
|
|
|
|
|
|
run->numData++;
|
|
|
|
|
|
|
|
|
|
return (OK);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-21 17:11:06 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
int
|
2012-02-07 18:43:07 +01:00
|
|
|
OUTpData(runDesc *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2012-02-07 18:43:07 +01:00
|
|
|
runDesc *run = plotPtr; // FIXME
|
2000-04-27 22:03:57 +02:00
|
|
|
int i;
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
run->pointCount++;
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2008-08-27 15:39:05 +02:00
|
|
|
#ifdef TCL_MODULE
|
|
|
|
|
steps_completed = run->pointCount;
|
|
|
|
|
#endif
|
2014-02-01 14:24:04 +01:00
|
|
|
/* interpolated batch mode output to file in transient analysis */
|
|
|
|
|
if (interpolated && run->circuit->CKTcurJob->JOBtype == 4 && run->writeOut) {
|
|
|
|
|
InterpFileAdd(run, refValue, valuePtr);
|
|
|
|
|
return (OK);
|
|
|
|
|
}
|
|
|
|
|
/* interpolated interactive or control mode output to plot in transient analysis */
|
|
|
|
|
else if (interpolated && run->circuit->CKTcurJob->JOBtype == 4 && !(run->writeOut)) {
|
|
|
|
|
InterpPlotAdd(run, refValue, valuePtr);
|
|
|
|
|
return (OK);
|
|
|
|
|
}
|
|
|
|
|
/* standard batch mode output to file */
|
|
|
|
|
else if (run->writeOut) {
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
if (run->pointCount == 1)
|
|
|
|
|
fileInit_pass2(run);
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
fileStartPoint(run->fp, run->binary, run->pointCount);
|
|
|
|
|
|
|
|
|
|
if (run->refIndex != -1) {
|
2012-05-01 14:32:07 +02:00
|
|
|
if (run->isComplex) {
|
|
|
|
|
fileAddComplexValue(run->fp, run->binary, refValue->cValue);
|
2001-02-07 16:24:51 +01:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
/* While we're looking at the reference value, print it to the screen
|
2012-09-20 20:30:53 +02:00
|
|
|
every quarter of a second, to give some feedback without using
|
|
|
|
|
too much CPU time */
|
2013-03-23 09:54:44 +01:00
|
|
|
#ifndef HAS_WINGUI
|
2013-12-30 14:34:07 +01:00
|
|
|
if (!orflag) {
|
|
|
|
|
currclock = clock();
|
|
|
|
|
if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) {
|
|
|
|
|
fprintf(stderr, " Reference value : % 12.5e\r",
|
|
|
|
|
refValue->cValue.real);
|
|
|
|
|
lastclock = currclock;
|
|
|
|
|
}
|
2012-05-01 14:32:07 +02:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
} else {
|
2001-02-07 16:24:51 +01:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
/* And the same for a non-complex value */
|
2001-02-07 16:24:51 +01:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
fileAddRealValue(run->fp, run->binary, refValue->rValue);
|
2013-03-23 09:54:44 +01:00
|
|
|
#ifndef HAS_WINGUI
|
2013-12-30 14:34:07 +01:00
|
|
|
if (!orflag) {
|
|
|
|
|
currclock = clock();
|
|
|
|
|
if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) {
|
|
|
|
|
fprintf(stderr, " Reference value : % 12.5e\r",
|
|
|
|
|
refValue->rValue);
|
|
|
|
|
lastclock = currclock;
|
|
|
|
|
}
|
2012-05-01 14:32:07 +02:00
|
|
|
}
|
|
|
|
|
#endif
|
2000-10-03 07:22:07 +02:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
for (i = 0; i < run->numData; i++) {
|
|
|
|
|
/* we've already printed reference vec first */
|
2012-05-18 21:13:31 +02:00
|
|
|
if (run->data[i].outIndex == -1)
|
|
|
|
|
continue;
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2008-08-27 15:39:05 +02:00
|
|
|
#ifdef TCL_MODULE
|
2012-05-01 14:32:07 +02:00
|
|
|
blt_add(i, refValue ? refValue->rValue : NAN);
|
2008-08-27 15:39:05 +02:00
|
|
|
#endif
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
if (run->data[i].regular) {
|
2012-09-20 20:30:53 +02:00
|
|
|
if (run->data[i].type == IF_REAL)
|
2012-05-01 14:32:07 +02:00
|
|
|
fileAddRealValue(run->fp, run->binary,
|
2012-05-18 21:13:31 +02:00
|
|
|
valuePtr->v.vec.rVec [run->data[i].outIndex]);
|
2000-04-27 22:03:57 +02:00
|
|
|
else if (run->data[i].type == IF_COMPLEX)
|
2012-05-01 14:32:07 +02:00
|
|
|
fileAddComplexValue(run->fp, run->binary,
|
2012-05-18 21:13:31 +02:00
|
|
|
valuePtr->v.vec.cVec [run->data[i].outIndex]);
|
2000-04-27 22:03:57 +02:00
|
|
|
else
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(stderr, "OUTpData: unsupported data type\n");
|
2000-04-27 22:03:57 +02:00
|
|
|
} else {
|
2012-05-18 21:13:31 +02:00
|
|
|
IFvalue val;
|
2000-04-27 22:03:57 +02:00
|
|
|
/* should pre-check instance */
|
2012-05-01 14:32:07 +02:00
|
|
|
if (!getSpecial(&run->data[i], run, &val)) {
|
2001-02-07 16:24:51 +01:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
/* If this is the first data point, print a warning for any unrecognized
|
|
|
|
|
variables, since this has not already been checked */
|
2001-02-07 16:24:51 +01:00
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
if (run->pointCount == 1)
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(stderr, "Warning: unrecognized variable - %s\n",
|
|
|
|
|
run->data[i].name);
|
2001-02-07 16:24:51 +01:00
|
|
|
|
2000-09-13 00:00:57 +02:00
|
|
|
if (run->isComplex) {
|
2012-05-18 21:38:42 +02:00
|
|
|
val.cValue.real = 0;
|
|
|
|
|
val.cValue.imag = 0;
|
2012-05-18 21:13:31 +02:00
|
|
|
fileAddComplexValue(run->fp, run->binary, val.cValue);
|
2000-09-13 00:00:57 +02:00
|
|
|
} else {
|
2012-05-18 21:38:42 +02:00
|
|
|
val.rValue = 0;
|
2012-05-18 21:13:31 +02:00
|
|
|
fileAddRealValue(run->fp, run->binary, val.rValue);
|
2012-05-18 21:07:46 +02:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
continue;
|
2012-05-18 21:07:46 +02:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
if (run->data[i].type == IF_REAL)
|
2012-05-18 21:13:31 +02:00
|
|
|
fileAddRealValue(run->fp, run->binary, val.rValue);
|
2000-04-27 22:03:57 +02:00
|
|
|
else if (run->data[i].type == IF_COMPLEX)
|
2012-05-18 21:13:31 +02:00
|
|
|
fileAddComplexValue(run->fp, run->binary, val.cValue);
|
2000-04-27 22:03:57 +02:00
|
|
|
else
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(stderr, "OUTpData: unsupported data type\n");
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2008-08-27 15:39:05 +02:00
|
|
|
#ifdef TCL_MODULE
|
2012-05-18 21:13:31 +02:00
|
|
|
blt_add(i, valuePtr->v.vec.rVec [run->data[i].outIndex]);
|
2008-08-27 15:39:05 +02:00
|
|
|
#endif
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
fileEndPoint(run->fp, run->binary);
|
2001-02-07 16:24:51 +01:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
/* Check that the write to disk completed successfully, otherwise abort */
|
2001-02-07 16:24:51 +01:00
|
|
|
|
2000-09-13 00:00:57 +02:00
|
|
|
if (ferror(run->fp)) {
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(stderr, "Warning: rawfile write error !!\n");
|
|
|
|
|
shouldstop = TRUE;
|
2012-05-18 21:07:46 +02:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
} else {
|
2001-02-07 16:24:51 +01:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
/* This is interactive mode. Update the screen with the reference
|
|
|
|
|
variable just the same */
|
2001-02-07 16:24:51 +01:00
|
|
|
|
2013-03-23 09:54:44 +01:00
|
|
|
#ifndef HAS_WINGUI
|
2013-12-30 14:34:07 +01:00
|
|
|
if (!orflag) {
|
|
|
|
|
currclock = clock();
|
|
|
|
|
if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) {
|
|
|
|
|
if (run->isComplex) {
|
|
|
|
|
fprintf(stderr, " Reference value : % 12.5e\r",
|
|
|
|
|
refValue ? refValue->cValue.real : NAN);
|
|
|
|
|
} else {
|
|
|
|
|
fprintf(stderr, " Reference value : % 12.5e\r",
|
|
|
|
|
refValue ? refValue->rValue : NAN);
|
|
|
|
|
}
|
|
|
|
|
lastclock = currclock;
|
2012-05-01 14:32:07 +02:00
|
|
|
}
|
2001-02-07 16:24:51 +01:00
|
|
|
}
|
2002-01-03 23:44:21 +01:00
|
|
|
#endif
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
for (i = 0; i < run->numData; i++) {
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2008-08-27 15:39:05 +02:00
|
|
|
#ifdef TCL_MODULE
|
2012-05-01 14:32:07 +02:00
|
|
|
/*Locks the blt vector to stop access*/
|
|
|
|
|
blt_lockvec(i);
|
2008-08-27 15:39:05 +02:00
|
|
|
#endif
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
if (run->data[i].outIndex == -1) {
|
2009-05-21 17:11:06 +02:00
|
|
|
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);
|
2000-04-27 22:03:57 +02:00
|
|
|
} else if (run->data[i].regular) {
|
2009-05-21 17:11:06 +02:00
|
|
|
if (run->data[i].type == IF_REAL)
|
2012-05-01 14:32:07 +02:00
|
|
|
plotAddRealValue(&run->data[i],
|
|
|
|
|
valuePtr->v.vec.rVec[run->data[i].outIndex]);
|
2009-05-21 17:11:06 +02:00
|
|
|
else if (run->data[i].type == IF_COMPLEX)
|
|
|
|
|
plotAddComplexValue(&run->data[i],
|
2012-05-01 14:32:07 +02:00
|
|
|
valuePtr->v.vec.cVec[run->data[i].outIndex]);
|
2000-04-27 22:03:57 +02:00
|
|
|
} else {
|
2012-05-18 21:13:31 +02:00
|
|
|
IFvalue val;
|
2012-05-01 14:32:07 +02:00
|
|
|
/* should pre-check instance */
|
2009-05-21 17:11:06 +02:00
|
|
|
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);
|
2012-05-01 14:32:07 +02:00
|
|
|
else
|
2009-05-21 17:11:06 +02:00
|
|
|
fprintf(stderr, "OUTpData: unsupported data type\n");
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2008-08-27 15:39:05 +02:00
|
|
|
#ifdef TCL_MODULE
|
2009-05-21 17:11:06 +02:00
|
|
|
/*relinks and unlocks vector*/
|
2012-05-18 21:38:42 +02:00
|
|
|
blt_relink(i, (run->data[i]).vec);
|
2008-08-27 15:39:05 +02:00
|
|
|
#endif
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
gr_iplot(run->runPlot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ft_bpcheck(run->runPlot, run->pointCount) == FALSE)
|
|
|
|
|
shouldstop = TRUE;
|
|
|
|
|
|
2008-08-27 15:39:05 +02:00
|
|
|
#ifdef TCL_MODULE
|
|
|
|
|
Tcl_ExecutePerLoop();
|
2013-03-23 17:40:37 +01:00
|
|
|
#elif defined SHARED_MODULE
|
|
|
|
|
sh_ExecutePerLoop();
|
2008-08-27 15:39:05 +02:00
|
|
|
#endif
|
|
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
return (OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ARGSUSED */ /* until some code gets written */
|
|
|
|
|
int
|
|
|
|
|
OUTwReference(void *plotPtr, IFvalue *valuePtr, void **refPtr)
|
|
|
|
|
{
|
2010-11-16 21:38:24 +01:00
|
|
|
NG_IGNORE(refPtr);
|
|
|
|
|
NG_IGNORE(valuePtr);
|
|
|
|
|
NG_IGNORE(plotPtr);
|
2010-11-16 20:11:32 +01:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
return (OK);
|
|
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
|
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* ARGSUSED */ /* until some code gets written */
|
|
|
|
|
int
|
2012-02-07 18:43:07 +01:00
|
|
|
OUTwData(runDesc *plotPtr, int dataIndex, IFvalue *valuePtr, void *refPtr)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2010-11-16 21:38:24 +01:00
|
|
|
NG_IGNORE(refPtr);
|
|
|
|
|
NG_IGNORE(valuePtr);
|
|
|
|
|
NG_IGNORE(dataIndex);
|
|
|
|
|
NG_IGNORE(plotPtr);
|
2010-11-16 20:11:32 +01:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
return (OK);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* ARGSUSED */ /* until some code gets written */
|
|
|
|
|
int
|
2012-02-07 18:43:07 +01:00
|
|
|
OUTwEnd(runDesc *plotPtr)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2010-11-16 21:38:24 +01:00
|
|
|
NG_IGNORE(plotPtr);
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
return (OK);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-21 17:11:06 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
int
|
2012-02-07 18:43:07 +01:00
|
|
|
OUTendPlot(runDesc *plotPtr)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2012-02-07 18:43:07 +01:00
|
|
|
runDesc *run = plotPtr; // FIXME
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2014-02-01 14:24:04 +01:00
|
|
|
if (interpolated && run->circuit->CKTcurJob->JOBtype == 4 && run->writeOut) {
|
|
|
|
|
tfree(valueold);
|
|
|
|
|
tfree(valuenew);
|
|
|
|
|
fileEnd(run);
|
|
|
|
|
}
|
|
|
|
|
else if (run->writeOut) {
|
2000-04-27 22:03:57 +02:00
|
|
|
fileEnd(run);
|
2012-05-18 21:13:31 +02:00
|
|
|
} else {
|
2000-04-27 22:03:57 +02:00
|
|
|
gr_end_iplot();
|
|
|
|
|
plotEnd(run);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
freeRun(run);
|
|
|
|
|
|
|
|
|
|
return (OK);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-21 17:11:06 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* ARGSUSED */ /* until some code gets written */
|
|
|
|
|
int
|
2012-02-07 18:43:07 +01:00
|
|
|
OUTbeginDomain(runDesc *plotPtr, IFuid refName, int refType, IFvalue *outerRefValue)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2010-11-16 21:38:24 +01:00
|
|
|
NG_IGNORE(outerRefValue);
|
|
|
|
|
NG_IGNORE(refType);
|
|
|
|
|
NG_IGNORE(refName);
|
|
|
|
|
NG_IGNORE(plotPtr);
|
2010-11-16 20:11:32 +01:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
return (OK);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* ARGSUSED */ /* until some code gets written */
|
|
|
|
|
int
|
2012-02-07 18:43:07 +01:00
|
|
|
OUTendDomain(runDesc *plotPtr)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2010-11-16 21:38:24 +01:00
|
|
|
NG_IGNORE(plotPtr);
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
return (OK);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-21 17:11:06 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* ARGSUSED */ /* until some code gets written */
|
|
|
|
|
int
|
2012-02-07 18:43:07 +01:00
|
|
|
OUTattributes(runDesc *plotPtr, IFuid varName, int param, IFvalue *value)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2012-02-07 18:43:07 +01:00
|
|
|
runDesc *run = plotPtr; // FIXME
|
2010-07-04 19:54:22 +02:00
|
|
|
GRIDTYPE type;
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-12-28 18:10:06 +01:00
|
|
|
struct dvec *d;
|
|
|
|
|
|
2010-11-16 21:38:24 +01:00
|
|
|
NG_IGNORE(value);
|
2010-11-16 20:11:32 +01:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
if (param == OUT_SCALE_LIN)
|
2012-05-01 14:32:07 +02:00
|
|
|
type = GRID_LIN;
|
2000-04-27 22:03:57 +02:00
|
|
|
else if (param == OUT_SCALE_LOG)
|
2012-05-01 14:32:07 +02:00
|
|
|
type = GRID_XLOG;
|
2000-04-27 22:03:57 +02:00
|
|
|
else
|
2012-05-01 14:32:07 +02:00
|
|
|
return E_UNSUPP;
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
if (run->writeOut) {
|
2012-05-01 14:32:07 +02:00
|
|
|
if (varName) {
|
2012-05-18 21:13:31 +02:00
|
|
|
int i;
|
2012-05-01 14:32:07 +02:00
|
|
|
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;
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
} else {
|
2012-05-01 14:32:07 +02:00
|
|
|
if (varName) {
|
|
|
|
|
for (d = run->runPlot->pl_dvecs; d; d = d->v_next)
|
|
|
|
|
if (!strcmp(varName, d->v_name))
|
|
|
|
|
d->v_gridtype = type;
|
2012-12-28 18:10:06 +01:00
|
|
|
} else if (param == PLOT_COMB) {
|
|
|
|
|
for (d = run->runPlot->pl_dvecs; d; d = d->v_next)
|
2013-10-01 21:50:02 +02:00
|
|
|
d->v_plottype = PLOT_COMB;
|
2012-05-01 14:32:07 +02:00
|
|
|
} else {
|
|
|
|
|
run->runPlot->pl_scale->v_gridtype = type;
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (OK);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-21 17:11:06 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* The file writing routines. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
fileInit(runDesc *run)
|
|
|
|
|
{
|
|
|
|
|
char buf[513];
|
2001-01-21 18:18:20 +01:00
|
|
|
int i;
|
2010-11-06 21:11:24 +01:00
|
|
|
size_t n;
|
2012-05-01 14:32:07 +02:00
|
|
|
|
2000-10-03 07:22:07 +02:00
|
|
|
lastclock = clock();
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
/* This is a hack. */
|
|
|
|
|
run->isComplex = FALSE;
|
|
|
|
|
for (i = 0; i < run->numData; i++)
|
|
|
|
|
if (run->data[i].type == IF_COMPLEX)
|
|
|
|
|
run->isComplex = TRUE;
|
|
|
|
|
|
2010-11-06 21:11:24 +01:00
|
|
|
n = 0;
|
2000-04-27 22:03:57 +02:00
|
|
|
sprintf(buf, "Title: %s\n", run->name);
|
2010-11-06 21:11:24 +01:00
|
|
|
n += strlen(buf);
|
2000-04-27 22:03:57 +02:00
|
|
|
fputs(buf, run->fp);
|
2001-01-21 18:18:20 +01:00
|
|
|
sprintf(buf, "Date: %s\n", datestring());
|
2010-11-06 21:11:24 +01:00
|
|
|
n += strlen(buf);
|
2000-09-12 21:02:26 +02:00
|
|
|
fputs(buf, run->fp);
|
2001-01-21 18:18:20 +01:00
|
|
|
sprintf(buf, "Plotname: %s\n", run->type);
|
2010-11-06 21:11:24 +01:00
|
|
|
n += strlen(buf);
|
2000-09-12 21:02:26 +02:00
|
|
|
fputs(buf, run->fp);
|
2001-01-21 18:18:20 +01:00
|
|
|
sprintf(buf, "Flags: %s\n", run->isComplex ? "complex" : "real");
|
2010-11-06 21:11:24 +01:00
|
|
|
n += strlen(buf);
|
2000-04-27 22:03:57 +02:00
|
|
|
fputs(buf, run->fp);
|
2001-01-21 18:18:20 +01:00
|
|
|
sprintf(buf, "No. Variables: %d\n", run->numData);
|
2010-11-06 21:11:24 +01:00
|
|
|
n += strlen(buf);
|
2001-01-21 18:18:20 +01:00
|
|
|
fputs(buf, run->fp);
|
|
|
|
|
sprintf(buf, "No. Points: ");
|
2010-11-06 21:11:24 +01:00
|
|
|
n += strlen(buf);
|
2012-05-01 14:32:07 +02:00
|
|
|
fputs(buf, run->fp);
|
2000-09-03 11:00:08 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
fflush(run->fp); /* Gotta do this for LATTICE. */
|
|
|
|
|
if (run->fp == stdout || (run->pointPos = ftell(run->fp)) <= 0)
|
2010-11-06 21:11:24 +01:00
|
|
|
run->pointPos = (long) n;
|
2001-01-21 18:18:20 +01:00
|
|
|
fprintf(run->fp, "0 \n"); /* Save 8 spaces here. */
|
2012-05-01 14:32:07 +02:00
|
|
|
|
2007-10-08 22:18:38 +02:00
|
|
|
/*fprintf(run->fp, "Command: version %s\n", ft_sim->version);*/
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(run->fp, "Variables:\n");
|
2000-09-13 00:00:57 +02:00
|
|
|
|
2007-10-08 22:18:38 +02:00
|
|
|
printf("No. of Data Columns : %d \n", run->numData);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static void
|
|
|
|
|
fileInit_pass2(runDesc *run)
|
|
|
|
|
{
|
2001-01-21 18:18:20 +01:00
|
|
|
int i, type;
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
for (i = 0; i < run->numData; i++) {
|
2008-01-02 19:24:56 +01:00
|
|
|
|
2012-05-18 21:13:31 +02:00
|
|
|
char *name = run->data[i].name;
|
2008-01-02 19:24:56 +01:00
|
|
|
|
2001-01-21 18:18:20 +01:00
|
|
|
if (substring("#branch", name))
|
2000-04-27 22:03:57 +02:00
|
|
|
type = SV_CURRENT;
|
|
|
|
|
else if (cieq(name, "time"))
|
|
|
|
|
type = SV_TIME;
|
|
|
|
|
else if (cieq(name, "frequency"))
|
|
|
|
|
type = SV_FREQUENCY;
|
2009-05-21 17:11:06 +02:00
|
|
|
else if (cieq(name, "temp-sweep"))
|
2005-05-09 22:20:18 +02:00
|
|
|
type = SV_TEMP;
|
2009-05-21 17:11:06 +02:00
|
|
|
else if (cieq(name, "res-sweep"))
|
2005-05-09 22:20:18 +02:00
|
|
|
type = SV_RES;
|
2009-05-21 17:11:06 +02:00
|
|
|
else if ((*name == '@') && (substring("[g", name)))
|
2012-05-01 14:32:07 +02:00
|
|
|
type = SV_ADMITTANCE;
|
2012-10-03 15:01:36 +02:00
|
|
|
else if ((*name == '@') && (substring("[c", name)))
|
|
|
|
|
type = SV_CAPACITANCE;
|
|
|
|
|
else if ((*name == '@') && (substring("[i", name)))
|
|
|
|
|
type = SV_CURRENT;
|
|
|
|
|
else if ((*name == '@') && (substring("[q", name)))
|
|
|
|
|
type = SV_CHARGE;
|
2001-01-21 18:18:20 +01:00
|
|
|
else
|
2000-04-27 22:03:57 +02:00
|
|
|
type = SV_VOLTAGE;
|
2012-05-01 14:32:07 +02:00
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
if (type == SV_CURRENT) {
|
2012-05-18 21:13:31 +02:00
|
|
|
char *branch = strstr(name, "#branch");
|
|
|
|
|
if (branch)
|
2012-05-01 14:32:07 +02:00
|
|
|
*branch = '\0';
|
|
|
|
|
fprintf(run->fp, "\t%d\ti(%s)\t%s", i, name, ft_typenames(type));
|
2012-05-18 21:13:31 +02:00
|
|
|
if (branch)
|
|
|
|
|
*branch = '#';
|
2012-09-20 20:30:53 +02:00
|
|
|
} else if (type == SV_VOLTAGE) {
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(run->fp, "\t%d\tv(%s)\t%s", i, name, ft_typenames(type));
|
2008-01-02 19:24:56 +01:00
|
|
|
} else {
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(run->fp, "\t%d\t%s\t%s", i, name, ft_typenames(type));
|
2008-01-02 19:24:56 +01:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2001-01-21 18:18:20 +01:00
|
|
|
if (run->data[i].gtype == GRID_XLOG)
|
|
|
|
|
fprintf(run->fp, "\tgrid=3");
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2001-01-21 18:18:20 +01:00
|
|
|
fprintf(run->fp, "\n");
|
2000-09-12 21:02:26 +02:00
|
|
|
}
|
2000-09-03 11:00:08 +02:00
|
|
|
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(run->fp, "%s:\n", run->binary ? "Binary" : "Values");
|
2012-05-18 21:13:31 +02:00
|
|
|
fflush(run->fp);
|
2000-09-13 00:00:57 +02:00
|
|
|
|
2000-10-03 07:22:07 +02:00
|
|
|
/* Allocate Row buffer */
|
2000-09-13 00:00:57 +02:00
|
|
|
|
2001-01-21 18:18:20 +01:00
|
|
|
if (run->binary) {
|
2012-02-09 21:46:12 +01:00
|
|
|
rowbuflen = (size_t) (run->numData);
|
2010-11-06 21:14:21 +01:00
|
|
|
if (run->isComplex)
|
|
|
|
|
rowbuflen *= 2;
|
2012-02-09 21:46:12 +01:00
|
|
|
rowbuf = TMALLOC(double, rowbuflen);
|
2012-05-18 21:13:31 +02:00
|
|
|
} else {
|
|
|
|
|
// fIXME rowbuflen = 0;
|
|
|
|
|
rowbuf = NULL;
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static void
|
|
|
|
|
fileStartPoint(FILE *fp, bool bin, int num)
|
|
|
|
|
{
|
|
|
|
|
if (!bin)
|
|
|
|
|
fprintf(fp, "%d\t", num - 1);
|
2012-05-01 14:32:07 +02:00
|
|
|
|
2001-01-21 18:18:20 +01:00
|
|
|
/* reset buffer pointer to zero */
|
2012-05-01 14:32:07 +02:00
|
|
|
|
2001-01-21 18:18:20 +01:00
|
|
|
column = 0;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static void
|
2000-10-03 07:22:07 +02:00
|
|
|
fileAddRealValue(FILE *fp, bool bin, double value)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2001-01-21 18:18:20 +01:00
|
|
|
if (bin)
|
2012-05-18 21:38:42 +02:00
|
|
|
rowbuf[column++] = value;
|
2001-01-21 18:18:20 +01:00
|
|
|
else
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(fp, "\t%.*e\n", DOUBLE_PRECISION, value);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static void
|
2000-10-03 07:22:07 +02:00
|
|
|
fileAddComplexValue(FILE *fp, bool bin, IFcomplex value)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2001-01-21 18:18:20 +01:00
|
|
|
if (bin) {
|
2012-05-18 21:38:42 +02:00
|
|
|
rowbuf[column++] = value.real;
|
|
|
|
|
rowbuf[column++] = value.imag;
|
2001-01-21 18:18:20 +01:00
|
|
|
} else {
|
|
|
|
|
fprintf(fp, "\t%.*e,%.*e\n", DOUBLE_PRECISION, value.real,
|
2000-04-27 22:03:57 +02:00
|
|
|
DOUBLE_PRECISION, value.imag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* ARGSUSED */ /* until some code gets written */
|
|
|
|
|
static void
|
|
|
|
|
fileEndPoint(FILE *fp, bool bin)
|
|
|
|
|
{
|
2012-05-18 21:38:42 +02:00
|
|
|
/* write row buffer to file */
|
2012-05-18 21:13:31 +02:00
|
|
|
/* otherwise the data has already been written */
|
|
|
|
|
|
|
|
|
|
if (bin)
|
2012-05-01 14:32:07 +02:00
|
|
|
fwrite(rowbuf, sizeof(double), rowbuflen, fp);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* Here's the hack... Run back and fill in the number of points. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
fileEnd(runDesc *run)
|
|
|
|
|
{
|
|
|
|
|
if (run->fp != stdout) {
|
2012-05-18 21:13:31 +02:00
|
|
|
long place = ftell(run->fp);
|
2012-05-01 14:32:07 +02:00
|
|
|
fseek(run->fp, run->pointPos, SEEK_SET);
|
2001-01-21 18:18:20 +01:00
|
|
|
fprintf(run->fp, "%d", run->pointCount);
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(stdout, "\nNo. of Data Rows : %d\n", run->pointCount);
|
|
|
|
|
fseek(run->fp, place, SEEK_SET);
|
2000-04-27 22:03:57 +02:00
|
|
|
} else {
|
2012-05-01 14:32:07 +02:00
|
|
|
/* Yet another hack-around */
|
|
|
|
|
fprintf(stderr, "@@@ %ld %d\n", run->pointPos, run->pointCount);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
fflush(run->fp);
|
2000-10-03 07:22:07 +02:00
|
|
|
|
2001-01-21 18:18:20 +01:00
|
|
|
if (run->binary) {
|
2012-05-01 14:32:07 +02:00
|
|
|
/* deallocate row buffer */
|
|
|
|
|
tfree(rowbuf);
|
2001-01-21 18:18:20 +01:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2009-05-21 17:11:06 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* The plot maintenance routines. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
plotInit(runDesc *run)
|
|
|
|
|
{
|
|
|
|
|
struct plot *pl = plot_alloc(run->type);
|
|
|
|
|
char buf[100];
|
|
|
|
|
struct dvec *v;
|
|
|
|
|
dataDesc *dd;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
pl->pl_title = copy(run->name);
|
|
|
|
|
pl->pl_name = copy(run->type);
|
2012-05-18 21:38:42 +02:00
|
|
|
pl->pl_date = copy(datestring());
|
2000-04-27 22:03:57 +02:00
|
|
|
pl->pl_ndims = 0;
|
|
|
|
|
plot_new(pl);
|
|
|
|
|
plot_setcur(pl->pl_typename);
|
|
|
|
|
run->runPlot = pl;
|
|
|
|
|
|
|
|
|
|
/* This is a hack. */
|
|
|
|
|
/* if any of them complex, make them all complex */
|
|
|
|
|
run->isComplex = FALSE;
|
2012-05-18 21:13:31 +02:00
|
|
|
for (i = 0; i < run->numData; i++)
|
|
|
|
|
if (run->data[i].type == IF_COMPLEX)
|
|
|
|
|
run->isComplex = TRUE;
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
for (i = 0; i < run->numData; i++) {
|
|
|
|
|
dd = &run->data[i];
|
|
|
|
|
v = alloc(struct dvec);
|
|
|
|
|
if (isdigit(*dd->name)) {
|
|
|
|
|
(void) sprintf(buf, "V(%s)", dd->name);
|
|
|
|
|
v->v_name = copy(buf);
|
2012-09-20 20:30:53 +02:00
|
|
|
} else {
|
2000-04-27 22:03:57 +02:00
|
|
|
v->v_name = copy(dd->name);
|
2012-09-20 20:30:53 +02:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
if (substring("#branch", v->v_name))
|
|
|
|
|
v->v_type = SV_CURRENT;
|
|
|
|
|
else if (cieq(v->v_name, "time"))
|
|
|
|
|
v->v_type = SV_TIME;
|
|
|
|
|
else if (cieq(v->v_name, "frequency"))
|
|
|
|
|
v->v_type = SV_FREQUENCY;
|
2011-03-18 21:15:10 +01:00
|
|
|
else if (cieq(v->v_name, "onoise_spectrum"))
|
|
|
|
|
v->v_type = SV_OUTPUT_N_DENS;
|
|
|
|
|
else if (cieq(v->v_name, "onoise_integrated"))
|
|
|
|
|
v->v_type = SV_OUTPUT_NOISE;
|
|
|
|
|
else if (cieq(v->v_name, "inoise_spectrum"))
|
|
|
|
|
v->v_type = SV_INPUT_N_DENS;
|
|
|
|
|
else if (cieq(v->v_name, "inoise_integrated"))
|
|
|
|
|
v->v_type = SV_INPUT_NOISE;
|
2009-05-21 17:11:06 +02:00
|
|
|
else if (cieq(v->v_name, "temp-sweep"))
|
2005-05-09 22:20:18 +02:00
|
|
|
v->v_type = SV_TEMP;
|
2009-05-21 17:11:06 +02:00
|
|
|
else if (cieq(v->v_name, "res-sweep"))
|
2005-05-09 22:20:18 +02:00
|
|
|
v->v_type = SV_RES;
|
2009-05-21 17:11:06 +02:00
|
|
|
else if ((*(v->v_name) == '@') && (substring("[g", v->v_name)))
|
2012-05-01 14:32:07 +02:00
|
|
|
v->v_type = SV_ADMITTANCE;
|
2012-10-03 15:01:36 +02:00
|
|
|
else if ((*(v->v_name) == '@') && (substring("[c", v->v_name)))
|
|
|
|
|
v->v_type = SV_CAPACITANCE;
|
|
|
|
|
else if ((*(v->v_name) == '@') && (substring("[i", v->v_name)))
|
|
|
|
|
v->v_type = SV_CURRENT;
|
|
|
|
|
else if ((*(v->v_name) == '@') && (substring("[q", v->v_name)))
|
|
|
|
|
v->v_type = SV_CHARGE;
|
2012-05-01 14:32:07 +02:00
|
|
|
else
|
2000-04-27 22:03:57 +02:00
|
|
|
v->v_type = SV_VOLTAGE;
|
|
|
|
|
v->v_length = 0;
|
|
|
|
|
v->v_scale = NULL;
|
|
|
|
|
if (!run->isComplex) {
|
|
|
|
|
v->v_flags = VF_REAL;
|
|
|
|
|
v->v_realdata = NULL;
|
|
|
|
|
} else {
|
|
|
|
|
v->v_flags = VF_COMPLEX;
|
|
|
|
|
v->v_compdata = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
v->v_flags |= VF_PERMANENT;
|
|
|
|
|
|
|
|
|
|
vec_new(v);
|
|
|
|
|
dd->vec = v;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static void
|
|
|
|
|
plotAddRealValue(dataDesc *desc, double value)
|
|
|
|
|
{
|
|
|
|
|
struct dvec *v = desc->vec;
|
|
|
|
|
|
|
|
|
|
if (isreal(v)) {
|
2012-05-18 21:13:31 +02:00
|
|
|
v->v_realdata = TREALLOC(double, v->v_realdata, v->v_length + 1);
|
2012-05-01 14:32:07 +02:00
|
|
|
v->v_realdata[v->v_length] = value;
|
2000-04-27 22:03:57 +02:00
|
|
|
} else {
|
2012-05-01 14:32:07 +02:00
|
|
|
/* a real parading as a VF_COMPLEX */
|
2012-05-18 21:13:31 +02:00
|
|
|
v->v_compdata = TREALLOC(ngcomplex_t, v->v_compdata, v->v_length + 1);
|
2012-05-01 14:32:07 +02:00
|
|
|
v->v_compdata[v->v_length].cx_real = value;
|
|
|
|
|
v->v_compdata[v->v_length].cx_imag = 0.0;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
v->v_length++;
|
2012-05-18 21:38:42 +02:00
|
|
|
v->v_dims[0] = v->v_length; /* va, must be updated */
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static void
|
|
|
|
|
plotAddComplexValue(dataDesc *desc, IFcomplex value)
|
|
|
|
|
{
|
|
|
|
|
struct dvec *v = desc->vec;
|
|
|
|
|
|
2012-05-18 21:13:31 +02:00
|
|
|
v->v_compdata = TREALLOC(ngcomplex_t, v->v_compdata, v->v_length + 1);
|
2000-04-27 22:03:57 +02:00
|
|
|
v->v_compdata[v->v_length].cx_real = value.real;
|
|
|
|
|
v->v_compdata[v->v_length].cx_imag = value.imag;
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
v->v_length++;
|
2012-05-18 21:38:42 +02:00
|
|
|
v->v_dims[0] = v->v_length; /* va, must be updated */
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* ARGSUSED */ /* until some code gets written */
|
|
|
|
|
static void
|
|
|
|
|
plotEnd(runDesc *run)
|
|
|
|
|
{
|
2012-05-18 21:38:42 +02:00
|
|
|
fprintf(stderr, "\n");
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(stdout, "\nNo. of Data Rows : %d\n", run->pointCount);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2009-05-21 17:11:06 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* ParseSpecial takes something of the form "@name[param,index]" and rips
|
|
|
|
|
* out name, param, andstrchr.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
parseSpecial(char *name, char *dev, char *param, char *ind)
|
|
|
|
|
{
|
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
|
|
*dev = *param = *ind = '\0';
|
|
|
|
|
|
|
|
|
|
if (*name != '@')
|
2000-10-03 07:22:07 +02:00
|
|
|
return FALSE;
|
2000-04-27 22:03:57 +02:00
|
|
|
name++;
|
2012-05-01 14:32:07 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
s = dev;
|
|
|
|
|
while (*name && (*name != '['))
|
|
|
|
|
*s++ = *name++;
|
|
|
|
|
*s = '\0';
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
if (!*name)
|
2000-10-03 07:22:07 +02:00
|
|
|
return TRUE;
|
2000-04-27 22:03:57 +02:00
|
|
|
name++;
|
|
|
|
|
|
|
|
|
|
s = param;
|
|
|
|
|
while (*name && (*name != ',') && (*name != ']'))
|
|
|
|
|
*s++ = *name++;
|
|
|
|
|
*s = '\0';
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
if (*name == ']')
|
|
|
|
|
return (!name[1] ? TRUE : FALSE);
|
|
|
|
|
else if (!*name)
|
2000-10-03 07:22:07 +02:00
|
|
|
return FALSE;
|
2000-04-27 22:03:57 +02:00
|
|
|
name++;
|
|
|
|
|
|
|
|
|
|
s = ind;
|
|
|
|
|
while (*name && (*name != ']'))
|
|
|
|
|
*s++ = *name++;
|
|
|
|
|
*s = '\0';
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
if (*name && !name[1])
|
2000-10-03 07:22:07 +02:00
|
|
|
return TRUE;
|
2000-04-27 22:03:57 +02:00
|
|
|
else
|
2000-10-03 07:22:07 +02:00
|
|
|
return FALSE;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* This routine must match two names with or without a V() around them. */
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
name_eq(char *n1, char *n2)
|
|
|
|
|
{
|
|
|
|
|
char buf1[BSIZE_SP], buf2[BSIZE_SP], *s;
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
if ((s = strchr(n1, '(')) != NULL) {
|
2000-04-27 22:03:57 +02:00
|
|
|
strcpy(buf1, s);
|
2012-05-18 21:38:42 +02:00
|
|
|
if ((s = strchr(buf1, ')')) == NULL)
|
2000-10-03 07:22:07 +02:00
|
|
|
return FALSE;
|
2000-04-27 22:03:57 +02:00
|
|
|
*s = '\0';
|
|
|
|
|
n1 = buf1;
|
|
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
|
|
|
|
if ((s = strchr(n2, '(')) != NULL) {
|
2000-04-27 22:03:57 +02:00
|
|
|
strcpy(buf2, s);
|
2012-05-18 21:38:42 +02:00
|
|
|
if ((s = strchr(buf2, ')')) == NULL)
|
2000-10-03 07:22:07 +02:00
|
|
|
return FALSE;
|
2000-04-27 22:03:57 +02:00
|
|
|
*s = '\0';
|
|
|
|
|
n2 = buf2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (strcmp(n1, n2) ? FALSE : TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static bool
|
|
|
|
|
getSpecial(dataDesc *desc, runDesc *run, IFvalue *val)
|
|
|
|
|
{
|
|
|
|
|
IFvalue selector;
|
|
|
|
|
struct variable *vv;
|
|
|
|
|
|
|
|
|
|
selector.iValue = desc->specIndex;
|
|
|
|
|
if (INPaName(desc->specParamName, val, run->circuit, &desc->specType,
|
2012-05-01 14:32:07 +02:00
|
|
|
desc->specName, &desc->specFast, ft_sim, &desc->type,
|
|
|
|
|
&selector) == OK) {
|
|
|
|
|
desc->type &= (IF_REAL | IF_COMPLEX); /* mask out other bits */
|
|
|
|
|
return TRUE;
|
2012-05-18 21:13:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((vv = if_getstat(run->circuit, &desc->name[1])) != NULL) {
|
2012-05-01 14:32:07 +02:00
|
|
|
/* skip @ sign */
|
|
|
|
|
desc->type = IF_REAL;
|
|
|
|
|
if (vv->va_type == CP_REAL)
|
|
|
|
|
val->rValue = vv->va_real;
|
|
|
|
|
else if (vv->va_type == CP_NUM)
|
|
|
|
|
val->rValue = vv->va_num;
|
|
|
|
|
else if (vv->va_type == CP_BOOL)
|
|
|
|
|
val->rValue = (vv->va_bool ? 1.0 : 0.0);
|
2012-05-18 21:13:31 +02:00
|
|
|
else
|
2012-05-01 14:32:07 +02:00
|
|
|
return FALSE; /* not a real */
|
|
|
|
|
tfree(vv);
|
|
|
|
|
return TRUE;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2000-10-03 07:22:07 +02:00
|
|
|
return FALSE;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static void
|
|
|
|
|
freeRun(runDesc *run)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
for (i = 0; i < run->numData; i++) {
|
2012-05-01 14:32:07 +02:00
|
|
|
tfree(run->data[i].name);
|
|
|
|
|
tfree(run->data[i].specParamName);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
tfree(run->data);
|
* src/main.c, src/multidec.c, src/proc2mod.c,
src/frontend/display.c, src/frontend/outitf.c,
src/frontend/help/readhelp.c, src/frontend/help/x11disp.c,
src/frontend/parser/complete.c, src/frontend/parser/glob.c,
src/frontend/plotting/graf.c,
src/frontend/plotting/graphdb.c,
src/frontend/plotting/x11.c, src/include/graph.h,
src/include/iferrmsg.h, src/include/ifsim.h,
src/include/macros.h, src/maths/poly/polyfit.c,
src/maths/sparse/spalloc.c, src/maths/sparse/spconfig.h,
src/misc/alloc.c, src/misc/mktemp.c,
src/spicelib/analysis/cktpzstr.c,
src/spicelib/devices/bsim2/b2temp.c,
src/spicelib/devices/bsim3/b3temp.c,
src/spicelib/devices/bsim3v1/b3v1temp.c,
src/spicelib/devices/bsim3v2/b3v2temp.c,
src/spicelib/devices/bsim4/b4temp.c: replaced malloc
realloc and free calls to use tmalloc trealloc and txfree.
* tests/diffpair.out, tests/fourbitadder.out,
tests/resistance/res_partition.out: Updated.
2000-10-14 15:16:53 +02:00
|
|
|
tfree(run->type);
|
|
|
|
|
tfree(run->name);
|
2012-05-18 21:38:42 +02:00
|
|
|
|
* src/main.c, src/multidec.c, src/proc2mod.c,
src/frontend/display.c, src/frontend/outitf.c,
src/frontend/help/readhelp.c, src/frontend/help/x11disp.c,
src/frontend/parser/complete.c, src/frontend/parser/glob.c,
src/frontend/plotting/graf.c,
src/frontend/plotting/graphdb.c,
src/frontend/plotting/x11.c, src/include/graph.h,
src/include/iferrmsg.h, src/include/ifsim.h,
src/include/macros.h, src/maths/poly/polyfit.c,
src/maths/sparse/spalloc.c, src/maths/sparse/spconfig.h,
src/misc/alloc.c, src/misc/mktemp.c,
src/spicelib/analysis/cktpzstr.c,
src/spicelib/devices/bsim2/b2temp.c,
src/spicelib/devices/bsim3/b3temp.c,
src/spicelib/devices/bsim3v1/b3v1temp.c,
src/spicelib/devices/bsim3v2/b3v2temp.c,
src/spicelib/devices/bsim4/b4temp.c: replaced malloc
realloc and free calls to use tmalloc trealloc and txfree.
* tests/diffpair.out, tests/fourbitadder.out,
tests/resistance/res_partition.out: Updated.
2000-10-14 15:16:53 +02:00
|
|
|
tfree(run);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
int
|
|
|
|
|
OUTstopnow(void)
|
|
|
|
|
{
|
|
|
|
|
if (ft_intrpt || shouldstop) {
|
|
|
|
|
ft_intrpt = shouldstop = FALSE;
|
|
|
|
|
return (1);
|
2012-05-18 21:13:31 +02:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-05-18 21:13:31 +02:00
|
|
|
return (0);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* Print out error messages. */
|
|
|
|
|
|
|
|
|
|
static struct mesg {
|
2012-05-01 14:32:07 +02:00
|
|
|
char *string;
|
|
|
|
|
long flag;
|
2003-12-25 18:30:36 +01:00
|
|
|
} msgs[] = {
|
2012-05-01 14:32:07 +02:00
|
|
|
{ "Warning", ERR_WARNING } ,
|
|
|
|
|
{ "Fatal error", ERR_FATAL } ,
|
|
|
|
|
{ "Panic", ERR_PANIC } ,
|
|
|
|
|
{ "Note", ERR_INFO } ,
|
|
|
|
|
{ NULL, 0 }
|
2012-05-18 21:38:42 +02:00
|
|
|
};
|
|
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
OUTerror(int flags, char *format, IFuid *names)
|
|
|
|
|
{
|
|
|
|
|
struct mesg *m;
|
|
|
|
|
char buf[BSIZE_SP], *s, *bptr;
|
|
|
|
|
int nindex = 0;
|
|
|
|
|
|
2010-07-20 20:41:25 +02:00
|
|
|
if ((flags == ERR_INFO) && cp_getvar("printinfo", CP_BOOL, NULL))
|
2012-05-01 14:32:07 +02:00
|
|
|
return;
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
for (m = msgs; m->flag; m++)
|
2012-05-01 14:32:07 +02:00
|
|
|
if (flags & m->flag)
|
|
|
|
|
fprintf(cp_err, "%s: ", m->string);
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
for (s = format, bptr = buf; *s; s++) {
|
2013-01-26 14:40:29 +01:00
|
|
|
if (*s == '%' && (s == format || s[-1] != '%') && s[1] == 's') {
|
2012-05-01 14:32:07 +02:00
|
|
|
if (names[nindex])
|
|
|
|
|
strcpy(bptr, names[nindex]);
|
|
|
|
|
else
|
|
|
|
|
strcpy(bptr, "(null)");
|
|
|
|
|
bptr += strlen(bptr);
|
|
|
|
|
s++;
|
|
|
|
|
nindex++;
|
|
|
|
|
} else {
|
|
|
|
|
*bptr++ = *s;
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-05-18 21:38:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
*bptr = '\0';
|
2012-05-01 14:32:07 +02:00
|
|
|
fprintf(cp_err, "%s\n", buf);
|
|
|
|
|
fflush(cp_err);
|
2000-10-03 07:22:07 +02:00
|
|
|
}
|
2014-02-01 14:24:04 +01:00
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
InterpFileAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
static double timeold = 0.0, timenew = 0.0, timestep = 0.0;
|
|
|
|
|
bool nodata = FALSE;
|
|
|
|
|
bool interpolatenow = FALSE;
|
|
|
|
|
|
|
|
|
|
if (run->pointCount == 1) {
|
|
|
|
|
fileInit_pass2(run);
|
|
|
|
|
timestep = run->circuit->CKTinitTime + run->circuit->CKTstep;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (run->refIndex != -1) {
|
|
|
|
|
/* Save first time step */
|
|
|
|
|
if (refValue->rValue == run->circuit->CKTinitTime) {
|
|
|
|
|
timeold = refValue->rValue;
|
|
|
|
|
fileStartPoint(run->fp, run->binary, run->pointCount);
|
|
|
|
|
fileAddRealValue(run->fp, run->binary, run->circuit->CKTinitTime);
|
|
|
|
|
interpolatenow = nodata = FALSE;
|
|
|
|
|
}
|
|
|
|
|
/* Save last time step */
|
|
|
|
|
else if (refValue->rValue == run->circuit->CKTfinalTime) {
|
|
|
|
|
timeold = refValue->rValue;
|
|
|
|
|
fileStartPoint(run->fp, run->binary, run->pointCount);
|
|
|
|
|
fileAddRealValue(run->fp, run->binary, run->circuit->CKTfinalTime);
|
|
|
|
|
interpolatenow = nodata = FALSE;
|
|
|
|
|
}
|
|
|
|
|
/* Save exact point */
|
|
|
|
|
else if (refValue->rValue == timestep) {
|
|
|
|
|
timeold = refValue->rValue;
|
|
|
|
|
fileStartPoint(run->fp, run->binary, run->pointCount);
|
|
|
|
|
fileAddRealValue(run->fp, run->binary, timestep);
|
|
|
|
|
timestep += run->circuit->CKTstep;
|
|
|
|
|
interpolatenow = nodata = FALSE;
|
|
|
|
|
}
|
|
|
|
|
else if (refValue->rValue > timestep) {
|
|
|
|
|
/* add the next time step value to the vector */
|
|
|
|
|
fileStartPoint(run->fp, run->binary, run->pointCount);
|
|
|
|
|
timenew = refValue->rValue;
|
|
|
|
|
fileAddRealValue(run->fp, run->binary, timestep);
|
|
|
|
|
timestep += run->circuit->CKTstep;
|
|
|
|
|
nodata = FALSE;
|
|
|
|
|
interpolatenow = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Do not save this step */
|
|
|
|
|
run->pointCount--;
|
|
|
|
|
timeold = refValue->rValue;
|
|
|
|
|
nodata = TRUE;
|
|
|
|
|
interpolatenow = FALSE;
|
|
|
|
|
}
|
|
|
|
|
#ifndef HAS_WINGUI
|
|
|
|
|
if (!orflag) {
|
|
|
|
|
currclock = clock();
|
|
|
|
|
if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) {
|
|
|
|
|
fprintf(stderr, " Reference value : % 12.5e\r",
|
|
|
|
|
refValue->rValue);
|
|
|
|
|
lastclock = currclock;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < run->numData; i++) {
|
|
|
|
|
/* we've already printed reference vec first */
|
|
|
|
|
if (run->data[i].outIndex == -1)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
#ifdef TCL_MODULE
|
|
|
|
|
blt_add(i, refValue ? refValue->rValue : NAN);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (run->data[i].regular) {
|
|
|
|
|
/* Store value or interpolate and store or do not store any value to file */
|
|
|
|
|
if (!interpolatenow && !nodata) {
|
|
|
|
|
/* store the first or last value */
|
|
|
|
|
valueold[i] = valuePtr->v.vec.rVec [run->data[i].outIndex];
|
|
|
|
|
fileAddRealValue(run->fp, run->binary, valueold[i]);
|
|
|
|
|
}
|
|
|
|
|
else if (interpolatenow) {
|
|
|
|
|
/* Interpolate time if actual time is greater than proposed next time step */
|
|
|
|
|
double newval;
|
|
|
|
|
valuenew[i] = valuePtr->v.vec.rVec [run->data[i].outIndex];
|
|
|
|
|
newval = (timestep - run->circuit->CKTstep - timeold)/(timenew - timeold) * (valuenew[i] - valueold[i]) + valueold[i];
|
|
|
|
|
fileAddRealValue(run->fp, run->binary, newval);
|
|
|
|
|
valueold[i] = valuenew[i];
|
|
|
|
|
}
|
|
|
|
|
else if (nodata)
|
|
|
|
|
/* Just keep the transient output value corresponding to timeold,
|
|
|
|
|
but do not store to file */
|
|
|
|
|
valueold[i] = valuePtr->v.vec.rVec [run->data[i].outIndex];
|
|
|
|
|
} else {
|
|
|
|
|
IFvalue val;
|
|
|
|
|
/* 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);
|
|
|
|
|
val.rValue = 0;
|
|
|
|
|
fileAddRealValue(run->fp, run->binary, val.rValue);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!interpolatenow && !nodata) {
|
|
|
|
|
/* store the first or last value */
|
|
|
|
|
valueold[i] = val.rValue;
|
|
|
|
|
fileAddRealValue(run->fp, run->binary, valueold[i]);
|
|
|
|
|
}
|
|
|
|
|
else if (interpolatenow) {
|
|
|
|
|
/* Interpolate time if actual time is greater than proposed next time step */
|
|
|
|
|
double newval;
|
|
|
|
|
valuenew[i] = val.rValue;
|
|
|
|
|
newval = (timestep - run->circuit->CKTstep - timeold)/(timenew - timeold) * (valuenew[i] - valueold[i]) + valueold[i];
|
|
|
|
|
fileAddRealValue(run->fp, run->binary, newval);
|
|
|
|
|
valueold[i] = valuenew[i];
|
|
|
|
|
}
|
|
|
|
|
else if (nodata)
|
|
|
|
|
/* Just keep the transient output value corresponding to timeold,
|
|
|
|
|
but do not store to file */
|
|
|
|
|
valueold[i] = val.rValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef TCL_MODULE
|
|
|
|
|
blt_add(i, valuePtr->v.vec.rVec [run->data[i].outIndex]);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ft_bpcheck(run->runPlot, run->pointCount) == FALSE)
|
|
|
|
|
shouldstop = TRUE;
|
|
|
|
|
|
|
|
|
|
#ifdef TCL_MODULE
|
|
|
|
|
Tcl_ExecutePerLoop();
|
|
|
|
|
#elif defined SHARED_MODULE
|
|
|
|
|
sh_ExecutePerLoop();
|
|
|
|
|
#endif
|
|
|
|
|
return(OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
InterpPlotAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
|
|
|
|
|
{
|
|
|
|
|
int i, iscale = -1;
|
|
|
|
|
static double timeold = 0.0, timenew = 0.0, timestep = 0.0;
|
|
|
|
|
bool nodata = FALSE;
|
|
|
|
|
bool interpolatenow = FALSE;
|
|
|
|
|
|
|
|
|
|
if (run->pointCount == 1)
|
|
|
|
|
timestep = run->circuit->CKTinitTime + run->circuit->CKTstep;
|
|
|
|
|
|
|
|
|
|
/* find the scale vector */
|
|
|
|
|
for (i = 0; i < run->numData; i++)
|
|
|
|
|
if (run->data[i].outIndex == -1) {
|
|
|
|
|
iscale = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (iscale == -1)
|
|
|
|
|
fprintf(stderr, "Error: no scale vector found\n");
|
|
|
|
|
|
|
|
|
|
#ifdef TCL_MODULE
|
|
|
|
|
/*Locks the blt vector to stop access*/
|
|
|
|
|
blt_lockvec(iscale);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Save first time step */
|
|
|
|
|
if (refValue->rValue == run->circuit->CKTinitTime) {
|
|
|
|
|
timeold = refValue->rValue;
|
|
|
|
|
plotAddRealValue(&run->data[iscale], refValue->rValue);
|
|
|
|
|
interpolatenow = nodata = FALSE;
|
|
|
|
|
}
|
|
|
|
|
/* Save last time step */
|
|
|
|
|
else if (refValue->rValue == run->circuit->CKTfinalTime) {
|
|
|
|
|
timeold = refValue->rValue;
|
|
|
|
|
plotAddRealValue(&run->data[iscale], run->circuit->CKTfinalTime);
|
|
|
|
|
interpolatenow = nodata = FALSE;
|
|
|
|
|
}
|
|
|
|
|
/* Save exact point */
|
|
|
|
|
else if (refValue->rValue == timestep) {
|
|
|
|
|
timeold = refValue->rValue;
|
|
|
|
|
plotAddRealValue(&run->data[iscale], timestep);
|
|
|
|
|
timestep += run->circuit->CKTstep;
|
|
|
|
|
interpolatenow = nodata = FALSE;
|
|
|
|
|
}
|
|
|
|
|
else if (refValue->rValue > timestep) {
|
|
|
|
|
/* add the next time step value to the vector */
|
|
|
|
|
timenew = refValue->rValue;
|
|
|
|
|
plotAddRealValue(&run->data[iscale], timestep);
|
|
|
|
|
timestep += run->circuit->CKTstep;
|
|
|
|
|
nodata = FALSE;
|
|
|
|
|
interpolatenow = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Do not save this step */
|
|
|
|
|
run->pointCount--;
|
|
|
|
|
timeold = refValue->rValue;
|
|
|
|
|
nodata = TRUE;
|
|
|
|
|
interpolatenow = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef TCL_MODULE
|
|
|
|
|
/*relinks and unlocks vector*/
|
|
|
|
|
blt_relink(iscale, (run->data[iscale]).vec);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef HAS_WINGUI
|
|
|
|
|
if (!orflag) {
|
|
|
|
|
currclock = clock();
|
|
|
|
|
if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) {
|
|
|
|
|
fprintf(stderr, " Reference value : % 12.5e\r",
|
|
|
|
|
refValue->rValue);
|
|
|
|
|
lastclock = currclock;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < run->numData; i++) {
|
|
|
|
|
if (i == iscale)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
#ifdef TCL_MODULE
|
|
|
|
|
/*Locks the blt vector to stop access*/
|
|
|
|
|
blt_lockvec(i);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (run->data[i].regular) {
|
|
|
|
|
/* Store value or interpolate and store or do not store any value to file */
|
|
|
|
|
if (!interpolatenow && !nodata) {
|
|
|
|
|
/* store the first or last value */
|
|
|
|
|
valueold[i] = valuePtr->v.vec.rVec [run->data[i].outIndex];
|
|
|
|
|
plotAddRealValue(&run->data[i], valueold[i]);
|
|
|
|
|
}
|
|
|
|
|
else if (interpolatenow) {
|
|
|
|
|
/* Interpolate time if actual time is greater than proposed next time step */
|
|
|
|
|
double newval;
|
|
|
|
|
valuenew[i] = valuePtr->v.vec.rVec [run->data[i].outIndex];
|
|
|
|
|
newval = (timestep - run->circuit->CKTstep - timeold)/(timenew - timeold) * (valuenew[i] - valueold[i]) + valueold[i];
|
|
|
|
|
plotAddRealValue(&run->data[i], newval);
|
|
|
|
|
valueold[i] = valuenew[i];
|
|
|
|
|
}
|
|
|
|
|
else if (nodata)
|
|
|
|
|
/* Just keep the transient output value corresponding to timeold,
|
|
|
|
|
but do not store to file */
|
|
|
|
|
valueold[i] = valuePtr->v.vec.rVec [run->data[i].outIndex];
|
|
|
|
|
} else {
|
|
|
|
|
IFvalue val;
|
|
|
|
|
/* should pre-check instance */
|
|
|
|
|
if (!getSpecial(&run->data[i], run, &val))
|
|
|
|
|
continue;
|
|
|
|
|
if (!interpolatenow && !nodata) {
|
|
|
|
|
/* store the first or last value */
|
|
|
|
|
valueold[i] = val.rValue;
|
|
|
|
|
plotAddRealValue(&run->data[i], valueold[i]);
|
|
|
|
|
}
|
|
|
|
|
else if (interpolatenow) {
|
|
|
|
|
/* Interpolate time if actual time is greater than proposed next time step */
|
|
|
|
|
double newval;
|
|
|
|
|
valuenew[i] = val.rValue;
|
|
|
|
|
newval = (timestep - run->circuit->CKTstep - timeold)/(timenew - timeold) * (valuenew[i] - valueold[i]) + valueold[i];
|
|
|
|
|
plotAddRealValue(&run->data[i], newval);
|
|
|
|
|
valueold[i] = valuenew[i];
|
|
|
|
|
}
|
|
|
|
|
else if (nodata)
|
|
|
|
|
/* Just keep the transient output value corresponding to timeold,
|
|
|
|
|
but do not store to file */
|
|
|
|
|
valueold[i] = val.rValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef TCL_MODULE
|
|
|
|
|
/*relinks and unlocks vector*/
|
|
|
|
|
blt_relink(i, (run->data[i]).vec);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gr_iplot(run->runPlot);
|
|
|
|
|
|
|
|
|
|
if (ft_bpcheck(run->runPlot, run->pointCount) == FALSE)
|
|
|
|
|
shouldstop = TRUE;
|
|
|
|
|
|
|
|
|
|
#ifdef TCL_MODULE
|
|
|
|
|
Tcl_ExecutePerLoop();
|
|
|
|
|
#elif defined SHARED_MODULE
|
|
|
|
|
sh_ExecutePerLoop();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return(OK);
|
|
|
|
|
}
|