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

#define blank_1 blank_

/*<       subroutine addelt(loce,loc,id,inodx,inodi,nnodi) >*/
/* Subroutine */ int addelt_(loce, loc, id, inodx, inodi, nnodi)
integer *loce, *loc, *id, *inodx, *inodi, *nnodi;
{
    /* Initialized data */

    static integer lnod[50] = { 10,14,16,8,15,16,15,16,13,8,18,38,27,35,8,8,
	    35,5,5,5,5,5,5,5,0,0,0,0,0,0,21,21,21,21,21,21,21,21,21,21,8,8,8,
	    8,8,0,0,0,0,0 };
    static integer lval[50] = { 5,4,4,2,1,1,1,1,4,4,3,4,4,16,1,1,9,2,1,1,19,
	    55,17,46,0,0,0,0,0,0,1,1,1,1,1,17,17,17,17,17,1,1,1,1,1,0,0,0,0,0 
	    };
    static integer nnods[50] = { 2,2,2,0,2,2,2,2,2,2,2,4,3,4,4,4,4,0,1,0,0,0,
	    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0 };

    /* System generated locals */
    integer i_1, i_2;

    /* Local variables */
    static integer itab, locp, locv;
    extern /* Subroutine */ int getm4_(), copy4_(), copy8_();
    static integer j, locpe, locve, nlocp, nword, jstop;
    extern /* Subroutine */ int cpytb4_(), cpytb8_();
#define nodplc ((integer *)&blank_1)
#define cvalue ((complex *)&blank_1)
    extern /* Subroutine */ int newnod_();
    static integer nssnod, nlocpe, nodold, nodnew;
    extern /* Subroutine */ int sizmem_();

    /* Parameter adjustments */
    --inodx;
    --inodi;

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

/*     this routine adds an element to the nominal circuit definition */
/* lists. */

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

/* ... inodx(1), inodi(1) are arrays (see subckt) */
/*<       dimension inodx(1),inodi(1) >*/

/*<       dimension lnod(50),lval(50),nnods(50) >*/
/*<       data lnod /10,14,16, 8,15,16,15,16,13, 8, >*/
/*<      1           18,38,27,35, 8, 8,35, 5, 5, 5, >*/
/*<      2            5, 5, 5, 5, 0, 0, 0, 0, 0, 0, >*/
/*<      3           21,21,21,21,21,21,21,21,21,21, >*/
/*<      4            8, 8, 8, 8, 8, 0, 0, 0, 0, 0 / >*/
/*<       data lval / 5, 4, 4, 2, 1, 1, 1, 1, 4, 4, >*/
/*<      1            3, 4, 4,16, 1, 1, 9, 2, 1, 1, >*/
/*<      2           19,55,17,46, 0, 0, 0, 0, 0, 0, >*/
/*<      3            1, 1, 1, 1, 1,17,17,17,17,17, >*/
/*<      4            1, 1, 1, 1, 1, 0, 0, 0, 0, 0 / >*/
/*<       data nnods / 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, >*/
/*<      1             2, 4, 3, 4, 4, 4, 4, 0, 1, 0, >*/
/*<      2             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, >*/
/*<      3             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, >*/
/*<      4             2, 2, 2, 0, 0, 0, 0, 0, 0, 0 / >*/

/*  copy integer part */

/*<       nword=lnod(id)-3 >*/
    nword = lnod[*id - 1] - 3;
/*<       if (nword.le.0) go to 10 >*/
    if (nword <= 0) {
	goto L10;
    }
/*<       call copy4(nodplc(loc+2),nodplc(loce+2),nword) >*/
    copy4_(&nodplc[*loc + 1], &nodplc[*loce + 1], &nword);

/*  set nodes */

/*<    10 if (id.ge.21) go to 100 >*/
L10:
    if (*id >= 21) {
	goto L100;
    }
/*<       if (nnods(id).eq.0) go to 100 >*/
    if (nnods[*id - 1] == 0) {
	goto L100;
    }
/*<       if (id.le.4) go to 20 >*/
    if (*id <= 4) {
	goto L20;
    }
/*<       if (id.le.8) go to 40 >*/
    if (*id <= 8) {
	goto L40;
    }
/*<       if (id.eq.19) go to 70 >*/
    if (*id == 19) {
	goto L70;
    }
/*<    20 jstop=nnods(id) >*/
L20:
    jstop = nnods[*id - 1];
/*<       do 30 j=1,jstop >*/
    i_1 = jstop;
    for (j = 1; j <= i_1; ++j) {
/*<       call newnod(nodplc(loc+j+1),nodplc(loce+j+1),inodx(1), >*/
/*<      1  inodi(1),nnodi) >*/
	newnod_(&nodplc[*loc + j], &nodplc[*loce + j], &inodx[1], &inodi[1], 
		nnodi);
/*<    30 continue >*/
/* L30: */
    }
/*<       go to 100 >*/
    goto L100;
/*<    40 call newnod(nodplc(loc+2),nodplc(loce+2),inodx(1),inodi(1),nnodi) >*/
L40:
    newnod_(&nodplc[*loc + 1], &nodplc[*loce + 1], &inodx[1], &inodi[1], 
	    nnodi);
/*<       call newnod(nodplc(loc+3),nodplc(loce+3),inodx(1),inodi(1),nnodi) >*/
    newnod_(&nodplc[*loc + 2], &nodplc[*loce + 2], &inodx[1], &inodi[1], 
	    nnodi);
/*<       if (id.ge.7) go to 100 >*/
    if (*id >= 7) {
	goto L100;
    }
/*<       nlocp=loc+id+1 >*/
    nlocp = *loc + *id + 1;
/*<       nssnod=2*nodplc(loc+4) >*/
    nssnod = nodplc[*loc + 3] << 1;
/*<       call getm4(nodplc(loce+id+1),nssnod) >*/
    getm4_(&nodplc[*loce + *id], &nssnod);
/*<       nlocpe=loce+id+1 >*/
    nlocpe = *loce + *id + 1;
/*<    50 do 60 j=1,nssnod >*/
L50:
    i_1 = nssnod;
    for (j = 1; j <= i_1; ++j) {
/*<       locp=nodplc(nlocp) >*/
	locp = nodplc[nlocp - 1];
/*<       nodold=nodplc(locp+j) >*/
	nodold = nodplc[locp + j - 1];
/*<       call newnod(nodold,nodnew,inodx(1),inodi(1),nnodi) >*/
	newnod_(&nodold, &nodnew, &inodx[1], &inodi[1], nnodi);
/*<       locpe=nodplc(nlocpe) >*/
	locpe = nodplc[nlocpe - 1];
/*<       nodplc(locpe+j)=nodnew >*/
	nodplc[locpe + j - 1] = nodnew;
/*<    60 continue >*/
/* L60: */
    }
/*<       go to 100 >*/
    goto L100;
/*<    70 nlocp=loc+2 >*/
L70:
    nlocp = *loc + 2;
/*<       call sizmem(nodplc(loc+2),nssnod) >*/
    sizmem_(&nodplc[*loc + 1], &nssnod);
/*<       call getm4(nodplc(loce+2),nssnod) >*/
    getm4_(&nodplc[*loce + 1], &nssnod);
/*<       nlocpe=loce+2 >*/
    nlocpe = *loce + 2;
/*<       go to 50 >*/
    goto L50;

/*  copy real part */

/*<   100 if (nogo.ne.0) go to 300 >*/
L100:
    if (flags_1.nogo != 0) {
	goto L300;
    }
/*<       locv=nodplc(loc+1) >*/
    locv = nodplc[*loc];
/*<       locve=nodplc(loce+1) >*/
    locve = nodplc[*loce];
/*<       call copy8(value(locv),value(locve),lval(id)) >*/
    copy8_(&blank_1.value[locv - 1], &blank_1.value[locve - 1], &lval[*id - 1]
	    );

/*  treat non-node tables specially */

/*<   200 if (id.ge.11) go to 300 >*/
/* L200: */
    if (*id >= 11) {
	goto L300;
    }
/*<       go to (300,210,220,300,230,240,230,240,260,260), id >*/
    switch (*id) {
	case 1:  goto L300;
	case 2:  goto L210;
	case 3:  goto L220;
	case 4:  goto L300;
	case 5:  goto L230;
	case 6:  goto L240;
	case 7:  goto L230;
	case 8:  goto L240;
	case 9:  goto L260;
	case 10:  goto L260;
    }
/*<   210 if (nodplc(loc+4).eq.1) go to 300 >*/
L210:
    if (nodplc[*loc + 3] == 1) {
	goto L300;
    }
/*<       call cpytb8(loc+7,loce+7) >*/
    i_1 = *loc + 7;
    i_2 = *loce + 7;
    cpytb8_(&i_1, &i_2);
/*<       go to 300 >*/
    goto L300;
/*<   220 if (nodplc(loc+4).eq.1) go to 300 >*/
L220:
    if (nodplc[*loc + 3] == 1) {
	goto L300;
    }
/*<       call cpytb8(loc+10,loce+10) >*/
    i_1 = *loc + 10;
    i_2 = *loce + 10;
    cpytb8_(&i_1, &i_2);
/*<       go to 300 >*/
    goto L300;
/*<   230 itab=5 >*/
L230:
    itab = 5;
/*<       go to 250 >*/
    goto L250;
/*<   240 itab=6 >*/
L240:
    itab = 6;
/*<   250 if (id.le.6) go to 255 >*/
L250:
    if (*id <= 6) {
	goto L255;
    }
/*<       call cpytb4(loc+itab+1,loce+itab+1) >*/
    i_1 = *loc + itab + 1;
    i_2 = *loce + itab + 1;
    cpytb4_(&i_1, &i_2);
/*<   255 call cpytb4(loc+itab+2,loce+itab+2) >*/
L255:
    i_1 = *loc + itab + 2;
    i_2 = *loce + itab + 2;
    cpytb4_(&i_1, &i_2);
/*<       call cpytb8(loc+itab+3,loce+itab+3) >*/
    i_1 = *loc + itab + 3;
    i_2 = *loce + itab + 3;
    cpytb8_(&i_1, &i_2);
/*<       call cpytb8(loc+itab+4,loce+itab+4) >*/
    i_1 = *loc + itab + 4;
    i_2 = *loce + itab + 4;
    cpytb8_(&i_1, &i_2);
/*<       call cpytb4(loc+itab+5,loce+itab+5) >*/
    i_1 = *loc + itab + 5;
    i_2 = *loce + itab + 5;
    cpytb4_(&i_1, &i_2);
/*<       call cpytb8(loc+itab+6,loce+itab+6) >*/
    i_1 = *loc + itab + 6;
    i_2 = *loce + itab + 6;
    cpytb8_(&i_1, &i_2);
/*<       go to 300 >*/
    goto L300;
/*<   260 call cpytb8(loc+5,loce+5) >*/
L260:
    i_1 = *loc + 5;
    i_2 = *loce + 5;
    cpytb8_(&i_1, &i_2);


/*<   300 return >*/
L300:
    return 0;
/*<       end >*/
} /* addelt_ */

#undef cvalue
#undef nodplc


