function [lon,lat,var]=read_nc_aviso_med_2014(nc_file,latN,latS,lonW,lonE,type);
% Read AVISO from netcdf files
%
%  USAGE: Works with AVISO netcdf file format from 2014
%	  To read previous AVISO files see read_nc_aviso_2013
%%%%%%%%%%%
% 14/03/2017: AD: created from read_nc_aviso_med_2014.m to use new netcdf
%%%%%%
%nc=netcdf(nc_file,'r');

%lon=nc{'NbLongitudes'}(:);
%lat=nc{'NbLatitudes'}(:);
lon=ncread(nc_file,'lon');%=nc{'lon'}(:); %Longitude (degrees east 0 360)
lat=ncread(nc_file,'lat');%=nc{'lat'}(:); %Latitude (degrees north -90 90)
% index
% Mandatory: lonW and lonE are given in -180:180 !!!
%lonE(lonE<0)=360+lonE;
%lonW(lonW<0)=360+lonW;
lon=lon-360;
if lonW>lonE%
	good_lonW=find(lon>=lonW);
	good_lonE=find(lon<=lonE);
	good_lon=[good_lonW; good_lonE];
else
	good_lon=find(lon>=lonW & lon<=lonE);
end
good_lon=find(lon>=lonW & lon<=lonE);
good_lat=find(lat>=latS & lat<=latN);
lon=lon(good_lon);
lat=lat(good_lat);
% Convert lon from 0:360 to -180:180
lon(lon>180)=lon(lon>180)-360;
% Create lon and lat matrices
[lon lat]=meshgrid(lon,lat);
if strcmp(type,'uv')
	% Load u-component
	u=ncread(nc_file,'u');%=squeeze(nc{'u'}(:));
u=u';
	u=u(good_lat,good_lon);
        %scale_factor=ncreadatt(nc_file,'u','scale_factor');
        %u=u*scale_factor;
	% Load v-component
	v=ncread(nc_file,'v');
v=v';
	v=v(good_lat,good_lon);
        %scale_factor=ncreadatt(nc_file,'u','scale_factor');
        %v=v*scale_factor;
	var.u=u;
	var.v=v;
else
	var=ncread(nc_file,'adt');
var=var';
	var=var(good_lat,good_lon);
	%scale_factor=ncreadatt(nc_file,'adt','scale_factor');
	%var=var*scale_factor;
end

disp(['     Successfully read!!!'])
