C
C SUBROUTINE 'STRTKN'
C ===================
C
C Split string into lists of character and numeric value tokens
C
      SUBROUTINE STRTKN (STR, SEP, MAXTOK, CHSTR, NCHSTR, VALUES, NVALS)
C
C PARAMETERS
C
C      STR (I)   Character string to be searched
C      SEP (I)   Character string containing characters to be used as 
C                separators; if this starts with a space then white space or 
C                white space + one other separator character will be taken as 
C                a single separator.
C   MAXTOK (I)   Maximum number of tokens to be looked for
C    CHSTR (O)   Array returning character strings (tokens may be truncated
C                or expanded with blanks depending on the lengths of the
C                character strings in this array and the lengths of the
C                tokens found (should be dimensioned to at least MAXTOK)
C   NCHSTR (O)   No. of character string tokens found
C   VALUES (O)   Array returning real values (should be dimensioned to
C                at least MAXTOK)
C    NVALS (O)   Number of value tokens found
C
C====== Specification statements
C
      CHARACTER*(*) CHSTR(*)
      CHARACTER*(*) STR, SEP
      REAL VALUES(*)
      LOGICAL ERR
C
C====== Get tokens
C
      NTOK = 0
      NCHSTR = 0
      NVALS = 0
      IL = 0
100   I = NXTTOK (STR, SEP, IL, M1, M2)
      IF (I.LT.0) RETURN
      NTOK = NTOK + 1
      ERR = .TRUE.
      IF (I.GT.0) X = FLPVAL (STR(M1:M2), ERR)
      IF (ERR) THEN
         NCHSTR = NCHSTR + 1
         IF (I.EQ.0) THEN
            CHSTR (NCHSTR) = ' '
         ELSE
            CHSTR (NCHSTR) = STR (M1:M2)
         ENDIF
      ELSE
         NVALS = NVALS + 1
         VALUES (NVALS) = X
      ENDIF
      IF (NTOK.LT.MAXTOK) GO TO 100
      RETURN
      END
