function ub = ubqf( T, Hs, h )
% UBQF - Quick approximation of near-bottom orbital velocity
% ub = ubqf( T, Hs, h )
%
% (eg, Dyer, 1986, Eqn 3.50, p 98).
%
% Uses approximate explicit method found in 
% Dean and Dalrymple (1991), p 72.
% Calls qkhf.m
%
% Input:
%  T Wave period [s]
%  Hs Wave height [m]
%  h Water depth [m]
% Returns:
%  Wave-orbital velocity amplitude ub = Hs*pi / T*sinh(kh) [m/s]

%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use of this program is self described.
% Program written in Matlab v7.1.0 SP3
% Program ran on PC with Windows XP Professional OS.
%
% "Although this program has been used by the USGS, no warranty, 
% expressed or implied, is made by the USGS or the United States 
% Government as to the accuracy and functioning of the program 
% and related program material nor shall the fact of distribution 
% constitute any such warranty, and no responsibility is assumed 
% by the USGS in connection therewith."
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Chris Sherwood, USGS
% March 17, 1999

% Idiot lights
if( T < 0.0001 )
  %fprintf(stderr,'Warning from ubqf: small T = %g\n',T); %ML 7 doesn't
  %like stderr?
  fprintf(1,'Warning from ubqf: small T = %g\n',T);
  ub = 0.;
  return
end
if( Hs >= 0.78*h ),      
  %fprintf(stderr,'Warning from ubqf: wave is breaking; Hs limited.\n');
  fprintf(1,'Warning from ubqf: wave is breaking; Hs limited.\n');
  Hs = 0.78*h;
end   
w=2*pi./T;
kh=qkhf(w,h);
amp = Hs ./ (2.*sinh(kh));
ub = w .* amp;





