%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%    Ekman Spiral
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ug = 10        %   Geostrophic wind

f = 10^(-4);   %   Coriolis parameter
K = 5          %    Eddy momentum flux coefficient

gamma = sqrt(f/(2*K));  

z = linspace(0,3000,301)  %  Vertical coordinate

%%%%%%%%%  Calculate Ekman Spiral
u = ug * ( 1 - exp(-gamma*z).*cos(gamma*z) ) ;
v = ug * (   + exp(-gamma*z).*sin(gamma*z) ) ;

hold on
plot(u(1:100),v(1:100),'b')
plot(u(101:200),v(101:200),'m')
plot(u(201:300),v(201:300),'r')

axis([0,12,-6,+6])
title('EKMAN SPIRAL')
legend('First km','Second km','Third km',4)
axis('square')
grid('on')

print -djpeg ekman

return
%%%%%%%%%%%%%%%%%%%%%%%%