	program enstat
        parameter(l=9,m=40)
c
	real pp(l),varb(m,l)
        character*81  bb1
        character*81  bb2
        bb1(1:44)='   ----------------------------------------'
        bb1(45:81)='------------------------------------- '
        bb2(1:44)='    MAX      MIN       Q1       Q2       Q3'
        bb2(45:81)='      P10%    P90%     P95%     ENSM'
c
c.... max min qartile1 quartile2 quartile3 percentile10 percentile90
c.... ensemble-mean
	open(10,file='temp22.txt',form='formatted',
     1	  status='old')
	open(22,file='formatted_stat.txt',form='formatted',
     1	  status='unknown')
c
        write(22,*) bb1 
        write(22,*) bb2
        write(22,*) bb1 
	open(20,file='ensts.dat',form='unformatted',
     1  status='unknown',access='direct',recl=l*4)
        do i=1,m
          read(10,*) (pp(j),j=1,l)
          write(22,100) (pp(j),j=1,l)
          do j=1,l
            varb(i,j)=pp(j)
          enddo
        enddo 
c
        do i=1,m
          do j=1,l
            pp(j)=varb(i,j)
          enddo
	  write(20,rec=i) pp
        enddo
c
  100   format(9f9.2)
        stop
	end
c
