      Subroutine Chknam(Filnam,IFlag)
c
c ***********************************************************************
c *                                                                     *
c *        Subroutine Chknam - To see if a file name syntax is bad      *
c *                                                                     *
c *        Input values:                                                *
c *                                                                     *
c *        Filnam - Character string containing the file name to check  *
c *                                                                     *
c *        Output values:                                               *
c *                                                                     *
c *        Iflag  - Flag to tell program to abort option                *
c *                                                                     *
c *          Programmed by Steven C. Fisher, DTNSRDC Code 1522          *
c *                                                                     *
c ***********************************************************************
c
      Include 'Cflags'
c
      Character*60 Filnam
      Integer*4 Index,LIB$Find_File,
     $          LIB$Find_File_End,Lib$Match_Cond
      Integer*4 Icontex,Iresult
      Character*60 File_Out,File_Name,Direct
      Character*255 Fspec,Chr*1
      Include '($RMSDEF)'
c
      Iflag = 1
c
c             See if a filename was given
c
      If (Filnam(1:1) .EQ. ' ' .AND. Filnam(2:2) .EQ. ' ') Then
         If (Iabort .EQ. .TRUE.) Then  
            Call Abort
            Go To 20
         End If
         Write(6,150) 7
150      Format(' Routine halted since no file name was given',1A1)
         Return
      End If
c
c             Check the file name for invalid characters and Ctrl-C's
c
 5    Continue
c
      Do 10 I=1,60
         If (Filnam(I:I) .EQ. '*') Then
            Write(6,100)
100         Format(' ERROR - No asterics allowed')
            Go To 20
         End If
         If (Iabort .EQ. .TRUE.) Then  
            Call Abort
            Go To 20
         End If
         Direct(I:I) = Filnam(I:I)
 10   Continue
c
      Icontex = 0
      Fspec = Chr
      File_Out = Chr
      File_Name = Chr
      I1 = 0
      I2 = 0
      Index = Lib$Find_File(File_Name,File_Out,Icontex,
     $         Direct,Fspec,RMS,I1,I2)
      Iresult = LIB$Match_Cond(Index,RMS$_Nmf,RMS$_Dev,RMS$_Dir,
     $              RMS$_Dnf,RMS$_Dnr,RMS$_Fnm,
     $              RMS$_Fnd,RMS$_Nod,RMS$_Fnf,RMS$_Syn,RMS$_Fab)
      If (Iresult .LE. 1) Go To 30 
      If (Iresult .EQ. 9) Go To 40
c
c              See if there was an error encountered
c
      If (Iresult .EQ. 2) Then
         Write(6,200)
200      Format(' ERROR - Incorrect device name ')
      Else If (Iresult .EQ. 3) Then
         Write(6,250)
250      Format(' ERROR - Invalid directory name ')
      Else If (Iresult .EQ. 4) Then
         Write(6,300)
300      Format(' ERROR - Directory does not exist on the device')
      Else If (Iresult .EQ. 5) Then
         Write(6,350)
350      Format(' ERROR - Device Not ready or not mounted')
      Else If (Iresult .EQ. 6) Then
         Write(6,400)
400      Format(' ERROR - Invalid file name')
      Else If (Iresult .EQ. 7) Then
         Write(6,450)
450      Format(' ERROR - Error occured during a directory search')
      Else If (Iresult .EQ. 8) Then
         Write(6,500)
500      Format(' ERROR - Bad Node name')
      Else If (Iresult .EQ. 10) Then
         Write(6,525)
525      Format(' ERROR - Bad syntax')
      End If
c
c              Get a new file name if necesary
c
 20   Continue
      If (Iresult .GT. 1) Then
         Write(6,550)
550      Format(' ERROR - Please enter a new file name:',
     $       ' (return to stop)')
         Read(5,600,END=20,ERR=20) Filnam
600      Format(A)
         Index = LIB$Find_File_End(Icontex)
         If (Filnam(1:1) .EQ. ' ' .AND. Filnam(2:2) .EQ. ' ') Then
            Write(6,150) 7
            Return
         End If
         Go To 5
      End If
c
c             Clean up, Etc.
c
 30   Continue
      If (.NOT. Index) Call Lib$Signal(%Val(Index))      
 40   Continue
      Index = LIB$Find_File_End(Icontex)
      Iflag = 0
      Return
      End
      Subroutine Filchk(Filnam,Isiz,Iflag)
c
c ***********************************************************************
c *                                                                     *
c *      Subroutine FILCHK - To see if a file already exists, or if     *
c *      a file name is bad.  (PDP routine)                             *
c *                                                                     *
c *      Input values:                                                  *
c *                                                                     *
c *      Filnam - Character string containing the file name to check    *
c *      Isiz   - Size of the file to create, in blocks                 *
c *                                                                     *
c *      Output values:                                                 *
c *                                                                     *
c *      Iflag  - Flag to see if there is a problem with the file       *
c *               name, or file size (OK If Iflag = 0)                  *
c *                                                                     *
c *        Programmed by Steven C. Fisher, DTNSRDC Code 1522            *
c *                                                                     *
c ***********************************************************************
c
      Character Filnam*60
c
 10   Continue
c
c         Check to see if the file name has reasonable syntax
c
      Call Chknam(Filnam,Iflag)
      Return
c
      End
