      INTEGER RD(884)
      INTEGER AP,I,TEST
      INTEGER KEYS(50),ORDERS(50)
      INTEGER GETARG,LOADRD,FINDF0,ISATTY
      INTEGER ARG(128),ORD(128)
      INTEGER AAAAA0(3)
      INTEGER AAAAB0(15)
      INTEGER AAAAC0(16)
      INTEGER AAAAD0(15)
      DATA AAAAA0/170,243,0/
      DATA AAAAB0/170,243,160,225,243,227,229,238,228,233,238,231,170,23
     *8,0/
      DATA AAAAC0/170,243,160,228,229,243,227,229,238,228,233,238,231,17
     *0,238,0/
      DATA AAAAD0/170,243,160,245,238,228,229,230,233,238,229,228,170,23
     *8,0/
      IF((LOADRD(RD,-10).EQ.-2))GOTO 10000
        CALL ERROR('Can''t access input relation.')
10000 AP=1
      GOTO 10003
10001 AP=AP+(1)
10003 IF(((GETARG(2*AP-1,ARG,128).EQ.-1).OR.(TEST.EQ.-1)))GOTO 10002
        IF((AP.LT.50))GOTO 10004
          CALL ERROR('Too many sort keys.')
10004   KEYS(AP)=FINDF0(RD,ARG)
        IF((KEYS(AP).NE.0))GOTO 10005
          CALL PRINT(-15,AAAAA0,ARG)
          CALL ERROR(': field not defined.')
10005   TEST=GETARG(2*AP,ORD,128)
        IF((TEST.EQ.-1))GOTO 10006
          IF((ORD(1).NE.225))GOTO 10007
            CALL PRINT(-11,AAAAB0,ARG)
            ORDERS(AP)=1
            GOTO 10008
10007       IF((ORD(1).NE.228))GOTO 10009
              CALL PRINT(-11,AAAAC0,ARG)
              ORDERS(AP)=-1
              GOTO 10010
10009         CALL PRINT(-11,AAAAD0,ARG)
              ORDERS(AP)=1
10010     CONTINUE
10008   CONTINUE
10006 GOTO 10001
10002 IF((AP.NE.1))GOTO 10011
        AP=1
        I=3+1
        GOTO 10014
10012   AP=AP+(1)
        I=I+22
10014   IF((I.GT.RD(2)))GOTO 10013
          KEYS(AP)=I
          ORDERS(AP)=1
        GOTO 10012
10013 CONTINUE
10011 KEYS(AP)=0
      CALL SAVERD(RD,-11)
      IF((ISATTY(-11).NE.1))GOTO 10015
        CALL PRINT0(RD,-11)
10015 CALL SORT(RD,KEYS,ORDERS,-10,-11)
      IF((ISATTY(-11).NE.1))GOTO 10016
        CALL PRINU0(RD,-11)
10016 CALL SWT
      END
      SUBROUTINE SORT(RD,KEYS,ORDERS,IFD,OFD)
      INTEGER RD(884)
      INTEGER KEYS(50),ORDERS(50)
      INTEGER IFD,OFD
      INTEGER ROWBUF(32768),NAME(30)
      INTEGER INFIL(7),ROWPTR(4096),NROWS,HIGH,LIM,LOW,T,I
      INTEGER GTEXT
      INTEGER OUTFD
      INTEGER MAKFIL,OPEN
      HIGH=0
10017   T=GTEXT(RD,ROWPTR,NROWS,ROWBUF,IFD)
        CALL QUICK(RD,KEYS,ORDERS,ROWPTR,NROWS,ROWBUF)
        IF((T.NE.-1))GOTO 10019
        IF((HIGH.GT.0))GOTO 10019
        GOTO 10018
10019     HIGH=HIGH+(1)
          OUTFD=MAKFIL(HIGH)
          CALL PTEXT(RD,ROWPTR,NROWS,ROWBUF,OUTFD)
          CALL CLOSE(OUTFD)
10018 CONTINUE
      IF((T.NE.-1))GOTO 10017
      IF((HIGH.NE.0))GOTO 10020
        CALL PTEXT(RD,ROWPTR,NROWS,ROWBUF,OFD)
        CALL REWIND(OFD)
        RETURN
10020 LOW=1
      GOTO 10023
10021 LOW=LOW+(7)
10023 IF((LOW.GE.HIGH))GOTO 10022
        LIM=MIN0(LOW+7-1,HIGH)
        CALL GOPEN(INFIL,LOW,LIM)
        IF((LIM.LT.HIGH))GOTO 10024
          CALL MERGE(RD,KEYS,ORDERS,INFIL,LIM-LOW+1,OFD)
          GOTO 10025
10024     HIGH=HIGH+(1)
          OUTFD=MAKFIL(HIGH)
          CALL MERGE(RD,KEYS,ORDERS,INFIL,LIM-LOW+1,OUTFD)
          CALL CLOSE(OUTFD)
10025   CALL GREMOV(INFIL,LOW,LIM)
      GOTO 10021
10022 CALL REWIND(OFD)
      RETURN
      END
      SUBROUTINE GNAME(N,NAME)
      INTEGER N
      INTEGER NAME(30)
      INTEGER AAAAE0(17)
      DATA AAAAE0/189,244,229,237,240,189,175,242,243,189,240,233,228,18
     *9,170,233,0/
      CALL ENCODE(NAME,30,AAAAE0,N)
      RETURN
      END
      INTEGER FUNCTION MAKFIL(N)
      INTEGER N
      INTEGER NAME(30)
      INTEGER CREATE
      CALL GNAME(N,NAME)
      MAKFIL=CREATE(NAME,3)
      IF((MAKFIL.NE.-3))GOTO 10026
        CALL CANT(NAME)
10026 RETURN
      END
      SUBROUTINE GOPEN(INFIL,LOW,LIM)
      INTEGER INFIL(7)
      INTEGER LOW,LIM
      INTEGER NAME(30)
      INTEGER I
      INTEGER OPEN
      I=1
      GOTO 10029
10027 I=I+(1)
10029 IF((I.GT.LIM-LOW+1))GOTO 10028
        CALL GNAME(LOW+I-1,NAME)
        INFIL(I)=OPEN(NAME,1)
        IF((INFIL(I).NE.-3))GOTO 10030
          CALL CANT(NAME)
10030 GOTO 10027
10028 RETURN
      END
      SUBROUTINE GREMOV(INFIL,LOW,LIM)
      INTEGER INFIL(7)
      INTEGER LOW,LIM
      INTEGER NAME(30)
      INTEGER I
      I=1
      GOTO 10033
10031 I=I+(1)
10033 IF((I.GT.LIM-LOW+1))GOTO 10032
        CALL CLOSE(INFIL(I))
        CALL GNAME(LOW+I-1,NAME)
        CALL REMOVE(NAME)
      GOTO 10031
10032 RETURN
      END
      SUBROUTINE MERGE(RD,KEYS,ORDERS,INFIL,NFILES,OUTFIL)
      INTEGER RD(884)
      INTEGER KEYS(50),ORDERS(50)
      INTEGER INFIL(7),OUTFIL
      INTEGER NFILES
      INTEGER ROWBUF(900)
      INTEGER GETROW
      INTEGER I,INF,RBP,RP1,NF,ROWPTR(7)
      RBP=1
      NF=0
      I=1
      GOTO 10036
10034 I=I+(1)
10036 IF((I.GT.NFILES))GOTO 10035
        IF((GETROW(RD,INFIL(I),ROWBUF(RBP)).EQ.-1))GOTO 10037
          NF=NF+(1)
          ROWPTR(NF)=RBP
          RBP=RBP+(RD(3))
10037 GOTO 10034
10035 CALL QUICK(RD,KEYS,ORDERS,ROWPTR,NF,ROWBUF)
10038 IF((NF.LE.0))GOTO 10039
        RP1=ROWPTR(1)
        CALL PUTROW(RD,OUTFIL,ROWBUF(RP1))
        INF=RP1/RD(3)+1
        IF((GETROW(RD,INFIL(INF),ROWBUF(RP1)).NE.-1))GOTO 10040
          ROWPTR(1)=ROWPTR(NF)
          NF=NF-(1)
10040   CALL REHEAP(RD,KEYS,ORDERS,ROWPTR,NF,ROWBUF)
      GOTO 10038
10039 RETURN
      END
      SUBROUTINE REHEAP(RD,KEYS,ORDERS,ROWPTR,NF,ROWBUF)
      INTEGER RD(884)
      INTEGER KEYS(50),ORDERS(50)
      INTEGER ROWPTR(1),NF
      INTEGER ROWBUF(32768)
      INTEGER I,J
      INTEGER COMPA0
      I=1
      GOTO 10043
10041 I=J
10043 IF((2*I.GT.NF))GOTO 10042
        J=2*I
        IF((J.GE.NF))GOTO 10044
          IF((COMPA0(RD,KEYS,ORDERS,ROWPTR(J),ROWPTR(J+1),ROWBUF).LE.0))
     *GOTO 10045
            J=J+(1)
10045   CONTINUE
10044   IF((COMPA0(RD,KEYS,ORDERS,ROWPTR(I),ROWPTR(J),ROWBUF).GT.0))GOTO
     * 10046
          GOTO 10042
10046   CALL EXCHAN(ROWPTR(I),ROWPTR(J),ROWBUF)
      GOTO 10041
10042 RETURN
      END
      INTEGER FUNCTION GTEXT(RD,ROWPTR,NROWS,ROWBUF,INFILE)
      INTEGER RD(884)
      INTEGER ROWPTR(4096),NROWS,I
      INTEGER ROWBUF(32768)
      INTEGER INFILE,OUTFI0
      INTEGER RBP,LEN
      INTEGER GETROW
      NROWS=0
      RBP=1
10047   IF((GETROW(RD,INFILE,ROWBUF(RBP)).NE.-1))GOTO 10048
          GTEXT=-1
          RETURN
10048   NROWS=NROWS+(1)
        ROWPTR(NROWS)=RBP
        RBP=RBP+(RD(3))
      IF((RBP.GE.32768-102))GOTO 10049
      IF((NROWS.GE.4096))GOTO 10049
      GOTO 10047
10049 CONTINUE
      GTEXT=-2
      RETURN
      END
      SUBROUTINE PTEXT(RD,ROWPTR,NROWS,ROWBUF,OUTFIL)
      INTEGER RD(884)
      INTEGER ROWPTR(4096),NROWS
      INTEGER ROWBUF(32768)
      INTEGER OUTFIL
      INTEGER I,J
      I=1
      GOTO 10052
10050 I=I+(1)
10052 IF((I.GT.NROWS))GOTO 10051
        J=ROWPTR(I)
        CALL PUTROW(RD,OUTFIL,ROWBUF(J))
      GOTO 10050
10051 RETURN
      END
      INTEGER FUNCTION COMPA0(RD,KEYS,ORDERS,RP1,RP2,ROWBUF)
      INTEGER RD(884)
      INTEGER KEYS(50),ORDERS(50)
      INTEGER RP1,RP2
      INTEGER ROWBUF(1)
      INTEGER K,R,KP
      INTEGER BUF1(500),BUF2(500)
      INTEGER COMPB0
      KP=1
      GOTO 10055
10053 KP=KP+(1)
10055 IF((KEYS(KP).EQ.0))GOTO 10054
        K=KEYS(KP)
        CALL GETDA0(RD,K,ROWBUF(RP1),BUF1)
        CALL GETDA0(RD,K,ROWBUF(RP2),BUF2)
        R=COMPB0(RD(K),BUF1,BUF2)
        IF((R.EQ.2))GOTO 10056
          COMPA0=(R-2)*ORDERS(KP)
          RETURN
10056 GOTO 10053
10054 COMPA0=0
      RETURN
      END
      SUBROUTINE EXCHAN(RP1,RP2,ROWBUF)
      INTEGER RP1,RP2
      INTEGER ROWBUF(1)
      INTEGER K
      K=RP1
      RP1=RP2
      RP2=K
      RETURN
      END
      SUBROUTINE QUICK(RD,KEYS,ORDERS,ROWPTR,NROWS,ROWBUF)
      INTEGER RD(884)
      INTEGER KEYS(50),ORDERS(50)
      INTEGER ROWPTR(1),NROWS
      INTEGER ROWBUF(1)
      INTEGER I,J,LV(12),P,PIVROW,UV(12)
      INTEGER COMPA0
      LV(1)=1
      UV(1)=NROWS
      P=1
10057 IF((P.LE.0))GOTO 10058
        IF((LV(P).LT.UV(P)))GOTO 10059
          P=P-(1)
          GOTO 10060
10059     I=LV(P)-1
          J=UV(P)
          PIVROW=ROWPTR(J)
10061     IF((I.GE.J))GOTO 10062
            I=I+(1)
            GOTO 10065
10063       I=I+(1)
10065       IF((COMPA0(RD,KEYS,ORDERS,ROWPTR(I),PIVROW,ROWBUF).GE.0))GOT
     *O 10064
            GOTO 10063
10064       J=J-(1)
            GOTO 10068
10066       J=J-(1)
10068       IF((J.LE.I))GOTO 10067
              IF((COMPA0(RD,KEYS,ORDERS,ROWPTR(J),PIVROW,ROWBUF).GT.0))G
     *OTO 10069
                GOTO 10067
10069       GOTO 10066
10067       IF((I.GE.J))GOTO 10070
              CALL EXCHAN(ROWPTR(I),ROWPTR(J),ROWBUF)
10070     GOTO 10061
10062     J=UV(P)
          CALL EXCHAN(ROWPTR(I),ROWPTR(J),ROWBUF)
          IF((I-LV(P).GE.UV(P)-I))GOTO 10071
            LV(P+1)=LV(P)
            UV(P+1)=I-1
            LV(P)=I+1
            GOTO 10072
10071       LV(P+1)=I+1
            UV(P+1)=UV(P)
            UV(P)=I-1
10072     P=P+(1)
10060 GOTO 10057
10058 RETURN
      END
      INTEGER FUNCTION LOADRD(RD,FD)
      INTEGER RD(884)
      INTEGER FD
      INTEGER ISATTY,READF
      IF((ISATTY(FD).NE.1))GOTO 10073
        CALL REMARK('Sorry, a relation can''t be read from the terminal.
     *')
        LOADRD=-3
        RETURN
10073 IF((READF(RD(1),1,FD).NE.-1))GOTO 10074
        LOADRD=-3
        RETURN
10074 IF((READF(RD(2),RD(1)-1,FD).NE.-1))GOTO 10075
        CALL REMARK('relation is corrupted!!.')
        LOADRD=-3
        RETURN
10075 LOADRD=-2
      RETURN
      END
      SUBROUTINE SAVERD(RD,FD)
      INTEGER RD(884)
      INTEGER FD
      INTEGER ISATTY
      IF((ISATTY(FD).NE.1))GOTO 10076
        CALL PRINV0(RD,FD)
        GOTO 10077
10076   CALL WRITEF(RD,RD(1),FD)
10077 RETURN
      END
      SUBROUTINE PRINV0(RD,FD)
      INTEGER RD(884)
      INTEGER FD
      INTEGER I
      INTEGER TYPE(102)
      INTEGER AAAAF0(10)
      INTEGER AAAAG0(33)
      INTEGER AAAAH0(10)
      INTEGER AAAAI0
      INTEGER AAAAJ0(8)
      INTEGER AAAAK0(5)
      INTEGER AAAAL0(7)
      INTEGER AAAAM0(24)
      INTEGER AAAAN0(10)
      DATA AAAAF0/170,179,185,172,172,173,248,170,238,0/
      DATA AAAAG0/252,160,244,249,240,229,160,160,160,160,252,160,236,22
     *9,238,231,244,232,160,252,160,238,225,237,229,170,177,179,248,252,
     *170,238,0/
      DATA AAAAH0/170,179,185,172,172,173,248,170,238,0/
      DATA AAAAJ0/233,238,244,229,231,229,242,0/
      DATA AAAAK0/242,229,225,236,0/
      DATA AAAAL0/243,244,242,233,238,231,0/
      DATA AAAAM0/252,160,170,183,243,160,252,160,170,181,233,160,160,25
     *2,160,170,177,182,243,160,252,170,238,0/
      DATA AAAAN0/170,179,185,172,172,173,248,170,238,0/
      CALL PRINT(FD,AAAAF0)
      CALL PRINT(FD,AAAAG0)
      CALL PRINT(FD,AAAAH0)
      I=3+1
      GOTO 10080
10078 I=I+22
10080 IF((I.GT.RD(2)))GOTO 10079
        AAAAI0=RD(I)
        GOTO 10081
10082     CALL CTOC(AAAAJ0,TYPE,102)
        GOTO 10083
10084     CALL CTOC(AAAAK0,TYPE,102)
        GOTO 10083
10085     CALL CTOC(AAAAL0,TYPE,102)
        GOTO 10083
10081   GOTO(10082,10084,10085),AAAAI0
10083   CALL PRINT(FD,AAAAM0,TYPE,RD(I+1),RD(I+5))
      GOTO 10078
10079 CALL PRINT(FD,AAAAN0)
      RETURN
      END
      INTEGER FUNCTION ADDFI0(RD,TYPE,LEN,NAME)
      INTEGER RD(884)
      INTEGER TYPE,LEN
      INTEGER NAME(1)
      INTEGER I
      INTEGER AAAAO0
      I=RD(2)+22
      IF((I+22-1.LE.884))GOTO 10086
        ADDFI0=0
        RETURN
10086 RD(I)=TYPE
      RD(I+4)=LENGTH(NAME)
      AAAAO0=TYPE
      GOTO 10087
10088   RD(I+1)=2
        RD(I+4)=MAX0(RD(I+4),10)
      GOTO 10089
10090   RD(I+1)=4
        RD(I+4)=MAX0(RD(I+4),15)
      GOTO 10089
10091   RD(I+1)=LEN
        RD(I+4)=MAX0(RD(I+4),LEN)
      GOTO 10089
10087 GOTO(10088,10090,10091),AAAAO0
        CALL ERROR('in add_field_to_rd: bogus type passed.')
10089 RD(I+2)=RD(3)+1
      RD(I+3)=RD(3)+RD(I+1)
      CALL CTOC(NAME,RD(I+5),17)
      RD(1)=RD(1)+(22)
      RD(2)=RD(2)+(22)
      RD(3)=RD(3)+(RD(I+1))
      IF((RD(3).LE.500))GOTO 10092
        ADDFI0=0
        RETURN
10092 ADDFI0=I
      RETURN
      END
      INTEGER FUNCTION FINDF0(RD,NAME)
      INTEGER RD(884)
      INTEGER NAME(1)
      INTEGER I
      INTEGER EQUAL
      I=3+1
      GOTO 10095
10093 I=I+22
10095 IF((I.GT.RD(2)))GOTO 10094
        IF((EQUAL(RD(I+5),NAME).NE.1))GOTO 10096
          FINDF0=I
          RETURN
10096 GOTO 10093
10094 FINDF0=0
      RETURN
      END
      INTEGER FUNCTION COMPB0(TYPE,BUF1,BUF2)
      INTEGER TYPE
      INTEGER BUF1(500),BUF2(500)
      INTEGER R
      INTEGER COMPC0,COMPD0,COMPE0
      INTEGER AAAAP0
      INTEGER AAAAQ0(34)
      DATA AAAAQ0/233,238,160,227,239,237,240,225,242,229,223,230,233,22
     *9,236,228,186,160,226,239,231,245,243,160,244,249,240,229,160,170,
     *233,170,238,0/
      AAAAP0=TYPE
      GOTO 10097
10098   R=COMPC0(BUF1,BUF2)
      GOTO 10099
10100   R=COMPD0(BUF1,BUF2)
      GOTO 10099
10101   R=COMPE0(BUF1,BUF2)
      GOTO 10099
10097 GOTO(10098,10100,10101),AAAAP0
        CALL PRINT(-15,AAAAQ0,TYPE)
        R=2
10099 COMPB0=R
      RETURN
      END
      INTEGER FUNCTION COMPC0(I1,I2)
      INTEGER * 4 I1,I2
      IF((I1.GE.I2))GOTO 10102
        COMPC0=1
        RETURN
10102 IF((I1.LE.I2))GOTO 10103
        COMPC0=3
        RETURN
10103 COMPC0=2
      RETURN
      END
      INTEGER FUNCTION COMPD0(D1,D2)
      REAL * 8 D1,D2
      IF((D1.GE.D2))GOTO 10104
        COMPD0=1
        RETURN
10104 IF((D1.LE.D2))GOTO 10105
        COMPD0=3
        RETURN
10105 COMPD0=2
      RETURN
      END
      INTEGER FUNCTION COMPE0(S1,S2)
      INTEGER S1(1),S2(1)
      INTEGER I
      I=1
      GOTO 10108
10106 I=I+(1)
10108 IF((S1(I).NE.S2(I)))GOTO 10107
      IF((S1(I).EQ.0))GOTO 10107
      GOTO 10106
10107 IF((S1(I).NE.S2(I)))GOTO 10109
        COMPE0=2
        RETURN
10109 IF((S1(I).EQ.0))GOTO 10111
      IF((S1(I).LT.S2(I)))GOTO 10111
      GOTO 10110
10111   COMPE0=1
        RETURN
10110 COMPE0=3
      RETURN
      END
      SUBROUTINE PRINT0(RD,FD)
      INTEGER RD(884)
      INTEGER FD
      INTEGER I
      INTEGER AAAAR0(2)
      INTEGER AAAAS0(7)
      INTEGER AAAAT0(3)
      INTEGER AAAAU0(2)
      INTEGER AAAAV0(7)
      INTEGER AAAAW0(3)
      INTEGER AAAAX0(2)
      INTEGER AAAAY0(7)
      INTEGER AAAAZ0(3)
      DATA AAAAR0/173,0/
      DATA AAAAS0/170,163,172,172,173,248,0/
      DATA AAAAT0/170,238,0/
      DATA AAAAU0/252,0/
      DATA AAAAV0/160,170,163,243,160,252,0/
      DATA AAAAW0/170,238,0/
      DATA AAAAX0/173,0/
      DATA AAAAY0/170,163,172,172,173,248,0/
      DATA AAAAZ0/170,238,0/
      CALL PRINT(FD,AAAAR0)
      I=3+1
      GOTO 10114
10112 I=I+22
10114 IF((I.GT.RD(2)))GOTO 10113
        CALL PRINT(FD,AAAAS0,RD(I+4)+3)
      GOTO 10112
10113 CALL PRINT(FD,AAAAT0)
      CALL PRINT(FD,AAAAU0)
      I=3+1
      GOTO 10117
10115 I=I+22
10117 IF((I.GT.RD(2)))GOTO 10116
        CALL PRINT(FD,AAAAV0,RD(I+4),RD(I+5))
      GOTO 10115
10116 CALL PRINT(FD,AAAAW0)
      CALL PRINT(FD,AAAAX0)
      I=3+1
      GOTO 10120
10118 I=I+22
10120 IF((I.GT.RD(2)))GOTO 10119
        CALL PRINT(FD,AAAAY0,RD(I+4)+3)
      GOTO 10118
10119 CALL PRINT(FD,AAAAZ0)
      RETURN
      END
      SUBROUTINE PRINU0(RD,FD)
      INTEGER RD(884)
      INTEGER FD
      INTEGER I
      INTEGER AAABA0(2)
      INTEGER AAABB0(7)
      INTEGER AAABC0(3)
      DATA AAABA0/173,0/
      DATA AAABB0/170,163,172,172,173,248,0/
      DATA AAABC0/170,238,0/
      CALL PRINT(FD,AAABA0)
      I=3+1
      GOTO 10123
10121 I=I+22
10123 IF((I.GT.RD(2)))GOTO 10122
        CALL PRINT(FD,AAABB0,RD(I+4)+3)
      GOTO 10121
10122 CALL PRINT(FD,AAABC0)
      RETURN
      END
      SUBROUTINE PRINW0(RD,FD,BUF)
      INTEGER RD(884)
      INTEGER FD
      INTEGER BUF(500)
      INTEGER I
      INTEGER AAABD0(2)
      INTEGER AAABE0
      INTEGER AAABF0(7)
      INTEGER AAABG0(7)
      INTEGER AAABH0(9)
      INTEGER AAABI0(3)
      DATA AAABD0/252,0/
      DATA AAABF0/160,170,163,236,160,252,0/
      DATA AAABG0/160,170,163,228,160,252,0/
      DATA AAABH0/160,170,163,172,163,243,160,252,0/
      DATA AAABI0/170,238,0/
      CALL PRINT(FD,AAABD0)
      I=3+1
      GOTO 10126
10124 I=I+22
10126 IF((I.GT.RD(2)))GOTO 10125
        AAABE0=RD(I)
        GOTO 10127
10128     CALL PRINT(FD,AAABF0,RD(I+4),BUF(RD(I+2)))
        GOTO 10129
10130     CALL PRINT(FD,AAABG0,RD(I+4),BUF(RD(I+2)))
        GOTO 10129
10131     CALL PRINT(FD,AAABH0,RD(I+4),RD(I+1),BUF(RD(I+2)))
        GOTO 10129
10127   GOTO(10128,10130,10131),AAABE0
10129 GOTO 10124
10125 CALL PRINT(FD,AAABI0)
      RETURN
      END
      INTEGER FUNCTION GETROW(RD,FD,BUF)
      INTEGER RD(884)
      INTEGER FD
      INTEGER BUF(500),I
      INTEGER READF
      I=READF(BUF,RD(3),FD)
      GETROW=I
      RETURN
      END
      SUBROUTINE PUTROW(RD,FD,BUF)
      INTEGER RD(884)
      INTEGER FD
      INTEGER BUF(500)
      INTEGER ISATTY
      IF((ISATTY(FD).NE.1))GOTO 10132
        CALL PRINW0(RD,FD,BUF)
        GOTO 10133
10132   CALL WRITEF(BUF,RD(3),FD)
10133 RETURN
      END
      SUBROUTINE GETDA0(RD,I,BUF,DEST)
      INTEGER RD(884)
      INTEGER I,BUF(1),DEST(102)
      INTEGER J,K
      INTEGER AAABJ0
      AAABJ0=RD(I)
      GOTO 10134
10135   J=RD(I+2)
        DEST(1)=BUF(J)
        DEST(2)=BUF(J+1)
      GOTO 10136
10137   J=RD(I+2)
        DEST(1)=BUF(J)
        DEST(2)=BUF(J+1)
        DEST(3)=BUF(J+2)
        DEST(4)=BUF(J+3)
      GOTO 10136
10138   J=RD(I+3)
        K=RD(I+1)
        GOTO 10141
10139   J=J-(1)
        K=K-(1)
10141   IF((K.LE.0))GOTO 10140
        IF((BUF(J).NE.160))GOTO 10140
        GOTO 10139
10140   DEST(K+1)=0
        GOTO 10144
10142   J=J-(1)
        K=K-(1)
10144   IF((K.LE.0))GOTO 10143
          DEST(K)=BUF(J)
        GOTO 10142
10143 GOTO 10136
10134 GOTO(10135,10137,10138),AAABJ0
10136 RETURN
      END
      SUBROUTINE PUTDA0(RD,I,BUF,SRC)
      INTEGER RD(884)
      INTEGER I,BUF(1),SRC(102)
      INTEGER J,K
      INTEGER AAABK0
      AAABK0=RD(I)
      GOTO 10145
10146   J=RD(I+2)
        BUF(J)=SRC(1)
        BUF(J+1)=SRC(2)
      GOTO 10147
10148   J=RD(I+2)
        BUF(J)=SRC(1)
        BUF(J+1)=SRC(2)
        BUF(J+2)=SRC(3)
        BUF(J+3)=SRC(4)
      GOTO 10147
10149   J=RD(I+2)
        K=1
        GOTO 10152
10150   J=J+(1)
        K=K+(1)
10152   IF((SRC(K).EQ.0))GOTO 10151
        IF((K.GT.RD(I+1)))GOTO 10151
          BUF(J)=SRC(K)
        GOTO 10150
10151   GOTO 10155
10153   K=K+(1)
        J=J+(1)
10155   IF((K.GT.RD(I+1)))GOTO 10154
          BUF(J)=160
        GOTO 10153
10154 GOTO 10147
10145 GOTO(10146,10148,10149),AAABK0
10147 RETURN
      END
      INTEGER FUNCTION COMPF0(RD,ROW1,ROW2)
      INTEGER RD(884)
      INTEGER ROW1(500),ROW2(500)
      INTEGER BUF1(500),BUF2(500)
      INTEGER R,I
      INTEGER COMPB0
      I=3+1
      GOTO 10158
10156 I=I+22
10158 IF((I.GT.RD(2)))GOTO 10157
        CALL GETDA0(RD,I,ROW1,BUF1)
        CALL GETDA0(RD,I,ROW2,BUF2)
        R=COMPB0(RD(I),BUF1,BUF2)
        IF((R.EQ.2))GOTO 10159
          COMPF0=R
          RETURN
10159 GOTO 10156
10157 COMPF0=2
      RETURN
      END
C ---- Long Name Map ----
C comparefield                   compb0
C printheader                    print0
C comparerow                     compf0
C compare                        compa0
C printtrailer                   prinu0
C compareinteger                 compc0
C comparestring                  compe0
C putdata                        putda0
C findfield                      findf0
C outfile                        outfi0
C printrd                        prinv0
C printrow                       prinw0
C comparereal                    compd0
C getdata                        getda0
C addfieldtord                   addfi0
