function [field,x,y,z]=hopsgui_ksliceu(filein,kindex,time,var)

%       USAGE: [field,x,y,z]=hopsgui_ksliceu(filein,kindex,time,time)
%
% HOPS_KSLICEV  Returns a matrix containing a horizontal slice (field),
%   of the u componetn of the velocity and the  position (x,y) at a 
%   specified jindex and time step from an HOPS output (PE) file. 
%
%   In case of a non-oblique domain iindex represent a fixed longitude
% inputs: 	
% 		filein -- the .nc file
% 		time -- time of teh simulatio
%		var -- string with the variable name
%		kindex = k index along which slice is taken
%
%  Pedro Velez (UIB), July 1999




vargrid='vgrid3';
x=getnc(filein,vargrid,[-1 -1 kindex 1],[-1 -1 kindex 1],1,1,2);
y=getnc(filein,vargrid,[-1 -1 kindex 2],[-1 -1 kindex 2],1,1,2);
z=getnc(filein,vargrid,[-1 -1 kindex 3],[-1 -1 kindex 3],1,1,2);
field=getnc(filein,var,[time -1 -1 kindex 1],[time -1 -1 kindex 1],1,1,2);
field(find(field==0))=NaN;

land=getnc(filein,'landv',[-1 -1],[-1 -1],1,1,1);
field(find(land~=2))=NaN;
