
        subroutine get_sea(isea,idim,jdim,hlat,hlon,im,jm,nm)
!------------------------------------------------------------------c
!                                                                  c
!     get the sea mask                                             c
!                                                                  c
!     <--  isea         sea mask                                   c
!     -->  idim,jdim    dimension of input file                    c
!     -->  hlat,hlon    postion of the grid points                 c
!     --> im,jm,nm      dimension of the grid
!                                                                  c
!------------------------------------------------------------------c

         implicit none

        integer,intent(in)::im,jm,nm
        real isea(0:im+1,0:jm+1,nm),glatd,glond,x,y
        integer nbx,nby,idim,jdim,i,j,gds(200),r,k,ii,ji
        real hlat(0:im+1,0:jm+1,nm),hlon(0:im+1,0:jm+1,nm)
        real ,allocatable:: seabyte(:,:)

         allocate(seabyte(idim,jdim))
         nbx=idim
         nby=jdim
	write(6,*) 'opening 4 minute'
	open(unit=2,file='../data_in/static/global_4m.ieee',  &
	  form='unformatted', &
     	  access='sequential',err=920,status='old')

        write(6,*) 'unit 2 open ', nbx,nby
        do J=1,nby
        read(2) (seabyte(I,J),I=1,nbx)
        enddo
	goto 921

  920   write(6,*) '!!!!!!!!!trouble opening the seamask data!!!!!!'
  921      write(6,*) 'data read successfully '
        close(2)

	GDS(1)=0
	GDS(2)=5400
	GDS(3)=2700
	GDS(4)=-89933
	GDS(5)=-179933
	GDS(6)=128
	GDS(7)=89933
	GDS(8)=179933
	GDS(9)=067
	GDS(10)=067

        do 442 r=1,nm
          do 442 j=1,jm
           do 442 i=1,im

!             print *,i,j,r            
             glatd=hlat(i,j,r)
             glond=hlon(i,j,r)
             if(glond.lt.0) glond=glond+360
!             glond=360.-glond
             call ced_ij(glatd,glond,x,y,gds)  
             ii=int(x)
             ji=int(y)                   
!             print *,i,j,r,glatd,glond,x,y,ii,ji
!	If input data is 1 --> land --> isea=0
!	If input data is 0 --> water --> isea=1
!
	if (seabyte(II,JI) .eq. 1) then
	isea(i,j,r)=0
	elseif (seabyte(II,JI) .eq. 0) then
	isea(i,j,r)=1
	else
	write(6,*) 'bad seabyte value!!!!! ', II,JI, seabyte(II,JI)
	endif  
 442    continue
     
      deallocate(seabyte)                    
      return
      end


