      INTEGERIVAR(16),FIX(20),STATUS,I,II,ISTAT,N,NP,J
      INTEGERNL,NPAR,NFUN,NDAT,NIND,KUN,KNUL,IDVAR
      INTEGERITER,MADRID(1),NAMLEN
      REALCHISQ,RELAX
      DOUBLEPRECISIONERR(20),PAR(20)
      CHARACTER*80LINE,HEAD,OUT
      CHARACTER*80NAME,FILE,FNAME
      CHARACTER*4TYPE
      CHARACTER*30AUX,AUX1
      CHARACTER*16MSG
      INTEGERFZFUNX  
      INTEGERFZINDX  
      INTEGERFZPARX  
      INTEGERFZDEFX  
      INTEGERFZNCHR 
      INTEGERFZNING 
      INTEGERFZNREL 
      INTEGERFZCING 
      INTEGERFZCREL 
      PARAMETER(FZFUNX  =16)
      PARAMETER(FZINDX  =3)
      PARAMETER(FZPARX  =128)
      PARAMETER(FZDEFX  =50)
      PARAMETER(FZNCHR =28)
      PARAMETER(FZNING =14)
      PARAMETER(FZNREL =109)
      PARAMETER(FZCREL =103)
      PARAMETER(FZCING =5)
      CHARACTER*12FZNAME
      CHARACTER*4FZTYPE
      CHARACTER*12FZMASK
      CHARACTER*12FZRIMA
      CHARACTER*8FZFNAM(FZDEFX  )
      CHARACTER*80FZSPEC(FZFUNX  )
      CHARACTER*8FZPTON  (FZPARX  )
      INTEGERFZNFUN
      INTEGERFZNITR 
      INTEGERFZNDAT
      INTEGERFZNPTT 
      INTEGERFZFLAG
      INTEGERFZDVAR
      INTEGERFZWEIT  
      INTEGERFZNIND
      INTEGERFZIVAR(FZINDX  )
      INTEGERFZNPIX(FZINDX  )
      INTEGERFZFIXD (FZPARX  )
      INTEGERFZFCOE (FZFUNX  )
      INTEGERFZACTR  (FZFUNX  )
      INTEGERFZPLEN(FZPARX  )
      INTEGERFZNAXS 
      INTEGERFZPPRN
      INTEGERFZIWGT
      INTEGERFZIBND
      INTEGERFZIMET
      REALFZRELX 
      REALFZCCHS 
      REALFZCHIQ 
      REALFZCHI(100)
      REALFZSTAT (FZINDX  )
      REALFZSTEP(FZINDX  )
      DOUBLEPRECISIONFZERRR (FZPARX  )
      DOUBLEPRECISIONFZVALE (FZPARX  )
      DOUBLEPRECISIONFZGUES (FZPARX  )
      DOUBLEPRECISIONFZDUMM
      REALFZUNCR (FZPARX  )
      REALFZPFAC(FZPARX  )
      INTEGERFZPTRI
      INTEGERFZPTRM
      INTEGERFZMAPD  
      INTEGERFZFPAR(FZDEFX  )
      INTEGERFZSELE(20)
      CHARACTER*28FZCHAR
      INTEGERFZINTG(FZNING )
      REALFZREAL(FZNREL )
      REALFZMETR  (10)
      DOUBLEPRECISIONFZLOWB(FZPARX  )
      DOUBLEPRECISIONFZUPPB(FZPARX  )
      INTEGERFZNRPX  
      INTEGERFERPAR
      INTEGERFERFUN
      INTEGERFERTAB
      INTEGERFERDAT
      INTEGERFERPFU
      INTEGERFERDUP
      INTEGERFERCON
      INTEGERFZIDEN
      COMMON/FITCM0/FZNAME,FZTYPE,FZMASK,FZRIMA,FZFNAM,FZSPEC,FZPTON  
      COMMON/FITCM1/FZERRR ,FZVALE ,FZGUES ,FZNFUN,FZNITR ,FZNDAT,FZNPTT
     + ,FZFLAG,FZDVAR,FZWEIT  ,FZNIND,FZIVAR,FZNPIX,FZFIXD ,FZFCOE ,FZAC
     +TR  ,FZPLEN,FZRELX ,FZCCHS ,FZCHIQ ,FZCHI,FZSTAT ,FZSTEP,FZUNCR ,F
     +ZPFAC,FZPTRI,FZPTRM,FZMAPD  ,FZFPAR,FZSELE
      COMMON/FITCM2/FZMETR  ,FZLOWB,FZUPPB,FZNRPX  ,FZPPRN,FZIWGT,FZIBND
     +,FZIMET
      COMMON/FITCM3/FERPAR,FERFUN,FERTAB,FERDAT,FERPFU,FERDUP,FERCON,FZI
     +DEN
      EQUIVALENCE(FZNAXS ,FZNIND)
      EQUIVALENCE(FZCHAR,FZNAME)
      EQUIVALENCE(FZINTG,FZNFUN)
      EQUIVALENCE(FZREAL,FZRELX )
      EQUIVALENCE(FZDUMM,FZGUES )
      COMMON/VMR/MADRID
      DATANAMLEN/80/
      DATAMSG/'ERR:FITREADxxxx'/
      DATAHEAD/' Parameter Initial Guess      Actual Value       Error '
     +/
      CALLSTSPRO('FITREAD')
      CALLFITBL
      FZTYPE=' '
      CALLSTKRDC('P1',1,1,NAMLEN,I,NAME,KUN,KNUL,ISTAT)
      IF(NAME(1:1).EQ.'?')THEN
      CALLSTKRDC('FITNAME',1,1,NAMLEN,I,NAME,KUN,KNUL,ISTAT)
      ELSE
      CALLSTKWRC('FITNAME',1,NAME,1,NAMLEN,KUN,ISTAT)
      ENDIF
      CALLFTINIT(NAME,ISTAT)
      CALLFTINFO(FILE,TYPE,IDVAR,NIND,NFUN,NDAT,ISTAT)
      IF(TYPE.EQ.'BDF ')THEN
      LINE=' Fit on image '//FILE
      CALLSTTPUT(LINE,ISTAT)
      ELSE
      IF(TYPE.EQ.'TBL ')THEN
      LINE=' Fit on table '//FILE
      CALLSTTPUT(LINE,ISTAT)
      ELSE
      CALLSTTPUT(' Fit on one dep. variable',ISTAT)
      ENDIF
      ENDIF
      LINE=' No. of data points '
      WRITE(LINE(25:32),9030)NDAT
      CALLSTTPUT(LINE,ISTAT)
      CALLSTTPUT(' ',ISTAT)
      IF(TYPE.EQ.'TBL ')THEN
      LINE=' Dependent variable '
      WRITE(LINE(25:28),9000)IDVAR
      CALLSTTPUT(LINE,ISTAT)
      ENDIF
      LINE=' No. of ind. variables '
      WRITE(LINE(25:28),9000)NIND
      CALLSTTPUT(LINE,ISTAT)
      IF(NIND.GT.0)THEN
      CALLFTRDIN(NIND,IVAR,N,ISTAT)
      IF(TYPE.EQ.'BDF ')THEN
      LINE=' variable .... is axis   ....'
      ELSE
      IF(TYPE.EQ.'TBL ')THEN
      LINE=' variable .... is column ....'
      ELSE
      NIND=0
      ENDIF
      ENDIF
      DO10I=1,NIND
      WRITE(LINE(11:14),9000)I
      WRITE(LINE(26:29),9000)IVAR(I)
      CALLSTTPUT(LINE,ISTAT)
   10 CONTINUE
      ENDIF
      CALLSTTPUT(' ',ISTAT)
      LINE=' No. of functions '
      WRITE(LINE(25:28),9000)NFUN
      CALLSTTPUT(LINE,ISTAT)
      NP=0
      DO30I=1,NFUN
      CALLSTTPUT(' ',ISTAT)
      CALLFTRDFN(I,LINE,ISTAT)
      II=INDEX(LINE,')')
      CALLSTTPUT(LINE(1:II),ISTAT)
      CALLSTTPUT(HEAD,ISTAT)
      CALLFTRDPR(I,FNAME,NPAR,PAR,ERR,FIX,ISTAT)
      LINE=FZSPEC(I)
      IF(NPAR.GT.0)THEN
      DO20J=1,NPAR
      NP=NP+1
      NL=FZPLEN(NP)
      AUX=FZPTON  (NP)
      AUX1=AUX(1:NL)//'='
      II=INDEX(LINE,AUX1(1:NL+1))
      IF(II.EQ.0)THEN
      AUX1='-'
      ELSE
      AUX=LINE(II+NL+1:)
      II=INDEX(AUX,' ')-1
      AUX1=AUX(1:II)
      ENDIF
      WRITE(OUT,9010)FZPTON  (NP),AUX1(1:16),PAR(J),ERR(J)
      CALLSTTPUT(OUT,ISTAT)
   20 CONTINUE
      ENDIF
   30 CONTINUE
      CALLSTTPUT(' ',ISTAT)
      CALLFTSTAT(CHISQ,RELAX,ITER,ISTAT)
      WRITE(LINE,9020)CHISQ,RELAX,ITER
      CALLSTTPUT(LINE,ISTAT)
      IF(ISTAT.NE.0)THEN
      WRITE(MSG(13:16),9000)ISTAT
      CALLTDERRR(ISTAT,MSG,STATUS)
      ENDIF
      CALLSTSEPI
 9000 FORMAT(I4)
 9010 FORMAT(1X,A,2X,A,1X,E14.6,1X,E14.6)
 9020 FORMAT(' Chi sq. = ',E13.4,' relaxation factor = ',F7.3,' itera','
     +tions = ',I4)
 9030 FORMAT(I8)
      END
