C*	DSMPRS	- PARSE COMMAND LINE
C
	SUBROUTINE DSMPRS (ISTDEV, IENDEV)
C
C 11/21/79	LEN	- ADDED WORD TO DSMNOT.DAT AFTER 9 WORDS OF DATE/TIME
C		TO POINT TO MESSAGES FOR EXCEEDED ALLOCATIONS AT END OF DSMNOT.
C 12/10/79	LEN	- ALLOWED MORE THAN ONE UIC SPECIFICATION ON THE
C		INPUT COMMAND LINE E.G (DSM DB2:[310,*]+[320,4]+[1,*]
C 04/17/80	LEN	- IF CAN'T OPEN DSM.LOG, MAKE A NEW VERSION
C
C	PARSE MCR COMMAND LINE -
C
C	ISTDEV	- RETURNED,STARTING DEVICE TO SEARCH, RELATIVE TO IDEV(1,ISTDEV)
C	IENDEV	- RETURNED, ENDING DEVICE TO SEARCH, RELATIVE TO IDEV(1,IENDEV)
C
	INCLUDE 'DSMCM.COM/NOLIST'
C
	DIMENSION IBUF(40), ITASK(16), IDLUN(6)
	BYTE BDLUN(12), BASC50(6), BUIC(2)
C
	EQUIVALENCE (ITASK,IDLUN,BDLUN,BASC50)
	EQUIVALENCE (IUIC, BUIC)
C
	DATA ILTB/7/, IRBTB/1/
C
	LBITON(IBIT) = IAND(IBIT,IFLAGS) .NE. 0
C
	CALL GETMCR (IBUF, IDSW)
	IF (IDSW .LT. 0) GO TO 400
	LALL = .FALSE.
C
C	PARSE MCR/PDS COMMAND LINE
C
	CALL GETADR (IBUFAD, IBUF)
	NCH = 80
C
C	LOOP ON ALL UIC'S ON COMMAND LINE
C	NOTE THAT ONLY THE FIRST UIC MAY HAVE AN ASSOCIATED DEVICE/UNIT #
C	ALL FOLLOWING UIC'S WILL BE SEARCHED ON SAME DEVICE
C
	LFIRST = .TRUE.
	NDSCAN = 0
 100	CONTINUE
	IFLAGS = 0
	CALL DSMPR1 (IBUFAD, NCH, NER)
	IF (NER.NE.0) GO TO 610
	IF (.NOT.LFIRST) GO TO 370		! NOT FIRST TIME
	LFIRST = .FALSE.
C
C	IF UIC NOT SPECIFIED, GETTSK WILL GET THE DEFAULT UIC
C
	IF (LBITON(IDSUIC)) GO TO 200
	CALL GETTSK (ITASK, IDSW)
	IF (IDSW .LT. 0) GO TO 620
	IUIC = ITASK(8)
C
C	IF DEVICE NOT SPECIFIED, GETLUN WILL GET THE DEFAULT DEVICE.
C	**NOTE** WE ARE COUNTNG ON LUN 1 BEING ASSIGNED BY DEFAULT
C		 TO THE DEFAULT DEVICE, IE NOT ASSIGNED OR PREVIOUSLY
C		 USED UP TO THIS POINT.
C
 200	CONTINUE
	IF (LBITON(IDSDEV)) GO TO 300
	CALL GETLUN (1, IDLUN, IDSW)
	IF (IDSW .LT. 0) GO TO 630
	IUDEV = IDLUN(1)
	IUNIT = BDLUN(3)
C
 300	CONTINUE
C
C	COMPARE DEVICE FOR VALIDITY AGAINST DEVICE LIST
C
	DO 350 I=1, MAXDEV
	IF (IDEV(1,I).EQ.IUDEV .AND. IDEV(2,I).EQ.IUNIT) GO TO 360
 350	CONTINUE
	GO TO 605
C
 360	CONTINUE
	ISTDEV = I
	IENDEV = I
	IUDSAV = IUDEV
	IUNSAV = IUNIT
	GO TO 385
C
C	HERE TO PROCESS SUBSEQUENT UIC'S - DISALLOW FURTHER DEVICE SPEC
C
 370	CONTINUE
	IF (IUDEV.EQ.IUDSAV .AND. IUNIT.EQ.IUNSAV) GO TO 372
	IF (LBITON (IDSDEV)) GO TO 606		! DIFFERENT DEVICE !
	IUDEV = IUDSAV
	IUNIT = IUNSAV
 372	IF (.NOT.LBITON(IDSUIC)) GO TO 607	! NO UIC SPECIFIED !
C
C	CONVERT UIC TO RAD50 FOR COMPARES IN DSMNDE.FTN
C
 385	CONTINUE
	NDSCAN = NDSCAN + 1
	IF (NDSCAN .GT. MXSCAN) GO TO 610
	ENCODE (6, 500,BASC50) BUIC(2), BUIC(1)
 500	FORMAT (O3, O3)
	DO 390 I=1,6
	IF (BASC50(I) .EQ. ' ') BASC50(I) = '0'
 390	CONTINUE
	CALL IRAD50 (3, BASC50(1), IGRP50(NDSCAN))
	CALL IRAD50 (3, BASC50(4), IOWN50(NDSCAN))
	IGPFLG(NDSCAN) = IFLAGS
	IF (LBITON(IDSPLU)) GO TO 100
	IF (.NOT.LBITON(IDSEOL)) GO TO 610
	GO TO 900
C
C	SET FOR SYSTEM MODE, RUN REALTIME
C	ASSUME GETMCR WILL FAIL IT RUN/RE IS STARTUP MODE.
C	SET UNIT 6 TO LB0:[1,1]DSM.LOG IF IN 'ALL' MODE SO WE HAVE A
C	REPORT OF $$$DSM ACTIVITIES REGARDING FILE DELETIONS AND
C	PDSUPF.DAT MODIFICATIONS.
C
 400	CONTINUE
	LALL = .TRUE.
D	GO TO 8888
D8887	CONTINUE
	CALL ERRSET (29, .TRUE., .FALSE., .TRUE., .FALSE., )
	OPEN (UNIT=6, NAME='LB0:[1,1]DSM.LOG', ACCESS='APPEND',
	1	TYPE='OLD', CARRIAGECONTROL = 'FORTRAN', ERR=402)
	GO TO 405
C
C	UNABLE TO OPEN DSM.LOG, MAKE A NEW ONE
C
 402	CONTINUE
	OPEN (UNIT=6, NAME='LB0:[1,1]DSM.LOG', 
	1	TYPE='NEW', CARRIAGECONTROL = 'FORTRAN')
 405	CONTINUE
D8888	CONTINUE
	WRITE (6, 501) IDTTM
 501	FORMAT (/' $$$DSM ACTIVITY LOG FOR ',9A2/)
	ISTDEV = 1
	IENDEV = MAXDEV
C
C	OPEN TOTALS OUTPUT FILE FOR UIC'S BLOCKS USED SUMMARYS
C	USED IN ...NOT ON LOGIN FOR REPORT TO USER.
C	10 ATTEMPTS WILL BE MADE TO OPEN THE FILE
C
	DO 410 I=1, 10
	CALL X1LU (FIDTB, RBTB, IRBTB, 1, 0,
	1	ILTB, 'U', 'LB0:', -1, '[1,1]DSMNOT.DAT', NER)
	IF (NER .EQ. 0) GO TO 420
 410	CONTINUE
	CALL DSMER (ILTB, NER)
C
C	WRITE OUT 9 WORDS OF DATE AND TIME, 1 WORD TO POINT TO MESSAGES AT
C	END OF DSMNOT FOR EXCEEDED ALLOCATIONS, AND 1 WORD NFO COUNT(0). THIS
C	WILL BE WRITTEN OVER WITH CORRECT NFO ON COMPLETION OF EACH DEVICE.
C	NFO=0 IN DSMNOT.DAT INDICATES THE END-OF-FILE.
C
 420	CONTINUE
	NRTB = 1
D	GO TO 9000
D8999	CONTINUE
	CALL X1DW (FIDTB, NRTB, 9, IDTTM)
	CALL X1DW (FIDTB, NRTB, 1, 0)
	CALL X1DW (FIDTB, NRTB, 1, 0)
D9000	CONTINUE
	GO TO 900
C
C	ERROR MESSAGES
C
 605	CONTINUE
	WRITE (6, 505) (IDEV(1,I),IDEV(2,I),I=1,MAXDEV)
 505	FORMAT (' DSM - ILLEGAL DEVICE, MUST BE - ',<MAXDEV>
	1	('''',A2,O2,':''', 3X))
	GO TO 890
 606	CONTINUE
	WRITE (6, 506) IUDSAV,IUNSAV
 506	FORMAT (' DSM - ONLY ONE DEVICE TYPE ALLOWED, DEFAULT = ',
	1	A2,O2,':')
	GO TO 890
 607	CONTINUE
	WRITE (6, 507)
 507	FORMAT (' DSM - MUST SPECIFY SUBSEQUENT UIC''S')
	GO TO 890
 610	CONTINUE
	WRITE (6, 510)
 510	FORMAT (' DSM - COMMAND SYNTAX ERROR')
	GO TO 890
C
 620	CONTINUE
	WRITE (6, 520) IDSW
 520	FORMAT (' DSM - ERROR ON GETTSK',I5)
	GO TO 890
C
 630	CONTINUE
	WRITE (6, 530) IDSW
 530	FORMAT (' DSM - ERROR ON GETLUN',I5)
	GO TO 890
C
 890	CONTINUE
	CALL EXIT
C
 900	CONTINUE
	RETURN
C
	END
