      SUBROUTINE GETNOD(DLINK,LENGTH,AVAIL,POST,ERSTAT)
      IMPLICIT NONE
C
C**********************************************************************
C
C   NAME- GETNOD
C
C   LANGUAGE- VS FORTRAN  TYPE- SUBROUTINE      COMPUTER- NAS 9000
C
C   VERSION- 1.0    DATE- 09/13/89   PROGRAMMER- G. RAJASHEKAR (SMSRC)
C   VERSION- 2.0    DATE- 07/19/94   PROGRAMMER- FRANK TILLEY (SMSRC)
C         ATOVS-12  EXPLICITLY DECLARED I*4 VARIABLE "LENGTH".
C   VERSION- 2.1    DATE- 04/29/96   PROGRAMMER- FRANK TILLEY (SMSRC)
C      FOR REHOSTING TO CRAY: CHANGED ALL I*4 TO INT.
C
C   FUNCTION - GIVEN A POINTER POINTING TO THE CURRENT ELEMENT OF A
C              LINKED LIST, THIS SUBROUTINE WILL RETURN THE POSITION
C              OF THE NEXT AVAILABLE NODE IN THE LINKED LIST.
C
C   CALLING SEQUENCE PARAMETERS-
C
C   NAME     TYPE    I/O     FUNCTION
C   ----     ----    ---     --------
C
C   DLINK    INT      I      INTEGER LINK ARRAY OF DIMENSION LENGTH.
C
C   LENGTH   INT      I      LENGTH OF THE LINK ARRAY.
C
C   AVAIL    INT     I/O     INPUT: CURRENT NODE IN LIST
C                            OUTPUT: SUBSEQUENT NODE.
C
C   POST     INT      O      POINTER TO NODE CURRENT AT TIME
C                            OF ENTRY TO ROUTINE.
C
C   ERSTAT   INT      O      ERROR STATUS
C
      INTEGER   LENGTH
      INTEGER   DLINK(LENGTH),AVAIL,POST, ERSTAT
C
C
C   SUBROUTINES CALLED - NONE
C
C   FUNCTIONS USED - NONE
C
C   EXIT STATE - ERSTAT IS SET TO 99 IF NO NODES ARE AVAILABLE
C
C**********************************************************************
C
C*** THE NEXT NODE AVAILABLE IN THE STORAGE POOL IS ASSIGNED TO AVAIL.
C
      POST = AVAIL
      AVAIL = DLINK(AVAIL)
C
C*** SEND ERROR MESSAGE IF THERE IS NO MORE NODES AVAILABLE IN THE
C    STORAGE POOL FOR INSERTING DATA.
C
      ERSTAT = 0
      IF (DLINK(AVAIL) .EQ. -1) THEN
         ERSTAT = 99
         RETURN
      END IF
C
      RETURN
      END
