CIDER: Enable printing either binary or ascii data output to file.
Patch provided by Brian Taylor, see (https://sourceforge.net/p/ngspice/mailman/message/37309841/)
This commit is contained in:
parent
9bb401d9cd
commit
8eeb924460
|
|
@ -76,7 +76,7 @@ extern void ONEQrhsLoad(ONEdevice *);
|
|||
extern void ONEQcommonTerms(ONEdevice *);
|
||||
|
||||
/*oneprint.c */
|
||||
extern void ONEprnSolution(FILE *, ONEdevice *, OUTPcard *);
|
||||
extern void ONEprnSolution(FILE *, ONEdevice *, OUTPcard *, BOOLEAN, char *);
|
||||
extern void ONEmemStats(FILE *, ONEdevice *);
|
||||
extern void ONEcpuStats(FILE *f, ONEdevice *);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ Author: 1992 David A. Gates, U. C. Berkeley CAD Group
|
|||
|
||||
|
||||
void
|
||||
ONEprnSolution(FILE *file, ONEdevice *pDevice, OUTPcard *output)
|
||||
ONEprnSolution(FILE *file, ONEdevice *pDevice, OUTPcard *output, BOOLEAN asciiSave, char *extra)
|
||||
{
|
||||
int index, i;
|
||||
int index, i, ii;
|
||||
int numVars = 0;
|
||||
ONEnode **nodeArray=NULL;
|
||||
ONEnode *pNode;
|
||||
|
|
@ -114,7 +114,11 @@ ONEprnSolution(FILE *file, ONEdevice *pDevice, OUTPcard *output)
|
|||
|
||||
/* Initialize rawfile */
|
||||
numVars = output->OUTPnumVars;
|
||||
fprintf(file, "Title: Device %s internal state\n", pDevice->name);
|
||||
if (extra != NULL) {
|
||||
fprintf(file, "Title: Device %s (%s) internal state\n", pDevice->name, extra);
|
||||
} else {
|
||||
fprintf(file, "Title: Device %s internal state\n", pDevice->name);
|
||||
}
|
||||
fprintf(file, "Plotname: Device Cross Section\n");
|
||||
fprintf(file, "Flags: real\n");
|
||||
fprintf(file, "Command: deftype p xs cross\n");
|
||||
|
|
@ -186,7 +190,11 @@ ONEprnSolution(FILE *file, ONEdevice *pDevice, OUTPcard *output)
|
|||
if (output->OUTPmup) {
|
||||
fprintf(file, "\t%d mup mobility\n", numVars++);
|
||||
}
|
||||
fprintf(file, "Binary:\n");
|
||||
if (asciiSave) {
|
||||
fprintf(file, "Values:\n");
|
||||
} else {
|
||||
fprintf(file, "Binary:\n");
|
||||
}
|
||||
|
||||
for (index = 1; index <= pDevice->numNodes; index++) {
|
||||
pNode = nodeArray[index];
|
||||
|
|
@ -305,7 +313,16 @@ ONEprnSolution(FILE *file, ONEdevice *pDevice, OUTPcard *output)
|
|||
if (output->OUTPmup) {
|
||||
data[numVars++] = mup;
|
||||
}
|
||||
fwrite(data, sizeof(double), (size_t) numVars, file);
|
||||
if (asciiSave) {
|
||||
for (ii = 0; ii < numVars; ii++) {
|
||||
if (ii == 0) {
|
||||
fprintf(file, "%d", index - 1);
|
||||
}
|
||||
fprintf(file, "\t%e\n", data[ii]);
|
||||
}
|
||||
} else {
|
||||
fwrite(data, sizeof(double), (size_t) numVars, file);
|
||||
}
|
||||
}
|
||||
FREE(nodeArray);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ Author: 1992 David A. Gates, U. C. Berkeley CAD Group
|
|||
#include "ngspice/numenum.h"
|
||||
#include "ngspice/spmatrix.h"
|
||||
#include "ngspice/cidersupt.h"
|
||||
#include "ngspice/cpextern.h"
|
||||
|
||||
|
||||
/* Used in Solution Projection Calculations */
|
||||
|
|
@ -161,3 +162,19 @@ foundError(int error)
|
|||
}
|
||||
return( matrixError );
|
||||
}
|
||||
|
||||
/* Return TRUE if the filetype variable matches the string 's' */
|
||||
BOOLEAN compareFiletypeVar(char *s)
|
||||
{
|
||||
char buf[BSIZE_SP];
|
||||
|
||||
if (cp_getvar("filetype", CP_STRING, buf, sizeof(buf))) {
|
||||
if (!strcmp(buf, s)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ extern void TWOQrhsLoad(TWOdevice *);
|
|||
extern void TWOQcommonTerms(TWOdevice *);
|
||||
|
||||
/*twoprint.c */
|
||||
extern void TWOprnSolution(FILE *, TWOdevice *, OUTPcard *);
|
||||
extern void TWOprnSolution(FILE *, TWOdevice *, OUTPcard *, BOOLEAN, char *);
|
||||
extern void TWOmemStats(FILE *, TWOdevice *);
|
||||
extern void TWOcpuStats(FILE *, TWOdevice *);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Author: 1992 David A. Gates, U. C. Berkeley CAD Group
|
|||
|
||||
|
||||
void
|
||||
TWOprnSolution(FILE *file, TWOdevice *pDevice, OUTPcard *output)
|
||||
TWOprnSolution(FILE *file, TWOdevice *pDevice, OUTPcard *output, BOOLEAN asciiSave, char *extra)
|
||||
{
|
||||
int index, xIndex, yIndex;
|
||||
int numVars = 0;
|
||||
|
|
@ -34,6 +34,7 @@ TWOprnSolution(FILE *file, TWOdevice *pDevice, OUTPcard *output)
|
|||
double jcy, jdy, jny, jpy, jty;
|
||||
double *xScale = pDevice->xScale;
|
||||
double *yScale = pDevice->yScale;
|
||||
int ii;
|
||||
|
||||
if (output->OUTPnumVars == -1) {
|
||||
/* First pass. Need to count number of variables in output. */
|
||||
|
|
@ -123,7 +124,11 @@ TWOprnSolution(FILE *file, TWOdevice *pDevice, OUTPcard *output)
|
|||
|
||||
/* Initialize rawfile */
|
||||
numVars = output->OUTPnumVars;
|
||||
fprintf(file, "Title: Device %s internal state\n", pDevice->name);
|
||||
if (extra != NULL) {
|
||||
fprintf(file, "Title: Device %s (%s) internal state\n", pDevice->name, extra);
|
||||
} else {
|
||||
fprintf(file, "Title: Device %s internal state\n", pDevice->name);
|
||||
}
|
||||
fprintf(file, "Plotname: Device Cross Section\n");
|
||||
fprintf(file, "Flags: real\n");
|
||||
fprintf(file, "Command: deftype p xs cross\n");
|
||||
|
|
@ -205,7 +210,11 @@ TWOprnSolution(FILE *file, TWOdevice *pDevice, OUTPcard *output)
|
|||
if (output->OUTPmup) {
|
||||
fprintf(file, "\t%d mup mobility\n", numVars++);
|
||||
}
|
||||
fprintf(file, "Binary:\n");
|
||||
if (asciiSave) {
|
||||
fprintf(file, "Values:\n");
|
||||
} else {
|
||||
fprintf(file, "Binary:\n");
|
||||
}
|
||||
|
||||
for (xIndex = 1; xIndex <= pDevice->numXNodes; xIndex++) {
|
||||
for (yIndex = 1; yIndex <= pDevice->numYNodes; yIndex++) {
|
||||
|
|
@ -215,8 +224,9 @@ TWOprnSolution(FILE *file, TWOdevice *pDevice, OUTPcard *output)
|
|||
/* Find the element to which this node belongs. */
|
||||
for (index = 0; index < 4; index++) {
|
||||
pElem = pNode->pElems[index];
|
||||
if (pElem != NULL && pElem->evalNodes[(index + 2) % 4])
|
||||
if (pElem != NULL && pElem->evalNodes[(index + 2) % 4]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
nodeFields(pElem, pNode, &ex, &ey);
|
||||
nodeCurrents(pElem, pNode, &mun, &mup,
|
||||
|
|
@ -307,14 +317,32 @@ TWOprnSolution(FILE *file, TWOdevice *pDevice, OUTPcard *output)
|
|||
if (output->OUTPmup) {
|
||||
data[numVars++] = mup;
|
||||
}
|
||||
fwrite(data, sizeof(double), (size_t) numVars, file);
|
||||
if (asciiSave) {
|
||||
for (ii = 0; ii < numVars; ii++) {
|
||||
if (ii == 0) {
|
||||
fprintf(file, "%d %d", yIndex, xIndex);
|
||||
}
|
||||
fprintf(file, "\t%e\n", data[ii]);
|
||||
}
|
||||
} else {
|
||||
fwrite(data, sizeof(double), (size_t) numVars, file);
|
||||
}
|
||||
} else {
|
||||
for (index = 0; index < output->OUTPnumVars; index++) {
|
||||
data[index] = 0.0;
|
||||
}
|
||||
data[0] = yScale[yIndex] * 1e-2;
|
||||
data[1] = xScale[xIndex] * 1e-2;
|
||||
fwrite(data, sizeof(double), (size_t) numVars, file);
|
||||
if (asciiSave) {
|
||||
for (ii = 0; ii < numVars; ii++) {
|
||||
if (ii == 0) {
|
||||
fprintf(file, "%d %d", yIndex, xIndex);
|
||||
}
|
||||
fprintf(file, "\t%e\n", data[ii]);
|
||||
}
|
||||
} else {
|
||||
fwrite(data, sizeof(double), (size_t) numVars, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ extern double guessNewConc(double , double );
|
|||
extern double lookup(double **, double );
|
||||
extern BOOLEAN hasSORConverged(double *, double *, int);
|
||||
extern BOOLEAN foundError(int );
|
||||
extern BOOLEAN compareFiletypeVar(char *);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ NBJTdump(GENmodel *inModel, CKTcircuit *ckt)
|
|||
char *prefix;
|
||||
int *state_num;
|
||||
int anyOutput = 0;
|
||||
BOOLEAN writeAscii = TRUE;
|
||||
|
||||
if (ckt->CKTmode & MODEDCOP) {
|
||||
prefix = "OP";
|
||||
|
|
@ -68,12 +69,15 @@ NBJTdump(GENmodel *inModel, CKTcircuit *ckt)
|
|||
anyOutput = 1;
|
||||
sprintf(fileName, "%s%s.%d.%s", output->OUTProotFile, prefix,
|
||||
*state_num, inst->NBJTname);
|
||||
if ((fpState = fopen(fileName, "wb")) == NULL) {
|
||||
|
||||
writeAscii = compareFiletypeVar("ascii");
|
||||
|
||||
if (!(fpState = fopen(fileName, (writeAscii ? "w" : "wb")))) {
|
||||
perror(fileName);
|
||||
} else {
|
||||
NBJTputHeader(fpState, ckt, inst);
|
||||
ONEprnSolution(fpState, inst->NBJTpDevice,
|
||||
model->NBJToutputs);
|
||||
model->NBJToutputs, writeAscii, "nbjt");
|
||||
fclose(fpState);
|
||||
LOGmakeEntry(fileName, description);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ NBJT2dump(GENmodel *inModel, CKTcircuit *ckt)
|
|||
char *prefix;
|
||||
int *state_num;
|
||||
int anyOutput = 0;
|
||||
BOOLEAN writeAscii = TRUE;
|
||||
|
||||
if (ckt->CKTmode & MODEDCOP) {
|
||||
prefix = "OP";
|
||||
|
|
@ -69,12 +70,15 @@ NBJT2dump(GENmodel *inModel, CKTcircuit *ckt)
|
|||
anyOutput = 1;
|
||||
sprintf(fileName, "%s%s.%d.%s", output->OUTProotFile, prefix,
|
||||
*state_num, inst->NBJT2name);
|
||||
if ((fpState = fopen(fileName, "wb")) == NULL) {
|
||||
|
||||
writeAscii = compareFiletypeVar("ascii");
|
||||
|
||||
if (!(fpState = fopen(fileName, (writeAscii ? "w" : "wb")))) {
|
||||
perror(fileName);
|
||||
} else {
|
||||
NBJT2putHeader(fpState, ckt, inst);
|
||||
TWOprnSolution(fpState, inst->NBJT2pDevice,
|
||||
model->NBJT2outputs);
|
||||
model->NBJT2outputs, writeAscii, "nbjt2");
|
||||
fclose(fpState);
|
||||
LOGmakeEntry(fileName, description);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ NUMDdump(GENmodel *inModel, CKTcircuit *ckt)
|
|||
char *prefix;
|
||||
int *state_num;
|
||||
int anyOutput = 0;
|
||||
BOOLEAN writeAscii = TRUE;
|
||||
|
||||
if (ckt->CKTmode & MODEDCOP) {
|
||||
prefix = "OP";
|
||||
|
|
@ -68,12 +69,15 @@ NUMDdump(GENmodel *inModel, CKTcircuit *ckt)
|
|||
anyOutput = 1;
|
||||
sprintf(fileName, "%s%s.%d.%s", output->OUTProotFile, prefix,
|
||||
*state_num, inst->NUMDname);
|
||||
if ((fpState = fopen(fileName, "wb")) == NULL) {
|
||||
|
||||
writeAscii = compareFiletypeVar("ascii");
|
||||
|
||||
if (!(fpState = fopen(fileName, (writeAscii ? "w" : "wb")))) {
|
||||
perror(fileName);
|
||||
} else {
|
||||
NUMDputHeader(fpState, ckt, inst);
|
||||
ONEprnSolution(fpState, inst->NUMDpDevice,
|
||||
model->NUMDoutputs);
|
||||
model->NUMDoutputs, writeAscii, "numd");
|
||||
fclose(fpState);
|
||||
LOGmakeEntry(fileName, description);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ NUMD2dump(GENmodel *inModel, CKTcircuit *ckt)
|
|||
char *prefix;
|
||||
int *state_num;
|
||||
int anyOutput = 0;
|
||||
BOOLEAN writeAscii = TRUE;
|
||||
|
||||
if (ckt->CKTmode & MODEDCOP) {
|
||||
prefix = "OP";
|
||||
|
|
@ -69,12 +70,15 @@ NUMD2dump(GENmodel *inModel, CKTcircuit *ckt)
|
|||
anyOutput = 1;
|
||||
sprintf(fileName, "%s%s.%d.%s", output->OUTProotFile, prefix,
|
||||
*state_num, inst->NUMD2name);
|
||||
if ((fpState = fopen(fileName, "wb")) == NULL) {
|
||||
|
||||
writeAscii = compareFiletypeVar("ascii");
|
||||
|
||||
if (!(fpState = fopen(fileName, (writeAscii ? "w" : "wb")))) {
|
||||
perror(fileName);
|
||||
} else {
|
||||
NUMD2putHeader(fpState, ckt, inst);
|
||||
TWOprnSolution(fpState, inst->NUMD2pDevice,
|
||||
model->NUMD2outputs);
|
||||
model->NUMD2outputs, writeAscii, "numd2");
|
||||
fclose(fpState);
|
||||
LOGmakeEntry(fileName, description);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ NUMOSdump(GENmodel *inModel, CKTcircuit *ckt)
|
|||
char *prefix;
|
||||
int *state_num;
|
||||
int anyOutput = 0;
|
||||
BOOLEAN writeAscii = TRUE;
|
||||
|
||||
if (ckt->CKTmode & MODEDCOP) {
|
||||
prefix = "OP";
|
||||
|
|
@ -69,12 +70,15 @@ NUMOSdump(GENmodel *inModel, CKTcircuit *ckt)
|
|||
anyOutput = 1;
|
||||
sprintf(fileName, "%s%s.%d.%s", output->OUTProotFile, prefix,
|
||||
*state_num, inst->NUMOSname);
|
||||
if ((fpState = fopen(fileName, "wb")) == NULL) {
|
||||
|
||||
writeAscii = compareFiletypeVar("ascii");
|
||||
|
||||
if (!(fpState = fopen(fileName, (writeAscii ? "w" : "wb")))) {
|
||||
perror(fileName);
|
||||
} else {
|
||||
NUMOSputHeader(fpState, ckt, inst);
|
||||
TWOprnSolution(fpState, inst->NUMOSpDevice,
|
||||
model->NUMOSoutputs);
|
||||
model->NUMOSoutputs, writeAscii, "numos");
|
||||
fclose(fpState);
|
||||
LOGmakeEntry(fileName, description);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue