From dff212c630410fcbd5fa93e9889c8f18cf76b80b Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 29 Jan 2023 11:51:15 +0100 Subject: [PATCH 1/2] Preliminary bug-617 fix: Don't set temperature to a step beyond the sweep boundaries. --- src/spicelib/analysis/dctrcurv.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/spicelib/analysis/dctrcurv.c b/src/spicelib/analysis/dctrcurv.c index 996e907c7..2f53734c9 100644 --- a/src/spicelib/analysis/dctrcurv.c +++ b/src/spicelib/analysis/dctrcurv.c @@ -465,6 +465,17 @@ DCtrCurv(CKTcircuit *ckt, int restart) DEVices[rcode]->DEVload(job->TRCVvElt[i]->GENmodPtr, ckt); } else if (job->TRCVvType[i] == TEMP_CODE) { /* temperature */ ckt->CKTtemp += job->TRCVvStep[i]; + + /* FIXME: Do the Temp check already here for the first time. + If the stop criterion is fulfilled, discard Temp evaluation, because + CKTtemp may report errors if a large extra Temp step is exercized. */ + if (SGN(job->TRCVvStep[i]) * + ((ckt->CKTtemp - CONSTCtoK) - job->TRCVvStop[i]) > DBL_EPSILON * 1e+03) { +// ckt->CKTtemp -= job->TRCVvStep[i]; // Undo the large step +// ckt->CKTtemp += SGN(job->TRCVvStep[i]) * DBL_EPSILON * 2e+03; // Add just a small step + continue; // Skip model evaluation + } + inp_evaluate_temper(ft_curckt); CKTtemp(ckt); } From 2d936f1e8fb09bc4055a57feb0bb844d14631b85 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 30 Jan 2023 10:56:03 +0100 Subject: [PATCH 2/2] In the ngspice shared library the fcn ivers is called with a NULL argument. The fix safeguards against argv0 being NULL. In this case Spice_Exec_Path is set to NULL, it is safeguarded against NULL when being used. --- src/misc/ivars.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/misc/ivars.c b/src/misc/ivars.c index 51263a200..ce5446982 100644 --- a/src/misc/ivars.c +++ b/src/misc/ivars.c @@ -105,19 +105,23 @@ ivars(char *argv0) AsciiRawFile = atoi(temp); /* path of the ngspice executable */ - Spice_Exec_Path = copy(argv0); - /* find the last occurence of "ngspice" in Spice_Exec_Path */ - char* path_end = strstr(Spice_Exec_Path, "ngspice"); - if (path_end) { - char* exec_only = strstr(path_end + 7, "ngspice"); - while (exec_only) { - path_end = strstr(exec_only, "ngspice"); + if (argv0) { + Spice_Exec_Path = copy(argv0); + /* find the last occurence of "ngspice" in Spice_Exec_Path */ + char* path_end = strstr(Spice_Exec_Path, "ngspice"); + if (path_end) { + char* exec_only = strstr(path_end + 7, "ngspice"); + while (exec_only) { + path_end = strstr(exec_only, "ngspice"); + if (path_end) + exec_only = strstr(path_end + 7, "ngspice"); + } if (path_end) - exec_only = strstr(path_end + 7, "ngspice"); + *path_end = '\0'; } - if (path_end) - *path_end = '\0'; } + else + Spice_Exec_Path = NULL; } void