Trying to get ngspice working on Fedora

Now that Fedora has the requisite libraries, I’m trying to get ngspice working. It compiled fine, but when I try to run the first example from, I get the following:

push: stackp: 0 -> 1
Circuit: KiCad schematic
pop: stackp: 1 -> 0
calling getcommand run
Initial parse : [ run ]
After history substitution : [ run ]
After alias substitution : [ run ]
Returning  : [ run ]
getcommand run
docommand run
After variable substitution : [ run ]
After backquote substitution : [ run ]
After globbing : [ run ]
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
 Reference value :  1.00000e+00
No. of Data Rows : 51
Warning - approaching max data size: current size =  612.805 MB, limit =  292.078 MB

I have created the .spiceinit file, and it contains:

* user provided init file
set ngbehavior=ps
set debug

Does anyone know how to increase the data size limit? Or is there perhaps something else wrong?

BTW, I also tried the example from the demo directory “demos/simulation/pspice” but it gave the same error.


I saved the netlist from the simple example I’ve been running:

.title KiCad schematic
V101 in 0 PULSE (0 5 1u 1u 1u 1 1)
C101 Net-_C101-Pad1_ 0 1u
C102 out 0 100n
R101 Net-_C101-Pad1_ in 10k
R102 out Net-_C101-Pad1_ 1k
.save @v101[i]
.save @c101[i]
.save @c102[i]
.save @r101[i]
.save @r102[i]
.save V(0)
.save V(GND)
.save V(Net-_C101-Pad1_)
.save V(in)
.save V(out)
.tran 1u 100m

When I run this circuit in stand-alone ngspice, it works without producing any warnings or errors. Interestingly, ngspice does a lot of overprinting, apparently to indicate the run-time of the job. Here is a small example of the character stream, where there are tons of backspaces as part of the overprinting:

saf$ od -c foo
0000000   %   0   .   0   0  \b  \b  \b  \b  \b   %   0   .   0   0  \b
0000020  \b  \b  \b  \b   %   0   .   0   0  \b  \b  \b  \b  \b   %   0
0000040   .   0   0  \b  \b  \b  \n

The captured output from this simple circuit is around 1 Mbyte!

Is there a way to tell the library not to produce all this text?

Let’s see if maybe @holger can shed some light on this situation

You are receiving a lot of debug output. Don’t use
set debug
in .spiceinit. This has been for developers only to hunt bugs. I never use this (because there are no more bugs :wink: ). Sometimes it may be o.k. to use
set ngdebug

1 Like

I took the debug line out completely. So now I just have:

$ cat .spiceinit 
* user provided init file
set ngbehavior=ps

However, I still get all of the “percent complete” status printed in the lower half of the ngspice window, and KiCad still crashes if I try to select that text.

The library is apparently sending over 1 megabyte of “percent complete” status to KiCad, including tons of backspaces. I think this should be suppressed, or KiCad should be made more tolerant of all this data.

Also, it looks really bad, as you can see near the bottom of this screen shot:

Forgot to mention, that I also still see the warning about the “max data size” even after removing the debug line.

Unfortunately there is no switch in ngspice to simply suppress the output. The code is supposed to send a ref value approximately every 250ms realtime. The caller (eeschema) has to handle this string. The string ends with a \r that allows to overprint the previous value in a console output. Multiple \b are strange, not yet any idea.

The memory warning stems from a different piece of code. The simple circuit should not use up 612 MB.

Could you post your eeschema file, and somebody with KiCad on another Linux help us by running the same simulation example, just to check if this is a Fedora specific issue? I am not using KiCad on Linux, so cannot act immediately.

I will do a test on Linux with your netlist and the ngspice library on Linux over the weekend.

Seems to be a Fedora ngspice problem. ngspice has been built with outdated or risky configure flags. Here the flag --enable-ndev is the problem. The ngspice manual explicitely states that this one belongs to the risky, outdated flags.

I will contact the Fedora packager.

Update: email sent

1 Like

In addition I will add a flag
.option norefvalue
to ngspice to allow users to suppress such outputs.

Update: A patch is uploaded to the ngspice pre-master branch.

1 Like

Thanks for taking a look at the problem.

I have placed the KiCad project that shows the problem here:

I guess someone on the KiCad team will have to change the --enable-ndev flag.

If I understand correctly, your patch .option norefvalue will be in the ngspice library, so we will have to wait for that library to be updated in Fedora. Is that correct? Should I contact the Fedora maintainer of ngspice and ask that the library be updated?

This is an ngspice flag. Thus this the task of the Fedora ngspice maintainer. I have already contacted him and submitted my request.

This will be available only in the next ngspice release (no fixed date available, probably mid of 2019). If this is too late, one has to download and compile ngspice himself. The tarball of the pre-master branch is available at, button ‘Download snapshot’, compile instructions are given in the ngspice manual, chapt. 32.

Got it. So we can probably expect the --enable-ndev flag to be removed in a few weeks, and that should fix the excessive memory use problem.

But the “ref value” suppression probably won’t be available for roughly 6 months or so, unless the Fedora maintainer is willing to apply your patch sooner.

@holger I may be slightly confused, but removing the --enable-ndev build flag, is that functionally equivalent to the runtime norefvalue option?

When I look at the patch in

It looks like it does the same. I didn’t look beyond the patch, so maybe I am missing some context, but I figured you would be able to tell.

I ask here because of my question on

removing the --enable-ndev is necessary for several reasons.

It will disable the strange ndev status output. It will also disable some code that has not been used for 10 years or so and may have led to other crashes in the past, and is not maintained any more. This is a must!

Whwn done so, we still have the ‘reference value’ output that is a short string sent out every 0.25 seconds or so to show the simulation status. This has been with shared ngspice since its beginning. In a short example this would mean that only a few strings are sent via printf over the ngspice interface. This has never been a problem up to now.

Setting norefvalue will disable the strange ndev status output (if --enable-ndev is still there) and also the ‘reference value’ output. But I guess that this is not really required for the current problem.

In addition there is a fresh bug report that the memory check (issuing the memory warning) has a bug. I have just tested it with Cygwin, and there it is o.k.

Is the fresh bug report about the memory check the same one I reported above, or is it a separate bug report? If it is separate, can I read about it somewhere?

I guess I misunderstood you earlier, because I thought you were saying that removing --enable-ndev would correct the “Warning - approaching max data size” message that I had reported. If that is not the case, then we still need to correct the maxdata warning.

Installed ngspice from the tarball you specified in debian linux.
Here is my circuit:
Here is the result from running test 1:

Not sure what the error message means.
This is my first time running ngspice on linux, so maybe I forgot something. Will have another look at this tomorrow.
Does the warning at the bottom look familiar?

The warning message is a bug and can be ignored. It will be removed in the next ngspice release.

I simply will remove this warning from the shared ngspice library. It stems from the old times when you sat in front of the console, typing commands, and reaching the memory limit of your machine. In an automated system, in a dll this is more or less useless. The caller has to take care of watching the memory. It seems to be too complex to figure out how to always get the correct numbers under all use cases and OSs.

The error messages are caused by the space between number and unit. You should type 1u and 100n.

Ok, now it makes sense. We can tell people to ignore the memory warning, perhaps by mentioning it in the next set of release notes. And once a new ngspice library is integrated, with @holger’s change, then the memory warning will disappear.

That just leaves the ref string issue, which causes a KiCad crash if you try to select that text. While that issue would be fixed by removing the --enable-ndev flag and/or by adding the .option norefvalue flag, I wonder if we could fix it sooner, by adding some filtering in KiCad to discard the ref string.

@nickoe - do you know if KiCad could filter the text in the lower half of the simulation window? If so, we could discard the huge (megabyte+) ref string by filtering out any string containing % signs and backspaces. That should solve the crash problem.