/* setup.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 {
    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 atime, aprog[3], adate, atitle[10], defl, defw, defad, defas, 
	    rstats[50];
    integer iwidth, lwidth, nopage;
} miscel_;

#define miscel_1 miscel_

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 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 value[200000];
} blank_;

#define blank_1 blank_

/* spice version 2g.6  sccsid=setup.ma 3/15/83 */
/*<       subroutine setup >*/
/* Subroutine */ int setup_()
{
    /* System generated locals */
    integer i_1;

    /* Local variables */
    static integer node;
    extern /* Subroutine */ int getm4_();
    static integer i;
    static doublereal t1;
    extern integer indxx_();
    static doublereal t2;
#define nodplc ((integer *)&blank_1)
#define cvalue ((complex *)&blank_1)
    extern logical memptr_();
    extern /* Subroutine */ int second_(), clrmem_(), matptr_(), reordr_(), 
	    matloc_(), sizmem_();
    static integer nic, loc;

/*<       implicit double precision (a-h,o-z) >*/

/*     this routine drives the sparse matrix setup used by spice. */

/* 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=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=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=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=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=blank 3/15/83 */
/*<       common /blank/ value(200000) >*/
/*<       integer nodplc(64) >*/
/*<       complex cvalue(32) >*/
/*<       equivalence (value(1),nodplc(1),cvalue(1)) >*/

/*<       logical memptr >*/

/*<       call second(t1) >*/
    second_(&t1);
/*<       nstop=numnod+jelcnt(3)+jelcnt(6)+jelcnt(8)+jelcnt(9)+2*jelcnt(17) >*/
    cirdat_1.nstop = cirdat_1.numnod + cirdat_1.jelcnt[2] + cirdat_1.jelcnt[5]
	     + cirdat_1.jelcnt[7] + cirdat_1.jelcnt[8] + (cirdat_1.jelcnt[16] 
	    << 1);

/*     clear old tables */

/*<       if (memptr(irpt)) call clrmem(irpt) >*/
    if (memptr_(&tabinf_1.irpt)) {
	clrmem_(&tabinf_1.irpt);
    }
/*<       if (memptr(jcpt)) call clrmem(jcpt) >*/
    if (memptr_(&tabinf_1.jcpt)) {
	clrmem_(&tabinf_1.jcpt);
    }
/*<       if (memptr(irowno)) call clrmem(irowno) >*/
    if (memptr_(&tabinf_1.irowno)) {
	clrmem_(&tabinf_1.irowno);
    }
/*<       if (memptr(jcolno)) call clrmem(jcolno) >*/
    if (memptr_(&tabinf_1.jcolno)) {
	clrmem_(&tabinf_1.jcolno);
    }

/*  reserve matrix locations for each element */

/*<       call matptr >*/
    matptr_();
/*<       if (nogo.ne.0) go to 1000 >*/
    if (flags_1.nogo != 0) {
	goto L1000;
    }

/*  reorder matrix pointers */

/*<       nttbr=0 >*/
    tabinf_1.nttbr = 0;
/*<       do 120 i=2,nstop >*/
    i_1 = cirdat_1.nstop;
    for (i = 2; i <= i_1; ++i) {
/*<       loc=i >*/
	loc = i;
/*<   110 if (nodplc(jcpt+loc).eq.0) go to 120 >*/
L110:
	if (nodplc[tabinf_1.jcpt + loc - 1] == 0) {
	    goto L120;
	}
/*<       loc=nodplc(jcpt+loc) >*/
	loc = nodplc[tabinf_1.jcpt + loc - 1];
/*<       nttbr=nttbr+1 >*/
	++tabinf_1.nttbr;
/*<       go to 110 >*/
	goto L110;
/*<   120 continue >*/
L120:
    ;}
/* ...  add ground */
/*<       nttar=nttbr >*/
    tabinf_1.nttar = tabinf_1.nttbr;
/*<       call reordr >*/
    reordr_();
/*<       if (nogo.ne.0) go to 1000 >*/
    if (flags_1.nogo != 0) {
	goto L1000;
    }

/*  store matrix locations */

/*<       call matloc >*/
    matloc_();

/*  .nodeset */

/*<   200 call sizmem(nsnod,nic) >*/
/* L200: */
    sizmem_(&tabinf_1.nsnod, &nic);
/*<       if(nic.eq.0) go to 220 >*/
    if (nic == 0) {
	goto L220;
    }
/*<       call getm4(nsmat,nic) >*/
    getm4_(&tabinf_1.nsmat, &nic);
/*<       do 210 i=1,nic >*/
    i_1 = nic;
    for (i = 1; i <= i_1; ++i) {
/*<       node=nodplc(nsnod+i) >*/
	node = nodplc[tabinf_1.nsnod + i - 1];
/*<       nodplc(nsmat+i)=indxx(node,node) >*/
	nodplc[tabinf_1.nsmat + i - 1] = indxx_(&node, &node);
/*<   210 continue >*/
/* L210: */
    }

/*  transient initial conditions */

/*<   220 call sizmem(icnod,nic) >*/
L220:
    sizmem_(&tabinf_1.icnod, &nic);
/*<       if(nic.eq.0) go to 300 >*/
    if (nic == 0) {
	goto L300;
    }
/*<       call getm4(icmat,nic) >*/
    getm4_(&tabinf_1.icmat, &nic);
/*<       do 230 i=1,nic >*/
    i_1 = nic;
    for (i = 1; i <= i_1; ++i) {
/*<       node=nodplc(icnod+i) >*/
	node = nodplc[tabinf_1.icnod + i - 1];
/*<       nodplc(icmat+i)=indxx(node,node) >*/
	nodplc[tabinf_1.icmat + i - 1] = indxx_(&node, &node);
/*<   230 continue >*/
/* L230: */
    }

/*<   300 call clrmem(iseq) >*/
L300:
    clrmem_(&tabinf_1.iseq);
/*<       call clrmem(iseq1) >*/
    clrmem_(&tabinf_1.iseq1);
/*<       call clrmem(neqn) >*/
    clrmem_(&tabinf_1.neqn);
/*<       call clrmem(nodevs) >*/
    clrmem_(&tabinf_1.nodevs);
/*<       call clrmem(ndiag) >*/
    clrmem_(&tabinf_1.ndiag);

/*  finished */

/*<  1000 call second(t2) >*/
L1000:
    second_(&t2);
/*<       rstats(2)=rstats(2)+t2-t1 >*/
    miscel_1.rstats[1] = miscel_1.rstats[1] + t2 - t1;
/*<       return >*/
    return 0;
/*<       end >*/
} /* setup_ */

#undef cvalue
#undef nodplc


