        SUBROUTINE CLISTERR
C Output of ERRFIT, error estimator for models of binaries fit with 
C BINFIT
C
C     J.T. Armstrong          23 Jan 1991
C
      INCLUDE 'BINFIT.INC'

      CHARACTER*64 OUTNAM
      CHARACTER*24 MESSAGE
      CHARACTER*80 HISTRY
      CHARACTER*1  BLANK
      INTEGER*4    VLBOPE, GETIN, IER, LEN1, OUTPR
      REAL*8       TJDINT, TJDPRIME

      DATA BLANK/' '/

   10 WRITE(OUTC,*) ' Enter name of file for output (default=screen): '
      READ(INC,'(A)') OUTNAM
      IF (OUTNAM.EQ.' ') THEN
          OUTPR = OUTC
D         WRITE(OUTPR,'(A,I2)') ' OUTPR = ',OUTPR
      ELSE
          OUTPR = OUTDAT
          OPEN(UNIT=OUTPR,FILE=OUTNAM,STATUS='NEW',FORM='FORMATTED',
     1         ERR=10)
      END IF

      CALL MKHIST('ERRFIT','4 Mar 1991',HISTRY)
      L = LEN1(HISTRY)
      WRITE(OUTPR,1000) HISTRY(1:L)
      WRITE (OUTPR,1000) ' Input data file(s):  '
      DO I = 1, NFILES
          L = LEN1(INFILE(I))
          WRITE(OUTPR,1000) '      ',INFILE(I)(1:L)
      END DO
      L = LEN1(MODDSN)
      WRITE (OUTPR,1000) ' Final model file:  ',MODDSN(1:L)
      WRITE (OUTPR,1001) STARNAME,NDAY,NYEAR
      WRITE (OUTPR,1000) '    Filter    Width     Reduced Degrees of'
      WRITE (OUTPR,1000) '                         Chi^2    Freedom'
      DO IG=1,NFILT
          WRITE (OUTPR,1002) LAMBDA0(IG),DLAMBDA(IG),FCHISQ(IG),
     1                       NZVIS(IG)-NVPAR(IG)
      END DO
      WRITE (OUTPR,1003) 'Reduced chi squared for all data:  ',TCHISQ
      WRITE (OUTPR,1004) 'Number of data points:             ',NZTOT
      WRITE (OUTPR,1004) 'Degrees of freedom:                ',
     1                     NZTOT-NVPARTOT
      WRITE (OUTPR,1000) ' Final model:'
      CALL CWRITEMD(OUTPR,' ',PARM,0,0)

      CALL WRITEHD(OUTPR,BLANK)
      DO IC = 1, NCOMP
          DO IG = 1,NFILT
              CALL CWRITEMD(OUTPR,BLANK,PARM,IC,IG)
          END DO
      END DO
      WRITE(OUTPR,1000) '  '
      WRITE(OUTPR,*)  'Uncertainties to larger parameter values:'
      DO IC = 1, NCOMP
          DO IG = 1,NFILT
              CALL CWRITEMD(OUTPR,BLANK,PUNCERTU,IC,IG)
          END DO
      END DO
      WRITE(OUTPR,1000) '  '
      WRITE(OUTPR,*)  'Uncertainties to smaller parameter values:'
      DO IC = 1, NCOMP
          DO IG = 1,NFILT
              CALL CWRITEMD(OUTPR,BLANK,PUNCERTD,IC,IG)
          END DO
      END DO
      WRITE(OUTPR,1000) '  '
      WRITE(OUTPR,*) 'Uncertainties with parabolic approximation:'
      DO IC = 1, NCOMP
          DO IG = 1,NFILT
              CALL CWRITEMD(OUTPR,BLANK,PUNCERT0,IC,IG)
          END DO
      END DO
      WRITE(OUTPR,1000) '  '

      CLOSE(OUTPR)

      RETURN

 1000 FORMAT (A,A,A,A)
 1001 FORMAT (' Source: ',A,' Day: ',I4,' Year: ',I5)
 1002 FORMAT (' ',3X,F5.1,' nm',2X,F3.0,' nm',3X,F8.3,3X,I4)
 1003 FORMAT (' ',(A), F8.3 )
 1004 FORMAT (' ',(A), I4 )
 1005 FORMAT (' ',(A), F10.0 )

      END


