subroutine f_dump_2d(lb,ub,s, gf, name, params)
  use tensors
  use input_params
  
  interface
     
     subroutine dump_2d(params, name, u,lb,ub,s)
       use input_params
       implicit none
       real*8,dimension(100) :: params
       character*(*)     :: name
       integer, dimension(3)         :: lb,ub,s
       real*8, dimension(s(1),s(2),s(3)), target :: u
       integer ierr,java_ser,java_bbser2d
     end subroutine dump_2d
     
  end interface
  
  implicit none
  integer, dimension(3)         :: lb,ub,s
  real*8, dimension(s(1),s(2),s(3)), target :: gf 
  real*8,dimension(100) :: params
  character (LEN=40)    :: name
  
  call dump_2d(params,name,gf,lb,ub,s)
  
  return
end subroutine f_dump_2d


subroutine dump_2d(params, name, u,lb,ub,s)
  use input_params
  implicit none

  real*8,dimension(100) :: params
  character*(*)     :: name
  integer, dimension(3)         :: lb,ub,s
  real*8, dimension(s(1),s(2),s(3)), target :: u 
  integer ierr,java_ser,java_bbser2d
  real*8, dimension(:),allocatable :: x, fxy
  
  integer i,j,k,l
  allocate ( fxy(s(1)*s(2))  )
  
  
  k = int((s(3)+1)/2)
  
  l = 0
  do j = 1 , s(2)
     do i = 1, s(1)
        l = l + 1
        fxy(l) = u(i,j,k)
     end do
  end do
  !  params(P_CURRENTTIME) = params(P_CURRENTTIME) + 1.0d0
  
  ierr =  java_bbser2d(name, params(P_CURRENTTIME), params(P_XMIN), &
       params(P_XMAX), &
       int(params(P_NX)),params(P_YMIN),params(P_YMAX), &
       int(params(P_NY)),fxy)
  
  return
end subroutine dump_2d

