There is no flux at the end, it is a dirchelet boundary condition.
S(:,numx) = S0; %S(x=d,t)=S0
P(:,numx) = 0; %P(x=d,t)=0
Yes, the interface node is:
Ds1*dS1/dx = Ds2*dS2/dx
Dp1*dP1/dx = Dp2*dP2/dx
which I have evaluated in MATLAB as the following...