function [depth,st,titlerun]=hopsgui_exprofiles(filein,var,x0,y0,time)

%   [depth,st,titlerun]=hopsgui_exprofiles(filein,var,x0,y0,time)
%
%   Returns a profile at specific position
%
%   
% inputs:
%               filein -- the .nc file
%               var    -- the variable
%               x0,y0  -- the position
%		    time   -- the time
% Outputs:      
%		 
%		 depth- vector with date depths
%		 st 	- profile  the var
%
%  Pedro Velez (UIB), July 1999

vargrid='tgrid3';
if strcmp('wvsv',strrep(var,' ',''))
	vargrid='wvgrid3';
elseif strcmp('wvst',strrep(var,' ',''))
	vargrid='wtgrid3';
elseif strcmp('wvzv',strrep(var,' ',''))	
	vargrid='vgrid3';
elseif strcmp('|Ut|',strrep(var,' ',''))
	vargrid='vgrid3';	
end


titlerun=deblank(getnc(filein,'titlrun')');
x=getnc(filein,vargrid,[1 -1 1 1],[1 -1 1 1],1,1,2);
y=getnc(filein,vargrid,[-1 1 1 2],[-1 1 1 2],1,1,2);
ix=locate(x,x0);
iy=locate(y,y0);
depth=getnc(filein,vargrid,[iy ix -1 3],[iy ix -1 3],1,1,2);


if strcmp('|Ut|',strrep(var,' ',''))
u=getnc(filein,'vtot',[time iy ix -1 1],[time iy ix -1 1],1,1,2);
v=getnc(filein,'vtot',[time iy ix -1 2],[time iy ix -1 2],1,1,2);
st=sqrt(u.^2+v.^2);
return;
end


st=getnc(filein,var,[time iy ix -1],[time iy ix -1],1,1,2);

