From e84c2108762054d693ade806bc5123ac44c628bc Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Wed, 1 Sep 2021 12:26:49 +0200 Subject: [PATCH] 'Option interp' and command 'stop' have been incompatible. Allow both in a run. Issue note (however not checked) that stop time data have to fit the inpolated times. --- src/frontend/breakp.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/frontend/breakp.c b/src/frontend/breakp.c index a7b1bc398..f420a938a 100644 --- a/src/frontend/breakp.c +++ b/src/frontend/breakp.c @@ -24,6 +24,7 @@ static void printcond(struct dbcomm *d, FILE *fp); static int howmanysteps = 0; static int steps = 0; +static bool interpolated = FALSE; /* Set a breakpoint. Possible commands are: @@ -42,6 +43,14 @@ com_stop(wordlist *wl) return; } + /* Check to see if we have to consider interpolated data. */ + if (cp_getvar("interp", CP_BOOL, NULL, 0)) { + interpolated = TRUE; + fprintf(cp_out, "Note: Stop condition has to fit the interpolated time data!\n\n"); + } + else + interpolated = FALSE; + struct dbcomm *thisone = NULL; struct dbcomm *d = NULL; char *s, buf[64]; @@ -469,6 +478,7 @@ satisfied(struct dbcomm *d, struct plot *plot) { struct dvec *v1 = NULL, *v2 = NULL; double d1, d2; + static double laststoptime = 0.; if (d->db_nodename1) { if ((v1 = vec_fromplot(d->db_nodename1, plot)) == NULL) { @@ -496,13 +506,22 @@ satisfied(struct dbcomm *d, struct plot *plot) d2 = v2->v_realdata[v2->v_length - 1]; else d2 = realpart((v2->v_compdata[v2->v_length - 1])); + /* option interp: no new time step since last stop */ + } else if (interpolated && AlmostEqualUlps(d1, laststoptime, 3)){ + d2 = 0.; } else { d2 = d->db_value2; } switch (d->db_op) { case DBC_EQU: - return (AlmostEqualUlps(d1, d2, 3) ? TRUE : FALSE); + { + bool hit = AlmostEqualUlps(d1, d2, 3) ? TRUE : FALSE; + /* option interp: save the last stop time */ + if (interpolated && hit) + laststoptime = d1; + return hit; + } // return ((d1 == d2) ? TRUE : FALSE); case DBC_NEQ: return ((d1 != d2) ? TRUE : FALSE);