The write command is used to save simulation data to a file.
write [-a] [-w] [-f filename] [expr ...]If -a is given, the output is appended to the output file if it exists. When -w is given and the appendwrite variable is set, output will overwrite an existing output file. The output file is specified with the -f option in the token that follows. These options and the filename must occur ahead of the list of expressions to plot. If no -f is given, the first unrecognized token found is taken as the output file name.
There are three data formats universally available, the ``rawfile'' format native to WRspice and other simulators based on Berkeley SPICE3, the comma separated variable (CSV) format, and the Common Simulation Data Format (CSDF). The CSDF is obsolete, but was once supported by HSPICE and WaveView, and is retained for backward compatibility. Currently, WaveView supports the rawfile format, so CSDF is not required to use WaveView.
In the CentOS 7 and 8 releases, a third output format is available: the Cadence PSF format. This support is provided through third-party libraries which support only the indicated operating systems. Unlike the other formats, PSF output can not be read back into WRspice. This format is used by the waveform viewer component of the Cadence Analog Design Environment (ADE) product.
PSF output consists of files created in a specified directory. Presently, output is available only for AC, DC, transient, and operating-point analysis. Only simple analysis is supported, no chained DC or looping.
To specify PSF output, one gives a ``filename'', for example to the write command or the rawfile variable, in the form
psf[@path]
If this is simply ``psf'', output goes to a directory named psf in the current directory. Otherwise, the psf keyword can be followed by a `@' character and a path to a directory, with no white space around the @. Output will go to the indicated directory. In either case, the directory will be created if it doesn't exist, but in the second case and parent directories must currently exist, they won't be created.
If the file name is given an extension from among those listed below, CSDF output will be generated. Otherwise, rawfile format will be used. NOTE: CSDF is obsolete and is no longer supported by HSPICE or WaveView.
.csdfThe N is an integer, and tr, ac, and sw correspond to transient, ac, and dc sweep results, respectively. This is the same convention as used by HSPICE when generating files for post-processing.
.trN
.acN
.swN
A .csv extension will specify a CSV file.
If no expr is given, then all vectors in the current plot will be written, the same as giving the word ``all'' as an expr. If, in addition, no file name is given, a default name will be used. The default name is the value of the rawfile variable if set, or the argument to the -r command line option if one was given, or ``rawspice.raw''.
The command writes out the exprs to the file. First, vectors are grouped together by plots, and written out as such. For example, if the expression list contained three vectors from one plot and two from another, then two plots will be written, one with three vectors and one with two. Additionally, if the scale for a vector isn't present, it is automatically written out as well.
The default rawfile format is ASCII, but this may be changed with the filetype variable or the SPICE_ASCIIRAWFILE environment variable.
If the appendwrite variable is set, the data will be appended to an existing file.
Files that have been appended to, or have multiple plots, are concatenations of data for a single plot. This is expected and perfectly legitimate for rawfiles, and for CSV and CSDF files used only by WRspice, but concatenated CSDF files may not be portable to other applications.