      integer N                    !" 1file $BCf$N%G!<%?9T?t(B(k,l => -85:85)
      integer EN                   !" $B%"%s%5%s%V%k?t(B(1:99)
      parameter (N=171*171)  
      parameter (EN=99)      
      real t0                   !" $B;~9o(B t
      real t                    !" $B;~9o(B t
      real k(N)                    !" $BEl@>GH?t(B
      real l(N)                    !" $BFnKLGH?t(B
      double precision eksp(EN,N)  !" $B%(%M%k%.!<%9%Z%/%H%k(B
      double precision sumeksp(N)  !" $B%(%M%k%.!<%9%Z%/%H%k$N%"%s%5%s%V%kOB(B
      double precision meaneksp(N) !" $B%(%M%k%.!<%9%Z%/%H%k$N%"%s%5%s%V%kJ?6Q(B
      character title1*5
      character title2*6
      character title3*3
      character title4*2
      character title5*5
      character title6*5
      character ifname1*29         !" $BF~NO%U%!%$%kL>(B
      character ifname2*30         !" $BF~NO%U%!%$%kL>(B
      character ofname*31          !" $B=PNO%U%!%$%kL>(B
      character dirname1*46        !" $B3JG<%G%#%l%/%H%jL>(B
      character dirname2*47        !" $B3JG<%G%#%l%/%H%jL>(B
      character dirname3*47        !" $B3JG<%G%#%l%/%H%jL>(B
      character ifilename*77       !" $BF~NO%U%!%$%kL>(B(dirname+ifname)
      character ofilename*78       !" $B=PNO%U%!%$%kL>(B(dirname+ofname)

*               ----5---10---15---20---25---30---35---40---45---
c      ifname1 ='exp4- -1-eksp_t=0.00_file.txt'
c      ifname2 ='exp4-  -1-eksp_t=0.00_file.txt'
      ifname1 ='exp4- -1-eksp_t=    _file.txt'
      ifname2 ='exp4-  -1-eksp_t=    _file.txt'
      ofname  ='exp4-ensemble-1-eksp_t=    .txt' 
      dirname1='/work32/taniro/exp4-1-ensemble/ncdata/txtdata/'
      dirname2='/work31/taniro/exp4-1-ensemble2/ncdata/txtdata/'
      dirname3='/work32/taniro/exp4-1-ensemble/ncdata/meandata/'

      t0 = 0.0

      do it=1,51

         t = t0 + 0.2*(it-1)

         if (t.lt.10) then
            write(ifname1(17:20),'(f4.2)') t
            write(ifname2(18:21),'(f4.2)') t
            write(ofname(24:27) ,'(f4.2)') t
         else
            write(ifname1(17:20),'(f4.1)') t
            write(ifname2(18:21),'(f4.1)') t
            write(ofname(24:27) ,'(f4.1)') t
         end if

      do in=1,EN
         if (in.lt.10) then
            ifilename=dirname1//ifname1
            write(ifilename(52:52),'(i1)') in
         else if (in.lt.50) then
            ifilename=dirname1//ifname2
            write(ifilename(52:53),'(i2)') in
         else 
            ifilename=dirname2//ifname2
            write(ifilename(53:54),'(i2)') in
         end if
         write(*,*) 'file ',ifilename,' reading ...'
         open(20,file=ifilename, form='formatted', status='old')
         read(20,*) title1,title2,title3,title4,title5,title6
         do i=1,N
            read(20,*) k(i), l(i), eksp(in,i)
         end do
         close(20)
c         do i=1,N
c            write(*,*) k(i), l(i), eksp(in,i)
c         end do
      end do

      ofilename=dirname3//ofname
      open(21,file=ofilename, form='formatted', status='unknown')

      write(21,*) title1,' ',title2,' ',title3,',',
     &     title4,',',title5,' ',title6

      do j=1,N
         sumeksp(j) = 0.0D0
         do jn=1,EN
            sumeksp(j) = sumeksp(j) + eksp(jn,j)
         end do
         meaneksp(j) = sumeksp(j)/EN
c         write(*,*) 'sumeksp(',j,')=',sumeksp(j)
c         write(*,*) k(j),l(j),' meaneksp(',j,')=',meaneksp(j)
         write(21,*) k(j),l(j),meaneksp(j)
      end do

      close(21)

      end do

      end
