/* newnod.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_

/* Table of constant values */

static integer c__1 = 1;

/*<       subroutine newnod(nodold,nodnew,inodx,inodi,nnodi) >*/
/* Subroutine */ int newnod_(nodold, nodnew, inodx, inodi, nnodi)
integer *nodold, *nodnew, *inodx, *inodi, *nnodi;
{
    /* System generated locals */
    integer i_1;

    /* Local variables */
    static integer i, jnodi, jnodx;
#define nodplc ((integer *)&blank_1)
#define cvalue ((complex *)&blank_1)
    extern /* Subroutine */ int extmem_();

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

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

/*     this routine makes a new node number for an element which is about 
*/
/* to be added to the circuit as a result of a subcircuit call. */

/* 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)) >*/

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

/*<       if (nodold.ne.0) go to 5 >*/
    if (*nodold != 0) {
	goto L5;
    }
/*<       nodnew=1 >*/
    *nodnew = 1;
/*<       go to 20 >*/
    goto L20;
/*<     5 do 10 i=1,nnodi >*/
L5:
    i_1 = *nnodi;
    for (i = 1; i <= i_1; ++i) {
/*<       jnodx=inodx(1) >*/
	jnodx = inodx[1];
/*<       if (nodold.ne.nodplc(jnodx+i)) go to 10 >*/
	if (*nodold != nodplc[jnodx + i - 1]) {
	    goto L10;
	}
/*<       jnodi=inodi(1) >*/
	jnodi = inodi[1];
/*<       nodnew=nodplc(jnodi+i) >*/
	*nodnew = nodplc[jnodi + i - 1];
/*<       go to 20 >*/
	goto L20;
/*<    10 continue >*/
L10:
    ;}

/*<       call extmem(inodx(1),1) >*/
    extmem_(&inodx[1], &c__1);
/*<       call extmem(inodi(1),1) >*/
    extmem_(&inodi[1], &c__1);
/*<       call extmem(junode,1) >*/
    extmem_(&tabinf_1.junode, &c__1);
/*<       nnodi=nnodi+1 >*/
    ++(*nnodi);
/*<       ncnods=ncnods+1 >*/
    ++cirdat_1.ncnods;
/*<       jnodx=inodx(1) >*/
    jnodx = inodx[1];
/*<       nodplc(jnodx+nnodi)=nodold >*/
    nodplc[jnodx + *nnodi - 1] = *nodold;
/*<       jnodi=inodi(1) >*/
    jnodi = inodi[1];
/*<       nodplc(jnodi+nnodi)=ncnods >*/
    nodplc[jnodi + *nnodi - 1] = cirdat_1.ncnods;
/*<       nodplc(junode+ncnods)=nodplc(junode+ncnods-1)+1 >*/
    nodplc[tabinf_1.junode + cirdat_1.ncnods - 1] = nodplc[tabinf_1.junode + 
	    cirdat_1.ncnods - 2] + 1;
/*<       nodnew=ncnods >*/
    *nodnew = cirdat_1.ncnods;
/*<    20 return >*/
L20:
    return 0;
/*<       end >*/
} /* newnod_ */

#undef cvalue
#undef nodplc


