      SUBROUTINE PLNM (MO, PA, NA, PB, NB, PC, NC)
C     ******************************************************************
C     FORTRAN SUBROUTINE FOR POLYNOMIAL ARITHMETIC
C     ******************************************************************
C     MO = MODE OF OPERATION
C     PA = ADDRESS OF POLYNOMIAL A
C     NA = SPECIFICATION OF POLYNOMIAL A
C     PB = ADDRESS OF POLYNOMIAL B
C     NB = SPECIFICATION OF POLYNOMIAL B
C     PC = ADDRESS OF POLYNOMIAL C
C     NC = SPECIFICATION OF POLYNOMIAL C
C
C     MX(1) = INTERVAL BETWEEN COEFFICIENTS
C     MX(2) = NUMBER OF COEFFICIENTS
C
C     CALL PLNM (1, PA, NA, PB, NB)         FOR TRANSFER
C     CALL PLNM (2, PA, NA, PB, NB, PC, NC) FOR ADD
C     CALL PLNM (3, PA, NA, PB, NB, PC, NC) FOR SUBTRACT
C     CALL PLNM (4, PA, NA, PB, NB, PC, NC) FOR MULTIPLY
C     CALL PLNM (5, PA, NA, PB, NB, PC, NC) FOR DIVIDE
C
      DIMENSION PA(1), NA(2), PB(1), NB(2), PC(1), NC(2)
  001 IF(MO.LE.1)GO TO 010
      IF(MO.EQ.2)GO TO 020
      IF(MO.EQ.3)GO TO 030
      IF(MO.EQ.4)GO TO 040
      GO TO 050
  010 IA=NA(1)
      IB=NB(1)
      K=1
      KA=1
      KB=1
      GO TO 014
  011 IF(K.LE.NA(2))GO TO 012
      PB(KB)=0.0
      GO TO 013
  012 PB(KB)=PA(KA)
  013 K=K+1
      KA=KA+IA
      KB=KB+IB
  014 IF(K.LE.NB(2))GO TO 011
      RETURN
  020 IA=NA(1)
      IB=NB(1)
      IC=NC(1)
      K=1
      KA=1
      KB=1
      KC=1
      GO TO 026
  021 IF(K.LE.NA(2))GO TO 022
      TA=0.0
      GO TO 023
  022 TA=PA(KA)
  023 IF(K.LE.NB(2))GO TO 024
      TB=0.0
      GO TO 025
  024 TB=PB(KB)
  025 PC(KC)=TA+TB
      K=K+1
      KA=KA+IA
      KB=KB+IB
      KC=KC+IC
  026 IF(K.LE.NC(2))GO TO 021
      RETURN
  030 IA=NA(1)
      IB=NB(1)
      IC=NC(1)
      K=1
      KA=1
      KB=1
      KC=1
      GO TO 036
  031 IF(K.LE.NA(2))GO TO 032
      TA=0.0
      GO TO 033
  032 TA=PA(KA)
  033 IF(K.LE.NB(2))GO TO 034
      TB=0.0
      GO TO 035
  034 TB=PB(KB)
  035 PC(KC)=TA-TB
      K=K+1
      KA=KA+IA
      KB=KB+IB
      KC=KC+IC
  036 IF(K.LE.NC(2))GO TO 031
      RETURN
  040 IA=NA(1)
      IB=NB(1)
      IC=NC(1)
      M=1
      KC=1
      GO TO 048
  041 IF(M.GT.NA(2))GO TO 042
      I=1
      KA=1-IA+M*IA
      KB=1
      GO TO 043
  042 I=1+M-NA(2)
      KA=1-IA+IA*NA(2)
      KB=1-IB+I*IB
  043 IF(M.GT.NB(2))GO TO 044
      N=M
      GO TO 045
  044 N=NB(2)
  045 SM=0.0
      IF(M.GE.NA(2)+NB(2))GO TO 047
      DO 046 K=I,N
      SM=SM+PA(KA)*PB(KB)
      KA=KA-IA
      KB=KB+IB
  046 CONTINUE
  047 PC(KC)=SM
      M=M+1
      KC=KC+IC
  048 IF(M.LE.NC(2))GO TO 041
      RETURN
  050 IA=NA(1)
      IB=NB(1)
      IC=NC(1)
      I=1
      KA=1
      KB=1
      GO TO 054
  051 IF(I.LE.NA(2))GO TO 052
      TA=0.0
      GO TO 053
  052 TA=PA(KA)
  053 TB=PB(KB)
      IF(TA.NE.0.0)GO TO 055
      IF(TB.NE.0.0)GO TO 055
      I=I+1
      KA=KA+IA
      KB=KB+IB
  054 IF(I.LE.NB(2))GO TO 051
  055 K=I
      KA=1-IA+I*IA
      M=1
      KC=1
      GO TO 059
  056 IF(K.LE.NA(2))GO TO 057
      PC(KC)=0.0
      GO TO 058
  057 PC(KC)=PA(KA)
  058 K=K+1
      M=M+1
      KA=KA+IA
      KC=KC+IC
  059 IF(M.LE.NC(2))GO TO 056
  060 M=1
      KA=1
      N=NB(2)
      GO TO 064
  061 L=M
      KB=1-IB+I*IB
      KC=1-IC+M*IC
      QM=PC(KC)/PB(KB)
      DO 062 K=I,N
      PC(KC)=PC(KC)-QM*PB(KB)
      IF(L.GE.NC(2))GO TO 063
      L=L+1
      KB=KB+IB
      KC=KC+IC
  062 CONTINUE
  063 PC(KA)=QM
      M=M+1
      KA=KA+IC
  064 IF(M.LE.NC(2))GO TO 061
      RETURN
      END
