From ee9578055fe734b7917a70d3c5d1cb3f6089e3c1 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 6 Jul 2026 10:39:49 +0200 Subject: [PATCH] If stricterrorhandling is set, ngspice detects the dangling capacitors and resioiostors, lists them and then bails out. --- src/spicelib/analysis/cktsetup.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/spicelib/analysis/cktsetup.c b/src/spicelib/analysis/cktsetup.c index b3829ab79..99e9fe4a0 100644 --- a/src/spicelib/analysis/cktsetup.c +++ b/src/spicelib/analysis/cktsetup.c @@ -134,7 +134,13 @@ CKTtopologyReduce(CKTcircuit *ckt) else if (nn > 0) degree[nn]--; removed_this_pass++; - if (reported++ < 40) + if (ft_stricterror) { + fprintf(stderr, + "Dangling capacitor %s " + "(floating node %s) found in netlist.\n", ci->CAPname, + (char*)CKTnodName(ckt, (mode & 2) ? nn : pn)); + } + else if (reported++ < 40) fprintf(stdout, "Topology reduction: removed dangling capacitor %s " "(floating node %s)\n", ci->CAPname, @@ -165,11 +171,17 @@ CKTtopologyReduce(CKTcircuit *ckt) else if (nn > 0) degree[nn]--; removed_this_pass++; - if (reported++ < 40) + if (ft_stricterror) { + fprintf(stderr, + "Dangling resistor %s " + "(floating node %s) found in netlist.\n", ri->RESname, + (char*)CKTnodName(ckt, (mode & 2) ? nn : pn)); + } + else if (reported++ < 40) fprintf(stdout, "Topology reduction: removed dangling resistor %s " "(floating node %s)\n", ri->RESname, - (char *)CKTnodName(ckt, (mode & 2) ? nn : pn)); + (char*)CKTnodName(ckt, (mode & 2) ? nn : pn)); } } @@ -178,9 +190,17 @@ CKTtopologyReduce(CKTcircuit *ckt) break; } - if (removed_total) + if (removed_total) { + if (ft_stricterror) { + fprintf(stderr, "\nError: %d dangling passive(s) found.\n " + " Please correct the netlist.\n", removed_total); + FREE(degree); + controlled_exit(EXIT_BAD); + } + fprintf(stdout, "Topology reduction: %d dangling passive(s) removed " - "from the matrix.\n", removed_total); + "from the matrix.\n", removed_total); + } FREE(degree); }