C
C This file is issued from the MODULEF library, but has been 
C subsequently modified
C
      SUBROUTINE FONOP2(NCODOP,IMODE,MOPN,MI,MR,ML,MC,MD,ICODE)
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C           S.P. FONOP2          (FONCTIONS INTERPRETEES)
C           -----------
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C BUT :
C     EFFECTUER UNE OPERATION BINAIRE
C
C PARAMETRES D ENTREE :
C     NCODOP  : CODE OPERATION
C     IMODE   : 1 OPERATION SUR LES TYPES SEULEMENT
C             : 0 OPERATION SUR LES TYPES ET LES VALEURS
C     MOPN    : PILE DES OPERANDES
C     MI,MR,ML,MC,MD : TABLE DES CONSTANTES ENTIERES, REELLES, ...
C
C PARAMETRES DE SORTIE :
C     ICODE   : CODE DE RETOUR (VOIR LE S.P. FONERR)
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C PROGRAMMEUR : PATRICK LAUG ; INRIA (3) 954 90 20 POSTE 508
C ......................................................................
      INTEGER          MOPN(*),MI(*)
      REAL             MR(*)
      LOGICAL          ML(*)
      INTEGER          MC(*)
      DOUBLE PRECISION MD(*)
      COMMON /FONLC / LCI,LCR,LCL,LCC,LCD,LCOPN,LCOPT,LCSYM,LCEXP,LCIDN
      COMMON /FONLM / LMI,LMR,LML,LMC,LMD,LMOPN,LMOPT,LMSYM,LMEXP,LMIDN
C
C REPERAGE DES OPERANDES
      ICODE = 0
      LCOPN = LCOPN - 1
      IF (LCOPN.LE.0) GOTO 800
      ITYPE1 = (MOPN(LCOPN)-30 000) / 1000
      IF (ITYPE1.GT.2) GOTO 800
      II = 30 000 + ITYPE1*1000
      I1 = MOPN(LCOPN) - II
      ITYPE2 = (MOPN(LCOPN+1)-30 000) / 1000
      IF (ITYPE2.NE.ITYPE1) GOTO 800
      I2 = MOPN(LCOPN+1) - II
      I3 = (LMI - LMOPN) + LCOPN
      MOPN(LCOPN) = II + I3
      IF (IMODE.NE.0) RETURN
C
C BRANCHEMENT SELON NCODOP
      GOTO (10,20,30,40,50,60,70,80,90,100,110,120,130,140),NCODOP
      GOTO 800
C
C
C  1: +
   10 GOTO (11,12,13,800,15),ITYPE1
   11 MI(I3) = MI(I1) + MI(I2)
      GOTO 900
   12 MR(I3) = MR(I1) + MR(I2)
      GOTO 900
   13 ML(I3) = ML(I1) .OR. ML(I2)
      GOTO 900
   15 MD(I3) = MD(I1) + MD(I2)
      GOTO 900
C
C  2: -
   20 GOTO (21,22,800,800,25),ITYPE1
   21 MI(I3) = MI(I1) - MI(I2)
      GOTO 900
   22 MR(I3) = MR(I1) - MR(I2)
      GOTO 900
   25 MD(I3) = MD(I1) - MD(I2)
      GOTO 900
C
C  3: *
   30 GOTO (31,32,33,800,35),ITYPE1
   31 MI(I3) = MI(I1) * MI(I2)
      GOTO 900
   32 MR(I3) = MR(I1) * MR(I2)
      GOTO 900
   33 ML(I3) = ML(I1) .AND. ML(I2)
      GOTO 900
   35 MD(I3) = MD(I1) * MD(I2)
      GOTO 900
C
C  4: /
   40 GOTO (41,42,800,800,45),ITYPE1
   41 MI(I3) = MI(I1) / MI(I2)
      GOTO 900
   42 MR(I3) = MR(I1) / MR(I2)
      GOTO 900
   45 MD(I3) = MD(I1) / MD(I2)
      GOTO 900
C
C  5: **
   50 GOTO (51,52,800,800,55),ITYPE1
   51 MI(I3) = MI(I1) ** MI(I2)
      GOTO 900
C --- ON UTILISE SI POSSIBLE UN EXPOSANT ENTIER
   52 IEXP = NINT(MR(I2))
      IF (REAL(IEXP).EQ.MR(I2)) THEN
         MR(I3) = MR(I1) ** IEXP
      ELSE
         MR(I3) = MR(I1) ** MR(I2)
      END IF
      GOTO 900
   55 IEXP = NINT(MD(I2))
      IF (DBLE(IEXP).EQ.MD(I2)) THEN
         MD(I3) = MD(I1) ** IEXP
      ELSE
         MD(I3) = MD(I1) ** MD(I2)
      END IF
      GOTO 900
C
C  6: .EQ.
   60 GOTO (61,62,63,64,65),ITYPE1
   61 ML(I3) = MI(I1) .EQ. MI(I2)
      GOTO 900
   62 ML(I3) = MR(I1) .EQ. MR(I2)
      GOTO 900
   63 ML(I3) = ML(I1) .EQV. ML(I2)
      GOTO 900
   64 ML(I3) = MC(I1) .EQ. MC(I2)
      GOTO 900
   65 ML(I3) = MD(I1) .EQ. MD(I2)
      GOTO 900
C
C  7: .NE.
   70 GOTO (71,72,73,74,75),ITYPE1
   71 ML(I3) = MI(I1) .NE. MI(I2)
      GOTO 900
   72 ML(I3) = MR(I1) .NE. MR(I2)
      GOTO 900
   73 ML(I3) = ML(I1) .NEQV. ML(I2)
      GOTO 900
   74 ML(I3) = MC(I1) .NE. MC(I2)
      GOTO 900
   75 ML(I3) = MD(I1) .NE. MD(I2)
      GOTO 900
C
C  8: .GT.
   80 GOTO (81,82,800,800,85),ITYPE1
   81 ML(I3) = MI(I1) .GT. MI(I2)
      GOTO 900
   82 ML(I3) = MR(I1) .GT. MR(I2)
      GOTO 900
   85 ML(I3) = MD(I1) .GT. MD(I2)
      GOTO 900
C
C  9: .LT.
   90 GOTO (91,92,800,800,95),ITYPE1
   91 ML(I3) = MI(I1) .LT. MI(I2)
      GOTO 900
   92 ML(I3) = MR(I1) .LT. MR(I2)
      GOTO 900
   95 ML(I3) = MD(I1) .LT. MD(I2)
      GOTO 900
C
C 10: .GE.
  100 GOTO (101,102,800,800,105),ITYPE1
  101 ML(I3) = MI(I1) .GE. MI(I2)
      GOTO 900
  102 ML(I3) = MR(I1) .GE. MR(I2)
      GOTO 900
  105 ML(I3) = MD(I1) .GE. MD(I2)
      GOTO 900
C
C 11: .LE.
  110 GOTO (111,112,800,800,115),ITYPE1
  111 ML(I3) = MI(I1) .LE. MI(I2)
      GOTO 900
  112 ML(I3) = MR(I1) .LE. MR(I2)
      GOTO 900
  115 ML(I3) = MD(I1) .LE. MD(I2)
      GOTO 900
C
C 12: MOD
  120 GOTO (121,122,800,800,125),ITYPE1
  121 MI(I3) = MOD(MI(I1), MI(I2))
      GOTO 900
  122 MR(I3) = MOD(MR(I1), MR(I2))
      GOTO 900
  125 MD(I3) = MOD(MD(I1), MD(I2))
      GOTO 900
C
C 13: MIN
  130 GOTO (131,132,800,800,135),ITYPE1
  131 MI(I3) = MIN(MI(I1), MI(I2))
      GOTO 900
  132 MR(I3) = MIN(MR(I1), MR(I2))
      GOTO 900
  135 MD(I3) = MIN(MD(I1), MD(I2))
      GOTO 900
C
C 14: MAX
  140 GOTO (141,142,800,800,145),ITYPE1
  141 MI(I3) = MAX(MI(I1), MI(I2))
      GOTO 900
  142 MR(I3) = MAX(MR(I1), MR(I2))
      GOTO 900
  145 MD(I3) = MAX(MD(I1), MD(I2))
      GOTO 900
C
C RETOUR (AVEC OU SANS ERREUR)
  800 ICODE = 18
  900 RETURN
      END
