      SUBROUTINE MAIN
      LOGICAL*1 ARG(40), NAME(40)
      INTEGER VERBOS, DEBUG, I
      INTEGER GETARG, INDEX, LENGTH
      LOGICAL*1 USESTR(25)
      DATA USESTR(1)/117/,USESTR(2)/115/,USESTR(3)/97/,USESTR(4)/103/,US
     *ESTR(5)/101/,USESTR(6)/58/,USESTR(7)/32/,USESTR(8)/32/,USESTR(9)/1
     *09/,USESTR(10)/117/,USESTR(11)/98/,USESTR(12)/108/,USESTR(13)/100/
     *,USESTR(14)/32/,USESTR(15)/91/,USESTR(16)/45/,USESTR(17)/100/,USES
     *TR(18)/118/,USESTR(19)/93/,USESTR(20)/32/,USESTR(21)/116/,USESTR(2
     *2)/97/,USESTR(23)/115/,USESTR(24)/107/,USESTR(25)/0/
      CALL QUERY(USESTR)
      DEBUG = 0
      VERBOS = 0
      NAME(1) = 0
      I=1
23000 IF (.NOT.(GETARG(I, ARG, 40) .NE. -1))GOTO 23002
      CALL FOLD(ARG)
      IF (.NOT.(ARG(1) .EQ. 45))GOTO 23003
      IF (.NOT.(INDEX(ARG, 100) .GT. 0))GOTO 23005
      DEBUG = 1
23005 CONTINUE
      IF (.NOT.(INDEX(ARG, 118) .GT. 0))GOTO 23007
      VERBOS = 1
23007 CONTINUE
      GOTO 23004
23003 CONTINUE
      CALL STRCPY(ARG, NAME)
23004 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      IF (.NOT.(NAME(1) .EQ. 0))GOTO 23009
      CALL ERROR(USESTR)
23009 CONTINUE
      IF (.NOT.(LENGTH(NAME) .GT. 4))GOTO 23011
      NAME(5) = 0
23011 CONTINUE
      CALL DOMU(NAME, DEBUG, VERBOS)
      RETURN
      END
      SUBROUTINE DOMU(NAME, DEBUG, VERBOS)
      INTEGER DEBUG, VERBOS, B1(256), B2(256), JUNK, INTM, MINT, INTR, R
     *INT, STVADR, STBLCK, ROSIZE, INT, NLBL, N
      INTEGER SSPAWN, OPEN, READF, WRITEF, CREATE, REMOVE, GETLIN
      LOGICAL*1 NAME(5), MUTASK(40), TASKMU(40), ROTASK(40), TASKRO(40),
     * FILE(40), SPWBUF(80), BUF(512), PID(7)
      LOGICAL*1 LOCAL(6)
      LOGICAL*1 PIPCMD(58)
      LOGICAL*1 PIPFMT(54)
      LOGICAL*1 ROMAC(30)
      LOGICAL*1 ROTKB(56)
      LOGICAL*1 DMMAC(7)
      LOGICAL*1 DMTKB(33)
      LOGICAL*1 MUCMD(72)
      DATA LOCAL(1)/108/,LOCAL(2)/111/,LOCAL(3)/99/,LOCAL(4)/97/,LOCAL(5
     *)/108/,LOCAL(6)/0/
      DATA PIPCMD(1)/112/,PIPCMD(2)/105/,PIPCMD(3)/112/,PIPCMD(4)/32/,PI
     *PCMD(5)/100/,PIPCMD(6)/117/,PIPCMD(7)/109/,PIPCMD(8)/109/,PIPCMD(9
     *)/121/,PIPCMD(10)/46/,PIPCMD(11)/116/,PIPCMD(12)/115/,PIPCMD(13)/1
     *07/,PIPCMD(14)/59/,PIPCMD(15)/42/,PIPCMD(16)/47/,PIPCMD(17)/100/,P
     *IPCMD(18)/101/,PIPCMD(19)/47/,PIPCMD(20)/110/,PIPCMD(21)/109/,PIPC
     *MD(22)/44/,PIPCMD(23)/100/,PIPCMD(24)/117/,PIPCMD(25)/109/,PIPCMD(
     *26)/109/,PIPCMD(27)/121/,PIPCMD(28)/46/,PIPCMD(29)/111/,PIPCMD(30)
     */98/,PIPCMD(31)/106/,PIPCMD(32)/59/,PIPCMD(33)/42/,PIPCMD(34)/44/,
     *PIPCMD(35)/100/,PIPCMD(36)/117/,PIPCMD(37)/109/,PIPCMD(38)/109/,PI
     *PCMD(39)/121/,PIPCMD(40)/46/,PIPCMD(41)/109/,PIPCMD(42)/97/,PIPCMD
     *(43)/99/,PIPCMD(44)/59/,PIPCMD(45)/42/,PIPCMD(46)/44/,PIPCMD(47)/1
     *00/,PIPCMD(48)/117/,PIPCMD(49)/109/,PIPCMD(50)/109/,PIPCMD(51)/121
     */,PIPCMD(52)/46/,PIPCMD(53)/116/,PIPCMD(54)/107/,PIPCMD(55)/98/,PI
     *PCMD(56)/59/,PIPCMD(57)/42/,PIPCMD(58)/0/
      DATA PIPFMT(1)/112/,PIPFMT(2)/105/,PIPFMT(3)/112/,PIPFMT(4)/32/,PI
     *PFMT(5)/37/,PIPFMT(6)/115/,PIPFMT(7)/114/,PIPFMT(8)/111/,PIPFMT(9)
     */46/,PIPFMT(10)/116/,PIPFMT(11)/115/,PIPFMT(12)/107/,PIPFMT(13)/59
     */,PIPFMT(14)/42/,PIPFMT(15)/47/,PIPFMT(16)/100/,PIPFMT(17)/101/,PI
     *PFMT(18)/47/,PIPFMT(19)/110/,PIPFMT(20)/109/,PIPFMT(21)/44/,PIPFMT
     *(22)/37/,PIPFMT(23)/115/,PIPFMT(24)/114/,PIPFMT(25)/111/,PIPFMT(26
     *)/46/,PIPFMT(27)/111/,PIPFMT(28)/98/,PIPFMT(29)/106/,PIPFMT(30)/59
     */,PIPFMT(31)/42/,PIPFMT(32)/44/,PIPFMT(33)/37/,PIPFMT(34)/115/,PIP
     *FMT(35)/114/,PIPFMT(36)/111/,PIPFMT(37)/46/,PIPFMT(38)/109/,PIPFMT
     *(39)/97/,PIPFMT(40)/99/,PIPFMT(41)/59/,PIPFMT(42)/42/,PIPFMT(43)/4
     *4/,PIPFMT(44)/37/,PIPFMT(45)/115/,PIPFMT(46)/114/,PIPFMT(47)/111/,
     *PIPFMT(48)/46/,PIPFMT(49)/116/,PIPFMT(50)/107/,PIPFMT(51)/98/,PIPF
     *MT(52)/59/,PIPFMT(53)/42/,PIPFMT(54)/0/
      DATA ROMAC(1)/9/,ROMAC(2)/46/,ROMAC(3)/112/,ROMAC(4)/115/,ROMAC(5)
     */101/,ROMAC(6)/99/,ROMAC(7)/116/,ROMAC(8)/9/,ROMAC(9)/114/,ROMAC(1
     *0)/111/,ROMAC(11)/37/,ROMAC(12)/115/,ROMAC(13)/10/,ROMAC(14)/9/,RO
     *MAC(15)/46/,ROMAC(16)/98/,ROMAC(17)/108/,ROMAC(18)/107/,ROMAC(19)/
     *98/,ROMAC(20)/9/,ROMAC(21)/37/,ROMAC(22)/111/,ROMAC(23)/10/,ROMAC(
     *24)/9/,ROMAC(25)/46/,ROMAC(26)/101/,ROMAC(27)/110/,ROMAC(28)/100/,
     *ROMAC(29)/10/,ROMAC(30)/0/
      DATA ROTKB(1)/37/,ROTKB(2)/115/,ROTKB(3)/114/,ROTKB(4)/111/,ROTKB(
     *5)/47/,ROTKB(6)/109/,ROTKB(7)/109/,ROTKB(8)/47/,ROTKB(9)/45/,ROTKB
     *(10)/104/,ROTKB(11)/100/,ROTKB(12)/47/,ROTKB(13)/45/,ROTKB(14)/112
     */,ROTKB(15)/114/,ROTKB(16)/44/,ROTKB(17)/44/,ROTKB(18)/114/,ROTKB(
     *19)/111/,ROTKB(20)/37/,ROTKB(21)/115/,ROTKB(22)/61/,ROTKB(23)/37/,
     *ROTKB(24)/115/,ROTKB(25)/114/,ROTKB(26)/111/,ROTKB(27)/10/,ROTKB(2
     *8)/47/,ROTKB(29)/10/,ROTKB(30)/115/,ROTKB(31)/116/,ROTKB(32)/97/,R
     *OTKB(33)/99/,ROTKB(34)/107/,ROTKB(35)/61/,ROTKB(36)/48/,ROTKB(37)/
     *10/,ROTKB(38)/112/,ROTKB(39)/97/,ROTKB(40)/114/,ROTKB(41)/61/,ROTK
     *B(42)/114/,ROTKB(43)/111/,ROTKB(44)/37/,ROTKB(45)/115/,ROTKB(46)/5
     *8/,ROTKB(47)/37/,ROTKB(48)/111/,ROTKB(49)/58/,ROTKB(50)/37/,ROTKB(
     *51)/111/,ROTKB(52)/10/,ROTKB(53)/47/,ROTKB(54)/47/,ROTKB(55)/10/,R
     *OTKB(56)/0/
      DATA DMMAC(1)/9/,DMMAC(2)/46/,DMMAC(3)/101/,DMMAC(4)/110/,DMMAC(5)
     */100/,DMMAC(6)/10/,DMMAC(7)/0/
      DATA DMTKB(1)/100/,DMTKB(2)/117/,DMTKB(3)/109/,DMTKB(4)/109/,DMTKB
     *(5)/121/,DMTKB(6)/61/,DMTKB(7)/100/,DMTKB(8)/117/,DMTKB(9)/109/,DM
     *TKB(10)/109/,DMTKB(11)/121/,DMTKB(12)/10/,DMTKB(13)/47/,DMTKB(14)/
     *10/,DMTKB(15)/114/,DMTKB(16)/101/,DMTKB(17)/115/,DMTKB(18)/99/,DMT
     *KB(19)/111/,DMTKB(20)/109/,DMTKB(21)/61/,DMTKB(22)/114/,DMTKB(23)/
     *111/,DMTKB(24)/37/,DMTKB(25)/115/,DMTKB(26)/47/,DMTKB(27)/114/,DMT
     *KB(28)/111/,DMTKB(29)/10/,DMTKB(30)/47/,DMTKB(31)/47/,DMTKB(32)/10
     */,DMTKB(33)/0/
      DATA MUCMD(1)/109/,MUCMD(2)/97/,MUCMD(3)/99/,MUCMD(4)/32/,MUCMD(5)
     */37/,MUCMD(6)/115/,MUCMD(7)/114/,MUCMD(8)/111/,MUCMD(9)/61/,MUCMD(
     *10)/37/,MUCMD(11)/115/,MUCMD(12)/114/,MUCMD(13)/111/,MUCMD(14)/10/
     *,MUCMD(15)/116/,MUCMD(16)/107/,MUCMD(17)/98/,MUCMD(18)/32/,MUCMD(1
     *9)/64/,MUCMD(20)/64/,MUCMD(21)/37/,MUCMD(22)/115/,MUCMD(23)/114/,M
     *UCMD(24)/111/,MUCMD(25)/46/,MUCMD(26)/116/,MUCMD(27)/107/,MUCMD(28
     *)/98/,MUCMD(29)/10/,MUCMD(30)/112/,MUCMD(31)/105/,MUCMD(32)/112/,M
     *UCMD(33)/32/,MUCMD(34)/37/,MUCMD(35)/115/,MUCMD(36)/61/,MUCMD(37)/
     *37/,MUCMD(38)/115/,MUCMD(39)/10/,MUCMD(40)/109/,MUCMD(41)/97/,MUCM
     *D(42)/99/,MUCMD(43)/32/,MUCMD(44)/100/,MUCMD(45)/117/,MUCMD(46)/10
     *9/,MUCMD(47)/109/,MUCMD(48)/121/,MUCMD(49)/61/,MUCMD(50)/100/,MUCM
     *D(51)/117/,MUCMD(52)/109/,MUCMD(53)/109/,MUCMD(54)/121/,MUCMD(55)/
     *10/,MUCMD(56)/116/,MUCMD(57)/107/,MUCMD(58)/98/,MUCMD(59)/32/,MUCM
     *D(60)/64/,MUCMD(61)/64/,MUCMD(62)/100/,MUCMD(63)/117/,MUCMD(64)/10
     *9/,MUCMD(65)/109/,MUCMD(66)/121/,MUCMD(67)/46/,MUCMD(68)/116/,MUCM
     *D(69)/107/,MUCMD(70)/98/,MUCMD(71)/10/,MUCMD(72)/0/
      CALL SPRINT(MUTASK, 8Hmu%s.tsk, NAME)
      CALL SPRINT(TASKMU, 8H%smu.tsk, NAME)
      CALL SPRINT(ROTASK, 8Hro%s.tsk, NAME)
      CALL SPRINT(TASKRO, 8H%sro.tsk, NAME)
      JUNK = REMOVE(MUTASK)
      JUNK = REMOVE(ROTASK)
      JUNK = SSPAWN(LOCAL, PIPCMD, PID, 119)
      CALL SPRINT(SPWBUF, PIPFMT, NAME, NAME, NAME, NAME)
      JUNK = SSPAWN(LOCAL, SPWBUF, PID, 119)
      CALL SPRINT(SPWBUF, 9Hpip %s=%s, MUTASK, TASKMU)
      IF (.NOT.(VERBOS .EQ. 1))GOTO 23013
      CALL REMARK(SPWBUF)
23013 CONTINUE
      JUNK = SSPAWN(LOCAL, SPWBUF, PID, 119)
      INTM = OPEN(TASKMU, 1)
      IF (.NOT.(INTM .EQ. -3))GOTO 23015
      CALL CANT(TASKMU)
23015 CONTINUE
      IF (.NOT.(READF(B1, 512, INTM) .NE. 512))GOTO 23017
      CALL ERROR(27HError reading label block 0)
23017 CONTINUE
      CALL CLOSE(INTM)
      STVADR = B1(19)
      STBLCK = B1(123)
      ROSIZE = 64 * B1(124)
      CALL SPRINT(FILE, 8H%sro.mac, NAME)
      INT = CREATE(FILE, 2)
      IF (.NOT.(INT .EQ. -3))GOTO 23019
      CALL CANT(FILE)
23019 CONTINUE
      CALL SPRINT(BUF, ROMAC, NAME, ROSIZE)
      CALL PUTLIN(BUF, INT)
      CALL CLOSE(INT)
      IF (.NOT.(VERBOS .EQ. 1))GOTO 23021
      CALL REMARK(FILE)
      CALL PUTLIN(BUF, 3)
23021 CONTINUE
      CALL SPRINT(FILE, 8H%sro.tkb, NAME)
      INT = CREATE(FILE, 2)
      IF (.NOT.(INT .EQ. -3))GOTO 23023
      CALL CANT(FILE)
23023 CONTINUE
      CALL SPRINT(BUF, ROTKB, NAME, NAME, NAME, NAME, STVADR, ROSIZE)
      CALL PUTLIN(BUF, INT)
      CALL CLOSE(INT)
      IF (.NOT.(VERBOS .EQ. 1))GOTO 23025
      CALL REMARK(FILE)
      CALL PUTLIN(BUF, 3)
23025 CONTINUE
      CALL STRCPY(9Hdummy.mac, FILE)
      INT = CREATE(FILE, 2)
      IF (.NOT.(INT .EQ. -3))GOTO 23027
      CALL CANT(FILE)
23027 CONTINUE
      CALL PUTLIN(DMMAC, INT)
      CALL CLOSE(INT)
      IF (.NOT.(VERBOS .EQ. 1))GOTO 23029
      CALL REMARK(FILE)
      CALL PUTLIN(DMMAC, 3)
23029 CONTINUE
      CALL STRCPY(9Hdummy.tkb, FILE)
      INT = CREATE(FILE, 2)
      IF (.NOT.(INT .EQ. -3))GOTO 23031
      CALL CANT(FILE)
23031 CONTINUE
      CALL SPRINT(BUF, DMTKB, NAME)
      CALL PUTLIN(BUF, INT)
      CALL CLOSE(INT)
      IF (.NOT.(VERBOS .EQ. 1))GOTO 23033
      CALL REMARK(FILE)
      CALL PUTLIN(BUF, 3)
23033 CONTINUE
      CALL STRCPY(9Hmubld.cmd, FILE)
      INT = CREATE(FILE, 2)
      IF (.NOT.(INT .EQ. -3))GOTO 23035
      CALL CANT(FILE)
23035 CONTINUE
      CALL SPRINT(BUF, MUCMD, NAME, NAME, NAME, ROTASK, TASKRO)
      CALL PUTLIN(BUF, INT)
      CALL CLOSE(INT)
      IF (.NOT.(VERBOS .EQ. 1))GOTO 23037
      CALL REMARK(FILE)
23037 CONTINUE
      INT = OPEN(FILE, 1)
      N=GETLIN(BUF, INT)
23039 IF (.NOT.(N .NE. -1))GOTO 23041
      BUF(N) = 0
      IF (.NOT.(VERBOS .EQ. 1))GOTO 23042
      CALL REMARK(BUF)
23042 CONTINUE
      JUNK = SSPAWN(LOCAL, BUF, PID, 119)
23040 N=GETLIN(BUF, INT)
      GOTO 23039
23041 CONTINUE
      CALL CLOSE(INT)
      CALL CLOSE(1)
      CALL CLOSE(2)
      INTM = OPEN(TASKMU, 1)
      IF (.NOT.(INTM .EQ. -3))GOTO 23044
      CALL CANT(TASKMU)
23044 CONTINUE
      MINT = CREATE(MUTASK, 3)
      IF (.NOT.(MINT .EQ. -3))GOTO 23046
      CALL CANT(MUTASK)
23046 CONTINUE
      INT = OPEN(9Hdummy.tsk, 1)
      IF (.NOT.(INT .EQ. -3))GOTO 23048
      CALL CANT(9Hdummy.tsk)
23048 CONTINUE
      IF (.NOT.(READF(B1, 512, INTM) .NE. 512))GOTO 23050
      CALL ERROR(36HError reading label block for taskmu)
23050 CONTINUE
      IF (.NOT.(READF(B2, 512, INT) .NE. 512))GOTO 23052
      CALL ERROR(39HError reading label block for dummy.tsk)
23052 CONTINUE
      I=17
23054 IF (.NOT.(I .LE. 30))GOTO 23056
      B1(I) = B2(I)
23055 I=I+1
      GOTO 23054
23056 CONTINUE
      CALL CLOSE(INT)
      IF (.NOT.(DEBUG .EQ. 0))GOTO 23057
      JUNK = SSPAWN(LOCAL, PIPCMD, PID, 119)
23057 CONTINUE
      INTR = OPEN(TASKRO, 1)
      IF (.NOT.(INTR .EQ. -3))GOTO 23059
      CALL CANT(TASKRO)
23059 CONTINUE
      RINT = CREATE(ROTASK, 3)
      IF (.NOT.(RINT .EQ. -3))GOTO 23061
      CALL CANT(ROTASK)
23061 CONTINUE
      JUNK = WRITEF(B1, 512, MINT)
      I=2
23063 IF (.NOT.(I .LT. STBLCK))GOTO 23065
      JUNK = READF(B1, 512, INTM)
      JUNK = WRITEF(B1, 512, MINT)
23064 I=I+1
      GOTO 23063
23065 CONTINUE
      IF (.NOT.(READF(B1, 512, INTR) .NE. 512))GOTO 23066
      CALL ERROR(40HError reading label block for taskro.tsk)
23066 CONTINUE
      NLBL = B1(121)
      JUNK = WRITEF(B1, 512, RINT)
      I=2
23068 IF (.NOT.(I .LE. NLBL))GOTO 23070
      JUNK = READF(B1, 512, INTR)
      JUNK = WRITEF(B1, 512, RINT)
23069 I=I+1
      GOTO 23068
23070 CONTINUE
      NLBL = (ROSIZE - 1) / 512 + 1
      I=1
23071 IF (.NOT.(I .LE. NLBL))GOTO 23073
      JUNK = READF(B1, 512, INTM)
      JUNK = WRITEF(B1, 512, MINT)
      JUNK = WRITEF(B1, 512, RINT)
      JUNK = READF(B2, 512, INTR)
23072 I=I+1
      GOTO 23071
23073 CONTINUE
23074 IF (.NOT.(READF(B1, 512, INTM) .EQ. 512))GOTO 23075
      JUNK = WRITEF(B1, 512, MINT)
      GOTO 23074
23075 CONTINUE
      CALL CLOSE(INTM)
      CALL CLOSE(MINT)
23076 IF (.NOT.(READF(B1, 512, INTR) .EQ. 512))GOTO 23077
      JUNK = WRITEF(B1, 512, RINT)
      GOTO 23076
23077 CONTINUE
      CALL CLOSE(INTR)
      CALL CLOSE(RINT)
      IF (.NOT.(DEBUG .EQ. 0))GOTO 23078
      CALL SPRINT(SPWBUF, PIPFMT, NAME, NAME, NAME, NAME)
      JUNK = SSPAWN(LOCAL, SPWBUF, PID, 119)
23078 CONTINUE
      RETURN
      END
