      SUBROUTINE INTLML(DVALUE,DLINK,AVAIL,MCLASS,CLASNM,VAL,ERSTAT)
C
C**********************************************************************
C
C   NAME- INTLML
C
C   LANGUAGE- VS FORTRAN  TYPE- SUBROUTINE      COMPUTER- NAS 9000
C
C   VERSION- 1.0    DATE- 08/23/89   PROGRAMMER- G. RAJASHEKAR (SMSRC)
C   VERSION- 2.0    DATE- 04/29/96   PROGRAMMER- FRANK TILLEY (SMSRC)
C     FOR REHOSTING TO CRAY: CHANGED I*4 TO INT.
C
C   FUNCTION - THIS SUBROUTINE WILL SET THE POINTER TO THE STARTING
C              NODE OF THE LINKED LIST IN THE STORAGE POOL FOR THE
C              GIVEN CLASS AND THEN INVOKE THE INSERT TAIL ROUTINE
C              TO INSERT THE INPUT VALUE AT TAIL OF THE LINKED LIST.
C
C   CALLING SEQUENCE PARAMETERS-
C
C   NAME     TYPE    I/O     FUNCTION
C   ----     ----    ---     --------
C   DVALUE   INT     I/O     INTEGER VALUE ARRAY OF DIMENSION MPNOD.
C
C   DLINK    INT     I/O     INTEGER LINK ARRAY OF DIMENSION MPNOD.
C
C   AVAIL    INT     I/O     TO UPDATE THE POSITION OF THE
C                            AVAILABLE NODE.
C
C   MCLASS   INT      I      THIS ARRAY WILL HOLD THE POINTERS TO ALL
C                            THE LINKED LISTS IN THE STORAGE POOL.
C
C   CLASNM   INT      I      CLASS NUMBER.
C
C   VAL      INT      I      VALUE TO BE INSERTED INTO THE GIVEN CLASS
C                            LINKED LIST.
C
C   ERSTAT   INT      O      IF THE STORAGE POOL IS FULL THEN ERROR
C                            STATUS IS RETURNED AS NON-ZERO
C
C
      INCLUDE 'LLPARM'
C
      INTEGER   AVAIL,CLASNM,VAL,ERSTAT
      INTEGER   DVALUE(MPNOD),DLINK(MPNOD),MCLASS(MAXCL)
C
C   LOCAL PARAMETERS-
C
C   VARIABLE               TYPE   FUNCTION
C   --------               ----   --------
C   START                  INT    POINTER TO THE STARTING POSITION OF
C                                 THE LINKED LIST IN THE STORAGE POOL.
C
C
      INTEGER   START
C
      INCLUDE 'SPVAL'
C
C   SUBROUTINES CALLED - LLINTL
C
C   FUNCTIONS USED - NONE
C
C   EXIT STATES  - NONE
C
C   COMMENTS - PRIOR TO CALLING INTLML, THE INPUT LIST OF POINTERS
C              (MCLASS ARRAY) MUST BE INITIALIZED TO MISSING VALUES
C              SINCE INTLML USES THESE MISSING VALUES TO DETERMINE
C              THE EXISTANCE OF THE SPECIFIED CLASS LINKED LIST.
C              FAILING TO SET THE LIST OF POINTERS (MCLASS ARRAY)
C              TO MISSING VALUES MAY PRODUCE UNPREDICTABLE ERRORS.
C
C***********************************************************************
C
C--- IF THE LINKED LIST FOR THE GIVEN CLASS IS CREATED FOR THE FIRST
C    TIME THEN THIS PART OF THE PROGRAM WILL STORE THE POINTER TO THE
C    STARTING POSITION FOR THE LINKED LIST IN THE CORRESPONDING ELEMENT
C    OF THE MCLASS ARRAY AND THEN INVOKES THE INSERT TAIL ROUTINE.
C
C
      ERSTAT = 0

      IF (MCLASS(CLASNM).EQ.I4SPV) THEN
         MCLASS(CLASNM) = AVAIL
         START = MCLASS(CLASNM)
         CALL LLINTL(START,DVALUE,DLINK,AVAIL,VAL,ERSTAT)
         IF (ERSTAT.NE.0) GO TO 9000
      ELSE
C--- IF THE LINKED LIST FOR THE GIVEN CLASS ALREADY EXISTS THEN, THIS
C    PART OF THE PROGRAM WILL TAKE THE POINTER TO THE STARTING POSITION
C    OF THE REQUIRED LIST FROM THE MCLASS ARRAY AND THEN INVOKES THE
C    INSERT TAIL ROUTINE.
C
         START = MCLASS(CLASNM)
         CALL LLINTL(START,DVALUE,DLINK,AVAIL,VAL,ERSTAT)
      END IF
C
 9000 RETURN
C
      END
