In some situations it may be desirable to share circuit and analysis across multiple backends. Examples are cross verification, benchmarking, pointing out differences, or demonstrate problems.

Gnucap provides a mechanism that can be used to share batch files with other spice implementations more easily. Consider the following spice input.

spice

I1 1 0 1
R1 1 0 1

*>.print dc v(1)
.dc
*>.end
.print dc v(1)

The key concept here is the “anticomment”: Spice normally ignores all lines starting with “*”. Gnucap in spice mode does not ignore lines starting with *>.

With this, the input above runs with either gnucap, gnucap -b and ngpice -b, performing a similar simulation with similar results.

As you may have noticed, post-punchcard file formats often define preprocessor conditionals. Typical contenders for comparisons such as ngspice do not support any of these.