C
C This file is issued from the MODULEF library, but has been 
C subsequently modified
C
      SUBROUTINE FONAID(CIDEN,NUMERO,ICODE)
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C           S.P. FONAID          (FONCTIONS INTERPRETEES)
C           -----------
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C BUT :
C     AJOUTER UN IDENTIFICATEUR DANS LA TABLE DES IDENTIFICATEURS
C
C PARAMETRES D ENTREE :
C     CIDEN   : IDENTIFICATEUR A AJOUTER
C
C PARAMETRES DE SORTIE :
C     NUMERO  : NUMERO DANS LA TABLE DES IDENTIFICATEURS
C     ICODE   : CODE DE RETOUR (VOIR LE S.P. FONERR)
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C PROGRAMMEUR : PATRICK LAUG ; INRIA (3) 954 90 20 POSTE 508
C ......................................................................
      PARAMETER (LIDN=8)
      CHARACTER*(*) CIDEN
      CHARACTER*256 MIDN(LIDN)
      COMMON /FONIDN/ MIDN
      COMMON /FONNUM/ IDLIG,IFLIG,NITEMS,NBIDEN,IMPLIC
      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 L'IDENTIFICATEUR EST-IL DEJA DANS LA TABLE ?
      CALL FONCID(CIDEN,NUMERO,ICODE)
      IF (ICODE.EQ.0) THEN
         ICODE = 22
         RETURN
      END IF
C
C ON N'A PAS TROUVE L'IDENTIFICATEUR
      IDEB = INDEX(MIDN(LCIDN), '||') + 1
      LTOTAL = IDEB + LEN(CIDEN) + 1
      IF (LTOTAL .GT. 256) THEN
         LCIDN = LCIDN + 1
         IF (LCIDN .GT. LMIDN) THEN
            ICODE = 31
            RETURN
         END IF
         MIDN(LCIDN)(1:1) = '|'
         IDEB = 2
         LTOTAL = LEN(CIDEN) + 3
      END IF
      MIDN(LCIDN)(IDEB:LTOTAL-2)   = CIDEN
      MIDN(LCIDN)(LTOTAL-1:LTOTAL) = '||'
      NBIDEN = NBIDEN + 1
      ICODE = 0
      END
