!--Output Topo. Data Size--
      implicit none
      integer,parameter :: kq=60*360+1,lq=60*180+1
      integer,parameter :: ks=130*60+1,ke=140*60+1
      integer,parameter :: ls=90*60+30*60+1,le=90*60+40*60+1
      integer*2 :: itopo2(kq,lq)
      integer   :: itopo4(kq,lq)
      real*8    ::  x(kq),y(lq)
      integer :: k,l
      common /main1/itopo2
      common /main2/itopo4
!--input file--
      open(10,file='./GEBCO.raw.bin',form='unformatted',access='direct',recl=kq*lq*2)
!--output file--
      open(20,file='./GEBCO.OUT',form='unformatted')
!--Input GEBCO data--
!---------------------------------------------------------------------------------------- 
!  NOTE: itopo: The GEBCO 1minute data start at the North Pole (90N,180W), and 
!               are arranged in bands of 360*60 values ranging eastward from 180.E to 180W.
!               The (360*60+1)st starts the latitude band for 89.59'N, and so on. 
!---------------------------------------------------------------------------------------
      read(10,rec=1) itopo2
      do k=1,kq
        x(k)=dble(k-1)/60.d0
      end do
      do l=1,lq
        y(l)=-90.d0+dble(l-1)/60.d0
      end do
!--rearrange the order of GEBCO data--
      do l=1,lq
        do k=1,kq/2
          itopo4(k,l)=itopo2(k+kq/2,lq-l+1)
        end do
        do k=kq/2+1,kq
          itopo4(k,l)=itopo2(k-kq/2,lq-l+1)
        end do
      end do             
!--single precision data output--
      write(6,*) 'DATA SIZE: k=',ke-ks+1,' l=',le-ls+1
      write(6,*) 'X=',x(ks),'-',x(ke)
      write(6,*) 'Y=',y(ls),'-',y(le) 
      write(20) ke-ks+1,le-ls+1
      write(20) (x(k),k=ks,ke),(y(l),l=ls,le)
      write(20) ((itopo4(k,l),k=ks,ke),l=ls,le)
      stop
      end
