From 46c5a8d375fdf6e3b878ad75a2857f371d7c153b Mon Sep 17 00:00:00 2001 From: Giles Atkinson <“gatk555@gmail.com”> Date: Sat, 29 Mar 2025 14:20:52 +0000 Subject: [PATCH] Fix for an error message seen when testing the shx shared-library program: do not allow a negative timestep. --- src/sharedspice.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sharedspice.c b/src/sharedspice.c index 059e4a3e2..5049fd12a 100644 --- a/src/sharedspice.c +++ b/src/sharedspice.c @@ -2471,8 +2471,14 @@ sharedsync(double *pckttime, double *pcktdelta, double olddelta, double finalt, step if return value from getsync is 1. */ int retval = getsync(*pckttime, pcktdelta, olddelta, redostep, ng_ident, loc, userptr); /* never move beyond final time */ - if (*pckttime + *pcktdelta > finalt) - *pcktdelta = finalt - *pckttime - 1.1 * delmin; + if (*pckttime + *pcktdelta > finalt) { + double newdelta; + + newdelta = finalt - *pckttime - 1.1 * delmin; + if (newdelta <= 0.0) + newdelta = finalt - *pckttime; + *pcktdelta = newdelta; + } /* user has decided to redo the step, ignoring redostep being set to 0 by ngspice. */