2 # ngspice2genspic - Copyright 2004 Ian Jackson - see below
4 # Reads the output from ngspice and outputs a `genspic' file
5 # for use with genspic2gnuplot. Takes no arguments or options.
9 # Only frequency (.AC) and transient plots have been tested.
11 # Displaying voltages and currents on the same .TRAN graph won't work
12 # well because they currently have to have the same Y scale.
14 # This whole scheme is very clumsy. There should be a driver program
15 # with command-line option parsing.
17 # This program and its documentation are free software; you can
18 # redistribute them and/or modify them under the terms of the GNU
19 # General Public License as published by the Free Software Foundation;
20 # either version 3, or (at your option) any later version.
22 # This program and its documentation are distributed in the hope that
23 # they will be useful, but WITHOUT ANY WARRANTY; without even the
24 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
25 # PURPOSE. See the GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License along
28 # with this program; if not, consult the Free Software Foundation's
29 # website at www.fsf.org, or the GNU Project website at www.gnu.org.
37 } elsif (m/^Current dynamic memory/ ||
38 m/^Dynamic memory limit/ ||
39 m/^Level not specified/ ||
46 } elsif (!m/\S/ && $mode eq InitTransSkip) {
48 } elsif (m/^Initial Transient/ && $mode eq '') {
50 } elsif (m/^Node/ && $mode eq InitTrans) {
52 } elsif (m/\w/ && $mode eq InitTransSkip) {
53 } elsif (m/^\-\-/ && length $mode) {
54 } elsif (m/^\s\s+(\w+) Analysis /) {
62 } elsif (m/^\s\s+/ && ($mode eq Table or !length $mode)) {
63 } elsif (m/^Index / && $mode eq Table) {
65 ($index,$key,@nowheadings) = split /\s+/, $_;
66 $logxy= 0+($key eq 'frequency');
67 } elsif (m/^\d+\s/ && $mode eq Table) {
68 ($index,$key,@nowcolumns) = split /\s+/, $_;
69 shift @nowcolumns if $key =~ s/\,$//;
70 $coldata[$index] .= " $key" if $dokey;
71 $coldata[$index] .= " @nowcolumns";
73 foreach $c (@nowheadings) {
75 $h= 'y2' if $c =~ m/^ph\(/;
76 push @columns, "$h:$c";
79 } elsif (!m/\S/ && $mode eq Table) {
80 print "S $ctable $logxy @columns\n" or die $!;
81 foreach $l (@coldata) { printf "D%s\n", $l or die $!; }
82 print "T\n" or die $!;
87 $mode= '' if $mode eq InitTransSkip;
92 die "no plots" unless defined $ctable;
93 print "F\n" or die $!;
95 # $Id: ngspice2genspic,v 1.3 2007-09-21 21:21:15 ianmdlvl Exp $