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

/* Table of constant values */

static integer c__1 = 1;

/*<       subroutine alfnum(number,string,ipos) >*/
/* Subroutine */ int alfnum_(number, string, ipos)
integer *number;
doublereal *string;
integer *ipos;
{
    /* Initialized data */

    static struct {
	char e_1[80];
	doublereal e_2;
	} equiv_9 = { {'0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', '3', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '4', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', '5', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', '6', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '7', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', '8', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', '9', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, 0. };

#define adigit ((doublereal *)&equiv_9)

    static struct {
	char e_1[8];
	doublereal e_2;
	} equiv_10 = { {'-', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, 0. };

#define aminus (*(doublereal *)&equiv_10)


    extern /* Subroutine */ int move_();
    static integer istop, idigit;
    static doublereal tmpdgt;
    static integer istart, numtmp, num;

    /* Parameter adjustments */
    --string;

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

/*     this routine converts number into character form, storing the */
/* characters in the character array string, beginning with the position 
*/
/* indicated by ipos. */

/* **** note that the 'ipos' variable is changed to indicate the position 
*/
/*      of the next unwritten character.  this could clobber constants if 
*/
/*      ipos is not a variable in the calling program */

/*<       dimension string(1) >*/
/*<       dimension adigit(10) >*/
/*<       data adigit / 1h0,1h1,1h2,1h3,1h4,1h5,1h6,1h7,1h8,1h9 / >*/
/*<       data aminus / 1h- / >*/


/*<       num=number >*/
    num = *number;

/*  check for number < 0 */

/*<       if (num.ge.0) go to 10 >*/
    if (num >= 0) {
	goto L10;
    }
/*<       num=-num >*/
    num = -num;
/* ...  negative number:  insert minus sign */
/*<       call move(string,ipos,aminus,1,1) >*/
    move_(&string[1], ipos, &aminus, &c__1, &c__1);
/*<       ipos=ipos+1 >*/
    ++(*ipos);

/*  convert number one digit at a time, in reverse order */

/*<    10 istart=ipos >*/
L10:
    istart = *ipos;
/*<    20 numtmp=num/10 >*/
L20:
    numtmp = num / 10;
/*<       idigit=num-numtmp*10 >*/
    idigit = num - numtmp * 10;
/*<       call move(string,ipos,adigit(idigit+1),1,1) >*/
    move_(&string[1], ipos, &adigit[idigit], &c__1, &c__1);
/*<       ipos=ipos+1 >*/
    ++(*ipos);
/*<       num=numtmp >*/
    num = numtmp;
/*<       if (num.ne.0) go to 20 >*/
    if (num != 0) {
	goto L20;
    }
/*<       istop=ipos-1 >*/
    istop = *ipos - 1;

/*  now reverse the order of the digits */

/*<    30 if (istop.le.istart) go to 40 >*/
L30:
    if (istop <= istart) {
	goto L40;
    }
/*<       call move(tmpdgt,1,string,istart,1) >*/
    move_(&tmpdgt, &c__1, &string[1], &istart, &c__1);
/*<       call move(string,istart,string,istop,1) >*/
    move_(&string[1], &istart, &string[1], &istop, &c__1);
/*<       call move(string,istop,tmpdgt,1,1) >*/
    move_(&string[1], &istop, &tmpdgt, &c__1, &c__1);
/*<       istart=istart+1 >*/
    ++istart;
/*<       istop=istop-1 >*/
    --istop;
/*<       go to 30 >*/
    goto L30;

/*  conversion complete */

/*<    40 return >*/
L40:
    return 0;
/*<       end >*/
} /* alfnum_ */

#undef aminus
#undef adigit


