/* ntrpl8.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 omega, time, delta, delold[7], ag[7], vt, xni, egfet, xmu, 
	    sfactr;
    integer mode, modedc, icalc, initf, method, iord, maxord, noncon, iterno, 
	    itemno, nosolv, modac, ipiv, ivmflg, ipostp, iscrch, iofile;
} status_;

#define status_1 status_

struct {
    doublereal xincr, string[15], xstart, yvar[8];
    integer itab[8], itype[8], ilogy[8], npoint, numout, kntr, numdgt;
} outinf_;

#define outinf_1 outinf_

struct {
    doublereal value[200000];
} blank_;

#define blank_1 blank_

/*<       subroutine ntrpl8(locx,locy,numpnt) >*/
/* Subroutine */ int ntrpl8_(locx, locy, numpnt)
integer *locx, *locy, *numpnt;
{
    /* System generated locals */
    integer i_1, i_2;
    doublereal d_1, d_2;

    /* Local variables */
    static integer loco;
    static doublereal dx1x2, xvar;
    static integer loco1, loco2, i, k, icpnt, locyt, ippnt;
    static doublereal v1, v2, x1, x2, xvtol;
#define nodplc ((integer *)&blank_1)
#define cvalue ((complex *)&blank_1)
    static doublereal tol, yvr, dxx1;

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

/*     this routine interpolates the analysis data to obtain the values */

/* printed and/or plotted, using linear interpolation. */

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


/*  for dc transfer curve, no interpolation necessary */

/*<       if(mode.ne.1) go to 4 >*/
    if (status_1.mode != 1) {
	goto L4;
    }
/*<       numpnt=icalc >*/
    *numpnt = status_1.icalc;
/*<       loco=loutpt >*/
    loco = tabinf_1.loutpt;
/*<       do 3 i=1,numpnt >*/
    i_1 = *numpnt;
    for (i = 1; i <= i_1; ++i) {
/*<       locyt=locy >*/
	locyt = *locy;
/*<       value(locx+i)=value(loco+1) >*/
	blank_1.value[*locx + i - 1] = blank_1.value[loco];
/*<       do 2 k=1,kntr >*/
	i_2 = outinf_1.kntr;
	for (k = 1; k <= i_2; ++k) {
/*<       iseq=itab(k) >*/
	    tabinf_1.iseq = outinf_1.itab[k - 1];
/*<       iseq=nodplc(iseq+4) >*/
	    tabinf_1.iseq = nodplc[tabinf_1.iseq + 3];
/*<       value(locyt+i)=value(loco+iseq) >*/
	    blank_1.value[locyt + i - 1] = blank_1.value[loco + tabinf_1.iseq 
		    - 1];
/*<       locyt=locyt+npoint >*/
	    locyt += outinf_1.npoint;
/*<     2 continue >*/
/* L2: */
	}
/*<       loco=loco+numout >*/
	loco += outinf_1.numout;
/*<     3 continue >*/
/* L3: */
    }
/*<       return >*/
    return 0;
/*<     4 continue >*/
L4:
/*<       xvar=xstart >*/
    xvar = outinf_1.xstart;
/*<       xvtol=xincr*1.0d-5 >*/
    xvtol = outinf_1.xincr * 1e-5;
/*<       ippnt=0 >*/
    ippnt = 0;
/*<       icpnt=2 >*/
    icpnt = 2;
/*<       loco1=loutpt >*/
    loco1 = tabinf_1.loutpt;
/*<       loco2=loco1+numout >*/
    loco2 = loco1 + outinf_1.numout;
/*<       if (icalc.lt.2) go to 50 >*/
    if (status_1.icalc < 2) {
	goto L50;
    }
/*<    10 x1=value(loco1+1) >*/
L10:
    x1 = blank_1.value[loco1];
/*<       x2=value(loco2+1) >*/
    x2 = blank_1.value[loco2];
/*<       dx1x2=x1-x2 >*/
    dx1x2 = x1 - x2;
/*<    20 if (xincr.lt.0.0d0) go to 24 >*/
L20:
    if (outinf_1.xincr < 0.) {
	goto L24;
    }
/*<       if (xvar.le.(x2+xvtol)) go to 30 >*/
    if (xvar <= x2 + xvtol) {
	goto L30;
    }
/*<       go to 28 >*/
    goto L28;
/*<    24 if (xvar.ge.(x2+xvtol)) go to 30 >*/
L24:
    if (xvar >= x2 + xvtol) {
	goto L30;
    }
/*<    28 if (icpnt.ge.icalc) go to 100 >*/
L28:
    if (icpnt >= status_1.icalc) {
	goto L100;
    }
/*<       icpnt=icpnt+1 >*/
    ++icpnt;
/*<       loco1=loco2 >*/
    loco1 = loco2;
/*<       loco2=loco1+numout >*/
    loco2 = loco1 + outinf_1.numout;
/*<       go to 10 >*/
    goto L10;
/*<    30 ippnt=ippnt+1 >*/
L30:
    ++ippnt;
/*<       value(locx+ippnt)=xvar >*/
    blank_1.value[*locx + ippnt - 1] = xvar;
/*<       dxx1=xvar-x1 >*/
    dxx1 = xvar - x1;
/*<       locyt=locy >*/
    locyt = *locy;
/*<       do 40 i=1,kntr >*/
    i_1 = outinf_1.kntr;
    for (i = 1; i <= i_1; ++i) {
/*<       iseq=itab(i) >*/
	tabinf_1.iseq = outinf_1.itab[i - 1];
/*<       iseq=nodplc(iseq+4) >*/
	tabinf_1.iseq = nodplc[tabinf_1.iseq + 3];
/*<       v1=value(loco1+iseq) >*/
	v1 = blank_1.value[loco1 + tabinf_1.iseq - 1];
/*<       v2=value(loco2+iseq) >*/
	v2 = blank_1.value[loco2 + tabinf_1.iseq - 1];
/*<       yvr=v1+(v1-v2)*dxx1/dx1x2 >*/
	yvr = v1 + (v1 - v2) * dxx1 / dx1x2;
/*<       tol=dmin1(dabs(v1),dabs(v2))*1.0d-10 >*/
/* Computing MAX */
	d_1 = abs(v1), d_2 = abs(v2);
	tol = min(d_2,d_1) * 1e-10;
/*<       if (dabs(yvr).le.tol) yvr=0.0d0 >*/
	if (abs(yvr) <= tol) {
	    yvr = 0.;
	}
/*<       value(locyt+ippnt)=yvr >*/
	blank_1.value[locyt + ippnt - 1] = yvr;
/*<       locyt=locyt+npoint >*/
	locyt += outinf_1.npoint;
/*<    40 continue >*/
/* L40: */
    }
/*<       if (ippnt.ge.npoint) go to 100 >*/
    if (ippnt >= outinf_1.npoint) {
	goto L100;
    }
/*<       xvar=xstart+dble(ippnt)*xincr >*/
    xvar = outinf_1.xstart + (doublereal) ippnt * outinf_1.xincr;
/*<       if (dabs(xvar).ge.dabs(xvtol)) go to 20 >*/
    if (abs(xvar) >= abs(xvtol)) {
	goto L20;
    }
/*<       xvar=0.0d0 >*/
    xvar = 0.;
/*<       go to 20 >*/
    goto L20;

/*  special handling if icalc = 1 */

/* ...  icalc=1;  just copy over the single point and return */
/*<    50 ippnt=1 >*/
L50:
    ippnt = 1;
/*<       value(locx+ippnt)=xvar >*/
    blank_1.value[*locx + ippnt - 1] = xvar;
/*<       locyt=locy >*/
    locyt = *locy;
/*<       do 60 i=1,kntr >*/
    i_1 = outinf_1.kntr;
    for (i = 1; i <= i_1; ++i) {
/*<       iseq=itab(i) >*/
	tabinf_1.iseq = outinf_1.itab[i - 1];
/*<       iseq=nodplc(iseq+4) >*/
	tabinf_1.iseq = nodplc[tabinf_1.iseq + 3];
/*<       value(locyt+ippnt)=value(loco1+iseq) >*/
	blank_1.value[locyt + ippnt - 1] = blank_1.value[loco1 + 
		tabinf_1.iseq - 1];
/*<       locyt=locyt+npoint >*/
	locyt += outinf_1.npoint;
/*<    60 continue >*/
/* L60: */
    }
/*<       go to 100 >*/
    goto L100;

/*  return */

/*<   100 numpnt=ippnt >*/
L100:
    *numpnt = ippnt;
/*<       return >*/
    return 0;
/*<       end >*/
} /* ntrpl8_ */

#undef cvalue
#undef nodplc


