function [z_mix] = isotherm_depth_wod01(temp, depth, incr)
%depth of a given isotherm (incr)
%------------------------------------------------

 
tlen=length(temp(1,:));

%-------------------------------------------------------------------------------------------

for i=1:tlen,
    
    z_mix_ind_temporary=zeros(1,111);		%holds levels where temp-temp1 >=0.5
    sub=temp(:,i);	%vector of temps for each level on a given day
    temp1=sub(1);		%SST
    k=1;
    for d=2:length(depth),		%find depth below mixed layer
        if (sub(d) <= incr) & (sub(d-1) > 0)	
							%has to be defined and have one level 
							%above defined and not below mixed layer
			cc=0;
			for jj=2:d
				if sub(jj)<0
					cc=cc+1;
				end
			end
			if cc==0
            	z_mix_ind_temporary(k)=d;
            	k=k+1;
			end
        end
    end

    %if k>2
    %    ERROR = 'mld_pt'                       %more than one mixed layer defined
    %end

    if z_mix_ind_temporary(1)>0                   %mixed layer depth is defined                                      
        z_mix_ind=z_mix_ind_temporary(1);		%first level (2 -> 11) below mixed layer
    
        z_mix_below(i)=depth(z_mix_ind);			%depth of first level below mixed layer
        z_mix_above(i)=depth(z_mix_ind-1);			%depth of first level above thermocline
        de(i)=z_mix_below(i)-z_mix_above(i);
    
        temp_below(i)=sub(z_mix_ind);			%temp of first level below mixed layer
        temp_above(i)=sub(z_mix_ind-1);
        if abs(temp_above(i)-temp_below(i)) > 0.01
            z_mix(i) = abs(z_mix_above(i) + ((z_mix_above(i) - z_mix_below(i))/(temp_above(i) - temp_below(i)))*(-temp_above(i)+incr));
			
			
        else
            z_mix(i) = z_mix_above(i);
			
        end
        t_mix(i)=temp1-incr;		%temperature at mixed layer depth
    
    else
        z_mix(i)=-9999;
        t_mix(i)=-9999;
		
		
    end
    
end


temp_mix=t_mix;
