	SUBROUTINE PARSE (INP, OUPNAM, DEVR, EXTR, LAST)
C
C	VERSION OF 02-MAR-83.  
C
C	R. W. BARNARD, ALBUQUERQUE, NM
C
	BYTE INP(1), OUPNAM(1), INPNAM(15), DEV(4), EXT(4), IEXT
	DATA NUL /"0/
C
	IF (LAST.GT.0) GO TO 150		!AUXILLARY FILE
	IEXT=.FALSE.
	DO 10 K=1,14
10	INPNAM(K)= INP(K)		!NEED TO ADD NULL BYTE TO INPNAM
	INPNAM(15)= NUL			!FOR INDEX TO STOP THERE.
C
C	LOOK FOR DEVICE
	ICT= 4
	KOLON= INDEX (INPNAM, ':')	!USE : TO INDICATE DEVICE GIVEN
	IF (KOLON.GT.0) GO TO 40	!DEV: GIVEN
	CALL R50ASC (3, DEVR, DEV)	!BUILD BYTE SPECIFICATION
	DEV(4)= ':'			!FROM RAD 50 SPEC
C
C	CHECK FOR 1- OR 2-CHARACTER DEVICES
	DO 20 K=2,4			!STARTING AT THE END, CHECK TO SEE
	J= 5- K				!IF ANY CHARS IN DEVICE ARE BLANK
	IF (DEV(J).NE.' ') GO TO 20	!NO - BRANCH
	DEV(J)= DEV(J+1)		!YES - COPY COLON BACK ONE SPACE
	ICT= ICT-1			!DECREMENT END OF DEVICE COUNTER
20	CONTINUE
C
	DO 30 K=1,ICT			!NO DEV GIVEN
30	OUPNAM(K)= DEV(K)		!USE DEFAULT DEVICE SPEC
	LAST= ICT			!POSITION IN OUPNAM FOR DEFAULT
	GO TO 60
40	DO 50 K=1,KOLON			!YES - DEV GIVEN
50	OUPNAM(K)= INPNAM(K)		!COPY
	LAST= KOLON			!NEXT POS IN OUPNAM
C
C	WORK ON FILENAME NOW
60	DO 70 K= 1,7
	KI= KOLON+ K
	KPOINT= K-1			!POS OF LAST ALPHA CHAR IN INPNAM
	IF (INPNAM(KI).EQ.'.') IEXT=.TRUE.	!EXT GIVEN
	IF (INPNAM(KI).EQ.' '.OR.IEXT) GO TO 80	!FILE NAME < 6 CHAR & NO EXT
70	CONTINUE
80	DO 90 K= 1,KPOINT	!USE ACTUAL CHAR COUNT FROM INPNAM
	KI= KOLON+ K
	KO= LAST+ K		!LOCATION IN OUPNAM (OFFSET IN INPNAM)
90	OUPNAM(KO)= INPNAM(KI)		!FOR DEFAULT FILENAME
	LAST= KO			!TOTAL LENGTH OF OUPNAM W/O EXT
C
	IF (IEXT) GO TO 120			!EXT GIVEN
100	CALL R50ASC (3, EXTR, EXT(2))		!BUILD EXT FROM RAD 50
	EXT(1)= '.'				!SPECIFICATIONS
	DO 110 K= 1,4				!NO EXT - USE DEFAULT
	KO= LAST+K				!OFFSET FOR OUPNAM
110	OUPNAM(KO)= EXT(K)			!COPY DEFAULT EXTENSION
	GO TO 140
C
120	OUPNAM(LAST+1)= INPNAM(KI+1)		!COPIES "."
	KOLON= KI				!REDEFINE OFFSET IN INPUT
	DO 130 K= 2,4				!YES - COPY EXT
	KI= KOLON+ K				!OFFSET FOR INPNAM
	KO= LAST+ K				!OFFSET FOR OUPNAM
	IEXT= (INPNAM(KI).LT.'A'.OR.INPNAM(KI).GT.'Z')	!LAST CHAR OF EXT
     1	.AND. (INPNAM(KI).LT.'0'.OR.INPNAM(KI).GT.'9')	!(OR NUMBER)!
	IF (IEXT) GO TO 140		!SKIP IF NO ALPHA OR NUM (IE, END)
130	OUPNAM(KO)= INPNAM(KI)			!COPY
C
140	KO= KO+ 1				!LOCATION OF NEXT CHAR
	OUPNAM(KO)= NUL				!NULL BYTE TO CLOSE
	RETURN
C
150	DO 160 K= 1,LAST			!COPIES OVER AUX FILE
160	OUPNAM(K)= INP(K)			!(DEV AND FILENAME)
	GO TO 100				!GO COPY EXTENSION
	END
