       parameter (ngx=501, ngy=191)
       character*12 cdate
       dimension cd(ngx,ngy),sig_wht(ngx,ngy),
     + pper(ngx,ngy),z0(ngx,ngy),beta(ngx,ngy)
       dimension sig_wht0(ngx,ngy),rms(ngx,ngy),
     +  diff(ngx,ngy),pper0(ngx,ngy),beta0(ngx,ngy)


        rms = 0.
c SPECIAL VALUE IS 9999.

c cdate = yyyymmddhhmm

       open(60,file='WAVES.INPUT_1',form='unformatted')
       open(61,file='WAVES.INPUT_0',form='unformatted')

c --- athos
       alonw = 29.0000
       alone = 33.0000
       alats = 42.0000 
       alatn = 44.0000


       is = (alonw+8.) *10 + 1
       js = (alats-29.) *10 + 1
       ie = (alone+8.) *10 + 1
       je = (alatn-29.) *10 + 1

        print *,is,ie
        print *,js,je

       do ii = 1,2
       read(60) cdate
       read(60) ((cd(i,j),i=1,ngx),j=1,ngy)
       read(60) ((sig_wht(i,j),i=1,ngx),j=1,ngy)
       read(60) ((pper(i,j),i=1,ngx),j=1,ngy)
       read(60) ((z0(i,j),i=1,ngx),j=1,ngy)
       read(60) ((beta(i,j),i=1,ngx),j=1,ngy)
       read(61) cdate
       read(61) ((cd(i,j),i=1,ngx),j=1,ngy)
       read(61) ((sig_wht0(i,j),i=1,ngx),j=1,ngy)
       read(61) ((pper0(i,j),i=1,ngx),j=1,ngy)
       read(61) ((z0(i,j),i=1,ngx),j=1,ngy)
       read(61) ((beta(i,j),i=1,ngx),j=1,ngy)
       end do

       ii = 0
       do itimes = 1,163
       read(60) cdate
       read(60) ((cd(i,j),i=1,ngx),j=1,ngy)
       read(60) ((sig_wht(i,j),i=1,ngx),j=1,ngy)
       read(60) ((pper(i,j),i=1,ngx),j=1,ngy)
       read(60) ((z0(i,j),i=1,ngx),j=1,ngy)
       read(60) ((beta(i,j),i=1,ngx),j=1,ngy)

       read(61) cdate
       read(61) ((cd(i,j),i=1,ngx),j=1,ngy)
       read(61) ((sig_wht0(i,j),i=1,ngx),j=1,ngy)
       read(61) ((pper0(i,j),i=1,ngx),j=1,ngy)
       read(61) ((z0(i,j),i=1,ngx),j=1,ngy)
       read(61) ((beta0(i,j),i=1,ngx),j=1,ngy)

c      if (itimes.eq.1) then
c       print *,itimes,cdate,sig_wht(ik,jk),sig_wht0(ik,jk)
c      end if
       if (mod(ii,3).eq.0) then
        beta_av = 0.
        swh_av = 0.
        swh0_av = 0.
        pp = 0.
         do i = is,ie
         do j = js,je
          if (sig_wht0(i,j).lt.40.) then
           beta_av = beta_av + beta0(i,j)
           swh0_av = swh0_av + sig_wht0(i,j)
           swh_av = swh_av + sig_wht(i,j)
           pp = pp + 1.
          end if
          end do
          end do
          print *,beta_av/pp,swh_av/pp,swh0_av/pp
          
       end if

       ii = ii + 1


       end do

 300  FORMAT(8e10.3)



       stop
       end

