% 	SUBROUTINE CHAR2I(STRING,IVAL,NVALS) A C_TITLE CHAR2I converts ASCII character string to binary integer. N C                                                                             I C_ARGS    TYPE        VARIABLE    I/O    DESCRIPTION                      A 	CHARACTER*(*) STRING      !I     Character string of any length  G C                                        which contains  only  decimal  H C                                        characters or characters '+' or- C                                        '-'. E 	INTEGER*4 IVAL(1)         !O     Dimensioned variable containing the H C                                        character integers converted to: C                                        binary integers. E 	INTEGER*4 NVALS           !I     Number of integers to extract from  > C                                        the character string. C A C_DESC  CHAR2I shall convert an ASCII character string of varying H C       length and containing only decimal characters and characters '+'L C       or '-' to binary integer form. The calling routine shall specify the? C       number of integer variables to extract from the string. N C                                                                             E C_HIST  24Sep85  Eric M. Eliason  U.S.G.S. Flagstaff Original Version 7 C       13Nov86  Joni L. Bauers   updated documentation  C N C_END                                                                         N C*****************************************************************************/ C Initialize the output array IVAL to all zeros M C****************************************************************************        DO 10 I = 1,NVALS     10 IVAL(I) = 0 N C*****************************************************************************E C Find, if there is one, the blank character or comma after the first ! C number in the character string. M C****************************************************************************        ISTART = 1       DO 500 IV = 1,NVALS M C**************************************************************************** = C Find the first non-blank character in the  character string M C****************************************************************************        ILEN = LEN(STRING)       DO 100 I1 = ISTART,ILEN A       IF (STRING(I1:I1).NE.' '.AND.STRING(I1:I1).NE.',') GOTO 110    100 CONTINUEN C*****************************************************************************< C All characters in string are blank, return a value of zeroM C****************************************************************************        GOTO 9000    110 CONTINUE         DO 200 I2 = I1,ILEN @       IF (STRING(I2:I2).EQ.' '.OR.STRING(I2:I2).EQ.',') GOTO 210   200 CONTINUE       I2 = ILEN + 1    210 I2 = I2 - 1 O C****************************************************************************** B C Use the DECODE statement to convert the string to binary integerO C******************************************************************************        NCHARS = I2 - I1 + 14       DECODE(NCHARS,900,STRING(I1:I2),ERR=9000) IRES   900 FORMAT(I<NCHARS>)        IVAL(IV) = IRES O C****************************************************************************** # C Set up for next time through loop N C*****************************************************************************       ISTART = I2 + 1    500 CONTINUE         RETURNO C****************************************************************************** C C Set the result to zero, something wrong with the character string O C******************************************************************************   9000 CONTINUE       RETURN	       END 