      implicit none
      integer,parameter :: iq=360*30,jq=180*30  !ETOPO2 DATA POINTS
      integer,parameter :: is=130*30+1,ie=140*30+1
      integer,parameter :: js=90*30+30*30,je=90*30+40*30   
      integer*2 :: itopo2(iq,jq)
      integer   :: itopo4(iq,jq)
      real*8    :: x(iq),y(jq)
      integer   :: i,j
      common /main1/itopo2
      common /main2/itopo4
!--input file--
      open(10,file='./ETOPO2.raw.bin',form='unformatted',access='direct',recl=360*30*180*30*2)
!--single data--
      open(20,file='./ETOPO2.OUT',form='unformatted')
!--Output data range--
!--Input data-------------------------------------------------------
      read(10,rec=1) itopo2
      do j=1,jq
        do i=1,iq/2
          itopo4(i,j)=itopo2(i+iq/2,jq-j+1) 
        end do
        do i=iq/2+1,iq
          itopo4(i,j)=itopo2(i-iq/2,jq-j+1)
        end do
      end do 
!--------------------------------------------------------------------   
      do i=1,iq
        x(i)=dble(i-1)/30.d0
      end do
      do j=1,jq
        y(j)=-90.d0+dble(j)/30.d0
      end do
!---------------------------------------------------------------------
      write(6,*) 'DATA SIZE: i=',ie-is+1,' j=',je-js+1
      write(6,*) 'X=',x(is),'-',x(ie)
      write(6,*) 'Y=',y(js),'-',y(je) 
      write(20) ie-is+1,je-js+1
      write(20) (x(i),i=is,ie),(y(j),j=js,je)
      write(20) ((itopo4(i,j),i=is,ie),j=js,je)    
      stop
      end      


