C	functions to read text and numbers from a character string

C	REMOVED functions: getreal, getreal0, getreald, getcd
C	REMOVED subroutine: tripd
C	(not impl for quadruple precision)






	SUBROUTINE SKIPCOMMA (TEXT,IPOS)
C	skip blanks and also a comma if it is the next non-blank character
	CHARACTER*(*) TEXT !  input:  the character string
	INTEGER IPOS       !  input:  the first position
C	                   !  output: the next position

	ILAST=LEN(TEXT)

	DO WHILE (IPOS.LE.ILAST)
	 IF (TEXT(IPOS:IPOS).EQ.' ') THEN
	  IPOS=IPOS+1
	 ELSE
	  GOTO 11
	 END IF
	END DO

11	IF (IPOS.LE.ILAST) THEN
	  IF (TEXT(IPOS:IPOS).EQ.',') IPOS=IPOS+1
	END IF

	RETURN
	END





	CHARACTER*(*) FUNCTION GETSTRING (TEXT,IPOS)
C	get next string without blanks
	CHARACTER*(*) TEXT !  input:  the character string
	INTEGER IPOS       !  input:  the first position
C	                   !  output: the next position

	CHARACTER*1 CH

	ILAST=LEN(TEXT)

	DO WHILE (IPOS.LE.ILAST)
	 IF (TEXT(IPOS:IPOS).EQ.' ') THEN
	  IPOS=IPOS+1
	 ELSE
	  GOTO 11
	 END IF
	END DO

11	IF (IPOS.GT.ILAST) THEN
	 GETSTRING=' '
	ELSE
	 GETSTRING=' '
	 J=0
	 DO WHILE (IPOS.LE.ILAST)
	  CH=TEXT(IPOS:IPOS)
	  IF (CH.NE.' ') THEN
	   J=J+1
	   IF (J.LE.LEN(GETSTRING)) THEN
	    GETSTRING(J:J)=CH
	    IPOS=IPOS+1
	   ELSE
	    STOP 5561
	   END IF
	  ELSE
	   GOTO 21
	  END IF
	 END DO
	END IF

21	RETURN
	END





	CHARACTER*(*) FUNCTION GETCHNB (TEXT,IPOS)
C	get next CHaracter that is Non-Blank
	CHARACTER*(*) TEXT !  input:  the character string
	INTEGER IPOS       !  input:  the first position
C	                   !  output: the next position

	ILAST=LEN(TEXT)

	DO WHILE (IPOS.LE.ILAST)
	 IF (TEXT(IPOS:IPOS).EQ.' ') THEN
	  IPOS=IPOS+1
	 ELSE
	  GOTO 11
	 END IF
	END DO

11	IF (IPOS.GT.ILAST) THEN
	 GETCHNB=' '
	ELSE
	 GETCHNB=' '
	 IF (1.LE.LEN(GETCHNB)) THEN
	  GETCHNB(1:1)=TEXT(IPOS:IPOS)
	  IPOS=IPOS+1
	 ELSE
	  STOP 5561
	 END IF
	END IF

	RETURN
	END





	INTEGER FUNCTION IGETINTP (TEXT,IPOS)
C	get positive integer without introductory blanks and sign
	CHARACTER*(*) TEXT !  input:  the character string
	INTEGER IPOS       !  input:  the first position
C	                   !  output: the next position

	INTEGER IREAD(40)
	CHARACTER*1 CH

	CH='0'
	ICH0=ICHAR(CH)
	CH='9'
	ICH9=ICHAR(CH)

	ILAST=LEN(TEXT)

	IF (IPOS.GT.ILAST) THEN
	 IGETINTP=0
	ELSE
	 J=0
	 DO WHILE (IPOS.LE.ILAST)
	  CH=TEXT(IPOS:IPOS)
	  ICH=ICHAR(CH)
	  IF (ICH.GE.ICH0 .AND. ICH.LE.ICH9) THEN
	   J=J+1
	   IF (J.GT.40) STOP 1566
	   IREAD(J)=ICH-ICH0
	   IPOS=IPOS+1
	  ELSE
	   GOTO 21
	  END IF
	 END DO
21	 IGETINTP=0
	 DO K=1,J
	  IGETINTP=IGETINTP+IREAD(K)*(10**(J-K))
	 END DO
	END IF

	CALL SKIPCOMMA (TEXT,IPOS)

	RETURN
	END






	INTEGER FUNCTION IGETINT (TEXT,IPOS)
C	get integer
	CHARACTER*(*) TEXT !  input:  the character string
	INTEGER IPOS       !  input:  the first position to search in
C	                   !  output: the next position

	INTEGER IREAD(40)
	CHARACTER*1 CH

	CH='0'
	ICH0=ICHAR(CH)
	CH='9'
	ICH9=ICHAR(CH)

	ILAST=LEN(TEXT)

	DO WHILE (IPOS.LE.ILAST)
	 IF (TEXT(IPOS:IPOS).EQ.' ') THEN
	  IPOS=IPOS+1
	 ELSE
	  GOTO 11
	 END IF
	END DO

11	IF (IPOS.GT.ILAST) THEN
	 IGETINT=0
	ELSE
	 CH=TEXT(IPOS:IPOS)
	 IF (CH.EQ.'+') THEN
	  IFAKT=1
	  IPOS=IPOS+1
	 ELSE IF (CH.EQ.'-') THEN
	  IFAKT=-1
	  IPOS=IPOS+1
	 ELSE
	  IFAKT=1
	 END IF
	 J=0
	 DO WHILE (IPOS.LE.ILAST)
	  CH=TEXT(IPOS:IPOS)
	  ICH=ICHAR(CH)
	  IF (ICH.GE.ICH0 .AND. ICH.LE.ICH9) THEN
	   J=J+1
	   IF (J.GT.40) STOP 1566
	   IREAD(J)=ICH-ICH0
	   IPOS=IPOS+1
	  ELSE
	   GOTO 21
	  END IF
	 END DO
21	 IGETINT=0
	 DO K=1,J
	  IGETINT=IGETINT+IREAD(K)*(10**(J-K))
	 END DO
	 IGETINT=IFAKT*IGETINT
	END IF

	CALL SKIPCOMMA (TEXT,IPOS)

	RETURN
	END
