/* spice.f -- translated by f2c (version of 3 February 1990  3:36:42).
   You must link the resulting object file with the libraries:
	-lF77 -lI77 -lm -lc   (in that order)
*/

#include "f2c.h"

/* Common Block Declarations */

struct {
    integer ielmnt, isbckt, nsbckt, iunsat, nunsat, itemps, numtem, isens, 
	    nsens, ifour, nfour, ifield, icode, idelim, icolum, insize, 
	    junode, lsbkpt, numbkp, iorder, jmnode, iur, iuc, ilc, ilr, 
	    numoff, isr, nmoffc, iseq, iseq1, neqn, nodevs, ndiag, iswap, 
	    iequa, macins, lvnim1, lx0, lvn, lynl, lyu, lyl, lx1, lx2, lx3, 
	    lx4, lx5, lx6, lx7, ld0, ld1, ltd, imynl, imvn, lcvn, nsnod, 
	    nsmat, nsval, icnod, icmat, icval, loutpt, lpol, lzer, irswpf, 
	    irswpr, icswpf, icswpr, irpt, jcpt, irowno, jcolno, nttbr, nttar, 
	    lvntmp;
} tabinf_;

#define tabinf_1 tabinf_

struct {
    doublereal atime, aprog[3], adate, atitle[10], defl, defw, defad, defas, 
	    rstats[50];
    integer iwidth, lwidth, nopage;
} miscel_;

#define miscel_1 miscel_

struct {
    doublereal achar, afield[15], oldlin[15];
    integer kntrc, kntlim;
} line_;

#define line_1 line_

struct {
    integer locate[50], jelcnt[50], nunods, ncnods, numnod, nstop, nut, nlt, 
	    nxtrm, ndist, ntlin, ibr, numvs, numalt, numcyc;
} cirdat_;

#define cirdat_1 cirdat_

struct {
    doublereal vto, beta, gamma, phi, phib, cox, xnsub, xnfs, xd, xj, xld, 
	    xlamda, uo, uexp, vbp, utra, vmax, xneff, xl, xw, vbi, von, vdsat,
	     qspof, beta0, beta1, cdrain, xqco, xqc, fnarrw, fshort;
    integer lev;
} mosarg_;

#define mosarg_1 mosarg_

struct {
    doublereal omega, time, delta, delold[7], ag[7], vt, xni, egfet, xmu, 
	    sfactr;
    integer mode, modedc, icalc, initf, method, iord, maxord, noncon, iterno, 
	    itemno, nosolv, modac, ipiv, ivmflg, ipostp, iscrch, iofile;
} status_;

#define status_1 status_

struct {
    integer iprnta, iprntl, iprntm, iprntn, iprnto, limtim, limpts, lvlcod, 
	    lvltim, itl1, itl2, itl3, itl4, itl5, itl6, igoof, nogo, keof;
} flags_;

#define flags_1 flags_

struct {
    doublereal twopi, xlog2, xlog10, root2, rad, boltz, charge, ctok, gmin, 
	    reltol, abstol, vntol, trtol, chgtol, eps0, epssil, epsox, pivtol,
	     pivrel;
} knstnt_;

#define knstnt_1 knstnt_

struct {
    doublereal cpyknt;
    integer istack[1], lorg, icore, maxcor, maxuse, memavl, ldval, numblk, 
	    loctab, ltab, ifwa, nwoff, ntab, maxmem, memerr, nwd4, nwd8, 
	    nwd16;
} memmgr_;

#define memmgr_1 memmgr_

struct {
    doublereal tcstar[2], tcstop[2], tcincr[2];
    integer icvflg, itcelm[2], kssop, kinel, kidin, kovar, kidout;
} dc_;

#define dc_1 dc_

struct {
    doublereal fstart, fstop, fincr, skw2, refprl, spw2;
    integer jacflg, idfreq, inoise, nosprt, nosout, nosin, idist, idprt;
} ac_;

#define ac_1 ac_

struct {
    doublereal tstep, tstop, tstart, delmax, tdmax, forfre;
    integer jtrflg;
} tran_;

#define tran_1 tran_

struct {
    doublereal xincr, string[15], xstart, yvar[8];
    integer itab[8], itype[8], ilogy[8], npoint, numout, kntr, numdgt;
} outinf_;

#define outinf_1 outinf_

struct {
    integer maxtim, itime, icost;
} cje_;

#define cje_1 cje_

struct {
    integer idebug[20];
} debug_;

#define debug_1 debug_

struct {
    doublereal value[200000];
} blank_;

#define blank_1 blank_

/* Table of constant values */

static integer c__50 = 50;
static integer c_n1 = -1;
static integer c__1 = 1;

/* spice version 2g.6  sccsid=root.ma 3/15/83 */
/*<       program spice >*/
/* Main program */ MAIN__()
{
    /* Initialized data */

    static struct {
	char e_1[8];
	doublereal e_2;
	} equiv_30 = { {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, 0. };

#define ablnk (*(doublereal *)&equiv_30)

    static struct {
	char e_1[32];
	doublereal e_2;
	} equiv_31 = { {'j', 'o', 'b', ' ', 's', 't', 'a', 't', 'i', 's', 't',
		 'i', 'c', 's', ' ', 's', 'u', 'm', 'm', 'a', 'r', 'y', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, 0. };

#define acctit ((doublereal *)&equiv_31)

    static struct {
	char e_1[8];
	doublereal e_2;
	} equiv_32 = { {' ', ' ', 's', 'p', 'i', 'c', 'e', ' '}, 0. };

#define ahdr1 (*(doublereal *)&equiv_32)

    static struct {
	char e_1[8];
	doublereal e_2;
	} equiv_33 = { {'2', 'g', '.', '6', ' ', ' ', ' ', ' '}, 0. };

#define ahdr2 (*(doublereal *)&equiv_33)

    static struct {
	char e_1[8];
	doublereal e_2;
	} equiv_34 = { {'3', '/', '1', '5', '/', '8', '3', ' '}, 0. };

#define ahdr3 (*(doublereal *)&equiv_34)


    /* Format strings */
    static char fmt_301[] = "(\0020\002,9x,\002***** job aborted\002)";
    static char fmt_306[] = "(\0020\002,9x,\002***** this parameter change i\
s illegal\002)";
    static char fmt_311[] = "(\0020\002,/,9x,\002job concluded\002)";
    static char fmt_361[] = "(\002   nunods ncnods numnod numel  diodes  bjt\
s  jfets  mfets\002//,i9,2i7,i6,i8,i6,2i7)";
    static char fmt_371[] = "(/\0020  numtem icvflg jtrflg jacflg inoise  id\
ist   nogo\002/,\0020 \002,7i7)";
    static char fmt_381[] = "(/\0020  nstop   nttbr   nttar   ifill    iops \
   perspa\002//,1x,5f8.0,f9.3)";
    static char fmt_391[] = "(/\0020  numttp  numrtp  numnit  maxmem  memuse\
  copyknt\002,//,2x,3f8.0,2x,i6,2x,i6,2x,f8.0)";
    static char fmt_401[] = "(/,\0020\002,9x,\002readin  \002,12x,f10.2/,\
\0020\002,9x,\002setup   \002,12x,f10.2/,\0020\002,9x,\002trcurv  \002,12x,f\
10.2,10x,f6.0/,\0020\002,9x,\002dcan    \002,12x,f10.2,10x,f6.0/,\0020\002,9\
x,\002dcdcmp  \002,12x,f10.3,10x,f6.0/,\0020\002,9x,\002dcsol   \002,12x,f10\
.3/,\0020\002,9x,\002acan    \002,12x,f10.2,10x,f6.0/,\0020\002,9x,\002trana\
n  \002,12x,f10.2,10x,f6.0/,\0020\002,9x,\002output  \002,12x,f10.2)";
    static char fmt_402[] = "(\0020\002,9x,\002load    \002,12x,f10.3/,\002\
0\002,9x,\002codgen  \002,12x,f10.3,10x,f6.0/,\0020\002,9x,\002codexc  \002,\
12x,f10.3/,\0020\002,9x,\002macins  \002,12x,f10.3)";
    static char fmt_801[] = "(\0020\002,9x,\002overhead\002,12x,f10.2)";
    static char fmt_811[] = "(\0020\002,9x,\002total job time      \002,f10.\
2)";
    static char fmt_901[] = "(\0021warning:  further analysis stopped due to\
 cpu time limit\002/)";
    static char fmt_1001[] = "(/1x,\002input deck (file) contains no data\
.\002)";

    /* System generated locals */
    integer i_1;

    /* Builtin functions */
    double atan2(), log(), sqrt();
    integer s_wsfe(), e_wsfe(), do_fio();
    /* Subroutine */ int s_stop();

    /* Local variables */
    extern /* Subroutine */ int acan_(), dcop_();
    static doublereal time1, time2;
    extern /* Subroutine */ int zero8_();
    static integer i;
    static doublereal ohead;
    extern integer iargc_();
    extern /* Subroutine */ int xtime_(), xdate_(), setup_(), alter_();
    static integer numel;
    extern /* Subroutine */ int title_();
    static doublereal tcost;
    static integer icost1;
    static doublereal et;
    extern /* Subroutine */ int getcje_();
#define nodplc ((integer *)&blank_1)
#define cvalue ((complex *)&blank_1)
    extern integer iopraw_();
    static integer nodata;
    extern /* Subroutine */ int second_(), setmem_(), readin_(), errchk_(), 
	    tmpupd_(), dctran_(), ovtpvt_();

    /* Fortran I/O blocks */
    static cilist io__11 = { 0, 0, 0, fmt_301, 0 };
    static cilist io__12 = { 0, 0, 0, fmt_306, 0 };
    static cilist io__13 = { 0, 0, 0, fmt_311, 0 };
    static cilist io__16 = { 0, 0, 0, fmt_361, 0 };
    static cilist io__17 = { 0, 0, 0, fmt_371, 0 };
    static cilist io__18 = { 0, 0, 0, fmt_381, 0 };
    static cilist io__19 = { 0, 0, 0, fmt_391, 0 };
    static cilist io__20 = { 0, 0, 0, fmt_401, 0 };
    static cilist io__21 = { 0, 0, 0, fmt_402, 0 };
    static cilist io__26 = { 0, 0, 0, fmt_801, 0 };
    static cilist io__27 = { 0, 0, 0, fmt_811, 0 };
    static cilist io__28 = { 0, 0, 0, fmt_901, 0 };
    static cilist io__29 = { 0, 0, 0, fmt_1001, 0 };


/* ...  cray notes: */
/* .. change data filnam to 5lspice */
/* .. change call overlay .. remove last zero */
/* .. change ??????program to subroutine in all but this overlay */
/* .. delete overlay spice,0,0 card below */
/* .. */
/*<       implicit double precision (a-h,o-z) >*/


/* spice version 2g.6  sccsid=root.ma 3/15/83 */

/*     spice is an electronic circuit simulation program that was deve- */

/* loped by the integrated circuits group of the electronics research */
/* laboratory and the department of electrical engineering and computer */

/* sciences at the university of california, berkeley, california.  the */

/* program spice is available free of charge to any interested party. */
/* the sale, resale, or use of this program for profit without the */
/* express written consent of the department of electrical engineering */
/* and computer sciences, university of california, berkeley, california, 
*/
/* is forbidden. */


/*     the present version is based on the spice2 program versions 2e.3 */

/* and 2f.1 developed at the university of california berkeley and the */
/* hewlett-packard spice version 2.7. */
/*     this version is designed to be transportable on most computers */
/* with an ansi fortran compiler and enough memory space for code and */
/* data. the memory manager uses the function 'locf' to find the */
/* address of a pointer; this function must be provided. */


/* implementation notes: */

/*     subroutines mclock and mdate return the time (as hh:mm:ss) and */
/* the date (as dd mmm yy), respectively.  subroutine getcje returns in */

/* common block /cje/ various attributes of the current job environment. 
*/
/* spice expects getcje to set /cje/ variables maxtim, itime, and icost. 
*/
/* maxtim is the maximum cpu time in seconds, itime is the elapsed cpu */
/* time in seconds, and icost is the job cost in cents. */
/* subroutine memory is used to change the number of memory words */
/* allocated to spice.  if the amount of memory allocated to a jobstep */
/* is fixed, subroutine memory need not be changed. */
/*     subroutine second(t) returns the time in seconds and is used */
/* for timing purposes. it must be provided where not available. */
/*     ifamwa (set in a data statement below) should be set to the */
/* address of the first available word of memory (following overlays, if 
*/
/* any).  the proper value should be easily obtainable from any load map. 
*/
/* ifamwa is used only on computers where the program (spice) can change 
*/
/* the allocated memory dynamically at run time according to circuit 
size. */
/* (see also comments under subroutine setmem). */
/*     all berkeley spice2.f release versions do not implement the ifamwa 
*/
/* feature due to its dependence on operating system. */
/*     with the exception of most flags, all data in spice are stored in 
*/
/* the form of managed tables allocated in the /blank/ array value(). */
/* array value() can be redimensioned in the main program according to */
/* memory availability at each user site. it should be noted again that */

/* the program dynamically manages its data within the bounds of array */
/* value(). */
/*     the vax release versions assume the virtual memory feature and */
/* dimension value() to 200,000 double precision words. */
/*     the cdc and ibm versions dimension value() to 20000 real or */
/* real*8 words, respectively. */
/*     spice is particularly well-suited to being run using a one-level */

/* overlay structure beginning with routines spice (the overlay root), */
/* readin, errchk, setup, dctran, dcop, acan, and ovtpvt.  the order of */

/* the routines in this listing corresponds to that structure.  note */
/* that if cdc explicit overlaying is to be used, an overlay directive */
/* card must be inserted before the first line of each of the just-named 
*/
/* routines. */


/* spice version 2g.6  sccsid=tabinf 3/15/83 */
/*<       common /tabinf/ ielmnt,isbckt,nsbckt,iunsat,nunsat,itemps,numtem, >*/
/*<      1   isens,nsens,ifour,nfour,ifield,icode,idelim,icolum,insize, >*/
/*<      2   junode,lsbkpt,numbkp,iorder,jmnode,iur,iuc,ilc,ilr,numoff,isr, >*/
/*<      3   nmoffc,iseq,iseq1,neqn,nodevs,ndiag,iswap,iequa,macins,lvnim1, >*/
/*<      4   lx0,lvn,lynl,lyu,lyl,lx1,lx2,lx3,lx4,lx5,lx6,lx7,ld0,ld1,ltd, >*/
/*<      5   imynl,imvn,lcvn,nsnod,nsmat,nsval,icnod,icmat,icval, >*/
/*<      6   loutpt,lpol,lzer,irswpf,irswpr,icswpf,icswpr,irpt,jcpt, >*/
/*<      7   irowno,jcolno,nttbr,nttar,lvntmp >*/
/* spice version 2g.6  sccsid=miscel 3/15/83 */
/*<       common /miscel/ atime,aprog(3),adate,atitle(10),defl,defw,defad, >*/
/*<      1  defas,rstats(50),iwidth,lwidth,nopage >*/
/* spice version 2g.6  sccsid=line 3/15/83 */
/*<       common /line/ achar,afield(15),oldlin(15),kntrc,kntlim >*/
/* spice version 2g.6  sccsid=cirdat 3/15/83 */
/*<       common /cirdat/ locate(50),jelcnt(50),nunods,ncnods,numnod,nstop, >*/
/*<      1   nut,nlt,nxtrm,ndist,ntlin,ibr,numvs,numalt,numcyc >*/
/* spice version 2g.6  sccsid=mosarg 3/15/83 */
/*<       common /mosarg/ vto,beta,gamma,phi,phib,cox,xnsub,xnfs,xd,xj,xld, >*/
/*<      1   xlamda,uo,uexp,vbp,utra,vmax,xneff,xl,xw,vbi,von,vdsat,qspof, >*/
/*<      2   beta0,beta1,cdrain,xqco,xqc,fnarrw,fshort,lev >*/
/* spice version 2g.6  sccsid=status 3/15/83 */
/*<       common /status/ omega,time,delta,delold(7),ag(7),vt,xni,egfet, >*/
/*<      1   xmu,sfactr,mode,modedc,icalc,initf,method,iord,maxord,noncon, >*/
/*<      2   iterno,itemno,nosolv,modac,ipiv,ivmflg,ipostp,iscrch,iofile >*/
/* spice version 2g.6  sccsid=flags 3/15/83 */
/*<       common /flags/ iprnta,iprntl,iprntm,iprntn,iprnto,limtim,limpts, >*/
/*<      1   lvlcod,lvltim,itl1,itl2,itl3,itl4,itl5,itl6,igoof,nogo,keof >*/
/* spice version 2g.6  sccsid=knstnt 3/15/83 */
/*<       common /knstnt/ twopi,xlog2,xlog10,root2,rad,boltz,charge,ctok, >*/
/*<      1   gmin,reltol,abstol,vntol,trtol,chgtol,eps0,epssil,epsox, >*/
/*<      2   pivtol,pivrel >*/
/* spice version 2g.6  sccsid=memmgr 3/15/83 */
/*<       common /memmgr/ cpyknt,istack(1),lorg,icore,maxcor,maxuse,memavl, >*/
/*<      1   ldval,numblk,loctab,ltab,ifwa,nwoff,ntab,maxmem,memerr,nwd4, >*/
/*<      2   nwd8,nwd16 >*/
/* spice version 2g.6  sccsid=dc 3/15/83 */
/*<       common /dc/ tcstar(2),tcstop(2),tcincr(2),icvflg,itcelm(2),kssop, >*/
/*<      1   kinel,kidin,kovar,kidout >*/
/* spice version 2g.6  sccsid=ac 3/15/83 */
/*<       common /ac/ fstart,fstop,fincr,skw2,refprl,spw2,jacflg,idfreq, >*/
/*<      1   inoise,nosprt,nosout,nosin,idist,idprt >*/
/* spice version 2g.6  sccsid=tran 3/15/83 */
/*<       common /tran/ tstep,tstop,tstart,delmax,tdmax,forfre,jtrflg >*/
/* spice version 2g.6  sccsid=outinf 3/15/83 */
/*<       common /outinf/ xincr,string(15),xstart,yvar(8),itab(8),itype(8), >*/
/*<      1   ilogy(8),npoint,numout,kntr,numdgt >*/
/* spice version 2g.6  sccsid=cje 3/15/83 */
/*<       common /cje/ maxtim,itime,icost >*/
/* spice version 2g.6  sccsid=debug 3/15/83 */
/*<       common/debug/ idebug(20) >*/
/* spice version 2g.6  sccsid=blank 3/15/83 */
/*<       common /blank/ value(200000) >*/
/*<       integer nodplc(64) >*/
/*<       complex cvalue(32) >*/
/*<       equivalence (value(1),nodplc(1),cvalue(1)) >*/



/*<       dimension acctit(4) >*/
/*<       dimension remain(4) >*/
/*<       data ablnk /1h  / >*/
/*<       data acctit / 8hjob stat, 8histics s, 8hummary  , 8h         / >*/
/*<       data ahdr1,ahdr2,ahdr3 / 8h  spice ,8h2g.6    ,8h3/15/83     / >*/


/*<       ipostp=0 >*/
    status_1.ipostp = 0;
/*     check if a raw data file should be written */
/*     open file if so required */
/*<       if  (iargc().gt.0) ipostp=iopraw() >*/
    if (iargc_() > 0) {
	status_1.ipostp = iopraw_();
    }
/*<       maxmem=2*200000 >*/
    memmgr_1.maxmem = 400000;
/*<       maxtim=1e8 >*/
    cje_1.maxtim = (float)1e8;
/*<       icost=0 >*/
    cje_1.icost = 0;
/*<       iofile=6 >*/
    status_1.iofile = 6;

/*  initialization */

/*<       aprog(1)=ahdr1 >*/
    miscel_1.aprog[0] = ahdr1;
/*<       aprog(2)=ahdr2 >*/
    miscel_1.aprog[1] = ahdr2;
/*<       aprog(3)=ahdr3 >*/
    miscel_1.aprog[2] = ahdr3;
/*<       achar=ablnk >*/
    line_1.achar = ablnk;
/*<       keof=0 >*/
    flags_1.keof = 0;
/*<       call xtime(atime) >*/
    xtime_(&miscel_1.atime);
/*<       call xdate(adate) >*/
    xdate_(&miscel_1.adate);
/*<       boltz=1.3806226d-23 >*/
    knstnt_1.boltz = 1.3806226e-23;
/*<       charge=1.6021918d-19 >*/
    knstnt_1.charge = 1.6021918e-19;
/*<       ctok=273.15d0 >*/
    knstnt_1.ctok = 273.15;
/*<       eps0=8.854214871d-12 >*/
    knstnt_1.eps0 = 8.854214871e-12;
/*<       epssil=11.7d0*eps0 >*/
    knstnt_1.epssil = knstnt_1.eps0 * 11.7;
/*<       epsox=3.9d0*eps0 >*/
    knstnt_1.epsox = knstnt_1.eps0 * 3.9;
/*<       twopi=8.0d0*datan2(1.0d0,1.0d0) >*/
    knstnt_1.twopi = atan2(1., 1.) * 8.;
/*<       rad=360.0d0/twopi >*/
    knstnt_1.rad = 360. / knstnt_1.twopi;
/*<       xlog2=dlog(2.0d0) >*/
    knstnt_1.xlog2 = log(2.);
/*<       xlog10=dlog(10.0d0) >*/
    knstnt_1.xlog10 = log(10.);
/*<       root2=dsqrt(2.0d0) >*/
    knstnt_1.root2 = sqrt(2.);
/*<       nodata=1 >*/
    nodata = 1;

/*  begin job */

/*<    10 if (keof.eq.1) go to 1000 >*/
L10:
    if (flags_1.keof == 1) {
	goto L1000;
    }
/*<       call getcje >*/
    getcje_();
/*<       call second(time1) >*/
    second_(&time1);
/*<       icost1=icost >*/
    icost1 = cje_1.icost;
/*<       igoof=0 >*/
    flags_1.igoof = 0;
/*<       mode=0 >*/
    status_1.mode = 0;
/*<       nogo=0 >*/
    flags_1.nogo = 0;
/*<       call setmem(nodplc(1),maxmem) >*/
    setmem_(nodplc, &memmgr_1.maxmem);
/*<       if (nogo.ne.0) go to 1000 >*/
    if (flags_1.nogo != 0) {
	goto L1000;
    }
/*<       call zero8(rstats,50) >*/
    zero8_(miscel_1.rstats, &c__50);

/*  read remainder of data deck and check for input errors */

/*<       call readin >*/
    readin_();
/*<       if (nogo.ne.0) go to 300 >*/
    if (flags_1.nogo != 0) {
	goto L300;
    }
/*<       if (keof.eq.1) go to 1000 >*/
    if (flags_1.keof == 1) {
	goto L1000;
    }
/*<       nodata=0 >*/
    nodata = 0;
/*<    50 call errchk >*/
/* L50: */
    errchk_();
/*<       if (nogo.ne.0) go to 300 >*/
    if (flags_1.nogo != 0) {
	goto L300;
    }
/*<       call setup >*/
    setup_();
/*<       if (nogo.ne.0) go to 300 >*/
    if (flags_1.nogo != 0) {
	goto L300;
    }

/*  change parameters and re-analisis */

/*<       if (numcyc.eq.0) go to 90 >*/
    if (cirdat_1.numcyc == 0) {
	goto L90;
    }
/*<    70 if (numcyc.ge.numalt) go to 310 >*/
L70:
    if (cirdat_1.numcyc >= cirdat_1.numalt) {
	goto L310;
    }
/*<       numcyc=numcyc+1 >*/
    ++cirdat_1.numcyc;
/*<       call alter >*/
    alter_();
/*<       if (nogo.ne.0) go to 305 >*/
    if (flags_1.nogo != 0) {
	goto L305;
    }

/*  cycle through temperatures */

/*<    90 itemno=1 >*/
L90:
    status_1.itemno = 1;
/*<       if (numtem.eq.1) go to 110 >*/
    if (tabinf_1.numtem == 1) {
	goto L110;
    }
/*<   100 if (itemno.eq.numtem) go to 70 >*/
L100:
    if (status_1.itemno == tabinf_1.numtem) {
	goto L70;
    }
/*<       itemno=itemno+1 >*/
    ++status_1.itemno;
/*<       call tmpupd >*/
    tmpupd_();

/*  dc transfer curves */

/*<   110 if (icvflg.eq.0) go to 150 >*/
L110:
    if (dc_1.icvflg == 0) {
	goto L150;
    }
/* ...  see routine *dctran* for explanation of *mode*, etc. */
/*<       mode=1 >*/
    status_1.mode = 1;
/*<       modedc=3 >*/
    status_1.modedc = 3;
/*<       call dctran >*/
    dctran_();
/*<       call ovtpvt >*/
    ovtpvt_();
/*<       if (nogo.ne.0) go to 300 >*/
    if (flags_1.nogo != 0) {
	goto L300;
    }

/*  small signal operating point */

/*<   150 if (kssop.gt.0) go to 170 >*/
L150:
    if (dc_1.kssop > 0) {
	goto L170;
    }
/*<       if (jacflg.ne.0) go to 170 >*/
    if (ac_1.jacflg != 0) {
	goto L170;
    }
/*<       if ((icvflg+jtrflg).gt.0) go to 250 >*/
    if (dc_1.icvflg + tran_1.jtrflg > 0) {
	goto L250;
    }
/*<   170 mode=1 >*/
L170:
    status_1.mode = 1;
/*<       modedc=1 >*/
    status_1.modedc = 1;
/*<       call dctran >*/
    dctran_();
/*<       if (nogo.ne.0) go to 300 >*/
    if (flags_1.nogo != 0) {
	goto L300;
    }
/*<       call dcop >*/
    dcop_();
/*<       if (nogo.ne.0) go to 300 >*/
    if (flags_1.nogo != 0) {
	goto L300;
    }

/*  ac small signal analysis */

/*<   200 if (jacflg.eq.0) go to 250 >*/
/* L200: */
    if (ac_1.jacflg == 0) {
	goto L250;
    }
/*<       mode=3 >*/
    status_1.mode = 3;
/*<       call acan >*/
    acan_();
/*<       call ovtpvt >*/
    ovtpvt_();
/*<       if (nogo.ne.0) go to 300 >*/
    if (flags_1.nogo != 0) {
	goto L300;
    }

/*  transient analysis */

/*<   250 if (jtrflg.eq.0) go to 100 >*/
L250:
    if (tran_1.jtrflg == 0) {
	goto L100;
    }
/*<       mode=1 >*/
    status_1.mode = 1;
/*<       modedc=2 >*/
    status_1.modedc = 2;
/*<       call dctran >*/
    dctran_();
/*<       if (nogo.ne.0) go to 300 >*/
    if (flags_1.nogo != 0) {
	goto L300;
    }
/*<       call dcop >*/
    dcop_();
/*<       if (nogo.ne.0) go to 300 >*/
    if (flags_1.nogo != 0) {
	goto L300;
    }
/*<       mode=2 >*/
    status_1.mode = 2;
/*<       call dctran >*/
    dctran_();
/*<       call ovtpvt >*/
    ovtpvt_();
/*<       if (nogo.ne.0) go to 300 >*/
    if (flags_1.nogo != 0) {
	goto L300;
    }
/*<       go to 100 >*/
    goto L100;

/*  job concluded */

/*<   300 write (iofile,301) >*/
L300:
    io__11.ciunit = status_1.iofile;
    s_wsfe(&io__11);
    e_wsfe();
/*<   301 format(1h0,9x,'***** job aborted') >*/
/*<       nodata=0 >*/
    nodata = 0;
/*<       go to 320 >*/
    goto L320;
/*<   305 write (iofile,306) >*/
L305:
    io__12.ciunit = status_1.iofile;
    s_wsfe(&io__12);
    e_wsfe();
/*<   306 format (1h0,9x,'***** this parameter change is illegal') >*/
/*<   310 write (iofile,311) >*/
L310:
    io__13.ciunit = status_1.iofile;
    s_wsfe(&io__13);
    e_wsfe();
/*<   311 format(1h0,/,9x,'job concluded') >*/

/*  job accounting */

/*<   320 continue >*/
L320:
/*<       numel=0 >*/
    numel = 0;
/*<       do 360 i=1,18 >*/
    for (i = 1; i <= 18; ++i) {
/*<   360 numel=numel+jelcnt(i) >*/
/* L360: */
	numel += cirdat_1.jelcnt[i - 1];
    }
/*<       numtem=max0(numtem-1,1) >*/
/* Computing MAX */
    i_1 = tabinf_1.numtem - 1;
    tabinf_1.numtem = max(1,i_1);
/*<       idist=min0(idist,1) >*/
    ac_1.idist = min(ac_1.idist,1);
/*<       if (iprnta.eq.0) go to 800 >*/
    if (flags_1.iprnta == 0) {
	goto L800;
    }
/*<       call title(-1,lwidth,1,acctit) >*/
    title_(&c_n1, &miscel_1.lwidth, &c__1, acctit);
/*<       write (iofile,361) nunods,ncnods,numnod,numel,(jelcnt(i),i=11,14) >*/
    io__16.ciunit = status_1.iofile;
    s_wsfe(&io__16);
    do_fio(&c__1, (char *)&cirdat_1.nunods, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&cirdat_1.ncnods, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&cirdat_1.numnod, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&numel, (ftnlen)sizeof(integer));
    for (i = 11; i <= 14; ++i) {
	do_fio(&c__1, (char *)&cirdat_1.jelcnt[i - 1], (ftnlen)sizeof(integer)
		);
    }
    e_wsfe();
/*<   361 format('   nunods ncnods numnod numel  diodes  bjts  jfets  mfets' >*/
/*<      1   //,i9,2i7,i6,i8,i6,2i7) >*/
/*<       write (iofile,371) numtem,icvflg,jtrflg,jacflg,inoise,idist,nogo >*/
    io__17.ciunit = status_1.iofile;
    s_wsfe(&io__17);
    do_fio(&c__1, (char *)&tabinf_1.numtem, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&dc_1.icvflg, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&tran_1.jtrflg, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&ac_1.jacflg, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&ac_1.inoise, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&ac_1.idist, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&flags_1.nogo, (ftnlen)sizeof(integer));
    e_wsfe();
/*<   371 format(/'0  numtem icvflg jtrflg jacflg inoise  idist   nogo'/, >*/
/*<      1   2h0 ,7i7) >*/
/*<       write (iofile,381) rstats(20),rstats(21),rstats(22),rstats(23), >*/
/*<      1   rstats(26),rstats(27) >*/
    io__18.ciunit = status_1.iofile;
    s_wsfe(&io__18);
    do_fio(&c__1, (char *)&miscel_1.rstats[19], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&miscel_1.rstats[20], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&miscel_1.rstats[21], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&miscel_1.rstats[22], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&miscel_1.rstats[25], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&miscel_1.rstats[26], (ftnlen)sizeof(doublereal));
    e_wsfe();
/*<   381 format(/'0  nstop   nttbr   nttar   ifill    iops    perspa'//, >*/
/*<      1   1x,5f8.0,f9.3) >*/
/*<       write (iofile,391) rstats(30),rstats(31),rstats(32),maxmem,maxuse, >*/
/*<      1   cpyknt >*/
    io__19.ciunit = status_1.iofile;
    s_wsfe(&io__19);
    do_fio(&c__1, (char *)&miscel_1.rstats[29], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&miscel_1.rstats[30], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&miscel_1.rstats[31], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&memmgr_1.maxmem, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&memmgr_1.maxuse, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&memmgr_1.cpyknt, (ftnlen)sizeof(doublereal));
    e_wsfe();
/*<   391 format(/'0  numttp  numrtp  numnit  maxmem  memuse  copyknt',//, >*/
/*<      1   2x,3f8.0,2x,i6,2x,i6,2x,f8.0) >*/
/*<       write (iofile,401) (rstats(i),i=1,6),rstats(50),rstats(49), >*/
/*<      1   rstats(46),(rstats(i),i=7,11) >*/
    io__20.ciunit = status_1.iofile;
    s_wsfe(&io__20);
    for (i = 1; i <= 6; ++i) {
	do_fio(&c__1, (char *)&miscel_1.rstats[i - 1], (ftnlen)sizeof(
		doublereal));
    }
    do_fio(&c__1, (char *)&miscel_1.rstats[49], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&miscel_1.rstats[48], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&miscel_1.rstats[45], (ftnlen)sizeof(doublereal));
    for (i = 7; i <= 11; ++i) {
	do_fio(&c__1, (char *)&miscel_1.rstats[i - 1], (ftnlen)sizeof(
		doublereal));
    }
    e_wsfe();
/*<   401 format(/, >*/
/*<      1   1h0,9x,'readin  ',12x,f10.2/, >*/
/*<      2   1h0,9x,'setup   ',12x,f10.2/, >*/
/*<      3   1h0,9x,'trcurv  ',12x,f10.2,10x,f6.0/, >*/
/*<      4   1h0,9x,'dcan    ',12x,f10.2,10x,f6.0/, >*/
/*<      5   1h0,9x,'dcdcmp  ',12x,f10.3,10x,f6.0/, >*/
/*<      6   1h0,9x,'dcsol   ',12x,f10.3/, >*/
/*<      7   1h0,9x,'acan    ',12x,f10.2,10x,f6.0/, >*/
/*<      8   1h0,9x,'tranan  ',12x,f10.2,10x,f6.0/, >*/
/*<      9   1h0,9x,'output  ',12x,f10.2) >*/
/*<       write (iofile,402) rstats(45),rstats(48),rstats(47),rstats(44), >*/
/*<      1   rstats(43) >*/
    io__21.ciunit = status_1.iofile;
    s_wsfe(&io__21);
    do_fio(&c__1, (char *)&miscel_1.rstats[44], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&miscel_1.rstats[47], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&miscel_1.rstats[46], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&miscel_1.rstats[43], (ftnlen)sizeof(doublereal));
    do_fio(&c__1, (char *)&miscel_1.rstats[42], (ftnlen)sizeof(doublereal));
    e_wsfe();
/*<   402 format( >*/
/*<      1   1h0,9x,'load    ',12x,f10.3/, >*/
/*<      2   1h0,9x,'codgen  ',12x,f10.3,10x,f6.0/, >*/
/*<      3   1h0,9x,'codexc  ',12x,f10.3/, >*/
/*<      4   1h0,9x,'macins  ',12x,f10.3) >*/
/*<   800 call getcje >*/
L800:
    getcje_();
/*<       call second(time2) >*/
    second_(&time2);
/*<       et=time2-time1 >*/
    et = time2 - time1;
/*<       tcost=dble(icost-icost1)/100.0d0 >*/
    tcost = (doublereal) (cje_1.icost - icost1) / 100.;
/*<       if (iprnta.eq.0) go to 810 >*/
    if (flags_1.iprnta == 0) {
	goto L810;
    }
/*<       ohead=et-(rstats(1)+rstats(2)+rstats(3)+rstats(5)+rstats(7) >*/
/*<      1   +rstats(9)+rstats(11)) >*/
    ohead = et - (miscel_1.rstats[0] + miscel_1.rstats[1] + miscel_1.rstats[2]
	     + miscel_1.rstats[4] + miscel_1.rstats[6] + miscel_1.rstats[8] + 
	    miscel_1.rstats[10]);
/*<       write (iofile,801) ohead >*/
    io__26.ciunit = status_1.iofile;
    s_wsfe(&io__26);
    do_fio(&c__1, (char *)&ohead, (ftnlen)sizeof(doublereal));
    e_wsfe();
/*<   801 format(1h0,9x,'overhead',12x,f10.2) >*/
/*<   810 write (iofile,811) et >*/
L810:
    io__27.ciunit = status_1.iofile;
    s_wsfe(&io__27);
    do_fio(&c__1, (char *)&et, (ftnlen)sizeof(doublereal));
    e_wsfe();
/*<   811 format(1h0,9x,'total job time      ',f10.2) >*/
/*<       rstats(33)=cpyknt >*/
    miscel_1.rstats[32] = memmgr_1.cpyknt;
/*<       rstats(34)=et >*/
    miscel_1.rstats[33] = et;
/*<       rstats(35)=tcost >*/
    miscel_1.rstats[34] = tcost;
/*<       rstats(36)=ohead >*/
    miscel_1.rstats[35] = ohead;
/*<   900 if ((maxtim-itime).ge.limtim) go to 10 >*/
/* L900: */
    if (cje_1.maxtim - cje_1.itime >= flags_1.limtim) {
	goto L10;
    }
/*<       write (iofile,901) >*/
    io__28.ciunit = status_1.iofile;
    s_wsfe(&io__28);
    e_wsfe();
/*<   901 format('1warning:  further analysis stopped due to cpu time limit' >*/
/*<      1/) >*/
/*<  1000 if(nodata.ne.0) write(iofile,1001) >*/
L1000:
    if (nodata != 0) {
	io__29.ciunit = status_1.iofile;
	s_wsfe(&io__29);
	e_wsfe();
    }
/*<  1001 format(/1x,'input deck (file) contains no data.') >*/
/*<       stop >*/
    s_stop("", 0L);
/*<       end >*/
} /* MAIN__ */

#undef cvalue
#undef nodplc
#undef ahdr3
#undef ahdr2
#undef ahdr1
#undef acctit
#undef ablnk


/* Main program alias */ int spice_ () { MAIN__ (); }
