       PROGRAM NAO_RW
       IMPLICIT NONE
       CHARACTER*1 AA
       INTEGER IANDEB,IANFIN,IAN
       INTEGER IH,IM,IMONTH
       PARAMETER (IANDEB=1825,IANFIN=1995,IMONTH=12)
       REAL YEAR,NAO(0:IMONTH+1),NAODM
       INTEGER INDEX

       OPEN(10,file='../input/nao_25_99.txt',form='formatted')
       OPEN(11,file='../out_nao/nao_25_99_3m.dat',form='formatted')
       OPEN(12,file='../out_nao/nao_25_99_1m.dat',form='formatted')
       OPEN(13,file='../out_nao/nao_25_99_dm.dat',form='formatted')

c      do ih=1,5
c      read(10,*)AA
c      print *,AA
c      enddo


       index=0
       do ian=IANDEB,IANFIN
       NAODM=NAO(12)/4.
       read(10,*)YEAR,(NAO(IM),IM=1,IMONTH)
       NAODM=NAODM+(NAO(1)+NAO(2)+NAO(3))/4.
       print *,YEAR,NAO(1)
       do IM=1,IMONTH-1,3
          write(11,110)YEAR+FLOAT(IM+1)/FLOAT(IMONTH)
     C           ,(NAO(IM)+NAO(IM+1)+NAO(IM+2))/3.
       enddo
       do IM=1,IMONTH
          index=index+1
          write(12,110)YEAR+FLOAT(IM-1)/FLOAT(IMONTH),NAO(IM)
       enddo
       if(ian.gt.IANDEB)then
       write(13,110)YEAR,NAODM
       endif
       enddo

 110   format(f9.4,1x,f6.2)
       stop
       end


