# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "<stdin>"
module vertical_shared_mod
  use tomo_space_conv_mod
  use put_3d_mod
  use err_shared_mod
  use calc_semblance_mod
  implicit none
  contains
  logical function vertical_errors(pos,extra,time,dip,rat,axis,scale&
    &,zero,dt,bulk)
    real,dimension(:) :: pos,axis,scale,zero,dt,dip,time
    real, pointer :: vel(:,:,:)
    real :: rat,v,amp,trans,extra
    logical :: bulk
    integer :: i,n1,n2,n3
    vertical_errors=.false.
    if (.not. vel_tomo_3d_pt(vel)) then
      write(0,*) "trouble getting velocity pointer"
      return
    end if
    v= get_val_lin_pos(vel,pos(3),pos(1),pos(2))
    trans=atan(1.)/45.
    amp=cos(atan (sqrt(dip(1)**2+dip(2)**2)))
    do i=1,size(dt)
      if (.not. bulk) then
        dt(i)=(1.-rat) * amp*tan(axis(i))**2*pos(3)/v
      else
        dt(i)=rat**2-1.! *time(i)
      end if
      zero(i)=-2*cos(axis(i))
    end do
    vertical_errors=.true.
  end function
end module
