/* dcsol.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 {
    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 value[200000];
} blank_;

#define blank_1 blank_

/*<       subroutine dcsol >*/
/* Subroutine */ int dcsol_()
{
    /* System generated locals */
    integer i_1;

    /* Local variables */
    static integer iord, jord, i, j, locnn;
    extern integer indxx_();
    static doublereal t1, t2;
    extern /* Subroutine */ int second_();
#define nodplc ((integer *)&blank_1)
#define cvalue ((complex *)&blank_1)
    static integer loc;

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

/*     this routine solves the system of circuit equations by performing 
*/
/* a forward and backward substitution step using the previously-computed 
*/
/* lu factors. */

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

/*  forward substitution */

/*<       call second(t1) >*/
    second_(&t1);
/*<       do 20 i=2,nstop >*/
    i_1 = cirdat_1.nstop;
    for (i = 2; i <= i_1; ++i) {
/*<       loc=i >*/
	loc = i;
/*<       iord=nodplc(irswpf+i) >*/
	iord = nodplc[tabinf_1.irswpf + i - 1];
/*<    10 loc=nodplc(jcpt+loc) >*/
L10:
	loc = nodplc[tabinf_1.jcpt + loc - 1];
/*<       if (nodplc(jcolno+loc).ge.i) go to 20 >*/
	if (nodplc[tabinf_1.jcolno + loc - 1] >= i) {
	    goto L20;
	}
/*<       j=nodplc(jcolno+loc) >*/
	j = nodplc[tabinf_1.jcolno + loc - 1];
/*<       jord=nodplc(irswpf+j) >*/
	jord = nodplc[tabinf_1.irswpf + j - 1];
/*<       value(lvn+iord)=value(lvn+iord)- >*/
/*<      1           value(lvn+loc)*value(lvn+jord) >*/
	blank_1.value[tabinf_1.lvn + iord - 1] -= blank_1.value[tabinf_1.lvn 
		+ loc - 1] * blank_1.value[tabinf_1.lvn + jord - 1];
/*<       go to 10 >*/
	goto L10;
/*<    20 continue >*/
L20:
    ;}

/*     back substitution */

/*<       i=nstop >*/
    i = cirdat_1.nstop;
/*<       iord=nodplc(irswpf+i) >*/
    iord = nodplc[tabinf_1.irswpf + i - 1];
/*<       jord=nodplc(icswpf+i) >*/
    jord = nodplc[tabinf_1.icswpf + i - 1];
/*<       locnn=indxx(iord,jord) >*/
    locnn = indxx_(&iord, &jord);
/*<    30 value(lvn+iord)=value(lvn+iord)/value(lvn+locnn) >*/
L30:
    blank_1.value[tabinf_1.lvn + iord - 1] /= blank_1.value[tabinf_1.lvn + 
	    locnn - 1];
/*<       i=i-1 >*/
    --i;
/*<       if (i.le.1) go to 100 >*/
    if (i <= 1) {
	goto L100;
    }
/*<       iord=nodplc(irswpf+i) >*/
    iord = nodplc[tabinf_1.irswpf + i - 1];
/*<       loc=i >*/
    loc = i;
/*<    35 loc=nodplc(jcpt+loc) >*/
L35:
    loc = nodplc[tabinf_1.jcpt + loc - 1];
/*<    40 if (nodplc(jcolno+loc).ne.i) go to 35 >*/
/* L40: */
    if (nodplc[tabinf_1.jcolno + loc - 1] != i) {
	goto L35;
    }
/*<       locnn=loc >*/
    locnn = loc;
/*<    50 loc=nodplc(jcpt+loc) >*/
L50:
    loc = nodplc[tabinf_1.jcpt + loc - 1];
/*<       if (loc.eq.0) go to 30 >*/
    if (loc == 0) {
	goto L30;
    }
/*<       j=nodplc(jcolno+loc) >*/
    j = nodplc[tabinf_1.jcolno + loc - 1];
/*<       jord=nodplc(irswpf+j) >*/
    jord = nodplc[tabinf_1.irswpf + j - 1];
/*<       value(lvn+iord)=value(lvn+iord)- >*/
/*<      1           value(lvn+loc)*value(lvn+jord) >*/
    blank_1.value[tabinf_1.lvn + iord - 1] -= blank_1.value[tabinf_1.lvn + 
	    loc - 1] * blank_1.value[tabinf_1.lvn + jord - 1];
/*<       go to 50 >*/
    goto L50;
/*<   100 call second(t2) >*/
L100:
    second_(&t2);
/*<       rstats(46)=rstats(46)+t2-t1 >*/
    miscel_1.rstats[45] = miscel_1.rstats[45] + t2 - t1;
/*<       return >*/
    return 0;
/*<       end >*/
} /* dcsol_ */

#undef cvalue
#undef nodplc


