cc compare.for          2/18/92  "Compare Models"

      program graph        
                  
      include 'models.h'
      real psi,rho
      real k,mcall1,mcall2,sz,rate1,rate2,rate,oldrate,div1,div2,div3
      integer mtime,flag,ifdiv1,ifdiv2,ifdiv3,reps1
      character*22 string1
      character*12 string2
      real t,mcall,tdiv1,szdiv,tmp
      real biasbscall,biaseur,biasamc,biasams
      real*8 mbiasbscall,mbiaseur,mbiasamc,mbiasams
      real*8 vbiasbscall,vbiaseur,vbiasamc,vbiasams
      real ceur,cams,camc,cbscall,xmu
      character*40 fname,fname1
      integer*4 total,records,mpTimerElapsed,i
      real*8 bstime,amctime,eustime,amstime,othertime 
      real v(4)
      integer reps(4)
      real data1(25000), data2(25000), data3(25000), data4(25000)

CMPF  ONFE reps
CMPF  ONFE v          

      open(UNIT=INFILE0,FILE=IOfile,STATUS='OLD',
     &     ACCESS='SEQUENTIAL',ERR=998)
      read(INFILE0,55,ERR=999) fname1

      open(UNIT=INFILE1,FILE=fname1,STATUS='OLD',
     &     ACCESS='SEQUENTIAL',ERR=998)

      total = 0
      records = 1

      vbiasbscall = 0.0
      vbiasamc = 0.0
      vbiaseur = 0.0
      vbiasams = 0.0

      do 222 i=1, 25000
777    read(INFILE1,'(A22,I3,F7.2,2(F7.2),F7.2,A12,I2,F6.2,
     & F8.4,3(I4,F8.4),4(1X,F9.4))',ERR=999,END=333) string1,mtime,k,
     & mcall1,mcall2,sz,string2,flag,rate1,rate2,ifdiv1,div1,
     & ifdiv2,div2,ifdiv3,div3,biasbscall,biasamc,biaseur,biasams
 
       total = total + 1
       if (mtime.eq.0.or.biasbscall.eq.0.0) goto 222
       data1(records) =  biasbscall
       data2(records) = biasamc
       data3(records) = biaseur 
       data4(records) = biasams 
       records = records + 1
222   continue
 
333   continue
      close(INFILE1)

      records = records - 1
c      print *,records
      read(INFILE0,55,ERR=998) fname
      print *,fname
      open(UNIT=OUTFILE1,FILE=fname,STATUS='UNKNOWN',
     &     ACCESS='SEQUENTIAL',ERR=998)

      close(INFILE0)

      WRITE(OUTFILE1,*) 'TitleText: '//fname1
      WRITE(OUTFILE1,*) 'Ticks: false'
      WRITE(OUTFILE1,*) 'BoundBox: on'
      WRITE(OUTFILE1,*) 'YUnitText: Model Bias '
      WRITE(OUTFILE1,*) 'XUnitText: Record     '
      WRITE(OUTFILE1,*) 'Markers: on'
c      WRITE(OUTFILE1,*) 'StyleMarkers: on'
      WRITE(OUTFILE1,*) 'NoLines: false'
c      WRITE(OUTFILE1,*) 'PixelMarkers: true'

      WRITE(OUTFILE1,*) 
      WRITE(OUTFILE1,*) '"B-S '
      do 441 i=1,records
       if (data1(i).ne.0.0)            
     &  write(OUTFILE1,'(I5,1X,F9.4)',ERR=998) i,data1(i)
441   continue

      WRITE(OUTFILE1,*) 
      WRITE(OUTFILE1,*) '"American Constant  '
      do 442 i=1,records
       if (data2(i).ne.0.0)         
     &  write(OUTFILE1,'(I5,1X,F9.4)',ERR=998) i,data2(i)
442   continue

      WRITE(OUTFILE1,*) 
      WRITE(OUTFILE1,*) '"European Stochastic'
      do 443 i=1, records  
      if (data3(i).ne.0.0)        
     &  write(OUTFILE1,'(I5,1X,F9.4)',ERR=998) i,data3(i)
443   continue

      WRITE(OUTFILE1,*) 
      WRITE(OUTFILE1,*) '"American Stochastic'
      do 444 i=1, records  
       if (data4(i).ne.0.0)           
     &  write(OUTFILE1,'(I5,1X,F9.4)',ERR=998) i,data4(i)
444   continue

      close(INFILE0)
      close(OUTFILE1)

      print *, '---- Program finished ----'
      print *, 'Total records =',total
      stop 
       
999   print *, 'read or write file error!'
      total = total + 1
      goto 777

998   stop 'open or read file error!'

55    format (A40)
66    format (F9.6,F9.6)

      end
