C******************** START FILE UFLCHK.FOR ; GROUP UFILS0 ******************
C==================================================================
C  UFILS0.FOR
C  UTILITY SUBROUTINES FOR UFILES FILE SYSTEM
C
C-------------
C  UFLCHK
C
C  CHECK STATUS OF PASSED LOGICAL UNIT NUMBER
C   IF IT IS KNOWN RETURN THE INTERNAL CHANNEL NUMBER ASSOCIATED
C  WITH IT.  IF IT IS NOT KNOWN PRINT AN ERROR MESSAGE, SET FLAG
C  AND EXIT
C
      SUBROUTINE UFLCHK(ILUN,ZNAME,ICHAN,IER)
C
      USE UFILES
      CHARACTER*10 ZNAME
C
C  ILUN-- LOGICAL UNIT NUMBER TO CHECK
C   A CALL TO UFSETR SHOULD HAVE BEEN MADE FIRST
C  ZNAME-- NAME OF SUBROUTINE CALLING UFLCHK
C  ICHAN-- OUTPUT INTERNAL CHANNEL NUMBER WITH WHICH ILUN IS
C   ASSOCIATED
C  IER-- RETURN CODE, 0 DENOTES SUCCESS
C
      IER=0
      ICHAN=IUXCHA(ILUN)
      IF(ICHAN.NE.0) RETURN
      IER=1
      WRITE(UFELUN,9001) ZNAME,ILUN
 9001 FORMAT(
     >  ' ? ',A10,' -- ATTEMPT TO USE UNASSIGNED LOGICAL UNIT NUMBER:',
     >  2X,I3/'   CALL UFSETR(LUN,...) FIRST'/)
      IER=1
      RETURN
      	END
C******************** END FILE UFLCHK.FOR ; GROUP UFILS0 ******************
