      SUBROUTINE GETMNAME
C Gets model file name
      INCLUDE 'BINFIT.INC'
      INCLUDE 'MODEL.INC'

      IF (FRSTRY) THEN
C  Return here on file open error
   20     WRITE (OUTC,1000) ' Input model file name'
          READ(INC,1000) MODDSN
          IF (MODDSN.NE.' ') THEN
              IER = VLBOPE(INMOD, MODDSN, 'MODEL', 'OLD', MODDSN)
              IF (IER.NE.1) GO TO 20      ! Try again
              NEWMOD = .FALSE.
          ELSE
              NEWMOD = .TRUE.
          END IF
C   20     IER = GETIN(MODDSN, ' Input model file name'//
C     1                ' (default=create new model file): ', L)
C          IF (IER.NE.1) CALL EXIT
C          IF (L.LT.1) THEN
C              NEWMOD = .TRUE.
C          ELSE
C              IER = VLBOPE(INMOD, MODDSN, 'MODEL', 'OLD', MODDSN)
C              IF (IER.NE.1) GOTO 20        ! Try again
C              NEWMOD = .FALSE.
C          END IF
      ELSE
          INQUIRE (FILE=MODDSN,NAME=OLDDSN)
          LENGTH = INDEX(OLDDSN,' ') - 1
C  Return here on new file name error
   21     WRITE (OUTC,1000) '$New input model file name (default=',
     1                       OLDDSN(1:LENGTH),'): '
          READ  (INC, 1000) NEWDSN
          IF (NEWDSN .NE. ' ') THEN
              CLOSE (UNIT=INMOD)
              OPEN  (UNIT=INMOD,FILE=NEWDSN,STATUS='OLD',
     1               FORM='FORMATTED',ERR=21)   ! On error, try again
              MODDSN = NEWDSN
          ELSE
              CLOSE (UNIT=INMOD)
              OPEN  (UNIT=INMOD,FILE=MODDSN,STATUS='OLD',
     1               FORM='FORMATTED',ERR=21)   ! On error, try again
          END IF
          NEWMOD = .FALSE.
      END IF
      RETURN
 1000 FORMAT(A,A,A,A)
      END
