Scripts can be written to automate a large number of runs on a circuit, saving the output in a sequence of rawfiles. Typically this is done in the background, using WRspice in batch or server modes. This section addresses some of the subtleties of using these modes.
A pure script file, i.e., one which does not include a circuit description, consists of an unread ``title'' line, followed by a control block. The control block begins with a ``.control'' line, continues with one or more executable statements, and terminates with a ``.endc'' line. In WRspice, an ``.exec'' line can be used rather than the .control line, though for backward compatibility with SPICE3, it is recommended that the traditional .control be used. The executable statements are any statements understandable to the WRspice shell. Typically, such statements appear just as they would be entered on the command line if given as text input. Scripts can call other scripts to any depth.
Before a script is read, the variables argc and argv are set to the number of words on the command line, and a list of those words respectively. Their previous values (if any) are pushed onto a stack, and popped back in place when the script terminates. Thus, within a command script, these predefined variables are available for use in the script.
If WRspice is run with the -b flag, it will process the circuit in batch mode, similar to SPICE2. The files are input on the command line, and if no files are listed, the standard input is read. Most of the control lines recognized by SPICE2 will be handled, including .plot, .print, and .four. The output will be a margin analysis file if a margin run is input, otherwise if the -r option is used (-r rawfilename), a rawfile is produced. Otherwise, output is sent to the standard output, in the form of ascii plots and print output as directed by .plot/.print lines. The format of this output is somewhat different from SPICE2, however, and much less information is available from an operating point analysis. Some SPICE2 options are not supported.
Server mode is similar to batch mode, however input is taken only from the standard input, and output is exclusively to the standard output. The output is either in rawfile or margin analysis format, and inappropriate command line options such as -r, -b are ignored.
In server mode, lines in a control file such as
.controlwill generate raw output (on stdout). The same lines in batch mode will produce nothing, unless followed by a write rawfilename line. Similarly, a run rawfilename will perform the analysis in the circuit (not the control) file, and create rawfilename in batch mode. In server mode, the output is to stdout, and rawfilename is ignored. In a control file, run will generate raw data on stdout in server mode, but will do nothing in batch mode unless followed by a write command. This is true whether or not the -r option is used in invoking WRspice. However, if the input file is a circuit file, and there are .plot/.print lines, if -r is not given, the ascii plots and prints will be generated on stdout in batch mode.
cktfile
tran 1p 100p
...
Examples: