      program satstats
c
c  Reads matchup data file, performs statistics on satellite chl
c  vs in situ chl.  Specifically, median percent error and
c  semi-interquartile range (SIQR)
c
      parameter(npts=50000)
      real rad(6)
      real pctr(npts)
c
      open(4,file='match.dat',status='old',form='formatted')
      n = 0
5     read(4,10,end=6)iyr,idoy,xlon,ylat,chlis,chlsat,
     *         rad(1),rad(2),rad(3),rad(4),
     *         rad(5),rad(6)
      if (chlis .le. 0.0)go to 5
      n = n+1
      pctr(n) = (chlsat-chlis)/chlis
      go to 5
6     close(4)
      nchl = n
      if (nchl .gt. npts)then 
       write(6,*)'ERROR nchl>npts ',nchl,npts
       stop
      endif
c
c  Statistics
      call mediqr(pctr,nchl,xmed,xiqr)
      pmed = xmed*100.0
      siqr = 0.5*xiqr*100.0
      write(6,20)'median error,siqr,N = ',pmed,'%',siqr,'%',nchl
c
10    format(2i6,2f8.2,2f8.3,6f8.4)
20    format(a30,2(f7.1,a1),i6)
      end
