      implicit none

      integer,parameter :: mx=180
      integer,parameter :: my=91

      real :: values(mx,my),results(mx,my),ave(mx,my),std(mx,my)
      integer :: id,i,j,iyear,imonth,iday,ihour
      integer :: mask(mx*my)
      character(len=70) :: snd(2),sno(2),sna(2),sns(2)
      character(len=70) :: input,model
      character(len=3) :: sea

      data snd /'_SLP_','.txt'/
      data sns /'_SLP_Std1981-2000_','.txt'/
      data sna /'_SLP_Mean1981-2000_','.txt'/
      data sno /'_Pt_Standardized_','.txt'/

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

      open(1,file=trim(model)//trim(sna(1))//
     & trim(sea)//trim(sna(2)))
      read(1,'(10f9.3)')((ave(i,j),i=1,mx),j=1,my)

      open(5,file=trim(model)//trim(sns(1))//
     & trim(sea)//trim(sns(2)))
      read(5,'(10f9.3)')((std(i,j),i=1,mx),j=1,my)

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

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

      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)')((values(i,j),i=1,mx),j=1,my)
         do j=1,my
            do i=1,mx
               results(i,j)=(values(i,j)-ave(i,j))/std(i,j)
            enddo
         enddo
         write(2,'(i6,3i4.2)') iyear,imonth,iday,ihour
         write(2,'(10f9.3)') ((results(i,j),i=1,mx),j=1,my)
      enddo

99    close(1)
      close(3)
      close(2)
      close(4)
      close(5)
      end
