



      LOGICAL FUNCTION GOTFILE(IUNIT,NAME)



















      IMPLICIT      NONE
      INTEGER       IUNIT, IERR
      LOGICAL       GVFISF
      CHARACTER*(*) NAME







      GOTFILE=.TRUE.
      IUNIT=0



      CALL GVSROF (IUNIT,IERR)
      IF (IUNIT.LE.0.OR.IERR.NE.0) THEN
         GOTFILE=.FALSE.
         GOTO 998
      END IF



      IF (GVFISF(NAME)) CALL GVSDEL (NAME)



      CALL GETFILN (IUNIT,' ',NAME,IERR)
      IF (IERR.NE.0) GOTFILE=.FALSE.



  998 CONTINUE


      RETURN
      END   
      LOGICAL FUNCTION GRTFILE(IUNIT,NAME)


















      IMPLICIT      NONE
      INTEGER       IUNIT, IERR
      LOGICAL       GVFISF
      CHARACTER*(*) NAME







      IF (.NOT.GVFISF(NAME)) THEN
         CALL GVST6C ('?FILNOF',NAME,.TRUE.)
         GRTFILE=.FALSE.
         GOTO 998
      END IF



      GRTFILE=.TRUE.
      IUNIT=0



      CALL GVSROF (IUNIT,IERR)
      IF (IUNIT.LE.0.OR.IERR.NE.0) THEN
         GRTFILE=.FALSE.
         GOTO 998
      END IF



      CALL GETFILE (IUNIT,' ',NAME,IERR)
      IF (IERR.NE.0) GRTFILE=.FALSE.



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE GVSOPF (TEXTIN,NUMUNT,TYPE)


















      IMPLICIT      NONE
      INTEGER       NUMUNT
      CHARACTER*(*) TEXTIN, TYPE
      CHARACTER*80  TEXT



      IF (NUMUNT.GT.0) THEN
         CALL GVSSTX (TEXT,TEXTIN)
         CALL GVSCLF (NUMUNT)



         IF (TYPE(1:3).EQ.'OLD') THEN




               OPEN (UNIT=NUMUNT,FILE=TEXT,ACCESS='SEQUENTIAL',
     +          FORM='FORMATTED',STATUS='OLD',ERR=999)




         ELSE IF (TYPE(1:3).EQ.'APP') THEN
            OPEN (UNIT=NUMUNT,FILE=TEXT,ACCESS='APPEND',
     +       FORM='FORMATTED',STATUS='OLD',ERR=999)



         ELSE IF (TYPE(1:3).EQ.'NEW') THEN
            CALL GVSDEL (TEXT)
            OPEN (UNIT=NUMUNT,FILE=TEXT,ACCESS='SEQUENTIAL',
     +       FORM='FORMATTED',STATUS='NEW',ERR=999)



         ELSE IF (TYPE(1:7).EQ.'UNKNOWN') THEN
            OPEN (UNIT=NUMUNT,FILE=TEXT,ACCESS='SEQUENTIAL',FORM=
     +       'FORMATTED',STATUS='UNKNOWN',ERR=999)



         ELSE
            CALL GVSTTB ('?FILO02')
            CALL GVSTT6 (TYPE)
         END IF
         RETURN
      ELSE



         CALL GVSTTI ('?FILO03',NUMUNT)
      END IF
      RETURN



  999 CONTINUE
      CALL GVSCLF (NUMUNT)
      CALL GVSTTE ('?FILNOF')
      CALL GVSTT6 (TEXT)

      RETURN
      END
      SUBROUTINE GVSOUF (TEXTIN,NUMUNT,TYPE)
















      IMPLICIT      NONE
      INTEGER       NUMUNT
      CHARACTER*(*) TEXTIN, TYPE
      CHARACTER*80  TEXT



      IF (NUMUNT.GT.0) THEN
         CALL GVSSTX (TEXT,TEXTIN)
         CALL GVSCLF (NUMUNT)



         IF (TYPE(1:3).EQ.'OLD') THEN




               OPEN (UNIT=NUMUNT,FILE=TEXT,ACCESS='SEQUENTIAL',
     +          FORM='UNFORMATTED',STATUS='OLD',ERR=999)




         ELSE IF (TYPE(1:3).EQ.'NEW') THEN



            CALL GVSDEL (TEXT)
            OPEN (UNIT=NUMUNT,FILE=TEXT,ACCESS='SEQUENTIAL',FORM=
     +       'UNFORMATTED',STATUS='UNKNOWN',ERR=999)



         ELSE IF (TYPE(1:7).EQ.'UNKNOWN') THEN
            OPEN (UNIT=NUMUNT,FILE=TEXT,ACCESS='SEQUENTIAL',FORM=
     +       'UNFORMATTED',STATUS='UNKNOWN',ERR=999)
            RETURN



         ELSE
            CALL GVSTTB ('?FILO01')
            CALL GVSTT6 (TYPE)
         END IF
         RETURN
      ELSE 



         CALL GVSTTI ('?FILO03',NUMUNT)
      END IF
      RETURN



  999 CONTINUE
      CALL GVSTTE ('?FILNOF')
      CALL GVSTT6 (TEXT)
   
      RETURN
      END
      SUBROUTINE WIF112

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       GVFLEN
      LOGICAL       GVFFOP, GVFISF



      CALL GVSCLF (IU100)
      IF (GVFLEN(FILNMS(100)).EQ.0) CALL GVSCCC
     + (FILNMS(100),FILDIR(28),'ALCOOR.XYZ')
      IF (GVFISF(FILNMS(100))) THEN

               OPEN (UNIT=IU100,FILE=FILNMS(100),ACCESS='DIRECT',
     +          RECL=1120,STATUS='OLD')





         IF (.NOT.GVFFOP(IU100)) CALL GVSTTB ('?FILO04')
      ELSE
         CALL GVSTTE ('?FILO05')
      END IF

      RETURN
      END
      SUBROUTINE GVSODF (IUNIT,KILL,FIL,STAT,REC,MES,IERR)

















      IMPLICIT      NONE
      INTEGER       IUNIT, IERR, REC, GVFLEN
      LOGICAL       GVFIBN, GVFFOP, KILL, GVFISF
      CHARACTER*80  FILE
      CHARACTER*(*) FIL, STAT, MES








      CALL GVSSTX (FILE,FIL)
      IF (.NOT.GVFIBN(IUNIT,1,120)) THEN
         IERR=1
         GOTO 998
      END IF
      IF (IUNIT.EQ.5.OR.IUNIT.EQ.6) THEN
         IERR=1
         GOTO 998
      END IF
      IF (STAT.EQ.'OLD') THEN
         IF (.NOT.GVFISF(FIL)) THEN
            CALL GVST6C ('?NEWE137',FIL,.TRUE.)
            GOTO 998
         END IF
      END IF



      IERR=0
      CALL GVSCLF (IUNIT)
      IF (KILL) CALL GVSDEL (FILE)




      OPEN (UNIT=IUNIT,FILE=FILE,ACCESS='DIRECT',RECL=4*REC,STATUS=STAT)






      IF (.NOT.GVFFOP(IUNIT)) THEN
         IERR=1
         IF (GVFLEN(MES).GT.0) CALL SHOWTEXT (MES)
         CALL GVST6C ('?M3820',FILE,.TRUE.)
      END IF



  998 CONTINUE


      RETURN
      END   
