C function called once, but run 3 times, what could be the cause?

Hi,
In the function call, I print the time follow the function being called immediately,

function(t);
Display("%f", t);

It prints,

t=0.000008,
t=0.020010,
t=0.040010,
t=0.060010,
t=0.080010,

I pass the time to the function() being called, and print the time out using printf(), it output,

t=0.000008,
t=0.000008,
t=0.020010,
t=0.020010,
t=0.040010,
t=0.040010,
t=0.040010,
t=0.060010,
t=0.060010,
t=0.060010,
t=0.080010,
t=0.080010,
t=0.080010,

The function() is called in one place only in the QSpice C++ module. And there is no loop inside function() so it should print info only once per call.

I wonder what could trigger this behaviour? It’s the most weird one I can’t understand and no idea how to debug. Not sure if there’s mechanism in QSpice that may cause this?

Thanks so much.
Weifu

Hi, Weifu.

I’m guessing that you have a Trunc() function in your code. By default, Trunc() calls the evaluation function for hypothetical evaluations. Display() suppresses output during those hypothetical evaluations. printf() does not. Change printf() to Display() or remove Trunc() if not needed.

–robert

1 Like

You are my savior! After commenting out Trunc() function it works immediately. I happend to find your great github QSpice repo that you mentioned the interpretation of Trunc function in the CBlock_Doc. I’ll give it a good read. Thank you sir.

If you include Trunc() and use fprintf() or printf(), here is a reference for you. Just as @RDunn replied, use Display() instead if you just need a return in the output window.

2 Likes

Hi, Kelvin.

I think that you could use the recently added ForKeeps variable and eliminate the LiveEval instance data member. Simplifies the code a bit.

–robert

1 Like

I didn’t fully understand the *ForKeeps until your reminder. Yes, Forkeeps variable should eliminate the LiveEval instance data member.

1 Like