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

#define blank_1 blank_

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

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

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

/*     this routine evaluates the adjoint circuit response by doing a */
/* forward/backward substitution on the transpose of the coefficient */
/* matrix. */

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

/*  forward substitution */

/*<       do 20 i=2,nstop >*/
    i_1 = cirdat_1.nstop;
    for (i = 2; i <= i_1; ++i) {
/*<       iord=nodplc(icswpf+i) >*/
	iord = nodplc[tabinf_1.icswpf + i - 1];
/*<       loc=i >*/
	loc = i;
/*<    10 loc=nodplc(irpt+loc) >*/
L10:
	loc = nodplc[tabinf_1.irpt + loc - 1];
/*<       if (nodplc(irowno+loc).ge.i) go to 15 >*/
	if (nodplc[tabinf_1.irowno + loc - 1] >= i) {
	    goto L15;
	}
/*<       j=nodplc(irowno+loc) >*/
	j = nodplc[tabinf_1.irowno + loc - 1];
/*<       jord=nodplc(icswpf+j) >*/
	jord = nodplc[tabinf_1.icswpf + j - 1];
/*<       value(lvn+iord)=value(lvn+iord)-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;
/*<    15 jord=nodplc(irswpf+i) >*/
L15:
	jord = nodplc[tabinf_1.irswpf + i - 1];
/*<       locnn=indxx(jord,iord) >*/
	locnn = indxx_(&jord, &iord);
/*<       value(lvn+iord)=value(lvn+iord)/value(lvn+locnn) >*/
	blank_1.value[tabinf_1.lvn + iord - 1] /= blank_1.value[tabinf_1.lvn 
		+ locnn - 1];
/*<    20 continue >*/
/* L20: */
    }

/*  backward substitution */

/*<       i=nstop >*/
    i = cirdat_1.nstop;
/*<    30 i=i-1 >*/
L30:
    --i;
/*<       if (i.le.1) go to 60 >*/
    if (i <= 1) {
	goto L60;
    }
/*<       iord=nodplc(icswpf+i) >*/
    iord = nodplc[tabinf_1.icswpf + i - 1];
/*<       loc=i >*/
    loc = i;
/*<    35 loc=nodplc(irpt+loc) >*/
L35:
    loc = nodplc[tabinf_1.irpt + loc - 1];
/*<    40 if (nodplc(irowno+loc).ne.i) go to 35 >*/
/* L40: */
    if (nodplc[tabinf_1.irowno + loc - 1] != i) {
	goto L35;
    }
/*<    50 loc=nodplc(irpt+loc) >*/
L50:
    loc = nodplc[tabinf_1.irpt + loc - 1];
/*<       if (loc.eq.0) go to 30 >*/
    if (loc == 0) {
	goto L30;
    }
/*<       j=nodplc(irowno+loc) >*/
    j = nodplc[tabinf_1.irowno + loc - 1];
/*<       jord=nodplc(icswpf+j) >*/
    jord = nodplc[tabinf_1.icswpf + j - 1];
/*<       value(lvn+iord)=value(lvn+iord)-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;

/*     reorder solution vector */

/*<    60 do 70 i=1,nstop >*/
L60:
    i_1 = cirdat_1.nstop;
    for (i = 1; i <= i_1; ++i) {
/*<       j=nodplc(irswpr+i) >*/
	j = nodplc[tabinf_1.irswpr + i - 1];
/*<       k=nodplc(icswpf+j) >*/
	k = nodplc[tabinf_1.icswpf + j - 1];
/*<       value(lvntmp+i)=value(lvn+k) >*/
	blank_1.value[tabinf_1.lvntmp + i - 1] = blank_1.value[tabinf_1.lvn + 
		k - 1];
/*<    70 continue >*/
/* L70: */
    }
/*<       call copy8(value(lvntmp+1),value(lvn+1),nstop) >*/
    copy8_(&blank_1.value[tabinf_1.lvntmp], &blank_1.value[tabinf_1.lvn], &
	    cirdat_1.nstop);

/*  finished */

/*<       return >*/
    return 0;
/*<       end >*/
} /* asol_ */

#undef cvalue
#undef nodplc


