/* nxtpwr.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"

/*<       subroutine nxtpwr(pwrseq,pdim) >*/
/* Subroutine */ int nxtpwr_(pwrseq, pdim)
integer *pwrseq, *pdim;
{
    /* System generated locals */
    integer i_1;

    /* Local variables */
    static integer psum, i, k, km1;

    /* Parameter adjustments */
    --pwrseq;

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

/*     this routine determines the 'next' set of exponents for the */
/* different dimensions of a polynomial. */

/*<       integer pwrseq(1),pdim,psum >*/


/*<       if (pdim.eq.1) go to 80 >*/
    if (*pdim == 1) {
	goto L80;
    }
/*<       k=pdim >*/
    k = *pdim;
/*<    10 if (pwrseq(k).ne.0) go to 20 >*/
L10:
    if (pwrseq[k] != 0) {
	goto L20;
    }
/*<       k=k-1 >*/
    --k;
/*<       if (k.ne.0) go to 10 >*/
    if (k != 0) {
	goto L10;
    }
/*<       go to 80 >*/
    goto L80;
/*<    20 if (k.eq.pdim) go to 30 >*/
L20:
    if (k == *pdim) {
	goto L30;
    }
/*<       pwrseq(k)=pwrseq(k)-1 >*/
    --pwrseq[k];
/*<       pwrseq(k+1)=pwrseq(k+1)+1 >*/
    ++pwrseq[k + 1];
/*<       go to 100 >*/
    goto L100;
/*<    30 km1=k-1 >*/
L30:
    km1 = k - 1;
/*<       do 40 i=1,km1 >*/
    i_1 = km1;
    for (i = 1; i <= i_1; ++i) {
/*<       if (pwrseq(i).ne.0) go to 50 >*/
	if (pwrseq[i] != 0) {
	    goto L50;
	}
/*<    40 continue >*/
/* L40: */
    }
/*<       pwrseq(1)=pwrseq(pdim)+1 >*/
    pwrseq[1] = pwrseq[*pdim] + 1;
/*<       pwrseq(pdim)=0 >*/
    pwrseq[*pdim] = 0;
/*<       go to 100 >*/
    goto L100;
/*<    50 psum=1 >*/
L50:
    psum = 1;
/*<       k=pdim >*/
    k = *pdim;
/*<    60 if (pwrseq(k-1).ge.1) go to 70 >*/
L60:
    if (pwrseq[k - 1] >= 1) {
	goto L70;
    }
/*<       psum=psum+pwrseq(k) >*/
    psum += pwrseq[k];
/*<       pwrseq(k)=0 >*/
    pwrseq[k] = 0;
/*<       k=k-1 >*/
    --k;
/*<       go to 60 >*/
    goto L60;
/*<    70 pwrseq(k)=pwrseq(k)+psum >*/
L70:
    pwrseq[k] += psum;
/*<       pwrseq(k-1)=pwrseq(k-1)-1 >*/
    --pwrseq[k - 1];
/*<       go to 100 >*/
    goto L100;
/*<    80 pwrseq(1)=pwrseq(1)+1 >*/
L80:
    ++pwrseq[1];

/*  finished */

/*<   100 return >*/
L100:
    return 0;
/*<       end >*/
} /* nxtpwr_ */

