function [field,x,y,z]=oaggui_jslice(filein,jindex,time,var)

%       USAGE: [field,x,y,z]=oaggui_jslice(filein,jindex,time,time)
%
% HOPS_JSLICE  Returns a matrix containing a vertical slice (field),
%   of the variable var  and the  position (y,z) 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
%		jindex = J index along which slice is taken
%
% Pedro Velez (UIB-IEO), July 1999



if  strcmp('potden',strrep(var,' ',''))
[temp,x,y,z]=oaggui_jslice(filein,jindex,time,'temp');
[salt,x,y,z]=oaggui_jslice(filein,jindex,time,'salt');
field=potden80(salt,potemp80(salt,temp,-repmat(z',size(x,1),1)),-repmat(z',size(x,1),1));
return;
end



vargrid='grid2';

x=getnc(filein,'grid2',[1 -1 1],[1 -1 1],1,1,2);
y=getnc(filein,'grid2',[-1 1 2],[-1 1 2],1,1,2);
z=getnc(filein,'zout',[-1 3],[-1 3],1,1,2);
field=getnc(filein,var,[time jindex -1 -1],[time jindex -1 -1],1,1,2);
field(find(field==0))=NaN;

 %The array is temp(tlat, tlon, outlev)
 %The array is x,y,z(tlat, tlon, outlev)
 
 %y(jindex) is the latitude of the longitudinal section in case of a 
 %non oblique domain


