24 #define DOUBLE_PRECISION 15 81 static bool name_eq(
char*,
char*);
185 cktName =
"circuit name";
190 fprintf(
cp_err,
"(debug printing enabled)\n");
219 savesused = (
bool *)
tmalloc(
sizeof (
bool) * numsaves);
221 for (i = 0; i < numsaves; i++)
222 if (
cieq(saves[i],
"all")) {
232 for (i = 0; i < numsaves; i++)
242 if (numsaves && !saveall) {
243 for (i = 0; i < numsaves; i++) {
244 for (j = 0; j < outd->
numNames; j++)
254 for (i = 0; i < outd->
numNames; i++)
262 for (i = 0; i < numsaves; i++) {
265 if (!
parseSpecial(saves[i], namebuf, parambuf, depbuf)) {
266 if (numsaves == 1 && !saves[0])
267 fprintf(
cp_err,
"Warning: no variables saved\n");
269 fprintf(
cp_err,
"Warning: can't parse '%s': ignored\n",
275 for (j = 0; j < run->
numData; j++)
280 for (j = 0; j < outd->
numNames; j++)
285 "Warning: can't find '%s': value '%s' ignored\n",
334 sizeof (
dataDesc) * (run->numData + 1));
335 data = &run->data[run->numData];
346 run->refIndex = run->numData;
371 sizeof (
dataDesc) * (run->numData + 1));
372 data = &run->data[run->numData];
460 for (i = 0; i < run->
numData; i++) {
462 for (j = 0; j < numDims; j++)
482 if (run->refIndex != -1) {
489 for (i = 0; i < run->numData; i++) {
491 if (run->data[i].outIndex == -1)
continue;
493 if (run->data[i].regular) {
494 if(run->data[i].type ==
IF_REAL)
497 [run->data[i].outIndex]);
501 [run->data[i].outIndex]);
503 fprintf(stderr,
"OUTdata: unsupported data type\n");
509 if (run->data[i].type ==
IF_REAL)
516 fprintf(stderr,
"OUTdata: unsupported data type\n");
534 for (i = 0; i < run->numData; i++) {
535 if (run->data[i].outIndex == -1) {
536 if (run->data[i].type ==
IF_REAL)
543 else if (run->data[i].regular) {
544 if (run->data[i].type ==
IF_REAL)
547 [run->data[i].outIndex],inc);
551 [run->data[i].outIndex],inc);
557 if (run->data[i].type ==
IF_REAL)
564 fprintf(stderr,
"OUTdata: unsupported data type\n");
612 run->isComplex =
false;
613 for (i = 0; i < run->numData; i++)
615 run->isComplex =
true;
617 fprintf(run->fp,
"Title: %s\n", run->name);
619 fprintf(run->fp,
"Plotname: %s\n", run->type);
620 fprintf(run->fp,
"Flags: %s\n", run->isComplex ?
"complex" :
"real");
621 fprintf(run->fp,
"No. Variables: %d\n", run->numData);
622 fprintf(run->fp,
"No. Points: ");
625 run->pointPos = ftell(run->fp);
626 fprintf(run->fp,
"0 \n");
629 fprintf(run->fp,
"Variables:\n");
631 for (i = 0; i < run->numData; i++) {
632 if (isdigit(*run->data[i].name)) {
633 (void) sprintf(buf,
"v(%s)", run->data[i].name);
637 name = run->data[i].name;
641 else if (
cieq(name,
"time"))
643 else if (
cieq(name,
"frequency"))
647 fprintf(run->fp,
"\t%d\t%s\t%s\n", i, name,
651 fprintf(run->fp,
"%s:\n", run->binary ?
"Binary" :
"Values");
665 fprintf(fp,
"%d", num - 1);
679 fwrite((
char *) &value,
sizeof (
double), 1, fp);
696 fwrite((
char *) &value.
real, sizeof (
double), 1, fp);
697 fwrite((
char *) &value.
imag, sizeof (
double), 1, fp);
727 if (run->fp == stdout)
730 place = ftell(run->fp);
731 fseek(run->fp, run->pointPos, 0);
732 fprintf(run->fp,
"%d", run->pointCount);
733 fseek(run->fp, place, 0);
746 double tstart, tstop, tstep;
773 run->isComplex =
false;
774 for (i = 0; i < run->numData; i++) {
775 if (run->data[i].type ==
IF_COMPLEX) run->isComplex =
true;
778 for (i = 0; i < run->numData; i++) {
781 if (isdigit(*dd->
name)) {
782 (void) sprintf(buf,
"v(%s)", dd->
name);
799 if (!run->isComplex) {
822 struct dvec *v = desc->vec;
832 sizeof (double) * (v->
v_length + 1));
866 struct dvec *v = desc->vec;
911 *dev = *param = *ind =
'\0';
918 while (*name && (*name !=
'['))
926 while (*name && (*name !=
',') && (*name !=
']'))
930 return (!name[1] ?
true :
false);
936 while (*name && (*name !=
']'))
939 if (*name && !name[1])
964 for ( ; ; n1++,n2++) {
965 if ((*n1 == 0 || *n1 ==
')') && (*n2 == 0 || *n2 ==
')'))
984 selector.
iValue = desc->specIndex;
986 desc->specName, &desc->specFast,
ft_sim, &desc->type,
996 val->
rValue = vv->va_real;
1000 val->
rValue = (vv->va_bool ? 1.0 : 0.0);
1019 for (i = 0; i < run->numData; i++) {
1020 txfree(run->data[i].name);
1021 txfree(run->data[i].specParamName);
1023 txfree((
char*)run->data);
1077 if (flags & m->
flag)
1080 for (s = format, bptr = buf; *s; s++) {
1081 if (*s ==
'%' && (s == format || *(s-1) !=
'%') && *(s+1) ==
's') {
1082 strcpy(bptr, names[nindex]);
1083 bptr += strlen(names[nindex]);
1092 fprintf(
cp_err,
"%s\n", buf);
static char buf[MAXPROMPT]
int OUTbeginPlot(GENERIC *outdp)
static void addPointToFile()
bool cp_getvar(char *n, int t, char *r)
struct plot * plot_alloc()
static void fileAddComplexValue()
static void fileStartPoint()
union uIFvalue::@13::@14 vec
static struct mesg msgs[]
static void fileAddRealValue()
int OUTsetDims(GENERIC *plotPtr, int *dims, int numDims)
int bzero(char *ptr, int num)
static bool parseSpecial()
static void addPointToPlot()
struct variable * if_getstat(char *n, char *c, wordlist **w)
bool ft_getOutReq(FILE **fpp, struct plot **plotp, bool *binp, char *name, char *title)
static struct sOUTcontrol OUTcntrl
int OUTerror(int flags, char *format, IFuid *names)
static void plotAddComplexValue()
int OUTendPlot(GENERIC *plotPtr)
int OUTdata(GENERIC *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
static void fileEndPoint()
static void out_destroy()
static void plotAddRealValue()
static int addSpecialDesc()