*DECK DRVDEL
      SUBROUTINE DRVDEL(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
*
*-----------------------------------------------------------------------
*
* DESTROY ONE OR MANY LINKED LISTS OR FILES.
*
* INPUT/OUTPUT PARAMETERS:
*  NENTRY : NUMBER OF LINKED LISTS AND FILES USED BY THE MODULE.
*  HENTRY : CHARACTER*12 NAME OF EACH LINKED LIST OR FILE.
*  IENTRY : =0 CLE-2000 VARIABLE; =1 LINKED LIST; =2 XSM FILE;
*           =3 SEQUENTIAL BINARY FILE; =4 SEQUENTIAL ASCII FILE;
*           =5 DIRECT ACCESS FILE.
*  JENTRY : =-2 THE LINKED LIST OR FILE HAVE BEEN DESTROYED;
*           =-1 THE LINKED LIST OR FILE IS CLOSED;
*           =0 THE LINKED LIST OR FILE IS CREATED.
*           =1 THE LINKED LIST OR FILE IS OPEN FOR MODIFICATIONS;
*           =2 THE LINKED LIST OR FILE IS OPEN IN READ-ONLY MODE.
*  KENTRY : FILE UNIT NUMBER OR LINKED LIST ADDRESS.
*           DIMENSION HENTRY(NENTRY),IENTRY(NENTRY),JENTRY(NENTRY),
*           KENTRY(NENTRY)
*
*-------------------------------------- AUTHOR: A. HEBERT ; 08/11/93 ---
*
      USE GANLIB
*----
*  SUBROUTINE ARGUMENTS
*----
      INTEGER NENTRY,IENTRY(NENTRY),JENTRY(NENTRY)
      CHARACTER HENTRY(NENTRY)*12
      TYPE(C_PTR) KENTRY(NENTRY)
*----
*  LOCAL VARIABLES
*----
      CHARACTER HSMG*131,TEXT12*12
      LOGICAL LDEL
*
      LDEL=.TRUE.
      DO 40 I=1,NENTRY
      IF(JENTRY(I).EQ.1) THEN
         TEXT12=HENTRY(1)
         LDEL=.FALSE.
         IF(IENTRY(I).LE.2) THEN
            CALL LCMCL(KENTRY(I),2)
            JENTRY(I)=-2
            KENTRY(I)=C_NULL_PTR
         ELSE
            NUNIT=FILUNIT(KENTRY(I))
            IERR=FILCLS(KENTRY(I),2)
            IF(IERR.LT.0) THEN
               WRITE(HSMG,'(29HDRVDEL: FILCLS FAILURE. IERR=,I3,
     1         7H NUNIT=,I5,6H NAME=,A12)') IERR,NUNIT,TEXT12
               CALL XABORT(HSMG)
            ENDIF
            JENTRY(I)=-2
            KENTRY(I)=C_NULL_PTR
         ENDIF
      ENDIF
   40 CONTINUE
      IF(LDEL) CALL XABORT('DRVDEL: NO ENTRY DELETED.')
      RETURN
      END
