function dataout=dodepth(datain,coreinfo,shiftdata);

% function dataout=(datain,coreinfo,shiftdata);
%
% Calculates curated and shifted depths given core#, Section#, and depth in
% cm below top of Section
%
% datain:
% col 1: Core #
% col 2: Section #
% col 3: Depth, cm (below top of section)
%
% coreinfo:
% col 1: Core #
% col 2: Section #
% col 3: Curated depth
%
% shiftdata:
% col 1: Core #
% col 2: shift in m
%
% dataout
%
% col 1: Core #
% col 2: Section #
% col 3: Depth, cm (below top of section)
% col 4: Curated and shifted depth, mbsf

na=zeros(length(datain(:,1)),1);na=na./na;
a=datain;

% Shift table
s=shiftdata;
% curated depth table
d=coreinfo;


for i=1:length(a(:,1)),
    iz=find(d(:,1)==a(i,1) & d(:,2)==a(i,2));
    is=find(s(:,1)==a(i,1));
    cs=0;
    if length(is)>0,
        cs=s(is,2);
    end
    if length(iz)>0,
        z=d(iz,3)+cs;
        na(i,1)=z+a(i,3)/100;
    end
end

dataout=[datain na];