Menu

#72 Printing hidden errors to terminal

open-accepted
Ouch! (1)
2
2022-03-27
2020-01-10
No

Hi!
I've had a problem when I've made little mistake using cm_event_queue().
I've called model in time == TIME and time < TIME.
There was no warning or errors in terminal.
So,
How about printing errors from file cmevt.c ?

change this :

    /* If breakpoint time <= current event time, return error */
    if(time <= g_mif_info.circuit.evt_step) {
        g_mif_info.errmsg =
        "ERROR - cm_event_queue() - Event time cannot be <= current time\n";
        return(MIF_ERROR);
    }

to this:

    /* If breakpoint time <= current event time, return error */
    if(time <= g_mif_info.circuit.evt_step) {
        g_mif_info.errmsg =
        "ERROR - cm_event_queue() - Event time cannot be <= current time\n;
        printf("ERROR - cm_event_queue() - Event time cannot be <= current time\nInstance: %s\n", g_mif_info.instance->MIFname);
        return(MIF_ERROR);
    }

Maybe, it makes sense to print other hidden errors? Especially in debug mode.


Thanks,
Bohdan

Discussion

  • Bohdan Tkhir

    Bohdan Tkhir - 2020-01-10

    By the way.
    Generic xspice adc_bridge. It switches between ANALOG and EVENT by making cm_event_queue(current_time).
    Isn't it an error?

    V_SRC vdd 0 DC 0 SIN (0 1 10)
    A_ADC [vdd] [events] ADC
        .model ADC adc_bridge(in_low=0.5 in_high=0.5)
    .control
    tran 1 1
    run
    plot events
    .endc
    

    Console output after printing errors:

    Initial Transient Solution
    
    Node                                   Voltage
    ----                                   -------
    vdd                                          0
    v_src#branch                                 0
    
    ERROR - cm_event_queue() - Event time cannot be <= current time
    Instance: a_adc
    ERROR - cm_event_queue() - Event time cannot be <= current time
    Instance: a_adc
    ERROR - cm_event_queue() - Event time cannot be <= current time
    Instance: a_adc
    ......
    
     
    • marcel hendrix

      marcel hendrix - 2020-01-10

      I don't see anything out of the order (with ngspice-29).
      There are two events for each positive sinewave half, as expected.
      (Making in_low and in_high slightly different doesn't change this).

      ngspice 1 -> eprint events
      
      **** Results Data ****
      
      Time or Step
      events
      
      
      0.000000000e+00     0s
      1.280000100e-02     1s
      4.560000100e-02     0s
      1.256000010e-01     1s
      1.456000010e-01     0s
      2.256000010e-01     1s
      2.456000010e-01     0s
      3.256000010e-01     1s
      3.456000010e-01     0s
      4.256000010e-01     1s
      4.456000010e-01     0s
      5.256000010e-01     1s
      5.456000010e-01     0s
      6.256000010e-01     1s
      6.456000010e-01     0s
      7.256000010e-01     1s
      7.456000010e-01     0s
      8.256000010e-01     1s
      8.456000010e-01     0s
      9.256000010e-01     1s
      9.456000010e-01     0s
      
      
      
      **** Messages ****
      
      
      **** Statistics ****
      
      Operating point analog/event alternations:  1
      Operating point load calls:                 2
      Operating point event passes:               2
      Transient analysis load calls:              58
      Transient analysis timestep backups:        0
      

      -marcel

       
      • Bohdan Tkhir

        Bohdan Tkhir - 2020-01-10

        Hi, Marcel!
        It will work , but there will be hidden errors in g_mif_info structure.
        It's not about in_low or in_high.
        Did you change cmevt.c as described in main message?( It requires rebuild of ngspice )
        Just now checked on 31+ (pre-master ):

        ERROR - cm_event_queue() - Event time cannot be <= current time
        Instance: a_adc
        

        It is caused by next lines of generic adc_bridge:

         /* call for event breakpoint... */
         current_time = TIME;
         cm_event_queue(current_time);
        

        It means that we are calling model in time == TIME , which is an error in order to cmevt.c:244-249

         

        Last edit: Bohdan Tkhir 2020-01-10
    • marcel hendrix

      marcel hendrix - 2020-01-10

      On 2020-01-10 09:46, Bohdan Tkhir wrote:

      By the way.
      Generic xspice adc_bridge. It switches between ANALOG and EVENT by
      making cm_event_queue(current_time).
      Isn't it an error?
      ~~~
      V_SRC vdd 0 DC 0 SIN (0 1 10)
      A_ADC [vdd] [events] ADC
      .model ADC adc_bridge(in_low=0.5 in_high=0.5)
      .control
      tran 1 1
      run
      plot events
      .endc
      ~~~

      Did you intentionally make in_low == in_high to provoke this error?

      -marcel

       
      • Bohdan Tkhir

        Bohdan Tkhir - 2020-01-10

        No, It's not about in_low == in_high, you can set anything you want
        (Replied to this question extensively in comment above).

         
  • Giles Atkinson

    Giles Atkinson - 2022-03-02
    • status: open --> open-accepted
    • assigned_to: Giles Atkinson
     
  • Giles Atkinson

    Giles Atkinson - 2022-03-02

    Here is an error reporting mechanism that never reports an error.

     
  • Giles Atkinson

    Giles Atkinson - 2022-03-02

    cm_event_queue(current_time);
    ... is almost certainly correct, as far as I understand it. So that probably should be '<', not '<=".

     
  • Giles Atkinson

    Giles Atkinson - 2022-03-27
    • labels: --> Ouch!
    • Priority: 5 --> 2
     
  • Giles Atkinson

    Giles Atkinson - 2022-03-27

    Raising priority as it has just cost me hours of debugging time. Needs fixing, but is it limited to XSPICE? Check for use of macros in inpmacs.h.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.