      implicit none

      integer,parameter :: mx=360
      integer,parameter :: my=181

      real :: results(mx,my),mask(mx,my)
      integer :: i,j,iyear,imonth,iday,ihour
      character(len=70) :: snd(2),sno(2),input,model
      character(len=3) :: sea

      data snd /'_Hs_','.txt'/
      data sno /'_Hs_Mask1981-2000_','.txt'/

      call get_command_argument(1,input)
      read(input,*) model
      call get_command_argument(2,input)
      read(input,*) sea

      open(3,file=trim(model)//trim(snd(1))//
     & trim(sea)//trim(snd(2)))

      mask=0
      print*,trim(model)//trim(sno(1))//
     & trim(sea)//trim(sno(2))

      do
         read(3,'(i6,3i4.2)',end=99) iyear,imonth,iday,ihour
         read(3,'(10f9.3)')((results(i,j),i=1,mx),j=1,my)
         if(iyear.gt.1980.and.iyear.lt.2001) then
           do i=1,mx
              do j=1,my
                 if(results(i,j).lt.-990) mask(i,j)=mask(i,j)+1
              enddo
           enddo
         endif
      enddo

99    open(2,file=trim(model)//trim(sno(1))//
     & trim(sea)//trim(sno(2)))

      do j=1,my
         do i=1,mx
            if(mask(i,j).lt.1) then
               write(2,*) (j-1)*mx+i
            endif
         enddo
      enddo

      close(3)
      close(2)
      end
