1C*GRITOC - convert integer to character string
2C+
3      INTEGER FUNCTION GRITOC(INT, STR)
4      INTEGER INT
5      CHARACTER*(*) STR
6C
7C Convert integer INT into (decimal) character string in STR.
8C-----------------------------------------------------------------------
9      CHARACTER*10 DIGITS
10      INTEGER D, I, INTVAL, J, L
11      CHARACTER K
12      DATA DIGITS /'0123456789'/
13C
14      INTVAL = ABS(INT)
15      I = 0
16C
17C Generate digits in reverse order.
18C
19  10  CONTINUE
20          I = I+1
21          D = 1 + MOD(INTVAL, 10)
22          STR(I:I) = DIGITS(D:D)
23          INTVAL = INTVAL/10
24          IF (I.LT.LEN(STR) .AND. INTVAL.NE.0) GOTO 10
25C
26C Add minus sign if necessary.
27C
28      IF (INT.LT.0 .AND. I.LT.LEN(STR)) THEN
29          I = I+1
30          STR(I:I) = '-'
31      END IF
32      GRITOC = I
33C
34C Reverse string in place.
35C
36      L = I/2
37      DO 20 J=1,L
38          K = STR(I:I)
39          STR(I:I) = STR(J:J)
40          STR(J:J) = K
41          I = I-1
42   20 CONTINUE
43C-----------------------------------------------------------------------
44      END
45