      SUBROUTINE FILE(MAMP,IOUT,MX,MXT2)
C
C     THIS SUBROUTINE OPENS THE SCRATCH AND OUTPUT FILES GENERATED BY 
C     COUPLE 
C 
C     RECL=16*MX*MX IS NEEDED TO WRITE A MX*MX COMPLEX MATRIX 
C     (2*MX*MX 8 BYTE (64 BIT) WORDS) ON UNIT 1,2,3 AND 8
C
C     ELIMINATED STATUS='SCRATCH' FOR LF90 ON 8/20/96
C
      IMPLICIT REAL*8 (A-H,O-Z)
C
CCC      NRECL=16*MX*MX
CCC      OPEN(1,STATUS='SCRATCH',RECL=NRECL,FORM='UNFORMATTED')
CCC      OPEN(2,STATUS='SCRATCH',RECL=NRECL,FORM='UNFORMATTED')
CCC      OPEN(3,STATUS='SCRATCH',RECL=NRECL,FORM='UNFORMATTED')
CCC      OPEN(8,STATUS='SCRATCH',RECL=NRECL,FORM='UNFORMATTED')
C
C      OPEN(21,STATUS='SCRATCH',FORM='UNFORMATTED',IOSTAT=I21)
C      OPEN(2, STATUS='SCRATCH',FORM='UNFORMATTED',IOSTAT=I2)
C      OPEN(3, STATUS='SCRATCH',FORM='UNFORMATTED',IOSTAT=I3)
C      OPEN(8, STATUS='SCRATCH',FORM='UNFORMATTED',IOSTAT=I8)
C      
C
      OPEN(21,FILE='SCRACH21.DAT',STATUS='UNKNOWN',FORM='UNFORMATTED'
     1       ,IOSTAT=I21)
      OPEN(2, FILE='SCRACH2.DAT', STATUS='UNKNOWN',FORM='UNFORMATTED'
     1       ,IOSTAT=I2)
      OPEN(3, FILE='SCRACH3.DAT', STATUS='UNKNOWN',FORM='UNFORMATTED'
     1       ,IOSTAT=I3)
      OPEN(8, FILE='SCRACH8.DAT', STATUS='UNKNOWN',FORM='UNFORMATTED'
     1       ,IOSTAT=I8)
C
C     OPEN DIRECT ACCESS FILE FOR STORAGE OR RETRIEVAL OF
C     EIGENVALUES WITH IREIG .NE. 0
C
      IRECL=16*MX
C      OPEN(18,STATUS='SCRATCH',FORM='UNFORMATTED',ACCESS='DIRECT',
C     1        RECL=IRECL,IOSTAT=I18)
C      
      OPEN(18,FILE='SCRACH18.DAT',STATUS='UNKNOWN',FORM='UNFORMATTED'
     1       ,ACCESS='DIRECT',RECL=IRECL,IOSTAT=I18)
C
CCC      NRECL=16*MXT2*MXT2
CCC      OPEN(4,STATUS='SCRATCH',RECL=NRECL,FORM='UNFORMATTED')
C      OPEN(4,STATUS='SCRATCH',FORM='UNFORMATTED',IOSTAT=I4)
C
      OPEN(4,FILE='SCRACH4.DAT',STATUS='UNKNOWN',FORM='UNFORMATTED'
     1      ,IOSTAT=I4)
C
      OPEN(10,FILE='COUPLE.TL',FORM='FORMATTED',IOSTAT=I10)
      IF(MAMP .GT. 0) OPEN(11,FILE='COUPLE.AMP',FORM='FORMATTED')
      OPEN(7 ,FILE='COUPLE.CPR',FORM='UNFORMATTED',IOSTAT=I7)
C
      IF(IOUT .NE. 1) THEN 
      OPEN(12,FILE='COUPLEO.TL',FORM='FORMATTED',IOSTAT=I12)
      OPEN(13,FILE='COUPLEI.TL',FORM='FORMATTED',IOSTAT=I13)
      OPEN(17,FILE='COUPLES.TL',FORM='FORMATTED',IOSTAT=I17)
C
      OPEN(14,FILE='COUPLEO.CPR',FORM='UNFORMATTED',IOSTAT=I14)
      OPEN(15,FILE='COUPLEI.CPR',FORM='UNFORMATTED',IOSTAT=I15)
      OPEN(16,FILE='COUPLES.CPR',FORM='UNFORMATTED',IOSTAT=I16)
      END IF
C
      RETURN
      END
