      SUBROUTINE OPENFILE(IFLAG,LUNIT,FILENAME)
      CHARACTER*(*) FILENAME
      
      CLOSE(LUNIT)
      IF(IFLAG.EQ.1) THEN
         OPEN(LUNIT,FILE=FILENAME,FORM='FORMATTED',STATUS='UNKNOWN')
      ELSE
         OPEN(LUNIT,FILE=FILENAME,FORM='UNFORMATTED',STATUS='UNKNOWN')
      ENDIF
      WRITE(*,'(A,I4,A,A50)') 'Opening unit ',LUNIT,' with file ',
     $    FILENAME
      RETURN
      END







