function [DEPTH,DENSITY]=depth_m(PRESSURE,SAL,TEMP,LAT,LON);

%% --------------- Compute DEPTH from PRESSURE, and DENSITY ---------------

[nz,np]=size(PRESSURE);
Z=nan(nz,np);
SA=nan(nz,np);
CT=nan(nz,np);
in_ocean=nan(nz,np);
DENSITY=nan(nz,np);

for i=1:length(LAT)
    % Compute Depth from pressure
    Z(:,i)=gsw_z_from_p(PRESSURE(:,i),LAT(i)); % Thermodynamic functions from TEOS-10
    
    % Compute Absolute Salinity
    [SA(:,i), in_ocean(:,i)] = gsw_SA_from_SP(SAL(:,i),PRESSURE(:,i),LON(i),LAT(i));
    
    % Compute Conservative Temperature from in-situ temperature and salinity
    CT(:,i)=gsw_CT_from_t(SA(:,i),TEMP(:,i),PRESSURE(:,i));
    
    % Compute Density
    pr=0; % in dbar, reference pressure to compute potential density
    DENSITY(:,i)=gsw_rho(SA(:,i),CT(:,i),pr);
    % DENSITY(:,i)=gsw_rho(SA(:,i),CT(:,i),E.PRESSURE(:,i));
end
DEPTH=-Z;
% end