        character id*56,pgm*8,ifile*80
        dimension s(2000),c(2000),t(2000)

        d2r=3.1415927/180.
        print*,'enter sin grid:'
        read(5,100) ifile
100     format(a)
        open(10,file=ifile,form='unformatted',status='old')
        print*,'enter cos grid:'
        read(5,100) ifile
        open(11,file=ifile,form='unformatted',status='old')
        print*,'enter output grid:'
        read(5,100) ifile
        open(12,file=ifile,form='unformatted',status='unknown')
        read(10) id,pgm,nc,nr,nz,xo,dx,yo,dy
        read(11) id,pgm,nc,nr,nz,xo,dx,yo,dy
        write(12) id,pgm,nc,nr,nz,xo,dx,yo,dy
        do j=1,nr
        read(10) dlt,(s(i),i=1,nc)
        read(11) dlt,(c(i),i=1,nc)
        do i=1,nc
        t(i) = atan2(s(i),c(i)) / d2r
        enddo
        write(12) dlt,(t(i),i=1,nc)
        enddo
c       print*,'trend.grd created'
        stop
        end
