Add '.save nosub' to suppress storing the node vectors from inside

of subcircuits.

Saves a lot of memeory if using devices with subcircuit models,
and one is not interested in the inner workings of the device model.
This commit is contained in:
Holger Vogt 2024-05-24 17:38:30 +02:00
parent 02a5cd5ea6
commit 252ca65f56
2 changed files with 13 additions and 13 deletions

View File

@ -65,30 +65,22 @@ settrace(wordlist *wl, int what, char *name)
char *s = cp_unquote(wl->wl_word); char *s = cp_unquote(wl->wl_word);
char *db_nodename1 = NULL; char *db_nodename1 = NULL;
char db_type = 0; char db_type = 0;
if (eq(s, "all")) { if (eq(s, "all") || eq(s, "nosub")) {
switch (what) { switch (what) {
case VF_PRINT: case VF_PRINT:
db_type = DB_TRACEALL; db_type = DB_TRACEALL;
break; break;
/* case VF_PLOT:
db_type = DB_IPLOTALL;
break; */
case VF_ACCUM: case VF_ACCUM:
/* db_type = DB_SAVEALL; */
db_nodename1 = copy(s); db_nodename1 = copy(s);
db_type = DB_SAVE; db_type = DB_SAVE;
break; break;
} }
tfree(s); tfree(s);
/* wrd_chtrace(NULL, TRUE, what); */
} else { } else {
switch (what) { switch (what) {
case VF_PRINT: case VF_PRINT:
db_type = DB_TRACENODE; db_type = DB_TRACENODE;
break; break;
/* case VF_PLOT:
db_type = DB_IPLOT;
break; */
case VF_ACCUM: case VF_ACCUM:
db_type = DB_SAVE; db_type = DB_SAVE;
break; break;
@ -98,7 +90,6 @@ settrace(wordlist *wl, int what, char *name)
tfree(s); tfree(s);
if (!db_nodename1) /* skip on error */ if (!db_nodename1) /* skip on error */
continue; continue;
/* wrd_chtrace(s, TRUE, what); */
} }
/* Don't save a nodename more than once */ /* Don't save a nodename more than once */

View File

@ -143,6 +143,7 @@ beginPlot(JOB *analysisPtr, CKTcircuit *circuitPtr, char *cktName, char *analNam
char *ch, tmpname[BSIZE_SP]; char *ch, tmpname[BSIZE_SP];
bool saveall = TRUE; bool saveall = TRUE;
bool savealli = FALSE; bool savealli = FALSE;
bool savenosub = FALSE;
char *an_name; char *an_name;
int initmem; int initmem;
/*to resume a run saj /*to resume a run saj
@ -213,6 +214,13 @@ beginPlot(JOB *analysisPtr, CKTcircuit *circuitPtr, char *cktName, char *analNam
saves[i].used = 1; saves[i].used = 1;
continue; continue;
} }
if (cieq(saves[i].name, "nosub")) {
savenosub = TRUE;
savesused[i] = TRUE;
saves[i].used = 1;
continue;
}
#ifdef SHARED_MODULE #ifdef SHARED_MODULE
/* this may happen if shared ngspice*/ /* this may happen if shared ngspice*/
if (cieq(saves[i].name, "none")) { if (cieq(saves[i].name, "none")) {
@ -226,7 +234,7 @@ beginPlot(JOB *analysisPtr, CKTcircuit *circuitPtr, char *cktName, char *analNam
} }
} }
if (numsaves && !saveall) if (numsaves && !saveall && !savenosub)
initmem = numsaves; initmem = numsaves;
else else
initmem = numNames; initmem = numNames;
@ -245,7 +253,7 @@ beginPlot(JOB *analysisPtr, CKTcircuit *circuitPtr, char *cktName, char *analNam
/* Pass 1. */ /* Pass 1. */
if (numsaves && !saveall) { if (numsaves && !saveall && !savenosub) {
for (i = 0; i < numsaves; i++) { for (i = 0; i < numsaves; i++) {
if (!savesused[i]) { if (!savesused[i]) {
for (j = 0; j < numNames; j++) { for (j = 0; j < numNames; j++) {
@ -269,7 +277,8 @@ beginPlot(JOB *analysisPtr, CKTcircuit *circuitPtr, char *cktName, char *analNam
for (i = 0; i < numNames; i++) for (i = 0; i < numNames; i++)
if (!refName || !name_eq(dataNames[i], refName)) if (!refName || !name_eq(dataNames[i], refName))
/* Save the node as long as it's not an internal device node */ /* Save the node as long as it's not an internal device node */
if (!strstr(dataNames[i], "#internal") && if (!(savenosub && strchr(dataNames[i], '.')) && /* don't save subckt nodes */
!strstr(dataNames[i], "#internal") &&
!strstr(dataNames[i], "#source") && !strstr(dataNames[i], "#source") &&
!strstr(dataNames[i], "#drain") && !strstr(dataNames[i], "#drain") &&
!strstr(dataNames[i], "#collector") && !strstr(dataNames[i], "#collector") &&