      SUBROUTINE MAIN
      INTEGER HASHT0(37),TEMPT0,CLDAT0(2)
      INTEGER TEMPB0(4059)
      COMMON /SWT$TP/TEMPT0,HASHT0,TEMPB0,CLDAT0
      INTEGER JUNK,CODE,UNIT,I,L,J
      INTEGER BUF(102),INFO(8)
      INTEGER LENGTH,CTOP,GTEMP,GCTOI,EQUAL
      INTEGER STR(102),NM(102),REPL(102)
      INTEGER DYNPOS(8)
      INTEGER DYNTXT(42)
      INTEGER AAAAA0
      INTEGER AAAAB0(15)
      INTEGER AAAAC0(7)
      INTEGER AAAAD0,AAAAE0,AAAAF0,AAAAG0,AAAAH0
      INTEGER SCOPY,LENGTH
      DATA DYNTXT/1,228,225,244,229,0,2,244,233,237,229,0,3,245,243,229,
     *242,0,4,240,233,228,0,5,240,225,243,243,247,228,0,6,228,225,249,0,
     *7,232,239,237,229,0/
      DATA DYNPOS/7,1,7,13,19,24,32,37/
      DATA AAAAB0/229,248,244,242,225,190,244,229,237,240,236,225,244,22
     *9,0/
      DATA AAAAC0/227,236,228,225,244,225,0/
      DO 10001 I=1,37
        HASHT0(I)=0
10001 CONTINUE
10002 TEMPT0=0
      I=1
      GOTO 10005
10003 I=I+(1)
10005 IF((I.GT.DYNPOS(1)))GOTO 10004
        CALL SCOPY(DYNTXT,DYNPOS(I+1)+1,NM,1)
        REPL(1)=-DYNTXT(DYNPOS(I+1))
        AAAAA0=1
        GOTO 10000
10004 CALL RDTK$$(1,INFO,BUF,102,CODE)
      CALL ERRPR$(:0,CODE,0,0,'rdtk$$',6)
      IF((INFO(1).NE.6))GOTO 10007
        I=1
        INFO(2)=CTOP(AAAAB0,I,BUF,102)
10007 INFO(1)=0
      CALL TSRC$$(:1+:40000,BUF,UNIT,INFO,JUNK,CODE)
      CALL ERRPR$(:0,CODE,BUF,INFO(2),'tsrc$$',6)
      CLDAT0(1)=:6002
      CLDAT0(2)=:6
10008   CALL RDLIN$(UNIT,BUF,102,CODE)
        IF((CODE.NE.1))GOTO 10009
          GOTO 10010
10009   CALL ERRPR$(:0,CODE,'Reading template file',21,'initswt',7)
        CALL PTOC(BUF,0,STR,102)
        IF((GTEMP(STR,NM,REPL).EQ.-1))GOTO 10011
          IF((EQUAL(NM,AAAAC0).NE.1))GOTO 10012
            I=1
            CLDAT0(1)=GCTOI(REPL,I,8)
            CLDAT0(2)=GCTOI(REPL,I,8)
10012     AAAAA0=2
          GOTO 10000
10013   CONTINUE
10011 CONTINUE
      GOTO 10008
10010 CONTINUE
1     CALL SRCH$$(:4,0,0,UNIT,JUNK,CODE)
      CALL ERRPR$(:0,CODE,'Closing template file',21,'initswt',7)
      CALL EXIT
      GOTO 10014
10000 AAAAH0=LENGTH(NM)+3
      IF((REPL(1).LE.0))GOTO 10015
        AAAAH0=AAAAH0+(LENGTH(REPL)+1)
10015 IF((TEMPT0+AAAAH0.LE.4059))GOTO 10016
        AAAAE0=1
        GOTO 10019
10017   AAAAE0=AAAAE0+(1)
10019   IF((NM(AAAAE0).EQ.0))GOTO 10018
          CALL T1OU(NM(AAAAE0))
        GOTO 10017
10018   CALL ERRPR$(:2,37,': too many system templates',27,'initswt',7)
        GOTO 1
10016 AAAAD0=0
      AAAAE0=1
      GOTO 10022
10020 AAAAE0=AAAAE0+(1)
10022 IF((AAAAE0.GT.4))GOTO 10021
      IF((NM(AAAAE0).EQ.0))GOTO 10021
        AAAAD0=AAAAD0+(NM(AAAAE0))
      GOTO 10020
10021 AAAAD0=MOD(AAAAD0,37)+1
      AAAAF0=TEMPT0+1
      TEMPB0(AAAAF0)=HASHT0(AAAAD0)
      HASHT0(AAAAD0)=AAAAF0
      AAAAG0=AAAAF0+2+SCOPY(NM,1,TEMPB0,AAAAF0+2)+1
      IF((REPL(1).GT.0))GOTO 10023
        TEMPB0(AAAAF0+1)=REPL(1)
        TEMPT0=AAAAG0-1
        GOTO 10025
10023   TEMPB0(AAAAF0+1)=AAAAG0
        TEMPT0=AAAAG0+SCOPY(REPL,1,TEMPB0,AAAAG0)
10024 GOTO 10025
10014 CONTINUE
10025 GOTO(10003,10013),AAAAA0
      GOTO 10025
      END
C ---- Long Name Map ----
C Temptop                        tempt0
C Cldataptr                      cldat0
C Tempbuf                        tempb0
C addentry                       adden0
C Hashtb                         hasht0
