      subroutine elprnt
      implicit double precision (a-h,o-z)
c
c     this routine prints a circuit element summary.
c
c 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
c 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
c 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
c 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
c spice version 2g.6  sccsid=tran 3/15/83
      common /tran/ tstep,tstop,tstart,delmax,tdmax,forfre,jtrflg
c spice version 2g.6  sccsid=blank 3/15/83
      common /blank/ value(50000)
c spice version 2g.6  sccsid=status 3/15/83
      common /status/ omega,time,delta,delold(7),ag(7),vt,xni,egfet,
     1   xmu,sfactr,mode,modedc,icalc,initf,method,iord,maxord,noncon,
     2   iterno,itemno,nosolv,modac,ipiv,ivmflg,ipostp,iscrch,iofile
      integer nodplc(64)
      complex cvalue(32)
      equivalence (value(1),nodplc(1),cvalue(1))
c
c
      dimension itab(25),astyp(6)
      dimension eltitl(4)
      data eltitl / 8hcircuit , 8helement , 8hsummary , 8h         /
      data astyp / 1h , 5hpulse, 3hsin, 3hexp, 3hpwl, 4hsffm /
      data ablnk,aoff /1h ,3hoff/
c
c  print listing of elements
c
      call title(0,lwidth,1,eltitl)
c
c  print resistors
c
      if (jelcnt(1).eq.0) go to 50
      ititle=0
   21 format(//'0**** resistors'/'0     name        nodes     value
     1  tc1        tc2'//)
      loc=locate(1)
   30 if ((loc.eq.0).or.(nodplc(loc+8).ne.0)) go to 50
      if (ititle.eq.0) write (iofile,21)
      ititle=1
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      write (iofile,31) value(locv),nodplc(junode+node1),
     1   nodplc(junode+node2),value(locv+2),value(locv+3),value(locv+4)
   31 format(6x,a8,2i5,1p3d11.2)
   40 loc=nodplc(loc)
      go to 30
c
c  print capacitors and inductors
c
   50 if ((jelcnt(2)+jelcnt(3)).eq.0) go to 80
      ititle=0
   51 format(//'0**** capacitors and inductors'/'0     name        nodes
     1    in cond     value'//)
      do 70 id=2,3
      loc=locate(id)
   60 if (loc.eq.0) go to 70
      if ((id.eq.2).and.(nodplc(loc+12).ne.0)) go to 70
      if ((id.eq.3).and.(nodplc(loc+14).ne.0)) go to 70
      if (ititle.eq.0) write (iofile,51)
      ititle=1
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      if (nodplc(loc+4).ne.1) go to 62
      write (iofile,31) value(locv),nodplc(junode+node1),
     1   nodplc(junode+node2),value(locv+2),value(locv+1)
      go to 65
   62 ltab=7
      if (id.eq.3) ltab=10
      call sizmem(nodplc(loc+ltab),nparam)
      ispot=nodplc(loc+ltab)+1
      write (iofile,63) value(locv),nodplc(junode+node1),
     1   nodplc(junode+node2),value(locv+2)
   63 format(6x,a8,2i5,1pd11.2,'   variable')
   65 loc=nodplc(loc)
      go to 60
   70 continue
c
c  print mutual inductors
c
   80 if (jelcnt(4).eq.0) go to 100
      ititle=0
   81 format(//'0**** mutual inductors'/'0     name        coupled induc
     1tors   value'//)
      loc=locate(4)
   90 if ((loc.eq.0).or.(nodplc(loc+6).ne.0)) go to 110
      if (ititle.eq.0) write (iofile,81)
      ititle=1
      locv=nodplc(loc+1)
      nl1=nodplc(loc+2)
      nl1=nodplc(nl1+1)
      nl2=nodplc(loc+3)
      nl2=nodplc(nl2+1)
      write (iofile,91) value(locv),value(nl1),value(nl2),value(locv+1)
   91 format(6x,a8,4x,a8,2x,a8,1pd10.2)
   95 loc=nodplc(loc)
      go to 90
c
c  print nonlinear voltage controlled sources
c
  100 if (jelcnt(5).eq.0) go to 120
      ititle=0
  101 format(//'0**** voltage-controlled current sources'/'0     name
     1     +    -   dimension   function')
      loc=locate(5)
  110 if ((loc.eq.0).or.(nodplc(loc+13).ne.0)) go to 120
      if (ititle.eq.0) write (iofile,101)
      ititle=1
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      write (iofile,111) value(locv),nodplc(junode+node1),
     1   nodplc(junode+node2),nodplc(loc+4)
  111 format(6x,a8,2i5,i8,9x,'poly')
  115 loc=nodplc(loc)
      go to 110
c
c  nonlinear voltage controlled voltage sources
c
  120 if (jelcnt(6).eq.0) go to 140
      ititle=0
  121 format(//'0**** voltage-controlled voltage sources'/'0     name
     1     +    -   dimension   function')
      loc=locate(6)
  130 if ((loc.eq.0).or.(nodplc(loc+14).ne.0)) go to 140
      if (ititle.eq.0) write (iofile,121)
      ititle=1
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      write (iofile,111) value(locv),nodplc(junode+node1),
     1   nodplc(junode+node2),nodplc(loc+4)
  135 loc=nodplc(loc)
      go to 130
c
c  nonlinear current controlled current sources
c
  140 if (jelcnt(7).eq.0) go to 160
      ititle=0
  141 format(//'0**** current-controlled current sources'/'0     name
     1     +    -   dimension   function')
      loc=locate(7)
  150 if ((loc.eq.0).or.(nodplc(loc+13).ne.0)) go to 160
      if (ititle.eq.0) write (iofile,141)
      ititle=1
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      write (iofile,111) value(locv),nodplc(junode+node1),
     1   nodplc(junode+node2),nodplc(loc+4)
  155 loc=nodplc(loc)
      go to 150
c
c  nonlinear current controlled voltage sources
c
  160 if (jelcnt(8).eq.0) go to 170
      ititle=0
  161 format(//'0**** current-controlled voltage sources'/'0     name
     1     +    -   dimension   function')
      loc=locate(8)
  165 if ((loc.eq.0).or.(nodplc(loc+14).ne.0)) go to 170
      if (ititle.eq.0) write (iofile,161)
      ititle=1
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      write (iofile,111) value(locv),nodplc(junode+node1),
     1   nodplc(junode+node2),nodplc(loc+4)
  167 loc=nodplc(loc)
      go to 165
c
c  print independent sources
c
  170 if ((jelcnt(9)+jelcnt(10)).eq.0) go to 250
      ititle=0
  171 format(//'0**** independent sources'/'0     name        nodes   dc
     1 value   ac value   ac phase   transient'//)
      do 245 id=9,10
      loc=locate(id)
  180 if (loc.eq.0) go to 245
      if ((id.eq.9).and.(nodplc(loc+11).ne.0)) go to 245
      if ((id.eq.10).and.(nodplc(loc+6).ne.0)) go to 245
      if (ititle.eq.0) write (iofile,171)
      ititle=1
      locv=nodplc(loc+1)
      locp=nodplc(loc+5)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      itype=nodplc(loc+4)+1
      anam=astyp(itype)
      write (iofile,181) value(locv),nodplc(junode+node1),
     1   nodplc(junode+node2),value(locv+1),value(locv+2),
     2   value(locv+3),anam
  181 format(6x,a8,2i5,1p3d11.2,2x,a8)
      if (jtrflg.eq.0) go to 240
      jstart=locp+1
      go to (240,190,200,210,220,230), itype
  190 jstop=locp+7
      write (iofile,191) (value(j),j=jstart,jstop)
  191 format(1h0,42x,'initial value',1pd11.2,/,
     1           43x,'pulsed value.',  d11.2,/,
     2           43x,'delay time...',  d11.2,/,
     3           43x,'risetime.....',  d11.2,/,
     4           43x,'falltime.....',  d11.2,/,
     5           43x,'width........',  d11.2,/,
     6           43x,'period.......',  d11.2,/)
      go to 240
  200 jstop=locp+5
      write (iofile,201) (value(j),j=jstart,jstop)
  201 format(1h0,42x,'offset.......',1pd11.2,/,
     1           43x,'amplitude....',  d11.2,/,
     2           43x,'frequency....',  d11.2,/,
     3           43x,'delay........',  d11.2,/,
     4           43x,'theta........',  d11.2,/)
      go to 240
  210 jstop=locp+6
      write (iofile,211) (value(j),j=jstart,jstop)
  211 format(1h0,42x,'initial value',1pd11.2,/,
     1           43x,'pulsed value.',  d11.2,/,
     2           43x,'rise delay...',  d11.2,/,
     3           43x,'rise tau.....',  d11.2,/,
     4           43x,'fall delay...',  d11.2,/,
     5           43x,'fall tau.....',  d11.2,/)
      go to 240
  220 call sizmem(nodplc(loc+5),jstop)
      jstop=locp+jstop
      write (iofile,221) (value(j),j=jstart,jstop)
  221 format(1h0,49x,'time       value'//,(46x,1p2d11.2))
      write (iofile,226)
  226 format(1x)
      go to 240
  230 jstop=locp+5
      write (iofile,231) (value(j),j=jstart,jstop)
  231 format(1h0,42x,'offset.......',1pd11.2,/,
     1           43x,'amplitude....',  d11.2,/,
     2           43x,'carrier freq.',  d11.2,/,
     3           43x,'modn index...',  d11.2,/,
     4           43x,'signal freq..',  d11.2,/)
  240 loc=nodplc(loc)
      go to 180
  245 continue
c
c  print transmission lines
c
  250 if (jelcnt(17).eq.0) go to 260
      ititle=0
  251 format(//'0**** transmission lines'/'0     name             nodes
     1           z0         td'//)
      loc=locate(17)
  253 if ((loc.eq.0).or.(nodplc(loc+33).ne.0)) go to 260
      if (ititle.eq.0) write (iofile,251)
      ititle=1
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      node3=nodplc(loc+4)
      node4=nodplc(loc+5)
      write (iofile,256) value(locv),nodplc(junode+node1),
     1   nodplc(junode+node2),nodplc(junode+node3),
     2   nodplc(junode+node4),value(locv+1),value(locv+2)
  256 format(6x,a8,4i5,1p2d11.2)
  258 loc=nodplc(loc)
      go to 253
c
c  print diodes
c
  260 if (jelcnt(11).eq.0) go to 290
      ititle=0
  261 format(//'0**** diodes'/'0     name        +    -  model       are
     1a'//)
      loc=locate(11)
  270 if ((loc.eq.0).or.(nodplc(loc+16).ne.0)) go to 290
      if (ititle.eq.0) write (iofile,261)
      ititle=1
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      locm=nodplc(loc+5)
      locm=nodplc(locm+1)
      aic=ablnk
      if (nodplc(loc+6).eq.1) aic=aoff
      write (iofile,271) value(locv),nodplc(junode+node1),
     1   nodplc(junode+node2),value(locm),value(locv+1),aic
  271 format(6x,a8,2i5,2x,a8,f8.3,2x,a8)
  280 loc=nodplc(loc)
      go to 270
c
c  print transistors
c
  290 if (jelcnt(12).eq.0) go to 320
      ititle=0
  291 format(//'0**** bipolar junction transistors'/'0     name        c
     1    b    e    s  model       area'//)
      loc=locate(12)
  300 if ((loc.eq.0).or.(nodplc(loc+36).ne.0)) go to 320
      if (ititle.eq.0) write (iofile,291)
      ititle=1
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      node3=nodplc(loc+4)
      node4=nodplc(loc+5)
      locm=nodplc(loc+8)
      locm=nodplc(locm+1)
      aic=ablnk
      if (nodplc(loc+9).eq.1) aic=aoff
      write (iofile,301) value(locv),nodplc(junode+node1),
     1   nodplc(junode+node2),nodplc(junode+node3),nodplc(junode+node4),
     2   value(locm),value(locv+1),aic
  301 format(6x,a8,4i5,2x,a8,f8.3,2x,a8)
  310 loc=nodplc(loc)
      go to 300
c
c  print jfets
c
  320 if (jelcnt(13).eq.0) go to 350
      ititle=0
  321 format(//'0**** jfets'/'0     name        d    g    s  model
     1 area'//)
      loc=locate(13)
  330 if ((loc.eq.0).or.(nodplc(loc+25).ne.0)) go to 350
      if (ititle.eq.0) write (iofile,321)
      ititle=1
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      node3=nodplc(loc+4)
      locm=nodplc(loc+7)
      locm=nodplc(locm+1)
      aic=ablnk
      if (nodplc(loc+8).eq.1) aic=aoff
      write (iofile,331) value(locv),nodplc(junode+node1),
     1   nodplc(junode+node2),nodplc(junode+node3),
     2   value(locm),value(locv+1),aic
  331 format(6x,a8,3i5,2x,a8,f8.3,2x,a8)
  340 loc=nodplc(loc)
      go to 330
c
c  print mosfets
c
  350 if (jelcnt(14).eq.0) go to 400
      ititle=0
  351 format(//'0**** mosfets',/,'0name',6x,'d   g   s   b  model',6x,
     1      'w       ad       pd      rds'/
     2  37x,'l       as       ps      rss',//)
      loc=locate(14)
  360 if ((loc.eq.0).or.(nodplc(loc+33).ne.0)) go to 400
      if (ititle.eq.0) write (iofile,351)
      ititle=1
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      node3=nodplc(loc+4)
      node4=nodplc(loc+5)
      locm=nodplc(loc+8)
      locm=nodplc(locm+1)
      aic=ablnk
      if (nodplc(loc+9).eq.1) aic=aoff
      write (iofile,361) value(locv),nodplc(junode+node1),
     1   nodplc(junode+node2),nodplc(junode+node3),
     2   nodplc(junode+node4),value(locm),value(locv+2),
     3   value(locv+3),value(locv+11),value(locv+13),
     4   value(locv+1),value(locv+4),value(locv+12),value(locv+14),aic
  361 format(1x,a8,4i4,1x,a8,1p4d8.1,/34x,1p4d8.1,1x,a8)
  370 loc=nodplc(loc)
      go to 360
c
c  subcircuit calls
c
  400 if (jelcnt(19).eq.0) go to 500
      ititle=0
  401 format(//'0**** subcircuit calls'/'0     name     subcircuit   ext
     1ernal nodes'//)
      loc=locate(19)
  410 if (loc.eq.0) go to 500
      if (ititle.eq.0) write (iofile,401)
      ititle=1
      locv=nodplc(loc+1)
      locn=nodplc(loc+2)
      call sizmem(nodplc(loc+2),nnodx)
      locs=nodplc(loc+3)
      locsv=nodplc(locs+1)
      jstart=1
      ndprln=(lwidth-28)/5
  412 jstop=min0(nnodx,jstart+ndprln-1)
      do 414 j=jstart,jstop
      node=nodplc(locn+j)
      itab(j-jstart+1)=nodplc(junode+node)
  414 continue
      if (jstart.eq.1)
     1   write (iofile,416) value(locv),value(locsv),(itab(j),j=1,jstop)
  416 format(6x,a8,2x,a8,4x,20i5)
      if (jstart.ne.1)
     1   write (iofile,418) (itab(j-jstart+1),j=jstart,jstop)
  418 format(28x,20i5)
      jstart=jstop+1
      if (jstart.le.nnodx) go to 412
      if (nnodx.le.ndprln) go to 420
      write (iofile,226)
  420 loc=nodplc(loc)
      go to 410
c
c  finished
c
  500 return
      end
c spice version 2g.6  sccsid=errchk.ma 3/15/83
      subroutine errchk
      implicit double precision (a-h,o-z)
c
c
c     this routine drives the pre-processing and general error-checking
c of input performed by spice.
c
c 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
c 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
c 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
c spice version 2g.6  sccsid=cje 3/15/83
      common /cje/ maxtim,itime,icost
c spice version 2g.6  sccsid=status 3/15/83
      common /status/ omega,time,delta,delold(7),ag(7),vt,xni,egfet,
     1   xmu,sfactr,mode,modedc,icalc,initf,method,iord,maxord,noncon,
     2   iterno,itemno,nosolv,modac,ipiv,ivmflg,ipostp,iscrch,iofile
c 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
c spice version 2g.6  sccsid=knstnt 3/15/83
      common /knstnt/ twopi,xlog2,xlog10,root2,rad,boltz,charge,ctok,
     1   gmin,reltol,abstol,vntol,trtol,chgtol,eps0,epssil,epsox,
     2   pivtol,pivrel
c 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
c 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
c spice version 2g.6  sccsid=tran 3/15/83
      common /tran/ tstep,tstop,tstart,delmax,tdmax,forfre,jtrflg
c spice version 2g.6  sccsid=outinf 3/15/83
      common /outinf/ xincr,string(15),xstart,yvar(8),itab(8),itype(8),
     1   ilogy(8),npoint,numout,kntr,numdgt
c spice version 2g.6  sccsid=blank 3/15/83
      common /blank/ value(50000)
      integer nodplc(64)
      complex cvalue(32)
      equivalence (value(1),nodplc(1),cvalue(1))
c
c
      dimension titlop(4)
      dimension nnods(50),aname(2)
      data aname / 4htrap, 4hgear /
      data titlop / 8hoption s, 8hummary  , 8h        , 8h         /
      data ndefin / 2h.u /
      data nnods / 2, 2, 2, 0, 2, 2, 2, 2, 2, 2,
     1             2, 4, 3, 4, 0, 0, 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 /
      data aelmt,amodel,aoutpt /7helement,5hmodel,6houtput/
      data alsdc,alstr,alsac / 2hdc, 4htran, 2hac /
c
c
      call second(t1)
      do 60 id=1,50
      loc=locate(id)
   10 if (loc.eq.0) go to 60
      if (nodplc(loc+2).ne.ndefin) go to 50
      nogo=1
      locv=nodplc(loc+1)
      if (id.ge.21) go to 20
      anam=aelmt
      go to 40
   20 if (id.ge.31) go to 30
      anam=amodel
      go to 40
   30 anam=aoutpt
   40 write (iofile,41) anam,value(locv)
   41 format('0*error*:  ',2a8,' has been referenced but not defined'/)
   50 loc=nodplc(loc)
      go to 10
   60 continue
      if (nogo.ne.0) go to 2000
c
c  construct ordered list of user specified nodes
c
      call getm4(junode,1)
      nodplc(junode+1)=0
      nunods=1
      do 180 id=1,50
      if (nnods(id).eq.0) go to 180
      loc=locate(id)
  110 if (loc.eq.0) go to 180
      if (id.le.4) go to 120
      if (id.le.8) go to 150
      if (id.eq.19) go to 165
      if (id.le.40) go to 120
      if (id.le.43) go to 170
  120 jstop=loc+nnods(id)-1
      do 130 j=loc,jstop
      call putnod(nodplc(j+2))
  130 continue
      go to 170
  150 call putnod(nodplc(loc+2))
      call putnod(nodplc(loc+3))
      if (id.ge.7) go to 170
      locp=nodplc(loc+id+1)
      nssnod=2*nodplc(loc+4)
  155 do 160 j=1,nssnod
      call putnod(nodplc(locp+j))
  160 continue
      go to 170
  165 locp=nodplc(loc+2)
      call sizmem(nodplc(loc+2),nssnod)
      go to 155
  170 loc=nodplc(loc)
      go to 110
  180 continue
      if (nogo.ne.0) go to 2000
      ncnods=nunods
c
c  assign program nodes
c
  200 do 280 id=1,50
      if (nnods(id).eq.0) go to 280
      loc=locate(id)
  210 if (loc.eq.0) go to 280
      if (id.le.4) go to 220
      if (id.le.8) go to 250
      if (id.eq.19) go to 265
      if (id.le.40) go to 220
      if (id.le.43) go to 240
  220 jstop=loc+nnods(id)-1
      do 230 j=loc,jstop
      call getnod(nodplc(j+2))
  230 continue
      go to 270
  240 if (nodplc(loc+5).eq.0) go to 220
      go to 270
  250 call getnod(nodplc(loc+2))
      call getnod(nodplc(loc+3))
      if (id.ge.7) go to 270
      locp=nodplc(loc+id+1)
      nssnod=2*nodplc(loc+4)
  255 do 260 j=1,nssnod
      call getnod(nodplc(locp+j))
  260 continue
      go to 270
  265 locp=nodplc(loc+2)
      call sizmem(nodplc(loc+2),nssnod)
      go to 255
  270 loc=nodplc(loc)
      go to 210
  280 continue
c
c  check and set .nodeset nodes to their internal values
c
      call sizmem(nsnod,nic)
      if(nic.eq.0) go to 300
      do 290 i=1,nic
      call getnod(nodplc(nsnod+i))
  290 continue
c
c   check and set .ic nodes to their internal values
c
  300 call sizmem(icnod,nic)
      if(nic.eq.0) go to 320
      do 310 i=1,nic
      call getnod(nodplc(icnod+i))
  310 continue
  320 if (nogo.ne.0) go to 2000
c
c  expand subcircuit calls
c
      call subckt
      if (nogo.ne.0) go to 2000
      if (ncnods.ge.2) go to 400
      write (iofile,321)
  321 format('0*error*:  circuit has no nodes'/)
      nogo=1
      go to 2000
  400 numnod=ncnods
c
c  link unsatisfied references
c
      call lnkref
      if (nogo.ne.0) go to 2000
c
c  generate subcircuit element names
c
      if (jelcnt(19).eq.0) go to 530
      do 520 id=1,24
      loc=locate(id)
  510 if (loc.eq.0) go to 520
      call subnam(loc)
      loc=nodplc(loc)
      go to 510
  520 continue
c
c  translate node initial conditions to device initial conditions
c  (capacitance, diode, bjt, jfet and mosfet only) when uic is
c  specified on the .tran card
c
  530 if (nosolv.le.0) go to 600
      call sizmem(icnod,nic)
      if(nic.eq.0) go to 600
      call getm8(lvnim1,numnod)
      call zero8(value(lvnim1+1),numnod)
      do 535 i=1,nic
      node=nodplc(icnod+i)
  535 value(lvnim1+node)=value(icval+i)
      loc=locate(2)
  540 if(loc.eq.0) go to 550
      locv=nodplc(loc+1)
      if(value(locv+2).ne.0.0d0) go to 545
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      value(locv+2)=value(lvnim1+node1)-value(lvnim1+node2)
  545 loc=nodplc(loc)
      go to 540
  550 loc=locate(11)
  555 if(loc.eq.0) go to 565
      locv=nodplc(loc+1)
      if(value(locv+2).ne.0.0d0) go to 560
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      value(locv+2)=value(lvnim1+node1)-value(lvnim1+node2)
  560 loc=nodplc(loc)
      go to 555
  565 loc=locate(12)
  570 if(loc.eq.0) go to 580
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      node3=nodplc(loc+4)
      if(value(locv+2).eq.0.0d0) value(locv+2)=value(lvnim1+node2)-
     1  value(lvnim1+node3)
      if(value(locv+3).eq.0.0d0) value(locv+3)=value(lvnim1+node1)-
     1  value(lvnim1+node3)
      loc=nodplc(loc)
      go to 570
  580 loc=locate(13)
  585 if(loc.eq.0) go to 590
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      node3=nodplc(loc+4)
      if(value(locv+2).eq.0.0d0) value(locv+2)=value(lvnim1+node1)-
     1  value(lvnim1+node3)
      if(value(locv+3).eq.0.0d0) value(locv+3)=value(lvnim1+node2)-
     1  value(lvnim1+node3)
      loc=nodplc(loc)
      go to 585
  590 loc=locate(14)
  595 if(loc.eq.0) go to 598
      locv=nodplc(loc+1)
      node1=nodplc(loc+2)
      node2=nodplc(loc+3)
      node3=nodplc(loc+4)
      node4=nodplc(loc+5)
      if(value(locv+5).eq.0.0d0) value(locv+5)=value(lvnim1+node1)-
     1  value(lvnim1+node3)
      if(value(locv+6).eq.0.0d0) value(locv+6)=value(lvnim1+node2)-
     1  value(lvnim1+node3)
      if(value(locv+7).eq.0.0d0) value(locv+7)=value(lvnim1+node4)-
     1  value(lvnim1+node3)
      loc=nodplc(loc)
      go to 595
  598 call clrmem(lvnim1)
c
c  process sources
c
  600 if (jtrflg.eq.0) go to 700
      do 690 id=9,10
      loc=locate(id)
  610 if (loc.eq.0) go to 690
      locv=nodplc(loc+1)
      locp=nodplc(loc+5)
      jtype=nodplc(loc+4)+1
      go to (680,620,630,640,650,675), jtype
  620 value(locp+3)=dmax1(value(locp+3),0.0d0)
      if (value(locp+4).le.0.0d0) value(locp+4)=tstep
      if (value(locp+5).le.0.0d0) value(locp+5)=tstep
      if (value(locp+6).le.0.0d0) value(locp+6)=tstop
      if (value(locp+7).le.0.0d0) value(locp+7)=tstop
      temp=value(locp+4)+value(locp+5)+value(locp+6)
      value(locp+7)=dmax1(value(locp+7),temp)
      value(locv+1)=value(locp+1)
      go to 680
  630 if (value(locp+3).le.0.0d0) value(locp+3)=1.0d0/tstop
      value(locp+4)=dmax1(value(locp+4),0.0d0)
      value(locv+1)=value(locp+1)
      go to 680
  640 value(locp+3)=dmax1(value(locp+3),0.0d0)
      if (value(locp+4).le.0.0d0) value(locp+4)=tstep
      if (value(locp+5).le.value(locp+3))
     1   value(locp+5)=value(locp+3)+tstep
      if (value(locp+6).le.0.0d0) value(locp+6)=tstep
      value(locv+1)=value(locp+1)
      go to 680
  650 value(locp+1)=dmin1(dmax1(value(locp+1),0.0d0),tstop)
      iknt=1
      call sizmem(nodplc(loc+5),nump)
  660 temp=value(locp+iknt)
      if (value(locp+iknt+2).eq.0.0d0) go to 670
      if (value(locp+iknt+2).ge.tstop) go to 670
      value(locp+iknt+2)=dmax1(value(locp+iknt+2),temp)
      if(temp.ne.value(locp+iknt+2)) go to 665
      write(iofile,661) value(locv)
  661 format('0*error*:  element ',a8,' piecewise linear source table no
     1t increasing in time')
      nogo=1
  665 iknt=iknt+2
      if (iknt.lt.nump) go to 660
  670 value(locp+iknt+2)=tstop
      value(locv+1)=value(locp+2)
      call relmem(nodplc(loc+5),nump-iknt-3)
      go to 680
  675 if (value(locp+3).le.0.0d0) value(locp+3)=1.0d0/tstop
      if (value(locp+5).le.0.0d0) value(locp+5)=1.0d0/tstop
      value(locv+1)=value(locp+1)
  680 loc=nodplc(loc)
      go to 610
  690 continue
c
c  use default values for mos device geometries if not specified
c
  700 loc=locate(14)
  710 if(loc.eq.0) go to 720
      locv=nodplc(loc+1)
      if(value(locv+1).le.0.0d0) value(locv+1)=defl
      if(value(locv+2).le.0.0d0) value(locv+2)=defw
      if(value(locv+3).le.0.0d0) value(locv+3)=defad
      if(value(locv+4).le.0.0d0) value(locv+4)=defas
      loc=nodplc(loc)
      go to 710
c
c  print listing of elements, process device models,
c  and check topology
c
  720 if (iprntl.eq.0) go to 730
      call elprnt
  730 call topchk
      call modchk
      if (nogo.ne.0) go to 2000
c
c  invert resistance values
c
  800 loc=locate(1)
  810 if (loc.eq.0) go to 900
      locv=nodplc(loc+1)
      value(locv+1)=1.0d0/value(locv+2)
      loc=nodplc(loc)
      go to 810
c
c  process mutual inductors
c
  900 loc=locate(4)
  910 if (loc.eq.0) go to 1000
      locv=nodplc(loc+1)
      nl1=nodplc(loc+2)
      lptr1=nodplc(nl1+1)
      nl2=nodplc(loc+3)
      lptr2=nodplc(nl2+1)
      value(locv+1)=value(locv+1)*dsqrt(value(lptr1+1)*value(lptr2+1))
      loc=nodplc(loc)
      go to 910
c
c  limit delmax  if transmission lines in circuit
c
 1000 if (jtrflg.eq.0) go to 1200
      tdmax=0.0d0
      loc=locate(17)
 1010 if (loc.eq.0) go to 1200
      locv=nodplc(loc+1)
      delmax=dmin1(delmax,value(locv+2)/2.0d0)
      tdmax=dmax1(tdmax,value(locv+2))
      loc=nodplc(loc)
      go to 1010
c
c  process source parameters
c
 1200 numbkp=0
      if (jtrflg.eq.0) go to 1205
      tol=1.0d-2*delmax
      numbkp=2
      call getm8(lsbkpt,numbkp)
      value(lsbkpt+1)=0.0d0
      value(lsbkpt+2)=tstop
 1205 do 1290 id=9,10
      loc=locate(id)
 1210 if (loc.eq.0) go to 1290
      locv=nodplc(loc+1)
      locp=nodplc(loc+5)
      temp=value(locv+3)/rad
      value(locv+3)=value(locv+2)*dsin(temp)
      value(locv+2)=value(locv+2)*dcos(temp)
      if (jtrflg.eq.0) go to 1280
      jtype=nodplc(loc+4)+1
      go to (1280,1220,1230,1235,1240,1260), jtype
 1220 value(locp+4)=value(locp+4)+value(locp+3)
      temp=value(locp+5)
      value(locp+5)=value(locp+4)+value(locp+6)
      value(locp+6)=value(locp+5)+temp
      time=0.0d0
 1225 call extmem(lsbkpt,4)
      value(lsbkpt+numbkp+1)=value(locp+3)+time
      value(lsbkpt+numbkp+2)=value(locp+4)+time
      value(lsbkpt+numbkp+3)=value(locp+5)+time
      value(lsbkpt+numbkp+4)=value(locp+6)+time
      numbkp=numbkp+4
      time=time+value(locp+7)
      if (time.ge.tstop) go to 1280
      go to 1225
 1230 value(locp+3)=value(locp+3)*twopi
      call extmem(lsbkpt,1)
 1231 value(lsbkpt+numbkp+1)=value(locp+4)
      numbkp=numbkp+1
      go to 1280
 1235 call extmem(lsbkpt,2)
      value(lsbkpt+numbkp+1)=value(locp+3)
      value(lsbkpt+numbkp+2)=value(locp+5)
      numbkp=numbkp+2
      go to 1280
 1240 iknt=1
      call sizmem(nodplc(loc+5),nump)
 1250 call extmem(lsbkpt,1)
      value(lsbkpt+numbkp+1)=value(locp+iknt)
      numbkp=numbkp+1
      iknt=iknt+2
      if (iknt.le.nump) go to 1250
      go to 1280
 1260 value(locp+3)=value(locp+3)*twopi
      value(locp+5)=value(locp+5)*twopi
 1280 loc=nodplc(loc)
      go to 1210
 1290 continue
c
c  augment breakpoint table for transmission line delays
c
      if (jtrflg.eq.0) go to 1300
      loc=locate(17)
 1292 if (loc.eq.0) go to 1300
      locv=nodplc(loc+1)
      td=value(locv+2)
      ntemp=numbkp
      do 1296 ibkp=1,ntemp
      time=value(lsbkpt+ibkp)
 1294 time=time+td
      if (time.ge.tstop) go to 1296
      call extmem(lsbkpt,1)
      value(lsbkpt+numbkp+1)=time
      numbkp=numbkp+1
      go to 1294
 1296 continue
      call shlsrt(value(lsbkpt+1),numbkp)
      nbkpt=1
      do 1298 i=2,numbkp
      if ((value(lsbkpt+i)-value(lsbkpt+nbkpt)).lt.tol) go to 1298
      nbkpt=nbkpt+1
      value(lsbkpt+nbkpt)=value(lsbkpt+i)
      if (value(lsbkpt+nbkpt).ge.tstop) go to 1299
 1298 continue
 1299 call relmem(lsbkpt,numbkp-nbkpt)
      numbkp=nbkpt
      value(lsbkpt+numbkp)=dmax1(value(lsbkpt+numbkp),tstop)
      loc=nodplc(loc)
      go to 1292
c
c  finish breakpoint table
c
 1300 if (jtrflg.eq.0) go to 1600
      call extmem(lsbkpt,1)
      value(lsbkpt+numbkp+1)=tstop
      numbkp=numbkp+1
      call shlsrt(value(lsbkpt+1),numbkp)
      nbkpt=1
      do 1310 i=2,numbkp
      if ((value(lsbkpt+i)-value(lsbkpt+nbkpt)).lt.tol) go to 1310
      nbkpt=nbkpt+1
      value(lsbkpt+nbkpt)=value(lsbkpt+i)
      if (value(lsbkpt+nbkpt).ge.tstop) go to 1320
 1310 continue
 1320 call relmem(lsbkpt,numbkp-nbkpt)
      numbkp=nbkpt
      value(lsbkpt+numbkp)=dmax1(value(lsbkpt+numbkp),tstop)
c
c  print option summary
c
 1600 if (iprnto.eq.0) go to 1700
      call title(0,lwidth,1,titlop)
      write (iofile,1601) gmin,reltol,abstol,vntol,lvlcod,itl1,itl2
 1601 format('0dc analysis -',/,
     1   '0    gmin   = ',1pd10.3,/,
     2   '     reltol = ',  d10.3,/,
     3   '     abstol = ',  d10.3,/,
     4   '     vntol  = ',  d10.3,/,
     5   '     lvlcod = ',     i6,/,
     6   '     itl1   = ',     i6,/,
     7   '     itl2   = ',     i6,/)
      write (iofile,1605) pivtol,pivrel
 1605 format(
     1   '     pivtol = ',1pd10.3,/,
     2   '     pivrel = ',  d10.3)
      write (iofile,1611) aname(method),maxord,chgtol,trtol,lvltim,xmu,
     1   itl3,itl4,itl5
 1611 format('0transient analysis -',/,
     1   '0    method =  ',a8,/,
     2   '     maxord = ',     i6,/,
     3   '     chgtol = ',1pd10.3,/,
     4   '     trtol  = ',  d10.3,/,
     5   '     lvltim = ',     i6,/,
     6   '     mu     = ',0pf10.3,/,
     7   '     itl3   = ',     i6,/,
     8   '     itl4   = ',     i6,/,
     9   '     itl5   = ',     i6,/)
      write (iofile,1621) limpts,limtim,maxtim,numdgt,value(itemps+1),
     1   defl,defw,defad,defas
 1621 format('0miscellaneous -',/,
     1   '0    limpts = ',     i6,/,
     2   '     limtim = ',     i6,/,
     3   '     cptime = ',     i9,/,
     4   '     numdgt = ',     i6,/,
     5   '     tnom   = ',0pf10.3,/,
     6   '     defl   = ',1pd10.3,/,
     7   '     defw   = ',d10.3,/,
     8   '     defad  = ',d10.3,/,
     9   '     defas  = ',d10.3)
c
c  miscellaneous error checking
c
 1700 if (icvflg.eq.0) go to 1720
      if (icvflg.le.limpts) go to 1710
      icvflg=0
      write (iofile,1701) limpts,alsdc
 1701 format('0warning:  more than ',i5,' points for ',a4,' analysis,',/
     11x,'analysis omitted.  this limit may be overridden using the ',/
     21x,'limpts parameter on the .option card'/)
      go to 1720
 1710 if ((jelcnt(31)+jelcnt(36)).gt.0) go to 1720
      if(ipostp.ne.0) go to 1720
      icvflg=0
      write (iofile,1711) alsdc
 1711 format('0warning:  no ',a4,' outputs specified .',
     1  '.. analysis omitted'/)
 1720 if (jtrflg.eq.0) go to 1740
      if (method.eq.1) maxord=2
      if ((method.eq.2).and.(maxord.ge.3)) lvltim=2
      if (jtrflg.le.limpts) go to 1730
      jtrflg=0
      write (iofile,1701) limpts,alstr
      go to 1740
 1730 if ((jelcnt(32)+jelcnt(37)+nfour).gt.0) go to 1735
      if(ipostp.ne.0) go to 1735
      jtrflg=0
      write (iofile,1711) alstr
      go to 1740
 1735 if (nfour.eq.0) go to 1740
      forprd=1.0d0/forfre
      if ((tstop-forprd).ge.(tstart-1.0d-12)) go to 1740
      nfour=0
      call clrmem(ifour)
      write (iofile,1736)
 1736 format('0warning:  fourier analysis fundamental frequency is incom
     1patible with'/11x,'transient analysis print interval ... fourier a
     2nalysis omitted'/)
 1740 if (jacflg.eq.0) go to 1800
      if (jacflg.le.limpts) go to 1750
      jacflg=0
      write (iofile,1701) limpts,alsac
      go to 1800
 1750 if ((jelcnt(33)+jelcnt(34)+jelcnt(35)+jelcnt(38)+jelcnt(39)
     1   +jelcnt(40)+idist+inoise).gt.0) go to 1800
      if(ipostp.ne.0) go to 1800
      jacflg=0
      write (iofile,1711) alsac
c
c  sequence through the output lists
c
 1800 do 1820 id=41,45
      if (id.le.43) numout=1
      loc=locate(id)
 1810 if (loc.eq.0) go to 1820
      numout=numout+1
      nodplc(loc+4)=numout
      loc=nodplc(loc)
      go to 1810
 1820 continue
c
c   increase number of .prints if too many outputs for output line-width
c
      ifwdth=max0(numdgt-1,0)+9
      noprln=min0(8,(lwidth-12)/ifwdth)
      do 1860 id=31,35
      loc=locate(id)
 1830 if(loc.eq.0) go to 1860
      noprex=nodplc(loc+3)-noprln
      if(noprex.le.0) go to 1850
      nodplc(loc+3)=noprln
      call find(dble(jelcnt(id)),id,locnew,1)
      nodplc(locnew+2)=nodplc(loc+2)
      nodplc(locnew+3)=noprex
      call copy4(nodplc(loc+2*noprln+4),nodplc(locnew+4),2*noprex)
 1850 loc=nodplc(loc)
      go to 1830
 1860 continue
c
c  exit
c
 2000 call second(t2)
      rstats(1)=rstats(1)+t2-t1
      return
      end
      subroutine errmem(inam,ierror,ipntr)
      implicit double precision (a-h,o-z)
      dimension ipntr(1)
c spice version 2g.6  sccsid=status 3/15/83
      common /status/ omega,time,delta,delold(7),ag(7),vt,xni,egfet,
     1   xmu,sfactr,mode,modedc,icalc,initf,method,iord,maxord,noncon,
     2   iterno,itemno,nosolv,modac,ipiv,ivmflg,ipostp,iscrch,iofile
c spice version 2g.6  sccsid=memmgr 3/15/83
      common /memmgr/ cpyknt,istack(1),lorg,icore,maxcor,maxuse,memavl,
     1   ldval,numblk,loctab,ltab,ifwa,nwoff,ntab,maxmem,memerr,nwd4,
     2   nwd8,nwd16
      dimension errnam(7)
      data errnam /6hclrmem,6hextmem,6hgetmem,6hptrmem,6hrelmem,
     1   6hsetmem,6hsizmem/
c
      go to (200,410,420,300,510,530),ierror
c
c*** error(s) found ***
c
c.. nxtevn and/or nxtmem incompatible with nwd4, nwd8, and nwd16
c
  200 write(iofile,201)
  201 format('0memory manager variables nwd4-8-16 incompatible with nxte
     1vn and nxtmem')
      go to 900
c
c...  memory needs exceed maximum available space
  300 write (iofile,301) maxmem
  301 format('0*error*:  memory requirement exceeds machine capacity',
     1/'0 memory needs exceed',i6)
      go to 900
c...    *isize* < 0
  410 write(iofile,411)
  411 format('0size parameter negative')
      go to 900
c...  getmem:  attempt to reallocate existing block
  420 write(iofile,421)
  421 format('0attempt to reallocate existing table')
      go to 900
c...    *ipntr* invalid
  510 write(iofile,511)
  511 format('0table pointer invalid')
      go to 900
c...  relmem:  *isize* larger than indicated block
  530 write(iofile,531)
  531 format('0attempt to release more than total table')
c...  issue error message
  900 write (iofile,901) errnam(inam)
  901 format('0*abort*:  internal memory manager error at entry ',
     1  a7)
  950 call dmpmem(ipntr(1))
 1000 stop
      end
      subroutine evpoly(result,itype,lcoef,ncoef,larg,
     1  narg,lexp)
      implicit double precision (a-h,o-z)
c
c     this routine evaluates a polynomial.  lcoef points to the coef-
c ficients, and larg points to the values of the polynomial argument(s).
c
c spice version 2g.6  sccsid=blank 3/15/83
      common /blank/ value(50000)
      integer nodplc(64)
      complex cvalue(32)
      equivalence (value(1),nodplc(1),cvalue(1))
c
c
      if (itype) 100,200,300
c
c  integration (polynomial *must* be one-dimensional)
c
  100 result=0.0d0
      arg=1.0d0
      arg1=value(larg+1)
      do 110 i=1,ncoef
      arg=arg*arg1
      result=result+value(lcoef+i)*arg/dble(i)
  110 continue
      go to 1000
c
c  evaluation of the polynomial
c
  200 result=value(lcoef+1)
      if (ncoef.eq.1) go to 1000
      call zero4(nodplc(lexp+1),narg)
      do 220 i=2,ncoef
      call nxtpwr(nodplc(lexp+1),narg)
      if (value(lcoef+i).eq.0.0d0) go to 220
      arg=1.0d0
      do 210 j=1,narg
      call evterm(val,value(larg+j),nodplc(lexp+j))
      arg=arg*val
  210 continue
      result=result+value(lcoef+i)*arg
  220 continue
      go to 1000
c
c  partial derivative with respect to the itype*th variable
c
  300 result=0.0d0
      if (ncoef.eq.1) go to 1000
      call zero4(nodplc(lexp+1),narg)
      do 330 i=2,ncoef
      call nxtpwr(nodplc(lexp+1),narg)
      if (nodplc(lexp+itype).eq.0) go to 330
      if (value(lcoef+i).eq.0.0d0) go to 330
      arg=1.0d0
      do 320 j=1,narg
      if (j.eq.itype) go to 310
      call evterm(val,value(larg+j),nodplc(lexp+j))
      arg=arg*val
      go to 320
  310 call evterm(val,value(larg+j),nodplc(lexp+j)-1)
      arg=arg*dble(nodplc(lexp+j))*val
  320 continue
      result=result+value(lcoef+i)*arg
  330 continue
c
c  finished
c
 1000 return
      end
      subroutine evterm(val,arg,iexp)
      implicit double precision (a-h,o-z)
c
c     this routine evaluates one term of a polynomial.
c
      jexp=iexp+1
      if (jexp.ge.6) go to 60
      go to (10,20,30,40,50), jexp
   10 val=1.0d0
      go to 100
   20 val=arg
      go to 100
   30 val=arg*arg
      go to 100
   40 val=arg*arg*arg
      go to 100
   50 val=arg*arg
      val=val*val
      go to 100
   60 if (arg.eq.0.0d0) go to 70
      argexp=dble(iexp)*dlog(dabs(arg))
      if (argexp.lt.-200.0d0) go to 70
      val=dexp(argexp)
      if((iexp/2)*2.eq.iexp) go to 100
      val=dsign(val,arg)
      go to 100
   70 val=0.0d0
c
c  finished
c
  100 return
      end
      subroutine extmem(ipntr,ksize)
      implicit double precision (a-h,o-z)
      dimension ipntr(1)
c spice version 2g.6  sccsid=memmgr 3/15/83
      common /memmgr/ cpyknt,istack(1),lorg,icore,maxcor,maxuse,memavl,
     1   ldval,numblk,loctab,ltab,ifwa,nwoff,ntab,maxmem,memerr,nwd4,
     2   nwd8,nwd16
      logical memptr
c
c***  extmem - extend size of existing block
c
c
c...  check for valid pointer
      if (memptr(ipntr(1))) go to 10
      memerr=5
      call errmem(2,memerr,ipntr(1))
   10 isize=ksize*istack(ltab+5)
c...  check for valid size
      if (isize.ge.0) go to 20
      memerr=2
      call errmem(2,memerr,ipntr(1))
c...  check if enough space already there
   20 if ((istack(ltab+2)-istack(ltab+3)).ge.isize) go to 40
      need=nxtevn(isize)-memavl
      if (need.le.0) go to 30
c...  insufficient space -- bump memory size
      need=nxtmem(need)
      icore=icore+need
      call memory
      if(memerr.ne.0) call errmem(2,memerr,ipntr(1))
      ltab1=ldval-ntab
      istack(ltab1+2)=istack(ltab1+2)+need
c...  relocate block entry table
      nwords=numblk*ntab
      cpyknt=cpyknt+dble(nwords)
      call copy4(istack(loctab+1),istack(loctab+need+1),nwords)
      loctab=loctab+need
      ldval=ldval+need
      memavl=memavl+need
      ltab=ltab+need
c...  move blocks to make space
   30 continue
      call comprs(0,ltab)
      call comprs(1,ltab)
   40 jsize=istack(ltab+3)
      istack(ltab+3)=istack(ltab+3)+isize
      memavl=memavl-(nxtevn(istack(ltab+3))-nxtevn(jsize))
      call memadj
      return
      end
      subroutine extnam(aname,index)
      implicit double precision (a-h,o-z)
c
c     this routine adds 'aname' to the list of 'unsatisfied' names (that
c is, names which can only be resolved after subcircuit expansion).
c
c 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
c spice version 2g.6  sccsid=blank 3/15/83
      common /blank/ value(50000)
      integer nodplc(64)
      complex cvalue(32)
      equivalence (value(1),nodplc(1),cvalue(1))
      integer xxor
c
c
      anam=aname
      if (nunsat.eq.0) go to 20
      do 10 index=1,nunsat
      if (xxor(anam,value(iunsat+index)).eq.0) go to 30
   10 continue
c
   20 call extmem(iunsat,1)
      nunsat=nunsat+1
      index=nunsat
      value(iunsat+index)=anam
   30 return
      end
